From 6c7f3300a026ce10da1de820f9cbd79db37c27ab Mon Sep 17 00:00:00 2001 From: gitlost Date: Tue, 9 Nov 2021 13:43:56 +0000 Subject: [PATCH] DATAMATRIX: fix mis-encoding of FNC1/GS in EDIFACT in GS1 mode (was writing a literal ']'); improve performance by removing use of intermediate grid array; DEBUG -> DM_DEBUG --- ChangeLog | 1 + backend/dmatrix.c | 59 +++++++-------- backend/tests/test_dmatrix.c | 139 +++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc27b349..1760d3d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -59,6 +59,7 @@ Bugs - library.c: check for stacking symbols >= 200 - DATAMATRIX: fix mis-encoding of non-encodables in X12 and EDIFACT modes, props Alex Geller +- DATAMATRIX: fix mis-encoding of FNC1/GS in EDIFACT in GS1 mode Version 2.10.0 2021-08-14 diff --git a/backend/dmatrix.c b/backend/dmatrix.c index 3b7f92ea..b5c64d6d 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -61,15 +61,15 @@ static void dm_placementbit(int *array, const int NR, const int NC, int r, int c } // Necessary for DMRE (ISO/IEC 21471:2020 Annex E) if (r >= NR) { -#ifdef DEBUG +#ifdef DM_DEBUG fprintf(stderr, "r >= NR:%i,%i at r=%i->", p, b, r); #endif r -= NR; -#ifdef DEBUG +#ifdef DM_DEBUG fprintf(stderr, "%i,c=%i\n", r, c); #endif } -#ifdef DEBUG +#ifdef DM_DEBUG if (0 != array[r * NC + c]) { int a = array[r * NC + c]; fprintf(stderr, "Double:%i,%i->%i,%i at r=%i,c=%i\n", a >> 3, a & 7, p, b, r, c); @@ -248,6 +248,16 @@ static int dm_isX12(const unsigned char input) { return 0; } +/* Return true (1) if a character is valid in EDIFACT set */ +static int dm_isedifact(const unsigned char input, const int gs1) { + + if ((input >= ' ' && input <= '^') && (!gs1 || input != '[')) { /* Can't encode GS1 FNC1/GS in EDIFACT */ + return 1; + } + + return 0; +} + static int dm_p_r_6_2_1(const unsigned char inputData[], const int position, const int sourcelen) { /* Annex P section (r)(6)(ii)(I) "If one of the three X12 terminator/separator characters first @@ -372,7 +382,7 @@ static int dm_look_ahead_test(const unsigned char inputData[], const int sourcel } /* edifact ... step (p) */ - if ((c >= ' ') && (c <= '^')) { + if (dm_isedifact(c, gs1)) { edf_count += DM_MULT_3_DIV_4; // (p)(1) } else { if (is_extended) { @@ -937,7 +947,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], /* step (f) EDIFACT encodation */ } else if (current_mode == DM_EDIFACT) { - if ((source[sp] >= ' ') && (source[sp] <= '^')) { + if (dm_isedifact(source[sp], gs1)) { next_mode = DM_EDIFACT; if (process_p == 3) { /* Note different then spec Step (f)(1), which suggests checking when 0, but this seems to work @@ -981,7 +991,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], tp = dm_update_b256_field_length(target, tp, b256_start); /* B.2.1 255-state randomising algorithm */ for (i = b256_start; i < tp; i++) { - int prn = ((149 * (i + 1)) % 255) + 1; + const int prn = ((149 * (i + 1)) % 255) + 1; target[i] = (unsigned char) ((target[i] + prn) & 0xFF); } next_mode = DM_ASCII; @@ -1214,7 +1224,6 @@ static int datamatrix_200(struct zint_symbol *symbol, const unsigned char source #endif { // placement int x, y, NC, NR, *places; - unsigned char *grid; NC = W - 2 * (W / FW); NR = H - 2 * (H / FH); if (!(places = (int *) calloc(NC * NR, sizeof(int)))) { @@ -1222,31 +1231,24 @@ static int datamatrix_200(struct zint_symbol *symbol, const unsigned char source return ZINT_ERROR_MEMORY; } dm_placement(places, NR, NC); - if (!(grid = (unsigned char *) calloc((size_t) W * H, sizeof(unsigned char)))) { - free(places); - strcpy(symbol->errtxt, "719: Insufficient memory for grid array"); - return ZINT_ERROR_MEMORY; - } for (y = 0; y < H; y += FH) { for (x = 0; x < W; x++) - grid[y * W + x] = 1; + set_module(symbol, (H - y) - 1, x); for (x = 0; x < W; x += 2) - grid[(y + FH - 1) * W + x] = 1; + set_module(symbol, y, x); } for (x = 0; x < W; x += FW) { for (y = 0; y < H; y++) - grid[y * W + x] = 1; + set_module(symbol, (H - y) - 1, x); for (y = 0; y < H; y += 2) - grid[y * W + x + FW - 1] = 1; + set_module(symbol, (H - y) - 1, x + FW - 1); } -#ifdef DEBUG +#ifdef DM_DEBUG // Print position matrix as in standard for (y = NR - 1; y >= 0; y--) { for (x = 0; x < NC; x++) { - int v; - if (x != 0) - fprintf(stderr, "|"); - v = places[(NR - y - 1) * NC + x]; + const int v = places[(NR - y - 1) * NC + x]; + if (x != 0) fprintf(stderr, "|"); fprintf(stderr, "%3d.%2d", (v >> 3), 8 - (v & 7)); } fprintf(stderr, "\n"); @@ -1255,19 +1257,14 @@ static int datamatrix_200(struct zint_symbol *symbol, const unsigned char source for (y = 0; y < NR; y++) { for (x = 0; x < NC; x++) { const int v = places[(NR - y - 1) * NC + x]; - if (v == 1 || (v > 7 && (binary[(v >> 3) - 1] & (1 << (v & 7))))) - grid[(1 + y + 2 * (y / (FH - 2))) * W + 1 + x + 2 * (x / (FW - 2))] = 1; - } - } - for (y = H - 1; y >= 0; y--) { - for (x = 0; x < W; x++) { - if (grid[W * y + x]) { - set_module(symbol, (H - y) - 1, x); + if (v == 1 || (v > 7 && (binary[(v >> 3) - 1] & (1 << (v & 7))))) { + set_module(symbol, H - (1 + y + 2 * (y / (FH - 2))) - 1, 1 + x + 2 * (x / (FW - 2))); } } - symbol->row_height[(H - y) - 1] = 1; } - free(grid); + for (y = 0; y < H; y++) { + symbol->row_height[y] = 1; + } free(places); } diff --git a/backend/tests/test_dmatrix.c b/backend/tests/test_dmatrix.c index 097b2b5c..d9f5ee23 100644 --- a/backend/tests/test_dmatrix.c +++ b/backend/tests/test_dmatrix.c @@ -683,6 +683,11 @@ static void test_input(int index, int generate, int debug) { /* 98*/ { UNICODE_MODE, 0, -1, -1, -1, "ABCDEFGHIJKLM*", 0, 0, 16, 16, 1, "EE 59 E9 6D 24 80 5F 93 9A FE 4E 2B 09 FF 50 A2 83 BE 32 E1 2F 17 1E F3", "C40 == X12, p_r_6_2_1 true" }, /* 99*/ { UNICODE_MODE, 0, -1, -1, -1, "\015\015\015\015\015\015\015\015\015a\015\015\015\015\015\015\015", 0, 0, 12, 26, 1, "EE 00 01 00 01 00 01 FE 62 EE 00 01 00 01 FE 0E B5 9A 73 85 83 20 23 2C E0 EC EC BF 71 E0", "a not X12 encodable" }, /*100*/ { UNICODE_MODE, 0, -1, -1, -1, ".........a.......", 0, 0, 18, 18, 0, "(32) F0 BA EB AE BA EB AE B9 F0 62 2F 2F 2F 2F 2F 2F 2F 81 78 BE 1F 90 B8 89 73 66 DC BD", "a not EDIFACT encodable; BWIPP different encodation (switches to ASCII one dot before)" }, + /*101*/ { GS1_MODE, 0, -1, -1, -1, "[90]........[91]....", 0, 0, 12, 26, 1, "E8 DC 2F 2F 2F 2F 2F 2F 2F 2F E8 DD 2F 2F 2F 2F C6 CC 13 68 0D 9D A9 A5 B8 D5 5A F3 7B 18", "Can't use GS1 EDIFACT if contains FNC1/GS" }, + /*102*/ { GS1_MODE, 0, -1, -1, -1, "[90]........", 0, 0, 8, 32, 1, "E8 DC F0 BA EB AE BA EB AE 81 B1 C0 AB DA A5 92 AF E2 05 DE 56", "Can use GS1 EDIFACT if no FNC1/GS" }, + /*103*/ { GS1_MODE, 0, -1, -1, -1, "[90]ABCDEFGH[91]ABCD", 0, 0, 12, 26, 1, "E8 DC E6 59 E9 6D 24 80 4A AA CE 59 E9 FE 45 81 6A 05 49 36 67 C8 00 DE 35 29 C5 9A 17 EA", "GS1 C40 ok" }, + /*104*/ { GS1_MODE, 0, -1, -1, -1, "[90]ABCD", 0, 0, 14, 14, 1, "E8 DC 42 43 44 45 81 38 98 32 8C 23 4D 87 5A 95 04 A7", "Final ASC unlatch" }, + /*105*/ { UNICODE_MODE, 0, -1, -1, -1, ">*\015>*\015>......", 0, 0, 12, 26, 1, "EE 0C A9 FE 3F 2B 0E 3F 2F 2F 2F 2F 2F 2F 81 ED 05 28 1E 8E 6B F5 A0 35 C9 B5 A3 A8 FC 5D", "X12 then ASC" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -2088,6 +2093,140 @@ static void test_encode(int index, int generate, int debug) { "110111010101111111011010" "111111111111111111111111" }, + /* 54*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;<>@[]_`~!||()?{}'123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678912345678912345678912345678900001234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^;<>@[]_`~!||()?{}'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^;<>@[]_`~!||()?{}'\001\002\003\004\005\006...............\015\015\015\015\015\015\015\015abcdefghijklmnopqrstuvwxyz\015\015\015\015\015\015\015\015...............\001\002\003\004\005\006ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^...............", 0, 132, 132, 0, "Mixed modes (except B256); BWIPP different encodation", + "101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "101001101001010011000111100011111001011001011010011011010011011101110111100110101011100111110000100011100000011010110110111101110001" + "101100101010110110010011000010100000111010101111010101001001101010100011010100110111111010101011001011100110101010000001010110111100" + "100110010000100111011110100001010100101110111101000000001001000011101111111011010000010110001001100000010001111101111011101011100111" + "101010011110000110101010001010010010000101101101000110111111111110111011001011001111011011101001000100000110001111001101110111010100" + "100001101000001110110111000000101011010001011111110001000100100001111100100000001001001110111111101001110110011010001101010001110111" + "110000101111011110011010000001101111000100001110000111110100111010101010100110110101001011010111101101101111101001100001000001011100" + "111101011101000110000110111101011100101010111111110110010100011101100000010001011101000111010110111011100001111011011000000110101101" + "111100100111111111101010110000000110111100101101101101000110011110110100000100010001110010000001011111111100001111010110111011000110" + "110110011010110000100110010000000010111110111011100111111000110011100111110101111110011111111011110001100001011100110001101111101111" + "101111110100111101111010011100110111001000001111000101111011010010101111101110101110100011001100111111010010101011000101101000110010" + "101011101110100100000110101100100010010011011001011011101001010001110011101011110000101110001100101101110000111001110101100000110101" + "101011000011010111011011110110000100101101101111101011101000011000111111011010101011000011101101000001011110001111101100010010110010" + "110110000001101101000111110100001000100010111110111000111111100111110001011100001001101111001111100111101011011011101111111100111011" + "100010110001001100001011011111001110100100001110110111010111100100111111000111101000010010101000111010101111001111111100010010100110" + "101110110111001001001110011110111011111110011110010101001110100011101111110010111001011111010000101101011011011001110000011100011111" + "111101111011011010001011111100111101000011001000111100001111110100101011010011010010100010110001101100000011101110000000100011110110" + "111111101001100101100111100011000101000011111111010111100001011111100011010001010000100110110001110110101010111101111000100100011001" + "101101101101010111010010110000110001001011001011101011011010100010101100011100011101000011011100001110111100101101010001000100111100" + "101101111111010111110111000001011011000011111010011001011111000011100111100111101010100110111111001010110110011010011010100010111111" + "101100010101001011010010011110100101101101001010001011000101001010100011101000101010001010101100100111000010101100001010000110100000" + "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "111111000101011100101110011100100011100110111010111101010011001111111100001101011101100110001010110111000010011001011100110001001101" + "111101101010101010011011111011001010100000101111101111000101110100101010110100100111001010110011100100111001101000100111100010000110" + "110101100101000010000111011001100011110110011001101000100011010101100010010110100111101110010111111001101100011100100111001011001111" + "100100011111111110011011101001001101010011101011000110101011000110111010001111111111101010000001101010111100001011111011110111101100" + "111011100100100001110110111111100101011101111110100011100001110011101111001000010110111110000011100010101000111100001101000001001001" + "100110001100010001111011010111110001101001101000110111001110010010110100101111000011010011000000000100001000101111000001001011010010" + "111001010100100011100111010110011010110001011110100111101011010001110010111001111001001111000101100110100010111001011101110110111101" + "111011000110110011110010000011100101100101001010000111011110011100100011110101001100010011100001011011110111001101101100000000000010" + "100111111011111000011111111010110100000101111100010110011111100111110111011010000111110111000101111010011101111000001011111101011011" + "101110110101110110100011000111110010010110101111000011001011101000100000010001111001010010011011011101010001001011101101011000000010" + "101111001110010100101110000110000000101011111111111010111100001001100001111011101010010111001111011001110111011010000011111000101101" + "110010110010111011000011110011101011010111101101000100101010110100101110100101111011010010001110010101111010001000110011001101111010" + "110000110111011001101111101100011001010010011010001011000010001101101010010101111001010111001011100111101110111101111001111110011001" + "111110110011101000010011001001101001000011001001001011111010010100111010101100110110001011010110110101101101101010100011101100111100" + "101000111010111001011110111101111000000101111011100100101111110101111100001011111100000111101111011101101011111100001001001010011101" + "100010110011010010001010111011010110010000001110100100110101011100100111010010110011110011100110111100001001001111010101100111011100" + "101101101001010000100110111001010001101001011100010100010010011111111010101111001001111111111111111111010100111101001011010010001101" + "100010001100011110100011111100000110011010001100000111000011101100101000101010100001010010111101101101111101001010000101100110101110" + "100101100111101000010110010111110110010000011111111001111001001101110110010000010100010111110011001001101001111101000001011100101111" + "100100111000100100011011111001101110011110101110111010010110110100101010011110010110001011111110110101010001101110010011001011011100" + "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "110111101101010110101111101011100001101001011111000011111110010111100001001000110110111111001010010000110011011101110111000001011111" + "111001111100101111000011111111010000101001101010101100111010001100110001000001110001111011011010001000111100001000000100111110100010" + "101101110110010111100111110001100101010111011000100111001111001001111101001101101100011111101111100100111111111011100011000010111011" + "111100101110011000110010111110110100100101101110100010110100101010111001110000010100110011110101111011101011101111101100101101111100" + "101011001001110000101110101111110110100100111011110000010010110101111110010101100111001111010010011000000000011010001101011111111101" + "110010101001010001001011000101101111110100101101011111000011100110111110011011011001111011000100001011110110101011011000101000101100" + "101010111000110010111111101111001001010100011101001001110111011011111000111010011100100111111011111100100111111010110101010111010011" + "101011111101010010100010110010101010100111001001001110000010010010110111111001110101111010000111100100111000001011110101011001010110" + "110111010000111001000110110010111111111001111101001010000010011001100001100010011110101110010001000011110000111111101011100111000011" + "100010101010101001001010110011000100111110001001011111001111010100100011110100010101111011100101000110010101001100101101011011100110" + "100011111000000011000110110111010111001011111110011011000100010101110011101001001101110111101010110100110101011101010111100011110001" + "100001010001000101001010100011000010011111101111001101101010111010100011010011111100101011000011100001001010001100111010001010111100" + "100101111001100011110110000000110000011011111010111101111111010101111000111110101010011111000111011001111001111111010011000001010101" + "110001111011101010001011000110111111001011001100110100010011010110110100111110010010011010001011100011111101101110101010100011101110" + "101101100101100010001111000011001010111000111010100101011010010001110110000000101010010111001110110011101100011001011101101011010001" + "101000100111000100010011110111000100110100101010111100010001001010110101000100101110001011100101111101111111001011101100000001001110" + "111110011111101011110111100101001010010110011110010011101001011101111110011010011001101111000000111000101001111101000010110000011011" + "110010010111101001011010000001001010111010001101011010001010101100111010011010001111110011101111001011101001101001011111010010001010" + "100010010110110010010110011110100111010001111111001101100101101011111111100000101000000110011000000100000110111110101101100111001011" + "111111000010011011111011011110100011010000101111011100011111000010101111010000000110001011011001111011001000001000001100110110111000" + "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "110101111010011001111110111000011010011111011010010111100110101011100110011101000111001111111100111011101110011110001100011101110011" + "101011001111110111110010110100010010111010101000011010001000000010100010111101110110000010011100100000101110001110010000010000010110" + "111010000001111110011110000111101001010000011000101101010110101001100101000101110111000111000100110110011101011111011100110000010011" + "110001111100110011010011101110001001111111101101011011010001010000101001101010001101100011100100010100110101001011100000001110111000" + "111011100111000100010111010101100111001011111101000111011100000001100110111100101100101110111010001101100001111011011101010100111001" + "100111010010010000111010011100100101000111001100101111100100000010100101110000101001001011100001100100010101001101111111100001101110" + "110101110000101111010111110111100101001110011000001010111110000111100111111001011000011111100010011111110100011100101000011010110001" + "100001011110011011100011011011110001010101101010110101011000001110110101100001111100001011111000000000010110001111001111111000110010" + "100111001010011010100110101101011110111100011110010100111110000101101000110001110100111111110111000010000101011011011100000111001001" + "111011001110010011110011011010111111011001101010010000110101101010101001110101011100011010001001111111100110001000110011111100010110" + "101101000001101001010111001110111011011101111110000010111110111101101000110001101100010110001101111010101000011011100001000111000111" + "101001010000001010110010000100111000011011001101100000011100010110111110101000101110100010001000010000111101001000110001001011100110" + "111110100101101110000110010110000110111001011100010000111001000011111001101000000010101110010011000000110100011101011011001110100101" + "111110110100000101101011000101110101111100001001000100111100010000110111111010101110101011100010110011011000001001000110110110000010" + "111011110111010100010110100101001100010111111101000110000011010111111010100111010010100110100111011000000001011001010101000001100011" + "110101111011000001011010101110110111111001101000011101011010010000110100000110000101011010111101101011111000001110011001101100000010" + "101110101100111101001111110110001011101011111000000101001111100101111100110111011111010111011001010100100100011011000111111001001001" + "110011010110111011011010111001110001111111001010001111011110100100100111010101111100111010100010000111001101101010001110001110101110" + "110101000010111010011110101101111001110001011001110110001110101001110100101101101011100111110000111001101100111011001101010100011011" + "110100110111111000010010111100001100111100101010111000010000000110100100001000001101001011110111000010111011001100011001110000010110" + "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "100000100100010001101110101000001010101100011110100001100011110111110111111100010000111111000100101011011111111100000011110101100001" + "111010000111111100000010001100010011000011001100111100011111110010111110001100001111110010010101011011001101001011010111001000101100" + "100100001011111101101110100111101101100001111010111000010100000011110000000111110111101111111001111011011100011001101000111011101101" + "111111010011110100101011100100101000111110001001110110011010011010101101011101111111010011001100101001111101101011110011000100001000" + "111111111010010111101110001010010000110101111011110011101010100011110010110111110010101110000111101010100101111001101010111111011101" + "111100000011011001110010101010001110000100001101001100100110001010101011010011110001110010011100010111111101101011010110111010110010" + "100100000100101101111110010000011011110111111110010000011010100111101110000010000001100111010000101101010011111111101010111010000111" + "110100010001011001010010010000101101011011001110001010001110100110111011001001111100100010111001001111111100001100000000100110000010" + "101100101101001110111110011000101010101111011011100110101111101011111101011111110111001111101000111001010000011101000100011011001111" + "110110011100011011111010111001100111011000001101000100000101010010110110101101000101011011000001101110101110001101010100011101111100" + "101110000000111011000111011001101101000111111110110101010101110101110100000011100010111110111110001001101110011100100101001100011001" + "101110011010011000100011110110110100110100101011001101110010010100111111100111101100111010011001011100101000001111010011000111000010" + "100001000111100000011111011111100000001011111100000110100001100101100011101100101010010111110100010001110101111100111010101100110001" + "110000010011110110010010111101011010110000001111101101111111011110100001001000111011011011000111010100000110001111100100110100110100" + "100111010110001010001111111011000110010001011111000011110000110011111111101000011100110111101000001110100100111110101110011110111111" + "110110001111011111001011100110011001110111101100000011010001011100111001011100111010111010000010000000001000001011110010111010111110" + "101110111010010101001110101111011100001011011110000100000110000001101110110011100100110110111100111100000110111011110111101011010101" + "111101111111101011011010110110111100101010001101101100010111011100101001000010110101111010011000000111101011101100010001101001100010" + "100100001101111001101111101110101011000010111001101010111110100111100001111000111110110111010001111110111111011011010010111101110101" + "110100111100010101110011011100001111001000101001100110000000001100101000101001001001100010100001111010010101101100011001111011010110" + "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "110110010101011111101111000110111100100100111100011011101010011101100000001001000000011110001000011100010111011010111010010001100011" + "111001001100010110011011111011110010011111101101101101110000100100110101100010000101010010100111100010110100001000000001100110000000" + "111010100011000101101110111011010111100100011110110011001011000001111010001010110011000110101010101000010001111000101111111111110001" + "110111011011100011110010011100000100110001001010001010010110110110111010101011000100011010010010100011110100001010101011000110000110" + "101111001101101011011110011010010101011011011101101011110111001001110000100110101001100111100101100000000011111110000110101000111101" + "110011011100001110001010010111110000010000001101000111001011100110100010000110100000011010011101110011101100101100100010110101010000" + "100110011011101010001111110100100111110010011111100011100001010011100010111101111101101111110001101100000101111101001001101000111011" + "101000000100111010011010110101110110100000101101000110100100011100111000100100001001001010000100111101100110001110001101100011011100" + "100001011010100011111111111011101111011100011100110110111111011011100000110100011001001111111000000101101010111111000101000000011001" + "111100110011100111010011010010110000110000001010100011111101100000100111111011100111110010100101011010010000101000010100001011110110" + "111110101010000110110110110101100111011010011100011001011110000111111010001011010111000110101000100001100000111111101100111101000111" + "110110111110001001111011101010011110110101001011000010101101101000111000101100101010011011110000111010011101101000001100111100110110" + "101000101110101011001110101000100010101011111011011000110110000001100010010000011001100110010101101011010111011001010110100111010001" + "111100110101101101010011011110010110101110101000101100110010011010110100110011001110111011001010000101100000001001011001010100100000" + "101100011111111111100110010100100101000000011001000011101000001001101011000001001110011111110011100000010001011100100100001100000011" + "110000011111010101110011001111010111001010101100110000000001100000110101111110101001010010100100110110101000101011110110101010100110" + "100000011010110011011110010111100101101001011100111111101100100011111110111001111001101111010000000101101011111011001111000010010011" + "100010001001111101000010001000010001010111001001000111100011011100101111000001011100101010101000001011010000101100000111100101000000" + "100110011011101010100111110101011111010101111110010111101010101111101101001011110100110110111001111010110001011010100110001001010101" + "100101011100010111111010100000000010010011001111010000010110101010111000101111100110100011001110001101101001001001100111011011001100" + "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + }, }; int data_size = ARRAY_SIZE(data); int i, length, ret;