void TestOfficeDiscoverStrategy::TestDiscoverPptDocumentStatistics() { MockDocumentStatisticsVisitor visitor; OfficeDiscoverStrategy cut(visitor, PPT_DOCSTATS); cut.DiscoverDocumentStatistics(); assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatisticsBegin")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatisticsBegin] was not raised.")); assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatistics")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatistics] was not raised.")); assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatisticsEnd")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatisticsEnd] was not raised.")); //Last save time=2004/12/3 02:11:13 PM SYSTEMTIME expectedDate; expectedDate.wYear = 2004; expectedDate.wMonth = 12; expectedDate.wDay = 3; expectedDate.wHour = 12; expectedDate.wMinute = 11; expectedDate.wSecond = 13; expectedDate.wMilliseconds = 0; assertEquals(GetDateTimeString(&expectedDate), visitor[_T("Last save time")]); assertEquals(_T("pair"), visitor[_T("Last author")]); assertEquals(_T("2"), visitor[_T("Revision number")]); assertEquals(_T(""), visitor[_T("Last print date")]); assertEquals(_T("0"), visitor[_T("Total editing time")]); }
/* * setClockTime - set the current clock time */ static void setClockTime( void ) { char date[128]; GetDateTimeString( date ); tSec1 = date[DATE_LEN - 2]; tSec2 = date[DATE_LEN - 1]; tMin1 = date[DATE_LEN - 5]; tMin2 = date[DATE_LEN - 4]; tHour1 = date[DATE_LEN - 8]; tHour2 = date[DATE_LEN - 7]; } /* setClockTime */
void TestOfficeDiscoverStrategy::TestDiscoverExcelDocumentStatistics() { MockDocumentStatisticsVisitor visitor; OfficeDiscoverStrategy cut(visitor, EXCEL_DOCSTATS); cut.DiscoverDocumentStatistics(); assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatisticsBegin")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatisticsBegin] was not raised.")); assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatistics")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatistics] was not raised.")); assertMessage(visitor.IsEventRaised(_T("MockDocumentStatisticsVisitor::OnDocumentStatisticsEnd")), _T("The event [MockDocumentStatisticsVisitor::OnDocumentStatisticsEnd] was not raised.")); //Creation date=1996/10/15 01:33:28 AM - Local time = System time + 2 SYSTEMTIME expectedDate; expectedDate.wYear = 1996; expectedDate.wMonth = 10; expectedDate.wDay = 14; expectedDate.wHour = 23; expectedDate.wMinute = 33; expectedDate.wSecond = 28; expectedDate.wMilliseconds = 0; assertEquals(GetDateTimeString(&expectedDate), visitor[_T("Creation date")]); //Last save time=2004/12/3 12:25:00 PM expectedDate.wYear = 2004; expectedDate.wMonth = 12; expectedDate.wDay = 3; expectedDate.wHour = 10; expectedDate.wMinute = 25; expectedDate.wSecond = 0; expectedDate.wMilliseconds = 0; assertEquals(GetDateTimeString(&expectedDate), visitor[_T("Last save time")]); assertEquals(_T("pair"), visitor[_T("Last author")]); assertEquals(_T(""), visitor[_T("Revision number")]); assertEquals(_T(""), visitor[_T("Last print date")]); assertEquals(_T(""), visitor[_T("Total editing time")]); }
void MonitorDataLogger::setConfig(bool bLogData_in, unsigned int logEvery_in) { if (bLogData_in && !bLogData) { // generate the file name double t0 = CurrentTime_s(); QString sDir = "C:/data/SuperLaserLand/"; QString fileName = sDir + QString::fromStdString(GetDateTimeString(t0)) + ".csv"; // Set up the file logFile.setFileName(fileName); if (logFile.open(QIODevice::WriteOnly | QIODevice::Text)) { printf("Starting log file %s\n", fileName.toLatin1().constData()); logTextStream.setDevice(&logFile); logTextStream << "TIME [s], "; for (int i = 0; i < 7; i ++) { logTextStream << channelNames->value(i); if (i < 6) logTextStream << ", "; } logTextStream << "\n"; logTextStream.flush(); bLogData = true; logEvery = logEvery_in; logCounter = 0; timer.restart(); } else { printf("Cannot open log file %s\n", fileName.toLatin1().constData()); } } else { bLogData = false; logFile.close(); } }
static error_status_t Transfer( char *Filename,byte_pipe *data) { HANDLE hFile; byte pcBuffer[MAX_BUFFER_SIZE]; // Buffer to store the elements in DWORD transferred; unsigned long nActualTransferCount; // Actual number of elements received BOOL bDone = FALSE; // Inidicates when the pipe is done //DWORD transferred,res ; DWORD res=RPC_S_OK; hFile = CreateFile((const char*)&(Filename[0]),GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0); if(hFile == INVALID_HANDLE_VALUE) { DBG("CreateFile(\"Filename\") failed\n"); res = GetLastError(); return res; } char DateTime[25]; DBG(GetDateTimeString(DateTime)<<": Transferring file "<<Filename); while(FALSE == bDone) { data->pull( // Grab a chunck of data from the client data->state, // Pointer to the state pcBuffer, // Buffer to put data in MAX_BUFFER_SIZE/sizeof(byte), // Max number of elements to receive &nActualTransferCount); // Actual number of elements received // A data transfer count of 0 means the end of the pipe if(nActualTransferCount == 0) { bDone = TRUE; } else { if(!WriteFile(hFile,pcBuffer,nActualTransferCount,&transferred,0)) { res = GetLastError(); CloseHandle(hFile); DeleteFile((const char*)&(Filename[0])); DBG("WriteFile() failed ("<<res<<")") return res; } } }
void TimerThread( void ) { char date[80]; char_info *clk; while( !exit_thread ) { Sleep( 55 ); ClockTicks++; if( EditFlags.ClockActive && EditFlags.SpinningOurWheels && EditFlags.Spinning ) { (*(char_info *)SpinLoc).ch = SpinData[SpinCount]; MyVioShowBuf( SpinLoc-Scrn, 1 ); SpinCount++; if( SpinCount >= 4 ) { SpinCount = 0; } } if( (ClockTicks % 9) != 0 ) { continue; } GetDateTimeString( date ); if( EditFlags.ClockActive && EditFlags.Clock ) { int bytes = 5; clk = (char_info *) ClockStart; if( EditFlags.DisplaySeconds ) { clk[7].ch = date[DATE_LEN - 1]; clk[6].ch = date[DATE_LEN - 2]; clk[5].ch = ':'; bytes = 8; } clk[4].ch = date[DATE_LEN - 4]; clk[3].ch = date[DATE_LEN - 5]; clk[2].ch = ':'; clk[1].ch = date[DATE_LEN - 7]; clk[0].ch = date[DATE_LEN - 8]; MyVioShowBuf( ClockStart - Scrn, bytes ); } } ExitThread( 0 ); }
/* * finiSourceErrFile - close up error file */ static void finiSourceErrFile( char *fn ) { char drive[_MAX_DRIVE], directory[_MAX_DIR], name[_MAX_FNAME]; char path[FILENAME_MAX]; char tmp[MAX_SRC_LINE]; if( !EditFlags.CompileScript ) { return; } _splitpath( fn, drive, directory, name, NULL ); _makepath( path, drive, directory, name, ".err" ); remove( path ); if( srcErrFile != NULL ) { GetDateTimeString( tmp ); MyFprintf( srcErrFile, "\nCompile of %s finished on %s\n", fn, tmp ); MyFprintf( srcErrFile, "%d errors encountered\n", SourceErrCount ); fclose( srcErrFile ); srcErrFile = NULL; rename( srcErrFileName, path ); } } /* finiSourceErrFile */
/* * UpdateStatusWindow - update the status window */ void UpdateStatusWindow( void ) { char *str, *ptr; char result[5 * MAX_STR]; char *res; int digits; long num; bool use_num; int line; char numstr[12]; int format; char c; if( BAD_ID( status_window_id ) || EditFlags.DisplayHold || EditFlags.Quiet || !EditFlags.StatusInfo || EditVars.StatusString == NULL ) { return; } res = result; line = 1; format = FMT_LEFT; EditFlags.ModeInStatusLine = false; for( str = EditVars.StatusString; (c = *str) != '\0'; ++str ) { if( c == '$' ) { str++; ptr = str; while( isdigit( *str ) ) { str++; } if( ptr != str ) { digits = strtoul( ptr, NULL, 10 ); } else { digits = 0; } use_num = false; num = 0; c = *str; if( c == '\0' ) break; switch( c ) { case '$': *res++ = '$'; break; case 'c': *res++ = ','; break; case 'n': *res = 0; StatusLine( line, result, format ); res = result; line++; break; case 'L': num = CurrentPos.line; use_num = true; break; case 'C': num = VirtualColumnOnCurrentLine( CurrentPos.column ); use_num = true; break; case 'D': #ifdef __WIN__ GetDateString( res ); #else GetDateTimeString( res ); #endif res += strlen( res ); break; case 'T': GetTimeString( res ); res += strlen( res ); break; case 'M': /* print the desired mode */ EditFlags.ModeInStatusLine = true; GetModeString( res ); res += strlen( res ); break; #ifdef __WIN__ case 'H': GetMenuHelpString( res ); res += strlen( res ); break; case '[': *res++ = STATUS_ESC_CHAR; *res++ = STATUS_NEXT_BLOCK; break; case '|': *res++ = STATUS_ESC_CHAR; *res++ = STATUS_FORMAT_CENTER; break; case '>': *res++ = STATUS_ESC_CHAR; *res++ = STATUS_FORMAT_RIGHT; break; case '<': *res++ = STATUS_ESC_CHAR; *res++ = STATUS_FORMAT_LEFT; break; #else case '|': format = FMT_CENTRE; break; case '>': format = FMT_RIGHT; break; case '<': format = FMT_LEFT; break; #endif } if( use_num ) { ltoa( num, numstr, 10 ); digits -= strlen( numstr ); while( digits > 0 ) { *res++ = ' '; digits--; } ptr = numstr; while( *ptr != '\0' ) { *res++ = *ptr++; } } } else { *res++ = c; } } *res = 0; if( res != result ) { StatusLine( line, result, format ); } } /* UpdateStatusWindow */
/* * GenerateConfiguration - write out a config file */ vi_rc GenerateConfiguration( const char *fname, bool is_cmdline ) { FILE *fp; int i; char token[128]; const char *str; char *buff; int num; rgb c; const char *res; char tmpstr[MAX_STR]; if( fname == NULL ) { fname = CFG_NAME; } fp = fopen( fname, "w" ); if( fp == NULL ) { return( ERR_FILE_OPEN ); } isCmdLine = is_cmdline; buff = MemAllocUnsafe( VBUF_SIZE ); if( buff != NULL ) { setvbuf( fp, buff, _IOFBF, VBUF_SIZE ); } MyFprintf( fp, "#\n# %s configuration file\n# %s\n#\n", #if defined( __WIN__ ) banner1w1( "Text Editor for Windows" ), banner1w2( _VI_VERSION_ ) ); #else banner1w1( "Vi Text Editor" ), banner1w2( _VI_VERSION_ ) ); #endif if( is_cmdline ) { GetDateTimeString( token ); MyFprintf( fp, "# File generated on %s\n#\n", token ); } writeTitle( fp, "Hook script assignments" ); doHookAssign( fp, SRC_HOOK_WRITE ); doHookAssign( fp, SRC_HOOK_READ ); doHookAssign( fp, SRC_HOOK_BUFFIN ); doHookAssign( fp, SRC_HOOK_BUFFOUT ); doHookAssign( fp, SRC_HOOK_COMMAND ); doHookAssign( fp, SRC_HOOK_MODIFIED ); doHookAssign( fp, SRC_HOOK_MENU ); doHookAssign( fp, SRC_HOOK_MOUSE_LINESEL ); doHookAssign( fp, SRC_HOOK_MOUSE_CHARSEL ); writeTitle( fp, "General Settings" ); num = GetNumberOfTokens( SetVarTokens ); for( i = 0; i < num; i++ ) { if( i == SETVAR_T_TILECOLOR || i == SETVAR_T_FIGNORE || i == SETVAR_T_FILENAME ) { continue; } res = GetASetVal( GetTokenStringCVT( SetVarTokens, i, token, true ), tmpstr ); switch( i ) { case SETVAR_T_STATUSSTRING: case SETVAR_T_FILEENDSTRING: case SETVAR_T_HISTORYFILE: case SETVAR_T_TMPDIR: /* strings with possible spaces */ MyFprintf( fp, "set %s = \"%s\"\n", token, res ); break; case SETVAR_T_GADGETSTRING: if( !IsGadgetStringChanged( res ) ) break; // fall through default: MyFprintf( fp, "set %s = %s\n", token, res ); break; } } writeTitle( fp, "Boolean Settings" ); num = GetNumberOfTokens( SetFlagTokens ); for( i = 0; i < num; i++ ) { str = GetASetVal( GetTokenStringCVT( SetFlagTokens, i, token, true ), tmpstr ); MyFprintf( fp, "set %s%s\n", (*str == '0') ? "no" : "", token ); } writeTitle( fp, "Match pairs" ); for( i = INITIAL_MATCH_COUNT; i < MatchCount; i += 2 ) { MyFprintf( fp, "match /" ); outputMatchData( fp, MatchData[i] ); outputMatchData( fp, MatchData[i + 1] ); MyFprintf( fp, "\n" ); } writeTitle( fp, "Command Mode Mappings" ); doMaps( fp, KeyMaps, "" ); writeTitle( fp, "Insert Mode Mappings" ); doMaps( fp, InputKeyMaps, "!" ); writeTitle( fp, "Color Settings" ); for( i = 0; i < GetNumColors(); i++ ) { if( GetColorSetting( i, &c ) ) { MyFprintf( fp, "setcolor %d %d %d %d\n", i, c.red, c.green, c.blue ); } } #ifdef __WIN__ writeTitle( fp, "Font Settings" ); BarfFontData( fp ); #endif writeTitle( fp, "Window Configuration" ); doWindow( fp, PCL_T_COMMANDWINDOW, &cmdlinew_info, false ); doWindow( fp, PCL_T_STATUSWINDOW, &statusw_info, false ); doWindow( fp, PCL_T_COUNTWINDOW, &repcntw_info, false ); doWindow( fp, PCL_T_EDITWINDOW, &editw_info, false ); doWindow( fp, PCL_T_FILECWINDOW, &filecw_info, false ); doWindow( fp, PCL_T_DIRWINDOW, &dirw_info, false ); doWindow( fp, PCL_T_FILEWINDOW, &filelistw_info, false ); doWindow( fp, PCL_T_MESSAGEWINDOW, &messagew_info, false ); #ifndef __WIN__ doWindow( fp, PCL_T_SETWINDOW, &setw_info, false ); doWindow( fp, PCL_T_LINENUMBERWINDOW, &linenumw_info, false ); doWindow( fp, PCL_T_EXTRAINFOWINDOW, &extraw_info, false ); doWindow( fp, PCL_T_SETVALWINDOW, &setvalw_info, false ); doWindow( fp, PCL_T_MENUWINDOW, &menuw_info, false ); doWindow( fp, PCL_T_MENUBARWINDOW, &menubarw_info, true ); doWindow( fp, PCL_T_ACTIVEMENUWINDOW, &activemenu_info, true ); doWindow( fp, PCL_T_GREYEDMENUWINDOW, &greyedmenu_info, true ); doWindow( fp, PCL_T_ACTIVEGREYEDMENUWINDOW, &activegreyedmenu_info, true ); #endif writeTitle( fp, "Menu Configuration" ); BarfMenuData( fp ); #ifdef __WIN__ writeTitle( fp, "ToolBar Configuration" ); BarfToolBarData( fp ); #endif writeTitle( fp, "File Type Source" ); FTSBarfData( fp ); fclose( fp ); if( is_cmdline ) { Message1( "Configuration file \"%s\" generated", fname ); } MemFree( buff ); return( DO_NOT_CLEAR_MESSAGE_WINDOW ); } /* GenerateConfiguration */
DWORD __cdecl main(int argc, char* argv[]) { DHCP_RESUME_HANDLE ResumeHandle = 0; LPDHCPV6_IP_ARRAY EnumScopesV6 = NULL; DWORD nReadV6 = 0, nTotalV6 = 0; DHCP_RESUME_IPV6_HANDLE ResumeHandleV6 = {0,0}; LPDHCP_CLIENT_INFO_ARRAY_V6 ClientsV6 = NULL; DWORD nClientsReadV6 = 0, nClientsTotalV6 = 0; DWORD error1 = ERROR_SUCCESS, error2 = ERROR_SUCCESS; WCHAR *szDateTimeStr = NULL, *szDuid = NULL, *szClientIp = NULL, *szScopeIp = NULL; WCHAR szServer[SERVERNAME_BUF_SIZE] = {0}; if (2 != argc) { wprintf(L"Usage: DhcpServerShowLeasesV6.exe <Server IpAdd/Name>"); return ERROR_INVALID_PARAMETER; } MultiByteToWideChar(0, 0, argv[1], (int)strlen(argv[1]), szServer, SERVERNAME_BUF_SIZE); do { // enumerate all the IpV6 scopes on the server. error1 = DhcpEnumSubnetsV6(szServer, &ResumeHandle, (DWORD)~0, &EnumScopesV6, &nReadV6, &nTotalV6); if (0 == nTotalV6) { wprintf(L"No scopes on this server.\n"); } if (ERROR_NO_MORE_ITEMS == error1) // there are no IpV6 scopes { break; } if (ERROR_SUCCESS != error1 && ERROR_MORE_DATA != error1) { wprintf(L"DhcpServerShowLeasesV6 returned with error: %d\n",error1); return error1; } // iterating over all the scopes one by one to get the clients for each scope. for (unsigned int count=0; count < EnumScopesV6->NumElements; count++) { // converting scope IP address from DHCP_IPV6_ADDRESS to LPWSTR szScopeIp = ConvertIpV6AddtoWstr(EnumScopesV6->Elements[count]); wprintf(L"\nScope : %s\n\n", szScopeIp ? szScopeIp : L" "); do { // enumerating the clients on a specific IpV6 scope //the leases shown include all the leases present and can be filtered out on the basic of Address State attribute of client. error2 = DhcpEnumSubnetClientsV6(szServer, EnumScopesV6->Elements[count], &ResumeHandleV6, (DWORD)~0, &ClientsV6, &nClientsReadV6, &nClientsTotalV6); if (0 == nClientsTotalV6) { wprintf(L"No clients on this scope.\n"); } if (ERROR_NO_MORE_ITEMS == error2) { break; } if (ERROR_SUCCESS != error2 && ERROR_MORE_DATA != error2) { wprintf(L"DhcpServerShowLeasesV6 returned with error: %d\n",error2); return error2; } //iterating over all the clients on a speicified scope. for (unsigned int count = 0; count < ClientsV6->NumElements; count++) { //converting client Ip from DHCP_IPV6_ADDRESS to LPWSTR szClientIp = ConvertIpV6AddtoWstr(ClientsV6->Clients[count]->ClientIpAddress); wprintf(L"ClientAddress : %s\n",szClientIp ? szClientIp : L" "); //converting client DUID from byte * to LPWSTR szDuid = GetHardwareAddress(ClientsV6->Clients[count]->ClientDUID); wprintf(L"DUID : %s\n",szDuid ? szDuid : L" "); wprintf(L"IAID : %d\n",ClientsV6->Clients[count]->IAID); // if lease duration is infinite then lease never expires. if (DHCP_DATE_TIME_INFINITE_LOW == ClientsV6->Clients[count]->ClientValidLeaseExpires.dwLowDateTime && DHCP_DATE_TIME_INFINITE_HIGH == ClientsV6->Clients[count]->ClientValidLeaseExpires.dwHighDateTime) { wprintf(L"Lease Expires : Never\n\n"); } // if lease duration is 0 the client is inactive. else if (DHCP_DATE_TIME_ZERO_LOW == ClientsV6->Clients[count]->ClientValidLeaseExpires.dwLowDateTime && DHCP_DATE_TIME_ZERO_HIGH == ClientsV6->Clients[count]->ClientValidLeaseExpires.dwHighDateTime) { wprintf(L"Lease Expires : Inactive\n\n"); } else { // converting the date time information from FILETIME * to LPWSTR. szDateTimeStr = GetDateTimeString(*(FILETIME *)(&ClientsV6->Clients[count]->ClientValidLeaseExpires)); wprintf(L"Lease Expires : %s\n\n", szDateTimeStr ? szDateTimeStr : L" "); } if (NULL != szClientIp) { free(szClientIp); szClientIp = NULL; } if (NULL != szDuid) { free(szDuid); szDuid = NULL; } if (NULL != szDateTimeStr) { free(szDateTimeStr); szDateTimeStr = NULL; } } if (NULL != ClientsV6) { DhcpRpcFreeMemory(ClientsV6); ClientsV6 = NULL; } nClientsReadV6 = 0; nClientsTotalV6 = 0; } while (ERROR_MORE_DATA == error2); if (NULL != szScopeIp) { free(szScopeIp); szScopeIp = NULL; } } nReadV6 = 0; nTotalV6 = 0; if (NULL != EnumScopesV6) { DhcpRpcFreeMemory(EnumScopesV6); EnumScopesV6 = NULL; } } while (ERROR_MORE_DATA == error1); return 0; }
/* * 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 */
int main(int argc, char **argv) { int i; char ts[50]; //timestring int cc; //current counter (9S08QG8) int hc[4]; //hour counter (9S08QG8) char tv[2]; //temperatur value (LM75) if(argc == 2){ if(strncmp(argv[1],"-V",2) == 0){ verbose_max = true; verbose = true; }else if(strncmp(argv[1],"-v",2) == 0){ verbose = true; }else if(strncmp(argv[1],"-r",2) == 0){ readtest = true; }else if(strncmp(argv[1],"-w",2) == 0){ writetest = true; }else if(strncmp(argv[1],"-c",2) == 0){ verbose = true; calibrate_9s08 = true; }else if(strncmp(argv[1],"-d",2) == 0){ ValueToDatabase(false,"2015-07-23 00:00:00",1,2,3,10,11,12,13); }else if(strncmp(argv[1],"-t",2) == 0){ verbose = true; ThreadPowerOff(); return(0); }else if(strncmp(argv[1],"-T",2) == 0){ //verbose_max = true; verbose = true; restoredata_9S08 = true; } }else if(argc == 4){ if(strncmp(argv[1],"-p",2) == 0){ printf("v1: %s\n",argv[1]); printf("v2: %s\n",argv[2]); printf("v3: %s\n",argv[3]); if(strncmp(argv[2],"1",1) == 0){ int val = atoi(argv[3]); printf("val: %d\n",val); SetPWM(1,val); }else if(strncmp(argv[2],"2",1) == 0){ int val = atoi(argv[3]); SetPWM(2,val); } return(0); } } if(readtest){ ReadTest(); return(0); } if(writetest){ WriteTest(); return(0); } if(calibrate_9s08){ Calibrate9s08(); return(0); } if(restoredata_9S08){ BackupValueFromDatabase(&cc,&hc[0],&hc[1],&hc[2],&hc[3]); SetCounterValue_MC9S08QG8(cc); if(verbose){ printf("counter: %d\n",cc); } for(i=0;i<4;i++){ SetHourCounterValue_MC9S08QG8(i,hc[i]); if(verbose){ printf("hourcounter [%d]: %d\n",i,hc[i]); } } return(0); } strcpy(ts,GetDateTimeString()); if(verbose){ printf("Uhrzeit: %s\n",ts); } cc = GetCounterValue_MC9S08QG8(); if(verbose){ printf("counter: %d\n",cc); } for(i=0;i<4;i++){ hc[i] = GetHourCounterValue_MC9S08QG8(i); if(verbose){ printf("hourcounter [%d]: %d\n",i,hc[i]); } } for(i=0;i<2;i++){ tv[i] = GetTemperaturValue_LM75_8Bit(i); if(verbose){ printf("LM75.%d temperature: %d\n",i,tv[i]); } } ValueToDatabase(false,ts,cc,tv[0],tv[1],hc[0],hc[1],hc[2],hc[3]); return(0); }
/* * GenerateConfiguration - write out a config file */ vi_rc GenerateConfiguration( char *fname, bool is_cmdline ) { FILE *f; int i; char token[128]; char *str; char boolstr[3]; char *buff; int num; rgb c; char *fmt; char *res; if( fname == NULL ) { fname = CFG_NAME; } f = fopen( fname, "w" ); if( f == NULL ) { return( ERR_FILE_OPEN ); } isCmdLine = is_cmdline; buff = MemAllocUnsafe( VBUF_SIZE ); if( buff != NULL ) { setvbuf( f, buff, _IOFBF, VBUF_SIZE ); } MyFprintf( f, "#\n# WATCOM %s %s configuration file\n# %s\n#\n", TITLE, VERSIONT, AUTHOR ); if( is_cmdline ) { GetDateTimeString( token ); MyFprintf( f, "# File generated on %s\n#\n", token ); } writeTitle( f, "Hook script assignments" ); doHookAssign( f, SRC_HOOK_WRITE ); doHookAssign( f, SRC_HOOK_READ ); doHookAssign( f, SRC_HOOK_BUFFIN ); doHookAssign( f, SRC_HOOK_BUFFOUT ); doHookAssign( f, SRC_HOOK_COMMAND ); doHookAssign( f, SRC_HOOK_MODIFIED ); doHookAssign( f, SRC_HOOK_MENU ); doHookAssign( f, SRC_HOOK_MOUSE_LINESEL ); doHookAssign( f, SRC_HOOK_MOUSE_CHARSEL ); writeTitle( f, "General Settings" ); num = GetNumberOfTokens( SetTokens1 ); for( i = 0; i < num; i++ ) { if( i == SET1_T_TILECOLOR || i == SET1_T_FIGNORE || i == SET1_T_FILENAME ) { continue; } strcpy( token, GetTokenString( SetTokens1, i ) ); strlwr( token ); res = GetASetVal( token ); if( i == SET1_T_STATUSSTRING || i == SET1_T_FILEENDSTRING || i == SET1_T_HISTORYFILE || i == SET1_T_TMPDIR ) { /* strings with possible spaces */ fmt = "set %s = \"%s\"\n"; } else { fmt = "set %s = %s\n"; } MyFprintf( f, fmt, token, res ); } writeTitle( f, "Boolean Settings" ); num = GetNumberOfTokens( SetTokens2 ); for( i = 0; i < num; i++ ) { strcpy( token, GetTokenString( SetTokens2, i ) ); strlwr( token ); str = GetASetVal( token ); boolstr[0] = 0; if( str[0] == '0' ) { boolstr[0] = 'n'; boolstr[1] = 'o'; boolstr[2] = 0; } MyFprintf( f, "set %s%s\n", boolstr, token ); } writeTitle( f, "Match pairs" ); for( i = INITIAL_MATCH_COUNT; i < MatchCount; i += 2 ) { MyFprintf( f, "match /" ); outputMatchData( f, MatchData[i] ); outputMatchData( f, MatchData[i + 1] ); MyFprintf( f, "\n" ); } writeTitle( f, "Command Mode Mappings" ); doMaps( f, KeyMaps, "" ); writeTitle( f, "Insert Mode Mappings" ); doMaps( f, InputKeyMaps, "!" ); writeTitle( f, "Color Settings" ); for( i = 0; i < GetNumColors(); i++ ) { if( GetColorSetting( i, &c ) ) { MyFprintf( f, "setcolor %d %d %d %d\n", i, c.red, c.green, c.blue ); } } #ifdef __WIN__ writeTitle( f, "Font Settings" ); BarfFontData( f ); #endif writeTitle( f, "Window Configuration" ); doWindow( f, PCL_T_COMMANDWINDOW, &cmdlinew_info, FALSE ); doWindow( f, PCL_T_STATUSWINDOW, &statusw_info, FALSE ); doWindow( f, PCL_T_COUNTWINDOW, &repcntw_info, FALSE ); doWindow( f, PCL_T_EDITWINDOW, &editw_info, FALSE ); doWindow( f, PCL_T_FILECWINDOW, &filecw_info, FALSE ); doWindow( f, PCL_T_DIRWINDOW, &dirw_info, FALSE ); doWindow( f, PCL_T_FILEWINDOW, &filelistw_info, FALSE ); doWindow( f, PCL_T_MESSAGEWINDOW, &messagew_info, FALSE ); #ifndef __WIN__ doWindow( f, PCL_T_SETWINDOW, &setw_info, FALSE ); doWindow( f, PCL_T_LINENUMBERWINDOW, &linenumw_info, FALSE ); doWindow( f, PCL_T_EXTRAINFOWINDOW, &extraw_info, FALSE ); doWindow( f, PCL_T_SETVALWINDOW, &setvalw_info, FALSE ); doWindow( f, PCL_T_MENUWINDOW, &menuw_info, FALSE ); doWindow( f, PCL_T_MENUBARWINDOW, &menubarw_info, TRUE ); doWindow( f, PCL_T_ACTIVEMENUWINDOW, &activemenu_info, TRUE ); doWindow( f, PCL_T_GREYEDMENUWINDOW, &greyedmenu_info, TRUE ); doWindow( f, PCL_T_ACTIVEGREYEDMENUWINDOW, &activegreyedmenu_info, TRUE ); #endif writeTitle( f, "Menu Configuration" ); BarfMenuData( f ); #ifdef __WIN__ writeTitle( f, "ToolBar Configuration" ); BarfToolBarData( f ); #endif writeTitle( f, "File Type Source" ); FTSBarfData( f ); fclose( f ); if( is_cmdline ) { Message1( "Configuration file \"%s\" generated", fname ); } MemFree( buff ); return( DO_NOT_CLEAR_MESSAGE_WINDOW ); } /* GenerateConfiguration */
/** * @param strLogText - error log text. */ void CExpressModeDlg::GetErrorLog(CString& strLogText) { strLogText.Empty(); if (! m_pXMLElementDocument) return; HRESULT hRes; static const TCHAR szDividerMsg[] = _T("----------------------------------------\r\n"); static const TCHAR szNewLine[] = _T("\r\n"); CString strApplication; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./application"), strApplication); if (! strApplication.IsEmpty()) { static const TCHAR szAppMsg[] = _T("Application: "); strLogText += szAppMsg; strLogText += strApplication; strLogText += szNewLine; } CString strVersion; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./version"), strVersion); if (! strVersion.IsEmpty()) { static const TCHAR szVersionMsg[] = _T("Version: "); strLogText += szVersionMsg; strLogText += strVersion; strLogText += szNewLine; } CString strComputer; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./computer"), strComputer); if (! strComputer.IsEmpty()) { static const TCHAR szComputerNameMsg[] = _T("Computer: "); strLogText += szComputerNameMsg; strLogText += strComputer; strLogText += szNewLine; } CString strUser; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./user"), strUser); if (! strUser.IsEmpty()) { static const TCHAR szUserNameMsg[] = _T("User: "******"./timestamp"), strTimeStamp); if (! strTimeStamp.IsEmpty()) { ULONGLONG uiTimeStamp = _tcstoui64(strTimeStamp, NULL, 0); if (uiTimeStamp != 0) { GetDateTimeString(uiTimeStamp, strTimeStamp); if (! strTimeStamp.IsEmpty()) { static const TCHAR szDateTimeMsg[] = _T("Date: "); strLogText += szDateTimeMsg; strLogText += strTimeStamp; strLogText += szNewLine; } } } CString strErrorReason; GetErrorReason(strErrorReason); if (! strErrorReason.IsEmpty()) { static const TCHAR szErrorMsg[] = _T("\r\nError Reason:\r\n"); strLogText += szErrorMsg; strLogText += szDividerMsg; strLogText += strErrorReason; } CString strUserMessage; if (GetXMLNodeText(m_pXMLElementDocument, OLESTR("./usermsg"), strUserMessage) && ! strUserMessage.IsEmpty()) { static const TCHAR szUserMsg[] = _T("\r\n\r\nUser Message:\r\n"); strLogText += szUserMsg; strLogText += szDividerMsg; strLogText += strUserMessage; } CComPtr<IXMLDOMNode> pXMLNodeSysError; if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./syserror"), pXMLNodeSysError)) { CString strSysErrorCode; GetXMLNodeText(pXMLNodeSysError, OLESTR("./code"), strSysErrorCode); if (! strSysErrorCode.IsEmpty()) { static const TCHAR szSysErrorMsg[] = _T("\r\n\r\nSystem Error:\r\n"); strLogText += szSysErrorMsg; strLogText += szDividerMsg; strLogText += strSysErrorCode; CString strSysErrorDescription; GetXMLNodeText(pXMLNodeSysError, OLESTR("./description"), strSysErrorDescription); if (! strSysErrorDescription.IsEmpty()) { strLogText += _T(" - "); strLogText += strSysErrorDescription; } } } CComPtr<IXMLDOMNode> pXMLNodeComError; if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./comerror"), pXMLNodeComError)) { CString strComErrorDescription; GetXMLNodeText(pXMLNodeComError, OLESTR("./description"), strComErrorDescription); CString strComErrorHelpFile; GetXMLNodeText(pXMLNodeComError, OLESTR("./helpfile"), strComErrorHelpFile); CString strComErrorSource; GetXMLNodeText(pXMLNodeComError, OLESTR("./source"), strComErrorSource); CString strComErrorGuid; GetXMLNodeText(pXMLNodeComError, OLESTR("./guid"), strComErrorGuid); if (! strComErrorDescription.IsEmpty() || ! strComErrorHelpFile.IsEmpty() || ! strComErrorSource.IsEmpty() || ! strComErrorGuid.IsEmpty()) { static const TCHAR szCOMErrorMsg[] = _T("\r\n\r\nCOM Error:\r\n"); static const TCHAR szDescriptionMsg[] = _T("Description: "); static const TCHAR szHelpFileMsg[] = _T("Help File: "); static const TCHAR szSourceMsg[] = _T("Source: "); static const TCHAR szGuidMsg[] = _T("GUID: "); strLogText += szCOMErrorMsg; strLogText += szDividerMsg; BOOL bNotEmpty = FALSE; if (! strComErrorDescription.IsEmpty()) { bNotEmpty = TRUE; strLogText += szDescriptionMsg; strLogText += strComErrorDescription; } if (! strComErrorHelpFile.IsEmpty()) { if (bNotEmpty) strLogText += szNewLine; else bNotEmpty = TRUE; strLogText += szHelpFileMsg; strLogText += strComErrorHelpFile; } if (! strComErrorSource.IsEmpty()) { if (bNotEmpty) strLogText += szNewLine; else bNotEmpty = TRUE; strLogText += szSourceMsg; strLogText += strComErrorSource; } if (! strComErrorGuid.IsEmpty()) { if (bNotEmpty) strLogText += szNewLine; else bNotEmpty = TRUE; strLogText += szGuidMsg; strLogText += strComErrorGuid; } } } CComPtr<IXMLDOMNode> pXMLNodeRegisters; if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./registers"), pXMLNodeRegisters)) { static const TCHAR szRegistersMsg[] = _T("\r\n\r\nRegisters:\r\n"); CString strRegValue; switch (GetPlatform()) { case TPLAT_X86: { GetXMLNodeText(pXMLNodeRegisters, OLESTR("./eax"), strRegValue); DWORD dwEAX = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ebx"), strRegValue); DWORD dwEBX = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ecx"), strRegValue); DWORD dwECX = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./edx"), strRegValue); DWORD dwEDX = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./esi"), strRegValue); DWORD dwESI = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./edi"), strRegValue); DWORD dwEDI = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./esp"), strRegValue); DWORD dwESP = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ebp"), strRegValue); DWORD dwEBP = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./eip"), strRegValue); DWORD dwEIP = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./cs"), strRegValue); DWORD dwCS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ds"), strRegValue); DWORD dwDS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ss"), strRegValue); DWORD dwSS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./es"), strRegValue); DWORD dwES = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./fs"), strRegValue); DWORD dwFS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./gs"), strRegValue); DWORD dwGS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./eflags"), strRegValue); DWORD dwEFLAGS = _tcstoul(strRegValue, NULL, 0); strRegValue.Format( _T("EAX=%08X EBX=%08X ECX=%08X EDX=%08X\r\n") _T("ESI=%08X EDI=%08X FLG=%08X\r\n") _T("EBP=%08X ESP=%08X EIP=%08X\r\n") _T("CS=%04X DS=%04X SS=%04X ES=%04X FS=%04X GS=%04X"), dwEAX, dwEBX, dwECX, dwEDX, dwESI, dwEDI, dwEFLAGS, dwEBP, dwESP, dwEIP, dwCS, dwDS, dwSS, dwES, dwFS, dwGS); } break; case TPLAT_X64: { GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rax"), strRegValue); DWORD dwRAX = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rbx"), strRegValue); DWORD dwRBX = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rcx"), strRegValue); DWORD dwRCX = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rdx"), strRegValue); DWORD dwRDX = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rsi"), strRegValue); DWORD dwRSI = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rdi"), strRegValue); DWORD dwRDI = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rsp"), strRegValue); DWORD dwRSP = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rbp"), strRegValue); DWORD dwRBP = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rip"), strRegValue); DWORD dwRIP = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./cs"), strRegValue); DWORD dwCS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ds"), strRegValue); DWORD dwDS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ss"), strRegValue); DWORD dwSS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./es"), strRegValue); DWORD dwES = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./fs"), strRegValue); DWORD dwFS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./gs"), strRegValue); DWORD dwGS = _tcstoul(strRegValue, NULL, 0); GetXMLNodeText(pXMLNodeRegisters, OLESTR("./eflags"), strRegValue); DWORD dwEFLAGS = _tcstoul(strRegValue, NULL, 0); strRegValue.Format( _T("RAX=%016X RBX=%016X\r\n") _T("RCX=%016X RDX=%016X\r\n") _T("RSI=%016X RDI=%016X\r\n") _T("FLG=%08X RBP=%016X\r\n") _T("RSP=%016X RIP=%016X\r\n") _T("CS=%04X DS=%04X SS=%04X ES=%04X FS=%04X GS=%04X"), dwRAX, dwRBX, dwRCX, dwRDX, dwRSI, dwRDI, dwEFLAGS, dwRBP, dwRSP, dwRIP, dwCS, dwDS, dwSS, dwES, dwFS, dwGS); } break; default: _ASSERT(FALSE); } strLogText += szRegistersMsg; strLogText += szDividerMsg; strLogText += strRegValue; } CComPtr<IXMLDOMNode> pXMLNodeCpus; if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./cpus"), pXMLNodeCpus)) { CString strNumCpus; GetXMLNodeText(pXMLNodeCpus, OLESTR("./number"), strNumCpus); if (! strNumCpus.IsEmpty() && _tcstoul(strNumCpus, NULL, 0) != 0) { static const TCHAR szCpuMsg[] = _T("\r\n\r\nCPU:\r\n"); static const TCHAR szArchitectureMsg[] = _T("Architecture: "); static const TCHAR szNumCpusMsg[] = _T("Number of Processors: "); static const TCHAR szCpuDescriptionsMsg[] = _T("\r\nProcessors Descriptions:"); strLogText += szCpuMsg; strLogText += szDividerMsg; CString strArchitecture; GetXMLNodeText(pXMLNodeCpus, OLESTR("./architecture"), strArchitecture); if (! strArchitecture.IsEmpty()) { strLogText += szArchitectureMsg; strLogText += strArchitecture; strLogText += szNewLine; } strLogText += szNumCpusMsg; strLogText += strNumCpus; strLogText += szCpuDescriptionsMsg; CString strCpuDescription; CComPtr<IXMLDOMNodeList> pXMLNodeListCpus; if (SelectXMLNodes(pXMLNodeCpus, OLESTR("./cpu"), pXMLNodeListCpus)) { for (int iItemPos = 1; ; ++iItemPos) { CComPtr<IXMLDOMNode> pXMLNodeCpu; hRes = pXMLNodeListCpus->nextNode(&pXMLNodeCpu); CHECK_HRESULT(hRes); if (hRes != S_OK) break; GetXMLNodeText(pXMLNodeCpu, OLESTR("./description"), strCpuDescription); TCHAR szItemPos[16]; _itot_s(iItemPos, szItemPos, countof(szItemPos), 10); strLogText += szNewLine; strLogText += szItemPos; strLogText += _T(". "); strLogText += strCpuDescription; } } } } CComPtr<IXMLDOMNode> pXMLNodeOs; if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./os"), pXMLNodeOs)) { static const TCHAR szOSMsg[] = _T("\r\n\r\nOperating System:\r\n"); static const TCHAR szOsVersionMsg[] = _T("OS Version: "); static const TCHAR szBuildNumberMsg[] = _T("Build Number: "); CString strOsVersion; GetXMLNodeText(pXMLNodeOs, OLESTR("./version"), strOsVersion); CString strServicePack; GetXMLNodeText(pXMLNodeOs, OLESTR("./spack"), strServicePack); CString strBuildNumber; GetXMLNodeText(pXMLNodeOs, OLESTR("./build"), strBuildNumber); strLogText += szOSMsg; strLogText += szDividerMsg; strLogText += szOsVersionMsg; strLogText += strOsVersion; if (! strServicePack.IsEmpty()) { strLogText += _T(' '); strLogText += strServicePack; } strLogText += szNewLine; strLogText += szBuildNumberMsg; strLogText += strBuildNumber; } CComPtr<IXMLDOMNode> pXMLNodeMemory; if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./memory"), pXMLNodeMemory)) { static const TCHAR szMemMsg[] = _T("\r\n\r\nMemory Usage:\r\n"); CString strMemValue; GetXMLNodeText(pXMLNodeMemory, OLESTR("./load"), strMemValue); DWORD dwCurMemLoad = _tcstoul(strMemValue, NULL, 0); GetXMLNodeText(pXMLNodeMemory, OLESTR("./totalphys"), strMemValue); DWORD dwTotalPhysMem = _tcstoul(strMemValue, NULL, 0); GetXMLNodeText(pXMLNodeMemory, OLESTR("./availphys"), strMemValue); DWORD dwAvailPhysMem = _tcstoul(strMemValue, NULL, 0); GetXMLNodeText(pXMLNodeMemory, OLESTR("./totalpage"), strMemValue); DWORD dwTotalPageMem = _tcstoul(strMemValue, NULL, 0); GetXMLNodeText(pXMLNodeMemory, OLESTR("./availpage"), strMemValue); DWORD dwAvailPageMem = _tcstoul(strMemValue, NULL, 0); strMemValue.Format( _T("Current Memory Load: %lu%%\r\n") _T("Total Physical Memory: %lu MB\r\n") _T("Available Physical Memory: %lu MB\r\n") _T("Total Page File Memory: %lu MB\r\n") _T("Available Page File Memory: %lu MB"), dwCurMemLoad, dwTotalPhysMem / (1024 * 1024), dwAvailPhysMem / (1024 * 1024), dwTotalPageMem / (1024 * 1024), dwAvailPageMem / (1024 * 1024)); strLogText += szMemMsg; strLogText += szDividerMsg; strLogText += strMemValue; } CStackEntry StackEntry; CComPtr<IXMLDOMNodeList> pXMLNodeListThreads; if (SelectXMLNodes(m_pXMLElementDocument, OLESTR("./threads/thread"), pXMLNodeListThreads)) { static const TCHAR szTraceMsg[] = _T("\r\nStack Trace: "); static const TCHAR szThreadIDMsg[] = _T(", TID: "); static const TCHAR szThreadMsg[] = _T(" Thread"); strLogText += szNewLine; CString strThreadID, strThreadStatus; for (;;) { CComPtr<IXMLDOMNode> pXMLNodeThread; hRes = pXMLNodeListThreads->nextNode(&pXMLNodeThread); CHECK_HRESULT(hRes); if (hRes != S_OK) break; GetXMLNodeText(pXMLNodeThread, OLESTR("./id"), strThreadID); GetXMLNodeText(pXMLNodeThread, OLESTR("./status"), strThreadStatus); if (! strThreadStatus.IsEmpty()) { strThreadStatus.MakeLower(); strThreadStatus.SetAt(0, (TCHAR)_totupper(strThreadStatus.GetAt(0))); strThreadStatus += szThreadMsg; } strLogText += szTraceMsg; strLogText += strThreadStatus; strLogText += szThreadIDMsg; strLogText += strThreadID; strLogText += szNewLine; strLogText += szDividerMsg; CComPtr<IXMLDOMNodeList> pXMLNodeListStackFrames; if (SelectXMLNodes(pXMLNodeThread, OLESTR("./stack/frame"), pXMLNodeListStackFrames)) { for (;;) { CComPtr<IXMLDOMNode> pXMLNodeStackFrame; hRes = pXMLNodeListStackFrames->nextNode(&pXMLNodeStackFrame); CHECK_HRESULT(hRes); if (hRes != S_OK) break; GetStackEntry(pXMLNodeStackFrame, StackEntry); if (! StackEntry.m_strModule.IsEmpty()) { strLogText += _T('\"'); strLogText += StackEntry.m_strModule; strLogText += _T('\"'); } if (! StackEntry.m_strAddress.IsEmpty()) { strLogText += _T(" at "); strLogText += StackEntry.m_strAddress; } if (! StackEntry.m_strFunctionInfo.IsEmpty()) { strLogText += _T(", "); strLogText += StackEntry.m_strFunctionInfo; } if (! StackEntry.m_strSourceFile.IsEmpty()) { strLogText += _T(" in "); strLogText += StackEntry.m_strSourceFile; } if (! StackEntry.m_strLineInfo.IsEmpty()) { strLogText += _T(", "); strLogText += StackEntry.m_strLineInfo; } strLogText += szNewLine; } } } } CString strCommandLine; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./cmdline"), strCommandLine); if (! strCommandLine.IsEmpty()) { static const TCHAR szCommandLineMsg[] = _T("\r\nCommand Line:\r\n"); strLogText += szCommandLineMsg; strLogText += szDividerMsg; strLogText += strCommandLine; } CString strCurrentDirectory; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./curdir"), strCurrentDirectory); if (! strCurrentDirectory.IsEmpty()) { static const TCHAR szCurrentDirMsg[] = _T("\r\n\r\nCurrent Directory:\r\n"); strLogText += szCurrentDirMsg; strLogText += szDividerMsg; strLogText += strCurrentDirectory; } CComPtr<IXMLDOMNodeList> pXMLNodeListEnvVars; if (SelectXMLNodes(m_pXMLElementDocument, OLESTR("./environment/variable"), pXMLNodeListEnvVars)) { static const TCHAR szEnvironmentMsg[] = _T("\r\n\r\nEnvironment Variables:\r\n"); strLogText += szEnvironmentMsg; strLogText += szDividerMsg; CString strVarName, strVarValue; for (;;) { CComPtr<IXMLDOMNode> pXMLNodeEnvVar; hRes = pXMLNodeListEnvVars->nextNode(&pXMLNodeEnvVar); CHECK_HRESULT(hRes); if (hRes != S_OK) break; GetXMLNodeText(pXMLNodeEnvVar, OLESTR("./name"), strVarName); GetXMLNodeText(pXMLNodeEnvVar, OLESTR("./value"), strVarValue); strLogText += strVarName; strLogText += _T('='); strLogText += strVarValue; strLogText += szNewLine; } } CComPtr<IXMLDOMNodeList> pXMLNodeListProcesses; if (SelectXMLNodes(m_pXMLElementDocument, OLESTR("./processes/process"), pXMLNodeListProcesses)) { static const TCHAR szProcessMsg[] = _T("\r\nProcess: "); static const TCHAR szModulesMsg[] = _T(", Modules:\r\n"); static const TCHAR szProcessIDMsg[] = _T(", PID: "); static const TCHAR szBaseMsg[] = _T(", Base: "); CString strProcessID, strProcessName, strModuleName, strModuleVersion, strModuleBase; for (;;) { CComPtr<IXMLDOMNode> pXMLNodeProcess; hRes = pXMLNodeListProcesses->nextNode(&pXMLNodeProcess); CHECK_HRESULT(hRes); if (hRes != S_OK) break; GetXMLNodeText(pXMLNodeProcess, OLESTR("./name"), strProcessName); GetXMLNodeText(pXMLNodeProcess, OLESTR("./id"), strProcessID); strLogText += szProcessMsg; strLogText += strProcessName; strLogText += szProcessIDMsg; strLogText += strProcessID; strLogText += szModulesMsg; strLogText += szDividerMsg; CComPtr<IXMLDOMNodeList> pXMLNodeListModules; if (SelectXMLNodes(pXMLNodeProcess, OLESTR("./modules/module"), pXMLNodeListModules)) { for (;;) { CComPtr<IXMLDOMNode> pXMLNodeModule; hRes = pXMLNodeListModules->nextNode(&pXMLNodeModule); CHECK_HRESULT(hRes); if (hRes != S_OK) break; GetXMLNodeText(pXMLNodeModule, OLESTR("./name"), strModuleName); GetXMLNodeText(pXMLNodeModule, OLESTR("./version"), strModuleVersion); GetXMLNodeText(pXMLNodeModule, OLESTR("./base"), strModuleBase); strLogText += strModuleName; if (! strModuleVersion.IsEmpty()) { strLogText += _T(" ("); strLogText += strModuleVersion; strLogText += _T(')'); } if (! strModuleBase.IsEmpty()) { PVOID ptrBaseAddress = (PVOID)_tcstoui64(strModuleBase, NULL, 0); if (ptrBaseAddress != NULL) { strModuleBase.Format(_T("%08lX"), ptrBaseAddress); strLogText += szBaseMsg; strLogText += strModuleBase; } } strLogText += szNewLine; } } } } }
static String GetTimeCode() {return GetDateTimeString("%H%M%S");}
static String GetDateCode() {return GetDateTimeString("%Y%m%d");}