static void printOutAlias(UFILE *out, UResourceBundle *parent, Resource r, const char *key, int32_t indent, const char *pname, UErrorCode *status) { static const UChar cr[] = { 0xA }; // LF int32_t len = 0; const UChar* thestr = res_getAlias(&(parent->fResData), r, &len); UChar *string = quotedString(thestr); if(opt_truncate && len > truncsize) { char msg[128]; printIndent(out, indent); sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n", (long)len, (long)truncsize/2); printCString(out, msg, -1); len = truncsize; } if(U_SUCCESS(*status)) { static const UChar openStr[] = { 0x003A, 0x0061, 0x006C, 0x0069, 0x0061, 0x0073, 0x0020, 0x007B, 0x0020, 0x0022 }; /* ":alias { \"" */ static const UChar closeStr[] = { 0x0022, 0x0020, 0x007D, 0x0020 }; /* "\" } " */ printIndent(out, indent); if(key != NULL) { printCString(out, key, -1); } printString(out, openStr, UPRV_LENGTHOF(openStr)); printString(out, string, len); printString(out, closeStr, UPRV_LENGTHOF(closeStr)); if(verbose) { printCString(out, " // ALIAS", -1); } printString(out, cr, UPRV_LENGTHOF(cr)); } else { reportError(pname, status, "getting binary value"); } uprv_free(string); }
/* * Enumerate one resource item and its children and extract dependencies from * aliases. */ static void ures_enumDependencies(const char *itemName, const ResourceData *pResData, Resource res, const char *inKey, const char *parentKey, int32_t depth, CheckDependency check, void *context, Package *pkg, UErrorCode *pErrorCode) { switch(res_getPublicType(res)) { case URES_STRING: { UBool useResSuffix = TRUE; // Check for %%ALIAS if(depth==1 && inKey!=NULL) { if(0!=strcmp(inKey, "%%ALIAS")) { break; } } // Check for %%DEPENDENCY else if(depth==2 && parentKey!=NULL) { if(0!=strcmp(parentKey, "%%DEPENDENCY")) { break; } useResSuffix = FALSE; } else { // we ignore all other strings break; } int32_t length; const UChar *alias=res_getString(pResData, res, &length); checkAlias(itemName, res, alias, length, useResSuffix, check, context, pErrorCode); } break; case URES_ALIAS: { int32_t length; const UChar *alias=res_getAlias(pResData, res, &length); checkAlias(itemName, res, alias, length, TRUE, check, context, pErrorCode); } break; case URES_TABLE: { /* recurse */ int32_t count=res_countArrayItems(pResData, res); for(int32_t i=0; i<count; ++i) { const char *itemKey; Resource item=res_getTableItemByIndex(pResData, res, i, &itemKey); ures_enumDependencies( itemName, pResData, item, itemKey, inKey, depth+1, check, context, pkg, pErrorCode); if(U_FAILURE(*pErrorCode)) { fprintf(stderr, "icupkg/ures_enumDependencies(%s table res=%08x)[%d].recurse(%s: %08x) failed\n", itemName, res, i, itemKey, item); break; } } } break; case URES_ARRAY: { /* recurse */ int32_t count=res_countArrayItems(pResData, res); for(int32_t i=0; i<count; ++i) { Resource item=res_getArrayItem(pResData, res, i); ures_enumDependencies( itemName, pResData, item, NULL, inKey, depth+1, check, context, pkg, pErrorCode); if(U_FAILURE(*pErrorCode)) { fprintf(stderr, "icupkg/ures_enumDependencies(%s array res=%08x)[%d].recurse(%08x) failed\n", itemName, res, i, item); break; } } } break; default: break; } }