1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 1999-2016, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
12 * tab size: 8 (not used)
15 * created on: 1999nov01
16 * created by: Markus W. Scherer
18 * This program reads a list of data files and combines them
19 * into one common, memory-mappable file.
24 #include "unicode/utypes.h"
25 #include "unicode/putil.h"
30 #include "unicode/uclean.h"
34 #include "pkg_gencmn.h"
36 static UOption options[]={
38 /*1*/ UOPTION_HELP_QUESTION_MARK,
39 /*2*/ UOPTION_VERBOSE,
40 /*3*/ UOPTION_COPYRIGHT,
41 /*4*/ UOPTION_DESTDIR,
42 /*5*/ UOPTION_DEF( "comment", 'C', UOPT_REQUIRES_ARG),
43 /*6*/ UOPTION_DEF( "name", 'n', UOPT_REQUIRES_ARG),
44 /*7*/ UOPTION_DEF( "type", 't', UOPT_REQUIRES_ARG),
45 /*8*/ UOPTION_DEF( "source", 'S', UOPT_NO_ARG),
46 /*9*/ UOPTION_DEF( "entrypoint", 'e', UOPT_REQUIRES_ARG),
47 /*10*/UOPTION_SOURCEDIR,
51 main(int argc, char* argv[]) {
52 UBool sourceTOC, verbose;
55 U_MAIN_INIT_ARGS(argc, argv);
57 /* preset then read command line options */
58 argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options);
60 /* error handling, printing usage message */
63 "error in command line argument \"%s\"\n",
69 if(argc<0 || options[0].doesOccur || options[1].doesOccur) {
70 FILE *where = argc < 0 ? stderr : stdout;
73 * Broken into chucks because the C89 standard says the minimum
74 * required supported string length is 509 bytes.
77 "%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);
78 if (options[0].doesOccur || options[1].doesOccur) {
80 "Read the list file (default: standard input) and create a common data\n"
81 "file from specified files. Omit any files larger than maxsize, if maxsize > 0.\n");
84 "\t-h, -?, --help this usage text\n"
85 "\t-v, --verbose verbose output\n"
86 "\t-c, --copyright include the ICU copyright notice\n"
87 "\t-C, --comment comment include a comment string\n"
88 "\t-d, --destdir dir destination directory\n");
90 "\t-n, --name filename output filename, without .type extension\n"
91 "\t (default: " U_ICUDATA_NAME ")\n"
92 "\t-t, --type filetype type of the destination file\n"
93 "\t (default: \" dat \")\n"
94 "\t-S, --source tocfile write a .c source file with the table of\n"
96 "\t-e, --entrypoint name override the c entrypoint name\n"
97 "\t (default: \"<name>_<type>\")\n");
99 return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
102 sourceTOC=options[8].doesOccur;
104 verbose = options[2].doesOccur;
106 maxSize=(uint32_t)uprv_strtoul(argv[1], NULL, 0);
108 createCommonDataFile(options[4].doesOccur ? options[4].value : NULL,
109 options[6].doesOccur ? options[6].value : NULL,
110 options[9].doesOccur ? options[9].value : options[6].doesOccur ? options[6].value : NULL,
111 options[7].doesOccur ? options[7].value : NULL,
112 options[10].doesOccur ? options[10].value : NULL,
113 options[3].doesOccur ? U_COPYRIGHT_STRING : options[5].doesOccur ? options[5].value : NULL,
114 argc == 2 ? NULL : argv[2],
115 maxSize, sourceTOC, verbose, NULL);
120 * Hey, Emacs, please set the following:
123 * indent-tabs-mode: nil