Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 1999-2008, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ******************************************************************************* |
michael@0 | 8 | * file name: gencmn.c |
michael@0 | 9 | * encoding: US-ASCII |
michael@0 | 10 | * tab size: 8 (not used) |
michael@0 | 11 | * indentation:4 |
michael@0 | 12 | * |
michael@0 | 13 | * created on: 1999nov01 |
michael@0 | 14 | * created by: Markus W. Scherer |
michael@0 | 15 | * |
michael@0 | 16 | * This program reads a list of data files and combines them |
michael@0 | 17 | * into one common, memory-mappable file. |
michael@0 | 18 | */ |
michael@0 | 19 | |
michael@0 | 20 | #include <stdio.h> |
michael@0 | 21 | #include <stdlib.h> |
michael@0 | 22 | #include "unicode/utypes.h" |
michael@0 | 23 | #include "unicode/putil.h" |
michael@0 | 24 | #include "cmemory.h" |
michael@0 | 25 | #include "cstring.h" |
michael@0 | 26 | #include "filestrm.h" |
michael@0 | 27 | #include "toolutil.h" |
michael@0 | 28 | #include "unicode/uclean.h" |
michael@0 | 29 | #include "unewdata.h" |
michael@0 | 30 | #include "uoptions.h" |
michael@0 | 31 | #include "putilimp.h" |
michael@0 | 32 | #include "pkg_gencmn.h" |
michael@0 | 33 | |
michael@0 | 34 | static UOption options[]={ |
michael@0 | 35 | /*0*/ UOPTION_HELP_H, |
michael@0 | 36 | /*1*/ UOPTION_HELP_QUESTION_MARK, |
michael@0 | 37 | /*2*/ UOPTION_VERBOSE, |
michael@0 | 38 | /*3*/ UOPTION_COPYRIGHT, |
michael@0 | 39 | /*4*/ UOPTION_DESTDIR, |
michael@0 | 40 | /*5*/ UOPTION_DEF( "comment", 'C', UOPT_REQUIRES_ARG), |
michael@0 | 41 | /*6*/ UOPTION_DEF( "name", 'n', UOPT_REQUIRES_ARG), |
michael@0 | 42 | /*7*/ UOPTION_DEF( "type", 't', UOPT_REQUIRES_ARG), |
michael@0 | 43 | /*8*/ UOPTION_DEF( "source", 'S', UOPT_NO_ARG), |
michael@0 | 44 | /*9*/ UOPTION_DEF( "entrypoint", 'e', UOPT_REQUIRES_ARG), |
michael@0 | 45 | /*10*/UOPTION_SOURCEDIR, |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | extern int |
michael@0 | 49 | main(int argc, char* argv[]) { |
michael@0 | 50 | UBool sourceTOC, verbose; |
michael@0 | 51 | uint32_t maxSize; |
michael@0 | 52 | |
michael@0 | 53 | U_MAIN_INIT_ARGS(argc, argv); |
michael@0 | 54 | |
michael@0 | 55 | /* preset then read command line options */ |
michael@0 | 56 | argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); |
michael@0 | 57 | |
michael@0 | 58 | /* error handling, printing usage message */ |
michael@0 | 59 | if(argc<0) { |
michael@0 | 60 | fprintf(stderr, |
michael@0 | 61 | "error in command line argument \"%s\"\n", |
michael@0 | 62 | argv[-argc]); |
michael@0 | 63 | } else if(argc<2) { |
michael@0 | 64 | argc=-1; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | if(argc<0 || options[0].doesOccur || options[1].doesOccur) { |
michael@0 | 68 | FILE *where = argc < 0 ? stderr : stdout; |
michael@0 | 69 | |
michael@0 | 70 | /* |
michael@0 | 71 | * Broken into chucks because the C89 standard says the minimum |
michael@0 | 72 | * required supported string length is 509 bytes. |
michael@0 | 73 | */ |
michael@0 | 74 | fprintf(where, |
michael@0 | 75 | "%csage: %s [ -h, -?, --help ] [ -v, --verbose ] [ -c, --copyright ] [ -C, --comment comment ] [ -d, --destdir dir ] [ -n, --name filename ] [ -t, --type filetype ] [ -S, --source tocfile ] [ -e, --entrypoint name ] maxsize listfile\n", argc < 0 ? 'u' : 'U', *argv); |
michael@0 | 76 | if (options[0].doesOccur || options[1].doesOccur) { |
michael@0 | 77 | fprintf(where, "\n" |
michael@0 | 78 | "Read the list file (default: standard input) and create a common data\n" |
michael@0 | 79 | "file from specified files. Omit any files larger than maxsize, if maxsize > 0.\n"); |
michael@0 | 80 | fprintf(where, "\n" |
michael@0 | 81 | "Options:\n" |
michael@0 | 82 | "\t-h, -?, --help this usage text\n" |
michael@0 | 83 | "\t-v, --verbose verbose output\n" |
michael@0 | 84 | "\t-c, --copyright include the ICU copyright notice\n" |
michael@0 | 85 | "\t-C, --comment comment include a comment string\n" |
michael@0 | 86 | "\t-d, --destdir dir destination directory\n"); |
michael@0 | 87 | fprintf(where, |
michael@0 | 88 | "\t-n, --name filename output filename, without .type extension\n" |
michael@0 | 89 | "\t (default: " U_ICUDATA_NAME ")\n" |
michael@0 | 90 | "\t-t, --type filetype type of the destination file\n" |
michael@0 | 91 | "\t (default: \" dat \")\n" |
michael@0 | 92 | "\t-S, --source tocfile write a .c source file with the table of\n" |
michael@0 | 93 | "\t contents\n" |
michael@0 | 94 | "\t-e, --entrypoint name override the c entrypoint name\n" |
michael@0 | 95 | "\t (default: \"<name>_<type>\")\n"); |
michael@0 | 96 | } |
michael@0 | 97 | return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | sourceTOC=options[8].doesOccur; |
michael@0 | 101 | |
michael@0 | 102 | verbose = options[2].doesOccur; |
michael@0 | 103 | |
michael@0 | 104 | maxSize=(uint32_t)uprv_strtoul(argv[1], NULL, 0); |
michael@0 | 105 | |
michael@0 | 106 | createCommonDataFile(options[4].doesOccur ? options[4].value : NULL, |
michael@0 | 107 | options[6].doesOccur ? options[6].value : NULL, |
michael@0 | 108 | options[9].doesOccur ? options[9].value : options[6].doesOccur ? options[6].value : NULL, |
michael@0 | 109 | options[7].doesOccur ? options[7].value : NULL, |
michael@0 | 110 | options[10].doesOccur ? options[10].value : NULL, |
michael@0 | 111 | options[3].doesOccur ? U_COPYRIGHT_STRING : options[5].doesOccur ? options[5].value : NULL, |
michael@0 | 112 | argc == 2 ? NULL : argv[2], |
michael@0 | 113 | maxSize, sourceTOC, verbose, NULL); |
michael@0 | 114 | |
michael@0 | 115 | return 0; |
michael@0 | 116 | } |
michael@0 | 117 | /* |
michael@0 | 118 | * Hey, Emacs, please set the following: |
michael@0 | 119 | * |
michael@0 | 120 | * Local Variables: |
michael@0 | 121 | * indent-tabs-mode: nil |
michael@0 | 122 | * End: |
michael@0 | 123 | * |
michael@0 | 124 | */ |