/* ******************************************************************************* * Copyright (C) 2004-2006, International Business Machines Corporation and * * others. All Rights Reserved. * **/ #include "unicode/utypes.h" #include "unicode/putil.h" #include "unicode/udata.h" #include "unicode/ustdio.h" #include "unicode/ures.h" #include "icons.h" #include "demo_settings.h" #include U_CFUNC char ubrowseres_dat[]; int icons_init() { UErrorCode status = U_ZERO_ERROR; udata_setAppData( "ubrowseres", (const void*) ubrowseres_dat, &status); if(U_FAILURE(status)) { return 1; } return 0; } void icons_write ( /* UFILE *OUT, */ const char *path ) { UResourceBundle *rb; UErrorCode status = U_ZERO_ERROR; UResourceBundle *n = NULL; UErrorCode s2 = U_ZERO_ERROR; const char *thePath = NULL; thePath = "ubrowseres"; rb = ures_open(thePath, "icons", &status); /* direct */ if(U_FAILURE(status)) { fprintf(stdout, "Content-type: text/html;charset=utf-8\n\n"); fprintf(stdout, "Error: Couldn't open bundle [%s] in path [%s], looking for [%s].

\r\n", "icons", (thePath==NULL)?"NULL":thePath, path); fprintf(stdout, "Error: %s\n", u_errorName(status)); fprintf(stdout, "


ICU Home\r\n"); return; } if(!path || !(*path) || (*path == '/')) { #if 1 fprintf(stdout, "Content-type: text/html;charset=utf-8\n\nan error has occured.\n"); #else fprintf(stdout, "Content-type", "text/html;charset=utf-8\n\n"); fprintf(lx->fOUT, "bundle list for %s\r\n", lx->dispLocale); fprintf(lx->fOUT, ""); fprintf(lx->fOUT, "

%s : %s

\r\n", FSWF_bundlePath(), lx->dispLocale); fprintf(lx->fOUT, "V: %s

\n", ures_getVersionNumber(rb)); fprintf(lx->fOUT, "

"); fprintf(lx->fOUT, ""); fprintf(lx->fOUT, ""); /* exit(0); */ #endif } else { const uint8_t *bin= NULL; int32_t len; /* have some kind of path*/ n = ures_getByKey(rb, path, n, &s2); if(U_FAILURE(s2)) { fprintf(stdout, "Content-type: %s\n\n", "text/html"); fprintf(stdout, "Error: Couldn't get [%s] in bundle [%s] in path [%s]

\r\n", path, "icons", (thePath==NULL)?"NULL":thePath); fprintf(stdout, "Error: %s\n", u_errorName(s2)); fprintf(stdout, "


ICU Home\r\n"); return; } bin = ures_getBinary(n, &len, &s2); if(U_FAILURE(s2)) { fprintf(stdout, "Content-type: %s\n\n", "text/html"); fprintf(stdout, "Error: Couldn't get binary [%s] in bundle [%s] in path [%s]

\r\n", path, "icons", u_getDataDirectory()); fprintf(stdout, "Error: %s\n", u_errorName(s2)); fprintf(stdout, "


ICU Home\r\n"); return ; } /* whew! */ { const char *type; if(strstr(path, ".html")) type = "text/html"; else if(strstr(path, ".gif")) type = "image/gif"; else if(strstr(path, ".jpg")) type = "image/jpeg"; else type = "application/octet-stream"; fprintf(stdout, "Content-type: %s\n", type); } fprintf(stdout, "Content-length: %d\n\n", len); fflush(stdout); fwrite(bin, 1, len, stdout); } ures_close(n); }