Code format and audit, part 3

Update copyright info, remove unused code, etc.
This commit is contained in:
Robin Stuart 2016-02-20 11:29:19 +00:00
parent 8a88ffdd7b
commit 660d8148bd
13 changed files with 14979 additions and 14423 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,21 +2,21 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk> Copyright (C) 2008-2016 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2006 Kentaro Fukuchi <fukuchi@megaui.net> Copyright (C) 2006 Kentaro Fukuchi <fukuchi@megaui.net>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
are met: are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors 3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software may be used to endorse or promote products derived from this software
without specific prior written permission. without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -27,9 +27,9 @@
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE. SUCH DAMAGE.
*/ */
#define LEVEL_L 1 #define LEVEL_L 1
#define LEVEL_M 2 #define LEVEL_M 2
@ -40,128 +40,128 @@
/* From ISO/IEC 18004:2006 Table 7 */ /* From ISO/IEC 18004:2006 Table 7 */
static int qr_data_codewords_L[] = { static int qr_data_codewords_L[] = {
19, 34, 55, 80, 108, 136, 156, 194, 232, 274, 324, 370, 428, 461, 523, 589, 647, 19, 34, 55, 80, 108, 136, 156, 194, 232, 274, 324, 370, 428, 461, 523, 589, 647,
721, 795, 861, 932, 1006, 1094, 1174, 1276, 1370, 1468, 1531, 1631, 721, 795, 861, 932, 1006, 1094, 1174, 1276, 1370, 1468, 1531, 1631,
1735, 1843, 1955, 2071, 2191, 2306, 2434, 2566, 2702, 2812, 2956 1735, 1843, 1955, 2071, 2191, 2306, 2434, 2566, 2702, 2812, 2956
}; };
static int qr_data_codewords_M[] = { static int qr_data_codewords_M[] = {
16, 28, 44, 64, 86, 108, 124, 154, 182, 216, 254, 290, 334, 365, 415, 453, 507, 16, 28, 44, 64, 86, 108, 124, 154, 182, 216, 254, 290, 334, 365, 415, 453, 507,
563, 627, 669, 714, 782, 860, 914, 1000, 1062, 1128, 1193, 1267, 563, 627, 669, 714, 782, 860, 914, 1000, 1062, 1128, 1193, 1267,
1373, 1455, 1541, 1631, 1725, 1812, 1914, 1992, 2102, 2216, 2334 1373, 1455, 1541, 1631, 1725, 1812, 1914, 1992, 2102, 2216, 2334
}; };
static int qr_data_codewords_Q[] = { static int qr_data_codewords_Q[] = {
13, 22, 34, 48, 62, 76, 88, 110, 132, 154, 180, 206, 244, 261, 295, 325, 367, 13, 22, 34, 48, 62, 76, 88, 110, 132, 154, 180, 206, 244, 261, 295, 325, 367,
397, 445, 485, 512, 568, 614, 664, 718, 754, 808, 871, 911, 397, 445, 485, 512, 568, 614, 664, 718, 754, 808, 871, 911,
985, 1033, 1115, 1171, 1231, 1286, 1354, 1426, 1502, 1582, 1666 985, 1033, 1115, 1171, 1231, 1286, 1354, 1426, 1502, 1582, 1666
}; };
static int qr_data_codewords_H[] = { static int qr_data_codewords_H[] = {
9, 16, 26, 36, 46, 60, 66, 86, 100, 122, 140, 158, 180, 197, 223, 253, 283, 9, 16, 26, 36, 46, 60, 66, 86, 100, 122, 140, 158, 180, 197, 223, 253, 283,
313, 341, 385, 406, 442, 464, 514, 538, 596, 628, 661, 701, 313, 341, 385, 406, 442, 464, 514, 538, 596, 628, 661, 701,
745, 793, 845, 901, 961, 986, 1054, 1096, 1142, 1222, 1276 745, 793, 845, 901, 961, 986, 1054, 1096, 1142, 1222, 1276
}; };
static int qr_total_codewords[] = { static int qr_total_codewords[] = {
26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815, 26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815,
901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051,
2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706 2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
}; };
static int qr_blocks_L[] = { static int qr_blocks_L[] = {
1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12,
12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25
}; };
static int qr_blocks_M[] = { static int qr_blocks_M[] = {
1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20,
21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49
}; };
static int qr_blocks_Q[] = { static int qr_blocks_Q[] = {
1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25,
27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68
}; };
static int qr_blocks_H[] = { static int qr_blocks_H[] = {
1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30,
32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81
}; };
static int qr_sizes[] = { static int qr_sizes[] = {
21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97,
101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177
}; };
static int micro_qr_sizes[] = { static int micro_qr_sizes[] = {
11, 13, 15, 17 11, 13, 15, 17
}; };
static int qr_align_loopsize[] = { static int qr_align_loopsize[] = {
0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7 0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7
}; };
static int qr_table_e1[] = { static int qr_table_e1[] = {
6, 18, 0, 0, 0, 0, 0, 6, 18, 0, 0, 0, 0, 0,
6, 22, 0, 0, 0, 0, 0, 6, 22, 0, 0, 0, 0, 0,
6, 26, 0, 0, 0, 0, 0, 6, 26, 0, 0, 0, 0, 0,
6, 30, 0, 0, 0, 0, 0, 6, 30, 0, 0, 0, 0, 0,
6, 34, 0, 0, 0, 0, 0, 6, 34, 0, 0, 0, 0, 0,
6, 22, 38, 0, 0, 0, 0, 6, 22, 38, 0, 0, 0, 0,
6, 24, 42, 0, 0, 0, 0, 6, 24, 42, 0, 0, 0, 0,
6, 26, 46, 0, 0, 0, 0, 6, 26, 46, 0, 0, 0, 0,
6, 28, 50, 0, 0, 0, 0, 6, 28, 50, 0, 0, 0, 0,
6, 30, 54, 0, 0, 0, 0, 6, 30, 54, 0, 0, 0, 0,
6, 32, 58, 0, 0, 0, 0, 6, 32, 58, 0, 0, 0, 0,
6, 34, 62, 0, 0, 0, 0, 6, 34, 62, 0, 0, 0, 0,
6, 26, 46, 66, 0, 0, 0, 6, 26, 46, 66, 0, 0, 0,
6, 26, 48, 70, 0, 0, 0, 6, 26, 48, 70, 0, 0, 0,
6, 26, 50, 74, 0, 0, 0, 6, 26, 50, 74, 0, 0, 0,
6, 30, 54, 78, 0, 0, 0, 6, 30, 54, 78, 0, 0, 0,
6, 30, 56, 82, 0, 0, 0, 6, 30, 56, 82, 0, 0, 0,
6, 30, 58, 86, 0, 0, 0, 6, 30, 58, 86, 0, 0, 0,
6, 34, 62, 90, 0, 0, 0, 6, 34, 62, 90, 0, 0, 0,
6, 28, 50, 72, 94, 0, 0, 6, 28, 50, 72, 94, 0, 0,
6, 26, 50, 74, 98, 0, 0, 6, 26, 50, 74, 98, 0, 0,
6, 30, 54, 78, 102, 0, 0, 6, 30, 54, 78, 102, 0, 0,
6, 28, 54, 80, 106, 0, 0, 6, 28, 54, 80, 106, 0, 0,
6, 32, 58, 84, 110, 0, 0, 6, 32, 58, 84, 110, 0, 0,
6, 30, 58, 86, 114, 0, 0, 6, 30, 58, 86, 114, 0, 0,
6, 34, 62, 90, 118, 0, 0, 6, 34, 62, 90, 118, 0, 0,
6, 26, 50, 74, 98, 122, 0, 6, 26, 50, 74, 98, 122, 0,
6, 30, 54, 78, 102, 126, 0, 6, 30, 54, 78, 102, 126, 0,
6, 26, 52, 78, 104, 130, 0, 6, 26, 52, 78, 104, 130, 0,
6, 30, 56, 82, 108, 134, 0, 6, 30, 56, 82, 108, 134, 0,
6, 34, 60, 86, 112, 138, 0, 6, 34, 60, 86, 112, 138, 0,
6, 30, 58, 86, 114, 142, 0, 6, 30, 58, 86, 114, 142, 0,
6, 34, 62, 90, 118, 146, 0, 6, 34, 62, 90, 118, 146, 0,
6, 30, 54, 78, 102, 126, 150, 6, 30, 54, 78, 102, 126, 150,
6, 24, 50, 76, 102, 128, 154, 6, 24, 50, 76, 102, 128, 154,
6, 28, 54, 80, 106, 132, 158, 6, 28, 54, 80, 106, 132, 158,
6, 32, 58, 84, 110, 136, 162, 6, 32, 58, 84, 110, 136, 162,
6, 26, 54, 82, 110, 138, 166, 6, 26, 54, 82, 110, 138, 166,
6, 30, 58, 86, 114, 142, 170 6, 30, 58, 86, 114, 142, 170
}; };
static unsigned int qr_annex_c[] = { static unsigned int qr_annex_c[] = {
/* Format information bit sequences */ /* Format information bit sequences */
0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, 0x77c4, 0x72f3, 0x7daa, 0x789d,
0x662f, 0x6318, 0x6c41, 0x6976, 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b, 0x662f, 0x6318, 0x6c41, 0x6976, 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b,
0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed
}; };
static long int qr_annex_d[] = { static long int qr_annex_d[] = {
/* Version information bit sequences */ /* Version information bit sequences */
0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, 0x0f928, 0x10b78, 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, 0x0f928, 0x10b78,
0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, 0x177ec, 0x18ec4, 0x191e1, 0x1afab,
0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b,
0x2542e, 0x26a64, 0x27541, 0x28c69 0x2542e, 0x26a64, 0x27541, 0x28c69
}; };
static int qr_annex_c1[] = { static int qr_annex_c1[] = {
/* Micro QR Code format information */ /* Micro QR Code format information */
0x4445, 0x4172, 0x4e2b, 0x4b1c, 0x55ae, 0x5099, 0x5fc0, 0x5af7, 0x6793, 0x62a4, 0x6dfd, 0x68ca, 0x7678, 0x734f, 0x4445, 0x4172, 0x4e2b, 0x4b1c, 0x55ae, 0x5099, 0x5fc0, 0x5af7, 0x6793, 0x62a4, 0x6dfd, 0x68ca, 0x7678, 0x734f,
0x7c16, 0x7921, 0x06de, 0x03e9, 0x0cb0, 0x0987, 0x1735, 0x1202, 0x1d5b, 0x186c, 0x2508, 0x203f, 0x2f66, 0x2a51, 0x34e3, 0x7c16, 0x7921, 0x06de, 0x03e9, 0x0cb0, 0x0987, 0x1735, 0x1202, 0x1d5b, 0x186c, 0x2508, 0x203f, 0x2f66, 0x2a51, 0x34e3,
0x31d4, 0x3e8d, 0x3bba 0x31d4, 0x3e8d, 0x3bba
}; };

