* Decompress a string. * * Characters values >= 0x80 (1AAAABBB) are unpacked to 2 characters * from the table. AAAA gives the 1st characted. * BBB the 2nd one (from a sub-table depending on AAAA) * * @param source The compressed string. * @param dest The decompressed string. * @return The length of decompressed string. */
| 33 | * @return The length of decompressed string. |
| 34 | */ |
| 35 | uint16 String_Decompress(const char *s, char *dest, uint16 destLen) |
| 36 | { |
| 37 | static const char couples[] = |
| 38 | " etainosrlhcdupm" /* 1st char */ |
| 39 | "tasio wb" /* <SPACE>? */ |
| 40 | " rnsdalm" /* e? */ |
| 41 | "h ieoras" /* t? */ |
| 42 | "nrtlc sy" /* a? */ |
| 43 | "nstcloer" /* i? */ |
| 44 | " dtgesio" /* n? */ |
| 45 | "nr ufmsw" /* o? */ |
| 46 | " tep.ica" /* s? */ |
| 47 | "e oiadur" /* r? */ |
| 48 | " laeiyod" /* l? */ |
| 49 | "eia otru" /* h? */ |
| 50 | "etoakhlr" /* c? */ |
| 51 | " eiu,.oa" /* d? */ |
| 52 | "nsrctlai" /* u? */ |
| 53 | "leoiratp" /* p? */ |
| 54 | "eaoip bm"; /* m? */ |
| 55 | uint16 count; |
| 56 | |
| 57 | for (count = 0; *s != '\0'; s++) { |
| 58 | uint8 c = *s; |
| 59 | if ((c & 0x80) != 0) { |
| 60 | c &= 0x7F; |
| 61 | dest[count++] = couples[c >> 3]; /* 1st char */ |
| 62 | c = couples[c + 16]; /* 2nd char */ |
| 63 | } |
| 64 | dest[count++] = c; |
| 65 | if (count >= destLen - 1) { |
| 66 | Warning("String_Decompress() : truncating output !\n"); |
| 67 | break; |
| 68 | } |
| 69 | } |
| 70 | dest[count] = '\0'; |
| 71 | return count; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Appends ".(ENG|FRE|...)" to the given string. |
no test coverage detected