int main(int argc, char *argv[]) { try { // std::cout<<"Starting Program"<<std::endl; bool dumpDot = false; bool debug = false; --argc; ++argv; while (argc > 0 && argv[0][0] == '-') { switch (argv[0][1]) { case 's': dumpDot = true; break; case 'd': debug = true; break; default: std::cerr << "unrecognized option \"" << argv[0] << "\"\n"; /* FALLTHROUGH */ case 'h': throw UsageError(); } --argc; ++argv; } // std::cout<<"I'm here now"<<std::endl; if (argc > 0) throw UsageError(); IR::XMListream r(std::cin); IR::Node *n; r >> n; AST::Modules *mods = dynamic_cast<AST::Modules*>(n); if (!mods) throw IR::Error("Root node is not a Modules object"); for ( std::vector<AST::Module*>::iterator i = mods->modules.begin() ; i != mods->modules.end() ; i++ ) { assert(*i); AST::GRCgraph *g = dynamic_cast<AST::GRCgraph*>((*i)->body); if (!g) throw IR::Error("Module is not in GRC format"); GRCBAL::convertGRC(std::cout, g, *i, dumpDot, debug); } } catch (IR::Error &e) { std::cerr << e.s << std::endl; exit(-1); } catch (UsageError &) { std::cerr << "Usage: cec-grcbal [-s] [-d] [-h]\n" "-s Print the sequential BAL graph in .dot format\n" "-d Print debugging output\n" "-h Print this usage message\n" ; return 1; } // std::cout<<"All Done"<<std::endl; return 0; }
double ExpectNextDouble() { const char *p = ExpectNext(); assert(p != NULL); char *endptr; double result = ParseDouble(p, &endptr); if (p == endptr) UsageError(); return result; }
int ExpectNextInt() { const char *p = ExpectNext(); assert(p != NULL); char *endptr; int result = ParseInt(p, &endptr); if (p == endptr) UsageError(); return result; }
Ref<Theme> Theme::load(String path) { String themePath = path; if (themePath->isRelativePath()) { if (!Dir::exists(themePath)) { if (!themePath->contains('/')) themePath = String("themes/") + themePath; if (!Dir::exists(themePath)) themePath = FLUX_BUNDLE_LOOKUP(themePath); } } if (themePath == "" || !Dir::exists(themePath)) throw UsageError(Format("Failed to locate theme \"%%\"") << path); return new Theme(themePath); }
Theme::Theme(String path) : path_(path), name_(path->fileName()), paletteByScope_(PaletteByScope::create()) { Ref<Dir> dir = Dir::open(path); String name; while (dir->read(&name)) { if (name == "." || name == "..") continue; if (!(name->count() > 0 && ('a' <= name->at(0) && name->at(0) <= 'z'))) continue; Ref<Palette> palette = Palette::load(path + "/" + name); paletteByScope_->insert(palette->scope(), palette); } if (!paletteByScope_->lookup(Palette::defaultScope(), &defaultPalette_)) throw UsageError(Format("Palette \"default\" missing in theme \"%%\"") << path); }
std::set<LogChannel*> LogManager::getChannels(std::string channelName) { std::set<LogChannel*> channels; for (channel_it i = LogChannel::getChannels()->begin(); i != LogChannel::getChannels()->end(); i++) { if ( (*i)->getName() == channelName) channels.insert(*i); } if (channels.size() > 0) return channels; LOG_ERROR(out) << "[LogManager] No channel \"" << channelName << "\" available." << std::endl; printChannels(); BOOST_THROW_EXCEPTION(UsageError() << error_message(std::string("[LogManager] Invalid channel name: ") + channelName)); }
LogLevel LogManager::getLogLevel(std::string strLevel) { if (strLevel == "all") return All; else if (strLevel == "user") return User; else if (strLevel == "debug") return Debug; else if (strLevel == "error") return Error; else if (strLevel == "none") return Quiet; else { LOG_ERROR(out) << "[Logger] Unknown log level \"" << strLevel << "\"." << std::endl; util::ProgramOptions::printUsage(); BOOST_THROW_EXCEPTION(UsageError() << error_message("[Logger] Invalid log level")); } }
void ExpectEnd() { if (!IsEmpty()) UsageError(); }
const char *ExpectNext() { if (IsEmpty()) UsageError(); return GetNext(); }
int main (int argc, char *argv[]) { /* Declare variables */ FILE *fpHeader; FILE *fpData; FILE *fpTemp; char strTag[TAG_LEN]; char strValue[VALUE_LEN]; char strHeaderDataFile[PATH_LEN]; char strImageDataFile[PATH_LEN]; char strOutputFile[PATH_LEN]; char strLog[LOG_FILE_NAME_LEN]; char strIP[IP_LEN]; char strPort[PORT_LEN]; char strCTNArgument[CTN_ARGUMENT_LEN]; char strPath[PATH_LEN]; char strCommand[COMMAND_LEN]; char *tmp; static char strMsg[MSG_LEN]; static char strBuffer[BUFFER_LEN]; static char strTemporaryFile[PATH_LEN]; int i=0; /* Initialize variables */ strLog[0] ='\0'; strIP[0] ='\0'; strPort[0] ='\0'; strPath[0] ='\0'; strOutputFile[0] ='\0'; /* Check for correct usage of the application */ if (argc != 4) { UsageError(); return ERROR_USAGE; } /* Name of the output DICOM file */ strcpy (strOutputFile, argv[3]); /* Name of pixel data file */ strcpy (strImageDataFile, argv[2]); /* Name of header information file */ strcpy (strHeaderDataFile, argv[1]); /* Open header file */ if ((fpHeader = fopen (strHeaderDataFile, "r")) == NULL) { strMsg[0]='\0'; sprintf (strMsg, "Cannot open header file : %s", strHeaderDataFile); WriteToLog (strMsg); return ERROR_FILE_OPEN; } fclose (fpHeader); /* Open data file */ if ((fpData = fopen (strImageDataFile, "rb")) == NULL) { strMsg[0]='\0'; sprintf (strMsg, "Cannot open image data file : %s", strImageDataFile); WriteToLog (strMsg); return ERROR_FILE_OPEN; } fclose (fpData); /* Set the path of the CTN execuatbles from the configuration file */ tmp = (char *)getenv("DICOM_BIN_DIR"); if (tmp == NULL) strcpy (strPath, ""); else strcpy (strPath, tmp); /* Create argument list for CTN command */ strcpy (strTemporaryFile, TEMPORARY_DICOM_FILE); sprintf (strCTNArgument, "-i %s -p %s %s", strHeaderDataFile, strImageDataFile, strTemporaryFile); sprintf (strCommand, "%s/dcm_create_object %s", strPath, strCTNArgument); /* Execute CTN command - dcm_create_object */ system (strCommand); /* Open temporary file - temp.dcm */ if ((fpTemp = fopen (strTemporaryFile, "rb")) == NULL) { strMsg[0]='\0'; sprintf (strMsg, "Cannot open temporary dicom file : %s", strTemporaryFile); WriteToLog (strMsg); return ERROR_FILE_OPEN; } fclose (fpTemp); /* Create the command */ strCommand[0] = '\0'; sprintf (strCommand, "%s/dcm_ctnto10 %s %s", strPath, strTemporaryFile, strOutputFile); /* Execute CTN command - dcm_ctnto10 */ system (strCommand); return SUCCESS; }
int main (int argc, char *argv[]) { /* Declare variables */ FILE* fpPixels; FILE* fpByteSwapped; FILE* fpParameter; static char strName[NAME_LEN]; static char strEqualTo[EQUAL_TO_LEN]; static char strTemp[VALUE_LEN]; static char strBuffer[BUFFER_LEN]; static char strMsg[MSG_LEN]; char d1; short nValue =0; short nValue1=0; short nValue2=0; short nMax=0; short nMin=255; int nRow=0; int nCol=0; int nTotalRow=0; int nTotalCol=0; int nFileCount=1; int nBits=0; int nSlices=1; int nOrientation=1; int i=0; int nCount=0; /* Check for correct usage of the application */ if (argc != 3) { UsageError(); return ERROR_USAGE; } /* Open raw pixel data file in read mode */ fpPixels = fopen (argv[1], "r+b"); if (fpPixels == NULL) { strMsg[0]='\0'; sprintf (strMsg, "Cannot open pixel data file in read mode: %s", argv[1]); WriteToLog (strMsg); return ERROR_FILE_OPEN; } /* Open converted pixel data file in write mode */ fpByteSwapped = fopen (argv[2], "w+b"); if (fpByteSwapped == NULL) { fclose (fpPixels); strMsg[0]='\0'; sprintf (strMsg, "Cannot open converted data file in write mode: %s", argv[2]); WriteToLog (strMsg); return ERROR_FILE_OPEN; } /* Open parameter file : temp.out in read mode */ /* fpParameter = fopen ("temp.out", "r+t"); fpParameter = fopen ("../../bin/temp.out", "r+t"); */ fpParameter = fopen ("temp.out", "r+t"); if (fpParameter == NULL) { fclose (fpPixels); fclose (fpByteSwapped); strMsg[0]='\0'; sprintf (strMsg, "Cannot open file - temp.out in read mode: %s", argv[2]); WriteToLog (strMsg); return ERROR_FILE_OPEN; } /* Iterate through the parameter file */ while (!feof(fpParameter)) { /* Read each line of the parameter file */ fgets (strBuffer, 100, fpParameter); /* Parse each line */ i = sscanf (strBuffer, "%s %s %[^;]s", strName, strEqualTo, strTemp); if (strcmp (strName, "Row")==0) { /* Store value of 'Row' */ nTotalRow = atoi(strTemp); } if (strcmp (strName, "Col")==0) { /* Store value of 'Col' */ nTotalCol = atoi(strTemp); } if (strcmp (strName, "FileCount")==0) { /* Store value of 'File Count' */ nFileCount = atoi(strTemp); if (nFileCount < 1) nFileCount = 1; } if (strcmp (strName, "Bits")==0) { /* Store value of 'Bits Allocated' */ nBits = atoi(strTemp); } if (strcmp (strName, "Slices")==0) { /* Store value of 'Slices' */ nSlices = atoi(strTemp); if (nSlices < 1) nSlices = 1; } } /* Calculate the number of orientation */ nOrientation = (nFileCount / nSlices); if (nOrientation < 1) nOrientation = 1; /** printf ("nTotalRow=%d\n", nTotalRow); printf ("nTotalCol=%d\n", nTotalCol); printf ("nBits=%d\n", nBits); printf ("nSlices=%d\n", nSlices); printf ("nFileCount=%d\n", nFileCount); printf ("nOrientation=%d\n", nOrientation); **/ if (nBits > 16) { sprintf (strMsg, "Bit size %d is not supported.\n", nBits); WriteToLog (strMsg); fclose (fpParameter); fclose (fpPixels); fclose (fpByteSwapped); return ERROR_FILE_OPEN; } if (nBits != 16) { /* Return for non-16 bit images */ /* fclose (fpParameter); fclose (fpPixels); fclose (fpByteSwapped); printf ("\nFile cannot be opened in write mode\n"); return -1; */ } if (fseek(fpPixels, 0, SEEK_SET) != 0) { /* Go to beginning of pixel data file */ fclose (fpPixels); fclose (fpByteSwapped); sprintf (strMsg, "Cannot reposition file pointer\n"); WriteToLog (strMsg); return -1; } if (nBits == 16) { for (i=0; i<nOrientation; ++i ) { for (nCount=1; nCount<=nSlices; ++nCount) { for (nRow = 0; nRow < nTotalRow ; nRow++) { for (nCol = 0; nCol < nTotalCol ; nCol++) { /* Read 2 bytes */ fread(&nValue, 2, 1, fpPixels); /* Swap the 2 bytes */ nValue1 = nValue2 = 0; nValue1 = nValue >> 8 ; nValue2 = nValue << 8 ; nValue2 |= nValue1 ; /* Write the swapped data in converted file */ fwrite(&nValue2, 2, 1, fpByteSwapped); } } } } fclose (fpByteSwapped); } else { for (i=0; i<nOrientation; ++i )
void main(int argc, char *argv[]) { int height, width, temp; Boolean GOT_QID = False; CONDITION cond; toplevel = XtAppInitialize( /* create application context */ &app_ctx, "print_server_display", NULL, 0, #ifdef SOLARIS (Cardinal *) & argc, #else &argc, #endif argv, NULL, NULL, 0); width = MAX_WIDTH - 10; height = MAX_HEIGHT - 10; argc--; argv++; while (argc > 0) { if (strcmp(*argv, "-w") == 0) { argc--; argv++; temp = atoi(*argv); if (temp < MIN_WIDTH) { fprintf(stderr, "Height must be > %d\n", MIN_WIDTH); UsageError(); exit(0); } if (temp > MAX_WIDTH) { fprintf(stderr, "Height must be < %d\n", MAX_WIDTH); UsageError(); exit(0); } width = temp; argc--; argv++; } else if (strcmp(*argv, "-h") == 0) { argc--; argv++; temp = atoi(*argv); if (temp < MIN_HEIGHT) { fprintf(stderr, "Height must be > %d\n", MIN_HEIGHT); UsageError(); exit(0); } if (temp > MAX_HEIGHT) { fprintf(stderr, "Height must be < %d\n", MAX_HEIGHT); UsageError(); exit(0); } height = temp; argc--; argv++; } else if (strcmp(*argv, "-v") == 0) { argc--; argv++; (void) COND_EstablishCallback(cond_CB); } else { if (argc != 1) { fprintf(stderr, "Only the last parameter is a none switch\n"); UsageError(); exit(0); } queue_id = atoi(*argv); if (queue_id == 0) { fprintf(stderr, "Invalid queueu ID\n"); UsageError(); exit(0); } argc--; argv++; GOT_QID = True; } } if (GOT_QID == False) { fprintf(stderr, "Error: Missing QID\n"); UsageError(); exit(0); } THR_Init(); /* The print_server_display creates a GQ with the specified ID */ cond = GQ_InitQueue(queue_id, 128, sizeof(GQ_ELEM)); if (cond != GQ_NORMAL) { fprintf(stderr, "GQ_InitQueue failed to create GQ with ID : %d\n", queue_id); COND_DumpConditions(); exit(1); } /* now get hold of the just created GQ */ cond = GQ_GetQueue(queue_id, sizeof(GQ_ELEM)); switch (cond) { case GQ_SHAREDMEMORYFAIL: fprintf(stderr, "GQ Shared Memory failed\n"); exit(0); case GQ_FILEACCESSFAIL: fprintf(stderr, "GQ File Access failed\n"); exit(0); case GQ_BADELEMSIZE: fprintf(stderr, "GQ Bad Element Size\n"); exit(0); case GQ_UNIMPLEMENTED: fprintf(stderr, "GQ Unimplemented\n"); exit(0); case GQ_NORMAL: break; } session_list = LST_Create(); printf("width = %d, height = %d\n", width, height); createMainWin(); XtRealizeWidget(toplevel); DISP_Initialize(toplevel, width, height); /* DISP_CreateSession("1.2.840.113654.2.3.1993.9.123.9.3221", "test", &session_list); DISP_AddBox("test", "PRN_13674.2", &session_list); DISP_AddBox("test2", "PRN_13674.2", &session_list); DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3226", "PRN_13674.5", &session_list); DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3225", "PRN_13674.4", &session_list); DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3226", "PRN_13674.3", &session_list); */ /*lint -e64*/ XtAppAddTimeOut(app_ctx, TIMEOUT, pollQueue, NULL); /*lint +e64*/ XtAppMainLoop(app_ctx); THR_Shutdown(); }
int main(int argc, char *argv[]) { int verbose = 0; bool printBLIF = false; bool printDot = false; bool printStatistics = false; int cycles = 0; int outputstyle = 0; bool testv = false; bool printVerilog = false; std::ifstream testvectors; --argc; ++argv; try { while (argc > 0 && argv[0][0] == '-') { switch (argv[0][1]) { case 'b': printBLIF = true; break; case 'd': printDot = true; break; case 's': printStatistics = true; break; case 'V': --argc; ++argv; if (argc == 0) throw UsageError(); verbose = atoi(argv[0]); break; case 'c': --argc; ++argv; if (argc == 0) throw UsageError(); cycles = atoi(argv[0]); break; case 'o': --argc; ++argv; if (argc == 0) throw UsageError(); outputstyle = atoi(argv[0]); break; case 't': --argc; ++argv; if (argc == 0) throw UsageError(); testv = true; testvectors.open(argv[0]); break; case 'v': printVerilog = true; break; default: throw UsageError(); } --argc; ++argv; } if (argc > 1) throw UsageError(); { BLIF::Netlist *n; if (argc == 1) { std::ifstream i(argv[0]); if (!i.is_open()) { std::cerr << "could not open " << argv[0] << std::endl; return 1; } n = BLIF::read_blif(i); i.close(); } else { n = BLIF::read_blif(std::cin); } if (printBLIF) print_blif(std::cout, *n); if (printDot) print_dot(std::cout, *n); if (printVerilog) print_verilog(std::cout, *n); if (printStatistics) { unsigned int gates = 0; unsigned int inputs = 0; unsigned int outputs = 0; unsigned int latches = 0; for ( std::vector<BLIF::Gate*>::const_iterator i = n->gates.begin() ; i != n->gates.end() ; i++ ) { if ( (*i)->is_input ) inputs++; if ( (*i)->is_output ) outputs++; if ( (*i)->is_latch ) latches++; if ( !( (*i)->is_input || (*i)->is_latch) ) gates++; } std::cerr << "gates: " << gates << " latches: " << latches << " inputs: " << inputs << " outputs: " << outputs << std::endl; } if (cycles > 0 || testv) { // Run simulation BLIF::Simulator sim(*n); sim.debug = verbose & 1; if (outputstyle == 1) { for ( std::vector<BLIF::Gate*>::const_iterator j = sim.outputs.begin() ; j != sim.outputs.end() ; j++ ) std::cout << (*j)->name << ' '; for ( std::vector<BLIF::Gate*>::const_iterator j = sim.latches.begin() ; j != sim.latches.end() ; j++ ) std::cout << (*j)->name << ' '; std::cout << '\n'; } for ( int i = 0 ; cycles > 0 ? i < cycles : true ; i++ ) { if ( testv ) { std::string line; getline(testvectors, line); if (testvectors.fail()) break; if ( line.size() < sim.inputs.size() ) { std::cerr << "Not enough inputs (" << line.size() << '<' << sim.inputs.size() << ") in test vector file\n"; break; } std::string::const_iterator j = line.begin(); for ( std::vector<BLIF::Gate*>::const_iterator i = sim.inputs.begin() ; i != sim.inputs.end() ; j++ ) { if ((*j) != ' ') { sim.setInput(*i, (*j) == '1'); i++; } } } sim.simulate(); switch (outputstyle) { case 1: for ( std::vector<BLIF::Gate*>::const_iterator j = sim.outputs.begin() ; j != sim.outputs.end() ; j++ ) std::cout << (sim.getOutput(*j) ? '1' : '0'); std::cout << ' '; for ( std::vector<BLIF::Gate*>::const_iterator j = sim.latches.begin() ; j != sim.latches.end() ; j++ ) std::cout << (sim.getLatch(*j) ? '1' : '0'); std::cout << '\n'; break; default: { char buf[5]; sprintf(buf, "%4d", i); std::cout << buf; for ( std::vector<BLIF::Gate*>::const_iterator j = sim.outputs.begin() ; j != sim.outputs.end() ; j++ ) std::cout << ' ' << (*j)->name << '=' << (sim.getOutput(*j) ? '1' : '0'); std::cout << '\n'; } break; } } } } } catch (UsageError &) { std::cerr << "Usage: cec-blifutil [-b] [-d] [-s] [-V <level>] [-c <cycles>] [-o <style>] [-v] [<file.blif>]\n" "-v Print Verilog version of input netlist\n" "-b Print BLIF version of input netlist\n" "-d Print dot version of input\n" "-s Print statistics on the netlist\n" "-c <cycles> Simulate for the given number of cycles\n" "-t <vectorfile> Use this file of test vectors as input stimuli\n" "-o <style> Set the simulation output style to 0, 1, 2, etc.\n" "-V <level> Set verbosity to <level>\n" ; return 1; } return 0; }
int main (int argc, char *argv[]) { /* Declare variables */ static BOOLEAN bQuiet; static BOOLEAN bPing; static char strTag[TAG_LEN]; static char strValue[VALUE_LEN]; static char strAETitleExternal[AE_TITLE_LEN]; static char strAETitleCTN[AE_TITLE_LEN]; static char strIP[IP_LEN]; static char strPort[PORT_LEN]; static char strCTNArgument[CTN_ARGUMENT_LEN]; static char strPath[PATH_LEN]; static char strCommand[COMMAND_LEN]; static char strImage[IMAGE_NAME_LEN]; static char strMsg[MSG_LEN]; static char strConfFile[PATH_LEN]; static char strBuffer[BUFFER_LEN+2]; static char *dcmFile; char *tmp; FILE *fpConf; static int i=0; static int ret; /* Initialize variables */ strCTNArgument[0] ='\0'; /* The argument list of CTN command */ strCommand[0] ='\0'; /* The CTN command to start image server */ strTag[0] ='\0'; /* Tag of the parameter in configuration file */ strValue[0] ='\0'; /* Value of the corresponding tag */ strImage[0] ='\0'; /* Image sent to the server */ bQuiet = TRUE;/* send_image will not run in quiet mode */ bPing = FALSE; /* Set default values to tag-values */ /* AE title of Client Application */ strcpy (strAETitleExternal, DEFAULT_STR_AE_TITLE_EXTERNAL); /* AE Title of CTN Application */ strcpy (strAETitleCTN, DEFAULT_STR_AE_TITLE_CTN); /* IP address of the system */ strcpy (strIP, DEFAULT_STR_HOST); /* TCP/IP port of the system */ strcpy (strPort, DEFAULT_STR_PORT); /* The path of CTN binary */ strcpy (strPath, DEFAULT_STR_CTN_BIN_PATH); /* Check for correct usage of the application */ if( argc < 2 ) { UsageError(); return ERROR_USAGE; } dcmFile = NULL; i = 1; while (i < argc && argv[i][0] == '-') { switch (*(argv[i] + 1)) { case 'v': bQuiet = FALSE; break; case 'p': bPing = TRUE; break; default: UsageError(); return ERROR_USAGE; break; } i++; } if (i >= argc) { if (!bPing) { UsageError(); return ERROR_USAGE; } } else dcmFile = argv[i]; if (dcmFile == NULL) { if (bPing) dcmFile = "dummy"; else return ERROR_USAGE; } /* NB: these were set by the script dicom_store */ tmp = (char *)getenv("DICOM_BIN_DIR"); if (tmp != NULL) { sprintf (strPath, "%s/", tmp); } tmp = (char *)getenv("DICOM_CONF_DIR"); if (tmp != NULL) sprintf (strConfFile, "%s/%s", tmp, STORE_IMAGE_CONF); else sprintf (strConfFile, "%s", STORE_IMAGE_CONF); /* Open configuration file */ fpConf = fopen (strConfFile, "r"); if (fpConf == NULL) { strMsg[0]='\0'; sprintf (strMsg, "Cannot open configuration file : %s", STORE_IMAGE_CONF); WriteToLog (strMsg); } if (fpConf != NULL) { /* Read the configuration file, if it exists */ while (!feof (fpConf) ) { if (feof(fpConf) != 0) { break; } strTag[0]=0; strValue[0]=0; strBuffer[0]=0; /* Read each line of the configuration file */ fgets (strBuffer, BUFFER_LEN, fpConf); /* Skip lines which starts with '#' */ if (strBuffer[0]=='#' ) { continue; } /* Assign values to tags and its value */ sscanf (strBuffer, "%s : %s", strTag, strValue); if(strcmp (strTag, "SCU_TITLE") == 0) { /* Read the AE Title of Client Application from the configuration file */ sprintf (strAETitleExternal, " -aet %s ", strValue); } else if(strcmp (strTag, "AE_TITLE") == 0) { /* Read the AE Title of CTN Application from the configuration file */ sprintf (strAETitleCTN, " -aec %s ", strValue); } else if(strcmp (strTag, "HOST") == 0) { /* Read the TCP/IP address from the configuration file */ sprintf (strIP, " %s ", strValue); } else if(strcmp (strTag, "PORT") == 0) { /* Read the TCP/IP port from the configuration file */ sprintf (strPort, " %s ", strValue); } } fclose(fpConf); } /* Create the argument list for the CTN command : send_image */ if (bPing) // sprintf (strCTNArgument, "%s %s %s %s ", strAETitleExternal, strAETitleCTN, strIP, strPort); sprintf (strCTNArgument, " %s %s %s %s", strIP, strPort, strAETitleCTN, strAETitleExternal); else // sprintf (strCTNArgument, "%s %s %s %s %s ", strAETitleExternal, strAETitleCTN, strIP, strPort, dcmFile); sprintf (strCTNArgument, " %s %s %s %s ", strIP, strPort, strAETitleCTN,strAETitleExternal); // sprintf (strCTNArgument, " %s %s %s %s %s/*.dcm ", strIP, strPort, strAETitleCTN,strAETitleExternal, dcmFile); /* Create the CTN command, along with arguments which is to be executed */ /* The variable 'bQuiet' is preserved for later use, presently the */ /* application is always run in non-quiet mode */ if (bQuiet) { if (bPing) // sprintf (strCommand, "%sdicom_echo -r 0 %s ", strPath, strCTNArgument); sprintf (strCommand, "%sechoscu %s ", strPath, strCTNArgument); else // sprintf (strCommand, "%ssend_image -q %s ", strPath, strCTNArgument); // sprintf (strCommand, "%sstorescu %s ", strPath, strCTNArgument); sprintf (strCommand, "find %s -name \"*.dcm\" | xargs %sstorescu %s ", dcmFile, strPath, strCTNArgument); } else { if (bPing) // sprintf (strCommand, "%sdicom_echo -r 0 -v %s ", strPath, strCTNArgument); sprintf (strCommand, "%sechoscu -v %s ", strPath, strCTNArgument); else // sprintf (strCommand, "%ssend_image -v %s ", strPath, strCTNArgument); // sprintf (strCommand, "%sstorescu -v %s ", strPath, strCTNArgument); sprintf (strCommand, "find %s -name \"*.dcm\" | xargs %sstorescu -v %s ", dcmFile, strPath, strCTNArgument); } strMsg[0]='\0'; sprintf (strMsg, "Attempting to send image...\n\tExecuting ... %s", strCommand); WriteToLog (strMsg); /* Execute the CTN command 'send_image' to send images in server */ ret = system (strCommand); if (ret == SUCCESS) ret = 0; else ret = 1; printf("%d\n", ret); return (ret); }
void LogManager::init() { // set global log level if (!logLevel) { setGlobalLogLevel(User); out.setLogLevel(User); } else { LOG_DEBUG(out) << "[LogManager] " << logLevel.getLongParam() << " command-line option detected" << std::endl; std::string verbosity = logLevel; setGlobalLogLevel(getLogLevel(verbosity)); LOG_DEBUG(out) << "[LogManager] Loglevel set to \"" << verbosity << "\"" << std::endl; } if (showChannels) { printChannels(); exit(0); } // read from program options Logger::showChannelPrefix(showChannelPrefix); Logger::showThreadId(showThreadId); // set channel log levels if (channelLevel) { LOG_DEBUG(out) << "[LogManager] " << channelLevel.getLongParam() << " command-line option detected" << std::endl; std::string channelLevels = channelLevel; while (channelLevels.length() > 0) { size_t pos_eq = channelLevels.find_first_of("="); LOG_ALL(out) << "[LogManager] Found '=' at " << pos_eq << std::endl; if (pos_eq == std::string::npos) { LOG_ERROR(out) << "[LogManager] Invalid " << channelLevel.getLongParam() << " syntax." << std::endl; util::ProgramOptions::printUsage(); BOOST_THROW_EXCEPTION(UsageError() << error_message("[LogManager] Invalid command line syntax")); } std::string name = channelLevels.substr(0, pos_eq); channelLevels = channelLevels.substr(pos_eq + 1, channelLevels.length() - 1); std::string level; size_t pos_co = channelLevels.find_first_of(","); if (pos_co == std::string::npos) { LOG_ALL(out) << "[LogManager] no further channels" << std::endl; level = channelLevels.substr(0, channelLevels.length()); channelLevels = ""; } else { LOG_ALL(out) << "[LogManager] ',' detected, there are further channels at " << pos_co << std::endl; level = channelLevels.substr(0, pos_co); channelLevels = channelLevels.substr(pos_co + 1, channelLevels.length() - 1); LOG_ALL(out) << "[LogManager] remaining argument " << channelLevels << std::endl; } std::set<LogChannel*> channels = getChannels(name); for (channel_it i = channels.begin(); i != channels.end(); i++) (*i)->setLogLevel(getLogLevel(level)); LOG_DEBUG(out) << "[LogManager] log-level of channel \"" << name << "\" set to \"" << level << "\"" << std::endl; } } // redirect channels to files if (channelToFile) { LOG_DEBUG(out) << "[LogManager] " << channelToFile.getLongParam() << " command-line option detected" << std::endl; std::string channelFiles = channelToFile; while (channelFiles.length() > 0) { size_t pos_eq = channelFiles.find_first_of("="); if (pos_eq == std::string::npos) { LOG_ERROR(out) << "[LogManager] Invalid " << channelToFile.getLongParam() << " syntax." << std::endl; util::ProgramOptions::printUsage(); BOOST_THROW_EXCEPTION(UsageError() << error_message("[LogManager] Invalid command line syntax")); } std::string name = channelFiles.substr(0, pos_eq); channelFiles = channelFiles.substr(pos_eq + 1, channelFiles.length() - 1); std::string file; size_t pos_co = channelFiles.find_first_of(","); if (pos_co == std::string::npos) { file = channelFiles.substr(0, channelFiles.length()); channelFiles = ""; } else { file = channelFiles.substr(0, pos_co); channelFiles = channelFiles.substr(pos_co + 1, channelFiles.length() - 1); } std::set<LogChannel*> channels = getChannels(name); for (channel_it i = channels.begin(); i != channels.end(); i++) (*i)->redirectToFile(file); LOG_DEBUG(out) << "[LogManager] channel \"" << name << "\" redirected to file \"" << file << "\"" << std::endl; } } #ifdef HAVE_GIT_SHA1 LOG_USER(out) << "[LogManager] git sha1 of this build: " << __git_sha1 << std::endl; #endif }