static void udbg_register_cleanup(void) { ucln_registerCleanup(UCLN_TOOLUTIL, tu_cleanup); }
U_CAPI void U_EXPORT2 uplug_init(UErrorCode *status) { #if !U_ENABLE_DYLOAD (void)status; /* unused */ #else const char *plugin_dir; if(U_FAILURE(*status)) return; plugin_dir = getenv("ICU_PLUGINS"); #if defined(DEFAULT_ICU_PLUGINS) if(plugin_dir == NULL || !*plugin_dir) { plugin_dir = DEFAULT_ICU_PLUGINS; } #endif #if UPLUG_TRACE DBG((stderr, "ICU_PLUGINS=%s\n", plugin_dir)); #endif if(plugin_dir != NULL && *plugin_dir) { FILE *f; #ifdef OS390BATCH /* There are potentially a lot of ways to implement a plugin directory on OS390/zOS */ /* Keeping in mind that unauthorized file access is logged, monitored, and enforced */ /* I've chosen to open a DDNAME if BATCH and leave it alone for (presumably) UNIX */ /* System Services. Alternative techniques might be allocating a member in */ /* SYS1.PARMLIB or setting an environment variable "ICU_PLUGIN_PATH" (?). The */ /* DDNAME can be connected to a file in the HFS if need be. */ uprv_strncpy(plugin_file,"//DD:ICUPLUG", 2047); /* JAM 20 Oct 2011 */ #else uprv_strncpy(plugin_file, plugin_dir, 2047); uprv_strncat(plugin_file, U_FILE_SEP_STRING,2047); uprv_strncat(plugin_file, "icuplugins",2047); uprv_strncat(plugin_file, U_ICU_VERSION_SHORT ,2047); uprv_strncat(plugin_file, ".txt" ,2047); #endif #if UPLUG_TRACE DBG((stderr, "pluginfile= %s\n", plugin_file)); #endif #ifdef __MVS__ if (iscics()) /* 12 Nov 2011 JAM */ { f = NULL; } else #endif { f = fopen(plugin_file, "r"); } if(f != NULL) { char linebuf[1024]; char *p, *libName=NULL, *symName=NULL, *config=NULL; int32_t line = 0; while(fgets(linebuf,1023,f)) { line++; if(!*linebuf || *linebuf=='#') { continue; } else { p = linebuf; while(*p&&isspace((int)*p)) p++; if(!*p || *p=='#') continue; libName = p; while(*p&&!isspace((int)*p)) { p++; } if(!*p || *p=='#') continue; /* no tab after libname */ *p=0; /* end of libname */ p++; while(*p&&isspace((int)*p)) { p++; } if(!*p||*p=='#') continue; /* no symname after libname +tab */ symName = p; while(*p&&!isspace((int)*p)) { p++; } if(*p) { /* has config */ *p=0; ++p; while(*p&&isspace((int)*p)) { p++; } if(*p) { config = p; } } /* chop whitespace at the end of the config */ if(config!=NULL&&*config!=0) { p = config+strlen(config); while(p>config&&isspace((int)*(--p))) { *p=0; } } /* OK, we're good. */ { UErrorCode subStatus = U_ZERO_ERROR; UPlugData *plug = uplug_initPlugFromLibrary(libName, symName, config, &subStatus); if(U_FAILURE(subStatus) && U_SUCCESS(*status)) { *status = subStatus; } #if UPLUG_TRACE DBG((stderr, "PLUGIN libName=[%s], sym=[%s], config=[%s]\n", libName, symName, config)); DBG((stderr, " -> %p, %s\n", (void*)plug, u_errorName(subStatus))); #else (void)plug; /* unused */ #endif } } } fclose(f); } else { #if UPLUG_TRACE DBG((stderr, "Can't open plugin file %s\n", plugin_file)); #endif } } uplug_loadWaitingPlugs(status); #endif /* U_ENABLE_DYLOAD */ ucln_registerCleanup(UCLN_UPLUG, uplug_cleanup); }