/* ******************************************************************************* * * * COPYRIGHT: * * (C) Copyright International Business Machines Corporation, 1999 * * Licensed Material - Program-Property of IBM - All Rights Reserved. * * US Government Users Restricted Rights - Use, duplication, or disclosure * * restricted by GSA ADP Schedule Contract with IBM Corp. * * * ******************************************************************************* * file name: gencnval.c * encoding: US-ASCII * tab size: 8 (not used) * indentation:4 * * created on: 1999nov05 * created by: Markus W. Scherer * * This program reads convrtrs.txt and writes a memory-mappable * converter name alias table to cnvalias.dat . */ #include #include #include #include "utypes.h" #include "cmemory.h" #include "cstring.h" #include "filestrm.h" #include "unewdata.h" #define STRING_STORE_SIZE 100000 #define MAX_ALIAS_COUNT 2000 #define DATA_NAME "cnvalias" #define DATA_TYPE "dat" #define DATA_COPYRIGHT "\n" \ "*******************************************************************************\n" \ "* COPYRIGHT: *\n" \ "* (C) Copyright International Business Machines Corporation, 1999 *\n" \ "* Licensed Material - Program-Property of IBM - All Rights Reserved. *\n" \ "* US Government Users Restricted Rights - Use, duplication, or disclosure *\n" \ "* restricted by GSA ADP Schedule Contract with IBM Corp. *\n" \ "*******************************************************************************\n" /* UDataInfo cf. udata.h */ static const UDataInfo dataInfo={ sizeof(UDataInfo), 0, U_IS_BIG_ENDIAN, U_CHARSET_FAMILY, sizeof(UChar), 0, 0x43, 0x76, 0x41, 0x6c, /* dataFormat="CvAl" */ 1, 0, 0, 0, /* formatVersion */ 1, 3, 1, 0 /* dataVersion */ }; static char stringStore[STRING_STORE_SIZE]; static uint32_t stringTop=0; typedef struct { const char *alias; uint16_t converter; } Alias; static Alias aliases[MAX_ALIAS_COUNT]; static uint16_t aliasCount=0; typedef struct { const char *converter; uint16_t aliasCount; } Converter; static Converter converters[MAX_ALIAS_COUNT]; static uint16_t converterCount=0; /* prototypes --------------------------------------------------------------- */ static void parseLine(const char *line); static void addAlias(const char *alias, uint16_t converter); static uint16_t addConverter(const char *converter); static char * allocString(uint32_t length); static int compareAliases(const void *file1, const void *file2); static int compareConverters(const void *converter1, const void *converter2); /* -------------------------------------------------------------------------- */ extern int main(int argc, char *argv[]) { char line[512]; const char *path, *arg; FileStream *in; UNewDataMemory *out; char *s; UErrorCode errorCode=U_ZERO_ERROR; int i; uint16_t stringOffset; bool_t haveCopyright=TRUE; fprintf(stderr, "usage: %s [-c[+|-]]\n" "\tread convrtrs.txt and create " DATA_NAME "." DATA_TYPE "\n" "\t\t-c[+|-] do (not) include a copyright notice\n", argv[0]); for(i=1; iSTRING_STORE_SIZE) { fprintf(stderr, "gencnval: out of memory\n"); exit(U_MEMORY_ALLOCATION_ERROR); } p=stringStore+stringTop; stringTop=top; return p; } static int compareAliases(const void *alias1, const void *alias2) { return icu_stricmp(((Alias *)alias1)->alias, ((Alias *)alias2)->alias); }