int main(int na, char **argv) { struct coms *c; char *x; ctl_action_t act; msx_read_debug_file(NULL); program_name = argv[0]; if((x = strrchr(argv[0], '/'))) program_name = x+1; if( na < 2 || na > 10 ) usage(); for(int i=0 ; i < na ; i++) { if(strcmp(argv[i], "--help") == 0) { usage(); } if(strcmp(argv[i], "--copyright") == 0) { show_copyright(); } } for( x = argv[1] ; *x ; x++) if( *x >= 'A' && *x <= 'Z') *x += 'a' - 'A'; for( c = coms ; c->com ; c++ ) if(!strcmp(c->com, argv[1])) break; if(!c->com) { printf("%s: No such option.\n", argv[0]); exit(1); } // Initilazing the act structure act.ctl_id = c->no; act.ctl_str = strdup(c->com); act.ctl_target = c->type; act.ctl_resp = glob_res_buff; act.ctl_res_len = GLOB_RES_BUFF_SIZE; act.ctl_argp = glob_arg_buff; act.ctl_arg_len = GLOB_ARG_BUFF_SIZE; // Performing ctl action if( c->type & CTL_TRG_INFOD_CTL) { if(!infod_do_ctl(na, argv, &act)) exit(1); } else { printf("Only infod ctl supported\n"); exit(1); } return(0); }
void checkHelpCmdLine(infod_cmdline_t *opts, int argc, char **argv) { for(int i=0 ; i < argc ; i++) { if(strcmp(argv[i], "--help") == 0) { usage(NULL); } if(strcmp(argv[i], "--copyright") == 0) { show_copyright(NULL); } } }
void main () { // Debug_Init(); // Debug(); _cputype= -1; _fputype= -1; _fpuinfo= 0; _systype= -1; _extendertype= -1; _dpmiflags= -1; _modetype= 0; // Real or V86 mode cpu_speed= -1; fpu_speed= -1; risc_speed= -1; intPR_speed= -1; intRP_speed= -1; irqPR_speed= -1; irqRP_speed= -1; lmem_movsw= -1; lmem_movsd= -1; lmem_stosw= -1; lmem_stosd= -1; hmem_movsw= -1; hmem_movsd= -1; hmem_stosw= -1; hmem_stosd= -1; vmem_movsw= -1; vmem_movsd= -1; vmem_stosw= -1; vmem_stosd= -1; printf("\n"); printf("PCTEST -- Protected Mode Diagnostic Utility Version %s",version); printf("\n"); printf("Copyright (C) Supernar Systems, Ltd. 1996-2002"); printf("\n"); printf("---------------------------------------------------------"); printf("\n"); get_system_information(); measure_system_speed(); show_copyright(); show_system_information(); exit(0); }
INT main (INT argc, char *argv[]) #endif { #if PC_WATCOM struct find_t info; #endif UINT n; LONG status = 0; /****/ if (argc < 2) { print_help(); exit(1); } printf( "\nRORTEST - reorient, requant, crop, join or els-code seq. jpg and pic files.\n" "(c) 1995, Pegasus Imaging Corporation, Tampa, Florida\n" ); /* Get command line arguments. */ parse_parms(argc, argv); if (!skip_copyright) show_copyright(); num_tables = 0; if (QTableName[0] != '\0') /* User supplied a file name holding Q-table values */ { /* qtable is assumed NOT in zig_zag order (unlike what's in jpg file ) */ FILE *QFile; LONG qq,u,stat = 0; int len,c; /****/ QFile = fopen(QTableName, "rt"); check(QFile != NULL, "Q-table %s could not be opened", QTableName); u = 192; if(regions) { u += u; region_qtable = (WORD *)qtable; } memset(qtable,0,u); n = 0; u = 255; if(regions) u = 65535; while(n < 192) { len = fscanf(QFile, " %d", &qq); if(len != 1) { if(len == EOF) break; c = getc(QFile); if(c == '#') { /* comment to the end of line */ while(1) { c = getc(QFile); if(c == '\n'|| c == EOF) break; } if(c == EOF) break; continue; } else break; } if(qq < 1 || qq > u) { printf("Program terminated:illegal quantization value(s)\n"); stat = -1; break; } if(regions) region_qtable[n++] = qq; else qtable[n++] = qq; } fclose(QFile); QFile = NULL; if(stat != 0) exit(1); check(n == 64 || n == 128 || n == 192, "incorrect number of quantization values"); num_tables = n/64; } #if PC_WATCOM n = 0; if (_dos_findfirst(src_name, _A_NORMAL, &info) == 0) { do { strcpy(src_name, src_path); strcat(src_name, info.name); if (wild_card) { strcpy(des_name, des_path); strcat(des_name, info.name); strcpy(strchr(des_name, '.'), des_ext); } status = expand(); n++; } while ( _dos_findnext(&info) == 0); } else printf("\n image not found.\n", n); printf("\nThere were %d images converted or attempted.\n", n); #else status = expand(); #endif if(status != 0) printf("status = %d\n",status); return (0); }
void parseoptions(int argc, char*argv[]) { int c; double dval; char *endptr; while((c = dxf2rad_getopt(argc, argv, "HhglcfrvV:s:e:d:a:f:G:")) != EOF) { switch(c) { case 'e': parse_entarg(); break; case 'h': disallow_plus(c); exit_with_usage(0); break; case 'H': disallow_plus(c); show_copyright(); break; case 'f': disallow_plus(c); Options.skipfrozen++; break; case 'r': disallow_plus(c); Options.verbose++; break; case 'l': disallow_plus(c); if(Options.exportmode == bycolor) { fprintf(stderr, "Can't use both export modes together\n"); exit_with_usage(-1); } Options.exportmode = bylayer; break; case 'c': disallow_plus(c); if(Options.exportmode == bylayer) { fprintf(stderr, "Can't use both export modes together\n"); exit_with_usage(-1); } Options.exportmode = bycolor; break; case 'G': disallow_plus(c); if(Options.prefix) { fprintf(stderr, "Modifier prefix specified more than once\n"); exit_with_usage(-1); } Options.prefixlen = strlen(optarg); if((Options.prefixlen + 32) >= MAXSTRING) { fprintf(stderr, "Modifier prefix too long\n"); exit_with_usage(-1); } Options.prefix = malloc(Options.prefixlen+1); strncpy(Options.prefix, optarg, Options.prefixlen+1); break; case 'g': if(optsign == '-') Options.geom = 0; else Options.geom = 1; break; case 'v': if(optsign == '-') Options.views = 0; else Options.views = 1; break; case 'V': disallow_plus(c); if(Options.viewprefix) { fprintf(stderr, "View prefix specified more than once\n"); exit_with_usage(-1); } Options.viewprefixlen = strlen(optarg); if((Options.viewprefixlen + 32) > MAXSTRING) { fprintf(stderr, "View prefix too long\n"); exit_with_usage(-1); } Options.viewprefix = malloc(Options.viewprefixlen+1); strncpy(Options.viewprefix, optarg, Options.viewprefixlen+1); break; case 's': disallow_plus(c); dval = strtod((const char*)optarg, &endptr); if(dval == 0.0) { fprintf(stderr, "Invalid or zero scale factor: \"%s\"\n", optarg); exit_with_usage(-1); } else if(dval == DBL_MAX || dval == DBL_MIN) { fprintf(stderr, "Invalid scale factor: \"%s\"\n", optarg); exit_with_usage(-1); } else if(*endptr != '\0') { fprintf(stderr, "Invalid scale factor: \"%s\"\n", optarg); exit_with_usage(-1); } Options.scale = dval; break; case 'd': disallow_plus(c); dval = strtod((const char*)optarg, &endptr); if(dval == 0.0) { fprintf(stderr, "Invalid or zero distance tolerance: \"%s\"\n", optarg); exit_with_usage(-1); } else if(dval == DBL_MAX || dval == DBL_MIN) { fprintf(stderr, "Invalid distance tolerance: \"%s\"\n", optarg); exit_with_usage(-1); } else if(*endptr != '\0') { fprintf(stderr, "Invalid distance tolerance: \"%s\"\n", optarg); exit_with_usage(-1); } Options.disttol = dval; break; case 'a': disallow_plus(c); dval = strtod((const char*)optarg, &endptr); if(dval == 0.0) { fprintf(stderr, "Invalid or zero angle tolerance: \"%s\"\n", optarg); exit_with_usage(-1); } else if(dval == DBL_MAX || dval == DBL_MIN) { fprintf(stderr, "Invalid angle tolerance: \"%s\"\n", optarg); exit_with_usage(-1); } else if(*endptr != '\0') { fprintf(stderr, "Invalid angle tolerance: \"%s\"\n", optarg); exit_with_usage(-1); } Options.angtol = dval * DEG2RAD; break; } } if(Options.geom == 0 && Options.views == 0) { fprintf(stderr, "No output specified, nothing to do\n"); exit_with_usage(-1); } if(Options.exportmode == none) { Options.exportmode = bylayer; } if(Options.prefix == NULL) { if(Options.exportmode == bylayer) { Options.prefix = "l_"; Options.prefixlen = 2; } if(Options.exportmode == bycolor) { Options.prefix = "c_"; Options.prefixlen = 2; } } /* Get file names and add extensions if necessary. */ if((argc - optind) > 2) { fprintf(stderr, "Too many arguments\n"); exit_with_usage(-1); } if((argc - optind) < 1) { fprintf(stderr, "Missing input file argument\n"); exit_with_usage(-1); } if ((strlen(argv[optind]) + 5) > MAXPATH){ fprintf(stderr, "Input file path name too long\n"); exit_with_usage(-1); } strncpy(Inputfile, argv[optind], MAXPATH); if (strcspn(Inputfile,".") == strlen(Inputfile)) strncat(Inputfile, ".dxf", 5); if((argc - optind) < 2 || (argv[optind+1][0] == '-' && argv[optind+1][1] == '\0')) { if(Options.geom == 1) { Options.verbose = 0; } Outputfile[0] = '\0'; } else { if ((strlen(argv[optind+1]) + 5) > MAXPATH){ fprintf(stderr, "Output file path name too long\n"); exit_with_usage(-1); } strncpy(Outputfile, argv[optind+1], MAXPATH); if (strcspn(Outputfile,".") == strlen(Outputfile)) strncat(Outputfile, ".rad", 4); } if(Options.viewprefix == NULL) { size_t pnlen; char *pn; pnlen = strlen(Outputfile[0]?Outputfile:Inputfile); Options.viewprefix = malloc(pnlen+2); strncpy(Options.viewprefix, Outputfile[0]?Outputfile:Inputfile, pnlen+1); pn = strrchr(Options.viewprefix, '.'); if(pn != NULL) *pn = '\0'; strncat(pn, "_", 2); Options.viewprefixlen = strlen(Options.viewprefix); } }