1221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/* 2221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom******************************************************************************* 3221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* 4221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* Copyright (C) 1999-2010, International Business Machines 5221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* Corporation and others. All Rights Reserved. 6221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* 7221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom******************************************************************************* 8221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* file name: icuinfo.cpp 9221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* encoding: US-ASCII 10221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* tab size: 8 (not used) 11221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* indentation:4 12221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* 13221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* created on: 2009-2010 14221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* created by: Steven R. Loomis 15221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* 16221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom* This program shows some basic info about the current ICU. 17221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom*/ 18221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 19221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include <stdio.h> 20221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include <stdlib.h> 21221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "unicode/utypes.h" 22221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "unicode/putil.h" 23221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "unicode/uclean.h" 24221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "udbgutil.h" 25221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "unewdata.h" 26221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "cmemory.h" 27221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "cstring.h" 28221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "uoptions.h" 29221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "toolutil.h" 30221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "icuplugimp.h" 31221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include <unicode/uloc.h> 32221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include <unicode/ucnv.h> 33221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "unicode/ucal.h" 34221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include <unicode/ulocdata.h> 35221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "putilimp.h" 36221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "unicode/uchar.h" 37221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 38221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic UOption options[]={ 39221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom /*0*/ UOPTION_HELP_H, 40221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom /*1*/ UOPTION_HELP_QUESTION_MARK, 41221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom /*2*/ UOPTION_ICUDATADIR, 42221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom /*3*/ UOPTION_VERBOSE, 43221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom /*4*/ UOPTION_DEF("list-plugins", 'L', UOPT_NO_ARG), 44221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom /*5*/ UOPTION_DEF("milisecond-time", 'm', UOPT_NO_ARG), 45221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom /*6*/ UOPTION_DEF("cleanup", 'K', UOPT_NO_ARG), 46221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom}; 47221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 48221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic UErrorCode initStatus = U_ZERO_ERROR; 49221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic UBool icuInitted = FALSE; 50221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 51221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic void do_init() { 52221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(!icuInitted) { 53221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom u_init(&initStatus); 54221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom icuInitted = TRUE; 55221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 56221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom} 57221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 58221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** 59221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * Print the current platform 60221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */ 61221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic const char *getPlatform() 62221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom{ 63221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if defined(U_PLATFORM) 64221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return U_PLATFORM; 65221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#elif defined(U_WINDOWS) 66221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return "Windows"; 67221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#elif defined(U_PALMOS) 68221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return "PalmOS"; 69221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#elif defined(_PLATFORM_H) 70221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return "Other (POSIX-like)"; 71221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#else 72221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return "unknown" 73221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 74221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom} 75221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 76221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid cmd_millis() 77221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom{ 78221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Milliseconds since Epoch: %.0f\n", uprv_getUTCtime()); 79221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom} 80221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 81221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid cmd_version(UBool noLoad) 82221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom{ 83221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom UVersionInfo icu; 84221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom char str[200]; 85221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("<ICUINFO>\n"); 86221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("International Components for Unicode for C/C++\n"); 87221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("%s\n", U_COPYRIGHT_STRING); 88221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Compiled-Version: %s\n", U_ICU_VERSION); 89221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom u_getVersion(icu); 90221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom u_versionToString(icu, str); 91221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Runtime-Version: %s\n", str); 92221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Compiled-Unicode-Version: %s\n", U_UNICODE_VERSION); 93221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom u_getUnicodeVersion(icu); 94221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom u_versionToString(icu, str); 95221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Runtime-Unicode-Version: %s\n", U_UNICODE_VERSION); 96221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Platform: %s\n", getPlatform()); 97221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if defined(U_BUILD) 98221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Build: %s\n", U_BUILD); 99221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if defined(U_HOST) 100221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(strcmp(U_BUILD,U_HOST)) { 101221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Host: %s\n", U_HOST); 102221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 103221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 104221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 105221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if defined(U_CC) 106221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("C compiler: %s\n", U_CC); 107221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 108221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if defined(U_CXX) 109221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("C++ compiler: %s\n", U_CXX); 110221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 111221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if defined(CYGWINMSVC) 112221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Cygwin: CYGWINMSVC\n"); 113221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 114221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("ICUDATA: %s\n", U_ICUDATA_NAME); 115221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom do_init(); 116221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Data Directory: %s\n", u_getDataDirectory()); 117221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("ICU Initialization returned: %s\n", u_errorName(initStatus)); 118221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf( "Default locale: %s\n", uloc_getDefault()); 119221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 120221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom UErrorCode subStatus = U_ZERO_ERROR; 121221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ulocdata_getCLDRVersion(icu, &subStatus); 122221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(U_SUCCESS(subStatus)) { 123221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom u_versionToString(icu, str); 124221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("CLDR-Version: %s\n", str); 125221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } else { 126221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("CLDR-Version: %s\n", u_errorName(subStatus)); 127221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 128221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 129221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 130221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if !UCONFIG_NO_CONVERSION 131221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(noLoad == FALSE) 132221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 133221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Default converter: %s\n", ucnv_getDefaultName()); 134221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 135221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 136221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if !UCONFIG_NO_FORMATTING 137221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 138221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom UChar buf[100]; 139221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom char buf2[100]; 140221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom UErrorCode subsubStatus= U_ZERO_ERROR; 141221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom int32_t len; 142221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 143221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom len = ucal_getDefaultTimeZone(buf, 100, &subsubStatus); 144221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(U_SUCCESS(subsubStatus)&&len>0) { 145221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom u_UCharsToChars(buf, buf2, len+1); 146221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Default TZ: %s\n", buf2); 147221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } else { 148221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Default TZ: %s\n", u_errorName(subsubStatus)); 149221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 150221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 151221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 152221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom UErrorCode subStatus = U_ZERO_ERROR; 153221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const char *tzVer = ucal_getTZDataVersion(&subStatus); 154221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(U_FAILURE(subStatus)) { 155221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom tzVer = u_errorName(subStatus); 156221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 157221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("TZ data version: %s\n", tzVer); 158221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 159221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 160221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 161221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#if U_ENABLE_DYLOAD 162221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const char *pluginFile = uplug_getPluginFile(); 163221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Plugin file is: %s\n", (pluginFile&&*pluginFile)?pluginFile:"(not set. try setting ICU_PLUGINS to a directory.)"); 164221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#else 165221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom fprintf(stderr, "Dynamic Loading: is disabled. No plugins will be loaded at start-up.\n"); 166221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 167221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("</ICUINFO>\n\n"); 168221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom} 169221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 170221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid cmd_cleanup() 171221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom{ 172221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom u_cleanup(); 173221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom fprintf(stderr,"ICU u_cleanup() called.\n"); 174221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom} 175221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 176221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 177221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid cmd_listplugins() { 178221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom int32_t i; 179221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom UPlugData *plug; 180221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 181221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom do_init(); 182221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("ICU Initialized: u_init() returned %s\n", u_errorName(initStatus)); 183221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 184221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Plugins: \n"); 185221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf( "# %6s %s \n", 186221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom "Level", 187221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom "Name" ); 188221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf( " %10s:%-10s\n", 189221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom "Library", 190221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom "Symbol" 191221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ); 192221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 193221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 194221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf( " config| (configuration string)\n"); 195221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf( " >>> Error | Explanation \n"); 196221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf( "-----------------------------------\n"); 197221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 198221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom for(i=0;(plug=uplug_getPlugInternal(i))!=NULL;i++) { 199221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom UErrorCode libStatus = U_ZERO_ERROR; 200221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const char *name = uplug_getPlugName(plug); 201221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const char *sym = uplug_getSymbolName(plug); 202221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const char *lib = uplug_getLibraryName(plug, &libStatus); 203221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const char *config = uplug_getConfiguration(plug); 204221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom UErrorCode loadStatus = uplug_getPlugLoadStatus(plug); 205221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const char *message = NULL; 206221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 207221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("\n#%d %-6s %s \n", 208221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom i+1, 209221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom udbg_enumName(UDBG_UPlugLevel,(int32_t)uplug_getPlugLevel(plug)), 210221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom name!=NULL?(*name?name:"this plugin did not call uplug_setPlugName()"):"(null)" 211221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ); 212221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf(" plugin| %10s:%-10s\n", 213221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom (U_SUCCESS(libStatus)?(lib!=NULL?lib:"(null)"):u_errorName(libStatus)), 214221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sym!=NULL?sym:"(null)" 215221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ); 216221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 217221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(config!=NULL&&*config) { 218221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf(" config| %s\n", config); 219221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 220221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 221221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom switch(loadStatus) { 222221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom case U_PLUGIN_CHANGED_LEVEL_WARNING: 223221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom message = "Note: This plugin changed the system level (by allocating memory or calling something which does). Later plugins may not load."; 224221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom break; 225221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 226221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom case U_PLUGIN_DIDNT_SET_LEVEL: 227221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom message = "Error: This plugin did not call uplug_setPlugLevel during QUERY."; 228221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom break; 229221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 230221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom case U_PLUGIN_TOO_HIGH: 231221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom message = "Error: This plugin couldn't load because the system level was too high. Try loading this plugin earlier."; 232221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom break; 233221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 234221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom case U_ZERO_ERROR: 235221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom message = NULL; /* no message */ 236221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom break; 237221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom default: 238221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(U_FAILURE(loadStatus)) { 239221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom message = "error loading:"; 240221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } else { 241221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom message = "warning during load:"; 242221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 243221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 244221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 245221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(message!=NULL) { 246221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("\\\\\\ status| %s\n" 247221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom "/// %s\n", u_errorName(loadStatus), message); 248221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 249221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 250221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 251221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if(i==0) { 252221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("No plugins loaded.\n"); 253221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 254221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 255221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom} 256221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 257221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 258221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 259221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromextern int 260main(int argc, char* argv[]) { 261 UErrorCode errorCode = U_ZERO_ERROR; 262 UBool didSomething = FALSE; 263 264 /* preset then read command line options */ 265 argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); 266 267 /* error handling, printing usage message */ 268 if(argc<0) { 269 fprintf(stderr, 270 "error in command line argument \"%s\"\n", 271 argv[-argc]); 272 } 273 if( options[0].doesOccur || options[1].doesOccur) { 274 fprintf(stderr, "%s: Output information about the current ICU\n", argv[0]); 275 fprintf(stderr, "Options:\n" 276 " -h or --help - Print this help message.\n" 277 " -m or --millisecond-time - Print the current UTC time in milliseconds.\n" 278 " -d <dir> or --icudatadir <dir> - Set the ICU Data Directory\n" 279 " -v - Print version and configuration information about ICU\n" 280 " -L or --list-plugins - List and diagnose issues with ICU Plugins\n" 281 " -K or --cleanup - Call u_cleanup() before exitting (will attempt to unload plugins)\n" 282 "\n" 283 "If no arguments are given, the tool will print ICU version and configuration information.\n" 284 ); 285 fprintf(stderr, "International Components for Unicode %s\n%s\n", U_ICU_VERSION, U_COPYRIGHT_STRING ); 286 return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; 287 } 288 289 if(options[2].doesOccur) { 290 u_setDataDirectory(options[2].value); 291 } 292 293 if(options[5].doesOccur) { 294 cmd_millis(); 295 didSomething=TRUE; 296 } 297 if(options[4].doesOccur) { 298 cmd_listplugins(); 299 didSomething = TRUE; 300 } 301 302 if(options[3].doesOccur) { 303 cmd_version(FALSE); 304 didSomething = TRUE; 305 } 306 307 if(options[6].doesOccur) { /* 2nd part of version: cleanup */ 308 cmd_cleanup(); 309 didSomething = TRUE; 310 } 311 312 if(!didSomething) { 313 cmd_version(FALSE); /* at least print the version # */ 314 } 315 316 return U_FAILURE(errorCode); 317} 318