Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 2000-2011, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ******************************************************************************* |
michael@0 | 8 | * |
michael@0 | 9 | * File reslist.h |
michael@0 | 10 | * |
michael@0 | 11 | * Modification History: |
michael@0 | 12 | * |
michael@0 | 13 | * Date Name Description |
michael@0 | 14 | * 02/21/00 weiv Creation. |
michael@0 | 15 | ******************************************************************************* |
michael@0 | 16 | */ |
michael@0 | 17 | |
michael@0 | 18 | #ifndef RESLIST_H |
michael@0 | 19 | #define RESLIST_H |
michael@0 | 20 | |
michael@0 | 21 | #define KEY_SPACE_SIZE 65536 |
michael@0 | 22 | #define RESLIST_MAX_INT_VECTOR 2048 |
michael@0 | 23 | |
michael@0 | 24 | #include "unicode/utypes.h" |
michael@0 | 25 | #include "unicode/ures.h" |
michael@0 | 26 | #include "unicode/ustring.h" |
michael@0 | 27 | #include "uresdata.h" |
michael@0 | 28 | #include "cmemory.h" |
michael@0 | 29 | #include "cstring.h" |
michael@0 | 30 | #include "unewdata.h" |
michael@0 | 31 | #include "ustr.h" |
michael@0 | 32 | #include "uhash.h" |
michael@0 | 33 | |
michael@0 | 34 | U_CDECL_BEGIN |
michael@0 | 35 | |
michael@0 | 36 | typedef struct KeyMapEntry { |
michael@0 | 37 | int32_t oldpos, newpos; |
michael@0 | 38 | } KeyMapEntry; |
michael@0 | 39 | |
michael@0 | 40 | /* Resource bundle root table */ |
michael@0 | 41 | struct SRBRoot { |
michael@0 | 42 | struct SResource *fRoot; |
michael@0 | 43 | char *fLocale; |
michael@0 | 44 | int32_t fIndexLength; |
michael@0 | 45 | int32_t fMaxTableLength; |
michael@0 | 46 | UBool noFallback; /* see URES_ATT_NO_FALLBACK */ |
michael@0 | 47 | int8_t fStringsForm; /* default STRINGS_UTF16_V1 */ |
michael@0 | 48 | UBool fIsPoolBundle; |
michael@0 | 49 | |
michael@0 | 50 | char *fKeys; |
michael@0 | 51 | KeyMapEntry *fKeyMap; |
michael@0 | 52 | int32_t fKeysBottom, fKeysTop; |
michael@0 | 53 | int32_t fKeysCapacity; |
michael@0 | 54 | int32_t fKeysCount; |
michael@0 | 55 | int32_t fLocalKeyLimit; /* key offset < limit fits into URES_TABLE */ |
michael@0 | 56 | |
michael@0 | 57 | UHashtable *fStringSet; |
michael@0 | 58 | uint16_t *f16BitUnits; |
michael@0 | 59 | int32_t f16BitUnitsCapacity; |
michael@0 | 60 | int32_t f16BitUnitsLength; |
michael@0 | 61 | |
michael@0 | 62 | const char *fPoolBundleKeys; |
michael@0 | 63 | int32_t fPoolBundleKeysLength; |
michael@0 | 64 | int32_t fPoolBundleKeysCount; |
michael@0 | 65 | int32_t fPoolChecksum; |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | struct SRBRoot *bundle_open(const struct UString* comment, UBool isPoolBundle, UErrorCode *status); |
michael@0 | 69 | void bundle_write(struct SRBRoot *bundle, const char *outputDir, const char *outputPkg, char *writtenFilename, int writtenFilenameLen, UErrorCode *status); |
michael@0 | 70 | |
michael@0 | 71 | /* write a java resource file */ |
michael@0 | 72 | void bundle_write_java(struct SRBRoot *bundle, const char *outputDir, const char* outputEnc, char *writtenFilename, |
michael@0 | 73 | int writtenFilenameLen, const char* packageName, const char* bundleName, UErrorCode *status); |
michael@0 | 74 | |
michael@0 | 75 | /* write a xml resource file */ |
michael@0 | 76 | /* commented by Jing*/ |
michael@0 | 77 | /* void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc, |
michael@0 | 78 | char *writtenFilename, int writtenFilenameLen,UErrorCode *status); */ |
michael@0 | 79 | |
michael@0 | 80 | /* added by Jing*/ |
michael@0 | 81 | void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc, const char* rbname, |
michael@0 | 82 | char *writtenFilename, int writtenFilenameLen, const char* language, const char* package, UErrorCode *status); |
michael@0 | 83 | |
michael@0 | 84 | void bundle_close(struct SRBRoot *bundle, UErrorCode *status); |
michael@0 | 85 | void bundle_setlocale(struct SRBRoot *bundle, UChar *locale, UErrorCode *status); |
michael@0 | 86 | int32_t bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *status); |
michael@0 | 87 | |
michael@0 | 88 | const char * |
michael@0 | 89 | bundle_getKeyBytes(struct SRBRoot *bundle, int32_t *pLength); |
michael@0 | 90 | |
michael@0 | 91 | int32_t |
michael@0 | 92 | bundle_addKeyBytes(struct SRBRoot *bundle, const char *keyBytes, int32_t length, UErrorCode *status); |
michael@0 | 93 | |
michael@0 | 94 | void |
michael@0 | 95 | bundle_compactKeys(struct SRBRoot *bundle, UErrorCode *status); |
michael@0 | 96 | |
michael@0 | 97 | /* Various resource types */ |
michael@0 | 98 | |
michael@0 | 99 | /* |
michael@0 | 100 | * Return a unique pointer to a dummy object, |
michael@0 | 101 | * for use in non-error cases when no resource is to be added to the bundle. |
michael@0 | 102 | * (NULL is used in error cases.) |
michael@0 | 103 | */ |
michael@0 | 104 | struct SResource* res_none(void); |
michael@0 | 105 | |
michael@0 | 106 | struct SResTable { |
michael@0 | 107 | uint32_t fCount; |
michael@0 | 108 | int8_t fType; /* determined by table_write16() for table_preWrite() & table_write() */ |
michael@0 | 109 | struct SResource *fFirst; |
michael@0 | 110 | struct SRBRoot *fRoot; |
michael@0 | 111 | }; |
michael@0 | 112 | |
michael@0 | 113 | struct SResource* table_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status); |
michael@0 | 114 | void table_add(struct SResource *table, struct SResource *res, int linenumber, UErrorCode *status); |
michael@0 | 115 | |
michael@0 | 116 | struct SResArray { |
michael@0 | 117 | uint32_t fCount; |
michael@0 | 118 | struct SResource *fFirst; |
michael@0 | 119 | struct SResource *fLast; |
michael@0 | 120 | }; |
michael@0 | 121 | |
michael@0 | 122 | struct SResource* array_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status); |
michael@0 | 123 | void array_add(struct SResource *array, struct SResource *res, UErrorCode *status); |
michael@0 | 124 | |
michael@0 | 125 | struct SResString { |
michael@0 | 126 | struct SResource *fSame; /* used for duplicates */ |
michael@0 | 127 | UChar *fChars; |
michael@0 | 128 | int32_t fLength; |
michael@0 | 129 | int32_t fSuffixOffset; /* this string is a suffix of fSame at this offset */ |
michael@0 | 130 | int8_t fNumCharsForLength; |
michael@0 | 131 | }; |
michael@0 | 132 | |
michael@0 | 133 | struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status); |
michael@0 | 134 | |
michael@0 | 135 | /** |
michael@0 | 136 | * Remove a string from a bundle and close (delete) it. |
michael@0 | 137 | * The string must not have been added to a table or array yet. |
michael@0 | 138 | * This function only undoes what string_open() did. |
michael@0 | 139 | */ |
michael@0 | 140 | void bundle_closeString(struct SRBRoot *bundle, struct SResource *string); |
michael@0 | 141 | |
michael@0 | 142 | struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, UChar *value, int32_t len, const struct UString* comment, UErrorCode *status); |
michael@0 | 143 | |
michael@0 | 144 | struct SResIntVector { |
michael@0 | 145 | uint32_t fCount; |
michael@0 | 146 | uint32_t *fArray; |
michael@0 | 147 | }; |
michael@0 | 148 | |
michael@0 | 149 | struct SResource* intvector_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status); |
michael@0 | 150 | void intvector_add(struct SResource *intvector, int32_t value, UErrorCode *status); |
michael@0 | 151 | |
michael@0 | 152 | struct SResInt { |
michael@0 | 153 | uint32_t fValue; |
michael@0 | 154 | }; |
michael@0 | 155 | |
michael@0 | 156 | struct SResource *int_open(struct SRBRoot *bundle, const char *tag, int32_t value, const struct UString* comment, UErrorCode *status); |
michael@0 | 157 | |
michael@0 | 158 | struct SResBinary { |
michael@0 | 159 | uint32_t fLength; |
michael@0 | 160 | uint8_t *fData; |
michael@0 | 161 | char* fFileName; /* file name for binary or import binary tags if any */ |
michael@0 | 162 | }; |
michael@0 | 163 | |
michael@0 | 164 | struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t length, uint8_t *data, const char* fileName, const struct UString* comment, UErrorCode *status); |
michael@0 | 165 | |
michael@0 | 166 | /* Resource place holder */ |
michael@0 | 167 | |
michael@0 | 168 | struct SResource { |
michael@0 | 169 | int8_t fType; /* nominal type: fRes (when != 0xffffffff) may use subtype */ |
michael@0 | 170 | UBool fWritten; /* res_write() can exit early */ |
michael@0 | 171 | uint32_t fRes; /* resource item word; 0xffffffff if not known yet */ |
michael@0 | 172 | int32_t fKey; /* Index into bundle->fKeys; -1 if no key. */ |
michael@0 | 173 | int line; /* used internally to report duplicate keys in tables */ |
michael@0 | 174 | struct SResource *fNext; /*This is for internal chaining while building*/ |
michael@0 | 175 | struct UString fComment; |
michael@0 | 176 | union { |
michael@0 | 177 | struct SResTable fTable; |
michael@0 | 178 | struct SResArray fArray; |
michael@0 | 179 | struct SResString fString; |
michael@0 | 180 | struct SResIntVector fIntVector; |
michael@0 | 181 | struct SResInt fIntValue; |
michael@0 | 182 | struct SResBinary fBinaryValue; |
michael@0 | 183 | } u; |
michael@0 | 184 | }; |
michael@0 | 185 | |
michael@0 | 186 | const char * |
michael@0 | 187 | res_getKeyString(const struct SRBRoot *bundle, const struct SResource *res, char temp[8]); |
michael@0 | 188 | |
michael@0 | 189 | void res_close(struct SResource *res); |
michael@0 | 190 | |
michael@0 | 191 | void setIncludeCopyright(UBool val); |
michael@0 | 192 | UBool getIncludeCopyright(void); |
michael@0 | 193 | |
michael@0 | 194 | void setFormatVersion(int32_t formatVersion); |
michael@0 | 195 | |
michael@0 | 196 | void setUsePoolBundle(UBool use); |
michael@0 | 197 | |
michael@0 | 198 | /* in wrtxml.cpp */ |
michael@0 | 199 | uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc); |
michael@0 | 200 | |
michael@0 | 201 | U_CDECL_END |
michael@0 | 202 | #endif /* #ifndef RESLIST_H */ |