gentest.c revision b13da9df870a61b11249bf741347908dbea0edd8
1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*******************************************************************************
3b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   Copyright (C) 1999-2007, International Business Machines
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*******************************************************************************
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   file name:  gentest.c
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   encoding:   US-ASCII
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   tab size:   8 (not used)
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   indentation:4
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   created on: 2000mar03
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   created by: Madhu Katragadda
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   This program writes a little data file for testing the udata API.
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <stdio.h>
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <stdlib.h>
21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/putil.h"
23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uclean.h"
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/udata.h"
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/udbgutil.h"
26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unewdata.h"
27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "cmemory.h"
28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "cstring.h"
29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uoptions.h"
30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "gentest.h"
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define DATA_NAME "test"
33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define DATA_TYPE "icu"
34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* UDataInfo cf. udata.h */
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic const UDataInfo dataInfo={
37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    sizeof(UDataInfo),
38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    0,
39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    U_IS_BIG_ENDIAN,
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    U_CHARSET_FAMILY,
42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    sizeof(UChar),
43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    0,
44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {0x54, 0x65, 0x73, 0x74},     /* dataFormat="Test" */
46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {1, 0, 0, 0},                 /* formatVersion */
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {1, 0, 0, 0}                  /* dataVersion */
48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic void createData(const char*, UErrorCode *);
51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic int outputJavaStuff(const char * progname, const char *outputDir);
53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic UOption options[]={
55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  /*0*/ UOPTION_HELP_H,
56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  /*1*/ UOPTION_HELP_QUESTION_MARK,
57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  /*2*/ UOPTION_DESTDIR,
58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  /*3*/ UOPTION_DEF("genres", 'r', UOPT_NO_ARG),
59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  /*4*/ UOPTION_DEF("javastuff", 'j', UOPT_NO_ARG),
60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruextern int
63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querumain(int argc, char* argv[]) {
64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode errorCode = U_ZERO_ERROR;
65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* preset then read command line options */
67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    options[2].value=u_getDataDirectory();
68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* error handling, printing usage message */
71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(argc<0) {
72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr,
73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "error in command line argument \"%s\"\n",
74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            argv[-argc]);
75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(argc<0 || options[0].doesOccur || options[1].doesOccur) {
77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr,
78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "usage: %s [-options]\n"
79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\tcreate the test file " DATA_NAME "." DATA_TYPE " unless the -r option is given.\n"
80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\toptions:\n"
81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\t\t-h or -? or --help  this usage text\n"
82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\t\t-d or --destdir     destination directory, followed by the path\n"
83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\t\t-r or --genres      generate resource file testtable32.txt instead of UData test \n"
84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\t\t-j or --javastuff   generate Java source for DebugUtilities. \n",
85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            argv[0]);
86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if( options[4].doesOccur ) {
90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    	return outputJavaStuff( argv[0], options[2].value );
91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else if ( options[3].doesOccur ) {
92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return genres32( argv[0], options[2].value );
93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* printf("Generating the test memory mapped file\n"); */
95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        createData(options[2].value, &errorCode);
96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return U_FAILURE(errorCode);
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* Create data file ----------------------------------------------------- */
101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic void
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QuerucreateData(const char* outputDirectory, UErrorCode *errorCode) {
103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UNewDataMemory *pData;
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char stringValue[]={'Y', 'E', 'A', 'R', '\0'};
105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint16_t intValue=2000;
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    long dataLength;
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint32_t size;
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    pData=udata_create(outputDirectory, DATA_TYPE, DATA_NAME, &dataInfo,
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                       U_COPYRIGHT_STRING, errorCode);
112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(U_FAILURE(*errorCode)) {
113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr, "gentest: unable to create data memory, error %d\n", *errorCode);
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        exit(*errorCode);
115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* write the data to the file */
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* a 16 bit value  and a String*/
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    udata_write16(pData, intValue);
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    udata_writeString(pData, stringValue, sizeof(stringValue));
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* finish up */
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    dataLength=udata_finish(pData, errorCode);
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(U_FAILURE(*errorCode)) {
125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr, "gentest: error %d writing the output file\n", *errorCode);
126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        exit(*errorCode);
127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    size=sizeof(stringValue) + sizeof(intValue);
129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(dataLength!=(long)size) {
132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr, "gentest: data length %ld != calculated size %lu\n",
133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            dataLength, (unsigned long)size);
134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        exit(U_INTERNAL_PROGRAM_ERROR);
135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* Create Java file ----------------------------------------------------- */
139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic int
141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruoutputJavaStuff(const char* progname, const char *outputDir) {
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i,t,count;
143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char file[512];
144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    FILE *out;
145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uprv_strcpy(file,outputDir);
147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(*outputDir &&  /* don't put a trailing slash if outputDir is empty */
148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        file[strlen(file)-1]!=U_FILE_SEP_CHAR) {
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            uprv_strcat(file,U_FILE_SEP_STRING);
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uprv_strcat(file,"DebugUtilitiesData.java");
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    out = fopen(file, "w");
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /*puts(file);*/
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    printf("%s: Generating %s\n", progname, file);
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(out == NULL) {
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr, "%s: Couldn't create resource test file %s\n",
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            progname, file);
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return 1;
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "/** Copyright (C) 2007, International Business Machines Corporation and Others. All Rights Reserved. **/\n\n");
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "/* NOTE: this file is AUTOMATICALLY GENERATED by gentest. */\n\n");
163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "package com.ibm.icu.dev.test.util;\n\n");
164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "public class DebugUtilitiesData extends Object {\n");
165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "    public static final String ICU4C_VERSION=\"%s\";\n", U_ICU_VERSION);
166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(t=0;t<UDBG_ENUM_COUNT;t++) {
167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(out, "    public static final int %s = %d;\n", udbg_enumName(UDBG_UDebugEnumType,t), t);
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "    public static final String [] TYPES = { \n");
170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(t=0;t<UDBG_ENUM_COUNT;t++) {
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(out, "        \"%s\", /* %d */\n", udbg_enumName(UDBG_UDebugEnumType,t), t);
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "    };\n\n");
174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "    public static final String [][] NAMES = { \n");
176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(t=0;t<UDBG_ENUM_COUNT;t++) {
177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        count = udbg_enumCount((UDebugEnumType)t);
178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(out, "        /* %s, %d */\n", udbg_enumName(UDBG_UDebugEnumType,t), t);
179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(out, "        { \n");
180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for(i=0;i<count;i++) {
181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(out,
182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "           \"%s\", /* %d */ \n", udbg_enumName((UDebugEnumType)t,i), i);
183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(out, "        },\n");
185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "    };\n\n");
187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "    public static final int [][] VALUES = { \n");
189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(t=0;t<UDBG_ENUM_COUNT;t++) {
190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        count = udbg_enumCount((UDebugEnumType)t);
191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(out, "        /* %s, %d */\n", udbg_enumName(UDBG_UDebugEnumType,t), t);
192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(out, "        { \n");
193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for(i=0;i<count;i++) {
194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(out,
195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "           ");
196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            switch(t) {
197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            case UDBG_UCalendarDateFields:
198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            case UDBG_UCalendarMonths:
199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                fprintf(out, "com.ibm.icu.util.Calendar.%s, /* %d */", udbg_enumName((UDebugEnumType)t,i), i);
200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                break;
201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            case UDBG_UDebugEnumType:
202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            default:
203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                fprintf(out,"%d, /* %s */", i, udbg_enumName((UDebugEnumType)t,i));
204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(out,"\n");
206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(out, "        },\n");
208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "    };\n\n");
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(out, "}\n");
211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fclose(out);
213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return 0;
215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if 0
217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t count = udbg_enumCount((UDebugEnumType)t);
218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(count == -1) {
219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr,"%s: enumCount(%d) returned -1\n", progname, count);
220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return 1;
221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(t=0;t<=UDBG_ENUM_COUNT;t++) {
223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        int32_t count = udbg_enumCount((UDebugEnumType)t);
224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(count == -1) {
225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(stderr,"%s: enumCount(%d) returned -1\n", progname, count);
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return 1;
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for(i=0;i<=count;i++) {
229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if(i<count) {
230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if( i!=udbg_enumArrayValue((UDebugEnumType)t, i)) {
231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    fprintf(stderr, "%s: FAIL: udbg_enumArrayValue(%d,%d) returned %d, expected %d\n", progname, t, i, udbg_enumArrayValue((UDebugEnumType)t,i), i);
232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    return 1;
233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(stderr, "%s: udbg_enumArrayValue(%d,%d) = %s, returned %d\n", progname, t, i,
236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                udbg_enumName((UDebugEnumType)t,i), udbg_enumArrayValue((UDebugEnumType)t,i));
237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(udbg_enumExpectedCount((UDebugEnumType)t) != count) {
239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(stderr, "%s: FAIL: udbg_enumExpectedCount(%d): %d, != UCAL_FIELD_COUNT=%d \n", progname, t, udbg_enumExpectedCount((UDebugEnumType)t), count);
240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return 1;
241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(stderr, "%s: udbg_ucal_fieldCount: %d, UCAL_FIELD_COUNT=udbg_enumCount %d ", progname, udbg_enumExpectedCount((UDebugEnumType)t), count);
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
247