1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/tools/gencmn/gencmn.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,124 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* 1.7 +* Copyright (C) 1999-2008, International Business Machines 1.8 +* Corporation and others. All Rights Reserved. 1.9 +* 1.10 +******************************************************************************* 1.11 +* file name: gencmn.c 1.12 +* encoding: US-ASCII 1.13 +* tab size: 8 (not used) 1.14 +* indentation:4 1.15 +* 1.16 +* created on: 1999nov01 1.17 +* created by: Markus W. Scherer 1.18 +* 1.19 +* This program reads a list of data files and combines them 1.20 +* into one common, memory-mappable file. 1.21 +*/ 1.22 + 1.23 +#include <stdio.h> 1.24 +#include <stdlib.h> 1.25 +#include "unicode/utypes.h" 1.26 +#include "unicode/putil.h" 1.27 +#include "cmemory.h" 1.28 +#include "cstring.h" 1.29 +#include "filestrm.h" 1.30 +#include "toolutil.h" 1.31 +#include "unicode/uclean.h" 1.32 +#include "unewdata.h" 1.33 +#include "uoptions.h" 1.34 +#include "putilimp.h" 1.35 +#include "pkg_gencmn.h" 1.36 + 1.37 +static UOption options[]={ 1.38 +/*0*/ UOPTION_HELP_H, 1.39 +/*1*/ UOPTION_HELP_QUESTION_MARK, 1.40 +/*2*/ UOPTION_VERBOSE, 1.41 +/*3*/ UOPTION_COPYRIGHT, 1.42 +/*4*/ UOPTION_DESTDIR, 1.43 +/*5*/ UOPTION_DEF( "comment", 'C', UOPT_REQUIRES_ARG), 1.44 +/*6*/ UOPTION_DEF( "name", 'n', UOPT_REQUIRES_ARG), 1.45 +/*7*/ UOPTION_DEF( "type", 't', UOPT_REQUIRES_ARG), 1.46 +/*8*/ UOPTION_DEF( "source", 'S', UOPT_NO_ARG), 1.47 +/*9*/ UOPTION_DEF( "entrypoint", 'e', UOPT_REQUIRES_ARG), 1.48 +/*10*/UOPTION_SOURCEDIR, 1.49 +}; 1.50 + 1.51 +extern int 1.52 +main(int argc, char* argv[]) { 1.53 + UBool sourceTOC, verbose; 1.54 + uint32_t maxSize; 1.55 + 1.56 + U_MAIN_INIT_ARGS(argc, argv); 1.57 + 1.58 + /* preset then read command line options */ 1.59 + argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); 1.60 + 1.61 + /* error handling, printing usage message */ 1.62 + if(argc<0) { 1.63 + fprintf(stderr, 1.64 + "error in command line argument \"%s\"\n", 1.65 + argv[-argc]); 1.66 + } else if(argc<2) { 1.67 + argc=-1; 1.68 + } 1.69 + 1.70 + if(argc<0 || options[0].doesOccur || options[1].doesOccur) { 1.71 + FILE *where = argc < 0 ? stderr : stdout; 1.72 + 1.73 + /* 1.74 + * Broken into chucks because the C89 standard says the minimum 1.75 + * required supported string length is 509 bytes. 1.76 + */ 1.77 + fprintf(where, 1.78 + "%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); 1.79 + if (options[0].doesOccur || options[1].doesOccur) { 1.80 + fprintf(where, "\n" 1.81 + "Read the list file (default: standard input) and create a common data\n" 1.82 + "file from specified files. Omit any files larger than maxsize, if maxsize > 0.\n"); 1.83 + fprintf(where, "\n" 1.84 + "Options:\n" 1.85 + "\t-h, -?, --help this usage text\n" 1.86 + "\t-v, --verbose verbose output\n" 1.87 + "\t-c, --copyright include the ICU copyright notice\n" 1.88 + "\t-C, --comment comment include a comment string\n" 1.89 + "\t-d, --destdir dir destination directory\n"); 1.90 + fprintf(where, 1.91 + "\t-n, --name filename output filename, without .type extension\n" 1.92 + "\t (default: " U_ICUDATA_NAME ")\n" 1.93 + "\t-t, --type filetype type of the destination file\n" 1.94 + "\t (default: \" dat \")\n" 1.95 + "\t-S, --source tocfile write a .c source file with the table of\n" 1.96 + "\t contents\n" 1.97 + "\t-e, --entrypoint name override the c entrypoint name\n" 1.98 + "\t (default: \"<name>_<type>\")\n"); 1.99 + } 1.100 + return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; 1.101 + } 1.102 + 1.103 + sourceTOC=options[8].doesOccur; 1.104 + 1.105 + verbose = options[2].doesOccur; 1.106 + 1.107 + maxSize=(uint32_t)uprv_strtoul(argv[1], NULL, 0); 1.108 + 1.109 + createCommonDataFile(options[4].doesOccur ? options[4].value : NULL, 1.110 + options[6].doesOccur ? options[6].value : NULL, 1.111 + options[9].doesOccur ? options[9].value : options[6].doesOccur ? options[6].value : NULL, 1.112 + options[7].doesOccur ? options[7].value : NULL, 1.113 + options[10].doesOccur ? options[10].value : NULL, 1.114 + options[3].doesOccur ? U_COPYRIGHT_STRING : options[5].doesOccur ? options[5].value : NULL, 1.115 + argc == 2 ? NULL : argv[2], 1.116 + maxSize, sourceTOC, verbose, NULL); 1.117 + 1.118 + return 0; 1.119 +} 1.120 +/* 1.121 + * Hey, Emacs, please set the following: 1.122 + * 1.123 + * Local Variables: 1.124 + * indent-tabs-mode: nil 1.125 + * End: 1.126 + * 1.127 + */