View File

@ -27,7 +27,7 @@
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE. SUCH DAMAGE.
*/ */
// It is not written with high efficiency in mind, so is probably // It is not written with high efficiency in mind, so is probably
// not suitable for real-time encoding. The aim was to keep it // not suitable for real-time encoding. The aim was to keep it
@ -52,8 +52,8 @@
#include <stdlib.h> // only needed for malloc/free #include <stdlib.h> // only needed for malloc/free
#include "reedsol.h" #include "reedsol.h"
static int gfpoly; static int gfpoly;
static int symsize; // in bits static int symsize; // in bits
static int logmod; // 2**symsize - 1 static int logmod; // 2**symsize - 1
static int rlen; static int rlen;
static int *logt = NULL, *alog = NULL, *rspoly = NULL; static int *logt = NULL, *alog = NULL, *rspoly = NULL;
@ -68,30 +68,29 @@ static int *logt = NULL, *alog = NULL, *rspoly = NULL;
// polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is // polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d. // a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
void rs_init_gf(int poly) void rs_init_gf(int poly) {
{ int m, b, p, v;
int m, b, p, v;
// Find the top bit, and hence the symbol size // Find the top bit, and hence the symbol size
for (b = 1, m = 0; b <= poly; b <<= 1) for (b = 1, m = 0; b <= poly; b <<= 1)
m++; m++;
b >>= 1; b >>= 1;
m--; m--;
gfpoly = poly; gfpoly = poly;
symsize = m; symsize = m;
// Calculate the log/alog tables // Calculate the log/alog tables
logmod = (1 << m) - 1; logmod = (1 << m) - 1;
logt = (int *)malloc(sizeof(int) * (logmod + 1)); logt = (int *) malloc(sizeof (int) * (logmod + 1));
alog = (int *)malloc(sizeof(int) * logmod); alog = (int *) malloc(sizeof (int) * logmod);
for (p = 1, v = 0; v < logmod; v++) { for (p = 1, v = 0; v < logmod; v++) {
alog[v] = p; alog[v] = p;
logt[p] = v; logt[p] = v;
p <<= 1; p <<= 1;
if (p & b) if (p & b)
p ^= poly; p ^= poly;
} }
} }
// rs_init_code(nsym, index) initialises the Reed-Solomon encoder // rs_init_code(nsym, index) initialises the Reed-Solomon encoder
@ -101,71 +100,69 @@ void rs_init_gf(int poly)
// (x + 2**i)*(x + 2**(i+1))*... [nsym terms] // (x + 2**i)*(x + 2**(i+1))*... [nsym terms]
// For ECC200, index is 1. // For ECC200, index is 1.
void rs_init_code(int nsym, int index) void rs_init_code(int nsym, int index) {
{ int i, k;
int i, k;
rspoly = (int *)malloc(sizeof(int) * (nsym + 1)); rspoly = (int *) malloc(sizeof (int) * (nsym + 1));
rlen = nsym; rlen = nsym;
rspoly[0] = 1; rspoly[0] = 1;
for (i = 1; i <= nsym; i++) { for (i = 1; i <= nsym; i++) {
rspoly[i] = 1; rspoly[i] = 1;
for (k = i - 1; k > 0; k--) { for (k = i - 1; k > 0; k--) {
if (rspoly[k]) if (rspoly[k])
rspoly[k] = alog[(logt[rspoly[k]] + index) % logmod]; rspoly[k] = alog[(logt[rspoly[k]] + index) % logmod];
rspoly[k] ^= rspoly[k - 1]; rspoly[k] ^= rspoly[k - 1];
} }
rspoly[0] = alog[(logt[rspoly[0]] + index) % logmod]; rspoly[0] = alog[(logt[rspoly[0]] + index) % logmod];
index++; index++;
} }
} }
void rs_encode(int len, unsigned char *data, unsigned char *res) void rs_encode(int len, unsigned char *data, unsigned char *res) {
{ int i, k, m;
int i, k, m; for (i = 0; i < rlen; i++)
for (i = 0; i < rlen; i++) res[i] = 0;
res[i] = 0; for (i = 0; i < len; i++) {
for (i = 0; i < len; i++) { m = res[rlen - 1] ^ data[i];
m = res[rlen - 1] ^ data[i]; for (k = rlen - 1; k > 0; k--) {
for (k = rlen - 1; k > 0; k--) { if (m && rspoly[k])
if (m && rspoly[k]) res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod];
res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod]; else
else res[k] = res[k - 1];
res[k] = res[k - 1]; }
} if (m && rspoly[0])
if (m && rspoly[0]) res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod];
res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod]; else
else res[0] = 0;
res[0] = 0; }
}
} }
void rs_encode_long(int len, unsigned int *data, unsigned int *res) /* The same as above but for larger bitlengths - Aztec code compatible */
{ /* The same as above but for larger bitlengths - Aztec code compatible */ void rs_encode_long(int len, unsigned int *data, unsigned int *res) {
int i, k, m; int i, k, m;
for (i = 0; i < rlen; i++) for (i = 0; i < rlen; i++)
res[i] = 0; res[i] = 0;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
m = res[rlen - 1] ^ data[i]; m = res[rlen - 1] ^ data[i];
for (k = rlen - 1; k > 0; k--) { for (k = rlen - 1; k > 0; k--) {
if (m && rspoly[k]) if (m && rspoly[k])
res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod]; res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod];
else else
res[k] = res[k - 1]; res[k] = res[k - 1];
} }
if (m && rspoly[0]) if (m && rspoly[0])
res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod]; res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod];
else else
res[0] = 0; res[0] = 0;
} }
} }
void rs_free(void) /* Free memory */
{ /* Free memory */ void rs_free(void) {
free(logt); free(logt);
free(alog); free(alog);
free(rspoly); free(rspoly);
rspoly = NULL; rspoly = NULL;
} }

