void *interpretor( void *arg ) { char command[256]; CUBE *cube = (CUBE*)arg; printf( "Welcome to the Rubik's Cube Simulotor vers 0.1\n" "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n" ); printhelp(NULL); for(;;) { fgets(command,256,stdin); command[strlen(command)-1]=0; if(!strcmp(command,"help")) { printhelp(NULL); } else if(!strncmp(command,"help ",5)) { printhelp(command+5); } else if(!strcmp(command,"reset")) { Reset(cube); printf("OK\n"); } else if(!strcmp(command,"scramble")) { Scramble(cube); printf("OK\n"); } else if(!strcmp(command,"exit")) { exit(0); } else if(!strcmp(command,"test")) { test(cube); printf("OK\n"); } else if((!strcmp(command,"rxy"))||(!strcmp(command,"ryx"))) { r_xy(cube); printf("OK\n"); } else if((!strcmp(command,"rxy'"))||(!strcmp(command,"rxy-"))|| (!strcmp(command,"ryx'"))||(!strcmp(command,"ryx-"))) { r_xy_inv(cube); printf("OK\n"); } else if((!strcmp(command,"rxz"))||(!strcmp(command,"rzx"))) { r_xz(cube); printf("OK\n"); } else if((!strcmp(command,"rxz'"))||(!strcmp(command,"rxz-"))|| (!strcmp(command,"rzx'"))||(!strcmp(command,"rzx-"))) { r_xz_inv(cube); printf("OK\n"); } else if((!strcmp(command,"ryz"))||(!strcmp(command,"rzy"))) { r_xy(cube); printf("OK\n"); } else if((!strcmp(command,"ryz'"))||(!strcmp(command,"ryz-"))|| (!strcmp(command,"rzy'"))||(!strcmp(command,"rzy-"))) { r_xy_inv(cube); printf("OK\n"); } else if(check(command)) { Exec(cube,command); printf("OK\n"); } else { printf("Invalid command\n"); } } #ifndef _WIN32 pthread_exit(0); #endif //_WIN32 }
int main(int argc, char *argv[]) { short int x; FILE *fp; if ( ( argc < 2 ) ) { printhelp(); } if ( ( strIs(argv[1], "-h") ) | ( strIs(argv[1], "--help") ) | ( strIs(argv[1], "/?") ) ) printhelp(); for ( x = 1 ; x < argc ; x++ ) { fp = fopen(argv[x], "r"); if ( fp == NULL ) { perror("Error"); exit(errno); } extractAcctounts(fp); } decrypt(); outPasswds(); return 0; }
void process_command() { map<string, param>::iterator p; for (int i = 1; i < fArgc; i++) { if (fArgv[i][0] == '-') { if ( (strcmp(fArgv[i], "-help") == 0) || (strcmp(fArgv[i], "-h") == 0) || (strcmp(fArgv[i], "--help") == 0) ) { printhelp(); exit(1); } p = fKeyParam.find(fArgv[i]); if (p == fKeyParam.end()) { cout << fArgv[0] << " : unrecognized option " << fArgv[i] << "\n"; printhelp(); exit(1); } char* end; *(p->second.fZone) = float(strtod(fArgv[i+1], &end)); i++; } else { fFiles.push_back(fArgv[i]); } } }
int main(int argc, char* argv[]) { if( argc < 3 ) return printhelp(NULL); bool vertexShader = false, freename = false; glslopt_target languageTarget = kGlslTargetOpenGL; const char* source = 0; char* dest = 0; for( int i=1; i < argc; i++ ) { if( argv[i][0] == '-' ) { if( 0 == strcmp("-v", argv[i]) ) vertexShader = true; else if( 0 == strcmp("-f", argv[i]) ) vertexShader = false; else if( 0 == strcmp("-1", argv[i]) ) languageTarget = kGlslTargetOpenGL; else if( 0 == strcmp("-2", argv[i]) ) languageTarget = kGlslTargetOpenGLES20; else if( 0 == strcmp("-3", argv[i]) ) languageTarget = kGlslTargetOpenGLES30; } else { if( source == 0 ) source = argv[i]; else if( dest == 0 ) dest = argv[i]; } } if( !source ) return printhelp("Must give a source"); if( !init(languageTarget) ) { printf("Failed to initialize glslopt!\n"); return 1; } if ( !dest ) { dest = (char *) calloc(strlen(source)+5, sizeof(char)); snprintf(dest, strlen(source)+5, "%s.out", source); freename = true; } int result = 0; if( !compileShader(dest, source, vertexShader) ) result = 1; if( freename ) free(dest); term(); return result; }
void readoptions(int argc, char **argv, char **romfilename, int *fullscreen, tmachine *machine, video_mode *vmode, int *nosound, float *scale, int *codemasters) { int c; int option_index; struct option long_options[] = { {"fullscreen", no_argument, fullscreen, 1}, {"machine", required_argument, NULL, 't'}, {"mode", required_argument, NULL, 'm'}, {"nosound", no_argument, nosound, 1}, {"scale", required_argument, NULL, 's'}, {"codemasters", no_argument, codemasters, 1}, {"help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0} }; if(argc<=1) { printusage(); log4me_print("Try '"PACKAGE" --help' for more information.\n"); } while((c = getopt_long(argc, argv, "", long_options, &option_index))!=-1) { //printf("-> %c %d (%d)\n", c, (int)c, option_index); switch(c) { case 's': *scale = atof(optarg); if(*scale<1) { log4me_print("wrong scale parameter, set to default value\n"); *scale = DEFAULT_SCALE; } break; case 't': *machine = strcasecmp(optarg, "export")==0 ? EXPORT : JAPAN; break; case 'm': *vmode = strcasecmp(optarg, "pal")==0 ? VM_PAL : VM_NTSC; break; case 'h': printhelp(); exit(EXIT_SUCCESS); break; case '?': printhelp(); exit(EXIT_FAILURE); break; } } if(optind>=argc) { log4me_print("ROM filename missing.\n"); exit(EXIT_FAILURE); } *romfilename = argv[optind]; }
int main( int argc, char *argv[] ) { int i; /* first set all the parameters */ printf( "Enter n (0 for help): " ); scanf( "%d", &n ); if (n == 0) { printhelp(); return(0); } printf( "Enter format (0,1,2,3): " ); scanf( "%d", &out_format ); printf( "Enter MaxChild, lb , ub: " ); scanf( "%d%d%d", &mc, &lb, &ub ); if(out_format==1) outputP = 1; if(out_format==2) outputL = 1; if(out_format==3) {outputP = 1; outputL = 1;} num = 0; /* mc = n; */ if (ub < n-1 && lb < ub) omit = 1; for( i=1; i<=n; i++) chi[i]=0; /* now start the program */ if (lb > n || n > MaxSize-1) printf("Error: Invalid parameter!\n"); else for (i=1; i<=lb+1; i++) { par[i] = L[i] = nextp[i] = i-1; rChi[i] = i+1; chi[par[i]] = 1; } rChi[lb+1] = 0; if (lb < ub) Gen(lb+2, 0, 0); if (lb == ub) Gen(lb+2,lb+1,1); if (lb > ub) { printf("lower bound must be <= upper bound!\n"); return( 1 ); } printf("Total = %4d\n",num); return( 0 ); }
static void cmdline(int argc, char **argv) { int flags, opt; int nsecs, tfnd; const char *options = "hvl:"; nsecs = 0; tfnd = 0; flags = 0; while ((opt = getopt(argc, argv, options)) != -1) { switch (opt) { case 'v': printversion(argv[0]); exit(0); break; case 'l': g_dbglvl = atoi(optarg); if (g_dbglvl<0 || g_dbglvl>MAXDBGLVL) { fprintf(stderr, "Error unsuported debug level %d.\n", g_dbglvl); exit(1); } break; case 'h': default: printhelp(argv[0]); exit(1); break; } } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setWindowIcon(QIcon(":/sbicon.png")); a.setStyle(QStyleFactory::create("Fusion")); a.setApplicationName("Soundbench"); a.setApplicationDisplayName("Soundbench"); a.setApplicationVersion(QString::fromStdString(std::to_string(SBVERSION_MAJOR)+'.'+std::to_string(SBVERSION_MINOR)+'.'+std::to_string(SBVERSION_PATCH))); //Parse some arguments. std::string arg; if (argc == 2) { arg = argv[1]; if (arg == "--help" || arg == "-h") { printhelp(); return 0; } } std::cerr << "Soundbench " << SBVERSION << " (" << SBVERSION_CODENAME << ")\n"; std::cerr << "Version Series: " << SBVERSION_MAJOR << '.' << SBVERSION_MINOR << ".x\n"; if (arg == "--version" || arg == "-v") return 0; sb::ConfigManager* cfg = new sb::ConfigManager; sb::Soundbench* sb = cfg->initSoundbench(); SoundbenchUI sbui(sb, cfg); sbui.show(); std::cerr << "Soundbench loaded.\n"; int ret = a.exec(); delete sb; delete cfg; return ret; }
int main(int argc,char ** argv) { int index=0; struct option argarr[]={ { "port",1,NULL,'P' }, { "mgroup",1,NULL,'M' }, { "player",1,NULL,'p' }, { "help",1,NULL,'H' }, { NULL,0,NULL,0 } }; /* *初始化 *级别: 默认值 ,配置文件,环境变量,命令行参数 * */ int c; while(1) { c= getopt_long(argc,argv,"P:M:p:H",argarr,&index) if(c<0) switch(c) { case 'p': client_conf.revport=optarg; break; case 'M' client_conf.mgroup=optarg; break; case 'p' client_conf.player_cmd=optarg; break; case 'H' printhelp(); exit(0); break; default: abort(); break; } } pip(); fork(); // 子继承调用解码器 // 父进程 从网络上收包 发送给子进程 exit(0); }
int main(int argc, char *argv[]){ LARGE_INTEGER frequency; LARGE_INTEGER t1, t2; double elapsedTime; int ret = 0; QueryPerformanceFrequency(&frequency); QueryPerformanceCounter(&t1); if(argc != 2){ printhelp(); return EXIT_FAILURE; } startLogger("log.txt"); readSettingsFromConfigFile(argv[1]); setUpSpectrum(); logIt(DEBUG, "pathToSlice=%s", cfg.pathToSlice); logIt(DEBUG, "pathToOutputReconstruction=%s", cfg.pathToOutputReconstruction); setUpAttenuation(); logIt(INFO, "Everything set up successfully. Starting simulation..."); ret = simulation(cfg.pathToSlice, cfg.pathToOutputSinogram); reconstruction(cfg.pathToOutputSinogram, cfg.pathToOutputReconstruction); QueryPerformanceCounter(&t2); elapsedTime = (double)(t2.QuadPart - t1.QuadPart) / frequency.QuadPart; logIt(INFO, "Total computation time: %f seconds.", elapsedTime); logIt(INFO, "Reconstructed image saved as %s. Exiting...", cfg.pathToOutputReconstruction); logIt(DEBUG, "main(int argc, char *argv[]) finished."); stopLogger(); return ret; }
int main(int argc, char **argv) { int ch; /* Option character */ while (1) { ch = getopt(argc, argv, "c"); if (-1 == ch) { /* No more options, break out of while loop. */ break; } switch (ch) { case 'c': printcommand = true; break; default: printhelp(); exit(0); } /* switch ch */ } /* while 1 */ init(); wm_state = getatom("WM_STATE"); findhidden(); cleanup(); exit(0); }
int main(void){ char str[100], input[100]; // Prints Intro printf("Simple Calculator\n"); // Prints the input prompt, along with goto label to jump back to input inputPrompt: printf(">>>"); fgets(str,sizeof(str),stdin); sscanf(str, "%[^\n]",input); // printf("The input is: %s\n",input); /* Checks to see if the user wants to quit */ if(strcmp(input, "q") == 0 || strcmp(input,"Q") == 0){ printf(" Goodbye!"); exit(0); } /* Checks to see if the user asked for help */ else if(strcmp(input,"h") == 0 || strcmp(input,"H") == 0){ printhelp(); } /* If the string entered has passed all pre-checks, then send off to functions dealing with arithmetic */ else{ /* Send the user input to the function that will standardise the whitespaces to use as delimiters * (make sure there is only ever one whitespace at most) */ standardiseWhitespaces(input); // printf("After White spaces: %s\n",input); /* Run through a bunch of checks, print an error message and go back to the input prompt if something is found */ if(operatorsIncorrect(input) == TRUE || tooManyPoints(input) == TRUE || invalidCharacters(input) == TRUE) { printf(" Error: Illegal input!\n"); goto inputPrompt; } if(divideByZero(input) == TRUE){ printf(" Error: Divide by zero!\n"); goto inputPrompt; } /* Converts any e's to scientific notation */ convertFromScientificNotation(input); // printf("After Scientific Notation: %s\n",input); /* Put string through function to turn it in to post-fix notation */ convertToPostfix(input); // printf("After postfix: %s\n",input); /* Puts the postfix notation string in to the arithmetic function, which then interprets the equation, solves it , then prints it */ printf(" %lf\n",arithmetic(input)); } /* Goes to the start of the program where it prompts for input */ goto inputPrompt; }
int main(int argc, char *argv[]) { if(argc < 2) { printhelp(); return 0; } try { if(strcmp(argv[1], "copyU8") == 0 && argc > 3) copy(argv[2], argv[3], 8); else if(strcmp(argv[1], "copyS8") == 0 && argc > 3) copy(argv[2], argv[3], 9); else if(strcmp(argv[1], "copyS16") == 0 && argc > 3) copy(argv[2], argv[3], 17); else if(strcmp(argv[1], "copyU16") == 0 && argc > 3) copy(argv[2], argv[3], 16); else if(strcmp(argv[1], "copyF32") == 0 && argc > 3) copy(argv[2], argv[3], 32); else if(strcmp(argv[1], "copyF64") == 0 && argc > 3) copy(argv[2], argv[3], 64); else if(strcmp(argv[1], "rescaleIntensity") == 0 && argc > 5) rescaleIntensity(argv[2], argv[3], atof(argv[4]), atof(argv[5])); else if(strcmp(argv[1], "gaussianFilter") == 0 && argc > 4) gaussianFilter(argv[2], argv[3], atof(argv[4])); else if(strcmp(argv[1], "hessianFilter") == 0 && argc > 4) hessianFilter(argv[2], argv[3], atof(argv[4])); else if(strcmp(argv[1], "tensorHessianFilter") == 0 && argc > 4) hessianFilter(argv[2], argv[3], atof(argv[4])); else if(strcmp(argv[1], "floodFill") == 0 && argc > 8) floodFill(argv[2], argv[3], atof(argv[4]), atof(argv[5]), atoi(argv[6]), atoi(argv[7]), atoi(argv[8])); else if(strcmp(argv[1], "threshold") == 0 && argc > 5) threshold(argv[2], argv[3], atof(argv[4]), atof(argv[5])); else if(strcmp(argv[1], "multiscaleHessian") == 0 && argc > 6) multiscaleHessian(argv[2], argv[3], atof(argv[4]), atof(argv[5]), atoi(argv[6])); else if(strcmp(argv[1], "minIntensity") == 0 && argc > 2) minIntensity(argv[2]); else if(strcmp(argv[1], "maxIntensity") == 0 && argc > 2) maxIntensity(argv[2]); else if(strcmp(argv[1], "upscaleForCenteredSkeleton") == 0 && argc > 3) upscaleForCenteredSkeleton(argv[2], argv[3]); else if(strcmp(argv[1], "skeletonFromBinary") == 0 && argc > 3) skeletonFromBinary(argv[2], argv[3]); else if(strcmp(argv[1], "centeredSkeleton") == 0 && argc > 3) centeredSkeleton(argv[2], argv[3]); else if(strcmp(argv[1], "whiteForegroundHoleFill") == 0 && argc > 3) whiteForegroundHoleFill(argv[2], argv[3]); else if(strcmp(argv[1], "blackForegroundHoleFill") == 0 && argc > 3) blackForegroundHoleFill(argv[2], argv[3]); else if(strcmp(argv[1], "whiteTopHat") == 0 && argc > 4) whiteTopHat(argv[2], argv[3], atof(argv[4])); else if(strcmp(argv[1], "blackTopHat") == 0 && argc > 4) blackTopHat(argv[2], argv[3], atof(argv[4])); else if(strcmp(argv[1], "dilate") == 0 && argc > 4) dilate(argv[2], argv[3], atof(argv[4])); else if(strcmp(argv[1], "erode") == 0 && argc > 4) erode(argv[2], argv[3], atof(argv[4])); else if(strcmp(argv[1], "skeletonToTreeIntSpace") == 0 && argc > 4) skeletonToTreeIntSpace(argv[2], argv[3], atoi(argv[4])); else if(strcmp(argv[1], "skeletonToTree") == 0 && argc > 4) skeletonToTree(argv[2], argv[3], atoi(argv[4])); else if(strcmp(argv[1], "estimateDiameters") == 0 && argc > 5) estimateDiameters(argv[2], argv[3], argv[4], atoi(argv[5])); else if(strcmp(argv[1], "skeletonToTreeIntSpace") == 0 && argc > 3) skeletonToTreeIntSpace(argv[2], argv[3], 0); else if(strcmp(argv[1], "skeletonToTree") == 0 && argc > 3) skeletonToTree(argv[2], argv[3], 0); else if(strcmp(argv[1], "estimateDiameters") == 0 && argc > 4) estimateDiameters(argv[2], argv[3], argv[4], 0); else if(strcmp(argv[1], "info") == 0 && argc > 1) info(argv[0]); else std::cout << "Unknown command " << argv[1] << " or invalid arguments" << std::endl; } catch( itk::ExceptionObject & err ) { std::cerr << "ITK exception" << std::endl; std::cerr << err << std::endl; return -2; } catch(...) { std::cerr << "Unknown exception" << std::endl; return -1; } return 0; }
int main(int argc, char **argv) { int z; int opt; int port; int buffersize = 256; char buffer[buffersize]; int addrSize = 128; char addr[addrSize]; memset (addr, '\0', addrSize); int cmdSize = 256; char command[cmdSize]; memset (command, '\0', cmdSize); //Defaults sprintf(addr,"127.0.0.1"); port = 4949; //INCLUDED ARGUMENTS FROM CLI while((opt = getopt(argc, argv, "a:p:c:v:")) > 0) { switch(opt) { case 'a': snprintf(addr, addrSize-1, "%s", (char*) optarg); break; case 'p': port = atoi(optarg); break; case 'c': snprintf(command, cmdSize-1, "%s", (char*) optarg); break; case 'v': printf("coffeec version 2.5\n"); default: printhelp(); exit(0); } } if(strlen(command)<=0) { fprintf(stderr, "No command given\n"); return 0; } z = sendMessage(addr, port, command, buffer, buffersize); if(z) printf("Received response %s\n",buffer); else printf("ERROR : command failed"); exit(1); }
// Print using a preorder traversal void printhelp(GTNode<E>* root) { if (root->isLeaf()) cout << "Leaf: "; else cout << "Internal: "; cout << root->value() << "\n"; // Now process the children of "root" for (GTNode<E>* temp = root->leftmostChild(); temp != NULL; temp = temp->rightSibling()) printhelp(temp); }
int main(int argc, char **argv) { int opt; char conf_path[D_CONF_PATH_LEN + 1] = {0}; while((opt = getopt(argc, argv, "f:h")) != EOF) { switch(opt) { case 'f': fprintf(stderr, "Conf path: %s\n", optarg); strncpy(conf_path, optarg, D_CONF_PATH_LEN); break; case 'h': default: printhelp(argv[0]); exit(EXIT_FAILURE); } } signal(SIGTERM, sig_handler); signal(SIGINT, sig_handler); if (mst_config_load(conf_path) != 0) { fprintf(stderr, "Exiting...\n"); exit(EXIT_FAILURE); } mst_config_dump(&g_mst_conf); //exit(EXIT_SUCCESS); mst_init_shm_cntrs(); mst_mm_init(); mst_config_init(); mst_log_init(); mst_levent_init(); //mst_timer_init(); mst_tun_init(); mst_timer_init(); mst_init_epoll_queue(); mst_init_nw_queue(); mst_init_tun_queue(); if (mst_setup_network()) { exit(EXIT_FAILURE); } //mst_loop_network(); mst_init_network(); mst_loop_timer(NULL); fprintf(stderr, "Something caused exit....\n"); return 0; }
int main() { uart_init(0); // init the UART before we can printf volatile char c; int i,j; char browse_buf[256]; spi_master = 0; slave = 1; spi_core_slave_select(spi_master, 0); // Deselect slaves // Clear the read FIFO while (spi_core_data_avail(spi_master)) c = spi_core_read_data(spi_master); programming_file_start = (unsigned long) &spiprogram_data; programming_file_end = (unsigned long) &end_spiprogram_data; programming_file_length = programming_file_end - programming_file_start; // SPI core 0, should already be configured to read out data // when we reset. printf("\n\n\tSPI flash programming app\n\n"); while(1){ printf("[p,v,s,h] > "); c = uart_getc(DEFAULT_UART); printf("%c",c); printf("\n"); if (c == 'h') printhelp(); else if (c == 's') print_spi_status(); else if (c == 'p') program_spi(spi_master, slave, (char *) &spiprogram_data, programming_file_length); else if (c == 'v') verify_spi(spi_master, slave, (char *) &spiprogram_data, programming_file_length); else if ( c== 'r') { printf("Read page\n"); spi_read_block(spi_master, slave, ((console_get_num())<<8), 256, browse_buf); console_browse_buffer(browse_buf); } } return 0; }
int dropbearconvert_main(int argc, char ** argv) { #else int main(int argc, char ** argv) { #endif int intype, outtype; const char* infile; const char* outfile; crypto_init(); seedrandom(); #if DEBUG_TRACE /* It's hard for it to get in the way _too_ much */ debug_trace = 1; #endif /* get the commandline options */ if (argc != 5) { fprintf(stderr, "All arguments must be specified\n"); goto usage; } /* input type */ if (argv[1][0] == 'd') { intype = KEYFILE_DROPBEAR; } else if (argv[1][0] == 'o') { intype = KEYFILE_OPENSSH; } else { fprintf(stderr, "Invalid input key type\n"); goto usage; } /* output type */ if (argv[2][0] == 'd') { outtype = KEYFILE_DROPBEAR; } else if (argv[2][0] == 'o') { outtype = KEYFILE_OPENSSH; } else { fprintf(stderr, "Invalid output key type\n"); goto usage; } /* we don't want output readable by others */ umask(077); infile = argv[3]; outfile = argv[4]; return do_convert(intype, infile, outtype, outfile); usage: printhelp(argv[0]); return 1; }
void parsecmdline(int argc, char **argv) { port = 7000; strcpy(host, "127.0.0.1"); strcpy(inputfile, "seq"); strcpy(savefile, ""); usevis = 0; Neq = 10000; beta = 1.0; node = 0; Nc = 10; key[0] = (unsigned short)getpid(); key[1] = (unsigned short)time(NULL); key[2] = (unsigned short)getuid(); for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "-h") == 0) { strcpy(host, argv[i+1]); i++; } else if (strcmp(argv[i], "-p") == 0) { sscanf(argv[i+1], "%d", &port); i++; } else if (strcmp(argv[i], "-i") == 0) { strcpy(inputfile, argv[i+1]); i++; } else if (strcmp(argv[i], "-k") == 0) { sscanf(argv[i+1], "%hu", &key[0]); sscanf(argv[i+2], "%hu", &key[1]); sscanf(argv[i+3], "%hu", &key[2]); i += 3; } else if (strcmp(argv[i], "-e") == 0) { sscanf(argv[i+1], "%ld", &Neq); i++; } else if (strcmp(argv[i], "-v") == 0) { usevis = 1; } else if (strcmp(argv[i], "-w") == 0) { strcpy(savefile, argv[i+1]); i++; } else if (strcmp(argv[i], "-b") == 0) { sscanf(argv[i+1], "%lf", &beta); i++; } else if (strcmp(argv[i], "-n") == 0) { sscanf(argv[i+1], "%d", &node); i++; } else if (strcmp(argv[i], "-c") == 0) { sscanf(argv[i+1], "%d", &Nc); i++; } else { printf("bad command line parameter %s\n", argv[i]); printhelp(); exit(0); } } }
int main(int argc, char **argv) { char *datadir; int inpnum; //setseeds(3,3); datadir= getenv("SMAQDATA"); if(datadir !=NULL) { strcpy(dirname, datadir); }; if(argc != 2){ printhelp(); return 1; }; inpnum = atoi(argv[1]); if(((inpnum<1 )|| (inpnum>48)) && ((inpnum<101 )|| (inpnum>148)) && ((inpnum<51 )|| (inpnum>74)) ){ printhelp(); return 2; } signal(SIGUSR1, gotsignal); siginterrupt(SIGUSR1, 0); initSMAQ(); inputsSMAQ(0,inpnum); vmeclose(); return 0; }
int dropbearconvert_main(int argc, char ** argv) { #else int main(int argc, char ** argv) { #endif int intype, outtype; const char* infile; const char* outfile; /* get the commandline options */ if (argc != 5) { fprintf(stderr, "All arguments must be specified\n"); goto usage; } /* input type */ if (argv[1][0] == 'd') { intype = KEYFILE_DROPBEAR; } else if (argv[1][0] == 'o') { intype = KEYFILE_OPENSSH; } else { fprintf(stderr, "Invalid input key type\n"); goto usage; } /* output type */ if (argv[2][0] == 'd') { outtype = KEYFILE_DROPBEAR; } else if (argv[2][0] == 'o') { outtype = KEYFILE_OPENSSH; } else { fprintf(stderr, "Invalid output key type\n"); goto usage; } /* we don't want output readable by others */ umask(077); infile = argv[3]; outfile = argv[4]; return do_convert(intype, infile, outtype, outfile); usage: printhelp(argv[0]); return 1; }
int main () { char *menu = "WATSON\n+---------------+\n| [0] Play Game |\n| [1] Help |\n| [2] Quit |\n+---------------+\n> "; //eventually ASCII art printf("%s", menu); int inp = getchar(); switch(inp) { case 0: playgame(); break; case 1: printhelp(); break; case 2: exit(0); break; } exit(0); }
/** * Parsuje i zwraca argumenty wywołania, * w przypadku braku któregokolwiek zwraca wartości domyślne. * * @param argv Argumenty wywołania (bez nazwy programu!). * @param argc Ilość argumentów. * @return Ładna struktura z zapakowanymi wszystkimi potrzebnymi danymi. */ struct params parseargs(char **argv, const size_t argc) { /* Domyślne wartości, zgodne z treścią zadania. */ struct params result = { { 0 }, 1000, 30, 3 }; /* Czy wczytany został adres do którego drogę chcemy wyliczać? */ bool addr = false; for (uint i = 0; i < argc; i++) { int retv = 0; if (OPTARG(argv[i], "-h", "--help")) { printhelp(); exit(1); } else if (argv[i][0] == '-' && i < argc - 1) { retv = parseopt(argv[i], argv[i + 1], &result); i++; } else { retv = handle( "parse ip adress", inet_pton(AF_INET, argv[i], &result.addr.sin_addr) ); addr = true; } /* * `sscanf` zwraca ilość poprawnie zczytanych * parametrów a `inet_pton` 1 jeżeli uda mu się * sparsować adres. Wystarczy więc sprawdzić czy * `retv` jest większy od zera, w przeciwnym razie * argument jest nieprawidłowy. */ if (retv <= 0) { printf("Incorrect argument: %s.\n", argv[i]); printf("Try with `--help` for more information.\n"); exit(1); } } if (!addr) { printf("Remote server address not given.\n"); exit(1); } return result; }
void setParameters(int argc, char* argv[], int* action, int* unify_features, int* all_linkages, int* out_to_file){ int i; for (i=1; i<argc; i++){ if (strcmp(argv[i],"-t")==0) *action=TRANSLATE; else if(strcmp(argv[i],"-du")==0) *unify_features=FALSE; else if(strcmp(argv[i],"-a")==0) *all_linkages=TRUE; else if(strcmp(argv[i],"-o")==0) *out_to_file=TRUE; else if(strcmp(argv[i],"-h")==0){ printhelp(); exit(0); } } }
int main(int argc, char **argv) { char *c = argc == 2 ? argv[1] : " "; switch(type(c)) { case 0: cxflag = 1; break; case 1: csflag = 1; break; case 2: jflag = 1; break; default: printhelp(); break; } FILE *fp; char *line; char *name; char[] *param; bool marker = false; if(strcmp(c," ") != 0) { fp = fopen(c,"r"); while(scanf(fp, "%s", line) != EOF) { char *tok = strtok(line," "); while(tok != NULL) { if(marker) { marker = false; name = tok; } if(strcmp(tok,"class") == 0) marker = true; tok = strtok(NULL," "); } } } }
int main(int argc, char **argv){ char operator; int incheck; struct node *number1; struct node *number2; struct node *result; char outputBase; if(argc == 1){ fprintf(stderr, "ERROR: Too few inputs\n"); return 0; } incheck = inputCheck(argv); if (incheck == -1) return 0; outputBase = argv[4][0]; if (strcmp(argv[1], "-h") == 0){ printhelp(); return 0; } operator = argv[1][0]; number1 = convert(argv[2]); number2 = convert(argv[3]); if(outputBase == 'd'){ if(operator == '+') result = quicksum(number1, number2); else if (operator == '-') result = quicksub(number1, number2); else{ fprintf(stderr, "ERROR: Bad operator!\n"); return 0; } printf("d"); printint(number1->num+number2->num); return 0; } if (operator == '+') result = add(number1, number2); else if (operator == '-') result = subtract(number1, number2); else{ fprintf(stderr, "ERROR: Bad operator!\n"); return 0; } print(result, outputBase); printf("\n"); return 0; }
main(int argc, char** argv) { int num_threads = DEFAULT_THREADS; int runtime = 0; int delay = 0; long mloops = 0; int opt; while ((opt = getopt(argc, argv, "ht:r:d:l:")) != -1) { switch (opt) { case 'h': printhelp(); exit(0); break; case 't': num_threads = atoi(optarg); break; case 'r': runtime = atoi(optarg); break; case 'd': delay = atoi(optarg); break; case 'l': mloops = atoll(optarg); break; } } if (runtime && mloops) { fprintf(stderr, "-r and -l options cannot be specified at the same time.\n"); exit(1); } else if (!runtime && !mloops) { fprintf(stderr, "Must specify either -r or -l option; use -h to see help.\n"); exit(1); } long num_loops = mloops ? mloops * 1000000L : LOOPS * num_threads; run_dhrystone(runtime, num_threads, num_loops, delay); }
void inputsetup_box(int pl, int x, int y) { int h = 8; #ifdef JOYSTICK if (num_joyst) h++; #endif clearbox(x-1, y, 0, h+4); printhelp(x+2, y+h+2); setcurs(x, y); printmenuitem("Input Setup", 1); #ifdef TWOPLAYER if (!pl) printstr(" single"); printstr(" player"); if (pl) putch(pl+'0'); #endif drawbox(x, y+1, 31, h, NULL); inputsetup_menu(pl, x+1, y+2); clearbox(x, y, 0, h+4); }
void setCursor() { if(cursorColumnLast != cursorColumn) { if(cursorColumn>0xF0U) cursorColumn=0x03U; if(cursorColumn>0x03U) cursorColumn=0U; cursorEnable[cursorColumn]=1U; if(!joyState[6]) { cursorEnable[cursorColumnLast]=0U; } //cursorRow[cursorColumn] = cursorRowMain; cursorColumnLast = cursorColumn; } for(j=0;j!=4;j++) { if(shiftSelect && !joyState[6] && cursorColumn != j) { cursorEnable[j] = 0; } if(cursorEnable[j]) { if(cursorRow[j] > 0xF0U) cursorRow[j] = 0x08U; if(cursorRow[j] > 0x08U) cursorRow[j] = 0U; move_sprite(SPRITE_ARRT_START, cursorBigStartX[cursorColumn], cursorBigStartY[0]); move_sprite(j+SPRITE_ARRL_START, cursorStartX[j], (cursorRow[j] * SCREEN_YSPACE) + SCREEN_PSTARTY + SCREEN_YO); if(j==cursorColumn) cursorRowMain = cursorRow[j]; } } for(j=0;j!=4;j++) { if(!cursorEnable[j]) { cursorRow[j] = cursorRowMain; move_sprite(j+SPRITE_ARRL_START,0, 0); } } if(!joyState[6]) { shiftSelect = 0; } else { shiftSelect = 1; } printhelp(); }
int main(int argc, char *argv[]) try { std::vector<std::string> positional; bool live = false; std::string filter; uint32_t every = 5*60; for (int n=1; n<argc; ++n) { std::string arg = argv[n]; bool havenext = n+1 < argc; if (havenext && (arg == "--bpf" || arg == "--filter")) { filter = argv[n+1]; ++n; } else if (havenext && (arg == "--every" || arg == "-e")) { every = boost::lexical_cast<uint32_t>(argv[n+1]); ++n; } else if (arg == "--live") live = true; else if (arg == "-h" or arg == "--help") { printhelp(argv[0]); return -1; } else positional.push_back(arg); } if (live && positional.size()>1) throw format_exception("can only do live capture on one device (use 'any' for all)"); if (!live && positional.empty()) throw format_exception("need at least one pcap file"); my_packet_listener_t listener(every); pcap_reader_t reader(&listener); if (!live) { BOOST_FOREACH(const std::string &file, positional) reader.read_file(file, filter); } else {