size_t parse1::insert(const string & str){ string t_str = remove_white( remove_comments(str)); if (isLabel(t_str)) { makeSymbol(t_str); return linked_list.size(); }else if(is_at(t_str)){ makeSplit(t_str); return linked_list.size(); } if (t_str == "") { return linked_list.size();} else {linked_list.push_back(t_str);} return linked_list.size(); }
///////////////////////////////////////////////////////////////////// // // Function: // // Description: // ///////////////////////////////////////////////////////////////////// UINT CACCConfigMd5sum::OnExecution() { std::string strDataDirectory; std::string strInstallDirectory; std::string strLocation; char contents[8196]; UINT uiReturnValue = 0; TCHAR szMessage[16392]; FILE *file; memset(&contents,'\0',sizeof(contents)); SetProperty(_T("KEEPEXISTINGCONFIG"), _T("0")); uiReturnValue = GetProperty( _T("INSTALLDIR"), strInstallDirectory ); if ( uiReturnValue ) return uiReturnValue; if (strInstallDirectory.rfind('\\') != strInstallDirectory.size() - 1 ) { strInstallDirectory = strInstallDirectory + "\\"; _sntprintf(szMessage,sizeof(szMessage),_T("Added trailing slash to install dir"),strLocation.c_str()); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); } uiReturnValue = GetProperty( _T("DATADIR"), strDataDirectory ); if ( uiReturnValue ) return uiReturnValue; if (strDataDirectory.rfind('\\') != strDataDirectory.size() - 1 ) { strDataDirectory = strDataDirectory + "\\"; _sntprintf(szMessage,sizeof(szMessage),_T("Added trailing slash to data dir"),strLocation.c_str()); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); } // Figure out of the file is in the data directory or the install directory // it should be in the data directory, but if it isn't we will check the install directory strLocation = strDataDirectory + _T("cc_config.xml"); file = fopen(strLocation.c_str(),"r"); if ( file == NULL ) { _sntprintf(szMessage,sizeof(szMessage),_T("fopen: Error Message '%s': '%s'"),strerror(errno),strLocation.c_str()); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); strLocation = strInstallDirectory + _T("cc_config.xml"); file = fopen(strLocation.c_str(),"r"); if ( file == NULL ) { _sntprintf(szMessage,sizeof(szMessage),_T("fopen: Error Message '%s': '%s'"),strerror(errno),strLocation.c_str()); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); return ERROR_SUCCESS; } else { _sntprintf(szMessage,sizeof(szMessage),_T("fopen: File found at: '%s'"),strLocation.c_str()); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); } } else { _sntprintf(szMessage,sizeof(szMessage),_T("fopen: File found at: '%s'"),strLocation.c_str()); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); } int bytesread = (int) fread(&contents, sizeof(char), sizeof(contents), file); if ( bytesread > 0 && bytesread < sizeof(char) ) { contents[bytesread]='\0'; } if ( !feof(file) ) { _sntprintf(szMessage,sizeof(szMessage),_T("File is more than 8kb: '%s'"),strLocation); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); fclose(file); return ERROR_SUCCESS; } if ( ferror(file) ) { _sntprintf(szMessage,sizeof(szMessage),_T("Error reading file at: '%s'"),strLocation); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); return ERROR_FILE_INVALID; } fclose(file); remove_white(contents); _sntprintf(szMessage,sizeof(szMessage),_T("File contents: '%s'"),contents); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); if ( CheckFile(contents) ) { if ( remove(strLocation.c_str()) ) { _sntprintf(szMessage,sizeof(szMessage),_T("Failed to delete CCConfig version from previous install. Error Message '%s'"),strerror(errno)); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); return ERROR_FAIL_I24; } _sntprintf(szMessage,sizeof(szMessage),_T("CCConfig was a version from previous install. Deleted")); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); return ERROR_SUCCESS; } _sntprintf(szMessage,sizeof(szMessage),_T("CCConfig was not a version from previous install")); SetProperty(_T("KEEPEXISTINGCONFIG"), _T("1")); LogMessage(INSTALLMESSAGE_INFO,NULL, NULL,NULL,NULL,szMessage); return ERROR_SUCCESS; }