/*! 外部ファイルを指定でのファイルを表示 */ BOOL CEditView::MakeDiffTmpFile2( TCHAR* tmpName, const TCHAR* orgName, ECodeType code, ECodeType saveCode ) { //一時 TCHAR* pszTmpName = _ttempnam( NULL, SAKURA_DIFF_TEMP_PREFIX ); if( NULL == pszTmpName ){ WarningMessage( NULL, LS(STR_DIFF_FAILED) ); return FALSE; } _tcscpy( tmpName, pszTmpName ); free( pszTmpName ); bool bBom = false; const STypeConfigMini* typeMini; CDocTypeManager().GetTypeConfigMini( CDocTypeManager().GetDocumentTypeOfPath( orgName ), &typeMini ); CFileLoad cfl( typeMini->m_encoding ); CTextOutputStream out(tmpName, saveCode, true, false); if(!out){ WarningMessage( NULL, LS(STR_DIFF_FAILED_TEMP) ); return FALSE; } try{ bool bBigFile; #ifdef _WIN64 bBigFile = true; #else bBigFile = false; #endif cfl.FileOpen( orgName, bBigFile, code, GetDllShareData().m_Common.m_sFile.GetAutoMIMEdecode(), &bBom ); CNativeW cLine; CEol cEol; while( RESULT_FAILURE != cfl.ReadLine( &cLine, &cEol ) ) { const wchar_t* pLineData; CLogicInt nLineLen; pLineData= cLine.GetStringPtr(&nLineLen); if( 0 == nLineLen || NULL == pLineData ) break; if( bBom ){ CNativeW cLine2(L"\ufeff"); cLine2.AppendString(pLineData, nLineLen); out.WriteString(cLine2.GetStringPtr(), cLine2.GetStringLength()); bBom = false; }else{ out.WriteString(pLineData,nLineLen); } } if( bBom ){ out.WriteString(L"\ufeff", 1); } } catch(...){ out.Close(); _tunlink( tmpName ); //関数の実行に失敗したとき、一時ファイルの削除は関数内で行う。 WarningMessage( NULL, LS(STR_DIFF_FAILED_TEMP) ); return FALSE; } return TRUE; }
/*! 一時ファイルを作成する @author MIK @date 2002/05/26 @date 2005/10/29 引数変更const char* → char* 一時ファイル名の取得処理もここでおこなう。maru @date 2007/08/?? kobake 機械的にUNICODE化 @date 2008/01/26 kobake 出力形式修正 @date 2013/06/21 エンコードをASCII系にする(SJIS固定をやめる) */ BOOL CEditView::MakeDiffTmpFile( TCHAR* filename, HWND hWnd, ECodeType code, bool bBom ) { //一時 TCHAR* pszTmpName = _ttempnam( NULL, SAKURA_DIFF_TEMP_PREFIX ); if( NULL == pszTmpName ){ WarningMessage( NULL, LS(STR_DIFF_FAILED) ); return FALSE; } _tcscpy( filename, pszTmpName ); free( pszTmpName ); //自分か? if( NULL == hWnd ) { EConvertResult eWriteResult = CWriteManager().WriteFile_From_CDocLineMgr( m_pcEditDoc->m_cDocLineMgr, SSaveInfo( filename, code, EOL_NONE, bBom ) ); return RESULT_FAILURE != eWriteResult; } CTextOutputStream out(filename, code, true, false); if(!out){ WarningMessage( NULL, LS(STR_DIFF_FAILED_TEMP) ); return FALSE; } bool bError = false; try{ if( ! MakeDiffTmpFile_core(out, hWnd, *this, bBom) ){ bError = true; } } catch(...){ bError = true; } if( bError ){ out.Close(); _tunlink( filename ); //関数の実行に失敗したとき、一時ファイルの削除は関数内で行う。2005.10.29 WarningMessage( NULL, LS(STR_DIFF_FAILED_TEMP) ); } return TRUE; }
void ColormapEditor::manage() { this->DXWindow::manage(); // // If the .net had the name of a .cm file and this is the first time // we're opening this editor, then make sure the values form the .cm // file are fed back into the node (they were installed in // createWorkArea()). // const char *name; if (this->neverManaged && (name = this->colormapNode->getNetSavedCMFilename())) { struct STATSTRUCT statbuf; if (STATFUNC(name,&statbuf) == 0) { // File exists XmColorMapEditorRead(this->colormapEditor,(char*)name); } else { WarningMessage("Can't locate color map file '%s', " "using default map",name); } } this->handleStateChange(); this->neverManaged = FALSE; }
static int SCDrainAndProcess(SCMessageQueue *mq, SCHandler *handlers) { SCMsgHdr *hdr; uint32_t length; const uint8_t *msg; void *msg_handle; int rval; /* Read a message from the queue. */ pthread_mutex_lock(&mq->mutex); rval = RBMQ_ReadMsg(mq->queue, (const void **) &hdr, &msg, &length, &msg_handle); pthread_mutex_unlock(&mq->mutex); if (rval != 0) return 1; /* Handle it. */ SCProcessMessage(handlers, hdr, msg, length); /* And, finally, acknowledge it. */ pthread_mutex_lock(&mq->mutex); rval = RBMQ_AckMsg(mq->queue, msg_handle); pthread_mutex_unlock(&mq->mutex); if (rval != 0) WarningMessage("Error ACK'ing message %p!\n", msg_handle); return 0; }
static void sdlCheckError(BOOL bRes, const char *strDescription) { if( bRes) return; const char *sdlError = SDL_GetError(); if( !sdlError) return; // ignore stupid 'successful' error WarningMessage("%s: %s", strDescription, sdlError); }
boolean Browser::openFile(char *filenm) { struct STATSTRUCT statb; char title[512]; this->from = new std::ifstream(filenm); if(!this->from) { WarningMessage("File open failed for file %s", filenm); return FALSE; } if(STATFUNC(filenm, &statb) == -1) { // stat failed return FALSE; } this->file_size = statb.st_size; // // Clear any existing mark // this->marker_pos = 0; this->marker_char[0] = '\0'; this->page_start = 0; this->page_start_line_no = 0; this->loadBuffer(0); title[0] = '\0'; strcat(title, "File Browser: "); strcat(title, filenm); this->setWindowTitle(title); return TRUE; }
void DXPacketIF::DXProcessErrorWARNING(void *, int, void *p) { char *line = (char *)p, *s; char buffer[512]; if (FindDelimitedString(line,':',':',buffer) && strstr(buffer,"POPUP")) { char *c = strchr(line,':'); if (c && (c = strchr(c+1,':'))) WarningMessage(c+1); } if (FindDelimitedString(line,':',':',buffer) && strstr(buffer,"MSGERRUP")) { // // These messages are warnings that we want to treat as // an error message. // if (theDXApplication->doesErrorOpenMessage() && !theDXApplication->messageWindow->isManaged()) theDXApplication->messageWindow->manage(); // // Remove the MSGERRUP characters from the message. // s = strstr(line,"MSGERRUP"); char *c = s + strlen("MSGERRUP"); while (*c) { *s = *c; s++; c++; } *s = '\0'; } theDXApplication->getMessageWindow()->addWarning(line); }
/* * Read entire world (both brushes and current state). */ void CWorld::Read_t(CTStream *pistrm) // throw char * { _pfWorldEditingProfile.IncrementAveragingCounter(); _bFileReplacingApplied = FALSE; // need high FPU precision CSetFPUPrecision FPUPrecision(FPT_53BIT); // clear eventual old data in the world Clear(); // lock all arrays and containers LockAll(); pistrm->ExpectID_t("WRLD"); // 'world' // read the world brushes from the file ReadBrushes_t(pistrm); // read current world state from the file ReadState_t(pistrm); pistrm->ExpectID_t("WEND"); // 'world end' // unlock all arrays and containers UnlockAll(); if( _bFileReplacingApplied) WarningMessage("Some of files needed to load world have been replaced while loading"); }
BOOL CModelerDoc::OnOpenDocument(LPCTSTR lpszPathName) { m_bDocLoadedOk = FALSE; CTFileName fnModelFile = CTString(lpszPathName); try { fnModelFile.RemoveApplicationPath_t(); } catch( char *err_str) { AfxMessageBox( err_str); return FALSE; } try { m_emEditModel.Load_t( fnModelFile); } catch( char *err_str) { CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); MessageBoxA(pMainFrame->m_hWnd, err_str, "Warning! Model load failed.", MB_OK|MB_ICONHAND|MB_SYSTEMMODAL); return FALSE; } INDEX ctLoadedModels=m_emEditModel.edm_aamAttachedModels.Count(); INDEX ctAttachmentPositions=m_emEditModel.edm_md.md_aampAttachedPosition.Count(); if(ctLoadedModels<ctAttachmentPositions) { for( INDEX iPos=ctLoadedModels; iPos<ctAttachmentPositions; iPos++) { m_emEditModel.edm_aamAttachedModels.New(); m_emEditModel.edm_aamAttachedModels.Lock(); CAttachedModel &am=m_emEditModel.edm_aamAttachedModels[iPos]; DECLARE_CTFILENAME( fnAxis, "Data\\Models\\Editor\\Axis.mdl"); am.am_bVisible=TRUE; am.am_strName="Not loaded"; am.am_iAnimation=0; try { am.SetModel_t(fnAxis); } catch( char *strError) { WarningMessage( strError); } m_emEditModel.edm_aamAttachedModels.Unlock(); } } m_bDocLoadedOk = TRUE; // flush stale caches _pShell->Execute("FreeUnusedStock();"); SelectSurface( 0, TRUE); return TRUE; }
extern "C" void ColormapAddCtlDialog_ValueRangeCB(Widget widget, XtPointer clientData, XtPointer callData) { ASSERT(widget); ASSERT(clientData); WarningMessage("Values must be in the range 0.0 to 1.0"); }
extern "C" void ColormapAddCtlDialog_LevelRangeCB(Widget widget, XtPointer clientData, XtPointer callData) { ASSERT(widget); ASSERT(clientData); ColormapAddCtlDialog *dialog = (ColormapAddCtlDialog*) clientData; ColormapNode* node; node = dialog->editor->getColormapNode(); WarningMessage("Values must be in the range %g to %g", node->getMinimumValue(), node->getMaximumValue()); }
int IdleProcessingRegisterHandler(IdleProcessingHandler func) { IdleHandlerElement *e; if ((e = calloc(1, sizeof(*e))) == NULL) { WarningMessage("%s\n", "Failed to allocate an idle handler element"); return -1; } e->handler = func; e->next = idle_handlers; idle_handlers = e; return 0; }
static int StreamUDPDeleteSession(const SessionKey *key) { SessionControlBlock *scb = session_api->get_session_by_key(udp_lws_cache, key); if (scb) { if( StreamSetRuntimeConfiguration( scb, scb->protocol ) == 0 ) session_api->delete_session( udp_lws_cache, scb, "ha sync" ); else WarningMessage(" WARNING: Attempt to delete a UDP Session when no valid runtime configuration.\n" ); } return 0; }
boolean MacroParameterNode::canSwitchNetwork(Network *from, Network *to) { if (!to->canBeMacro()) { WarningMessage( "Attempt to add %s tool to network would make the \n" "network a macro, but the network contains tools which will\n" "not allow it to become a macro.\n" "Attempt ignored.", this->getNameString()); return FALSE; } return this->UniqueNameNode::canSwitchNetwork(from,to); }
// タイマーの更新を開始/停止する。 20060126 aroka // ファンクションキー表示はタイマーにより更新しているが、 // アプリのフォーカスが外れたときに親ウィンドウからON/OFFを // 呼び出してもらうことにより、余計な負荷を停止したい。 void CFuncKeyWnd::Timer_ONOFF( bool bStart ) { if( NULL != GetHwnd() ){ if( bStart ){ /* タイマーを起動 */ if( 0 == ::SetTimer( GetHwnd(), IDT_FUNCWND, TIMER_TIMEOUT, NULL ) ){ WarningMessage( GetHwnd(), LS(STR_ERR_DLGFUNCKEYWN1) ); } } else { /* タイマーを削除 */ ::KillTimer( GetHwnd(), IDT_FUNCWND ); m_nCurrentKeyState = -1; } } return; }
void SideChannelStopTXThread(void) { int rval; if (!ScSideChannelEnabled()) return; if (p_tx_thread_id != NULL) { stop_processing = 1; pthread_mutex_lock(&tx_queue.mutex); pthread_cond_signal(&tx_queue.cond); pthread_mutex_unlock(&tx_queue.mutex); if ((rval = pthread_join(*p_tx_thread_id, NULL)) != 0) WarningMessage("Side channel TX thread termination returned an error: %s\n", strerror(rval)); } }
int KinectInternalData::WriteRegister(unsigned short registeridx, unsigned short value) { unsigned short reply[2]; unsigned short command[2]; int res; command[0] = registeridx; command[1] = value; TraceMessage("Writing value %04x to register %04x", value, registeridx); res = SendCommand(0x03, (unsigned char*)command, 4, (unsigned char*)reply, 4); if (res < 0) return res; if (res != 2) { WarningMessage("WriteRegister: SendCommand returned %d [%04x %04x], 0000 expected!", res, reply[0], reply[1]); } return 0; };
// start pasring fnParseFile file (may include mesh,skeleton,animset,...) BOOL StartParser(CTString fnParseFile) { CTFileName fnFull; fnFull = _fnmApplicationPath + fnParseFile; yyin = NULL; astrText.PopAll(); astrText.Clear(); // initialize pre-parsing variables yyin = fopen(fnFull, "r"); // reset include depth ptr include_stack_ptr = 0; strCurentFileName = fnFull; _yy_iIndex = 0; _yy_jIndex = 0; _yy_iLine = 1; // load data try { if (yyin==NULL) { ThrowF_t("Cannot open file '%s'!", (const char*)fnParseFile ); } yyrestart(yyin); yyparse(); fclose(yyin); } // if an error in parsing occured catch(char *strError) { WarningMessage(strError); // AfxMessageBox(strError); theApp.ErrorMessage(strError); if(yyin!=NULL) fclose(yyin); return FALSE; } return TRUE; }
/* Create file cache */ FileCache *file_cache_create(uint64_t memcap, uint32_t cleanup_files) { FileCache *fileCache = NULL; int max_files = 0; uint64_t file_segment_memcap = memcap/2; if( !memcap ) { WarningMessage("%s(%d) File cache memory unlimited!\n", file_name, file_line); } /* Half for file segment, half for file context tracking*/ max_files = get_max_files_from_memcap(memcap - file_segment_memcap); fileCache = SnortAlloc( sizeof( *fileCache ) ); if( fileCache ) { fileCache->max_files = max_files; /* Okay, now create the table */ fileCache->hashTable = sfxhash_new(max_files, sizeof(FileKey), sizeof(FileEntry), 0, 0, NULL, file_entry_free_func, 1 ); if (!fileCache->hashTable) FatalError( "%s(%d) Unable to create a file cache.\n", file_name, file_line); sfxhash_set_max_nodes( fileCache->hashTable, max_files ); fileCache->file_segment_memcap = file_segment_memcap; fileCache->max_file_depth = file_api->get_max_file_depth(); fileCache->cleanup_files = cleanup_files; } else { FatalError( "%s(%d) Unable to create a file cache.\n", file_name, file_line); } return fileCache; }
// // Switch the node from one net to another. Look for a transmitter // to connect to. // void ReceiverNode::switchNetwork(Network *from, Network *to, boolean silently) { const char *label = this->getLabelString(); // // Check for a connected input. If there is an arc, do nothing // because any required name change on the part of the transmitter // will keep us up-to-date. If there is no arc, then it's tough to // know what name to use. // List *l = (List*)this->getInputArks(1); boolean found = FALSE; if (l->getSize() > 0) { Ark *a = (Ark*)l->getElement(1); int dummy; if (EqualString(a->getSourceNode(dummy)->getLabelString(), label)) { found = TRUE; } else { delete a; } } boolean avoiding_cycle = FALSE; if (!found) { l = to->makeClassifiedNodeList(ClassTransmitterNode, FALSE); if (l) { Node *n; ListIterator iterator(*l); while ( (n = (Node*)iterator.getNext()) ) { if (EqualString(label, n->getLabelString())) { if (to->checkForCycle(n, this)) { avoiding_cycle = TRUE; break; } } } if (!avoiding_cycle) { iterator.setList(*l); while ( (n = (Node*)iterator.getNext()) ) { if (EqualString(label, n->getLabelString())) { // link me to transmitter new Ark(n, 1, this, 1); found = TRUE; } } } delete l; } } // // If the receiver has no arc, then check for name uniqueness and rename the // receiver if necessary. (If the receiver has an arc, then it's up to the // transmitter to handle name uniqueness.) // if (!found) { if (!avoiding_cycle) { const char* conflict = to->nameConflictExists(this, label); if (conflict) { if (!silently) WarningMessage ("A %s with name \"%s\" already exists.", conflict, label); this->setLabelString ("Receiver"); } } else { if (!silently) WarningMessage ( "Receiver \"%s\" has been renamed \"%s\"\n" "due to a cyclic connection.", this->getLabelString(), "Receiver" ); this->setLabelString ("Receiver"); } } this->UniqueNameNode::switchNetwork(from, to, silently); }
void MacroParameterNode::switchNetwork(Network *from, Network *to, boolean silently) { MacroDefinition *md = from->getDefinition(); ParameterDefinition *pd = this->getParameterDefinition(); ParameterDefinition *dummyPd; int n; dummyPd = new ParameterDefinition(-1); dummyPd->setDummy(TRUE); dummyPd->addType(new DXType(DXType::ObjectType)); if(this->isInput()) md->replaceInput(dummyPd, pd); else md->replaceOutput(dummyPd, pd); // // Switch the Network pointers // this->UniqueNameNode::switchNetwork(from, to, silently); // // Make sure we are a macro // to->makeMacro(TRUE); md = to->getDefinition(); if(this->isInput()) { n = md->getFirstAvailableInputPosition(); if (n <= md->getInputCount()) { dummyPd = md->getInputDefinition(n); ASSERT(dummyPd->isDummy()); md->replaceInput(pd,dummyPd); } else { md->addInput(pd); } this->setIndex(n); } else { n = md->getFirstAvailableOutputPosition(); if (n <= md->getOutputCount()) { ParameterDefinition *dummyPd = md->getOutputDefinition(n); ASSERT(dummyPd->isDummy()); md->replaceOutput(pd,dummyPd); } else { md->addOutput(pd); } this->setIndex(n); } // // See if the input is named input_%d or output_%d // and if so, change it to match the possibly new index. // pd = this->getParameterDefinition(); char buf[64]; if (this->isInput()) { strcpy(buf,"input_"); } else { strcpy(buf,"output_"); } int buflen = strlen(buf); const char* current_name = pd->getNameString(); const char* new_name = NUL(char*); boolean name_reset = FALSE; if (EqualSubstring(current_name, buf, buflen)) { int endint = 0; const char *end = ¤t_name[strlen(current_name)]; if (IsInteger(current_name+buflen,endint) && ((current_name+buflen+endint) == end)) { sprintf(buf+buflen,"%d",this->getIndex()); pd->setName(buf); name_reset = TRUE; } } // // Resolve name conflicts with other nodes using global names. // if (!name_reset) { int name_clash=0, i; if (this->isInput()) { int count = to->getInputCount(); for (i=1 ; !name_clash && (i <= count) ; i++) { ParameterDefinition *opd = to->getInputDefinition(i); if ((i != this->getIndex()) && EqualString(current_name,opd->getNameString())) name_clash = i; } } else { int count = to->getOutputCount(); for (i=1 ; !name_clash && (i <= count) ; i++) { ParameterDefinition *opd = to->getOutputDefinition(i); if ((i != this->getIndex()) && EqualString(current_name,opd->getNameString())) name_clash = i; } } if (name_clash) { char name_buf[64]; if (this->isInput()) { sprintf(name_buf,"input_%d", this->getIndex()); } else { sprintf(name_buf,"output_%d", this->getIndex()); } new_name = name_buf; if (!silently) WarningMessage ( "Parameter name `%s' is the same name used by parameter #%d.\n" "Your macro %s has been renamed \"%s\".", current_name, name_clash, (this->isInput()? "Input" : "Output"), new_name ); pd->setName(name_buf); name_reset = TRUE; } } if (!name_reset) { const char* conflict = to->nameConflictExists(this, this->getUniqueName()); if (conflict) { char name_buf[64]; if (this->isInput()) { sprintf(name_buf,"input_%d", this->getIndex()); } else { sprintf(name_buf,"output_%d", this->getIndex()); } new_name = name_buf; if (!silently) WarningMessage ( "A %s with name \"%s\" already exists.\n" "Your macro %s has been renamed \"%s\".", conflict, this->getUniqueName(), (this->isInput()? "Input" : "Output"), name_buf ); pd->setName(name_buf); name_reset = TRUE; } } }
static void *SideChannelThread(void *arg) { struct timespec ts; struct timeval tv; SCHandler *handler; SCModule *module; SCMsgHdr *hdr; uint32_t length; const uint8_t *msg; void *msg_handle; int rval; tx_thread_pid = gettid(); tx_thread_running = 1; pthread_mutex_lock(&tx_queue.mutex); while (!stop_processing) { /* If the message queue is empty, we will stop without unlocking it so we can immediately start a timed wait. */ while ((rval = RBMQ_ReadMsg(tx_queue.queue, (const void **) &hdr, &msg, &length, &msg_handle)) == 0) { pthread_mutex_unlock(&tx_queue.mutex); for (handler = tx_handlers; handler; handler = handler->next) { if (hdr->type == handler->type || handler->type == SC_MSG_TYPE_ANY) handler->processMsgFunc(hdr, msg, length); } pthread_mutex_lock(&tx_queue.mutex); rval = RBMQ_AckMsg(tx_queue.queue, msg_handle); if (rval != 0) WarningMessage("Error ACK'ing message %p!\n", msg_handle); /* Again, not unlocking so that we're already locked for the three places we can go from here, which are all expecting it (dequeue, timed wait, or done). */ Side_Channel_Stats.tx_messages_processed++; #ifndef REG_TEST if (stop_processing) goto done; #endif } if (stop_processing) goto done; gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec + 10; ts.tv_nsec = tv.tv_usec * 1000; rval = pthread_cond_timedwait(&tx_queue.cond, &tx_queue.mutex, &ts); /* If we timed out waiting for new output messages to process, run the registered idle routines. */ if (rval == ETIMEDOUT && !stop_processing) { for (module = modules; module; module = module->next) { if (module->enabled && module->funcs.idleFunc) module->funcs.idleFunc(); } } } done: pthread_mutex_unlock(&tx_queue.mutex); LogMessage("Side Channel thread exiting...\n"); return NULL; }
BOOL CModelerDoc::OnSaveDocument(LPCTSTR lpszPathName) { CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); //return CDocument::OnSaveDocument(lpszPathName); CTFileName fnModelFile = CTString(lpszPathName); try { fnModelFile.RemoveApplicationPath_t(); } catch( char *err_str) { AfxMessageBox( err_str); return FALSE; } #if BUILD_PUBLISHER WarningMessage( "Saving is disabled in this version!"); return FALSE; #else try { m_emEditModel.Save_t( fnModelFile); m_emEditModel.SaveMapping_t( fnModelFile.NoExt()+".map", 0); } catch( char *err_str) { MessageBoxA(pMainFrame->m_hWnd, err_str, "Warning! Model Save failed.", MB_OK|MB_ICONHAND|MB_SYSTEMMODAL); return FALSE; } SetModifiedFlag( FALSE); CModelerView *pModelerView = CModelerView::GetActiveView(); if( pModelerView != NULL) { pModelerView->SaveThumbnail(); } // reload attachments of all loaded models POSITION pos = theApp.m_pdtModelDocTemplate->GetFirstDocPosition(); while (pos!=NULL) { CModelerDoc *pmdCurrent = (CModelerDoc *)theApp.m_pdtModelDocTemplate->GetNextDoc(pos); if( pmdCurrent != this) { BOOL bUpdateAttachments = TRUE; // if document is modified if( pmdCurrent->IsModified()) { CTString strMessage; CTFileName fnDoc = CTString(pmdCurrent->GetPathName()); strMessage.PrintF("Do you want to save model \"%s\" before reloading its attachments?", fnDoc.FileName() ); if( ::MessageBox( pMainFrame->m_hWnd, strMessage, "Warning !", MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON1 | MB_TASKMODAL | MB_TOPMOST) != IDYES) { bUpdateAttachments = FALSE; } // save document else { pmdCurrent->OnSaveDocument(pmdCurrent->GetPathName()); } } if( bUpdateAttachments) { POSITION pos = pmdCurrent->GetFirstViewPosition(); while (pos != NULL) { CView* pView = GetNextView(pos); ((CModelerView *)pView)->m_ModelObject.AutoSetAttachments(); //CModelData *pmd = (CModelData *) ((CModelerView *)pView)->m_ModelObject.GetData(); //pmd->Reload(); } } } } return TRUE; #endif }
int KinectInternalData::SendCommand(unsigned short command, unsigned char *commandbuffer, unsigned int commandbufferlength, unsigned char *replybuffer, unsigned int replybufferlength) { int i, j, ret = 0; uint8_t obuf[0x2000]; uint8_t ibuf[0x2000]; ZeroMemory(obuf, 0x2000); ZeroMemory(ibuf, 0x2000); cam_hdr *chdr = (cam_hdr *)obuf; cam_hdr *rhdr = (cam_hdr *)ibuf; chdr->cmd = command; chdr->tag = mCommandTag; chdr->len = commandbufferlength / 2; chdr->magic[0] = 0x47; chdr->magic[1] = 0x4d; memcpy (obuf + sizeof (*chdr), commandbuffer, commandbufferlength); ret = usb_control_msg(mDeviceHandle, 0x40, 0, 0, 0, (char*)obuf, commandbufferlength + sizeof (cam_hdr), 1600); //ret = usb_control_msg(mDeviceHandle, 0x40, 0, 0, 0, (char*)ibuf, 0x200, 1600); if (ret < 0) { ErrorMessage("SendCommand: Failed to send control message! (%d)\n", ret); return ret; } do { ret = usb_control_msg(mDeviceHandle, 0xc0, 0, 0, 0, (char*)ibuf, 0x200, 1600); Sleep(10); } while (ret == 0); TraceMessage("Control reply: %d\n", ret); if (ret < sizeof (cam_hdr)) { ErrorMessage ("SendCommand: Input control transfer failed (%d)\n", ret); return ret; } ret -= sizeof (cam_hdr); if (rhdr->magic[0] != 0x52 || rhdr->magic[1] != 0x42) { ErrorMessage ("SendCommand: Bad magic %02x %02x\n", rhdr->magic[0], rhdr->magic[1]); return -1; } if (rhdr->cmd != chdr->cmd) { ErrorMessage ("SendCommand: Bad cmd %02x != %02x\n", rhdr->cmd, chdr->cmd); return -1; } if (rhdr->tag != chdr->tag) { ErrorMessage ("SendCommand: Bad tag %04x != %04x\n", rhdr->tag, chdr->tag); return -1; } if (rhdr->len != (ret / 2)) { ErrorMessage ("SendCommand: Bad len %04x != %04x\n", rhdr->len, (int) (ret / 2)); return -1; } if (ret > replybufferlength) { WarningMessage ("SendCommand: Data buffer is %d bytes long, but got %d bytes\n", replybufferlength, ret); memcpy (replybuffer, ibuf + sizeof (*rhdr), replybufferlength); } else { memcpy (replybuffer, ibuf + sizeof (*rhdr), ret); } mCommandTag++; return ret; };
bool COutputAdapterDiff::OutputA(const ACHAR* pBuf, int size) { if( size == -1 ){ size = auto_strlen(pBuf); } //@@@ 2003.05.31 MIK // 先頭がBinary filesならバイナリファイルのため意味のある差分が取られなかった if( bFirst ) { bFirst = false; if( strncmp( pBuf, "Binary files ", strlen( "Binary files " ) ) == 0 ) { WarningMessage( NULL, LS(STR_ERR_DLGEDITVWDIFF4) ); return false; } } //読み出した文字列をチェックする int j; for( j = 0; j < (int)size/*-1*/; j++ ) { if( bLineHead ) { if( pBuf[j] != '\n' && pBuf[j] != '\r' ) { bLineHead = false; //DIFF情報の始まりか? if( pBuf[j] >= '0' && pBuf[j] <= '9' ) { bDiffInfo = true; nDiffLen = 0; szDiffData[nDiffLen++] = pBuf[j]; } /* else if( pBuf[j] == '<' || pBuf[j] == '>' || pBuf[j] == '-' ) { bDiffInfo = false; nDiffLen = 0; } */ } } else { //行末に達したか? if( pBuf[j] == '\n' || pBuf[j] == '\r' ) { //DIFF情報があれば解析する if( bDiffInfo == true && nDiffLen > 0 ) { szDiffData[nDiffLen] = '\0'; m_view->AnalyzeDiffInfo( szDiffData, nFlgFile12 ); nDiffLen = 0; } bDiffInfo = false; bLineHead = true; } else if( bDiffInfo == true ) { //DIFF情報に追加する szDiffData[nDiffLen++] = pBuf[j]; if( nDiffLen >= 99 ) { nDiffLen = 0; bDiffInfo = false; } } } } return true; }
/*! 差分表示 @param pszFile1 [in] 自ファイル名 @param pszFile2 [in] 相手ファイル名 @param nFlgOpt [in] 0b000000000 ||||||+--- -i ignore-case 大文字小文字同一視 |||||+---- -w ignore-all-space 空白無視 ||||+----- -b ignore-space-change 空白変更無視 |||+------ -B ignore-blank-lines 空行無視 ||+------- -t expand-tabs TAB-SPACE変換 |+-------- (編集中のファイルが旧ファイル) +--------- (DIFF差分がないときにメッセージ表示) @note HandleCommandからの呼び出し対応(ダイアログなし版) @author MIK @date 2002/05/25 @date 2005/10/28 旧Command_Diffから関数名の変更。 GetCommander().Command_Diff_Dialogだけでなく新Command_Diff からも呼ばれる関数。maru @date 2013/06/21 ExecCmdを利用するように */ void CEditView::ViewDiffInfo( const TCHAR* pszFile1, const TCHAR* pszFile2, int nFlgOpt, bool bUTF8 ) /* bool bFlgCase, //大文字小文字同一視 bool bFlgBlank, //空白無視 bool bFlgWhite, //空白変更無視 bool bFlgBLine, //空行無視 bool bFlgTabSpc, //TAB-SPACE変換 bool bFlgFile12, //編集中のファイルが旧ファイル */ { CWaitCursor cWaitCursor( this->GetHwnd() ); int nFlgFile12 = 1; /* exeのあるフォルダ */ TCHAR szExeFolder[_MAX_PATH + 1]; TCHAR cmdline[1024]; GetExedir( cmdline, _T("diff.exe") ); SplitPath_FolderAndFile( cmdline, szExeFolder, NULL ); // From Here Dec. 28, 2002 MIK // diff.exeの存在チェック if( !IsFileExists( cmdline, true ) ) { WarningMessage( GetHwnd(), LS(STR_ERR_DLGEDITVWDIFF2) ); return; } cmdline[0] = _T('\0'); //今あるDIFF差分を消去する。 if( CDiffManager::getInstance()->IsDiffUse() ) GetCommander().Command_Diff_Reset(); //m_pcEditDoc->m_cDocLineMgr.ResetAllDiffMark(); //オプションを作成する TCHAR szOption[16]; // "-cwbBt" _tcscpy( szOption, _T("-") ); if( nFlgOpt & 0x0001 ) _tcscat( szOption, _T("i") ); //-i ignore-case 大文字小文字同一視 if( nFlgOpt & 0x0002 ) _tcscat( szOption, _T("w") ); //-w ignore-all-space 空白無視 if( nFlgOpt & 0x0004 ) _tcscat( szOption, _T("b") ); //-b ignore-space-change 空白変更無視 if( nFlgOpt & 0x0008 ) _tcscat( szOption, _T("B") ); //-B ignore-blank-lines 空行無視 if( nFlgOpt & 0x0010 ) _tcscat( szOption, _T("t") ); //-t expand-tabs TAB-SPACE変換 if( _tcscmp( szOption, _T("-") ) == 0 ) szOption[0] = _T('\0'); //オプションなし if( nFlgOpt & 0x0020 ) nFlgFile12 = 0; else nFlgFile12 = 1; // To Here Dec. 28, 2002 MIK { //コマンドライン文字列作成(MAX:1024) auto_sprintf( cmdline, _T("\"%ts\\%ts\" %ts \"%ts\" \"%ts\""), szExeFolder, //sakura.exeパス _T("diff.exe"), //diff.exe szOption, //diffオプション ( nFlgFile12 ? pszFile2 : pszFile1 ), ( nFlgFile12 ? pszFile1 : pszFile2 ) ); } { int nFlgOpt = 0; nFlgOpt |= 0x01; // GetStdOut if( bUTF8 ){ nFlgOpt |= 0x80; // UTF-8 out (SJISと違ってASCIIセーフなので) nFlgOpt |= 0x100; // UTF-8 in } nFlgOpt |= 0x40; // 拡張情報出力無効 COutputAdapterDiff oa(this, nFlgFile12); bool ret = ExecCmd( cmdline, nFlgOpt, NULL, &oa ); if( ret ){ if( oa.bDiffInfo == true && oa.nDiffLen > 0 ) { oa.szDiffData[oa.nDiffLen] = '\0'; AnalyzeDiffInfo( oa.szDiffData, nFlgFile12 ); } } } //DIFF差分が見つからなかったときにメッセージ表示 if( nFlgOpt & 0x0040 ) { if( !CDiffManager::getInstance()->IsDiffUse() ) { InfoMessage( this->GetHwnd(), LS(STR_ERR_DLGEDITVWDIFF5) ); } } //分割したビューも更新 m_pcEditWnd->Views_Redraw(); return; }
// returns true if the ROM was loaded OK bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR TdfFileName) { HANDLE hTemp; DWORD dwFilesize; DWORD NumQuarterBlocks = 0; UnloadCart(Cart); // first, make sure any previous carts have been unloaded Cart->iCurrentRamBankNo = 0; Cart->iCurrentRomBankNo = 1; Cart->bRamEnableState = 0; Cart->bMBC1RAMbanking = 0; // Attempt to load the ROM file. hTemp = CreateFile(RomFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hTemp != INVALID_HANDLE_VALUE && (Cart->hRomFile = CreateFileMapping(hTemp, NULL, PAGE_READONLY, 0, 0, NULL) ) ) { // if the first case fails, the file doesn't exist. The second case can fail if the file size is zero. dwFilesize = GetFileSize(hTemp, NULL); CloseHandle(hTemp); Cart->RomData = (LPCBYTE)MapViewOfFile( Cart->hRomFile, FILE_MAP_READ, 0, 0, 0 ); } else { DebugWriteA("Couldn't load the ROM file, GetLastError returned %08x\n", GetLastError()); if (hTemp != INVALID_HANDLE_VALUE) CloseHandle(hTemp); // if file size was zero, make sure we don't leak the handle ErrorMessage(IDS_ERR_GBROM, 0, false); return false; } if (dwFilesize < 0x8000) // a Rom file has to be at least 32kb { DebugWriteA("ROM file wasn't big enough to be a GB ROM!\n"); ErrorMessage(IDS_ERR_GBROM, 0, false); UnloadCart(Cart); return false; } DebugWriteA(" Cartridge Type #:"); DebugWriteByteA(Cart->RomData[0x147]); DebugWriteA("\n"); switch (Cart->RomData[0x147]) { // if we hadn't checked the file size before, this might have caused an access violation case 0x00: Cart->iCartType = GB_NORM; Cart->bHasRam = false; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x01: Cart->iCartType = GB_MBC1; Cart->bHasRam = false; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x02: Cart->iCartType = GB_MBC1; Cart->bHasRam = true; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x03: Cart->iCartType = GB_MBC1; Cart->bHasRam = true; Cart->bHasBattery = true; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x05: Cart->iCartType = GB_MBC2; Cart->bHasRam = false; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x06: Cart->iCartType = GB_MBC2; Cart->bHasRam = false; Cart->bHasBattery = true; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x08: Cart->iCartType = GB_NORM; Cart->bHasRam = true; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x09: Cart->iCartType = GB_NORM; Cart->bHasRam = true; Cart->bHasBattery = true; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x0B: Cart->iCartType = GB_MMMO1; Cart->bHasRam = false; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x0C: Cart->iCartType = GB_MMMO1; Cart->bHasRam = true; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x0D: Cart->iCartType = GB_MMMO1; Cart->bHasRam = true; Cart->bHasBattery = true; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x0F: Cart->iCartType = GB_MBC3; Cart->bHasRam = false; Cart->bHasBattery = true; Cart->bHasTimer = true; Cart->bHasRumble = false; break; case 0x10: Cart->iCartType = GB_MBC3; Cart->bHasRam = true; Cart->bHasBattery = true; Cart->bHasTimer = true; Cart->bHasRumble = false; break; case 0x11: Cart->iCartType = GB_MBC3; Cart->bHasRam = false; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x12: Cart->iCartType = GB_MBC3; Cart->bHasRam = true; Cart->bHasBattery = true; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x13: Cart->iCartType = GB_MBC3; Cart->bHasRam = true; Cart->bHasBattery = true; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x19: Cart->iCartType = GB_MBC5; Cart->bHasRam = false; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x1A: Cart->iCartType = GB_MBC5; Cart->bHasRam = true; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x1B: Cart->iCartType = GB_MBC5; Cart->bHasRam = true; Cart->bHasBattery = true; Cart->bHasTimer = false; Cart->bHasRumble = false; break; case 0x1C: Cart->iCartType = GB_MBC5; Cart->bHasRam = false; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = true; break; case 0x1D: Cart->iCartType = GB_MBC5; Cart->bHasRam = true; Cart->bHasBattery = false; Cart->bHasTimer = false; Cart->bHasRumble = true; break; case 0x1E: Cart->iCartType = GB_MBC5; Cart->bHasRam = true; Cart->bHasBattery = true; Cart->bHasTimer = false; Cart->bHasRumble = true; break; default: WarningMessage( IDS_ERR_GBROM, MB_OK | MB_ICONWARNING); DebugWriteA("TPak: unsupported paktype\n"); UnloadCart(Cart); return false; } // assign read/write handlers switch (Cart->iCartType) { case GB_NORM: // Raw cartridge Cart->ptrfnReadCart = &ReadCartNorm; Cart->ptrfnWriteCart = &WriteCartNorm; break; case GB_MBC1: Cart->ptrfnReadCart = &ReadCartMBC1; Cart->ptrfnWriteCart = &WriteCartMBC1; break; case GB_MBC2: Cart->ptrfnReadCart = &ReadCartMBC2; Cart->ptrfnWriteCart = &WriteCartMBC2; break; case GB_MBC3: Cart->ptrfnReadCart = &ReadCartMBC3; Cart->ptrfnWriteCart = &WriteCartMBC3; break; case GB_MBC5: Cart->ptrfnReadCart = &ReadCartMBC5; Cart->ptrfnWriteCart = &WriteCartMBC5; break; default: // Don't pretend we know how to handle carts we don't support Cart->ptrfnReadCart = NULL; Cart->ptrfnWriteCart = NULL; DebugWriteA("Unsupported paktype: can't read/write cart type %02X\n", Cart->iCartType); UnloadCart(Cart); return false; } // Determine ROM size for paging checks Cart->iNumRomBanks = 2; switch (Cart->RomData[0x148]) { case 0x01: Cart->iNumRomBanks = 4; break; case 0x02: Cart->iNumRomBanks = 8; break; case 0x03: Cart->iNumRomBanks = 16; break; case 0x04: Cart->iNumRomBanks = 32; break; case 0x05: Cart->iNumRomBanks = 64; break; case 0x06: Cart->iNumRomBanks = 128; break; case 0x52: Cart->iNumRomBanks = 72; break; case 0x53: Cart->iNumRomBanks = 80; break; case 0x54: Cart->iNumRomBanks = 96; break; } if (dwFilesize != 0x4000 * Cart->iNumRomBanks) // Now that we know how big the ROM is supposed to be, check it again { ErrorMessage(IDS_ERR_GBROM, 0, false); UnloadCart(Cart); return false; } // Determine RAM size for paging checks Cart->iNumRamBanks = 0; switch (Cart->RomData[0x149]) { case 0x01: Cart->iNumRamBanks = 1; NumQuarterBlocks = 1; break; case 0x02: Cart->iNumRamBanks = 1; NumQuarterBlocks = 4; break; case 0x03: Cart->iNumRamBanks = 4; NumQuarterBlocks = 16; break; case 0x04: Cart->iNumRamBanks = 16; NumQuarterBlocks = 64; break; case 0x05: Cart->iNumRamBanks = 8; NumQuarterBlocks = 32; break; } DebugWriteA("GB cart has %d ROM banks, %d RAM quarter banks\n", Cart->iNumRomBanks, NumQuarterBlocks); if (Cart->bHasTimer) { DebugWriteA("GB cart timer present\n"); } // Attempt to load the SRAM file, but only if RAM is supposed to be present. // For saving back to a file, if we map too much it will expand the file. if (Cart->bHasRam) { if (Cart->bHasBattery) { hTemp = CreateFile( RamFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); if( hTemp == INVALID_HANDLE_VALUE ) {// test if Read-only access is possible hTemp = CreateFile( RamFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); if (Cart->bHasTimer && Cart->bHasBattery) { Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC)); ClearData(Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC)); } else { Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800); ClearData(Cart->RamData, NumQuarterBlocks * 0x0800); } if( hTemp != INVALID_HANDLE_VALUE ) { DWORD dwBytesRead; if (Cart->bHasTimer && Cart->bHasBattery) ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), &dwBytesRead, NULL); else ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800, &dwBytesRead, NULL); WarningMessage( IDS_DLG_TPAK_READONLY, MB_OK | MB_ICONWARNING); } else { WarningMessage( IDS_ERR_GBSRAMERR, MB_OK | MB_ICONWARNING); return true; } } else { // file is OK, use a mapping if (Cart->bHasTimer && Cart->bHasBattery) Cart->hRamFile = CreateFileMapping( hTemp, NULL, PAGE_READWRITE, 0, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), NULL); else Cart->hRamFile = CreateFileMapping( hTemp, NULL, PAGE_READWRITE, 0, NumQuarterBlocks * 0x0800, NULL); if (Cart->hRamFile != NULL) { Cart->RamData = (LPBYTE)MapViewOfFile( Cart->hRamFile, FILE_MAP_ALL_ACCESS, 0, 0, 0 ); } else { // could happen, if the file isn't big enough AND can't be grown to fit DWORD dwBytesRead; if (Cart->bHasTimer && Cart->bHasBattery) { Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC)); ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), &dwBytesRead, NULL); } else { Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800); ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800, &dwBytesRead, NULL); } if (dwBytesRead < NumQuarterBlocks * 0x0800 + ((Cart->bHasTimer && Cart->bHasBattery) ? sizeof(gbCartRTC) : 0)) { ClearData(Cart->RamData, NumQuarterBlocks * 0x0800 + ((Cart->bHasTimer && Cart->bHasBattery) ? sizeof(gbCartRTC) : 0)); WarningMessage( IDS_ERR_GBSRAMERR, MB_OK | MB_ICONWARNING); } else { WarningMessage( IDS_DLG_TPAK_READONLY, MB_OK | MB_ICONWARNING); } } } if (Cart->bHasTimer && Cart->bHasBattery) { dwFilesize = GetFileSize(hTemp, 0); if (dwFilesize >= (NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC) ) ) { // Looks like there is extra data in the SAV file than just RAM data... assume it is RTC data. gbCartRTC RTCTimer; CopyMemory( &RTCTimer, &Cart->RamData[NumQuarterBlocks * 0x0800], sizeof(RTCTimer) ); Cart->TimerData[0] = (BYTE)RTCTimer.mapperSeconds; Cart->TimerData[1] = (BYTE)RTCTimer.mapperMinutes; Cart->TimerData[2] = (BYTE)RTCTimer.mapperHours; Cart->TimerData[3] = (BYTE)RTCTimer.mapperDays; Cart->TimerData[4] = (BYTE)RTCTimer.mapperControl; Cart->LatchedTimerData[0] = (BYTE)RTCTimer.mapperLSeconds; Cart->LatchedTimerData[1] = (BYTE)RTCTimer.mapperLMinutes; Cart->LatchedTimerData[2] = (BYTE)RTCTimer.mapperLHours; Cart->LatchedTimerData[3] = (BYTE)RTCTimer.mapperLDays; Cart->LatchedTimerData[4] = (BYTE)RTCTimer.mapperLControl; Cart->timerLastUpdate = RTCTimer.mapperLastTime; UpdateRTC(Cart); } else { ReadTDF(Cart); // try to open TDF format, clear/init Cart->TimerData if that fails } } CloseHandle(hTemp); } else { // no battery; just allocate some RAM Cart->RamData = (LPBYTE)P_malloc(Cart->iNumRamBanks * 0x2000); } } Cart->TimerDataLatched = false; return true; }
/* TRUE==正常 FALSE==入力エラー */ int CDlgGrep::GetData( void ) { /* サブフォルダからも検索する*/ m_bSubFolder = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_SUBFOLDER ); m_pShareData->m_Common.m_sSearch.m_bGrepSubFolder = m_bSubFolder; /* Grep:サブフォルダも検索 */ /* この編集中のテキストから検索する */ m_bFromThisText = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_FROMTHISTEXT ); /* 英大文字と英小文字を区別する */ m_sSearchOption.bLoHiCase = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_LOHICASE )); //2001/06/23 N.Nakatani /* 単語単位で検索 */ m_sSearchOption.bWordOnly = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_WORD )); /* 正規表現 */ m_sSearchOption.bRegularExp = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_REGULAREXP )); /* 文字コード自動判別 */ // m_bKanjiCode_AutoDetect = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_KANJICODEAUTODETECT ); /* 文字コードセット */ { int nIdx; HWND hWndCombo = ::GetDlgItem( GetHwnd(), IDC_COMBO_CHARSET ); nIdx = Combo_GetCurSel( hWndCombo ); m_nGrepCharSet = (ECodeType)Combo_GetItemData( hWndCombo, nIdx ); } /* 行を出力/該当部分/否マッチ行 を出力 */ if( ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTLINE ) ){ m_nGrepOutputLineType = 1; }else if( ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_NOHIT ) ){ m_nGrepOutputLineType = 2; }else{ m_nGrepOutputLineType = 0; } /* Grep: 出力形式 */ if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE1 ) ){ m_nGrepOutputStyle = 1; /* Grep: 出力形式 */ } if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE2 ) ){ m_nGrepOutputStyle = 2; /* Grep: 出力形式 */ } if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE3 ) ){ m_nGrepOutputStyle = 3; } m_bGrepOutputFileOnly = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_FILE_ONLY ); m_bGrepOutputBaseFolder = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_BASE_PATH ); m_bGrepSeparateFolder = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_SEP_FOLDER ); /* 検索文字列 */ int nBufferSize = ::GetWindowTextLength( GetItemHwnd(IDC_COMBO_TEXT) ) + 1; std::vector<TCHAR> vText(nBufferSize); ::DlgItem_GetText( GetHwnd(), IDC_COMBO_TEXT, &vText[0], nBufferSize); m_strText = to_wchar(&vText[0]); m_bSetText = true; /* 検索ファイル */ ::DlgItem_GetText( GetHwnd(), IDC_COMBO_FILE, m_szFile, _countof2(m_szFile) ); /* 検索フォルダ */ ::DlgItem_GetText( GetHwnd(), IDC_COMBO_FOLDER, m_szFolder, _countof2(m_szFolder) ); m_pShareData->m_Common.m_sSearch.m_nGrepCharSet = m_nGrepCharSet; // 文字コード自動判別 m_pShareData->m_Common.m_sSearch.m_nGrepOutputLineType = m_nGrepOutputLineType; // 行を出力/該当部分/否マッチ行 を出力 m_pShareData->m_Common.m_sSearch.m_nGrepOutputStyle = m_nGrepOutputStyle; // Grep: 出力形式 m_pShareData->m_Common.m_sSearch.m_bGrepOutputFileOnly = m_bGrepOutputFileOnly; m_pShareData->m_Common.m_sSearch.m_bGrepOutputBaseFolder = m_bGrepOutputBaseFolder; m_pShareData->m_Common.m_sSearch.m_bGrepSeparateFolder = m_bGrepSeparateFolder; //やめました // if( 0 == wcslen( m_szText ) ){ // WarningMessage( GetHwnd(), _T("検索のキーワードを指定してください。") ); // return FALSE; // } if( 0 != auto_strlen( m_szFile ) ){ CGrepEnumKeys enumKeys; int nErrorNo = enumKeys.SetFileKeys( m_szFile ); if( 1 == nErrorNo ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP2) ); return FALSE; }else if( nErrorNo == 2 ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP3) ); return FALSE; } } /* この編集中のテキストから検索する */ if( m_szFile[0] == _T('\0') ){ // Jun. 16, 2003 Moca // 検索パターンが指定されていない場合のメッセージ表示をやめ、 // 「*.*」が指定されたものと見なす. _tcscpy( m_szFile, _T("*.*") ); } if( m_szFolder[0] == _T('\0') ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP4) ); return FALSE; } { //カレントディレクトリを保存。このブロックから抜けるときに自動でカレントディレクトリは復元される。 CCurrentDirectoryBackupPoint cCurDirBackup; // 2011.11.24 Moca 複数フォルダ指定 std::vector<std::tstring> vPaths; CGrepAgent::CreateFolders( m_szFolder, vPaths ); int nFolderLen = 0; TCHAR szFolder[_MAX_PATH]; szFolder[0] = _T('\0'); for( int i = 0 ; i < (int)vPaths.size(); i ++ ){ // 相対パス→絶対パス if( !::SetCurrentDirectory( vPaths[i].c_str() ) ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP5) ); return FALSE; } TCHAR szFolderItem[_MAX_PATH]; ::GetCurrentDirectory( _MAX_PATH, szFolderItem ); // ;がフォルダ名に含まれていたら""で囲う if( auto_strchr( szFolderItem, _T(';') ) ){ szFolderItem[0] = _T('"'); ::GetCurrentDirectory( _MAX_PATH, szFolderItem + 1 ); auto_strcat(szFolderItem, _T("\"")); } int nFolderItemLen = auto_strlen( szFolderItem ); if( _MAX_PATH < nFolderLen + nFolderItemLen + 1 ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP6) ); return FALSE; } if( i ){ auto_strcat( szFolder, _T(";") ); } auto_strcat( szFolder, szFolderItem ); nFolderLen = auto_strlen( szFolder ); } auto_strcpy( m_szFolder, szFolder ); } //@@@ 2002.2.2 YAZAKI CShareData.AddToSearchKeyArr()追加に伴う変更 /* 検索文字列 */ if( 0 < m_strText.size() ){ // From Here Jun. 26, 2001 genta // 正規表現ライブラリの差し替えに伴う処理の見直し int nFlag = 0; nFlag |= m_sSearchOption.bLoHiCase ? 0x01 : 0x00; if( m_sSearchOption.bRegularExp && !CheckRegexpSyntax( m_strText.c_str(), GetHwnd(), true, nFlag) ){ return FALSE; } // To Here Jun. 26, 2001 genta 正規表現ライブラリ差し替え if( m_strText.size() < _MAX_PATH ){ CSearchKeywordManager().AddToSearchKeyArr( m_strText.c_str() ); m_pShareData->m_Common.m_sSearch.m_sSearchOption = m_sSearchOption; // 検索オプション } }else{ // 2014.07.01 空キーも登録する CSearchKeywordManager().AddToSearchKeyArr( L"" ); } // この編集中のテキストから検索する場合、履歴に残さない Uchi 2008/5/23 if (!m_bFromThisText) { /* 検索ファイル */ CSearchKeywordManager().AddToGrepFileArr( m_szFile ); /* 検索フォルダ */ CSearchKeywordManager().AddToGrepFolderArr( m_szFolder ); } return TRUE; }
// load (called from load(Setting *, const tstringi &) only) void SettingLoader::load(const tstringi &i_filename) { m_currentFilename = i_filename; tstring data; if (!readFile(&data, m_currentFilename)) { Acquire a(m_soLog); *m_log << m_currentFilename << _T(" : error: file not found") << std::endl; #if 1 *m_log << data << std::endl; #endif m_isThereAnyError = true; return; } // prefix if (m_prefixesRefCcount == 0) { static const _TCHAR *prefixes[] = { _T("="), _T("=>"), _T("&&"), _T("||"), _T(":"), _T("$"), _T("&"), _T("-="), _T("+="), _T("!!!"), _T("!!"), _T("!"), _T("E0-"), _T("E1-"), // <SCAN_CODE_EXTENTION> _T("S-"), _T("A-"), _T("M-"), _T("C-"), // <BASIC_MODIFIER> _T("W-"), _T("*"), _T("~"), _T("U-"), _T("D-"), // <KEYSEQ_MODIFIER> _T("R-"), _T("IL-"), _T("IC-"), _T("I-"), // <ASSIGN_MODIFIER> _T("NL-"), _T("CL-"), _T("SL-"), _T("KL-"), _T("MAX-"), _T("MIN-"), _T("MMAX-"), _T("MMIN-"), _T("T-"), _T("TS-"), _T("M0-"), _T("M1-"), _T("M2-"), _T("M3-"), _T("M4-"), _T("M5-"), _T("M6-"), _T("M7-"), _T("M8-"), _T("M9-"), _T("L0-"), _T("L1-"), _T("L2-"), _T("L3-"), _T("L4-"), _T("L5-"), _T("L6-"), _T("L7-"), _T("L8-"), _T("L9-"), }; m_prefixes = new std::vector<tstringi>; for (size_t i = 0; i < NUMBER_OF(prefixes); ++ i) m_prefixes->push_back(prefixes[i]); std::sort(m_prefixes->begin(), m_prefixes->end(), prefixSortPred); } m_prefixesRefCcount ++; // create parser Parser parser(data.c_str(), data.size()); parser.setPrefixes(m_prefixes); while (true) { try { if (!parser.getLine(&m_tokens)) break; m_ti = m_tokens.begin(); } catch (ErrorMessage &e) { if (m_log && m_soLog) { Acquire a(m_soLog); *m_log << m_currentFilename << _T("(") << parser.getLineNumber() << _T(") : error: ") << e << std::endl; } m_isThereAnyError = true; continue; } try { load_LINE(); if (!isEOL()) throw WarningMessage() << _T("back garbage is ignored."); } catch (WarningMessage &w) { if (m_log && m_soLog) { Acquire a(m_soLog); *m_log << i_filename << _T("(") << parser.getLineNumber() << _T(") : warning: ") << w << std::endl; } } catch (ErrorMessage &e) { if (m_log && m_soLog) { Acquire a(m_soLog); *m_log << i_filename << _T("(") << parser.getLineNumber() << _T(") : error: ") << e << std::endl; } m_isThereAnyError = true; } } // m_prefixes -- m_prefixesRefCcount; if (m_prefixesRefCcount == 0) delete m_prefixes; if (0 < m_canReadStack.size()) { Acquire a(m_soLog); *m_log << m_currentFilename << _T("(") << parser.getLineNumber() << _T(") : error: unbalanced `if'. ") << _T("you forget `endif', didn'i_token you?") << std::endl; m_isThereAnyError = true; } }
void CChildFrame::TestGame( BOOL bFullScreen) { // turn off info window CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); pMainFrame->HideInfoWindow(); CWorldEditorView *pPerspectiveView = GetPerspectiveView(); ASSERT( pPerspectiveView != NULL); SetActiveView( pPerspectiveView, FALSE); CWorldEditorDoc* pDoc = pPerspectiveView->GetDocument(); CTFileName fnmWorldToPlay; CTFileName fnmTempWorld = CTString("Temp\\TestGame.wld"); // if the world was never saved or if it is modified if( (!pDoc->m_bWasEverSaved && wed_bSaveTestGameFirstTime) || pDoc->IsModified()) { // save world under temporary name ASSERT_VALID(pDoc); try { pDoc->m_woWorld.Save_t(fnmTempWorld); fnmWorldToPlay = fnmTempWorld; } catch( char *strError) { AfxMessageBox( CString(strError)); pPerspectiveView->EnableToolTips(TRUE); return; } // if the world is not modified (it is saved on disk) } else { // use the saved world fnmWorldToPlay = CTString(CStringA(pDoc->GetPathName())); try { fnmWorldToPlay.RemoveApplicationPath_t(); } catch( char *strError) { AfxMessageBox( CString(strError)); pPerspectiveView->EnableToolTips(TRUE); return; } } // set rendering preferences _wrpWorldRenderPrefs = pPerspectiveView->m_vpViewPrefs.m_wrpWorldRenderPrefs; _mrpModelRenderPrefs = pPerspectiveView->m_vpViewPrefs.m_mrpModelRenderPrefs; _wrpWorldRenderPrefs.SetShadowsType( pPerspectiveView->GetChildFrame()->m_stShadowType); _wrpWorldRenderPrefs.SetSelectedEntityModel( theApp.m_pEntityMarkerModelObject); _wrpWorldRenderPrefs.SetSelectedPortalModel( theApp.m_pPortalMarkerModelObject); _wrpWorldRenderPrefs.SetEmptyBrushModel( theApp.m_pEmptyBrushModelObject); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture1, 0); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture2, 1); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture3, 2); _wrpWorldRenderPrefs.DisableVisTweaks(FALSE); _wrpWorldRenderPrefs.SetSelectedEntityModel( theApp.m_pEntityMarkerModelObject); _wrpWorldRenderPrefs.SetSelectedPortalModel( theApp.m_pPortalMarkerModelObject); _wrpWorldRenderPrefs.SetEmptyBrushModel( theApp.m_pEmptyBrushModelObject); // prepare test game view/draw ports CViewPort *pvp = pPerspectiveView->m_pvpViewPort; CDrawPort *pdp = pPerspectiveView->m_pdpDrawPort; pdp->SetOverlappedRendering(FALSE); // we are not rendering scene over already rendered scene (used for CSG layer) // if full screen mode is required HWND hWndFullScreen=NULL; HINSTANCE hInstanceFullScreen; WNDCLASSEX wcFullScreen; char achWindowTitle[256]; // current window title if( bFullScreen) { // get full screen display mode info const PIX pixSizeI = theApp.m_dmFullScreen.dm_pixSizeI; const PIX pixSizeJ = theApp.m_dmFullScreen.dm_pixSizeJ; const DisplayDepth dd = theApp.m_dmFullScreen.dm_ddDepth; const GfxAPIType gat = theApp.m_gatFullScreen; // set OpenGL fullscreen (before window) if( gat==GAT_OGL) { const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd); if( !bRes) { WarningMessage( "Unable to setup full screen display."); return; } } // register the window class hInstanceFullScreen = AfxGetInstanceHandle(); ASSERT( hInstanceFullScreen!=NULL); wcFullScreen.cbSize = sizeof(wcFullScreen); wcFullScreen.style = CS_HREDRAW | CS_VREDRAW; wcFullScreen.lpfnWndProc = ::DefWindowProc; wcFullScreen.cbClsExtra = 0; wcFullScreen.cbWndExtra = 0; wcFullScreen.hInstance = hInstanceFullScreen; wcFullScreen.hIcon = LoadIcon( hInstanceFullScreen, (LPCTSTR)IDR_MAINFRAME ); wcFullScreen.hCursor = NULL; wcFullScreen.hbrBackground = NULL; wcFullScreen.lpszMenuName = CString(APPLICATION_NAME); wcFullScreen.lpszClassName = CString(APPLICATION_NAME); wcFullScreen.hIconSm = NULL; RegisterClassEx(&wcFullScreen); // create a window, invisible initially hWndFullScreen = CreateWindowExA( WS_EX_TOPMOST, APPLICATION_NAME, "Serious Editor - Full Screen Test Game", // title WS_POPUP, 0,0, pixSizeI, pixSizeJ, // window size NULL, NULL, hInstanceFullScreen, NULL); // didn't make it? ASSERT( hWndFullScreen!=NULL); if( hWndFullScreen==NULL) { if( gat==GAT_OGL) _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); WarningMessage( "Unable to setup window for full screen display."); return; } // set windows for engine CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); SE_UpdateWindowHandle( hWndFullScreen); // set window title and show it sprintf( achWindowTitle, "Serious Editor - Test Game (FullScreen %dx%d)", pixSizeI, pixSizeJ); ::SetWindowTextA( hWndFullScreen, achWindowTitle); ::ShowWindow( hWndFullScreen, SW_SHOWNORMAL); // set Direct3D full screen (after window) #ifdef SE1_D3D if( gat==GAT_D3D) { const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd); if( !bRes) { WarningMessage( "Unable to setup full screen display."); ::DestroyWindow( hWndFullScreen); SE_UpdateWindowHandle( pMainFrame->m_hWnd); return; } } #endif // SE1_D3D // create canvas _pGfx->CreateWindowCanvas( hWndFullScreen, &pvp, &pdp); // initial screen fill and swap, just to get context running BOOL bSuccess = FALSE; if( pdp!=NULL && pdp->Lock()) { pdp->Fill(C_dGREEN|CT_OPAQUE); pdp->Unlock(); pvp->SwapBuffers(); bSuccess = TRUE; } // must succeed! ASSERT( bSuccess); if( !bSuccess) { _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); WarningMessage( "Unable to setup canvas for full screen display."); return; } } // enable sound snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16); _pSound->SetFormat( (enum CSoundLibrary::SoundFormat)snd_iFormat, TRUE); // run quick test game extern BOOL _bInOnDraw; _bInOnDraw = TRUE; _pGameGUI->QuickTest( fnmWorldToPlay, pdp, pvp); _bInOnDraw = FALSE; // disable sound _pSound->SetFormat( CSoundLibrary::SF_NONE); // restore default display mode and close test full screen window if( hWndFullScreen!=NULL) { _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); ::DestroyWindow( hWndFullScreen); SE_UpdateWindowHandle( pMainFrame->m_hWnd); } // redraw all views pDoc->UpdateAllViews( NULL); pPerspectiveView->EnableToolTips( TRUE); }