OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * | 3 * |
4 * Copyright (C) 1999-2012, International Business Machines | 4 * Copyright (C) 1999-2015, International Business Machines |
5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
6 * | 6 * |
7 ******************************************************************************* | 7 ******************************************************************************* |
8 * file name: icuinfo.cpp | 8 * file name: icuinfo.cpp |
9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
11 * indentation:4 | 11 * indentation:4 |
12 * | 12 * |
13 * created on: 2009-2010 | 13 * created on: 2009-2010 |
14 * created by: Steven R. Loomis | 14 * created by: Steven R. Loomis |
(...skipping 18 matching lines...) Expand all Loading... |
33 #include "unicode/ucal.h" | 33 #include "unicode/ucal.h" |
34 #include <unicode/ulocdata.h> | 34 #include <unicode/ulocdata.h> |
35 #include "putilimp.h" | 35 #include "putilimp.h" |
36 #include "unicode/uchar.h" | 36 #include "unicode/uchar.h" |
37 | 37 |
38 static UOption options[]={ | 38 static UOption options[]={ |
39 /*0*/ UOPTION_HELP_H, | 39 /*0*/ UOPTION_HELP_H, |
40 /*1*/ UOPTION_HELP_QUESTION_MARK, | 40 /*1*/ UOPTION_HELP_QUESTION_MARK, |
41 /*2*/ UOPTION_ICUDATADIR, | 41 /*2*/ UOPTION_ICUDATADIR, |
42 /*3*/ UOPTION_VERBOSE, | 42 /*3*/ UOPTION_VERBOSE, |
43 /*4*/ UOPTION_DEF("list-plugins", 'L', UOPT_NO_ARG), | 43 /*4*/ UOPTION_DEF("list-plugins", 'L', UOPT_NO_ARG), // may be a no-op if disa
bled |
44 /*5*/ UOPTION_DEF("milisecond-time", 'm', UOPT_NO_ARG), | 44 /*5*/ UOPTION_DEF("milisecond-time", 'm', UOPT_NO_ARG), |
45 /*6*/ UOPTION_DEF("cleanup", 'K', UOPT_NO_ARG), | 45 /*6*/ UOPTION_DEF("cleanup", 'K', UOPT_NO_ARG), |
46 /*7*/ UOPTION_DEF("xml", 'x', UOPT_REQUIRES_ARG), | 46 /*7*/ UOPTION_DEF("xml", 'x', UOPT_REQUIRES_ARG), |
47 }; | 47 }; |
48 | 48 |
49 static UErrorCode initStatus = U_ZERO_ERROR; | 49 static UErrorCode initStatus = U_ZERO_ERROR; |
50 static UBool icuInitted = FALSE; | 50 static UBool icuInitted = FALSE; |
51 | 51 |
52 static void do_init() { | 52 static void do_init() { |
53 if(!icuInitted) { | 53 if(!icuInitted) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if(U_CHARSET_FAMILY==charsetFamily) { | 101 if(U_CHARSET_FAMILY==charsetFamily) { |
102 //printf("U_CHARSET_FAMILY: %d\n", U_CHARSET_FAMILY); | 102 //printf("U_CHARSET_FAMILY: %d\n", U_CHARSET_FAMILY); |
103 } else { | 103 } else { |
104 fprintf(stderr, " error: U_CHARSET_FAMILY=%d != %d=actual charset famil
y\n", | 104 fprintf(stderr, " error: U_CHARSET_FAMILY=%d != %d=actual charset famil
y\n", |
105 U_CHARSET_FAMILY, charsetFamily); | 105 U_CHARSET_FAMILY, charsetFamily); |
106 errorCode=U_INTERNAL_PROGRAM_ERROR; | 106 errorCode=U_INTERNAL_PROGRAM_ERROR; |
107 } | 107 } |
108 | 108 |
109 printf("\n\nICU Initialization returned: %s\n", u_errorName(initStatus)); | 109 printf("\n\nICU Initialization returned: %s\n", u_errorName(initStatus)); |
110 | 110 |
111 | 111 |
| 112 #if UCONFIG_ENABLE_PLUGINS |
112 #if U_ENABLE_DYLOAD | 113 #if U_ENABLE_DYLOAD |
113 const char *pluginFile = uplug_getPluginFile(); | 114 const char *pluginFile = uplug_getPluginFile(); |
114 printf("Plugin file is: %s\n", (pluginFile&&*pluginFile)?pluginFile:"(not se
t. try setting ICU_PLUGINS to a directory.)"); | 115 printf("Plugin file is: %s\n", (pluginFile&&*pluginFile)?pluginFile:"(not se
t. try setting ICU_PLUGINS to a directory.)"); |
115 #else | 116 #else |
116 fprintf(stderr, "Dynamic Loading: is disabled. No plugins will be loaded at
start-up.\n"); | 117 fprintf(stderr, "Dynamic Loading: is disabled. No plugins will be loaded at
start-up.\n"); |
117 #endif | 118 #endif |
| 119 #else |
| 120 fprintf(stderr, "Plugins are disabled.\n"); |
| 121 #endif |
118 } | 122 } |
119 | 123 |
120 void cmd_cleanup() | 124 void cmd_cleanup() |
121 { | 125 { |
122 u_cleanup(); | 126 u_cleanup(); |
123 fprintf(stdout, "ICU u_cleanup() called.\n"); | 127 fprintf(stdout, "ICU u_cleanup() called.\n"); |
124 } | 128 } |
125 | 129 |
126 | 130 |
127 void cmd_listplugins() { | 131 void cmd_listplugins() { |
| 132 #if UCONFIG_ENABLE_PLUGINS |
128 int32_t i; | 133 int32_t i; |
129 UPlugData *plug; | 134 UPlugData *plug; |
130 | 135 |
131 do_init(); | 136 do_init(); |
132 printf("ICU Initialized: u_init() returned %s\n", u_errorName(initStatus)); | 137 printf("ICU Initialized: u_init() returned %s\n", u_errorName(initStatus)); |
133 | 138 |
134 printf("Plugins: \n"); | 139 printf("Plugins: \n"); |
135 printf( "# %6s %s \n", | 140 printf( "# %6s %s \n", |
136 "Level", | 141 "Level", |
137 "Name" ); | 142 "Name" ); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 199 |
195 if(message!=NULL) { | 200 if(message!=NULL) { |
196 printf("\\\\\\ status| %s\n" | 201 printf("\\\\\\ status| %s\n" |
197 "/// %s\n", u_errorName(loadStatus), message); | 202 "/// %s\n", u_errorName(loadStatus), message); |
198 } | 203 } |
199 | 204 |
200 } | 205 } |
201 if(i==0) { | 206 if(i==0) { |
202 printf("No plugins loaded.\n"); | 207 printf("No plugins loaded.\n"); |
203 } | 208 } |
204 | 209 #endif |
205 } | 210 } |
206 | 211 |
207 | 212 |
208 | 213 |
209 extern int | 214 extern int |
210 main(int argc, char* argv[]) { | 215 main(int argc, char* argv[]) { |
211 UErrorCode errorCode = U_ZERO_ERROR; | 216 UErrorCode errorCode = U_ZERO_ERROR; |
212 UBool didSomething = FALSE; | 217 UBool didSomething = FALSE; |
213 | 218 |
214 /* preset then read command line options */ | 219 /* preset then read command line options */ |
215 argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); | 220 argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); |
216 | 221 |
217 /* error handling, printing usage message */ | 222 /* error handling, printing usage message */ |
218 if(argc<0) { | 223 if(argc<0) { |
219 fprintf(stderr, | 224 fprintf(stderr, |
220 "error in command line argument \"%s\"\n", | 225 "error in command line argument \"%s\"\n", |
221 argv[-argc]); | 226 argv[-argc]); |
222 } | 227 } |
223 if( options[0].doesOccur || options[1].doesOccur) { | 228 if( options[0].doesOccur || options[1].doesOccur) { |
224 fprintf(stderr, "%s: Output information about the current ICU\n", argv[0])
; | 229 fprintf(stderr, "%s: Output information about the current ICU\n", argv[0])
; |
225 fprintf(stderr, "Options:\n" | 230 fprintf(stderr, "Options:\n" |
226 " -h or --help - Print this help message.\n" | 231 " -h or --help - Print this help message.\n" |
227 " -m or --millisecond-time - Print the current UTC time i
n milliseconds.\n" | 232 " -m or --millisecond-time - Print the current UTC time i
n milliseconds.\n" |
228 " -d <dir> or --icudatadir <dir> - Set the ICU Data Directory\n
" | 233 " -d <dir> or --icudatadir <dir> - Set the ICU Data Directory\n
" |
229 " -v - Print version and configurat
ion information about ICU\n" | 234 " -v - Print version and configurat
ion information about ICU\n" |
| 235 #if UCONFIG_ENABLE_PLUGINS |
230 " -L or --list-plugins - List and diagnose issues wit
h ICU Plugins\n" | 236 " -L or --list-plugins - List and diagnose issues wit
h ICU Plugins\n" |
| 237 #endif |
231 " -K or --cleanup - Call u_cleanup() before exit
ting (will attempt to unload plugins)\n" | 238 " -K or --cleanup - Call u_cleanup() before exit
ting (will attempt to unload plugins)\n" |
232 "\n" | 239 "\n" |
233 "If no arguments are given, the tool will print ICU version and co
nfiguration information.\n" | 240 "If no arguments are given, the tool will print ICU version and co
nfiguration information.\n" |
234 ); | 241 ); |
235 fprintf(stderr, "International Components for Unicode %s\n%s\n", U_ICU_VER
SION, U_COPYRIGHT_STRING ); | 242 fprintf(stderr, "International Components for Unicode %s\n%s\n", U_ICU_VER
SION, U_COPYRIGHT_STRING ); |
236 return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; | 243 return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; |
237 } | 244 } |
238 | 245 |
239 if(options[2].doesOccur) { | 246 if(options[2].doesOccur) { |
240 u_setDataDirectory(options[2].value); | 247 u_setDataDirectory(options[2].value); |
(...skipping 30 matching lines...) Expand all Loading... |
271 cmd_cleanup(); | 278 cmd_cleanup(); |
272 didSomething = TRUE; | 279 didSomething = TRUE; |
273 } | 280 } |
274 | 281 |
275 if(!didSomething) { | 282 if(!didSomething) { |
276 cmd_version(FALSE, errorCode); /* at least print the version # */ | 283 cmd_version(FALSE, errorCode); /* at least print the version # */ |
277 } | 284 } |
278 | 285 |
279 return U_FAILURE(errorCode); | 286 return U_FAILURE(errorCode); |
280 } | 287 } |
OLD | NEW |