int WindowsShellCommands::execWithData(const std::string &dir, const std::string &source) { std::string fullDirPath = workarea + slash(dir); std::string fullSourcePath = fullDirPath + slash(source); system(("copy \"" + fullSourcePath + "\" \"" + fullSourcePath + ".bat\"").c_str()); PROCESS_INFORMATION pi; STARTUPINFO si; GetStartupInfo(&si); LARGE_INTEGER startTime, finishTime, counterFrequency; QueryPerformanceFrequency(&counterFrequency); QueryPerformanceCounter(&startTime); CreateProcess((fullSourcePath + ".bat").c_str(), NULL, NULL, NULL, FALSE, 0, NULL, fullDirPath.c_str(), &si, &pi); WaitForSingleObject(pi.hProcess, execData.time ? execData.time : INFINITE); TerminateProcess(pi.hProcess, 0); QueryPerformanceCounter(&finishTime); execData.time = (finishTime.QuadPart - startTime.QuadPart) / (counterFrequency.QuadPart / 1000); PROCESS_MEMORY_COUNTERS pmc; GetProcessMemoryInfo(pi.hProcess, &pmc, sizeof(pmc)); execData.memory = pmc.QuotaPeakNonPagedPoolUsage + pmc.QuotaPeakPagedPoolUsage; system(("del \"" + fullSourcePath + ".bat\"").c_str()); GetExitCodeProcess(pi.hProcess, (LPDWORD)&execData.exitCode); return execData.exitCode; }
int WindowsShellCommands::exec(const std::string &dir, const std::string &source) { std::string fullDirPath = workarea + slash(dir); std::string fullSourcePath = fullDirPath + slash(source); system(("copy \"" + fullSourcePath + "\" \"" + fullSourcePath + ".bat\"").c_str()); int exitCode = system(("cd " + fullDirPath + " && \"" + fullSourcePath + ".bat\"").c_str()); system(("del \"" + fullSourcePath + ".bat\"").c_str()); return exitCode; }
int call_notoken(char **env, t_list *list, int i) { int a; char *str; char **save; a = 0; if ((save = malloc(sizeof(char *) * 4096)) == NULL) return (-1); i--; str = list[i].command; save = list[i].option; if ((a = checker(save, env)) == -2) { return (-2); } else { if (!(a == 1)) if (!(slash(env, save)) == 0) if ((my_exec(env, str, save)) != 0) my_putstr("42sh : Command not found\n"); } return (0); }
void eos::Clock::OnTimerClock(ax::Event::Msg* msg) { time_t t = time(0); // get time now struct tm * now = localtime( & t ); int s = now->tm_sec; std::string sec = s < 10 ? "0" + std::to_string(s) : std::to_string(s); int m = now->tm_min; std::string min = m < 10 ? "0" + std::to_string(m) : std::to_string(m); std::string space(":"); _clock_str = std::to_string(now->tm_hour) + space + min + space + sec; std::string slash("/"); m = now->tm_mon + 1; std::string month = m < 10 ? "0" + std::to_string(m) : std::to_string(m); int d = now->tm_mday; std::string day = d < 10 ? "0" + std::to_string(d) : std::to_string(d); _date_str = day + slash + month + slash + std::to_string(now->tm_year + 1900); win->Update(); }
static void validateTopicName(const QString& topic) { if (topic.isEmpty()) { throw std::invalid_argument("empty topic"); } // Can't start or end with a '/' but anywhere else is okay // Can't have "//" as that implies empty token if (topic.startsWith("/") || topic.endsWith("/") || topic.contains("//")) { throw std::invalid_argument(QString("invalid topic: %1").arg(topic).toStdString()); } QString::const_iterator topicEnd = topic.end(); QChar A('A'), Z('Z'), a('a'), z('z'), zero('0'), nine('9'); QChar dash('-'), slash('/'), underscore('_'); for (QString::const_iterator i = topic.begin(); i < topicEnd; ++i) { QChar c(*i); if ((A <= c) && (c <= Z)) continue; if ((a <= c) && (c <= z)) continue; if ((zero <= c) && (c <= nine)) continue; if ((c == underscore) || (c == dash) || (c == slash)) continue; throw std::invalid_argument(QString("invalid topic: %1").arg(topic).toStdString()); } }
Traceback::Traceback(Sequence seq1, Sequence seq2) { int length1 = seq1.seq.length(); int length2 = seq2.seq.length(); array.resize(length1+1); for (int i=0; i<(length1+1); i++) { array[i].resize(length2+1); for (int j=0; j<(length2+1); j++) { array[i][j] = '0'; } } for (int i=1; i<length1+1; i++) { array[i][0] = '|'; } for (int j=1; j<length2+1; j++) { array[0][j] = '~'; } Score score(seq1, seq2); for (int i=1; i<length1+1; i++) { for (int j=1; j<length2+1; j++) { array[i][j] = slash(num_max( score.array[i-1][j-1] + weight(i, j, seq1.seq, seq2.seq), score.array[i-1][j] + seq2.penalty, score.array[i][j-1] + seq1.penalty )); } } }
void ProcFileSystem::refresh() { CoreMessage msg; ProcessInfo info; String slash("/"); Directory *procDir; // TODO: memory leak! Cleanup the whole cache first... (currently broken) // clearFileCache(); rootDir->clear(); /* Update root. */ rootDir->insert(DirectoryFile, "."); rootDir->insert(DirectoryFile, ".."); /* Reinsert into the cache. */ insertFileCache(rootDir, "."); insertFileCache(rootDir, ".."); // Refresh UserProcess table msg.action = ReadProcess; msg.buffer = procs; msg.number = ZERO; msg.type = IPCType; IPCMessage(CORESRV_PID, API::SendReceive, &msg, sizeof(msg)); // Insert processes pseudo files for (int i = 0; i < MAX_PROCS; i++) { // Skip unused PIDs if (!procs[i].command[0]) continue; // Per-process directory procDir = new Directory; procDir->insert(DirectoryFile, "."); procDir->insert(DirectoryFile, ".."); procDir->insert(RegularFile, "cmdline"); procDir->insert(RegularFile, "status"); rootDir->insert(DirectoryFile, "%u", i); // Insert into the cache insertFileCache(procDir, "%u", i); insertFileCache(procDir, "%u/.", i); insertFileCache(rootDir, "%u/..", i); // Set commandline insertFileCache(new PseudoFile("%s", procs[i].command), "%u/cmdline", i); // Request kernel's process information ProcessCtl(i, InfoPID, (Address) &info); // Process status insertFileCache(new PseudoFile("%s", states[info.state]), "%u/status", i); } }
void handle_icon_view_item_activated(GtkWidget *widget, GtkTreePath *tree_path, gpointer unused) { const char *opener = "/home/s/bin/op"; char *argv[] = { NULL, NULL, NULL }; char *new_path = NULL; char *file_path = NULL; gint *pidx; pid_t pid; fsnode_t *child; pidx = gtk_tree_path_get_indices(tree_path); /* they directly correlate to fsents in current_fsdir */ if (*pidx < 0 || *pidx >= current_fsnode->nchildren) return; child = current_fsnode->children + *pidx; if (child->type == DIRECTORY) { if (!strcmp(child->name, "..")) new_path = ascend(current_fsnode->path); else new_path = str_glue(current_fsnode->path, slash(current_fsnode->path), child->name, NULL); change_dir(new_path); free(new_path); } else { pid = fork(); if (pid > 0) return; else if (pid < 0) { warn("fork"); return; } else { file_path = str_glue(current_fsnode->path, slash(current_fsnode->path), child->name, NULL); argv[0] = strdup(opener); argv[1] = strdup(file_path); if (execv("/home/s/bin/op", argv)) err(1, "execlp"); } } }
inline typename std::enable_if< is_same_decayed<Vector, std::vector<std::string>>::value, std::string >::type join(Vector&& a_dirs) { if (a_dirs.empty()) return ""; size_t n = 0; for (auto& s : a_dirs) n += s.size()+1; // Don't count leading slash std::string res(n-1, slash()); char* p = const_cast<char*>(res.c_str()); for (auto it = a_dirs.begin(), e = a_dirs.end(); it != e; p += it->size()+1, ++it) memcpy(p, it->c_str(), it->size()); return res; }
void mkdir_parent (const std::string& path) { std::string::size_type slash(path.find('/', 1)); while (slash != std::string::npos) { std::string prefix(path.substr(0, slash)); if (GetFileAttributes(prefix.c_str()) == INVALID_FILE_ATTRIBUTES) { // prefix does not exist, so try to create it if (!CreateDirectory(prefix.c_str(), NULL)) { throw System_error("CreateDirectory", prefix, GetLastError()); } } slash = path.find('/', slash + 1); } }
int call_no_env(char **save, char **env, t_list *list, int i) { int a; a = 0; i--; save = list[i].option; if ((a = checker(save, env)) == -2) return (-2); else { if (!(a == 1)) if (!(slash(env, save)) == 0) my_putstr("Env is empty\n"); } return (0); }
::String getVersionString() { const char* gl_ver = (const char*)glGetString(GL_VERSION); const char* gl_sl = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); const char* gl_ren = (const char*)glGetString(GL_RENDERER); const char* gl_ven = (const char*)glGetString(GL_VENDOR); ::String ver = ::String( gl_ver ? gl_ver : "GL(null)" ); ::String sl = ::String( gl_sl ? gl_sl : "GLSL(null)" ); ::String ren = ::String( gl_ren ? gl_ren : "GLRenderer(null)" ); ::String ven = ::String( gl_ven ? gl_ven : "GLVendor(null)" ); ::String slash(" / "); return slash + ver + slash + sl + slash + ren + slash + ven + slash; } //getVersionString
void fi::VPDetectionWrapper::computeVanishingPoint(const std::string &image_filename, const std::string &vp_out_dir_name) { //create results folder //boost::filesystem::path sep_tor = boost::filesystem::path("/").native(); boost::filesystem::path slash("/"); //std::string preferred_slash = slash.make_preferred().native().string(); std::string vp_results_out_dir(vp_out_dir_name + slash.string() + VP_RESULTS_DIR); vp_results_out_dir = correctSlashes(vp_results_out_dir); boost::filesystem::create_directory(vp_results_out_dir); //std::string vp_tool(VPDETECTION_TOOL); char *a = VPDETECTION_TOOL; std::string b ( boost::lexical_cast<std::string>(a)+ " --outdir="+ vp_results_out_dir + " "+ image_filename); b=correctSlashes(b); std::cout <<"command: "<<b<<std::endl; //system(b.c_str()); //undo this for new data sets }
void battle(s_player *player1, s_monster *monster1){ char *entree_clavier; while (1){ if (player1->pv <= 0){ my_putstr("\nYou Are a looser\n"); return; } else if (monster1->pv <= 0){ my_putstr("\nYou Are a great Winner\n"); return; } my_putstr("\nplayer : => "); entree_clavier = readLine(); if ((my_strcmp(entree_clavier,"help") == 0)) aff_help(); else if ((my_strcmp(entree_clavier,"stat") == 0)) stat(player1); else if ((my_strcmp(entree_clavier,"libra") == 0)) libra(player1, monster1); else if ((my_strcmp(entree_clavier,"attack") == 0)){ attack(player1, monster1); rand_attack(player1, monster1); } else if ((my_strcmp(entree_clavier,"fire") == 0)){ fire(player1, monster1); rand_attack(player1, monster1); } else if ((my_strcmp(entree_clavier,"slash") == 0)){ slash(player1, monster1); rand_attack(player1, monster1); } else if ((my_strcmp(entree_clavier,"thunder") == 0)){ thunder(player1, monster1); rand_attack(player1, monster1); } else if ((my_strcmp(entree_clavier,"quit") == 0)) return; else my_putstr("\nkeyboard entry wrong tap help\n"); } }
void client(int argc, char **argv, char *abs_exe_path, char *path_invocation) { TBase * base = read_file(); char arg[PATH_MAX] = ""; if (argc > 1) { int i; for (i = 1; i < argc; i++) { strcat(arg, argv[i]); strcat(arg, " "); } } if (!base) return; int n = sprintf(abs_exe_path, "java -cp \"%s\" -Dbr.uff.ic.labgc.invocation=\"%s\" -Dbr.uff.ic.labgc.repository=\"%s\" -Djava.rmi.server.codebase=file:\"%s\" -Djava.rmi.server.hostname=%s -Djava.security.policy=\"%s\" br.uff.ic.labgc.AppCLI %s", base->jar_path, path_invocation, base->repository_path, base->rmi_path, base->rmi_host, base->policity_path, arg); #ifdef __WIN32__ abs_exe_path = slash(abs_exe_path); #endif freeall(base); free(base); }
void mkdir_parent (const std::string& path) { std::string::size_type slash(path.find('/', 1)); while (slash != std::string::npos) { std::string prefix(path.substr(0, slash)); struct stat status; if (stat(prefix.c_str(), &status) == 0) { // already exists - make sure it's a directory if (!S_ISDIR(status.st_mode)) { throw System_error("mkdir_parent", prefix, ENOTDIR); } } else { if (errno != ENOENT) { throw System_error("mkdir_parent", prefix, errno); } // doesn't exist - mkdir it if (mkdir(prefix.c_str(), 0777) == -1) { throw System_error("mkdir", prefix, errno); } } slash = path.find('/', slash + 1); } }
/// Split \a a_path to directory and filename inline std::pair<std::string, std::string> split(std::string const& a_path) { auto found = a_path.rfind(slash()); return found == std::string::npos ? std::make_pair("", a_path) : std::make_pair(a_path.substr(0, found), a_path.substr(found+1)); }
VError VArchiveUnStream::ProceedCatalog() { VError result = VE_OK; VStr8 dotSlash("./"); VStr8 slash("/"); VStr8 extra("::"); VStr8 folderSep(XBOX::FOLDER_SEPARATOR); if ( fStream->GetLong() == 'FPBK' ) { VString filePath; VString fileExtra; VString storedPath; uLONG kind = 0; uLONG creator = 0; sLONG8 dataFileSize = 0; sLONG8 resFileSize = 0; uBYTE version = fStream->GetByte(); uLONG8 fileCount = fStream->GetLong8(); fTotalByteCount = 0; if ( fStream->GetLong() == 'LIST' ) { for ( uLONG i = 0; i < fileCount && result == VE_OK; i++ ) { if ( fStream->GetLong() == 'file' ) { result = filePath.ReadFromStream(fStream); if ( result == VE_OK ) { VIndex index = filePath.Find(extra); fileExtra = filePath; fileExtra.Remove(1,index+1); filePath.Remove(index,filePath.GetLength()-index+1); storedPath = filePath; if ( filePath.Find( dotSlash ) > 0 ) { // some archives have bogous file paths such as ./Z:/folder filePath.Exchange( (UniChar) ':', (UniChar) '_'); filePath.Replace(fDestinationFolder.GetPath(),1,2); } filePath.Exchange(slash ,folderSep, 1, 255); dataFileSize = fStream->GetLong8(); fTotalByteCount += dataFileSize; resFileSize = fStream->GetLong8(); fTotalByteCount += resFileSize; kind = fStream->GetLong(); creator = fStream->GetLong(); VFile *file = new VFile(filePath); fFileCatalog.push_back(new VArchiveCatalog(file,dataFileSize,resFileSize,storedPath,fileExtra,kind,creator)); ReleaseRefCountable( &file); } } else result = VE_STREAM_BAD_SIGNATURE; } } else result = VE_STREAM_BAD_SIGNATURE; } return result; }
//ACI0078887 23rd Nov 2012, O.R., always specify folder used for computing relative path of entry in TOC VError VArchiveStream::_WriteCatalog( const VFile* inFile, const XBOX::VFilePath& inSourceFolder,const VString &inExtraInfo, uLONG8 &ioTotalByteCount ) { VString fileInfo; VStr8 slash("/"); VStr8 extra("::"); VStr8 folderSep(XBOX::FOLDER_SEPARATOR); VError result = VE_INVALID_PARAMETER; XBOX::VString savedExtraInfo = inExtraInfo; //ACI0078887 23rd Nov 2012, O.R., compute relative path using the specified source folder //don't assume that extra info carries relative folder info //ACI0078887 23rd Nov 2012, O.R., compute relative path using the specified source folder //don't assume that extra info carries relative folder info if (savedExtraInfo == PRESERVE_PARENT_OPTION) { //this is a bogus extra info that we use internally so we need to clear it so that it is not saved into //the archive. //This options means that the file will have to be restored in with its parent directory preserved. savedExtraInfo.Clear(); VFolder *folder = inFile->RetainParentFolder(); VString fileName; folder->GetName(fileInfo); // folder name can be a drive letter like Z: fileInfo.Exchange( (UniChar) ':', (UniChar) '_'); inFile->GetName(fileName); fileInfo += slash; fileInfo += fileName; fileInfo.Insert( slash, 1 ); folder->Release(); result = VE_OK; } else { if(testAssert(inFile->GetPath().GetRelativePath(inSourceFolder,fileInfo))) { result = VE_OK; fileInfo.Insert( FOLDER_SEPARATOR, 1); } } if(result == VE_OK) { fileInfo.Exchange(folderSep ,slash, 1, 255); if ( fileInfo.GetUniChar(1) == '/' ) fileInfo.Insert( '.', 1 ); fileInfo += extra; fileInfo += savedExtraInfo; result = fStream->PutLong('file'); if ( result == VE_OK ) { result = fileInfo.WriteToStream(fStream); } if ( result == VE_OK ) { sLONG8 fileSize = 0; inFile->GetSize(&fileSize); fStream->PutLong8(fileSize); ioTotalByteCount += fileSize; #if VERSIONWIN || VERSION_LINUX /* rez file size */ fStream->PutLong8(0); /* no file kind or creator under Windows */ fStream->PutLong(0); /* kind */ fStream->PutLong(0); /* creator */ #elif VERSIONMAC inFile->GetResourceForkSize(&fileSize); fStream->PutLong8(fileSize); ioTotalByteCount += fileSize; OsType osType; inFile->MAC_GetKind( &osType ); result = fStream->PutLong( osType ); inFile->MAC_GetCreator( &osType ); result = fStream->PutLong( osType ); #endif } } return result; }
CONDITION MLMPPS::handleNSetDataSet(DUL_PRESENTATIONCONTEXT* ctx, MSG_N_SET_REQ** message, MSG_N_SET_RESP* response, DUL_ASSOCIATESERVICEPARAMETERS* params, MString& directoryName) { MLogClient logClient; logClient.log(MLogClient::MLOG_VERBOSE, params->callingAPTitle, "MLMPPS::handleNSetDataSet", __LINE__, "MPPS N-Set dataset received"); //::DCM_DumpElements(&(*message)->dataSet, 1); MFileOperations f; MString instanceUID((*message)->instanceUID); MString slash("/"); MString callingAPTitle(params->callingAPTitle); MString newDirectory = mStorageDir + slash + params->callingAPTitle + slash + instanceUID; f.createDirectory(newDirectory); f.createDirectory(newDirectory); MString s = f.uniqueFile(newDirectory, "set"); char* s1 = s.strData(); ::DCM_WriteFile(&(*message)->dataSet, DCM_ORDERLITTLEENDIAN, s1 ); logClient.log(MLogClient::MLOG_VERBOSE, params->callingAPTitle, "MLMPPS::handleNSetDataSet", __LINE__, "MPPS N-Set data set written to " + s); char mppsPath[512]; newDirectory.safeExport(mppsPath, sizeof(mppsPath)); strcat (mppsPath, "/mpps.dcm"); MPPSAssistant assistant; int rslt; rslt = assistant.validateNSetDataSet(mppsPath, s1); rslt = assistant.mergeNSetDataSet(mppsPath, s1); logClient.log(MLogClient::MLOG_VERBOSE, params->callingAPTitle, "MLMPPS::handleNSetDataSet", __LINE__, MString("MPPS status updated ") + mppsPath); delete [] s1; response->dataSetType = DCM_CMDDATANULL; response->conditionalFields = 0; ::strcpy(response->classUID, (*message)->classUID); ::strcpy(response->instanceUID, (*message)->instanceUID); response->status = MSG_K_SUCCESS; return SRV_NORMAL; }
int initCondForPut( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp, bulkOprInp_t *bulkOprInp, rodsRestart_t *rodsRestart ) { char *tmpStr; if ( rodsArgs == NULL ) { // JMC cppcheck - nullptr rodsLog( LOG_ERROR, "initCondForPut :: NULL rodsArgs" ); return -1; } if ( dataObjOprInp == NULL ) { rodsLog( LOG_ERROR, "initCondForPut: NULL dataObjOprInp input" ); return USER__NULL_INPUT_ERR; } memset( dataObjOprInp, 0, sizeof( dataObjInp_t ) ); if ( rodsArgs->bulk == True ) { if ( bulkOprInp == NULL ) { rodsLog( LOG_ERROR, "initCondForPut: NULL bulkOprInp input" ); return USER__NULL_INPUT_ERR; } bzero( bulkOprInp, sizeof( bulkOprInp_t ) ); if ( rodsArgs->checksum == True ) { addKeyVal( &bulkOprInp->condInput, REG_CHKSUM_KW, "" ); } else if ( rodsArgs->verifyChecksum == True ) { addKeyVal( &bulkOprInp->condInput, VERIFY_CHKSUM_KW, "" ); } initAttriArrayOfBulkOprInp( bulkOprInp ); } dataObjOprInp->oprType = PUT_OPR; if ( rodsArgs->all == True ) { addKeyVal( &dataObjOprInp->condInput, ALL_KW, "" ); } if ( rodsArgs->dataType == True ) { if ( rodsArgs->dataTypeString == NULL ) { addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW, "generic" ); } else { if ( strcmp( rodsArgs->dataTypeString, "t" ) == 0 || strcmp( rodsArgs->dataTypeString, "tar" ) == 0 ) { addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW, "tar file" ); } else { addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW, rodsArgs->dataTypeString ); } } } else { addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW, "generic" ); } if ( rodsArgs->force == True ) { addKeyVal( &dataObjOprInp->condInput, FORCE_FLAG_KW, "" ); if ( rodsArgs->bulk == True ) { addKeyVal( &bulkOprInp->condInput, FORCE_FLAG_KW, "" ); } } #ifdef windows_platform dataObjOprInp->numThreads = NO_THREADING; #else if ( rodsArgs->number == True ) { if ( rodsArgs->numberValue == 0 ) { dataObjOprInp->numThreads = NO_THREADING; } else { dataObjOprInp->numThreads = rodsArgs->numberValue; } } #endif if ( rodsArgs->physicalPath == True ) { if ( rodsArgs->physicalPathString == NULL ) { rodsLog( LOG_ERROR, "initCondForPut: NULL physicalPathString error" ); return USER__NULL_INPUT_ERR; } else { boost::filesystem::path slash( "/" ); std::string preferred_slash = slash.make_preferred().native(); if ( preferred_slash[0] != rodsArgs->physicalPathString[0] ) { rodsLog( LOG_ERROR, "initCondForPut: physical path [%s] must be absolute, not relative", rodsArgs->physicalPathString ); return USER_INPUT_PATH_ERR; } addKeyVal( &dataObjOprInp->condInput, FILE_PATH_KW, rodsArgs->physicalPathString ); } } if ( rodsArgs->resource == True ) { if ( rodsArgs->resourceString == NULL ) { rodsLog( LOG_ERROR, "initCondForPut: NULL resourceString error" ); return USER__NULL_INPUT_ERR; } else { addKeyVal( &dataObjOprInp->condInput, DEST_RESC_NAME_KW, rodsArgs->resourceString ); if ( rodsArgs->bulk == True ) { addKeyVal( &bulkOprInp->condInput, DEST_RESC_NAME_KW, rodsArgs->resourceString ); } } } else if ( myRodsEnv != NULL && strlen( myRodsEnv->rodsDefResource ) > 0 ) { /* use rodsDefResource but set the DEF_RESC_NAME_KW instead. * Used by dataObjCreate. Will only make a new replica only if * DEST_RESC_NAME_KW is set */ addKeyVal( &dataObjOprInp->condInput, DEF_RESC_NAME_KW, myRodsEnv->rodsDefResource ); if ( rodsArgs->bulk == True ) { addKeyVal( &bulkOprInp->condInput, DEF_RESC_NAME_KW, myRodsEnv->rodsDefResource ); } } if ( rodsArgs->replNum == True ) { addKeyVal( &dataObjOprInp->condInput, REPL_NUM_KW, rodsArgs->replNumValue ); } if ( rodsArgs->purgeCache == True ) { // JMC - backport 4537 addKeyVal( &dataObjOprInp->condInput, PURGE_CACHE_KW, "" ); } if ( rodsArgs->rbudp == True ) { /* use -Q for rbudp transfer */ addKeyVal( &dataObjOprInp->condInput, RBUDP_TRANSFER_KW, "" ); } if ( rodsArgs->veryVerbose == True ) { addKeyVal( &dataObjOprInp->condInput, VERY_VERBOSE_KW, "" ); } if ( ( tmpStr = getenv( RBUDP_SEND_RATE_KW ) ) != NULL ) { addKeyVal( &dataObjOprInp->condInput, RBUDP_SEND_RATE_KW, tmpStr ); } if ( ( tmpStr = getenv( RBUDP_PACK_SIZE_KW ) ) != NULL ) { addKeyVal( &dataObjOprInp->condInput, RBUDP_PACK_SIZE_KW, tmpStr ); } memset( rodsRestart, 0, sizeof( rodsRestart_t ) ); if ( rodsArgs->restart == True ) { int status; status = openRestartFile( rodsArgs->restartFileString, rodsRestart ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "initCondForPut: openRestartFile of %s error", rodsArgs->restartFileString ); return status; } if ( rodsRestart->doneCnt == 0 ) { /* brand new */ if ( rodsArgs->bulk == True ) { rstrcpy( rodsRestart->oprType, BULK_OPR_KW, NAME_LEN ); } else { rstrcpy( rodsRestart->oprType, NON_BULK_OPR_KW, NAME_LEN ); } } else { if ( rodsArgs->bulk == True ) { if ( strcmp( rodsRestart->oprType, BULK_OPR_KW ) != 0 ) { rodsLog( LOG_ERROR, "initCondForPut: -b cannot be used to restart this iput" ); return BULK_OPR_MISMATCH_FOR_RESTART; } } else { if ( strcmp( rodsRestart->oprType, NON_BULK_OPR_KW ) != 0 ) { rodsLog( LOG_ERROR, "initCondForPut: -b must be used to restart this iput" ); return BULK_OPR_MISMATCH_FOR_RESTART; } } } } if ( rodsArgs->retries == True && rodsArgs->restart == False && rodsArgs->lfrestart == False ) { rodsLog( LOG_ERROR, "initCondForPut: --retries must be used with -X or --lfrestart option" ); return USER_INPUT_OPTION_ERR; } /* Not needed - dataObjOprInp->createMode = 0700; */ /* mmap in rbudp needs O_RDWR */ dataObjOprInp->openFlags = O_RDWR; if ( rodsArgs->lfrestart == True ) { if ( rodsArgs->bulk == True ) { rodsLog( LOG_NOTICE, "initCondForPut: --lfrestart cannot be used with -b option" ); } else if ( rodsArgs->rbudp == True ) { rodsLog( LOG_NOTICE, "initCondForPut: --lfrestart cannot be used with -Q option" ); } else { conn->fileRestart.flags = FILE_RESTART_ON; rstrcpy( conn->fileRestart.infoFile, rodsArgs->lfrestartFileString, MAX_NAME_LEN ); } } if ( rodsArgs->wlock == True ) { // JMC - backport 4604 addKeyVal( &dataObjOprInp->condInput, LOCK_TYPE_KW, WRITE_LOCK_TYPE ); } if ( rodsArgs->rlock == True ) { // JMC - backport 4612 rodsLog( LOG_ERROR, "initCondForPut: --rlock not supported, changing it to --wlock" ); addKeyVal( &dataObjOprInp->condInput, LOCK_TYPE_KW, WRITE_LOCK_TYPE ); } return 0; }
WindowsShellCommands::WindowsShellCommands(const std::string &workareaPath) { workarea = slash(workareaPath); }
void WindowsShellCommands::del(const std::string &source) { system(("del \"" + workarea + slash(source) + "\"").c_str()); }
/// Join \a a_dir and \a a_file inline std::string join(std::string const& a_dir, std::string const& a_file) { return a_dir.empty() ? a_file : a_dir[a_dir.size()-1] == slash() ? a_dir + a_file : a_dir + slash_str() + a_file; }
// Returns the next token in the character stream. // If no next token can be identified, an error // is emitted and we return the error token. Token Lexer::scan() { // Keep consuming characters until we find // a token. while (true) { space(); // Update the position of the current source location. // This denotes the beginning of the current token. loc_ = in_.location(); switch (peek()) { case 0: return eof(); case '{': return lbrace(); case '}': return rbrace(); case '(': return lparen(); case ')': return rparen(); case '[': return lbrack(); case ']': return rbrack(); case ',': return comma(); case ':': return colon(); case ';': return semicolon(); case '.': return dot(); case '+': return plus(); case '-': return minus(); case '*': return star(); case '/': get(); if (peek() == '/') { comment(); continue; } else { return slash(); } case '%': return percent(); case '=': return equal(); case '!': return bang(); case '<': return langle(); case '>': return rangle(); case '&': return ampersand(); case '|': return bar(); case '^': return hat(); case '0': // if the next character is a 'b' then this // is a binary literal if (peek(1) == 'b') return binary_integer(); // if the next character is an 'x' then this // is a hexadecimal integer if (peek(1) == 'x') return hexadecimal_integer(); // otherwise proceed to regular integer lexing case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return integer(); case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': return word(); case '\'': return character(); case '"': return string(); default: return error(); } } }
void WindowsShellCommands::copy(const std::string &source, const std::string &dest) { system(("copy \"" + workarea + slash(source) + "\" \"" + workarea + slash(dest) + "\"").c_str()); }
bool WindowsShellCommands::exists(const std::string &source) { return system(("if exist \"" + workarea + slash(source) + "\" (exit /b 1) else (exit /b 0)").c_str()); }
CONDITION MLStorage::handleCStoreDataSet(DUL_PRESENTATIONCONTEXT* ctx, MSG_C_STORE_REQ** message, MSG_C_STORE_RESP* response, DUL_ASSOCIATESERVICEPARAMETERS* params, MString& fileName) { MLogClient logClient; logClient.log(MLogClient::MLOG_VERBOSE, params->callingAPTitle, "MLStorage::handleCStoreDataSet", __LINE__, "About to translate and store SOP Instance"); logClient.log(MLogClient::MLOG_VERBOSE, params->callingAPTitle, "MLStorage::handleCStoreDataSet", __LINE__, "File is: " + fileName); MDICOMDomainXlate xlate; MDICOMWrapper w((*message)->dataSet); MPatient patient; xlate.translateDICOM(w, patient); patient.issuerOfPatientID("OF1"); MStudy study; xlate.translateDICOM(w, study); MSeries series; xlate.translateDICOM(w, series); MSOPInstance sopInstance; xlate.translateDICOM(w, sopInstance); MString sopInstanceUID = sopInstance.instanceUID(); logClient.log(MLogClient::MLOG_VERBOSE, params->callingAPTitle, "MLStorage::handleCStoreDataSet", __LINE__, "SOP Instance UID: " + sopInstanceUID); MString slash("/"); MString callingAPTitle(params->callingAPTitle); MString newDirectory; MString newFile; char x[65]; sopInstance.instanceUID().safeExport(x, sizeof(x)); if (x[0] == 'x') { // Special case newDirectory = mLogDir + slash + params->callingAPTitle + slash + study.studyInstanceUID(); } else { newDirectory = mLogDir + slash + params->callingAPTitle + slash + study.studyInstanceUID() + slash + series.seriesInstanceUID(); } newFile = newDirectory + slash + sopInstance.instanceUID(); sopInstance.fileName(newFile); MFileOperations fileOp; fileOp.createDirectory(newDirectory); fileOp.rename(fileName, newFile); logClient.log(MLogClient::MLOG_VERBOSE, params->callingAPTitle, "MLStorage::handleCStoreDataSet", __LINE__, "File Rename: " + newFile); if (sopInstance.instanceUID() != "x") mImageManager.enterSOPInstance(patient, study, series, sopInstance); logClient.log(MLogClient::MLOG_VERBOSE, params->callingAPTitle, "MLStorage::handleCStoreDataSet", __LINE__, "C-Store Data Set complete"); }
char char_slash() { string sl = slash(); assert( sl.size() == 1 ); return sl[0]; }
int wmain() { wchar_t* exePath = 0; if (_get_wpgmptr(&exePath) != 0) return 1; std::wstring launcherDirectory = exePath; if (launcherDirectory.empty()) { std::wcout << L"error -- failed to get exe path: " << message() << L" (" << GetLastError() << L")" << std::endl; return 1; } auto pos = launcherDirectory.find_last_of('\\'); if (pos == std::wstring::npos) { std::wcout << L"error -- failed to get exe path: " << message() << L" (" << GetLastError() << L")" << std::endl; return 1; } launcherDirectory = launcherDirectory.substr(0, pos); std::wifstream infile(L"launcher.cfg"); if (!infile) { std::wcout << L"error -- unable to find 'launcher.cfg'!" << std::endl; return 1; } const size_t length = 256; wchar_t buffer[length]; if (!infile.getline(buffer, length)) { std::wcout << L"error -- unable to read executable name from line 1 of 'launcher.cfg'!" << std::endl; std::wcout << L"(example exe: 'age2.exe')" << std::endl; return 1; } std::wstring executable = buffer; if (!infile.getline(buffer, length)) { std::wcout << L"error -- unable to read current directory from line 2 of 'launcher.cfg'!" << std::endl; std::wcout << L"(example package-relative current directory: 'bin\\x64')" << std::endl; return 1; } std::wstring currentDirectory = buffer; trim(executable); trim(currentDirectory); if (executable.empty()) { std::wcout << L"error -- invalid executable specified on line 1 of 'launcher.cfg'!" << std::endl; return 1; } if (currentDirectory.empty()) { std::wcout << L"error -- invalid current directory specified on line 2 of 'launcher.cfg'!" << std::endl; return 1; } slash(executable); slash(currentDirectory); std::wstring currentDirectoryPath = launcherDirectory + currentDirectory; std::wstring executablePath = currentDirectoryPath + executable; STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); BOOL created = CreateProcessW(executablePath.c_str(), 0, 0, 0, FALSE, 0, 0, currentDirectoryPath.c_str(), &si, &pi); if (FALSE == created) { std::wcout << L"error -- failed to create process: " << message() << L" (" << GetLastError() << L")" << std::endl; std::wcout << L"path: " << executablePath << std::endl; return 1; } CloseHandle(pi.hProcess); CloseHandle(pi.hThread); return 0; }