HANXIN: 0xFFE terminator; reedsol/AZTEC: stack-based; AZTEC/HANXIN/QR/GRIDMATRIX speedups; #209
@ -70,24 +70,24 @@ static inline char convert_pattern(char data, int shift) {
|
||||
|
||||
/* Adds Reed-Solomon error correction to auspost */
|
||||
static void rs_error(char data_pattern[]) {
|
||||
size_t reader, triple_writer = 0;
|
||||
char triple[31];
|
||||
int reader, len, triple_writer = 0;
|
||||
unsigned char triple[31];
|
||||
unsigned char result[5];
|
||||
rs_t rs;
|
||||
|
||||
for (reader = 2; reader < strlen(data_pattern); reader += 3, triple_writer++) {
|
||||
for (reader = 2, len = (int) strlen(data_pattern); reader < len; reader += 3, triple_writer++) {
|
||||
triple[triple_writer] = convert_pattern(data_pattern[reader], 4)
|
||||
+ convert_pattern(data_pattern[reader + 1], 2)
|
||||
+ convert_pattern(data_pattern[reader + 2], 0);
|
||||
}
|
||||
|
||||
rs_init_gf(0x43);
|
||||
rs_init_code(4, 1);
|
||||
rs_encode(triple_writer, (unsigned char*) triple, result);
|
||||
rs_init_gf(&rs, 0x43);
|
||||
rs_init_code(&rs, 4, 1);
|
||||
rs_encode(&rs, triple_writer, triple, result);
|
||||
|
||||
for (reader = 4; reader > 0; reader--) {
|
||||
strcat(data_pattern, AusBarTable[(int) result[reader - 1]]);
|
||||
}
|
||||
rs_free();
|
||||
}
|
||||
|
||||
/* Handles Australia Posts's 4 State Codes */
|
||||
@ -168,7 +168,7 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
localstr[zeroes] = '\0';
|
||||
}
|
||||
|
||||
strcat(localstr, (char*) source);
|
||||
strncat(localstr, (char *) source, length);
|
||||
h = strlen(localstr);
|
||||
/* Verifiy that the first 8 characters are numbers */
|
||||
memcpy(dpid, localstr, 8);
|
||||
|
720
backend/aztec.c
@ -560,7 +560,6 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
|
||||
}
|
||||
|
||||
if ((length - sp) >= 8) {
|
||||
int latch = 0;
|
||||
j = 0;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
@ -663,7 +662,6 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
|
||||
}
|
||||
|
||||
if ((length - sp) >= 8) {
|
||||
int latch = 0;
|
||||
j = 0;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
@ -764,7 +762,6 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
|
||||
}
|
||||
|
||||
if ((length - sp) >= 8) {
|
||||
int latch = 0;
|
||||
j = 0;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
@ -1163,13 +1160,15 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
|
||||
strcpy(symbol->errtxt, "512: Input data too long");
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
printf("targets:\n");
|
||||
for(i = 0; i < tp; i++) {
|
||||
printf("[%d]", target[i]);
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("Target:");
|
||||
for (i = 0; i < tp; i++) {
|
||||
printf(" [%d]", target[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
*/
|
||||
|
||||
return tp;
|
||||
}
|
||||
|
||||
@ -1191,6 +1190,7 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
char datagrid[136][120];
|
||||
int row, col;
|
||||
int sub_version = 0;
|
||||
rs_t rs;
|
||||
|
||||
if ((symbol->option_2 < 0) || (symbol->option_2 > 10)) {
|
||||
strcpy(symbol->errtxt, "513: Invalid symbol size");
|
||||
@ -1239,10 +1239,9 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
|
||||
large_uint_array(&elreg, data, codewords, 5 /*bits*/);
|
||||
|
||||
rs_init_gf(0x25);
|
||||
rs_init_code(codewords, 1);
|
||||
rs_encode_long(codewords, data, ecc);
|
||||
rs_free();
|
||||
rs_init_gf(&rs, 0x25);
|
||||
rs_init_code(&rs, codewords, 1);
|
||||
rs_encode_uint(&rs, codewords, data, ecc);
|
||||
|
||||
for (i = 0; i < codewords; i++) {
|
||||
stream[i] = data[i];
|
||||
@ -1344,10 +1343,9 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
}
|
||||
|
||||
/* Calculate error correction data */
|
||||
rs_init_gf(0x12d);
|
||||
rs_init_code(ecc_cw, 1);
|
||||
rs_encode_long(data_cw, data, ecc);
|
||||
rs_free();
|
||||
rs_init_gf(&rs, 0x12d);
|
||||
rs_init_code(&rs, ecc_cw, 1);
|
||||
rs_encode_uint(&rs, data_cw, data, ecc);
|
||||
|
||||
/* "Stream" combines data and error correction data */
|
||||
for (i = 0; i < data_cw; i++) {
|
||||
@ -1446,19 +1444,18 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
|
||||
data_blocks = c1_blocks[size - 1];
|
||||
|
||||
rs_init_gf(0x12d);
|
||||
rs_init_code(c1_ecc_blocks[size - 1], 0);
|
||||
rs_init_gf(&rs, 0x12d);
|
||||
rs_init_code(&rs, c1_ecc_blocks[size - 1], 0);
|
||||
for (i = 0; i < data_blocks; i++) {
|
||||
for (j = 0; j < c1_data_blocks[size - 1]; j++) {
|
||||
|
||||
sub_data[j] = data[j * data_blocks + i];
|
||||
}
|
||||
rs_encode_long(c1_data_blocks[size - 1], sub_data, sub_ecc);
|
||||
rs_encode_uint(&rs, c1_data_blocks[size - 1], sub_data, sub_ecc);
|
||||
for (j = 0; j < c1_ecc_blocks[size - 1]; j++) {
|
||||
ecc[c1_ecc_length[size - 1] - (j * data_blocks + i) - 1] = sub_ecc[j];
|
||||
}
|
||||
}
|
||||
rs_free();
|
||||
|
||||
/* "Stream" combines data and error correction data */
|
||||
for (i = 0; i < data_length; i++) {
|
||||
|
104
backend/common.c
@ -303,11 +303,12 @@ INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, cons
|
||||
return *state;
|
||||
}
|
||||
|
||||
/* Convert UTF-8 to Unicode. If `disallow_4byte` unset, allow all values (UTF-32).
|
||||
* If `disallow_4byte` set, only allow codepoints <= U+FFFF (ie four-byte sequences not allowed) (UTF-16, no surrogates) */
|
||||
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[], size_t *length, int disallow_4byte) {
|
||||
size_t bpos;
|
||||
int jpos;
|
||||
/* Convert UTF-8 to Unicode. If `disallow_4byte` unset, allow all values (UTF-32). If `disallow_4byte` set,
|
||||
* only allow codepoints <= U+FFFF (ie four-byte sequences not allowed) (UTF-16, no surrogates) */
|
||||
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[],
|
||||
int *length, int disallow_4byte) {
|
||||
int bpos;
|
||||
int jpos;
|
||||
unsigned int codepoint, state = 0;
|
||||
|
||||
bpos = 0;
|
||||
@ -361,99 +362,6 @@ INTERNAL void set_minimum_height(struct zint_symbol *symbol, const int min_heigh
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate optimized encoding modes. Adapted from Project Nayuki */
|
||||
INTERNAL void pn_define_mode(char *mode, const unsigned int data[], const size_t length, const int debug,
|
||||
unsigned int state[], const char mode_types[], const int num_modes,
|
||||
pn_head_costs head_costs, pn_switch_cost switch_cost, pn_eod_cost eod_cost, pn_cur_cost cur_cost) {
|
||||
/*
|
||||
* Copyright (c) Project Nayuki. (MIT License)
|
||||
* https://www.nayuki.io/page/qr-code-generator-library
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
* - The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
int i, j, k, cm_i;
|
||||
unsigned int min_cost;
|
||||
char cur_mode;
|
||||
#ifndef _MSC_VER
|
||||
unsigned int prev_costs[num_modes];
|
||||
char char_modes[length * num_modes];
|
||||
unsigned int cur_costs[num_modes];
|
||||
#else
|
||||
unsigned int *prev_costs;
|
||||
char *char_modes;
|
||||
unsigned int *cur_costs;
|
||||
prev_costs = (unsigned int *) _alloca(num_modes * sizeof(unsigned int));
|
||||
char_modes = (char *) _alloca(length * num_modes);
|
||||
cur_costs = (unsigned int *) _alloca(num_modes * sizeof(unsigned int));
|
||||
#endif
|
||||
|
||||
/* char_modes[i * num_modes + j] represents the mode to encode the code point at index i such that the final
|
||||
* segment ends in mode_types[j] and the total number of bits is minimized over all possible choices */
|
||||
memset(char_modes, 0, length * num_modes);
|
||||
|
||||
/* At the beginning of each iteration of the loop below, prev_costs[j] is the minimum number of 1/6 (1/XX_MULT)
|
||||
* bits needed to encode the entire string prefix of length i, and end in mode_types[j] */
|
||||
memcpy(prev_costs, (*head_costs)(state), num_modes * sizeof(unsigned int));
|
||||
|
||||
/* Calculate costs using dynamic programming */
|
||||
for (i = 0, cm_i = 0; i < (int) length; i++, cm_i += num_modes) {
|
||||
memset(cur_costs, 0, num_modes * sizeof(unsigned int));
|
||||
|
||||
(*cur_cost)(state, data, length, i, char_modes, prev_costs, cur_costs);
|
||||
|
||||
if (eod_cost && i == (int) length - 1) { /* Add end of data costs if last character */
|
||||
for (j = 0; j < num_modes; j++) {
|
||||
if (char_modes[cm_i + j]) {
|
||||
cur_costs[j] += (*eod_cost)(state, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Start new segment at the end to switch modes */
|
||||
for (j = 0; j < num_modes; j++) { /* To mode */
|
||||
for (k = 0; k < num_modes; k++) { /* From mode */
|
||||
if (j != k && char_modes[cm_i + k]) {
|
||||
unsigned int new_cost = cur_costs[k] + (*switch_cost)(state, k, j);
|
||||
if (!char_modes[cm_i + j] || new_cost < cur_costs[j]) {
|
||||
cur_costs[j] = new_cost;
|
||||
char_modes[cm_i + j] = mode_types[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(prev_costs, cur_costs, num_modes * sizeof(unsigned int));
|
||||
}
|
||||
|
||||
/* Find optimal ending mode */
|
||||
min_cost = prev_costs[0];
|
||||
cur_mode = mode_types[0];
|
||||
for (i = 1; i < num_modes; i++) {
|
||||
if (prev_costs[i] < min_cost) {
|
||||
min_cost = prev_costs[i];
|
||||
cur_mode = mode_types[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Get optimal mode for each code point by tracing backwards */
|
||||
for (i = length - 1, cm_i = i * num_modes; i >= 0; i--, cm_i -= num_modes) {
|
||||
j = strchr(mode_types, cur_mode) - mode_types;
|
||||
cur_mode = char_modes[cm_i + j];
|
||||
mode[i] = cur_mode;
|
||||
}
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf(" Mode: %.*s\n", (int) length, mode);
|
||||
}
|
||||
}
|
||||
|
||||
INTERNAL int colour_to_red(int colour) {
|
||||
int return_val = 0;
|
||||
|
||||
|
@ -110,18 +110,9 @@ extern "C" {
|
||||
INTERNAL int istwodigits(const unsigned char source[], const int length, const int position);
|
||||
INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte);
|
||||
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[],
|
||||
size_t *length, int disallow_4byte);
|
||||
int *length, int disallow_4byte);
|
||||
INTERNAL void set_minimum_height(struct zint_symbol *symbol, const int min_height);
|
||||
|
||||
typedef unsigned int *(*pn_head_costs)(unsigned int state[]);
|
||||
typedef unsigned int (*pn_switch_cost)(unsigned int state[], const int k, const int j);
|
||||
typedef unsigned int (*pn_eod_cost)(unsigned int state[], const int k);
|
||||
typedef void (*pn_cur_cost)(unsigned int state[], const unsigned int data[], const size_t length, const int i,
|
||||
char *char_modes, unsigned int prev_costs[], unsigned int cur_costs[]);
|
||||
INTERNAL void pn_define_mode(char *mode, const unsigned int data[], const size_t length, const int debug,
|
||||
unsigned int state[], const char mode_types[], const int num_modes,
|
||||
pn_head_costs head_costs, pn_switch_cost switch_cost, pn_eod_cost eod_cost, pn_cur_cost cur_cost);
|
||||
|
||||
INTERNAL int colour_to_red(int colour);
|
||||
INTERNAL int colour_to_green(int colour);
|
||||
INTERNAL int colour_to_blue(int colour);
|
||||
|
@ -193,14 +193,16 @@ static void ecc200placement(int *array, const int NR, const int NC) {
|
||||
static void ecc200(unsigned char *binary, const int bytes, const int datablock, const int rsblock, const int skew) {
|
||||
int blocks = (bytes + 2) / datablock, b;
|
||||
int n;
|
||||
rs_init_gf(0x12d);
|
||||
rs_init_code(rsblock, 1);
|
||||
rs_t rs;
|
||||
|
||||
rs_init_gf(&rs, 0x12d);
|
||||
rs_init_code(&rs, rsblock, 1);
|
||||
for (b = 0; b < blocks; b++) {
|
||||
unsigned char buf[256], ecc[256];
|
||||
int p = 0;
|
||||
for (n = b; n < bytes; n += blocks)
|
||||
buf[p++] = binary[n];
|
||||
rs_encode(p, buf, ecc);
|
||||
rs_encode(&rs, p, buf, ecc);
|
||||
p = rsblock - 1; // comes back reversed
|
||||
for (n = b; n < rsblock * blocks; n += blocks) {
|
||||
if (skew) {
|
||||
@ -216,7 +218,6 @@ static void ecc200(unsigned char *binary, const int bytes, const int datablock,
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_free();
|
||||
}
|
||||
|
||||
/* Return true (1) if a character is valid in X12 set */
|
||||
@ -1289,9 +1290,9 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
|
||||
unsigned char *grid;
|
||||
NC = W - 2 * (W / FW);
|
||||
NR = H - 2 * (H / FH);
|
||||
places = (int*) malloc(NC * NR * sizeof (int));
|
||||
places = (int *) malloc(sizeof(int) * NC * NR);
|
||||
ecc200placement(places, NR, NC);
|
||||
grid = (unsigned char*) malloc(W * H);
|
||||
grid = (unsigned char *) malloc((size_t) W * H);
|
||||
memset(grid, 0, W * H);
|
||||
for (y = 0; y < H; y += FH) {
|
||||
for (x = 0; x < W; x++)
|
||||
@ -1328,7 +1329,6 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
|
||||
//fprintf (stderr, "\n");
|
||||
}
|
||||
for (y = H - 1; y >= 0; y--) {
|
||||
int x;
|
||||
for (x = 0; x < W; x++) {
|
||||
if (grid[W * y + x]) {
|
||||
set_module(symbol, (H - y) - 1, x);
|
||||
|
@ -39,7 +39,7 @@
|
||||
#endif
|
||||
|
||||
/* Convert Unicode to other character encodings */
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length) {
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *length) {
|
||||
int in_posn;
|
||||
int out_posn;
|
||||
int ext;
|
||||
@ -69,7 +69,7 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch
|
||||
bytelen = 2;
|
||||
glyph = (source[in_posn] & 0x1f) << 6;
|
||||
|
||||
if ((int) *length < (in_posn + 2)) {
|
||||
if (*length < (in_posn + 2)) {
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -85,11 +85,11 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch
|
||||
bytelen = 3;
|
||||
glyph = (source[in_posn] & 0x0f) << 12;
|
||||
|
||||
if ((int) *length < (in_posn + 2)) {
|
||||
if (*length < (in_posn + 2)) {
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if ((int) *length < (in_posn + 3)) {
|
||||
if (*length < (in_posn + 3)) {
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch
|
||||
|
||||
in_posn += bytelen;
|
||||
out_posn++;
|
||||
} while (in_posn < (int) *length);
|
||||
} while (in_posn < *length);
|
||||
dest[out_posn] = '\0';
|
||||
*length = out_posn;
|
||||
|
||||
@ -253,7 +253,7 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch
|
||||
}
|
||||
|
||||
/* Find the lowest ECI mode which will encode a given set of Unicode text */
|
||||
INTERNAL int get_best_eci(unsigned char source[], size_t length) {
|
||||
INTERNAL int get_best_eci(unsigned char source[], int length) {
|
||||
int eci = 3;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
@ -52,7 +52,6 @@
|
||||
* License along with the GNU LIBICONV Library; see the file COPYING.LIB.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
@ -60,7 +59,8 @@
|
||||
#include "gb2312.h"
|
||||
#include "gb18030.h"
|
||||
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */
|
||||
/* Convert Unicode to other encodings */
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *length);
|
||||
|
||||
/*
|
||||
* CP936 extensions (libiconv-1.16/lib/cp936ext.h)
|
||||
@ -81,7 +81,7 @@ static const unsigned short cp936ext_pagefe[24] = {
|
||||
0xa6e5, 0xa6e8, 0xa6e9, 0xa6ea, 0xa6eb, 0x0000, 0x0000, 0x0000, /*0x40-0x47*/
|
||||
};
|
||||
|
||||
static int cp936ext_wctomb(unsigned int* r, unsigned int wc) {
|
||||
static int cp936ext_wctomb(unsigned int *r, unsigned int wc) {
|
||||
unsigned short c = 0;
|
||||
if (wc >= 0x0140 && wc < 0x0150) {
|
||||
c = cp936ext_page01[wc-0x0140];
|
||||
@ -2383,7 +2383,7 @@ static const Summary16 gbkext_inv_uni2indx_pagefe[31] = {
|
||||
{ 14311, 0x0000 }, { 14311, 0x0000 }, { 14311, 0x0014 },
|
||||
};
|
||||
|
||||
static int gbkext_inv_wctomb(unsigned int* r, unsigned int wc) {
|
||||
static int gbkext_inv_wctomb(unsigned int *r, unsigned int wc) {
|
||||
const Summary16 *summary = NULL;
|
||||
if (wc >= 0x0200 && wc < 0x02e0) {
|
||||
summary = &gbkext_inv_uni2indx_page02[(wc>>4)-0x020];
|
||||
@ -2424,7 +2424,7 @@ static int gbkext_inv_wctomb(unsigned int* r, unsigned int wc) {
|
||||
* GBK (libiconv-1.16/lib/gbk.h)
|
||||
*/
|
||||
|
||||
static int gbk_wctomb(unsigned int* r, unsigned int wc) {
|
||||
static int gbk_wctomb(unsigned int *r, unsigned int wc) {
|
||||
int ret;
|
||||
|
||||
/* ZINT: Note these mappings U+30FB and U+2015 different from GB 2312 */
|
||||
@ -2553,7 +2553,7 @@ static const unsigned short gb18030ext_pagefe[16] = {
|
||||
0xa6ed, 0xa6f3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/
|
||||
};
|
||||
|
||||
static int gb18030ext_wctomb(unsigned int* r, unsigned int wc) {
|
||||
static int gb18030ext_wctomb(unsigned int *r, unsigned int wc) {
|
||||
unsigned short c = 0;
|
||||
if (wc == 0x01f9) {
|
||||
c = 0xa8bf;
|
||||
@ -2727,7 +2727,7 @@ static const unsigned short gb18030uni_ranges[206] = {
|
||||
25994, 25998, 26012, 26016, 26110, 26116
|
||||
};
|
||||
|
||||
static int gb18030uni_wctomb(unsigned int* r1, unsigned int* r2, unsigned int wc) {
|
||||
static int gb18030uni_wctomb(unsigned int *r1, unsigned int *r2, unsigned int wc) {
|
||||
unsigned int i = wc;
|
||||
if (i >= 0x0080 && i <= 0xffff) {
|
||||
if (i == 0xe7c7) {
|
||||
@ -2798,7 +2798,7 @@ static const unsigned short gb18030_pua2charset[31*3] = {
|
||||
0xe864, 0xe864, 0xfea0,
|
||||
};
|
||||
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int* r1, unsigned int* r2, unsigned int wc) {
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, unsigned int wc) {
|
||||
int ret;
|
||||
|
||||
/* Code set 0 (ASCII) */
|
||||
@ -2870,13 +2870,14 @@ INTERNAL int gb18030_wctomb_zint(unsigned int* r1, unsigned int* r2, unsigned in
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to GB 18030 and place in array of ints */
|
||||
INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], size_t* p_length, unsigned int* gbdata) {
|
||||
INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata) {
|
||||
int error_number, ret;
|
||||
unsigned int i, j, length;
|
||||
#ifndef _MSC_VER
|
||||
unsigned int utfdata[*p_length + 1];
|
||||
#else
|
||||
unsigned int* utfdata = (unsigned int*) _alloca((*p_length + 1) * sizeof(unsigned int));
|
||||
unsigned int *utfdata = (unsigned int *) _alloca((*p_length + 1) * sizeof(unsigned int));
|
||||
#endif
|
||||
|
||||
error_number = utf8_to_unicode(symbol, source, utfdata, p_length, 0 /*disallow_4byte*/);
|
||||
@ -2905,12 +2906,13 @@ INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char so
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to single byte ECI and place in array of ints */
|
||||
INTERNAL int gb18030_utf8tosb(int eci, const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte) {
|
||||
INTERNAL int gb18030_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte) {
|
||||
int error_number;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char single_byte[*p_length + 1];
|
||||
#else
|
||||
unsigned char* single_byte = (unsigned char*) _alloca(*p_length + 1);
|
||||
unsigned char *single_byte = (unsigned char *) _alloca(*p_length + 1);
|
||||
#endif
|
||||
|
||||
error_number = utf_to_eci(eci, source, single_byte, p_length);
|
||||
@ -2924,9 +2926,9 @@ INTERNAL int gb18030_utf8tosb(int eci, const unsigned char source[], size_t* p_l
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match HANXIN Chinese mode in single entry,
|
||||
* and quad-bytes in 2 entries. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb18030_cpy(const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte) {
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match HANXIN Chinese
|
||||
* mode in single entry, and quad-bytes in 2 entries. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb18030_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte) {
|
||||
unsigned int i, j, length;
|
||||
int done;
|
||||
unsigned char c1, c2, c3, c4;
|
||||
|
@ -37,10 +37,12 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int* r1, unsigned int* r2, unsigned int wc);
|
||||
INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], size_t* p_length, unsigned int* gbdata);
|
||||
INTERNAL int gb18030_utf8tosb(int eci, const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte);
|
||||
INTERNAL void gb18030_cpy(const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte);
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, unsigned int wc);
|
||||
INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata);
|
||||
INTERNAL int gb18030_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte);
|
||||
INTERNAL void gb18030_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -52,14 +52,14 @@
|
||||
* License along with the GNU LIBICONV Library; see the file COPYING.LIB.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "gb2312.h"
|
||||
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */
|
||||
/* Convert Unicode to other encodings */
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *length);
|
||||
|
||||
/*
|
||||
* GB2312.1980-0 (libiconv-1.16/lib/gb2312.h)
|
||||
@ -1502,7 +1502,7 @@ static const Summary16 gb2312_uni2indx_pageff[15] = {
|
||||
{ 7441, 0x0000 }, { 7441, 0x0000 }, { 7441, 0x002b },
|
||||
};
|
||||
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int* r, unsigned int wc) {
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
const Summary16 *summary = NULL;
|
||||
if (wc < 0x0460) {
|
||||
if (wc == 0x00b7) { /* ZINT: Patched to duplicate map to 0xA1A4 */
|
||||
@ -1544,13 +1544,14 @@ INTERNAL int gb2312_wctomb_zint(unsigned int* r, unsigned int wc) {
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to GB 2312 (EUC-CN) and place in array of ints */
|
||||
INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], size_t* p_length, unsigned int* gbdata) {
|
||||
INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata) {
|
||||
int error_number;
|
||||
unsigned int i, length;
|
||||
#ifndef _MSC_VER
|
||||
unsigned int utfdata[*p_length + 1];
|
||||
#else
|
||||
unsigned int* utfdata = (unsigned int*) _alloca((*p_length + 1) * sizeof(unsigned int));
|
||||
unsigned int *utfdata = (unsigned int *) _alloca((*p_length + 1) * sizeof(unsigned int));
|
||||
#endif
|
||||
|
||||
error_number = utf8_to_unicode(symbol, source, utfdata, p_length, 1 /*disallow_4byte*/);
|
||||
@ -1573,12 +1574,13 @@ INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char sou
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to single byte ECI and place in array of ints */
|
||||
INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte) {
|
||||
INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte) {
|
||||
int error_number;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char single_byte[*p_length + 1];
|
||||
#else
|
||||
unsigned char* single_byte = (unsigned char*) _alloca(*p_length + 1);
|
||||
unsigned char *single_byte = (unsigned char *) _alloca(*p_length + 1);
|
||||
#endif
|
||||
|
||||
error_number = utf_to_eci(eci, source, single_byte, p_length);
|
||||
@ -1592,9 +1594,9 @@ INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], size_t* p_le
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match GRIDMATRIX Chinese mode in a single entry.
|
||||
* If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte) {
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match GRIDMATRIX Chinese
|
||||
* mode in a single entry. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte) {
|
||||
unsigned int i, j, length;
|
||||
unsigned char c1, c2;
|
||||
|
||||
@ -1604,7 +1606,8 @@ INTERNAL void gb2312_cpy(const unsigned char source[], size_t* p_length, unsigne
|
||||
c1 = source[i];
|
||||
c2 = source[i + 1];
|
||||
if (((c1 >= 0xA1 && c1 <= 0xA9) || (c1 >= 0xB0 && c1 <= 0xF7)) && c2 >= 0xA1 && c2 <= 0xFE) {
|
||||
/* This may or may not be valid GB 2312 (EUC-CN), but don't care as long as it can be encoded in GRIDMATRIX Chinese mode */
|
||||
/* This may or may not be valid GB 2312 (EUC-CN), but don't care as long as it can be encoded in
|
||||
* GRIDMATRIX Chinese mode */
|
||||
gbdata[j] = (c1 << 8) | c2;
|
||||
i++;
|
||||
} else {
|
||||
|
@ -37,10 +37,12 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int* r, unsigned int wc);
|
||||
INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], size_t* p_length, unsigned int* gbdata);
|
||||
INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte);
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte);
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int *r, unsigned int wc);
|
||||
INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata);
|
||||
INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte);
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -49,11 +49,13 @@
|
||||
|
||||
static const char numeral_nondigits[] = " +-.,"; /* Non-digit numeral set, excluding EOL (carriage return/linefeed) */
|
||||
|
||||
/* Whether in numeral or not. If in numeral, *p_numeral_end is set to position after numeral, and *p_numeral_cost is set to per-numeral cost */
|
||||
static int in_numeral(const unsigned int gbdata[], const size_t length, const unsigned int posn, unsigned int* p_numeral_end, unsigned int* p_numeral_cost) {
|
||||
unsigned int i, digit_cnt, nondigit, nondigit_posn;
|
||||
/* Whether in numeral or not. If in numeral, *p_numeral_end is set to position after numeral,
|
||||
* and *p_numeral_cost is set to per-numeral cost */
|
||||
static int in_numeral(const unsigned int gbdata[], const int length, const int in_posn,
|
||||
unsigned int *p_numeral_end, unsigned int *p_numeral_cost) {
|
||||
int i, digit_cnt, nondigit, nondigit_posn;
|
||||
|
||||
if (posn < *p_numeral_end) {
|
||||
if (in_posn < (int) *p_numeral_end) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -61,7 +63,7 @@ static int in_numeral(const unsigned int gbdata[], const size_t length, const un
|
||||
/* Also ensures that numeric mode is not selected when it cannot be used: for example in
|
||||
a string which has "2.2.0" (cannot have more than one non-numeric character for each
|
||||
block of three numeric characters) */
|
||||
for (i = posn, digit_cnt = 0, nondigit = 0, nondigit_posn = 0; i < length && i < posn + 4 && digit_cnt < 3; i++) {
|
||||
for (i = in_posn, digit_cnt = 0, nondigit = 0, nondigit_posn = 0; i < length && i < in_posn + 4 && digit_cnt < 3; i++) {
|
||||
if (gbdata[i] >= '0' && gbdata[i] <= '9') {
|
||||
digit_cnt++;
|
||||
} else if (strchr(numeral_nondigits, gbdata[i])) {
|
||||
@ -88,7 +90,7 @@ static int in_numeral(const unsigned int gbdata[], const size_t length, const un
|
||||
if (nondigit && nondigit_posn == i - 1) { /* Non-digit can't be at end */
|
||||
nondigit = 0;
|
||||
}
|
||||
*p_numeral_end = posn + digit_cnt + nondigit;
|
||||
*p_numeral_end = in_posn + digit_cnt + nondigit;
|
||||
/* Calculate per-numeral cost where 120 == (10 + 10) * GM_MULT, 60 == 10 * GM_MULT */
|
||||
if (digit_cnt == 3) {
|
||||
*p_numeral_cost = nondigit == 2 ? 24 /* (120 / 5) */ : nondigit == 1 ? 30 /* (120 / 4) */ : 20 /* (60 / 3) */;
|
||||
@ -119,19 +121,19 @@ static int in_numeral(const unsigned int gbdata[], const size_t length, const un
|
||||
|
||||
#define GM_NUM_MODES 6
|
||||
|
||||
/* Initial mode costs */
|
||||
static unsigned int head_costs[GM_NUM_MODES] = {
|
||||
/* H N (+pad prefix) L U M B (+byte count) */
|
||||
4 * GM_MULT, (4 + 2) * GM_MULT, 4 * GM_MULT, 4 * GM_MULT, 4 * GM_MULT, (4 + 9) * GM_MULT
|
||||
};
|
||||
/* Calculate optimized encoding modes. Adapted from Project Nayuki */
|
||||
/* Copyright (c) Project Nayuki. (MIT License) See qr.c for detailed notice */
|
||||
static void define_mode(char* mode, const unsigned int gbdata[], const int length, const int debug) {
|
||||
/* Must be in same order as GM_H etc */
|
||||
static const char mode_types[] = { GM_CHINESE, GM_NUMBER, GM_LOWER, GM_UPPER, GM_MIXED, GM_BYTE, '\0' };
|
||||
|
||||
static unsigned int* gm_head_costs(unsigned int state[]) {
|
||||
(void)state; /* Unused */
|
||||
return head_costs;
|
||||
}
|
||||
/* Initial mode costs */
|
||||
static unsigned int head_costs[GM_NUM_MODES] = {
|
||||
/* H N (+pad prefix) L U M B (+byte count) */
|
||||
4 * GM_MULT, (4 + 2) * GM_MULT, 4 * GM_MULT, 4 * GM_MULT, 4 * GM_MULT, (4 + 9) * GM_MULT
|
||||
};
|
||||
|
||||
/* Cost of switching modes from k to j - see AIMD014 Rev. 1.63 Table 9 – Type conversion codes */
|
||||
static unsigned int gm_switch_cost(unsigned int state[], const int k, const int j) {
|
||||
/* Cost of switching modes from k to j - see AIMD014 Rev. 1.63 Table 9 – Type conversion codes */
|
||||
static const unsigned int switch_costs[GM_NUM_MODES][GM_NUM_MODES] = {
|
||||
/* H N L U M B */
|
||||
/*H*/ { 0, (13 + 2) * GM_MULT, 13 * GM_MULT, 13 * GM_MULT, 13 * GM_MULT, (13 + 9) * GM_MULT },
|
||||
@ -142,107 +144,172 @@ static unsigned int gm_switch_cost(unsigned int state[], const int k, const int
|
||||
/*B*/ { 4 * GM_MULT, (4 + 2) * GM_MULT, 4 * GM_MULT, 4 * GM_MULT, 4 * GM_MULT, 0 },
|
||||
};
|
||||
|
||||
(void)state; /* Unused */
|
||||
return switch_costs[k][j];
|
||||
}
|
||||
|
||||
/* Final end-of-data cost - see AIMD014 Rev. 1.63 Table 9 – Type conversion codes */
|
||||
static unsigned int gm_eod_cost(unsigned int state[], const int k) {
|
||||
/* Final end-of-data cost - see AIMD014 Rev. 1.63 Table 9 – Type conversion codes */
|
||||
static const unsigned int eod_costs[GM_NUM_MODES] = {
|
||||
/* H N L U M B */
|
||||
13 * GM_MULT, 10 * GM_MULT, 5 * GM_MULT, 5 * GM_MULT, 10 * GM_MULT, 4 * GM_MULT
|
||||
};
|
||||
|
||||
(void)state; /* Unused */
|
||||
return eod_costs[k];
|
||||
}
|
||||
|
||||
/* Calculate cost of encoding current character */
|
||||
static void gm_cur_cost(unsigned int state[], const unsigned int gbdata[], const size_t length, const int i, char* char_modes, unsigned int prev_costs[], unsigned int cur_costs[]) {
|
||||
int cm_i = i * GM_NUM_MODES;
|
||||
unsigned int numeral_end = 0, numeral_cost = 0, byte_count = 0; /* State */
|
||||
int double_byte, space, numeric, lower, upper, control, double_digit, eol;
|
||||
unsigned int* p_numeral_end = &state[0];
|
||||
unsigned int* p_numeral_cost = &state[1];
|
||||
unsigned int* p_byte_count = &state[2];
|
||||
|
||||
double_byte = gbdata[i] > 0xFF;
|
||||
space = gbdata[i] == ' ';
|
||||
numeric = gbdata[i] >= '0' && gbdata[i] <= '9';
|
||||
lower = gbdata[i] >= 'a' && gbdata[i] <= 'z';
|
||||
upper = gbdata[i] >= 'A' && gbdata[i] <= 'Z';
|
||||
control = !space && !numeric && !lower && !upper && gbdata[i] < 0x7F; /* Exclude DEL */
|
||||
double_digit = i < (int) length - 1 && numeric && gbdata[i + 1] >= '0' && gbdata[i + 1] <= '9';
|
||||
eol = i < (int) length - 1 && gbdata[i] == 13 && gbdata[i + 1] == 10;
|
||||
int i, j, k, cm_i;
|
||||
unsigned int min_cost;
|
||||
char cur_mode;
|
||||
unsigned int prev_costs[GM_NUM_MODES];
|
||||
unsigned int cur_costs[GM_NUM_MODES];
|
||||
#ifndef _MSC_VER
|
||||
char char_modes[length * GM_NUM_MODES];
|
||||
#else
|
||||
char *char_modes = (char *) _alloca(length * GM_NUM_MODES);
|
||||
#endif
|
||||
|
||||
/* Hanzi mode can encode anything */
|
||||
cur_costs[GM_H] = prev_costs[GM_H] + (double_digit || eol ? 39 : 78); /* (6.5 : 13) * GM_MULT */
|
||||
char_modes[cm_i + GM_H] = GM_CHINESE;
|
||||
/* char_modes[i * GM_NUM_MODES + j] represents the mode to encode the code point at index i such that the final
|
||||
* segment ends in mode_types[j] and the total number of bits is minimized over all possible choices */
|
||||
memset(char_modes, 0, length * GM_NUM_MODES);
|
||||
|
||||
/* Byte mode can encode anything */
|
||||
if (*p_byte_count == 512 || (double_byte && *p_byte_count == 511)) {
|
||||
cur_costs[GM_B] = head_costs[GM_B];
|
||||
if (double_byte && *p_byte_count == 511) {
|
||||
cur_costs[GM_B] += 48; /* 8 * GM_MULT */
|
||||
double_byte = 0; /* Splitting double-byte so mark as single */
|
||||
/* At the beginning of each iteration of the loop below, prev_costs[j] is the minimum number of 1/6 (1/XX_MULT)
|
||||
* bits needed to encode the entire string prefix of length i, and end in mode_types[j] */
|
||||
memcpy(prev_costs, head_costs, GM_NUM_MODES * sizeof(unsigned int));
|
||||
|
||||
/* Calculate costs using dynamic programming */
|
||||
for (i = 0, cm_i = 0; i < length; i++, cm_i += GM_NUM_MODES) {
|
||||
memset(cur_costs, 0, GM_NUM_MODES * sizeof(unsigned int));
|
||||
|
||||
space = numeric = lower = upper = control = double_digit = eol = 0;
|
||||
|
||||
double_byte = gbdata[i] > 0xFF;
|
||||
if (!double_byte) {
|
||||
space = gbdata[i] == ' ';
|
||||
if (!space) {
|
||||
numeric = gbdata[i] >= '0' && gbdata[i] <= '9';
|
||||
if (!numeric) {
|
||||
lower = gbdata[i] >= 'a' && gbdata[i] <= 'z';
|
||||
if (!lower) {
|
||||
upper = gbdata[i] >= 'A' && gbdata[i] <= 'Z';
|
||||
if (!upper) {
|
||||
control = gbdata[i] < 0x7F; /* Exclude DEL */
|
||||
if (control && i + 1 < length) {
|
||||
eol = gbdata[i] == 13 && gbdata[i + 1] == 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (i + 1 < length) {
|
||||
double_digit = gbdata[i + 1] >= '0' && gbdata[i + 1] <= '9';
|
||||
}
|
||||
}
|
||||
}
|
||||
*p_byte_count = 0;
|
||||
}
|
||||
cur_costs[GM_B] += prev_costs[GM_B] + (double_byte ? 96 : 48); /* (16 : 8) * GM_MULT */
|
||||
char_modes[cm_i + GM_B] = GM_BYTE;
|
||||
*p_byte_count += double_byte ? 2 : 1;
|
||||
|
||||
if (in_numeral(gbdata, length, i, p_numeral_end, p_numeral_cost)) {
|
||||
cur_costs[GM_N] = prev_costs[GM_N] + *p_numeral_cost;
|
||||
char_modes[cm_i + GM_N] = GM_NUMBER;
|
||||
}
|
||||
/* Hanzi mode can encode anything */
|
||||
cur_costs[GM_H] = prev_costs[GM_H] + (double_digit || eol ? 39 : 78); /* (6.5 : 13) * GM_MULT */
|
||||
char_modes[cm_i + GM_H] = GM_CHINESE;
|
||||
|
||||
if (control) {
|
||||
cur_costs[GM_L] = prev_costs[GM_L] + 78; /* (7 + 6) * GM_MULT */
|
||||
char_modes[cm_i + GM_L] = GM_LOWER;
|
||||
cur_costs[GM_U] = prev_costs[GM_U] + 78; /* (7 + 6) * GM_MULT */
|
||||
char_modes[cm_i + GM_U] = GM_UPPER;
|
||||
cur_costs[GM_M] = prev_costs[GM_M] + 96; /* (10 + 6) * GM_MULT */
|
||||
char_modes[cm_i + GM_M] = GM_MIXED;
|
||||
} else {
|
||||
if (lower || space) {
|
||||
cur_costs[GM_L] = prev_costs[GM_L] + 30; /* 5 * GM_MULT */
|
||||
/* Byte mode can encode anything */
|
||||
if (byte_count == 512 || (double_byte && byte_count == 511)) {
|
||||
cur_costs[GM_B] = head_costs[GM_B];
|
||||
if (double_byte && byte_count == 511) {
|
||||
cur_costs[GM_B] += 48; /* 8 * GM_MULT */
|
||||
double_byte = 0; /* Splitting double-byte so mark as single */
|
||||
}
|
||||
byte_count = 0;
|
||||
}
|
||||
cur_costs[GM_B] += prev_costs[GM_B] + (double_byte ? 96 : 48); /* (16 : 8) * GM_MULT */
|
||||
char_modes[cm_i + GM_B] = GM_BYTE;
|
||||
byte_count += double_byte ? 2 : 1;
|
||||
|
||||
if (in_numeral(gbdata, length, i, &numeral_end, &numeral_cost)) {
|
||||
cur_costs[GM_N] = prev_costs[GM_N] + numeral_cost;
|
||||
char_modes[cm_i + GM_N] = GM_NUMBER;
|
||||
}
|
||||
|
||||
if (control) {
|
||||
cur_costs[GM_L] = prev_costs[GM_L] + 78; /* (7 + 6) * GM_MULT */
|
||||
char_modes[cm_i + GM_L] = GM_LOWER;
|
||||
}
|
||||
if (upper || space) {
|
||||
cur_costs[GM_U] = prev_costs[GM_U] + 30; /* 5 * GM_MULT */
|
||||
cur_costs[GM_U] = prev_costs[GM_U] + 78; /* (7 + 6) * GM_MULT */
|
||||
char_modes[cm_i + GM_U] = GM_UPPER;
|
||||
}
|
||||
if (numeric || lower || upper || space) {
|
||||
cur_costs[GM_M] = prev_costs[GM_M] + 36; /* 6 * GM_MULT */
|
||||
cur_costs[GM_M] = prev_costs[GM_M] + 96; /* (10 + 6) * GM_MULT */
|
||||
char_modes[cm_i + GM_M] = GM_MIXED;
|
||||
} else {
|
||||
if (lower || space) {
|
||||
cur_costs[GM_L] = prev_costs[GM_L] + 30; /* 5 * GM_MULT */
|
||||
char_modes[cm_i + GM_L] = GM_LOWER;
|
||||
}
|
||||
if (upper || space) {
|
||||
cur_costs[GM_U] = prev_costs[GM_U] + 30; /* 5 * GM_MULT */
|
||||
char_modes[cm_i + GM_U] = GM_UPPER;
|
||||
}
|
||||
if (numeric || lower || upper || space) {
|
||||
cur_costs[GM_M] = prev_costs[GM_M] + 36; /* 6 * GM_MULT */
|
||||
char_modes[cm_i + GM_M] = GM_MIXED;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == length - 1) { /* Add end of data costs if last character */
|
||||
for (j = 0; j < GM_NUM_MODES; j++) {
|
||||
if (char_modes[cm_i + j]) {
|
||||
cur_costs[j] += eod_costs[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Start new segment at the end to switch modes */
|
||||
for (j = 0; j < GM_NUM_MODES; j++) { /* To mode */
|
||||
for (k = 0; k < GM_NUM_MODES; k++) { /* From mode */
|
||||
if (j != k && char_modes[cm_i + k]) {
|
||||
unsigned int new_cost = cur_costs[k] + switch_costs[k][j];
|
||||
if (!char_modes[cm_i + j] || new_cost < cur_costs[j]) {
|
||||
cur_costs[j] = new_cost;
|
||||
char_modes[cm_i + j] = mode_types[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(prev_costs, cur_costs, GM_NUM_MODES * sizeof(unsigned int));
|
||||
}
|
||||
|
||||
/* Find optimal ending mode */
|
||||
min_cost = prev_costs[0];
|
||||
cur_mode = mode_types[0];
|
||||
for (i = 1; i < GM_NUM_MODES; i++) {
|
||||
if (prev_costs[i] < min_cost) {
|
||||
min_cost = prev_costs[i];
|
||||
cur_mode = mode_types[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate optimized encoding modes */
|
||||
static void define_mode(char* mode, const unsigned int gbdata[], const size_t length, const int debug) {
|
||||
static const char mode_types[] = { GM_CHINESE, GM_NUMBER, GM_LOWER, GM_UPPER, GM_MIXED, GM_BYTE, '\0' }; /* Must be in same order as GM_H etc */
|
||||
unsigned int state[3] = { 0 /*numeral_end*/, 0 /*numeral_cost*/, 0 /*byte_count*/ };
|
||||
/* Get optimal mode for each code point by tracing backwards */
|
||||
for (i = length - 1, cm_i = i * GM_NUM_MODES; i >= 0; i--, cm_i -= GM_NUM_MODES) {
|
||||
j = strchr(mode_types, cur_mode) - mode_types;
|
||||
cur_mode = char_modes[cm_i + j];
|
||||
mode[i] = cur_mode;
|
||||
}
|
||||
|
||||
pn_define_mode(mode, gbdata, length, debug, state, mode_types, GM_NUM_MODES, gm_head_costs, gm_switch_cost, gm_eod_cost, gm_cur_cost);
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf(" Mode: %.*s\n", length, mode);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the length indicator for byte encoded blocks */
|
||||
static void add_byte_count(char binary[], const size_t byte_count_posn, const int byte_count) {
|
||||
static void add_byte_count(char binary[], const int byte_count_posn, const int byte_count) {
|
||||
/* AIMD014 6.3.7: "Let L be the number of bytes of input data to be encoded in the 8-bit binary data set.
|
||||
* First output (L-1) as a 9-bit binary prefix to record the number of bytes..." */
|
||||
bin_append_posn(byte_count - 1, 9, binary, byte_count_posn);
|
||||
}
|
||||
|
||||
/* Add a control character to the data stream */
|
||||
static void add_shift_char(char binary[], int shifty, int debug) {
|
||||
static int add_shift_char(char binary[], int bp, int shifty, int debug) {
|
||||
int i;
|
||||
int glyph = 0;
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
if (shift_set[i] == shifty) {
|
||||
glyph = i;
|
||||
break;
|
||||
if (shifty < 32) {
|
||||
glyph = shifty;
|
||||
} else {
|
||||
for (i = 32; i < 64; i++) {
|
||||
if (shift_set[i] == shifty) {
|
||||
glyph = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,51 +317,54 @@ static void add_shift_char(char binary[], int shifty, int debug) {
|
||||
printf("SHIFT [%d] ", glyph);
|
||||
}
|
||||
|
||||
bin_append(glyph, 6, binary);
|
||||
bp = bin_append_posn(glyph, 6, binary, bp);
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
static int gm_encode(unsigned int gbdata[], const size_t length, char binary[], const int reader, const int eci, int debug) {
|
||||
static int gm_encode(unsigned int gbdata[], const int length, char binary[], const int reader, const int eci,
|
||||
int *bin_len, int debug) {
|
||||
/* Create a binary stream representation of the input data.
|
||||
7 sets are defined - Chinese characters, Numerals, Lower case letters, Upper case letters,
|
||||
Mixed numerals and latters, Control characters and 8-bit binary data */
|
||||
unsigned int sp;
|
||||
int sp;
|
||||
int current_mode, last_mode;
|
||||
unsigned int glyph = 0;
|
||||
int c1, c2, done;
|
||||
int p = 0, ppos;
|
||||
int numbuf[3], punt = 0;
|
||||
size_t number_pad_posn, byte_count_posn = 0;
|
||||
int number_pad_posn, byte_count_posn = 0;
|
||||
int byte_count = 0;
|
||||
int shift;
|
||||
int bp;
|
||||
#ifndef _MSC_VER
|
||||
char mode[length];
|
||||
#else
|
||||
char* mode = (char*) _alloca(length);
|
||||
#endif
|
||||
|
||||
strcpy(binary, "");
|
||||
*binary = '\0';
|
||||
bp = 0;
|
||||
|
||||
sp = 0;
|
||||
current_mode = 0;
|
||||
number_pad_posn = 0;
|
||||
|
||||
if (reader) {
|
||||
bin_append(10, 4, binary); /* FNC3 - Reader Initialisation */
|
||||
bp = bin_append_posn(10, 4, binary, bp); /* FNC3 - Reader Initialisation */
|
||||
}
|
||||
|
||||
if (eci != 0) {
|
||||
/* ECI assignment according to Table 8 */
|
||||
bin_append(12, 4, binary); /* ECI */
|
||||
bp = bin_append_posn(12, 4, binary, bp); /* ECI */
|
||||
if (eci <= 1023) {
|
||||
bin_append(eci, 11, binary);
|
||||
}
|
||||
if ((eci >= 1024) && (eci <= 32767)) {
|
||||
strcat(binary, "10");
|
||||
bin_append(eci, 15, binary);
|
||||
}
|
||||
if (eci >= 32768) {
|
||||
strcat(binary, "11");
|
||||
bin_append(eci, 20, binary);
|
||||
bp = bin_append_posn(eci, 11, binary, bp);
|
||||
} else if (eci <= 32767) {
|
||||
bp = bin_append_posn(2, 2, binary, bp);
|
||||
bp = bin_append_posn(eci, 15, binary, bp);
|
||||
} else {
|
||||
bp = bin_append_posn(3, 2, binary, bp);
|
||||
bp = bin_append_posn(eci, 20, binary, bp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,31 +377,31 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
switch (current_mode) {
|
||||
case 0:
|
||||
switch (next_mode) {
|
||||
case GM_CHINESE: bin_append(1, 4, binary);
|
||||
case GM_CHINESE: bp = bin_append_posn(1, 4, binary, bp);
|
||||
break;
|
||||
case GM_NUMBER: bin_append(2, 4, binary);
|
||||
case GM_NUMBER: bp = bin_append_posn(2, 4, binary, bp);
|
||||
break;
|
||||
case GM_LOWER: bin_append(3, 4, binary);
|
||||
case GM_LOWER: bp = bin_append_posn(3, 4, binary, bp);
|
||||
break;
|
||||
case GM_UPPER: bin_append(4, 4, binary);
|
||||
case GM_UPPER: bp = bin_append_posn(4, 4, binary, bp);
|
||||
break;
|
||||
case GM_MIXED: bin_append(5, 4, binary);
|
||||
case GM_MIXED: bp = bin_append_posn(5, 4, binary, bp);
|
||||
break;
|
||||
case GM_BYTE: bin_append(6, 4, binary);
|
||||
case GM_BYTE: bp = bin_append_posn(6, 4, binary, bp);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GM_CHINESE:
|
||||
switch (next_mode) {
|
||||
case GM_NUMBER: bin_append(8161, 13, binary);
|
||||
case GM_NUMBER: bp = bin_append_posn(8161, 13, binary, bp);
|
||||
break;
|
||||
case GM_LOWER: bin_append(8162, 13, binary);
|
||||
case GM_LOWER: bp = bin_append_posn(8162, 13, binary, bp);
|
||||
break;
|
||||
case GM_UPPER: bin_append(8163, 13, binary);
|
||||
case GM_UPPER: bp = bin_append_posn(8163, 13, binary, bp);
|
||||
break;
|
||||
case GM_MIXED: bin_append(8164, 13, binary);
|
||||
case GM_MIXED: bp = bin_append_posn(8164, 13, binary, bp);
|
||||
break;
|
||||
case GM_BYTE: bin_append(8165, 13, binary);
|
||||
case GM_BYTE: bp = bin_append_posn(8165, 13, binary, bp);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -349,45 +419,45 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
break; // 0 pad digits
|
||||
}
|
||||
switch (next_mode) {
|
||||
case GM_CHINESE: bin_append(1019, 10, binary);
|
||||
case GM_CHINESE: bp = bin_append_posn(1019, 10, binary, bp);
|
||||
break;
|
||||
case GM_LOWER: bin_append(1020, 10, binary);
|
||||
case GM_LOWER: bp = bin_append_posn(1020, 10, binary, bp);
|
||||
break;
|
||||
case GM_UPPER: bin_append(1021, 10, binary);
|
||||
case GM_UPPER: bp = bin_append_posn(1021, 10, binary, bp);
|
||||
break;
|
||||
case GM_MIXED: bin_append(1022, 10, binary);
|
||||
case GM_MIXED: bp = bin_append_posn(1022, 10, binary, bp);
|
||||
break;
|
||||
case GM_BYTE: bin_append(1023, 10, binary);
|
||||
case GM_BYTE: bp = bin_append_posn(1023, 10, binary, bp);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GM_LOWER:
|
||||
case GM_UPPER:
|
||||
switch (next_mode) {
|
||||
case GM_CHINESE: bin_append(28, 5, binary);
|
||||
case GM_CHINESE: bp = bin_append_posn(28, 5, binary, bp);
|
||||
break;
|
||||
case GM_NUMBER: bin_append(29, 5, binary);
|
||||
case GM_NUMBER: bp = bin_append_posn(29, 5, binary, bp);
|
||||
break;
|
||||
case GM_LOWER:
|
||||
case GM_UPPER: bin_append(30, 5, binary);
|
||||
case GM_UPPER: bp = bin_append_posn(30, 5, binary, bp);
|
||||
break;
|
||||
case GM_MIXED: bin_append(124, 7, binary);
|
||||
case GM_MIXED: bp = bin_append_posn(124, 7, binary, bp);
|
||||
break;
|
||||
case GM_BYTE: bin_append(126, 7, binary);
|
||||
case GM_BYTE: bp = bin_append_posn(126, 7, binary, bp);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GM_MIXED:
|
||||
switch (next_mode) {
|
||||
case GM_CHINESE: bin_append(1009, 10, binary);
|
||||
case GM_CHINESE: bp = bin_append_posn(1009, 10, binary, bp);
|
||||
break;
|
||||
case GM_NUMBER: bin_append(1010, 10, binary);
|
||||
case GM_NUMBER: bp = bin_append_posn(1010, 10, binary, bp);
|
||||
break;
|
||||
case GM_LOWER: bin_append(1011, 10, binary);
|
||||
case GM_LOWER: bp = bin_append_posn(1011, 10, binary, bp);
|
||||
break;
|
||||
case GM_UPPER: bin_append(1012, 10, binary);
|
||||
case GM_UPPER: bp = bin_append_posn(1012, 10, binary, bp);
|
||||
break;
|
||||
case GM_BYTE: bin_append(1015, 10, binary);
|
||||
case GM_BYTE: bp = bin_append_posn(1015, 10, binary, bp);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -396,15 +466,15 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
add_byte_count(binary, byte_count_posn, byte_count);
|
||||
byte_count = 0;
|
||||
switch (next_mode) {
|
||||
case GM_CHINESE: bin_append(1, 4, binary);
|
||||
case GM_CHINESE: bp = bin_append_posn(1, 4, binary, bp);
|
||||
break;
|
||||
case GM_NUMBER: bin_append(2, 4, binary);
|
||||
case GM_NUMBER: bp = bin_append_posn(2, 4, binary, bp);
|
||||
break;
|
||||
case GM_LOWER: bin_append(3, 4, binary);
|
||||
case GM_LOWER: bp = bin_append_posn(3, 4, binary, bp);
|
||||
break;
|
||||
case GM_UPPER: bin_append(4, 4, binary);
|
||||
case GM_UPPER: bp = bin_append_posn(4, 4, binary, bp);
|
||||
break;
|
||||
case GM_MIXED: bin_append(5, 4, binary);
|
||||
case GM_MIXED: bp = bin_append_posn(5, 4, binary, bp);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -474,15 +544,15 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
printf("[%d] ", glyph);
|
||||
}
|
||||
|
||||
bin_append(glyph, 13, binary);
|
||||
bp = bin_append_posn(glyph, 13, binary, bp);
|
||||
sp++;
|
||||
break;
|
||||
|
||||
case GM_NUMBER:
|
||||
if (last_mode != current_mode) {
|
||||
/* Reserve a space for numeric digit padding value (2 bits) */
|
||||
number_pad_posn = strlen(binary);
|
||||
strcat(binary, "XX");
|
||||
number_pad_posn = bp;
|
||||
bp = bin_append_posn(0, 2, binary, bp);
|
||||
}
|
||||
p = 0;
|
||||
ppos = -1;
|
||||
@ -539,7 +609,7 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
printf("[%d] ", glyph);
|
||||
}
|
||||
|
||||
bin_append(glyph, 10, binary);
|
||||
bp = bin_append_posn(glyph, 10, binary, bp);
|
||||
}
|
||||
|
||||
glyph = (100 * (numbuf[0] - '0')) + (10 * (numbuf[1] - '0')) + (numbuf[2] - '0');
|
||||
@ -547,34 +617,34 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
printf("[%d] ", glyph);
|
||||
}
|
||||
|
||||
bin_append(glyph, 10, binary);
|
||||
bp = bin_append_posn(glyph, 10, binary, bp);
|
||||
break;
|
||||
|
||||
case GM_BYTE:
|
||||
if (last_mode != current_mode) {
|
||||
/* Reserve space for byte block length indicator (9 bits) */
|
||||
byte_count_posn = strlen(binary);
|
||||
strcat(binary, "LLLLLLLLL");
|
||||
byte_count_posn = bp;
|
||||
bp = bin_append_posn(0, 9, binary, bp);
|
||||
}
|
||||
glyph = gbdata[sp];
|
||||
if (byte_count == 512 || (glyph > 0xFF && byte_count == 511)) {
|
||||
/* Maximum byte block size is 512 bytes. If longer is needed then start a new block */
|
||||
if (glyph > 0xFF && byte_count == 511) { /* Split double-byte */
|
||||
bin_append(glyph >> 8, 8, binary);
|
||||
bp = bin_append_posn(glyph >> 8, 8, binary, bp);
|
||||
glyph &= 0xFF;
|
||||
byte_count++;
|
||||
}
|
||||
add_byte_count(binary, byte_count_posn, byte_count);
|
||||
bin_append(7, 4, binary);
|
||||
byte_count_posn = strlen(binary);
|
||||
strcat(binary, "LLLLLLLLL");
|
||||
bp = bin_append_posn(7, 4, binary, bp);
|
||||
byte_count_posn = bp;
|
||||
bp = bin_append_posn(0, 9, binary, bp);
|
||||
byte_count = 0;
|
||||
}
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf("[%d] ", glyph);
|
||||
}
|
||||
bin_append(glyph, glyph > 0xFF ? 16 : 8, binary);
|
||||
bp = bin_append_posn(glyph, glyph > 0xFF ? 16 : 8, binary, bp);
|
||||
sp++;
|
||||
byte_count++;
|
||||
if (glyph > 0xFF) {
|
||||
@ -586,14 +656,11 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
shift = 1;
|
||||
if ((gbdata[sp] >= '0') && (gbdata[sp] <= '9')) {
|
||||
shift = 0;
|
||||
}
|
||||
if ((gbdata[sp] >= 'A') && (gbdata[sp] <= 'Z')) {
|
||||
} else if ((gbdata[sp] >= 'A') && (gbdata[sp] <= 'Z')) {
|
||||
shift = 0;
|
||||
}
|
||||
if ((gbdata[sp] >= 'a') && (gbdata[sp] <= 'z')) {
|
||||
} else if ((gbdata[sp] >= 'a') && (gbdata[sp] <= 'z')) {
|
||||
shift = 0;
|
||||
}
|
||||
if (gbdata[sp] == ' ') {
|
||||
} else if (gbdata[sp] == ' ') {
|
||||
shift = 0;
|
||||
}
|
||||
|
||||
@ -604,11 +671,11 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
printf("[%d] ", glyph);
|
||||
}
|
||||
|
||||
bin_append(glyph, 6, binary);
|
||||
bp = bin_append_posn(glyph, 6, binary, bp);
|
||||
} else {
|
||||
/* Shift Mode character */
|
||||
bin_append(1014, 10, binary); /* shift indicator */
|
||||
add_shift_char(binary, gbdata[sp], debug);
|
||||
bp = bin_append_posn(1014, 10, binary, bp); /* shift indicator */
|
||||
bp = add_shift_char(binary, bp, gbdata[sp], debug);
|
||||
}
|
||||
|
||||
sp++;
|
||||
@ -618,8 +685,7 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
shift = 1;
|
||||
if ((gbdata[sp] >= 'A') && (gbdata[sp] <= 'Z')) {
|
||||
shift = 0;
|
||||
}
|
||||
if (gbdata[sp] == ' ') {
|
||||
} else if (gbdata[sp] == ' ') {
|
||||
shift = 0;
|
||||
}
|
||||
|
||||
@ -630,11 +696,11 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
printf("[%d] ", glyph);
|
||||
}
|
||||
|
||||
bin_append(glyph, 5, binary);
|
||||
bp = bin_append_posn(glyph, 5, binary, bp);
|
||||
} else {
|
||||
/* Shift Mode character */
|
||||
bin_append(125, 7, binary); /* shift indicator */
|
||||
add_shift_char(binary, gbdata[sp], debug);
|
||||
bp = bin_append_posn(125, 7, binary, bp); /* shift indicator */
|
||||
bp = add_shift_char(binary, bp, gbdata[sp], debug);
|
||||
}
|
||||
|
||||
sp++;
|
||||
@ -644,8 +710,7 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
shift = 1;
|
||||
if ((gbdata[sp] >= 'a') && (gbdata[sp] <= 'z')) {
|
||||
shift = 0;
|
||||
}
|
||||
if (gbdata[sp] == ' ') {
|
||||
} else if (gbdata[sp] == ' ') {
|
||||
shift = 0;
|
||||
}
|
||||
|
||||
@ -656,17 +721,17 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
printf("[%d] ", glyph);
|
||||
}
|
||||
|
||||
bin_append(glyph, 5, binary);
|
||||
bp = bin_append_posn(glyph, 5, binary, bp);
|
||||
} else {
|
||||
/* Shift Mode character */
|
||||
bin_append(125, 7, binary); /* shift indicator */
|
||||
add_shift_char(binary, gbdata[sp], debug);
|
||||
bp = bin_append_posn(125, 7, binary, bp); /* shift indicator */
|
||||
bp = add_shift_char(binary, bp, gbdata[sp], debug);
|
||||
}
|
||||
|
||||
sp++;
|
||||
break;
|
||||
}
|
||||
if (strlen(binary) > 9191) {
|
||||
if (bp > 9191) {
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -694,37 +759,46 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
||||
|
||||
/* Add "end of data" character */
|
||||
switch (current_mode) {
|
||||
case GM_CHINESE: bin_append(8160, 13, binary);
|
||||
case GM_CHINESE: bp = bin_append_posn(8160, 13, binary, bp);
|
||||
break;
|
||||
case GM_NUMBER: bin_append(1018, 10, binary);
|
||||
case GM_NUMBER: bp = bin_append_posn(1018, 10, binary, bp);
|
||||
break;
|
||||
case GM_LOWER:
|
||||
case GM_UPPER: bin_append(27, 5, binary);
|
||||
case GM_UPPER: bp = bin_append_posn(27, 5, binary, bp);
|
||||
break;
|
||||
case GM_MIXED: bin_append(1008, 10, binary);
|
||||
case GM_MIXED: bp = bin_append_posn(1008, 10, binary, bp);
|
||||
break;
|
||||
case GM_BYTE: bin_append(0, 4, binary);
|
||||
case GM_BYTE: bp = bin_append_posn(0, 4, binary, bp);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Add padding bits if required */
|
||||
p = 7 - (strlen(binary) % 7);
|
||||
p = 7 - (bp % 7);
|
||||
if (p % 7) {
|
||||
bin_append(0, p, binary);
|
||||
bp = bin_append_posn(0, p, binary, bp);
|
||||
}
|
||||
|
||||
if (strlen(binary) > 9191) {
|
||||
if (bp > 9191) {
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
binary[bp] = '\0';
|
||||
*bin_len = bp;
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf("\nBinary (%d): %s\n", bp, binary);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gm_add_ecc(const char binary[], const size_t data_posn, const int layers, const int ecc_level, unsigned char word[]) {
|
||||
static void gm_add_ecc(const char binary[], const int data_posn, const int layers, const int ecc_level,
|
||||
unsigned char word[]) {
|
||||
int data_cw, i, j, wp, p;
|
||||
int n1, b1, n2, b2, e1, b3, e2;
|
||||
int block_size, ecc_size;
|
||||
unsigned char data[1320], block[130];
|
||||
unsigned char data_block[115], ecc_block[70];
|
||||
rs_t rs;
|
||||
|
||||
data_cw = gm_data_codewords[((layers - 1) * 5) + (ecc_level - 1)];
|
||||
|
||||
@ -733,7 +807,7 @@ static void gm_add_ecc(const char binary[], const size_t data_posn, const int la
|
||||
}
|
||||
|
||||
/* Convert from binary stream to 7-bit codewords */
|
||||
for (i = 0; i < (int) data_posn; i++) {
|
||||
for (i = 0; i < data_posn; i++) {
|
||||
for (p = 0; p < 7; p++) {
|
||||
if (binary[i * 7 + p] == '1') {
|
||||
data[i] += (0x40 >> p);
|
||||
@ -743,7 +817,7 @@ static void gm_add_ecc(const char binary[], const size_t data_posn, const int la
|
||||
|
||||
/* Add padding codewords */
|
||||
data[data_posn] = 0x00;
|
||||
for (i = (int) (data_posn + 1); i < data_cw; i++) {
|
||||
for (i = (data_posn + 1); i < data_cw; i++) {
|
||||
if (i & 1) {
|
||||
data[i] = 0x7e;
|
||||
} else {
|
||||
@ -760,6 +834,8 @@ static void gm_add_ecc(const char binary[], const size_t data_posn, const int la
|
||||
b3 = gm_ebeb[((layers - 1) * 20) + ((ecc_level - 1) * 4) + 1];
|
||||
e2 = gm_ebeb[((layers - 1) * 20) + ((ecc_level - 1) * 4) + 2];
|
||||
|
||||
rs_init_gf(&rs, 0x89);
|
||||
|
||||
/* Split the data into blocks */
|
||||
wp = 0;
|
||||
for (i = 0; i < (b1 + b2); i++) {
|
||||
@ -784,10 +860,8 @@ static void gm_add_ecc(const char binary[], const size_t data_posn, const int la
|
||||
}
|
||||
|
||||
/* Calculate ECC data for this block */
|
||||
rs_init_gf(0x89);
|
||||
rs_init_code(ecc_size, 1);
|
||||
rs_encode(data_size, data_block, ecc_block);
|
||||
rs_free();
|
||||
rs_init_code(&rs, ecc_size, 1);
|
||||
rs_encode(&rs, data_size, data_block, ecc_block);
|
||||
|
||||
/* Correct error correction data but in reverse order */
|
||||
for (j = 0; j < data_size; j++) {
|
||||
@ -922,15 +996,17 @@ static void place_layer_id(char* grid, int size, int layers, int modules, int ec
|
||||
}
|
||||
}
|
||||
|
||||
INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], size_t length) {
|
||||
INTERNAL int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int size, modules, error_number;
|
||||
int auto_layers, min_layers, layers, auto_ecc_level, min_ecc_level, ecc_level;
|
||||
int x, y, i;
|
||||
int full_multibyte;
|
||||
char binary[9300];
|
||||
int data_cw, input_latch = 0;
|
||||
unsigned char word[1460];
|
||||
unsigned char word[1460] = {0};
|
||||
int data_max, reader = 0;
|
||||
int size_squared;
|
||||
int bin_len;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
unsigned int gbdata[length + 1];
|
||||
@ -939,11 +1015,8 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
unsigned int* gbdata = (unsigned int *) _alloca((length + 1) * sizeof (unsigned int));
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 1460; i++) {
|
||||
word[i] = 0;
|
||||
}
|
||||
|
||||
full_multibyte = symbol->option_3 == ZINT_FULL_MULTIBYTE; /* If set use Hanzi mode in DATA_MODE or for single-byte Latin */
|
||||
/* If ZINT_FULL_MULTIBYTE set use Hanzi mode in DATA_MODE or for single-byte Latin */
|
||||
full_multibyte = (symbol->option_3 & 0xFF) == ZINT_FULL_MULTIBYTE;
|
||||
|
||||
if ((symbol->input_mode & 0x07) == DATA_MODE) {
|
||||
gb2312_cpy(source, &length, gbdata, full_multibyte);
|
||||
@ -951,7 +1024,8 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
int done = 0;
|
||||
if (symbol->eci != 29) { /* Unless ECI 29 (GB) */
|
||||
/* Try single byte (Latin) conversion first */
|
||||
int error_number = gb2312_utf8tosb(symbol->eci && symbol->eci <= 899 ? symbol->eci : 3, source, &length, gbdata, full_multibyte);
|
||||
error_number = gb2312_utf8tosb(symbol->eci && symbol->eci <= 899 ? symbol->eci : 3, source, &length,
|
||||
gbdata, full_multibyte);
|
||||
if (error_number == 0) {
|
||||
done = 1;
|
||||
} else if (symbol->eci && symbol->eci <= 899) {
|
||||
@ -961,7 +1035,7 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
}
|
||||
if (!done) {
|
||||
/* Try GB 2312 (EUC-CN) */
|
||||
int error_number = gb2312_utf8tomb(symbol, source, &length, gbdata);
|
||||
error_number = gb2312_utf8tomb(symbol, source, &length, gbdata);
|
||||
if (error_number != 0) {
|
||||
return error_number;
|
||||
}
|
||||
@ -975,14 +1049,14 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
||||
error_number = gm_encode(gbdata, length, binary, reader, symbol->eci, symbol->debug);
|
||||
error_number = gm_encode(gbdata, length, binary, reader, symbol->eci, &bin_len, symbol->debug);
|
||||
if (error_number != 0) {
|
||||
strcpy(symbol->errtxt, "531: Input data too long");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Determine the size of the symbol */
|
||||
data_cw = (int)strlen(binary) / 7;
|
||||
data_cw = bin_len / 7; /* Binary length always a multiple of 7 */
|
||||
|
||||
auto_layers = 13;
|
||||
for (i = 12; i > 0; i--) {
|
||||
@ -1011,8 +1085,7 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
auto_ecc_level = 3;
|
||||
if (layers == 1) {
|
||||
auto_ecc_level = 5;
|
||||
}
|
||||
if ((layers == 2) || (layers == 3)) {
|
||||
} else if ((layers == 2) || (layers == 3)) {
|
||||
auto_ecc_level = 4;
|
||||
}
|
||||
ecc_level = auto_ecc_level;
|
||||
@ -1020,8 +1093,7 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
min_ecc_level = 1;
|
||||
if (layers == 1) {
|
||||
min_ecc_level = 4;
|
||||
}
|
||||
if (layers == 2) {
|
||||
} else if (layers == 2) {
|
||||
min_ecc_level = 2;
|
||||
}
|
||||
|
||||
@ -1033,7 +1105,8 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
}
|
||||
}
|
||||
if (data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)]) {
|
||||
if (input_latch && ecc_level > min_ecc_level) { /* If layers user-specified (option_2), try reducing ECC level first */
|
||||
/* If layers user-specified (option_2), try reducing ECC level first */
|
||||
if (input_latch && ecc_level > min_ecc_level) {
|
||||
do {
|
||||
ecc_level--;
|
||||
} while ((data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)]) && (ecc_level > min_ecc_level));
|
||||
@ -1041,7 +1114,8 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
while (data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)] && (layers < 13)) {
|
||||
layers++;
|
||||
}
|
||||
while (data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)] && ecc_level > 1) { /* ECC min level 1 for layers > 2 */
|
||||
/* ECC min level 1 for layers > 2 */
|
||||
while (data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)] && ecc_level > 1) {
|
||||
ecc_level--;
|
||||
}
|
||||
}
|
||||
@ -1069,18 +1143,15 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
|
||||
#endif
|
||||
size = 6 + (layers * 12);
|
||||
modules = 1 + (layers * 2);
|
||||
size_squared = size * size;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
char grid[size * size];
|
||||
char grid[size_squared];
|
||||
#else
|
||||
grid = (char *) _alloca((size * size) * sizeof (char));
|
||||
grid = (char *) _alloca(size_squared * sizeof(char));
|
||||
#endif
|
||||
|
||||
for (x = 0; x < size; x++) {
|
||||
for (y = 0; y < size; y++) {
|
||||
grid[(y * size) + x] = '0';
|
||||
}
|
||||
}
|
||||
memset(grid, '0', size_squared);
|
||||
|
||||
place_data_in_grid(word, grid, modules, size);
|
||||
place_layer_id(grid, size, layers, modules, ecc_level);
|
||||
|
1026
backend/hanxin.c
@ -115,8 +115,8 @@ void ZBarcode_Delete(struct zint_symbol *symbol) {
|
||||
free(symbol);
|
||||
}
|
||||
|
||||
INTERNAL int get_best_eci(unsigned char source[], size_t length); /* Calculate suitable ECI mode */
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */
|
||||
INTERNAL int get_best_eci(unsigned char source[], int length); /* Calculate suitable ECI mode */
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *length); /* Convert Unicode to other encodings */
|
||||
|
||||
INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN system barcodes */
|
||||
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Code 3 from 9 (or Code 39) */
|
||||
@ -157,29 +157,29 @@ INTERNAL int rsslimited(struct zint_symbol *symbol, unsigned char source[], int
|
||||
INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS Expanded */
|
||||
INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int length); /* Composite Symbology */
|
||||
INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int length); /* TNT KIX Code */
|
||||
INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Aztec Code */
|
||||
INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Code */
|
||||
INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int length); /* Italian Pharmacode */
|
||||
INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int length); /* DAFT Code */
|
||||
INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-14 */
|
||||
INTERNAL int nve_18(struct zint_symbol *symbol, unsigned char source[], int length); /* NVE-18 */
|
||||
INTERNAL int microqr(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* Micro QR Code */
|
||||
INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int length); /* Micro QR Code */
|
||||
INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Runes */
|
||||
INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Korea Post */
|
||||
INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Japanese Post */
|
||||
INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], const int length); /* Code 49 */
|
||||
INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], int length); /* Channel Code */
|
||||
INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int length); /* Code One */
|
||||
INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* Grid Matrix */
|
||||
INTERNAL int han_xin(struct zint_symbol * symbol, const unsigned char source[], size_t length); /* Han Xin */
|
||||
INTERNAL int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Grid Matrix */
|
||||
INTERNAL int han_xin(struct zint_symbol * symbol, unsigned char source[], int length); /* Han Xin */
|
||||
INTERNAL int dotcode(struct zint_symbol * symbol, const unsigned char source[], int length); /* DotCode */
|
||||
INTERNAL int codablock(struct zint_symbol * symbol, const unsigned char source[], const size_t length); /* Codablock */
|
||||
INTERNAL int upnqr(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* UPNQR */
|
||||
INTERNAL int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* QR Code */
|
||||
INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int length); /* UPNQR */
|
||||
INTERNAL int qr_code(struct zint_symbol *symbol, unsigned char source[], int length); /* QR Code */
|
||||
INTERNAL int dmatrix(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* Data Matrix (IEC16022) */
|
||||
INTERNAL int vin(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* VIN Code (Vehicle Identification Number) */
|
||||
INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* Royal Mail 4-state Mailmark */
|
||||
INTERNAL int ultracode(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* Ultracode */
|
||||
INTERNAL int rmqr(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* rMQR */
|
||||
INTERNAL int rmqr(struct zint_symbol *symbol, unsigned char source[], int in_length); /* rMQR */
|
||||
INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int length); /* DPD Code */
|
||||
|
||||
INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to PNG/BMP/PCX */
|
||||
@ -261,8 +261,8 @@ static int dump_plot(struct zint_symbol *symbol) {
|
||||
}
|
||||
|
||||
/* Process health industry bar code data */
|
||||
static int hibc(struct zint_symbol *symbol, unsigned char source[], size_t length) {
|
||||
size_t i;
|
||||
static int hibc(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i;
|
||||
int counter, error_number;
|
||||
char to_process[113], check_digit;
|
||||
|
||||
@ -669,6 +669,15 @@ unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cap_flag & ZINT_CAP_MASK) {
|
||||
switch (symbol_id) {
|
||||
case BARCODE_QRCODE:
|
||||
case BARCODE_MICROQR:
|
||||
case BARCODE_HANXIN:
|
||||
result |= ZINT_CAP_MASK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -700,7 +709,7 @@ int ZBarcode_ValidID(int symbol_id) {
|
||||
return ids[symbol_id] != 0;
|
||||
}
|
||||
|
||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, size_t in_length);
|
||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int in_length);
|
||||
|
||||
static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char *source, const int length) {
|
||||
int error_number = 0;
|
||||
@ -726,7 +735,7 @@ static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char
|
||||
return error_number;
|
||||
}
|
||||
|
||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, size_t in_length) {
|
||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int in_length) {
|
||||
/* These are the "norm" standards which only support Latin-1 at most, though a few support ECI */
|
||||
int error_number = 0;
|
||||
unsigned char *preprocessed = source;
|
||||
|
@ -144,6 +144,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
|
||||
int check_count;
|
||||
int i, j, len;
|
||||
int length = (int) in_length;
|
||||
rs_t rs;
|
||||
|
||||
if (length > 26) {
|
||||
strcpy(symbol->errtxt, "580: Input too long");
|
||||
@ -402,10 +403,9 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
|
||||
}
|
||||
|
||||
// Generation of Reed-Solomon Check Numbers
|
||||
rs_init_gf(0x25);
|
||||
rs_init_code(check_count, 1);
|
||||
rs_encode((data_top + 1), data, check);
|
||||
rs_free();
|
||||
rs_init_gf(&rs, 0x25);
|
||||
rs_init_code(&rs, check_count, 1);
|
||||
rs_encode(&rs, (data_top + 1), data, check);
|
||||
|
||||
// Append check digits to data
|
||||
for (i = 1; i <= check_count; i++) {
|
||||
|
@ -43,18 +43,18 @@ static void maxi_do_primary_check(int maxi_codeword[144]) {
|
||||
int j;
|
||||
int datalen = 10;
|
||||
int ecclen = 10;
|
||||
rs_t rs;
|
||||
|
||||
rs_init_gf(0x43);
|
||||
rs_init_code(ecclen, 1);
|
||||
rs_init_gf(&rs, 0x43);
|
||||
rs_init_code(&rs, ecclen, 1);
|
||||
|
||||
for (j = 0; j < datalen; j += 1)
|
||||
data[j] = maxi_codeword[j];
|
||||
|
||||
rs_encode(datalen, data, results);
|
||||
rs_encode(&rs, datalen, data, results);
|
||||
|
||||
for (j = 0; j < ecclen; j += 1)
|
||||
maxi_codeword[ datalen + j] = results[ecclen - 1 - j];
|
||||
rs_free();
|
||||
}
|
||||
|
||||
/* Handles error correction of odd characters in secondary */
|
||||
@ -63,9 +63,10 @@ static void maxi_do_secondary_chk_odd(int maxi_codeword[144], int ecclen) {
|
||||
unsigned char results[30];
|
||||
int j;
|
||||
int datalen = 68;
|
||||
rs_t rs;
|
||||
|
||||
rs_init_gf(0x43);
|
||||
rs_init_code(ecclen, 1);
|
||||
rs_init_gf(&rs, 0x43);
|
||||
rs_init_code(&rs, ecclen, 1);
|
||||
|
||||
if (ecclen == 20)
|
||||
datalen = 84;
|
||||
@ -74,11 +75,10 @@ static void maxi_do_secondary_chk_odd(int maxi_codeword[144], int ecclen) {
|
||||
if (j & 1) // odd
|
||||
data[(j - 1) / 2] = maxi_codeword[j + 20];
|
||||
|
||||
rs_encode(datalen / 2, data, results);
|
||||
rs_encode(&rs, datalen / 2, data, results);
|
||||
|
||||
for (j = 0; j < (ecclen); j += 1)
|
||||
maxi_codeword[ datalen + (2 * j) + 1 + 20 ] = results[ecclen - 1 - j];
|
||||
rs_free();
|
||||
}
|
||||
|
||||
/* Handles error correction of even characters in secondary */
|
||||
@ -87,22 +87,22 @@ static void maxi_do_secondary_chk_even(int maxi_codeword[144], int ecclen) {
|
||||
unsigned char results[30];
|
||||
int j;
|
||||
int datalen = 68;
|
||||
rs_t rs;
|
||||
|
||||
if (ecclen == 20)
|
||||
datalen = 84;
|
||||
|
||||
rs_init_gf(0x43);
|
||||
rs_init_code(ecclen, 1);
|
||||
rs_init_gf(&rs, 0x43);
|
||||
rs_init_code(&rs, ecclen, 1);
|
||||
|
||||
for (j = 0; j < datalen + 1; j += 1)
|
||||
if (!(j & 1)) // even
|
||||
data[j / 2] = maxi_codeword[j + 20];
|
||||
|
||||
rs_encode(datalen / 2, data, results);
|
||||
rs_encode(&rs, datalen / 2, data, results);
|
||||
|
||||
for (j = 0; j < (ecclen); j += 1)
|
||||
maxi_codeword[ datalen + (2 * j) + 20] = results[ecclen - 1 - j];
|
||||
rs_free();
|
||||
}
|
||||
|
||||
/* Moves everything up so that a shift or latch can be inserted */
|
||||
|
@ -196,10 +196,10 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
/* Pixel Plotting */
|
||||
incr = use_alpha ? 4 : 3;
|
||||
for (row = 0; row < symbol->bitmap_height; row++) {
|
||||
int p = symbol->bitmap_width * row;
|
||||
unsigned char *pb = pixelbuf + symbol->bitmap_width * row;
|
||||
image_data = outdata;
|
||||
for (column = 0; column < symbol->bitmap_width; column++, p++, image_data += incr) {
|
||||
memcpy(image_data, map[pixelbuf[p]], incr);
|
||||
for (column = 0; column < symbol->bitmap_width; column++, pb++, image_data += incr) {
|
||||
memcpy(image_data, map[*pb], incr);
|
||||
}
|
||||
/* write row contents to file */
|
||||
png_write_row(png_ptr, outdata);
|
||||
|
1215
backend/qr.c
14
backend/qr.h
@ -1,7 +1,7 @@
|
||||
/* qr.h Data for QR Code, Micro QR Code and rMQR
|
||||
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2006 Kentaro Fukuchi <fukuchi@megaui.net>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@ -35,12 +35,20 @@
|
||||
#define LEVEL_Q 3
|
||||
#define LEVEL_H 4
|
||||
|
||||
#define RHODIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"
|
||||
#define QR_PERCENT 38 /* Alphanumeric mode % */
|
||||
|
||||
/* From ISO/IEC 18004:2015 Table 5 Encoding/decoding table for Alphanumeric mode */
|
||||
static const char qr_alphanumeric[59] = {
|
||||
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, /* SP-/ */
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, /* 0-? */
|
||||
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, /* @-O */
|
||||
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 /* P-Z */
|
||||
};
|
||||
|
||||
#define RMQR_VERSION 100
|
||||
#define MICROQR_VERSION 200
|
||||
|
||||
/* From ISO/IEC 18004:2006 Table 7 */
|
||||
/* From ISO/IEC 18004:2015 Table 7 */
|
||||
static const unsigned short int qr_data_codewords_L[] = {
|
||||
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,
|
||||
|
@ -82,7 +82,7 @@ static int buffer_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
|
||||
NULL, blue, cyan, NULL, NULL, NULL, green, NULL, NULL, NULL, black, NULL, magenta, /* A-M */
|
||||
NULL, NULL, NULL, NULL, red, NULL, NULL, NULL, NULL, white, NULL, yellow, NULL /* N-Z */
|
||||
};
|
||||
int row, column, p;
|
||||
int row, column;
|
||||
int plot_alpha = 0;
|
||||
unsigned char *bitmap;
|
||||
|
||||
@ -130,7 +130,7 @@ static int buffer_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
for (row = 0; row < symbol->bitmap_height; row++) {
|
||||
p = row * symbol->bitmap_width;
|
||||
int p = row * symbol->bitmap_width;
|
||||
bitmap = symbol->bitmap + p * 3;
|
||||
for (column = 0; column < symbol->bitmap_width; column++, p++, bitmap += 3) {
|
||||
memcpy(bitmap, map[pixelbuf[p]], 3);
|
||||
@ -139,10 +139,11 @@ static int buffer_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
|
||||
}
|
||||
} else {
|
||||
for (row = 0; row < symbol->bitmap_height; row++) {
|
||||
p = row * symbol->bitmap_width;
|
||||
bitmap = symbol->bitmap + p * 3;
|
||||
for (column = 0; column < symbol->bitmap_width; column++, p++, bitmap += 3) {
|
||||
memcpy(bitmap, map[pixelbuf[p]], 3);
|
||||
int r = row * symbol->bitmap_width;
|
||||
unsigned char *pb = pixelbuf + r;
|
||||
bitmap = symbol->bitmap + r * 3;
|
||||
for (column = 0; column < symbol->bitmap_width; column++, pb++, bitmap += 3) {
|
||||
memcpy(bitmap, map[*pb], 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -470,7 +471,6 @@ static void draw_string(unsigned char *pixbuf, unsigned char input_string[], int
|
||||
if (odd_si) {
|
||||
x_incr += i * letter_width / 2;
|
||||
}
|
||||
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) suppress (probable) false positive about 2nd arg input_string[i] being uninitialized
|
||||
draw_letter(pixbuf, input_string[i], string_left_hand + x_incr, yposn, textflags, image_width, image_height, si);
|
||||
}
|
||||
}
|
||||
@ -1063,7 +1063,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
|
||||
}
|
||||
|
||||
if (!textdone) {
|
||||
unsigned char local_text[sizeof(symbol->text)];
|
||||
unsigned char local_text[sizeof(symbol->text)] = {0}; /* Suppress clang-analyzer-core.CallAndMessage warning */
|
||||
to_iso8859_1(symbol->text, local_text);
|
||||
/* Put the human readable text at the bottom */
|
||||
textpos = (main_width / 2 + xoffset) * si;
|
||||
|
@ -37,9 +37,9 @@
|
||||
// <Some notes on the theory and implementation need to be added here>
|
||||
|
||||
// Usage:
|
||||
// First call rs_init_gf(poly) to set up the Galois Field parameters.
|
||||
// Then call rs_init_code(size, index) to set the encoding size
|
||||
// Then call rs_encode(datasize, data, out) to encode the data.
|
||||
// First call rs_init_gf(&rs, prime_poly) to set up the Galois Field parameters.
|
||||
// Then call rs_init_code(&rs, nsym, index) to set the encoding size
|
||||
// Then call rs_encode(&rs, datalen, data, out) to encode the data.
|
||||
//
|
||||
// These can be called repeatedly as required - but note that
|
||||
// rs_init_code must be called following any rs_init_gf call.
|
||||
@ -48,129 +48,220 @@
|
||||
// replaced with constants in the obvious way, and additionally
|
||||
// malloc/free can be avoided by using static arrays of a suitable
|
||||
// size.
|
||||
// Note: use of statics has been done for (up to) 8-bit tables.
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include "common.h"
|
||||
#include "reedsol.h"
|
||||
static int logmod; // 2**symsize - 1
|
||||
static int rlen;
|
||||
#include "reedsol_logs.h"
|
||||
|
||||
static int *logt = NULL, *alog = NULL, *rspoly = NULL;
|
||||
|
||||
// rs_init_gf(poly) initialises the parameters for the Galois Field.
|
||||
// rs_init_gf(&rs, prime_poly) initialises the parameters for the Galois Field.
|
||||
// The symbol size is determined from the highest bit set in poly
|
||||
// This implementation will support sizes up to 30 bits (though that
|
||||
// will result in very large log/antilog tables) - bit sizes of
|
||||
// 8 or 4 are typical
|
||||
// This implementation will support sizes up to 8 bits (see rs_unit_init_gf()
|
||||
// for sizes > 8 bits and <= 30 bits) - bit sizes of 8 or 4 are typical
|
||||
//
|
||||
// The poly is the bit pattern representing the GF characteristic
|
||||
// polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is
|
||||
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
|
||||
|
||||
INTERNAL void rs_init_gf(const int poly) {
|
||||
int m, b, p, v;
|
||||
INTERNAL void rs_init_gf(rs_t *rs, const unsigned int prime_poly) {
|
||||
struct item {
|
||||
const unsigned char *logt;
|
||||
const unsigned char *alog;
|
||||
};
|
||||
/* To add a new prime poly of degree <= 8 add its details to this table and to the table in `test_generate()`
|
||||
* in "backend/tests/test_reedsol.c" and regenerate the log tables by running "./test_reedsol -f generate -g".
|
||||
* Paste the result in "reedsol_logs.h" */
|
||||
static const struct item data[] = {
|
||||
{ logt_0x13, alog_0x13 }, /* 0 000- */
|
||||
{ logt_0x25, alog_0x25 }, /* 0 001- */
|
||||
{ logt_0x43, alog_0x43 }, /* 0 010- */
|
||||
{ NULL, NULL },
|
||||
{ logt_0x89, alog_0x89 }, /* 0 100- */
|
||||
{ NULL, NULL },
|
||||
{ NULL, NULL },
|
||||
{ NULL, NULL },
|
||||
{ logt_0x11d, alog_0x11d }, /* 1 000- */
|
||||
{ logt_0x12d, alog_0x12d }, /* 1 001- */
|
||||
{ NULL, NULL },
|
||||
{ logt_0x163, alog_0x163 }, /* 1 011- */
|
||||
};
|
||||
|
||||
// Suppress clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning
|
||||
assert(poly >= 2);
|
||||
/* Using bits 9-6 as hash to save a few cycles */
|
||||
/* Alter this hash or just iterate if new prime poly added that doesn't fit */
|
||||
unsigned int hash = prime_poly >> 5;
|
||||
|
||||
// Find the top bit, and hence the symbol size
|
||||
for (b = 1, m = 0; b <= poly; b <<= 1)
|
||||
m++;
|
||||
b >>= 1;
|
||||
m--;
|
||||
|
||||
// Ensure m not negative to supress gcc -Walloc-size-larger-than
|
||||
if (m < 0) {
|
||||
m = 0;
|
||||
}
|
||||
|
||||
// Calculate the log/alog tables
|
||||
logmod = (1 << m) - 1;
|
||||
logt = (int *) malloc(sizeof (int) * (logmod + 1));
|
||||
alog = (int *) malloc(sizeof (int) * logmod);
|
||||
|
||||
for (p = 1, v = 0; v < logmod; v++) {
|
||||
alog[v] = p;
|
||||
logt[p] = v;
|
||||
p <<= 1;
|
||||
if (p & b)
|
||||
p ^= poly;
|
||||
}
|
||||
rs->logt = data[hash].logt;
|
||||
rs->alog = data[hash].alog;
|
||||
}
|
||||
|
||||
// rs_init_code(nsym, index) initialises the Reed-Solomon encoder
|
||||
// rs_init_code(&rs, nsym, index) initialises the Reed-Solomon encoder
|
||||
// nsym is the number of symbols to be generated (to be appended
|
||||
// to the input data). index is usually 1 - it is the index of
|
||||
// the constant in the first term (i) of the RS generator polynomial:
|
||||
// (x + 2**i)*(x + 2**(i+1))*... [nsym terms]
|
||||
// For ECC200, index is 1.
|
||||
|
||||
INTERNAL void rs_init_code(const int nsym, int index) {
|
||||
#include <stdio.h>
|
||||
INTERNAL void rs_init_code(rs_t *rs, const int nsym, int index) {
|
||||
int i, k;
|
||||
const unsigned char *logt = rs->logt;
|
||||
const unsigned char *alog = rs->alog;
|
||||
unsigned char *rspoly = rs->rspoly;
|
||||
|
||||
rspoly = (int *) malloc(sizeof (int) * (nsym + 1));
|
||||
|
||||
rlen = nsym;
|
||||
rs->nsym = nsym;
|
||||
|
||||
rspoly[0] = 1;
|
||||
for (i = 1; i <= nsym; i++) {
|
||||
rspoly[i] = 1;
|
||||
for (k = i - 1; k > 0; k--) {
|
||||
if (rspoly[k])
|
||||
rspoly[k] = alog[(logt[rspoly[k]] + index) % logmod];
|
||||
rspoly[k] ^= rspoly[k - 1];
|
||||
rspoly[k] = alog[logt[rspoly[k]] + index]; /* Multiply coeff by 2**index */
|
||||
rspoly[k] ^= rspoly[k - 1]; /* Add coeff of x**(k-1) * x */
|
||||
}
|
||||
rspoly[0] = alog[(logt[rspoly[0]] + index) % logmod];
|
||||
rspoly[0] = alog[logt[rspoly[0]] + index]; /* 2**(i + (i+1) + ... + index) */
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
INTERNAL void rs_encode(const size_t len, const unsigned char *data, unsigned char *res) {
|
||||
/* rs_encode(&rs, datalen, data, res) generates nsym Reed-Solomon codes (nsym as given in rs_init_code())
|
||||
* and places them in reverse order in res */
|
||||
|
||||
INTERNAL void rs_encode(const rs_t *rs, const int datalen, const unsigned char *data, unsigned char *res) {
|
||||
int i, k;
|
||||
for (i = 0; i < rlen; i++)
|
||||
res[i] = 0;
|
||||
for (i = 0; i < (int) len; i++) {
|
||||
int m = res[rlen - 1] ^ data[i];
|
||||
for (k = rlen - 1; k > 0; k--) {
|
||||
if (m && rspoly[k])
|
||||
res[k] = (unsigned char) (res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod]);
|
||||
else
|
||||
res[k] = res[k - 1];
|
||||
}
|
||||
if (m && rspoly[0])
|
||||
res[0] = (unsigned char) (alog[(logt[m] + logt[rspoly[0]]) % logmod]);
|
||||
else
|
||||
const unsigned char *logt = rs->logt;
|
||||
const unsigned char *alog = rs->alog;
|
||||
const unsigned char *rspoly = rs->rspoly;
|
||||
const int nsym = rs->nsym;
|
||||
|
||||
memset(res, 0, nsym);
|
||||
for (i = 0; i < datalen; i++) {
|
||||
unsigned int m = res[nsym - 1] ^ data[i];
|
||||
if (m) {
|
||||
unsigned int log_m = logt[m];
|
||||
for (k = nsym - 1; k > 0; k--) {
|
||||
if (rspoly[k])
|
||||
res[k] = (unsigned char) (res[k - 1] ^ alog[log_m + logt[rspoly[k]]]);
|
||||
else
|
||||
res[k] = res[k - 1];
|
||||
}
|
||||
res[0] = alog[log_m + logt[rspoly[0]]]; /* rspoly[0] can't be zero */
|
||||
} else {
|
||||
memmove(res + 1, res, nsym - 1);
|
||||
res[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The same as above but for larger bitlengths - Aztec code compatible */
|
||||
INTERNAL void rs_encode_long(const int len, const unsigned int *data, unsigned int *res) {
|
||||
/* The same as above but for unsigned int data and result - Aztec code compatible */
|
||||
|
||||
INTERNAL void rs_encode_uint(const rs_t *rs, const int datalen, const unsigned int *data, unsigned int *res) {
|
||||
int i, k;
|
||||
for (i = 0; i < rlen; i++)
|
||||
res[i] = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
int m = res[rlen - 1] ^ data[i];
|
||||
for (k = rlen - 1; k > 0; k--) {
|
||||
if (m && rspoly[k])
|
||||
res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod];
|
||||
else
|
||||
res[k] = res[k - 1];
|
||||
}
|
||||
if (m && rspoly[0])
|
||||
res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod];
|
||||
else
|
||||
const unsigned char *logt = rs->logt;
|
||||
const unsigned char *alog = rs->alog;
|
||||
const unsigned char *rspoly = rs->rspoly;
|
||||
const int nsym = rs->nsym;
|
||||
|
||||
memset(res, 0, sizeof(unsigned int) * nsym);
|
||||
for (i = 0; i < datalen; i++) {
|
||||
unsigned int m = res[nsym - 1] ^ data[i];
|
||||
if (m) {
|
||||
unsigned int log_m = logt[m];
|
||||
for (k = nsym - 1; k > 0; k--) {
|
||||
if (rspoly[k])
|
||||
res[k] = res[k - 1] ^ alog[log_m + logt[rspoly[k]]];
|
||||
else
|
||||
res[k] = res[k - 1];
|
||||
}
|
||||
res[0] = alog[log_m + logt[rspoly[0]]];
|
||||
} else {
|
||||
memmove(res + 1, res, sizeof(unsigned int) * (nsym - 1));
|
||||
res[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Free memory */
|
||||
INTERNAL void rs_free(void) {
|
||||
free(logt);
|
||||
free(alog);
|
||||
free(rspoly);
|
||||
rspoly = NULL;
|
||||
/* Versions of the above for bitlengths > 8 and <= 30 and unsigned int data and results - Aztec code compatible */
|
||||
|
||||
// Usage:
|
||||
// First call rs_uint_init_gf(&rs_uint, prime_poly, logmod) to set up the Galois Field parameters.
|
||||
// Then call rs_uint_init_code(&rs_uint, nsym, index) to set the encoding size
|
||||
// Then call rs_uint_encode(&rs_uint, datalen, data, out) to encode the data.
|
||||
// Then call rs_uint_free(&rs_uint) to free the log tables.
|
||||
|
||||
/* `logmod` (field characteristic) will be 2**bitlength - 1, eg 1023 for bitlength 10, 4095 for bitlength 12 */
|
||||
INTERNAL void rs_uint_init_gf(rs_uint_t *rs_uint, const unsigned int prime_poly, const int logmod) {
|
||||
int b, p, v;
|
||||
unsigned int *logt, *alog;
|
||||
|
||||
b = logmod + 1;
|
||||
|
||||
logt = (unsigned int *) malloc(sizeof(unsigned int) * b);
|
||||
alog = (unsigned int *) malloc(sizeof(unsigned int) * b * 2);
|
||||
|
||||
// Calculate the log/alog tables
|
||||
for (p = 1, v = 0; v < logmod; v++) {
|
||||
alog[v] = p;
|
||||
alog[logmod + v] = p; /* Double up, avoids mod */
|
||||
logt[p] = v;
|
||||
p <<= 1;
|
||||
if (p & b) /* If overflow */
|
||||
p ^= prime_poly; /* Subtract prime poly */
|
||||
}
|
||||
rs_uint->logt = logt;
|
||||
rs_uint->alog = alog;
|
||||
}
|
||||
|
||||
INTERNAL void rs_uint_init_code(rs_uint_t *rs_uint, const int nsym, int index) {
|
||||
int i, k;
|
||||
const unsigned int *logt = rs_uint->logt;
|
||||
const unsigned int *alog = rs_uint->alog;
|
||||
unsigned short *rspoly = rs_uint->rspoly;
|
||||
|
||||
rs_uint->nsym = nsym;
|
||||
|
||||
rspoly[0] = 1;
|
||||
for (i = 1; i <= nsym; i++) {
|
||||
rspoly[i] = 1;
|
||||
for (k = i - 1; k > 0; k--) {
|
||||
if (rspoly[k])
|
||||
rspoly[k] = alog[(logt[rspoly[k]] + index)];
|
||||
rspoly[k] ^= rspoly[k - 1];
|
||||
}
|
||||
rspoly[0] = alog[(logt[rspoly[0]] + index)];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
INTERNAL void rs_uint_encode(const rs_uint_t *rs_uint, const int datalen, const unsigned int *data, unsigned int *res) {
|
||||
int i, k;
|
||||
const unsigned int *logt = rs_uint->logt;
|
||||
const unsigned int *alog = rs_uint->alog;
|
||||
const unsigned short *rspoly = rs_uint->rspoly;
|
||||
const int nsym = rs_uint->nsym;
|
||||
|
||||
memset(res, 0, sizeof(unsigned int) * nsym);
|
||||
for (i = 0; i < datalen; i++) {
|
||||
unsigned int m = res[nsym - 1] ^ data[i];
|
||||
if (m) {
|
||||
unsigned int log_m = logt[m];
|
||||
for (k = nsym - 1; k > 0; k--) {
|
||||
if (rspoly[k])
|
||||
res[k] = res[k - 1] ^ alog[log_m + logt[rspoly[k]]];
|
||||
else
|
||||
res[k] = res[k - 1];
|
||||
}
|
||||
res[0] = alog[log_m + logt[rspoly[0]]];
|
||||
} else {
|
||||
memmove(res + 1, res, sizeof(unsigned int) * (nsym - 1));
|
||||
res[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INTERNAL void rs_uint_free(rs_uint_t *rs_uint) {
|
||||
free(rs_uint->logt);
|
||||
free(rs_uint->alog);
|
||||
}
|
||||
|
@ -38,14 +38,33 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INTERNAL void rs_init_gf(const int poly);
|
||||
INTERNAL void rs_init_code(const int nsym,int index);
|
||||
INTERNAL void rs_encode(const size_t len,const unsigned char *data, unsigned char *res);
|
||||
INTERNAL void rs_encode_long(const int len,const unsigned int *data, unsigned int *res);
|
||||
INTERNAL void rs_free(void);
|
||||
typedef struct {
|
||||
const unsigned char *logt; /* These are static */
|
||||
const unsigned char *alog;
|
||||
unsigned char rspoly[256];
|
||||
int nsym;
|
||||
} rs_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int *logt; /* These are malloced */
|
||||
unsigned int *alog;
|
||||
unsigned short rspoly[4096]; /* 12-bit max - needs to be enlarged if > 12-bit used */
|
||||
int nsym;
|
||||
} rs_uint_t;
|
||||
|
||||
INTERNAL void rs_init_gf(rs_t *rs, const unsigned int prime_poly);
|
||||
INTERNAL void rs_init_code(rs_t *rs, const int nsym, int index);
|
||||
INTERNAL void rs_encode(const rs_t *rs, const int datalen, const unsigned char *data, unsigned char *res);
|
||||
INTERNAL void rs_encode_uint(const rs_t *rs, const int datalen, const unsigned int *data, unsigned int *res);
|
||||
/* No free needed as log tables static */
|
||||
|
||||
INTERNAL void rs_uint_init_gf(rs_uint_t *rs_uint, const unsigned int prime_poly, const int logmod);
|
||||
INTERNAL void rs_uint_init_code(rs_uint_t *rs_uint, const int nsym, int index);
|
||||
INTERNAL void rs_uint_encode(const rs_uint_t *rs_uint, const int datalen, const unsigned int *data, unsigned int *res);
|
||||
INTERNAL void rs_uint_free(rs_uint_t *rs_uint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __REEDSOL_H */
|
||||
#endif /* __REEDSOL_H */
|
||||
|
264
backend/reedsol_logs.h
Normal file
@ -0,0 +1,264 @@
|
||||
/* reedsol_logs.h - Log and antilog tables for Reed-Solomon
|
||||
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
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
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
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
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#ifndef REEDSOL_LOGS_H
|
||||
#define REEDSOL_LOGS_H
|
||||
|
||||
/* Static log/antilog tables for prime polys of up to degree 8 (> 8 too large so generated at runtime instead).
|
||||
* Antilog tables doubled to avoid mod. */
|
||||
|
||||
/* Paste output of "./test_reedsol -f generate -g" here */
|
||||
static const unsigned char logt_0x13[16] = {
|
||||
0x00, 0x00, 0x01, 0x04, 0x02, 0x08, 0x05, 0x0A, 0x03, 0x0E, 0x09, 0x07, 0x06, 0x0D, 0x0B, 0x0C,
|
||||
};
|
||||
static const unsigned char alog_0x13[30] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0C, 0x0B, 0x05, 0x0A, 0x07, 0x0E, 0x0F, 0x0D, 0x09,
|
||||
0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0C, 0x0B, 0x05, 0x0A, 0x07, 0x0E, 0x0F, 0x0D, 0x09,
|
||||
};
|
||||
|
||||
static const unsigned char logt_0x25[32] = {
|
||||
0x00, 0x00, 0x01, 0x12, 0x02, 0x05, 0x13, 0x0B, 0x03, 0x1D, 0x06, 0x1B, 0x14, 0x08, 0x0C, 0x17,
|
||||
0x04, 0x0A, 0x1E, 0x11, 0x07, 0x16, 0x1C, 0x1A, 0x15, 0x19, 0x09, 0x10, 0x0D, 0x0E, 0x18, 0x0F,
|
||||
};
|
||||
static const unsigned char alog_0x25[62] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x05, 0x0A, 0x14, 0x0D, 0x1A, 0x11, 0x07, 0x0E, 0x1C, 0x1D, 0x1F,
|
||||
0x1B, 0x13, 0x03, 0x06, 0x0C, 0x18, 0x15, 0x0F, 0x1E, 0x19, 0x17, 0x0B, 0x16, 0x09, 0x12,
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x05, 0x0A, 0x14, 0x0D, 0x1A, 0x11, 0x07, 0x0E, 0x1C, 0x1D, 0x1F,
|
||||
0x1B, 0x13, 0x03, 0x06, 0x0C, 0x18, 0x15, 0x0F, 0x1E, 0x19, 0x17, 0x0B, 0x16, 0x09, 0x12,
|
||||
};
|
||||
|
||||
static const unsigned char logt_0x43[64] = {
|
||||
0x00, 0x00, 0x01, 0x06, 0x02, 0x0C, 0x07, 0x1A, 0x03, 0x20, 0x0D, 0x23, 0x08, 0x30, 0x1B, 0x12,
|
||||
0x04, 0x18, 0x21, 0x10, 0x0E, 0x34, 0x24, 0x36, 0x09, 0x2D, 0x31, 0x26, 0x1C, 0x29, 0x13, 0x38,
|
||||
0x05, 0x3E, 0x19, 0x0B, 0x22, 0x1F, 0x11, 0x2F, 0x0F, 0x17, 0x35, 0x33, 0x25, 0x2C, 0x37, 0x28,
|
||||
0x0A, 0x3D, 0x2E, 0x1E, 0x32, 0x16, 0x27, 0x2B, 0x1D, 0x3C, 0x2A, 0x15, 0x14, 0x3B, 0x39, 0x3A,
|
||||
};
|
||||
static const unsigned char alog_0x43[126] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x23, 0x05, 0x0A, 0x14, 0x28,
|
||||
0x13, 0x26, 0x0F, 0x1E, 0x3C, 0x3B, 0x35, 0x29, 0x11, 0x22, 0x07, 0x0E, 0x1C, 0x38, 0x33, 0x25,
|
||||
0x09, 0x12, 0x24, 0x0B, 0x16, 0x2C, 0x1B, 0x36, 0x2F, 0x1D, 0x3A, 0x37, 0x2D, 0x19, 0x32, 0x27,
|
||||
0x0D, 0x1A, 0x34, 0x2B, 0x15, 0x2A, 0x17, 0x2E, 0x1F, 0x3E, 0x3F, 0x3D, 0x39, 0x31, 0x21,
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x23, 0x05, 0x0A, 0x14, 0x28,
|
||||
0x13, 0x26, 0x0F, 0x1E, 0x3C, 0x3B, 0x35, 0x29, 0x11, 0x22, 0x07, 0x0E, 0x1C, 0x38, 0x33, 0x25,
|
||||
0x09, 0x12, 0x24, 0x0B, 0x16, 0x2C, 0x1B, 0x36, 0x2F, 0x1D, 0x3A, 0x37, 0x2D, 0x19, 0x32, 0x27,
|
||||
0x0D, 0x1A, 0x34, 0x2B, 0x15, 0x2A, 0x17, 0x2E, 0x1F, 0x3E, 0x3F, 0x3D, 0x39, 0x31, 0x21,
|
||||
};
|
||||
|
||||
static const unsigned char logt_0x89[128] = {
|
||||
0x00, 0x00, 0x01, 0x1F, 0x02, 0x3E, 0x20, 0x67, 0x03, 0x07, 0x3F, 0x0F, 0x21, 0x54, 0x68, 0x5D,
|
||||
0x04, 0x7C, 0x08, 0x79, 0x40, 0x4F, 0x10, 0x73, 0x22, 0x0B, 0x55, 0x26, 0x69, 0x2E, 0x5E, 0x33,
|
||||
0x05, 0x52, 0x7D, 0x3C, 0x09, 0x2C, 0x7A, 0x4D, 0x41, 0x43, 0x50, 0x2A, 0x11, 0x45, 0x74, 0x17,
|
||||
0x23, 0x76, 0x0C, 0x1C, 0x56, 0x19, 0x27, 0x39, 0x6A, 0x13, 0x2F, 0x59, 0x5F, 0x47, 0x34, 0x6E,
|
||||
0x06, 0x0E, 0x53, 0x5C, 0x7E, 0x1E, 0x3D, 0x66, 0x0A, 0x25, 0x2D, 0x32, 0x7B, 0x78, 0x4E, 0x72,
|
||||
0x42, 0x29, 0x44, 0x16, 0x51, 0x3B, 0x2B, 0x4C, 0x12, 0x58, 0x46, 0x6D, 0x75, 0x1B, 0x18, 0x38,
|
||||
0x24, 0x31, 0x77, 0x71, 0x0D, 0x5B, 0x1D, 0x65, 0x57, 0x6C, 0x1A, 0x37, 0x28, 0x15, 0x3A, 0x4B,
|
||||
0x6B, 0x36, 0x14, 0x4A, 0x30, 0x70, 0x5A, 0x64, 0x60, 0x61, 0x48, 0x62, 0x35, 0x49, 0x6F, 0x63,
|
||||
};
|
||||
static const unsigned char alog_0x89[254] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x09, 0x12, 0x24, 0x48, 0x19, 0x32, 0x64, 0x41, 0x0B,
|
||||
0x16, 0x2C, 0x58, 0x39, 0x72, 0x6D, 0x53, 0x2F, 0x5E, 0x35, 0x6A, 0x5D, 0x33, 0x66, 0x45, 0x03,
|
||||
0x06, 0x0C, 0x18, 0x30, 0x60, 0x49, 0x1B, 0x36, 0x6C, 0x51, 0x2B, 0x56, 0x25, 0x4A, 0x1D, 0x3A,
|
||||
0x74, 0x61, 0x4B, 0x1F, 0x3E, 0x7C, 0x71, 0x6B, 0x5F, 0x37, 0x6E, 0x55, 0x23, 0x46, 0x05, 0x0A,
|
||||
0x14, 0x28, 0x50, 0x29, 0x52, 0x2D, 0x5A, 0x3D, 0x7A, 0x7D, 0x73, 0x6F, 0x57, 0x27, 0x4E, 0x15,
|
||||
0x2A, 0x54, 0x21, 0x42, 0x0D, 0x1A, 0x34, 0x68, 0x59, 0x3B, 0x76, 0x65, 0x43, 0x0F, 0x1E, 0x3C,
|
||||
0x78, 0x79, 0x7B, 0x7F, 0x77, 0x67, 0x47, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0x69, 0x5B, 0x3F, 0x7E,
|
||||
0x75, 0x63, 0x4F, 0x17, 0x2E, 0x5C, 0x31, 0x62, 0x4D, 0x13, 0x26, 0x4C, 0x11, 0x22, 0x44,
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x09, 0x12, 0x24, 0x48, 0x19, 0x32, 0x64, 0x41, 0x0B,
|
||||
0x16, 0x2C, 0x58, 0x39, 0x72, 0x6D, 0x53, 0x2F, 0x5E, 0x35, 0x6A, 0x5D, 0x33, 0x66, 0x45, 0x03,
|
||||
0x06, 0x0C, 0x18, 0x30, 0x60, 0x49, 0x1B, 0x36, 0x6C, 0x51, 0x2B, 0x56, 0x25, 0x4A, 0x1D, 0x3A,
|
||||
0x74, 0x61, 0x4B, 0x1F, 0x3E, 0x7C, 0x71, 0x6B, 0x5F, 0x37, 0x6E, 0x55, 0x23, 0x46, 0x05, 0x0A,
|
||||
0x14, 0x28, 0x50, 0x29, 0x52, 0x2D, 0x5A, 0x3D, 0x7A, 0x7D, 0x73, 0x6F, 0x57, 0x27, 0x4E, 0x15,
|
||||
0x2A, 0x54, 0x21, 0x42, 0x0D, 0x1A, 0x34, 0x68, 0x59, 0x3B, 0x76, 0x65, 0x43, 0x0F, 0x1E, 0x3C,
|
||||
0x78, 0x79, 0x7B, 0x7F, 0x77, 0x67, 0x47, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0x69, 0x5B, 0x3F, 0x7E,
|
||||
0x75, 0x63, 0x4F, 0x17, 0x2E, 0x5C, 0x31, 0x62, 0x4D, 0x13, 0x26, 0x4C, 0x11, 0x22, 0x44,
|
||||
};
|
||||
|
||||
static const unsigned char logt_0x11d[256] = {
|
||||
0x00, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1A, 0xC6, 0x03, 0xDF, 0x33, 0xEE, 0x1B, 0x68, 0xC7, 0x4B,
|
||||
0x04, 0x64, 0xE0, 0x0E, 0x34, 0x8D, 0xEF, 0x81, 0x1C, 0xC1, 0x69, 0xF8, 0xC8, 0x08, 0x4C, 0x71,
|
||||
0x05, 0x8A, 0x65, 0x2F, 0xE1, 0x24, 0x0F, 0x21, 0x35, 0x93, 0x8E, 0xDA, 0xF0, 0x12, 0x82, 0x45,
|
||||
0x1D, 0xB5, 0xC2, 0x7D, 0x6A, 0x27, 0xF9, 0xB9, 0xC9, 0x9A, 0x09, 0x78, 0x4D, 0xE4, 0x72, 0xA6,
|
||||
0x06, 0xBF, 0x8B, 0x62, 0x66, 0xDD, 0x30, 0xFD, 0xE2, 0x98, 0x25, 0xB3, 0x10, 0x91, 0x22, 0x88,
|
||||
0x36, 0xD0, 0x94, 0xCE, 0x8F, 0x96, 0xDB, 0xBD, 0xF1, 0xD2, 0x13, 0x5C, 0x83, 0x38, 0x46, 0x40,
|
||||
0x1E, 0x42, 0xB6, 0xA3, 0xC3, 0x48, 0x7E, 0x6E, 0x6B, 0x3A, 0x28, 0x54, 0xFA, 0x85, 0xBA, 0x3D,
|
||||
0xCA, 0x5E, 0x9B, 0x9F, 0x0A, 0x15, 0x79, 0x2B, 0x4E, 0xD4, 0xE5, 0xAC, 0x73, 0xF3, 0xA7, 0x57,
|
||||
0x07, 0x70, 0xC0, 0xF7, 0x8C, 0x80, 0x63, 0x0D, 0x67, 0x4A, 0xDE, 0xED, 0x31, 0xC5, 0xFE, 0x18,
|
||||
0xE3, 0xA5, 0x99, 0x77, 0x26, 0xB8, 0xB4, 0x7C, 0x11, 0x44, 0x92, 0xD9, 0x23, 0x20, 0x89, 0x2E,
|
||||
0x37, 0x3F, 0xD1, 0x5B, 0x95, 0xBC, 0xCF, 0xCD, 0x90, 0x87, 0x97, 0xB2, 0xDC, 0xFC, 0xBE, 0x61,
|
||||
0xF2, 0x56, 0xD3, 0xAB, 0x14, 0x2A, 0x5D, 0x9E, 0x84, 0x3C, 0x39, 0x53, 0x47, 0x6D, 0x41, 0xA2,
|
||||
0x1F, 0x2D, 0x43, 0xD8, 0xB7, 0x7B, 0xA4, 0x76, 0xC4, 0x17, 0x49, 0xEC, 0x7F, 0x0C, 0x6F, 0xF6,
|
||||
0x6C, 0xA1, 0x3B, 0x52, 0x29, 0x9D, 0x55, 0xAA, 0xFB, 0x60, 0x86, 0xB1, 0xBB, 0xCC, 0x3E, 0x5A,
|
||||
0xCB, 0x59, 0x5F, 0xB0, 0x9C, 0xA9, 0xA0, 0x51, 0x0B, 0xF5, 0x16, 0xEB, 0x7A, 0x75, 0x2C, 0xD7,
|
||||
0x4F, 0xAE, 0xD5, 0xE9, 0xE6, 0xE7, 0xAD, 0xE8, 0x74, 0xD6, 0xF4, 0xEA, 0xA8, 0x50, 0x58, 0xAF,
|
||||
};
|
||||
static const unsigned char alog_0x11d[510] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1D, 0x3A, 0x74, 0xE8, 0xCD, 0x87, 0x13, 0x26,
|
||||
0x4C, 0x98, 0x2D, 0x5A, 0xB4, 0x75, 0xEA, 0xC9, 0x8F, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0,
|
||||
0x9D, 0x27, 0x4E, 0x9C, 0x25, 0x4A, 0x94, 0x35, 0x6A, 0xD4, 0xB5, 0x77, 0xEE, 0xC1, 0x9F, 0x23,
|
||||
0x46, 0x8C, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x5D, 0xBA, 0x69, 0xD2, 0xB9, 0x6F, 0xDE, 0xA1,
|
||||
0x5F, 0xBE, 0x61, 0xC2, 0x99, 0x2F, 0x5E, 0xBC, 0x65, 0xCA, 0x89, 0x0F, 0x1E, 0x3C, 0x78, 0xF0,
|
||||
0xFD, 0xE7, 0xD3, 0xBB, 0x6B, 0xD6, 0xB1, 0x7F, 0xFE, 0xE1, 0xDF, 0xA3, 0x5B, 0xB6, 0x71, 0xE2,
|
||||
0xD9, 0xAF, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xBD, 0x67, 0xCE,
|
||||
0x81, 0x1F, 0x3E, 0x7C, 0xF8, 0xED, 0xC7, 0x93, 0x3B, 0x76, 0xEC, 0xC5, 0x97, 0x33, 0x66, 0xCC,
|
||||
0x85, 0x17, 0x2E, 0x5C, 0xB8, 0x6D, 0xDA, 0xA9, 0x4F, 0x9E, 0x21, 0x42, 0x84, 0x15, 0x2A, 0x54,
|
||||
0xA8, 0x4D, 0x9A, 0x29, 0x52, 0xA4, 0x55, 0xAA, 0x49, 0x92, 0x39, 0x72, 0xE4, 0xD5, 0xB7, 0x73,
|
||||
0xE6, 0xD1, 0xBF, 0x63, 0xC6, 0x91, 0x3F, 0x7E, 0xFC, 0xE5, 0xD7, 0xB3, 0x7B, 0xF6, 0xF1, 0xFF,
|
||||
0xE3, 0xDB, 0xAB, 0x4B, 0x96, 0x31, 0x62, 0xC4, 0x95, 0x37, 0x6E, 0xDC, 0xA5, 0x57, 0xAE, 0x41,
|
||||
0x82, 0x19, 0x32, 0x64, 0xC8, 0x8D, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xDD, 0xA7, 0x53, 0xA6,
|
||||
0x51, 0xA2, 0x59, 0xB2, 0x79, 0xF2, 0xF9, 0xEF, 0xC3, 0x9B, 0x2B, 0x56, 0xAC, 0x45, 0x8A, 0x09,
|
||||
0x12, 0x24, 0x48, 0x90, 0x3D, 0x7A, 0xF4, 0xF5, 0xF7, 0xF3, 0xFB, 0xEB, 0xCB, 0x8B, 0x0B, 0x16,
|
||||
0x2C, 0x58, 0xB0, 0x7D, 0xFA, 0xE9, 0xCF, 0x83, 0x1B, 0x36, 0x6C, 0xD8, 0xAD, 0x47, 0x8E,
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1D, 0x3A, 0x74, 0xE8, 0xCD, 0x87, 0x13, 0x26,
|
||||
0x4C, 0x98, 0x2D, 0x5A, 0xB4, 0x75, 0xEA, 0xC9, 0x8F, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0,
|
||||
0x9D, 0x27, 0x4E, 0x9C, 0x25, 0x4A, 0x94, 0x35, 0x6A, 0xD4, 0xB5, 0x77, 0xEE, 0xC1, 0x9F, 0x23,
|
||||
0x46, 0x8C, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x5D, 0xBA, 0x69, 0xD2, 0xB9, 0x6F, 0xDE, 0xA1,
|
||||
0x5F, 0xBE, 0x61, 0xC2, 0x99, 0x2F, 0x5E, 0xBC, 0x65, 0xCA, 0x89, 0x0F, 0x1E, 0x3C, 0x78, 0xF0,
|
||||
0xFD, 0xE7, 0xD3, 0xBB, 0x6B, 0xD6, 0xB1, 0x7F, 0xFE, 0xE1, 0xDF, 0xA3, 0x5B, 0xB6, 0x71, 0xE2,
|
||||
0xD9, 0xAF, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xBD, 0x67, 0xCE,
|
||||
0x81, 0x1F, 0x3E, 0x7C, 0xF8, 0xED, 0xC7, 0x93, 0x3B, 0x76, 0xEC, 0xC5, 0x97, 0x33, 0x66, 0xCC,
|
||||
0x85, 0x17, 0x2E, 0x5C, 0xB8, 0x6D, 0xDA, 0xA9, 0x4F, 0x9E, 0x21, 0x42, 0x84, 0x15, 0x2A, 0x54,
|
||||
0xA8, 0x4D, 0x9A, 0x29, 0x52, 0xA4, 0x55, 0xAA, 0x49, 0x92, 0x39, 0x72, 0xE4, 0xD5, 0xB7, 0x73,
|
||||
0xE6, 0xD1, 0xBF, 0x63, 0xC6, 0x91, 0x3F, 0x7E, 0xFC, 0xE5, 0xD7, 0xB3, 0x7B, 0xF6, 0xF1, 0xFF,
|
||||
0xE3, 0xDB, 0xAB, 0x4B, 0x96, 0x31, 0x62, 0xC4, 0x95, 0x37, 0x6E, 0xDC, 0xA5, 0x57, 0xAE, 0x41,
|
||||
0x82, 0x19, 0x32, 0x64, 0xC8, 0x8D, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xDD, 0xA7, 0x53, 0xA6,
|
||||
0x51, 0xA2, 0x59, 0xB2, 0x79, 0xF2, 0xF9, 0xEF, 0xC3, 0x9B, 0x2B, 0x56, 0xAC, 0x45, 0x8A, 0x09,
|
||||
0x12, 0x24, 0x48, 0x90, 0x3D, 0x7A, 0xF4, 0xF5, 0xF7, 0xF3, 0xFB, 0xEB, 0xCB, 0x8B, 0x0B, 0x16,
|
||||
0x2C, 0x58, 0xB0, 0x7D, 0xFA, 0xE9, 0xCF, 0x83, 0x1B, 0x36, 0x6C, 0xD8, 0xAD, 0x47, 0x8E,
|
||||
};
|
||||
|
||||
static const unsigned char logt_0x12d[256] = {
|
||||
0x00, 0x00, 0x01, 0xF0, 0x02, 0xE1, 0xF1, 0x35, 0x03, 0x26, 0xE2, 0x85, 0xF2, 0x2B, 0x36, 0xD2,
|
||||
0x04, 0xC3, 0x27, 0x72, 0xE3, 0x6A, 0x86, 0x1C, 0xF3, 0x8C, 0x2C, 0x17, 0x37, 0x76, 0xD3, 0xEA,
|
||||
0x05, 0xDB, 0xC4, 0x60, 0x28, 0xDE, 0x73, 0x67, 0xE4, 0x4E, 0x6B, 0x7D, 0x87, 0x08, 0x1D, 0xA2,
|
||||
0xF4, 0xBA, 0x8D, 0xB4, 0x2D, 0x63, 0x18, 0x31, 0x38, 0x0D, 0x77, 0x99, 0xD4, 0xC7, 0xEB, 0x5B,
|
||||
0x06, 0x4C, 0xDC, 0xD9, 0xC5, 0x0B, 0x61, 0xB8, 0x29, 0x24, 0xDF, 0xFD, 0x74, 0x8A, 0x68, 0xC1,
|
||||
0xE5, 0x56, 0x4F, 0xAB, 0x6C, 0xA5, 0x7E, 0x91, 0x88, 0x22, 0x09, 0x4A, 0x1E, 0x20, 0xA3, 0x54,
|
||||
0xF5, 0xAD, 0xBB, 0xCC, 0x8E, 0x51, 0xB5, 0xBE, 0x2E, 0x58, 0x64, 0x9F, 0x19, 0xE7, 0x32, 0xCF,
|
||||
0x39, 0x93, 0x0E, 0x43, 0x78, 0x80, 0x9A, 0xF8, 0xD5, 0xA7, 0xC8, 0x3F, 0xEC, 0x6E, 0x5C, 0xB0,
|
||||
0x07, 0xA1, 0x4D, 0x7C, 0xDD, 0x66, 0xDA, 0x5F, 0xC6, 0x5A, 0x0C, 0x98, 0x62, 0x30, 0xB9, 0xB3,
|
||||
0x2A, 0xD1, 0x25, 0x84, 0xE0, 0x34, 0xFE, 0xEF, 0x75, 0xE9, 0x8B, 0x16, 0x69, 0x1B, 0xC2, 0x71,
|
||||
0xE6, 0xCE, 0x57, 0x9E, 0x50, 0xBD, 0xAC, 0xCB, 0x6D, 0xAF, 0xA6, 0x3E, 0x7F, 0xF7, 0x92, 0x42,
|
||||
0x89, 0xC0, 0x23, 0xFC, 0x0A, 0xB7, 0x4B, 0xD8, 0x1F, 0x53, 0x21, 0x49, 0xA4, 0x90, 0x55, 0xAA,
|
||||
0xF6, 0x41, 0xAE, 0x3D, 0xBC, 0xCA, 0xCD, 0x9D, 0x8F, 0xA9, 0x52, 0x48, 0xB6, 0xD7, 0xBF, 0xFB,
|
||||
0x2F, 0xB2, 0x59, 0x97, 0x65, 0x5E, 0xA0, 0x7B, 0x1A, 0x70, 0xE8, 0x15, 0x33, 0xEE, 0xD0, 0x83,
|
||||
0x3A, 0x45, 0x94, 0x12, 0x0F, 0x10, 0x44, 0x11, 0x79, 0x95, 0x81, 0x13, 0x9B, 0x3B, 0xF9, 0x46,
|
||||
0xD6, 0xFA, 0xA8, 0x47, 0xC9, 0x9C, 0x40, 0x3C, 0xED, 0x82, 0x6F, 0x14, 0x5D, 0x7A, 0xB1, 0x96,
|
||||
};
|
||||
static const unsigned char alog_0x12d[510] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x2D, 0x5A, 0xB4, 0x45, 0x8A, 0x39, 0x72, 0xE4,
|
||||
0xE5, 0xE7, 0xE3, 0xEB, 0xFB, 0xDB, 0x9B, 0x1B, 0x36, 0x6C, 0xD8, 0x9D, 0x17, 0x2E, 0x5C, 0xB8,
|
||||
0x5D, 0xBA, 0x59, 0xB2, 0x49, 0x92, 0x09, 0x12, 0x24, 0x48, 0x90, 0x0D, 0x1A, 0x34, 0x68, 0xD0,
|
||||
0x8D, 0x37, 0x6E, 0xDC, 0x95, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xED, 0xF7, 0xC3, 0xAB, 0x7B,
|
||||
0xF6, 0xC1, 0xAF, 0x73, 0xE6, 0xE1, 0xEF, 0xF3, 0xCB, 0xBB, 0x5B, 0xB6, 0x41, 0x82, 0x29, 0x52,
|
||||
0xA4, 0x65, 0xCA, 0xB9, 0x5F, 0xBE, 0x51, 0xA2, 0x69, 0xD2, 0x89, 0x3F, 0x7E, 0xFC, 0xD5, 0x87,
|
||||
0x23, 0x46, 0x8C, 0x35, 0x6A, 0xD4, 0x85, 0x27, 0x4E, 0x9C, 0x15, 0x2A, 0x54, 0xA8, 0x7D, 0xFA,
|
||||
0xD9, 0x9F, 0x13, 0x26, 0x4C, 0x98, 0x1D, 0x3A, 0x74, 0xE8, 0xFD, 0xD7, 0x83, 0x2B, 0x56, 0xAC,
|
||||
0x75, 0xEA, 0xF9, 0xDF, 0x93, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x4D, 0x9A, 0x19, 0x32, 0x64, 0xC8,
|
||||
0xBD, 0x57, 0xAE, 0x71, 0xE2, 0xE9, 0xFF, 0xD3, 0x8B, 0x3B, 0x76, 0xEC, 0xF5, 0xC7, 0xA3, 0x6B,
|
||||
0xD6, 0x81, 0x2F, 0x5E, 0xBC, 0x55, 0xAA, 0x79, 0xF2, 0xC9, 0xBF, 0x53, 0xA6, 0x61, 0xC2, 0xA9,
|
||||
0x7F, 0xFE, 0xD1, 0x8F, 0x33, 0x66, 0xCC, 0xB5, 0x47, 0x8E, 0x31, 0x62, 0xC4, 0xA5, 0x67, 0xCE,
|
||||
0xB1, 0x4F, 0x9E, 0x11, 0x22, 0x44, 0x88, 0x3D, 0x7A, 0xF4, 0xC5, 0xA7, 0x63, 0xC6, 0xA1, 0x6F,
|
||||
0xDE, 0x91, 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0xCD, 0xB7, 0x43, 0x86, 0x21, 0x42, 0x84, 0x25, 0x4A,
|
||||
0x94, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x6D, 0xDA, 0x99, 0x1F, 0x3E, 0x7C, 0xF8, 0xDD, 0x97,
|
||||
0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xAD, 0x77, 0xEE, 0xF1, 0xCF, 0xB3, 0x4B, 0x96,
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x2D, 0x5A, 0xB4, 0x45, 0x8A, 0x39, 0x72, 0xE4,
|
||||
0xE5, 0xE7, 0xE3, 0xEB, 0xFB, 0xDB, 0x9B, 0x1B, 0x36, 0x6C, 0xD8, 0x9D, 0x17, 0x2E, 0x5C, 0xB8,
|
||||
0x5D, 0xBA, 0x59, 0xB2, 0x49, 0x92, 0x09, 0x12, 0x24, 0x48, 0x90, 0x0D, 0x1A, 0x34, 0x68, 0xD0,
|
||||
0x8D, 0x37, 0x6E, 0xDC, 0x95, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xED, 0xF7, 0xC3, 0xAB, 0x7B,
|
||||
0xF6, 0xC1, 0xAF, 0x73, 0xE6, 0xE1, 0xEF, 0xF3, 0xCB, 0xBB, 0x5B, 0xB6, 0x41, 0x82, 0x29, 0x52,
|
||||
0xA4, 0x65, 0xCA, 0xB9, 0x5F, 0xBE, 0x51, 0xA2, 0x69, 0xD2, 0x89, 0x3F, 0x7E, 0xFC, 0xD5, 0x87,
|
||||
0x23, 0x46, 0x8C, 0x35, 0x6A, 0xD4, 0x85, 0x27, 0x4E, 0x9C, 0x15, 0x2A, 0x54, 0xA8, 0x7D, 0xFA,
|
||||
0xD9, 0x9F, 0x13, 0x26, 0x4C, 0x98, 0x1D, 0x3A, 0x74, 0xE8, 0xFD, 0xD7, 0x83, 0x2B, 0x56, 0xAC,
|
||||
0x75, 0xEA, 0xF9, 0xDF, 0x93, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x4D, 0x9A, 0x19, 0x32, 0x64, 0xC8,
|
||||
0xBD, 0x57, 0xAE, 0x71, 0xE2, 0xE9, 0xFF, 0xD3, 0x8B, 0x3B, 0x76, 0xEC, 0xF5, 0xC7, 0xA3, 0x6B,
|
||||
0xD6, 0x81, 0x2F, 0x5E, 0xBC, 0x55, 0xAA, 0x79, 0xF2, 0xC9, 0xBF, 0x53, 0xA6, 0x61, 0xC2, 0xA9,
|
||||
0x7F, 0xFE, 0xD1, 0x8F, 0x33, 0x66, 0xCC, 0xB5, 0x47, 0x8E, 0x31, 0x62, 0xC4, 0xA5, 0x67, 0xCE,
|
||||
0xB1, 0x4F, 0x9E, 0x11, 0x22, 0x44, 0x88, 0x3D, 0x7A, 0xF4, 0xC5, 0xA7, 0x63, 0xC6, 0xA1, 0x6F,
|
||||
0xDE, 0x91, 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0xCD, 0xB7, 0x43, 0x86, 0x21, 0x42, 0x84, 0x25, 0x4A,
|
||||
0x94, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x6D, 0xDA, 0x99, 0x1F, 0x3E, 0x7C, 0xF8, 0xDD, 0x97,
|
||||
0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xAD, 0x77, 0xEE, 0xF1, 0xCF, 0xB3, 0x4B, 0x96,
|
||||
};
|
||||
|
||||
static const unsigned char logt_0x163[256] = {
|
||||
0x00, 0x00, 0x01, 0xC5, 0x02, 0x8B, 0xC6, 0x6C, 0x03, 0x32, 0x8C, 0xC0, 0xC7, 0x25, 0x6D, 0x51,
|
||||
0x04, 0x17, 0x33, 0xEE, 0x8D, 0xD8, 0xC1, 0xEA, 0xC8, 0x0C, 0x26, 0xF7, 0x6E, 0x86, 0x52, 0x7C,
|
||||
0x05, 0x42, 0x18, 0x91, 0x34, 0x73, 0xEF, 0x4C, 0x8E, 0xCE, 0xD9, 0xD1, 0xC2, 0xBD, 0xEB, 0xF4,
|
||||
0xC9, 0x2D, 0x0D, 0xDC, 0x27, 0xB4, 0xF8, 0xA4, 0x6F, 0xB0, 0x87, 0xD4, 0x53, 0x1E, 0x7D, 0x9E,
|
||||
0x06, 0x64, 0x43, 0x37, 0x19, 0x81, 0x92, 0xE3, 0x35, 0xE1, 0x74, 0x76, 0xF0, 0x9A, 0x4D, 0x78,
|
||||
0x8F, 0x4A, 0xCF, 0xF2, 0xDA, 0xA2, 0xD2, 0x9C, 0xC3, 0x6A, 0xBE, 0x4F, 0xEC, 0xE8, 0xF5, 0x7A,
|
||||
0xCA, 0xAC, 0x2E, 0x08, 0x0E, 0x57, 0xDD, 0x66, 0x28, 0x12, 0xB5, 0x45, 0xF9, 0x5E, 0xA5, 0x39,
|
||||
0x70, 0xBA, 0xB1, 0x1B, 0x88, 0x22, 0xD5, 0x83, 0x54, 0x5B, 0x1F, 0x94, 0x7E, 0x97, 0x9F, 0xE5,
|
||||
0x07, 0xAB, 0x65, 0x56, 0x44, 0x11, 0x38, 0x5D, 0x1A, 0xB9, 0x82, 0x21, 0x93, 0x5A, 0xE4, 0x96,
|
||||
0x36, 0x63, 0xE2, 0x80, 0x75, 0xE0, 0x77, 0x99, 0xF1, 0x49, 0x9B, 0xA1, 0x4E, 0x69, 0x79, 0xE7,
|
||||
0x90, 0x41, 0x4B, 0x72, 0xD0, 0xCD, 0xF3, 0xBC, 0xDB, 0x2C, 0xA3, 0xB3, 0xD3, 0xAF, 0x9D, 0x1D,
|
||||
0xC4, 0xFE, 0x6B, 0x8A, 0xBF, 0x31, 0x50, 0x24, 0xED, 0x16, 0xE9, 0xD7, 0xF6, 0x0B, 0x7B, 0x85,
|
||||
0xCB, 0x3F, 0xAD, 0x2A, 0x2F, 0xFC, 0x09, 0x14, 0x0F, 0xA9, 0x58, 0xB7, 0xDE, 0x61, 0x67, 0x47,
|
||||
0x29, 0x3E, 0x13, 0xFB, 0xB6, 0xA8, 0x46, 0x60, 0xFA, 0x3D, 0x5F, 0xA7, 0xA6, 0x3C, 0x3A, 0x3B,
|
||||
0x71, 0x40, 0xBB, 0xCC, 0xB2, 0x2B, 0x1C, 0xAE, 0x89, 0xFD, 0x23, 0x30, 0xD6, 0x15, 0x84, 0x0A,
|
||||
0x55, 0xAA, 0x5C, 0x10, 0x20, 0xB8, 0x95, 0x59, 0x7F, 0x62, 0x98, 0xDF, 0xA0, 0x48, 0xE6, 0x68,
|
||||
};
|
||||
static const unsigned char alog_0x163[510] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x63, 0xC6, 0xEF, 0xBD, 0x19, 0x32, 0x64, 0xC8,
|
||||
0xF3, 0x85, 0x69, 0xD2, 0xC7, 0xED, 0xB9, 0x11, 0x22, 0x44, 0x88, 0x73, 0xE6, 0xAF, 0x3D, 0x7A,
|
||||
0xF4, 0x8B, 0x75, 0xEA, 0xB7, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xC3, 0xE5, 0xA9, 0x31, 0x62, 0xC4,
|
||||
0xEB, 0xB5, 0x09, 0x12, 0x24, 0x48, 0x90, 0x43, 0x86, 0x6F, 0xDE, 0xDF, 0xDD, 0xD9, 0xD1, 0xC1,
|
||||
0xE1, 0xA1, 0x21, 0x42, 0x84, 0x6B, 0xD6, 0xCF, 0xFD, 0x99, 0x51, 0xA2, 0x27, 0x4E, 0x9C, 0x5B,
|
||||
0xB6, 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0x83, 0x65, 0xCA, 0xF7, 0x8D, 0x79, 0xF2, 0x87, 0x6D, 0xDA,
|
||||
0xD7, 0xCD, 0xF9, 0x91, 0x41, 0x82, 0x67, 0xCE, 0xFF, 0x9D, 0x59, 0xB2, 0x07, 0x0E, 0x1C, 0x38,
|
||||
0x70, 0xE0, 0xA3, 0x25, 0x4A, 0x94, 0x4B, 0x96, 0x4F, 0x9E, 0x5F, 0xBE, 0x1F, 0x3E, 0x7C, 0xF8,
|
||||
0x93, 0x45, 0x8A, 0x77, 0xEE, 0xBF, 0x1D, 0x3A, 0x74, 0xE8, 0xB3, 0x05, 0x0A, 0x14, 0x28, 0x50,
|
||||
0xA0, 0x23, 0x46, 0x8C, 0x7B, 0xF6, 0x8F, 0x7D, 0xFA, 0x97, 0x4D, 0x9A, 0x57, 0xAE, 0x3F, 0x7E,
|
||||
0xFC, 0x9B, 0x55, 0xAA, 0x37, 0x6E, 0xDC, 0xDB, 0xD5, 0xC9, 0xF1, 0x81, 0x61, 0xC2, 0xE7, 0xAD,
|
||||
0x39, 0x72, 0xE4, 0xAB, 0x35, 0x6A, 0xD4, 0xCB, 0xF5, 0x89, 0x71, 0xE2, 0xA7, 0x2D, 0x5A, 0xB4,
|
||||
0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xE3, 0xA5, 0x29, 0x52,
|
||||
0xA4, 0x2B, 0x56, 0xAC, 0x3B, 0x76, 0xEC, 0xBB, 0x15, 0x2A, 0x54, 0xA8, 0x33, 0x66, 0xCC, 0xFB,
|
||||
0x95, 0x49, 0x92, 0x47, 0x8E, 0x7F, 0xFE, 0x9F, 0x5D, 0xBA, 0x17, 0x2E, 0x5C, 0xB8, 0x13, 0x26,
|
||||
0x4C, 0x98, 0x53, 0xA6, 0x2F, 0x5E, 0xBC, 0x1B, 0x36, 0x6C, 0xD8, 0xD3, 0xC5, 0xE9, 0xB1,
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x63, 0xC6, 0xEF, 0xBD, 0x19, 0x32, 0x64, 0xC8,
|
||||
0xF3, 0x85, 0x69, 0xD2, 0xC7, 0xED, 0xB9, 0x11, 0x22, 0x44, 0x88, 0x73, 0xE6, 0xAF, 0x3D, 0x7A,
|
||||
0xF4, 0x8B, 0x75, 0xEA, 0xB7, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xC3, 0xE5, 0xA9, 0x31, 0x62, 0xC4,
|
||||
0xEB, 0xB5, 0x09, 0x12, 0x24, 0x48, 0x90, 0x43, 0x86, 0x6F, 0xDE, 0xDF, 0xDD, 0xD9, 0xD1, 0xC1,
|
||||
0xE1, 0xA1, 0x21, 0x42, 0x84, 0x6B, 0xD6, 0xCF, 0xFD, 0x99, 0x51, 0xA2, 0x27, 0x4E, 0x9C, 0x5B,
|
||||
0xB6, 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0x83, 0x65, 0xCA, 0xF7, 0x8D, 0x79, 0xF2, 0x87, 0x6D, 0xDA,
|
||||
0xD7, 0xCD, 0xF9, 0x91, 0x41, 0x82, 0x67, 0xCE, 0xFF, 0x9D, 0x59, 0xB2, 0x07, 0x0E, 0x1C, 0x38,
|
||||
0x70, 0xE0, 0xA3, 0x25, 0x4A, 0x94, 0x4B, 0x96, 0x4F, 0x9E, 0x5F, 0xBE, 0x1F, 0x3E, 0x7C, 0xF8,
|
||||
0x93, 0x45, 0x8A, 0x77, 0xEE, 0xBF, 0x1D, 0x3A, 0x74, 0xE8, 0xB3, 0x05, 0x0A, 0x14, 0x28, 0x50,
|
||||
0xA0, 0x23, 0x46, 0x8C, 0x7B, 0xF6, 0x8F, 0x7D, 0xFA, 0x97, 0x4D, 0x9A, 0x57, 0xAE, 0x3F, 0x7E,
|
||||
0xFC, 0x9B, 0x55, 0xAA, 0x37, 0x6E, 0xDC, 0xDB, 0xD5, 0xC9, 0xF1, 0x81, 0x61, 0xC2, 0xE7, 0xAD,
|
||||
0x39, 0x72, 0xE4, 0xAB, 0x35, 0x6A, 0xD4, 0xCB, 0xF5, 0x89, 0x71, 0xE2, 0xA7, 0x2D, 0x5A, 0xB4,
|
||||
0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xE3, 0xA5, 0x29, 0x52,
|
||||
0xA4, 0x2B, 0x56, 0xAC, 0x3B, 0x76, 0xEC, 0xBB, 0x15, 0x2A, 0x54, 0xA8, 0x33, 0x66, 0xCC, 0xFB,
|
||||
0x95, 0x49, 0x92, 0x47, 0x8E, 0x7F, 0xFE, 0x9F, 0x5D, 0xBA, 0x17, 0x2E, 0x5C, 0xB8, 0x13, 0x26,
|
||||
0x4C, 0x98, 0x53, 0xA6, 0x2F, 0x5E, 0xBC, 0x1B, 0x36, 0x6C, 0xD8, 0xD3, 0xC5, 0xE9, 0xB1,
|
||||
};
|
||||
|
||||
#endif /* REEDSOL_LOGS_H */
|
@ -52,20 +52,20 @@
|
||||
* License along with the GNU LIBICONV Library; see the file COPYING.LIB.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "sjis.h"
|
||||
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */
|
||||
/* Convert Unicode to other encodings */
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *length);
|
||||
|
||||
/*
|
||||
* JISX0201.1976-0 (libiconv-1.16/lib/jisx0201.h)
|
||||
*/
|
||||
|
||||
static int jisx0201_wctomb(unsigned int* r, unsigned int wc) {
|
||||
static int jisx0201_wctomb(unsigned int *r, unsigned int wc) {
|
||||
if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) {
|
||||
*r = wc;
|
||||
return 1;
|
||||
@ -1444,7 +1444,7 @@ static const Summary16 jisx0208_uni2indx_pageff[15] = {
|
||||
{ 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0028 },
|
||||
};
|
||||
|
||||
static int jisx0208_wctomb(unsigned int* r, unsigned int wc) {
|
||||
static int jisx0208_wctomb(unsigned int *r, unsigned int wc) {
|
||||
const Summary16 *summary = NULL;
|
||||
if (wc < 0x0100) {
|
||||
summary = &jisx0208_uni2indx_page00[(wc>>4)];
|
||||
@ -1484,7 +1484,7 @@ static int jisx0208_wctomb(unsigned int* r, unsigned int wc) {
|
||||
*/
|
||||
|
||||
/* Returns 1 or 2 on success, 0 if no mapping */
|
||||
INTERNAL int sjis_wctomb_zint(unsigned int* r, unsigned int wc) {
|
||||
INTERNAL int sjis_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
int ret;
|
||||
|
||||
/* Try JIS X 0201-1976. */
|
||||
@ -1494,7 +1494,8 @@ INTERNAL int sjis_wctomb_zint(unsigned int* r, unsigned int wc) {
|
||||
}
|
||||
|
||||
/* Try JIS X 0208-1990. */
|
||||
/* ZINT: Note leaving mapping of full-width reverse solidus U+FF3C to 0x815F (duplicate of patched U+005C) to avoid having to regen tables */
|
||||
/* ZINT: Note leaving mapping of full-width reverse solidus U+FF3C to 0x815F (duplicate of patched U+005C) to avoid
|
||||
* having to regen tables */
|
||||
ret = jisx0208_wctomb(r, wc);
|
||||
if (ret) {
|
||||
return ret;
|
||||
@ -1515,13 +1516,14 @@ INTERNAL int sjis_wctomb_zint(unsigned int* r, unsigned int wc) {
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to Shift JIS and place in array of ints */
|
||||
INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], size_t* p_length, unsigned int* jisdata) {
|
||||
INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *jisdata) {
|
||||
int error_number;
|
||||
unsigned int i, length;
|
||||
#ifndef _MSC_VER
|
||||
unsigned int utfdata[*p_length + 1];
|
||||
#else
|
||||
unsigned int* utfdata = (unsigned int*) _alloca((*p_length + 1) * sizeof(unsigned int));
|
||||
unsigned int *utfdata = (unsigned int *) _alloca((*p_length + 1) * sizeof(unsigned int));
|
||||
#endif
|
||||
|
||||
error_number = utf8_to_unicode(symbol, source, utfdata, p_length, 1 /*disallow_4byte*/);
|
||||
@ -1540,12 +1542,13 @@ INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char sourc
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to single byte ECI and place in array of ints */
|
||||
INTERNAL int sjis_utf8tosb(int eci, const unsigned char source[], size_t* p_length, unsigned int* jisdata, int full_multibyte) {
|
||||
INTERNAL int sjis_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *jisdata,
|
||||
int full_multibyte) {
|
||||
int error_number;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char single_byte[*p_length + 1];
|
||||
#else
|
||||
unsigned char* single_byte = (unsigned char*) _alloca(*p_length + 1);
|
||||
unsigned char *single_byte = (unsigned char *) _alloca(*p_length + 1);
|
||||
#endif
|
||||
|
||||
error_number = utf_to_eci(eci, source, single_byte, p_length);
|
||||
@ -1559,9 +1562,9 @@ INTERNAL int sjis_utf8tosb(int eci, const unsigned char source[], size_t* p_leng
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match QR Kanji mode in a single entry.
|
||||
* If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void sjis_cpy(const unsigned char source[], size_t* p_length, unsigned int* jisdata, int full_multibyte) {
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match QR Kanji mode in a
|
||||
* single entry. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int *jisdata, int full_multibyte) {
|
||||
unsigned int i, j, jis, length;
|
||||
unsigned char c;
|
||||
|
||||
@ -1571,7 +1574,8 @@ INTERNAL void sjis_cpy(const unsigned char source[], size_t* p_length, unsigned
|
||||
if (((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xEB)) && length - i >= 2) {
|
||||
jis = (c << 8) | source[i + 1];
|
||||
if ((jis >= 0x8140 && jis <= 0x9FFC) || (jis >= 0xE040 && jis <= 0xEBBF)) {
|
||||
/* This may or may not be valid Shift JIS, but don't care as long as it can be encoded in QR Kanji mode */
|
||||
/* This may or may not be valid Shift JIS, but don't care as long as it can be encoded in
|
||||
* QR Kanji mode */
|
||||
jisdata[j] = jis;
|
||||
i++;
|
||||
} else {
|
||||
|
@ -37,10 +37,12 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INTERNAL int sjis_wctomb_zint(unsigned int* r, unsigned int wc);
|
||||
INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], size_t* p_length, unsigned int* jisdata);
|
||||
INTERNAL int sjis_utf8tosb(int eci, const unsigned char source[], size_t* p_length, unsigned int* jisdata, int full_multibyte);
|
||||
INTERNAL void sjis_cpy(const unsigned char source[], size_t* p_length, unsigned int* jisdata, int full_multibyte);
|
||||
INTERNAL int sjis_wctomb_zint(unsigned int *r, unsigned int wc);
|
||||
INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *jisdata);
|
||||
INTERNAL int sjis_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *jisdata,
|
||||
int full_multibyte);
|
||||
INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int *jisdata, int full_multibyte);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ zint_add_test(print, test_print)
|
||||
zint_add_test(ps, test_ps)
|
||||
zint_add_test(qr, test_qr)
|
||||
zint_add_test(raster, test_raster)
|
||||
zint_add_test(reedsol, test_reedsol)
|
||||
zint_add_test(rss, test_rss)
|
||||
zint_add_test(sjis, test_sjis)
|
||||
zint_add_test(svg, test_svg)
|
||||
|
BIN
backend/tests/data/emf/ean13_5addon_#185.emf
Normal file
BIN
backend/tests/data/emf/maxicode_#185.emf
Normal file
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 398 B |
@ -17,7 +17,7 @@ TE
|
||||
0.00 0.00 0.00 setrgbcolor
|
||||
2.00 40.00 TB 0.00 14.00 TR
|
||||
TE
|
||||
2.00 40.00 TB 18.00 2.00 TR
|
||||
2.00 40.00 TB 20.00 2.00 TR
|
||||
TE
|
||||
2.00 40.00 TB 24.00 2.00 TR
|
||||
TE
|
||||
@ -27,155 +27,147 @@ TE
|
||||
TE
|
||||
10.00 30.00 TB 12.00 2.00 TR
|
||||
TE
|
||||
2.00 38.00 TB 16.00 2.00 TR
|
||||
TE
|
||||
2.00 38.00 TB 22.00 4.00 TR
|
||||
TE
|
||||
10.00 30.00 TB 28.00 2.00 TR
|
||||
TE
|
||||
10.00 30.00 TB 40.00 2.00 TR
|
||||
TE
|
||||
6.00 32.00 TB 4.00 6.00 TR
|
||||
TE
|
||||
2.00 36.00 TB 18.00 2.00 TR
|
||||
10.00 28.00 TB 16.00 2.00 TR
|
||||
TE
|
||||
2.00 36.00 TB 20.00 2.00 TR
|
||||
TE
|
||||
6.00 32.00 TB 32.00 6.00 TR
|
||||
TE
|
||||
8.00 28.00 TB 24.00 2.00 TR
|
||||
2.00 34.00 TB 22.00 2.00 TR
|
||||
TE
|
||||
2.00 32.00 TB 16.00 4.00 TR
|
||||
2.00 32.00 TB 20.00 2.00 TR
|
||||
TE
|
||||
2.00 32.00 TB 24.00 2.00 TR
|
||||
TE
|
||||
2.00 30.00 TB 22.00 2.00 TR
|
||||
TE
|
||||
2.00 28.00 TB 0.00 14.00 TR
|
||||
TE
|
||||
2.00 28.00 TB 16.00 2.00 TR
|
||||
TE
|
||||
2.00 28.00 TB 20.00 2.00 TR
|
||||
TE
|
||||
2.00 28.00 TB 24.00 2.00 TR
|
||||
TE
|
||||
2.00 28.00 TB 28.00 14.00 TR
|
||||
TE
|
||||
2.00 26.00 TB 18.00 2.00 TR
|
||||
TE
|
||||
2.00 26.00 TB 22.00 4.00 TR
|
||||
2.00 26.00 TB 16.00 4.00 TR
|
||||
TE
|
||||
2.00 24.00 TB 0.00 2.00 TR
|
||||
TE
|
||||
2.00 24.00 TB 4.00 2.00 TR
|
||||
2.00 24.00 TB 4.00 10.00 TR
|
||||
TE
|
||||
2.00 24.00 TB 8.00 2.00 TR
|
||||
2.00 24.00 TB 22.00 2.00 TR
|
||||
TE
|
||||
2.00 24.00 TB 12.00 2.00 TR
|
||||
2.00 24.00 TB 28.00 10.00 TR
|
||||
TE
|
||||
2.00 24.00 TB 18.00 6.00 TR
|
||||
2.00 22.00 TB 4.00 6.00 TR
|
||||
TE
|
||||
2.00 24.00 TB 32.00 2.00 TR
|
||||
2.00 22.00 TB 16.00 2.00 TR
|
||||
TE
|
||||
2.00 24.00 TB 38.00 2.00 TR
|
||||
2.00 22.00 TB 20.00 10.00 TR
|
||||
TE
|
||||
2.00 22.00 TB 0.00 12.00 TR
|
||||
2.00 22.00 TB 34.00 8.00 TR
|
||||
TE
|
||||
2.00 22.00 TB 14.00 4.00 TR
|
||||
2.00 20.00 TB 0.00 2.00 TR
|
||||
TE
|
||||
2.00 22.00 TB 20.00 2.00 TR
|
||||
2.00 20.00 TB 10.00 6.00 TR
|
||||
TE
|
||||
2.00 22.00 TB 28.00 2.00 TR
|
||||
TE
|
||||
2.00 22.00 TB 40.00 2.00 TR
|
||||
TE
|
||||
6.00 16.00 TB 0.00 2.00 TR
|
||||
TE
|
||||
2.00 20.00 TB 4.00 14.00 TR
|
||||
2.00 20.00 TB 18.00 4.00 TR
|
||||
TE
|
||||
2.00 20.00 TB 24.00 2.00 TR
|
||||
TE
|
||||
2.00 20.00 TB 32.00 4.00 TR
|
||||
2.00 20.00 TB 28.00 4.00 TR
|
||||
TE
|
||||
4.00 16.00 TB 8.00 2.00 TR
|
||||
2.00 20.00 TB 34.00 2.00 TR
|
||||
TE
|
||||
4.00 16.00 TB 28.00 2.00 TR
|
||||
2.00 20.00 TB 40.00 2.00 TR
|
||||
TE
|
||||
2.00 18.00 TB 34.00 2.00 TR
|
||||
2.00 18.00 TB 2.00 2.00 TR
|
||||
TE
|
||||
2.00 18.00 TB 40.00 2.00 TR
|
||||
2.00 18.00 TB 8.00 4.00 TR
|
||||
TE
|
||||
2.00 18.00 TB 14.00 2.00 TR
|
||||
TE
|
||||
2.00 18.00 TB 22.00 8.00 TR
|
||||
TE
|
||||
2.00 18.00 TB 36.00 6.00 TR
|
||||
TE
|
||||
2.00 16.00 TB 0.00 2.00 TR
|
||||
TE
|
||||
2.00 16.00 TB 4.00 4.00 TR
|
||||
TE
|
||||
2.00 16.00 TB 12.00 2.00 TR
|
||||
TE
|
||||
2.00 16.00 TB 24.00 2.00 TR
|
||||
4.00 14.00 TB 16.00 6.00 TR
|
||||
TE
|
||||
2.00 16.00 TB 32.00 2.00 TR
|
||||
4.00 14.00 TB 24.00 2.00 TR
|
||||
TE
|
||||
2.00 16.00 TB 38.00 4.00 TR
|
||||
4.00 14.00 TB 30.00 2.00 TR
|
||||
TE
|
||||
2.00 14.00 TB 16.00 8.00 TR
|
||||
2.00 16.00 TB 38.00 2.00 TR
|
||||
TE
|
||||
2.00 14.00 TB 26.00 2.00 TR
|
||||
TE
|
||||
2.00 14.00 TB 30.00 2.00 TR
|
||||
TE
|
||||
4.00 12.00 TB 34.00 2.00 TR
|
||||
TE
|
||||
2.00 14.00 TB 38.00 2.00 TR
|
||||
2.00 14.00 TB 36.00 2.00 TR
|
||||
TE
|
||||
2.00 12.00 TB 0.00 14.00 TR
|
||||
TE
|
||||
2.00 12.00 TB 20.00 4.00 TR
|
||||
2.00 12.00 TB 18.00 2.00 TR
|
||||
TE
|
||||
2.00 12.00 TB 26.00 6.00 TR
|
||||
2.00 12.00 TB 22.00 2.00 TR
|
||||
TE
|
||||
2.00 12.00 TB 26.00 2.00 TR
|
||||
TE
|
||||
2.00 12.00 TB 32.00 4.00 TR
|
||||
TE
|
||||
4.00 10.00 TB 40.00 2.00 TR
|
||||
TE
|
||||
10.00 2.00 TB 0.00 2.00 TR
|
||||
TE
|
||||
10.00 2.00 TB 12.00 2.00 TR
|
||||
TE
|
||||
2.00 10.00 TB 18.00 2.00 TR
|
||||
4.00 8.00 TB 16.00 4.00 TR
|
||||
TE
|
||||
2.00 10.00 TB 22.00 6.00 TR
|
||||
2.00 10.00 TB 30.00 4.00 TR
|
||||
TE
|
||||
2.00 10.00 TB 30.00 6.00 TR
|
||||
TE
|
||||
2.00 10.00 TB 38.00 4.00 TR
|
||||
2.00 10.00 TB 36.00 2.00 TR
|
||||
TE
|
||||
6.00 4.00 TB 4.00 6.00 TR
|
||||
TE
|
||||
2.00 8.00 TB 16.00 2.00 TR
|
||||
2.00 8.00 TB 22.00 2.00 TR
|
||||
TE
|
||||
2.00 8.00 TB 20.00 4.00 TR
|
||||
2.00 8.00 TB 26.00 2.00 TR
|
||||
TE
|
||||
2.00 8.00 TB 26.00 6.00 TR
|
||||
2.00 8.00 TB 32.00 6.00 TR
|
||||
TE
|
||||
2.00 8.00 TB 34.00 4.00 TR
|
||||
2.00 6.00 TB 16.00 2.00 TR
|
||||
TE
|
||||
2.00 8.00 TB 40.00 2.00 TR
|
||||
2.00 6.00 TB 20.00 12.00 TR
|
||||
TE
|
||||
2.00 6.00 TB 20.00 2.00 TR
|
||||
4.00 4.00 TB 34.00 4.00 TR
|
||||
TE
|
||||
2.00 6.00 TB 28.00 4.00 TR
|
||||
TE
|
||||
2.00 6.00 TB 38.00 2.00 TR
|
||||
TE
|
||||
2.00 4.00 TB 16.00 2.00 TR
|
||||
2.00 4.00 TB 16.00 6.00 TR
|
||||
TE
|
||||
2.00 4.00 TB 24.00 2.00 TR
|
||||
TE
|
||||
2.00 4.00 TB 32.00 6.00 TR
|
||||
TE
|
||||
2.00 4.00 TB 40.00 2.00 TR
|
||||
2.00 4.00 TB 28.00 4.00 TR
|
||||
TE
|
||||
2.00 2.00 TB 18.00 2.00 TR
|
||||
TE
|
||||
2.00 2.00 TB 28.00 4.00 TR
|
||||
2.00 2.00 TB 22.00 10.00 TR
|
||||
TE
|
||||
2.00 2.00 TB 34.00 2.00 TR
|
||||
2.00 2.00 TB 36.00 4.00 TR
|
||||
TE
|
||||
2.00 0.00 TB 0.00 14.00 TR
|
||||
TE
|
||||
2.00 0.00 TB 16.00 6.00 TR
|
||||
2.00 0.00 TB 16.00 2.00 TR
|
||||
TE
|
||||
2.00 0.00 TB 24.00 2.00 TR
|
||||
TE
|
||||
2.00 0.00 TB 28.00 2.00 TR
|
||||
TE
|
||||
2.00 0.00 TB 32.00 2.00 TR
|
||||
2.00 0.00 TB 30.00 2.00 TR
|
||||
TE
|
||||
2.00 0.00 TB 36.00 2.00 TR
|
||||
TE
|
||||
2.00 0.00 TB 40.00 2.00 TR
|
||||
TE
|
||||
|
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 247 B |
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 287 B |
@ -9,86 +9,82 @@
|
||||
<g id="barcode" fill="#000000">
|
||||
<rect x="0" y="0" width="42" height="42" fill="#FFFFFF" />
|
||||
<rect x="0.00" y="0.00" width="14.00" height="2.00" />
|
||||
<rect x="18.00" y="0.00" width="2.00" height="2.00" />
|
||||
<rect x="20.00" y="0.00" width="2.00" height="2.00" />
|
||||
<rect x="24.00" y="0.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="0.00" width="14.00" height="2.00" />
|
||||
<rect x="0.00" y="2.00" width="2.00" height="10.00" />
|
||||
<rect x="12.00" y="2.00" width="2.00" height="10.00" />
|
||||
<rect x="16.00" y="2.00" width="2.00" height="2.00" />
|
||||
<rect x="22.00" y="2.00" width="4.00" height="2.00" />
|
||||
<rect x="28.00" y="2.00" width="2.00" height="10.00" />
|
||||
<rect x="40.00" y="2.00" width="2.00" height="10.00" />
|
||||
<rect x="4.00" y="4.00" width="6.00" height="6.00" />
|
||||
<rect x="18.00" y="4.00" width="2.00" height="2.00" />
|
||||
<rect x="16.00" y="4.00" width="2.00" height="10.00" />
|
||||
<rect x="20.00" y="4.00" width="2.00" height="2.00" />
|
||||
<rect x="32.00" y="4.00" width="6.00" height="6.00" />
|
||||
<rect x="24.00" y="6.00" width="2.00" height="8.00" />
|
||||
<rect x="16.00" y="8.00" width="4.00" height="2.00" />
|
||||
<rect x="22.00" y="6.00" width="2.00" height="2.00" />
|
||||
<rect x="20.00" y="8.00" width="2.00" height="2.00" />
|
||||
<rect x="24.00" y="8.00" width="2.00" height="2.00" />
|
||||
<rect x="22.00" y="10.00" width="2.00" height="2.00" />
|
||||
<rect x="0.00" y="12.00" width="14.00" height="2.00" />
|
||||
<rect x="16.00" y="12.00" width="2.00" height="2.00" />
|
||||
<rect x="20.00" y="12.00" width="2.00" height="2.00" />
|
||||
<rect x="24.00" y="12.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="12.00" width="14.00" height="2.00" />
|
||||
<rect x="18.00" y="14.00" width="2.00" height="2.00" />
|
||||
<rect x="22.00" y="14.00" width="4.00" height="2.00" />
|
||||
<rect x="16.00" y="14.00" width="4.00" height="2.00" />
|
||||
<rect x="0.00" y="16.00" width="2.00" height="2.00" />
|
||||
<rect x="4.00" y="16.00" width="2.00" height="2.00" />
|
||||
<rect x="8.00" y="16.00" width="2.00" height="2.00" />
|
||||
<rect x="12.00" y="16.00" width="2.00" height="2.00" />
|
||||
<rect x="18.00" y="16.00" width="6.00" height="2.00" />
|
||||
<rect x="32.00" y="16.00" width="2.00" height="2.00" />
|
||||
<rect x="38.00" y="16.00" width="2.00" height="2.00" />
|
||||
<rect x="0.00" y="18.00" width="12.00" height="2.00" />
|
||||
<rect x="14.00" y="18.00" width="4.00" height="2.00" />
|
||||
<rect x="20.00" y="18.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="18.00" width="2.00" height="2.00" />
|
||||
<rect x="40.00" y="18.00" width="2.00" height="2.00" />
|
||||
<rect x="0.00" y="20.00" width="2.00" height="6.00" />
|
||||
<rect x="4.00" y="20.00" width="14.00" height="2.00" />
|
||||
<rect x="4.00" y="16.00" width="10.00" height="2.00" />
|
||||
<rect x="22.00" y="16.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="16.00" width="10.00" height="2.00" />
|
||||
<rect x="4.00" y="18.00" width="6.00" height="2.00" />
|
||||
<rect x="16.00" y="18.00" width="2.00" height="2.00" />
|
||||
<rect x="20.00" y="18.00" width="10.00" height="2.00" />
|
||||
<rect x="34.00" y="18.00" width="8.00" height="2.00" />
|
||||
<rect x="0.00" y="20.00" width="2.00" height="2.00" />
|
||||
<rect x="10.00" y="20.00" width="6.00" height="2.00" />
|
||||
<rect x="18.00" y="20.00" width="4.00" height="2.00" />
|
||||
<rect x="24.00" y="20.00" width="2.00" height="2.00" />
|
||||
<rect x="32.00" y="20.00" width="4.00" height="2.00" />
|
||||
<rect x="8.00" y="22.00" width="2.00" height="4.00" />
|
||||
<rect x="28.00" y="22.00" width="2.00" height="4.00" />
|
||||
<rect x="34.00" y="22.00" width="2.00" height="2.00" />
|
||||
<rect x="40.00" y="22.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="20.00" width="4.00" height="2.00" />
|
||||
<rect x="34.00" y="20.00" width="2.00" height="2.00" />
|
||||
<rect x="40.00" y="20.00" width="2.00" height="2.00" />
|
||||
<rect x="2.00" y="22.00" width="2.00" height="2.00" />
|
||||
<rect x="8.00" y="22.00" width="4.00" height="2.00" />
|
||||
<rect x="14.00" y="22.00" width="2.00" height="2.00" />
|
||||
<rect x="22.00" y="22.00" width="8.00" height="2.00" />
|
||||
<rect x="36.00" y="22.00" width="6.00" height="2.00" />
|
||||
<rect x="0.00" y="24.00" width="2.00" height="2.00" />
|
||||
<rect x="4.00" y="24.00" width="4.00" height="2.00" />
|
||||
<rect x="12.00" y="24.00" width="2.00" height="2.00" />
|
||||
<rect x="24.00" y="24.00" width="2.00" height="2.00" />
|
||||
<rect x="32.00" y="24.00" width="2.00" height="2.00" />
|
||||
<rect x="38.00" y="24.00" width="4.00" height="2.00" />
|
||||
<rect x="16.00" y="26.00" width="8.00" height="2.00" />
|
||||
<rect x="26.00" y="26.00" width="2.00" height="2.00" />
|
||||
<rect x="30.00" y="26.00" width="2.00" height="2.00" />
|
||||
<rect x="34.00" y="26.00" width="2.00" height="4.00" />
|
||||
<rect x="38.00" y="26.00" width="2.00" height="2.00" />
|
||||
<rect x="16.00" y="24.00" width="6.00" height="4.00" />
|
||||
<rect x="24.00" y="24.00" width="2.00" height="4.00" />
|
||||
<rect x="30.00" y="24.00" width="2.00" height="4.00" />
|
||||
<rect x="38.00" y="24.00" width="2.00" height="2.00" />
|
||||
<rect x="36.00" y="26.00" width="2.00" height="2.00" />
|
||||
<rect x="0.00" y="28.00" width="14.00" height="2.00" />
|
||||
<rect x="20.00" y="28.00" width="4.00" height="2.00" />
|
||||
<rect x="26.00" y="28.00" width="6.00" height="2.00" />
|
||||
<rect x="18.00" y="28.00" width="2.00" height="2.00" />
|
||||
<rect x="22.00" y="28.00" width="2.00" height="2.00" />
|
||||
<rect x="26.00" y="28.00" width="2.00" height="2.00" />
|
||||
<rect x="32.00" y="28.00" width="4.00" height="2.00" />
|
||||
<rect x="40.00" y="28.00" width="2.00" height="4.00" />
|
||||
<rect x="0.00" y="30.00" width="2.00" height="10.00" />
|
||||
<rect x="12.00" y="30.00" width="2.00" height="10.00" />
|
||||
<rect x="18.00" y="30.00" width="2.00" height="2.00" />
|
||||
<rect x="22.00" y="30.00" width="6.00" height="2.00" />
|
||||
<rect x="30.00" y="30.00" width="6.00" height="2.00" />
|
||||
<rect x="38.00" y="30.00" width="4.00" height="2.00" />
|
||||
<rect x="16.00" y="30.00" width="4.00" height="4.00" />
|
||||
<rect x="30.00" y="30.00" width="4.00" height="2.00" />
|
||||
<rect x="36.00" y="30.00" width="2.00" height="2.00" />
|
||||
<rect x="4.00" y="32.00" width="6.00" height="6.00" />
|
||||
<rect x="16.00" y="32.00" width="2.00" height="2.00" />
|
||||
<rect x="20.00" y="32.00" width="4.00" height="2.00" />
|
||||
<rect x="26.00" y="32.00" width="6.00" height="2.00" />
|
||||
<rect x="34.00" y="32.00" width="4.00" height="2.00" />
|
||||
<rect x="40.00" y="32.00" width="2.00" height="2.00" />
|
||||
<rect x="20.00" y="34.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="34.00" width="4.00" height="2.00" />
|
||||
<rect x="38.00" y="34.00" width="2.00" height="2.00" />
|
||||
<rect x="16.00" y="36.00" width="2.00" height="2.00" />
|
||||
<rect x="22.00" y="32.00" width="2.00" height="2.00" />
|
||||
<rect x="26.00" y="32.00" width="2.00" height="2.00" />
|
||||
<rect x="32.00" y="32.00" width="6.00" height="2.00" />
|
||||
<rect x="16.00" y="34.00" width="2.00" height="2.00" />
|
||||
<rect x="20.00" y="34.00" width="12.00" height="2.00" />
|
||||
<rect x="34.00" y="34.00" width="4.00" height="4.00" />
|
||||
<rect x="16.00" y="36.00" width="6.00" height="2.00" />
|
||||
<rect x="24.00" y="36.00" width="2.00" height="2.00" />
|
||||
<rect x="32.00" y="36.00" width="6.00" height="2.00" />
|
||||
<rect x="40.00" y="36.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="36.00" width="4.00" height="2.00" />
|
||||
<rect x="18.00" y="38.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="38.00" width="4.00" height="2.00" />
|
||||
<rect x="34.00" y="38.00" width="2.00" height="2.00" />
|
||||
<rect x="22.00" y="38.00" width="10.00" height="2.00" />
|
||||
<rect x="36.00" y="38.00" width="4.00" height="2.00" />
|
||||
<rect x="0.00" y="40.00" width="14.00" height="2.00" />
|
||||
<rect x="16.00" y="40.00" width="6.00" height="2.00" />
|
||||
<rect x="16.00" y="40.00" width="2.00" height="2.00" />
|
||||
<rect x="24.00" y="40.00" width="2.00" height="2.00" />
|
||||
<rect x="28.00" y="40.00" width="2.00" height="2.00" />
|
||||
<rect x="32.00" y="40.00" width="2.00" height="2.00" />
|
||||
<rect x="30.00" y="40.00" width="2.00" height="2.00" />
|
||||
<rect x="36.00" y="40.00" width="2.00" height="2.00" />
|
||||
<rect x="40.00" y="40.00" width="2.00" height="2.00" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.1 KiB |
@ -1,21 +1,21 @@
|
||||
FE 4B F8
|
||||
82 9A 08
|
||||
BA 42 E8
|
||||
BA 0A E8
|
||||
BA CA E8
|
||||
82 0A 08
|
||||
FE 2B F8
|
||||
82 02 08
|
||||
BA A2 E8
|
||||
BA 92 E8
|
||||
BA AA E8
|
||||
82 92 08
|
||||
FE AB F8
|
||||
00 58 00
|
||||
AA 70 90
|
||||
FD A2 08
|
||||
BF 88 C0
|
||||
88 02 48
|
||||
8A 0A 98
|
||||
00 F5 50
|
||||
FE 37 40
|
||||
82 5D D8
|
||||
BA B7 68
|
||||
BA 23 10
|
||||
BA 88 E8
|
||||
82 43 40
|
||||
FE EA A8
|
||||
00 C0 00
|
||||
BE 13 E0
|
||||
38 BE 78
|
||||
87 6B 48
|
||||
4D 1E 38
|
||||
B2 E9 10
|
||||
00 E9 20
|
||||
FE 54 C8
|
||||
82 C1 A8
|
||||
BA D4 E0
|
||||
BA BF 60
|
||||
BA EB 60
|
||||
82 5F 30
|
||||
FE 89 20
|
||||
|
@ -775,7 +775,28 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"110110000101100"
|
||||
"010001010010110"
|
||||
},
|
||||
/* 20*/ { BARCODE_AZTEC, DATA_MODE, 3, -1, -1, -1, "\101\300", -1, 0, 15, 15, 1, "AÀ",
|
||||
/* 20*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 2, "121212121abcd", -1, 0, 19, 19, 1, "#210",
|
||||
"1101101111001101010"
|
||||
"1101111011110110000"
|
||||
"0001111101100010000"
|
||||
"0100011111001001001"
|
||||
"1010110100101010010"
|
||||
"1000111111111111101"
|
||||
"0001110000000111110"
|
||||
"0111010111110110100"
|
||||
"1001010100010101010"
|
||||
"1001010101010101100"
|
||||
"0010010100010101100"
|
||||
"0110110111110111011"
|
||||
"1001110000000111010"
|
||||
"1011011111111110010"
|
||||
"0011000011111001100"
|
||||
"0110100001100101011"
|
||||
"1001001010110011011"
|
||||
"0011111001001010011"
|
||||
"1001101000100100001"
|
||||
},
|
||||
/* 21*/ { BARCODE_AZTEC, DATA_MODE, 3, -1, -1, -1, "\101\300", -1, 0, 15, 15, 1, "AÀ",
|
||||
"000000101011100"
|
||||
"000100010100111"
|
||||
"001100000110110"
|
||||
@ -792,7 +813,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"110001000111110"
|
||||
"111001100011011"
|
||||
},
|
||||
/* 21*/ { BARCODE_AZTEC, UNICODE_MODE, 26, -1, -1, -1, "AÀ", -1, 0, 15, 15, 1, "AÀ",
|
||||
/* 22*/ { BARCODE_AZTEC, UNICODE_MODE, 26, -1, -1, -1, "AÀ", -1, 0, 15, 15, 1, "AÀ",
|
||||
"001111011000101"
|
||||
"000110100011000"
|
||||
"001100001000111"
|
||||
@ -809,7 +830,291 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"001100010010010"
|
||||
"011110110011000"
|
||||
},
|
||||
/* 22*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "0", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (1st)",
|
||||
/* 23*/ { BARCODE_AZTEC, UNICODE_MODE, 100, -1, -1, -1, "A", -1, 0, 15, 15, 1, "FLG(3)",
|
||||
"001101001111101"
|
||||
"000000111011100"
|
||||
"001100000100101"
|
||||
"011111111111110"
|
||||
"001100000001111"
|
||||
"000101111101001"
|
||||
"011101000101001"
|
||||
"010101010101001"
|
||||
"100101000101101"
|
||||
"011101111101010"
|
||||
"100100000001100"
|
||||
"010111111111111"
|
||||
"000011011110011"
|
||||
"100011101111100"
|
||||
"000111110001110"
|
||||
},
|
||||
/* 24*/ { BARCODE_AZTEC, UNICODE_MODE, 1000, -1, -1, -1, "A", -1, 0, 15, 15, 1, "FLG(4)",
|
||||
"001010100011011"
|
||||
"001000100000101"
|
||||
"001100000100111"
|
||||
"011111111111110"
|
||||
"001100000001110"
|
||||
"000101111101000"
|
||||
"011101000101010"
|
||||
"100101010101001"
|
||||
"000101000101101"
|
||||
"011101111101011"
|
||||
"100100000001101"
|
||||
"010111111111100"
|
||||
"000011011110011"
|
||||
"101000000111010"
|
||||
"000001110101111"
|
||||
},
|
||||
/* 25*/ { BARCODE_AZTEC, UNICODE_MODE, 10000, -1, -1, -1, "A", -1, 0, 15, 15, 1, "FLG(5)",
|
||||
"000100110110010"
|
||||
"000001000010111"
|
||||
"001100000110101"
|
||||
"011111111111111"
|
||||
"000100000001010"
|
||||
"001101111101101"
|
||||
"011101000101110"
|
||||
"100101010101100"
|
||||
"100101000101101"
|
||||
"010101111101100"
|
||||
"101100000001011"
|
||||
"010111111111111"
|
||||
"000011110110011"
|
||||
"101010001110110"
|
||||
"000000011000101"
|
||||
},
|
||||
/* 26*/ { BARCODE_AZTEC, UNICODE_MODE, 100000, -1, -1, -1, "A", -1, 0, 15, 15, 1, "FLG(6)",
|
||||
"000010010000010"
|
||||
"001101000100110"
|
||||
"001100000110111"
|
||||
"011111111111111"
|
||||
"001100000001110"
|
||||
"001101111101010"
|
||||
"011101000101111"
|
||||
"110101010101011"
|
||||
"000101000101001"
|
||||
"011101111101101"
|
||||
"101100000001110"
|
||||
"010111111111101"
|
||||
"000011000110011"
|
||||
"101010100011011"
|
||||
"000000000111010"
|
||||
},
|
||||
/* 27*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, -1, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", -1, 0, 61, 61, 0, "Zint website example gui3.png NOTE now ends with CTRL_DL . instead of CTRL_PS .; BWIPP different encodation (doesn't use CTRL_PS doubles)",
|
||||
"0010110111101110101100000101001101110100010000100111011100001"
|
||||
"0001100000000000001101110010000100010101110011000001000011110"
|
||||
"0001111110101010100101000110101101000110011000101111011100110"
|
||||
"0011000000001001101011010000010110111000011110000000010001001"
|
||||
"0111001010111110010111100000001111101100011100100000001000000"
|
||||
"1001100111000000001000011101000000001011001100000111100110000"
|
||||
"1101101000101111010010010000101100010100100100111011011100000"
|
||||
"1100100110001001100001110100100101001100011000001010110010000"
|
||||
"0000101001000010000101001001101011110000000000100000001011111"
|
||||
"1011100100011001100110101001100001100011110111010110110101001"
|
||||
"0001101000110010111010000000001010111101010000100001001000100"
|
||||
"0110100010001101000100011011100011000110000011011111001010010"
|
||||
"0010000010110011001111011110101001010101001010100110000010000"
|
||||
"1110001010110000110011000100010001111110110000011011001111001"
|
||||
"1010101010101010101010101010101010101010101010101010101010101"
|
||||
"0010110110101001010101000111110011001011000111000011100111001"
|
||||
"1100110100101111110010000000111011110100100011101100110001100"
|
||||
"0001001001100101000010011100000111100000111010011000000001101"
|
||||
"1101000001000011101100000010011100001110110010101001000010010"
|
||||
"1010110011000101100001111000100001001111100010001100111001100"
|
||||
"0010011111000011101101000010101100001001000100100110000100001"
|
||||
"0000100101100001111110111011010011101000011010000100000011101"
|
||||
"1010011010011110110000000000011010110110101001111101010001000"
|
||||
"1000100001011000111011111010100000110100010111010001010001110"
|
||||
"1001100110000011001011011111111111111110011010101011001000000"
|
||||
"1011110010100101000001001000000000001100001001011011001000000"
|
||||
"0000011111110010010001111011111111101000000001110010001110100"
|
||||
"1100000001001100110101011010000000101000010110011110010011110"
|
||||
"0110010000111011111010111010111110101010111010111111001000010"
|
||||
"0001001001111101111000011010100010101011100000000000000001010"
|
||||
"1010101010101010101010101010101010101010101010101010101010101"
|
||||
"1010111000100000110011111010100010101011100001000111100001010"
|
||||
"1101101000101111100010101010111110101001110111100010010101110"
|
||||
"0010000101101001111100101010000000101101111100011110110111110"
|
||||
"1100101110001111000000111011111111101101000101101000010100011"
|
||||
"1000011000011101111101111000000000001111100100010100010011000"
|
||||
"0010000010010111001010001111111111111110000100101110110111011"
|
||||
"0001000100011000011111100010110001100011001101000000010000100"
|
||||
"1010001010001110100101011010001101011111010011111000011001110"
|
||||
"0110000110110101011111001110000010010001010111000101000010100"
|
||||
"0110101001110010110010011100001010001100000111111100011000000"
|
||||
"1010110110000001111100011001000011011001111100010110000100000"
|
||||
"0000011010001010000011011001101001110010001100101000111011010"
|
||||
"0001001010100100010010000010110110101110101100010101010001011"
|
||||
"1100010000010110110110101101101011111001101111110100011000011"
|
||||
"0110001101000001111010001100110011001111011111010010100011000"
|
||||
"1010101010101010101010101010101010101010101010101010101010101"
|
||||
"1011000001100100011100000111010101011110110011001000100000010"
|
||||
"0000111101110110001110101001001101000011110010100000101001010"
|
||||
"0100100001011000000001000100000010001011110101010011110110000"
|
||||
"0001001110010110101001011101101010001101000000100001101000010"
|
||||
"1110010011010000011001010010010101000100110100011010001101100"
|
||||
"0011001010010010011100110100011000111011100100110001001001001"
|
||||
"0000111010110000100100000001110011001110001101010100001010101"
|
||||
"1100010010110111011011111100001011001011001011100011100000101"
|
||||
"0110111000011101110110010111100000010000011101011010001110101"
|
||||
"0001000000111010000000001100001010101111100010100000010011101"
|
||||
"0101000010010000110000000010000001110010000111000111100011000"
|
||||
"0110100111000110011010010101111110001000000011101100000100101"
|
||||
"1110000011010000000000100001100001000111011110011010000000001"
|
||||
"0000010101001111100010001001111100101000010001110010010101101"
|
||||
},
|
||||
/* 28*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 36, "Lorem ipsum dolor sit amet.", -1, 0, 151, 151, 1, "Max version 151x151",
|
||||
"0110011000001101111010100010010110101010100001110111111001101101010000111100111111111001000011100001010000101001010001001010101001000111101011111001101"
|
||||
"1011011111111000001111111001010101111011100101110110001011011000101000010101101100000110011110100000010100110111100111111011011110001000110100111100100"
|
||||
"1110001110001111110101011110010010011011001011001000001010000010000110101010101011111110110010000010000111000010000011011110001111111001000010000000111"
|
||||
"1111111110111100000010100111101000111010110101100001000110010111110111110011110100111110101100011000001010110110100001111101110111001101001101011100001"
|
||||
"0001111011000111110101010100010001011101110011011100001110100100111111001010100000010111000001100010110011100000111110011000101100011011000010100100001"
|
||||
"1010011111011100100000000001110110111000110110010101110001011100100001101101111010100110101101111101111101011101101111001001010010011000011110010111000"
|
||||
"0010100000000010010111100000011001110011011011101010011101101010000010010110110100010010010001000100001011100011011010101010001000010011001010110111111"
|
||||
"0111111001111100110000010101000101011011100110110110010011011110101110111011000100111001101100111001011011110101000100101111101001100011010100010101110"
|
||||
"0010010101101010010100100100110010111100100010111001000100000101000110110000110110100000011010001001101010100010011110101100110010010100011010001011011"
|
||||
"1110101000010010000001001011111110111011001110110000111011111010110010001011111101011101110100100000010101110001010101101001101101101110011110100001110"
|
||||
"0001011111001011100101100010111101000010011010000010010100000111011111100010110101100000101011011101001000000011000001011110001001001011101001101001000"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"1110101001101000000110000100110101010101001011110010001100001111110110010000101011100011011001000110101100100110110100001010001011101111011000001110110"
|
||||
"0000111010111110110101010011100110100110111101010000011001110011001101100011100001000000100100110101110111010011010110011101110111100101011110001001001"
|
||||
"1110100110100000100100001010111100110000001000000100001010000010010110001010001111111010111001010110111100100001110110011000100011100011011001100001000"
|
||||
"1001000111111111011011001111011110111000011110101110011100011101110001010111001111001010100110010010000101011100110010001001011100010010111100110111101"
|
||||
"0001001001001100010001111110010110001101000011010111000011001000111110011110000100111111100010011001100111001001110111110000110101110001100010001000010"
|
||||
"0000000100011110100100000011010101101011010111110000000110110010011111110111010110100001111110011000010001110100101110000101011100001000111101100000010"
|
||||
"1001000010101000000001001000101000111110010000110111000111100111111010100100111101101001101010100010010010101001110011001100010001110001000000101001111"
|
||||
"1011010010111100010011100001111110100001100100010001001010110101111101010101111101010101011101110101011111110110011011101101001110000101110111010010110"
|
||||
"1000010000000110100010011000100011000000100000011111111101100001010111000010000101100110101011011010000100000100100111100010000010110100010011100010110"
|
||||
"1010110100110111101010110101000000001111001111011001111000010011010111001111110000111011000101000110010011011100110111101001111001000001110100001101001"
|
||||
"0001100110001110101110000010000000111100000011111000101110101111100111001110011001000110001011100101001100101110010000000000011111101011011011001010110"
|
||||
"1110001000010100000011010011011100011000010111101010111111010011001010011101010110011010001111101001100101011101100100011111111111000001010101011001011"
|
||||
"0100110011100111100111010110010011000001010011001100110010101000101001001010100111100110000001001101011101101000111001100100011010011000001001100111110"
|
||||
"0011001110110110101100000101000111010001110110010110101000010111111110100001101011000110011111000000101011011000110001010001101111000111000101000101101"
|
||||
"1001000100101010110101111010011011011101101000011000001011001000000011110000011110100111100011100001011001001011011100111010010100101110000000111011110"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"1101101101100010000110100110000001010101011010111011011010101100010100000100100110011100011000100111010110100100111011101010110111100011011000011011101"
|
||||
"0010011010011111011100111101111001010010101100001000011000111101010100111001011100010101011100110001001100110001101111101111000110110000010111001011111"
|
||||
"1101000110001011110100100110010100000011000000010000111010001001010100000010110101000010000000001010000001100011101011001110011011000111101011111001000"
|
||||
"1001000010110011011110000111100001100001111100111111001100010111011101101111111101011101110110101110111011011100111101110001110010110001000101011011000"
|
||||
"0000000100100000011011001110011011001010000011110000101001100000011100110010101010010010001010010011101100100100001001101000110111000000010010011111000"
|
||||
"0010111110111010010000100001111110010010100111100010001100110000100111011011010111010101100110110010000010011010111011010111011111111000000101110101110"
|
||||
"1010101111000010110010011010101001101010111000010010010001001110010111111100110111010110111001101100000000001010101100100000101011100101100011100100101"
|
||||
"0110101110110100101100111001111000011000001101000011100011011010110011010011001100011101011101011100110001110110000000100011011111011100101110111100110"
|
||||
"0111110110101000001001001000100101011000100001110011100000000000111111100100010101001100010010011101010011000110111100010000111000000111011000100100001"
|
||||
"1010010111111010001001100001001101111100100110101101011000011110010111001101101001101000000101111000010010010111001100111101110110010001101101010100000"
|
||||
"0011100010101101110010100010101000010011001000100000010110100110110010001100001100111100001010101101001010101000011110010110110101100101001000110000001"
|
||||
"0000001010011110010101110111001100001101011110000011110111111010101111001101111000110000110100110001101000111100010111010011001000001010100100010111110"
|
||||
"1100110111001001100100000000100000000001001000011001011011100000001111100110001110001111000011111001010111100111000111111110101011100101011000000100001"
|
||||
"0101110000110100000101101001001011011110110101011010110110010110000001101001011001110110000101101000000011111000101100101101001100101001001110010010001"
|
||||
"1000000100101010101110001010101010000110100000000010010101100100001000000000100110010100001011010001110100000111110110111010011110000000000011101100001"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"0010101101101101000001101000100111100101010000110001010010101000010000000000000010111010100010010000000010101111100001010010001101001110001001101000001"
|
||||
"0111010100111101011001001101101001000011000111111111110011010101000000010011101010101010010100000100110001011000100110100011110000110110000111111001101"
|
||||
"0001001101101100100010100000100110100000011001110010000110001011100100010010101011011000011000101011011110101011100100101000111001010001100011011100100"
|
||||
"1101011011011101000110100111100100011011110110101010011010011100101010000101000101000110101110001011000100110100101001011001000100011000011101000010101"
|
||||
"0011100100101001100001000100011011110010100000000110010100100101001000010000100111101100001011010010001101100111111000010010110000110110011001000001011"
|
||||
"0011100010111011110010111101010001000110110100110011101011110011111100101101011001101011001111000110111111010100100100101001111110010000100111000001010"
|
||||
"1100101101000011110101001110110011011100100011000011101101001001100011011000000111101011110010001100111101101100011000111100001010110100100011100100010"
|
||||
"0100110010010111110000101011101111111101111110000001010011111011111111101001110110001001011101100101110000111111101110000101101010010010010111110101010"
|
||||
"0011001100000011000111111000101001000010011011000010001111100001111011010100100110000100101000110010010011001110000100011100010111011101101001011111001"
|
||||
"0111110110010111010011000001010110110101010100011101001111011010001000011101100000001101101110000011000111010010100110010001110110100010010110001101100"
|
||||
"0110011111100110111111101000111110100100011001100010100101001100110100100010001010101110101010000110011111000001010101101100100011011100000001001110000"
|
||||
"0111110101010110000101100011100010010110000100110000001111110001111010010101010101100111001100011100001010010001001000101111110101001011111101001100001"
|
||||
"0111011010000001000101011010110010110011100010110110010011001101110011011100011110010000011001100100011001101101000110001000001000101010101010111000000"
|
||||
"0100000101011111110001001011011111000101011111101011101100011111001001110111110001010101011101101010110011111101100110100011001101010000000101001011001"
|
||||
"0011001010101111100011001010010011100001001011100111111111101111010011011100011110000110101001001101101100000100010001101010100101100001111011101001010"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"0000011100101011001000111110011011101100011010001011010010001110111011101000101001011111010011001010100011001000000000101110010010010111010010001111010"
|
||||
"1001100110011100011111000101000000100000011101110101110011111000000100011011000001110011100110001001101110010011001110101101100100100100001101000010111"
|
||||
"0001010010100000011111001110101010100111011011000111110100000010111111101010111001000001110000111000001111101011000010100000111000001000111001111000000"
|
||||
"1011111100010010110100100101010100010010001110100000101001011111110011110101101110000000110101001011100011111001111101111111111010110101010110100100001"
|
||||
"0101111011100000110101111100110110000000000011011101110011101111000101111100011101111000111010110110100100001111101110000010101011110010110011011010011"
|
||||
"1110100100110011000110110101000010010011000110110100011000010010111011000111010100110100010111111100110000010011101011000011010001011100000110000100001"
|
||||
"0001111101001000101110001100100001011100011010101000001111100000111100111110010100011101011001010101101001001010101101001110110110001100100010000100011"
|
||||
"0101010000110101111110010101100100001101101101111000101000110011100101001011001111101001001110100001101111111101111011100101111001001000010101011001110"
|
||||
"1001010000001111111000000010011001010011100000010111101101100101010111111110000000111010000010100111010010000100000110010010011110110111110001011100100"
|
||||
"1010111001010011111110000101000100010101001110101101111110110101101111111111111111100100110101111001010000111001101101110001111110111010110101110011111"
|
||||
"1000000100100010010101011110110111100111011011101000111111001110001001000000000001010110010000000110100001100000101111001000001010100101101000010001001"
|
||||
"1110011000111101010011001111011010010011001100101100101110010101101111011111111101010101011110111001010001110000000010000001011110101110010111001100111"
|
||||
"1100100000000011110001110010001100000011001011011000111101101001001001010000000101110011010010000011011100000000101100000010000101100110111010011101000"
|
||||
"1001001010110111111111010011010101111010101111000101110111011011110101010111110101001000001111111111010100111001111110010101001100110100000100110000000"
|
||||
"1110010000000011010111110000001010000110010011100111111100000001000011010100010101101111011010110000010000000010000110111100010001001011100000000101110"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"0111000010101100001110010100000100001100111001111010010011001110111001010100010101100001010000111111001010101010100010100010100001110101010001001110000"
|
||||
"1100010110010000110000100101001011111100111100101100001001111101011001010111110101000101010100111111001101011000111000010111000001011100000110000010011"
|
||||
"0000100111000001011000100110100010111000001010011101111100001111000101010000000101010101000011100110100101000011101100010110001001110001010000111000100"
|
||||
"1111110010010110011010100111010110000100111101111101111110110100000001011111111101000010010110101000010101010111010010100111010110011101110110000100011"
|
||||
"1100111010101111110010110100100110100010101010111111101010001101100011000000000001100010001000011110100001000001010010010000110011000001000010100011001"
|
||||
"1010111010010000101001111001111011111011001100101100000011010101100001111111111111111101001100110010010001110010100010010011000011100111011100110001110"
|
||||
"0101101101000000010100101000000111000000011011001000110000001110011000100110100010000101100000101011010110101110111111101100010111111000100001000100000"
|
||||
"0001101001011101010111101101111101011000001111111110000100010111011101101011010000101000110100010100100001010011111101011101110010001011101100000100100"
|
||||
"1101101111100101000111111110111010110101100010101010001101100000011001000110000010011001100011001101000100100111101000001100110101110101011011011010100"
|
||||
"1110001010010010110101010011011100000111101101111100001011111111001001010101010101001001111100010000010101011101101101001001011011110000110101101101000"
|
||||
"1110001011100111101011001100111010010111000001100111110001101110001101111010000011011000111010100001101011100010110010111100110111111010101000000010101"
|
||||
"0010100101111110111110001111000001101110100100100110011111010001001010010101000001111100100111110100001110110011111001011111010001100100101100010000001"
|
||||
"1010001010100100110110111010011010100010101001010101010101000011011000011110110111010010101000110101101111101011110110011100101000101101111011011011110"
|
||||
"0110000100010000100101110101101010010101010100001111011000111101011010110101010101101100001110011001001010111110001101100101000111011101000101101101000"
|
||||
"0111011011000001110010111100100001111100000011000000011010000101101010100010100101010000010001011001101101000100111100101110001100111001101001000111000"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"1001000110000001010110111110000011111101101010010001111000101001010100010010100110001100100001001000000000000100111101111110001001000111000000000010101"
|
||||
"1101000100010100111100010111111111001010011111100111101011111010101110110011101010010101100101111111001100011111111111110101011000110101001110001110000"
|
||||
"1100010101100000000000111000000001011101010011010111000100000011100111100010010001000011101001000100010101001001110101011010010011100001010011101000000"
|
||||
"1011100010110110110000100101100000000010010111010101100111110101001110000101111011100110101111100010101011110011110100101111101111011011101101111111110"
|
||||
"1001101001000101000101000110110101001110111000011011110000100000110101110010011011100111111011100101111001001100101011000000011100010111111011010110100"
|
||||
"1110100111010111100010100011100000010001101101110101000001111011010000000011000110100100110101101000110000110010101001101101110100100111110111000111001"
|
||||
"1110011001100100010111011010001010010100001001110101001101000001101100001010110111000010001010011010100111101100000101010100001011101110001001101110111"
|
||||
"0011001000011100100111111111000111111100110100100100001011010101011110101101110100101101101101110111101110011101001101100111100111001101100100010110111"
|
||||
"1101011110001110111110100110001001000111111010011001010000100011110110110100000001101101000010010010111011101010100111101100001000100011010011111111011"
|
||||
"1001100111010000100111100111010110111100010110111000010011110100110010011101100110101101010111001101100100111101001011001101010110100010111110010100010"
|
||||
"1010100000100101000100111010101101000101011010000010011101001100110101001010001001010011010010111101000111101011011001101000001011111011010001111010011"
|
||||
"0001111010010010001100110101111111101100001101101001000101111111111101010001111011001011101111111010011101010110111111001111100110001101100101001100110"
|
||||
"0101000000101011000000010000101001011110111011111101001101000010101100101100011000000100000000001011100101001101111100110100010010100010111010011110011"
|
||||
"1100010010110101000101011011110100001011100101001011011101111101000111101011000000100011001111100110011010111111101001010001001100000101011101001001010"
|
||||
"1011111100100010001111101100010001011011001010000111110000101010000100010100101010000000011000101001100011100111010111010110010100010101111010110011000"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"1010011001001000111101011100011010101000111000111111111111001001110110001010010101100001011010110111010101101100011101111100010111101001010011100001111"
|
||||
"1010000001011110101000101111001000110010000110001010111000011010110010111111110111100011001111111010001000110001111100010001100110100110100110110111100"
|
||||
"1110100110001001111000011110010110101001100000011010010010101110100011100110011100000010000000100100001000100101100001000000100110100011101010101110101"
|
||||
"0010111110010111100101011001100101010001010101101001001101011111011010011011000110001011101111001111011111011001010100010001110011101101011111101010010"
|
||||
"0110111010101110011111101100101011000110011011101001110100101101101100010010111101000111010010010010111100001100101010011000001000000111100010011000100"
|
||||
"1111111100011101110010111001000110010000101100101011101011011100110111000111010100001101001101111001001100011010111011110111111000010111010101000010100"
|
||||
"0101111000101010101001011010011111101111011011010010100110001110010010101010000010101111011010100000011100001101000001111110110111000100011011100111100"
|
||||
"0110000000011011110101001001011010100001010110010100011100111011000010000101010000001011110111111111100001010111010001110011001101010100110110000000000"
|
||||
"1100110001000100110100011010110011110110000011010100111010100100011000000000010000110000110000111100010001100101101101111110101110011110000010101111011"
|
||||
"1100110111110000010100001011001000001111001111101101010000011111001011100101110100100011110101110101011111111100001100100101100100111111010110011010110"
|
||||
"0110110011000111100000011110111001110001101011101000100010101101101101110100100011100110010011100111101111100101100111011110001100111011010001110001101"
|
||||
"0111001010110101011001001011000101101001001100110000000001111101011010001101001000010010011110101101111110011111101110100011101111001001011100101111101"
|
||||
"0010011101101010100111100010011100010011000011010101101000001010100011101010111111100110001000000001101100100110110000000110011001011001111011101100001"
|
||||
"1000110111011110100100110001000010010000100111011010001000011010111100010101001100011111101100010110000011011111101000001011111100110001101110110101011"
|
||||
"1101011001101010111110000110100101010000100001001110101110000100010110001110010001010011100010110101010110001100000001101000010011101010000000111101011"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"0001001110100100001101000110101001111011101001011011001100101100111110000010101011101111010000000000100110101101001101011100000100000011011000010011101"
|
||||
"1000010101110010110001111011101111111001101111011011101101011110001011110101010101011011010101100011101101010100111001111001100100010000001101111001011"
|
||||
"1001110110000010011011111000101000110010000010000111001101100100100101110000101010011110111011010000001010101111011110100110011011100000111001100111011"
|
||||
"0110000100011001011000111101110001111001000101000011111110011110110101000001111101111101100111110010101010110001011011000101011001101111110100110101011"
|
||||
"1010100111100111101110010100001010110011000000010110011000000010100001000010101000111011100001001001010111001101010100100000110001011100011001100100100"
|
||||
"1101011100111100110101110101001111100100010100110111011000010110100000000101001001001100011100101011110011110101001100110011010011111011010100100011100"
|
||||
"0001111101101100011000100010110100110011100011011110110011101000101010010100110110010000011010100100101001100100011011111100101100101000110001100000010"
|
||||
"0110110101010101011000000011101100110000010110111001001100111011011100000111110110111110110111101011000010010111010101110001110101110010111101011011101"
|
||||
"1011010000100001101110101100011101011001000010110111111001000111101101011010110010010111010011000111101000100000110000011000010010110001011011110111110"
|
||||
"0011101110011110110100001101100111100101101110100010001100011100001001001001000111001000000100100110001100111011100100001101101000011101010101100000010"
|
||||
"0101000110101100011100101110101011111000001000010101011000000011001100101000110010100000101010110001111101101011010010010100011000001010001010010100111"
|
||||
"1000100000111011001011000011100010110110100111011111001000111111111110011101010011100001010100111010011011011001001001011001010001011001011101011111110"
|
||||
"0111110000100111111101001110011000101101110000010010101111101101000010000010000011100101011000101000011110101111100010000110010010100100110011011110010"
|
||||
"0110100111111100001111000011010011010101101110001001110101111011000001000001001000100010001110100100001110010010010110100011001101000001100111110101001"
|
||||
"0010011011100100101100011110010110011010001010001110111000101011100101001000101001001001101000010110000110101000011110110010101110101000011000000010110"
|
||||
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
|
||||
"0000111011001011101000110110100010010000000011011011011101001010110100101110110100001010100000001000101100000100011011001100001001101011011000111010100"
|
||||
"1011101011110000100011110101010110111100011110111001011001010000001011111111010111001100010111110011111000110011001011111111010010110100111101001111101"
|
||||
"0111100100101010000001010010000101011001000001001101110000101010110000111110010110010101000010000011001011101001000110010010000011101010110001100111100"
|
||||
"1000101111010011001101110101000110000001001100111110010110010010010001011001010111100110110111001001001001111101101101010001011111100101110100011110100"
|
||||
"1101000111101110010011001110111100100110010000000110001101001001110000111100010101011100010011001101111100101110111100001000001111100000101011110110100"
|
||||
"0110111110110001100101011101000011111001001111010100100101110011010000111111101100100111010111000101000001010011110011100011010001111011100111001101100"
|
||||
"0101010101101010010000110100111010110010110001110011110011101100011111110000000101010001000011001011111100000111101000010010111111011111101000110010001"
|
||||
"1100111000010101000011100001001001101000111101110011001001010111011111001001011011100001101100100010000001111100101001001111110000000110101111001100111"
|
||||
"1001101001000001000111111110110101001101010000110110110011101100000101011010111100101000001011001101101010000010101000010110001101101011110001110010001"
|
||||
"1000000100011011110011111011110000011111110111001111111010110101100011000111010100100010001111000101110110110100000111000011101011011101111111000011111"
|
||||
"1000110110001001001111110010011100000100011010101101101101101001001001011110101010011110010011011110100111100111110111111110000101100111110000101010011"
|
||||
},
|
||||
/* 29*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "0", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (1st)",
|
||||
"11101010101"
|
||||
"11111111111"
|
||||
"01000000010"
|
||||
@ -822,7 +1127,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00101010100"
|
||||
},
|
||||
/* 23*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "25", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (2nd)",
|
||||
/* 30*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "25", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (2nd)",
|
||||
"11101100101"
|
||||
"11111111111"
|
||||
"01000000011"
|
||||
@ -835,7 +1140,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00100100000"
|
||||
},
|
||||
/* 24*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "125", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (3rd)",
|
||||
/* 31*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "125", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (3rd)",
|
||||
"11110101101"
|
||||
"11111111111"
|
||||
"11000000011"
|
||||
@ -848,7 +1153,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00111101000"
|
||||
},
|
||||
/* 25*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "255", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (4th)",
|
||||
/* 32*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "255", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (4th)",
|
||||
"11010101001"
|
||||
"11111111111"
|
||||
"01000000011"
|
||||
@ -861,7 +1166,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00110011100"
|
||||
},
|
||||
/* 26*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "1", -1, 0, 11, 11, 1, "",
|
||||
/* 33*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "1", -1, 0, 11, 11, 1, "",
|
||||
"11101010101"
|
||||
"11111111111"
|
||||
"11000000011"
|
||||
@ -874,7 +1179,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00100110100"
|
||||
},
|
||||
/* 27*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "15", -1, 0, 11, 11, 1, "",
|
||||
/* 34*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "15", -1, 0, 11, 11, 1, "",
|
||||
"11101001001"
|
||||
"11111111111"
|
||||
"11000000011"
|
||||
@ -887,7 +1192,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00001111100"
|
||||
},
|
||||
/* 28*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "16", -1, 0, 11, 11, 1, "",
|
||||
/* 35*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "16", -1, 0, 11, 11, 1, "",
|
||||
"11101110101"
|
||||
"11111111111"
|
||||
"11000000010"
|
||||
@ -900,7 +1205,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00111100100"
|
||||
},
|
||||
/* 29*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "63", -1, 0, 11, 11, 1, "",
|
||||
/* 36*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "63", -1, 0, 11, 11, 1, "",
|
||||
"11100101001"
|
||||
"11111111111"
|
||||
"11000000011"
|
||||
@ -913,7 +1218,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00101010000"
|
||||
},
|
||||
/* 30*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "64", -1, 0, 11, 11, 1, "",
|
||||
/* 37*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "64", -1, 0, 11, 11, 1, "",
|
||||
"11111010101"
|
||||
"11111111111"
|
||||
"01000000010"
|
||||
@ -926,7 +1231,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00111011100"
|
||||
},
|
||||
/* 31*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "65", -1, 0, 11, 11, 1, "",
|
||||
/* 38*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "65", -1, 0, 11, 11, 1, "",
|
||||
"11111010101"
|
||||
"11111111111"
|
||||
"11000000011"
|
||||
@ -939,7 +1244,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00110111100"
|
||||
},
|
||||
/* 32*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "126", -1, 0, 11, 11, 1, "",
|
||||
/* 39*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "126", -1, 0, 11, 11, 1, "",
|
||||
"11110101001"
|
||||
"11111111111"
|
||||
"01000000010"
|
||||
@ -952,7 +1257,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00110111000"
|
||||
},
|
||||
/* 33*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "127", -1, 0, 11, 11, 1, "",
|
||||
/* 40*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "127", -1, 0, 11, 11, 1, "",
|
||||
"11110101001"
|
||||
"11111111111"
|
||||
"11000000011"
|
||||
@ -965,7 +1270,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00111011000"
|
||||
},
|
||||
/* 34*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "128", -1, 0, 11, 11, 1, "",
|
||||
/* 41*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "128", -1, 0, 11, 11, 1, "",
|
||||
"11001010101"
|
||||
"11111111111"
|
||||
"11000000010"
|
||||
@ -978,7 +1283,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00100010000"
|
||||
},
|
||||
/* 35*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "191", -1, 0, 11, 11, 1, "",
|
||||
/* 42*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "191", -1, 0, 11, 11, 1, "",
|
||||
"11000101001"
|
||||
"11111111111"
|
||||
"01000000011"
|
||||
@ -991,7 +1296,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00100010100"
|
||||
},
|
||||
/* 36*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "192", -1, 0, 11, 11, 1, "",
|
||||
/* 43*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "192", -1, 0, 11, 11, 1, "",
|
||||
"11011010101"
|
||||
"11111111111"
|
||||
"11000000010"
|
||||
@ -1004,7 +1309,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00110011000"
|
||||
},
|
||||
/* 37*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "225", -1, 0, 11, 11, 1, "",
|
||||
/* 44*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "225", -1, 0, 11, 11, 1, "",
|
||||
"11010010101"
|
||||
"11111111111"
|
||||
"11000000011"
|
||||
@ -1017,7 +1322,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"01111111111"
|
||||
"00001100100"
|
||||
},
|
||||
/* 38*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "254", -1, 0, 11, 11, 1, "",
|
||||
/* 45*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "254", -1, 0, 11, 11, 1, "",
|
||||
"11010101001"
|
||||
"11111111111"
|
||||
"11000000010"
|
||||
@ -1034,7 +1339,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
char escaped[1024];
|
||||
char bwipp_buf[16384];
|
||||
char bwipp_buf[32768];
|
||||
char bwipp_msg[1024];
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
@ -1524,12 +1829,116 @@ static void test_fuzz(int index, int debug) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#define TEST_PERF_ITERATIONS 1000
|
||||
|
||||
// Not a real test, just performance indicator
|
||||
static void test_perf(int index, int debug) {
|
||||
|
||||
if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
|
||||
return;
|
||||
}
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
int option_1;
|
||||
int option_2;
|
||||
char *data;
|
||||
int ret;
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_AZTEC, -1, -1, -1,
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
0, 49, 49, "286 chars, 8-bit words, upper" },
|
||||
/* 1*/ { BARCODE_AZTEC, -1, -1, -1,
|
||||
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
||||
0, 79, 79, "900 chars, 10-bit words, numeric" },
|
||||
/* 2*/ { BARCODE_AZTEC, -1, -1, -1,
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377",
|
||||
0, 91, 91, "980 chars, 10-bit words, mixed" },
|
||||
/* 3*/ { BARCODE_AZTEC, -1, -1, -1,
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377",
|
||||
0, 113, 113, "1540 chars, 12-bit words, mixed" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer;
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
diff_encode = diff_buffer = 0;
|
||||
|
||||
for (int j = 0; j < TEST_PERF_ITERATIONS; j++) {
|
||||
struct zint_symbol *symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
diff_encode += clock() - start;
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/);
|
||||
diff_buffer += clock() - start;
|
||||
assert_zero(ret, "i:%d ZBarcode_Buffer ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
printf("%s: diff_encode %gms, diff_buffer %gms\n", data[i].comment, diff_encode * 1000.0 / CLOCKS_PER_SEC, diff_buffer * 1000.0 / CLOCKS_PER_SEC);
|
||||
|
||||
total_encode += diff_encode;
|
||||
total_buffer += diff_buffer;
|
||||
}
|
||||
if (index != -1) {
|
||||
printf("totals: encode %gms, buffer %gms\n", total_encode * 1000.0 / CLOCKS_PER_SEC, total_buffer * 1000.0 / CLOCKS_PER_SEC);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
{ "test_options", test_options, 1, 0, 1 },
|
||||
{ "test_encode", test_encode, 1, 1, 1 },
|
||||
{ "test_fuzz", test_fuzz, 1, 0, 1 },
|
||||
{ "test_perf", test_perf, 1, 0, 1 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
@ -178,11 +178,12 @@ static void test_encode(int index, int generate, int debug) {
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
int bwipp_cmp;
|
||||
char *comment;
|
||||
char *expected;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { -1, "123456789012", -1, 0, 16, 18, "",
|
||||
/* 0*/ { -1, "123456789012", -1, 0, 16, 18, 1, "",
|
||||
"100011101010111101"
|
||||
"111010010010100000"
|
||||
"110110100010001000"
|
||||
@ -200,6 +201,54 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"010111110100100111"
|
||||
"100010001101111100"
|
||||
},
|
||||
/* 1*/ { -1, "Code One", -1, 0, 16, 18, 1, "BWIPP example",
|
||||
"010011011101100110"
|
||||
"010010000001010110"
|
||||
"001010010101100110"
|
||||
"000110000011110110"
|
||||
"100010100000111001"
|
||||
"000010000000100000"
|
||||
"111111111111111111"
|
||||
"000000000000000000"
|
||||
"011111111111111110"
|
||||
"010000000000000010"
|
||||
"011111111111111110"
|
||||
"000100011110101101"
|
||||
"101101000111101011"
|
||||
"010100001110101100"
|
||||
"100001100111100100"
|
||||
"100000111000111000"
|
||||
},
|
||||
/* 2*/ { 3, "1234567890ABCDEF", -1, 0, 28, 32, 0, "https://fr.wikipedia.org/wiki/Liste_des_symbologies, same; BWIPP **NOT SAME**, has unlatch to ASCII at end, no doc so don't know if necessary",
|
||||
"10001110101011110111011110110101"
|
||||
"11101001001010000011000110101001"
|
||||
"11101001100010100010001000101000"
|
||||
"10011011010100000100010001100001"
|
||||
"10001010001000100010001000101000"
|
||||
"00011000010001000100010001100001"
|
||||
"10001010001000100010001000101000"
|
||||
"00011000010001000100010001100001"
|
||||
"10001010001000100010001000101000"
|
||||
"00011000010001000100010001100001"
|
||||
"00001000000000000000000000100000"
|
||||
"11111111111111111111111111111111"
|
||||
"00000000000000000000000000100000"
|
||||
"11111111111111111111111111111111"
|
||||
"00000000000000000000000000000000"
|
||||
"01111111111111111111111111111110"
|
||||
"01000000000000000000000000000010"
|
||||
"01111111111111111111111111111110"
|
||||
"10001010001000100010001000101000"
|
||||
"00011000010001000100010001100001"
|
||||
"10001010000101011110001101100110"
|
||||
"00011000010010101010111011100100"
|
||||
"11101011011100101001000110101100"
|
||||
"01111000000000010001000111101111"
|
||||
"00001010100010111100100100101100"
|
||||
"10001000101110100001010011100110"
|
||||
"00001011001001010100010001101111"
|
||||
"00101101111001111011011001111010"
|
||||
},
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
@ -220,9 +269,9 @@ static void test_encode(int index, int generate, int debug) {
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (generate) {
|
||||
printf(" /*%3d*/ { %d, \"%s\", %d, %s, %d, %d, \"%s\",\n",
|
||||
printf(" /*%3d*/ { %d, \"%s\", %d, %s, %d, %d, %d, \"%s\",\n",
|
||||
i, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||
testUtilModulesDump(symbol, " ", "\n");
|
||||
printf(" },\n");
|
||||
} else {
|
||||
@ -235,12 +284,16 @@ static void test_encode(int index, int generate, int debug) {
|
||||
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
|
||||
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
if (!data[i].bwipp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
} else {
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
|
||||
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ static void test_utf8_to_unicode(int index, int debug) {
|
||||
int length;
|
||||
int disallow_4byte;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_vals[20];
|
||||
char *comment;
|
||||
};
|
||||
@ -64,14 +64,14 @@ static void test_utf8_to_unicode(int index, int debug) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
ret = utf8_to_unicode(&symbol, (unsigned char *) data[i].data, vals, &ret_length, data[i].disallow_4byte);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %ld != %ld\n", i, ret_length, data[i].ret_length);
|
||||
for (size_t j = 0; j < ret_length; j++) {
|
||||
assert_equal(vals[j], data[i].expected_vals[j], "i:%d vals[%zu] %04X != %04X\n", i, j, vals[j], data[i].expected_vals[j]);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < ret_length; j++) {
|
||||
assert_equal(vals[j], data[i].expected_vals[j], "i:%d vals[%d] %04X != %04X\n", i, j, vals[j], data[i].expected_vals[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,8 +103,8 @@ static void test_debug_test_codeword_dump_int(int index, int debug) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
debug_test_codeword_dump_int(&symbol, data[i].codewords, data[i].length);
|
||||
assert_nonzero(strlen(symbol.errtxt) < 92, "i:%d strlen(%s) >= 92 (%zu)\n", i, symbol.errtxt, strlen(symbol.errtxt));
|
||||
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (%zu, %zu)\n", i, symbol.errtxt, data[i].expected, strlen(symbol.errtxt), strlen(data[i].expected));
|
||||
assert_nonzero(strlen(symbol.errtxt) < 92, "i:%d strlen(%s) >= 92 (%d)\n", i, symbol.errtxt, (int) strlen(symbol.errtxt));
|
||||
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (%d, %d)\n", i, symbol.errtxt, data[i].expected, (int) strlen(symbol.errtxt), (int) strlen(data[i].expected));
|
||||
}
|
||||
|
||||
testFinish();
|
||||
|
@ -42,6 +42,7 @@ static void test_bom(int debug) {
|
||||
symbol->input_mode = UNICODE_MODE;
|
||||
symbol->option_1 = 4;
|
||||
symbol->option_2 = 1;
|
||||
symbol->option_3 = 5 << 8; // Mask 100 (instead of automatic 010)
|
||||
symbol->debug |= debug;
|
||||
|
||||
char data[] = "\xEF\xBB\xBF‹"; // U+FEFF BOM, with U+2039 (only in Windows pages)
|
||||
|
@ -32,69 +32,6 @@
|
||||
#include "testcommon.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
static void test_emf(int index, int debug) {
|
||||
|
||||
testStart("");
|
||||
|
||||
if (!testUtilHaveLibreOffice()) {
|
||||
testSkip("LibreOffice not available");
|
||||
return;
|
||||
}
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
int option_1;
|
||||
int option_2;
|
||||
char *fgcolour;
|
||||
char *bgcolour;
|
||||
float scale;
|
||||
char *data;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_EANX, -1, -1, "", "", 0, "210987654321+54321" }, // #185 Byte count, font data, HeaderExtension1/2
|
||||
/* 1*/ { BARCODE_MAXICODE, -1, 20, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL..." }, // #185 Maxicode scaling
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
struct zint_symbol *symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
if (*data[i].fgcolour) {
|
||||
strcpy(symbol->fgcolour, data[i].fgcolour);
|
||||
}
|
||||
if (*data[i].bgcolour) {
|
||||
strcpy(symbol->bgcolour, data[i].bgcolour);
|
||||
}
|
||||
if (data[i].scale != 0) {
|
||||
symbol->scale = data[i].scale;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||
|
||||
char *filename = "out.emf";
|
||||
strcpy(symbol->outfile, filename);
|
||||
ret = ZBarcode_Print(symbol, 0);
|
||||
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||
|
||||
ret = testUtilVerifyLibreOffice(symbol->outfile, debug); // Slow
|
||||
assert_zero(ret, "i:%d %s libreoffice %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||
|
||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_print(int index, int generate, int debug) {
|
||||
|
||||
testStart("");
|
||||
@ -115,26 +52,29 @@ static void test_print(int index, int generate, int debug) {
|
||||
char *fgcolour;
|
||||
char *bgcolour;
|
||||
int rotate_angle;
|
||||
char* data;
|
||||
char* expected_file;
|
||||
char *data;
|
||||
char *expected_file;
|
||||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, BOLD_TEXT, -1, -1, -1, "", "", 0, "Égjpqy", "../data/emf/code128_egrave_bold.emf" },
|
||||
/* 1*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, "147AD0", "FC9630", 0, "123", "../data/emf/telenum_fg_bg.emf" },
|
||||
/* 2*/ { BARCODE_ULTRA, -1, -1, 5, -1, -1, "147AD0", "FC9630", 0, "123", "../data/emf/ultracode_fg_bg.emf" },
|
||||
/* 3*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "9780877799306+54321", "../data/emf/ean13_5addon_ggs_5.2.2.5.2-2.emf" },
|
||||
/* 4*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, "", "", 0, "012345678905+24", "../data/emf/upca_2addon_ggs_5.2.6.6-5.emf" },
|
||||
/* 5*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, "", "", 0, "0123456+12", "../data/emf/upce_2addon.emf" },
|
||||
/* 6*/ { BARCODE_UPCE, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, "", "", 0, "0123456+12", "../data/emf/upce_2addon_small_bold.emf" },
|
||||
/* 7*/ { BARCODE_ITF14, -1, BOLD_TEXT, -1, -1, -1, "", "", 0, "123", "../data/emf/itf14_bold.emf" },
|
||||
/* 8*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 90, "123", "../data/emf/code39_rotate_90.emf" },
|
||||
/* 9*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 180, "123", "../data/emf/code39_rotate_180.emf" },
|
||||
/* 10*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 270, "123", "../data/emf/code39_rotate_270.emf" },
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, BOLD_TEXT, -1, -1, -1, "", "", 0, "Égjpqy", "../data/emf/code128_egrave_bold.emf", "" },
|
||||
/* 1*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, "147AD0", "FC9630", 0, "123", "../data/emf/telenum_fg_bg.emf", "" },
|
||||
/* 2*/ { BARCODE_ULTRA, -1, -1, 5, -1, -1, "147AD0", "FC9630", 0, "123", "../data/emf/ultracode_fg_bg.emf", "" },
|
||||
/* 3*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "9780877799306+54321", "../data/emf/ean13_5addon_ggs_5.2.2.5.2-2.emf", "" },
|
||||
/* 4*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "210987654321+54321", "../data/emf/ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" },
|
||||
/* 5*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, "", "", 0, "012345678905+24", "../data/emf/upca_2addon_ggs_5.2.6.6-5.emf", "" },
|
||||
/* 6*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, "", "", 0, "0123456+12", "../data/emf/upce_2addon.emf", "" },
|
||||
/* 7*/ { BARCODE_UPCE, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, "", "", 0, "0123456+12", "../data/emf/upce_2addon_small_bold.emf", "" },
|
||||
/* 8*/ { BARCODE_ITF14, -1, BOLD_TEXT, -1, -1, -1, "", "", 0, "123", "../data/emf/itf14_bold.emf", "" },
|
||||
/* 9*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 90, "123", "../data/emf/code39_rotate_90.emf", "" },
|
||||
/* 10*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 180, "123", "../data/emf/code39_rotate_180.emf", "" },
|
||||
/* 11*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 270, "123", "../data/emf/code39_rotate_270.emf", "" },
|
||||
/* 12*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 20, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "../data/emf/maxicode_#185.emf", "#185 Maxicode scaling" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
char* data_dir = "../data/emf";
|
||||
char* emf = "out.emf";
|
||||
char *data_dir = "../data/emf";
|
||||
char *emf = "out.emf";
|
||||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
@ -171,12 +111,16 @@ static void test_print(int index, int generate, int debug) {
|
||||
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||
|
||||
if (generate) {
|
||||
printf(" /*%3d*/ { %s, %s, %s, %d, %d, %d, \"%s\", \"%s\", %d, \"%s\", \"%s\"},\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width,
|
||||
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file);
|
||||
printf(" /*%3d*/ { %s, %s, %s, %d, %d, %d, \"%s\", \"%s\", %d, \"%s\", \"%s\" \"%s\" },\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
|
||||
testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width,
|
||||
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle,
|
||||
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file, data[i].comment);
|
||||
ret = rename(symbol->outfile, data[i].expected_file);
|
||||
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
||||
if (have_libreoffice) {
|
||||
// Note this will fail (on Ubuntu anyway) if LibreOffice Base/Calc/Impress/Writer running (i.e. anything but LibreOffice Draw)
|
||||
// Doesn't seem to be a way to force Draw invocation through the command line
|
||||
ret = testUtilVerifyLibreOffice(data[i].expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s libreoffice %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
||||
}
|
||||
@ -198,7 +142,6 @@ static void test_print(int index, int generate, int debug) {
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
{ "test_emf", test_emf, 1, 0, 1 },
|
||||
{ "test_print", test_print, 1, 1, 1 },
|
||||
};
|
||||
|
||||
|
@ -155,7 +155,7 @@ static void test_gb18030_utf8tomb(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_gbdata[30];
|
||||
char *comment;
|
||||
};
|
||||
@ -190,12 +190,12 @@ static void test_gb18030_utf8tomb(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
ret = gb18030_utf8tomb(&symbol, (unsigned char *) data[i].data, &ret_length, gbdata);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt);
|
||||
if (ret == 0) {
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] 0x%04X != 0x%04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
|
||||
}
|
||||
@ -216,7 +216,7 @@ static void test_gb18030_utf8tosb(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_gbdata[30];
|
||||
char *comment;
|
||||
};
|
||||
@ -265,12 +265,12 @@ static void test_gb18030_utf8tosb(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
ret = gb18030_utf8tosb(data[i].eci, (unsigned char *) data[i].data, &ret_length, gbdata, data[i].full_multibyte);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
|
||||
}
|
||||
@ -289,7 +289,7 @@ static void test_gb18030_cpy(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_gbdata[30];
|
||||
char *comment;
|
||||
};
|
||||
@ -316,10 +316,10 @@ static void test_gb18030_cpy(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
gb18030_cpy((unsigned char *) data[i].data, &ret_length, gbdata, data[i].full_multibyte);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ static void test_gb2312_utf8tomb(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_gbdata[20];
|
||||
char *comment;
|
||||
};
|
||||
@ -130,12 +130,12 @@ static void test_gb2312_utf8tomb(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
ret = gb2312_utf8tomb(&symbol, (unsigned char *) data[i].data, &ret_length, gbdata);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt);
|
||||
if (ret == 0) {
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
|
||||
}
|
||||
@ -156,7 +156,7 @@ static void test_gb2312_utf8tosb(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_gbdata[20];
|
||||
char *comment;
|
||||
};
|
||||
@ -203,12 +203,12 @@ static void test_gb2312_utf8tosb(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
ret = gb2312_utf8tosb(data[i].eci, (unsigned char *) data[i].data, &ret_length, gbdata, data[i].full_multibyte);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
|
||||
}
|
||||
@ -227,7 +227,7 @@ static void test_gb2312_cpy(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_gbdata[20];
|
||||
char *comment;
|
||||
};
|
||||
@ -254,10 +254,10 @@ static void test_gb2312_cpy(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
gb2312_cpy((unsigned char *) data[i].data, &ret_length, gbdata, data[i].full_multibyte);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 44*/ { UNICODE_MODE, 0, -1, " 200mA至", 0, 0, "2F 60 40 00 60 2B 78 63 41 7F 40", "M6 H1 (GB 2312)" },
|
||||
/* 45*/ { UNICODE_MODE, 0, -1, "2A tel:86 019 82512738", 0, 0, "28 22 5F 4F 29 48 5F 6D 7E 6F 55 57 1F 28 63 0F 5A 11 64 0F 74", "M2 L5(with control) N15 (ASCII)" },
|
||||
/* 46*/ { UNICODE_MODE, 0, -1, "至2A tel:86 019 82512738", 0, 0, "30 07 56 60 4C 48 13 6A 32 17 7B 3F 5B 75 35 67 6A 18 63 76 44 39 03 7D 00", "B4 L5(with control) N15 (GB 2312)" },
|
||||
/* 47*/ { UNICODE_MODE, 0, -1, "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738", 0, 0, "(62) 29 22 22 1C 4E 41 42 7E 0A 40 14 00 37 7E 6F 00 62 7E 2C 00 1C 7E 4B 00 41 7E 18 00", "M8 H11 M6 B4 L5(with control) N15 (GB 2312) (*NOT SAME* as D3 example, M8 H11 M6 H1 M3 L4(with control) N15, which uses a few more bits)" },
|
||||
/* 47*/ { UNICODE_MODE, 0, -1, "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738", 0, 0, "(62) 29 22 22 1C 4E 41 42 7E 0A 40 14 00 37 7E 6F 00 62 7E 2C 00 1C 7E 4B 00 41 7E 18 00", "M8 H11 M6 B4 L5(with control) N15 (GB 2312) (*NOT SAME* as D3 example Figure D.1, M8 H11 M6 H1 M3 L4(with control) N15, which uses a few more bits)" },
|
||||
/* 48*/ { UNICODE_MODE, 0, -1, "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::", 0, 0, "(588) 37 68 68 68 68 68 74 7E 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B512 (ASCII)" },
|
||||
/* 49*/ { UNICODE_MODE, 0, -1, "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\177", 0, 0, "(591) 37 68 68 68 68 68 74 7E 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B513 (ASCII)" },
|
||||
/* 50*/ { UNICODE_MODE, 0, -1, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::至", 0, 0, "(591) 37 68 68 68 68 68 74 7C 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B511 H1 (GB 2312)" },
|
||||
@ -297,7 +297,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"111111000000100001"
|
||||
"111111000000111111"
|
||||
},
|
||||
/* 1*/ { "Grid Matrix", UNICODE_MODE, 5, -1, 0, 30, 30, "",
|
||||
/* 1*/ { "Grid Matrix", UNICODE_MODE, 5, -1, 0, 30, 30, "AIMD014 Figure 1 **NOT SAME** different encodation, uses Upper and Lower whereas figure uses Mixed and Lower",
|
||||
"111111000000111111000000111111"
|
||||
"110111010110110111010110110011"
|
||||
"100011011110111111011110111111"
|
||||
@ -329,7 +329,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"101111010010100001010010110111"
|
||||
"111111000000111111000000111111"
|
||||
},
|
||||
/* 2*/ { "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738", UNICODE_MODE, 3, 3, 0, 42, 42, "",
|
||||
/* 2*/ { "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738", UNICODE_MODE, 3, 3, 0, 42, 42, "AIMD014 Figure D.1 **NOT SAME** different encodation, see test_input dataset",
|
||||
"111111000000111111000000111111000000111111"
|
||||
"101101001100101111001010101011001100101101"
|
||||
"110001011010110101010000100011000000100001"
|
||||
@ -423,6 +423,89 @@ static void test_encode(int index, int generate, int debug) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#define TEST_PERF_ITERATIONS 1000
|
||||
|
||||
// Not a real test, just performance indicator
|
||||
static void test_perf(int index, int debug) {
|
||||
|
||||
if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
|
||||
return;
|
||||
}
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
int option_1;
|
||||
int option_2;
|
||||
char *data;
|
||||
int ret;
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, -1, -1,
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738",
|
||||
0, 66, 66, "97 chars, mixed modes" },
|
||||
/* 1*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, -1, -1,
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738"
|
||||
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738",
|
||||
0, 162, 162, "970 chars, mixed modes" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer;
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
diff_encode = diff_buffer = 0;
|
||||
|
||||
for (int j = 0; j < TEST_PERF_ITERATIONS; j++) {
|
||||
struct zint_symbol *symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
diff_encode += clock() - start;
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/);
|
||||
diff_buffer += clock() - start;
|
||||
assert_zero(ret, "i:%d ZBarcode_Buffer ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
printf("%s: diff_encode %gms, diff_buffer %gms\n", data[i].comment, diff_encode * 1000.0 / CLOCKS_PER_SEC, diff_buffer * 1000.0 / CLOCKS_PER_SEC);
|
||||
|
||||
total_encode += diff_encode;
|
||||
total_buffer += diff_buffer;
|
||||
}
|
||||
if (index != -1) {
|
||||
printf("totals: encode %gms, buffer %gms\n", total_encode * 1000.0 / CLOCKS_PER_SEC, total_buffer * 1000.0 / CLOCKS_PER_SEC);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
@ -430,6 +513,7 @@ int main(int argc, char *argv[]) {
|
||||
{ "test_options", test_options, 1, 0, 1 },
|
||||
{ "test_input", test_input, 1, 1, 1 },
|
||||
{ "test_encode", test_encode, 1, 1, 1 },
|
||||
{ "test_perf", test_perf, 1, 0, 1 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
@ -241,11 +241,11 @@ static void test_cap(int index) {
|
||||
/* 0*/ { BARCODE_CODE128, ZINT_CAP_HRT, ZINT_CAP_HRT },
|
||||
/* 1*/ { BARCODE_CODE128, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_GS1, ZINT_CAP_HRT | ZINT_CAP_STACKABLE },
|
||||
/* 2*/ { BARCODE_PDF417, ZINT_CAP_HRT | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE, ZINT_CAP_ECI | ZINT_CAP_READER_INIT },
|
||||
/* 3*/ { BARCODE_QRCODE, ZINT_CAP_HRT | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE, ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FULL_MULTIBYTE },
|
||||
/* 3*/ { BARCODE_QRCODE, ZINT_CAP_HRT | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK, ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK },
|
||||
/* 4*/ { BARCODE_EANX_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_ECI | ZINT_CAP_GS1, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_GS1 },
|
||||
/* 5*/ { BARCODE_HANXIN, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE },
|
||||
/* 5*/ { BARCODE_HANXIN, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK },
|
||||
/* 6*/ { BARCODE_CODE11, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE, 0 },
|
||||
/* 7*/ { BARCODE_POSTNET, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE | ZINT_CAP_COMPOSITE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE, 0 },
|
||||
/* 7*/ { BARCODE_POSTNET, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE | ZINT_CAP_COMPOSITE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK, 0 },
|
||||
/* 8*/ { 0, 0, 0 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
@ -168,8 +168,8 @@ static void test_print(int index, int generate, int debug) {
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
char* data_dir = "../data/png";
|
||||
char* png = "out.png";
|
||||
char *data_dir = "../data/png";
|
||||
char *png = "out.png";
|
||||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
char *text;
|
||||
|
227
backend/tests/test_reedsol.c
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
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
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
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
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
#include "../reedsol.h"
|
||||
|
||||
// Print out the log/alog tables for "backend/reedsol_logs.h"
|
||||
static void print_logs(const char *name, int logmod, unsigned int *logt, unsigned int *alog, int u16, int last) {
|
||||
int i;
|
||||
const char *type = u16 ? "short" : "char";
|
||||
const char *format = u16 ? " 0x%04X," : " 0x%02X,";
|
||||
|
||||
printf("static const unsigned %s logt_%s[%d] = {", type, name, logmod + 1);
|
||||
for (i = 0; i < logmod + 1; i++) {
|
||||
if (i % 16 == 0) printf("\n ");
|
||||
printf(format, i ? logt[i] : 0);
|
||||
}
|
||||
printf("\n};\n");
|
||||
|
||||
printf("static const unsigned %s alog_%s[%d] = {", type, name, logmod * 2);
|
||||
for (i = 0; i < logmod; i++) {
|
||||
if (i % 16 == 0) printf("\n ");
|
||||
printf(format, alog[i]);
|
||||
}
|
||||
// Double antilog table
|
||||
for (i = 0; i < logmod; i++) {
|
||||
if (i % 16 == 0) printf("\n ");
|
||||
printf(format, alog[i]);
|
||||
}
|
||||
printf("\n};\n");
|
||||
if (!last) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void gen_logs(const unsigned int prime_poly, int logmod, unsigned int *logt, unsigned int *alog) {
|
||||
int b, p, v;
|
||||
|
||||
b = logmod + 1;
|
||||
|
||||
// Calculate the log/alog tables
|
||||
for (p = 1, v = 0; v < logmod; v++) {
|
||||
alog[v] = p;
|
||||
logt[p] = v;
|
||||
p <<= 1;
|
||||
if (p & b)
|
||||
p ^= prime_poly;
|
||||
}
|
||||
}
|
||||
|
||||
// Dummy to generate static log/antilog tables for "backend/reedsol_logs.h"
|
||||
static void test_generate(int generate) {
|
||||
|
||||
if (!generate) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct item {
|
||||
const char *name;
|
||||
int logmod;
|
||||
unsigned int prime_poly;
|
||||
int u16;
|
||||
};
|
||||
struct item data[] = {
|
||||
{ "0x13", 15, 0x13, 0 },
|
||||
{ "0x25", 31, 0x25, 0 },
|
||||
{ "0x43", 63, 0x43, 0 },
|
||||
{ "0x89", 127, 0x89, 0 },
|
||||
{ "0x11d", 255, 0x11d, 0 },
|
||||
{ "0x12d", 255, 0x12d, 0 },
|
||||
{ "0x163", 255, 0x163, 0 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
unsigned int logt[4096];
|
||||
unsigned int alog[8192];
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
gen_logs(data[i].prime_poly, data[i].logmod, logt, alog);
|
||||
print_logs(data[i].name, data[i].logmod, logt, alog, data[i].u16, i + 1 == data_size);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_encoding(int index) {
|
||||
|
||||
testStart("");
|
||||
|
||||
struct item {
|
||||
unsigned int prime_poly;
|
||||
int nsym;
|
||||
int index;
|
||||
int datalen;
|
||||
unsigned char data[256];
|
||||
|
||||
unsigned char expected[256];
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { 0x43, 4, 1, 7, { 4, 20, 49, 37, 49, 38, 23 }, { 54, 17, 53, 58 } }, // AUSPOST Australia Post Customer Barcoding Technical Specifications Diagram 10
|
||||
/* 1*/ { 0x43, 7, 1, 10, { 9, 50, 1, 41, 47, 2, 39, 37, 1, 27 }, { 38, 50, 8, 16, 10, 20, 40 } }, // AZTEC ISO/IEC 24778:2008 Section G.4
|
||||
/* 2*/ { 0x13, 5, 1, 2, { 0, 9 }, { 12, 2, 3, 1, 9 } }, // AZTEC ISO/IEC 24778:2008 Section G.4 Mode Message
|
||||
/* 3*/ { 0x12d, 5, 1, 3, { 142, 164, 186 }, { 114, 25, 5, 88, 102 } }, // DATAMATRIX ISO/IEC 16022:2006 Annex O
|
||||
/* 4*/ { 0x89, 25, 1, 25, { 42, 13, 54, 39, 124, 91, 121, 65, 28, 40, 95, 48, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0 }, { 123, 47, 2, 20, 54, 112, 35, 23, 100, 89, 55, 17, 101, 4, 14, 33, 48, 62, 98, 52, 2, 79, 92, 70, 102 } }, // GRIDMATRIX AIMD014 Section 6.8
|
||||
/* 5*/ { 0x163, 4, 1, 21, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4 }, { 0xEB, 0xB4, 0x68, 0x1D } }, // HANXIN ISO/IEC DIS 20830:2019 Annex K.1
|
||||
/* 6*/ { 0x163, 24, 1, 27, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4, 0x8A, 0x2C, 0xC3, 0x4E, 0x3D, 0x09, 0x25, 0x9A, 0x7A, 0x29, 0xAB, 0xEA, 0x3E, 0x46, 0x4C, 0x7E, 0x73, 0xE8, 0x6C, 0xC7 }, { 0x08, 0x57, 0x0C, 0xE0, 0x7A, 0xA5, 0xDD, 0xA2, 0x99, 0xCF, 0xA4, 0x82, 0xAD, 0x11, 0xB0, 0x84, 0x74, 0x5D, 0x9A, 0x99, 0x0B, 0xCD, 0x49, 0x77 } }, // HANXIN ISO/IEC DIS 20830:2019 Annex K.2 1st block
|
||||
/* 7*/ { 0x163, 24, 1, 27, { 0xE7, 0x3E, 0x33, 0x29, 0xE8, 0xFC, }, { 0xA2, 0xA7, 0x68, 0x8A, 0x5F, 0xE6, 0xAA, 0x11, 0xA6, 0x69, 0x4A, 0xCF, 0xCF, 0x20, 0x5D, 0x00, 0x1B, 0x79, 0xA1, 0xFE, 0xB7, 0x94, 0x03, 0x9B } }, // HANXIN ISO/IEC DIS 20830:2019 Annex K.2 2nd block
|
||||
/* 8*/ { 0x163, 24, 1, 29, { 0x00 }, { 0x00 } }, // HANXIN ISO/IEC DIS 20830:2019 Annex K.2 3rd block
|
||||
/* 9*/ { 0x25, 6, 1, 16, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 14, 7, 23, 3, 23, 15 } }, // MAILMARK Royal Mail Mailmark barcode C encoding and decoding Example 2.3.1
|
||||
/* 10*/ { 0x25, 6, 1, 16, { 15, 22, 3, 25, 23, 26, 7, 3, 20, 14, 1, 4, 16, 3, 9, 28 }, { 27, 22, 24, 16, 6, 24 } }, // MAILMARK Royal Mail Mailmark barcode C encoding and decoding Example 2.3.2
|
||||
/* 11*/ { 0x25, 7, 1, 19, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 20, 1, 20, 7, 14, 11, 18 } }, // MAILMARK Royal Mail Mailmark barcode L encoding and decoding Example 2.3.1
|
||||
/* 12*/ { 0x25, 7, 1, 19, { 0, 8, 21, 10, 29, 1, 29, 21, 2, 24, 15, 2, 19, 1, 4, 15, 11, 4, 16 }, { 19, 7, 9, 8, 6, 16, 16 } }, // MAILMARK Royal Mail Mailmark barcode L encoding and decoding Example 2.3.2
|
||||
/* 13*/ { 0x43, 10, 1, 10, { 4, 13, 63, 1, 24, 9, 59, 3, 15, 4 }, { 50, 2, 42, 51, 53, 34, 22, 20, 5, 16 } }, // MAXICODE Annex H Primary
|
||||
/* 14*/ { 0x43, 20, 1, 42, { 5, 57, 49, 47, 8, 18, 59, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 31, 2, 58, 6, 6, 39, 13, 63, 2, 30, 19, 19, 14, 19, 23, 17, 62, 8, 2, 23 } }, // MAXICODE Annex H Secondary odd
|
||||
/* 15*/ { 0x43, 20, 1, 42, { 47, 40, 57, 3, 1, 19, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 1, 15, 22, 28, 39, 17, 60, 5, 35, 35, 4, 8, 0, 32, 51, 45, 63, 53, 61, 14 } }, // MAXICODE Annex H Secondary even
|
||||
/* 16*/ { 0x11d, 10, 0, 16, { 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, { 0xA5, 0x24, 0xD4, 0xC1, 0xED, 0x36, 0xC7, 0x87, 0x2C, 0x55 } }, // QRCODE Annex I.2
|
||||
/* 17*/ { 0x11d, 5, 0, 5, { 0x40, 0x18, 0xAC, 0xC3, 0x00 }, { 0x86, 0x0D, 0x22, 0xAE, 0x30 } }, // QRCODE Annex I.3
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
rs_t rs;
|
||||
unsigned char res[1024];
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
rs_init_gf(&rs, data[i].prime_poly);
|
||||
rs_init_code(&rs, data[i].nsym, data[i].index);
|
||||
rs_encode(&rs, data[i].datalen, data[i].data, res);
|
||||
|
||||
//fprintf(stderr, "res "); for (int j = data[i].nsym - 1; j >= 0; j--) fprintf(stderr, "%d ", res[j]); fprintf(stderr, "\n");
|
||||
//fprintf(stderr, "exp "); for (int j = 0; j < data[i].nsym; j++) fprintf(stderr, "%d ", data[i].expected[j]); fprintf(stderr, "\n");
|
||||
for (int j = 0; j < data[i].nsym; j++) {
|
||||
int k = data[i].nsym - 1 - j;
|
||||
assert_equal(res[k], data[i].expected[j], "i:%d res[%d] %d != expected[%d] %d\n", i, k, res[k], j, data[i].expected[j]);
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_encoding_uint(int index) {
|
||||
|
||||
testStart("");
|
||||
|
||||
struct item {
|
||||
unsigned int prime_poly;
|
||||
int logmod;
|
||||
int nsym;
|
||||
int index;
|
||||
int datalen;
|
||||
unsigned int data[256];
|
||||
|
||||
unsigned int expected[256];
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { 0x409, 1023, 4, 1, 7, { 0x3FF, 0x000, 0x100, 0x1FF, 0x3FF, 0x000, 0x123 }, { 229, 153, 993, 674 } },
|
||||
/* 1*/ { 0x1069, 4095, 4, 1, 7, { 0xFFF, 0x000, 0x700, 0x7FF, 0xFFF, 0x000, 0x123 }, { 3472, 2350, 3494, 575 } },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
rs_uint_t rs_uint;
|
||||
unsigned int res[1024];
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
rs_uint_init_gf(&rs_uint, data[i].prime_poly, data[i].logmod);
|
||||
rs_uint_init_code(&rs_uint, data[i].nsym, data[i].index);
|
||||
rs_uint_encode(&rs_uint, data[i].datalen, data[i].data, res);
|
||||
rs_uint_free(&rs_uint);
|
||||
|
||||
//fprintf(stderr, "res "); for (int j = data[i].nsym - 1; j >= 0; j--) fprintf(stderr, "%d ", res[j]); fprintf(stderr, "\n");
|
||||
//fprintf(stderr, "exp "); for (int j = 0; j < data[i].nsym; j++) fprintf(stderr, "%d ", data[i].expected[j]); fprintf(stderr, "\n");
|
||||
for (int j = 0; j < data[i].nsym; j++) {
|
||||
int k = data[i].nsym - 1 - j;
|
||||
assert_equal(res[k], data[i].expected[j], "i:%d res[%d] %d != expected[%d] %d\n", i, k, res[k], j, data[i].expected[j]);
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
{ "test_generate", test_generate, 0, 1, 0 },
|
||||
{ "test_encoding", test_encoding, 1, 0, 0 },
|
||||
{ "test_encoding_uint", test_encoding_uint, 1, 0, 0 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
||||
testReport();
|
||||
|
||||
return 0;
|
||||
}
|
@ -115,7 +115,7 @@ static void test_sjis_utf8tomb(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_jisdata[20];
|
||||
char *comment;
|
||||
};
|
||||
@ -149,12 +149,12 @@ static void test_sjis_utf8tomb(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
ret = sjis_utf8tomb(&symbol, (unsigned char *) data[i].data, &ret_length, jisdata);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt);
|
||||
if (ret == 0) {
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(jisdata[j], data[i].expected_jisdata[j], "i:%d jisdata[%d] %04X != %04X\n", i, j, jisdata[j], data[i].expected_jisdata[j]);
|
||||
}
|
||||
@ -175,7 +175,7 @@ static void test_sjis_utf8tosb(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_jisdata[20];
|
||||
char *comment;
|
||||
};
|
||||
@ -215,12 +215,12 @@ static void test_sjis_utf8tosb(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
ret = sjis_utf8tosb(data[i].eci, (unsigned char *) data[i].data, &ret_length, jisdata, data[i].full_multibyte);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(jisdata[j], data[i].expected_jisdata[j], "i:%d jisdata[%d] %04X != %04X\n", i, j, jisdata[j], data[i].expected_jisdata[j]);
|
||||
}
|
||||
@ -239,7 +239,7 @@ static void test_sjis_cpy(int index) {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int ret_length;
|
||||
unsigned int expected_jisdata[20];
|
||||
char *comment;
|
||||
};
|
||||
@ -265,10 +265,10 @@ static void test_sjis_cpy(int index) {
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
int ret_length = length;
|
||||
|
||||
sjis_cpy((unsigned char *) data[i].data, &ret_length, jisdata, data[i].full_multibyte);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %zu != %zu\n", i, ret_length, data[i].ret_length);
|
||||
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
|
||||
for (int j = 0; j < (int) ret_length; j++) {
|
||||
assert_equal(jisdata[j], data[i].expected_jisdata[j], "i:%d jisdata[%d] %04X != %04X\n", i, j, jisdata[j], data[i].expected_jisdata[j]);
|
||||
}
|
||||
|
@ -622,8 +622,8 @@ static void test_output_options(int index, int debug) {
|
||||
/* 12*/ { BARCODE_QRCODE, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 6 },
|
||||
/* 13*/ { BARCODE_QRCODE, -1, 3, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 6 },
|
||||
/* 14*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 1, 0, 6 },
|
||||
/* 15*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 0, 22, 6 },
|
||||
/* 16*/ { BARCODE_QRCODE, -1, 3, BARCODE_BOX, "A123", 0, 21, 21, 21, 54, 54, 1, 22, 6 },
|
||||
/* 15*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 0, 22, 8 },
|
||||
/* 16*/ { BARCODE_QRCODE, -1, 3, BARCODE_BOX, "A123", 0, 21, 21, 21, 54, 54, 1, 22, 8 },
|
||||
/* 17*/ { BARCODE_QRCODE, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 10, 12 },
|
||||
/* 18*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 1, 10, 12 },
|
||||
/* 19*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 0, 22, 12 },
|
||||
|
@ -65,7 +65,7 @@ void testStartReal(const char *func, const char *name) {
|
||||
}
|
||||
|
||||
void testEnd(int result) {
|
||||
if (testName[0]) {
|
||||
if (testName && testName[0]) {
|
||||
printf(".....%d: %s: %s ", tests, testFunc, testName);
|
||||
} else {
|
||||
printf(".....%d: %s: ", tests, testFunc);
|
||||
@ -79,7 +79,7 @@ void testEnd(int result) {
|
||||
}
|
||||
|
||||
void testFinish(void) {
|
||||
if (testName[0]) {
|
||||
if (testName && testName[0]) {
|
||||
printf(".....%d: %s: %s ", tests, testFunc, testName);
|
||||
} else {
|
||||
printf(".....%d: %s: ", tests, testFunc);
|
||||
@ -94,7 +94,7 @@ void testFinish(void) {
|
||||
|
||||
void testSkip(const char *msg) {
|
||||
skipped++;
|
||||
if (testName[0]) {
|
||||
if (testName && testName[0]) {
|
||||
printf(".....%d: %s: %s ", tests, testFunc, testName);
|
||||
} else {
|
||||
printf(".....%d: %s: ", tests, testFunc);
|
||||
@ -486,17 +486,43 @@ const char *testUtilInputModeName(int input_mode) {
|
||||
}
|
||||
|
||||
const char *testUtilOption3Name(int option_3) {
|
||||
switch (option_3) {
|
||||
case DM_SQUARE: return "DM_SQUARE";
|
||||
case DM_DMRE: return "DM_DMRE";
|
||||
case ZINT_FULL_MULTIBYTE: return "ZINT_FULL_MULTIBYTE";
|
||||
case ULTRA_COMPRESSION: return "ULTRA_COMPRESSION";
|
||||
static char buffer[64];
|
||||
|
||||
const char *name = NULL;
|
||||
unsigned int high_byte = option_3 == -1 ? 0 : (option_3 >> 8) & 0xFF;
|
||||
|
||||
switch (option_3 & 0xFF) {
|
||||
case DM_SQUARE:
|
||||
name = "DM_SQUARE";
|
||||
break;
|
||||
case DM_DMRE:
|
||||
name = "DM_DMRE";
|
||||
break;
|
||||
case ZINT_FULL_MULTIBYTE:
|
||||
name = "ZINT_FULL_MULTIBYTE";
|
||||
break;
|
||||
case ULTRA_COMPRESSION:
|
||||
name = "ULTRA_COMPRESSION";
|
||||
break;
|
||||
default:
|
||||
if (option_3 != -1 && (option_3 & 0xFF) != 0) {
|
||||
fprintf(stderr, "testUtilOption3Name: unknown value (%d)\n", option_3);
|
||||
abort();
|
||||
}
|
||||
name = (option_3 & 0xFF) ? "-1" : "0";
|
||||
break;
|
||||
}
|
||||
if (option_3 != -1 && option_3 != 0) {
|
||||
fprintf(stderr, "testUtilOption3Name: unknown value (%d)\n", option_3);
|
||||
abort();
|
||||
|
||||
if (high_byte) {
|
||||
if (option_3 & 0xFF) {
|
||||
sprintf(buffer, "%s | (%d << 8)", name, high_byte);
|
||||
} else {
|
||||
sprintf(buffer, "%d << 8", high_byte);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
return option_3 ? "-1" : "0";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *testUtilOutputOptionsName(int output_options) {
|
||||
@ -1805,7 +1831,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
|
||||
{ "databarstackedomnicomposite", BARCODE_DBAR_OMNSTK_CC, 138, 1, 0, 0, 33 /*linear_row_height*/, 1, },
|
||||
{ "databarexpandedstackedcomposite", BARCODE_DBAR_EXPSTK_CC, 139, 1, 1, 0, 34 /*linear_row_height*/, 1, },
|
||||
{ "channelcode", BARCODE_CHANNEL, 140, 0, 0, 0, 0, 0, },
|
||||
{ "codeone", BARCODE_CODEONE, 141, 0, 0, 0, 0, 0, },
|
||||
{ "codeone", BARCODE_CODEONE, 141, 0, 1, 0, 0, 0, },
|
||||
{ "", BARCODE_GRIDMATRIX, 142, 0, 0, 0, 0, 0, },
|
||||
{ "", BARCODE_UPNQR, 143, 0, 0, 0, 0, 0, },
|
||||
{ "ultracode", BARCODE_ULTRA, 144, 0, 0, 0, 0, 0, },
|
||||
@ -2237,6 +2263,12 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
||||
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sformat=compact", strlen(bwipp_opts_buf) ? " " : "");
|
||||
bwipp_opts = bwipp_opts_buf;
|
||||
}
|
||||
} else if (symbology == BARCODE_CODEONE) {
|
||||
if (option_2 >= 1 && option_2 <= 10) {
|
||||
static char codeone_versions[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'S', 'T' };
|
||||
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sversion=%c", strlen(bwipp_opts_buf) ? " " : "", codeone_versions[option_2 - 1]);
|
||||
bwipp_opts = bwipp_opts_buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,6 +304,7 @@ extern "C" {
|
||||
#define ZINT_CAP_FIXED_RATIO 0x0100 /* Aspect ratio */
|
||||
#define ZINT_CAP_READER_INIT 0x0200
|
||||
#define ZINT_CAP_FULL_MULTIBYTE 0x0400
|
||||
#define ZINT_CAP_MASK 0x0800
|
||||
|
||||
// Debug flags
|
||||
#define ZINT_DEBUG_PRINT 1
|
||||
|
@ -430,6 +430,7 @@ static char help_message[] = "zint tcl(stub,obj) dll\n"
|
||||
" -rows integer: Codablock F: number of rows\n"
|
||||
" -vers integer: Symbology option\n"
|
||||
" -dmre bool: Allow Data Matrix Rectangular Extended\n"
|
||||
" -mask integer: Mask pattern to use for QR (0..7), MicroQR (0..3) or HanXin (0..3)\n"
|
||||
" -separator 0..4 (default: 1) : Stacked symbologies: separator width\n"
|
||||
" -rotate angle: Image rotation by 0,90 or 270 degrees\n"
|
||||
" -secure integer: EC Level (PDF417, QR)\n"
|
||||
@ -602,6 +603,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
||||
int fFullMultiByte = 0;
|
||||
int addon_gap = 0;
|
||||
int Separator = 1;
|
||||
int Mask = 0;
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* >> Check if at least data and object is given and a pair number of */
|
||||
/* >> options */
|
||||
@ -632,13 +634,13 @@ static int Encode(Tcl_Interp *interp, int objc,
|
||||
"-gssep", "-height", "-init", "-mode", "-nobackground", "-notext",
|
||||
"-primary", "-rotate", "-rows", "-scale", "-secure", "-smalltext",
|
||||
"-square", "-to", "-vers", "-whitesp", "-fullmultibyte",
|
||||
"-separator", NULL};
|
||||
"-separator", "-mask", NULL};
|
||||
enum iOption {
|
||||
iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox, iCols,
|
||||
iDMRE, iDotSize, iDotty, iECI, iFG, iFormat, iGSSep, iHeight,
|
||||
iInit, iMode, iNoBackground, iNoText, iPrimary, iRotate, iRows,
|
||||
iScale, iSecure, iSmallText, iSquare, iTo, iVers,
|
||||
iWhiteSp, iFullMultiByte, iSeparator
|
||||
iWhiteSp, iFullMultiByte, iSeparator, iMask
|
||||
};
|
||||
int optionIndex;
|
||||
int intValue;
|
||||
@ -711,6 +713,14 @@ static int Encode(Tcl_Interp *interp, int objc,
|
||||
fError = 1;
|
||||
}
|
||||
break;
|
||||
case iMask:
|
||||
/* >> Int */
|
||||
if (TCL_OK != Tcl_GetIntFromObj(interp, objv[optionPos+1],
|
||||
&intValue))
|
||||
{
|
||||
fError = 1;
|
||||
}
|
||||
break;
|
||||
case iPrimary:
|
||||
/* > Primary String up to 90 characters */
|
||||
/* > Output filename up to 250 characters */
|
||||
@ -871,6 +881,15 @@ static int Encode(Tcl_Interp *interp, int objc,
|
||||
Separator = intValue;
|
||||
}
|
||||
break;
|
||||
case iMask:
|
||||
if (intValue < 0 || intValue > 7) {
|
||||
Tcl_SetObjResult(interp,
|
||||
Tcl_NewStringObj("Mask out of range", -1));
|
||||
fError = 1;
|
||||
} else {
|
||||
Mask = intValue + 1;
|
||||
}
|
||||
break;
|
||||
case iCols:
|
||||
case iVers:
|
||||
/* >> Int in Option 2 */
|
||||
@ -999,13 +1018,17 @@ static int Encode(Tcl_Interp *interp, int objc,
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* >>> option_3 is set by two values depending on the symbology */
|
||||
/* >>> option_3 is set by three values depending on the symbology */
|
||||
/* On wrong symbology, the option is ignored(as does the zint program)*/
|
||||
if (fFullMultiByte && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_FULL_MULTIBYTE)) {
|
||||
hSymbol->option_3 = ZINT_FULL_MULTIBYTE;
|
||||
} else if (Separator && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_STACKABLE)) {
|
||||
hSymbol->option_3 = Separator;
|
||||
}
|
||||
if (fFullMultiByte && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_FULL_MULTIBYTE)) {
|
||||
hSymbol->option_3 = ZINT_FULL_MULTIBYTE;
|
||||
}
|
||||
if (Mask && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_MASK)) {
|
||||
hSymbol->option_3 |= Mask << 8;
|
||||
}
|
||||
if (Separator && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_STACKABLE)) {
|
||||
hSymbol->option_3 = Separator;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* >>> option_2 is set by two values depending on the symbology */
|
||||
/* On wrong symbology, the option is ignored(as does the zint program)*/
|
||||
|
@ -1259,6 +1259,7 @@ ZINT_CAP_FIXED_RATIO | Does the symbology have a fixed width-to-height
|
||||
| (aspect) ratio?
|
||||
ZINT_CAP_READER_INIT | Does the symbology support Reader Initialisation?
|
||||
ZINT_CAP_FULL_MULTIBYTE | Is the ZINT_FULL_MULTIBYTE option applicable?
|
||||
ZINT_CAP_MASK | Is mask selection applicable?
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
For example:
|
||||
@ -2172,6 +2173,12 @@ Non-ASCII data density may be maximized by using the --fullmultibyte switch or
|
||||
by setting option_3 to ZINT_FULL_MULTIBYTE, but check that your barcode reader
|
||||
supports this before using.
|
||||
|
||||
QR Code has eight different masks designed to minimize unwanted patterns. The
|
||||
best mask to use is selected automatically by Zint but may be manually specified
|
||||
by using the --mask= switch with values 0-7, or by setting option_3 to
|
||||
(N + 1) << 8 where N is 0-7. To use with ZINT_FULL_MULTIBYTE set option_3 =
|
||||
ZINT_FULL_MULTIBYTE | (N + 1) << 8.
|
||||
|
||||
6.6.3 Micro QR Code (ISO 18004)
|
||||
-------------------------------
|
||||
A miniature version of the QR Code symbol for short messages. ECC levels can be
|
||||
@ -2195,6 +2202,12 @@ Input | Version | Symbol Size
|
||||
For barcode readers that support it, non-ASCII data density may be maximized by
|
||||
using the --fullmultibyte switch or by setting option_3 to ZINT_FULL_MULTIBYTE.
|
||||
|
||||
Micro QR Code has four different masks designed to minimize unwanted patterns.
|
||||
The best mask to use is selected automatically by Zint but may be manually
|
||||
specified by using the --mask= switch with values 0-3, or by setting option_3
|
||||
to (N + 1) << 8 where N is 0-3. To use with ZINT_FULL_MULTIBYTE set option_3 =
|
||||
ZINT_FULL_MULTIBYTE | (N + 1) << 8.
|
||||
|
||||
6.6.4 Rectangular Micro QR Code (rMQR)
|
||||
--------------------------------------
|
||||
A rectangular version of QR Code. Like QR code rMQR supports encoding of GS1
|
||||
@ -2426,7 +2439,7 @@ Annex A.
|
||||
A matrix symbology developed by Ted Williams in 1992 which encodes data in a
|
||||
way similar to Data Matrix. Code One is able to encode the Latin-1
|
||||
character set or GS1 data. There are two types of Code One symbol - variable
|
||||
height symbols which are roughly square (versions A thought to H) and
|
||||
height symbols which are roughly square (versions A through to H) and
|
||||
fixed-height versions (version S and T). These can be selected by using --vers=
|
||||
or setting option_2 as shown in the table below:
|
||||
|
||||
@ -2623,6 +2636,12 @@ Non-ASCII data density may be maximized by using the --fullmultibyte switch or
|
||||
by setting option_3 to ZINT_FULL_MULTIBYTE, but check that your barcode reader
|
||||
supports this before using.
|
||||
|
||||
Han Xin has four different masks designed to minimize unwanted patterns. The
|
||||
best mask to use is selected automatically by Zint but may be manually specified
|
||||
by using the --mask= switch with values 0-3, or by setting option_3 to
|
||||
(N + 1) << 8 where N is 0-3. To use with ZINT_FULL_MULTIBYTE set option_3 =
|
||||
ZINT_FULL_MULTIBYTE | (N + 1) << 8.
|
||||
|
||||
6.6.13 Ultracode
|
||||
----------------
|
||||
This symbology uses a grid of coloured elements to encode data. ECI and GS1
|
||||
|
@ -124,6 +124,7 @@ static void usage(void) {
|
||||
" --height=NUMBER Set height of symbol in multiples of X-dimension\n"
|
||||
" -i, --input=FILE Read input data from FILE\n"
|
||||
" --init Create reader initialisation/programming symbol\n"
|
||||
" --mask=NUMBER Set masking pattern to use (QR/Han Xin)\n"
|
||||
" --mirror Use batch data to determine filename\n"
|
||||
" --mode=NUMBER Set encoding mode (Maxicode/Composite)\n"
|
||||
" --nobackground Remove background (PNG/SVG/EPS only)\n"
|
||||
@ -484,6 +485,7 @@ int main(int argc, char **argv) {
|
||||
int batch_mode = 0;
|
||||
int mirror_mode = 0;
|
||||
int fullmultibyte = 0;
|
||||
int mask = 0;
|
||||
int separator = 0;
|
||||
int addon_gap = 0;
|
||||
char filetype[4] = {0};
|
||||
@ -539,6 +541,7 @@ int main(int argc, char **argv) {
|
||||
{"init", 0, 0, 0},
|
||||
{"input", 1, 0, 'i'},
|
||||
{"mirror", 0, 0, 0},
|
||||
{"mask", 1, 0, 0},
|
||||
{"mode", 1, 0, 0},
|
||||
{"nobackground", 0, 0, 0},
|
||||
{"notext", 0, 0, 0},
|
||||
@ -609,6 +612,20 @@ int main(int argc, char **argv) {
|
||||
if (!strcmp(long_options[option_index].name, "fullmultibyte")) {
|
||||
fullmultibyte = 1;
|
||||
}
|
||||
if (!strcmp(long_options[option_index].name, "mask")) {
|
||||
error_number = validator(NESET, optarg);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
fprintf(stderr, "Error 148: Invalid mask value\n");
|
||||
exit(1);
|
||||
}
|
||||
mask = atoi(optarg) + 1;
|
||||
if (mask <= 0 || mask > 8) {
|
||||
/* Values >= 1 and <= 8 (i.e. mask pattern >= 0 and <= 7) only permitted */
|
||||
fprintf(stderr, "Warning 147: Invalid mask value\n");
|
||||
fflush(stderr);
|
||||
mask = 0;
|
||||
}
|
||||
}
|
||||
if (!strcmp(long_options[option_index].name, "notext")) {
|
||||
my_symbol->show_hrt = 0;
|
||||
}
|
||||
@ -941,10 +958,15 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (data_arg_num) {
|
||||
unsigned int cap = ZBarcode_Cap(my_symbol->symbology, ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE);
|
||||
unsigned int cap = ZBarcode_Cap(my_symbol->symbology, ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE |
|
||||
ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK);
|
||||
if (fullmultibyte && (cap & ZINT_CAP_FULL_MULTIBYTE)) {
|
||||
my_symbol->option_3 = ZINT_FULL_MULTIBYTE;
|
||||
} else if (separator && (cap & ZINT_CAP_STACKABLE)) {
|
||||
}
|
||||
if (mask && (cap & ZINT_CAP_MASK)) {
|
||||
my_symbol->option_3 |= mask << 8;
|
||||
}
|
||||
if (separator && (cap & ZINT_CAP_STACKABLE)) {
|
||||
my_symbol->option_3 = separator;
|
||||
}
|
||||
if (addon_gap && (cap & ZINT_CAP_EXTENDABLE)) {
|
||||
|
@ -174,6 +174,7 @@ static void test_dump_args(int index, int debug) {
|
||||
int dmre;
|
||||
int eci;
|
||||
int fullmultibyte;
|
||||
int mask;
|
||||
int mode;
|
||||
char *primary;
|
||||
int rows;
|
||||
@ -185,41 +186,45 @@ static void test_dump_args(int index, int debug) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { -1, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B" },
|
||||
/* 1*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B" },
|
||||
/* 2*/ { BARCODE_CODE128, "123", "456", NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B\nD2 19 3B 72 67 4E 4D 8E B" },
|
||||
/* 3*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, -1, 1, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "Warning 141: Can't use batch mode if data given, ignoring\nD2 13 9B 39 65 C8 C9 8E B" },
|
||||
/* 4*/ { BARCODE_CODE128, NULL, NULL, "123\n45\n", NULL, -1, -1, 1, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B\nD3 97 62 3B 63 AC" },
|
||||
/* 5*/ { BARCODE_CODE128, NULL, NULL, "123\n45\n", "7\n",-1, -1, 1, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "Warning 144: Processing first input file 'test_dump_args1.txt' only\nD2 13 9B 39 65 C8 C9 8E B\nD3 97 62 3B 63 AC" },
|
||||
/* 6*/ { BARCODE_CODE128, "\t", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D0 90 D2 1A 63 AC" },
|
||||
/* 7*/ { BARCODE_CODE128, "\\t", NULL, NULL, NULL, ESCAPE_MODE, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D0 90 D2 1A 63 AC" },
|
||||
/* 8*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, BARCODE_BIND | BARCODE_BOX | SMALL_TEXT | BOLD_TEXT | CMYK_COLOUR, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B" },
|
||||
/* 9*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, BARCODE_DOTTY_MODE, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "Error 224: Selected symbology cannot be rendered as dots" },
|
||||
/* 10*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D0 97 BA 86 51 88 B1 11 AC 46 D8 C7 58\nD0 97 BB 12 46 88 C5 1A 3C 55 CC C7 58" },
|
||||
/* 11*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, 10, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "D0 97 BA 86 51 88 B1 11 AC 44 68 BC 98 EB\nD0 97 BB 12 46 2B BD 7B A3 47 8A 8D 18 EB" },
|
||||
/* 12*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, 3, -1, 0, -1, "D0 97 BA 58 51 88 B1 11 AC 46 36 C7 58\nD0 97 BB 12 46 88 C5 77 AF 74 62 C7 58\nD0 97 BA CE 5D EB DD 1A 3C 56 88 C7 58" },
|
||||
/* 13*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "B2 D6 96 CA B5 6D 64" },
|
||||
/* 14*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, 1, "B2 D6 96 CA B5 64" },
|
||||
/* 15*/ { BARCODE_CODE11, "123", NULL, "456", NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2" },
|
||||
/* 16*/ { BARCODE_CODE11, "123", "456", "789", "012", -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2\nB2 A6 D2 D5 64\nB2 AD AD 2D 64" },
|
||||
/* 17*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, 1, 0, 0, -1, "FF 54 7A BC 3D 4F 1D 5C 0F E8 A4\nFF 54 7A 90 2F D3 1F AB 8F E8 A4\nFF 54 6A F8 3A BF 15 3C 0F E8 A4\nFF 54 57 9E 24 E7 1A F7 CF E8 A4\nFF 54 7A E7 3D 0D 9D 73 0F E8 A4\nFF 54 7D 70 B9 CB DF 5E CF E8 A4" },
|
||||
/* 18*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "AA 8\nB3 4\n8F 0\nB2 C\nA6 0\nBA C\nD6 0\nEB 4\nE2 8\nFF C" },
|
||||
/* 19*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, READER_INIT, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "AA A\nAC 7\n8A 4\nA0 3\nC2 2\nB5 1\n82 2\nBA 7\n8C C\nA0 5\n86 A\nFF F" },
|
||||
/* 20*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\nA6 C7 FA F9\nB2 AA C7 BA\n98 BF F4 0F\nE8 DA 90 C8\nC7 D5 B6 DF\nC5 50 B0 2C\nFF FF FF FF" },
|
||||
/* 21*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 1, -1, "AA AA\nA6 D3\nB2 DA\n99 19\nA8 A6\n84 F7\nC0 8C\nF9 87\nFC 4C\nD8 A5\n83 E6\n99 75\nF7 82\nAE 65\n8D 6A\nFF FF" },
|
||||
/* 22*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "AA AA A8\nA6 94 BC\nB2 AD F0\n99 08 F4\nA9 E1 B8\n86 81 CC\nC2 F5 88\nF5 D5 3C\nF2 68 30\nDA 7A BC\nB7 FE 70\nA8 E7 34\n91 40 88\nD6 33 DC\nD2 89 20\nD1 6A 94\nE2 71 A8\nE4 3E EC\nF2 9D 70\nE5 8D FC\nB9 56 50\nFF FF FC" },
|
||||
/* 23*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, NULL, -1, -1, 0, -1, "AA AA AA AA AA AA AA AA\nA6 D9 C8 0B FC 57 F3 17\nB2 BA A7 CA C9 18 87 BE\n99 2F EF 2B F1 A1 B9 DF\nA8 84 99 CA CF 4A BF 14\n86 D5 D9 87 A4 EF F4 9F\n85 44 BF 22 E7 58 C6 8A\nFF FF FF FF FF FF FF FF" },
|
||||
/* 24*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, NULL, -1, -1, 1, -1, "AA AA A8\nA6 94 BC\nB2 AD F0\n99 08 F4\nA9 E1 B8\n86 81 CC\nC2 F5 88\nF5 D5 3C\nF2 68 30\nDA 7A BC\nB7 FE 70\nA8 E7 34\n91 40 88\nD6 33 DC\nD2 89 20\nD1 6A 94\nE2 71 A8\nE4 3E EC\nF2 9D 70\nE5 8D FC\nB9 56 50\nFF FF FC" },
|
||||
/* 25*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, -1, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "AA A8\nFA 9C\nBC 00\nD7 84\nED E0\nA4 E4\nA7 40\n9D 3C\nBF 50\nFA 24\nB1 68\nE5 04\n92 70\nFF FC" },
|
||||
/* 26*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" },
|
||||
/* 27*/ { BARCODE_DATAMATRIX, "[9\\x31]12[92]34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" },
|
||||
/* 28*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, "12345678+12", -1, -1, 0, -1, "DB BC D3 9C 44 E9 D2 2C 19 E7 A2 D8 A0 00 00 00\nDB 31 1C 9C C7 29 92 47 D9 E9 40 C8 A0 00 00 00\nDA 3B EB 10 AF 09 9A 18 9D 7D 82 E8 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
|
||||
/* 29*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, 2, "12345678+12", -1, -1, 0, -1, "D3 A3 E9 DB F5 C9 DB 43 D9 CB 98 D2 20 00 00 00\nD3 25 0F 11 E4 49 D3 51 F1 AC FC D6 20 00 00 00\nD1 33 48 19 39 E9 93 18 49 D8 98 D7 20 00 00 00\nD1 A6 FC DA 1C 49 9B C5 05 E2 84 D7 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
|
||||
/* 30*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, NULL, -1, 1, 0, -1, "FE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" },
|
||||
/* 31*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, 26, 0, -1, NULL, -1, 1, 0, -1, "FE 5B F8\n82 72 08\nBA DA E8\nBA 52 E8\nBA 2A E8\n82 0A 08\nFE AB F8\n00 D8 00\nEF F6 20\nB5 C2 28\n36 28 88\nFD 42 10\n62 2A C8\n00 95 70\nFE B7 38\n82 FD D8\nBA 97 00\nBA 43 60\nBA C8 C8\n82 C3 68\nFE EA F8" },
|
||||
/* 32*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 0, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 0A 08\nBA A2 E8\nBA 0A E8\nBA 5A E8\n82 72 08\nFE AB F8\n00 A0 00\nEF AE 20\n75 B5 20\n82 F7 58\nF4 9D C8\n5E 17 28\n00 C2 20\nFE 88 80\n82 82 38\nBA EA A8\nBA 55 50\nBA D7 68\n82 BD D0\nFE B7 78" },
|
||||
/* 33*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, NULL, -1, 1, 0, -1, "FE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" },
|
||||
/* 34*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, 0, -1, 1, -1, NULL, -1, 1, 0, -1, "FE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" },
|
||||
/* 0*/ { -1, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B" },
|
||||
/* 1*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B" },
|
||||
/* 2*/ { BARCODE_CODE128, "123", "456", NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B\nD2 19 3B 72 67 4E 4D 8E B" },
|
||||
/* 3*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, -1, 1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "Warning 141: Can't use batch mode if data given, ignoring\nD2 13 9B 39 65 C8 C9 8E B" },
|
||||
/* 4*/ { BARCODE_CODE128, NULL, NULL, "123\n45\n", NULL, -1, -1, 1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B\nD3 97 62 3B 63 AC" },
|
||||
/* 5*/ { BARCODE_CODE128, NULL, NULL, "123\n45\n", "7\n",-1, -1, 1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "Warning 144: Processing first input file 'test_dump_args1.txt' only\nD2 13 9B 39 65 C8 C9 8E B\nD3 97 62 3B 63 AC" },
|
||||
/* 6*/ { BARCODE_CODE128, "\t", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 90 D2 1A 63 AC" },
|
||||
/* 7*/ { BARCODE_CODE128, "\\t", NULL, NULL, NULL, ESCAPE_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 90 D2 1A 63 AC" },
|
||||
/* 8*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, BARCODE_BIND | BARCODE_BOX | SMALL_TEXT | BOLD_TEXT | CMYK_COLOUR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B" },
|
||||
/* 9*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, BARCODE_DOTTY_MODE, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "Error 224: Selected symbology cannot be rendered as dots" },
|
||||
/* 10*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 97 BA 86 51 88 B1 11 AC 46 D8 C7 58\nD0 97 BB 12 46 88 C5 1A 3C 55 CC C7 58" },
|
||||
/* 11*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, 10, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 97 BA 86 51 88 B1 11 AC 44 68 BC 98 EB\nD0 97 BB 12 46 2B BD 7B A3 47 8A 8D 18 EB" },
|
||||
/* 12*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, 3, -1, 0, -1, "D0 97 BA 58 51 88 B1 11 AC 46 36 C7 58\nD0 97 BB 12 46 88 C5 77 AF 74 62 C7 58\nD0 97 BA CE 5D EB DD 1A 3C 56 88 C7 58" },
|
||||
/* 13*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "B2 D6 96 CA B5 6D 64" },
|
||||
/* 14*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 1, "B2 D6 96 CA B5 64" },
|
||||
/* 15*/ { BARCODE_CODE11, "123", NULL, "456", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2" },
|
||||
/* 16*/ { BARCODE_CODE11, "123", "456", "789", "012", -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2\nB2 A6 D2 D5 64\nB2 AD AD 2D 64" },
|
||||
/* 17*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, 1, 0, 0, -1, "FF 54 7A BC 3D 4F 1D 5C 0F E8 A4\nFF 54 7A 90 2F D3 1F AB 8F E8 A4\nFF 54 6A F8 3A BF 15 3C 0F E8 A4\nFF 54 57 9E 24 E7 1A F7 CF E8 A4\nFF 54 7A E7 3D 0D 9D 73 0F E8 A4\nFF 54 7D 70 B9 CB DF 5E CF E8 A4" },
|
||||
/* 18*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA 8\nB3 4\n8F 0\nB2 C\nA6 0\nBA C\nD6 0\nEB 4\nE2 8\nFF C" },
|
||||
/* 19*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, READER_INIT, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\nAC 7\n8A 4\nA0 3\nC2 2\nB5 1\n82 2\nBA 7\n8C C\nA0 5\n86 A\nFF F" },
|
||||
/* 20*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\nA6 C7 FA F9\nB2 AA C7 BA\n98 BF F4 0F\nE8 DA 90 C8\nC7 D5 B6 DF\nC5 50 B0 2C\nFF FF FF FF" },
|
||||
/* 21*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA\nA6 D3\nB2 DA\n99 19\nA8 A6\n84 F7\nC0 8C\nF9 87\nFC 4C\nD8 A5\n83 E6\n99 75\nF7 82\nAE 65\n8D 6A\nFF FF" },
|
||||
/* 22*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA A8\nA6 94 BC\nB2 AD F0\n99 08 F4\nA9 E1 B8\n86 81 CC\nC2 F5 88\nF5 D5 3C\nF2 68 30\nDA 7A BC\nB7 FE 70\nA8 E7 34\n91 40 88\nD6 33 DC\nD2 89 20\nD1 6A 94\nE2 71 A8\nE4 3E EC\nF2 9D 70\nE5 8D FC\nB9 56 50\nFF FF FC" },
|
||||
/* 23*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA AA AA AA AA\nA6 D9 C8 0B FC 57 F3 17\nB2 BA A7 CA C9 18 87 BE\n99 2F EF 2B F1 A1 B9 DF\nA8 84 99 CA CF 4A BF 14\n86 D5 D9 87 A4 EF F4 9F\n85 44 BF 22 E7 58 C6 8A\nFF FF FF FF FF FF FF FF" },
|
||||
/* 24*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA A8\nA6 94 BC\nB2 AD F0\n99 08 F4\nA9 E1 B8\n86 81 CC\nC2 F5 88\nF5 D5 3C\nF2 68 30\nDA 7A BC\nB7 FE 70\nA8 E7 34\n91 40 88\nD6 33 DC\nD2 89 20\nD1 6A 94\nE2 71 A8\nE4 3E EC\nF2 9D 70\nE5 8D FC\nB9 56 50\nFF FF FC" },
|
||||
/* 25*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nFA 9C\nBC 00\nD7 84\nED E0\nA4 E4\nA7 40\n9D 3C\nBF 50\nFA 24\nB1 68\nE5 04\n92 70\nFF FC" },
|
||||
/* 26*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" },
|
||||
/* 27*/ { BARCODE_DATAMATRIX, "[9\\x31]12[92]34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" },
|
||||
/* 28*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, "12345678+12", -1, -1, 0, -1, "DB BC D3 9C 44 E9 D2 2C 19 E7 A2 D8 A0 00 00 00\nDB 31 1C 9C C7 29 92 47 D9 E9 40 C8 A0 00 00 00\nDA 3B EB 10 AF 09 9A 18 9D 7D 82 E8 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
|
||||
/* 29*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, 2, "12345678+12", -1, -1, 0, -1, "D3 A3 E9 DB F5 C9 DB 43 D9 CB 98 D2 20 00 00 00\nD3 25 0F 11 E4 49 D3 51 F1 AC FC D6 20 00 00 00\nD1 33 48 19 39 E9 93 18 49 D8 98 D7 20 00 00 00\nD1 A6 FC DA 1C 49 9B C5 05 E2 84 D7 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
|
||||
/* 30*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
|
||||
/* 31*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, 26, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 5B F8\n82 72 08\nBA DA E8\nBA 52 E8\nBA 2A E8\n82 0A 08\nFE AB F8\n00 D8 00\nEF F6 20\nB5 C2 28\n36 28 88\nFD 42 10\n62 2A C8\n00 95 70\nFE B7 38\n82 FD D8\nBA 97 00\nBA 43 60\nBA C8 C8\n82 C3 68\nFE EA F8" },
|
||||
/* 32*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 0A 08\nBA A2 E8\nBA 0A E8\nBA 5A E8\n82 72 08\nFE AB F8\n00 A0 00\nEF AE 20\n75 B5 20\n82 F7 58\nF4 9D C8\n5E 17 28\n00 C2 20\nFE 88 80\n82 82 38\nBA EA A8\nBA 55 50\nBA D7 68\n82 BD D0\nFE B7 78" },
|
||||
/* 33*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
|
||||
/* 34*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
|
||||
/* 35*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "FE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" },
|
||||
/* 36*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 AA\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\nAA 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
|
||||
/* 37*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 3, -1, NULL, -1, -1, 0, -1, "FE 16 FE\n80 E2 02\nBE C2 FA\nA0 A0 0A\nAE F6 EA\nAE 98 EA\nAE BA EA\n00 E0 00\n15 83 AA\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\nAB E7 50\n00 3A 00\nFE C2 EA\n02 22 EA\nFA DA EA\n0A 22 0A\nEA B2 FA\nEA 9A 02\nEA E8 FE" },
|
||||
/* 38*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 4, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 AA\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\nAA 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
@ -252,6 +257,7 @@ static void test_dump_args(int index, int debug) {
|
||||
arg_bool(cmd, "--dmre", data[i].dmre);
|
||||
arg_int(cmd, "--eci=", data[i].eci);
|
||||
arg_bool(cmd, "--fullmultibyte", data[i].fullmultibyte);
|
||||
arg_int(cmd, "--mask=", data[i].mask);
|
||||
arg_int(cmd, "--mode=", data[i].mode);
|
||||
arg_data(cmd, "--primary=", data[i].primary);
|
||||
arg_int(cmd, "--rows=", data[i].rows);
|
||||
@ -262,7 +268,7 @@ static void test_dump_args(int index, int debug) {
|
||||
strcat(cmd, " 2>&1");
|
||||
|
||||
assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i), "i:%d exec(%s) NULL\n", i, cmd);
|
||||
assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s)\n", i, buf, data[i].expected);
|
||||
assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd);
|
||||
|
||||
if (have_input1) {
|
||||
assert_zero(remove(input1_filename), "i:%d remove(%s) != 0 (%d)\n", i, input1_filename, errno);
|
||||
@ -473,6 +479,7 @@ static void test_checks(int index, int debug) {
|
||||
int eci;
|
||||
char *filetype;
|
||||
int height;
|
||||
int mask;
|
||||
int mode;
|
||||
int rotate;
|
||||
int rows;
|
||||
@ -486,34 +493,35 @@ static void test_checks(int index, int debug) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { -2, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 139: Invalid add-on gap value" },
|
||||
/* 1*/ { 6, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Invalid add-on gap value" },
|
||||
/* 2*/ { -1, -2, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 107: Invalid border width value" },
|
||||
/* 3*/ { -1, 1001, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 108: Border width out of range" },
|
||||
/* 4*/ { -1, -1, -1, 0.009, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 106: Invalid dot radius value" },
|
||||
/* 5*/ { -1, -1, -2, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 131: Invalid columns value" },
|
||||
/* 6*/ { -1, -1, 68, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 111: Number of columns out of range" },
|
||||
/* 7*/ { -1, -1, -1, -1, -2, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 138: Invalid ECI value" },
|
||||
/* 8*/ { -1, -1, -1, -1, 1000000, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 118: Invalid ECI code" },
|
||||
/* 9*/ { -1, -1, -1, -1, -1, "jpg", -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'jpg' not supported, ignoring" },
|
||||
/* 10*/ { -1, -1, -1, -1, -1, NULL, -2, -1, -1, -1, -1, -1, -1, -1, -1, "Error 109: Invalid symbol height value" },
|
||||
/* 11*/ { -1, -1, -1, -1, -1, NULL, 0, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height out of range" },
|
||||
/* 12*/ { -1, -1, -1, -1, -1, NULL, -1, -2, -1, -1, -1, -1, -1, -1, -1, "Error 136: Invalid mode value" },
|
||||
/* 13*/ { -1, -1, -1, -1, -1, NULL, -1, 7, -1, -1, -1, -1, -1, -1, -1, "Warning 116: Invalid mode" },
|
||||
/* 14*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value" },
|
||||
/* 15*/ { -1, -1, -1, -1, -1, NULL, -1, -1, 45, -1, -1, -1, -1, -1, -1, "Warning 137: Invalid rotation parameter" },
|
||||
/* 16*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Error 132: Invalid rows value" },
|
||||
/* 17*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, 45, -1, -1, -1, -1, -1, "Warning 112: Number of rows out of range" },
|
||||
/* 18*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, "Warning 105: Invalid scale value" },
|
||||
/* 19*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 0.49, -1, -1, -1, -1, "Warning 146: Scaling less than 0.5 will be set to 0.5 for 'png' output" },
|
||||
/* 20*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 134: Invalid ECC value" },
|
||||
/* 21*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 9, -1, -1, -1, "Warning 114: ECC level out of range" },
|
||||
/* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 128: Invalid separator value" },
|
||||
/* 23*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 5, -1, -1, "Warning 127: Invalid separator value" },
|
||||
/* 24*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 133: Invalid version value" },
|
||||
/* 25*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, 85, -1, "Warning 113: Invalid version" },
|
||||
/* 26*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid whitespace value '-2'" },
|
||||
/* 27*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 1001, "Warning 121: Whitespace value out of range" },
|
||||
/* 0*/ { -2, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 139: Invalid add-on gap value" },
|
||||
/* 1*/ { 6, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Invalid add-on gap value" },
|
||||
/* 2*/ { -1, -2, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 107: Invalid border width value" },
|
||||
/* 3*/ { -1, 1001, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 108: Border width out of range" },
|
||||
/* 4*/ { -1, -1, -1, 0.009, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 106: Invalid dot radius value" },
|
||||
/* 5*/ { -1, -1, -2, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 131: Invalid columns value" },
|
||||
/* 6*/ { -1, -1, 68, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 111: Number of columns out of range" },
|
||||
/* 7*/ { -1, -1, -1, -1, -2, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 138: Invalid ECI value" },
|
||||
/* 8*/ { -1, -1, -1, -1, 1000000, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 118: Invalid ECI code" },
|
||||
/* 9*/ { -1, -1, -1, -1, -1, "jpg", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'jpg' not supported, ignoring" },
|
||||
/* 10*/ { -1, -1, -1, -1, -1, NULL, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 109: Invalid symbol height value" },
|
||||
/* 11*/ { -1, -1, -1, -1, -1, NULL, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height out of range" },
|
||||
/* 12*/ { -1, -1, -1, -1, -1, NULL, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, "Error 148: Invalid mask value" },
|
||||
/* 13*/ { -1, -1, -1, -1, -1, NULL, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 147: Invalid mask value" },
|
||||
/* 14*/ { -1, -1, -1, -1, -1, NULL, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, "Warning 116: Invalid mode" },
|
||||
/* 15*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value" },
|
||||
/* 16*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, "Warning 137: Invalid rotation parameter" },
|
||||
/* 17*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Error 132: Invalid rows value" },
|
||||
/* 18*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, "Warning 112: Number of rows out of range" },
|
||||
/* 19*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, "Warning 105: Invalid scale value" },
|
||||
/* 20*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 0.49, -1, -1, -1, -1, "Warning 146: Scaling less than 0.5 will be set to 0.5 for 'png' output" },
|
||||
/* 21*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 134: Invalid ECC value" },
|
||||
/* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, "Warning 114: ECC level out of range" },
|
||||
/* 23*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 128: Invalid separator value" },
|
||||
/* 24*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, "Warning 127: Invalid separator value" },
|
||||
/* 25*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 133: Invalid version value" },
|
||||
/* 26*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 85, -1, "Warning 113: Invalid version" },
|
||||
/* 27*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid whitespace value '-2'" },
|
||||
/* 28*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1001, "Warning 121: Whitespace value out of range" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
@ -537,6 +545,7 @@ static void test_checks(int index, int debug) {
|
||||
arg_int(cmd, "--eci=", data[i].eci);
|
||||
arg_data(cmd, "--filetype=", data[i].filetype);
|
||||
arg_int(cmd, "--height=", data[i].height);
|
||||
arg_int(cmd, "--mask=", data[i].mask);
|
||||
arg_int(cmd, "--mode=", data[i].mode);
|
||||
arg_int(cmd, "--rotate=", data[i].rotate);
|
||||
arg_int(cmd, "--rows=", data[i].rows);
|
||||
|
@ -503,6 +503,48 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelHXMask">
|
||||
<property name="text">
|
||||
<string>&Mask:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>cmbHXMask</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cmbHXMask">
|
||||
<property name="maxVisibleItems">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -94,6 +94,48 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelMQRMask">
|
||||
<property name="text">
|
||||
<string>&Mask:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>cmbMQRMask</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cmbMQRMask">
|
||||
<property name="maxVisibleItems">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -283,6 +283,68 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelQRMask">
|
||||
<property name="text">
|
||||
<string>&Mask:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>cmbQRMask</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cmbQRMask">
|
||||
<property name="maxVisibleItems">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -345,7 +407,7 @@
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>43</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -811,6 +811,7 @@ void MainWindow::change_options()
|
||||
tabMain->insertTab(1,m_optionWidget,tr("QR Cod&e"));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbQRSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbQRECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbQRMask"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("radQRStand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("radQRGS1"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("radQRHIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
@ -842,6 +843,7 @@ void MainWindow::change_options()
|
||||
tabMain->insertTab(1,m_optionWidget,tr("Han Xin Cod&e"));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbHXSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbHXECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbHXMask"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("chkHXFullMultibyte"), SIGNAL(stateChanged( int )), SLOT(update_preview()));
|
||||
}
|
||||
|
||||
@ -855,6 +857,7 @@ void MainWindow::change_options()
|
||||
tabMain->insertTab(1,m_optionWidget,tr("Micro QR Cod&e"));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbMQRSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbMQRECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("cmbMQRMask"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("chkMQRFullMultibyte"), SIGNAL(stateChanged( int )), SLOT(update_preview()));
|
||||
}
|
||||
|
||||
@ -1424,8 +1427,12 @@ void MainWindow::update_preview()
|
||||
if (item_val) {
|
||||
m_bc.bc.setSecurityLevel(item_val);
|
||||
}
|
||||
item_val = m_optionWidget->findChild<QComboBox*>("cmbQRMask")->currentIndex();
|
||||
if (item_val) {
|
||||
m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3());
|
||||
}
|
||||
if (m_optionWidget->findChild<QCheckBox*>("chkQRFullMultibyte")->isChecked()) {
|
||||
m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE);
|
||||
m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE | m_bc.bc.option3());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1439,8 +1446,12 @@ void MainWindow::update_preview()
|
||||
if (item_val) {
|
||||
m_bc.bc.setSecurityLevel(item_val);
|
||||
}
|
||||
item_val = m_optionWidget->findChild<QComboBox*>("cmbMQRMask")->currentIndex();
|
||||
if (item_val) {
|
||||
m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3());
|
||||
}
|
||||
if (m_optionWidget->findChild<QCheckBox*>("chkMQRFullMultibyte")->isChecked()) {
|
||||
m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE);
|
||||
m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE | m_bc.bc.option3());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1522,8 +1533,12 @@ void MainWindow::update_preview()
|
||||
if (item_val) {
|
||||
m_bc.bc.setSecurityLevel(item_val);
|
||||
}
|
||||
item_val = m_optionWidget->findChild<QComboBox*>("cmbHXMask")->currentIndex();
|
||||
if (item_val) {
|
||||
m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3());
|
||||
}
|
||||
if (m_optionWidget->findChild<QCheckBox*>("chkHXFullMultibyte")->isChecked()) {
|
||||
m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE);
|
||||
m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE | m_bc.bc.option3());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1951,6 +1966,7 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) {
|
||||
case BARCODE_HIBC_QR:
|
||||
settings.setValue("studio/bc/qrcode/size", get_combobox_index("cmbQRSize"));
|
||||
settings.setValue("studio/bc/qrcode/ecc", get_combobox_index("cmbQRECC"));
|
||||
settings.setValue("studio/bc/qrcode/mask", get_combobox_index("cmbQRMask"));
|
||||
settings.setValue("studio/bc/qrcode/encoding_mode", get_button_group_index(QStringList() << "radDM200Stand" << "radQRGS1" << "radQRHIBC"));
|
||||
settings.setValue("studio/bc/qrcode/chk_full_multibyte", get_checkbox_val("chkQRFullMultibyte"));
|
||||
break;
|
||||
@ -1965,12 +1981,14 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) {
|
||||
case BARCODE_HANXIN:
|
||||
settings.setValue("studio/bc/hanxin/size", get_combobox_index("cmbHXSize"));
|
||||
settings.setValue("studio/bc/hanxin/ecc", get_combobox_index("cmbHXECC"));
|
||||
settings.setValue("studio/bc/hanxin/mask", get_combobox_index("cmbHXMask"));
|
||||
settings.setValue("studio/bc/hanxin/chk_full_multibyte", get_checkbox_val("chkHXFullMultibyte"));
|
||||
break;
|
||||
|
||||
case BARCODE_MICROQR:
|
||||
settings.setValue("studio/bc/microqr/size", get_combobox_index("cmbMQRSize"));
|
||||
settings.setValue("studio/bc/microqr/ecc", get_combobox_index("cmbMQRECC"));
|
||||
settings.setValue("studio/bc/microqr/mask", get_combobox_index("cmbMQRMask"));
|
||||
settings.setValue("studio/bc/microqr/chk_full_multibyte", get_checkbox_val("chkMQRFullMultibyte"));
|
||||
break;
|
||||
|
||||
@ -2174,6 +2192,7 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) {
|
||||
case BARCODE_HIBC_QR:
|
||||
set_combobox_from_setting(settings, "studio/bc/qrcode/size", "cmbQRSize");
|
||||
set_combobox_from_setting(settings, "studio/bc/qrcode/ecc", "cmbQRECC");
|
||||
set_combobox_from_setting(settings, "studio/bc/qrcode/mask", "cmbQRMask");
|
||||
set_radiobutton_from_setting(settings, "studio/bc/qrcode/encoding_mode", QStringList() << "radDM200Stand" << "radQRGS1" << "radQRHIBC");
|
||||
set_checkbox_from_setting(settings, "studio/bc/qrcode/chk_full_multibyte", "chkQRFullMultibyte");
|
||||
break;
|
||||
@ -2188,12 +2207,14 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) {
|
||||
case BARCODE_HANXIN:
|
||||
set_combobox_from_setting(settings, "studio/bc/hanxin/size", "cmbHXSize");
|
||||
set_combobox_from_setting(settings, "studio/bc/hanxin/ecc", "cmbHXECC");
|
||||
set_combobox_from_setting(settings, "studio/bc/hanxin/mask", "cmbHXMask");
|
||||
set_checkbox_from_setting(settings, "studio/bc/hanxin/chk_full_multibyte", "chkHXFullMultibyte");
|
||||
break;
|
||||
|
||||
case BARCODE_MICROQR:
|
||||
set_combobox_from_setting(settings, "studio/bc/microqr/size", "cmbMQRSize");
|
||||
set_combobox_from_setting(settings, "studio/bc/microqr/ecc", "cmbMQRECC");
|
||||
set_combobox_from_setting(settings, "studio/bc/microqr/mask", "cmbMQRMask");
|
||||
set_checkbox_from_setting(settings, "studio/bc/microqr/chk_full_multibyte", "chkMQRFullMultibyte");
|
||||
break;
|
||||
|
||||
|
@ -173,6 +173,10 @@ namespace Zint {
|
||||
m_option_2 = option;
|
||||
}
|
||||
|
||||
int QZint::option3() const {
|
||||
return m_option_3;
|
||||
}
|
||||
|
||||
void QZint::setOption3(int option) {
|
||||
m_option_3 = option;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
int option2() const;
|
||||
void setOption2(int option);
|
||||
|
||||
int option3() const;
|
||||
void setOption3(int option);
|
||||
|
||||
float scale() const;
|
||||
|
@ -199,6 +199,7 @@
|
||||
<ClInclude Include="..\backend\pdf417.h" />
|
||||
<ClInclude Include="..\backend\qr.h" />
|
||||
<ClInclude Include="..\backend\reedsol.h" />
|
||||
<ClInclude Include="..\backend\reedsol_logs.h" />
|
||||
<ClInclude Include="..\backend\rss.h" />
|
||||
<ClInclude Include="..\backend\sjis.h" />
|
||||
<ClInclude Include="..\backend\stdint_msvc.h" />
|
||||
|
@ -569,6 +569,10 @@
|
||||
RelativePath="..\backend\reedsol.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\backend\reedsol_logs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\backend\rss.h"
|
||||
>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)zintd.dll</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lpng\build\Release;..\..\..\zlib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>..\..\..\lpng\build\Release;..\..\..\zlib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -171,7 +171,7 @@
|
||||
<Link>
|
||||
<AdditionalDependencies>zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)zintd.dll</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lpng\build\Release;..\..\..\zlib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>..\..\..\lpng\build\Release;..\..\..\zlib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -378,6 +378,7 @@
|
||||
<ClInclude Include="..\..\backend\pdf417.h" />
|
||||
<ClInclude Include="..\..\backend\qr.h" />
|
||||
<ClInclude Include="..\..\backend\reedsol.h" />
|
||||
<ClInclude Include="..\..\backend\reedsol_logs.h" />
|
||||
<ClInclude Include="..\..\backend\rss.h" />
|
||||
<ClInclude Include="..\..\backend\sjis.h" />
|
||||
<ClInclude Include="..\..\backend\stdint_msvc.h" />
|
||||
|
@ -146,6 +146,7 @@
|
||||
<ClInclude Include="..\..\backend\pdf417.h" />
|
||||
<ClInclude Include="..\..\backend\qr.h" />
|
||||
<ClInclude Include="..\..\backend\reedsol.h" />
|
||||
<ClInclude Include="..\..\backend\reedsol_logs.h" />
|
||||
<ClInclude Include="..\..\backend\rss.h" />
|
||||
<ClInclude Include="..\..\backend\sjis.h" />
|
||||
<ClInclude Include="..\..\backend\stdint_msvc.h" />
|
||||
|
@ -158,7 +158,7 @@
|
||||
<DebugInformationFormat />
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>d:\opt\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>..\..\..\lpng\build\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@ -179,7 +179,7 @@
|
||||
</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>d:\opt\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>..\..\..\lpng\build\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_LIB|Win32'">
|
||||
|
@ -199,6 +199,7 @@
|
||||
<ClInclude Include="..\..\backend\pdf417.h" />
|
||||
<ClInclude Include="..\..\backend\qr.h" />
|
||||
<ClInclude Include="..\..\backend\reedsol.h" />
|
||||
<ClInclude Include="..\..\backend\reedsol_logs.h" />
|
||||
<ClInclude Include="..\..\backend\rss.h" />
|
||||
<ClInclude Include="..\..\backend\sjis.h" />
|
||||
<ClInclude Include="..\..\backend\stdint_msvc.h" />
|
||||
|