static void message_element_init(MessageQueueElement *el, const char *function_name, void *bt_address, DWORD resource_id, MessageType msg_type) { /* timestamp */ GetLocalTime(&el->time); /* process name, id and thread id */ get_process_name(el->process_name, sizeof(el->process_name)); el->process_id = GetCurrentProcessId(); el->thread_id = GetCurrentThreadId(); /* function name and return address */ strncpy(el->function_name, function_name, sizeof(el->function_name)); if (bt_address != NULL) { OString backtrace = Util::Instance()->CreateBacktrace(bt_address); strncpy(el->backtrace, backtrace.c_str(), sizeof(el->backtrace)); el->backtrace[sizeof(el->backtrace) - 1] = '\0'; } /* underlying resource id */ if (resource_id == 0) { resource_id = ospy_rand(); } el->resource_id = resource_id; /* message type */ el->type = msg_type; }
OString::OString(const OString& String) { if ((String.getText())) { text = new CHAR[strlen(String)+1]; strcpy(text, String); } else text = NULL; }
DllModule::DllModule(const OString &path) : m_path(path) { m_handle = LoadLibraryA(path.c_str()); if (m_handle == NULL) throw Error("LoadLibrary failed"); char tmp[_MAX_PATH]; if (GetModuleBaseNameA(GetCurrentProcess(), m_handle, tmp, sizeof(tmp)) == 0) throw Error("GetModuleBaseName failed"); m_name = tmp; OModuleInfo mi = Util::Instance()->GetModuleInfo(m_name.c_str()); m_base = reinterpret_cast<void *>(mi.startAddress); m_size = mi.endAddress - mi.startAddress; }
void OTerminal::handleInput(OString input) { OTerminalArg arg; arg.str = input; arg.split = input.split(d); if(input.size() >= 1) { for(unsigned i=0; i<fmap.size(); i++) { //if we found the command-function map //prepare the string and call the function if(input.startsWith(fmap[i].first)) { int cmdlen = fmap[i].first.length(); OString a = input.substring(cmdlen); //if there is a delimiter at the beginning of //the input string trim it until there are none left for(unsigned j=0; j<a.length(); j++) { if(a.startsWith(d)) { a = a.substring(d.length()); } else break; } arg.str = a; arg.split = a.split(d); //call the function fmap[i].second(arg); //we are done here return; } } //fallthrough, call the default function if(cdef) cdef(arg); } }
void oogo_ebuf_s(OUString msg) { OString os = OUStringToOString(msg, RTL_TEXTENCODING_UTF8); oogo_ebuf(os.getStr()); }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); #ifndef _DEBUG_ if(argc != 3){ dump("引数が違います"); return -1; } #endif dump("開始"); QString xpPath, sevenPath; #ifndef _DEBUG_ QString arg1(QString::fromUtf8(argv[1])); if( -1 != arg1.indexOf("xp")){ xpPath = arg1; sevenPath = QString::fromUtf8(argv[2]); } else{ xpPath = QString::fromUtf8(argv[2]); sevenPath = arg1; } #else xpPath = f8("D:\\Programming\\Qt\\CoordinateDiff\\CoordinateDiff-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\\data\\xp"); sevenPath = f8("D:\\Programming\\Qt\\CoordinateDiff\\CoordinateDiff-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\\data\\7"); #endif QDir xpFolder(xpPath); QFileInfoList xpFileList = xpFolder.entryInfoList(QDir::NoFilter, QDir::Name); QDir sevenFolder(sevenPath); QFileInfoList sevenFileList = sevenFolder.entryInfoList(QDir::NoFilter, QDir::Name); if(xpFileList.size() != sevenFileList.size()){ dump("ファイル数が違います"); } OString diffList; QFileInfoList xpOnlyList; // xpフォルダの各ファイルを、7フォルダ内のファイルから探して、 // 差分を比較する。7フォルダ内に無かったら、そのファイルを記録しておく。 foreach(QFileInfo xpFile, xpFileList){ if(xpFile.fileName() == "." || xpFile.fileName() == "..") continue; bool xpOnly = true; foreach(QFileInfo sevenFile, sevenFileList){ if(xpFile.fileName() == sevenFile.fileName()){ // 差分を作成 unsigned int bef = diffList.size(); int ret = makeDiff( xpFile, sevenFile, diffList, ret); if(bef != diffList.size()){ dump("差分あり:" + xpFile.fileName()); } // -1 xpファイルオープン失敗 // -2 7ファイルオープン失敗 // -3 xp・7ファイルに書かれている行数が違う if(ret != 1){ if(ret == -1){ dump("xpファイルオープン失敗:"+xpFile.fileName()); } else if(ret == -2){ dump("7ファイルオープン失敗:"+sevenFile.fileName()); } else if(ret == -3){ dump("xpファイルと7ファイルの行数が違う:"+xpFile.fileName() +", "+ sevenFile.fileName()); } } xpOnly = false; break; } } if(xpOnly) xpOnlyList.append(xpFile); } QFileInfoList sevenOnlyList; // 7フォルダ内にしかないファイルも探す foreach(QFileInfo sevenFile, sevenFileList){ bool sevenOnly = true; foreach(QFileInfo xpFile, xpFileList){ if(xpFile.fileName() == sevenFile.fileName()){ sevenOnly = false; break; } } if(sevenOnly) sevenOnlyList.append(sevenFile); }
void GTPMWin::backup() { #ifdef __TK21__ PSZ tempEnv; #else PCSZ tempEnv; #endif PSZ pstr; ULONG item, items; OString path; OString includes; OString excludes; OString batch; OString dirfile; OString str; ofstream incfile; ofstream excfile; ofstream batchfile; if ((DosScanEnv("TEMP", &tempEnv)) && (DosScanEnv("TMP", &tempEnv))) { path << GTPMApp::GTakPM->callName; path.rightCut('\\'); } else path << (PSZ)tempEnv; if (path.getText()[strlen(path) - 1] != '\\') path + "\\"; includes << path; includes + "gtmp.inc"; excludes << path; excludes + "gtmp.exc"; batch << path; batch + "gtmp.cmd"; dirfile << path; dirfile + "gtmp.dir"; path << "Cannot open: "; incfile.open(includes); if (!incfile) { path + includes; throw OPMException(path, 0); } excfile.open(excludes); if (!excfile) { path + excludes; throw OPMException(path, 0); } batchfile.open(batch); if (!batchfile) { path + batch; throw OPMException(path, 0); } // write includes-file items = Includes->queryItemCount(); for(item = 0; item < items; item++) if (Includes->queryItemText(str, item)) { pstr = str.getText(); while((pstr = strchr(pstr, '\\'))!=NULL) pstr[0] = '/'; incfile << ((PSZ)(strchr(str, ' ')+1)) << endl; } incfile.close(); // write excludes-file items = Excludes->queryItemCount(); for(item = 0; item < items; item++) if (Excludes->queryItemText(str, item)) { pstr = str.getText(); while((pstr = strchr(pstr, '\\'))!=NULL) pstr[0] = '/'; excfile << ((PSZ)(strchr(str, ' ')+1)) << endl; } excfile.close(); // write batchfile batchfile << "@ECHO OFF\n" << "echo Initializing Tape\n" << "tape stat >NUL 2>NUL\n" << "tape blocksize 0 stat sel 0 eraseq tell\n" << "echo Backup in progress\ntar -cEppP @" << (PSZ) includes << " --totals --exclude-from " << (PSZ) excludes << " -D " << (PSZ) dirfile << "\ntape stat\n" << "echo Compare in progress\n" << "tape rew >NUL 2>NUL\n" << "tar -dEppP\n" << "tape stat\n" << "echo Operation completed.\n"; batchfile.close(); tape->batch(batch); }
bool operator< (const char* lhs, const OString& rhs) { return rhs.compare(lhs) > 0; }
bool operator< (const OString& lhs, const char* rhs) { return lhs.compare(rhs) < 0; }
bool operator< (const std::string& lhs, const OString& rhs) { return rhs.compare(lhs) > 0; }
bool operator!= (const OString& lhs, const std::string& rhs) { return lhs.compare(rhs) != 0; }
bool operator!= (const OString& lhs, const OString& rhs) { return !(lhs.equals(rhs)); }
bool operator== (const OString& lhs, const OString& rhs) { return lhs.equals(rhs); }
bool operator>= (const OString& lhs, const OString& rhs) { return lhs.equals(rhs) || lhs.compare(rhs) > 0; }
bool operator> (const OString& lhs, const OString& rhs) { return lhs.compare(rhs) > 0; }