int main(int argc,char** argv){ char line[MAX_LINE_SIZE]; while((fgets(line,MAX_LINE_SIZE,stdin))!= NULL){ populateDB(line,size); ++size; } if (argc == 1){ printSyntax(); return 1; } if (strcmp(argv[1],"-a") == 0) listAllUC(); else if (strcmp(argv[1],"-b")== 0) listAllUCObligatory(); else if (strcmp(argv[1],"-c")== 0) listAllUCComple(); else if (strcmp(argv[1],"-d")== 0){ if (argc == 3) listDepUC(argv[2]); }else if (strcmp(argv[1],"-o")== 0) listAllUCOptative(); else if (strcmp(argv[1],"-s")== 0){ if (argc == 3) listFromSemester(atoi(argv[2])); }else printSyntax(); return 1; }
/** * Processes the args sent to main. */ int processArgs(int argc, char *argv[ ]) { if (argc < 3) { printSyntax(); return 0; } //if (strcmp(argv[1], "-edit") == 0) //{ // for (int i = 2; i < argc; ++i) // { // int result = checkOut(argv[i]); // if (result != 0) // return result; // } //} //else if (strcmp(argv[1], "-submit") == 0) //{ // for (int i = 2; i < argc; ++i) // { // int result = checkIn(argv[i]); // if (result != 0) // return result; // } //} if (strcmp(argv[1], "-compile") == 0) { Filename filename; for (int i = 2; i < argc; ++i) { File::setBasePath(""); filename.clear(); filename.setExtension(TEMPLATE_DEFINITION_EXTENSION); filename.setName(argv[i]); File fp(filename, "rt"); if (!fp.isOpened()) { fprintf(stderr, "cannot open file %s\n", argv[i]); return -1; } else { File::setBasePath(filename.getPath().c_str()); int result = parseTemplateDefinitionFile(fp); fp.close(); if (result != 0) return result; } } } else { printSyntax(); return 0; } return 0; } // processArgs
void printSyntax(struct tcl_syntax_stmt *stmt,int depth) { struct tcl_syntax_word *word; struct tcl_syntax_sub *sub; int i; for(;stmt;stmt=stmt->next) { for(i=0;i<depth;i++) {printf(" ");} printf("stmt:\n"); for(word=stmt->words;word;word=word->next) { for(i=0;i<depth+1;i++) {printf(" ");} printf(" word:\n"); for(sub=word->subs;sub;sub=sub->next) { for(i=0;i<depth+2;i++) {printf(" ");} if(sub->type==tcl_syntax_sub_str) { printf(" str: '%s'\n",sub->valStr); } else if(sub->type==tcl_syntax_sub_var) { printf(" var: '%s'\n",sub->valStr); } else if(sub->type==tcl_syntax_sub_stmt) { printf(" cmd:\n"); printSyntax(sub->valStmt,depth+1); } } } } }
int main(int argc, char* argv[]) { int i; int res = -1; void* bin; size_t binSize; void* algo; size_t algoSize; if(argc != 3) return printSyntax(); if((algo = loadFile(argv[1], &algoSize)) == NULL) return EXIT_FAILURE; if((bin = loadFile(argv[2], &binSize)) == NULL) return EXIT_FAILURE; res = linearize(algo, algoSize, bin, binSize); // add some padding to force the DFU statemachine play through for(i = 0; i < 2048; i++) printf("%c", 0xff); return (res < 0) ? EXIT_FAILURE : EXIT_SUCCESS; }
int main(int argc, char *argv[]) { #ifdef HAS_LOFARSTMAN register_lofarstman(); #endif // HAS_LOFARSTMAN int argi = 1; bool doFlag = false; enum Method { StddevMethod, RFIPercentangeMethod } method = StddevMethod; while(argi < argc && argv[argi][0] == '-') { std::string p(argv[argi]+1); if(p == "flag") doFlag = true; else if(p == "method") { ++argi; std::string m = argv[argi]; if(m == "stddev") method = StddevMethod; else if(m == "percentage") method = RFIPercentangeMethod; else throw std::runtime_error("Unknown method given"); } else throw std::runtime_error("Unknown parameter"); ++argi; } if(argi >= argc) { printSyntax(std::cerr, argv); return -1; } else { const char* filename = argv[argi]; std::set<size_t> badAntennas; switch(method) { case StddevMethod: badAntennas = detectStddev(filename); break; case RFIPercentangeMethod: badAntennas = detectRFIPercentage(filename); break; } if(doFlag) flagAntennas(filename, badAntennas); return 0; } }
int main(int argc, char *argv[]) { #ifdef HAS_LOFARSTMAN register_lofarstman(); #endif // HAS_LOFARSTMAN if(argc < 2) { printSyntax(std::cerr, argv); return -1; } else { const std::string action = argv[1]; if(action == "help") { if(argc != 3) { printSyntax(std::cout, argv); } else { std::string helpAction = argv[2]; if(helpAction == "help") { printSyntax(std::cout, argv); } else if(helpAction == "collect") { std::cout << "Syntax: " << argv[0] << " collect [-a] <ms> [quack timesteps] [list of antennae]\n\n" "The collect action will go over a whole measurement set and \n" "collect the default statistics. It will write the results in the \n" "quality subtables of the main measurement set.\n\n" "Currently, the default statistics are:\n" "\tRFIRatio, Count, Mean, SumP2, DCount, DMean, DSumP2.\n" "The subtables that will be updated are:\n" "\tQUALITY_KIND_NAME, QUALITY_TIME_STATISTIC,\n" "\tQUALITY_FREQUENCY_STATISTIC and QUALITY_BASELINE_STATISTIC.\n\n" "-c will use the CORRECTED_DATA column.\n"; } else if(helpAction == "summarize") { std::cout << "Syntax: " << argv[0] << " summarize <ms>\n\n" "Gives a summary of the statistics in the measurement set.\n"; } else if(helpAction == "query_b") { std::cout << "Syntax: " << argv[0] << " query_b <kind> <ms>\n\n" "Prints the given statistic for each baseline.\n"; } else if(helpAction == "query_t") { std::cout << "Syntax: " << argv[0] << " query_t <kind> <ms>\n\n" "Print the given statistic for each time step.\n"; } else if(helpAction == "query_g") { std::cout << "Syntax " << argv[0] << " query_g <kind> <ms>\n\n" "Print the given statistic for this measurement set.\n"; } else if(helpAction == "combine") { std::cout << "Syntax: " << argv[0] << " combine <target_ms> [<in_ms> [<in_ms> ..]]\n\n" "This will read all given input measurement sets, combine the statistics and \n" "write the results to a target measurement set. The target measurement set should\n" "not exist beforehand.\n"; } else if(helpAction == "histogram") { std::cout << "Syntax: " << argv[0] << " histogram <query> <ms>]\n\n" "Query can be:\n" "\trfislope - performs linear regression on the part of the histogram that should contain the RFI.\n" "\t Reports one value per polarisation.\n"; } else if(helpAction == "remove") { std::cout << "Syntax: " << argv[0] << " remove [ms]\n\n" "This will completely remove all quality tables from the measurement set.\n"; } else { std::cerr << "Unknown action specified in help.\n"; return -1; } } } else if(action == "collect" || action == "mwacollect") { bool mwacollect = (action == "mwacollect"); if(argc < 3) { std::cerr << "collect actions needs one or two parameters (the measurement set)\n"; return -1; } else { bool histograms = (std::string(argv[2]) == "-h"); int argi = histograms ? 3 : 2; std::string filename = argv[argi]; size_t flaggedTimesteps = 0; ++argi; std::set<size_t> flaggedAntennae; if(argi != argc) { flaggedTimesteps = atoi(argv[argi]); ++argi; while(argi != argc) { flaggedAntennae.insert(atoi(argv[argi])); ++argi; } } actionCollect(filename, histograms ? CollectHistograms : CollectDefault, mwacollect, flaggedTimesteps, flaggedAntennae); } } else if(action == "combine") { if(argc < 3 ) { std::cerr << "combine actions needs at least one parameter.\n"; return -1; } else { std::string outFilename = argv[2]; std::vector<std::string> inFilenames; for(int i=3;i<argc;++i) inFilenames.push_back(argv[i]); actionCombine(outFilename, inFilenames); } } else if(action == "histogram") { if(argc != 4) { std::cerr << "histogram actions needs two parameters (the query and the measurement set)\n"; return -1; } else { actionHistogram(argv[3], argv[2], false); } } else if(action == "summarize") { if(argc != 3) { std::cerr << "summarize actions needs one parameter (the measurement set)\n"; return -1; } else { actionSummarize(argv[2]); } } else if(action == "summarizerfi") { if(argc != 3) { std::cerr << "summarizerfi actions needs one parameter (the measurement set)\n"; return -1; } else { actionSummarizeRFI(argv[2]); } } else if(action == "query_g") { if(argc != 4) { std::cerr << "Syntax for query global stat: 'aoquality query_g <KIND> <MS>'\n"; return -1; } else { actionQueryGlobalStat(argv[2], argv[3]); } } else if(action == "query_b") { if(argc != 4) { std::cerr << "Syntax for query baselines: 'aoquality query_b <KIND> <MS>'\n"; return -1; } else { actionQueryBaselines(argv[2], argv[3]); } } else if(action == "query_t") { if(argc != 4) { std::cerr << "Syntax for query times: 'aoquality query_t <KIND> <MS>'\n"; return -1; } else { actionQueryTime(argv[2], argv[3]); return 0; } } else if(action == "remove") { if(argc != 3) { std::cerr << "Syntax for removing quality tables: 'aoquality remove <MS>'\n"; return -1; } else { actionRemove(argv[2]); return 0; } } else { std::cerr << "Unknown action '" << action << "'.\n\n"; printSyntax(std::cerr, argv); return -1; } return 0; } }
int main(int argc, char* argv[]) { HANDLE fd; int res = -1; void* bin; size_t binSize; if(argc < 3) return printSyntax(); if(strcmp(argv[2], "detect") == 0) { if(argc != 3) return printSyntax(); if((fd = serialOpen(argv[1])) == INVALID_HANDLE_VALUE) return EXIT_FAILURE; res = 0; if(res >= 0) res = osmoSDRDetect(fd); if(res >= 0) res = osmoSDRPrintUID(fd, 0); if(res >= 0) res = osmoSDRPrintUID(fd, 1); serialClose(fd); } else if(strcmp(argv[2], "blink") == 0) { if(argc != 3) return printSyntax(); if((fd = serialOpen(argv[1])) == INVALID_HANDLE_VALUE) return EXIT_FAILURE; res = 0; if(res >= 0) res = osmoSDRDetect(fd); if(res >= 0) res = osmoSDRBlink(fd); serialClose(fd); } else if(strcmp(argv[2], "ramload") == 0) { if(argc != 4) return printSyntax(); if((bin = loadFile(argv[3], &binSize)) == NULL) return EXIT_FAILURE; if((fd = serialOpen(argv[1])) == INVALID_HANDLE_VALUE) return EXIT_FAILURE; res = 0; if(res >= 0) res = osmoSDRDetect(fd); if(res >= 0) res = osmoSDRRamLoad(fd, bin, binSize); serialClose(fd); } else if(strcmp(argv[2], "flashfpga") == 0) { void* algo; size_t algoSize; if(argc != 5) return printSyntax(); if((algo = loadFile(argv[3], &algoSize)) == NULL) return EXIT_FAILURE; if((bin = loadFile(argv[4], &binSize)) == NULL) return EXIT_FAILURE; if((fd = serialOpen(argv[1])) == INVALID_HANDLE_VALUE) return EXIT_FAILURE; res = 0; if(res >= 0) res = osmoSDRDetect(fd); if(res >= 0) res = osmoSDRFlashFPGA(fd, algo, algoSize, bin, binSize); serialClose(fd); } else if(strcmp(argv[2], "flashmcu") == 0) { if(argc != 4) return printSyntax(); if((bin = loadFile(argv[3], &binSize)) == NULL) return EXIT_FAILURE; if((fd = serialOpen(argv[1])) == INVALID_HANDLE_VALUE) return EXIT_FAILURE; res = 0; if(res >= 0) res = osmoSDRDetect(fd); if(res >= 0) res = osmoSDRFlashMCU(fd, bin, binSize); serialClose(fd); } else { return printSyntax(); } return (res < 0) ? EXIT_FAILURE : EXIT_SUCCESS; }
int main() { char *txt=string_from_file("test.tcl"); if (!txt) { return 1; } bool err; struct parmac *stk,*p; struct tcl_parser tp; char closings[256]; int stkNum=2048; stk=(struct parmac*)malloc(sizeof(struct parmac)*stkNum); p=stk; tp.errMsg=NULL; tp.markStart=txt; tp.markEnd=txt; tp.pos=0; tp.row=0; tp.col=0; tp.closingStart=closings; tp.closingEnd=endof(closings); tp.closingIt=NULL; tp.recurseDepth=-1; tp.buildStk=NULL; tp.rootStmt=NULL; // tcl_parser_main_machine(p,txt); // int c = 0; while(parmac_run(&p,&tp,&err)) { // c++; // if(p+1==stk+sizeof(struct parmac)*stkNum) { // stkNum*=2; // int n=(p-stk);///sizeof(struct parmac); // stk=(struct parmac*)realloc(stk,sizeof(struct parmac)*stkNum); // p=stk+n; // printf("%i %p %p\n",n,p,stk+n); // } } printf("\n"); if(err) { printf("Error.\n"); if(tp.errMsg!=NULL) { printf(tp.errMsg); } } // printSyntax(tp.rootStmt,0); printf("done %p.\n",p); #ifdef _MSC_VER system("pause"); #endif return 0; }
int main (int argc, char **argv) { /* Local variables */ char input[CHAR_FNAME_LENGTH+1]; int printtime = NO; /* print time after each step? */ int save_tmp = DUMMY; /* save temporary files? */ int verbose = NO; /* print info during processing? */ int debug = NO; /* print debug statements during processing? */ int quiet = NO; /* suppress STDOUT messages? */ int too_many = NO; /* too many command-line arguments? */ int onecpu = NO; /* suppress openmp usage by using only 1 thread?*/ int i, j; /* loop indexes */ /* Function definitions */ void c_irafinit (int, char **); int CalWf3Run (char *, int, int, int, int, int); void WhichError (int); /* Initialize status to OK and MsgText to null */ status = WF3_OK; MsgText[0] = '\0'; input[0] = '\0'; /* Initialize IRAF environment */ c_irafinit(argc, argv); PtrRegister ptrReg; initPtrRegister(&ptrReg); /* Command line arguments: ** 0. Check for --version option ** 1. input file name ** 2. print time? ** 3. save intermediate files? ** 4. verbose? */ for (i = 1; i < argc; i++) { if (!(strcmp(argv[i],"--version"))) { printf("%s\n",WF3_CAL_VER_NUM); freeOnExit(&ptrReg); exit(0); } if (!(strcmp(argv[i],"--gitinfo"))) { printGitInfo(); freeOnExit(&ptrReg); exit(0); } if (!(strcmp(argv[i],"--help"))) { printHelp(); freeOnExit(&ptrReg); exit(0); } if (argv[i][0] == '-') { for (j = 1; argv[i][j] != '\0'; j++) { if (argv[i][j] == 't') { printtime = YES; } else if (argv[i][j] == 's') { save_tmp = YES; } else if (argv[i][j] == 'r'){ printf ("Current version: %s\n", WF3_CAL_VER); freeOnExit(&ptrReg); exit(0); } else if (argv[i][j] == 'v') { verbose = YES; } else if (argv[i][j] == 'd') { debug = NO; } else if (argv[i][j] == 'q') { quiet = YES; } else if (argv[i][j] == '1'){ onecpu = YES; } else { printf ("Unrecognized option %s\n", argv[i]); printSyntax(); freeOnExit(&ptrReg); exit (ERROR_RETURN); } } } else if (input[0] == '\0') { strcpy (input, argv[i]); } else { too_many = YES; } } if (input[0] == '\0' || too_many) { printSyntax(); freeOnExit(&ptrReg); exit (ERROR_RETURN); } /* Initialize the structure for managing trailer file comments */ InitTrlBuf (); addPtr(&ptrReg, &trlbuf, &CloseTrlBuf); trlGitInfo(); /* Copy command-line value for QUIET to structure */ SetTrlQuietMode (quiet); /* Call the CALWF3 main program */ if (CalWf3Run (input, printtime, save_tmp, verbose, debug, onecpu)) { if (status == NOTHING_TO_DO) { /* If there is just nothing to do, ** as for ACQ images, just quit. */ status = 0; sprintf (MsgText, "CALWF3 did NOT process %s", input); trlmessage (MsgText); freeOnExit(&ptrReg); exit(0); } else { /* Error during processing */ sprintf (MsgText, "CALWF3 processing NOT completed for %s", input); trlerror (MsgText); /* Provide interpretation of error for user */ WhichError (status); freeOnExit(&ptrReg); exit (ERROR_RETURN); } } /* Successful completion */ sprintf (MsgText, "CALWF3 completion for %s", input); trlmessage (MsgText); freeOnExit(&ptrReg); /* Exit the program */ exit (0); }
static void printHelp(void) { printSyntax(); }
int main (int argc, char **argv) { int status; /* zero is OK */ char *input, *output; /* file names */ int printtime = 0; /* print time after each step? */ int verbose = 0; /* print additional info? */ int too_many = 0; /* too many command-line arguments? */ int i, j; /* loop indexes */ c_irafinit (argc, argv); input = calloc (STIS_LINE+1, sizeof (char)); output = calloc (STIS_LINE+1, sizeof (char)); if (input == NULL || output == NULL) { printf ("ERROR: Can't even begin: out of memory.\n"); exit (ERROR_RETURN); } /* Get names of input and output files. */ for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { if (strcmp (argv[i], "--version") == 0) { PrVersion(); exit (0); } if (!(strcmp(argv[i],"--gitinfo"))) { printGitInfo(); exit(0); } if (!(strcmp(argv[i],"--help"))) { printHelp(); exit(0); } if (strcmp (argv[i], "-r") == 0) { PrFullVersion(); exit (0); } for (j = 1; argv[i][j] != '\0'; j++) { if (argv[i][j] == 't') { printtime = 1; } else if (argv[i][j] == 'v') { verbose = 1; } else { printf ("ERROR: Unrecognized option %s\n", argv[i]); printSyntax(); exit (1); } } } else if (input[0] == '\0') { strcpy (input, argv[i]); } else if (output[0] == '\0') { strcpy (output, argv[i]); } else { too_many = 1; } } if (input[0] == '\0' || too_many) { printSyntax(); exit (ERROR_RETURN); } if (output[0] == '\0') { if ((status = MkName (input, "_x2d", "_sx2", output, STIS_LINE))) exit (status); } /* Sum imsets. */ if ((status = CalStis8 (input, output, printtime, verbose))) { printf ("Error processing %s.\n", input); WhichError (status); } free (input); free (output); if (status) exit (ERROR_RETURN); else exit (0); }