static void help(void) { synopsis(stdout); printf( " -Dsym=val define preprocessor symbol with given value\n" " -Dsym define preprocessor symbol with value 1\n" " -Usym preprocessor symbol is undefined\n" " -iDsym=val \\ ignore C strings and comments\n" " -iDsym ) in sections controlled by these\n" " -iUsym / preprocessor symbols\n" " -fpath file containing #define and #undef directives\n" " -b blank lines instead of deleting them\n" " -B compress blank lines around deleted section\n" " -c complement (invert) keep vs. delete\n" " -d debugging mode\n" " -e ignore multiline preprocessor directives\n" " -h print help\n" " -Ipath extra include file path (ignored)\n" " -K disable && and || short-circuiting\n" " -k process constant #if expressions\n" " -Mext modify in place and keep backups\n" " -m modify input files in place\n" " -n add #line directives to output\n" " -opath output file name\n" " -S list #if control symbols with nesting\n" " -s list #if control symbols\n" " -t ignore C strings and comments\n" " -V print version\n" " -x{012} exit status mode\n" ); exit(0); }
static void short_usage (char *program_name) { PR_fprintf (PR_STDERR, "Type %s -H for more detailed descriptions\n", program_name); synopsis (program_name); }
void Command::setup_common(const boost::program_options::variables_map& vm, const po::options_description& desc) { if (vm.count("help")) { std::cout << "Usage: " << synopsis() << "\n\n" << CommandFactory::get_description(name()) << "\n" << desc << "\nUse 'osmium help " << name() << "' to display the manual page.\n"; exit(0); } if (vm.count("verbose")) { m_vout.verbose(true); } }
void help() { synopsis(stdout); fputs("\n" "-h\tprint this message\n" "-t\tpreprocess with tbl\n" "-p\tpreprocess with pic\n" "-e\tpreprocess with eqn\n" "-g\tpreprocess with grn\n" "-G\tpreprocess with grap\n" "-s\tpreprocess with soelim\n" "-R\tpreprocess with refer\n" "-Tdev\tuse device dev\n" "-X\tuse X11 previewer rather than usual postprocessor\n" "-mname\tread macros tmac.name\n" "-dcs\tdefine a string c as s\n" "-rcn\tdefine a number register c as n\n" "-nnum\tnumber first page n\n" "-olist\toutput only pages in list\n" "-ffam\tuse fam as the default font family\n" "-Fdir\tsearch dir for device directories\n" "-Mdir\tsearch dir for macro files\n" "-v\tprint version number\n" "-z\tsuppress formatted output\n" "-Z\tdon't postprocess\n" "-a\tproduce ASCII description of output\n" "-i\tread standard input after named input files\n" "-wname\tenable warning name\n" "-Wname\tinhibit warning name\n" "-E\tinhibit all errors\n" "-b\tprint backtraces with errors or warnings\n" "-l\tspool the output\n" "-c\tdisable color output\n" "-C\tenable compatibility mode\n" "-V\tprint commands on stdout instead of running them\n" "-Parg\tpass arg to the postprocessor\n" "-Larg\tpass arg to the spooler\n" "-N\tdon't allow newlines within eqn delimiters\n" "-S\tenable safer mode (the default)\n" "-U\tenable unsafe mode\n" "-Idir\tsearch dir for soelim, troff, and grops. Implies -s\n" "\n", stdout); exit(0); }
static void long_usage (char *program_name) { PRFileDesc *pr_stderr; pr_stderr = PR_STDERR; synopsis (program_name); PR_fprintf (pr_stderr, "\nDecode encrypted passwords (and other data).\n"); PR_fprintf (pr_stderr, "This program reads in standard configuration files looking\n" "for base 64 encoded data. Data that looks like it's base 64 encode\n" "is decoded an passed to the NSS SDR code. If the decode and decrypt\n" "is successful, then decrypted data is outputted in place of the\n" "original base 64 data. If the decode or decrypt fails, the original\n" "data is written and the reason for failure is logged to the \n" "optional logfile.\n"); PR_fprintf (pr_stderr, " %-13s Read stream including encrypted data from " "\"read_file\"\n", "-i read_file"); PR_fprintf (pr_stderr, " %-13s Write results to \"write_file\"\n", "-o write_file"); PR_fprintf (pr_stderr, " %-13s Find security databases in \"dbdir\"\n", "-d dbdir"); PR_fprintf (pr_stderr, " %-13s Log failed decrypt/decode attempts to \"log_file\"\n", "-l log_file"); PR_fprintf (pr_stderr, " %-13s Token password\n", "-p pwd"); PR_fprintf (pr_stderr, " %-13s Password file\n", "-f pwfile"); }
static void long_usage (char *program_name) { synopsis (program_name); PR_fprintf (pr_stderr, "\nSecret Decoder Test:\n"); PR_fprintf (pr_stderr, " %-13s Read encrypted data from \"file\"\n", "-i file"); PR_fprintf (pr_stderr, " %-13s Write newly generated encrypted data to \"file\"\n", "-o file"); PR_fprintf (pr_stderr, " %-13s Use \"text\" as the plaintext for encryption and verification\n", "-t text"); PR_fprintf (pr_stderr, " %-13s Find security databases in \"dbdir\"\n", "-d dbdir"); PR_fprintf (pr_stderr, " %-13s read the password from \"pwfile\"\n", "-f pwfile"); PR_fprintf (pr_stderr, " %-13s supply \"password\" on the command line\n", "-p password"); }
static void long_usage (char *program_name) { PRFileDesc *pr_stderr; pr_stderr = PR_STDERR; synopsis (program_name); PR_fprintf (pr_stderr, "\nCommands (must specify exactly one):\n"); PR_fprintf (pr_stderr, " %-13s Pretty-print a binary request read from stdin\n", "-p"); PR_fprintf (pr_stderr, " %-13s Pretty-print a binary response read from stdin\n", "-P"); PR_fprintf (pr_stderr, " %-13s Create a request for cert \"nickname\" on stdout\n", "-r nickname"); PR_fprintf (pr_stderr, " %-13s Get response for cert \"nickname\", dump to stdout\n", "-R nickname"); PR_fprintf (pr_stderr, " %-13s Get status for cert \"nickname\"\n", "-S nickname"); PR_fprintf (pr_stderr, " %-13s Fully verify cert \"nickname\", w/ status check\n", "-V nickname"); PR_fprintf (pr_stderr, "\n %-10s also can be the name of the file with DER or\n" " %-13s PEM(use -a option) cert encoding\n", "nickname", ""); PR_fprintf (pr_stderr, "Options:\n"); PR_fprintf (pr_stderr, " %-13s Decode input cert from PEM format. DER is default\n", "-a"); PR_fprintf (pr_stderr, " %-13s Add the service locator extension to the request\n", "-L"); PR_fprintf (pr_stderr, " %-13s Find security databases in \"dbdir\" (default %s)\n", "-d dbdir", DEFAULT_DB_DIR); PR_fprintf (pr_stderr, " %-13s Use \"location\" as URL of responder\n", "-l location"); PR_fprintf (pr_stderr, " %-13s Trust cert \"nickname\" as response signer\n", "-t nickname"); PR_fprintf (pr_stderr, " %-13s Sign requests with cert \"nickname\"\n", "-s nickname"); PR_fprintf (pr_stderr, " %-13s Type of certificate usage for verification:\n", "-u usage"); PR_fprintf (pr_stderr, "%-17s c SSL Client\n", ""); PR_fprintf (pr_stderr, "%-17s s SSL Server\n", ""); PR_fprintf (pr_stderr, "%-17s e Email Recipient\n", ""); PR_fprintf (pr_stderr, "%-17s E Email Signer\n", ""); PR_fprintf (pr_stderr, "%-17s S Object Signer\n", ""); PR_fprintf (pr_stderr, "%-17s C CA\n", ""); PR_fprintf (pr_stderr, " %-13s Validity time (default current time), one of:\n", "-w time"); PR_fprintf (pr_stderr, "%-17s %-25s (GMT)\n", "", "YYMMDDhhmm[ss]Z"); PR_fprintf (pr_stderr, "%-17s %-25s (later than GMT)\n", "", "YYMMDDhhmm[ss]+hhmm"); PR_fprintf (pr_stderr, "%-17s %-25s (earlier than GMT)\n", "", "YYMMDDhhmm[ss]-hhmm"); }
void usage(FILE *stream) { synopsis(stream); fprintf(stream, "%s -h gives more help\n", program_name); }
static void usage(void) { synopsis(stderr); exit(2); }
int main(int argc, char *argv[]) { printf("AnsiLove/C %s - ANSi / ASCII art to PNG converter\n"\ "Copyright (C) 2011-2012 Stefan Vogt, Brian Cassidy, Frederic Cambus.\n", VERSION); // SAUCE record related bool types bool justDisplaySAUCE = false; bool fileHasSAUCE = false; // retina output bool type bool createRetinaRep = false; // analyze options and do what has to be done bool outputIdentical = false; bool fileIsBinary = false; bool fileIsANSi = false; bool fileIsPCBoard = false; bool fileIsTundra = false; if (argc == 1 || argc >= 9) { synopsis(); return EXIT_SUCCESS; } if ((strcmp(argv[1], "-v") == 0) || (strcmp(argv[1], "--version") == 0)) { versionInfo(); return EXIT_SUCCESS; } if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) { showHelp(); return EXIT_SUCCESS; } if (strcmp(argv[1], "-e") == 0) { listExamples(); return EXIT_SUCCESS; } if ((argv[2] && (strcmp(argv[2], "-s") == 0)) || (argv[2] && (strcmp(argv[2], "-i") == 0)) || (argv[2] && (strcmp(argv[2], "-ir") == 0)) || (argv[2] && (strcmp(argv[2], "-o") == 0)) || (argv[2] && (strcmp(argv[2], "-or") == 0))) { if (strcmp(argv[2], "-s") == 0) { justDisplaySAUCE = true; } if (strcmp(argv[2], "-ir") == 0 || strcmp(argv[2], "-or") == 0) { createRetinaRep = true; } // let's check the file for a valid SAUCE record sauce *record = sauceReadFileName(argv[1]); // record == NULL also means there is no file, we can stop here if (record == NULL) { printf("\nFile %s not found.\n\n", argv[1]); return EXIT_FAILURE; } else { // if we find a SAUCE record, update bool flag if (strcmp(record->ID, SAUCE_ID) == 0) { fileHasSAUCE = true; } } // this should be self-explanatory if (justDisplaySAUCE == false) { // declaration of types we pass to ansilove.c char *input = argv[1]; char output[1000] = { 0 }; char retinaout[1000] = { 0 }; char columns[1000] = { 0 }; char font[1000] = { 0 }; char bits[1000] = { 0 }; char icecolors[1000] = { 0 }; char *fext; // find last position of char '.' so we can determine the file extension size_t index = strrchr(input, '.') - input; // calculate size of the input string size_t inpSize = strlen(input); // generate size_t result we can pass to our substr() implementation size_t result = inpSize - index; // finally create the file extension string fext = substr(input, inpSize - result, result); fext = strtolower(fext); if (fext == NULL) { fext = "none"; } // in case we got arguments for input and the '-i' or '-ir' flag is set if (strcmp(argv[2], "-i") == 0) { // append .png suffix to file name sprintf(output, "%s.png", input); sprintf(retinaout, "placeholder_%s.png", input); outputIdentical = true; } if (strcmp(argv[2], "-ir") == 0) { // again, append .png and also add @2x for retina output sprintf(output, "%s.png", input); sprintf(retinaout, "*****@*****.**", input); outputIdentical = true; } if ((strcmp(argv[2], "-o") == 0) && argv[3]) { // so the user provided an alternate path / file name sprintf(output, "%s.png", argv[3]); sprintf(retinaout, "placeholder_%s.png", input); } if ((strcmp(argv[2], "-or") == 0) && argv[3]) { // alternate path and retina? damn you! even more work. sprintf(output, "%s.png", argv[3]); sprintf(retinaout, "*****@*****.**", argv[3]); } if ((strcmp(argv[2], "-o") == 0) && !argv[3]) { // arrr... matey! setting the option -o without output file argument, eh? printf("\nOption -o is invalid without output file argument.\n\n"); return EXIT_FAILURE; } if ((strcmp(argv[2], "-or") == 0) && !argv[3]) { // y u no enter output file argument? printf("\nOption -or is invalid without output file argument.\n\n"); return EXIT_FAILURE; } // check for operands and apply them based on the file extension if ((strcmp(fext, ".bin") == 0) && outputIdentical == true) { // set binary bool value fileIsBinary = true; // font if (argc >= 4) { sprintf(font, "%s", argv[3]); } else { sprintf(font, "%s", "80x25"); } // bits if (argc >= 5) { sprintf(bits, "%s", argv[4]); } else { sprintf(bits, "%s", "8"); } // iCE colors if (argc >= 6) { sprintf(icecolors, "%s", argv[5]); } else { sprintf(icecolors, "%s", "0"); } // columns if (argc >= 7) { sprintf(columns, "%s", argv[6]); } else { sprintf(columns, "%s", "160"); } } else if ((strcmp(fext, ".bin") == 0) && outputIdentical == false) { // font if (argc >= 5) { sprintf(font, "%s", argv[4]); } else { sprintf(font, "%s", "80x25"); } // bits if (argc >= 6) { sprintf(bits, "%s", argv[5]); } else { sprintf(bits, "%s", "8"); } // iCE colors if (argc >= 7) { sprintf(icecolors, "%s", argv[6]); } else { sprintf(icecolors, "%s", "0"); } // columns if (argc >= 8) { sprintf(columns, "%s", argv[7]); } else { sprintf(columns, "%s", "160"); } } else { if (outputIdentical == true) { // font if (argc >= 4) { sprintf(font, "%s", argv[3]); } else { sprintf(font, "%s", "80x25"); } // bits if (argc >= 5) { sprintf(bits, "%s", argv[4]); } else { sprintf(bits, "%s", "8"); } // iCE colors if (argc >= 6) { sprintf(icecolors, "%s", argv[5]); } else { sprintf(icecolors, "%s", "0"); } } else { // font if (argc >= 5) { sprintf(font, "%s", argv[4]); } else { sprintf(font, "%s", "80x25"); } // bits if (argc >= 6) { sprintf(bits, "%s", argv[5]); } else { sprintf(bits, "%s", "8"); } // iCE colors if (argc >= 7) { sprintf(icecolors, "%s", argv[6]); } else { sprintf(icecolors, "%s", "0"); } } } // create the output file by invoking the appropiate function if (strcmp(fext, ".pcb") == 0) { // params: input, output, font, bits, icecolors alPcBoardLoader(input, output, retinaout, font, bits, createRetinaRep); fileIsPCBoard = true; } else if (strcmp(fext, ".bin") == 0) { // params: input, output, columns, font, bits, icecolors alBinaryLoader(input, output, retinaout, columns, font, bits, icecolors, createRetinaRep); fileIsBinary = true; } else if (strcmp(fext, ".adf") == 0) { // params: input, output, bits alArtworxLoader(input, output, retinaout, bits, createRetinaRep); } else if (strcmp(fext, ".idf") == 0) { // params: input, output, bits alIcedrawLoader(input, output, retinaout, bits, fileHasSAUCE, createRetinaRep); } else if (strcmp(fext, ".tnd") == 0) { alTundraLoader(input, output, retinaout, font, bits, createRetinaRep); fileIsTundra = true; } else if (strcmp(fext, ".xb") == 0) { // params: input, output, bits alXbinLoader(input, output, retinaout, bits, createRetinaRep); } else { // params: input, output, font, bits, icecolors, fext alAnsiLoader(input, output, retinaout, font, bits, icecolors, fext, createRetinaRep); fileIsANSi = true; } // gather information and report to the command line printf("\nInput File: %s\n", input); printf("Output File: %s\n", output); if (createRetinaRep == true) { printf("Retina Output File: %s\n", retinaout); } if (fileIsANSi == true || fileIsBinary == true || fileIsPCBoard == true || fileIsTundra == true) { printf("Font: %s\n", font); } if (fileIsANSi == true || fileIsBinary == true || fileIsPCBoard == true || fileIsTundra == true) { printf("Bits: %s\n", bits); } if (fileIsANSi == true || fileIsBinary == true || fileIsPCBoard == true) { printf("iCE Colors: %s\n", icecolors); } if (fileIsBinary == true) { printf("Columns: %s\n", columns); } } // either display SAUCE or tell us if there is no record if (fileHasSAUCE == false) { printf("\nFile %s does not have a SAUCE record.\n", argv[1]); } else { printf( "\n%s: %s v%s\n", "Id", record->ID, record->version); printf( "%s: %s\n", "Title", record->title ); printf( "%s: %s\n", "Author", record->author); printf( "%s: %s\n", "Group", record->group); printf( "%s: %s\n", "Date", record->date); printf( "%s: %d\n", "Datatype", record->dataType); printf( "%s: %d\n", "Filetype", record->fileType); if (record->flags != 0) { printf( "%s: %d\n", "Flags", record->flags); } if (record->tinfo1 != 0) { printf( "%s: %d\n", "Tinfo1", record->tinfo1); } if (record->tinfo2 != 0) { printf( "%s: %d\n", "Tinfo2", record->tinfo2); } if (record->tinfo3 != 0) { printf( "%s: %d\n", "Tinfo3", record->tinfo3); } if (record->tinfo4 != 0) { printf( "%s: %d\n", "Tinfo4", record->tinfo4); } if (record->comments > 0) { int32_t i; printf( "Comments: "); for(i = 0; i < record->comments; i++) { printf( "%s\n", record->comment_lines[i] ); } } } // post a message when the output file is created (in case we created output) if (justDisplaySAUCE == false) { printf("\nSuccessfully created output file.\n\n"); } else { printf("\n"); } } else { // in any other case the synopsis will be just fine synopsis(); return EXIT_SUCCESS; } return EXIT_SUCCESS; }