View File

@ -34,15 +34,14 @@
#define __REEDSOL_H #define __REEDSOL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C" {
{
#endif /* __cplusplus */ #endif /* __cplusplus */
extern void rs_init_gf(int poly); extern void rs_init_gf(int poly);
extern void rs_init_code(int nsym, int index); extern void rs_init_code(int nsym, int index);
extern void rs_encode(int len, unsigned char *data, unsigned char *res); extern void rs_encode(int len, unsigned char *data, unsigned char *res);
extern void rs_encode_long(int len, unsigned int *data, unsigned int *res); extern void rs_encode_long(int len, unsigned int *data, unsigned int *res);
extern void rs_free(void); extern void rs_free(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2007 Robin Stuart <robin@zint.org.uk> Copyright (C) 2007-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -28,7 +28,7 @@
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE. SUCH DAMAGE.
*/ */
#define NUMERIC 110 #define NUMERIC 110
#define ALPHA 97 #define ALPHA 97
@ -38,200 +38,261 @@
#define ALPHA_OR_ISO 121 #define ALPHA_OR_ISO 121
/* RSS-14 Tables */ /* RSS-14 Tables */
static int g_sum_table[9] = { 0, 161, 961, 2015, 2715, 0, 336, 1036, 1516}; static int g_sum_table[9] = {
static int t_table[9] = { 1, 10, 34, 70, 126, 4, 20, 48, 81}; 0, 161, 961, 2015, 2715, 0, 336, 1036, 1516
static int modules_odd[9] = { 12, 10, 8, 6, 4, 5, 7, 9, 11 }; };
static int modules_even[9] = { 4, 6, 8, 10, 12, 10, 8, 6, 4 };
static int widest_odd[9] = { 8, 6, 4, 3, 1, 2, 4, 6, 8 }; static int t_table[9] = {
static int widest_even[9] = { 1, 3, 5, 6, 8, 7, 5, 3, 1 }; 1, 10, 34, 70, 126, 4, 20, 48, 81
};
static int modules_odd[9] = {
12, 10, 8, 6, 4, 5, 7, 9, 11
};
static int modules_even[9] = {
4, 6, 8, 10, 12, 10, 8, 6, 4
};
static int widest_odd[9] = {
8, 6, 4, 3, 1, 2, 4, 6, 8
};
static int widest_even[9] = {
1, 3, 5, 6, 8, 7, 5, 3, 1
};
static int widths[8]; static int widths[8];
static int finder_pattern[45] = { static int finder_pattern[45] = {
3, 8, 2, 1, 1, 3, 8, 2, 1, 1,
3, 5, 5, 1, 1, 3, 5, 5, 1, 1,
3, 3, 7, 1, 1, 3, 3, 7, 1, 1,
3, 1, 9, 1, 1, 3, 1, 9, 1, 1,
2, 7, 4, 1, 1, 2, 7, 4, 1, 1,
2, 5, 6, 1, 1, 2, 5, 6, 1, 1,
2, 3, 8, 1, 1, 2, 3, 8, 1, 1,
1, 5, 7, 1, 1, 1, 5, 7, 1, 1,
1, 3, 9, 1, 1 1, 3, 9, 1, 1
}; };
static int checksum_weight[32] = { /* Table 5 */
1, 3, 9, 27, 2, 6, 18, 54, static int checksum_weight[32] = {
4, 12, 36, 29, 8, 24, 72, 58, /* Table 5 */
16, 48, 65, 37, 32, 17, 51, 74, 1, 3, 9, 27, 2, 6, 18, 54,
64, 34, 23, 69, 49, 68, 46, 59 4, 12, 36, 29, 8, 24, 72, 58,
16, 48, 65, 37, 32, 17, 51, 74,
64, 34, 23, 69, 49, 68, 46, 59
}; };
/* RSS Limited Tables */ /* RSS Limited Tables */
static int t_even_ltd[7] = { 28, 728, 6454, 203, 2408, 1, 16632 }; static int t_even_ltd[7] = {
static int modules_odd_ltd[7] = { 17, 13, 9, 15, 11, 19, 7 }; 28, 728, 6454, 203, 2408, 1, 16632
static int modules_even_ltd[7] = { 9, 13, 17, 11, 15, 7, 19 };
static int widest_odd_ltd[7] = { 6, 5, 3, 5, 4, 8, 1 };
static int widest_even_ltd[7] = { 3, 4, 6, 4, 5, 1, 8 };
static int checksum_weight_ltd[28] = { /* Table 7 */
1, 3, 9, 27, 81, 65, 17, 51, 64, 14, 42, 37, 22, 66,
20, 60, 2, 6, 18, 54, 73, 41, 34, 13, 39, 28, 84, 74
}; };
static int modules_odd_ltd[7] = {
17, 13, 9, 15, 11, 19, 7
};
static int modules_even_ltd[7] = {
9, 13, 17, 11, 15, 7, 19
};
static int widest_odd_ltd[7] = {
6, 5, 3, 5, 4, 8, 1
};
static int widest_even_ltd[7] = {
3, 4, 6, 4, 5, 1, 8
};
static int checksum_weight_ltd[28] = {
/* Table 7 */
1, 3, 9, 27, 81, 65, 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 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1,
2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1,
2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1,
2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1,
2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1
}; };
/* RSS Expanded Tables */ /* RSS Expanded Tables */
static int g_sum_exp[5] = { 0, 348, 1388, 2948, 3988 }; static int g_sum_exp[5] = {
static int t_even_exp[5] = { 4, 20, 52, 104, 204 }; 0, 348, 1388, 2948, 3988
static int modules_odd_exp[5] = { 12, 10, 8, 6, 4 };
static int modules_even_exp[5] = { 5, 7, 9, 11, 13 };
static int widest_odd_exp[5] = { 7, 5, 4, 3, 1 };
static int widest_even_exp[5] = { 2, 4, 5, 6, 8 };
static int checksum_weight_exp[184] = { /* Table 14 */
1, 3, 9, 27, 81, 32, 96, 77,
20, 60, 180, 118, 143, 7, 21, 63,
189, 145, 13, 39, 117, 140, 209, 205,
193, 157, 49, 147, 19, 57, 171, 91,
62, 186, 136, 197, 169, 85, 44, 132,
185, 133, 188, 142, 4, 12, 36, 108,
113, 128, 173, 97, 80, 29, 87, 50,
150, 28, 84, 41, 123, 158, 52, 156,
46, 138, 203, 187, 139, 206, 196, 166,
76, 17, 51, 153, 37, 111, 122, 155,
43, 129, 176, 106, 107, 110, 119, 146,
16, 48, 144, 10, 30, 90, 59, 177,
109, 116, 137, 200, 178, 112, 125, 164,
70, 210, 208, 202, 184, 130, 179, 115,
134, 191, 151, 31, 93, 68, 204, 190,
148, 22, 66, 198, 172, 94, 71, 2,
6, 18, 54, 162, 64, 192, 154, 40,
120, 149, 25, 75, 14, 42, 126, 167,
79, 26, 78, 23, 69, 207, 199, 175,
103, 98, 83, 38, 114, 131, 182, 124,
161, 61, 183, 127, 170, 88, 53, 159,
55, 165, 73, 8, 24, 72, 5, 15,
45, 135, 194, 160, 58, 174, 100, 89
}; };
static int finder_pattern_exp[60] = { /* Table 15 */
1, 8, 4, 1, 1, static int t_even_exp[5] = {
1, 1, 4, 8, 1, 4, 20, 52, 104, 204
3, 6, 4, 1, 1,
1, 1, 4, 6, 3,
3, 4, 6, 1, 1,
1, 1, 6, 4, 3,
3, 2, 8, 1, 1,
1, 1, 8, 2, 3,
2, 6, 5, 1, 1,
1, 1, 5, 6, 2,
2, 2, 9, 1, 1,
1, 1, 9, 2, 2
}; };
static int finder_sequence[198] = { /* Table 16 */
1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, static int modules_odd_exp[5] = {
1, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 12, 10, 8, 6, 4
1, 6, 3, 8, 0, 0, 0, 0, 0, 0, 0,
1, 10, 3, 8, 5, 0, 0, 0, 0, 0, 0,
1, 10, 3, 8, 7, 12, 0, 0, 0, 0, 0,
1, 10, 3, 8, 9, 12, 11, 0, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 10, 9, 0, 0,
1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 0,
1, 2, 3, 4, 5, 8, 7, 10, 9, 12, 11
}; };
static int modules_even_exp[5] = {
5, 7, 9, 11, 13
};
static int widest_odd_exp[5] = {
7, 5, 4, 3, 1
};
static int widest_even_exp[5] = {
2, 4, 5, 6, 8
};
static int checksum_weight_exp[184] = {
/* Table 14 */
1, 3, 9, 27, 81, 32, 96, 77,
20, 60, 180, 118, 143, 7, 21, 63,
189, 145, 13, 39, 117, 140, 209, 205,
193, 157, 49, 147, 19, 57, 171, 91,
62, 186, 136, 197, 169, 85, 44, 132,
185, 133, 188, 142, 4, 12, 36, 108,
113, 128, 173, 97, 80, 29, 87, 50,
150, 28, 84, 41, 123, 158, 52, 156,
46, 138, 203, 187, 139, 206, 196, 166,
76, 17, 51, 153, 37, 111, 122, 155,
43, 129, 176, 106, 107, 110, 119, 146,
16, 48, 144, 10, 30, 90, 59, 177,
109, 116, 137, 200, 178, 112, 125, 164,
70, 210, 208, 202, 184, 130, 179, 115,
134, 191, 151, 31, 93, 68, 204, 190,
148, 22, 66, 198, 172, 94, 71, 2,
6, 18, 54, 162, 64, 192, 154, 40,
120, 149, 25, 75, 14, 42, 126, 167,
79, 26, 78, 23, 69, 207, 199, 175,
103, 98, 83, 38, 114, 131, 182, 124,
161, 61, 183, 127, 170, 88, 53, 159,
55, 165, 73, 8, 24, 72, 5, 15,
45, 135, 194, 160, 58, 174, 100, 89
};
static int finder_pattern_exp[60] = {
/* Table 15 */
1, 8, 4, 1, 1,
1, 1, 4, 8, 1,
3, 6, 4, 1, 1,
1, 1, 4, 6, 3,
3, 4, 6, 1, 1,
1, 1, 6, 4, 3,
3, 2, 8, 1, 1,
1, 1, 8, 2, 3,
2, 6, 5, 1, 1,
1, 1, 5, 6, 2,
2, 2, 9, 1, 1,
1, 1, 9, 2, 2
};
static int finder_sequence[198] = {
/* Table 16 */
1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0,
1, 6, 3, 8, 0, 0, 0, 0, 0, 0, 0,
1, 10, 3, 8, 5, 0, 0, 0, 0, 0, 0,
1, 10, 3, 8, 7, 12, 0, 0, 0, 0, 0,
1, 10, 3, 8, 9, 12, 11, 0, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 10, 9, 0, 0,
1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 0,
1, 2, 3, 4, 5, 8, 7, 10, 9, 12, 11
};
static int weight_rows[210] = { static int weight_rows[210] = {
0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 5, 6, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 9, 10, 3, 4, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 3, 4, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, 3, 4, 13, 14, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 11, 12, 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, 3, 4, 13, 14, 11, 12, 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 15, 16, 21, 22, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, 3, 4, 13, 14, 15, 16, 21, 22, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 15, 16, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 15, 16, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 19, 20, 21, 22, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 19, 20, 21, 22, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 11, 12, 17, 18, 15, 16, 21, 22, 19, 20 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 11, 12, 17, 18, 15, 16, 21, 22, 19, 20
}; };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk> Copyright (C) 2008-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -28,7 +28,7 @@
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE. SUCH DAMAGE.
*/ */
#define SODIUM "0123456789X" #define SODIUM "0123456789X"
@ -37,132 +37,131 @@
#include <stdlib.h> #include <stdlib.h>
#include "common.h" #include "common.h"
static char *TeleTable[] = static char *TeleTable[] ={
{ "1111111111111111", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111",
"1111111111111111", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111", "31333111", "1131113131", "33113131", "1111333111", "3111113131", "1113133111", "1311133111", "111111113131",
"31333111", "1131113131", "33113131", "1111333111", "3111113131", "1113133111", "1311133111", "111111113131", "3131113111", "11313331", "333331", "111131113111", "31113331", "1133113111", "1313113111", "1111113331",
"3131113111", "11313331", "333331", "111131113111", "31113331", "1133113111", "1313113111", "1111113331", "31131331", "113111113111", "3311113111", "1111131331", "311111113111", "1113111331", "1311111331", "11111111113111",
"31131331", "113111113111", "3311113111", "1111131331", "311111113111", "1113111331", "1311111331", "11111111113111", "31313311", "1131311131", "33311131", "1111313311", "3111311131", "11333311", "13133311", "111111311131",
"31313311", "1131311131", "33311131", "1111313311", "3111311131", "11333311", "13133311", "111111311131", "31331131", "1131113311", "33113311", "1111331131", "3111113311", "1113131131", "1311131131", "111111113311",
"31331131", "1131113311", "33113311", "1111331131", "3111113311", "1113131131", "1311131131", "111111113311", "3131111131", "1131131311", "33131311", "111131111131", "3111131311", "1133111131", "1313111131", "111111131311",
"3131111131", "1131131311", "33131311", "111131111131", "3111131311", "1133111131", "1313111131", "111111131311", "3113111311", "113111111131", "3311111131", "111113111311", "311111111131", "111311111311", "131111111311", "11111111111131",
"3113111311", "113111111131", "3311111131", "111113111311", "311111111131", "111311111311", "131111111311", "11111111111131", "3131311111", "11313133", "333133", "111131311111", "31113133", "1133311111", "1313311111", "1111113133",
"3131311111", "11313133", "333133", "111131311111", "31113133", "1133311111", "1313311111", "1111113133", "313333", "113111311111", "3311311111", "11113333", "311111311111", "11131333", "13111333", "11111111311111",
"313333", "113111311111", "3311311111", "11113333", "311111311111", "11131333", "13111333", "11111111311111", "31311133", "1131331111", "33331111", " 1111311133", "3111331111", "11331133", "13131133", "111111331111",
"31311133", "1131331111", "33331111", " 1111311133", "3111331111", "11331133", "13131133", "111111331111", "3113131111", "1131111133", "33111133", "111113131111", "3111111133", "111311131111", "131111131111", "111111111133",
"3113131111", "1131111133", "33111133", "111113131111", "3111111133", "111311131111", "131111131111", "111111111133", "31311313", "113131111111", "3331111111", "1111311313", "311131111111", "11331313", "13131313", "11111131111111",
"31311313", "113131111111", "3331111111", "1111311313", "311131111111", "11331313", "13131313", "11111131111111", "3133111111", "1131111313", "33111313", "111133111111", "3111111313", "111313111111", "131113111111", "111111111313",
"3133111111", "1131111313", "33111313", "111133111111", "3111111313", "111313111111", "131113111111", "111111111313", "313111111111", "1131131113", "33131113", "11113111111111", "3111131113", "113311111111", "131311111111", "111111131113",
"313111111111", "1131131113", "33131113", "11113111111111","3111131113", "113311111111", "131311111111", "111111131113", "3113111113", "11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113", "131111111113"
"3113111113", "11311111111111","331111111111","111113111113", "31111111111111","111311111113","131111111113"}; };
int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len)
{
unsigned int i, count, check_digit;
int error_number;
char dest[512]; /*14 + 30 * 14 + 14 + 14 + 1 ~ 512 */
error_number = 0;
count = 0; int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len) {
unsigned int i, count, check_digit;
int error_number;
char dest[512]; /*14 + 30 * 14 + 14 + 14 + 1 ~ 512 */
if(src_len > 30) { error_number = 0;
strcpy(symbol->errtxt, "Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Start character */
strcpy(dest, TeleTable['_']);
for(i = 0; i < src_len; i++) { count = 0;
if(source[i] > 126) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
concat(dest, TeleTable[source[i]]);
count += source[i];
}
check_digit = 127 - (count % 127); if (src_len > 30) {
if(check_digit == 127) { check_digit = 0; } strcpy(symbol->errtxt, "Input too long");
concat(dest, TeleTable[check_digit]); return ZINT_ERROR_TOO_LONG;
}
/* Start character */
strcpy(dest, TeleTable['_']);
/* Stop character */ for (i = 0; i < src_len; i++) {
concat(dest, TeleTable['z']); if (source[i] > 126) {
/* Cannot encode extended ASCII */
expand(symbol, dest); strcpy(symbol->errtxt, "Invalid characters in input data");
for(i = 0; i < src_len; i++) { return ZINT_ERROR_INVALID_DATA;
if(source[i] == '\0') { }
symbol->text[i] = ' '; concat(dest, TeleTable[source[i]]);
} else { count += source[i];
symbol->text[i] = source[i]; }
}
} check_digit = 127 - (count % 127);
symbol->text[src_len] = '\0'; if (check_digit == 127) {
return error_number; check_digit = 0;
}
concat(dest, TeleTable[check_digit]);
/* Stop character */
concat(dest, TeleTable['z']);
expand(symbol, dest);
for (i = 0; i < src_len; i++) {
if (source[i] == '\0') {
symbol->text[i] = ' ';
} else {
symbol->text[i] = source[i];
}
}
symbol->text[src_len] = '\0';
return error_number;
} }
int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len) int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len) {
{ unsigned int i, count, check_digit, glyph;
unsigned int i, count, check_digit, glyph; int error_number, temp_length = src_len;
int error_number, temp_length = src_len; char dest[1024]; /* 14 + 60 * 14 + 14 + 14 + 1 ~ 1024 */
char dest[1024]; /* 14 + 60 * 14 + 14 + 14 + 1 ~ 1024 */ unsigned char temp[64];
unsigned char temp[64];
error_number = 0;
count = 0;
if(temp_length > 60) { error_number = 0;
strcpy(symbol->errtxt, "Input too long"); count = 0;
return ZINT_ERROR_TOO_LONG;
}
ustrcpy(temp, source);
to_upper(temp);
error_number = is_sane(NEON, temp, temp_length);
if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
/* Add a leading zero if required */
if (temp_length & 1)
{
memmove(temp + 1, temp, temp_length);
temp[0] = '0';
temp[++temp_length] = '\0'; if (temp_length > 60) {
} strcpy(symbol->errtxt, "Input too long");
return ZINT_ERROR_TOO_LONG;
}
ustrcpy(temp, source);
to_upper(temp);
error_number = is_sane(NEON, temp, temp_length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
/* Start character */ /* Add a leading zero if required */
strcpy(dest, TeleTable['_']); if (temp_length & 1) {
memmove(temp + 1, temp, temp_length);
temp[0] = '0';
for (i = 0; i < temp_length; i += 2) temp[++temp_length] = '\0';
{ }
if(temp[i] == 'X') {
strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
return ZINT_ERROR_INVALID_DATA;
}
if(temp[i + 1] == 'X') {
glyph = ctoi(temp[i]) + 17;
count += glyph;
} else {
glyph = (10 * ctoi(temp[i])) + ctoi(temp[i + 1]);
glyph += 27;
count += glyph;
}
concat(dest, TeleTable[glyph]);
}
check_digit = 127 - (count % 127); /* Start character */
if(check_digit == 127) { check_digit = 0; } strcpy(dest, TeleTable['_']);
concat(dest, TeleTable[check_digit]);
/* Stop character */ for (i = 0; i < temp_length; i += 2) {
concat(dest, TeleTable['z']); if (temp[i] == 'X') {
strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
expand(symbol, dest); return ZINT_ERROR_INVALID_DATA;
ustrcpy(symbol->text, temp); }
return error_number;
if (temp[i + 1] == 'X') {
glyph = ctoi(temp[i]) + 17;
count += glyph;
} else {
glyph = (10 * ctoi(temp[i])) + ctoi(temp[i + 1]);
glyph += 27;
count += glyph;
}
concat(dest, TeleTable[glyph]);
}
check_digit = 127 - (count % 127);
if (check_digit == 127) {
check_digit = 0;
}
concat(dest, TeleTable[check_digit]);
/* Stop character */
concat(dest, TeleTable['z']);
expand(symbol, dest);
ustrcpy(symbol->text, temp);
return error_number;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* zint.h - definitions for libzint /* zint.h - definitions for libzint
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -27,7 +27,7 @@
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE. SUCH DAMAGE.
*/ */
#ifndef ZINT_H #ifndef ZINT_H
#define ZINT_H #define ZINT_H
@ -36,67 +36,67 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
struct zint_render_line { struct zint_render_line {
float x, y, length, width; float x, y, length, width;
struct zint_render_line *next; /* Pointer to next line */ struct zint_render_line *next; /* Pointer to next line */
}; };
struct zint_render_string { struct zint_render_string {
float x, y, fsize; float x, y, fsize;
float width; /* Suggested string width, may be 0 if none recommended */ float width; /* Suggested string width, may be 0 if none recommended */
int length; int length;
unsigned char *text; unsigned char *text;
struct zint_render_string *next; /* Pointer to next character */ struct zint_render_string *next; /* Pointer to next character */
}; };
struct zint_render_ring { struct zint_render_ring {
float x, y, radius, line_width; float x, y, radius, line_width;
struct zint_render_ring *next; /* Pointer to next ring */ struct zint_render_ring *next; /* Pointer to next ring */
}; };
struct zint_render_hexagon { struct zint_render_hexagon {
float x, y; float x, y;
struct zint_render_hexagon *next; /* Pointer to next hexagon */ struct zint_render_hexagon *next; /* Pointer to next hexagon */
}; };
struct zint_render { struct zint_render {
float width, height; float width, height;
struct zint_render_line *lines; /* Pointer to first line */ struct zint_render_line *lines; /* Pointer to first line */
struct zint_render_string *strings; /* Pointer to first string */ struct zint_render_string *strings; /* Pointer to first string */
struct zint_render_ring *rings; /* Pointer to first ring */ struct zint_render_ring *rings; /* Pointer to first ring */
struct zint_render_hexagon *hexagons; /* Pointer to first hexagon */ struct zint_render_hexagon *hexagons; /* Pointer to first hexagon */
}; };
struct zint_symbol { struct zint_symbol {
int symbology; int symbology;
int height; int height;
int whitespace_width; int whitespace_width;
int border_width; int border_width;
int output_options; int output_options;
char fgcolour[10]; char fgcolour[10];
char bgcolour[10]; char bgcolour[10];
char outfile[256]; char outfile[256];
float scale; float scale;
int option_1; int option_1;
int option_2; int option_2;
int option_3; int option_3;
int show_hrt; int show_hrt;
int input_mode; int input_mode;
unsigned char text[128]; unsigned char text[128];
int rows; int rows;
int width; int width;
char primary[128]; char primary[128];
unsigned char encoded_data[178][143]; unsigned char encoded_data[178][143];
int row_height[178]; /* Largest symbol is 177x177 QR Code */ int row_height[178]; /* Largest symbol is 177x177 QR Code */
char errtxt[100]; char errtxt[100];
char *bitmap; char *bitmap;
int bitmap_width; int bitmap_width;
int bitmap_height; int bitmap_height;
struct zint_render *rendered; struct zint_render *rendered;
}; };
/* Tbarcode 7 codes */ /* Tbarcode 7 codes */
#define BARCODE_CODE11 1 #define BARCODE_CODE11 1
#define BARCODE_C25MATRIX 2 #define BARCODE_C25MATRIX 2
#define BARCODE_C25INTER 3 #define BARCODE_C25INTER 3
@ -153,7 +153,7 @@ struct zint_symbol {
#define BARCODE_ONECODE 85 #define BARCODE_ONECODE 85
#define BARCODE_PLESSEY 86 #define BARCODE_PLESSEY 86
/* Tbarcode 8 codes */ /* Tbarcode 8 codes */
#define BARCODE_TELEPEN_NUM 87 #define BARCODE_TELEPEN_NUM 87
#define BARCODE_ITF14 89 #define BARCODE_ITF14 89
#define BARCODE_KIX 90 #define BARCODE_KIX 90
@ -161,7 +161,7 @@ struct zint_symbol {
#define BARCODE_DAFT 93 #define BARCODE_DAFT 93
#define BARCODE_MICROQR 97 #define BARCODE_MICROQR 97
/* Tbarcode 9 codes */ /* Tbarcode 9 codes */
#define BARCODE_HIBC_128 98 #define BARCODE_HIBC_128 98
#define BARCODE_HIBC_39 99 #define BARCODE_HIBC_39 99
#define BARCODE_HIBC_DM 102 #define BARCODE_HIBC_DM 102
@ -171,7 +171,7 @@ struct zint_symbol {
#define BARCODE_HIBC_BLOCKF 110 #define BARCODE_HIBC_BLOCKF 110
#define BARCODE_HIBC_AZTEC 112 #define BARCODE_HIBC_AZTEC 112
/* Zint specific */ /* Zint specific */
#define BARCODE_AZRUNE 128 #define BARCODE_AZRUNE 128
#define BARCODE_CODE32 129 #define BARCODE_CODE32 129
#define BARCODE_EANX_CC 130 #define BARCODE_EANX_CC 130
@ -213,34 +213,34 @@ struct zint_symbol {
#define ZINT_ERROR_MEMORY 11 #define ZINT_ERROR_MEMORY 11
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(_MSC_VER) #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(_MSC_VER)
# if defined (DLL_EXPORT) || defined(PIC) || defined(_USRDLL) #if defined (DLL_EXPORT) || defined(PIC) || defined(_USRDLL)
# define ZINT_EXTERN __declspec(dllexport) #define ZINT_EXTERN __declspec(dllexport)
# elif defined(ZINT_DLL) #elif defined(ZINT_DLL)
# define ZINT_EXTERN __declspec(dllimport) #define ZINT_EXTERN __declspec(dllimport)
# else
# define ZINT_EXTERN extern
# endif
#else #else
# define ZINT_EXTERN extern #define ZINT_EXTERN extern
#endif
#else
#define ZINT_EXTERN extern
#endif #endif
ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void); ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
ZINT_EXTERN void ZBarcode_Clear(struct zint_symbol *symbol); ZINT_EXTERN void ZBarcode_Clear(struct zint_symbol *symbol);
ZINT_EXTERN void ZBarcode_Delete(struct zint_symbol *symbol); ZINT_EXTERN void ZBarcode_Delete(struct zint_symbol *symbol);
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input, int length); ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input, int length);
ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename); ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename);
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle); ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle); ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle); ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
ZINT_EXTERN int ZBarcode_Render(struct zint_symbol *symbol, float width, float height); ZINT_EXTERN int ZBarcode_Render(struct zint_symbol *symbol, float width, float height);
ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle); ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle); ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle); ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle);
ZINT_EXTERN int ZBarcode_ValidID(int symbol_id); ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
#ifdef __cplusplus #ifdef __cplusplus
} }