1999-11-22 17:56:30 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
1999-12-13 22:28:37 +00:00
|
|
|
*
|
2008-11-24 20:04:52 +00:00
|
|
|
* Copyright (C) 1999-2008, International Business Machines
|
1999-12-13 22:28:37 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
1999-11-22 17:56:30 +00:00
|
|
|
*******************************************************************************
|
|
|
|
* file name: gencmn.c
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 1999nov01
|
|
|
|
* created by: Markus W. Scherer
|
|
|
|
*
|
|
|
|
* This program reads a list of data files and combines them
|
|
|
|
* into one common, memory-mappable file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/utypes.h"
|
2001-01-03 00:18:57 +00:00
|
|
|
#include "unicode/putil.h"
|
1999-11-22 17:56:30 +00:00
|
|
|
#include "cmemory.h"
|
|
|
|
#include "cstring.h"
|
|
|
|
#include "filestrm.h"
|
1999-11-23 04:49:35 +00:00
|
|
|
#include "toolutil.h"
|
2003-08-14 21:34:54 +00:00
|
|
|
#include "unicode/uclean.h"
|
1999-11-23 04:49:35 +00:00
|
|
|
#include "unewdata.h"
|
2000-04-18 20:31:36 +00:00
|
|
|
#include "uoptions.h"
|
2006-08-15 23:27:31 +00:00
|
|
|
#include "putilimp.h"
|
2008-11-24 20:04:52 +00:00
|
|
|
#include "pkg_gencmn.h"
|
1999-11-22 17:56:30 +00:00
|
|
|
|
2000-04-18 20:31:36 +00:00
|
|
|
static UOption options[]={
|
2000-12-06 03:02:21 +00:00
|
|
|
/*0*/ UOPTION_HELP_H,
|
|
|
|
/*1*/ UOPTION_HELP_QUESTION_MARK,
|
|
|
|
/*2*/ UOPTION_VERBOSE,
|
|
|
|
/*3*/ UOPTION_COPYRIGHT,
|
|
|
|
/*4*/ UOPTION_DESTDIR,
|
|
|
|
/*5*/ UOPTION_DEF( "comment", 'C', UOPT_REQUIRES_ARG),
|
|
|
|
/*6*/ UOPTION_DEF( "name", 'n', UOPT_REQUIRES_ARG),
|
|
|
|
/*7*/ UOPTION_DEF( "type", 't', UOPT_REQUIRES_ARG),
|
|
|
|
/*8*/ UOPTION_DEF( "source", 'S', UOPT_NO_ARG),
|
2004-04-14 20:08:16 +00:00
|
|
|
/*9*/ UOPTION_DEF( "entrypoint", 'e', UOPT_REQUIRES_ARG),
|
|
|
|
/*10*/UOPTION_SOURCEDIR,
|
2000-04-18 20:31:36 +00:00
|
|
|
};
|
|
|
|
|
1999-11-22 17:56:30 +00:00
|
|
|
extern int
|
2000-09-21 21:49:32 +00:00
|
|
|
main(int argc, char* argv[]) {
|
2002-02-06 21:05:34 +00:00
|
|
|
UBool sourceTOC, verbose;
|
2008-11-24 20:04:52 +00:00
|
|
|
uint32_t maxSize;
|
1999-11-22 17:56:30 +00:00
|
|
|
|
2002-03-15 23:47:04 +00:00
|
|
|
U_MAIN_INIT_ARGS(argc, argv);
|
|
|
|
|
2000-04-18 20:31:36 +00:00
|
|
|
/* preset then read command line options */
|
|
|
|
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
|
|
|
|
|
|
|
|
/* error handling, printing usage message */
|
|
|
|
if(argc<0) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"error in command line argument \"%s\"\n",
|
|
|
|
argv[-argc]);
|
|
|
|
} else if(argc<2) {
|
|
|
|
argc=-1;
|
|
|
|
}
|
2004-04-14 20:08:16 +00:00
|
|
|
|
2000-04-18 20:31:36 +00:00
|
|
|
if(argc<0 || options[0].doesOccur || options[1].doesOccur) {
|
2002-02-12 20:04:52 +00:00
|
|
|
FILE *where = argc < 0 ? stderr : stdout;
|
2008-11-24 20:04:52 +00:00
|
|
|
|
2001-11-20 02:46:46 +00:00
|
|
|
/*
|
|
|
|
* Broken into chucks because the C89 standard says the minimum
|
|
|
|
* required supported string length is 509 bytes.
|
|
|
|
*/
|
2002-02-12 20:04:52 +00:00
|
|
|
fprintf(where,
|
2004-07-18 06:22:21 +00:00
|
|
|
"%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);
|
2002-04-02 00:55:09 +00:00
|
|
|
if (options[0].doesOccur || options[1].doesOccur) {
|
2002-02-12 20:04:52 +00:00
|
|
|
fprintf(where, "\n"
|
2004-07-18 06:22:21 +00:00
|
|
|
"Read the list file (default: standard input) and create a common data\n"
|
|
|
|
"file from specified files. Omit any files larger than maxsize, if maxsize > 0.\n");
|
2002-02-12 20:04:52 +00:00
|
|
|
fprintf(where, "\n"
|
2002-04-04 18:58:50 +00:00
|
|
|
"Options:\n"
|
|
|
|
"\t-h, -?, --help this usage text\n"
|
|
|
|
"\t-v, --verbose verbose output\n"
|
|
|
|
"\t-c, --copyright include the ICU copyright notice\n"
|
|
|
|
"\t-C, --comment comment include a comment string\n"
|
|
|
|
"\t-d, --destdir dir destination directory\n");
|
|
|
|
fprintf(where,
|
|
|
|
"\t-n, --name filename output filename, without .type extension\n"
|
2008-11-24 20:04:52 +00:00
|
|
|
"\t (default: " U_ICUDATA_NAME ")\n"
|
2002-04-04 18:58:50 +00:00
|
|
|
"\t-t, --type filetype type of the destination file\n"
|
2008-11-24 20:04:52 +00:00
|
|
|
"\t (default: \" dat \")\n"
|
2002-04-04 18:58:50 +00:00
|
|
|
"\t-S, --source tocfile write a .c source file with the table of\n"
|
|
|
|
"\t contents\n"
|
|
|
|
"\t-e, --entrypoint name override the c entrypoint name\n"
|
2002-06-05 21:45:39 +00:00
|
|
|
"\t (default: \"<name>_<type>\")\n");
|
2002-02-12 20:04:52 +00:00
|
|
|
}
|
2000-04-18 20:31:36 +00:00
|
|
|
return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
|
2000-02-29 18:34:21 +00:00
|
|
|
}
|
|
|
|
|
2000-05-03 23:08:50 +00:00
|
|
|
sourceTOC=options[8].doesOccur;
|
|
|
|
|
2002-02-06 21:05:34 +00:00
|
|
|
verbose = options[2].doesOccur;
|
|
|
|
|
2001-05-22 22:25:48 +00:00
|
|
|
maxSize=(uint32_t)uprv_strtoul(argv[1], NULL, 0);
|
1999-11-22 17:56:30 +00:00
|
|
|
|
2008-11-24 20:04:52 +00:00
|
|
|
createCommonDataFile(options[4].doesOccur ? options[4].value : NULL,
|
|
|
|
options[6].doesOccur ? options[6].value : NULL,
|
|
|
|
options[9].doesOccur ? options[9].value : options[6].doesOccur ? options[6].value : NULL,
|
|
|
|
options[7].doesOccur ? options[7].value : NULL,
|
|
|
|
options[10].doesOccur ? options[10].value : NULL,
|
|
|
|
options[3].doesOccur ? U_COPYRIGHT_STRING : options[5].doesOccur ? options[5].value : NULL,
|
|
|
|
argc == 2 ? NULL : argv[2],
|
|
|
|
maxSize, sourceTOC, verbose, NULL);
|
1999-11-22 17:56:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2000-02-29 18:34:21 +00:00
|
|
|
/*
|
|
|
|
* Hey, Emacs, please set the following:
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
*/
|