static void HandleSwitches(int argc, char *argv[]) { int s; while ((s = xgetopt(argc,argv,"uUbBI:i:O:o:T:t:c:C:n:N:")) != EOF) { switch (s){ case 'i': case 'I': cInProf = xoptarg; break; case 'o': case 'O': cOutProf = xoptarg; break; case 'b': case 'B': BlackPointCompensation =TRUE; break; case 't': case 'T': Intent = atoi(xoptarg); if (Intent > 3) Intent = 3; if (Intent < 0) Intent = 0; break; case 'U': case 'u': Undecorated = TRUE; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 2) FatalError("ERROR: Unknown precalc mode '%d'", PrecalcMode); break; case 'n': case 'N': if (PrecalcMode != 1) FatalError("Precalc mode already specified"); NumOfGridPoints = atoi(xoptarg); break; default: FatalError("Unknown option - run without args to see valid ones.\n"); } } }
static void HandleSwitches(int argc, char *argv[]) { int s; while ((s = xgetopt(argc, argv, "bBC:c:d:D:eEgGI:i:L:l:m:M:nNO:o:p:P:QqSsT:t:V:v:WwxX!:")) != EOF) { switch (s){ case '!': IncludePart = xoptarg; break; case 'b': case 'B': BlackPointCompensation = TRUE; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 3) FatalError("Unknown precalc mode '%d'", PrecalcMode); break; case 'd': case 'D': { cmsFloat64Number ObserverAdaptationState = atof(xoptarg); if (ObserverAdaptationState < 0 || ObserverAdaptationState > 1.0) FatalError("Adaptation states should be between 0 and 1"); cmsSetAdaptationState(ObserverAdaptationState); } break; case 'e': case 'E': lIsFloat = FALSE; break; case 'g': case 'G': GamutCheck = TRUE; break; case 'i': case 'I': if (lIsDeviceLink) FatalError("icctrans: Device-link already specified"); cInProf = xoptarg; break; case 'l': case 'L': cInProf = xoptarg; lIsDeviceLink = TRUE; break; // No extra intents for proofing case 'm': case 'M': ProofingIntent = atoi(xoptarg); if (ProofingIntent > 3) FatalError("Unknown Proofing Intent '%d'", ProofingIntent); break; // For compatibility case 'n': case 'N': Verbose = 0; break; // Output profile case 'o': case 'O': if (lIsDeviceLink) FatalError("icctrans: Device-link already specified"); cOutProf = xoptarg; break; // Proofing profile case 'p': case 'P': cProofing = xoptarg; break; // Quantize (get rid of decimals) case 'q': case 'Q': lQuantize = TRUE; break; // Inhibit unbounded mode case 's': case 'S': lUnbounded = FALSE; break; // The intent case 't': case 'T': Intent = atoi(xoptarg); break; // Verbosity level case 'V': case 'v': Verbose = atoi(xoptarg); if (Verbose < 0 || Verbose > 3) { FatalError("Unknown verbosity level '%d'", Verbose); } break; // Wide (16 bits) case 'W': case 'w': Width16 = TRUE; break; // Hexadecimal case 'x': case 'X': InHexa = TRUE; break; default: FatalError("Unknown option - run without args to see valid ones.\n"); } } // If output CGATS involved, switch to float if ((argc - xoptind) > 2) { lIsFloat = TRUE; } }
static void HandleSwitches(int argc, char *argv[]) { int s; while ((s=xgetopt(argc,argv,"bBnNvVGgh:H:i:I:o:O:P:p:t:T:c:C:Q:q:M:m:L:l:eEs:S:!:D:d:")) != EOF) { switch (s) { case 'b': case 'B': BlackPointCompensation = TRUE; break; case 'd': case 'D': ObserverAdaptationState = atof(xoptarg); if (ObserverAdaptationState < 0 || ObserverAdaptationState > 1.0) FatalError("Adaptation state should be 0..1"); break; case 'v': case 'V': Verbose = TRUE; break; case 'i': case 'I': if (lIsDeviceLink) FatalError("Device-link already specified"); cInpProf = xoptarg; break; case 'o': case 'O': if (lIsDeviceLink) FatalError("Device-link already specified"); cOutProf = xoptarg; break; case 'l': case 'L': if (cInpProf != NULL || cOutProf != NULL) FatalError("input/output profiles already specified"); cInpProf = xoptarg; lIsDeviceLink = TRUE; break; case 'p': case 'P': cProofing = xoptarg; break; case 't': case 'T': Intent = atoi(xoptarg); break; case 'N': case 'n': IgnoreEmbedded = TRUE; break; case 'e': case 'E': EmbedProfile = TRUE; break; case 'g': case 'G': GamutCheck = TRUE; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 2) FatalError("Unknown precalc mode '%d'", PrecalcMode); break; case 'H': case 'h': { int a = atoi(xoptarg); Help(a); } break; case 'q': case 'Q': jpegQuality = atoi(xoptarg); if (jpegQuality > 100) jpegQuality = 100; if (jpegQuality < 0) jpegQuality = 0; break; case 'm': case 'M': ProofingIntent = atoi(xoptarg); break; case 's': case 'S': SaveEmbedded = xoptarg; break; case '!': if (sscanf(xoptarg, "%hu,%hu,%hu", &Alarm[0], &Alarm[1], &Alarm[2]) == 3) { int i; for (i=0; i < 3; i++) { Alarm[i] = (Alarm[i] << 8) | Alarm[i]; } } break; default: FatalError("Unknown option - run without args to see valid ones"); } } }
static void HandleSwitches(int argc, char *argv[]) { int s; while ((s=xgetopt(argc,argv,"aAeEbBfFwWnNvVGgh:H:i:I:o:O:P:p:t:T:c:C:l:L:M:m:K:k:S:s:D:d:")) != EOF) { switch (s) { case 'a': case 'A': StoreAsAlpha = TRUE; break; case 'b': case 'B': BlackWhiteCompensation = TRUE; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 3) FatalError("Unknown precalc mode '%d'", PrecalcMode); break; case 'd': case 'D': ObserverAdaptationState = atof(xoptarg); if (ObserverAdaptationState != 0 && ObserverAdaptationState != 1.0) Warning("Adaptation states other that 0 or 1 are not yet implemented"); break; case 'e': case 'E': EmbedProfile = TRUE; break; case 'f': case 'F': PreserveBlack = TRUE; break; case 'g': case 'G': GamutCheck = TRUE; break; case 'v': case 'V': Verbose = TRUE; break; case 'i': case 'I': if (lIsDeviceLink) FatalError("Device-link already specified"); cInpProf = xoptarg; break; case 'o': case 'O': if (lIsDeviceLink) FatalError("Device-link already specified"); cOutProf = xoptarg; break; case 'l': case 'L': cInpProf = xoptarg; lIsDeviceLink = TRUE; break; case 'p': case 'P': cProofing = xoptarg; break; case 't': case 'T': Intent = atoi(xoptarg); if (Intent > 3) Intent = 3; if (Intent < 0) Intent = 0; break; case 'm': case 'M': ProofingIntent = atoi(xoptarg); if (ProofingIntent > 3) ProofingIntent = 3; if (ProofingIntent < 0) ProofingIntent = 0; break; case 'N': case 'n': IgnoreEmbedded = TRUE; break; case 'W': case 'w': Width16 = TRUE; break; case 'k': case 'K': InkLimit = atof(xoptarg); if (InkLimit < 0.0 || InkLimit > 400.0) FatalError("Ink limit must be 0%%..400%%"); break; case 's': case 'S': SaveEmbedded = xoptarg; break; case 'H': case 'h': { int a = atoi(xoptarg); Help(a); } break; default: FatalError("Unknown option - run without args to see valid ones"); } } }
static void HandleSwitches(int argc, char *argv[]) { int s; while ((s=xgetopt(argc,argv,"bBnNvVGgh:H:i:I:o:O:P:p:t:T:c:C:Q:q:M:m:L:l:eEs:S:")) != EOF) { switch (s) { case 'b': case 'B': BlackPointCompensation = TRUE; break; case 'v': case 'V': Verbose = TRUE; break; case 'i': case 'I': if (lIsDeviceLink) FatalError("Device-link already specified"); cInpProf = xoptarg; break; case 'o': case 'O': if (lIsDeviceLink) FatalError("Device-link already specified"); cOutProf = xoptarg; break; case 'l': case 'L': cInpProf = xoptarg; lIsDeviceLink = TRUE; break; case 'p': case 'P': cProofing = xoptarg; break; case 't': case 'T': Intent = atoi(xoptarg); if (Intent > 3) Intent = 3; if (Intent < 0) Intent = 0; break; case 'N': case 'n': IgnoreEmbedded = TRUE; break; case 'e': case 'E': EmbedProfile = TRUE; break; case 'g': case 'G': GamutCheck = TRUE; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 2) FatalError("Unknown precalc mode '%d'", PrecalcMode); break; case 'H': case 'h': { int a = atoi(xoptarg); Help(a); } break; case 'q': case 'Q': jpegQuality = atoi(xoptarg); if (jpegQuality > 100) jpegQuality = 100; if (jpegQuality < 0) jpegQuality = 0; break; case 'm': case 'M': ProofingIntent = atoi(xoptarg); if (ProofingIntent > 3) ProofingIntent = 3; if (ProofingIntent < 0) ProofingIntent = 0; break; case 's': case 'S': SaveEmbedded = xoptarg; break; default: FatalError("Unknown option - run without args to see valid ones"); } } }
int main(int argc, char **argv) { char *input; js_State *J; int status = 0; int strict = 0; int interactive = 0; int i, c; while ((c = xgetopt(argc, argv, "is")) != -1) { switch (c) { default: usage(); break; case 'i': interactive = 1; break; case 's': strict = 1; break; } } J = js_newstate(NULL, NULL, strict ? JS_STRICT : 0); js_newcfunction(J, jsB_gc, "gc", 0); js_setglobal(J, "gc"); js_newcfunction(J, jsB_load, "load", 1); js_setglobal(J, "load"); js_newcfunction(J, jsB_compile, "compile", 2); js_setglobal(J, "compile"); js_newcfunction(J, jsB_print, "print", 0); js_setglobal(J, "print"); js_newcfunction(J, jsB_write, "write", 0); js_setglobal(J, "write"); js_newcfunction(J, jsB_read, "read", 1); js_setglobal(J, "read"); js_newcfunction(J, jsB_readline, "readline", 0); js_setglobal(J, "readline"); js_newcfunction(J, jsB_repr, "repr", 0); js_setglobal(J, "repr"); js_newcfunction(J, jsB_quit, "quit", 1); js_setglobal(J, "quit"); js_dostring(J, require_js); js_dostring(J, stacktrace_js); if (xoptind == argc) { interactive = 1; } else { c = xoptind++; js_newarray(J); i = 0; while (xoptind < argc) { js_pushstring(J, argv[xoptind++]); js_setindex(J, -2, i++); } js_setglobal(J, "scriptArgs"); if (js_dofile(J, argv[c])) status = 1; } if (interactive) { if (isatty(0)) { using_history(); rl_bind_key('\t', rl_insert); input = readline(PS1); while (input) { eval_print(J, input); if (*input) add_history(input); free(input); input = readline(PS1); } putchar('\n'); } else { input = read_stdin(); if (!input || !js_dostring(J, input)) status = 1; free(input); } } js_gc(J, 0); js_freestate(J); return status; }
/** * Program entry point. Initialize modules, load ROM, run emulator. * \param argc command line argument count * \param argv[] command line argument values * \return exit code */ int main(int argc, char** argv) { printf("bc_emu: portable video game emulator\n" "Copyright © 2008-2010 Ondrej Balaz, <*****@*****.**>\n" "http://www.blami.net/prj/bc_emu\n" "This is free software licensed under MIT license. See LICENSE.\n" "\n"); /* register exit handler */ atexit(pc_atexit); /* prepare pc static fields */ pc_emu_name = NULL; pc_ui_name = NULL; pc_rom_file = NULL; /* prepare bc_emu global fields */ emu_rom = NULL; emu_progname = argv[0]; /* resolve command line arguments */ while(1) { int p = xgetopt(argc, argv, "-hVe:u:"); if(p == -1) break; switch(p) { case 'h': pc_print_usage(EXIT_SUCCESS); break; case 'V': pc_print_version(EXIT_SUCCESS); break; case 'e': pc_emu_name = xstrndup(xoptarg, strlen(xoptarg)); debug("-e: forced to use emulator `%s'", xoptarg); break; case 'u': pc_ui_name = xstrndup(xoptarg, strlen(xoptarg)); debug("-u: forced to use UI `%s'", xoptarg); break; case 1: pc_rom_file = xstrndup(xoptarg, strlen(xoptarg)); break; } } /* check and preload rom_file to global variable */ if(!pc_rom_file) { fprintf(stderr, "%s: missing ROM image filename\n", emu_progname); exit(EXIT_FAILURE); } /* put ROM image file to memory (doesn't bother 2nd and 3rd gen images are * around 15M max. */ emu_rom = pc_load_rom(pc_rom_file); if(!emu_rom) { fprintf(stderr, "%s: couldn't load ROM image from file: %s\n", emu_progname, pc_rom_file); exit(EXIT_FAILURE); } /* TODO emu/ui autoselect */ /* invoke architecture independent/safe bc_emu code */ /* bc_emu.c */ pc_is_init = 1; emu_main(pc_emu_name, pc_ui_name); /* called from exit_handler(): * bc_emu_exit(); */ return EXIT_SUCCESS; }
int main(int argc, const char* argv[]) { #ifdef _WIN32 WSADATA wsaData; #endif int opt, optind; const char *optarg; int use_daemon = 0; int remote_tcp = 0; int transport_timeout = 5; const char *hosts_file = NULL; const char *remote_addr = "8.8.8.8"; unsigned short local_port = 53, remote_port = 53; optind = 0; opt = xgetopt(argc, argv, options, &optind, &optarg); while(opt != -1) { switch(opt) { case 0: break; case 'p': local_port = (unsigned short)atoi(optarg); break; case 'P': remote_port = (unsigned short)atoi(optarg); break; case 'R': remote_addr = optarg; break; case 'T': remote_tcp = 1; break; case 'f': hosts_file = optarg; break; case 'd': use_daemon = 1; break; case 'v': printf("%s" " * version: %s\n", ascii_logo, VERSION); return 0; case 'h': default: display_help(); return -1; } opt = xgetopt(argc, argv, options, &optind, &optarg); } #ifdef _WIN32 WSAStartup(MAKEWORD(2,2), &wsaData); if(use_daemon) { freopen("NUL", "r", stdin); freopen("NUL", "w", stdout); freopen("NUL", "w", stderr); FreeConsole(); } #else if(use_daemon) { int fd; pid_t pid = fork(); if(pid < 0) { perror("fork"); return -1; } if(pid != 0) exit(0); pid = setsid(); if(pid < -1) { perror("setsid"); return -1; } chdir("/"); fd = open ("/dev/null", O_RDWR, 0); if(fd != -1) { dup2 (fd, 0); dup2 (fd, 1); dup2 (fd, 2); if(fd > 2) close (fd); } umask(0); } signal(SIGPIPE, SIG_IGN); #endif printf("%s" " * runing at %d%s\n" " * transport to %s:%d,%s\n" , ascii_logo , local_port , disable_cache? ", cache: off": "" , remote_addr , remote_port , remote_tcp? "tcp": "udp"); srand((unsigned int)time(NULL)); domain_cache_init(hosts_file); transport_cache_init(transport_timeout); return dnsproxy(local_port, remote_addr, remote_port, remote_tcp); }
static void HandleSwitches(int argc, char *argv[]) { int s; while ((s = xgetopt(argc,argv,"xXH:h:8k:K:BbO:o:T:t:D:d:C:c:n:N:f:F:lL")) != EOF) { switch (s){ case '8': lUse8bits = TRUE; break; case 'd': case 'D': Description = xoptarg; break; case 'o': case 'O': cOutProf = xoptarg; break; case 't': case 'T': Intent = atoi(xoptarg); if (Intent > 3) Intent = 3; if (Intent < 0) Intent = 0; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 2) FatalError("ERROR: Unknown precalc mode '%d'", PrecalcMode); break; case 'n': case 'N': if (PrecalcMode != 1) FatalError("Precalc mode already specified"); NumOfGridPoints = atoi(xoptarg); break; case 'b': case 'B': BlackPointCompensation = TRUE; break; case 'f': case 'F': BlackPreservation = atoi(xoptarg); if (BlackPreservation < 0 || BlackPreservation > 2) FatalError("ERROR: Unknown black preservation mode '%d'", BlackPreservation); break; case 'k': case 'K': InkLimit = atof(xoptarg); if (InkLimit < 0.0 || InkLimit > 400.0) FatalError("Ink limit must be 0%%..400%%"); break; case 'x': case 'X': TagResult = TRUE; break; case 'h': case 'H': Help(atoi(xoptarg)); break; case 'l': case 'L': NoPrelinearization = TRUE; break; default: FatalError("Unknown option - run without args to see valid ones.\n"); } } }
static void HandleSwitches(int argc, char *argv[]) { int s; xoptinit(); while ((s = xgetopt(argc, argv,"C:c:VvbBI:i:O:o:T:t:L:l:r:r:P:p:Mm")) != EOF) { switch (s){ case 'b': case 'B': BlackPointCompensation = TRUE; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 3) FatalError("Unknown precalc mode '%d'", PrecalcMode); break; case 'v': case 'V': Verbose = TRUE; break; case 'i': case 'I': if (lIsDeviceLink) FatalError("Device-link already specified"); cInProf = xoptarg; break; case 'o': case 'O': if (lIsDeviceLink) FatalError("Device-link already specified"); cOutProf = xoptarg; break; case 't': case 'T': Intent = atoi(xoptarg); if (Intent > 3) Intent = 3; if (Intent < 0) Intent = 0; break; case 'l': case 'L': cInProf = xoptarg; lIsDeviceLink = TRUE; break; case 'p': case 'P': cProofing = xoptarg; break; case 'r': case 'R': ProofingIntent = atoi(xoptarg); if (ProofingIntent > 3) ProofingIntent = 3; if (ProofingIntent < 0) ProofingIntent = 0; break; case 'm': case 'M': lMultiProfileChain = TRUE; break; default: FatalError("Unknown option."); } } // For multiprofile, need to specify -m if (xoptind < argc) { if (!lMultiProfileChain) FatalError("Use %cm for multiprofile transforms", SW); } }
// The toggles stuff static void HandleSwitches(int argc, char *argv[]) { int s; while ((s = xgetopt(argc,argv,"a:A:BbC:c:D:d:h:H:k:K:lLn:N:O:o:r:R:T:t:V:v:xX8y:Y:")) != EOF) { switch (s) { case 'a': case 'A': ObserverAdaptationState = atof(xoptarg); if (ObserverAdaptationState < 0 || ObserverAdaptationState > 1.0) FatalError("Adaptation state should be 0..1"); break; case 'b': case 'B': BlackPointCompensation = TRUE; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 2) { FatalError("Unknown precalc mode '%d'", PrecalcMode); } break; case 'd': case 'D': // Doing that is correct and safe: Description points to memory allocated in the command line. // same for Copyright and output devicelink. Description = xoptarg; break; case 'h': case 'H': Help(atoi(xoptarg)); return; case 'k': case 'K': InkLimit = atof(xoptarg); if (InkLimit < 0.0 || InkLimit > 400.0) { FatalError("Ink limit must be 0%%..400%%"); } break; case 'l': case 'L': KeepLinearization = TRUE; break; case 'n': case 'N': if (PrecalcMode != 1) { FatalError("Precalc mode already specified"); } NumOfGridPoints = atoi(xoptarg); break; case 'o': case 'O': cOutProf = xoptarg; break; case 'r': case 'R': Version = atof(xoptarg); if (Version < 2.0 || Version > 4.3) { fprintf(stderr, "WARNING: lcms was not aware of this version, tag types may be wrong!\n"); } break; case 't': case 'T': Intent = atoi(xoptarg); // Will be validated latter on break; case 'V': case 'v': Verbose = atoi(xoptarg); if (Verbose < 0 || Verbose > 3) { FatalError("Unknown verbosity level '%d'", Verbose); } break; case '8': lUse8bits = TRUE; break; case 'y': case 'Y': Copyright = xoptarg; break; case 'x': case 'X': TagResult = TRUE; break; default: FatalError("Unknown option - run without args to see valid ones.\n"); } } }
static void HandleSwitches(int argc, char *argv[]) { int s; while ((s = xgetopt(argc,argv,"%C:c:VvWwxXhHbBnNI:i:O:o:T:t:L:l:p:P:m:M:gG")) != EOF) { switch (s){ case 'b': case 'B': BlackPointCompensation = TRUE; break; case 'c': case 'C': PrecalcMode = atoi(xoptarg); if (PrecalcMode < 0 || PrecalcMode > 3) FatalError("Unknown precalc mode '%d'", PrecalcMode); break; case 'x': case 'X': InHexa = TRUE; break; case 'v': case 'V': Verbose = TRUE; break; case 'n': case 'N': lTerse = TRUE; break; case 'i': case 'I': if (lIsDeviceLink) FatalError("Device-link already specified"); cInProf = xoptarg; break; case 'o': case 'O': if (lIsDeviceLink) FatalError("Device-link already specified"); cOutProf = xoptarg; break; case 't': case 'T': Intent = atoi(xoptarg); if (Intent > 3) Intent = 3; if (Intent < 0) Intent = 0; break; case 'W': case 'w': Width16 = TRUE; break; case 'l': case 'L': cInProf = xoptarg; lIsDeviceLink = TRUE; break; case 'p': case 'P': cProofing = xoptarg; break; case 'm': case 'M': ProofingIntent = atoi(xoptarg); if (ProofingIntent > 3) ProofingIntent = 3; if (ProofingIntent < 0) ProofingIntent = 0; break; case 'g': case 'G': GamutCheck = TRUE; break; default: FatalError("Unknown option - run without args to see valid ones.\n"); } } }