diff --git a/ChangeLog b/ChangeLog index 2cd97934..f1b718df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Version 2.16.0.9 (dev) not released yet (2026-05-26) +Version 2.16.0.9 (dev) not released yet (2026-06-23) ==================================================== **Incompatible changes** @@ -11,6 +11,8 @@ Version 2.16.0.9 (dev) not released yet (2026-05-26) - New Qt Backend method `save_as_memfile()` to save file to memory - New Qt Backend methods `gs1Raw()` and `setGS1Raw()` for new `GS1RAW_MODE` option for processing GS1 input +- New Qt Backend helper methods `setBorderTypeValue()`, `encodedInputMode()`, + `encodedOutputOptions()`, `ECIValueToECIIndex()` and `ECIIndexToECIValue()` - CLI now warns if both "--dmre" and "--square" are given (previously silently ignored "--dmre") - New escape sequences `\L` (DLE), `\F` (FS), `\N` (US) @@ -22,6 +24,7 @@ Changes creating temporary file - CLI: allow "tiff" as filetype (saved as ".tif"); make args for "--scalexdimdp" and "--scmvv" optional; + make "--mirror" available in standard non-batch mode; add `ZINT_TEST`-only "--test" option to do various internal tests - GS1SE: exclude GS1_128 from requisite AIs check as may be spread across more than one barcode (ticket #348, props Harald Oehlmann and Terry Burton) @@ -71,6 +74,7 @@ Bugs - ZBarcode_Encode_Segs: allow for multiple (stacked) rows when setting absolute minimum height - CLI: stop looping over data args when have error +- composite: preserve `gs1_verify()` warning (if any) Version 2.16.0 (2025-12-19) diff --git a/backend/aztec.c b/backend/aztec.c index 00df7ec1..8015691a 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -46,6 +46,29 @@ #define AZ_BIN_CAP_CWDS_S "1661" /* String version of (AZTEC_BIN_CAPACITY / 12) */ +#ifdef ZINT_TEST +/* For testing `malloc()`/`realloc()` failures */ +static int az_fail_id = 0; +static int az_fail_at = 0; + +INTERNAL void zint_test_az_set_fail(const int id, const int at) { + az_fail_id = id; + az_fail_at = at; +} + +/* TODO: put these in "aztec.h" (& rename existing "aztec.h" to "aztec_tabs.h" */ +#define AZ_FAIL_ID_LIST_INIT 1 +#define AZ_FAIL_ID_CPY 2 +#define AZ_FAIL_ID_ADD_CHK 3 +#define AZ_FAIL_ID_LIST_ADD_CHK 4 + +#define az_malloc(id, sz) (az_fail_at > 0 && az_fail_id == (id) && --az_fail_at == 0 ? NULL : malloc(sz)) +#define az_realloc(id, ptr, sz) (az_fail_at > 0 && az_fail_id == (id) && --az_fail_at == 0 ? NULL : realloc(ptr, sz)) +#else +#define az_malloc(id, sz) malloc(sz) +#define az_realloc(id, ptr, sz) realloc(ptr, sz) +#endif + /* Count number of consecutive (. SP) or (, SP) Punct mode doubles for comparison against Digit mode encoding */ static int az_count_doubles(const unsigned char source[], const int length, const int position) { int i; @@ -455,7 +478,7 @@ struct az_state_list { static int az_state_list_init(struct az_state_list *list, const unsigned short initial_size) { const unsigned short size = initial_size < AZ_MIN_STATES_SIZE ? AZ_MIN_STATES_SIZE : initial_size; - if (!(list->states = (struct az_state *) malloc(sizeof(struct az_state) * size))) { + if (!(list->states = (struct az_state *) az_malloc(AZ_FAIL_ID_LIST_INIT, sizeof(struct az_state) * size))) { list->used = list->size = 0; return 0; } @@ -469,7 +492,7 @@ static int az_state_cpy(const struct az_state *src, struct az_state *dst) { const unsigned short size = src->tokens.size < AZ_MIN_TOKENS_SIZE ? AZ_MIN_TOKENS_SIZE : src->tokens.size; *dst = *src; - if (!(dst->tokens.tokens = (struct az_token *) malloc(sizeof(struct az_token) * size))) { + if (!(dst->tokens.tokens = (struct az_token *) az_malloc(AZ_FAIL_ID_CPY, sizeof(struct az_token) * size))) { return 0; } if (src->tokens.used) { @@ -490,18 +513,13 @@ static void az_state_free(struct az_state *state) { /* Check that there's enough room for `extra` more tokens in `state` */ static int az_tokens_add_chk(struct az_state *state, const int extra) { assert(extra > 0 && extra < AZ_MIN_TOKENS_SIZE); - if (!state->tokens.tokens) { - const unsigned short size = AZ_MIN_TOKENS_SIZE; - if (!(state->tokens.tokens = (struct az_token *) malloc(sizeof(struct az_token) * size))) { - return 0; - } - state->tokens.size = size; - state->tokens.used = 0; - } else if (state->tokens.used >= state->tokens.size - extra) { /* Compare this way to avoid possible overflow */ + assert(state->tokens.tokens); /* Always called only after a successful `az_state_cpy()` */ + if (state->tokens.used >= state->tokens.size - extra) { /* Compare this way to avoid possible overflow */ struct az_token *tokens; const unsigned short size = state->tokens.size * 2; if (size <= state->tokens.size /* Overflow */ - || !(tokens = (struct az_token *) realloc(state->tokens.tokens, sizeof(struct az_token) * size))) { + || !(tokens = (struct az_token *) az_realloc(AZ_FAIL_ID_ADD_CHK, state->tokens.tokens, + sizeof(struct az_token) * size))) { return 0; } assert(size > state->tokens.used + extra); @@ -517,7 +535,8 @@ static int az_state_list_add_chk(struct az_state_list *list) { struct az_state *states; const unsigned short size = list->size * 2; if (size <= list->size /* Overflow */ - || !(states = (struct az_state *) realloc(list->states, sizeof(struct az_state) * size))) { + || !(states = (struct az_state *) az_realloc(AZ_FAIL_ID_LIST_ADD_CHK, list->states, + sizeof(struct az_state) * size))) { return 0; } list->states = states; @@ -526,8 +545,8 @@ static int az_state_list_add_chk(struct az_state_list *list) { return 1; } -/* Free all states (including their tokens) of state list `list` */ -static void az_state_list_free(struct az_state_list *list) { +/* Free all states (including their tokens) of state list `list` - returns 0 for convenience */ +static int az_state_list_free(struct az_state_list *list) { int i; if (list->states) { for (i = 0; i < list->used; i++) { @@ -539,6 +558,7 @@ static void az_state_list_free(struct az_state_list *list) { list->states = NULL; } list->used = list->size = 0; + return 0; } #define AZ_FNC1_VAL 32 /* Pseudo-value for FNC1 - converted to 0 on setting token value */ @@ -919,13 +939,12 @@ static int az_UpdateStateListForPair(struct az_state_list *list, const int from, } for (i = 0; i < list->used; i++) { if (!az_UpdateStateForPair(list->states + i, from, pairCode, ret_list)) { - az_state_list_free(ret_list); - return 0; + return az_state_list_free(ret_list); /* Returns 0 */ } } az_SimplifyStates(ret_list); - az_state_list_free(list); + (void) az_state_list_free(list); list->states = ret_list->states; list->size = ret_list->size; list->used = ret_list->used; @@ -945,15 +964,14 @@ static int az_UpdateStateListForChar(struct az_state_list *list, const unsigned } for (i = 0; i < list->used; i++) { if (!az_UpdateStateForChar(list->states + i, source, from, fnc1_if_gs, ret_list)) { - az_state_list_free(ret_list); - return 0; + return az_state_list_free(ret_list); /* Returns 0 */ } } if (ret_list->used > 1) { az_SimplifyStates(ret_list); } - az_state_list_free(list); + (void) az_state_list_free(list); list->states = ret_list->states; list->size = ret_list->size; list->used = ret_list->used; @@ -995,14 +1013,12 @@ static int az_binary_string(const unsigned char source[], const int length, int /* (CR LF) -> 2, (. SP) -> 3, (, SP) -> 4, (: SP) -> 5 */ const int pairCode = source[i] == '\r' ? 2 : 3 + 7 - ((source[i] & 0x0F) >> 1); if (!az_UpdateStateListForPair(list, i, pairCode)) { - az_state_list_free(list); - return 0; + return az_state_list_free(list); /* Returns 0 */ } i++; } else { if (!az_UpdateStateListForChar(list, source, i, fncs[i])) { - az_state_list_free(list); - return 0; + return az_state_list_free(list); /* Returns 0 */ } } } @@ -1018,13 +1034,12 @@ static int az_binary_string(const unsigned char source[], const int length, int if (!az_EndByteShift(list->states + minStateIdx, &stateEnd, length)) { az_state_free(&stateEnd); - az_state_list_free(list); - return 0; + return az_state_list_free(list); /* Returns 0 */ } if (stateEnd.bitCount > AZTEC_BIN_CAPACITY) { az_state_free(&stateEnd); - az_state_list_free(list); + (void) az_state_list_free(list); return stateEnd.bitCount; } @@ -1055,7 +1070,7 @@ static int az_binary_string(const unsigned char source[], const int length, int *p_current_mode = stateEnd.mode; az_state_free(&stateEnd); - az_state_list_free(list); + (void) az_state_list_free(list); return bp; } @@ -1586,7 +1601,7 @@ static int az_codeword_size(const int layers) { /* Encodes Aztec Code as specified in ISO/IEC 24778:2008 */ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) { - int x, y, i, p, data_blocks, ecc_blocks, layers, total_bits; + int x, y, i, p, num_data_cws, num_ecc_cws, layers, total_bits; char bit_pattern[AZTEC_MAP_POSN_MAX + 1]; /* Note AZTEC_MAP_POSN_MAX > AZTEC_BIN_CAPACITY */ /* To lessen stack usage, share binary_string buffer with bit_pattern, as accessed separately */ char *binary_string = bit_pattern; @@ -1693,7 +1708,7 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons if (symbol->option_1 < -1 || symbol->option_1 > 4) { z_errtxtf(0, symbol, 503, "Error correction level '%d' out of range (1 to 4)", symbol->option_1); - if (symbol->warn_level == WARN_FAIL_ALL) { + if ((symbol->warn_level & 0xFF) == WARN_FAIL_ALL) { return ZINT_ERROR_INVALID_OPTION; } error_number = z_errtxt_adj(ZINT_WARN_INVALID_OPTION, symbol, "%1$s%2$s", ", ignoring"); @@ -1839,26 +1854,26 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons "Input too long for Reader Initialisation, requires %d layers (maximum 22)", layers); } - data_blocks = adjusted_length / codeword_size; + num_data_cws = adjusted_length / codeword_size; if (compact) { - ecc_blocks = AztecCompactSizes[layers - 1] - data_blocks; - if (layers == 4) { /* Can use spare blocks for ECC (76 available - 64 max data blocks) */ - ecc_blocks += 12; + num_ecc_cws = AztecCompactSizes[layers - 1] - num_data_cws; + if (layers == 4) { /* Can use spare codewords for ECC (76 available - 64 max data codewords) */ + num_ecc_cws += 12; } } else { - ecc_blocks = AztecSizes[layers - 1] - data_blocks; + num_ecc_cws = AztecSizes[layers - 1] - num_data_cws; } - if (ecc_blocks == 3) { + if (num_ecc_cws == 3) { ecc_ratio = 0.0f; error_number = z_errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 706, "Number of ECC codewords 3 at minimum"); symbol->option_1 = -1; /* Feedback options: indicate minimum 3 with -1 */ } else { - ecc_ratio = z_stripf((float) (ecc_blocks - 3) / (data_blocks + ecc_blocks)); + ecc_ratio = z_stripf((float) (num_ecc_cws - 3) / (num_data_cws + num_ecc_cws)); if (ecc_ratio < 0.05f) { error_number = ZEXT z_errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 708, "Number of ECC codewords %1$d less than 5%% + 3 of data codewords %2$d", - ecc_blocks, data_blocks); + num_ecc_cws, num_data_cws); symbol->option_1 = 0; /* Feedback options: indicate < 5% + 3 with 0 */ } else { /* Feedback options: 0.165 = (.1 + .23) / 2 etc */ @@ -1868,15 +1883,15 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons symbol->option_1 |= ((int) z_stripf(ecc_ratio * 100.0f)) << 8; } - data_part = (unsigned int *) z_alloca(sizeof(unsigned int) * data_blocks); - ecc_part = (unsigned int *) z_alloca(sizeof(unsigned int) * ecc_blocks); + data_part = (unsigned int *) z_alloca(sizeof(unsigned int) * num_data_cws); + ecc_part = (unsigned int *) z_alloca(sizeof(unsigned int) * num_ecc_cws); /* Copy across data into separate integers */ - memset(data_part, 0, sizeof(unsigned int) * data_blocks); - memset(ecc_part, 0, sizeof(unsigned int) * ecc_blocks); + memset(data_part, 0, sizeof(unsigned int) * num_data_cws); + memset(ecc_part, 0, sizeof(unsigned int) * num_ecc_cws); /* Split into codewords and calculate reed-solomon error correction codes */ - for (i = 0; i < data_blocks; i++) { + for (i = 0; i < num_data_cws; i++) { for (p = 0; p < codeword_size; p++) { if (adjusted_string[i * codeword_size + p] == '1') { data_part[i] |= 0x01 << (codeword_size - (p + 1)); @@ -1887,40 +1902,40 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons switch (codeword_size) { case 6: zint_rs_init_gf(&rs, 0x43); - zint_rs_init_code(&rs, ecc_blocks, 1); - zint_rs_encode_uint(&rs, data_blocks, data_part, ecc_part); + zint_rs_init_code(&rs, num_ecc_cws, 1); + zint_rs_encode_uint(&rs, num_data_cws, data_part, ecc_part); break; case 8: zint_rs_init_gf(&rs, 0x12d); - zint_rs_init_code(&rs, ecc_blocks, 1); - zint_rs_encode_uint(&rs, data_blocks, data_part, ecc_part); + zint_rs_init_code(&rs, num_ecc_cws, 1); + zint_rs_encode_uint(&rs, num_data_cws, data_part, ecc_part); break; case 10: if (!zint_rs_uint_init_gf(&rs_uint, 0x409, 1023)) { /* Can fail on malloc() */ return z_errtxt(ZINT_ERROR_MEMORY, symbol, 500, "Insufficient memory for Reed-Solomon log tables"); } - zint_rs_uint_init_code(&rs_uint, ecc_blocks, 1); - zint_rs_uint_encode(&rs_uint, data_blocks, data_part, ecc_part); + zint_rs_uint_init_code(&rs_uint, num_ecc_cws, 1); + zint_rs_uint_encode(&rs_uint, num_data_cws, data_part, ecc_part); zint_rs_uint_free(&rs_uint); break; case 12: if (!zint_rs_uint_init_gf(&rs_uint, 0x1069, 4095)) { /* Can fail on malloc() */ return z_errtxt(ZINT_ERROR_MEMORY, symbol, 700, "Insufficient memory for Reed-Solomon log tables"); } - zint_rs_uint_init_code(&rs_uint, ecc_blocks, 1); - zint_rs_uint_encode(&rs_uint, data_blocks, data_part, ecc_part); + zint_rs_uint_init_code(&rs_uint, num_ecc_cws, 1); + zint_rs_uint_encode(&rs_uint, num_data_cws, data_part, ecc_part); zint_rs_uint_free(&rs_uint); break; } - for (i = 0; i < ecc_blocks; i++) { + for (i = 0; i < num_ecc_cws; i++) { adjusted_length = z_bin_append_posn(ecc_part[i], codeword_size, adjusted_string, adjusted_length); } /* Invert the data so that actual data is on the outside and reed-solomon on the inside */ memset(bit_pattern, '0', AZTEC_MAP_POSN_MAX + 1); - total_bits = (data_blocks + ecc_blocks) * codeword_size; + total_bits = (num_data_cws + num_ecc_cws) * codeword_size; for (i = 0; i < total_bits; i++) { bit_pattern[i] = adjusted_string[total_bits - i - 1]; } @@ -1941,10 +1956,10 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons descriptor[0] = ((layers - 1) & 0x02) ? '1' : '0'; descriptor[1] = ((layers - 1) & 0x01) ? '1' : '0'; - /* The next 6 bits represent the number of data blocks minus 1 */ - descriptor[2] = reader_init || ((data_blocks - 1) & 0x20) ? '1' : '0'; + /* The next 6 bits represent the number of data codewords minus 1 */ + descriptor[2] = reader_init || ((num_data_cws - 1) & 0x20) ? '1' : '0'; for (i = 3; i < 8; i++) { - descriptor[i] = ((data_blocks - 1) & (0x10 >> (i - 3))) ? '1' : '0'; + descriptor[i] = ((num_data_cws - 1) & (0x10 >> (i - 3))) ? '1' : '0'; } if (debug_print) printf("Mode Message = %.8s\n", descriptor); } else { @@ -1953,10 +1968,10 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons descriptor[i] = ((layers - 1) & (0x10 >> i)) ? '1' : '0'; } - /* The next 11 bits represent the number of data blocks minus 1 */ - descriptor[5] = reader_init || ((data_blocks - 1) & 0x400) ? '1' : '0'; + /* The next 11 bits represent the number of data codewords minus 1 */ + descriptor[5] = reader_init || ((num_data_cws - 1) & 0x400) ? '1' : '0'; for (i = 6; i < 16; i++) { - descriptor[i] = ((data_blocks - 1) & (0x200 >> (i - 6))) ? '1' : '0'; + descriptor[i] = ((num_data_cws - 1) & (0x200 >> (i - 6))) ? '1' : '0'; } if (debug_print) printf("Mode Message = %.16s\n", descriptor); } @@ -2034,9 +2049,9 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons if (debug_print) { printf("Generating a %dx%d %s symbol with %d layers\n", dim, dim, compact ? "compact" : "full-size", layers); - printf("Requires %d codewords of %d-bits\n", data_blocks + ecc_blocks, codeword_size); + printf("Requires %d codewords of %d-bits\n", num_data_cws + num_ecc_cws, codeword_size); printf(" (%d data words, %d ecc words, %.1f%%, output option_1 0x%X, option_2 %d)\n", - data_blocks, ecc_blocks, ecc_ratio * 100, symbol->option_1, symbol->option_2); + num_data_cws, num_ecc_cws, ecc_ratio * 100, symbol->option_1, symbol->option_2); } return error_number; diff --git a/backend/aztec.h b/backend/aztec.h index ea0527fd..5711af9f 100644 --- a/backend/aztec.h +++ b/backend/aztec.h @@ -254,7 +254,7 @@ static const short AztecSizes[32] = { }; static const short AztecCompactSizes[4] = { - 17, 40, 51, 64 /* 64 data blocks (Mode Message max) but 76 altogether */ + 17, 40, 51, 64 /* 64 data codewords (Mode Message max) but 76 altogether */ }; /* Tables `AztecDataSizes` and `AztecCompactDataSizes` generated by "backend/tools/gen_aztec_data_sizes.php" */ diff --git a/backend/aztec_trace.h b/backend/aztec_trace.h index 2cbb708d..128b3dbf 100644 --- a/backend/aztec_trace.h +++ b/backend/aztec_trace.h @@ -34,25 +34,25 @@ #define Z_AZTEC_TRACE_H static void AZ_TRACE_EdgeToString(char *buf, const unsigned char *source, const int length, const char initial_mode, - struct az_edge *edges, struct az_edge *edge) { + struct az_edge *edges, struct az_edge *edge) { struct az_edge *previous_edge = AZ_PREVIOUS(edges, edge); int previousMode = previous_edge ? previous_edge->mode : initial_mode; - int previous = previous_edge ? (int) (previous_edge - edges) : 0; - int current = (int) (edge - edges); + int previous = previous_edge ? (int) (previous_edge - edges) : 0; + int current = (int) (edge - edges); (void)length; if (buf) { sprintf(buf, "%d_%c_%d %c(%d,%d) %d -> %d_%c_%d", edge->from, az_mode_char(previousMode), previous, az_mode_char(edge->mode), source[edge->from], edge->len, - edge->size, edge->from + 1, az_mode_char(edge->mode), current); + edge->size, edge->from + 1, az_mode_char(edge->mode), current); } else { printf("%d_%c_%d %c(%d,%d) %d -> %d_%c_%d", edge->from, az_mode_char(previousMode), previous, az_mode_char(edge->mode), source[edge->from], edge->len, - edge->size, edge->from + 1, az_mode_char(edge->mode), current); + edge->size, edge->from + 1, az_mode_char(edge->mode), current); } } static void AZ_TRACE_Path(const unsigned char *source, const int length, const char initial_mode, - struct az_edge *edges, struct az_edge *edge, char *result, const int result_size) { + struct az_edge *edges, struct az_edge *edge, char *result, const int result_size) { struct az_edge *current; AZ_TRACE_EdgeToString(result, source, length, initial_mode, edges, edge); current = AZ_PREVIOUS(edges, edge); diff --git a/backend/code.c b/backend/code.c index 46ae849b..10ce931e 100644 --- a/backend/code.c +++ b/backend/code.c @@ -241,9 +241,9 @@ INTERNAL int zint_excode39(struct zint_symbol *symbol, unsigned char source[], i } /* Then send the buffer to the C39 function */ - if ((error_number = zint_code39(symbol, buffer, (int) (b - buffer))) >= ZINT_ERROR) { - return error_number; - } + error_number = zint_code39(symbol, buffer, (int) (b - buffer)); + /* Due to above checks & not using content segs, can only return warning (height) */ + assert(error_number < ZINT_ERROR); if (saved_option_2 == 2) { symbol->option_2 = 2; /* Restore */ diff --git a/backend/code1.c b/backend/code1.c index d1bbbc3b..b94117a4 100644 --- a/backend/code1.c +++ b/backend/code1.c @@ -1,7 +1,7 @@ /* code1.c - USS Code One */ /* libzint - the open source barcode library - Copyright (C) 2009-2025 Robin Stuart + Copyright (C) 2009-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -195,30 +195,30 @@ static int c1_look_ahead_test(const unsigned char source[], const int length, co byte_count = C1_MULT_3; } + assert(current_mode != C1_EDI); /* Not called in EDI mode */ switch (current_mode) { case C1_C40: c40_count = 0; break; /* Step J2 */ case C1_TEXT: text_count = 0; break; /* Step J3 */ - case C1_EDI: edi_count = 0; break; /* Missing in spec */ case C1_BYTE: byte_count = 0; break; /* Step J4 */ } for (sp = position; sp < length; sp++) { - const unsigned char c = source[sp]; - const int is_extended = !z_isascii(c); + const unsigned char ch = source[sp]; + const int is_extended = !z_isascii(ch); /* Step L */ - if (z_isdigit(c)) { + if (z_isdigit(ch)) { ascii_count += C1_MULT_1_DIV_2; /* Step L1 */ } else { if (is_extended) { - ascii_count = ceilf(ascii_count) + C1_MULT_2; /* Step L2 */ + ascii_count = C1_MULT_CEIL(ascii_count) + C1_MULT_2; /* Step L2 */ } else { - ascii_count = ceilf(ascii_count) + C1_MULT_1; /* Step L3 */ + ascii_count = C1_MULT_CEIL(ascii_count) + C1_MULT_1; /* Step L3 */ } } /* Step M */ - if (c1_isc40(c)) { + if (c1_isc40(ch)) { c40_count += C1_MULT_2_DIV_3; /* Step M1 */ } else if (is_extended) { c40_count += C1_MULT_8_DIV_3; /* Step M2 */ @@ -227,7 +227,7 @@ static int c1_look_ahead_test(const unsigned char source[], const int length, co } /* Step N */ - if (c1_istext(c)) { + if (c1_istext(ch)) { text_count += C1_MULT_2_DIV_3; /* Step N1 */ } else if (is_extended) { text_count += C1_MULT_8_DIV_3; /* Step N2 */ @@ -236,7 +236,7 @@ static int c1_look_ahead_test(const unsigned char source[], const int length, co } /* Step O */ - if (c1_isedi(c)) { + if (c1_isedi(ch)) { edi_count += C1_MULT_2_DIV_3; /* Step O1 */ } else if (is_extended) { edi_count += C1_MULT_13_DIV_3; /* Step O2 */ @@ -245,7 +245,7 @@ static int c1_look_ahead_test(const unsigned char source[], const int length, co } /* Step P */ - if (gs1 && c == '\x1D') { + if (gs1 && ch == '\x1D') { byte_count += C1_MULT_3; /* Step P1 */ } else { byte_count += C1_MULT_1; /* Step P2 */ @@ -978,7 +978,7 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], int len } /* Call `c1_encode()` for each segment */ -static int c1_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, const int gs1, +static void c1_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, const int gs1, unsigned int target[], int *p_data_length, int *p_last_mode) { int i; int tp = 0; @@ -994,8 +994,6 @@ static int c1_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co } *p_data_length = tp; - - return 0; } /* Set symbol from datagrid */ @@ -1160,9 +1158,7 @@ INTERNAL int zint_codeone(struct zint_symbol *symbol, struct zint_seg segs[], co i); } - if (c1_encode_segs(symbol, segs, seg_count, gs1, target, &data_length, &last_mode)) { - return ZINT_ERROR_MEMORY; /* `c1_encode_segs()` only returns non-zero with OOM */ - } + c1_encode_segs(symbol, segs, seg_count, gs1, target, &data_length, &last_mode); assert(data_length); /* Can't exceed C1_MAX_CWS as input <= 90 */ if (data_length > 38) { @@ -1245,9 +1241,7 @@ INTERNAL int zint_codeone(struct zint_symbol *symbol, struct zint_seg segs[], co int blocks, data_blocks, ecc_blocks, ecc_length; int last_mode; - if (c1_encode_segs(symbol, segs, seg_count, gs1, target, &data_length, &last_mode)) { - return ZINT_ERROR_MEMORY; /* `c1_encode_segs()` only returns non-zero with OOM */ - } + c1_encode_segs(symbol, segs, seg_count, gs1, target, &data_length, &last_mode); if (data_length == 0) { return z_errtxt(ZINT_ERROR_TOO_LONG, symbol, 517, diff --git a/backend/common.c b/backend/common.c index 4326ea3f..722ba4d5 100644 --- a/backend/common.c +++ b/backend/common.c @@ -998,6 +998,24 @@ INTERNAL void z_hrt_conv_gs1_brackets_nochk(struct zint_symbol *symbol, const un symbol->text[length] = '\0'; } +#ifdef ZINT_TEST +/* For testing content segment `calloc()`/`malloc()` failures */ +static int z_ct_fail_id = 0; +static int z_ct_fail_at = 0; + +INTERNAL void zint_test_ct_set_fail(const int id, const int at) { + z_ct_fail_id = id; + z_ct_fail_at = at; +} + +#define ct_calloc(id, num, sz) (z_ct_fail_at > 0 && z_ct_fail_id == (id) && --z_ct_fail_at == 0 \ + ? NULL : calloc(num, sz)) +#define ct_malloc(id, sz) (z_ct_fail_at > 0 && z_ct_fail_id == (id) && --z_ct_fail_at == 0 ? NULL : malloc(sz)) +#else +#define ct_calloc(id, num, sz) calloc(num, sz) +#define ct_malloc(id, sz) malloc(sz) +#endif + /* Initialize `content_segs` for `seg_count` segments. On error sets `errtxt`, returning BARCODE_ERROR_MEMORY */ INTERNAL int z_ct_init_segs(struct zint_symbol *symbol, const int seg_count) { int i; @@ -1005,7 +1023,8 @@ INTERNAL int z_ct_init_segs(struct zint_symbol *symbol, const int seg_count) { if (symbol->content_segs) { z_ct_free_segs(symbol); } - if (!(symbol->content_segs = (struct zint_seg *) calloc((size_t) seg_count, sizeof(struct zint_seg)))) { + if (!(symbol->content_segs + = (struct zint_seg *) ct_calloc(Z_CT_FAIL_ID_INIT_SEGS, (size_t) seg_count, sizeof(struct zint_seg)))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 243, "Insufficient memory for content segs buffer"); } for (i = 0; i < seg_count; i++) { @@ -1039,7 +1058,8 @@ static int ct_init_seg_source(struct zint_symbol *symbol, const int seg_idx, con assert(!symbol->content_segs[seg_idx].source); assert(length > 0); - if (!(symbol->content_segs[seg_idx].source = (unsigned char *) malloc((size_t) length))) { + if (!(symbol->content_segs[seg_idx].source + = (unsigned char *) ct_malloc(Z_CT_FAIL_ID_INIT_SEG_SRC, (size_t) length))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 245, "Insufficient memory for content segs source buffer"); } return 0; diff --git a/backend/common.h b/backend/common.h index d2da2e21..475e2774 100644 --- a/backend/common.h +++ b/backend/common.h @@ -142,12 +142,13 @@ typedef unsigned __int64 uint64_t; #define z_isfintf(arg) (fmodf(arg, 1.0f) == 0.0f) /* Simple versions of functions with no dependence on locale */ -#define z_isdigit(ch) ((ch) <= '9' && (ch) >= '0') -#define z_isupper(ch) ((ch) >= 'A' && (ch) <= 'Z') -#define z_islower(ch) ((ch) >= 'a' && (ch) <= 'z') -#define z_isalpha(ch) (z_isupper(ch) || z_islower(ch)) -#define z_isascii(ch) (!((ch) & ~0x7F)) -#define z_iscntrl(ch) (!((ch) & ~0x1F) || (ch) == 127) +#define z_isdigit(ch) ((ch) <= '9' && (ch) >= '0') +#define z_isxdigit(ch) (z_isdigit(ch) || (((ch) | 0x20) >= 'a' && ((ch) | 0x20) <= 'f')) +#define z_isupper(ch) ((ch) >= 'A' && (ch) <= 'Z') +#define z_islower(ch) ((ch) >= 'a' && (ch) <= 'z') +#define z_isalpha(ch) z_islower(ch | 0x20) +#define z_isascii(ch) (!((ch) & ~0x7F)) +#define z_iscntrl(ch) (!((ch) & ~0x1F) || (ch) == 127) /* Shorthands to cast away char pointer signedness */ #define ZUCP(p) ((unsigned char *) (p)) @@ -355,6 +356,12 @@ INTERNAL void z_hrt_printf_nochk(struct zint_symbol *symbol, const char *fmt, .. INTERNAL void z_hrt_conv_gs1_brackets_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length); +#ifdef ZINT_TEST +/* For testing content segment `calloc()`/`malloc()` failures */ +#define Z_CT_FAIL_ID_INIT_SEGS 1 +#define Z_CT_FAIL_ID_INIT_SEG_SRC 2 +INTERNAL void zint_test_ct_set_fail(const int id, const int at); +#endif /* Initialize `content_segs` for `seg_count` segments. On error sets `errtxt`, returning BARCODE_ERROR_MEMORY */ INTERNAL int z_ct_init_segs(struct zint_symbol *symbol, const int seg_count); diff --git a/backend/composite.c b/backend/composite.c index 6a8c3a3d..c98dfcbb 100644 --- a/backend/composite.c +++ b/backend/composite.c @@ -66,12 +66,14 @@ INTERNAL int zint_ean_leading_zeroes(struct zint_symbol *symbol, const unsigned unsigned char local_source[], int *p_with_addon, unsigned char *zfirst_part, unsigned char *zsecond_part); -INTERNAL int zint_dbar_omnstk_set_height(struct zint_symbol *symbol, const int first_row); +INTERNAL int zint_dbar_stk_set_height(struct zint_symbol *symbol, const int first_row, const int no_errtxt); INTERNAL int zint_dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows); INTERNAL int zint_dbar_ltd_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows); INTERNAL int zint_dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows); INTERNAL int zint_dbar_exp_date(const unsigned char source[], const int length, const int position); +INTERNAL int zint_micropdf_variant(const int cols, const int mclength); + static int cc_min(const int first, const int second) { if (first <= second) @@ -111,11 +113,9 @@ static int cc_encode928(const unsigned short bitString[], unsigned short codeWor /* CC-A 2D component */ static void cc_a(struct zint_symbol *symbol, const char source[], const int cc_width) { - int i, segment, bitlen, cwCnt, variant; - int k, offset, j, total, rsCodeWords[8] = {0}; - int LeftRAPStart, RightRAPStart, CentreRAPStart, StartCluster; + int i, j, bitlen, cwCnt, ecc_cwds, variant; + int offset, rsCodeWords[8] = {0}; int LeftRAP, RightRAP, CentreRAP, Cluster; - int loop; unsigned short codeWords[28] = {0}; unsigned short bitStr[13] = {0}; char pattern[580]; @@ -126,14 +126,14 @@ static void cc_a(struct zint_symbol *symbol, const char source[], const int cc_w bitlen = (int) strlen(source); - for (segment = 0; segment < 13; segment++) { - const int strpos = segment * 16; + for (j = 0; j < 13; j++) { + const int strpos = j * 16; if (strpos >= bitlen) { break; } for (i = 0; i < 16 && strpos + i < bitlen; i++) { if (source[strpos + i] == '1') { - bitStr[segment] |= (0x8000 >> i); + bitStr[j] |= (0x8000 >> i); } } } @@ -173,15 +173,15 @@ static void cc_a(struct zint_symbol *symbol, const char source[], const int cc_w break; } - symbol->rows = cc_aVariants[variant]; - k = cc_aVariants[17 + variant]; - offset = cc_aVariants[34 + variant]; + symbol->rows = cc_aVariants[0][variant]; + ecc_cwds = cc_aVariants[1][variant]; + offset = cc_aVariants[2][variant]; /* Reed-Solomon error correction */ for (i = 0; i < cwCnt; i++) { - total = (codeWords[i] + rsCodeWords[k - 1]) % 929; - for (j = k - 1; j >= 0; j--) { + const int total = (codeWords[i] + rsCodeWords[ecc_cwds - 1]) % 929; + for (j = ecc_cwds - 1; j >= 0; j--) { if (j == 0) { rsCodeWords[j] = (929 - (total * cc_aCoeffs[offset + j]) % 929) % 929; } else { @@ -190,85 +190,66 @@ static void cc_a(struct zint_symbol *symbol, const char source[], const int cc_w } } - for (j = 0; j < k; j++) { + for (j = 0; j < ecc_cwds; j++) { if (rsCodeWords[j] != 0) { rsCodeWords[j] = 929 - rsCodeWords[j]; } } - for (i = k - 1; i >= 0; i--) { + for (i = ecc_cwds - 1; i >= 0; i--) { codeWords[cwCnt] = rsCodeWords[i]; cwCnt++; } /* Place data into table */ - LeftRAPStart = cc_aRAPTable[variant]; - CentreRAPStart = cc_aRAPTable[variant + 17]; - RightRAPStart = cc_aRAPTable[variant + 34]; - StartCluster = cc_aRAPTable[variant + 51] / 3; + LeftRAP = cc_aRAPTable[0][variant] - 1; + CentreRAP = cc_aRAPTable[1][variant] - 1; + RightRAP = cc_aRAPTable[2][variant] - 1; - LeftRAP = LeftRAPStart; - CentreRAP = CentreRAPStart; - RightRAP = RightRAPStart; - Cluster = StartCluster; /* Cluster can be 0, 1 or 2 for Cluster(0), Cluster(3) and Cluster(6) */ + /* Cluster can be 0, 1 or 2 for Cluster(0), Cluster(3) and Cluster(6) */ + Cluster = cc_aRAPTable[3][variant]; /* Pre-divided by 3 */ for (i = 0; i < symbol->rows; i++) { + const int k = i * cc_width; bp = 0; offset = 929 * Cluster; - k = i * cc_width; /* Copy the data into codebarre */ if (cc_width != 3) { - bp = z_bin_append_posn(zint_pdf_rap_side[LeftRAP - 1], 10, pattern, bp); + bp = z_bin_append_posn(zint_pdf_rap_side[LeftRAP], 10, pattern, bp); } - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + codeWords[k]], 16, pattern, bp); - pattern[bp++] = '0'; + bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + codeWords[k]]) << 1, 17, pattern, bp); if (cc_width >= 2) { if (cc_width == 3) { - bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP - 1], 10, pattern, bp); + bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP], 10, pattern, bp); } - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + codeWords[k + 1]], 16, pattern, bp); - pattern[bp++] = '0'; + bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + codeWords[k + 1]]) << 1, 17, pattern, bp); if (cc_width >= 3) { if (cc_width == 4) { - bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP - 1], 10, pattern, bp); + bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP], 10, pattern, bp); } - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + codeWords[k + 2]], 16, pattern, bp); - pattern[bp++] = '0'; + bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + codeWords[k + 2]]) << 1, 17, pattern, bp); if (cc_width == 4) { - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + codeWords[k + 3]], 16, pattern, bp); - pattern[bp++] = '0'; + bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + codeWords[k + 3]]) << 1, 17, pattern, + bp); } } } - bp = z_bin_append_posn(zint_pdf_rap_side[RightRAP - 1], 10, pattern, bp); + bp = z_bin_append_posn(zint_pdf_rap_side[RightRAP], 10, pattern, bp); pattern[bp++] = '1'; /* Stop */ /* So now pattern[] holds the string of '1's and '0's. - copy this to the symbol */ - for (loop = 0; loop < bp; loop++) { - if (pattern[loop] == '1') { - z_set_module(symbol, i, loop); + for (j = 0; j < bp; j++) { + if (pattern[j] == '1') { + z_set_module(symbol, i, j); } } symbol->row_height[i] = 2; /* Set up RAPs and Cluster for next row */ - LeftRAP++; - CentreRAP++; - RightRAP++; - Cluster++; - - if (LeftRAP == 53) { - LeftRAP = 1; - } - if (CentreRAP == 53) { - CentreRAP = 1; - } - if (RightRAP == 53) { - RightRAP = 1; - } - if (Cluster == 3) { - Cluster = 0; - } + LeftRAP = LeftRAP == 51 ? 0 : LeftRAP + 1; + CentreRAP = CentreRAP == 51 ? 0 : CentreRAP + 1; + RightRAP = RightRAP == 51 ? 0 : RightRAP + 1; + Cluster = Cluster == 2 ? 0 : Cluster + 1; } symbol->width = bp; @@ -284,17 +265,16 @@ static void cc_b(struct zint_symbol *symbol, const char source[], const int cc_w unsigned char *data_string = (unsigned char *) z_alloca(length + 3); short chainemc[180]; int mclength = 0; - int k, j, p, longueur, mccorrection[50] = {0}, offset; - int total; char pattern[580]; - int variant, LeftRAPStart, CentreRAPStart, RightRAPStart, StartCluster; - int LeftRAP, CentreRAP, RightRAP, Cluster, loop; - int columns; - int bp = 0; + int variant; +#ifndef NDEBUG + int ecc_cwds; +#endif const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; for (i = 0; i < length; i++) { const int binloc = i * 8; + int p; data_string[i] = 0; for (p = 0; p < 8; p++) { @@ -311,183 +291,27 @@ static void cc_b(struct zint_symbol *symbol, const char source[], const int cc_w /* Now figure out which variant of the symbol to use and load values accordingly */ - variant = 0; - - if (cc_width == 2) { - if (mclength <= 8) { - variant = 7; - } else if (mclength <= 13) { - variant = 8; - } else if (mclength <= 19) { - variant = 9; - } else if (mclength <= 24) { - variant = 10; - } else if (mclength <= 29) { - variant = 11; - } else if (mclength <= 33) { - variant = 12; - } else { - variant = 13; - } - } else if (cc_width == 3) { - if (mclength <= 6) { - variant = 14; - } else if (mclength <= 10) { - variant = 15; - } else if (mclength <= 14) { - variant = 16; - } else if (mclength <= 18) { - variant = 17; - } else if (mclength <= 24) { - variant = 18; - } else if (mclength <= 34) { - variant = 19; - } else if (mclength <= 46) { - variant = 20; - } else if (mclength <= 58) { - variant = 21; - } else if (mclength <= 70) { - variant = 22; - } else { - variant = 23; - } - } else if (cc_width == 4) { - if (mclength <= 8) { - variant = 24; - } else if (mclength <= 12) { - variant = 25; - } else if (mclength <= 18) { - variant = 26; - } else if (mclength <= 24) { - variant = 27; - } else if (mclength <= 30) { - variant = 28; - } else if (mclength <= 39) { - variant = 29; - } else if (mclength <= 54) { - variant = 30; - } else if (mclength <= 72) { - variant = 31; - } else if (mclength <= 90) { - variant = 32; - } else if (mclength <= 108) { - variant = 33; - } else { - variant = 34; - } - } + variant = zint_micropdf_variant(cc_width, mclength); + assert(variant > 0); /* Now we have the variant we can load the data - from here on the same as MicroPDF417 code */ variant--; assert(variant >= 0); - columns = zint_pdf_MicroVariants[variant]; /* columns */ - symbol->rows = zint_pdf_MicroVariants[variant + 34]; /* rows */ - k = zint_pdf_MicroVariants[variant + 68]; /* Number of EC CWs */ - longueur = (columns * symbol->rows) - k; /* Number of non-EC CWs */ - i = longueur - mclength; /* Amount of padding required */ - offset = zint_pdf_MicroVariants[variant + 102]; /* Coefficient offset */ + assert(zint_pdf_MicroVariants[0][variant] == cc_width); /* columns */ + symbol->rows = zint_pdf_MicroVariants[1][variant]; /* rows */ +#ifndef NDEBUG + ecc_cwds = zint_pdf_MicroVariants[2][variant]; /* Number of EC CWs */ +#else + (void) zint_pdf_MicroVariants[2][variant]; /* Number of EC CWs */ +#endif + /* Binary input padded to target length so no padding necessary */ + assert(cc_width * symbol->rows == mclength + ecc_cwds); - /* Binary input padded to target length so no padding should be necessary */ - while (i > 0) { - chainemc[mclength++] = 900; /* Not reached */ - i--; - } - - /* Reed-Solomon error correction */ - longueur = mclength; - for (i = 0; i < longueur; i++) { - total = (chainemc[i] + mccorrection[k - 1]) % 929; - for (j = k - 1; j >= 0; j--) { - if (j == 0) { - mccorrection[j] = (929 - (total * zint_pdf_Microcoeffs[offset + j]) % 929) % 929; - } else { - mccorrection[j] = (mccorrection[j - 1] + 929 - (total * zint_pdf_Microcoeffs[offset + j]) % 929) - % 929; - } - } - } - - for (j = 0; j < k; j++) { - if (mccorrection[j] != 0) { - mccorrection[j] = 929 - mccorrection[j]; - } - } - /* We add these codes to the string */ - for (i = k - 1; i >= 0; i--) { - chainemc[mclength++] = mccorrection[i]; - } - - /* Now get the RAP (Row Address Pattern) start values */ - LeftRAPStart = zint_pdf_RAPTable[variant]; - CentreRAPStart = zint_pdf_RAPTable[variant + 34]; - RightRAPStart = zint_pdf_RAPTable[variant + 68]; - StartCluster = zint_pdf_RAPTable[variant + 102] / 3; - - /* That's all values loaded, get on with the encoding */ - - LeftRAP = LeftRAPStart; - CentreRAP = CentreRAPStart; - RightRAP = RightRAPStart; - Cluster = StartCluster; - /* Cluster can be 0, 1 or 2 for Cluster(0), Cluster(3) and Cluster(6) */ + zint_micropdf_expand(symbol, chainemc, mclength, pattern, cc_width, variant, debug_print); for (i = 0; i < symbol->rows; i++) { - bp = 0; - offset = 929 * Cluster; - k = i * columns; - /* Copy the data into codebarre */ - bp = z_bin_append_posn(zint_pdf_rap_side[LeftRAP - 1], 10, pattern, bp); - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + chainemc[k]], 16, pattern, bp); - pattern[bp++] = '0'; - if (cc_width >= 2) { - if (cc_width == 3) { - bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP - 1], 10, pattern, bp); - } - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + chainemc[k + 1]], 16, pattern, bp); - pattern[bp++] = '0'; - if (cc_width >= 3) { - if (cc_width == 4) { - bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP - 1], 10, pattern, bp); - } - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + chainemc[k + 2]], 16, pattern, bp); - pattern[bp++] = '0'; - if (cc_width == 4) { - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + chainemc[k + 3]], 16, pattern, bp); - pattern[bp++] = '0'; - } - } - } - bp = z_bin_append_posn(zint_pdf_rap_side[RightRAP - 1], 10, pattern, bp); - pattern[bp++] = '1'; /* Stop */ - - /* So now pattern[] holds the string of '1's and '0's. - copy this to the symbol */ - for (loop = 0; loop < bp; loop++) { - if (pattern[loop] == '1') { - z_set_module(symbol, i, loop); - } - } symbol->row_height[i] = 2; - - /* Set up RAPs and Cluster for next row */ - LeftRAP++; - CentreRAP++; - RightRAP++; - Cluster++; - - if (LeftRAP == 53) { - LeftRAP = 1; - } - if (CentreRAP == 53) { - CentreRAP = 1; - } - if (RightRAP == 53) { - RightRAP = 1; - } - if (Cluster == 3) { - Cluster = 0; - } } - symbol->width = bp; if (debug_print) { printf("CC-B Columns: %d, Rows: %d, Variant: %d, CodeWords: %d\n", @@ -496,13 +320,13 @@ static void cc_b(struct zint_symbol *symbol, const char source[], const int cc_w } /* CC-C 2D component - byte compressed PDF417 */ -static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_width, const int ecc_level) { +static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_width, const int ecc) { const int length = (int) strlen(source) / 8; - int i, p; + int i; unsigned char *data_string = (unsigned char *) z_alloca(length + 4); short chainemc[1000]; - int mclength = 0, k; - int offset, longueur, loop, total, j, mccorrection[520] = {0}; + int mclength = 0, ecc_cwds; + int offset, j, mccorrection[520] = {0}; int c1, c2, c3, dummy[35]; char pattern[580]; int bp = 0; @@ -510,6 +334,7 @@ static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_w for (i = 0; i < length; i++) { const int binloc = i * 8; + int p; data_string[i] = 0; for (p = 0; p < 8; p++) { @@ -523,6 +348,7 @@ static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_w chainemc[mclength++] = 920; /* CC-C identifier */ zint_pdf_byteprocess(chainemc, &mclength, data_string, 0, length, 0); + assert(mclength > 0); /* Suppress clang-tidy-23 warning clang-analyzer-security.ArrayBound */ chainemc[0] = mclength; @@ -532,28 +358,15 @@ static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_w fputc('\n', stdout); } - k = 1; - for (i = 1; i <= (ecc_level + 1); i++) { - k *= 2; - } - /* 796 - we now take care of the Reed Solomon codes */ - switch (ecc_level) { - case 1: offset = 2; break; /* Not reached */ - case 2: offset = 6; break; /* Min ECC currently used is 2 */ - case 3: offset = 14; break; - case 4: offset = 30; break; - case 5: offset = 62; break; /* Max ECC currently used is 5 */ - case 6: offset = 126; break; /* Not reached */ - case 7: offset = 254; break; /* Not reached */ - case 8: offset = 510; break; /* Not reached */ - default: offset = 0; break; /* Not reached */ - } + assert(ecc >= 2 && ecc <= 5); + offset = (2 << ecc) - 2; + assert(offset >= 0 && offset <= 512); /* Suppress clang-tidy-23 warning clang-analyzer-security.ArrayBound */ + ecc_cwds = 1 << (ecc + 1); - longueur = mclength; - for (i = 0; i < longueur; i++) { - total = (chainemc[i] + mccorrection[k - 1]) % 929; - for (j = k - 1; j >= 0; j--) { + for (i = 0; i < mclength; i++) { + const int total = (chainemc[i] + mccorrection[ecc_cwds - 1]) % 929; + for (j = ecc_cwds - 1; j >= 0; j--) { if (j == 0) { mccorrection[j] = (929 - (total * zint_pdf_coefrs[offset + j]) % 929) % 929; } else { @@ -562,13 +375,13 @@ static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_w } } - for (j = 0; j < k; j++) { + for (j = 0; j < ecc_cwds; j++) { if (mccorrection[j] != 0) { mccorrection[j] = 929 - mccorrection[j]; } } /* We add these codes to the string */ - for (i = k - 1; i >= 0; i--) { + for (i = ecc_cwds - 1; i >= 0; i--) { chainemc[mclength++] = mccorrection[i]; } @@ -577,15 +390,15 @@ static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_w /* 818 - The CW string is finished */ symbol->rows = mclength / cc_width; c1 = (symbol->rows - 1) / 3; - c2 = ecc_level * 3 + (symbol->rows - 1) % 3; + c2 = ecc * 3 + (symbol->rows - 1) % 3; c3 = cc_width - 1; /* We now encode each row */ for (i = 0; i <= symbol->rows - 1; i++) { + const int k = (i / 3) * 30; for (j = 0; j < cc_width; j++) { dummy[j + 1] = chainemc[i * cc_width + j]; } - k = (i / 3) * 30; switch (i % 3) { case 0: dummy[0] = k + c1; @@ -607,14 +420,13 @@ static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_w bp = z_bin_append_posn(0x1FEA8, 17, pattern, bp); /* Row start */ for (j = 0; j <= cc_width + 1; j++) { - bp = z_bin_append_posn(zint_pdf_bitpattern[offset + dummy[j]], 16, pattern, bp); - pattern[bp++] = '0'; + bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + dummy[j]]) << 1, 17, pattern, bp); } bp = z_bin_append_posn(0x3FA29, 18, pattern, bp); /* Row Stop */ - for (loop = 0; loop < bp; loop++) { - if (pattern[loop] == '1') { - z_set_module(symbol, i, loop); + for (j = 0; j < bp; j++) { + if (pattern[j] == '1') { + z_set_module(symbol, i, j); } } symbol->row_height[i] = 3; @@ -623,7 +435,7 @@ static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_w if (debug_print) { printf("CC-C Columns: %d, Rows: %d, CodeWords: %d, ECC Level: %d\n", - cc_width, symbol->rows, mclength, ecc_level); + cc_width, symbol->rows, mclength, ecc); } } @@ -667,15 +479,12 @@ static int cc_b_calc_padding(const int binary_length, const int cc_width) { return target_bitsize; } -static int cc_c_calc_padding(const int binary_length, int *p_cc_width, const int linear_width, int *p_ecc_level) { - int target_bitsize = 0; - int byte_length, codewords_used, ecc_level, ecc_codewords, rows; +static int cc_c_calc_padding(const int binary_length, int *p_cc_width, const int linear_width, int *p_ecc) { + int target_bitsize; + int codewords_used, ecc, ecc_cwds, rows; int codewords_total, target_codewords, target_bytesize; - - byte_length = binary_length / 8; - if (binary_length % 8 != 0) { - byte_length++; - } + int cc_width; + const int byte_length = (binary_length + 7) >> 3; codewords_used = (byte_length / 6) * 5; codewords_used += byte_length % 6; @@ -683,62 +492,62 @@ static int cc_c_calc_padding(const int binary_length, int *p_cc_width, const int /* Recommended minimum ecc levels ISO/IEC 1543:2015 (PDF417) Annex E Table E.1, restricted by CC-C codeword max 900 (30 cols * 30 rows), GS1 General Specifications 19.1 5.9.2.3 */ if (codewords_used <= 40) { - ecc_level = 2; + ecc = 2; } else if (codewords_used <= 160) { - ecc_level = 3; + ecc = 3; } else if (codewords_used <= 320) { - ecc_level = 4; + ecc = 4; } else if (codewords_used <= 833) { /* 900 - 3 - 64 */ - ecc_level = 5; + ecc = 5; } else if (codewords_used <= 865) { /* 900 - 3 - 32 */ - ecc_level = 4; /* Not recommended but allow to meet advertised "up to 2361 digits" (allows max 2372) */ + ecc = 4; /* Not recommended but allow to meet advertised "up to 2361 digits" (allows max 2372) */ } else { return 0; } - *p_ecc_level = ecc_level; - ecc_codewords = 1 << (ecc_level + 1); + *p_ecc = ecc; + ecc_cwds = 1 << (ecc + 1); - codewords_used += ecc_codewords; + codewords_used += ecc_cwds; codewords_used += 3; + assert(codewords_used <= 900); /* Minimum possible linear width (with GS1_NO_CHECK) is 11*5 (start, FNC1, linkage, data, check) + 13 stop */ assert(linear_width >= 68); /* -52 = 7 left shift (section 12.3 f) + 10 right quiet zone - 17 start + 2x17 row indicators + 18 stop */ - *p_cc_width = linear_width == 68 ? 1 : (linear_width - 52) / 17; /* Ensure > 0 */ - if (*p_cc_width > 30) { - *p_cc_width = 30; + cc_width = linear_width == 68 ? 1 : (linear_width - 52) / 17; /* Ensure > 0 */ + if (cc_width > 30) { + cc_width = 30; } - assert(*p_cc_width > 0); - rows = (int) ceil((double) codewords_used / *p_cc_width); + assert(cc_width > 0); + rows = (int) ceil((double) codewords_used / cc_width); /* Stop the symbol from becoming too high */ - while (rows > 30 && *p_cc_width < 30) { - (*p_cc_width)++; - rows = (int) ceil((double) codewords_used / *p_cc_width); + while (rows > 30 && cc_width < 30) { + cc_width++; + rows = (int) ceil((double) codewords_used / cc_width); } + assert(rows <= 30); /* Guaranteed by codewords_used <= 900 */ - if (rows > 30) { /* Should never happen given `codewords_used` check above (865 / 30 ~ 28.83) */ - return 0; /* Not reached */ - } if (rows < 3) { rows = 3; } - codewords_total = *p_cc_width * rows; + codewords_total = cc_width * rows; + *p_cc_width = cc_width; - target_codewords = codewords_total - ecc_codewords; + target_codewords = codewords_total - ecc_cwds; target_codewords -= 3; target_bytesize = 6 * (target_codewords / 5); target_bytesize += target_codewords % 5; - target_bitsize = 8 * target_bytesize; + target_bitsize = target_bytesize << 3; return target_bitsize; } /* Handles all data encodation from section 5 of ISO/IEC 24723 */ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char source[], const int length, - char binary_string[], const int cc_mode, int *p_cc_width, int *p_ecc_level, const int linear_width) { + char binary_string[], const int cc_mode, int *p_cc_width, int *p_ecc, const int linear_width) { int encoding_method, read_posn, alpha_pad; int i, j, ai_crop, ai_crop_posn, fnc1_latch; int ai90_mode, remainder; @@ -755,7 +564,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour ai_crop_posn = -1; fnc1_latch = 0; alpha_pad = 0; - *p_ecc_level = 0; + *p_ecc = 0; target_bitsize = 0; mode = GF_NUMERIC; @@ -1033,7 +842,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour target_bitsize = cc_b_calc_padding(bp, *p_cc_width); break; case 3: - target_bitsize = cc_c_calc_padding(bp, p_cc_width, linear_width, p_ecc_level); + target_bitsize = cc_c_calc_padding(bp, p_cc_width, linear_width, p_ecc); break; } @@ -1064,7 +873,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour switch (cc_mode) { case 1: target_bitsize = cc_a_calc_padding(bp, *p_cc_width); break; case 2: target_bitsize = cc_b_calc_padding(bp, *p_cc_width); break; - case 3: target_bitsize = cc_c_calc_padding(bp, p_cc_width, linear_width, p_ecc_level); break; + case 3: target_bitsize = cc_c_calc_padding(bp, p_cc_width, linear_width, p_ecc); break; } if (target_bitsize == 0) { @@ -1089,7 +898,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour binary_string[target_bitsize] = '\0'; if (debug_print) { - printf("ECC: %d, CC width %d\n", *p_ecc_level, *p_cc_width); + printf("ECC: %d, CC width %d\n", *p_ecc, *p_cc_width); printf("Binary: %s (%d)\n", binary_string, target_bitsize); } @@ -1120,9 +929,9 @@ static int cc_linear_dummy_run(struct zint_symbol *symbol, unsigned char *source } INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], int length) { - int error_number = 0, warn_number = 0; - int cc_mode, cc_width = 0, ecc_level = 0; - int j, i, k; + int error_number = 0, warn_number; + int cc_mode, cc_width = 0, ecc = 0; + int i, j; /* Allow for 8 bits + 5-bit latch per char + 1000 bits overhead/padding */ const unsigned int bs = 13 * length + 1000 + 1; char *binary_string = (char *) z_alloca(bs); @@ -1135,6 +944,11 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], if (debug_print) printf("Reduced length: %d\n", length); + /* Hack to initialize `warn_number` to warning (if any) returned by `zint_gs1_verify()` */ + warn_number = symbol->warn_level >> 8; + symbol->warn_level &= 0xFF; + assert(warn_number < ZINT_ERROR); + /* Perform sanity checks on input options first */ primary_len = (int) strlen(symbol->primary); if (primary_len == 0) { @@ -1222,7 +1036,7 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], } if (cc_mode == 1) { - i = cc_binary_string(symbol, source, length, binary_string, cc_mode, &cc_width, &ecc_level, linear_width); + i = cc_binary_string(symbol, source, length, binary_string, cc_mode, &cc_width, &ecc, linear_width); if (i == ZINT_ERROR_TOO_LONG) { symbol->errtxt[0] = '\0'; /* Unset error text */ cc_mode = 2; @@ -1233,7 +1047,7 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], if (cc_mode == 2) { /* If the data didn't fit into CC-A it is recalculated for CC-B */ - i = cc_binary_string(symbol, source, length, binary_string, cc_mode, &cc_width, &ecc_level, linear_width); + i = cc_binary_string(symbol, source, length, binary_string, cc_mode, &cc_width, &ecc, linear_width); if (i == ZINT_ERROR_TOO_LONG) { if (symbol->symbology != BARCODE_GS1_128_CC) { return ZINT_ERROR_TOO_LONG; @@ -1247,7 +1061,7 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], if (cc_mode == 3) { /* If the data didn't fit in CC-B (and linear part is GS1-128) it is recalculated for CC-C */ - i = cc_binary_string(symbol, source, length, binary_string, cc_mode, &cc_width, &ecc_level, linear_width); + i = cc_binary_string(symbol, source, length, binary_string, cc_mode, &cc_width, &ecc, linear_width); if (i != 0) { return i; } @@ -1255,15 +1069,15 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], symbol->rows = 0; /* Composites are not stackable */ + assert(cc_mode >= 1 && cc_mode <= 3); switch (cc_mode) { - /* Note that ecc_level is only relevant to CC-C */ + /* Note that ecc is only relevant to CC-C */ case 1: cc_a(symbol, binary_string, cc_width); break; case 2: cc_b(symbol, binary_string, cc_width); break; - case 3: cc_c(symbol, binary_string, cc_width, ecc_level); break; - default: assert(0); break; /* Not reached */ + case 3: cc_c(symbol, binary_string, cc_width, ecc); break; } - if (symbol->option_1 >= 1 && symbol->option_1 <= 3 && symbol->option_1 != cc_mode) { + if (warn_number == 0 && symbol->option_1 >= 1 && symbol->option_1 <= 3 && symbol->option_1 != cc_mode) { warn_number = ZEXT z_errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 443, "Composite type changed from CC-%1$c to CC-%2$c", 'A' + (symbol->option_1 - 1), 'A' + (cc_mode - 1)); @@ -1401,8 +1215,8 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], } break; case BARCODE_DBAR_EXP_CC: - for (k = 1; !z_module_is_set(linear, 1, k - 1) && z_module_is_set(linear, 1, k); k++); - top_shift = k; + for (j = 1; !z_module_is_set(linear, 1, j - 1) && z_module_is_set(linear, 1, j); j++); + top_shift = j; break; case BARCODE_UPCA_CC: bottom_shift = 2; @@ -1417,8 +1231,8 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], top_shift = 1; break; case BARCODE_DBAR_EXPSTK_CC: - for (k = 1; !z_module_is_set(linear, 1, k - 1) && z_module_is_set(linear, 1, k); k++); - top_shift = k; + for (j = 1; !z_module_is_set(linear, 1, j - 1) && z_module_is_set(linear, 1, j); j++); + top_shift = j; break; } @@ -1460,31 +1274,40 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[], } symbol->rows += linear->rows; if (symbol->output_options & COMPLIANT_HEIGHT) { + /* Avoid overwriting any `zint_gs1_verify()` warning */ + const int no_errtxt = error_number != 0 || warn_number != 0; if (symbol->symbology == BARCODE_DBAR_STK_CC) { /* Databar Stacked needs special treatment due to asymmetric rows */ - error_number = zint_dbar_omnstk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/); + if (!no_errtxt) { + error_number = zint_dbar_stk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/, + no_errtxt); + } else { + (void) zint_dbar_stk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/, no_errtxt); + } } else if (symbol->symbology == BARCODE_DBAR_EXP_CC || symbol->symbology == BARCODE_DBAR_EXPSTK_CC) { /* If symbol->height given then min row height was returned, else default height */ - if (error_number == 0) { /* Avoid overwriting any `zint_gs1_verify()` warning */ + if (!no_errtxt) { error_number = z_set_height(symbol, symbol->height ? linear->height : 0.0f, - symbol->height ? 0.0f : linear->height, 0.0f, 0 /*no_errtxt*/); + symbol->height ? 0.0f : linear->height, 0.0f, no_errtxt); } else { (void) z_set_height(symbol, symbol->height ? linear->height : 0.0f, - symbol->height ? 0.0f : linear->height, 0.0f, 1 /*no_errtxt*/); + symbol->height ? 0.0f : linear->height, 0.0f, no_errtxt); } } else { /* If symbol->height given then min row height was returned, else default height */ - if (error_number == 0) { /* Avoid overwriting any previous warning (e.g. EAN-8 with add-on) */ + /* Avoid overwriting any previous warning (e.g. EAN-8 with add-on) */ + if (!no_errtxt) { error_number = z_set_height(symbol, symbol->height ? linear->height : 0.0f, - symbol->height ? 0.0f : linear->height, 0.0f, 0 /*no_errtxt*/); + symbol->height ? 0.0f : linear->height, 0.0f, no_errtxt); } else { (void) z_set_height(symbol, symbol->height ? linear->height : 0.0f, - symbol->height ? 0.0f : linear->height, 0.0f, 1 /*no_errtxt*/); + symbol->height ? 0.0f : linear->height, 0.0f, no_errtxt); } } } else { if (symbol->symbology == BARCODE_DBAR_STK_CC) { - (void) zint_dbar_omnstk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/); + (void) zint_dbar_stk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/, + 1 /*no_errtxt*/); } else { (void) z_set_height(symbol, symbol->height ? linear->height : 0.0f, symbol->height ? 0.0f : linear->height, 0.0f, 1 /*no_errtxt*/); diff --git a/backend/composite.h b/backend/composite.h index c0b0cc3a..897310d0 100644 --- a/backend/composite.h +++ b/backend/composite.h @@ -1,7 +1,7 @@ /* composite.c - Tables for UCC.EAN Composite Symbols */ /* libzint - the open source barcode library - Copyright (C) 2008-2024 Robin Stuart + Copyright (C) 2008-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -52,18 +52,18 @@ static const unsigned short cc_aCoeffs[30] = { }; /* rows, error codewords, k-offset of valid CC-A sizes from ISO/IEC 24723:2006 Table 9 */ -static const char cc_aVariants[51] = { - 5, 6, 7, 8, 9, 10, 12, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, - 4, 4, 5, 5, 6, 6, 7, 4, 5, 6, 7, 7, 4, 5, 6, 7, 8, - 0, 0, 4, 4, 9, 9, 15, 0, 4, 9, 15, 15, 0, 4, 9, 15, 22 +static const char cc_aVariants[3][17] = { + { 5, 6, 7, 8, 9, 10, 12, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7 }, + { 4, 4, 5, 5, 6, 6, 7, 4, 5, 6, 7, 7, 4, 5, 6, 7, 8 }, + { 0, 0, 4, 4, 9, 9, 15, 0, 4, 9, 15, 15, 0, 4, 9, 15, 22 } }; -/* following is Left RAP, Centre RAP, Right RAP and Start Cluster from ISO/IEC 24723:2006 tables 10 and 11 */ -static const char cc_aRAPTable[68] = { - 39, 1, 32, 8, 14, 43, 20, 11, 1, 5, 15, 21, 40, 43, 46, 34, 29, - 0, 0, 0, 0, 0, 0, 0, 43, 33, 37, 47, 1, 20, 23, 26, 14, 9, - 19, 33, 12, 40, 46, 23, 52, 23, 13, 17, 27, 33, 52, 3, 6, 46, 41, - 6, 0, 3, 3, 3, 0, 3, 3, 0, 3, 6, 6, 0, 0, 0, 0, 3 +/* following is Left RAP, Centre RAP, Right RAP and (Start Cluster / 3) from ISO/IEC 24723:2006 tables 10 and 11 */ +static const char cc_aRAPTable[4][17] = { + { 39, 1, 32, 8, 14, 43, 20, 11, 1, 5, 15, 21, 40, 43, 46, 34, 29 }, + { 0, 0, 0, 0, 0, 0, 0, 43, 33, 37, 47, 1, 20, 23, 26, 14, 9 }, + { 19, 33, 12, 40, 46, 23, 52, 23, 13, 17, 27, 33, 52, 3, 6, 46, 41 }, + { 2, 0, 1, 1, 1, 0, 1, 1, 0, 1, 2, 2, 0, 0, 0, 0, 1 } }; /* Row Address Patterns are as defined in pdf417.h */ diff --git a/backend/dotcode.c b/backend/dotcode.c index 4c77ce4a..55c5e432 100644 --- a/backend/dotcode.c +++ b/backend/dotcode.c @@ -1275,6 +1275,8 @@ INTERNAL int zint_dotcode(struct zint_symbol *symbol, struct zint_seg segs[], co min_dots = 9 * (data_length + 3 + (data_length / 2)) + 2; min_area = min_dots * 2; + assert(min_area >= 38); /* (9 * (1 + 3 + 0) + 2 = 19) * 2 */ + if (width == 0) { /* Automatic sizing */ /* Following Rule 3 (Section 5.2.2) and applying a recommended width to height ratio 3:2 */ @@ -1286,6 +1288,8 @@ INTERNAL int zint_dotcode(struct zint_symbol *symbol, struct zint_seg segs[], co height = (int) h; width = (int) w; + assert(height >= 5 && width >= 7); /* 38 * 0.666 = 25.308, 38 * 1.5 = 57 */ + if (((width + height) & 1) == 1) { if (width * height < min_area) { width++; @@ -1324,16 +1328,15 @@ INTERNAL int zint_dotcode(struct zint_symbol *symbol, struct zint_seg segs[], co height++; } } + assert(height >= 5 && width >= 5); if (debug_print) { printf("Width %d, Height %d\n", width, height); } if (height > 200 || width > 200) { - if (height > 200 && width > 200) { - ZEXT z_errtxtf(0, symbol, 526, "Resulting symbol size '%1$dx%2$d' (HxW) is too large (maximum 200x200)", - height, width); - } else if (width > 200) { + if (width > 200) { + assert(height <= 200); z_errtxtf(0, symbol, 528, "Resulting symbol width '%d' is too large (maximum 200)", width); } else { z_errtxtf(0, symbol, 735, "Resulting symbol height '%d' is too large (maximum 200)", height); @@ -1341,17 +1344,6 @@ INTERNAL int zint_dotcode(struct zint_symbol *symbol, struct zint_seg segs[], co return ZINT_ERROR_INVALID_OPTION; } - if (height < 5 || width < 5) { - /* Note: this branch probably no longer reached */ - assert(height >= 5 || width >= 5); /* If width < 5, min height is 19 */ - if (width < 5) { - z_errtxtf(0, symbol, 529, "Resulting symbol width '%d' is too small (minimum 5)", width); - } else { - z_errtxtf(0, symbol, 736, "Resulting symbol height '%d' is too small (minimum 5)", height); - } - return ZINT_ERROR_INVALID_OPTION; - } - n_dots = (height * width) / 2; dot_stream = (char *) z_alloca(height * width * 3); diff --git a/backend/eci.c b/backend/eci.c index 800435c4..88fe3412 100644 --- a/backend/eci.c +++ b/backend/eci.c @@ -1,7 +1,7 @@ /* eci.c - Extended Channel Interpretations */ /* libzint - the open source barcode library - Copyright (C) 2009-2025 Robin Stuart + Copyright (C) 2009-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -658,23 +658,12 @@ static int u_gb18030(const unsigned int u, unsigned char *dest) { /* Main ECI stuff */ -/* Helper to count the number of chars in a string within a range */ -static int chr_range_cnt(const unsigned char string[], const int length, const unsigned char c1, - const unsigned char c2) { +/* Helper to count the number of chars in a string less than or equal to `max` */ +static int chr_max_cnt(const unsigned char string[], const int length, const unsigned char max) { int count = 0; int i; - if (c1) { - for (i = 0; i < length; i++) { - if (string[i] >= c1 && string[i] <= c2) { - count++; - } - } - } else { - for (i = 0; i < length; i++) { - if (string[i] <= c2) { - count++; - } - } + for (i = 0; i < length; i++) { + count += string[i] <= max; } return count; } @@ -708,7 +697,7 @@ INTERNAL int zint_get_eci_length(const int eci, const unsigned char source[], in } else if (eci == 25 || eci == 33) { /* UTF-16 */ /* All ASCII chars take 2 bytes */ - length += chr_range_cnt(source, length, 0, 0x7F); + length += chr_max_cnt(source, length, 0x7F); /* Surrogate pairs are 4 UTF-8 bytes long so fit */ } else if (eci == 32) { /* GB 18030 */ @@ -717,7 +706,7 @@ INTERNAL int zint_get_eci_length(const int eci, const unsigned char source[], in } else if (eci == 34 || eci == 35) { /* UTF-32 */ /* Quadruple-up ASCII and double-up non-ASCII */ - length += chr_range_cnt(source, length, 0, 0x7F) * 2 + length; + length += chr_max_cnt(source, length, 0x7F) * 2 + length; } /* Big5, GB 2312, EUC-KR and GBK fit in UTF-8 length */ diff --git a/backend/filemem.c b/backend/filemem.c index 37fafa6f..24aefedd 100644 --- a/backend/filemem.c +++ b/backend/filemem.c @@ -60,6 +60,33 @@ # endif #endif +#ifdef ZINT_TEST +/* For testing `malloc()`/`realloc()` failures */ +static int fm_fail_id = 0; +static int fm_fail_at = 0; + +INTERNAL void zint_test_fm_set_fail(const int id, const int at) { + fm_fail_id = id; + fm_fail_at = at; +} + +#define FM_FAIL(id, ret) fm_fail_at > 0 && fm_fail_id == (id) && --fm_fail_at == 0 ? (ret) : +#define FM_FAIL_ERRNO(id, eno, ret) fm_fail_at > 0 && fm_fail_id == (id) && --fm_fail_at == 0 \ + ? (errno = (eno), (ret)) : +#define FM_FAIL_SETERR(id, eno) fm_fail_at > 0 && fm_fail_id == (id) && --fm_fail_at == 0 ? fm_seterr(fmp, eno) : + +#define fm_malloc(sz) (FM_FAIL(FM_FAIL_ID_MALLOC, NULL) malloc(sz)) +#define fm_realloc(ptr, sz) (FM_FAIL(FM_FAIL_ID_REALLOC, NULL) realloc(ptr, sz)) + +#else +#define FM_FAIL(id, ret) +#define FM_FAIL_ERRNO(id, eno, ret) +#define FM_FAIL_SETERR(id, eno) + +#define fm_malloc(sz) malloc(sz) +#define fm_realloc(ptr, sz) realloc(ptr, sz) +#endif + /* Helper to set `err` only if not already set, returning 0 always for convenience */ static int fm_seterr(struct filemem *restrict const fmp, const int err) { if (fmp->err == 0) { @@ -103,9 +130,8 @@ INTERNAL int zint_fm_open(struct filemem *restrict const fmp, struct zint_symbol #ifdef Z_NO_VSNPRINTF fmp->fp_null = NULL; #endif - if (fmp->flags & BARCODE_MEMORY_FILE) { - if (!(fmp->mem = (unsigned char *) malloc(FM_PAGE_SIZE))) { + if (!(fmp->mem = (unsigned char *) (FM_FAIL(FM_FAIL_ID_OPEN, NULL) fm_malloc(FM_PAGE_SIZE)))) { return fm_seterr(fmp, ENOMEM); } #ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */ @@ -128,7 +154,7 @@ INTERNAL int zint_fm_open(struct filemem *restrict const fmp, struct zint_symbol fmp->fp = stdout; return 1; } - if (!(fmp->fp = zint_out_fopen(symbol->outfile, mode))) { + if (!(fmp->fp = (FM_FAIL_ERRNO(FM_FAIL_ID_OPEN, EACCES, NULL) zint_out_fopen(symbol->outfile, mode)))) { return fm_seterr(fmp, errno); } return 1; @@ -159,7 +185,7 @@ static int fm_mem_expand(struct filemem *restrict const fmp, const size_t size) return fm_seterr(fmp, EOVERFLOW); } /* Protect against very large files & (Linux) OOM killer - cf `raster_malloc()` in "raster.c" */ - if (new_size > 0x40000000 /*1GB*/ || !(new_mem = (unsigned char *) realloc(fmp->mem, new_size))) { + if (new_size > 0x40000000 /*1GB*/ || !(new_mem = (unsigned char *) fm_realloc(fmp->mem, new_size))) { fm_clear_mem(fmp); return fm_seterr(fmp, new_size > 0x40000000 ? EINVAL : ENOMEM); } @@ -178,12 +204,13 @@ INTERNAL int zint_fm_write(const void *restrict ptr, const size_t size, const si if (fmp->err) { return 0; } + if (size == 0 || nitems == 0) { return 1; } if (fmp->flags & BARCODE_MEMORY_FILE) { const size_t tot_size = size * nitems; - if (tot_size / size != nitems) { + if ((FM_FAIL(FM_FAIL_ID_WRITE, 0) tot_size / size) != nitems) { return fm_seterr(fmp, EOVERFLOW); } if (!fm_mem_expand(fmp, tot_size)) { @@ -193,7 +220,7 @@ INTERNAL int zint_fm_write(const void *restrict ptr, const size_t size, const si fm_setpos(fmp, fmp->mempos + tot_size); return 1; } - if (fwrite(ptr, size, nitems, fmp->fp) != nitems) { + if ((FM_FAIL_ERRNO(FM_FAIL_ID_WRITE, EIO, 0) fwrite(ptr, size, nitems, fmp->fp)) != nitems) { return fm_seterr(fmp, errno); } return 1; @@ -206,14 +233,14 @@ INTERNAL int zint_fm_putc(const int ch, struct filemem *restrict const fmp) { return 0; } if (fmp->flags & BARCODE_MEMORY_FILE) { - if (!fm_mem_expand(fmp, 1)) { + if (!(FM_FAIL_SETERR(FM_FAIL_ID_PUTC, EIO) fm_mem_expand(fmp, 1))) { return 0; } fmp->mem[fmp->mempos] = (unsigned char) ch; fm_setpos(fmp, fmp->mempos + 1); return 1; } - if (fputc(ch, fmp->fp) == EOF) { + if ((FM_FAIL_ERRNO(FM_FAIL_ID_PUTC, EIO, EOF) fputc(ch, fmp->fp)) == EOF) { return fm_seterr(fmp, errno); } return 1; @@ -227,14 +254,14 @@ INTERNAL int zint_fm_puts(const char *str, struct filemem *restrict const fmp) { } if (fmp->flags & BARCODE_MEMORY_FILE) { const size_t len = strlen(str); - if (!fm_mem_expand(fmp, len)) { + if (!(FM_FAIL_SETERR(FM_FAIL_ID_PUTS, EIO) fm_mem_expand(fmp, len))) { return 0; } memcpy(fmp->mem + fmp->mempos, str, len); fm_setpos(fmp, fmp->mempos + len); return 1; } - if (fputs(str, fmp->fp) == EOF) { + if ((FM_FAIL_ERRNO(FM_FAIL_ID_PUTS, EIO, EOF) fputs(str, fmp->fp)) == EOF) { return fm_seterr(fmp, errno); } return 1; @@ -301,12 +328,12 @@ INTERNAL int zint_fm_printf(struct filemem *restrict const fmp, const char *fmt, } if (fmp->flags & BARCODE_MEMORY_FILE) { va_start(ap, fmt); - ret = fm_vprintf(fmp, fmt, ap); + ret = (FM_FAIL_SETERR(FM_FAIL_ID_PRINTF, EIO) fm_vprintf(fmp, fmt, ap)); va_end(ap); return ret; } va_start(ap, fmt); - ret = vfprintf(fmp->fp, fmt, ap) >= 0; + ret = (FM_FAIL_ERRNO(FM_FAIL_ID_PRINTF, EIO, -1) vfprintf(fmp->fp, fmt, ap)) >= 0; va_end(ap); return ret ? 1 : fm_seterr(fmp, errno); } @@ -323,8 +350,8 @@ INTERNAL int zint_fm_putsf(const char *prefix, const int dp, const float arg, st return 0; } if (prefix && *prefix) { - if (!zint_fm_puts(prefix, fmp)) { - return 0; + if (!(FM_FAIL_ERRNO(FM_FAIL_ID_PUTSF, EIO, 0) zint_fm_puts(prefix, fmp))) { + return fm_seterr(fmp, errno); } } @@ -345,7 +372,10 @@ INTERNAL int zint_fm_putsf(const char *prefix, const int dp, const float arg, st } } - return zint_fm_puts(buf, fmp); + if (!(FM_FAIL_ERRNO(FM_FAIL_ID_PUTSF, EIO, 0) zint_fm_puts(buf, fmp))) { + return fm_seterr(fmp, errno); + } + return 1; } /* `fclose()` if file, set `symbol->memfile` & `symbol->memfile_size` if memory, returning 1 on success, 0 on @@ -358,7 +388,7 @@ INTERNAL int zint_fm_close(struct filemem *restrict const fmp, struct zint_symbo return fm_seterr(fmp, EINVAL); } symbol->memfile_size = (int) fmp->mempos; - if ((size_t) symbol->memfile_size != fmp->mempos) { + if ((size_t) (FM_FAIL(FM_FAIL_ID_CLOSE, 0) symbol->memfile_size) != fmp->mempos) { fm_clear_mem(fmp); symbol->memfile_size = 0; return fm_seterr(fmp, EINVAL); @@ -375,12 +405,12 @@ INTERNAL int zint_fm_close(struct filemem *restrict const fmp, struct zint_symbo return fm_seterr(fmp, EINVAL); } if (fmp->flags & BARCODE_STDOUT) { - if (fflush(fmp->fp) != 0) { + if ((FM_FAIL_ERRNO(FM_FAIL_ID_CLOSE, EIO, EOF) fflush(fmp->fp)) != 0) { fmp->fp = NULL; return fm_seterr(fmp, errno); } } else { - if (fclose(fmp->fp) != 0) { + if ((FM_FAIL_ERRNO(FM_FAIL_ID_CLOSE, EIO, EOF) fclose(fmp->fp)) != 0) { fmp->fp = NULL; return fm_seterr(fmp, errno); } @@ -398,7 +428,8 @@ INTERNAL int zint_fm_seek(struct filemem *restrict const fmp, const long offset, if (fmp->flags & BARCODE_MEMORY_FILE) { const size_t start = whence == SEEK_SET ? 0 : whence == SEEK_CUR ? fmp->mempos : fmp->memend; const size_t new_pos = start + offset; - if ((offset > 0 && new_pos <= start) || (offset < 0 && new_pos >= start)) { /* Check for over/underflow */ + /* Check for over/underflow */ + if ((FM_FAIL(FM_FAIL_ID_SEEK, 1) (offset > 0 && new_pos <= start) || (offset < 0 && new_pos >= start))) { return fm_seterr(fmp, EINVAL); } if (!fm_mem_expand(fmp, new_pos)) { @@ -407,7 +438,7 @@ INTERNAL int zint_fm_seek(struct filemem *restrict const fmp, const long offset, fm_setpos(fmp, new_pos); return 1; } - if (fseek(fmp->fp, offset, whence) != 0) { + if ((FM_FAIL_ERRNO(FM_FAIL_ID_SEEK, EOVERFLOW, EOF) fseek(fmp->fp, offset, whence)) != 0) { return fm_seterr(fmp, errno); } return 1; @@ -421,13 +452,13 @@ INTERNAL long zint_fm_tell(struct filemem *restrict const fmp) { return -1; } if (fmp->flags & BARCODE_MEMORY_FILE) { - if (!fmp->mem) { + if (!(FM_FAIL(FM_FAIL_ID_TELL, NULL) fmp->mem)) { (void) fm_seterr(fmp, ENOMEM); return -1; } return (long) fmp->mempos; } - ret = ftell(fmp->fp); + ret = (FM_FAIL_ERRNO(FM_FAIL_ID_TELL, EOVERFLOW, -1) ftell(fmp->fp)); /* On many Linux distros `ftell()` returns LONG_MAX not -1 on error */ if (ret < 0 || ret == LONG_MAX) { (void) fm_seterr(fmp, errno); @@ -453,12 +484,12 @@ INTERNAL int zint_fm_flush(struct filemem *restrict const fmp) { return 0; } if (fmp->flags & BARCODE_MEMORY_FILE) { - if (!fmp->mem) { + if (!(FM_FAIL(FM_FAIL_ID_FLUSH, 0) fmp->mem)) { return fm_seterr(fmp, EINVAL); } return 1; } - if (fflush(fmp->fp) == EOF) { + if ((FM_FAIL_ERRNO(FM_FAIL_ID_FLUSH, EIO, EOF) fflush(fmp->fp)) == EOF) { return fm_seterr(fmp, errno); } return 1; diff --git a/backend/filemem.h b/backend/filemem.h index f096884b..3aada12f 100644 --- a/backend/filemem.h +++ b/backend/filemem.h @@ -90,6 +90,25 @@ INTERNAL int zint_fm_error(struct filemem *restrict const fmp); NOTE: don't use, included only for libpng compatibility */ INTERNAL int zint_fm_flush(struct filemem *restrict const fmp); +#ifdef ZINT_TEST +/* For testing `malloc()`/`realloc()` failures */ +#define FM_FAIL_ID_OPEN 1 +#define FM_FAIL_ID_WRITE 2 +#define FM_FAIL_ID_PUTC 3 +#define FM_FAIL_ID_PUTS 4 +#define FM_FAIL_ID_PRINTF 5 +#define FM_FAIL_ID_PUTSF 6 +#define FM_FAIL_ID_CLOSE 7 +#define FM_FAIL_ID_SEEK 8 +#define FM_FAIL_ID_TELL 9 +#define FM_FAIL_ID_FLUSH 10 +#define FM_FAIL_ID_MALLOC 11 +#define FM_FAIL_ID_REALLOC 12 + +INTERNAL void zint_test_fm_set_fail(const int id, const int at); +INTERNAL void zint_test_fm_set_alloc_fail(const int id, const int at); +#endif + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/backend/gif.c b/backend/gif.c index 673c05ce..4f89285c 100644 --- a/backend/gif.c +++ b/backend/gif.c @@ -30,6 +30,7 @@ */ /* SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #include "common.h" @@ -163,14 +164,14 @@ static int gif_NextCode(struct gif_state *pState, unsigned char *pPixelValueCur, return 1; } -static int gif_lzw(struct gif_state *pState, unsigned char paletteBitSize) { +static void gif_lzw(struct gif_state *pState, unsigned char paletteBitSize) { unsigned char PixelValueCur; unsigned char CodeBits; unsigned short Pos; + assert(pState->pIn != pState->pInEnd); + /* > Get first data byte */ - if (pState->pIn == pState->pInEnd) - return 0; PixelValueCur = pState->map[*pState->pIn++]; /* Number of bits per data item (=pixel) * We need at least a value of 2, otherwise the cc and eoi code consumes @@ -217,7 +218,7 @@ static int gif_lzw(struct gif_state *pState, unsigned char paletteBitSize) { = (unsigned char) (pState->OutPosCur - pState->OutByteCountPos - 1); } pState->OutPosCur++; - return 1; + return; } /* Check for currently last code */ if (pState->FreeCode == (1U << CodeBits)) @@ -444,11 +445,7 @@ INTERNAL int zint_gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixe zint_fm_write(outbuf, 1, 10, State.fmp); /* Call lzw encoding */ - if (!gif_lzw(&State, paletteBitSize)) { - free(State.pOut); - (void) zint_fm_close(State.fmp, symbol); - return z_errtxt(ZINT_ERROR_MEMORY, symbol, 613, "Insufficient memory for GIF LZW buffer"); - } + gif_lzw(&State, paletteBitSize); zint_fm_write(State.pOut, 1, State.OutPosCur, State.fmp); free(State.pOut); diff --git a/backend/gridmtx.c b/backend/gridmtx.c index 66f1a9ec..a7f64270 100644 --- a/backend/gridmtx.c +++ b/backend/gridmtx.c @@ -781,14 +781,14 @@ static int gm_encode_segs(const unsigned int ddata[], const struct zint_seg segs 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 data_cws, 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)]; + data_cws = gm_data_cws[layers - 1][ecc_level - 1]; for (i = 0; i < 1320; i++) { data[i] = 0; @@ -805,7 +805,7 @@ static void gm_add_ecc(const char binary[], const int data_posn, const int layer /* Add padding codewords */ data[data_posn] = 0x00; - for (i = (data_posn + 1); i < data_cw; i++) { + for (i = (data_posn + 1); i < data_cws; i++) { if (i & 1) { data[i] = 0x7E; } else { @@ -814,13 +814,13 @@ static void gm_add_ecc(const char binary[], const int data_posn, const int layer } /* Get block sizes */ - n1 = gm_n1[(layers - 1)]; - b1 = gm_b1[(layers - 1)]; + n1 = gm_n1[layers - 1]; + b1 = gm_b1[layers - 1]; n2 = n1 - 1; - b2 = gm_b2[(layers - 1)]; - e1 = gm_ebeb[((layers - 1) * 20) + ((ecc_level - 1) * 4)]; - b3 = gm_ebeb[((layers - 1) * 20) + ((ecc_level - 1) * 4) + 1]; - e2 = gm_ebeb[((layers - 1) * 20) + ((ecc_level - 1) * 4) + 2]; + b2 = gm_b2[layers - 1]; + e1 = gm_e1b3e2[layers - 1][ecc_level - 1][0]; + b3 = gm_e1b3e2[layers - 1][ecc_level - 1][1]; + e2 = gm_e1b3e2[layers - 1][ecc_level - 1][2]; zint_rs_init_gf(&rs, 0x89); @@ -921,7 +921,7 @@ static void gm_place_data_in_grid(const unsigned char word[], char grid[], const for (y = 0; y < modules; y++) { for (x = 0; x < modules; x++) { - macromodule = gm_macro_matrix[((y + offset) * 27) + (x + offset)]; + macromodule = gm_macro_matrix[y + offset][x + offset]; gm_place_macromodule(grid, x, y, word[macromodule * 2], word[(macromodule * 2) + 1], size); } } @@ -979,13 +979,13 @@ static void gm_place_layer_id(char *grid, const int size, const int layers, cons INTERNAL int zint_gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) { int warn_number = 0; int size, modules, error_number; - int auto_layers, min_layers, layers, auto_ecc_level, min_ecc_level, ecc_level; + int auto_layers, min_layers, layers, rec_ecc_level, min_rec_ecc_level, ecc_level; int x, y, i; int full_multibyte; char binary[9300]; - int data_cw, input_latch = 0; + int data_cws; unsigned char word[1460] = {0}; - int data_max, reader = 0; + int reader = 0; const struct zint_structapp *p_structapp = NULL; int size_squared; int bin_len; @@ -1079,95 +1079,77 @@ INTERNAL int zint_gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], } /* Determine the size of the symbol */ - data_cw = bin_len / 7; /* Binary length always a multiple of 7 */ + data_cws = bin_len / 7; /* Binary length always a multiple of 7 */ auto_layers = 13; for (i = 12; i > 0; i--) { - if (gm_recommend_cw[(i - 1)] >= data_cw) { + if (gm_recommend_cws[i - 1] >= data_cws) { auto_layers = i; } } min_layers = 13; for (i = 12; i > 0; i--) { - if (gm_max_cw[(i - 1)] >= data_cw) { + if (gm_max_cws[i - 1] >= data_cws) { min_layers = i; } } layers = auto_layers; if (symbol->option_2 >= 1 && symbol->option_2 <= 13) { - input_latch = 1; if (symbol->option_2 >= min_layers) { layers = symbol->option_2; } else { return ZEXT z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 534, "Input too long for Version %1$d, requires %2$d codewords (maximum %3$d)", - symbol->option_2, data_cw, gm_max_cw[symbol->option_2 - 1]); + symbol->option_2, data_cws, gm_max_cws[symbol->option_2 - 1]); } } - auto_ecc_level = 3; + /* Table 11 - Recommended error correction levels - Recommended ECL */ + rec_ecc_level = 3; if (layers == 1) { - auto_ecc_level = 5; + rec_ecc_level = 5; } else if (layers == 2 || layers == 3) { - auto_ecc_level = 4; + rec_ecc_level = 4; } - ecc_level = auto_ecc_level; + ecc_level = rec_ecc_level; - min_ecc_level = 1; + /* Table 11 - Recommended error correction levels - Minimum Recommended ECL */ + min_rec_ecc_level = 1; if (layers == 1) { - min_ecc_level = 4; + min_rec_ecc_level = 4; } else if (layers == 2) { - min_ecc_level = 2; + min_rec_ecc_level = 2; } if (symbol->option_1 >= 1 && symbol->option_1 <= 5) { - if (symbol->option_1 >= min_ecc_level) { + /* Silently ignoring user-specified if less than minimum recommended */ + if (symbol->option_1 >= min_rec_ecc_level) { ecc_level = symbol->option_1; } else { - ecc_level = min_ecc_level; + ecc_level = min_rec_ecc_level; } } - if (data_cw > gm_data_codewords[5 * (layers - 1) + (ecc_level - 1)]) { - /* 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); - } - while (data_cw > gm_data_codewords[5 * (layers - 1) + (ecc_level - 1)] && layers < 13) { - layers++; - } - /* ECC min level 1 for layers > 2 */ - while (data_cw > gm_data_codewords[5 * (layers - 1) + (ecc_level - 1)] && ecc_level > 1) { + if (data_cws > gm_data_cws[layers - 1][ecc_level - 1]) { + /* Reduce ECC level */ + const int min_ecc_level = layers > 1 ? 1 : 2; /* ECL 1 in version 1 symbols is invalid */ + do { ecc_level--; - } + } while (data_cws > gm_data_cws[layers - 1][ecc_level - 1] && ecc_level > min_ecc_level); + assert(data_cws <= gm_data_cws[layers - 1][ecc_level - 1]); } - data_max = 1313; - switch (ecc_level) { - case 2: data_max = 1167; break; - case 3: data_max = 1021; break; - case 4: data_max = 875; break; - case 5: data_max = 729; break; - } - - if (data_cw > data_max) { - return ZEXT z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 532, - "Input too long for ECC level %1$d, requires %2$d codewords (maximum %3$d)", - ecc_level, data_cw, data_max); - } if (debug_print) { - printf("Layers: %d, ECC level: %d, Data Codewords: %d\n", layers, ecc_level, data_cw); + printf("Layers: %d, ECC level: %d, Data Codewords: %d\n", layers, ecc_level, data_cws); } /* Feedback options */ symbol->option_1 = ecc_level; symbol->option_2 = layers; - gm_add_ecc(binary, data_cw, layers, ecc_level, word); + gm_add_ecc(binary, data_cws, layers, ecc_level, word); #ifdef ZINT_TEST - if (symbol->debug & ZINT_DEBUG_TEST) z_debug_test_codeword_dump(symbol, word, data_cw); + if (symbol->debug & ZINT_DEBUG_TEST) z_debug_test_codeword_dump(symbol, word, data_cws); #endif size = 6 + (layers * 12); modules = 1 + (layers * 2); diff --git a/backend/gridmtx.h b/backend/gridmtx.h index c5d70bee..e1012dbf 100644 --- a/backend/gridmtx.h +++ b/backend/gridmtx.h @@ -1,7 +1,7 @@ /* gridmtx.h - definitions for Grid Matrix */ /* libzint - the open source barcode library - Copyright (C) 2009-2022 Robin Stuart + Copyright (C) 2009-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -33,148 +33,99 @@ #ifndef Z_GRIDMTX_H #define Z_GRIDMTX_H +/* From Table 7 - Encoding of control characters */ static const char gm_shift_set[] = { - /* From Table 7 - Encoding of control characters */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* NULL -> SI */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* DLE -> US */ - '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', - ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~' + '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', + ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~' }; -static const unsigned short gm_recommend_cw[] = { - 9, 30, 59, 114, 170, 237, 315, 405, 506, 618, 741, 875, 1021 +static const short gm_recommend_cws[13] = { + 9, 30, 59, 114, 170, 237, 315, 405, 506, 618, 741, 875, 1021 }; -static const unsigned short gm_max_cw[] = { +static const short gm_max_cws[13] = { 11, 40, 79, 146, 218, 305, 405, 521, 650, 794, 953, 1125, 1313 }; -static const unsigned short gm_data_codewords[] = { - 0, 15, 13, 11, 9, - 45, 40, 35, 30, 25, - 89, 79, 69, 59, 49, - 146, 130, 114, 98, 81, - 218, 194, 170, 146, 121, - 305, 271, 237, 203, 169, - 405, 360, 315, 270, 225, - 521, 463, 405, 347, 289, - 650, 578, 506, 434, 361, - 794, 706, 618, 530, 441, - 953, 847, 741, 635, 529, - 1125, 1000, 875, 750, 625, - 1313, 1167, 1021, 875, 729 +static const short gm_data_cws[13][5] = { + { 0, 15, 13, 11, 9 }, /* 1 */ + { 45, 40, 35, 30, 25 }, /* 2 */ + { 89, 79, 69, 59, 49 }, /* 3 */ + { 146, 130, 114, 98, 81 }, /* 4 */ + { 218, 194, 170, 146, 121 }, /* 5 */ + { 305, 271, 237, 203, 169 }, /* 6 */ + { 405, 360, 315, 270, 225 }, /* 7 */ + { 521, 463, 405, 347, 289 }, /* 8 */ + { 650, 578, 506, 434, 361 }, /* 9 */ + { 794, 706, 618, 530, 441 }, /* 10 */ + { 953, 847, 741, 635, 529 }, /* 11 */ + { 1125, 1000, 875, 750, 625 }, /* 12 */ + { 1313, 1167, 1021, 875, 729 }, /* 13 */ }; -static const char gm_n1[] = { +/* Table A.1 N1 */ +static const char gm_n1[13] = { 18, 50, 98, 81, 121, 113, 113, 116, 121, 126, 118, 125, 122 }; -static const char gm_b1[] = { +/* Table A.1 B1 */ +static const char gm_b1[13] = { 1, 1, 1, 2, 2, 2, 2, 3, 2, 7, 5, 10, 6 }; -static const char gm_b2[] = { +/* Table A.1 B2 */ +static const char gm_b2[13] = { 0, 0, 0, 0, 0, 1, 2, 2, 4, 0, 4, 0, 6 }; -/* Values from table A.1 */ -static const char gm_ebeb[] = { - /* E1 B3 E2 B4 */ - 0, 0, 0, 0, /* version 1 */ - 3, 1, 0, 0, - 5, 1, 0, 0, - 7, 1, 0, 0, - 9, 1, 0, 0, - 5, 1, 0, 0, /* version 2 */ - 10, 1, 0, 0, - 15, 1, 0, 0, - 20, 1, 0, 0, - 25, 1, 0, 0, - 9, 1, 0, 0, /* version 3 */ - 19, 1, 0, 0, - 29, 1, 0, 0, - 39, 1, 0, 0, - 49, 1, 0, 0, - 8, 2, 0, 0, /* version 4 */ - 16, 2, 0, 0, - 24, 2, 0, 0, - 32, 2, 0, 0, - 41, 1, 40, 1, - 12, 2, 0, 0, /* version 5 */ - 24, 2, 0, 0, - 36, 2, 0, 0, - 48, 2, 0, 0, - 61, 1, 60, 1, - 11, 3, 0, 0, /* version 6 */ - 23, 1, 22, 2, - 34, 2, 33, 1, - 45, 3, 0, 0, - 57, 1, 56, 2, - 12, 1, 11, 3, /* version 7 */ - 23, 2, 22, 2, - 34, 3, 33, 1, - 45, 4, 0, 0, - 57, 1, 56, 3, - 12, 2, 11, 3, /* version 8 */ - 23, 5, 0, 0, - 35, 3, 34, 2, - 47, 1, 46, 4, - 58, 4, 57, 1, - 12, 6, 0, 0, /* version 9 */ - 24, 6, 0, 0, - 36, 6, 0, 0, - 48, 6, 0, 0, - 61, 1, 60, 5, - 13, 4, 12, 3, /* version 10 */ - 26, 1, 25, 6, - 38, 5, 37, 2, - 51, 2, 50, 5, - 63, 7, 0, 0, - 12, 6, 11, 3, /* version 11 */ - 24, 4, 23, 5, - 36, 2, 35, 7, - 47, 9, 0, 0, - 59, 7, 58, 2, - 13, 5, 12, 5, /* version 12 */ - 25, 10, 0, 0, - 38, 5, 37, 5, - 50, 10, 0, 0, - 63, 5, 62, 5, - 13, 1, 12, 11, /* version 13 */ - 25, 3, 24, 9, - 37, 5, 36, 7, - 49, 7, 48, 5, - 61, 9, 60, 3 +/* Table A.1 E1, B3, E2 */ +static const char gm_e1b3e2[13][5][3] = { + /* E1 B3 E2 */ + { { 0, 0, 0 }, { 3, 1, 0 }, { 5, 1, 0 }, { 7, 1, 0 }, { 9, 1, 0 } }, /* 1 */ + { { 5, 1, 0 }, { 10, 1, 0 }, { 15, 1, 0 }, { 20, 1, 0 }, { 25, 1, 0 } }, /* 2 */ + { { 9, 1, 0 }, { 19, 1, 0 }, { 29, 1, 0 }, { 39, 1, 0 }, { 49, 1, 0 } }, /* 3 */ + { { 8, 2, 0 }, { 16, 2, 0 }, { 24, 2, 0 }, { 32, 2, 0 }, { 41, 1, 40 } }, /* 4 */ + { { 12, 2, 0 }, { 24, 2, 0 }, { 36, 2, 0 }, { 48, 2, 0 }, { 61, 1, 60 } }, /* 5 */ + { { 11, 3, 0 }, { 23, 1, 22 }, { 34, 2, 33 }, { 45, 3, 0 }, { 57, 1, 56 } }, /* 6 */ + { { 12, 1, 11 }, { 23, 2, 22 }, { 34, 3, 33 }, { 45, 4, 0 }, { 57, 1, 56 } }, /* 7 */ + { { 12, 2, 11 }, { 23, 5, 0 }, { 35, 3, 34 }, { 47, 1, 46 }, { 58, 4, 57 } }, /* 8 */ + { { 12, 6, 0 }, { 24, 6, 0 }, { 36, 6, 0 }, { 48, 6, 0 }, { 61, 1, 60 } }, /* 9 */ + { { 13, 4, 12 }, { 26, 1, 25 }, { 38, 5, 37 }, { 51, 2, 50 }, { 63, 7, 0 } }, /* 10 */ + { { 12, 6, 11 }, { 24, 4, 23 }, { 36, 2, 35 }, { 47, 9, 0 }, { 59, 7, 58 } }, /* 11 */ + { { 13, 5, 12 }, { 25, 10, 0 }, { 38, 5, 37 }, { 50, 10, 0 }, { 63, 5, 62 } }, /* 12 */ + { { 13, 1, 12 }, { 25, 3, 24 }, { 37, 5, 36 }, { 49, 7, 48 }, { 61, 9, 60 } } /* 13 */ }; -static const unsigned short gm_macro_matrix[] = { - 728, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, - 727, 624, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 651, - 726, 623, 528, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 553, 652, - 725, 622, 527, 440, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 463, 554, 653, - 724, 621, 526, 439, 360, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 381, 464, 555, 654, - 723, 620, 525, 438, 359, 288, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 307, 382, 465, 556, 655, - 722, 619, 524, 437, 358, 287, 224, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 241, 308, 383, 466, 557, 656, - 721, 618, 523, 436, 357, 286, 223, 168, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 183, 242, 309, 384, 467, 558, 657, - 720, 617, 522, 435, 356, 285, 222, 167, 120, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 133, 184, 243, 310, 385, 468, 559, 658, - 719, 616, 521, 434, 355, 284, 221, 166, 119, 80, 49, 50, 51, 52, 53, 54, 55, 56, 91, 134, 185, 244, 311, 386, 469, 560, 659, - 718, 615, 520, 433, 354, 283, 220, 165, 118, 79, 48, 25, 26, 27, 28, 29, 30, 57, 92, 135, 186, 245, 312, 387, 470, 561, 660, - 717, 614, 519, 432, 353, 282, 219, 164, 117, 78, 47, 24, 9, 10, 11, 12, 31, 58, 93, 136, 187, 246, 313, 388, 471, 562, 661, - 716, 613, 518, 431, 352, 281, 218, 163, 116, 77, 46, 23, 8, 1, 2, 13, 32, 59, 94, 137, 188, 247, 314, 389, 472, 563, 662, - 715, 612, 517, 430, 351, 280, 217, 162, 115, 76, 45, 22, 7, 0, 3, 14, 33, 60, 95, 138, 189, 248, 315, 390, 473, 564, 663, - 714, 611, 516, 429, 350, 279, 216, 161, 114, 75, 44, 21, 6, 5, 4, 15, 34, 61, 96, 139, 190, 249, 316, 391, 474, 565, 664, - 713, 610, 515, 428, 349, 278, 215, 160, 113, 74, 43, 20, 19, 18, 17, 16, 35, 62, 97, 140, 191, 250, 317, 392, 475, 566, 665, - 712, 609, 514, 427, 348, 277, 214, 159, 112, 73, 42, 41, 40, 39, 38, 37, 36, 63, 98, 141, 192, 251, 318, 393, 476, 567, 666, - 711, 608, 513, 426, 347, 276, 213, 158, 111, 72, 71, 70, 69, 68, 67, 66, 65, 64, 99, 142, 193, 252, 319, 394, 477, 568, 667, - 710, 607, 512, 425, 346, 275, 212, 157, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 143, 194, 253, 320, 395, 478, 569, 668, - 709, 606, 511, 424, 345, 274, 211, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 195, 254, 321, 396, 479, 570, 669, - 708, 605, 510, 423, 344, 273, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 255, 322, 397, 480, 571, 670, - 707, 604, 509, 422, 343, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 323, 398, 481, 572, 671, - 706, 603, 508, 421, 342, 341, 340, 339, 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, 324, 399, 482, 573, 672, - 705, 602, 507, 420, 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 483, 574, 673, - 704, 601, 506, 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 575, 674, - 703, 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, 578, 577, 576, 675, - 702, 701, 700, 699, 698, 697, 696, 695, 694, 693, 692, 691, 690, 689, 688, 687, 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, 676, +static const short gm_macro_matrix[27][27] = { + { 728, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650 }, + { 727, 624, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 651 }, + { 726, 623, 528, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 553, 652 }, + { 725, 622, 527, 440, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 463, 554, 653 }, + { 724, 621, 526, 439, 360, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 381, 464, 555, 654 }, + { 723, 620, 525, 438, 359, 288, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 307, 382, 465, 556, 655 }, + { 722, 619, 524, 437, 358, 287, 224, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 241, 308, 383, 466, 557, 656 }, + { 721, 618, 523, 436, 357, 286, 223, 168, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 183, 242, 309, 384, 467, 558, 657 }, + { 720, 617, 522, 435, 356, 285, 222, 167, 120, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 133, 184, 243, 310, 385, 468, 559, 658 }, + { 719, 616, 521, 434, 355, 284, 221, 166, 119, 80, 49, 50, 51, 52, 53, 54, 55, 56, 91, 134, 185, 244, 311, 386, 469, 560, 659 }, + { 718, 615, 520, 433, 354, 283, 220, 165, 118, 79, 48, 25, 26, 27, 28, 29, 30, 57, 92, 135, 186, 245, 312, 387, 470, 561, 660 }, + { 717, 614, 519, 432, 353, 282, 219, 164, 117, 78, 47, 24, 9, 10, 11, 12, 31, 58, 93, 136, 187, 246, 313, 388, 471, 562, 661 }, + { 716, 613, 518, 431, 352, 281, 218, 163, 116, 77, 46, 23, 8, 1, 2, 13, 32, 59, 94, 137, 188, 247, 314, 389, 472, 563, 662 }, + { 715, 612, 517, 430, 351, 280, 217, 162, 115, 76, 45, 22, 7, 0, 3, 14, 33, 60, 95, 138, 189, 248, 315, 390, 473, 564, 663 }, + { 714, 611, 516, 429, 350, 279, 216, 161, 114, 75, 44, 21, 6, 5, 4, 15, 34, 61, 96, 139, 190, 249, 316, 391, 474, 565, 664 }, + { 713, 610, 515, 428, 349, 278, 215, 160, 113, 74, 43, 20, 19, 18, 17, 16, 35, 62, 97, 140, 191, 250, 317, 392, 475, 566, 665 }, + { 712, 609, 514, 427, 348, 277, 214, 159, 112, 73, 42, 41, 40, 39, 38, 37, 36, 63, 98, 141, 192, 251, 318, 393, 476, 567, 666 }, + { 711, 608, 513, 426, 347, 276, 213, 158, 111, 72, 71, 70, 69, 68, 67, 66, 65, 64, 99, 142, 193, 252, 319, 394, 477, 568, 667 }, + { 710, 607, 512, 425, 346, 275, 212, 157, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 143, 194, 253, 320, 395, 478, 569, 668 }, + { 709, 606, 511, 424, 345, 274, 211, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 195, 254, 321, 396, 479, 570, 669 }, + { 708, 605, 510, 423, 344, 273, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 255, 322, 397, 480, 571, 670 }, + { 707, 604, 509, 422, 343, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 323, 398, 481, 572, 671 }, + { 706, 603, 508, 421, 342, 341, 340, 339, 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, 324, 399, 482, 573, 672 }, + { 705, 602, 507, 420, 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 483, 574, 673 }, + { 704, 601, 506, 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 575, 674 }, + { 703, 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, 578, 577, 576, 675 }, + { 702, 701, 700, 699, 698, 697, 696, 695, 694, 693, 692, 691, 690, 689, 688, 687, 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, 676 } }; /* vim: set ts=4 sw=4 et : */ diff --git a/backend/gs1.c b/backend/gs1.c index d3b754bb..1c0f27d7 100644 --- a/backend/gs1.c +++ b/backend/gs1.c @@ -78,9 +78,8 @@ static int gs1_numeric(const unsigned char *data, int data_len, int offset, int data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (data_len) { const unsigned char *d = data + offset; @@ -128,9 +127,8 @@ static int gs1_cset82(const unsigned char *data, int data_len, int offset, int m data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (data_len) { const unsigned char *d = data + offset; @@ -155,9 +153,8 @@ static int gs1_cset39(const unsigned char *data, int data_len, int offset, int m data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (data_len) { const unsigned char *d = data + offset; @@ -182,9 +179,8 @@ static int gs1_cset64(const unsigned char *data, int data_len, int offset, int m data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (data_len) { const unsigned char *d = data + offset; @@ -215,9 +211,8 @@ static int gs1_csum(const unsigned char *data, int data_len, int offset, int min data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { const unsigned char *d = data + offset; @@ -250,9 +245,9 @@ static int gs1_csumalpha(const unsigned char *data, int data_len, int offset, in data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ + /* Do this check separately for backward compatibility */ if (data_len && data_len < 2) { *p_err_no = 4; @@ -294,9 +289,9 @@ static int gs1_gcppos1(const unsigned char *data, int data_len, int offset, int data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ + /* Do this check separately for backward compatibility */ if (data_len && data_len < 2) { *p_err_no = 4; @@ -652,13 +647,10 @@ static int gs1_iso4217(const unsigned char *data, int data_len, int offset, int static int gs1_pcenc(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, int *p_err_posn, char err_msg[50], const int length_only) { - static const char hex_chars[] = "0123456789ABCDEFabcdef"; - data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { const unsigned char *d = data + offset; @@ -671,7 +663,8 @@ static int gs1_pcenc(const unsigned char *data, int data_len, int offset, int mi *p_err_posn = (int) (d - data) + 1; return gs1_err_msg_cpy_nochk(err_msg, "Invalid % escape"); } - if (strchr(hex_chars, *(++d)) == NULL || strchr(hex_chars, *(++d)) == NULL) { + d += 2; + if (!z_isxdigit(*(d - 1)) || !z_isxdigit(*d)) { *p_err_no = 3; *p_err_posn = (int) (d - data) + 1; return gs1_err_msg_cpy_nochk(err_msg, "Invalid character for percent encoding"); @@ -690,9 +683,8 @@ static int gs1_yesno(const unsigned char *data, int data_len, int offset, int mi data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { if (data[offset] != '0' && data[offset] != '1') { @@ -713,9 +705,8 @@ static int gs1_importeridx(const unsigned char *data, int data_len, int offset, data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { const unsigned char *d = data + offset; @@ -737,9 +728,8 @@ static int gs1_nonzero(const unsigned char *data, int data_len, int offset, int data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { const int val = z_to_int(data + offset, data_len > max ? max : data_len); @@ -761,9 +751,8 @@ static int gs1_winding(const unsigned char *data, int data_len, int offset, int data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { if (data[offset] != '0' && data[offset] != '1' && data[offset] != '9') { @@ -783,9 +772,8 @@ static int gs1_zero(const unsigned char *data, int data_len, int offset, int min data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { if (data[offset] != '0') { @@ -843,9 +831,9 @@ static int gs1_iban(const unsigned char *data, int data_len, int offset, int min data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ + /* Do this check separately for backward compatibility */ if (data_len && data_len < 5) { *p_err_no = 4; @@ -920,9 +908,8 @@ static int gs1_nozeroprefix(const unsigned char *data, int data_len, int offset, data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { /* GS1 General Specifications Release 26.0 3.9.11 "The C/P serial number SHALL NOT begin with a "0" digit, @@ -1026,9 +1013,9 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ + /* Do separately for backward compatibility */ if (data_len && data_len < min_req_len) { *p_err_no = 4; @@ -1232,9 +1219,9 @@ static int gs1_couponposoffer(const unsigned char *data, int data_len, int offse data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ + /* Do separately for backward compatibility */ if (data_len && (data_len < min_len || data_len > max_len)) { *p_err_no = 4; @@ -1365,9 +1352,8 @@ static int gs1_hyphen(const unsigned char *data, int data_len, int offset, int m data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { const unsigned char *d = data + offset; @@ -1392,9 +1378,8 @@ static int gs1_iso5218(const unsigned char *data, int data_len, int offset, int data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { /* 0 = Not known, 1 = Male, 2 = Female, 9 = Not applicable */ @@ -1414,9 +1399,8 @@ static int gs1_posinseqslash(const unsigned char *data, int data_len, int offset data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { const unsigned char *d = data + offset; @@ -1478,9 +1462,8 @@ static int gs1_hasnondigit(const unsigned char *data, int data_len, int offset, data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { const unsigned char *d = data + offset; @@ -1561,9 +1544,8 @@ static int gs1_packagetype(const unsigned char *data, int data_len, int offset, data_len = data_len < offset ? 0 : data_len - offset; - if (data_len < min) { - return 0; - } + (void)min; + assert(data_len >= min); /* Min checked before being called */ if (!length_only && data_len) { /* Adapted from GS1 Syntax Dictionary and Linters diff --git a/backend/hanxin.c b/backend/hanxin.c index ecd0c250..70b2dbe5 100644 --- a/backend/hanxin.c +++ b/backend/hanxin.c @@ -1531,8 +1531,8 @@ INTERNAL int zint_hanxin(struct zint_symbol *symbol, struct zint_seg segs[], con if (!done) { /* Try GB 18030 */ int error_number = zint_gb18030_utf8(symbol, local_segs[i].source, &local_segs[i].length, dd); - if (error_number != 0) { - return error_number; + if (error_number != 0) { /* Shouldn't happen */ + return error_number; /* Not reached */ } if (local_segs[i].eci != 32) { warn_number = z_errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 543, diff --git a/backend/library.c b/backend/library.c index cea5097c..9ec0c305 100644 --- a/backend/library.c +++ b/backend/library.c @@ -245,6 +245,26 @@ INTERNAL int zint_plot_raster(struct zint_symbol *symbol, int rotate_angle, int /* Plot to EMF/EPS/SVG */ INTERNAL int zint_plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type); +/* Helper to convert `error_number` based on `warn_level` */ +static int error_warn_level(int error_number, struct zint_symbol *symbol) { + if (error_number < ZINT_ERROR && (symbol->warn_level & 0xFF) == WARN_FAIL_ALL) { + /* Convert to error equivalent */ + if (error_number == ZINT_WARN_NONCOMPLIANT) { + error_number = ZINT_ERROR_NONCOMPLIANT; + } else if (error_number == ZINT_WARN_USES_ECI) { + error_number = ZINT_ERROR_USES_ECI; + } else if (error_number == ZINT_WARN_INVALID_OPTION) { + error_number = ZINT_ERROR_INVALID_OPTION; + } else if (error_number == ZINT_WARN_HRT_TRUNCATED) { + error_number = ZINT_ERROR_HRT_TRUNCATED; + } else { /* Shouldn't happen */ + assert(0); /* Not reached */ + error_number = ZINT_ERROR_ENCODING_PROBLEM; + } + } + return error_number; +} + /* Prefix error message with Error/Warning */ static int error_tag(int error_number, struct zint_symbol *symbol, const int err_id, const char *error_string) { @@ -252,21 +272,7 @@ static int error_tag(int error_number, struct zint_symbol *symbol, const int err if (error_string) { z_errtxt(0, symbol, err_id, error_string); } - if (error_number < ZINT_ERROR && symbol->warn_level == WARN_FAIL_ALL) { - /* Convert to error equivalent */ - if (error_number == ZINT_WARN_NONCOMPLIANT) { - error_number = ZINT_ERROR_NONCOMPLIANT; - } else if (error_number == ZINT_WARN_USES_ECI) { - error_number = ZINT_ERROR_USES_ECI; - } else if (error_number == ZINT_WARN_INVALID_OPTION) { - error_number = ZINT_ERROR_INVALID_OPTION; - } else if (error_number == ZINT_WARN_HRT_TRUNCATED) { - error_number = ZINT_ERROR_HRT_TRUNCATED; - } else { /* Shouldn't happen */ - assert(0); /* Not reached */ - error_number = ZINT_ERROR_ENCODING_PROBLEM; - } - } + error_number = error_warn_level(error_number, symbol); if (error_number >= ZINT_ERROR) { z_errtxt_adj(0, symbol, "Error %s", NULL); } else { @@ -366,6 +372,7 @@ static int supports_non_iso8859_1(const int symbology) { /* Returns 1 if `symbol` can process EXTRA_ESCAPE_MODE */ static int supports_extra_escape_mode(const struct zint_symbol *const symbol) { + /* Note if change this must change copy in "frontend/main.c" */ return symbol->symbology == BARCODE_CODE128 || ((symbol->symbology == BARCODE_AZTEC || symbol->symbology == BARCODE_DATAMATRIX) && (symbol->input_mode & 0x07) != GS1_MODE); @@ -1206,50 +1213,48 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[ } if ((symbol->input_mode & 0x07) == GS1_MODE || check_force_gs1(symbol->symbology)) { - if (gs1_compliant(symbol->symbology)) { - /* Reduce input for composite and non-forced symbologies, others (GS1_128 and DBAR_EXP based) will - handle it themselves */ - const int is_composite = z_is_composite(symbol->symbology); + /* Reduce input for composite and non-forced symbologies, others (GS1_128 and DBAR_EXP based) will + handle it themselves */ + const int is_composite = z_is_composite(symbol->symbology); - /* Deal with any ECI first */ - if (symbol->eci) { - /* Check that ECI is at least CSET82 (an ASCII Invariant subset) compatible */ - if (symbol->eci == 25 || (symbol->eci >= 33 && symbol->eci <= 35)) { /* UTF-16/32 BE/LE */ - return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 856, - "In GS1 mode ECI must be ASCII compatible"); - } - /* Note not warning here that ECI is not supported in GS1 mode, leaving it up to individual - symbologies, as standards are inconsistent in mentioning it */ + assert(gs1_compliant(symbol->symbology)); + + /* Deal with any ECI first */ + if (symbol->eci) { + /* Check that ECI is at least CSET82 (an ASCII Invariant subset) compatible */ + if (symbol->eci == 25 || (symbol->eci >= 33 && symbol->eci <= 35)) { /* UTF-16/32 BE/LE */ + return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 856, "In GS1 mode ECI must be ASCII compatible"); } + /* Note not warning here that ECI is not supported in GS1 mode, leaving it up to individual + symbologies, as standards are inconsistent in mentioning it */ + } - if (is_composite || !check_force_gs1(symbol->symbology)) { - unsigned char *reduced = (unsigned char *) z_alloca(local_segs[0].length + 1); - error_number = zint_gs1_verify(symbol, local_segs[0].source, local_segs[0].length, reduced, - &local_segs[0].length, 0 /*set_hrt*/); - if (error_number) { + if (is_composite || !check_force_gs1(symbol->symbology)) { + unsigned char *reduced = (unsigned char *) z_alloca(local_segs[0].length + 1); + error_number = zint_gs1_verify(symbol, local_segs[0].source, local_segs[0].length, reduced, + &local_segs[0].length, 0 /*set_hrt*/); + if (error_number) { #ifdef ZINT_HAVE_GS1SE - if (is_composite && !(symbol->input_mode & GS1SYNTAXENGINE_MODE)) { - z_errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)"); - } + if (is_composite && !(symbol->input_mode & GS1SYNTAXENGINE_MODE)) { + z_errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)"); + } #else - if (is_composite) { - z_errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)"); - } + if (is_composite) { + z_errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)"); + } #endif - error_number = error_tag(error_number, symbol, -1, NULL); - if (error_number >= ZINT_ERROR) { - return error_number; - } - warn_number = error_number; /* Override any previous warning (errtxt has been overwritten) */ - } - memcpy(local_segs[0].source, reduced, local_segs[0].length + 1); /* Include terminating NUL */ - /* Set content segs for non-composites (composites set their own content segs) */ - if (!is_composite && content_segs && z_ct_cpy(symbol, reduced, local_segs[0].length)) { - return error_tag(ZINT_ERROR_MEMORY, symbol, -1, NULL); /* `z_ct_cpy()` only fails with OOM */ + error_number = error_warn_level(error_number, symbol); + if (error_number >= ZINT_ERROR) { + return error_tag(error_number, symbol, -1, NULL); } + warn_number = error_number; /* Override any previous warning (errtxt has been overwritten) */ + symbol->warn_level |= (warn_number << 8); /* Hack to let `zint_composite()` know */ + } + memcpy(local_segs[0].source, reduced, local_segs[0].length + 1); /* Include terminating NUL */ + /* Set content segs for non-composites (composites set their own content segs) */ + if (!is_composite && content_segs && z_ct_cpy(symbol, reduced, local_segs[0].length)) { + return error_tag(ZINT_ERROR_MEMORY, symbol, -1, NULL); /* `z_ct_cpy()` only fails with OOM */ } - } else { - return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 210, "Selected symbology does not support GS1 mode"); } } else if (content_segs && supports_non_iso8859_1(symbol->symbology)) { /* Copy these as-is. The content seg `eci` (& maybe `source`) will need to be updated individually */ diff --git a/backend/output.c b/backend/output.c index a5e7d8b9..c7fdf975 100644 --- a/backend/output.c +++ b/backend/output.c @@ -189,7 +189,7 @@ INTERNAL int zint_out_colour_get_cmyk(const char *colour, int *cyan, int *magent return 1 + have_alpha; } -/* Convert internal colour chars "WCBMRYGK" to RGB */ +/* Convert internal colour chars "WCBMRYGK" to RGB. Returns 1 on success, else 0 */ INTERNAL int zint_out_colour_char_to_rgb(const unsigned char ch, unsigned char *red, unsigned char *green, unsigned char *blue) { static const char chars[] = "WCBMRYGK"; @@ -955,6 +955,12 @@ static int out_maybe_mkdir(const char *path) { return 0; } +#ifdef ZINT_TEST /* Wrapper for direct testing */ +INTERNAL int zint_test_out_maybe_mkdir(const char *path) { + return out_maybe_mkdir(path); +} +#endif + /* Create output file, creating sub-directories if necessary. Returns `fopen()` FILE pointer */ INTERNAL FILE *zint_out_fopen(char filename[256], const char *mode) { FILE *outfile; diff --git a/backend/output.h b/backend/output.h index 012b4257..59153f02 100644 --- a/backend/output.h +++ b/backend/output.h @@ -49,7 +49,7 @@ INTERNAL int zint_out_colour_get_rgb(const char *colour, unsigned char *red, uns INTERNAL int zint_out_colour_get_cmyk(const char *colour, int *cyan, int *magenta, int *yellow, int *black, unsigned char *rgb_alpha); -/* Convert internal colour chars "WCBMRYGK" to RGB */ +/* Convert internal colour chars "WCBMRYGK" to RGB. Returns 1 on success, else 0 */ INTERNAL int zint_out_colour_char_to_rgb(const unsigned char ch, unsigned char *red, unsigned char *green, unsigned char *blue); diff --git a/backend/pdf417.c b/backend/pdf417.c index 598abe43..7a3b264f 100644 --- a/backend/pdf417.c +++ b/backend/pdf417.c @@ -1364,17 +1364,9 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int chainemc[0] = mclength; /* 796 - we now take care of the Reed Solomon codes */ - switch (ecc) { - case 1: offset = 2; break; - case 2: offset = 6; break; - case 3: offset = 14; break; - case 4: offset = 30; break; - case 5: offset = 62; break; - case 6: offset = 126; break; - case 7: offset = 254; break; - case 8: offset = 510; break; - default: offset = 0; break; - } + assert(ecc >= 0 && ecc <= 8); + offset = (2 << ecc) - 2; + assert(offset >= 0 && offset <= 512); /* Suppress clang-tidy-23 warning clang-analyzer-security.ArrayBound */ for (i = 0; i < mclength; i++) { total = (chainemc[i] + mccorrection[ecc_cws - 1]) % 929; @@ -1477,7 +1469,7 @@ INTERNAL int zint_pdf417(struct zint_symbol *symbol, struct zint_seg segs[], con if (symbol->option_1 < -1 || symbol->option_1 > 8) { z_errtxtf(0, symbol, 460, "Error correction level '%d' out of range (0 to 8)", symbol->option_1); - if (symbol->warn_level == WARN_FAIL_ALL) { + if ((symbol->warn_level & 0xFF) == WARN_FAIL_ALL) { return ZINT_ERROR_INVALID_OPTION; } error_number = z_errtxt_adj(ZINT_WARN_INVALID_OPTION, symbol, "%1$s%2$s", ", ignoring"); @@ -1485,7 +1477,7 @@ INTERNAL int zint_pdf417(struct zint_symbol *symbol, struct zint_seg segs[], con } if (symbol->option_2 < 0 || symbol->option_2 > 30) { z_errtxtf(0, symbol, 461, "Number of columns '%d' out of range (1 to 30)", symbol->option_2); - if (symbol->warn_level == WARN_FAIL_ALL) { + if ((symbol->warn_level & 0xFF) == WARN_FAIL_ALL) { return ZINT_ERROR_INVALID_OPTION; } error_number = z_errtxt_adj(ZINT_WARN_INVALID_OPTION, symbol, "%1$s%2$s", ", ignoring"); @@ -1512,207 +1504,105 @@ INTERNAL int zint_pdf417(struct zint_symbol *symbol, struct zint_seg segs[], con return error_number; } -/* Like PDF417 only much smaller! */ -INTERNAL int zint_micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) { - int i, k, j, longueur, mccorrection[50] = {0}, offset; - int ecc_cwds; - int total, mclength, error_number = 0; - short chainemc[PDF_MAX_STREAM_LEN]; - char pattern[580]; - int bp = 0; - int structapp_cws[18] = {0}; /* 3 (Index) + 10 (ID) + 4 (Count) + 1 (Last) */ - int structapp_cp = 0; - int variant; - int LeftRAP, CentreRAP, RightRAP, Cluster, loop; - const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; - /* From ISO/IEC 24728:2006 Table 1 — MicroPDF417 version characteristics */ - static char col_max_codewords[5] = { 0, 20, 37, 82, 126 }; - - if ((i = z_segs_length(segs, seg_count)) > MICRO_PDF_MAX_LEN) { - return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 474, - "Input length %d too long (maximum " MICRO_PDF_MAX_LEN_S ")", i); - } - if (symbol->option_3) { - return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 476, "Cannot specify rows for MicroPDF417"); - } - - /* Encoding starts out the same as PDF417, so use the same code */ - - if ((error_number = pdf_initial_segs(symbol, segs, seg_count, 1 /*is_micro*/, chainemc, &mclength, structapp_cws, - &structapp_cp))) { - assert(error_number >= ZINT_ERROR); - return error_number; - } - - /* This is where it all changes! */ - - if (mclength + structapp_cp > 126) { - return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 467, "Input too long, requires %d codewords (maximum 126)", - mclength + structapp_cp); - } - if (symbol->option_2 > 4) { - if (symbol->warn_level == WARN_FAIL_ALL) { - return z_errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 471, "Number of columns '%d' out of range (1 to 4)", - symbol->option_2); - } - error_number = z_errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 468, - "Number of columns '%d' out of range (1 to 4), ignoring", symbol->option_2); - symbol->option_2 = 0; - } - - if (debug_print) { - printf("\nEncoded Data Stream (%d):\n", mclength); - for (i = 0; i < mclength; i++) { - printf("%3d ", chainemc[i]); - } - fputc('\n', stdout); - } - - /* Now figure out which variant of the symbol to use and load values accordingly */ - - variant = 0; - - if (symbol->option_2 >= 1 && mclength + structapp_cp > col_max_codewords[symbol->option_2]) { - /* The user specified the column but the data doesn't fit - go to automatic */ - if (symbol->warn_level == WARN_FAIL_ALL) { - return ZEXT z_errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 469, - "Input too long for number of columns '%1$d', requires %2$d codewords (maximum %3$d)", - symbol->option_2, mclength + structapp_cp, col_max_codewords[symbol->option_2]); - } - error_number = z_errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 470, - "Input too long for number of columns '%d', ignoring", symbol->option_2); - symbol->option_2 = 0; - } - - if (symbol->option_2 == 1) { - /* The user specified 1 column and the data does fit */ - if (mclength + structapp_cp <= 4) { +/* Return variant based on `cols` and codeword length `mclength`. Returns 0 if `cols` 0 or no variant fits */ +INTERNAL int zint_micropdf_variant(const int cols, const int mclength) { + int variant = 0; + if (cols == 1) { + if (mclength <= 4) { variant = 1; - } else if (mclength + structapp_cp <= 7) { + } else if (mclength <= 7) { variant = 2; - } else if (mclength + structapp_cp <= 10) { + } else if (mclength <= 10) { variant = 3; - } else if (mclength + structapp_cp <= 12) { + } else if (mclength <= 12) { variant = 4; - } else if (mclength + structapp_cp <= 16) { + } else if (mclength <= 16) { variant = 5; } else { variant = 6; } - } else if (symbol->option_2 == 2) { - /* The user specified 2 columns and the data does fit */ - if (mclength + structapp_cp <= 8) { + } else if (cols == 2) { + if (mclength <= 8) { variant = 7; - } else if (mclength + structapp_cp <= 13) { + } else if (mclength <= 13) { variant = 8; - } else if (mclength + structapp_cp <= 19) { + } else if (mclength <= 19) { variant = 9; - } else if (mclength + structapp_cp <= 24) { + } else if (mclength <= 24) { variant = 10; - } else if (mclength + structapp_cp <= 29) { + } else if (mclength <= 29) { variant = 11; - } else if (mclength + structapp_cp <= 33) { + } else if (mclength <= 33) { variant = 12; } else { variant = 13; } - } else if (symbol->option_2 == 3) { - /* The user specified 3 columns and the data does fit */ - if (mclength + structapp_cp <= 6) { + } else if (cols == 3) { + if (mclength <= 6) { variant = 14; - } else if (mclength + structapp_cp <= 10) { + } else if (mclength <= 10) { variant = 15; - } else if (mclength + structapp_cp <= 14) { + } else if (mclength <= 14) { variant = 16; - } else if (mclength + structapp_cp <= 18) { + } else if (mclength <= 18) { variant = 17; - } else if (mclength + structapp_cp <= 24) { + } else if (mclength <= 24) { variant = 18; - } else if (mclength + structapp_cp <= 34) { + } else if (mclength <= 34) { variant = 19; - } else if (mclength + structapp_cp <= 46) { + } else if (mclength <= 46) { variant = 20; - } else if (mclength + structapp_cp <= 58) { + } else if (mclength <= 58) { variant = 21; - } else if (mclength + structapp_cp <= 70) { + } else if (mclength <= 70) { variant = 22; } else { variant = 23; } - } else if (symbol->option_2 == 4) { - /* The user specified 4 columns and the data does fit */ - if (mclength + structapp_cp <= 8) { + } else if (cols == 4) { + if (mclength <= 8) { variant = 24; - } else if (mclength + structapp_cp <= 12) { + } else if (mclength <= 12) { variant = 25; - } else if (mclength + structapp_cp <= 18) { + } else if (mclength <= 18) { variant = 26; - } else if (mclength + structapp_cp <= 24) { + } else if (mclength <= 24) { variant = 27; - } else if (mclength + structapp_cp <= 30) { + } else if (mclength <= 30) { variant = 28; - } else if (mclength + structapp_cp <= 39) { + } else if (mclength <= 39) { variant = 29; - } else if (mclength + structapp_cp <= 54) { + } else if (mclength <= 54) { variant = 30; - } else if (mclength + structapp_cp <= 72) { + } else if (mclength <= 72) { variant = 31; - } else if (mclength + structapp_cp <= 90) { + } else if (mclength <= 90) { variant = 32; - } else if (mclength + structapp_cp <= 108) { + } else if (mclength <= 108) { variant = 33; } else { variant = 34; } - } else { - /* Zint can choose automatically from all available variations */ - for (i = 27; i >= 0; i--) { - /* Note mclength + structapp_cp <= 126 and pdf_MicroAutosize[27] == 126 so variant will be set */ - if (pdf_MicroAutosize[i] >= mclength + structapp_cp) { - variant = pdf_MicroAutosize[i + 28]; - } else { - break; - } - } } - assert(variant > 0); /* Suppress clang-tidy clang-analyzer-core.uninitialized.Assign */ + return variant; +} - /* Now we have the variant we can load the data */ - variant--; - symbol->option_2 = zint_pdf_MicroVariants[variant]; /* Columns */ - symbol->rows = zint_pdf_MicroVariants[variant + 34]; /* Rows */ - ecc_cwds = zint_pdf_MicroVariants[variant + 68]; /* Number of EC CWs */ - longueur = (symbol->option_2 * symbol->rows) - ecc_cwds; /* Number of non-EC CWs */ - i = longueur - (mclength + structapp_cp); /* Amount of padding required */ - offset = zint_pdf_MicroVariants[variant + 102]; /* Coefficient offset */ - - /* Feedback options */ - /* Place in top byte, leaving bottom one for maybe future use - also compatible with AZTEC */ - symbol->option_1 = ((int) z_stripf(roundf(z_stripf(ecc_cwds * 100.0f / (longueur + ecc_cwds))))) << 8; - - if (debug_print) { - fputs("\nChoose symbol size:\n", stdout); - printf("%d columns x %d rows, variant %d\n", symbol->option_2, symbol->rows, variant + 1); - printf("%d data codewords (including %d pads), %d ecc codewords\n", longueur, i, ecc_cwds); - fputc('\n', stdout); - } - - /* We add the padding */ - while (i-- > 0) { - chainemc[mclength++] = 900; - } - - /* We add the Structured Append Macro Control Block if any */ - if (structapp_cp) { - for (i = 0; i < structapp_cp; i++) { - chainemc[mclength++] = structapp_cws[i]; - } - } +INTERNAL void zint_micropdf_expand(struct zint_symbol *symbol, short *chainemc, int mclength, char *pattern, + const int cols, const int variant, const int debug_print) { + int bp = 0; /* Suppress gcc warning -Wmaybe-uninitialized */ + int i, k, j, mccorrection[50] = {0}, ecc_cwds; + int offset = zint_pdf_MicroVariants[3][variant]; /* Coefficient offset */ + int LeftRAP = zint_pdf_RAPTable[0][variant] - 1; + int CentreRAP = zint_pdf_RAPTable[1][variant] - 1; + int RightRAP = zint_pdf_RAPTable[2][variant] - 1; + int Cluster; /* Reed-Solomon error correction */ - longueur = mclength; - for (i = 0; i < longueur; i++) { - total = (chainemc[i] + mccorrection[ecc_cwds - 1]) % 929; + ecc_cwds = zint_pdf_MicroVariants[2][variant]; /* Number of EC CWs */ + assert(ecc_cwds >= 7); /* Suppress clang-tidy-23 warning clang-analyzer-security.ArrayBound */ + + for (i = 0; i < mclength; i++) { + const int total = (chainemc[i] + mccorrection[ecc_cwds - 1]) % 929; for (j = ecc_cwds - 1; j >= 0; j--) { if (j == 0) { mccorrection[j] = (929 - (total * zint_pdf_Microcoeffs[offset + j]) % 929) % 929; @@ -1746,74 +1636,173 @@ INTERNAL int zint_micropdf417(struct zint_symbol *symbol, struct zint_seg segs[] } #endif - /* Now get the RAP (Row Address Pattern) start values */ - LeftRAP = zint_pdf_RAPTable[variant]; - CentreRAP = zint_pdf_RAPTable[variant + 34]; - RightRAP = zint_pdf_RAPTable[variant + 68]; - Cluster = zint_pdf_RAPTable[variant + 102] / 3; + /* Cluster can be 0, 1 or 2 for Cluster(0), Cluster(3) and Cluster(6) */ + Cluster = zint_pdf_RAPTable[3][variant]; /* Pre-divided by 3 */ /* That's all values loaded, get on with the encoding */ - /* Cluster can be 0, 1 or 2 for Cluster(0), Cluster(3) and Cluster(6) */ - if (debug_print) fputs("\nInternal row representation:\n", stdout); for (i = 0; i < symbol->rows; i++) { if (debug_print) printf("row %d: ", i); bp = 0; offset = 929 * Cluster; - k = i * symbol->option_2; + k = i * cols; /* Copy the data into codebarre */ - bp = z_bin_append_posn(zint_pdf_rap_side[LeftRAP - 1], 10, pattern, bp); + bp = z_bin_append_posn(zint_pdf_rap_side[LeftRAP], 10, pattern, bp); bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + chainemc[k]]) << 1, 17, pattern, bp); - if (symbol->option_2 >= 2) { - if (symbol->option_2 == 3) { - bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP - 1], 10, pattern, bp); + if (cols >= 2) { + if (cols == 3) { + bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP], 10, pattern, bp); } bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + chainemc[k + 1]]) << 1, 17, pattern, bp); - if (symbol->option_2 >= 3) { - if (symbol->option_2 == 4) { - bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP - 1], 10, pattern, bp); + if (cols >= 3) { + if (cols == 4) { + bp = z_bin_append_posn(zint_pdf_rap_centre[CentreRAP], 10, pattern, bp); } bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + chainemc[k + 2]]) << 1, 17, pattern, bp); - if (symbol->option_2 == 4) { + if (cols == 4) { bp = z_bin_append_posn(((int) zint_pdf_bitpattern[offset + chainemc[k + 3]]) << 1, 17, pattern, bp); } } } - bp = z_bin_append_posn(zint_pdf_rap_side[RightRAP - 1], 10, pattern, bp); + bp = z_bin_append_posn(zint_pdf_rap_side[RightRAP], 10, pattern, bp); pattern[bp++] = '1'; /* Stop */ if (debug_print) printf("%.*s\n", bp, pattern); /* So now pattern[] holds the string of '1's and '0's. - copy this to the symbol */ - for (loop = 0; loop < bp; loop++) { - if (pattern[loop] == '1') { - z_set_module(symbol, i, loop); + for (j = 0; j < bp; j++) { + if (pattern[j] == '1') { + z_set_module(symbol, i, j); } } /* Set up RAPs and Cluster for next row */ - LeftRAP++; - CentreRAP++; - RightRAP++; - Cluster++; - - if (LeftRAP == 53) { - LeftRAP = 1; - } - if (CentreRAP == 53) { - CentreRAP = 1; - } - if (RightRAP == 53) { - RightRAP = 1; - } - if (Cluster == 3) { - Cluster = 0; - } + LeftRAP = LeftRAP == 51 ? 0 : LeftRAP + 1; + CentreRAP = CentreRAP == 51 ? 0 : CentreRAP + 1; + RightRAP = RightRAP == 51 ? 0 : RightRAP + 1; + Cluster = Cluster == 2 ? 0 : Cluster + 1; } symbol->width = bp; +} + +/* Like PDF417 only much smaller! */ +INTERNAL int zint_micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) { + int i, longueur, padding; + int ecc_cwds; + int mclength, error_number = 0; + short chainemc[PDF_MAX_STREAM_LEN]; + char pattern[580]; + int structapp_cws[18] = {0}; /* 3 (Index) + 10 (ID) + 4 (Count) + 1 (Last) */ + int structapp_cp = 0; + int variant; + const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; + /* From ISO/IEC 24728:2006 Table 1 — MicroPDF417 version characteristics */ + static char col_max_codewords[5] = { 0, 20, 37, 82, 126 }; + + if ((i = z_segs_length(segs, seg_count)) > MICRO_PDF_MAX_LEN) { + return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 474, + "Input length %d too long (maximum " MICRO_PDF_MAX_LEN_S ")", i); + } + if (symbol->option_3) { + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 476, "Cannot specify rows for MicroPDF417"); + } + + /* Encoding starts out the same as PDF417, so use the same code */ + + if ((error_number = pdf_initial_segs(symbol, segs, seg_count, 1 /*is_micro*/, chainemc, &mclength, structapp_cws, + &structapp_cp))) { + assert(error_number >= ZINT_ERROR); + return error_number; + } + + /* This is where it all changes! */ + + if (mclength + structapp_cp > 126) { + return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 467, "Input too long, requires %d codewords (maximum 126)", + mclength + structapp_cp); + } + if (symbol->option_2 > 4) { + if ((symbol->warn_level & 0xFF) == WARN_FAIL_ALL) { + return z_errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 471, "Number of columns '%d' out of range (1 to 4)", + symbol->option_2); + } + error_number = z_errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 468, + "Number of columns '%d' out of range (1 to 4), ignoring", symbol->option_2); + symbol->option_2 = 0; + } + + if (debug_print) { + printf("\nEncoded Data Stream (%d):\n", mclength); + for (i = 0; i < mclength; i++) { + printf("%3d ", chainemc[i]); + } + fputc('\n', stdout); + } + + /* Now figure out which variant of the symbol to use and load values accordingly */ + + if (symbol->option_2 >= 1 && mclength + structapp_cp > col_max_codewords[symbol->option_2]) { + /* The user specified the column but the data doesn't fit - go to automatic */ + if ((symbol->warn_level & 0xFF) == WARN_FAIL_ALL) { + return ZEXT z_errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 469, + "Input too long for number of columns '%1$d', requires %2$d codewords (maximum %3$d)", + symbol->option_2, mclength + structapp_cp, col_max_codewords[symbol->option_2]); + } + error_number = z_errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 470, + "Input too long for number of columns '%d', ignoring", symbol->option_2); + symbol->option_2 = 0; + } + + /* If the user didn't specify column or the data doesn't fit */ + if (!(variant = zint_micropdf_variant(symbol->option_2, mclength + structapp_cp))) { + /* Zint can choose automatically from all available variations */ + for (i = 27; i >= 0; i--) { + /* Note mclength + structapp_cp <= 126 and pdf_MicroAutosize[27] == 126 so variant will be set */ + if (pdf_MicroAutosize[i] >= mclength + structapp_cp) { + variant = pdf_MicroAutosize[i + 28]; + } else { + break; + } + } + } + assert(variant > 0); /* Suppress clang-tidy-23 warning clang-analyzer-core.uninitialized.Assign */ + + /* Now we have the variant we can load the data */ + variant--; + symbol->option_2 = zint_pdf_MicroVariants[0][variant]; /* Columns */ + symbol->rows = zint_pdf_MicroVariants[1][variant]; /* Rows */ + ecc_cwds = zint_pdf_MicroVariants[2][variant]; /* Number of EC CWs */ + + longueur = (symbol->option_2 * symbol->rows) - ecc_cwds; /* Number of non-EC CWs */ + padding = longueur - (mclength + structapp_cp); /* Amount of padding required */ + + /* Feedback options */ + /* Place in top byte, leaving bottom one for maybe future use - also compatible with AZTEC */ + symbol->option_1 = ((int) z_stripf(roundf(z_stripf(ecc_cwds * 100.0f / (longueur + ecc_cwds))))) << 8; + + if (debug_print) { + fputs("\nChoose symbol size:\n", stdout); + printf("%d columns x %d rows, variant %d\n", symbol->option_2, symbol->rows, variant + 1); + printf("%d data codewords (including %d pads), %d ecc codewords\n", longueur, padding, ecc_cwds); + fputc('\n', stdout); + } + + /* We add the padding */ + while (padding-- > 0) { + chainemc[mclength++] = 900; + } + + /* We add the Structured Append Macro Control Block if any */ + if (structapp_cp) { + for (i = 0; i < structapp_cp; i++) { + chainemc[mclength++] = structapp_cws[i]; + } + } + + zint_micropdf_expand(symbol, chainemc, mclength, pattern, symbol->option_2, variant, debug_print); /* ISO/IEC 24728:2006 Section 5.8.2 2X minimum row height */ if (error_number) { diff --git a/backend/pdf417.h b/backend/pdf417.h index 8a8a6f5d..cdde0bb6 100644 --- a/backend/pdf417.h +++ b/backend/pdf417.h @@ -46,7 +46,7 @@ INTERNAL_DATA_EXTERN const unsigned short zint_pdf_coefrs[1022]; INTERNAL_DATA_EXTERN const unsigned short zint_pdf_bitpattern[2787]; /* 2787 = 929 * 3 */ /* Left RAP, Centre RAP, Right RAP and Start Cluster from ISO/IEC 15438:2015 Tables 10, 11 and 12 */ -INTERNAL_DATA_EXTERN const char zint_pdf_RAPTable[136]; /* 34 * 4 */ +INTERNAL_DATA_EXTERN const char zint_pdf_RAPTable[4][34]; /* Left and Right Row Address Pattern from ISO/IEC 15438:2015 Table 2 */ INTERNAL_DATA_EXTERN const unsigned short zint_pdf_rap_side[52]; @@ -57,13 +57,16 @@ INTERNAL_DATA_EXTERN const unsigned short zint_pdf_rap_centre[52]; /* MicroPDF417 coefficients from ISO/IEC 24728:2006 Annex F */ INTERNAL_DATA_EXTERN const unsigned short zint_pdf_Microcoeffs[344]; -/* Number of Data Columns (1st 34), Number of Rows (2nd 34), Number of EC CWs (3rd 34) from ISO/IEC 24728:2006 Table 1 - and k-offsets (4th 34) into `zint_pdf_Microcoeffs[]` above */ -INTERNAL_DATA_EXTERN const unsigned short zint_pdf_MicroVariants[136]; /* 34 * 4 */ +/* Number of Data Columns (row 0), Number of Rows (1), Number of EC CWs (2) from ISO/IEC 24728:2006 Table 1 + and k-offsets (3) into `zint_pdf_Microcoeffs[]` above */ +INTERNAL_DATA_EXTERN const unsigned short zint_pdf_MicroVariants[4][34]; INTERNAL void zint_pdf_byteprocess(short *chainemc, int *p_mclength, const unsigned char chaine[], int start, const int length, const int lastmode); +INTERNAL void zint_micropdf_expand(struct zint_symbol *symbol, short *chainemc, int mclength, char *pattern, + const int cols, const int variant, const int debug_print); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/backend/pdf417_tabs.h b/backend/pdf417_tabs.h index 41200a95..0d1a2f8b 100644 --- a/backend/pdf417_tabs.h +++ b/backend/pdf417_tabs.h @@ -413,12 +413,12 @@ INTERNAL_DATA const unsigned short zint_pdf_bitpattern[2787] = { /* 2787 = 929 * 0xC3EA, 0xC3E9, 0x83CA, 0x87DA, 0x83C9, 0x87D9, 0xE3F5 }; -/* Left RAP, Centre RAP, Right RAP and Start Cluster from ISO/IEC 15438:2015 Tables 10, 11 and 12 */ -INTERNAL_DATA const char zint_pdf_RAPTable[136] = { /* 34 * 4 */ - 1, 8, 36, 19, 9, 25, 1, 1, 8, 36, 19, 9, 27, 1, 7, 15, 25, 37, 1, 1, 21, 15, 1, 47, 1, 7, 15, 25, 37, 1, 1, 21, 15, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 25, 37, 17, 9, 29, 31, 25, 19, 1, 7, 15, 25, 37, 17, 9, 29, 31, 25, - 9, 8, 36, 19, 17, 33, 1, 9, 8, 36, 19, 17, 35, 1, 7, 15, 25, 37, 33, 17, 37, 47, 49, 43, 1, 7, 15, 25, 37, 33, 17, 37, 47, 49, - 0, 3, 6, 0, 6, 0, 0, 0, 3, 6, 0, 6, 6, 0, 0, 6, 0, 0, 0, 0, 6, 6, 0, 3, 0, 0, 6, 0, 0, 0, 0, 6, 6, 0 +/* Left RAP, Centre RAP, Right RAP and (Start Cluster / 3) from ISO/IEC 15438:2015 Tables 10, 11 and 12 */ +INTERNAL_DATA const char zint_pdf_RAPTable[4][34] = { + { 1, 8, 36, 19, 9, 25, 1, 1, 8, 36, 19, 9, 27, 1, 7, 15, 25, 37, 1, 1, 21, 15, 1, 47, 1, 7, 15, 25, 37, 1, 1, 21, 15, 1 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 25, 37, 17, 9, 29, 31, 25, 19, 1, 7, 15, 25, 37, 17, 9, 29, 31, 25 }, + { 9, 8, 36, 19, 17, 33, 1, 9, 8, 36, 19, 17, 35, 1, 7, 15, 25, 37, 33, 17, 37, 47, 49, 43, 1, 7, 15, 25, 37, 33, 17, 37, 47, 49 }, + { 0, 1, 2, 0, 2, 0, 0, 0, 1, 2, 0, 2, 2, 0, 0, 2, 0, 0, 0, 0, 2, 2, 0, 1, 0, 0, 2, 0, 0, 0, 0, 2, 2, 0 } }; /* Left and Right Row Address Pattern from ISO/IEC 15438:2015 Table 2 */ @@ -507,13 +507,13 @@ INTERNAL_DATA const unsigned short zint_pdf_Microcoeffs[344] = { 718, 435 }; -/* Number of Data Columns (1st 34), Number of Rows (2nd 34), Number of EC CWs (3rd 34) from ISO/IEC 24728:2006 Table 1 - and k-offsets (4th 34) into `zint_pdf_Microcoeffs[]` above */ -INTERNAL_DATA const unsigned short zint_pdf_MicroVariants[136] = { /* 34 * 4 */ - 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 11, 14, 17, 20, 24, 28, 8, 11, 14, 17, 20, 23, 26, 6, 8, 10, 12, 15, 20, 26, 32, 38, 44, 4, 6, 8, 10, 12, 15, 20, 26, 32, 38, 44, - 7, 7, 7, 8, 8, 8, 8, 9, 9, 10, 11, 13, 15, 12, 14, 16, 18, 21, 26, 32, 38, 44, 50, 8, 12, 14, 16, 18, 21, 26, 32, 38, 44, 50, - 0, 0, 0, 7, 7, 7, 7, 15, 15, 24, 34, 57, 84, 45, 70, 99, 115, 133, 154, 180, 212, 250, 294, 7, 45, 70, 99, 115, 133, 154, 180, 212, 250, 294 +/* Number of Data Columns (row 0), Number of Rows (1), Number of EC CWs (2) from ISO/IEC 24728:2006 Table 1 + and k-offsets (3) into `zint_pdf_Microcoeffs[]` above */ +INTERNAL_DATA const unsigned short zint_pdf_MicroVariants[4][34] = { + { 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }, + { 11, 14, 17, 20, 24, 28, 8, 11, 14, 17, 20, 23, 26, 6, 8, 10, 12, 15, 20, 26, 32, 38, 44, 4, 6, 8, 10, 12, 15, 20, 26, 32, 38, 44 }, + { 7, 7, 7, 8, 8, 8, 8, 9, 9, 10, 11, 13, 15, 12, 14, 16, 18, 21, 26, 32, 38, 44, 50, 8, 12, 14, 16, 18, 21, 26, 32, 38, 44, 50 }, + { 0, 0, 0, 7, 7, 7, 7, 15, 15, 24, 34, 57, 84, 45, 70, 99, 115, 133, 154, 180, 212, 250, 294, 7, 45, 70, 99, 115, 133, 154, 180, 212, 250, 294 } }; #ifdef __cplusplus diff --git a/backend/png.c b/backend/png.c index 8325f193..8c020274 100644 --- a/backend/png.c +++ b/backend/png.c @@ -1,7 +1,7 @@ /* png.c - Handles output to PNG file */ /* libzint - the open source barcode library - Copyright (C) 2009-2025 Robin Stuart + Copyright (C) 2009-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -32,6 +32,7 @@ #ifndef ZINT_NO_PNG +#include #include #include #include @@ -42,49 +43,42 @@ #include "filemem.h" #include "output.h" -/* Note using "wpng_" prefix not "png_" to avoid clashing with libpng */ +/* Note using "zpng_" prefix not "png_" to avoid clashing with libpng */ /* Note if change this need to change "backend/tests/test_png.c" definition also */ -struct wpng_error_type { +struct zpng_error_type { struct zint_symbol *symbol; jmp_buf jmpbuf; }; -static void wpng_error_handler(png_structp png_ptr, png_const_charp msg) { - struct wpng_error_type *wpng_error_ptr; - - wpng_error_ptr = (struct wpng_error_type *) png_get_error_ptr(png_ptr); - if (wpng_error_ptr == NULL) { - /* we are completely hosed now */ - fprintf(stderr, "Error 636: libpng error: %s\n", msg ? msg : ""); - fprintf(stderr, "Error 637: jmpbuf not recoverable, terminating\n"); - fflush(stderr); - return; /* libpng will call abort() */ - } - z_errtxtf(0, wpng_error_ptr->symbol, 635, "libpng error: %s", msg ? msg : ""); - longjmp(wpng_error_ptr->jmpbuf, 1); +/* Passed to `png_create_write_struct()` as `error_fn` */ +static void zpng_error_handler(png_structp png_ptr, png_const_charp msg) { + struct zpng_error_type *error_ptr = (struct zpng_error_type *) png_get_error_ptr(png_ptr); + assert(error_ptr); + z_errtxtf(0, error_ptr->symbol, 635, "libpng error: %s", msg ? msg : ""); + longjmp(error_ptr->jmpbuf, 1); } #ifdef ZINT_TEST /* Wrapper for direct testing */ -INTERNAL void zint_test_wpng_error_handler(png_structp png_ptr, png_const_charp msg) { - wpng_error_handler(png_ptr, msg); +INTERNAL void zint_test_zpng_error_handler(png_structp png_ptr, png_const_charp msg) { + zpng_error_handler(png_ptr, msg); } #endif /* libpng write callback */ -static void wpng_write(png_structp png_ptr, png_bytep ptr, size_t size) { +static void zpng_write(png_structp png_ptr, png_bytep ptr, size_t size) { struct filemem *fmp = (struct filemem *) png_get_io_ptr(png_ptr); (void) zint_fm_write(ptr, 1, size, fmp); } /* libpng flush callback */ -static void wpng_flush(png_structp png_ptr) { +static void zpng_flush(png_structp png_ptr) { struct filemem *fmp = (struct filemem *) png_get_io_ptr(png_ptr); (void) zint_fm_flush(fmp); } /* Guesstimate best compression strategy */ -static int wpng_guess_compression_strategy(struct zint_symbol *symbol, const unsigned char *pixelbuf) { +static int zpng_guess_compression_strategy(struct zint_symbol *symbol, const unsigned char *pixelbuf) { (void)pixelbuf; /* TODO: Do properly */ @@ -104,7 +98,7 @@ static int wpng_guess_compression_strategy(struct zint_symbol *symbol, const uns } INTERNAL int zint_png_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) { - struct wpng_error_type wpng_error; + struct zpng_error_type zpng_error; /* Passed to `png_create_write_struct()` as `error_ptr` */ struct filemem fm; struct filemem *const fmp = &fm; png_structp png_ptr; @@ -123,7 +117,7 @@ INTERNAL int zint_png_pixel_plot(struct zint_symbol *symbol, const unsigned char const unsigned char *pb; unsigned char *outdata = (unsigned char *) z_alloca(symbol->bitmap_width); - wpng_error.symbol = symbol; + zpng_error.symbol = symbol; (void) zint_out_colour_get_rgb(symbol->fgcolour, &fg.red, &fg.green, &fg.blue, &fg_alpha); (void) zint_out_colour_get_rgb(symbol->bgcolour, &bg.red, &bg.green, &bg.blue, &bg_alpha); @@ -217,7 +211,7 @@ INTERNAL int zint_png_pixel_plot(struct zint_symbol *symbol, const unsigned char } /* Set up error handling routine as proc() above */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &wpng_error, wpng_error_handler, NULL); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &zpng_error, zpng_error_handler, NULL); if (!png_ptr) { (void) zint_fm_close(fmp, symbol); return z_errtxt(ZINT_ERROR_MEMORY, symbol, 633, "Insufficient memory for PNG write structure buffer"); @@ -231,20 +225,20 @@ INTERNAL int zint_png_pixel_plot(struct zint_symbol *symbol, const unsigned char } /* catch jumping here */ - if (setjmp(wpng_error.jmpbuf)) { + if (setjmp(zpng_error.jmpbuf)) { png_destroy_write_struct(&png_ptr, &info_ptr); (void) zint_fm_close(fmp, symbol); return ZINT_ERROR_MEMORY; } /* Set our output functions */ - png_set_write_fn(png_ptr, fmp, wpng_write, wpng_flush); + png_set_write_fn(png_ptr, fmp, zpng_write, zpng_flush); /* set compression */ png_set_compression_level(png_ptr, 9); /* Compression strategy can make a difference */ - compression_strategy = wpng_guess_compression_strategy(symbol, pixelbuf); + compression_strategy = zpng_guess_compression_strategy(symbol, pixelbuf); if (compression_strategy != Z_DEFAULT_STRATEGY) { png_set_compression_strategy(png_ptr, compression_strategy); } @@ -302,6 +296,12 @@ INTERNAL int zint_png_pixel_plot(struct zint_symbol *symbol, const unsigned char } /* write row contents to file */ png_write_row(png_ptr, outdata); + +#ifdef ZINT_TEST + if (symbol->debug & 4096) { /* ZINT_DEBUG_TEST_PNG_FLUSH */ + png_write_flush(png_ptr); + } +#endif } } @@ -312,7 +312,8 @@ INTERNAL int zint_png_pixel_plot(struct zint_symbol *symbol, const unsigned char png_destroy_write_struct(&png_ptr, &info_ptr); if (zint_fm_error(fmp)) { - ZEXT z_errtxtf(0, symbol, 638, "Incomplete write of PNG output (%1$d: %2$s)", fmp->err, strerror(fmp->err)); + (void) ZEXT z_errtxtf(0, symbol, 638, "Incomplete write of PNG output (%1$d: %2$s)", + fmp->err, strerror(fmp->err)); (void) zint_fm_close(fmp, symbol); return ZINT_ERROR_FILE_WRITE; } @@ -328,6 +329,6 @@ INTERNAL int zint_png_pixel_plot(struct zint_symbol *symbol, const unsigned char #else #if defined(__clang__) /* Suppresses clang-tidy-18 "clang-diagnostic-empty-translation-unit" */ -typedef int wpng_make_clang_tidy_compilers_happy; +typedef int zpng_make_clang_tidy_compilers_happy; #endif #endif /* ZINT_NO_PNG */ diff --git a/backend/ps.c b/backend/ps.c index b597f8bb..a850d3d7 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -422,30 +422,13 @@ INTERNAL int zint_ps_plot(struct zint_symbol *symbol) { previous_diameter = circle->diameter - circle->width; radius = 0.5f * previous_diameter; } - if (circle->colour) { /* Legacy - no longer used */ - /* A 'white' circle */ - if (is_rgb) { - ps_put_rgbcolor(red_paper, green_paper, blue_paper, fmp); - } else { - ps_put_cmykcolor(cyan_paper, magenta_paper, yellow_paper, black_paper, fmp); - } - ps_put_circle(symbol, circle, radius, 0 /*type*/, fmp); - if (circle->next) { - if (is_rgb) { - ps_put_rgbcolor(red_ink, green_ink, blue_ink, fmp); - } else { - ps_put_cmykcolor(cyan_ink, magenta_ink, yellow_ink, black_ink, fmp); - } - } + assert(circle->colour == 0); /* Legacy - no longer used */ + if (circle->next && circle->y == circle->next->y && circle->diameter == circle->next->diameter) { + ps_put_circle(symbol, circle, radius, type_latch ? 2 : 1, fmp); + type_latch = 1; } else { - /* A 'black' circle */ - if (circle->next && circle->y == circle->next->y && circle->diameter == circle->next->diameter) { - ps_put_circle(symbol, circle, radius, type_latch ? 2 : 1, fmp); - type_latch = 1; - } else { - ps_put_circle(symbol, circle, radius, type_latch ? 3 : 0, fmp); - type_latch = 0; - } + ps_put_circle(symbol, circle, radius, type_latch ? 3 : 0, fmp); + type_latch = 0; } } diff --git a/backend/qr.c b/backend/qr.c index 14e10257..7c75b408 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -2352,6 +2352,8 @@ INTERNAL int zint_upnqr(struct zint_symbol *symbol, unsigned char source[], int user_mask = 0; /* Ignore */ } + /* Can't be GS1_MODE as checked before being called */ + assert((symbol->input_mode & 0x07) == DATA_MODE || (symbol->input_mode & 0x07) == UNICODE_MODE); switch (symbol->input_mode & 0x07) { case DATA_MODE: /* Input is already in ISO-8859-2 format */ @@ -2360,10 +2362,6 @@ INTERNAL int zint_upnqr(struct zint_symbol *symbol, unsigned char source[], int modes[i] = 'B'; } break; - case GS1_MODE: /* Should never happen as checked before being called */ - return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 571, - "UPNQR does not support GS1 data"); /* Not reached */ - break; case UNICODE_MODE: error_number = zint_utf8_to_eci(4, source, preprocessed, &length); if (error_number != 0) { diff --git a/backend/raster.c b/backend/raster.c index f6e4c7f7..5ab86838 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -53,6 +53,54 @@ #define ZFONT_HALIGN_RIGHT 2 #define ZFONT_UPCEAN_TEXT 4 /* Helper flag to indicate dealing with EAN/UPC */ +#ifdef ZINT_TEST +/* For testing `malloc()` failure */ + +static int raster_fail_id = 0; /* RAST_FAIL_ID_XXX below */ +static int raster_fail_at = 0; /* Number of times before failure */ + +INTERNAL void zint_test_raster_set_fail(const int id, const int at) { + raster_fail_id = id; + raster_fail_at = at; +} + +/* TODO: add new "raster.h" & put these in it */ +#define RAST_FAIL_ID_BITMAP 1 +#define RAST_FAIL_ID_ALPHA 2 +#define RAST_FAIL_ID_ROTATED 3 +#define RAST_FAIL_ID_MC_PIXELBUF 4 +#define RAST_FAIL_ID_MC_HEXAGON 5 +#define RAST_FAIL_ID_DOTTY_SCALED 6 +#define RAST_FAIL_ID_PIXELBUF 7 +#define RAST_FAIL_ID_SCALED 8 + +#define rast_malloc(id, sz) (raster_fail_at > 0 && raster_fail_id == (id) && --raster_fail_at == 0 \ + ? NULL : malloc(sz)) + +#define raster_malloc_bitmap(sz, psz) raster_malloc(RAST_FAIL_ID_BITMAP, sz, psz) +#define raster_malloc_alpha(sz, psz) raster_malloc(RAST_FAIL_ID_ALPHA, sz, psz) +#define raster_malloc_rotated(sz, psz) raster_malloc(RAST_FAIL_ID_ROTATED, sz, psz) +#define raster_malloc_mc_pixelbuf(sz, psz) raster_malloc(RAST_FAIL_ID_MC_PIXELBUF, sz, psz) +#define raster_malloc_mc_hexagon(sz, psz) raster_malloc(RAST_FAIL_ID_MC_HEXAGON, sz, psz) +#define raster_malloc_dotty_scaled(sz, psz) raster_malloc(RAST_FAIL_ID_DOTTY_SCALED, sz, psz) +#define raster_malloc_pixelbuf(sz, psz) raster_malloc(RAST_FAIL_ID_PIXELBUF, sz, psz) +#define raster_malloc_scaled(sz, psz) raster_malloc(RAST_FAIL_ID_SCALED, sz, psz) + +#else + +#define rast_malloc(id, sz) malloc(sz) + +#define raster_malloc_bitmap(sz, psz) raster_malloc(sz, psz) +#define raster_malloc_alpha(sz, psz) raster_malloc(sz, psz) +#define raster_malloc_rotated(sz, psz) raster_malloc(sz, psz) +#define raster_malloc_mc_pixelbuf(sz, psz) raster_malloc(sz, psz) +#define raster_malloc_mc_hexagon(sz, psz) raster_malloc(sz, psz) +#define raster_malloc_dotty_scaled(sz, psz) raster_malloc(sz, psz) +#define raster_malloc_pixelbuf(sz, psz) raster_malloc(sz, psz) +#define raster_malloc_scaled(sz, psz) raster_malloc(sz, psz) + +#endif + #ifndef ZINT_NO_PNG INTERNAL int zint_png_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf); #endif /* ZINT_NO_PNG */ @@ -64,14 +112,18 @@ INTERNAL int zint_tif_pixel_plot(struct zint_symbol *symbol, const unsigned char static const char ultra_colour[] = "0CBMRYGKW"; /* Wrapper to pre-check `size` on `malloc()` isn't too big (`prev_size` given if doing 2nd `malloc()` in a row) */ +#ifdef ZINT_TEST +static void *raster_malloc(const int id, size_t size, size_t prev_size) { +#else static void *raster_malloc(size_t size, size_t prev_size) { +#endif /* Check for large image `malloc`s, which produce very large files most systems can't handle anyway */ /* Also `malloc()` on Linux will (usually) succeed regardless of request, and then get untrappably killed on access by OOM killer if too much, so this is a crude mitigation */ if (size + prev_size < size /*Overflow check*/ || size + prev_size > 0x40000000 /*1GB*/) { return NULL; } - return malloc(size); + return rast_malloc(id, size); } static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) { @@ -112,7 +164,7 @@ static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf symbol->alphamap = NULL; } - if (!(symbol->bitmap = (unsigned char *) raster_malloc(bm_bitmap_size, 0 /*prev_size*/))) { + if (!(symbol->bitmap = (unsigned char *) raster_malloc_bitmap(bm_bitmap_size, 0 /*prev_size*/))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 661, "Insufficient memory for bitmap buffer"); } #ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */ @@ -121,7 +173,7 @@ static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf if (plot_alpha) { const size_t alpha_size = (size_t) symbol->bitmap_width * symbol->bitmap_height; - if (!(symbol->alphamap = (unsigned char *) raster_malloc(alpha_size, bm_bitmap_size))) { + if (!(symbol->alphamap = (unsigned char *) raster_malloc_alpha(alpha_size, bm_bitmap_size))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 662, "Insufficient memory for alphamap buffer"); } for (row = 0; row < symbol->bitmap_height; row++) { @@ -182,7 +234,7 @@ static int save_raster_image_to_file(struct zint_symbol *symbol, const int image if (rotate_angle) { size_t image_size = (size_t) image_width * image_height; - if (!(rotated_pixbuf = (unsigned char *) raster_malloc((size_t) image_size, 0 /*prev_size*/))) { + if (!(rotated_pixbuf = (unsigned char *) raster_malloc_rotated((size_t) image_size, 0 /*prev_size*/))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 650, "Insufficient memory for pixel buffer"); } #ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */ @@ -799,13 +851,13 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, const int rotate_ang assert(image_width && image_height); image_size = (size_t) image_width * image_height; - if (!(pixelbuf = (unsigned char *) raster_malloc(image_size, 0 /*prev_size*/))) { + if (!(pixelbuf = (unsigned char *) raster_malloc_mc_pixelbuf(image_size, 0 /*prev_size*/))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 655, "Insufficient memory for pixel buffer"); } memset(pixelbuf, DEFAULT_PAPER, image_size); hex_size = (size_t) hex_width * hex_height; - if (!(scaled_hexagon = (unsigned char *) raster_malloc(hex_size, image_size))) { + if (!(scaled_hexagon = (unsigned char *) raster_malloc_mc_hexagon(hex_size, image_size))) { free(pixelbuf); return z_errtxt(ZINT_ERROR_MEMORY, symbol, 656, "Insufficient memory for pixel buffer"); } @@ -893,7 +945,7 @@ static int plot_raster_dotty(struct zint_symbol *symbol, const int rotate_angle, scale_size = (size_t) scale_width * scale_height; /* Apply scale options by creating pixel buffer */ - if (!(scaled_pixelbuf = (unsigned char *) raster_malloc(scale_size, 0 /*prev_size*/))) { + if (!(scaled_pixelbuf = (unsigned char *) raster_malloc_dotty_scaled(scale_size, 0 /*prev_size*/))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 657, "Insufficient memory for pixel buffer"); } memset(scaled_pixelbuf, DEFAULT_PAPER, scale_size); @@ -1068,7 +1120,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl assert(image_width && image_height); image_size = (size_t) image_width * image_height; - if (!(pixelbuf = (unsigned char *) raster_malloc(image_size, 0 /*prev_size*/))) { + if (!(pixelbuf = (unsigned char *) raster_malloc_pixelbuf(image_size, 0 /*prev_size*/))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 658, "Insufficient memory for pixel buffer"); } memset(pixelbuf, DEFAULT_PAPER, image_size); @@ -1407,7 +1459,8 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl const int scale_height = (int) z_stripf(image_height * scaler); /* Apply scale options by creating another pixel buffer */ - if (!(scaled_pixelbuf = (unsigned char *) raster_malloc((size_t) scale_width * scale_height, image_size))) { + if (!(scaled_pixelbuf = (unsigned char *) raster_malloc_scaled((size_t) scale_width * scale_height, + image_size))) { free(pixelbuf); return z_errtxt(ZINT_ERROR_MEMORY, symbol, 659, "Insufficient memory for scaled pixel buffer"); } diff --git a/backend/reedsol.c b/backend/reedsol.c index 8336444f..b5d85b47 100644 --- a/backend/reedsol.c +++ b/backend/reedsol.c @@ -58,6 +58,20 @@ #include "reedsol.h" #include "reedsol_logs.h" +#ifdef ZINT_TEST +/* For testing `calloc()` failure */ + +static int rs_fail_id = 0; /* RS_FAIL_ID_XXX */ + +INTERNAL void zint_test_rs_set_fail(const int id) { + rs_fail_id = id; +} + +#define rs_calloc(id, num, sz) (rs_fail_id == (id) ? NULL : calloc(num, sz)) +#else +#define rs_calloc(id, num, sz) calloc(num, sz) +#endif + /* 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 8 bits (see rs_uint_init_gf() @@ -258,10 +272,10 @@ INTERNAL int zint_rs_uint_init_gf(rs_uint_t *rs_uint, const unsigned int prime_p rs_uint->logt = NULL; rs_uint->alog = NULL; - if (!(logt = (unsigned short *) calloc(b, sizeof(unsigned short)))) { + if (!(logt = (unsigned short *) rs_calloc(RS_FAIL_ID_LOGT, b, sizeof(unsigned short)))) { return 0; } - if (!(alog = (unsigned short *) calloc(b * 2, sizeof(unsigned short)))) { + if (!(alog = (unsigned short *) rs_calloc(RS_FAIL_ID_ALOG, b * 2, sizeof(unsigned short)))) { free(logt); return 0; } diff --git a/backend/reedsol.h b/backend/reedsol.h index 07130215..c6a9ec53 100644 --- a/backend/reedsol.h +++ b/backend/reedsol.h @@ -71,6 +71,13 @@ INTERNAL void zint_rs_uint_encode(const rs_uint_t *rs_uint, const int datalen, c unsigned int *res); INTERNAL void zint_rs_uint_free(rs_uint_t *rs_uint); +#ifdef ZINT_TEST +/* For testing `calloc()` failure */ +#define RS_FAIL_ID_LOGT 1 +#define RS_FAIL_ID_ALOG 2 +INTERNAL void zint_test_rs_set_fail(const int id); +#endif + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/backend/rss.c b/backend/rss.c index 42b399ba..38ec2c54 100644 --- a/backend/rss.c +++ b/backend/rss.c @@ -69,34 +69,37 @@ #include "gs1.h" #include "rss.h" -/* `combins()' in ISO/IEC 24724:2011 Annex B */ +/* `combins()` in ISO/IEC 24724:2011 Annex B */ /**************************************************************************** * dbar_combins(n,r): returns the number of Combinations of r selected from n: * Combinations = n! / (n - r)! * r! ****************************************************************************/ static int dbar_combins(const int n, const int r) { - int i; - int maxDenom, minDenom; - int val = 1, j = 1; + /* Generated by "backend/tests/test_rss -f test_generate_combins -g" (which uses `combins()`) */ + static const short combins[18][6] = { + { 1, 1, 1, 1, 1, 1 }, /* 0 */ + { 1, 1, 1, 1, 1, 1 }, /* 1 */ + { 1, 2, 1, 1, 1, 1 }, /* 2 */ + { 1, 3, 3, 1, 1, 1 }, /* 3 */ + { 1, 4, 6, 4, 1, 1 }, /* 4 */ + { 1, 5, 10, 10, 5, 1 }, /* 5 */ + { 1, 6, 15, 20, 15, 6 }, /* 6 */ + { 1, 7, 21, 35, 35, 21 }, /* 7 */ + { 1, 8, 28, 56, 70, 56 }, /* 8 */ + { 1, 9, 36, 84, 126, 126 }, /* 9 */ + { 1, 10, 45, 120, 210, 252 }, /* 10 */ + { 1, 11, 55, 165, 330, 462 }, /* 11 */ + { 1, 12, 66, 220, 495, 792 }, /* 12 */ + { 1, 13, 78, 286, 715, 1287 }, /* 13 */ + { 1, 14, 91, 364, 1001, 2002 }, /* 14 */ + { 1, 15, 105, 455, 1365, 3003 }, /* 15 */ + { 1, 16, 120, 560, 1820, 4368 }, /* 16 */ + { 1, 17, 136, 680, 2380, 6188 } /* 17 */ + }; - if (n - r > r) { - minDenom = r; - maxDenom = n - r; - } else { - minDenom = n - r; - maxDenom = r; - } - for (i = n; i > maxDenom; i--) { - val *= i; - if (j <= minDenom) { - val /= j; - j++; - } - } - for (; j <= minDenom; j++) { - val /= j; - } - return val; + assert(n >= 0 && n < 18); /* Max 19 modules (DBAR_LTD) - 2 */ + assert(r >= 0 && r < 6); /* Max 7 elements (DBAR_LTD) - 2 */ + return combins[n][r]; } /* `getRSSwidths()' in ISO/IEC 24724:2011 Annex B, modified to use arg `widths` instead of static, @@ -280,7 +283,8 @@ static void dbar_omn_separator(struct zint_symbol *symbol, int width, const int } /* Set Databar Stacked height, maintaining 5:7 ratio of the 2 main row heights */ -INTERNAL int zint_dbar_omnstk_set_height(struct zint_symbol *symbol, const int first_row) { +INTERNAL int zint_dbar_stk_set_height(struct zint_symbol *symbol, const int first_row, const int no_errtxt) { + int error_number = 0; float fixed_height = 0.0f; const int second_row = first_row + 2; /* 2 row separator */ int i; @@ -297,12 +301,11 @@ INTERNAL int zint_dbar_omnstk_set_height(struct zint_symbol *symbol, const int f (symbol->row_height[first_row] + symbol->row_height[second_row])); if (symbol->row_height[first_row] < 0.5f) { /* Absolute minimum */ symbol->row_height[first_row] = 0.5f; - symbol->row_height[second_row] = 0.7f; + symbol->row_height[second_row] = 0.7f; /* 0.7f is actually 0.699999988 (0x3F333333) */ } else { symbol->row_height[second_row] = z_stripf(symbol->height - fixed_height - symbol->row_height[first_row]); - if (symbol->row_height[second_row] < 0.7f) { - symbol->row_height[second_row] = 0.7f; - } + /* (h - 1) * 5/12 >= 0.5 -> h - 1 >= 0.5 * 12/5 -> h >= 2.2 -> rh[sr] >= (2.2 - 1 - 0.5) -> rh[sr] >= 0.7 */ + assert(symbol->row_height[second_row] >= 0.7f); } } symbol->height = z_stripf(z_stripf(symbol->row_height[first_row] + symbol->row_height[second_row]) @@ -310,11 +313,14 @@ INTERNAL int zint_dbar_omnstk_set_height(struct zint_symbol *symbol, const int f if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->row_height[first_row] < 5.0f || symbol->row_height[second_row] < 7.0f) { - return z_errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 379, "Height not compliant with standards"); + error_number = ZINT_WARN_NONCOMPLIANT; + if (!no_errtxt) { + z_errtxt(0, symbol, 379, "Height not compliant with standards"); + } } } - return 0; + return error_number; } /* Return DataBar Omnidirectional group (outside -1, inside +5-1) */ @@ -523,8 +529,8 @@ INTERNAL int zint_dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[] symbol->width = 50; } - if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls `zint_dbar_omnstk_set_height()` itself */ - error_number = zint_dbar_omnstk_set_height(symbol, 0 /*first_row*/); + if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls `zint_dbar_stk_set_height()` itself */ + error_number = zint_dbar_stk_set_height(symbol, 0 /*first_row*/, 0 /*no_errtxt*/); } } else if (symbol->symbology == BARCODE_DBAR_OMNSTK || symbol->symbology == BARCODE_DBAR_OMNSTK_CC) { diff --git a/backend/svg.c b/backend/svg.c index d27c6024..157fd246 100644 --- a/backend/svg.c +++ b/backend/svg.c @@ -30,6 +30,7 @@ */ /* SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #include @@ -295,24 +296,14 @@ INTERNAL int zint_svg_plot(struct zint_symbol *symbol) { svg_put_fattrib(" cy=\"", 2, circle->y, fmp); svg_put_fattrib(" r=\"", circle->width ? 3 : 2, radius, fmp); - if (circle->colour) { /* Legacy - no longer used */ - if (circle->width) { - zint_fm_printf(fmp, " stroke=\"#%s\"", bgcolour_string); - svg_put_fattrib(" stroke-width=\"", 3, circle->width, fmp); - zint_fm_puts(" fill=\"none\"", fmp); - } else { - zint_fm_printf(fmp, " fill=\"#%s\"", bgcolour_string); - } - /* This doesn't work how the user is likely to expect - more work needed! */ - svg_put_opacity_close(bg_alpha, bg_alpha_opacity, 1 /*close*/, fmp); - } else { - if (circle->width) { - zint_fm_printf(fmp, " stroke=\"#%s\"", fgcolour_string); - svg_put_fattrib(" stroke-width=\"", 3, circle->width, fmp); - zint_fm_puts(" fill=\"none\"", fmp); - } - svg_put_opacity_close(fg_alpha, fg_alpha_opacity, 1 /*close*/, fmp); + assert(circle->colour == 0); /* Legacy - no longer used */ + if (circle->width) { + zint_fm_printf(fmp, " stroke=\"#%s\"", fgcolour_string); + svg_put_fattrib(" stroke-width=\"", 3, circle->width, fmp); + zint_fm_puts(" fill=\"none\"", fmp); } + /* This doesn't work how the user is likely to expect - more work needed! */ + svg_put_opacity_close(fg_alpha, fg_alpha_opacity, 1 /*close*/, fmp); circle = circle->next; } diff --git a/backend/tests/data/gif/ultra_box.gif b/backend/tests/data/gif/ultra_box.gif new file mode 100644 index 00000000..1dea957d Binary files /dev/null and b/backend/tests/data/gif/ultra_box.gif differ diff --git a/backend/tests/data/png/telepen_compliant_dpmm_300dpi.png b/backend/tests/data/png/telepen_compliant_dpmm_300dpi.png new file mode 100644 index 00000000..0ac0ef1d Binary files /dev/null and b/backend/tests/data/png/telepen_compliant_dpmm_300dpi.png differ diff --git a/backend/tests/data/tif/code32_dpmm_200dpi.tif b/backend/tests/data/tif/code32_dpmm_200dpi.tif new file mode 100644 index 00000000..bd4b8eab Binary files /dev/null and b/backend/tests/data/tif/code32_dpmm_200dpi.tif differ diff --git a/backend/tests/test_aztec.c b/backend/tests/test_aztec.c index 4ade8c30..36256eff 100644 --- a/backend/tests/test_aztec.c +++ b/backend/tests/test_aztec.c @@ -341,9 +341,7 @@ static void test_bs(const testCtx *const p_ctx) { testFinish(); } -static void test_many_states(const testCtx *const p_ctx) { - int debug = p_ctx->debug; - +static const char *test_many_states_data(char *buf, const int length) { static char modes_buf[6][6] = { { 'A', 'B', ' ', 'C', 'D', 'E' }, /* AZ_U */ { 'a', ' ', 'b', 'c', 'd', 'e' }, /* AZ_L */ @@ -352,21 +350,7 @@ static void test_many_states(const testCtx *const p_ctx) { { '1', ',', ' ', '2', '3', ',' }, /* AZ_D */ { 'A', '*', '\016', '2', '1', '0' }, /* Single AZ_B () amongst non-AZ_B */ }; - - int i, j, k, ret; - struct zint_symbol *symbol = NULL; - - const int length = 3191; - char buf[3191]; - - char escaped[9216]; - char cmp_buf[32768]; - char cmp_msg[1024]; - - /* Only do zxing-cpp test if asked, too slow otherwise */ - int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); - - testStartSymbol(p_ctx->func_name, &symbol); + int i, j, k; for (i = 0; i < length; i += 36) { for (j = 0; j < 6; j++) { @@ -381,6 +365,28 @@ static void test_many_states(const testCtx *const p_ctx) { break; } } + return buf; +} + +static void test_many_states(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + int ret; + struct zint_symbol *symbol = NULL; + + const int length = 3191; + char buf[3191]; + + char escaped[9216]; + char cmp_buf[32768]; + char cmp_msg[1024]; + + /* Only do zxing-cpp test if asked, too slow otherwise */ + int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); + + testStartSymbol(p_ctx->func_name, &symbol); + + (void) test_many_states_data(buf, length); symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -392,21 +398,19 @@ static void test_many_states(const testCtx *const p_ctx) { ret = ZBarcode_Encode(symbol, TCU(buf), length); assert_nonzero(ret < ZINT_ERROR, "ZBarcode_Encode(%d) ret %d >= ZINT_ERROR (%s)\n", length, ret, symbol->errtxt); - if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, buf, length, debug)) { + if (do_zxingcpp && testUtilCanZXingCPP(0, symbol, buf, length, debug)) { int cmp_len, ret_len; char modules_dump[22801 + 1]; assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), - -1, "i:%d testUtilModulesDump == -1\n", i); - ret = testUtilZXingCPP(i, symbol, buf, length, modules_dump, 3 /*zxingcpp_cmp*/, + -1, "testUtilModulesDump == -1\n"); + ret = testUtilZXingCPP(0, symbol, buf, length, modules_dump, 3 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len); - assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", - i, testUtilBarcodeName(symbol->symbology), ret); + assert_zero(ret, "%s testUtilZXingCPP ret %d != 0\n", testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, buf, length, NULL /*primary*/, escaped, &ret_len); - assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", - i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, - escaped); + assert_zero(ret, "%s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", + testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); } ZBarcode_Delete(symbol); @@ -9933,6 +9937,84 @@ static void test_fuzz(const testCtx *const p_ctx) { testFinish(); } +INTERNAL void zint_test_az_set_fail(const int id, const int at); + +/* TODO: put these & above def in "aztec.h" (& rename existing "aztec.h" to "aztec_tabs.h" */ +#define AZ_FAIL_ID_LIST_INIT 1 +#define AZ_FAIL_ID_CPY 2 +#define AZ_FAIL_ID_ADD_CHK 3 +#define AZ_FAIL_ID_LIST_ADD_CHK 4 + +static void test_alloc(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int output_options; + const char *data; + int length; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_MEMORY_FILE, "Aa345", -1, ZINT_ERROR_MEMORY, { 1, 2, 3, 0, 0 }, 3, AZ_FAIL_ID_LIST_INIT }, + /* 1*/ { BARCODE_MEMORY_FILE, "\015\012. , : ", -1, ZINT_ERROR_MEMORY, { 1, 2, 3, 0, 0 }, 3, AZ_FAIL_ID_LIST_INIT }, + /* 2*/ { BARCODE_MEMORY_FILE, "Aa345", -1, ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0 }, 1, AZ_FAIL_ID_CPY }, + /* 3*/ { BARCODE_MEMORY_FILE, "ABC\241", -1, ZINT_ERROR_MEMORY, { 5, 0, 0, 0, 0 }, 1, AZ_FAIL_ID_CPY }, + /* 4*/ { BARCODE_MEMORY_FILE, "\241\015\012", -1, ZINT_ERROR_MEMORY, { 4, 0, 0, 0, 0 }, 1, AZ_FAIL_ID_CPY }, + /* 5*/ { BARCODE_MEMORY_FILE, NULL, 32, ZINT_ERROR_MEMORY, { 7, 42, 95, 96, 0 }, 4, AZ_FAIL_ID_CPY }, + /* 6*/ { BARCODE_MEMORY_FILE, NULL, 32, ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0 }, 1, AZ_FAIL_ID_ADD_CHK }, + /* 7*/ { BARCODE_MEMORY_FILE, "Code 2D!", -1, ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0 }, 1, AZ_FAIL_ID_LIST_ADD_CHK }, + /* 8*/ { BARCODE_MEMORY_FILE, "+/EO5232013", -1, ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0 }, 1, AZ_FAIL_ID_LIST_ADD_CHK }, + /* 9*/ { BARCODE_MEMORY_FILE, "+/KN12345A", -1, ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0 }, 1, AZ_FAIL_ID_LIST_ADD_CHK }, + /* 10*/ { BARCODE_MEMORY_FILE, ", . , ", -1, ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0 }, 1, AZ_FAIL_ID_LIST_ADD_CHK }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + char buf[3191]; + const char *text; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + if (data[i].data) { + text = data[i].data; + } else { + assert_nonzero(data[i].length > 0, "i:%d data length %d <= 0\n", i, data[i].length); + assert_nonzero(data[i].length <= ARRAY_SIZE(buf), "i:%d data length %d > buf %d\n", + i, data[i].length, ARRAY_SIZE(buf)); + text = test_many_states_data(buf, data[i].length); + } + length = testUtilSetSymbol(symbol, BARCODE_AZTEC, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + text, data[i].length, debug); + zint_test_az_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_az_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ @@ -9945,6 +10027,7 @@ int main(int argc, char *argv[]) { { "test_ct", test_ct }, { "test_ct_segs", test_ct_segs }, { "test_fuzz", test_fuzz }, + { "test_alloc", test_alloc }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_bmp.c b/backend/tests/test_bmp.c index 1279d022..3c9a0cdc 100644 --- a/backend/tests/test_bmp.c +++ b/backend/tests/test_bmp.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2025 Robin Stuart + Copyright (C) 2020-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -101,7 +101,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) { symbol->bitmap = (unsigned char *) data_buf; - ret = zint_bmp_pixel_plot(symbol, TCU(data_buf)); + ret = zint_bmp_pixel_plot(symbol, ZCUCP(data_buf)); assert_equal(ret, data[i].ret, "i:%d zint_bmp_pixel_plot ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); @@ -201,7 +201,7 @@ static void test_print(const testCtx *const p_ctx) { strcpy(symbol->bgcolour, data[i].bgcolour); } - ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); + ret = ZBarcode_Encode(symbol, ZCUCP(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); @@ -307,12 +307,72 @@ static void test_outfile(const testCtx *const p_ctx) { testFinish(); } +#include "filemem.h" + +static void test_fm(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_ACCESS, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_OPEN }, + /* 1*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 5, 11, 0, 0, 0 }, 2, FM_FAIL_ID_WRITE }, + /* 2*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + /* 3*/ { BARCODE_DATAMATRIX, BARCODE_STDOUT, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.bmp"); + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ { "test_pixel_plot", test_pixel_plot }, { "test_print", test_print }, { "test_outfile", test_outfile }, + { "test_fm", test_fm }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_code1.c b/backend/tests/test_code1.c index 8b24a16b..414f44e5 100644 --- a/backend/tests/test_code1.c +++ b/backend/tests/test_code1.c @@ -210,21 +210,29 @@ static void test_large(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length); - assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf)); + assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", + i, data[i].length, (int) strlen(data_buf)); - length = testUtilSetSymbol(symbol, BARCODE_CODEONE, -1 /*input_mode*/, data[i].eci, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug); + length = testUtilSetSymbol(symbol, BARCODE_CODEONE, -1 /*input_mode*/, data[i].eci, + -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, + data_buf, data[i].length, debug); if (data[i].structapp.count) { symbol->structapp = data[i].structapp; } ret = ZBarcode_Encode(symbol, TCU(data_buf), length); - 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); - assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); + 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", + i, ret ? "set" : "empty", symbol->errtxt); + assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", + i, symbol->errtxt, data[i].expected_errtxt); if (ret < ZINT_ERROR) { - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", + i, symbol->rows, data[i].expected_rows); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", + i, symbol->width, data[i].expected_width); } ZBarcode_Delete(symbol); @@ -312,15 +320,19 @@ static void test_input(const testCtx *const p_ctx) { } ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (ret < ZINT_ERROR) { - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", + i, symbol->rows, data[i].expected_rows); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", + i, symbol->width, data[i].expected_width); } - assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt); + assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", + i, symbol->errtxt, data[i].expected_errtxt); assert_equal(symbol->option_2, data[i].expected_option_2, "i:%d symbol->option_2 %d != %d\n", - i, symbol->option_2, data[i].expected_option_2); + i, symbol->option_2, data[i].expected_option_2); ZBarcode_Delete(symbol); } @@ -2900,7 +2912,8 @@ static void test_encode(const testCtx *const p_ctx) { char bwipp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT; char bwipp_msg[1024]; - int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ + /* Only do BWIPP test if asked, too slow otherwise */ + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); testStartSymbol(p_ctx->func_name, &symbol); @@ -2911,13 +2924,16 @@ static void test_encode(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, BARCODE_CODEONE, data[i].input_mode, data[i].eci, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); + length = testUtilSetSymbol(symbol, BARCODE_CODEONE, data[i].input_mode, data[i].eci, + -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, + data[i].data, data[i].length, debug); if (data[i].structapp.count) { symbol->structapp = data[i].structapp; } ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, %s, %d, %d, %d, \"%s\",\n", @@ -2936,9 +2952,11 @@ static void test_encode(const testCtx *const p_ctx) { int width, row; assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", - i, symbol->rows, data[i].expected_rows, testUtilEscape(data[i].data, length, escaped, sizeof(escaped))); + i, symbol->rows, data[i].expected_rows, testUtilEscape(data[i].data, length, + escaped, sizeof(escaped))); assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", - i, symbol->width, data[i].expected_width, testUtilEscape(data[i].data, length, escaped, sizeof(escaped))); + i, symbol->width, data[i].expected_width, testUtilEscape(data[i].data, length, + escaped, sizeof(escaped))); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", @@ -2946,14 +2964,20 @@ static void test_encode(const testCtx *const p_ctx) { if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { 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); + 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), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, + bwipp_buf, sizeof(bwipp_buf), NULL); + 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); + i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, + data[i].expected); } } } @@ -3067,7 +3091,7 @@ static void test_encode_segs(const testCtx *const p_ctx) { "0010011101100011101011" "0011010111000001111101" }, - /* 4*/ { UNICODE_MODE, -1, { 0, 0, "" }, { { TU("product:Google Pixel 4a - 128 GB of Storage - Black;price:$439.97"), -1, 3 }, { TU("品名:Google 谷歌 Pixel 4a -128 GB的存储空间-黑色;零售价:¥3149.79"), -1, 29 }, { TU("Produkt:Google Pixel 4a - 128 GB Speicher - Schwarz;Preis:444,90 €"), -1, 17 } }, 0, 70, 76, 0, "AIM ITS/04-023:2022 Annex A example; BWIPP different encodation", + /* 4*/ { UNICODE_MODE, -1, { 0, 0, "" }, { { TU("product:Google Pixel 4a - 128 GB of Storage - Black;price:$439.97"), -1, 3 }, { TU("品名:Google 谷歌 Pixel 4a -128 GB的存储空间-黑色;零售价:¥3149.79"), -1, 29 }, { TU("Produkt:Google Pixel 4a - 128 GB Speicher - Schwarz;Preis:444,90 €"), -1, 17 } }, 0, 70, 76, 1, "AIM ITS/04-023:2022 Annex A example", "1000110101010110001000100011111010110011011010101111000111000010111011110011" "0001101101110100100010010110111110100101111100011011101000110101010010101010" "0111101111011010010111011010001100110000001000101000110001000100001101101011" @@ -3088,8 +3112,8 @@ static void test_encode_segs(const testCtx *const p_ctx) { "0010101000101100001101000010101100110001111110111011000001011110101011101110" "0010100110000010010000111110011101011000000101111001010000001000001000101000" "0111100100110110111100101110101110111100011001011011001000010011111001101000" - "1110101100110101100110110010101011000011111110101000110010110100101110100010" - "1111100111101001000001010010011110001000111111101001011101110000011011100101" + "1110101100110101100110110010101011000011001101001011110010110100101110100010" + "1111100111101001000001010010011110001000001110011011111101110000011011100101" "1000101000100010001000100010100010001000100010001010001000100010001000101000" "0001100001000100010001000110000100010001000100011000010001000100010001100001" "1000111000100010001000100011100010001000100010001110001000100010001000111000" @@ -3120,24 +3144,24 @@ static void test_encode_segs(const testCtx *const p_ctx) { "0001100001000100010001000110000100010001000100011000010001000100010001100001" "1000101000100010001000100010100010001000100010001010001000100010001000101000" "0001100001000100010001000110000100010001000100011000010001000100010001100001" - "1000101000100010001000100010100010001000100010001010001000111001101111100110" - "0001100001000100010001000110000100010001000100011000010001000110100010100101" - "0101101000101000110010110110001110100100110101001000001100000010011101100010" - "0100101100111011100101111110111100100011111000111010110101000110001000100111" - "1011100010000010011110111110111011110111001100111000101011101100001101100001" - "0011111101010101000010110011010000101111001101011101101100000011001101111110" - "1001101110000000010100100110001000011000010000001001100010100101011001100000" - "1010100110110100010001001110110010011100001101001000000010100010111111100101" - "0001101110111011011001101110001100010010110101111000101011101001111000100000" - "0100100011110110101101100110010110110100101011001011011000011001000111100011" - "1010101111011001001000100110010011010011110100101010010111000101001001100110" - "1011100010101101111110010010001011100010010101111001001111010100011111100001" - "0110101001011011001101100110110001100100010000101011010010101001110100100110" - "1101101000100011101100101110100110011111100111111001010100100101111101100010" - "1100100010111011001011100010100100011110001000101011000010100011101011101111" - "1110100101000010010101100010010111010111001110011010010101111110100000100011" - "0110101011010011001101110110100011011101001011011001000100000001110011101110" - "1110110001111000110010010111100110011010101100011101011011100000011001110111" + "1000101000100010001000100010100010001000100010001010001000100110100101100110" + "0001100001000100010001000110000100010001000100011000010001110000010011100011" + "1101101010000000001001111110001110011010000010011011010011010110100110100010" + "1110101001001000011011100010011100110011111110011001101000011000110100101000" + "1000100011010000100011101010010011000100100101001010010111110100101111100001" + "1001110010011100001000011111010001001110011100011101011111011010100111110011" + "1011101100011011000000111110001100011011010011011010111100101001011101101100" + "0110101010111111010011110010100101011101010001111010100011100110000010100011" + "1011101110101111001011100110101000100111000011101000100011010101011101100100" + "1111100101001011101100011010111010100001100011111010100100101010010010101101" + "0100101001010011010000101110001011000110110101011011111001100101101101101101" + "0100100110101001111001111010101011000001001101111010000111011101101110100111" + "1100100010101000010111000010101101110000101011101001001101100011000010101010" + "1000100000001010100111010010110010100010000111101010101101111110110111101001" + "0010100111101101100111110010101101110001111111101000111110010010111000101110" + "0101100000110000001001101010111011100101011011001001100111011001111100100110" + "1111101011000100111100011110001101010100000011101000110000100111110000101110" + "1010111010101010000111011111100011000000001000111101000110011101001110111101" }, /* 5*/ { UNICODE_MODE, -1, { 0, 0, "" }, { { TU("price:$439.97"), -1, 3 }, { TU("零售价:¥3149.79"), -1, 29 }, { TU("Preis:444,90 €"), -1, 17 } }, 0, 40, 42, 1, "AIM ITS/04-023:2022 Annex A example price only", "100011010101011000101100100001110111110110" @@ -3289,7 +3313,8 @@ static void test_encode_segs(const testCtx *const p_ctx) { char bwipp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT; char bwipp_msg[1024]; - int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ + /* Only do BWIPP test if asked, too slow otherwise */ + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); testStartSymbol(p_ctx->func_name, &symbol); @@ -3309,20 +3334,28 @@ static void test_encode_segs(const testCtx *const p_ctx) { for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++); ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { char escaped1[4096]; char escaped2[4096]; - int length = data[i].segs[0].length == -1 ? (int) z_ustrlen(data[i].segs[0].source) : data[i].segs[0].length; - int length1 = data[i].segs[1].length == -1 ? (int) z_ustrlen(data[i].segs[1].source) : data[i].segs[1].length; - int length2 = data[i].segs[2].length == -1 ? (int) z_ustrlen(data[i].segs[2].source) : data[i].segs[2].length; - printf(" /*%3d*/ { %s, %d, { %d, %d, \"%s\" }, { { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d } }, %s, %d, %d, %d, \"%s\",\n", + int length = data[i].segs[0].length == -1 + ? (int) z_ustrlen(data[i].segs[0].source) : data[i].segs[0].length; + int length1 = data[i].segs[1].length == -1 + ? (int) z_ustrlen(data[i].segs[1].source) : data[i].segs[1].length; + int length2 = data[i].segs[2].length == -1 + ? (int) z_ustrlen(data[i].segs[2].source) : data[i].segs[2].length; + printf(" /*%3d*/ { %s, %d, { %d, %d, \"%s\" }, { { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d }," + " { TU(\"%s\"), %d, %d } }, %s, %d, %d, %d, \"%s\",\n", i, testUtilInputModeName(data[i].input_mode), data[i].option_2, data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, - testUtilEscape((const char *) data[i].segs[0].source, length, escaped, sizeof(escaped)), data[i].segs[0].length, data[i].segs[0].eci, - testUtilEscape((const char *) data[i].segs[1].source, length1, escaped1, sizeof(escaped1)), data[i].segs[1].length, data[i].segs[1].eci, - testUtilEscape((const char *) data[i].segs[2].source, length2, escaped2, sizeof(escaped2)), data[i].segs[2].length, data[i].segs[2].eci, + testUtilEscape((const char *) data[i].segs[0].source, length, escaped, sizeof(escaped)), + data[i].segs[0].length, data[i].segs[0].eci, + testUtilEscape((const char *) data[i].segs[1].source, length1, escaped1, sizeof(escaped1)), + data[i].segs[1].length, data[i].segs[1].eci, + testUtilEscape((const char *) data[i].segs[2].source, length2, escaped2, sizeof(escaped2)), + data[i].segs[2].length, data[i].segs[2].eci, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); if (ret < ZINT_ERROR) { testUtilModulesPrint(symbol, " ", "\n"); @@ -3335,24 +3368,30 @@ static void test_encode_segs(const testCtx *const p_ctx) { int width, row; assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", - i, symbol->rows, data[i].expected_rows); + i, symbol->rows, data[i].expected_rows); assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", - i, symbol->width, data[i].expected_width); + i, symbol->width, data[i].expected_width); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", - i, ret, width, row); + i, ret, width, row); if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { 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); + if (debug & ZINT_DEBUG_TEST_PRINT) { + printf("i:%d %s not BWIPP compatible (%s)\n", + i, testUtilBarcodeName(symbol->symbology), data[i].comment); + } } else { - ret = testUtilBwippSegs(i, symbol, -1, data[i].option_2, -1, data[i].segs, seg_count, NULL, bwipp_buf, sizeof(bwipp_buf)); - assert_zero(ret, "i:%d %s testUtilBwippSegs ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + ret = testUtilBwippSegs(i, symbol, -1, data[i].option_2, -1, data[i].segs, seg_count, NULL, + bwipp_buf, sizeof(bwipp_buf)); + assert_zero(ret, "i:%d %s testUtilBwippSegs 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); + i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, + data[i].expected); } } } @@ -3430,13 +3469,13 @@ static void test_rt(const testCtx *const p_ctx) { if (ret < ZINT_ERROR) { assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", - i, symbol->eci, data[i].expected_eci); + i, symbol->eci, data[i].expected_eci); if (symbol->output_options & BARCODE_CONTENT_SEGS) { assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i); assert_nonnull(symbol->content_segs[0].source, "i:%d content_segs[0].source NULL\n", i); assert_equal(symbol->content_segs[0].length, expected_length, - "i:%d content_segs[0].length %d != expected_length %d\n", - i, symbol->content_segs[0].length, expected_length); + "i:%d content_segs[0].length %d != expected_length %d\n", + i, symbol->content_segs[0].length, expected_length); assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length), "i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i, testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length, @@ -3517,8 +3556,9 @@ static void test_rt_segs(const testCtx *const p_ctx) { assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); - assert_equal(symbol->content_seg_count, data[i].expected_content_seg_count, "i:%d symbol->content_seg_count %d != %d\n", - i, symbol->content_seg_count, data[i].expected_content_seg_count); + assert_equal(symbol->content_seg_count, data[i].expected_content_seg_count, + "i:%d symbol->content_seg_count %d != %d\n", + i, symbol->content_seg_count, data[i].expected_content_seg_count); if (symbol->output_options & BARCODE_CONTENT_SEGS) { assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i); for (j = 0; j < symbol->content_seg_count; j++) { @@ -3529,7 +3569,8 @@ static void test_rt_segs(const testCtx *const p_ctx) { assert_equal(symbol->content_segs[j].length, expected_length, "i:%d content_segs[%d].length %d != expected_length %d\n", i, j, symbol->content_segs[j].length, expected_length); - assert_zero(memcmp(symbol->content_segs[j].source, data[i].expected_content_segs[j].source, expected_length), + assert_zero(memcmp(symbol->content_segs[j].source, data[i].expected_content_segs[j].source, + expected_length), "i:%d content_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, j, testUtilEscape((const char *) symbol->content_segs[j].source, expected_length, escaped, sizeof(escaped)), @@ -3565,7 +3606,7 @@ static void test_fuzz(const testCtx *const p_ctx) { static const struct item data[] = { /* 0*/ { -1, "3333P33B\035333V3333333333333\0363", -1, 0, 1, "" }, /* #181 Nico Gunkel, OSS-Fuzz */ /* 1*/ { -1, "{{-06\024755712162106130000000829203983\377", -1, 0, 1, "" }, /* #232 Jan Schrewe, CI-Fuzz, out-of-bounds in is_last_single_ascii() sp + 1 */ - /* 2*/ { -1, "\000\000\000\367\000\000\000\000\000\103\040\000\000\244\137\140\140\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\165\060\060\060\060\061\060\060\114\114\060\010\102\102\102\102\102\102\102\102\057\102\100\102\057\233\100\102", 60, 0, 1, "" }, /* #300 (#4) Andre Maute (`c1_c40text_cnt()` not accounting for extended ASCII shifts) */ + /* 2*/ { -1, "\000\000\000\367\000\000\000\000\000\103\040\000\000\244\137\140\140\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\165\060\060\060\060\061\060\060\114\114\060\010\102\102\102\102\102\102\102\102\057\102\100\102\057\233\100\102", 60, 0, 0, "" }, /* #300 (#4) Andre Maute (`c1_c40text_cnt()` not accounting for extended ASCII shifts); BWIPP: different encodation (does not switch at end to C40, same no. of codewords) */ /* 3*/ { 10, "\153\153\153\060\001\000\134\153\153\015\015\353\362\015\015\015\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\015\015\015\015\015\015\015\015\015\015\015\015\015\015\015\362\362\000", 65, ZINT_ERROR_TOO_LONG, 1, "" }, /* #300 (#8) Andre Maute (`c1_encode()` looping on latch) */ /* 4*/ { 10, "\015\015\353\362\015\015\015\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\015\015\015\015\015\015\015\015\015\015\015\015\015\015\015\362\362\000", 39, 0, 1, "" }, /* #300 (#8 shortened) Andre Maute */ /* 5*/ { 10, "\153\153\153\153\153\060\001\000\000\134\153\153\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\153\153\153\153\153\153\043\000\000\307\000\147\000\000\000\043\113\153\162\162\215\220", 90, ZINT_ERROR_TOO_LONG, 1, "" }, /* #300 (#12) Andre Maute (too small buffer for Version T) */ @@ -3577,7 +3618,8 @@ static void test_fuzz(const testCtx *const p_ctx) { char bwipp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT; char bwipp_msg[1024]; - int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ + /* Only do BWIPP test if asked, too slow otherwise */ + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); testStartSymbol(p_ctx->func_name, &symbol); @@ -3588,24 +3630,34 @@ static void test_fuzz(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, BARCODE_CODEONE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); + length = testUtilSetSymbol(symbol, BARCODE_CODEONE, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, + data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (ret < ZINT_ERROR) { if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { 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); + if (debug & ZINT_DEBUG_TEST_PRINT) { + printf("i:%d %s not BWIPP compatible (%s)\n", + i, testUtilBarcodeName(symbol->symbology), data[i].comment); + } } else { char modules_dump[4096]; - assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); - ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, + "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, + sizeof(bwipp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, modules_dump); 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, modules_dump); + i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, + modules_dump); } } } diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index da1f3a56..b71b4034 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -1346,6 +1346,7 @@ static void test_upu_s10_input(const testCtx *const p_ctx) { int debug = p_ctx->debug; struct item { + int output_options; const char *data; int ret; int expected_width; @@ -1353,36 +1354,37 @@ static void test_upu_s10_input(const testCtx *const p_ctx) { const char *comment; }; static const struct item data[] = { - /* 0*/ { "AB123456789ABC", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 14 wrong (12 or 13 characters required)", "" }, - /* 1*/ { "AB1234567AB", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 11 wrong (12 or 13 characters required)", "" }, - /* 2*/ { "1B123456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indicator (first 2 characters) (alphabetic only)", "" }, - /* 3*/ { "1B12345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indicator (first 2 characters) (alphabetic only)", "" }, - /* 4*/ { "A2123456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indicator (first 2 characters) (alphabetic only)", "" }, - /* 5*/ { "A212345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indicator (first 2 characters) (alphabetic only)", "" }, - /* 6*/ { "ABX23456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 9 characters) (digits only)", "" }, - /* 7*/ { "AB12345678XAB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 9 characters) (digits only)", "" }, - /* 8*/ { "ABX2345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 8 characters) (digits only)", "" }, - /* 9*/ { "AB1234567XAB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 8 characters) (digits only)", "" }, - /* 10*/ { "AB1234567891B", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, - /* 11*/ { "AB123456781B", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, - /* 12*/ { "AB123456789A2", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, - /* 13*/ { "AB12345678A2", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, - /* 14*/ { "AB123456789AB", ZINT_ERROR_INVALID_CHECK, 0, "Error 838: Invalid check digit '9', expecting '5'", "" }, - /* 15*/ { "JB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'JB' (first character should not be any of \"JKSTW\")", "" }, - /* 16*/ { "KB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'KB' (first character should not be any of \"JKSTW\")", "" }, - /* 17*/ { "LB123456785AD", 0, 156, "", "" }, - /* 18*/ { "SB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'SB' (first character should not be any of \"JKSTW\")", "" }, - /* 19*/ { "TB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'TB' (first character should not be any of \"JKSTW\")", "" }, - /* 20*/ { "WB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'WB' (first character should not be any of \"JKSTW\")", "" }, - /* 21*/ { "FB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'FB' (first 2 characters)", "" }, - /* 22*/ { "HB123456785AD", 0, 156, "", "" }, - /* 23*/ { "IB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'IB' (first 2 characters)", "" }, - /* 24*/ { "OB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'OB' (first 2 characters)", "" }, - /* 25*/ { "XB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'XB' (first 2 characters)", "" }, - /* 26*/ { "YB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'YB' (first 2 characters)", "" }, - /* 27*/ { "AB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 841: Country Code 'AB' (last two characters) is not ISO 3166-1", "" }, - /* 28*/ { "AB123100000IE", 0, 156, "", "Check digit 10 -> 0" }, - /* 29*/ { "AB000000005IE", 0, 156, "", "Check digit 11 -> 5" }, + /* 0*/ { -1, "AB123456789ABC", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 14 wrong (12 or 13 characters required)", "" }, + /* 1*/ { -1, "AB1234567AB", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 11 wrong (12 or 13 characters required)", "" }, + /* 2*/ { -1, "1B123456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indicator (first 2 characters) (alphabetic only)", "" }, + /* 3*/ { -1, "1B12345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indicator (first 2 characters) (alphabetic only)", "" }, + /* 4*/ { -1, "A2123456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indicator (first 2 characters) (alphabetic only)", "" }, + /* 5*/ { -1, "A212345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indicator (first 2 characters) (alphabetic only)", "" }, + /* 6*/ { -1, "ABX23456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 9 characters) (digits only)", "" }, + /* 7*/ { -1, "AB12345678XAB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 9 characters) (digits only)", "" }, + /* 8*/ { -1, "ABX2345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 8 characters) (digits only)", "" }, + /* 9*/ { -1, "AB1234567XAB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 8 characters) (digits only)", "" }, + /* 10*/ { -1, "AB1234567891B", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, + /* 11*/ { -1, "AB123456781B", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, + /* 12*/ { -1, "AB123456789A2", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, + /* 13*/ { -1, "AB12345678A2", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, + /* 14*/ { -1, "AB123456789AB", ZINT_ERROR_INVALID_CHECK, 0, "Error 838: Invalid check digit '9', expecting '5'", "" }, + /* 15*/ { -1, "JB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'JB' (first character should not be any of \"JKSTW\")", "" }, + /* 16*/ { -1, "KB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'KB' (first character should not be any of \"JKSTW\")", "" }, + /* 17*/ { -1, "LB123456785AD", 0, 156, "", "" }, + /* 18*/ { -1, "SB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'SB' (first character should not be any of \"JKSTW\")", "" }, + /* 19*/ { -1, "TB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'TB' (first character should not be any of \"JKSTW\")", "" }, + /* 20*/ { -1, "WB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator 'WB' (first character should not be any of \"JKSTW\")", "" }, + /* 21*/ { -1, "FB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'FB' (first 2 characters)", "" }, + /* 22*/ { -1, "HB123456785AD", 0, 156, "", "" }, + /* 23*/ { -1, "IB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'IB' (first 2 characters)", "" }, + /* 24*/ { -1, "OB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'OB' (first 2 characters)", "" }, + /* 25*/ { -1, "XB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'XB' (first 2 characters)", "" }, + /* 26*/ { -1, "YB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator 'YB' (first 2 characters)", "" }, + /* 27*/ { -1, "AB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 841: Country Code 'AB' (last two characters) is not ISO 3166-1", "" }, + /* 28*/ { COMPLIANT_HEIGHT, "AB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 841: Country Code 'AB' (last two characters) is not ISO 3166-1", "" }, + /* 29*/ { -1, "AB123100000IE", 0, 156, "", "Check digit 10 -> 0" }, + /* 30*/ { -1, "AB000000005IE", 0, 156, "", "Check digit 11 -> 5" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -1408,15 +1410,16 @@ static void test_upu_s10_input(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, BARCODE_UPU_S10, UNICODE_MODE, -1 /*eci*/, - -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { - printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n", - i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), + printf(" /*%3d*/ { %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n", + i, testUtilOutputOptionsName(data[i].output_options), + testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->width, testUtilEscape(symbol->errtxt, (int) strlen(symbol->errtxt), escaped2, sizeof(escaped2)), data[i].comment); } else { diff --git a/backend/tests/test_code16k.c b/backend/tests/test_code16k.c index 6be6affb..964f2698 100644 --- a/backend/tests/test_code16k.c +++ b/backend/tests/test_code16k.c @@ -72,18 +72,26 @@ static void test_large(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length); - assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf)); + assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", + i, data[i].length, (int) strlen(data_buf)); - length = testUtilSetSymbol(symbol, BARCODE_CODE16K, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug); + length = testUtilSetSymbol(symbol, BARCODE_CODE16K, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1, -1, -1 /*output_options*/, + data_buf, data[i].length, debug); ret = ZBarcode_Encode(symbol, TCU(data_buf), length); - 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); - assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); + 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", + i, ret ? "set" : "empty", symbol->errtxt); + assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", + i, symbol->errtxt, data[i].expected_errtxt); if (ret < ZINT_ERROR) { - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", + i, symbol->rows, data[i].expected_rows); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", + i, symbol->width, data[i].expected_width); } ZBarcode_Delete(symbol); @@ -128,10 +136,13 @@ static void test_reader_init(const testCtx *const p_ctx) { symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ - length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, data[i].output_options, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1, data[i].output_options, + data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n", @@ -139,10 +150,13 @@ static void test_reader_init(const testCtx *const p_ctx) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); + assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", + i, symbol->errtxt, data[i].expected); if (ret < ZINT_ERROR) { - 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); + 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); } } @@ -230,7 +244,9 @@ static void test_input(const testCtx *const p_ctx) { /* 45*/ { UNICODE_MODE, -1, -1, 0, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 12, 70, 0, 1, "(60) 76 100 95 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74 17", 12, 0, "BWIPP different encodation, uses Sh2C + other differences" }, /* 46*/ { UNICODE_MODE, COMPLIANT_HEIGHT, -1, 4, "A", -1, 0, 2, 70, 1, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 4, "option_3 separator" }, /* 47*/ { UNICODE_MODE, COMPLIANT_HEIGHT, -1, 5, "A", -1, 0, 2, 70, 1, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 1, "option_3 invalid 5 -> 1" }, - /* 48*/ { UNICODE_MODE, -1, -1, 5, "A", -1, 0, 2, 70, 1, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 5, "option_3 invalid 5 ignored unless COMPLIANT_HEIGHT" }, + /* 48*/ { DATA_MODE, -1, -1, 0, "A\007A\200", -1, 0, 2, 70, 1, 899, "(10) 0 33 71 33 101 64 103 103 36 66", 2, 0, "" }, + /* 49*/ { DATA_MODE, -1, -1, 0, "1234A\007A\200", -1, 0, 3, 70, 1, 899, "(15) 9 12 34 101 33 71 33 101 64 103 103 103 103 7 91", 3, 0, "" }, + /* 50*/ { GS1_MODE, -1, -1, 0, "[10]1[90]1", -1, 0, 2, 70, 1, 1, "(10) 4 10 100 17 102 25 16 17 93 104", 2, 0, "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -260,7 +276,8 @@ static void test_input(const testCtx *const p_ctx) { data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, %s, %d, %d, \"%s\", %d, %s, %d, %d, %d, %d, \"%s\", %d, %d, \"%s\" },\n", @@ -270,19 +287,28 @@ static void test_input(const testCtx *const p_ctx) { testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].zxingcpp_cmp, symbol->errtxt, symbol->option_1, symbol->option_3, data[i].comment); } else { - assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); + assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", + i, symbol->errtxt, data[i].expected); if (ret < ZINT_ERROR) { - 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); + 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); if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) { 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); + if (debug & ZINT_DEBUG_TEST_PRINT) { + printf("i:%d %s not BWIPP compatible (%s)\n", + i, testUtilBarcodeName(symbol->symbology), data[i].comment); + } } else { char modules_dump[4096]; - assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); - ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, + "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].data, length, NULL, cmp_buf, + sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", @@ -398,10 +424,13 @@ static void test_encode(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, + data[i].option_1, -1, -1, -1 /*output_options*/, + data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n", @@ -414,19 +443,25 @@ static void test_encode(const testCtx *const p_ctx) { if (ret < ZINT_ERROR) { int width, row; - 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); + 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); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); - assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); + 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, data[i].option_1, -1, -1, debug)) { - ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].data, length, NULL, cmp_buf, + sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_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, cmp_msg, cmp_buf, data[i].expected); + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, + data[i].expected); } if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { int cmp_len, ret_len; @@ -500,7 +535,8 @@ static void test_rt(const testCtx *const p_ctx) { expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length; ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (ret < ZINT_ERROR) { assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", @@ -513,8 +549,8 @@ static void test_rt(const testCtx *const p_ctx) { i, symbol->content_segs[0].length, expected_length); assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length), "i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i, - testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length, - escaped, sizeof(escaped)), + testUtilEscape((const char *) symbol->content_segs[0].source, + symbol->content_segs[0].length, escaped, sizeof(escaped)), testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)), expected_length); assert_equal(symbol->content_segs[0].eci, data[i].expected_content_eci, diff --git a/backend/tests/test_common.c b/backend/tests/test_common.c index 2a45248c..eef7fdf0 100644 --- a/backend/tests/test_common.c +++ b/backend/tests/test_common.c @@ -55,20 +55,37 @@ static void test_isXXX(const testCtx *const p_ctx) { struct item { char ch; + int ret_isxdigit; + int ret_isalpha; int ret_isascii; int ret_iscntrl; }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { '\177', 1, 1 }, /* DEL */ - /* 1*/ { '\200', 0, 0 }, - /* 3*/ { '\0', 1, 1 }, - /* 3*/ { '\001', 1, 1 }, /* SOH */ - /* 2*/ { '\t', 1, 1 }, - /* 4*/ { '\037', 1, 1 }, /* US */ - /* 5*/ { ' ', 1, 0 }, - /* 6*/ { '!', 1, 0 }, - /* 7*/ { '~', 1, 0 }, + /* 0*/ { '0', 1, 0, 1, 0 }, + /* 1*/ { '9', 1, 0, 1, 0 }, + /* 2*/ { 'A', 1, 1, 1, 0 }, + /* 3*/ { 'F', 1, 1, 1, 0 }, + /* 4*/ { 'a', 1, 1, 1, 0 }, + /* 5*/ { 'f', 1, 1, 1, 0 }, + /* 6*/ { '\177', 0, 0, 1, 1 }, /* DEL */ + /* 7*/ { '\200', 0, 0, 0, 0 }, + /* 8*/ { '\377', 0, 0, 0, 0 }, + /* 9*/ { '\0', 0, 0, 1, 1 }, + /* 10*/ { '\001', 0, 0, 1, 1 }, /* SOH */ + /* 11*/ { '\t', 0, 0, 1, 1 }, + /* 12*/ { '\037', 0, 0, 1, 1 }, /* US */ + /* 13*/ { ' ', 0, 0, 1, 0 }, + /* 14*/ { '!', 0, 0, 1, 0 }, + /* 15*/ { '~', 0, 0, 1, 0 }, + /* 16*/ { '@', 0, 0, 1, 0 }, + /* 17*/ { 'G', 0, 1, 1, 0 }, + /* 18*/ { 'Z', 0, 1, 1, 0 }, + /* 19*/ { '[', 0, 0, 1, 0 }, + /* 20*/ { '`', 0, 0, 1, 0 }, + /* 21*/ { 'g', 0, 1, 1, 0 }, + /* 22*/ { 'z', 0, 1, 1, 0 }, + /* 23*/ { '{', 0, 0, 1, 0 }, }; const int data_size = ARRAY_SIZE(data); int i, ret; @@ -79,6 +96,9 @@ static void test_isXXX(const testCtx *const p_ctx) { if (testContinue(p_ctx, i)) continue; + ret = z_isxdigit(data[i].ch); + assert_equal(ret, data[i].ret_isxdigit, "i:%d isxdigit ret %d != %d\n", i, ret, data[i].ret_isxdigit); + ret = z_isascii(data[i].ch); assert_equal(ret, data[i].ret_isascii, "i:%d isascii ret %d != %d\n", i, ret, data[i].ret_isascii); @@ -1196,6 +1216,35 @@ static void test_hrt_conv_gs1_brackets_nochk(const testCtx *const p_ctx) { testFinish(); } +static void test_ct_init_segs(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + int ret; + + struct zint_symbol s_symbol = {0}; + struct zint_symbol *symbol = &s_symbol; + + testStart(p_ctx->func_name); + + symbol->debug = debug; + + ret = z_ct_init_segs(symbol, 1); + assert_zero(ret, "z_ct_init_segs %d != 0\n", ret); + ZBarcode_Clear(symbol); + + ret = z_ct_init_segs(symbol, 1); + assert_zero(ret, "z_ct_init_segs %d != 0\n", ret); + ret = z_ct_init_segs(symbol, 2); + assert_zero(ret, "z_ct_init_segs %d != 0\n", ret); + ZBarcode_Clear(symbol); + + zint_test_ct_set_fail(Z_CT_FAIL_ID_INIT_SEGS, 1); + ret = z_ct_init_segs(symbol, 1); + assert_equal(ret, ZINT_ERROR_MEMORY, "z_ct_init_segs %d != 0, ZINT_ERROR_MEMORY\n", ret); + zint_test_ct_set_fail(0, 0); + + testFinish(); +} + static void test_ct_cpy_segs(const testCtx *const p_ctx) { int debug = p_ctx->debug; @@ -1678,6 +1727,7 @@ int main(int argc, char *argv[]) { { "test_hrt_cpy_cat_nochk", test_hrt_cpy_cat_nochk }, { "test_hrt_printf_nochk", test_hrt_printf_nochk }, { "test_hrt_conv_gs1_brackets_nochk", test_hrt_conv_gs1_brackets_nochk }, + { "test_ct_init_segs", test_ct_init_segs }, { "test_ct_cpy_segs", test_ct_cpy_segs }, { "test_ct_set_seg_extra_escapes_eci", test_ct_set_seg_extra_escapes_eci }, { "test_ct_cpy", test_ct_cpy }, diff --git a/backend/tests/test_composite.c b/backend/tests/test_composite.c index 64091db9..a834a271 100644 --- a/backend/tests/test_composite.c +++ b/backend/tests/test_composite.c @@ -4088,6 +4088,8 @@ static void test_input(const testCtx *const p_ctx) { int option_1; int option_2; int option_3; + int output_options; + float height; const char *data; const char *composite; @@ -4101,150 +4103,164 @@ static void test_input(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, "1234567", "[20]12", 0, 8, 72, "", 1, 0, 0 }, - /* 1*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567", "[20]12", 0, 8, 72, "", 1, 0, 0 }, /* EAN-8 */ - /* 2*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 3*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, /* EAN-8 */ - /* 4*/ { BARCODE_EAN8_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /* 5*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /* 6*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, - /* 7*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, - /* 8*/ { BARCODE_EAN8_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[20]1A", 0, 8, 72, "", 1, 0, 0 }, - /* 9*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[20]1A", 0, 8, 72, "", 1, 0, 0 }, - /* 10*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /* 12*/ { BARCODE_EAN8_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[02]12345678901234", 0, 8, 72, "", 1, 0, 0 }, - /* 13*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[02]12345678901234", 0, 8, 72, "", 1, 0, 0 }, - /* 14*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, "12345670", "[20]12", 0, 8, 72, "", 1, 0, 0 }, - /* 15*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "12345670", "[20]12", 0, 7, 99, "", 1, 0, 0 }, - /* 16*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "12345670", "[20]12", 0, 7, 99, "", 1, 0, 0 }, /* EAN-13 for EANX_CC as length 8 only EAN-8 for EANX_CHK */ - /* 17*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "123456789012", "[20]12", 0, 7, 99, "", 1, 0, 0 }, - /* 18*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456789012", "[20]12", 0, 7, 99, "", 1, 0, 0 }, /* EAN-13 */ - /* 19*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "1234567890128", "[20]12", 0, 7, 99, "", 1, 0, 0 }, - /* 20*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[20]12", 0, 7, 99, "", 1, 0, 0 }, /* EAN-13 */ - /* 21*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)", 1, 0, 0 }, - /* 22*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)", 1, 0, 0 }, - /* 23*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /* 24*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /* 25*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)", -1, 0, 0 }, - /* 26*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)", -1, 0, 0 }, - /* 27*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)", -1, 0, 0 }, - /* 28*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)", -1, 0, 0 }, - /* 29*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 30*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 31*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 32*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 33*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ - /* 34*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ - /* 35*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890128", "[20]1A", 0, 7, 99, "", 1, 0, 0 }, - /* 36*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890128", "[20]1A", 0, 7, 99, "", 1, 0, 0 }, - /* 37*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "1234567890128", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /* 38*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /* 39*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890128", "[02]12345678901234", 0, 7, 99, "", 1, 0, 0 }, - /* 40*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890128", "[02]12345678901234", 0, 7, 99, "", 1, 0, 0 }, - /* 41*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567", 0, 48, 99, "", 2, 0, 0 }, /* Max CC-B for EAN-13 */ - /* 42*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567", 0, 48, 99, "", 2, 0, 0 }, /* Max CC-B for EAN-13 */ - /* 43*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, -1, "Error 444: Input too long (2D component)", -1, 0, 0 }, - /* 44*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, -1, "Error 444: Input too long (2D component)", -1, 0, 0 }, - /* 45*/ { BARCODE_EAN13_CC, -1, 3, -1, -1, "1234567890128", "[20]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 447: Invalid mode (CC-C only valid with GS1-128 linear component)", 3, 0, 0 }, - /* 46*/ { BARCODE_EANX_CC, -1, 3, -1, -1, "1234567890128", "[20]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 447: Invalid mode (CC-C only valid with GS1-128 linear component)", 3, 0, 0 }, - /* 47*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, "123456789012345678901", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 449: Input length 21 wrong (linear component)", -1, 0, 0 }, - /* 48*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456789012345678901", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 449: Input length 21 wrong (linear component)", -1, 0, 0 }, - /* 49*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "1234567890123", "[20]12", 0, 5, 100, "", 1, 0, 0 }, - /* 50*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901231", "[20]12", 0, 5, 100, "", 1, 0, 0 }, - /* 51*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, - /* 52*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /* 53*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, - /* 54*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, - /* 55*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, - /* 56*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, - /* 57*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 5, 100, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ - /* 58*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[20]1A", 0, 5, 100, "", 1, 0, 0 }, - /* 59*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 100, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /* 60*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[02]12345678901234", 0, 5, 100, "", 1, 0, 0 }, - /* 61*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "1234567890123", "[20]12", 0, 6, 79, "", 1, 0, 0 }, - /* 62*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901231", "[20]12", 0, 6, 79, "", 1, 0, 0 }, - /* 63*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, - /* 64*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /* 65*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "123456789012345", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, - /* 66*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012345", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, - /* 67*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "A1234567890123", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 1 in input (digits only) (linear component)", 1, 0, 0 }, - /* 68*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "A1234567890123", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 1 in input (digits only) (linear component)", 1, 0, 0 }, - /* 69*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 6, 79, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ - /* 70*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[20]1A", 0, 6, 79, "", 1, 0, 0 }, - /* 71*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 6, 79, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /* 72*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[02]12345678901234", 0, 6, 79, "", 1, 0, 0 }, - /* 73*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "12345678901", "[20]12", 0, 7, 99, "", 1, 0, 0 }, - /* 74*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789012", "[20]12", 0, 7, 99, "", 1, 0, 0 }, - /* 75*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 270: Invalid check digit '3', expecting '2' (linear component)", 1, 0, 0 }, - /* 76*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 270: Invalid check digit '3', expecting '2' (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /* 77*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 289: Input length 13 too long (maximum 12) (linear component)", 1, 0, 0 }, - /* 78*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 289: Input length 13 too long (maximum 12) (linear component)", 1, 0, 0 }, - /* 79*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "12345678901A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 12 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 80*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 12 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 81*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ - /* 82*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012", "[20]1A", 0, 7, 99, "", 1, 0, 0 }, - /* 83*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789012", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /* 84*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012", "[02]12345678901234", 0, 7, 99, "", 1, 0, 0 }, - /* 85*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "123456", "[20]12", 0, 9, 55, "", 1, 0, 0 }, - /* 86*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567", "[20]12", 0, 9, 55, "", 1, 0, 0 }, - /* 87*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "12345670", "[20]12", 0, 9, 55, "", 1, 0, 0 }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */ - /* 88*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 274: Invalid check digit '1', expecting '0' (linear component)", 1, 0, 0 }, - /* 89*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 274: Invalid check digit '1', expecting '0' (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /* 90*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "123456712", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 291: Input length 9 too long (maximum 8) (linear component)", 1, 0, 0 }, - /* 91*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456712", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 291: Input length 9 too long (maximum 8) (linear component)", 1, 0, 0 }, - /* 92*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 8 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 93*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 8 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, - /* 94*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 55, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ - /* 95*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[20]1A", 0, 9, 55, "", 1, 0, 0 }, - /* 96*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 9, 55, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /* 97*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[02]12345678901234", 0, 9, 55, "", 1, 0, 0 }, - /* 98*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "1234567890123", "[20]12", 0, 9, 56, "", 1, 0, 0 }, - /* 99*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901231", "[20]12", 0, 9, 56, "", 1, 0, 0 }, - /*100*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, - /*101*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /*102*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "123456789012323", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, - /*103*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012323", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, - /*104*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, - /*105*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, - /*106*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ - /*107*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[20]1A", 0, 9, 56, "", 1, 0, 0 }, - /*108*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /*109*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[02]12345678901234", 0, 9, 56, "", 1, 0, 0 }, - /*110*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "1234567890123", "[20]12", 0, 11, 56, "", 1, 0, 0 }, - /*111*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901231", "[20]12", 0, 11, 56, "", 1, 0, 0 }, - /*112*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, - /*113*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, /* Linear component still checked */ - /*114*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, - /*115*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, - /*116*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, - /*117*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, - /*118*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 11, 56, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ - /*119*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[20]1A", 0, 11, 56, "", 1, 0, 0 }, - /*120*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 11, 56, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, - /*121*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[02]12345678901234", 0, 11, 56, "", 1, 0, 0 }, - /*122*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 445: No primary (linear component)", -1, 0, 0 }, - /*123*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 31, 273, "", 3, 0, 0 }, /* Tries CC-A then CC-B then CC-C - ensure errtxt empty */ - /*124*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123", ZINT_WARN_NONCOMPLIANT, 29, 702, "Warning 843: Input too long, requires 115 characters (maximum 48) (linear component)", 3, 0, 0 }, /* Overlarge linear and CC-C input */ - /*125*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL", ZINT_ERROR_TOO_LONG, -1, -1, "Error 442: Input too long (2D component)", -1, 0, 0 }, /* Overlarge linear and oversized CC-C input */ - /*126*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" "JKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLM", ZINT_ERROR_TOO_LONG, -1, -1, "Error 446: 2D component input too long, requires 2991 characters (maximum 2990)", -1, 0, 0 }, /* Reduced length 2291 */ - /*127*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012" "345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[11]121212[20]12", 0, 32, 579, "", 3, 0, 0 }, /* Reduced length 2372 digits (no FNC1s) with not recommended ECC 4 > 2361 digit limit given in ISO/IEC 24723:2010 4.1 (d)(2)(iii) */ - /*128*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", "[20]12", ZINT_WARN_NONCOMPLIANT, 5, 1146, "Warning 843: Input too long, requires 99 characters (maximum 48) (linear component)", 1, 0, 0 }, - /*129*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 344: Input too long, requires 103 symbol characters (maximum 102) (linear component)", -1, 0, 0 }, - /*130*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 0, 0 }, - /*131*/ { BARCODE_DBAR_EXPSTK_CC, -1, 1, -1, -1, "[91]1234567890123456789012345678901234", "[91]123456789012345678901234567890123456789012345678901234", 0, 17, 102, "", 1, 0, 0 }, - /*132*/ { BARCODE_DBAR_EXPSTK_CC, -1, 1, -1, -1, "[91]1234567890123456789012345678901234", "[91]1234567890123456789012345678901234567890123456789012345", ZINT_WARN_INVALID_OPTION, 20, 102, "Warning 443: Composite type changed from CC-A to CC-B", 2, 0, 0 }, - /*133*/ { BARCODE_GS1_128_CC, -1, 1, -1, -1, "[01]12345678901231", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_WARN_INVALID_OPTION, 31, 154, "Warning 443: Composite type changed from CC-A to CC-C", 3, 0, 0 }, - /*134*/ { BARCODE_GS1_128_CC, -1, 2, -1, -1, "[01]12345678901231", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_WARN_INVALID_OPTION, 31, 154, "Warning 443: Composite type changed from CC-B to CC-C", 3, 0, 0 }, - /*135*/ { BARCODE_GS1_128_CC, -1, 1, -1, -1, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLM", "[91]1234567890123456789012345678901234567890123456789012345", ZINT_WARN_INVALID_OPTION, 12, 585, "Warning 443: Composite type changed from CC-A to CC-B", 2, 0, 0 }, - /*136*/ { BARCODE_GS1_128_CC, -1, 1, -1, -1, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLMN", "[91]1234567890123456789012345678901234567890123456789012345", ZINT_WARN_NONCOMPLIANT, 12, 596, "Warning 843: Input too long, requires 49 characters (maximum 48) (linear component)", 2, 0, 0 }, /* Other warnings trump CC type change */ - /*137*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 1, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 1, 0 }, - /*138*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 2, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 2, 0 }, - /*139*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 3, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 151, "", 1, 3, 0 }, - /*140*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 4, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 200, "", 1, 4, 0 }, - /*141*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 2, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 151, "", 1, 0, 2 }, - /*142*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 3, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 0, 3 }, - /*143*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 4, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 0, 4 }, + /* 0*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[20]12", 0, 8, 72, "", 1, 0, 0 }, + /* 1*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[20]12", 0, 8, 72, "", 1, 0, 0 }, /* EAN-8 */ + /* 2*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, 0.0f, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 3*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, /* EAN-8 */ + /* 4*/ { BARCODE_EAN8_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /* 5*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /* 6*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, + /* 7*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, + /* 8*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, + /* 9*/ { BARCODE_EAN8_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567", "[20]1A", 0, 8, 72, "", 1, 0, 0 }, + /* 10*/ { BARCODE_EAN8_CC, GS1NOCHECK_MODE, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 247: Height not compliant with standards (too small)", 1, 0, 0 }, + /* 11*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567", "[20]1A", 0, 8, 72, "", 1, 0, 0 }, + /* 12*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /* 13*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /* 14*/ { BARCODE_EAN8_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567", "[02]12345678901234", 0, 8, 72, "", 1, 0, 0 }, + /* 15*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567", "[02]12345678901234", 0, 8, 72, "", 1, 0, 0 }, + /* 16*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, 0.0f, "12345670", "[20]12", 0, 8, 72, "", 1, 0, 0 }, + /* 17*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "12345670", "[20]12", 0, 7, 99, "", 1, 0, 0 }, + /* 18*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "12345670", "[20]12", 0, 7, 99, "", 1, 0, 0 }, /* EAN-13 for EANX_CC as length 8 only EAN-8 for EANX_CHK */ + /* 19*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012", "[20]12", 0, 7, 99, "", 1, 0, 0 }, + /* 20*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012", "[20]12", 0, 7, 99, "", 1, 0, 0 }, /* EAN-13 */ + /* 21*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[20]12", 0, 7, 99, "", 1, 0, 0 }, + /* 22*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[20]12", 0, 7, 99, "", 1, 0, 0 }, /* EAN-13 */ + /* 23*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)", 1, 0, 0 }, + /* 24*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)", 1, 0, 0 }, + /* 25*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /* 26*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /* 27*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)", -1, 0, 0 }, + /* 28*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)", -1, 0, 0 }, + /* 29*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)", -1, 0, 0 }, + /* 30*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)", -1, 0, 0 }, + /* 31*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 32*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 33*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 34*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 35*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /* 36*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /* 37*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890128", "[20]1A", 0, 7, 99, "", 1, 0, 0 }, + /* 38*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890128", "[20]1A", 0, 7, 99, "", 1, 0, 0 }, + /* 39*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /* 40*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /* 41*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890128", "[02]12345678901234", 0, 7, 99, "", 1, 0, 0 }, + /* 42*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890128", "[02]12345678901234", 0, 7, 99, "", 1, 0, 0 }, + /* 43*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567", 0, 48, 99, "", 2, 0, 0 }, /* Max CC-B for EAN-13 */ + /* 44*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567", 0, 48, 99, "", 2, 0, 0 }, /* Max CC-B for EAN-13 */ + /* 45*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, -1, "Error 444: Input too long (2D component)", -1, 0, 0 }, + /* 46*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, -1, "Error 444: Input too long (2D component)", -1, 0, 0 }, + /* 47*/ { BARCODE_EAN13_CC, -1, 3, -1, -1, -1, 0.0f, "1234567890128", "[20]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 447: Invalid mode (CC-C only valid with GS1-128 linear component)", 3, 0, 0 }, + /* 48*/ { BARCODE_EANX_CC, -1, 3, -1, -1, -1, 0.0f, "1234567890128", "[20]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 447: Invalid mode (CC-C only valid with GS1-128 linear component)", 3, 0, 0 }, + /* 49*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012345678901", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 449: Input length 21 wrong (linear component)", -1, 0, 0 }, + /* 50*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012345678901", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 449: Input length 21 wrong (linear component)", -1, 0, 0 }, + /* 51*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", 0, 5, 100, "", 1, 0, 0 }, + /* 52*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]12", 0, 5, 100, "", 1, 0, 0 }, + /* 53*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, + /* 54*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /* 55*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, + /* 56*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, + /* 57*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, + /* 58*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, + /* 59*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 5, 100, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /* 60*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]1A", 0, 5, 100, "", 1, 0, 0 }, + /* 61*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 100, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /* 62*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901231", "[02]12345678901234", 0, 5, 100, "", 1, 0, 0 }, + /* 63*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", 0, 6, 79, "", 1, 0, 0 }, + /* 64*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]12", 0, 6, 79, "", 1, 0, 0 }, + /* 65*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, + /* 66*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /* 67*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012345", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, + /* 68*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789012345", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, + /* 69*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, -1, 0.0f, "A1234567890123", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 1 in input (digits only) (linear component)", 1, 0, 0 }, + /* 70*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "A1234567890123", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 1 in input (digits only) (linear component)", 1, 0, 0 }, + /* 71*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 6, 79, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /* 72*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]1A", 0, 6, 79, "", 1, 0, 0 }, + /* 73*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 6, 79, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /* 74*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901231", "[02]12345678901234", 0, 6, 79, "", 1, 0, 0 }, + /* 75*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901", "[20]12", 0, 7, 99, "", 1, 0, 0 }, + /* 76*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012", "[20]12", 0, 7, 99, "", 1, 0, 0 }, + /* 77*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0.0f, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 270: Invalid check digit '3', expecting '2' (linear component)", 1, 0, 0 }, + /* 78*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 270: Invalid check digit '3', expecting '2' (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /* 79*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 289: Input length 13 too long (maximum 12) (linear component)", 1, 0, 0 }, + /* 80*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 289: Input length 13 too long (maximum 12) (linear component)", 1, 0, 0 }, + /* 81*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 12 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 82*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 12 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 83*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /* 84*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789012", "[20]1A", 0, 7, 99, "", 1, 0, 0 }, + /* 85*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /* 86*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789012", "[02]12345678901234", 0, 7, 99, "", 1, 0, 0 }, + /* 87*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0.0f, "123456", "[20]12", 0, 9, 55, "", 1, 0, 0 }, + /* 88*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[20]12", 0, 9, 55, "", 1, 0, 0 }, + /* 89*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0.0f, "12345670", "[20]12", 0, 9, 55, "", 1, 0, 0 }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */ + /* 90*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0.0f, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 274: Invalid check digit '1', expecting '0' (linear component)", 1, 0, 0 }, + /* 91*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 274: Invalid check digit '1', expecting '0' (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /* 92*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0.0f, "123456712", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 291: Input length 9 too long (maximum 8) (linear component)", 1, 0, 0 }, + /* 93*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456712", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 291: Input length 9 too long (maximum 8) (linear component)", 1, 0, 0 }, + /* 94*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0.0f, "1234567A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 8 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 95*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 8 in input (digits and \"+\" or space only) (linear component)", 1, 0, 0 }, + /* 96*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 55, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /* 97*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567", "[20]1A", 0, 9, 55, "", 1, 0, 0 }, + /* 98*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0.0f, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 9, 55, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /* 99*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567", "[02]12345678901234", 0, 9, 55, "", 1, 0, 0 }, + /*100*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", 0, 9, 56, "", 1, 0, 0 }, + /*101*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]12", 0, 9, 56, "", 1, 0, 0 }, + /*102*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, + /*103*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /*104*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012323", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, + /*105*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789012323", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, + /*106*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, + /*107*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, + /*108*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /*109*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]1A", 0, 9, 56, "", 1, 0, 0 }, + /*110*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /*111*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 379: Height not compliant with standards", 1, 0, 0 }, + /*112*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /*113*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901231", "[02]12345678901234", 0, 9, 56, "", 1, 0, 0 }, + /*114*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123", "[20]12", 0, 11, 56, "", 1, 0, 0 }, + /*115*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]12", 0, 11, 56, "", 1, 0, 0 }, + /*116*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, + /*117*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)", 1, 0, 0 }, /* Linear component still checked */ + /*118*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, -1, 0.0f, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, + /*119*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)", 1, 0, 0 }, + /*120*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, -1, 0.0f, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, + /*121*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)", 1, 0, 0 }, + /*122*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 11, 56, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, /* AI (20) should be 2 nos. */ + /*123*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901231", "[20]1A", 0, 11, 56, "", 1, 0, 0 }, + /*124*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, -1, 0.0f, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 11, 56, "Warning 261: AI (02) data position 14: Bad checksum '4', expected '1' (2D component)", 1, 0, 0 }, + /*125*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "12345678901231", "[02]12345678901234", 0, 11, 56, "", 1, 0, 0 }, + /*126*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 0.0f, "", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 445: No primary (linear component)", -1, 0, 0 }, + /*127*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 0.0f, "[01]12345678901231", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 31, 273, "", 3, 0, 0 }, /* Tries CC-A then CC-B then CC-C - ensure errtxt empty */ + /*128*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 0.0f, "[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123", ZINT_WARN_NONCOMPLIANT, 29, 702, "Warning 843: Input too long, requires 115 characters (maximum 48) (linear component)", 3, 0, 0 }, /* Overlarge linear and CC-C input */ + /*129*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 0.0f, "[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL", ZINT_ERROR_TOO_LONG, -1, -1, "Error 442: Input too long (2D component)", -1, 0, 0 }, /* Overlarge linear and oversized CC-C input */ + /*130*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 0.0f, "[01]12345678901231", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" "JKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLM", ZINT_ERROR_TOO_LONG, -1, -1, "Error 446: 2D component input too long, requires 2991 characters (maximum 2990)", -1, 0, 0 }, /* Reduced length 2291 */ + /*131*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 0.0f, "[01]12345678901231", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012" "345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[11]121212[20]12", 0, 32, 579, "", 3, 0, 0 }, /* Reduced length 2372 digits (no FNC1s) with not recommended ECC 4 > 2361 digit limit given in ISO/IEC 24723:2010 4.1 (d)(2)(iii) */ + /*132*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 0.0f, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", "[20]12", ZINT_WARN_NONCOMPLIANT, 5, 1146, "Warning 843: Input too long, requires 99 characters (maximum 48) (linear component)", 1, 0, 0 }, + /*133*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 0.0f, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 344: Input too long, requires 103 symbol characters (maximum 102) (linear component)", -1, 0, 0 }, + /*134*/ { BARCODE_DBAR_EXP_CC, -1, -1, -1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 5, 298, "", 1, 0, 0 }, + /*135*/ { BARCODE_DBAR_EXP_CC, -1, -1, -1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]1A", ZINT_WARN_NONCOMPLIANT, 5, 298, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, + /*136*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]1A", 0, 5, 298, "", 1, 0, 0 }, + /*137*/ { BARCODE_DBAR_EXP_CC, -1, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "[91]1234567890123456789012345678901234", "[20]1A", ZINT_WARN_NONCOMPLIANT, 5, 298, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)", 1, 0, 0 }, + /*138*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "[91]1234567890123456789012345678901234", "[20]1A", ZINT_WARN_NONCOMPLIANT, 5, 298, "Warning 247: Height not compliant with standards (too small)", 1, 0, 0 }, + /*139*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 0, 0 }, + /*140*/ { BARCODE_DBAR_EXPSTK_CC, -1, 1, -1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[91]123456789012345678901234567890123456789012345678901234", 0, 17, 102, "", 1, 0, 0 }, + /*141*/ { BARCODE_DBAR_EXPSTK_CC, -1, 1, -1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[91]1234567890123456789012345678901234567890123456789012345", ZINT_WARN_INVALID_OPTION, 20, 102, "Warning 443: Composite type changed from CC-A to CC-B", 2, 0, 0 }, + /*142*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, -1, -1, 0.0f, "[01]12345678901234", "[20]12", ZINT_WARN_NONCOMPLIANT, 9, 102, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1' (linear component)", 1, 0, 0 }, + /*143*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, -1, 0.0f, "[01]12345678901231", "[20]12", 0, 9, 102, "", 1, 0, 0 }, + /*144*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "[01]12345678901234", "[20]12", ZINT_WARN_NONCOMPLIANT, 9, 102, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1' (linear component)", 1, 0, 0 }, + /*145*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "[01]12345678901234", "[20]12", ZINT_WARN_NONCOMPLIANT, 9, 102, "Warning 247: Height not compliant with standards (too small)", 1, 0, 0 }, + /*146*/ { BARCODE_GS1_128_CC, -1, 1, -1, -1, -1, 0.0f, "[01]12345678901231", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_WARN_INVALID_OPTION, 31, 154, "Warning 443: Composite type changed from CC-A to CC-C", 3, 0, 0 }, + /*147*/ { BARCODE_GS1_128_CC, -1, 2, -1, -1, -1, 0.0f, "[01]12345678901231", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_WARN_INVALID_OPTION, 31, 154, "Warning 443: Composite type changed from CC-B to CC-C", 3, 0, 0 }, + /*148*/ { BARCODE_GS1_128_CC, -1, 1, -1, -1, -1, 0.0f, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLM", "[91]1234567890123456789012345678901234567890123456789012345", ZINT_WARN_INVALID_OPTION, 12, 585, "Warning 443: Composite type changed from CC-A to CC-B", 2, 0, 0 }, + /*149*/ { BARCODE_GS1_128_CC, -1, 1, -1, -1, -1, 0.0f, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLMN", "[91]1234567890123456789012345678901234567890123456789012345", ZINT_WARN_NONCOMPLIANT, 12, 596, "Warning 843: Input too long, requires 49 characters (maximum 48) (linear component)", 2, 0, 0 }, /* Other warnings trump CC type change */ + /*150*/ { BARCODE_GS1_128_CC, -1, 1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLM", "[91]1234567890123456789012345678901234567890123456789012345", ZINT_WARN_INVALID_OPTION, 12, 585, "Warning 443: Composite type changed from CC-A to CC-B", 2, 0, 0 }, + /*151*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 1, 0 }, + /*152*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 2, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 2, 0 }, + /*153*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 3, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 151, "", 1, 3, 0 }, + /*154*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 4, -1, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 200, "", 1, 4, 0 }, + /*155*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 2, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 151, "", 1, 0, 2 }, + /*156*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 3, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 0, 3 }, + /*157*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 4, -1, 0.0f, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "", 1, 0, 4 }, }; const int data_size = ARRAY_SIZE(data); int i, length, composite_length, ret; @@ -4260,10 +4276,13 @@ static void test_input(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, - data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, + data[i].option_1, data[i].option_2, data[i].option_3, data[i].output_options, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); + if (data[i].height) { + symbol->height = data[i].height; + } composite_length = (int) strlen(data[i].composite); diff --git a/backend/tests/test_eci.c b/backend/tests/test_eci.c index b4f9c9a8..dd91dfc5 100644 --- a/backend/tests/test_eci.c +++ b/backend/tests/test_eci.c @@ -698,6 +698,7 @@ static void test_utf8_to_eci_sb(const testCtx *const p_ctx) { unsigned char source[5]; unsigned char dest[2] = {0}; + const unsigned char source0x012c[] = "\xC4\xAC"; /* 0x012c not in any single-byte tables */ testStart(p_ctx->func_name); @@ -738,6 +739,12 @@ static void test_utf8_to_eci_sb(const testCtx *const p_ctx) { } } } + j = 0x012c; + length = 2; + ret = zint_utf8_to_eci(data[i].eci, source0x012c, dest, &length); + assert_equal(ret, ZINT_ERROR_INVALID_DATA, + "i:%d eci:%d codepoint:0x%x source:%s zint_utf8_to_eci ret %d != ZINT_ERROR_INVALID_DATA\n", + i, data[i].eci, j, source0x012c, ret); } testFinish(); @@ -1397,6 +1404,7 @@ static void test_utf8_to_eci_binary(const testCtx *const p_ctx) { /* 3*/ { "\302\220\302\221\302\222\302\223\302\224\302\225\302\226\302\227\302\230\302\231\302\232\302\233\302\234\302\235\302\236\302\237", 32, 0, 16 }, /* 4*/ { "\303\200\303\201\303\202\303\203\303\204\303\205\303\206\303\207\303\210\303\211\303\212\303\213\303\214\303\215\303\216\303\217", 32, 0, 16 }, /* 5*/ { "\303\220\303\221\303\222\303\223\303\224\303\225\303\226\303\227\303\230\303\231\303\232\303\233\303\234\303\235\303\236\303\237", 32, 0, 16 }, + /* 6*/ { "\304\242", 2, ZINT_ERROR_INVALID_DATA, -1 }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_emf.c b/backend/tests/test_emf.c index a7eb0964..19b690be 100644 --- a/backend/tests/test_emf.c +++ b/backend/tests/test_emf.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2025 Robin Stuart + Copyright (C) 2020-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -167,7 +167,7 @@ static void test_print(const testCtx *const p_ctx) { strcpy(symbol->bgcolour, data[i].bgcolour); } - ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); + ret = ZBarcode_Encode(symbol, ZCUCP(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); @@ -284,11 +284,70 @@ static void test_outfile(const testCtx *const p_ctx) { testFinish(); } +#include "filemem.h" + +static void test_fm(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_ACCESS, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_OPEN }, + /* 1*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 5, 11, 0, 0, 0 }, 2, FM_FAIL_ID_WRITE }, + /* 2*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.emf"); + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ { "test_print", test_print }, { "test_outfile", test_outfile }, + { "test_fm", test_fm }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_filemem.c b/backend/tests/test_filemem.c index 31fa5702..9d0853e7 100644 --- a/backend/tests/test_filemem.c +++ b/backend/tests/test_filemem.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2023-2025 Robin Stuart + Copyright (C) 2023-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -204,7 +204,8 @@ static void test_putsf(const testCtx *const p_ctx) { zint_fm_putsf(data[i].prefix, data[i].dp, data[i].arg, fmp); - assert_nonzero(zint_fm_close(fmp, symbol), "i:%d: zint_fm_close fail (%d, %s)\n", i, fmp->err, strerror(fmp->err)); + assert_nonzero(zint_fm_close(fmp, symbol), "i:%d: zint_fm_close fail (%d, %s)\n", + i, fmp->err, strerror(fmp->err)); if (locale) { assert_nonnull(setlocale(LC_ALL, locale), "i:%d: setlocale(%s) restore fail (%d, %s)\n", @@ -274,6 +275,9 @@ static void test_printf(const testCtx *const p_ctx) { ret = zint_fm_printf(fmp, fmt1, "gosh", 123, "gee"); assert_equal(ret, 1, "zint_fm_printf ret %d != 1\n", ret); + ret = zint_fm_flush(fmp); + assert_equal(ret, 1, "zint_fm_flush ret %d != 1\n", ret); + ret = zint_fm_close(fmp, symbol); assert_equal(ret, 1, "zint_fm_close ret %d != 1\n", ret); @@ -340,6 +344,92 @@ static void test_printf(const testCtx *const p_ctx) { testFinish(); } +static void test_write(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + const char *data; + size_t size; + size_t nitems; + const char *expected; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + struct item data[] = { + /* 0*/ { "123", 3, 1, "123" }, + /* 1*/ { "123", 3, 0, "" }, + /* 2*/ { "", 0, 1, "" }, + }; + int data_size = ARRAY_SIZE(data); + int i, j; + + struct zint_symbol symbol_data = {0}; + struct zint_symbol *const symbol = &symbol_data; + struct filemem fm = {0}; /* Suppress clang -fsanitize=memory false positive */ + struct filemem *const fmp = &fm; +#ifndef ZINT_TEST_NO_FMEMOPEN + FILE *fp; + char buf[512] = {0}; /* Suppress clang-16/17 run-time exception MemorySanitizer: use-of-uninitialized-value */ +#endif + + (void)debug; + + testStart(p_ctx->func_name); + + for (j = 0; j < 2; j++) { /* 1st `memfile`, then file */ +#ifdef ZINT_TEST_NO_FMEMOPEN + if (j == 1) break; /* Skip file test on Windows/Solaris */ +#endif + for (i = 0; i < data_size; i++) { + int expected_size; + + if (testContinue(p_ctx, i)) continue; + + ZBarcode_Reset(symbol); + if (j == 1) { +#ifndef ZINT_TEST_NO_FMEMOPEN + buf[0] = '\0'; + fp = fmemopen(buf, sizeof(buf), "w"); + assert_nonnull(fp, "%d: fmemopen fail (%d, %s)\n", i, errno, strerror(errno)); +#endif + } else { + symbol->output_options |= BARCODE_MEMORY_FILE; + } + assert_nonzero(zint_fm_open(fmp, symbol, "w"), "i:%d: zint_fm_open fail (%d, %s)\n", + i, fmp->err, strerror(fmp->err)); + if (j == 1) { +#ifndef ZINT_TEST_NO_FMEMOPEN + /* Hack in `fmemopen()` fp */ + assert_zero(fclose(fmp->fp), "i:%d fclose(fmp->fp) fail (%d, %s)\n", i, errno, strerror(errno)); + fmp->fp = fp; +#endif + } + + zint_fm_write(data[i].data, data[i].size, data[i].nitems, fmp); + + assert_nonzero(zint_fm_close(fmp, symbol), "i:%d: zint_fm_close fail (%d, %s)\n", + i, fmp->err, strerror(fmp->err)); + + if (j == 1) { +#ifndef ZINT_TEST_NO_FMEMOPEN + assert_zero(strcmp(buf, data[i].expected), "%d: strcmp(%s, %s) != 0\n", i, buf, data[i].expected); +#endif + } else { + expected_size = (int) strlen(data[i].expected); + assert_equal(symbol->memfile_size, expected_size, "i:%d: memfile_size %d != expected_size %d\n", + i, symbol->memfile_size, expected_size); + assert_nonnull(symbol->memfile, "i:%d memfile NULL\n", i); + assert_zero(memcmp(symbol->memfile, data[i].expected, expected_size), + "i:%d: memcmp(%.*s, %.*s) != 0\n", + i, symbol->memfile_size, symbol->memfile, expected_size, data[i].expected); + } + + ZBarcode_Clear(symbol); + } + } + + testFinish(); +} + static void test_seek(const testCtx *const p_ctx) { int debug = p_ctx->debug; @@ -469,14 +559,83 @@ static void test_large(const testCtx *const p_ctx) { testFinish(); } +static void test_alloc(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int option_2; + int output_options; + const char *outfile; + const char *fgcolour; + float scale; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_CODE128, -1, BARCODE_MEMORY_FILE, "out.pcx", "FEDCBA98", 0.0f, "12345", ZINT_ERROR_FILE_ACCESS, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_MALLOC }, + /* 1*/ { BARCODE_CODE128, -1, BARCODE_MEMORY_FILE, "out.pcx", "FEDCBA98", 0.0f, "12345", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_REALLOC }, + /* 2*/ { BARCODE_QRCODE, 34, BARCODE_MEMORY_FILE, "out.gif", NULL, 2.5f, "12345", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_REALLOC }, + /* 3*/ { BARCODE_MAXICODE, -1, BARCODE_MEMORY_FILE, "out.svg", "FEDCBA98", 101.43f, "12345", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_REALLOC }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, data[i].outfile); + if (data[i].fgcolour) { + strcpy(symbol->fgcolour, data[i].fgcolour); + } + if (data[i].scale) { + symbol->scale = data[i].scale; + } + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ { "test_file", test_file }, { "test_putsf", test_putsf }, { "test_printf", test_printf }, + { "test_write", test_write }, { "test_seek", test_seek }, { "test_large", test_large }, + { "test_alloc", test_alloc }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); @@ -487,4 +646,3 @@ int main(int argc, char *argv[]) { } /* vim: set ts=4 sw=4 et : */ - diff --git a/backend/tests/test_gif.c b/backend/tests/test_gif.c index cbcc19e2..f1afceea 100644 --- a/backend/tests/test_gif.c +++ b/backend/tests/test_gif.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2025 Robin Stuart + Copyright (C) 2020-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -183,7 +183,8 @@ static void test_print(const testCtx *const p_ctx) { /* 33*/ { BARCODE_CODE16K, -1, -1, 3, 5, -1, -1, 1.5, 0, 0, { 0, 0, "" }, "", "", "1234567890", "code16k_height1.5_wsp3_vwsp5.gif", "" }, /* 34*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 2, 9, "001002" }, "", "", "1234567890", "datamatrix_seq2of9.gif", "" }, /* 35*/ { BARCODE_ULTRA, -1, -1, 1, -1, -1, 2, 0, 0, 0, { 0, 0, "" }, "", "", "12", "ultra_rev2.gif", "Revision 2" }, - /* 36*/ { BARCODE_DPD, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "", "", "008182709980000020028101276", "dpd_compliant.gif", "Now with bind top 3X default" }, + /* 36*/ { BARCODE_ULTRA, 1, BARCODE_BOX | BARCODE_QUIET_ZONES | BARCODE_NO_QUIET_ZONES, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "", "", "12", "ultra_box.gif", "NO_QUIET_ZONES trumps QUIET_ZONES" }, + /* 37*/ { BARCODE_DPD, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "", "", "008182709980000020028101276", "dpd_compliant.gif", "Now with bind top 3X default" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -417,6 +418,67 @@ static void test_too_big(const testCtx *const p_ctx) { testFinish(); } +#include "filemem.h" + +static void test_fm(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_ACCESS, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_OPEN }, + /* 1*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 3, 5, 0, 0 }, 3, FM_FAIL_ID_WRITE }, + /* 2*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_PUTC }, + /* 3*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + (void)p_ctx; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.gif"); + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ @@ -425,6 +487,7 @@ int main(int argc, char *argv[]) { { "test_outfile", test_outfile }, { "test_large_scale", test_large_scale }, { "test_too_big", test_too_big }, + { "test_fm", test_fm }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_gridmtx.c b/backend/tests/test_gridmtx.c index fb1adbbc..38fa35f4 100644 --- a/backend/tests/test_gridmtx.c +++ b/backend/tests/test_gridmtx.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2025 Robin Stuart + Copyright (C) 2019-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -35,6 +35,7 @@ static void test_large(const testCtx *const p_ctx) { int debug = p_ctx->debug; struct item { + int option_1; int option_2; int option_3; const char *pattern; @@ -46,48 +47,49 @@ static void test_large(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { -1, -1, "1", 2751, 0, 162, 162, "" }, - /* 1*/ { -1, -1, "1", 2752, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, - /* 2*/ { -1, -1, "1", 2755, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, /* Triggers buffer > 9191 */ - /* 3*/ { -1, -1, "A", 1836, 0, 162, 162, "" }, - /* 4*/ { -1, -1, "A", 1837, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, - /* 5*/ { -1, -1, "A1", 1529, 0, 162, 162, "" }, - /* 6*/ { -1, -1, "A1", 1530, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, - /* 7*/ { -1, -1, "\200", 1143, 0, 162, 162, "" }, - /* 8*/ { -1, -1, "\200", 1144, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, - /* 9*/ { -1, ZINT_FULL_MULTIBYTE, "\241", 1410, 0, 162, 162, "" }, - /* 10*/ { -1, ZINT_FULL_MULTIBYTE, "\241", 1412, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, - /* 11*/ { 1, -1, "1", 18, 0, 18, 18, "" }, - /* 12*/ { 1, -1, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 13 codewords (maximum 11)" }, - /* 13*/ { 1, -1, "A", 13, 0, 18, 18, "" }, - /* 14*/ { 1, -1, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" }, - /* 15*/ { 1, -1, "\200", 7, 0, 18, 18, "" }, - /* 16*/ { 1, -1, "\200", 8, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" }, - /* 17*/ { 1, ZINT_FULL_MULTIBYTE, "\241", 8, 0, 18, 18, "" }, - /* 18*/ { 1, ZINT_FULL_MULTIBYTE, "\241", 10, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" }, - /* 19*/ { 2, ZINT_FULL_MULTIBYTE, "\241", 40, 0, 30, 30, "" }, - /* 20*/ { 2, ZINT_FULL_MULTIBYTE, "\241", 41, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 2, requires 42 codewords (maximum 40)" }, - /* 21*/ { 3, -1, "A", 108, 0, 42, 42, "" }, - /* 22*/ { 3, -1, "A", 109, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 3, requires 80 codewords (maximum 79)" }, - /* 23*/ { 4, -1, "A", 202, 0, 54, 54, "" }, - /* 24*/ { 4, -1, "A", 203, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 4, requires 147 codewords (maximum 146)" }, - /* 25*/ { 5, -1, "1", 453, 0, 66, 66, "" }, - /* 26*/ { 5, -1, "1", 454, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 5, requires 220 codewords (maximum 218)" }, - /* 27*/ { 6, -1, "1", 633, 0, 78, 78, "" }, - /* 28*/ { 6, -1, "1", 634, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 6, requires 306 codewords (maximum 305)" }, - /* 29*/ { 7, -1, "\200", 352, 0, 90, 90, "" }, - /* 30*/ { 7, -1, "\200", 353, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 7, requires 406 codewords (maximum 405)" }, - /* 31*/ { 8, -1, "A", 727, 0, 102, 102, "" }, - /* 32*/ { 8, -1, "A", 728, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 8, requires 522 codewords (maximum 521)" }, - /* 33*/ { 9, -1, "A", 908, 0, 114, 114, "" }, - /* 34*/ { 9, -1, "A", 909, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 9, requires 651 codewords (maximum 650)" }, - /* 35*/ { 10, -1, "1", 1662, 0, 126, 126, "" }, - /* 36*/ { 10, -1, "1", 1663, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 10, requires 796 codewords (maximum 794)" }, - /* 37*/ { 11, -1, "1", 1995, 0, 138, 138, "" }, - /* 38*/ { 11, -1, "1", 1996, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 11, requires 954 codewords (maximum 953)" }, - /* 39*/ { 11, -1, "1", 2748, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 11, requires 1311 codewords (maximum 953)" }, - /* 40*/ { 12, -1, "1", 2355, 0, 150, 150, "" }, - /* 41*/ { 12, -1, "1", 2356, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 12, requires 1126 codewords (maximum 1125)" }, + /* 0*/ { -1, -1, -1, "1", 2751, 0, 162, 162, "" }, + /* 1*/ { -1, -1, -1, "1", 2752, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, + /* 2*/ { -1, -1, -1, "1", 2755, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, /* Triggers buffer > 9191 */ + /* 3*/ { -1, -1, -1, "A", 1836, 0, 162, 162, "" }, + /* 4*/ { -1, -1, -1, "A", 1837, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, + /* 5*/ { -1, -1, -1, "A1", 1529, 0, 162, 162, "" }, + /* 6*/ { -1, -1, -1, "A1", 1530, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, + /* 7*/ { -1, -1, -1, "\200", 1143, 0, 162, 162, "" }, + /* 8*/ { -1, -1, -1, "\200", 1144, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, + /* 9*/ { -1, -1, ZINT_FULL_MULTIBYTE, "\241", 1410, 0, 162, 162, "" }, + /* 10*/ { -1, -1, ZINT_FULL_MULTIBYTE, "\241", 1412, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, + /* 11*/ { -1, 1, -1, "1", 18, 0, 18, 18, "" }, + /* 12*/ { -1, 1, -1, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 13 codewords (maximum 11)" }, + /* 13*/ { -1, 1, -1, "A", 13, 0, 18, 18, "" }, + /* 14*/ { -1, 1, -1, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" }, + /* 15*/ { -1, 1, -1, "\200", 7, 0, 18, 18, "" }, + /* 16*/ { -1, 1, -1, "\200", 8, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" }, + /* 17*/ { -1, 1, ZINT_FULL_MULTIBYTE, "\241", 8, 0, 18, 18, "" }, + /* 18*/ { -1, 1, ZINT_FULL_MULTIBYTE, "\241", 10, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" }, + /* 19*/ { -1, 2, ZINT_FULL_MULTIBYTE, "\241", 40, 0, 30, 30, "" }, + /* 20*/ { -1, 2, ZINT_FULL_MULTIBYTE, "\241", 41, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 2, requires 42 codewords (maximum 40)" }, + /* 21*/ { -1, 3, -1, "A", 108, 0, 42, 42, "" }, + /* 22*/ { -1, 3, -1, "A", 109, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 3, requires 80 codewords (maximum 79)" }, + /* 23*/ { -1, 4, -1, "A", 202, 0, 54, 54, "" }, + /* 24*/ { -1, 4, -1, "A", 203, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 4, requires 147 codewords (maximum 146)" }, + /* 25*/ { -1, 5, -1, "1", 453, 0, 66, 66, "" }, + /* 26*/ { -1, 5, -1, "1", 454, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 5, requires 220 codewords (maximum 218)" }, + /* 27*/ { -1, 6, -1, "1", 633, 0, 78, 78, "" }, + /* 28*/ { -1, 6, -1, "1", 634, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 6, requires 306 codewords (maximum 305)" }, + /* 29*/ { -1, 7, -1, "\200", 352, 0, 90, 90, "" }, + /* 30*/ { -1, 7, -1, "\200", 353, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 7, requires 406 codewords (maximum 405)" }, + /* 31*/ { -1, 8, -1, "A", 727, 0, 102, 102, "" }, + /* 32*/ { -1, 8, -1, "A", 728, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 8, requires 522 codewords (maximum 521)" }, + /* 33*/ { -1, 9, -1, "A", 908, 0, 114, 114, "" }, + /* 34*/ { -1, 9, -1, "A", 909, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 9, requires 651 codewords (maximum 650)" }, + /* 35*/ { -1, 10, -1, "1", 1662, 0, 126, 126, "" }, + /* 36*/ { -1, 10, -1, "1", 1663, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 10, requires 796 codewords (maximum 794)" }, + /* 37*/ { -1, 11, -1, "1", 1995, 0, 138, 138, "" }, + /* 38*/ { -1, 11, -1, "1", 1996, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 11, requires 954 codewords (maximum 953)" }, + /* 39*/ { -1, 11, -1, "1", 2748, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 11, requires 1311 codewords (maximum 953)" }, + /* 40*/ { -1, 12, -1, "1", 2355, 0, 150, 150, "" }, + /* 41*/ { -1, 12, -1, "1", 2356, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 12, requires 1126 codewords (maximum 1125)" }, + /* 42*/ { 2, 12, -1, "1", 2355, 0, 150, 150, "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -105,18 +107,26 @@ static void test_large(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length); - assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf)); + assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", + i, data[i].length, (int) strlen(data_buf)); - length = testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data_buf, data[i].length, debug); + length = testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, -1 /*input_mode*/, -1 /*eci*/, + data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, + data_buf, data[i].length, debug); ret = ZBarcode_Encode(symbol, TCU(data_buf), length); - 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); - assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); + 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", + i, ret ? "set" : "empty", symbol->errtxt); + assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", + i, symbol->errtxt, data[i].expected_errtxt); if (ret < ZINT_ERROR) { - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", + i, symbol->rows, data[i].expected_rows); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", + i, symbol->width, data[i].expected_width); } ZBarcode_Delete(symbol); diff --git a/backend/tests/test_gs1.c b/backend/tests/test_gs1.c index b06e8883..54507439 100644 --- a/backend/tests/test_gs1.c +++ b/backend/tests/test_gs1.c @@ -2910,6 +2910,8 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) { struct item { int symbology; int input_mode; + int output_options; + float height; const char *data; const char *composite; int ret; @@ -2917,261 +2919,263 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_GS1_128, -1, "[01]12345678901231", "", 0, "" }, - /* 1*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" }, - /* 2*/ { BARCODE_GS1_128, -1, "[01]12345678901234", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'" }, - /* 3*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]12345678901234", "", 0, "" }, - /* 4*/ { BARCODE_GS1_128, -1, "^0112345678901234", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'" }, - /* 5*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^0112345678901234", "", 0, "" }, - /* 6*/ { BARCODE_GS1_128, GS1RAW_MODE, "0112345678901234", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'" }, - /* 7*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "0112345678901234", "", 0, "" }, - /* 8*/ { BARCODE_GS1_128, -1, "[01]123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1" }, - /* 9*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]123456789012345", "", 0, "" }, - /* 10*/ { BARCODE_GS1_128, -1, "^01123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 859: Invalid data length for AI (01) at position 2" }, - /* 11*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^01123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 859: Invalid data length for AI (01) at position 2" }, /* Raw/caret need underlong data lengths to work - also new so no need for backward-compatibility */ - /* 12*/ { BARCODE_GS1_128, GS1RAW_MODE, "01123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 859: Invalid data length for AI (01) at position 1" }, - /* 13*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "01123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 859: Invalid data length for AI (01) at position 1" }, - /* 14*/ { BARCODE_GS1_128, -1, "[01]1234567890123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1" }, - /* 15*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]1234567890123", "", 0, "" }, - /* 16*/ { BARCODE_GS1_128, -1, "^011234567890123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 2" }, - /* 17*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^011234567890123", "", 0, "" }, /* Raw/caret too short data lengths ok */ - /* 18*/ { BARCODE_GS1_128, GS1RAW_MODE, "011234567890123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1" }, - /* 19*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "011234567890123", "", 0, "" }, - /* 20*/ { BARCODE_GS1_128, -1, "^011234567890123^", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 2" }, - /* 21*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^011234567890123^", "", 0, "" }, - /* 22*/ { BARCODE_GS1_128, GS1RAW_MODE, "011234567890123\035", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1" }, - /* 23*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "011234567890123\035", "", 0, "" }, - /* 24*/ { BARCODE_GS1_128, -1, "[01]12345678901231[20]1", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 19" }, - /* 25*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]12345678901231[20]1", "", 0, "" }, - /* 26*/ { BARCODE_GS1_128, -1, "^0112345678901231201", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 18" }, - /* 27*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^0112345678901231201", "", 0, "" }, - /* 28*/ { BARCODE_GS1_128, GS1RAW_MODE, "0112345678901231201", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 17" }, - /* 29*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "0112345678901231201", "", 0, "" }, - /* 30*/ { BARCODE_GS1_128, -1, "^0112345678901231201^", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 18" }, - /* 31*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^0112345678901231201^", "", 0, "" }, - /* 32*/ { BARCODE_GS1_128, GS1RAW_MODE, "0112345678901231201\035", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 17" }, - /* 33*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "0112345678901231201\035", "", 0, "" }, - /* 34*/ { BARCODE_GS1_128, -1, "^0112345678901231^201", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 19" }, - /* 35*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^0112345678901231^201", "", 0, "" }, - /* 36*/ { BARCODE_GS1_128, GS1RAW_MODE, "0112345678901231\035201", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 18" }, - /* 37*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "0112345678901231\035201", "", 0, "" }, - /* 38*/ { BARCODE_GS1_128, -1, "[03]123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (03) at position 1" }, - /* 39*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[03]123", "", 0, "" }, - /* 40*/ { BARCODE_GS1_128, -1, "^03123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (03) at position 2" }, - /* 41*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^03123", "", 0, "" }, - /* 42*/ { BARCODE_GS1_128, GS1RAW_MODE, "03123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (03) at position 1" }, - /* 43*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "03123", "", 0, "" }, - /* 44*/ { BARCODE_GS1_128, -1, "[04]1234[05]12345[06]123456", "", ZINT_ERROR_INVALID_DATA, "Error 260: Invalid AI (04) at position 1" }, - /* 45*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[04]1234[05]12345[06]123456", "", 0, "" }, - /* 46*/ { BARCODE_GS1_128, -1, "^041234^0512345^06123456", "", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (04) at position 2" }, - /* 47*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^041234^0512345^06123456", "", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (04) at position 2" }, /* Raw/caret mode needs valid AIs to work */ - /* 48*/ { BARCODE_GS1_128, GS1RAW_MODE, "041234\0350512345\03506123456", "", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (04) at position 1" }, - /* 49*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "041234\0350512345\03506123456", "", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (04) at position 1" }, - /* 50*/ { BARCODE_GS1_128, -1, "[01]1234567890123A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Non-numeric character 'A'" }, - /* 51*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]1234567890123A", "", 0, "" }, - /* 52*/ { BARCODE_GS1_128, -1, "^011234567890123A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Non-numeric character 'A'" }, - /* 53*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^011234567890123A", "", 0, "" }, - /* 54*/ { BARCODE_GS1_128, GS1RAW_MODE, "011234567890123A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Non-numeric character 'A'" }, - /* 55*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "011234567890123A", "", 0, "" }, - /* 56*/ { BARCODE_GS1_128, -1, "[01]1234567890123.", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Non-numeric character '.'" }, - /* 57*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]1234567890123.", "", 0, "" }, - /* 58*/ { BARCODE_GS1_128, -1, "[01]1234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, - /* 59*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]1234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */ - /* 60*/ { BARCODE_GS1_128, -1, "^011234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, - /* 61*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^011234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, - /* 62*/ { BARCODE_GS1_128, GS1RAW_MODE, "011234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, - /* 63*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "011234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, - /* 64*/ { BARCODE_GS1_128, -1, "[01]1234567890123\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, - /* 65*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]1234567890123\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */ - /* 66*/ { BARCODE_GS1_128, -1, "0112345678901231", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, - /* 67*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "0112345678901231", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */ - /* 68*/ { BARCODE_GS1_128, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (01) at position 1" }, - /* 69*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]", "", 0, "" }, /* Zero-length data not checked */ - /* 70*/ { BARCODE_GS1_128, -1, "^01", "", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (01) at position 2" }, - /* 71*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^01", "", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (01) at position 2" }, /* Raw/caret mode needs valid data_lengths to work */ - /* 72*/ { BARCODE_GS1_128, GS1RAW_MODE, "01", "", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (01) at position 1" }, - /* 73*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, "01", "", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (01) at position 1" }, - /* 74*/ { BARCODE_GS1_128, -1, "[01][20]12", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (01) at position 1" }, - /* 75*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01][20]12", "", 0, "" }, /* Zero-length data not checked */ - /* 76*/ { BARCODE_GS1_128, -1, "[0]123", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /* 77*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[0]123", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI with no data still checked */ - /* 78*/ { BARCODE_GS1_128, -1, "[0]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /* 79*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[0]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI with no data still checked */ - /* 80*/ { BARCODE_GS1_128, -1, "^0", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 2" }, - /* 81*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^0", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 2" }, - /* 82*/ { BARCODE_GS1_128, -1, "[]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /* 83*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[]12", "", 0, "" }, /* Length 0 AI with data not checked */ - /* 84*/ { BARCODE_GS1_128, -1, "[]12[01]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /* 85*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[]12[01]", "", 0, "" }, /* Length 0 AI with data not checked, non-short AI with zero-length data not checked */ - /* 86*/ { BARCODE_GS1_128, -1, "[01][]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short)" }, - /* 87*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01][]12", "", 0, "" }, /* Length 0 AI with data not checked, non-short AI with zero-length data not checked */ - /* 88*/ { BARCODE_GS1_128, -1, "[1]1[]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short)" }, - /* 89*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[1]1[]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short)" }, /* Length 1 AI with data still checked */ - /* 90*/ { BARCODE_GS1_128, -1, "[]12[1]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /* 91*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[]12[1]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI with data still checked */ - /* 92*/ { BARCODE_GS1_128, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /* 93*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 0 AI with no data still checked */ - /* 94*/ { BARCODE_GS1_128, -1, "^", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 1" }, - /* 95*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "^", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 1" }, - /* 96*/ { BARCODE_GS1_128, -1, "[01]12345678901231[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, - /* 97*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]12345678901231[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, /* Length 0 AI with no data still checked */ - /* 98*/ { BARCODE_GS1_128, -1, "[01]12345678901231[][20]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, - /* 99*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]12345678901231[][20]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, /* Length 0 AI with no data still checked */ - /*100*/ { BARCODE_GS1_128, -1, "[01]12345678901231[]1[20]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, - /*101*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]12345678901231[]1[20]12", "", 0, "" }, /* Length 0 AI with data not checked */ - /*102*/ { BARCODE_GS1_128, -1, "[1234567890]123", "", ZINT_ERROR_INVALID_DATA, "Error 255: Invalid AI at position 1 in input (AI too long)" }, - /*103*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[1234567890]123", "", ZINT_ERROR_INVALID_DATA, "Error 255: Invalid AI at position 1 in input (AI too long)" }, /* Too long still checked */ - /*104*/ { BARCODE_GS1_128, -1, "[12345]123", "", ZINT_ERROR_INVALID_DATA, "Error 255: Invalid AI at position 1 in input (AI too long)" }, - /*105*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[12345]123", "", ZINT_ERROR_INVALID_DATA, "Error 255: Invalid AI at position 1 in input (AI too long)" }, /* Too long still checked */ - /*106*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)AB[", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (91) data position 3: Invalid CSET 82 character '['" }, - /*107*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, "(91)AB[", "", 0, "" }, - /*108*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]12", 0, "" }, - /*109*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[20]12", 0, "" }, - /*110*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901234", "[20]12", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1' (linear component)" }, - /*111*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901234", "[20]12", 0, "" }, - /*112*/ { BARCODE_GS1_128_CC, -1, "[01]123456789012345", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1 (linear component)" }, - /*113*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]123456789012345", "[20]12", 0, "" }, - /*114*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]123", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 1 (2D component)" }, - /*115*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[20]123", 0, "" }, - /*116*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)" }, - /*117*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[20]1A", 0, "" }, - /*118*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (linear component)" }, - /*119*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (linear component)" }, /* Nonprintable ASCII still checked */ - /*120*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, - /*121*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */ - /*122*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" }, - /*123*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" }, - /*124*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, - /*125*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */ - /*126*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, - /*127*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */ - /*128*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (20) at position 1 (2D component)" }, - /*129*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]", 0, "" }, /* Zero-length data not checked */ - /*130*/ { BARCODE_GS1_128_CC, -1, "^011234567890121", "^20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 2 (2D component)" }, - /*131*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "^011234567890121", "^20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 2 (2D component)" }, - /*132*/ { BARCODE_GS1_128_CC, GS1RAW_MODE, "011234567890121", "20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 1 (2D component)" }, - /*133*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE | GS1RAW_MODE, "011234567890121", "20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 1 (2D component)" }, - /*134*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "^011234567890121", "^20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 2 (2D component)" }, - /*135*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, - /*136*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */ - /*137*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, - /*138*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */ - /*139*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" }, - /*140*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */ - /*141*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, - /*142*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ - /*143*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, - /*144*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ - /*145*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, - /*146*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ - /*147*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, - /*148*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite data */ - /*149*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "", 0, "" }, - /*150*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" }, - /*151*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26" }, - /*152*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" }, - /*153*/ { BARCODE_DBAR_EXP, -1, "^011234567890123110123^111234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 24" }, - /*154*/ { BARCODE_DBAR_EXP, GS1RAW_MODE, "011234567890123110123\035111234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 23" }, - /*155*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26" }, - /*156*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" }, - /*157*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 6: Non-numeric character 'A'" }, - /*158*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" }, - /*159*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, - /*160*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */ - /*161*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, - /*162*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */ - /*163*/ { BARCODE_DBAR_EXP, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, - /*164*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */ - /*165*/ { BARCODE_DBAR_EXP, -1, "[10]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (10) at position 1" }, - /*166*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[10]", "", 0, "" }, /* Zero-length data not checked */ - /*167*/ { BARCODE_DBAR_EXP, -1, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /*168*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI still checked */ - /*169*/ { BARCODE_DBAR_EXP, -1, "[]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /*170*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]1", "", 0, "" }, /* Length 0 AI with data not checked */ - /*171*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE | GS1RAW_MODE, "1", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 1" }, /* Checked as AI */ - /*172*/ { BARCODE_DBAR_EXP, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /*173*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 0 AI with no data still checked */ - /*174*/ { BARCODE_DBAR_EXP, -1, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" }, - /*175*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" }, /* Length 0 AI with no data still checked */ - /*176*/ { BARCODE_DBAR_EXP, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, - /*177*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXP */ - /*178*/ { BARCODE_DBAR_EXP, -1, "[]01914190S5(60)1239322", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, - /*179*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]019000000000000039302", "", 0, "" }, /* Encoding method 6 */ - /*180*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "^019000000000000039302", "", 0, "" }, - /*181*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE | GS1RAW_MODE, "019000000000000039302", "", 0, "" }, - /*182*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" }, - /*183*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" }, - /*184*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26 (linear component)" }, - /*185*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" }, - /*186*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 3: Invalid month '34' (linear component)" }, - /*187*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" }, - /*188*/ { BARCODE_DBAR_EXP_CC, -1, "^011234567890123110123^11123456", "^21ABC123^2212345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 3: Invalid month '34' (linear component)" }, - /*189*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "^011234567890123110123^11123456", "^21ABC123^2212345", 0, "" }, - /*190*/ { BARCODE_DBAR_EXP_CC, GS1RAW_MODE, "011234567890123110123\03511123456", "21ABC123\0352212345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 3: Invalid month '34' (linear component)" }, - /*191*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE | GS1RAW_MODE, "011234567890123110123\03511123456", "21ABC123\0352212345", 0, "" }, - /*192*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) at position 20 (2D component)" }, - /*193*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" }, - /*194*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) data position 8: Non-numeric character 'A' (2D component)" }, - /*195*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" }, - /*196*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, - /*197*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */ - /*198*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, - /*199*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */ - /*200*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, - /*201*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */ - /*202*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[10]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (10) at position 1 (2D component)" }, - /*203*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[10]", 0, "" }, /* Zero-length data not checked */ - /*204*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, - /*205*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */ - /*206*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, - /*207*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */ - /*208*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, - /*209*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ - /*210*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, - /*211*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ - /*212*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, - /*213*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */ - /*214*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "", 0, "" }, - /*215*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" }, - /*216*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26" }, - /*217*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" }, - /*218*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26" }, - /*219*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" }, - /*220*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 6: Non-numeric character 'A'" }, - /*221*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" }, - /*222*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, - /*223*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */ - /*224*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, - /*225*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */ - /*226*/ { BARCODE_DBAR_EXPSTK, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, - /*227*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */ - /*228*/ { BARCODE_DBAR_EXPSTK, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (01) at position 1" }, - /*229*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]", "", 0, "" }, /* Zero-length data not checked */ - /*230*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, - /*231*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXPSTK */ - /*232*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" }, - /*233*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" }, - /*234*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26 (linear component)" }, - /*235*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" }, - /*236*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 3: Invalid month '34' (linear component)" }, - /*237*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" }, - /*238*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) at position 20 (2D component)" }, - /*239*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" }, - /*240*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) data position 8: Non-numeric character 'A' (2D component)" }, - /*241*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" }, - /*242*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, - /*243*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */ - /*244*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, - /*245*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */ - /*246*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, - /*247*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */ - /*248*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[235]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (235) at position 1 (2D component)" }, - /*249*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[235]", 0, "" }, /* Zero-length data not checked */ - /*250*/ { BARCODE_DBAR_EXPSTK_CC, -1, "^011234567890121", "^235", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (23) at position 2 (2D component)" }, - /*251*/ { BARCODE_DBAR_EXPSTK_CC, GS1RAW_MODE, "011234567890121", "235", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (23) at position 1 (2D component)" }, - /*252*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, - /*253*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */ - /*254*/ { BARCODE_DBAR_EXPSTK_CC, -1, "^011234567890121", "^", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 1 (2D component)" }, + /* 0*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]12345678901231", "", 0, "" }, + /* 1*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231", "", 0, "" }, + /* 2*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]12345678901234", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'" }, + /* 3*/ { BARCODE_GS1_128, -1, COMPLIANT_HEIGHT, 1.0f, "[01]12345678901234", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'" }, + /* 4*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901234", "", 0, "" }, + /* 5*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, COMPLIANT_HEIGHT, 1.0f, "[01]12345678901234", "", ZINT_WARN_NONCOMPLIANT, "Warning 247: Height not compliant with standards (too small)" }, + /* 6*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^0112345678901234", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'" }, + /* 7*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^0112345678901234", "", 0, "" }, + /* 8*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "0112345678901234", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'" }, + /* 9*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "0112345678901234", "", 0, "" }, + /* 10*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1" }, + /* 11*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]123456789012345", "", 0, "" }, + /* 12*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^01123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 859: Invalid data length for AI (01) at position 2" }, + /* 13*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^01123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 859: Invalid data length for AI (01) at position 2" }, /* Raw/caret need underlong data lengths to work - also new so no need for backward-compatibility */ + /* 14*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "01123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 859: Invalid data length for AI (01) at position 1" }, + /* 15*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "01123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 859: Invalid data length for AI (01) at position 1" }, + /* 16*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]1234567890123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1" }, + /* 17*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890123", "", 0, "" }, + /* 18*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^011234567890123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 2" }, + /* 19*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^011234567890123", "", 0, "" }, /* Raw/caret too short data lengths ok */ + /* 20*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "011234567890123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1" }, + /* 21*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "011234567890123", "", 0, "" }, + /* 22*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^011234567890123^", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 2" }, + /* 23*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^011234567890123^", "", 0, "" }, + /* 24*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "011234567890123\035", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1" }, + /* 25*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "011234567890123\035", "", 0, "" }, + /* 26*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]12345678901231[20]1", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 19" }, + /* 27*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[20]1", "", 0, "" }, + /* 28*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^0112345678901231201", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 18" }, + /* 29*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^0112345678901231201", "", 0, "" }, + /* 30*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "0112345678901231201", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 17" }, + /* 31*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "0112345678901231201", "", 0, "" }, + /* 32*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^0112345678901231201^", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 18" }, + /* 33*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^0112345678901231201^", "", 0, "" }, + /* 34*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "0112345678901231201\035", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 17" }, + /* 35*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "0112345678901231201\035", "", 0, "" }, + /* 36*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^0112345678901231^201", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 19" }, + /* 37*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^0112345678901231^201", "", 0, "" }, + /* 38*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "0112345678901231\035201", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 18" }, + /* 39*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "0112345678901231\035201", "", 0, "" }, + /* 40*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[03]123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (03) at position 1" }, + /* 41*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[03]123", "", 0, "" }, + /* 42*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^03123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (03) at position 2" }, + /* 43*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^03123", "", 0, "" }, + /* 44*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "03123", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (03) at position 1" }, + /* 45*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "03123", "", 0, "" }, + /* 46*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[04]1234[05]12345[06]123456", "", ZINT_ERROR_INVALID_DATA, "Error 260: Invalid AI (04) at position 1" }, + /* 47*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[04]1234[05]12345[06]123456", "", 0, "" }, + /* 48*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^041234^0512345^06123456", "", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (04) at position 2" }, + /* 49*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^041234^0512345^06123456", "", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (04) at position 2" }, /* Raw/caret mode needs valid AIs to work */ + /* 50*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "041234\0350512345\03506123456", "", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (04) at position 1" }, + /* 51*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "041234\0350512345\03506123456", "", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (04) at position 1" }, + /* 52*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]1234567890123A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Non-numeric character 'A'" }, + /* 53*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890123A", "", 0, "" }, + /* 54*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^011234567890123A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Non-numeric character 'A'" }, + /* 55*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^011234567890123A", "", 0, "" }, + /* 56*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "011234567890123A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Non-numeric character 'A'" }, + /* 57*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "011234567890123A", "", 0, "" }, + /* 58*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]1234567890123.", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Non-numeric character '.'" }, + /* 59*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890123.", "", 0, "" }, + /* 60*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]1234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, + /* 61*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */ + /* 62*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^011234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, + /* 63*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^011234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, + /* 64*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "011234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, + /* 65*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "011234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, + /* 66*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]1234567890123\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, + /* 67*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890123\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */ + /* 68*/ { BARCODE_GS1_128, -1, -1, 0.0f, "0112345678901231", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, + /* 69*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "0112345678901231", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */ + /* 70*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (01) at position 1" }, + /* 71*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]", "", 0, "" }, /* Zero-length data not checked */ + /* 72*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^01", "", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (01) at position 2" }, + /* 73*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^01", "", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (01) at position 2" }, /* Raw/caret mode needs valid data_lengths to work */ + /* 74*/ { BARCODE_GS1_128, GS1RAW_MODE, -1, 0.0f, "01", "", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (01) at position 1" }, + /* 75*/ { BARCODE_GS1_128, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "01", "", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (01) at position 1" }, + /* 76*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01][20]12", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (01) at position 1" }, + /* 77*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01][20]12", "", 0, "" }, /* Zero-length data not checked */ + /* 78*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[0]123", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /* 79*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[0]123", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI with no data still checked */ + /* 80*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[0]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /* 81*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[0]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI with no data still checked */ + /* 82*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^0", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 2" }, + /* 83*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^0", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 2" }, + /* 84*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /* 85*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[]12", "", 0, "" }, /* Length 0 AI with data not checked */ + /* 86*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[]12[01]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /* 87*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[]12[01]", "", 0, "" }, /* Length 0 AI with data not checked, non-short AI with zero-length data not checked */ + /* 88*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01][]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short)" }, + /* 89*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01][]12", "", 0, "" }, /* Length 0 AI with data not checked, non-short AI with zero-length data not checked */ + /* 90*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[1]1[]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short)" }, + /* 91*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[1]1[]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short)" }, /* Length 1 AI with data still checked */ + /* 92*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[]12[1]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /* 93*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[]12[1]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI with data still checked */ + /* 94*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /* 95*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 0 AI with no data still checked */ + /* 96*/ { BARCODE_GS1_128, -1, -1, 0.0f, "^", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 1" }, + /* 97*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "^", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 1" }, + /* 98*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]12345678901231[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, + /* 99*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, /* Length 0 AI with no data still checked */ + /*100*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]12345678901231[][20]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, + /*101*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[][20]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, /* Length 0 AI with no data still checked */ + /*102*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[01]12345678901231[]1[20]12", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 19 in input (AI too short)" }, + /*103*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[]1[20]12", "", 0, "" }, /* Length 0 AI with data not checked */ + /*104*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[1234567890]123", "", ZINT_ERROR_INVALID_DATA, "Error 255: Invalid AI at position 1 in input (AI too long)" }, + /*105*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[1234567890]123", "", ZINT_ERROR_INVALID_DATA, "Error 255: Invalid AI at position 1 in input (AI too long)" }, /* Too long still checked */ + /*106*/ { BARCODE_GS1_128, -1, -1, 0.0f, "[12345]123", "", ZINT_ERROR_INVALID_DATA, "Error 255: Invalid AI at position 1 in input (AI too long)" }, + /*107*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, 0.0f, "[12345]123", "", ZINT_ERROR_INVALID_DATA, "Error 255: Invalid AI at position 1 in input (AI too long)" }, /* Too long still checked */ + /*108*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, 0.0f, "(91)AB[", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (91) data position 3: Invalid CSET 82 character '['" }, + /*109*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0.0f, "(91)AB[", "", 0, "" }, + /*110*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]12345678901231", "[20]12", 0, "" }, + /*111*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231", "[20]12", 0, "" }, + /*112*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]12345678901234", "[20]12", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1' (linear component)" }, + /*113*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901234", "[20]12", 0, "" }, + /*114*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]123456789012345", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (01) at position 1 (linear component)" }, + /*115*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]123456789012345", "[20]12", 0, "" }, + /*116*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]12345678901231", "[20]123", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (20) at position 1 (2D component)" }, + /*117*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231", "[20]123", 0, "" }, + /*118*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) data position 2: Non-numeric character 'A' (2D component)" }, + /*119*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231", "[20]1A", 0, "" }, + /*120*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (linear component)" }, + /*121*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (linear component)" }, /* Nonprintable ASCII still checked */ + /*122*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, + /*123*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */ + /*124*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" }, + /*125*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" }, + /*126*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, + /*127*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */ + /*128*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, + /*129*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */ + /*130*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (20) at position 1 (2D component)" }, + /*131*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]", 0, "" }, /* Zero-length data not checked */ + /*132*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "^011234567890121", "^20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 2 (2D component)" }, + /*133*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "^011234567890121", "^20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 2 (2D component)" }, + /*134*/ { BARCODE_GS1_128_CC, GS1RAW_MODE, -1, 0.0f, "011234567890121", "20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 1 (2D component)" }, + /*135*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "011234567890121", "20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 1 (2D component)" }, + /*136*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "^011234567890121", "^20", ZINT_ERROR_INVALID_DATA, "Error 858: Empty data field for AI (20) at position 2 (2D component)" }, + /*137*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, + /*138*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */ + /*139*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, + /*140*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */ + /*141*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" }, + /*142*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */ + /*143*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, + /*144*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ + /*145*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, + /*146*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ + /*147*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, + /*148*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ + /*149*/ { BARCODE_GS1_128_CC, -1, -1, 0.0f, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, + /*150*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite data */ + /*151*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[01]12345678901231", "", 0, "" }, + /*152*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231", "", 0, "" }, + /*153*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26" }, + /*154*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]1234", "", 0, "" }, + /*155*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "^011234567890123110123^111234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 24" }, + /*156*/ { BARCODE_DBAR_EXP, GS1RAW_MODE, -1, 0.0f, "011234567890123110123\035111234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 23" }, + /*157*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26" }, + /*158*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]1234A", "", 0, "" }, + /*159*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 6: Non-numeric character 'A'" }, + /*160*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]12345A", "", 0, "" }, + /*161*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, + /*162*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */ + /*163*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, + /*164*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */ + /*165*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, + /*166*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */ + /*167*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[10]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (10) at position 1" }, + /*168*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[10]", "", 0, "" }, /* Zero-length data not checked */ + /*169*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /*170*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI still checked */ + /*171*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /*172*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[]1", "", 0, "" }, /* Length 0 AI with data not checked */ + /*173*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "1", "", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 1" }, /* Checked as AI */ + /*174*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /*175*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 0 AI with no data still checked */ + /*176*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" }, + /*177*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" }, /* Length 0 AI with no data still checked */ + /*178*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, + /*179*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXP */ + /*180*/ { BARCODE_DBAR_EXP, -1, -1, 0.0f, "[]01914190S5(60)1239322", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, + /*181*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "[]019000000000000039302", "", 0, "" }, /* Encoding method 6 */ + /*182*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, 0.0f, "^019000000000000039302", "", 0, "" }, + /*183*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "019000000000000039302", "", 0, "" }, + /*184*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" }, + /*185*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" }, + /*186*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26 (linear component)" }, + /*187*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" }, + /*188*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 3: Invalid month '34' (linear component)" }, + /*189*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" }, + /*190*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "^011234567890123110123^11123456", "^21ABC123^2212345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 3: Invalid month '34' (linear component)" }, + /*191*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "^011234567890123110123^11123456", "^21ABC123^2212345", 0, "" }, + /*192*/ { BARCODE_DBAR_EXP_CC, GS1RAW_MODE, -1, 0.0f, "011234567890123110123\03511123456", "21ABC123\0352212345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 3: Invalid month '34' (linear component)" }, + /*193*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE | GS1RAW_MODE, -1, 0.0f, "011234567890123110123\03511123456", "21ABC123\0352212345", 0, "" }, + /*194*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) at position 20 (2D component)" }, + /*195*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" }, + /*196*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) data position 8: Non-numeric character 'A' (2D component)" }, + /*197*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" }, + /*198*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, + /*199*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */ + /*200*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, + /*201*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */ + /*202*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, + /*203*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */ + /*204*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "[10]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (10) at position 1 (2D component)" }, + /*205*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[10]", 0, "" }, /* Zero-length data not checked */ + /*206*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, + /*207*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */ + /*208*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, + /*209*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */ + /*210*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, + /*211*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ + /*212*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, + /*213*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */ + /*214*/ { BARCODE_DBAR_EXP_CC, -1, -1, 0.0f, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, + /*215*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */ + /*216*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "[01]12345678901231", "", 0, "" }, + /*217*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231", "", 0, "" }, + /*218*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26" }, + /*219*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]1234", "", 0, "" }, + /*220*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26" }, + /*221*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]1234A", "", 0, "" }, + /*222*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 6: Non-numeric character 'A'" }, + /*223*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]12345A", "", 0, "" }, + /*224*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, + /*225*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */ + /*226*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, + /*227*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */ + /*228*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, + /*229*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */ + /*230*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (01) at position 1" }, + /*231*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "[01]", "", 0, "" }, /* Zero-length data not checked */ + /*232*/ { BARCODE_DBAR_EXPSTK, -1, -1, 0.0f, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, + /*233*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, 0.0f, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXPSTK */ + /*234*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" }, + /*235*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" }, + /*236*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) at position 26 (linear component)" }, + /*237*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" }, + /*238*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) data position 3: Invalid month '34' (linear component)" }, + /*239*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" }, + /*240*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) at position 20 (2D component)" }, + /*241*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" }, + /*242*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) data position 8: Non-numeric character 'A' (2D component)" }, + /*243*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" }, + /*244*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, + /*245*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */ + /*246*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, + /*247*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */ + /*248*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, + /*249*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */ + /*250*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]1234567890121", "[235]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field for AI (235) at position 1 (2D component)" }, + /*251*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[235]", 0, "" }, /* Zero-length data not checked */ + /*252*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "^011234567890121", "^235", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (23) at position 2 (2D component)" }, + /*253*/ { BARCODE_DBAR_EXPSTK_CC, GS1RAW_MODE, -1, 0.0f, "011234567890121", "235", ZINT_ERROR_INVALID_DATA, "Error 856: Invalid AI (23) at position 1 (2D component)" }, + /*254*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, + /*255*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, 0.0f, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */ + /*256*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 0.0f, "^011234567890121", "^", ZINT_ERROR_INVALID_DATA, "Error 857: Invalid AI at position 1 (2D component)" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -3195,8 +3199,11 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) { text = data[i].data; } length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, - -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, text, -1, debug); + if (data[i].height) { + symbol->height = data[i].height; + } ret = ZBarcode_Encode(symbol, TCU(text), length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", @@ -3429,6 +3436,26 @@ static void test_gs1_lint_parse_raw_caret(const testCtx *const p_ctx) { /* 47*/ { "1012345678901234567890211", 0, 0, { 10, 0, 0, 0 }, { 0, 0, 0, 0 }, { 2, 0, 0, 0 }, { 20, 0, 0, 0 }, 2, 1 }, /* Ticket #352, props Simon Resch */ /* 48*/ { "^1012345678901234567890^211", 1, 2, { 10, 21, 0, 0 }, { 1, 24, 0, 0 }, { 3, 26, 0, 0 }, { 20, 1, 0, 0 }, 0, 0 }, /* 49*/ { "1012345678901234567890\035211", 1, 2, { 10, 21, 0, 0 }, { 0, 23, 0, 0 }, { 2, 25, 0, 0 }, { 20, 1, 0, 0 }, 0, 0 }, + /* 50*/ { "^243a^400b^40213131313131313130^420a", 1, 4, { 243, 400, 402, 420 }, { 1, 6, 11, 32 }, { 4, 9, 14, 35 }, { 1, 1, 17, 1 }, 0, 0 }, + /* 51*/ { "^421434a^423470^427a^710a", 1, 4, { 421, 423, 427, 710 }, { 1, 9, 16, 21 }, { 4, 12, 19, 24 }, { 4, 3, 1, 1 }, 0, 0 }, + /* 52*/ { "^3240123456^3270123456^3305123456^3340123456", 1, 4, { 3240, 3270, 3305, 3340 }, { 1, 12, 23, 34 }, { 5, 16, 27, 38 }, { 6, 6, 6, 6 }, 0, 0 }, + /* 53*/ { "^3570123456^3605123456^3640123456^3670123456", 1, 4, { 3570, 3605, 3640, 3670 }, { 1, 12, 23, 34 }, { 5, 16, 27, 38 }, { 6, 6, 6, 6 }, 0, 0 }, + /* 54*/ { "^3370123456^3470123456^4300a^7008%12", 1, 4, { 3370, 3470, 4300, 7008 }, { 1, 12, 23, 29 }, { 5, 16, 27, 33 }, { 6, 6, 1, 3 }, 0, 0 }, + /* 55*/ { "^3950123456^4302a^4307DE^4308a", 1, 4, { 3950, 4302, 4307, 4308 }, { 1, 12, 18, 25 }, { 5, 16, 22, 29 }, { 6, 1, 2, 1 }, 0, 0 }, + /* 56*/ { "^430912345678901234567890^4318a^43210^43240101010000", 1, 4, { 4309, 4318, 4321, 4324 }, { 1, 26, 32, 38 }, { 5, 30, 36, 42 }, { 20, 1, 1, 10 }, 0, 0 }, + /* 57*/ { "^4326010101^4330123456^70011234567890123^7002a", 1, 4, { 4326, 4330, 7001, 7002 }, { 1, 12, 23, 41 }, { 5, 16, 27, 45 }, { 6, 6, 13, 1 }, 0, 0 }, + /* 58*/ { "^70030101010000^70040^7005a^7007010101", 1, 4, { 7003, 7004, 7005, 7007 }, { 1, 16, 22, 28 }, { 5, 20, 26, 32 }, { 10, 1, 1, 6 }, 0, 0 }, + /* 59*/ { "^7009a^7010a^7011010101^7010a", 1, 4, { 7009, 7010, 7011, 7010 }, { 1, 7, 13, 24 }, { 5, 11, 17, 28 }, { 1, 1, 6, 1 }, 0, 0 }, + /* 60*/ { "^7011010101^7020a^70231234^7030004a", 1, 4, { 7011, 7020, 7023, 7030 }, { 1, 12, 18, 27 }, { 5, 16, 22, 31 }, { 6, 1, 4, 4 }, 0, 0 }, + /* 61*/ { "^70401xyz^70419^7230abc^7240a", 1, 4, { 7040, 7041, 7230, 7240 }, { 1, 10, 16, 24 }, { 5, 14, 20, 28 }, { 4, 1, 3, 1 }, 0, 0 }, + /* 62*/ { "^724109^7242a^725020000101^7251190406160800", 1, 4, { 7241, 7242, 7250, 7251 }, { 1, 8, 14, 27 }, { 5, 12, 18, 31 }, { 2, 1, 8, 12 }, 0, 0 }, + /* 63*/ { "^72520^7253a^7255a^7256a", 1, 4, { 7252, 7253, 7255, 7256 }, { 1, 7, 13, 19 }, { 5, 11, 17, 23 }, { 1, 1, 1, 1 }, 0, 0 }, + /* 64*/ { "^7257a^72582/3^8002a^800301234567890128a", 1, 4, { 7257, 7258, 8002, 8003 }, { 1, 7, 15, 21 }, { 5, 11, 19, 25 }, { 1, 3, 1, 15 }, 0, 0 }, + /* 65*/ { "^80041234^8005123456^8007AD^8009a", 1, 4, { 8004, 8005, 8007, 8009 }, { 1, 10, 21, 28 }, { 5, 14, 25, 32 }, { 4, 6, 2, 1 }, 0, 0 }, + /* 66*/ { "^8011a^8013a^8014a^8017313131313131313131", 1, 4, { 8011, 8013, 8014, 8017 }, { 1, 7, 13, 19 }, { 5, 11, 17, 23 }, { 1, 1, 1, 18 }, 0, 0 }, + /* 67*/ { "^8019a^8020a^8030a^8040123456789012345", 1, 4, { 8019, 8020, 8030, 8040 }, { 1, 7, 13, 19 }, { 5, 11, 17, 23 }, { 1, 1, 1, 15 }, 0, 0 }, + /* 68*/ { "^804212345678901234567890123456789012^8043123456789012345678^8110a^81111234", 1, 4, { 8042, 8043, 8110, 8111 }, { 1, 38, 61, 67 }, { 5, 42, 65, 71 }, { 32, 18, 1, 4 }, 0, 0 }, + /* 69*/ { "^8112a^8006123456789012310101", 1, 2, { 8112, 8006, 0, 0 }, { 1, 7, 0, 0 }, { 5, 11, 0, 0 }, { 1, 18, 0, 0 }, 0, 0 }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -3456,22 +3483,22 @@ static void test_gs1_lint_parse_raw_caret(const testCtx *const p_ctx) { assert_equal(ai_count, data[i].expected_ai_count, "i:%d ai_count %d != %d\n", i, ai_count, data[i].expected_ai_count); assert_zero(memcmp(ai_vals, data[i].expected_ai_vals, sizeof(int) * ARRAY_SIZE(ai_vals)), - "i:%d ai_vals %d,%d,%d,%d != %d,%d,%d,%d\n", i, + "i:%d ai_vals %d, %d, %d, %d != %d, %d, %d, %d\n", i, ai_vals[0], ai_vals[1], ai_vals[2], ai_vals[3], data[i].expected_ai_vals[0], data[i].expected_ai_vals[1], data[i].expected_ai_vals[2], data[i].expected_ai_vals[3]); assert_zero(memcmp(ai_locs, data[i].expected_ai_locs, sizeof(int) * ARRAY_SIZE(ai_locs)), - "i:%d ai_locs %d,%d,%d,%d != %d,%d,%d,%d\n", i, + "i:%d ai_locs %d, %d, %d, %d != %d, %d, %d, %d\n", i, ai_locs[0], ai_locs[1], ai_locs[2], ai_locs[3], data[i].expected_ai_locs[0], data[i].expected_ai_locs[1], data[i].expected_ai_locs[2], data[i].expected_ai_locs[3]); assert_zero(memcmp(data_locs, data[i].expected_data_locs, sizeof(int) * ARRAY_SIZE(data_locs)), - "i:%d data_locs %d,%d,%d,%d != %d,%d,%d,%d\n", i, + "i:%d data_locs %d, %d, %d, %d != %d, %d, %d, %d\n", i, data_locs[0], data_locs[1], data_locs[2], data_locs[3], data[i].expected_data_locs[0], data[i].expected_data_locs[1], data[i].expected_data_locs[2], data[i].expected_data_locs[3]); assert_zero(memcmp(data_lens, data[i].expected_data_lens, sizeof(int) * ARRAY_SIZE(data_lens)), - "i:%d data_lens %d,%d,%d,%d != %d,%d,%d,%d\n", i, + "i:%d data_lens %d, %d, %d, %d != %d, %d, %d, %d\n", i, data_lens[0], data_lens[1], data_lens[2], data_lens[3], data[i].expected_data_lens[0], data[i].expected_data_lens[1], data[i].expected_data_lens[2], data[i].expected_data_lens[3]); diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index e1cc88df..2be3c01e 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -53,6 +53,7 @@ static void test_checks(const testCtx *const p_ctx) { float dot_size; float text_gap; float guard_descent; + int rows; int warn_level; int ret; @@ -61,156 +62,156 @@ static void test_checks(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, "1234", -1, -1, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", -1 }, - /* 1*/ { BARCODE_CODE128, -1, "1234", -1, -1, 0, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, - /* 2*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, - /* 3*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 999999 + 1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: ECI code '1000000' out of range (0 to 999999, excluding 1, 2, 14 and 19)", -1 }, - /* 4*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.009, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 }, - /* 5*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 200.01, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 }, - /* 6*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, -1, 20.1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 }, - /* 7*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.01, 0.009, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 }, - /* 8*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, -0.1, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 765: Height out of range (0 to 2000)", -1 }, - /* 9*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 2000.01, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 765: Height out of range (0 to 2000)", -1 }, - /* 10*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, -1, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 766: Whitespace width out of range (0 to 100)", -1 }, - /* 11*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 101, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 766: Whitespace width out of range (0 to 100)", -1 }, - /* 12*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, -1, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 767: Whitespace height out of range (0 to 100)", -1 }, - /* 13*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 101, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 767: Whitespace height out of range (0 to 100)", -1 }, - /* 14*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, -1, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 768: Border width out of range (0 to 100)", -1 }, - /* 15*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 768: Border width out of range (0 to 100)", -1 }, - /* 16*/ { BARCODE_CODE128, -1, "1234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 220: Selected symbology does not support GS1 mode", -1 }, - /* 17*/ { BARCODE_EAN13, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, -5.1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 219: Text gap out of range (-5 to 10)", -1 }, - /* 18*/ { BARCODE_EANX, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, -5.1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 219: Text gap out of range (-5 to 10)", -1 }, - /* 19*/ { BARCODE_EAN13, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 10.1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 219: Text gap out of range (-5 to 10)", -1 }, - /* 20*/ { BARCODE_EANX, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 10.1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 219: Text gap out of range (-5 to 10)", -1 }, - /* 21*/ { BARCODE_EAN13, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, -0.5, -1, ZINT_ERROR_INVALID_OPTION, "Error 769: Guard bar descent out of range (0 to 50)", -1 }, - /* 22*/ { BARCODE_EANX, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, -0.5, -1, ZINT_ERROR_INVALID_OPTION, "Error 769: Guard bar descent out of range (0 to 50)", -1 }, - /* 23*/ { BARCODE_EAN13, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, 50.1, -1, ZINT_ERROR_INVALID_OPTION, "Error 769: Guard bar descent out of range (0 to 50)", -1 }, - /* 24*/ { BARCODE_EANX, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, 50.1, -1, ZINT_ERROR_INVALID_OPTION, "Error 769: Guard bar descent out of range (0 to 50)", -1 }, - /* 25*/ { BARCODE_GS1_128, -1, "[21]12\0004", 8, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 262: NUL characters not permitted in GS1 mode", -1 }, - /* 26*/ { BARCODE_GS1_128, -1, "[21]12é4", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1", -1 }, - /* 27*/ { BARCODE_GS1_128, -1, "[21]12\0074", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 251: Control characters are not supported by GS1", -1 }, - /* 28*/ { BARCODE_GS1_128, -1, "[21]1234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, - /* 29*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /* 30*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /* 31*/ { 0, -1, "1", -1, -1, 1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", BARCODE_CODE128 }, /* Not supporting beats invalid ECI */ - /* 32*/ { 0, -1, "1", -1, -1, 1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /* 33*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, 0.009, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", BARCODE_CODE128 }, - /* 34*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, 0.009, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /* 35*/ { 0, -1, "1", -1, -1, 1, 0, 0, 0, 0, -1, 0.009, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", BARCODE_CODE128 }, /* Invalid dot size no longer beats invalid ECI */ - /* 36*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, 0.009, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /* 37*/ { 5, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_C25STANDARD }, - /* 38*/ { 5, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_C25STANDARD }, - /* 39*/ { 17, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_UPCA }, - /* 40*/ { 17, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA }, - /* 41*/ { 19, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_TOO_LONG, "Error 362: Input length 1 too short (minimum 3)", BARCODE_CODABAR }, - /* 42*/ { 19, -1, "A1B", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 207: Codabar 18 not supported", BARCODE_CODABAR }, - /* 43*/ { 19, -1, "A1B", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 207: Codabar 18 not supported", -1 }, - /* 44*/ { 26, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_UPCA }, - /* 45*/ { 26, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA }, - /* 46*/ { 27, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 208: UPCD1 not supported", 27 }, - /* 47*/ { 33, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI", BARCODE_GS1_128 }, - /* 48*/ { 33, -1, "[10]23", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_GS1_128 }, - /* 49*/ { 33, -1, "[10]23", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_GS1_128 }, - /* 50*/ { 36, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_UPCA }, - /* 51*/ { 36, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA }, - /* 52*/ { 39, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_UPCE }, - /* 53*/ { 39, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCE }, - /* 54*/ { 41, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 479: Input length 1 is not standard (should be 5, 9 or 11 digits)", BARCODE_POSTNET }, - /* 55*/ { 41, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_POSTNET }, - /* 56*/ { 41, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, - /* 57*/ { 42, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_POSTNET }, - /* 58*/ { 42, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, - /* 59*/ { 43, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_POSTNET }, - /* 60*/ { 43, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, - /* 61*/ { 44, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_POSTNET }, - /* 62*/ { 44, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, - /* 63*/ { 45, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_POSTNET }, - /* 64*/ { 45, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, - /* 65*/ { 46, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_PLESSEY }, - /* 66*/ { 46, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_PLESSEY }, - /* 67*/ { 48, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_NVE18 }, - /* 68*/ { 48, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_NVE18 }, - /* 69*/ { 59, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_CODE128 }, - /* 70*/ { 59, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_CODE128 }, - /* 71*/ { 61, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_CODE128 }, - /* 72*/ { 61, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_CODE128 }, - /* 73*/ { 62, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_CODE93 }, - /* 74*/ { 62, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_CODE93 }, - /* 75*/ { 64, -1, "12345678", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_AUSPOST }, - /* 76*/ { 64, -1, "12345678", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_AUSPOST }, - /* 77*/ { 65, -1, "12345678", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_AUSPOST }, - /* 78*/ { 65, -1, "12345678", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_AUSPOST }, - /* 79*/ { 78, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_DBAR_OMN }, - /* 80*/ { 78, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_DBAR_OMN }, - /* 81*/ { 83, -1, "12345678901", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_PLANET }, - /* 82*/ { 83, -1, "12345678901", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_PLANET }, - /* 83*/ { 88, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI", BARCODE_GS1_128 }, - /* 84*/ { 88, -1, "[10]12", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_GS1_128 }, - /* 85*/ { 88, -1, "[10]12", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_GS1_128 }, - /* 86*/ { 91, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /* 87*/ { 91, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /* 88*/ { 94, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /* 89*/ { 94, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /* 90*/ { 95, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /* 91*/ { 95, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /* 92*/ { 100, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_HIBC_128 }, - /* 93*/ { 100, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_128 }, - /* 94*/ { 101, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_HIBC_39 }, - /* 95*/ { 101, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_39 }, - /* 96*/ { 103, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_HIBC_DM }, - /* 97*/ { 103, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_DM }, - /* 98*/ { 105, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_HIBC_QR }, - /* 99*/ { 105, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_QR }, - /*100*/ { 107, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_HIBC_PDF }, - /*101*/ { 107, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_PDF }, - /*102*/ { 109, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_HIBC_MICPDF }, - /*103*/ { 109, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_MICPDF }, - /*104*/ { 111, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_HIBC_BLOCKF }, - /*105*/ { 111, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_BLOCKF }, - /*106*/ { 113, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*107*/ { 113, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*108*/ { 114, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*109*/ { 114, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*110*/ { 117, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*111*/ { 117, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*112*/ { 118, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*113*/ { 118, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*114*/ { 122, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*115*/ { 122, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*116*/ { 123, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*117*/ { 123, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*118*/ { 124, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*119*/ { 124, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*120*/ { 125, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*121*/ { 125, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*122*/ { 126, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*123*/ { 126, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*124*/ { 127, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*125*/ { 127, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*126*/ { 150, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*127*/ { 150, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*128*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*129*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*130*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 }, - /*131*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 }, - /*132*/ { BARCODE_MAXICODE, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 }, - /*133*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 }, - /*134*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 }, - /*135*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 }, - /*136*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, - /*137*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, - /*138*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 }, - /*139*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, - /*140*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 512: ECI ignored for GS1 mode", -1 }, - /*141*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, /* Warning in encoder overrides library warnings */ - /*142*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 }, /* But not errors */ - /*143*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, - /*144*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, - /*145*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 }, - /*146*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 503: Error correction level '6' out of range (1 to 4), ignoring", -1 }, - /*147*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, - /*148*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, /* ECI warning trumps all other warnings */ - /*149*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, /* But not errors */ + /* 0*/ { BARCODE_CODE128, -1, "1234", -1, -1, 3, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", -1 }, + /* 1*/ { BARCODE_CODE128, -1, "1234", -1, -1, 0, 0, 0, 0, 0, -1, -1, 0, -1, -1, -1, 0, "", -1 }, /* Silently ignore rows < 0 */ + /* 2*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 3, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", -1 }, + /* 3*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 999999 + 1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: ECI code '1000000' out of range (0 to 999999, excluding 1, 2, 14 and 19)", -1 }, + /* 4*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.009, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 }, + /* 5*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 200.01, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 }, + /* 6*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, -1, 20.1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 }, + /* 7*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.01, 0.009, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 }, + /* 8*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, -0.1, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 765: Height out of range (0 to 2000)", -1 }, + /* 9*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 2000.01, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 765: Height out of range (0 to 2000)", -1 }, + /* 10*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, -1, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 766: Whitespace width out of range (0 to 100)", -1 }, + /* 11*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 101, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 766: Whitespace width out of range (0 to 100)", -1 }, + /* 12*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, -1, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 767: Whitespace height out of range (0 to 100)", -1 }, + /* 13*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 101, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 767: Whitespace height out of range (0 to 100)", -1 }, + /* 14*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, -1, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 768: Border width out of range (0 to 100)", -1 }, + /* 15*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 768: Border width out of range (0 to 100)", -1 }, + /* 16*/ { BARCODE_CODE128, -1, "1234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 220: Selected symbology does not support GS1 mode", -1 }, + /* 17*/ { BARCODE_EAN13, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, -5.1, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 219: Text gap out of range (-5 to 10)", -1 }, + /* 18*/ { BARCODE_EANX, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, -5.1, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 219: Text gap out of range (-5 to 10)", -1 }, + /* 19*/ { BARCODE_EAN13, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 10.1, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 219: Text gap out of range (-5 to 10)", -1 }, + /* 20*/ { BARCODE_EANX, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 10.1, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 219: Text gap out of range (-5 to 10)", -1 }, + /* 21*/ { BARCODE_EAN13, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, -0.5, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 769: Guard bar descent out of range (0 to 50)", -1 }, + /* 22*/ { BARCODE_EANX, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, -0.5, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 769: Guard bar descent out of range (0 to 50)", -1 }, + /* 23*/ { BARCODE_EAN13, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, 50.1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 769: Guard bar descent out of range (0 to 50)", -1 }, + /* 24*/ { BARCODE_EANX, -1, "123456789012", -1, -1, -1, 0, 0, 0, 101, -1, -1, 0, 50.1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 769: Guard bar descent out of range (0 to 50)", -1 }, + /* 25*/ { BARCODE_GS1_128, -1, "[21]12\0004", 8, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 262: NUL characters not permitted in GS1 mode", -1 }, + /* 26*/ { BARCODE_GS1_128, -1, "[21]12é4", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1", -1 }, + /* 27*/ { BARCODE_GS1_128, -1, "[21]12\0074", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 251: Control characters are not supported by GS1", -1 }, + /* 28*/ { BARCODE_GS1_128, -1, "[21]1234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", -1 }, + /* 29*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /* 30*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /* 31*/ { 0, -1, "1", -1, -1, 1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", BARCODE_CODE128 }, /* Not supporting beats invalid ECI */ + /* 32*/ { 0, -1, "1", -1, -1, 1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /* 33*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, 0.009, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", BARCODE_CODE128 }, + /* 34*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, 0.009, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /* 35*/ { 0, -1, "1", -1, -1, 1, 0, 0, 0, 0, -1, 0.009, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", BARCODE_CODE128 }, /* Invalid dot size no longer beats invalid ECI */ + /* 36*/ { 0, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, 0.009, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /* 37*/ { 5, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_C25STANDARD }, + /* 38*/ { 5, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_C25STANDARD }, + /* 39*/ { 17, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_UPCA }, + /* 40*/ { 17, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_UPCA }, + /* 41*/ { 19, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_TOO_LONG, "Error 362: Input length 1 too short (minimum 3)", BARCODE_CODABAR }, + /* 42*/ { 19, -1, "A1B", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 207: Codabar 18 not supported", BARCODE_CODABAR }, + /* 43*/ { 19, -1, "A1B", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 207: Codabar 18 not supported", -1 }, + /* 44*/ { 26, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_UPCA }, + /* 45*/ { 26, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_UPCA }, + /* 46*/ { 27, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_OPTION, "Error 208: UPCD1 not supported", 27 }, + /* 47*/ { 33, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI", BARCODE_GS1_128 }, + /* 48*/ { 33, -1, "[10]23", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_GS1_128 }, + /* 49*/ { 33, -1, "[10]23", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_GS1_128 }, + /* 50*/ { 36, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_UPCA }, + /* 51*/ { 36, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_UPCA }, + /* 52*/ { 39, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_UPCE }, + /* 53*/ { 39, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_UPCE }, + /* 54*/ { 41, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_NONCOMPLIANT, "Warning 479: Input length 1 is not standard (should be 5, 9 or 11 digits)", BARCODE_POSTNET }, + /* 55*/ { 41, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_POSTNET }, + /* 56*/ { 41, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, + /* 57*/ { 42, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_POSTNET }, + /* 58*/ { 42, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, + /* 59*/ { 43, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_POSTNET }, + /* 60*/ { 43, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, + /* 61*/ { 44, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_POSTNET }, + /* 62*/ { 44, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, + /* 63*/ { 45, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_POSTNET }, + /* 64*/ { 45, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET }, + /* 65*/ { 46, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_PLESSEY }, + /* 66*/ { 46, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_PLESSEY }, + /* 67*/ { 48, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_NVE18 }, + /* 68*/ { 48, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_NVE18 }, + /* 69*/ { 59, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_CODE128 }, + /* 70*/ { 59, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_CODE128 }, + /* 71*/ { 61, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_CODE128 }, + /* 72*/ { 61, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_CODE128 }, + /* 73*/ { 62, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_CODE93 }, + /* 74*/ { 62, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_CODE93 }, + /* 75*/ { 64, -1, "12345678", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_AUSPOST }, + /* 76*/ { 64, -1, "12345678", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_AUSPOST }, + /* 77*/ { 65, -1, "12345678", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_AUSPOST }, + /* 78*/ { 65, -1, "12345678", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_AUSPOST }, + /* 79*/ { 78, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_DBAR_OMN }, + /* 80*/ { 78, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_DBAR_OMN }, + /* 81*/ { 83, -1, "12345678901", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_PLANET }, + /* 82*/ { 83, -1, "12345678901", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_PLANET }, + /* 83*/ { 88, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI", BARCODE_GS1_128 }, + /* 84*/ { 88, -1, "[10]12", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_GS1_128 }, + /* 85*/ { 88, -1, "[10]12", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_GS1_128 }, + /* 86*/ { 91, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /* 87*/ { 91, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /* 88*/ { 94, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /* 89*/ { 94, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /* 90*/ { 95, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /* 91*/ { 95, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /* 92*/ { 100, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_HIBC_128 }, + /* 93*/ { 100, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_128 }, + /* 94*/ { 101, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_HIBC_39 }, + /* 95*/ { 101, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_39 }, + /* 96*/ { 103, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_HIBC_DM }, + /* 97*/ { 103, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_DM }, + /* 98*/ { 105, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_HIBC_QR }, + /* 99*/ { 105, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_QR }, + /*100*/ { 107, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_HIBC_PDF }, + /*101*/ { 107, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_PDF }, + /*102*/ { 109, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_HIBC_MICPDF }, + /*103*/ { 109, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_MICPDF }, + /*104*/ { 111, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", BARCODE_HIBC_BLOCKF }, + /*105*/ { 111, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_BLOCKF }, + /*106*/ { 113, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*107*/ { 113, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*108*/ { 114, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*109*/ { 114, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*110*/ { 117, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*111*/ { 117, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*112*/ { 118, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*113*/ { 118, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*114*/ { 122, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*115*/ { 122, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*116*/ { 123, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*117*/ { 123, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*118*/ { 124, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*119*/ { 124, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*120*/ { 125, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*121*/ { 125, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*122*/ { 126, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*123*/ { 126, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*124*/ { 127, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*125*/ { 127, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*126*/ { 150, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*127*/ { 150, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*128*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*129*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*130*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 }, + /*131*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 }, + /*132*/ { BARCODE_MAXICODE, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 }, + /*133*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 }, + /*134*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 }, + /*135*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 }, + /*136*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", -1 }, + /*137*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, + /*138*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 }, + /*139*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, + /*140*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 512: ECI ignored for GS1 mode", -1 }, + /*141*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, /* Warning in encoder overrides library warnings */ + /*142*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 }, /* But not errors */ + /*143*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, 0, "", -1 }, + /*144*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, + /*145*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 }, + /*146*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_INVALID_OPTION, "Warning 503: Error correction level '6' out of range (1 to 4), ignoring", -1 }, + /*147*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, + /*148*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, /* ECI warning trumps all other warnings */ + /*149*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, 0, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, /* But not errors */ }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -252,6 +253,9 @@ static void test_checks(const testCtx *const p_ctx) { if (data[i].guard_descent != -1) { symbol->guard_descent = data[i].guard_descent; } + if (data[i].rows) { + symbol->rows = data[i].rows; + } if (data[i].warn_level != -1) { symbol->warn_level = data[i].warn_level; } @@ -326,7 +330,9 @@ static void test_checks_segs(const testCtx *const p_ctx) { testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, data[i].option_1, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/, - NULL, 0, debug); + NULL, 0, + /* Avoid OOB on printing non-existing data in `z_debug_print_escape()` */ + data[i].segs[0].length < ZINT_MAX_DATA_LEN ? debug : 0); if (data[i].warn_level != -1) { symbol->warn_level = data[i].warn_level; } @@ -645,6 +651,7 @@ static void test_input_mode(const testCtx *const p_ctx) { int input_mode; int eci; const char *data; + int warn_level; int ret; int expected_input_mode; @@ -652,27 +659,28 @@ static void test_input_mode(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { DATA_MODE, -1, "1234", 0, DATA_MODE, "" }, - /* 1*/ { DATA_MODE | ESCAPE_MODE, -1, "1234", 0, DATA_MODE | ESCAPE_MODE, "" }, - /* 2*/ { UNICODE_MODE, -1, "1234", 0, UNICODE_MODE, "" }, - /* 3*/ { UNICODE_MODE | ESCAPE_MODE, -1, "1234", 0, UNICODE_MODE | ESCAPE_MODE, "" }, - /* 4*/ { GS1_MODE, -1, "[01]12345678901231", 0, GS1_MODE, "" }, - /* 5*/ { GS1_MODE | ESCAPE_MODE, -1, "[01]12345678901231", 0, GS1_MODE | ESCAPE_MODE, "" }, - /* 6*/ { 4 | ESCAPE_MODE, -1, "1234", ZINT_WARN_INVALID_OPTION, DATA_MODE, "Warning 212: Invalid input mode - reset to DATA_MODE" }, /* Unknown mode reset to bare DATA_MODE. Note: now warns */ - /* 7*/ { -1, -1, "1234", 0, DATA_MODE, "" }, - /* 8*/ { DATA_MODE | 0x10, -1, "1234", 0, DATA_MODE | 0x10, "" }, /* Unknown flags kept (but ignored) */ - /* 9*/ { UNICODE_MODE | 0x10, -1, "1234", 0, UNICODE_MODE | 0x10, "" }, - /* 10*/ { GS1_MODE | 0x20, -1, "[01]12345678901231", 0, GS1_MODE | 0x20, "" }, - /* 11*/ { GS1_MODE, 3, "[01]12345678901231", 0, GS1_MODE, "" }, - /* 12*/ { GS1_MODE, 20, "[01]12345678901231", 0, GS1_MODE, "" }, /* Shift JIS (ok as backslash not in CSET82) */ - /* 12*/ { GS1_MODE, 24, "[01]12345678901231", 0, GS1_MODE, "" }, /* Windows 1256 - Arabic */ - /* 13*/ { GS1_MODE, 25, "[01]12345678901231", ZINT_ERROR_INVALID_OPTION, GS1_MODE, "Error 856: In GS1 mode ECI must be ASCII compatible" }, /* UTF-16BE */ - /* 12*/ { GS1_MODE, 26, "[01]12345678901231", 0, GS1_MODE, "" }, /* UTF-8*/ - /* 12*/ { GS1_MODE, 32, "[01]12345678901231", 0, GS1_MODE, "" }, /* GB 18030 */ - /* 14*/ { GS1_MODE, 33, "[01]12345678901231", ZINT_ERROR_INVALID_OPTION, GS1_MODE, "Error 856: In GS1 mode ECI must be ASCII compatible" }, /* UTF-16LE */ - /* 15*/ { GS1_MODE, 34, "[01]12345678901231", ZINT_ERROR_INVALID_OPTION, GS1_MODE, "Error 856: In GS1 mode ECI must be ASCII compatible" }, /* UTF-32BE */ - /* 16*/ { GS1_MODE, 35, "[01]12345678901231", ZINT_ERROR_INVALID_OPTION, GS1_MODE, "Error 856: In GS1 mode ECI must be ASCII compatible" }, /* UTF-32LE */ - /* 17*/ { GS1_MODE, 170, "[01]12345678901231", 0, GS1_MODE, "" }, /* ASCII Invariant */ + /* 0*/ { DATA_MODE, -1, "1234", -1, 0, DATA_MODE, "" }, + /* 1*/ { DATA_MODE | ESCAPE_MODE, -1, "1234", -1, 0, DATA_MODE | ESCAPE_MODE, "" }, + /* 2*/ { UNICODE_MODE, -1, "1234", -1, 0, UNICODE_MODE, "" }, + /* 3*/ { UNICODE_MODE | ESCAPE_MODE, -1, "1234", -1, 0, UNICODE_MODE | ESCAPE_MODE, "" }, + /* 4*/ { GS1_MODE, -1, "[01]12345678901231", -1, 0, GS1_MODE, "" }, + /* 5*/ { GS1_MODE | ESCAPE_MODE, -1, "[01]12345678901231", -1, 0, GS1_MODE | ESCAPE_MODE, "" }, + /* 6*/ { 4 | ESCAPE_MODE, -1, "1234", -1, ZINT_WARN_INVALID_OPTION, DATA_MODE, "Warning 212: Invalid input mode - reset to DATA_MODE" }, /* Unknown mode reset to bare DATA_MODE. Note: now warns */ + /* 7*/ { 4 | ESCAPE_MODE, -1, "1234", WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, DATA_MODE, "Error 212: Invalid input mode - reset to DATA_MODE" }, + /* 8*/ { -1, -1, "1234", -1, 0, DATA_MODE, "" }, + /* 9*/ { DATA_MODE | 0x10, -1, "1234", -1, 0, DATA_MODE | 0x10, "" }, /* Unknown flags kept (but ignored) */ + /* 10*/ { UNICODE_MODE | 0x10, -1, "1234", -1, 0, UNICODE_MODE | 0x10, "" }, + /* 11*/ { GS1_MODE | 0x20, -1, "[01]12345678901231", -1, 0, GS1_MODE | 0x20, "" }, + /* 12*/ { GS1_MODE, 3, "[01]12345678901231", -1, 0, GS1_MODE, "" }, + /* 13*/ { GS1_MODE, 20, "[01]12345678901231", -1, 0, GS1_MODE, "" }, /* Shift JIS (ok as backslash not in CSET82) */ + /* 14*/ { GS1_MODE, 24, "[01]12345678901231", -1, 0, GS1_MODE, "" }, /* Windows 1256 - Arabic */ + /* 15*/ { GS1_MODE, 25, "[01]12345678901231", -1, ZINT_ERROR_INVALID_OPTION, GS1_MODE, "Error 856: In GS1 mode ECI must be ASCII compatible" }, /* UTF-16BE */ + /* 16*/ { GS1_MODE, 26, "[01]12345678901231", -1, 0, GS1_MODE, "" }, /* UTF-8*/ + /* 17*/ { GS1_MODE, 32, "[01]12345678901231", -1, 0, GS1_MODE, "" }, /* GB 18030 */ + /* 18*/ { GS1_MODE, 33, "[01]12345678901231", -1, ZINT_ERROR_INVALID_OPTION, GS1_MODE, "Error 856: In GS1 mode ECI must be ASCII compatible" }, /* UTF-16LE */ + /* 19*/ { GS1_MODE, 34, "[01]12345678901231", -1, ZINT_ERROR_INVALID_OPTION, GS1_MODE, "Error 856: In GS1 mode ECI must be ASCII compatible" }, /* UTF-32BE */ + /* 20*/ { GS1_MODE, 35, "[01]12345678901231", -1, ZINT_ERROR_INVALID_OPTION, GS1_MODE, "Error 856: In GS1 mode ECI must be ASCII compatible" }, /* UTF-32LE */ + /* 21*/ { GS1_MODE, 170, "[01]12345678901231", -1, 0, GS1_MODE, "" }, /* ASCII Invariant */ }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -692,6 +700,9 @@ static void test_input_mode(const testCtx *const p_ctx) { length = testUtilSetSymbol(symbol, symbology, data[i].input_mode, data[i].eci, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/, data[i].data, -1, debug); + if (data[i].warn_level != -1) { + symbol->warn_level = data[i].warn_level; + } ret = ZBarcode_Encode(symbol, ZCUCP(data[i].data), length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", @@ -835,34 +846,37 @@ static void test_escape_char_process(const testCtx *const p_ctx) { /*109*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 35, "\\U10FFFF", "", 0, 14, "F1 24 EB 80 EB 80 11 01 17 BA C6 05 9F 4C EA E5 18 31", 0, "" }, /*110*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[20]10", "[10]A", 0, 99, "(7) 105 102 20 10 100 59 106", 0, "" }, /*111*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[2\\x30]1\\d048", "[\\x310]\\x41", 0, 99, "(7) 105 102 20 10 100 59 106", 1, "" }, - /*112*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, - /*113*/ { BARCODE_AZTEC, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, - /*114*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 15, "(102) 31 31 30 30 31 31 30 31 31 31 30 30 31 31 30 30 31 31 30 31 30 30 31 30 30 30 30 30", 0, "" }, - /*115*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\\\^11", "", 0, 15, "(102) 30 31 31 30 31 31 31 30 31 31 30 30 31 31 31 31 30 31 31 30 31 31 30 30 31 31 31 31", 0, "Note double-backslash caret passed thru as backslash caret but does not error in non-EXTRA_ESCAPE_MODE, treated literally" }, - /*116*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^11", "", 0, 15, "(102) 31 31 30 30 31 31 30 31 31 31 30 30 31 31 30 30 31 31 30 31 30 30 31 30 30 30 30 30", 0, "Treated as backslash caret 1 (FNC1)" }, - /*117*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, - /*118*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, - /*119*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, - /*120*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "" }, - /*121*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, - /*122*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "Not allowed of DATAMATRIX in GS1_MODE" }, - /*123*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\\\^11", "", 0, 10, "5D 5F 8D 5C FB D1 69 3F", 0, "Note double-backslash caret passed thru as backslash caret but does not error in non-EXTRA_ESCAPE_MODE, treated literally" }, - /*124*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "Treated as backslash caret 1 (FNC1)" }, - /*125*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^B2", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^B\"", 0, "Passed thru as backslash caret B" }, - /*126*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 18, "A\\^1B", "", 0, 12, "42 E8 F1 13 43 F5 A4 26 80 68 7A AD", 0, "" }, - /*127*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, - /*128*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "バ\\^1ーコ\\^1ード\\^1東京\\^1都", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, - /*129*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 25, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, - /*130*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 33, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, - /*131*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 170, "A\\^1B", "", ZINT_ERROR_INVALID_DATA, 0, "Error 244: Invalid character in input for ECI '170'", 0, "" }, - /*132*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, - /*133*/ { BARCODE_CODE128, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, - /*134*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" }, - /*135*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" }, - /*136*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 348: Unrecognized extra escape \"\\^D\"", 0, "" }, - /*137*/ { BARCODE_CODE128, DATA_MODE, -1, "\\\\^A1", "", 0, 79, "(7) 104 60 62 33 17 43 106", 0, "Treated as literal backslash caret A" }, - /*138*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "Treated as backslash caret A (manual Code Set A)" }, - /*139*/ { BARCODE_CODE128, DATA_MODE, -1, "\\c", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\c' in input", 0, "" }, + /*112*/ { BARCODE_GS1_128_CC, GS1_MODE | GS1PARENS_MODE, -1, "(90)\\(\\)", "(10)A", 0, 101, "(9) 105 102 90 100 8 9 101 31 106", 0, "" }, + /*113*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[90]\\(\\)", "[10]A", ZINT_ERROR_INVALID_DATA, 0, "Error 853: Escaped parentheses only valid in GS1 mode with GS1 parentheses flag", 0, "" }, + /*114*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[10]A", "[90]\\(\\)", ZINT_ERROR_INVALID_DATA, 0, "Error 853: Escaped parentheses only valid in GS1 mode with GS1 parentheses flag", 0, "" }, + /*115*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*116*/ { BARCODE_AZTEC, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*117*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 15, "(102) 31 31 30 30 31 31 30 31 31 31 30 30 31 31 30 30 31 31 30 31 30 30 31 30 30 30 30 30", 0, "" }, + /*118*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\\\^11", "", 0, 15, "(102) 30 31 31 30 31 31 31 30 31 31 30 30 31 31 31 31 30 31 31 30 31 31 30 30 31 31 31 31", 0, "Note double-backslash caret passed thru as backslash caret but does not error in non-EXTRA_ESCAPE_MODE, treated literally" }, + /*119*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^11", "", 0, 15, "(102) 31 31 30 30 31 31 30 31 31 31 30 30 31 31 30 30 31 31 30 31 30 30 31 30 30 30 30 30", 0, "Treated as backslash caret 1 (FNC1)" }, + /*120*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, + /*121*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*122*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*123*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "" }, + /*124*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, + /*125*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "Not allowed of DATAMATRIX in GS1_MODE" }, + /*126*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\\\^11", "", 0, 10, "5D 5F 8D 5C FB D1 69 3F", 0, "Note double-backslash caret passed thru as backslash caret but does not error in non-EXTRA_ESCAPE_MODE, treated literally" }, + /*127*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "Treated as backslash caret 1 (FNC1)" }, + /*128*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^B2", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^B\"", 0, "Passed thru as backslash caret B" }, + /*129*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 18, "A\\^1B", "", 0, 12, "42 E8 F1 13 43 F5 A4 26 80 68 7A AD", 0, "" }, + /*130*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /*131*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "バ\\^1ーコ\\^1ード\\^1東京\\^1都", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /*132*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 25, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /*133*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 33, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /*134*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 170, "A\\^1B", "", ZINT_ERROR_INVALID_DATA, 0, "Error 244: Invalid character in input for ECI '170'", 0, "" }, + /*135*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /*136*/ { BARCODE_CODE128, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*137*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" }, + /*138*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" }, + /*139*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 348: Unrecognized extra escape \"\\^D\"", 0, "" }, + /*140*/ { BARCODE_CODE128, DATA_MODE, -1, "\\\\^A1", "", 0, 79, "(7) 104 60 62 33 17 43 106", 0, "Treated as literal backslash caret A" }, + /*141*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "Treated as backslash caret A (manual Code Set A)" }, + /*142*/ { BARCODE_CODE128, DATA_MODE, -1, "\\c", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\c' in input", 0, "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -1044,12 +1058,12 @@ static void test_cap(const testCtx *const p_ctx) { /* 1*/ { BARCODE_CODE128, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_GS1 | ZINT_CAP_BINDABLE, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_BINDABLE }, /* 2*/ { BARCODE_PDF417, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_BINDABLE, 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_MASK | ZINT_CAP_STRUCTAPP | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP }, - /* 4*/ { BARCODE_EAN8_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT }, - /* 5*/ { BARCODE_EANX_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT }, - /* 6*/ { BARCODE_EAN13_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT }, + /* 4*/ { BARCODE_EAN8_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EANUPC | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EANUPC | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT }, + /* 5*/ { BARCODE_EANX_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EANUPC | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EANUPC | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT }, + /* 6*/ { BARCODE_EAN13_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EANUPC | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EANUPC | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT }, /* 7*/ { BARCODE_HANXIN, ZINT_CAP_DOTTY | ZINT_CAP_QUIET_ZONES | 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 }, /* 8*/ { BARCODE_CODE11, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FIXED_RATIO | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_COMPLIANT_HEIGHT, 0 }, - /* 9*/ { 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 | ZINT_CAP_STRUCTAPP | ZINT_CAP_BINDABLE, 0 }, + /* 9*/ { BARCODE_POSTNET, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_EANUPC | 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 | ZINT_CAP_STRUCTAPP | ZINT_CAP_BINDABLE, 0 }, /* 10*/ { 0, 0, 0 }, }; const int data_size = ARRAY_SIZE(data); @@ -1058,6 +1072,8 @@ static void test_cap(const testCtx *const p_ctx) { testStart(p_ctx->func_name); + assert_equal(ZINT_CAP_EXTENDABLE, ZINT_CAP_EANUPC, "0x%X != 0x%X\n", ZINT_CAP_EXTENDABLE, ZINT_CAP_EANUPC); + for (i = 0; i < data_size; i++) { if (testContinue(p_ctx, i)) continue; @@ -2632,6 +2648,50 @@ static void test_reset(const testCtx *const p_ctx) { testFinish(); } +static void test_default_xdim(const testCtx *const p_ctx) { + + struct item { + int symbology; + float expected; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_AUSPOST, 0.5f }, + /* 1*/ { BARCODE_CEPNET, 0.591f }, + /* 2*/ { BARCODE_RM4SCC, 0.638f }, + /* 3*/ { BARCODE_JAPANPOST, 0.6f }, + /* 4*/ { BARCODE_DXFILMEDGE, 0.403548f }, + /* 5*/ { BARCODE_BC412, 0.12f }, + /* 6*/ { BARCODE_CODABAR, 0.38f }, + /* 7*/ { BARCODE_CODE32, 0.25f }, + /* 8*/ { BARCODE_DPD, 0.375f }, + /* 9*/ { BARCODE_FIM, 0.79375f }, + /* 10*/ { BARCODE_LOGMARS, 0.34925f }, + /* 11*/ { BARCODE_MAILMARK_2D, 0.5f }, + /* 12*/ { BARCODE_PHARMA, 0.5f }, + /* 13*/ { BARCODE_PHARMA_TWO, 1.0f }, + /* 14*/ { BARCODE_PZN, 0.25f }, + /* 15*/ { BARCODE_CODE16K, 0.33f }, + /* 16*/ { BARCODE_LAST + 1, 0.0f }, + }; + const int data_size = ARRAY_SIZE(data); + int i; + float ret; + + testStart(p_ctx->func_name); + + for (i = 0; i < data_size; i++) { + + if (testContinue(p_ctx, i)) continue; + + ret = ZBarcode_Default_Xdim(data[i].symbology); + assert_equal(ret, data[i].expected, "i:%d ZBarcode_Default_Xdim(%s) %.8g != %.8g\n", + i, testUtilBarcodeName(data[i].symbology), ret, data[i].expected); + } + + testFinish(); +} + static void test_scale_from_xdimdp(const testCtx *const p_ctx) { struct item { @@ -2706,34 +2766,40 @@ static void test_scale_from_xdimdp(const testCtx *const p_ctx) { /* 59*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "gif", 33.264f }, /* 60*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "emf", 8.316f }, /* 61*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "svg", 166.31999f }, - /* 62*/ { BARCODE_PDF417, 0.27f, 2, 50, "gif", 0.5f }, - /* 63*/ { BARCODE_PDF417, 0.27f, 2, 50, "svg", 0.27000001f }, - /* 64*/ { BARCODE_PDF417, 0.27f, 6, 150, "gif", 1 }, - /* 65*/ { BARCODE_PDF417, 0.27f, 6, 150, "svg", 0.81000006f }, - /* 66*/ { BARCODE_PDF417, 0.27f, 12, 300, "gif", 1.5 }, - /* 67*/ { BARCODE_PDF417, 0.27f, 12, 300, "svg", 1.6200001f }, - /* 68*/ { BARCODE_PDF417, 0.27f, 24, 600, "gif", 3 }, - /* 69*/ { BARCODE_PDF417, 0.27f, 24, 600, "emf", 3.2400002f }, - /* 70*/ { BARCODE_PDF417, 0.27f, 24, 600, "svg", 3.2400002f }, - /* 71*/ { BARCODE_PHARMA_TWO, 1, 2, 50, "gif", 1 }, - /* 72*/ { BARCODE_PHARMA_TWO, 1, 2, 50, "svg", 1 }, - /* 73*/ { BARCODE_PHARMA_TWO, 1, 6, 150, "gif", 3 }, - /* 74*/ { BARCODE_PHARMA_TWO, 1, 6, 150, "svg", 3 }, - /* 75*/ { BARCODE_PHARMA_TWO, 1, 8, 200, "gif", 4 }, - /* 76*/ { BARCODE_PHARMA_TWO, 1, 8, 200, "svg", 4 }, - /* 77*/ { BARCODE_PHARMA_TWO, 1, 189, 4800, "gif", 94.5f }, - /* 78*/ { BARCODE_PHARMA_TWO, 1, 189, 4800, "svg", 94.5f }, - /* 79*/ { BARCODE_PHARMA_TWO, 1, 378, 9600, "gif", 189 }, - /* 80*/ { BARCODE_PHARMA_TWO, 1, 378, 9600, "svg", 189 }, - /* 81*/ { BARCODE_PHARMA_TWO, 1, 401, 10200, "gif", 200 }, /* NOTE scale capped to 200 so doesn't round trip */ - /* 82*/ { BARCODE_PHARMA_TWO, 1, 401, 10200, "svg", 200 }, - /* 83*/ { BARCODE_CODE128, 0.5, 12, 300, "gif", 3 }, - /* 84*/ { BARCODE_CODE128, 0, 12, -1, "gif", 0 }, /* x_dim zero */ - /* 85*/ { BARCODE_CODE128, 200.1f, 12, -1, "gif", 0 }, /* x_dim > 200 */ - /* 86*/ { BARCODE_CODE128, 0.5f, -0.1f, -1, "gif", 0 }, /* dpmm neg */ - /* 87*/ { BARCODE_CODE128, 0.5f, 1000.1, -1, "gif", 0 }, /* dpmm > 1000 */ - /* 88*/ { BARCODE_CODE128, 0.5f, 300, -1, "abcd", 0 }, /* filetype unknown */ - /* 89*/ { BARCODE_QRCODE, 10, 31, 800, "gif", 155 }, + /* 62*/ { BARCODE_MAXICODE, 1.0f, 2, 24, "gif", 0.2f }, + /* 63*/ { BARCODE_PDF417, 0.27f, 2, 50, "gif", 0.5f }, + /* 64*/ { BARCODE_PDF417, 0.27f, 2, 50, "svg", 0.27000001f }, + /* 65*/ { BARCODE_PDF417, 0.27f, 6, 150, "gif", 1 }, + /* 66*/ { BARCODE_PDF417, 0.27f, 6, 150, "svg", 0.81000006f }, + /* 67*/ { BARCODE_PDF417, 0.27f, 12, 300, "gif", 1.5 }, + /* 68*/ { BARCODE_PDF417, 0.27f, 12, 300, "svg", 1.6200001f }, + /* 69*/ { BARCODE_PDF417, 0.27f, 24, 600, "gif", 3 }, + /* 70*/ { BARCODE_PDF417, 0.27f, 24, 600, "emf", 3.2400002f }, + /* 71*/ { BARCODE_PDF417, 0.27f, 24, 600, "svg", 3.2400002f }, + /* 72*/ { BARCODE_PHARMA_TWO, 1, 2, 50, "gif", 1 }, + /* 73*/ { BARCODE_PHARMA_TWO, 1, 2, 50, "svg", 1 }, + /* 74*/ { BARCODE_PHARMA_TWO, 1, 6, 150, "gif", 3 }, + /* 75*/ { BARCODE_PHARMA_TWO, 1, 6, 150, "svg", 3 }, + /* 76*/ { BARCODE_PHARMA_TWO, 1, 8, 200, "gif", 4 }, + /* 77*/ { BARCODE_PHARMA_TWO, 1, 8, 200, "svg", 4 }, + /* 78*/ { BARCODE_PHARMA_TWO, 1, 189, 4800, "gif", 94.5f }, + /* 79*/ { BARCODE_PHARMA_TWO, 1, 189, 4800, "svg", 94.5f }, + /* 80*/ { BARCODE_PHARMA_TWO, 1, 378, 9600, "gif", 189 }, + /* 81*/ { BARCODE_PHARMA_TWO, 1, 378, 9600, "svg", 189 }, + /* 82*/ { BARCODE_PHARMA_TWO, 1, 401, 10200, "gif", 200 }, /* NOTE scale capped to 200 so doesn't round trip */ + /* 83*/ { BARCODE_PHARMA_TWO, 1, 401, 10200, "svg", 200 }, + /* 84*/ { BARCODE_CODE128, 0.5f, 12, 300, "gif", 3 }, + /* 85*/ { BARCODE_CODE128, 0.5f, 0, 300, "gif", 3 }, + /* 86*/ { BARCODE_CODE128, 0.5f, 12, 300, "", 3 }, + /* 87*/ { BARCODE_CODE128, 0.5f, 2, 50, "", 0.5 }, + /* 88*/ { BARCODE_CODE128, 0.5f, 0.5f, 24, "gif", 0.5 }, + /* 89*/ { BARCODE_CODE128, 0, 12, -1, "gif", 0 }, /* x_dim zero */ + /* 90*/ { BARCODE_CODE128, 200.1f, 12, -1, "gif", 0 }, /* x_dim > 200 */ + /* 91*/ { BARCODE_CODE128, 0.5f, -0.1f, -1, "gif", 0 }, /* dpmm neg */ + /* 92*/ { BARCODE_CODE128, 0.5f, 1000.1, -1, "gif", 0 }, /* dpmm > 1000 */ + /* 93*/ { BARCODE_CODE128, 0.5f, 300, -1, "abcd", 0 }, /* filetype unknown */ + /* 94*/ { BARCODE_QRCODE, 10, 31, 800, "gif", 155 }, + /* 95*/ { BARCODE_LAST + 1, 0, 12, 300, "gif", 0 }, }; const int data_size = ARRAY_SIZE(data); int i; @@ -2756,8 +2822,8 @@ static void test_scale_from_xdimdp(const testCtx *const p_ctx) { dpmm_from_dpi = z_stripf(roundf(data[i].dpi / 25.4f)); ret = ZBarcode_Scale_From_XdimDp(data[i].symbology, data[i].x_dim, dpmm_from_dpi, data[i].filetype); assert_equal(ret, data[i].expected, - "i:%d ZBarcode_Scale_From_XdimDp(%s, %g (dpi %d), %g, %s) %.8g != %.8g\n", - i, testUtilBarcodeName(data[i].symbology), dpmm_from_dpi, data[i].dpi, data[i].x_dim, + "i:%d ZBarcode_Scale_From_XdimDp(%s, %g, %g (dpi %d), %s) %.8g != %.8g\n", + i, testUtilBarcodeName(data[i].symbology), data[i].x_dim, dpmm_from_dpi, data[i].dpi, data[i].filetype, ret, data[i].expected); if (data[i].expected > 0.1f && data[i].expected < 200.0f /* Can't round trip scales <= 0.1 or >= 200.0 */ @@ -2766,8 +2832,8 @@ static void test_scale_from_xdimdp(const testCtx *const p_ctx) { x_dim_from_scale = ZBarcode_XdimDp_From_Scale(data[i].symbology, ret, data[i].dpmm, data[i].filetype); x_dim_from_scale = z_stripf(z_stripf(roundf(x_dim_from_scale * 100.0f)) / 100.0f); assert_equal(x_dim_from_scale, data[i].x_dim, - "i:%d ZBarcode_XdimDp_From_Scale(%s, %g, %g, %s) %.8g != x_dim %.8g\n", - i, testUtilBarcodeName(data[i].symbology), ret, data[i].x_dim, data[i].filetype, + "i:%d ZBarcode_XdimDp_From_Scale(%s, %g, %g, \"%s\") %.8g != x_dim %.8g\n", + i, testUtilBarcodeName(data[i].symbology), ret, data[i].dpmm, data[i].filetype, x_dim_from_scale, data[i].x_dim); } } @@ -2817,6 +2883,8 @@ static void test_xdimdp_from_scale(const testCtx *const p_ctx) { /* 26*/ { BARCODE_CODE128, 200.01f, 12, -1, "gif", 0 }, /* scale > 200 */ /* 27*/ { BARCODE_CODE128, 0.5f, 0, -1, "gif", 0 }, /* xdim_mm_or_dpmm zero */ /* 28*/ { BARCODE_CODE128, 0.5f, 1000.1f, -1, "gif", 0 }, /* xdim_mm_or_dpmm > 1000 */ + /* 29*/ { BARCODE_CODE128, 1, 12, -1, "txt", 0 }, + /* 30*/ { BARCODE_LAST + 1, 1, 12, -1, "gif", 0 }, }; const int data_size = ARRAY_SIZE(data); int i; @@ -2838,8 +2906,8 @@ static void test_xdimdp_from_scale(const testCtx *const p_ctx) { dpmm_from_dpi = z_stripf(roundf(data[i].dpi / 25.4f)); ret = ZBarcode_XdimDp_From_Scale(data[i].symbology, data[i].scale, dpmm_from_dpi, data[i].filetype); assert_equal(ret, data[i].expected, - "i:%d ZBarcode_XdimDp_From_Scale(%s, %g (dpi %d), %g, %s) %.8g != %.8g\n", - i, testUtilBarcodeName(data[i].symbology), dpmm_from_dpi, data[i].dpi, data[i].scale, + "i:%d ZBarcode_XdimDp_From_Scale(%s, %g, %g (dpi %d), %s) %.8g != %.8g\n", + i, testUtilBarcodeName(data[i].symbology), data[i].scale, dpmm_from_dpi, data[i].dpi, data[i].filetype, ret, data[i].expected); } } @@ -2899,19 +2967,20 @@ static void test_utf8_to_eci(const testCtx *const p_ctx) { /* 35*/ { 24, "1234پ", -1, 0, 6, 0, "1234\201", 5 }, /* Windows-1256 */ /* 36*/ { 25, "1234é", -1, 0, 10, 0, "\0001\0002\0003\0004\000\351", 10 }, /* UTF-16BE */ /* 37*/ { 26, "1234é", -1, 0, 6, 0, "1234é", 6 }, /* UTF-8 */ - /* 38*/ { 27, "1234é", -1, 0, 6, ZINT_ERROR_INVALID_DATA, "", -1 }, /* ASCII */ - /* 39*/ { 27, "1234", -1, 0, 4, 0, "1234", -1 }, /* ASCII */ - /* 40*/ { 28, "1234_", -1, 0, 7, 0, "1234\241\304", 6 }, /* Big5 */ - /* 41*/ { 29, "1234崂", -1, 0, 7, 0, "1234\341\300", 6 }, /* GB 2312 */ - /* 42*/ { 30, "1234가", -1, 0, 7, 0, "1234\260\241", 6 }, /* EUC-KR */ - /* 43*/ { 31, "1234郎", -1, 0, 7, 0, "1234\375\234", 6 }, /* GBK */ - /* 44*/ { 32, "1234崂", -1, 0, 14, 0, "1234\341\300", 6 }, /* GB 18030 */ - /* 45*/ { 33, "1234é", -1, 0, 10, 0, "1\0002\0003\0004\000\351\000", 10 }, /* UTF-16LE */ - /* 46*/ { 34, "1234é", -1, 0, 20, 0, "\000\000\0001\000\000\0002\000\000\0003\000\000\0004\000\000\000\351", 20 }, /* UTF-16BE */ - /* 47*/ { 35, "1234é", -1, 0, 20, 0, "1\000\000\0002\000\000\0003\000\000\0004\000\000\000\351\000\000\000", 20 }, /* UTF-16LE */ - /* 48*/ { 170, "1234", -1, 0, 4, 0, "1234", 4 }, /* ISO 646 Invariant */ - /* 49*/ { 170, "1234#", -1, 0, 5, ZINT_ERROR_INVALID_DATA, "", -1 }, /* ISO 646 Invariant */ - /* 50*/ { 899, "1234\000\127\302\200ÿ", 10, 0, 10, 0, "1234\000\127\200\377", 8 }, /* Binary */ + /* 38*/ { 26, "1234\200", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "", -1 }, + /* 39*/ { 27, "1234é", -1, 0, 6, ZINT_ERROR_INVALID_DATA, "", -1 }, /* ASCII */ + /* 40*/ { 27, "1234", -1, 0, 4, 0, "1234", -1 }, /* ASCII */ + /* 41*/ { 28, "1234_", -1, 0, 7, 0, "1234\241\304", 6 }, /* Big5 */ + /* 42*/ { 29, "1234崂", -1, 0, 7, 0, "1234\341\300", 6 }, /* GB 2312 */ + /* 43*/ { 30, "1234가", -1, 0, 7, 0, "1234\260\241", 6 }, /* EUC-KR */ + /* 44*/ { 31, "1234郎", -1, 0, 7, 0, "1234\375\234", 6 }, /* GBK */ + /* 45*/ { 32, "1234崂", -1, 0, 14, 0, "1234\341\300", 6 }, /* GB 18030 */ + /* 46*/ { 33, "1234é", -1, 0, 10, 0, "1\0002\0003\0004\000\351\000", 10 }, /* UTF-16LE */ + /* 47*/ { 34, "1234é", -1, 0, 20, 0, "\000\000\0001\000\000\0002\000\000\0003\000\000\0004\000\000\000\351", 20 }, /* UTF-16BE */ + /* 48*/ { 35, "1234é", -1, 0, 20, 0, "1\000\000\0002\000\000\0003\000\000\0004\000\000\000\351\000\000\000", 20 }, /* UTF-16LE */ + /* 49*/ { 170, "1234", -1, 0, 4, 0, "1234", 4 }, /* ISO 646 Invariant */ + /* 50*/ { 170, "1234#", -1, 0, 5, ZINT_ERROR_INVALID_DATA, "", -1 }, /* ISO 646 Invariant */ + /* 51*/ { 899, "1234\000\127\302\200ÿ", 10, 0, 10, 0, "1234\000\127\200\377", 8 }, /* Binary */ }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -2956,6 +3025,26 @@ static void test_utf8_to_eci(const testCtx *const p_ctx) { } } + { + /* Call `ZBarcode_UTF8_To_ECI()` without `ZBarcode_Dest_Len_ECI()` */ + unsigned char dest[32] ZINT_TESTUTIL_SANITIZEM_INIT; + int dest_length ZINT_TESTUTIL_SANITIZEM_INIT; + const char *text; + int eci; + + text = "ABC"; + eci = 14; + ret = ZBarcode_UTF8_To_ECI(eci, ZCUCP(text), -1, dest, &dest_length); + assert_equal(ret, ZINT_ERROR_INVALID_OPTION, "ZBarcode_UTF8_To_ECI(%d, %s) ret %d != %d\n", + eci, text, ret, ZINT_ERROR_INVALID_OPTION); + + text = "AB\200"; + eci = 26; + ret = ZBarcode_UTF8_To_ECI(eci, ZCUCP(text), -1, dest, &dest_length); + assert_equal(ret, ZINT_ERROR_INVALID_DATA, "ZBarcode_UTF8_To_ECI(%d, %s) ret %d != %d\n", + eci, text, ret, ZINT_ERROR_INVALID_OPTION); + } + testFinish(); } @@ -2965,127 +3054,139 @@ static void test_content_segs(const testCtx *const p_ctx) { struct item { int symbology; int input_mode; + int option_2; const char *data; const char *expected; }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_CODE11, -1, "1234567890", "123456789019" }, - /* 1*/ { BARCODE_C25STANDARD, -1, "1234567890", "" }, - /* 2*/ { BARCODE_C25INTER, -1, "1234567890", "" }, - /* 3*/ { BARCODE_C25IATA, -1, "1234567890", "" }, - /* 4*/ { BARCODE_C25LOGIC, -1, "1234567890", "" }, - /* 5*/ { BARCODE_C25IND, -1, "1234567890", "" }, - /* 6*/ { BARCODE_CODE39, -1, "1234567890", "" }, - /* 7*/ { BARCODE_EXCODE39, -1, "1234567890", "" }, - /* 8*/ { BARCODE_EAN8, -1, "1234567", "12345670" }, - /* 9*/ { BARCODE_EANX, -1, "123456789012", "1234567890128" }, - /* 10*/ { BARCODE_EANX_CHK, -1, "1234567890128", "" }, - /* 11*/ { BARCODE_EAN13, -1, "123456789012", "1234567890128" }, - /* 12*/ { BARCODE_GS1_128, -1, "[01]12345678901231", "0112345678901231" }, - /* 13*/ { BARCODE_CODABAR, -1, "A00000000B", "" }, - /* 14*/ { BARCODE_CODE128, -1, "1234567890", "" }, - /* 15*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345678901236" }, - /* 16*/ { BARCODE_DPIDENT, -1, "12345678901", "123456789016" }, - /* 17*/ { BARCODE_CODE16K, -1, "1234567890", "" }, - /* 18*/ { BARCODE_CODE16K, GS1_MODE, "[01]12345678901231", "0112345678901231" }, - /* 19*/ { BARCODE_CODE49, -1, "1234567890", "" }, - /* 20*/ { BARCODE_CODE49, GS1_MODE, "[01]12345678901231", "0112345678901231" }, - /* 21*/ { BARCODE_CODE93, -1, "1234567890", "1234567890M%" }, - /* 22*/ { BARCODE_FLAT, -1, "1234567890", "" }, - /* 23*/ { BARCODE_DBAR_OMN, -1, "1234567890123", "0112345678901231" }, - /* 24*/ { BARCODE_DBAR_LTD, -1, "1234567890123", "0112345678901231" }, - /* 25*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "0112345678901231" }, - /* 26*/ { BARCODE_TELEPEN, -1, "1234567890", "1234567890n" }, - /* 27*/ { BARCODE_UPCA, -1, "12345678901", "0123456789012" }, - /* 28*/ { BARCODE_UPCA_CHK, -1, "123456789012", "0123456789012" }, - /* 29*/ { BARCODE_UPCE, -1, "1234567", "0123456000070" }, - /* 30*/ { BARCODE_UPCE_CHK, -1, "12345670", "0123456000070" }, - /* 31*/ { BARCODE_POSTNET, -1, "12345678901", "123456789014" }, - /* 32*/ { BARCODE_MSI_PLESSEY, -1, "1234567890", "" }, - /* 33*/ { BARCODE_FIM, -1, "A", "" }, - /* 34*/ { BARCODE_LOGMARS, -1, "1234567890", "" }, - /* 35*/ { BARCODE_PHARMA, -1, "123456", "" }, - /* 36*/ { BARCODE_PZN, -1, "123456", "-01234562" }, - /* 37*/ { BARCODE_PHARMA_TWO, -1, "12345678", "" }, - /* 38*/ { BARCODE_CEPNET, -1, "12345678", "123456784" }, - /* 39*/ { BARCODE_PDF417, -1, "1234567890", "" }, - /* 40*/ { BARCODE_PDF417COMP, -1, "1234567890", "" }, - /* 41*/ { BARCODE_MAXICODE, -1, "1234567890", "" }, - /* 42*/ { BARCODE_QRCODE, -1, "1234567890", "" }, - /* 43*/ { BARCODE_QRCODE, UNICODE_MODE, "1234567890", "" }, - /* 44*/ { BARCODE_QRCODE, GS1_MODE, "[01]12345678901231", "0112345678901231" }, - /* 45*/ { BARCODE_CODE128AB, -1, "1234567890", "" }, - /* 46*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "6212345678901234567890123" }, - /* 47*/ { BARCODE_AUSREPLY, -1, "12345678", "4512345678" }, - /* 48*/ { BARCODE_AUSROUTE, -1, "12345678", "8712345678" }, - /* 49*/ { BARCODE_AUSREDIRECT, -1, "12345678", "9212345678" }, - /* 50*/ { BARCODE_ISBNX, -1, "123456789", "9780123456786" }, - /* 51*/ { BARCODE_RM4SCC, -1, "1234567890", "12345678906" }, - /* 52*/ { BARCODE_DATAMATRIX, -1, "ABC", "" }, - /* 53*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]12345678901231", "0112345678901231" }, - /* 54*/ { BARCODE_EAN14, -1, "1234567890123", "0112345678901231" }, - /* 55*/ { BARCODE_VIN, -1, "12345678701234567", "" }, - /* 56*/ { BARCODE_CODABLOCKF, -1, "1234567890", "" }, - /* 57*/ { BARCODE_NVE18, -1, "12345678901234567", "00123456789012345675" }, - /* 58*/ { BARCODE_JAPANPOST, -1, "1234567890", "" }, - /* 59*/ { BARCODE_KOREAPOST, -1, "123456", "1234569" }, - /* 60*/ { BARCODE_DBAR_STK, -1, "1234567890123", "0112345678901231" }, - /* 61*/ { BARCODE_DBAR_OMNSTK, -1, "1234567890123", "0112345678901231" }, - /* 62*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "0112345678901231" }, - /* 63*/ { BARCODE_PLANET, -1, "12345678901", "123456789014" }, - /* 64*/ { BARCODE_MICROPDF417, -1, "1234567890", "" }, - /* 65*/ { BARCODE_USPS_IMAIL, -1, "12345678901234567890", "" }, - /* 66*/ { BARCODE_PLESSEY, -1, "1234567890", "12345678906E" }, - /* 67*/ { BARCODE_TELEPEN_NUM, -1, "1234567890", "1234567890g" }, - /* 68*/ { BARCODE_ITF14, -1, "1234567890", "00012345678905" }, - /* 69*/ { BARCODE_KIX, -1, "123456ABCDE", "" }, - /* 70*/ { BARCODE_AZTEC, -1, "1234567890AB", "" }, - /* 71*/ { BARCODE_DAFT, -1, "DAFTDAFTDAFTDAFT", "" }, - /* 72*/ { BARCODE_DPD, -1, "0123456789012345678901234567", "" }, - /* 73*/ { BARCODE_MICROQR, -1, "12345", "" }, - /* 74*/ { BARCODE_MICROQR, UNICODE_MODE, "12345", "" }, - /* 75*/ { BARCODE_HIBC_128, -1, "1234567890", "+12345678900" }, - /* 76*/ { BARCODE_HIBC_39, -1, "1234567890", "+12345678900" }, - /* 77*/ { BARCODE_HIBC_DM, -1, "ABC", "+ABCV" }, - /* 78*/ { BARCODE_HIBC_QR, -1, "1234567890AB", "+1234567890ABL" }, - /* 79*/ { BARCODE_HIBC_PDF, -1, "1234567890", "+12345678900" }, - /* 80*/ { BARCODE_HIBC_MICPDF, -1, "1234567890", "+12345678900" }, - /* 81*/ { BARCODE_HIBC_BLOCKF, -1, "1234567890", "+12345678900" }, - /* 82*/ { BARCODE_HIBC_AZTEC, -1, "1234567890AB", "+1234567890ABL" }, - /* 83*/ { BARCODE_DOTCODE, -1, "ABC", "" }, - /* 84*/ { BARCODE_HANXIN, -1, "1234567890AB", "" }, - /* 85*/ { BARCODE_HANXIN, UNICODE_MODE, "1234567890AB", "" }, - /* 86*/ { BARCODE_MAILMARK_2D, -1, "012100123412345678AB19XY1A 0", "JGB 012100123412345678AB19XY1A 0 " }, - /* 87*/ { BARCODE_UPU_S10, -1, "EE876543216CA", "" }, - /* 88*/ { BARCODE_MAILMARK_4S, -1, "01000000000000000AA00AA0A", "01000000000000000AA00AA0A " }, - /* 89*/ { BARCODE_AZRUNE, -1, "255", "" }, - /* 90*/ { BARCODE_CODE32, -1, "12345678", "3PRM8N" }, - /* 91*/ { BARCODE_EANX_CC, -1, "123456789012", "1234567890128|2001" }, - /* 92*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "0112345678901231|2001" }, - /* 93*/ { BARCODE_DBAR_OMN_CC, -1, "1234567890123", "0112345678901231|2001" }, - /* 94*/ { BARCODE_DBAR_LTD_CC, -1, "1234567890123", "0112345678901231|2001" }, - /* 95*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "0112345678901231|2001" }, - /* 96*/ { BARCODE_UPCA_CC, -1, "12345678901", "0123456789012|2001" }, - /* 97*/ { BARCODE_UPCE_CC, -1, "1234567", "0123456000070|2001" }, - /* 98*/ { BARCODE_DBAR_STK_CC, -1, "1234567890123", "0112345678901231|2001" }, - /* 99*/ { BARCODE_DBAR_OMNSTK_CC, -1, "1234567890123", "0112345678901231|2001" }, - /*100*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "0112345678901231|2001" }, - /*101*/ { BARCODE_CHANNEL, -1, "01", "" }, - /*102*/ { BARCODE_CODEONE, -1, "12345678901234567890", "" }, - /*103*/ { BARCODE_CODEONE, GS1_MODE, "[01]12345678901231", "0112345678901231" }, - /*104*/ { BARCODE_GRIDMATRIX, -1, "ABC", "" }, - /*105*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, "ABC", "" }, - /*106*/ { BARCODE_UPNQR, -1, "1234567890AB", "" }, - /*107*/ { BARCODE_ULTRA, -1, "1234567890", "" }, - /*108*/ { BARCODE_ULTRA, GS1_MODE, "[01]12345678901231", "0112345678901231" }, - /*109*/ { BARCODE_RMQR, -1, "12345", "" }, - /*110*/ { BARCODE_RMQR, UNICODE_MODE, "12345", "" }, - /*111*/ { BARCODE_RMQR, GS1_MODE, "[01]12345678901231", "0112345678901231" }, - /*112*/ { BARCODE_BC412, -1, "1234567", "1U234567" }, - /*113*/ { BARCODE_DXFILMEDGE, -1, "120476", "127-15" }, - /*114*/ { BARCODE_EAN8_CC, -1, "12345670", "12345670|2001" }, - /*115*/ { BARCODE_EAN13_CC, -1, "123456789012", "1234567890128|2001" }, + /* 0*/ { BARCODE_CODE11, -1, -1, "1234567890", "123456789019" }, + /* 1*/ { BARCODE_C25STANDARD, -1, -1, "1234567890", "" }, + /* 2*/ { BARCODE_C25INTER, -1, -1, "1234567890", "" }, + /* 3*/ { BARCODE_C25IATA, -1, -1, "1234567890", "" }, + /* 4*/ { BARCODE_C25LOGIC, -1, -1, "1234567890", "" }, + /* 5*/ { BARCODE_C25IND, -1, -1, "1234567890", "" }, + /* 6*/ { BARCODE_CODE39, -1, -1, "1234567890", "" }, + /* 7*/ { BARCODE_EXCODE39, -1, -1, "1234567890", "" }, + /* 8*/ { BARCODE_EAN8, -1, -1, "1234567", "12345670" }, + /* 9*/ { BARCODE_EANX, -1, -1, "123456789012", "1234567890128" }, + /* 10*/ { BARCODE_EANX_CHK, -1, -1, "1234567890128", "" }, + /* 11*/ { BARCODE_EAN13, -1, -1, "123456789012", "1234567890128" }, + /* 12*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231", "0112345678901231" }, + /* 13*/ { BARCODE_CODABAR, -1, -1, "A00000000B", "" }, + /* 14*/ { BARCODE_CODE128, -1, -1, "1234567890", "" }, + /* 15*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", "" }, + /* 16*/ { BARCODE_DPLEIT, -1, -1, "1234567890123", "12345678901236" }, + /* 17*/ { BARCODE_DPIDENT, -1, -1, "12345678901", "123456789016" }, + /* 18*/ { BARCODE_CODE16K, -1, -1, "1234567890", "" }, + /* 19*/ { BARCODE_CODE16K, UNICODE_MODE, -1, "1234567890", "" }, + /* 20*/ { BARCODE_CODE16K, GS1_MODE, -1, "[01]12345678901231", "0112345678901231" }, + /* 21*/ { BARCODE_CODE49, -1, -1, "1234567890", "" }, + /* 22*/ { BARCODE_CODE49, GS1_MODE, -1, "[01]12345678901231", "0112345678901231" }, + /* 23*/ { BARCODE_CODE93, -1, -1, "1234567890", "1234567890M%" }, + /* 24*/ { BARCODE_FLAT, -1, -1, "1234567890", "" }, + /* 25*/ { BARCODE_DBAR_OMN, -1, -1, "1234567890123", "0112345678901231" }, + /* 26*/ { BARCODE_DBAR_LTD, -1, -1, "1234567890123", "0112345678901231" }, + /* 27*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231", "0112345678901231" }, + /* 28*/ { BARCODE_TELEPEN, -1, -1, "1234567890", "1234567890n" }, + /* 29*/ { BARCODE_TELEPEN, -1, 1, "ABC\0201234", "ABC\0201234C" }, + /* 30*/ { BARCODE_UPCA, -1, -1, "12345678901", "0123456789012" }, + /* 31*/ { BARCODE_UPCA_CHK, -1, -1, "123456789012", "0123456789012" }, + /* 32*/ { BARCODE_UPCE, -1, -1, "1234567", "0123456000070" }, + /* 33*/ { BARCODE_UPCE_CHK, -1, -1, "12345670", "0123456000070" }, + /* 34*/ { BARCODE_POSTNET, -1, -1, "12345678901", "123456789014" }, + /* 35*/ { BARCODE_MSI_PLESSEY, -1, -1, "1234567890", "" }, + /* 36*/ { BARCODE_MSI_PLESSEY, -1, 1, "1234567890", "12345678903" }, + /* 37*/ { BARCODE_MSI_PLESSEY, -1, 2, "1234567890", "123456789031" }, + /* 38*/ { BARCODE_MSI_PLESSEY, -1, 3, "1234567890", "12345678903" }, + /* 39*/ { BARCODE_MSI_PLESSEY, -1, 4, "1234567890", "123456789031" }, + /* 40*/ { BARCODE_MSI_PLESSEY, -1, 5, "1234567890", "12345678900" }, + /* 41*/ { BARCODE_MSI_PLESSEY, -1, 6, "1234567890", "123456789007" }, + /* 42*/ { BARCODE_FIM, -1, -1, "A", "" }, + /* 43*/ { BARCODE_LOGMARS, -1, -1, "1234567890", "" }, + /* 44*/ { BARCODE_PHARMA, -1, -1, "123456", "" }, + /* 45*/ { BARCODE_PZN, -1, -1, "123456", "-01234562" }, + /* 46*/ { BARCODE_PHARMA_TWO, -1, -1, "12345678", "" }, + /* 47*/ { BARCODE_CEPNET, -1, -1, "12345678", "123456784" }, + /* 48*/ { BARCODE_PDF417, -1, -1, "1234567890", "" }, + /* 49*/ { BARCODE_PDF417COMP, -1, -1, "1234567890", "" }, + /* 50*/ { BARCODE_MAXICODE, -1, -1, "1234567890", "" }, + /* 51*/ { BARCODE_QRCODE, -1, -1, "1234567890", "" }, + /* 52*/ { BARCODE_QRCODE, UNICODE_MODE, -1, "1234567890", "" }, + /* 53*/ { BARCODE_QRCODE, GS1_MODE, -1, "[01]12345678901231", "0112345678901231" }, + /* 54*/ { BARCODE_CODE128AB, -1, -1, "1234567890", "" }, + /* 55*/ { BARCODE_AUSPOST, -1, -1, "12345678901234567890123", "6212345678901234567890123" }, + /* 56*/ { BARCODE_AUSREPLY, -1, -1, "12345678", "4512345678" }, + /* 57*/ { BARCODE_AUSROUTE, -1, -1, "12345678", "8712345678" }, + /* 58*/ { BARCODE_AUSREDIRECT, -1, -1, "12345678", "9212345678" }, + /* 59*/ { BARCODE_ISBNX, -1, -1, "123456789", "9780123456786" }, + /* 60*/ { BARCODE_RM4SCC, -1, -1, "1234567890", "12345678906" }, + /* 61*/ { BARCODE_DATAMATRIX, -1, -1, "ABC", "" }, + /* 62*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "[01]12345678901231", "0112345678901231" }, + /* 63*/ { BARCODE_EAN14, -1, -1, "1234567890123", "0112345678901231" }, + /* 64*/ { BARCODE_VIN, -1, -1, "12345678701234567", "" }, + /* 65*/ { BARCODE_CODABLOCKF, -1, -1, "1234567890", "" }, + /* 66*/ { BARCODE_NVE18, -1, -1, "12345678901234567", "00123456789012345675" }, + /* 67*/ { BARCODE_JAPANPOST, -1, -1, "1234567890", "" }, + /* 68*/ { BARCODE_KOREAPOST, -1, -1, "123456", "1234569" }, + /* 69*/ { BARCODE_DBAR_STK, -1, -1, "1234567890123", "0112345678901231" }, + /* 70*/ { BARCODE_DBAR_OMNSTK, -1, -1, "1234567890123", "0112345678901231" }, + /* 71*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231", "0112345678901231" }, + /* 72*/ { BARCODE_PLANET, -1, -1, "12345678901", "123456789014" }, + /* 73*/ { BARCODE_MICROPDF417, -1, -1, "1234567890", "" }, + /* 74*/ { BARCODE_USPS_IMAIL, -1, -1, "12345678901234567890", "" }, + /* 75*/ { BARCODE_PLESSEY, -1, -1, "1234567890", "12345678906E" }, + /* 76*/ { BARCODE_TELEPEN_NUM, -1, -1, "1234567890", "1234567890g" }, + /* 77*/ { BARCODE_TELEPEN_NUM, -1, -1, "1234567890\020", "1234567890\020W" }, + /* 78*/ { BARCODE_ITF14, -1, -1, "1234567890", "00012345678905" }, + /* 79*/ { BARCODE_KIX, -1, -1, "123456ABCDE", "" }, + /* 80*/ { BARCODE_AZTEC, -1, -1, "1234567890AB", "" }, + /* 81*/ { BARCODE_DAFT, -1, -1, "DAFTDAFTDAFTDAFT", "" }, + /* 82*/ { BARCODE_DPD, -1, -1, "0123456789012345678901234567", "" }, + /* 83*/ { BARCODE_MICROQR, -1, -1, "12345", "" }, + /* 84*/ { BARCODE_MICROQR, UNICODE_MODE, -1, "12345", "" }, + /* 85*/ { BARCODE_HIBC_128, -1, -1, "1234567890", "+12345678900" }, + /* 86*/ { BARCODE_HIBC_39, -1, -1, "1234567890", "+12345678900" }, + /* 87*/ { BARCODE_HIBC_DM, -1, -1, "ABC", "+ABCV" }, + /* 88*/ { BARCODE_HIBC_QR, -1, -1, "1234567890AB", "+1234567890ABL" }, + /* 89*/ { BARCODE_HIBC_PDF, -1, -1, "1234567890", "+12345678900" }, + /* 90*/ { BARCODE_HIBC_MICPDF, -1, -1, "1234567890", "+12345678900" }, + /* 91*/ { BARCODE_HIBC_BLOCKF, -1, -1, "1234567890", "+12345678900" }, + /* 92*/ { BARCODE_HIBC_AZTEC, -1, -1, "1234567890AB", "+1234567890ABL" }, + /* 93*/ { BARCODE_DOTCODE, -1, -1, "ABC", "" }, + /* 94*/ { BARCODE_HANXIN, -1, -1, "1234567890AB", "" }, + /* 95*/ { BARCODE_HANXIN, UNICODE_MODE, -1, "1234567890AB", "" }, + /* 96*/ { BARCODE_MAILMARK_2D, -1, -1, "012100123412345678AB19XY1A 0", "JGB 012100123412345678AB19XY1A 0 " }, + /* 97*/ { BARCODE_MAILMARK_2D, UNICODE_MODE, -1, "012100123412345678AB19XY1A 0", "JGB 012100123412345678AB19XY1A 0 " }, + /* 98*/ { BARCODE_UPU_S10, -1, -1, "EE876543216CA", "" }, + /* 99*/ { BARCODE_MAILMARK_4S, -1, -1, "01000000000000000AA00AA0A", "01000000000000000AA00AA0A " }, + /*100*/ { BARCODE_AZRUNE, -1, -1, "255", "" }, + /*101*/ { BARCODE_CODE32, -1, -1, "12345678", "3PRM8N" }, + /*102*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "1234567890128|2001" }, + /*103*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231", "0112345678901231|2001" }, + /*104*/ { BARCODE_DBAR_OMN_CC, -1, -1, "1234567890123", "0112345678901231|2001" }, + /*105*/ { BARCODE_DBAR_LTD_CC, -1, -1, "1234567890123", "0112345678901231|2001" }, + /*106*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231", "0112345678901231|2001" }, + /*107*/ { BARCODE_UPCA_CC, -1, -1, "12345678901", "0123456789012|2001" }, + /*108*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "0123456000070|2001" }, + /*109*/ { BARCODE_DBAR_STK_CC, -1, -1, "1234567890123", "0112345678901231|2001" }, + /*110*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, "1234567890123", "0112345678901231|2001" }, + /*111*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231", "0112345678901231|2001" }, + /*112*/ { BARCODE_CHANNEL, -1, -1, "01", "" }, + /*113*/ { BARCODE_CODEONE, -1, -1, "12345678901234567890", "" }, + /*114*/ { BARCODE_CODEONE, GS1_MODE, -1, "[01]12345678901231", "0112345678901231" }, + /*115*/ { BARCODE_GRIDMATRIX, -1, -1, "ABC", "" }, + /*116*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, -1, "ABC", "" }, + /*117*/ { BARCODE_UPNQR, -1, -1, "1234567890AB", "" }, + /*118*/ { BARCODE_ULTRA, -1, -1, "1234567890", "" }, + /*119*/ { BARCODE_ULTRA, GS1_MODE, -1, "[01]12345678901231", "0112345678901231" }, + /*120*/ { BARCODE_RMQR, -1, -1, "12345", "" }, + /*121*/ { BARCODE_RMQR, UNICODE_MODE, -1, "12345", "" }, + /*122*/ { BARCODE_RMQR, GS1_MODE, -1, "[01]12345678901231", "0112345678901231" }, + /*123*/ { BARCODE_BC412, -1, -1, "1234567", "1U234567" }, + /*124*/ { BARCODE_DXFILMEDGE, -1, -1, "120476", "127-15" }, + /*125*/ { BARCODE_EAN8_CC, -1, -1, "12345670", "12345670|2001" }, + /*126*/ { BARCODE_EAN13_CC, -1, -1, "123456789012", "1234567890128|2001" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -3111,7 +3212,7 @@ static void test_content_segs(const testCtx *const p_ctx) { text = data[i].data; } length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, - -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, BARCODE_CONTENT_SEGS, + -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, BARCODE_CONTENT_SEGS, text, -1, debug); expected = data[i].expected[0] ? data[i].expected : data[i].data; expected_length = (int) strlen(expected); @@ -3132,6 +3233,106 @@ static void test_content_segs(const testCtx *const p_ctx) { ZBarcode_Delete(symbol); } + for (i = 0; i < data_size; i++) { + int fail_at = 1; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + if (z_is_composite(data[i].symbology)) { + text = "[20]01"; + strcpy(symbol->primary, data[i].data); + fail_at = 1 + !(i & 1); /* Alternate between failing on linear and composite */ + } else { + text = data[i].data; + } + length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, + -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, BARCODE_CONTENT_SEGS, + text, -1, debug); + + zint_test_ct_set_fail(Z_CT_FAIL_ID_INIT_SEGS, fail_at); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); + assert_equal(ret, ZINT_ERROR_MEMORY, "i:%d Z_CT_FAIL_ID_INIT_SEGS ret %d != ZINT_ERROR_MEMORY %s\n", + i, ret, symbol->errtxt); + zint_test_ct_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + for (i = 0; i < data_size; i++) { + int fail_at = 1; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + if (z_is_composite(data[i].symbology)) { + text = "[20]01"; + strcpy(symbol->primary, data[i].data); + fail_at = 1 + !!(i & 1); /* Alternate between failing on linear and composite */ + } else { + text = data[i].data; + } + length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, + -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, BARCODE_CONTENT_SEGS, + text, -1, debug); + + zint_test_ct_set_fail(Z_CT_FAIL_ID_INIT_SEG_SRC, fail_at); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); + assert_equal(ret, ZINT_ERROR_MEMORY, "i:%d Z_CT_FAIL_ID_INIT_SEG_SRC ret %d != ZINT_ERROR_MEMORY %s\n", + i, ret, symbol->errtxt); + zint_test_ct_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + +#include "filemem.h" + +static void test_txt_hex_plot(const testCtx *const p_ctx) { + int ret; + struct zint_symbol *symbol = NULL; + unsigned char data[10] = {0}; + const int length = 1; + int at; + + (void)p_ctx; + + testStartSymbol(p_ctx->func_name, &symbol); + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + symbol->symbology = BARCODE_DATAMATRIX; + strcpy(symbol->outfile, "out.txt"); + ret = ZBarcode_Encode(symbol, data, ARRAY_SIZE(data)); + assert_zero(ret, "ZBarcode_Encode ret %d != 0 (%s)\n", ret, symbol->errtxt); + + for (at = 5; at < 10; at++) { + zint_test_fm_set_fail(FM_FAIL_ID_PUTC, at); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, ZINT_ERROR_FILE_WRITE, "ZBarcode_Print PUTC(%d) ret %d != ZINT_ERROR_FILE_WRITE (%s)\n", + at, ret, symbol->errtxt); + + ZBarcode_Clear(symbol); + ret = ZBarcode_Encode(symbol, data, length); + assert_zero(ret, "ZBarcode_Encode ret %d != 0 (%s)\n", ret, symbol->errtxt); + } + + zint_test_fm_set_fail(FM_FAIL_ID_CLOSE, 1); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, ZINT_ERROR_FILE_WRITE, "ZBarcode_Print CLOSE ret %d != ZINT_ERROR_FILE_WRITE (%s)\n", + ret, symbol->errtxt); + + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + testFinish(); } @@ -3165,10 +3366,12 @@ int main(int argc, char *argv[]) { { "test_zero_outfile", test_zero_outfile }, { "test_clear", test_clear }, { "test_reset", test_reset }, + { "test_default_xdim", test_default_xdim }, { "test_scale_from_xdimdp", test_scale_from_xdimdp }, { "test_xdimdp_from_scale", test_xdimdp_from_scale }, { "test_utf8_to_eci", test_utf8_to_eci }, { "test_content_segs", test_content_segs }, + { "test_txt_hex_plot", test_txt_hex_plot }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_maxicode.c b/backend/tests/test_maxicode.c index 98daee32..64a128fc 100644 --- a/backend/tests/test_maxicode.c +++ b/backend/tests/test_maxicode.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2025 Robin Stuart + Copyright (C) 2019-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -109,31 +109,45 @@ static void test_large(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length); - assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf)); + assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", + i, data[i].length, (int) strlen(data_buf)); - length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug); + length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, -1 /*eci*/, + data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, + data_buf, data[i].length, debug); strcpy(symbol->primary, data[i].primary); ret = ZBarcode_Encode(symbol, TCU(data_buf), length); - 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); + 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", + i, ret ? "set" : "empty", symbol->errtxt); if (ret < ZINT_ERROR) { - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", + i, symbol->rows, data[i].expected_rows); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", + i, symbol->width, data[i].expected_width); } else { - assert_zero(strcmp(symbol->errtxt, expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, expected_errtxt); + assert_zero(strcmp(symbol->errtxt, expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", + i, symbol->errtxt, expected_errtxt); } if (ret < ZINT_ERROR) { if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) { 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); + if (debug & ZINT_DEBUG_TEST_PRINT) { + printf("i:%d %s not BWIPP compatible (%s)\n", + i, testUtilBarcodeName(symbol->symbology), data[i].comment); + } } else { char modules_dump[33 * 33 + 1]; - assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); - ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, data_buf, length, symbol->primary, cmp_buf, sizeof(cmp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, + "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, data_buf, length, + symbol->primary, cmp_buf, sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, + testUtilBarcodeName(symbol->symbology), ret); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", @@ -1220,14 +1234,17 @@ static void test_encode(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); + length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, data[i].input_mode, -1 /*eci*/, + data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, + data[i].data, data[i].length, debug); if (data[i].structapp.count) { symbol->structapp = data[i].structapp; } strcpy(symbol->primary, data[i].primary); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, \"%s\", %s, %d, %d, %d, %d, \"%s\",\n", @@ -1242,22 +1259,31 @@ static void test_encode(const testCtx *const p_ctx) { if (ret < ZINT_ERROR) { int width, row; - 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); + 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); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); - assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); + 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, data[i].option_1, data[i].option_2, -1, debug)) { 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); + 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, data[i].option_1, data[i].option_2, -1, data[i].data, length, data[i].primary, cmp_buf, sizeof(cmp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, data[i].data, length, + data[i].primary, cmp_buf, sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_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, cmp_msg, cmp_buf, data[i].expected); + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, + data[i].expected); } } if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { @@ -1826,15 +1852,20 @@ static void test_encode_segs(const testCtx *const p_ctx) { for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++); ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { char escaped1[4096]; char escaped2[4096]; - int length = data[i].segs[0].length == -1 ? (int) z_ustrlen(data[i].segs[0].source) : data[i].segs[0].length; - int length1 = data[i].segs[1].length == -1 ? (int) z_ustrlen(data[i].segs[1].source) : data[i].segs[1].length; - int length2 = data[i].segs[2].length == -1 ? (int) z_ustrlen(data[i].segs[2].source) : data[i].segs[2].length; - printf(" /*%3d*/ { %s, %d, %d, { %d, %d, \"%s\" }, { { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d } }, \"%s\", %s, %d, %d, %d, \"%s\",\n", + int length = data[i].segs[0].length == -1 ? (int) z_ustrlen(data[i].segs[0].source) + : data[i].segs[0].length; + int length1 = data[i].segs[1].length == -1 ? (int) z_ustrlen(data[i].segs[1].source) + : data[i].segs[1].length; + int length2 = data[i].segs[2].length == -1 ? (int) z_ustrlen(data[i].segs[2].source) + : data[i].segs[2].length; + printf(" /*%3d*/ { %s, %d, %d, { %d, %d, \"%s\" }, { { TU(\"%s\"), %d, %d }," + "{ TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d } }, \"%s\", %s, %d, %d, %d, \"%s\",\n", i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, testUtilEscape((const char *) data[i].segs[0].source, length, escaped, sizeof(escaped)), @@ -1897,7 +1928,8 @@ static void test_encode_segs(const testCtx *const p_ctx) { ret = testUtilZXingCPPCmpSegs(symbol, cmp_msg, cmp_buf, cmp_len, data[i].segs, seg_count, data[i].primary, escaped, &ret_len); - assert_zero(ret, "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", + assert_zero(ret, + "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); } @@ -1908,6 +1940,32 @@ static void test_encode_segs(const testCtx *const p_ctx) { ZBarcode_Delete(symbol); } + if (!p_ctx->generate && p_ctx->index == -1) { + struct zint_seg segs[25] = {0}; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (i = 0; i < ARRAY_SIZE(segs); i++) { + segs[i].eci = 899; + segs[i].source = ZUCP("A"); + segs[i].length = 1; + } + symbol->symbology = BARCODE_MAXICODE; + symbol->option_1 = 5; + + seg_count = ARRAY_SIZE(segs); + ret = ZBarcode_Encode_Segs(symbol, segs, seg_count); + assert_equal(ret, ZINT_ERROR_TOO_LONG, "ZBarcode_Encode_Segs ret %d != %d (%s)\n", + ret, ZINT_ERROR_TOO_LONG, symbol->errtxt); + + seg_count = 19; + ret = ZBarcode_Encode_Segs(symbol, segs, seg_count); + assert_zero(ret, "ZBarcode_Encode_Segs ret %d != 0 (%s)\n", ret, symbol->errtxt); + + ZBarcode_Delete(symbol); + } + testFinish(); } @@ -1977,8 +2035,8 @@ static void test_rt(const testCtx *const p_ctx) { i, symbol->content_segs[0].length, expected_length); assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length), "i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i, - testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length, - escaped, sizeof(escaped)), + testUtilEscape((const char *) symbol->content_segs[0].source, + symbol->content_segs[0].length, escaped, sizeof(escaped)), testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)), expected_length); assert_equal(symbol->content_segs[0].eci, data[i].expected_content_eci, @@ -2050,8 +2108,9 @@ static void test_rt_segs(const testCtx *const p_ctx) { assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); - assert_equal(symbol->content_seg_count, data[i].expected_content_seg_count, "i:%d symbol->content_seg_count %d != %d\n", - i, symbol->content_seg_count, data[i].expected_content_seg_count); + assert_equal(symbol->content_seg_count, data[i].expected_content_seg_count, + "i:%d symbol->content_seg_count %d != %d\n", + i, symbol->content_seg_count, data[i].expected_content_seg_count); if (symbol->output_options & BARCODE_CONTENT_SEGS) { assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i); for (j = 0; j < symbol->content_seg_count; j++) { @@ -2062,7 +2121,8 @@ static void test_rt_segs(const testCtx *const p_ctx) { assert_equal(symbol->content_segs[j].length, expected_length, "i:%d content_segs[%d].length %d != expected_length %d\n", i, j, symbol->content_segs[j].length, expected_length); - assert_zero(memcmp(symbol->content_segs[j].source, data[i].expected_content_segs[j].source, expected_length), + assert_zero(memcmp(symbol->content_segs[j].source, data[i].expected_content_segs[j].source, + expected_length), "i:%d content_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, j, testUtilEscape((const char *) symbol->content_segs[j].source, expected_length, escaped, sizeof(escaped)), @@ -2115,10 +2175,13 @@ static void test_fuzz(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, data[i].eci, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); + length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, data[i].eci, + -1 /*option_1*/, -1, -1, -1 /*output_options*/, + data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); ZBarcode_Delete(symbol); } diff --git a/backend/tests/test_output.c b/backend/tests/test_output.c index 8e7c047e..3cda688f 100644 --- a/backend/tests/test_output.c +++ b/backend/tests/test_output.c @@ -35,6 +35,7 @@ #include #include #endif +#include static void test_check_colour_options(const testCtx *const p_ctx) { struct item { @@ -82,7 +83,8 @@ static void test_check_colour_options(const testCtx *const p_ctx) { ret = zint_out_check_colour_options(&symbol); assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt); - assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d symbol.errtxt (%s) != expected (%s)\n", i, symbol.errtxt, data[i].expected); + assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d symbol.errtxt (%s) != expected (%s)\n", + i, symbol.errtxt, data[i].expected); } testFinish(); @@ -130,10 +132,14 @@ static void test_colour_get_rgb(const testCtx *const p_ctx) { ret = zint_out_colour_get_rgb(data[i].colour, &red, &green, &blue, &alpha); assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); - assert_equal(red, data[i].red, "i:%d red 0x%02X (%d) != 0x%02X (%d) (green 0x%02X, blue 0x%02X)\n", i, red, red, data[i].red, data[i].red, green, blue); - assert_equal(green, data[i].green, "i:%d green %d (0x%02X) != %d (0x%02X)\n", i, green, green, data[i].green, data[i].green); - assert_equal(blue, data[i].blue, "i:%d blue %d (0x%02X) != %d (0x%02X)\n", i, blue, blue, data[i].blue, data[i].blue); - assert_equal(alpha, data[i].alpha, "i:%d alpha %d (0x%02X) != %d (0x%02X)\n", i, alpha, alpha, data[i].alpha, data[i].alpha); + assert_equal(red, data[i].red, "i:%d red 0x%02X (%d) != 0x%02X (%d) (green 0x%02X, blue 0x%02X)\n", + i, red, red, data[i].red, data[i].red, green, blue); + assert_equal(green, data[i].green, "i:%d green %d (0x%02X) != %d (0x%02X)\n", + i, green, green, data[i].green, data[i].green); + assert_equal(blue, data[i].blue, "i:%d blue %d (0x%02X) != %d (0x%02X)\n", + i, blue, blue, data[i].blue, data[i].blue); + assert_equal(alpha, data[i].alpha, "i:%d alpha %d (0x%02X) != %d (0x%02X)\n", + i, alpha, alpha, data[i].alpha, data[i].alpha); have_alpha = ret == 1; if (have_alpha) { @@ -142,11 +148,14 @@ static void test_colour_get_rgb(const testCtx *const p_ctx) { sprintf(rgb, "%02X%02X%02X", red, green, blue); } ret = zint_out_colour_get_cmyk(rgb, &cyan, &magenta, &yellow, &black, &rgb_alpha); - assert_equal(ret, 1 + have_alpha, "i:%d zint_out_colour_get_cmyk(%s) ret %d != %d\n", i, rgb, ret, 1 + have_alpha); - assert_equal(rgb_alpha, alpha, "i:%d rgb_alpha %d (0x%02X) != %d (0x%02X)\n", i, rgb_alpha, rgb_alpha, alpha, alpha); + assert_equal(ret, 1 + have_alpha, "i:%d zint_out_colour_get_cmyk(%s) ret %d != %d\n", + i, rgb, ret, 1 + have_alpha); + assert_equal(rgb_alpha, alpha, "i:%d rgb_alpha %d (0x%02X) != %d (0x%02X)\n", + i, rgb_alpha, rgb_alpha, alpha, alpha); sprintf(cmyk, "%d,%d,%d,%d", cyan, magenta, yellow, black); - assert_zero(strcmp(cmyk, data[i].expected_cmyk), "i:%d strcmp(%s, %s) != 0\n", i, cmyk, data[i].expected_cmyk); + assert_zero(strcmp(cmyk, data[i].expected_cmyk), "i:%d strcmp(%s, %s) != 0\n", + i, cmyk, data[i].expected_cmyk); } testFinish(); @@ -188,13 +197,15 @@ static void test_colour_get_cmyk(const testCtx *const p_ctx) { ret = zint_out_colour_get_cmyk(data[i].colour, &cyan, &magenta, &yellow, &black, &alpha); assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); - assert_equal(cyan, data[i].cyan, "i:%d cyan %d != %d (magenta %d, yellow %d, black %d)\n", i, cyan, data[i].cyan, magenta, yellow, black); + assert_equal(cyan, data[i].cyan, "i:%d cyan %d != %d (magenta %d, yellow %d, black %d)\n", + i, cyan, data[i].cyan, magenta, yellow, black); assert_equal(magenta, data[i].magenta, "i:%d magenta %d != %d\n", i, magenta, data[i].magenta); assert_equal(yellow, data[i].yellow, "i:%d yellow %d != %d\n", i, yellow, data[i].yellow); assert_equal(alpha, data[i].alpha, "i:%d alpha %d != %d\n", i, alpha, data[i].alpha); ret = zint_out_colour_get_rgb(data[i].colour, &red, &green, &blue, &rgb_alpha); - assert_equal(ret, data[i].ret_rgb, "i:%d zint_out_colour_get_rgb(%s) ret %d != %d\n", i, rgb, ret, data[i].ret_rgb); + assert_equal(ret, data[i].ret_rgb, "i:%d zint_out_colour_get_rgb(%s) ret %d != %d\n", + i, rgb, ret, data[i].ret_rgb); assert_equal(rgb_alpha, alpha, "i:%d rgb_alpha %d != %d\n", i, rgb_alpha, alpha); sprintf(rgb, "%02X%02X%02X%02X", red, green, blue, rgb_alpha); @@ -204,6 +215,47 @@ static void test_colour_get_cmyk(const testCtx *const p_ctx) { testFinish(); } +static void test_colour_char_to_rgb(const testCtx *const p_ctx) { + struct item { + const char ch; + int ret; + unsigned char red; + unsigned char green; + unsigned char blue; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { 'W', 1, 0xFF, 0xFF, 0xFF }, + /* 1*/ { 'C', 1, 0x00, 0xFF, 0xFF }, + /* 2*/ { 'B', 1, 0x00, 0x00, 0xFF }, + /* 3*/ { 'G', 1, 0x00, 0xFF, 0x00 }, + /* 4*/ { 'K', 1, 0x00, 0x00, 0x00 }, + /* 5*/ { 'L', 0, 0x00, 0x00, 0x00 }, + }; + const int data_size = ARRAY_SIZE(data); + int i, ret; + + testStart(p_ctx->func_name); + + for (i = 0; i < data_size; i++) { + /* Suppress clang-16 run-time exception MemorySanitizer: use-of-uninitialized-value (fixed in clang-17) */ + unsigned char red = 0, green = 0, blue = 0; + + if (testContinue(p_ctx, i)) continue; + + ret = zint_out_colour_char_to_rgb(data[i].ch, &red, &green, &blue); + assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); + assert_equal(red, data[i].red, "i:%d red 0x%02X (%d) != 0x%02X (%d) (green 0x%02X, blue 0x%02X)\n", + i, red, red, data[i].red, data[i].red, green, blue); + assert_equal(green, data[i].green, "i:%d green %d (0x%02X) != %d (0x%02X)\n", + i, green, green, data[i].green, data[i].green); + assert_equal(blue, data[i].blue, "i:%d blue %d (0x%02X) != %d (0x%02X)\n", + i, blue, blue, data[i].blue, data[i].blue); + } + + testFinish(); +} + INTERNAL int zint_test_out_quiet_zones(const struct zint_symbol *symbol, const int hide_text, const int comp_xoffset, float *left, float *right, float *top, float *bottom); @@ -287,22 +339,32 @@ static void test_set_whitespace_offsets(const testCtx *const p_ctx) { zint_out_set_whitespace_offsets(&symbol, data[i].hide_text, data[i].comp_xoffset, &xoffset, &yoffset, &roffset, &boffset, &qz_right, data[i].scaler, &xoffset_si, &yoffset_si, &roffset_si, &boffset_si, &qz_right_si); - assert_equal(xoffset, data[i].expected_xoffset, "i:%d xoffset %g != %g\n", i, xoffset, data[i].expected_xoffset); - assert_equal(yoffset, data[i].expected_yoffset, "i:%d yoffset %g != %g\n", i, yoffset, data[i].expected_yoffset); - assert_equal(roffset, data[i].expected_roffset, "i:%d roffset %g != %g\n", i, roffset, data[i].expected_roffset); - assert_equal(boffset, data[i].expected_boffset, "i:%d boffset %g != %g\n", i, boffset, data[i].expected_boffset); - assert_equal(qz_right, data[i].expected_qz_right, "i:%d qz_right %g != %g\n", i, qz_right, data[i].expected_qz_right); + assert_equal(xoffset, data[i].expected_xoffset, "i:%d xoffset %g != %g\n", + i, xoffset, data[i].expected_xoffset); + assert_equal(yoffset, data[i].expected_yoffset, "i:%d yoffset %g != %g\n", + i, yoffset, data[i].expected_yoffset); + assert_equal(roffset, data[i].expected_roffset, "i:%d roffset %g != %g\n", + i, roffset, data[i].expected_roffset); + assert_equal(boffset, data[i].expected_boffset, "i:%d boffset %g != %g\n", + i, boffset, data[i].expected_boffset); + assert_equal(qz_right, data[i].expected_qz_right, "i:%d qz_right %g != %g\n", + i, qz_right, data[i].expected_qz_right); if (data[i].scaler) { int expected_xoffset_si = (int) (data[i].expected_xoffset * data[i].scaler); int expected_yoffset_si = (int) (data[i].expected_yoffset * data[i].scaler); int expected_roffset_si = (int) (data[i].expected_roffset * data[i].scaler); int expected_boffset_si = (int) (data[i].expected_boffset * data[i].scaler); int expected_qz_right_si = (int) (data[i].expected_qz_right * data[i].scaler); - assert_equal(xoffset_si, expected_xoffset_si, "i:%d xoffset_si %d != %d\n", i, xoffset_si, expected_xoffset_si); - assert_equal(yoffset_si, expected_yoffset_si, "i:%d yoffset_si %d != %d\n", i, yoffset_si, expected_yoffset_si); - assert_equal(roffset_si, expected_roffset_si, "i:%d roffset_si %d != %d\n", i, roffset_si, expected_roffset_si); - assert_equal(boffset_si, expected_boffset_si, "i:%d boffset_si %d != %d\n", i, boffset_si, expected_boffset_si); - assert_equal(qz_right_si, expected_qz_right_si, "i:%d qz_right_si %d != %d\n", i, qz_right_si, expected_qz_right_si); + assert_equal(xoffset_si, expected_xoffset_si, "i:%d xoffset_si %d != %d\n", + i, xoffset_si, expected_xoffset_si); + assert_equal(yoffset_si, expected_yoffset_si, "i:%d yoffset_si %d != %d\n", + i, yoffset_si, expected_yoffset_si); + assert_equal(roffset_si, expected_roffset_si, "i:%d roffset_si %d != %d\n", + i, roffset_si, expected_roffset_si); + assert_equal(boffset_si, expected_boffset_si, "i:%d boffset_si %d != %d\n", + i, boffset_si, expected_boffset_si); + assert_equal(qz_right_si, expected_qz_right_si, "i:%d qz_right_si %d != %d\n", + i, qz_right_si, expected_qz_right_si); } else { assert_zero(xoffset_si, "i:%d xoffset_si %d non-zero\n", i, xoffset_si); assert_zero(yoffset_si, "i:%d yoffset_si %d non-zero\n", i, yoffset_si); @@ -323,6 +385,53 @@ static void test_set_whitespace_offsets(const testCtx *const p_ctx) { #define TEST_OUT_SEP_STR "/" #endif +INTERNAL int zint_test_out_maybe_mkdir(const char *path); + +static void test_out_maybe_mkdir(const testCtx *const p_ctx) { + int ret; + const char dir[] = "test_maybe_dir"; + const char subdir[] = "test_maybe_dir/subdir"; +#ifndef _WIN32 + const int skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */ +#endif + + testStart(p_ctx->func_name); + + (void) testUtilRmDir(dir); /* In case lying around from previous fail */ + (void) testUtilRemove(dir); /* In case lying around from previous fail */ + + ret = zint_test_out_maybe_mkdir(dir); + assert_zero(ret, "out_maybe_mkdir(%s) ret %d != 0\n", dir, ret); + + ret = zint_test_out_maybe_mkdir(dir); + assert_zero(ret, "out_maybe_mkdir(%s) (exists) ret %d != 0\n", dir, ret); + + assert_zero(testUtilRmDir(dir), "testUtilRmDir(%s) != 0 (%d: %s)\n", dir, errno, strerror(errno)); + + assert_equal(testUtilCreateFile(dir), 1, "CreateFile(%s) != 1 (%d: %s)\n", dir, errno, strerror(errno)); + + ret = zint_test_out_maybe_mkdir(dir); + assert_equal(ret, -1, "out_maybe_mkdir(%s) file exists ret %d != -1\n", dir, ret); + + assert_zero(testUtilRemove(dir), "testUtilRemove(%s) != 0 (%d: %s)\n", dir, errno, strerror(errno)); + +#ifndef _WIN32 + if (!skip_readonly_test) { + ret = zint_test_out_maybe_mkdir(dir); + assert_zero(ret, "ret %d != 0\n", ret); + assert_zero(chmod(dir, S_IRUSR | S_IRGRP | S_IROTH), "chmod((%s) read-only != 0 (%d: %s)\n", + dir, errno, strerror(errno)); + + ret = zint_test_out_maybe_mkdir(subdir); + assert_equal(ret, -1, "out_maybe_mkdir(%s) ret %d != -1\n", subdir, ret); + + assert_zero(testUtilRemove(dir), "testUtilRemove(%s) != 0 (%d: %s)\n", dir, errno, strerror(errno)); + } +#endif + + testFinish(); +} + static void test_fopen(const testCtx *const p_ctx) { struct item { const char dir[32]; @@ -393,17 +502,40 @@ static void test_fopen(const testCtx *const p_ctx) { if (data[i].succeed) { assert_nonnull(ret, "i:%d zint_out_fopen(%s) == NULL (%d: %s)\n", i, outfile, errno, strerror(errno)); assert_zero(fclose(ret), "i:%d fclose(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno)); - assert_nonzero(testUtilExists(outfile), "i:%d testUtilExists(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno)); + assert_nonzero(testUtilExists(outfile), "i:%d testUtilExists(%s) != 0 (%d: %s)\n", + i, outfile, errno, strerror(errno)); if (data[i].dir[0]) { - assert_nonzero(testUtilDirExists(dirname), "i:%d testUtilDirExists(%s) != 0 (%d: %s)\n", i, dirname, errno, strerror(errno)); + assert_nonzero(testUtilDirExists(dirname), "i:%d testUtilDirExists(%s) != 0 (%d: %s)\n", + i, dirname, errno, strerror(errno)); } - assert_zero(testUtilRemove(outfile), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno)); + assert_zero(testUtilRemove(outfile), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, outfile, errno, strerror(errno)); if (data[i].dir[0]) { if (data[i].subdir[0] && !subdir_exists) { - assert_zero(testUtilRmDir(subdirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", i, subdirname, errno, strerror(errno)); + assert_zero(testUtilRmDir(subdirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", + i, subdirname, errno, strerror(errno)); } if (!dir_exists && strcmp(dirname, "/") != 0 && strcmp(dirname, "\\") != 0) { - assert_zero(testUtilRmDir(dirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", i, dirname, errno, strerror(errno)); +#ifndef _WIN32 + /* Skip if running as root on Unix as can't create read-only file */ + const int skip_readonly_test = getuid() == 0; +#endif + assert_zero(testUtilRmDir(dirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", + i, dirname, errno, strerror(errno)); + +#ifndef _WIN32 + if (!skip_readonly_test) { + int iret = testUtilMkDir(dirname); + assert_zero(iret, "i:%d testUtilMkDir iret %d != 0\n", i, iret); + assert_zero(chmod(dirname, S_IRUSR | S_IRGRP | S_IROTH), + "i:%d chmod((%s) read-only != 0 (%d: %s)\n", i, dirname, errno, strerror(errno)); + ret = zint_out_fopen(outfile, "w"); + assert_null(ret, "i:%d zint_out_fopen(%s) != NULL (%d: %s)\n", + i, outfile, errno, strerror(errno)); + assert_zero(testUtilRmDir(dirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", + i, dirname, errno, strerror(errno)); + } +#endif } } } else { @@ -421,8 +553,10 @@ int main(int argc, char *argv[]) { { "test_check_colour_options", test_check_colour_options }, { "test_colour_get_rgb", test_colour_get_rgb }, { "test_colour_get_cmyk", test_colour_get_cmyk }, + { "test_colour_char_to_rgb", test_colour_char_to_rgb }, { "test_quiet_zones", test_quiet_zones }, { "test_set_whitespace_offsets", test_set_whitespace_offsets }, + { "test_out_maybe_mkdir", test_out_maybe_mkdir }, { "test_fopen", test_fopen }, }; diff --git a/backend/tests/test_pcx.c b/backend/tests/test_pcx.c index 29c69dbe..7db3bb16 100644 --- a/backend/tests/test_pcx.c +++ b/backend/tests/test_pcx.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2025 Robin Stuart + Copyright (C) 2020-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -221,11 +221,71 @@ static void test_outfile(const testCtx *const p_ctx) { testFinish(); } +#include "filemem.h" + +static void test_fm(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_ACCESS, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_OPEN }, + /* 1*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_WRITE }, + /* 3*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 2, 40, 200, 0 }, 4, FM_FAIL_ID_PUTC }, + /* 5*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.pcx"); + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ { "test_print", test_print }, { "test_outfile", test_outfile }, + { "test_fm", test_fm }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_pdf417.c b/backend/tests/test_pdf417.c index 5c073b70..e716c623 100644 --- a/backend/tests/test_pdf417.c +++ b/backend/tests/test_pdf417.c @@ -319,7 +319,8 @@ static void test_reader_init(const testCtx *const p_ctx) { if (p_ctx->generate) { printf(" /*%3d*/ { %s, %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n", - i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options), + i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), + testUtilOutputOptionsName(data[i].output_options), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { @@ -471,6 +472,8 @@ static void test_input(const testCtx *const p_ctx) { /* 88*/ { BARCODE_PDF417, DATA_MODE, -1, -1, -1, { 0, 0, "" }, "12345678901234567890", 0, 0, 9, 103, "(18) 10 902 211 358 354 304 269 753 190 900 327 902 163 367 231 586 808 731", 1, "" }, /* 89*/ { BARCODE_PDF417, DATA_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 0, 12, 137, "(48) 40 902 491 81 137 450 302 67 15 174 492 862 667 475 869 12 434 685 326 422 57 117 339", 1, "" }, /* 90*/ { BARCODE_PDF417, DATA_MODE, -1, -1, -1, { 0, 0, "" }, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 0, 12, 137, "(48) 40 902 491 81 137 450 302 67 15 174 492 862 667 475 869 12 434 685 326 422 57 117 339", 1, "" }, + /* 91*/ { BARCODE_PDF417, DATA_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "12345678901;;;;;; ", 0, 0, 8, 120, "(24) 16 902 154 98 332 101 900 865 0 0 0 896 806 806 900 900 455 477 237 629 768 622 623", 0, "BWIPP: different encodation, see below" }, + /* 92*/ { BARCODE_PDF417, DATA_MODE, -1, -1, -1, { 0, 0, "" }, "12345678901;;;;;; ", 0, 0, 8, 120, "(24) 16 841 63 125 187 249 1 750 0 0 29 806 806 809 900 900 105 646 736 649 641 551 905 630", 1, "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -508,7 +511,8 @@ static void test_input(const testCtx *const p_ctx) { i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { - printf(" /*%3d*/ { %s, %s, %d, %d, %d, { %d, %d, \"%s\" }, \"%s\", %s, %d, %d, %d, \"%s\", %d, \"%s\" },\n", + printf(" /*%3d*/ { %s, %s, %d, %d, %d, { %d, %d, \"%s\" }, \"%s\", %s, %d, %d, %d, \"%s\", %d" + ", \"%s\" },\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, data[i].option_2, data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, @@ -4871,7 +4875,8 @@ static void test_encode_segs(const testCtx *const p_ctx) { data[i].segs[0].length, debug)) { if ((data[i].input_mode & 0x07) == DATA_MODE) { if (debug & ZINT_DEBUG_TEST_PRINT) { - printf("i:%d %s multiple segments in DATA_MODE not currently supported for ZXing-C++ testing\n", + printf("i:%d %s multiple segments in DATA_MODE not currently supported" + " for ZXing-C++ testing\n", i, testUtilBarcodeName(symbol->symbology)); } } else { @@ -4887,9 +4892,10 @@ static void test_encode_segs(const testCtx *const p_ctx) { ret = testUtilZXingCPPCmpSegs(symbol, cmp_msg, cmp_buf, cmp_len, data[i].segs, seg_count, NULL /*primary*/, escaped, &ret_len); - assert_zero(ret, "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", - i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, - escaped); + assert_zero(ret, + "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, + ret_len, escaped); } } } @@ -4984,7 +4990,7 @@ static void test_rt(const testCtx *const p_ctx) { i, symbol->content_segs[0].length, expected_length); assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length), "i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i, - testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length, + testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length, escaped, sizeof(escaped)), testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)), expected_length); @@ -5066,8 +5072,9 @@ static void test_rt_segs(const testCtx *const p_ctx) { assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); - assert_equal(symbol->content_seg_count, data[i].expected_content_seg_count, "i:%d symbol->content_seg_count %d != %d\n", - i, symbol->content_seg_count, data[i].expected_content_seg_count); + assert_equal(symbol->content_seg_count, data[i].expected_content_seg_count, + "i:%d symbol->content_seg_count %d != %d\n", + i, symbol->content_seg_count, data[i].expected_content_seg_count); if (symbol->output_options & BARCODE_CONTENT_SEGS) { assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i); for (j = 0; j < symbol->content_seg_count; j++) { @@ -5078,7 +5085,8 @@ static void test_rt_segs(const testCtx *const p_ctx) { assert_equal(symbol->content_segs[j].length, expected_length, "i:%d content_segs[%d].length %d != expected_length %d\n", i, j, symbol->content_segs[j].length, expected_length); - assert_zero(memcmp(symbol->content_segs[j].source, data[i].expected_content_segs[j].source, expected_length), + assert_zero(memcmp(symbol->content_segs[j].source, data[i].expected_content_segs[j].source, + expected_length), "i:%d content_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, j, testUtilEscape((const char *) symbol->content_segs[j].source, expected_length, escaped, sizeof(escaped)), diff --git a/backend/tests/test_png.c b/backend/tests/test_png.c index 3801cd96..18f4ea78 100644 --- a/backend/tests/test_png.c +++ b/backend/tests/test_png.c @@ -137,6 +137,7 @@ static void test_print(const testCtx *const p_ctx) { int option_2; float height; float scale; + float dpmm; struct zint_structapp structapp; const char *fgcolour; const char *bgcolour; @@ -148,135 +149,136 @@ static void test_print(const testCtx *const p_ctx) { const char *comment; }; static const struct item data[] = { - /* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1.png", "" }, - /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", "", 0, "code128_latin1_2.png", "" }, - /* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1_bold.png", "" }, - /* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", "", 0, "code128_latin1_2_bold.png", "" }, - /* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1_small.png", "" }, - /* 5*/ { BARCODE_CODE128, UNICODE_MODE, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", "", 0, "code128_latin1_2_small.png", "" }, - /* 6*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "Égjpqy", "", 0, "code128_egrave.png", "" }, - /* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "Égjpqy", "", 0, "code128_egrave_bold.png", "" }, - /* 8*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "Égjpqy", "", 0, "code128_egrave_bold_box3.png", "" }, - /* 9*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "Égjpqy", "", 0, "code128_egrave_bold_hvwsp2_box2.png", "" }, - /* 10*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, 0, 0, { 0, 0, "" }, "", "", 1, "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", 0, "gs1_128_cc_fig12.png", "" }, - /* 11*/ { BARCODE_CODABLOCKF, -1, 3, -1, -1, -1, -1, 3, -1, 0, 0, { 0, 0, "" }, "", "", 1, "AAAAAAAAA", "", 0, "codablockf_3rows.png", "" }, - /* 12*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "AAAAAAAAA", "", 0, "codablockf_hvwsp2.png", "" }, - /* 13*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "AAAAAAAAA", "", 0, "codablockf_hvwsp2_box2.png", "" }, - /* 14*/ { BARCODE_EAN13, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9771384524017", "", 0, "ean13_ggs_5.2.2.1-1.png", "" }, - /* 15*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9771384524017", "", 0, "ean13_ggs_5.2.2.1-1.png", "" }, - /* 16*/ { BARCODE_EAN13, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9771384524017", "", 0, "ean13_ggs_5.2.2.1-1_gws.png", "" }, - /* 17*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9771384524017", "", 0, "ean13_ggs_5.2.2.1-1_gws.png", "" }, - /* 18*/ { BARCODE_EAN13, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2.png", "" }, - /* 19*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2.png", "" }, - /* 20*/ { BARCODE_EAN13, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2_gws.png", "" }, - /* 21*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2_gws.png", "" }, - /* 22*/ { BARCODE_EAN13, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2.png", "" }, - /* 23*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2.png", "" }, - /* 24*/ { BARCODE_EAN13, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2_gws.png", "" }, - /* 25*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2_gws.png", "" }, - /* 26*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012", "[91]12345678901234567890123456789", 0, "ean13_cc_cca_5x4.png", "" }, - /* 27*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012", "[91]12345678901234567890123456789", 0, "ean13_cc_cca_5x4.png", "" }, - /* 28*/ { BARCODE_EAN13_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012", "[91]12345678901234567890123456789", 0, "ean13_cc_cca_5x4_gws.png", "" }, - /* 29*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012", "[91]12345678901234567890123456789", 0, "ean13_cc_cca_5x4_gws.png", "" }, - /* 30*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4.png", "" }, - /* 31*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4.png", "" }, - /* 32*/ { BARCODE_EAN13_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4_gws.png", "" }, - /* 33*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4_gws.png", "" }, - /* 34*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4.png", "" }, - /* 35*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4.png", "" }, - /* 36*/ { BARCODE_EAN13_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_gws.png", "" }, - /* 37*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_gws.png", "" }, - /* 38*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_notext.png", "" }, - /* 39*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_notext.png", "" }, - /* 40*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "012345678905+24", "", 0, "upca_2addon_ggs_5.2.6.6-5.png", "" }, - /* 41*/ { BARCODE_UPCA, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "012345678905+24", "", 0, "upca_2addon_ggs_5.2.6.6-5_gws.png", "" }, - /* 42*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "614141234417+12345", "", 0, "upca_5addon.png", "" }, - /* 43*/ { BARCODE_UPCA, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "614141234417+12345", "", 0, "upca_5addon_gws.png", "" }, - /* 44*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, 0, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "614141234417+12345", "", 0, "upca_5addon_notext.png", "" }, - /* 45*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "614141234417+12345", "", 0, "upca_5addon_bind3.png", "" }, - /* 46*/ { BARCODE_UPCA, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, -1, -1, 1, 0, { 0, 0, "" }, "", "", 1, "012345678905+24", "", 0, "upca_2addon_h1.png", "" }, - /* 47*/ { BARCODE_UPCA, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, 0, -1, -1, 1, 0, { 0, 0, "" }, "", "", 1, "012345678905+24", "", 0, "upca_2addon_h1_notext.png", "" }, - /* 48*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345678901+12", "[91]123456789", 0, "upca_cc_2addon_cca_3x4.png", "" }, - /* 49*/ { BARCODE_UPCA_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345678901+12", "[91]123456789", 0, "upca_cc_2addon_cca_3x4_gws.png", "" }, - /* 50*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4.png", "" }, - /* 51*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4_notext.png", "" }, - /* 52*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4_bind3.png", "" }, - /* 53*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12", "", 0, "upce_2addon.png", "" }, - /* 54*/ { BARCODE_UPCE, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12", "", 0, "upce_2addon_gws.png", "" }, - /* 55*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12345", "", 0, "upce_5addon.png", "" }, - /* 56*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12345", "", 0, "upce_5addon_small.png", "" }, - /* 57*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12345", "", 0, "upce_5addon_small_gws.png", "" }, - /* 58*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2.png", "" }, - /* 59*/ { BARCODE_UPCE_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2_gws.png", "" }, - /* 60*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 3, 0, { 0, 0, "" }, "", "", 1, "0654321+89", "[91]1", 0, "upce_cc_2addon_h3.png", "" }, - /* 61*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 1, -1, 3, 0, { 0, 0, "" }, "", "", 1, "0654321+89", "[91]1", 0, "upce_cc_2addon_h3_notext.png", "" }, - /* 62*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2.png", "" }, - /* 63*/ { BARCODE_UPCE_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2_gws.png", "" }, - /* 64*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2_notext.png", "" }, - /* 65*/ { BARCODE_EAN8, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567", "", 0, "ean8_gss_5.2.2.2-1.png", "" }, - /* 66*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567", "", 0, "ean8_gss_5.2.2.2-1.png", "" }, - /* 67*/ { BARCODE_EAN8, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567", "", 0, "ean8_gss_5.2.2.2-1_gws.png", "" }, - /* 68*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567", "", 0, "ean8_gss_5.2.2.2-1_gws.png", "" }, - /* 69*/ { BARCODE_EAN8, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon.png", "" }, - /* 70*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon.png", "" }, - /* 71*/ { BARCODE_EAN8, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_gws.png", "" }, - /* 72*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_gws.png", "" }, - /* 73*/ { BARCODE_EAN8, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, -1, -1, 1, 0, { 0, 0, "" }, "", "", 1, " 16", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_h1.png", "" }, - /* 74*/ { BARCODE_EANX, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, -1, -1, 1, 0, { 0, 0, "" }, "", "", 1, " 16", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_h1.png", "" }, - /* 75*/ { BARCODE_EAN8, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, 0, -1, -1, 1, 0, { 0, 0, "" }, "", "", 1, " 16", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_h1_notext.png", "" }, - /* 76*/ { BARCODE_EANX, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, 0, -1, -1, 1, 0, { 0, 0, "" }, "", "", 1, " 16", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_h1_notext.png", "" }, - /* 77*/ { BARCODE_EAN8, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12345", "", ZINT_WARN_NONCOMPLIANT, "ean8_5addon.png", "" }, - /* 78*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12345", "", ZINT_WARN_NONCOMPLIANT, "ean8_5addon.png", "" }, - /* 79*/ { BARCODE_EAN8, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12345", "", ZINT_WARN_NONCOMPLIANT, "ean8_5addon_gws.png", "" }, - /* 80*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "1234567+12345", "", ZINT_WARN_NONCOMPLIANT, "ean8_5addon_gws.png", "" }, - /* 81*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9876543+65", "[91]1234567", ZINT_WARN_NONCOMPLIANT, "ean8_cc_2addon_cca_4x3.png", "" }, - /* 82*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9876543+65", "[91]1234567", ZINT_WARN_NONCOMPLIANT, "ean8_cc_2addon_cca_4x3.png", "" }, - /* 83*/ { BARCODE_EAN8_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9876543+65", "[91]1234567", ZINT_WARN_NONCOMPLIANT, "ean8_cc_2addon_cca_4x3_gws.png", "" }, - /* 84*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9876543+65", "[91]1234567", ZINT_WARN_NONCOMPLIANT, "ean8_cc_2addon_cca_4x3_gws.png", "" }, - /* 85*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9876543+74083", "[91]123456789012345678", ZINT_WARN_NONCOMPLIANT, "ean8_cc_5addon_ccb_8x3.png", "" }, - /* 86*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9876543+74083", "[91]123456789012345678", ZINT_WARN_NONCOMPLIANT, "ean8_cc_5addon_ccb_8x3.png", "" }, - /* 87*/ { BARCODE_EAN8_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9876543+74083", "[91]123456789012345678", ZINT_WARN_NONCOMPLIANT, "ean8_cc_5addon_ccb_8x3_gws.png", "" }, - /* 88*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0, 0, { 0, 0, "" }, "", "", 1, "9876543+74083", "[91]123456789012345678", ZINT_WARN_NONCOMPLIANT, "ean8_cc_5addon_ccb_8x3_gws.png", "" }, - /* 89*/ { BARCODE_EAN_5ADDON, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5.png", "" }, - /* 90*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5.png", "" }, - /* 91*/ { BARCODE_EAN_5ADDON, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5_gws.png", "" }, - /* 92*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5_gws.png", "" }, - /* 93*/ { BARCODE_EAN_5ADDON, -1, 2, BARCODE_BIND, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5_bind2.png", "" }, - /* 94*/ { BARCODE_EANX, -1, 2, BARCODE_BIND, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5_bind2.png", "" }, - /* 95*/ { BARCODE_EAN_2ADDON, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2.png", "" }, - /* 96*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2.png", "" }, - /* 97*/ { BARCODE_EAN_2ADDON, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2_gws.png", "" }, - /* 98*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2_gws.png", "" }, - /* 99*/ { BARCODE_EAN_2ADDON, -1, 1, BARCODE_BOX, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2_box1.png", "" }, - /*100*/ { BARCODE_EANX, -1, 1, BARCODE_BOX, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2_box1.png", "" }, - /*101*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "123", "", 0, "code39_small.png", "" }, - /*102*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3.5, { 0, 0, "" }, "", "", 1, "12345", "", 0, "postnet_zip.png", "300 dpi, using 1/43in X, 300 / 43 / 2 = ~3.5 scale" }, - /*103*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "CFCECDCC", 1, "12345", "", 0, "pdf417_bgalpha.png", "" }, - /*104*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "30313233", "", 1, "12345", "", 0, "pdf417_fgalpha.png", "" }, - /*105*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "20212244", "CFCECDCC", 1, "12345", "", 0, "pdf417_bgfgalpha.png", "" }, - /*106*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "0000007F", "FF000033", 1, "12345", "", 0, "ultra_bgfgalpha.png", "" }, - /*107*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "FF000033", 1, "12345", "", 0, "ultra_bgalpha.png", "" }, - /*108*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "0000007F", "FF0000", 1, "12345", "", 0, "ultra_fgalpha.png", "" }, - /*109*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "0000007F", "", 1, "12345", "", 0, "ultra_fgalpha_nobg.png", "" }, - /*110*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ultra_hvwsp1_box1.png", "" }, - /*111*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, { 0, 0, "" }, "00FF007F", "BABDB6", 1, "12345", "", 0, "ultra_fgalpha_hvwsp1_box1.png", "" }, - /*112*/ { BARCODE_ULTRA, -1, 1, BARCODE_BIND_TOP, 1, 1, -1, -1, -1, 0, 0, { 0, 0, "" }, "00FF007F", "BABDB6", 1, "12345", "", 0, "ultra_fgalpha_hvwsp1_bindtop1.png", "" }, - /*113*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5, { 0, 0, "" }, "", "", 1, "1", "", 0, "ultra_odd.png", "" }, - /*114*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_0.5.png", "6 dpmm, 150 dpi" }, - /*115*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0, 0.7, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" }, - /*116*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1.4, { 0, 0, "" }, "1111117F", "EEEEEEEE", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" }, - /*117*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2.1, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_2.1.png", "24 dpmm, 600 dpi" }, - /*118*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_hvwsp1_box2.png", "" }, - /*119*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_vwsp1_bind1.png", "" }, - /*120*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0, 2.0, { 0, 0, "" }, "", "", 1, "1234", "", 0, "datamatrix_2.0_bind1_dotty.png", "" }, - /*121*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, 2.0, { 0, 0, "" }, "", "", 1, "1234", "", 0, "datamatrix_2.0_hvwsp1_bind1_dotty.png", "" }, - /*122*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "12345678909", "", 0, "dbar_ltd.png", "" }, - /*123*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 5.0, 0, { 0, 0, "" }, "", "", 1, "Your Data Here!", "", ZINT_WARN_NONCOMPLIANT, "pdf417_height5.png", "" }, - /*124*/ { BARCODE_USPS_IMAIL, -1, -1, -1, -1, -1, -1, -1, -1, 7.75, 0, { 0, 0, "" }, "", "", 1, "12345678901234567890", "", 0, "imail_height7.75.png", "" }, - /*125*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 4, 7, "Z1.txt" }, "", "", 1, "3456", "", 0, "aztec_z1_seq4of7.png", "" }, - /*126*/ { BARCODE_PDF417, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, 5, 8, 16, 1.5, { 0, 0, "" }, "", "", 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "", ZINT_WARN_NONCOMPLIANT, "pdf417_#204.png", "Ticket #204 Blank line in PDF417" }, - /*127*/ { BARCODE_DPD, -1, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "008182709980000020028101276", "", 0, "dpd_compliant.png", "Now with bind top 3X default" }, - /*128*/ { BARCODE_CHANNEL, -1, -1, CMYK_COLOUR | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "100,85,0,20", "FFFFFF00", 1, "123", "", 0, "channel_cmyk_nobg.png", "" }, + /* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 10.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1.png", "" }, + /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 10.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", "", 0, "code128_latin1_2.png", "" }, + /* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 10.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1_bold.png", "" }, + /* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 10.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", "", 0, "code128_latin1_2_bold.png", "" }, + /* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 10.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1_small.png", "" }, + /* 5*/ { BARCODE_CODE128, UNICODE_MODE, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 10.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", "", 0, "code128_latin1_2_small.png", "" }, + /* 6*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "Égjpqy", "", 0, "code128_egrave.png", "" }, + /* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "Égjpqy", "", 0, "code128_egrave_bold.png", "" }, + /* 8*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "Égjpqy", "", 0, "code128_egrave_bold_box3.png", "" }, + /* 9*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "Égjpqy", "", 0, "code128_egrave_bold_hvwsp2_box2.png", "" }, + /* 10*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", 0, "gs1_128_cc_fig12.png", "" }, + /* 11*/ { BARCODE_CODABLOCKF, -1, 3, -1, -1, -1, -1, 3, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "AAAAAAAAA", "", 0, "codablockf_3rows.png", "" }, + /* 12*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "AAAAAAAAA", "", 0, "codablockf_hvwsp2.png", "" }, + /* 13*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "AAAAAAAAA", "", 0, "codablockf_hvwsp2_box2.png", "" }, + /* 14*/ { BARCODE_EAN13, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9771384524017", "", 0, "ean13_ggs_5.2.2.1-1.png", "" }, + /* 15*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9771384524017", "", 0, "ean13_ggs_5.2.2.1-1.png", "" }, + /* 16*/ { BARCODE_EAN13, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9771384524017", "", 0, "ean13_ggs_5.2.2.1-1_gws.png", "" }, + /* 17*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9771384524017", "", 0, "ean13_ggs_5.2.2.1-1_gws.png", "" }, + /* 18*/ { BARCODE_EAN13, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2.png", "" }, + /* 19*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2.png", "" }, + /* 20*/ { BARCODE_EAN13, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2_gws.png", "" }, + /* 21*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2_gws.png", "" }, + /* 22*/ { BARCODE_EAN13, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2.png", "" }, + /* 23*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2.png", "" }, + /* 24*/ { BARCODE_EAN13, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2_gws.png", "" }, + /* 25*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2_gws.png", "" }, + /* 26*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012", "[91]12345678901234567890123456789", 0, "ean13_cc_cca_5x4.png", "" }, + /* 27*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012", "[91]12345678901234567890123456789", 0, "ean13_cc_cca_5x4.png", "" }, + /* 28*/ { BARCODE_EAN13_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012", "[91]12345678901234567890123456789", 0, "ean13_cc_cca_5x4_gws.png", "" }, + /* 29*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012", "[91]12345678901234567890123456789", 0, "ean13_cc_cca_5x4_gws.png", "" }, + /* 30*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4.png", "" }, + /* 31*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4.png", "" }, + /* 32*/ { BARCODE_EAN13_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4_gws.png", "" }, + /* 33*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4_gws.png", "" }, + /* 34*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4.png", "" }, + /* 35*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4.png", "" }, + /* 36*/ { BARCODE_EAN13_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_gws.png", "" }, + /* 37*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_gws.png", "" }, + /* 38*/ { BARCODE_EAN13_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_notext.png", "" }, + /* 39*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_notext.png", "" }, + /* 40*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "012345678905+24", "", 0, "upca_2addon_ggs_5.2.6.6-5.png", "" }, + /* 41*/ { BARCODE_UPCA, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "012345678905+24", "", 0, "upca_2addon_ggs_5.2.6.6-5_gws.png", "" }, + /* 42*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "614141234417+12345", "", 0, "upca_5addon.png", "" }, + /* 43*/ { BARCODE_UPCA, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "614141234417+12345", "", 0, "upca_5addon_gws.png", "" }, + /* 44*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, 0, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "614141234417+12345", "", 0, "upca_5addon_notext.png", "" }, + /* 45*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "614141234417+12345", "", 0, "upca_5addon_bind3.png", "" }, + /* 46*/ { BARCODE_UPCA, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, -1, -1, 1.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "012345678905+24", "", 0, "upca_2addon_h1.png", "" }, + /* 47*/ { BARCODE_UPCA, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, 0, -1, -1, 1.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "012345678905+24", "", 0, "upca_2addon_h1_notext.png", "" }, + /* 48*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345678901+12", "[91]123456789", 0, "upca_cc_2addon_cca_3x4.png", "" }, + /* 49*/ { BARCODE_UPCA_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345678901+12", "[91]123456789", 0, "upca_cc_2addon_cca_3x4_gws.png", "" }, + /* 50*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4.png", "" }, + /* 51*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4_notext.png", "" }, + /* 52*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4_bind3.png", "" }, + /* 53*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12", "", 0, "upce_2addon.png", "" }, + /* 54*/ { BARCODE_UPCE, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12", "", 0, "upce_2addon_gws.png", "" }, + /* 55*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12345", "", 0, "upce_5addon.png", "" }, + /* 56*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12345", "", 0, "upce_5addon_small.png", "" }, + /* 57*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12345", "", 0, "upce_5addon_small_gws.png", "" }, + /* 58*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2.png", "" }, + /* 59*/ { BARCODE_UPCE_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2_gws.png", "" }, + /* 60*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 3.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "0654321+89", "[91]1", 0, "upce_cc_2addon_h3.png", "" }, + /* 61*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 1, -1, 3.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "0654321+89", "[91]1", 0, "upce_cc_2addon_h3_notext.png", "" }, + /* 62*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2.png", "" }, + /* 63*/ { BARCODE_UPCE_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2_gws.png", "" }, + /* 64*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2_notext.png", "" }, + /* 65*/ { BARCODE_EAN8, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567", "", 0, "ean8_gss_5.2.2.2-1.png", "" }, + /* 66*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567", "", 0, "ean8_gss_5.2.2.2-1.png", "" }, + /* 67*/ { BARCODE_EAN8, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567", "", 0, "ean8_gss_5.2.2.2-1_gws.png", "" }, + /* 68*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567", "", 0, "ean8_gss_5.2.2.2-1_gws.png", "" }, + /* 69*/ { BARCODE_EAN8, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon.png", "" }, + /* 70*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon.png", "" }, + /* 71*/ { BARCODE_EAN8, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_gws.png", "" }, + /* 72*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_gws.png", "" }, + /* 73*/ { BARCODE_EAN8, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, -1, -1, 1.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, " 16", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_h1.png", "" }, + /* 74*/ { BARCODE_EANX, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, -1, -1, 1.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, " 16", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_h1.png", "" }, + /* 75*/ { BARCODE_EAN8, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, 0, -1, -1, 1.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, " 16", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_h1_notext.png", "" }, + /* 76*/ { BARCODE_EANX, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, 0, -1, -1, 1.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, " 16", "", ZINT_WARN_NONCOMPLIANT, "ean8_2addon_h1_notext.png", "" }, + /* 77*/ { BARCODE_EAN8, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12345", "", ZINT_WARN_NONCOMPLIANT, "ean8_5addon.png", "" }, + /* 78*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12345", "", ZINT_WARN_NONCOMPLIANT, "ean8_5addon.png", "" }, + /* 79*/ { BARCODE_EAN8, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12345", "", ZINT_WARN_NONCOMPLIANT, "ean8_5addon_gws.png", "" }, + /* 80*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234567+12345", "", ZINT_WARN_NONCOMPLIANT, "ean8_5addon_gws.png", "" }, + /* 81*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9876543+65", "[91]1234567", ZINT_WARN_NONCOMPLIANT, "ean8_cc_2addon_cca_4x3.png", "" }, + /* 82*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9876543+65", "[91]1234567", ZINT_WARN_NONCOMPLIANT, "ean8_cc_2addon_cca_4x3.png", "" }, + /* 83*/ { BARCODE_EAN8_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9876543+65", "[91]1234567", ZINT_WARN_NONCOMPLIANT, "ean8_cc_2addon_cca_4x3_gws.png", "" }, + /* 84*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9876543+65", "[91]1234567", ZINT_WARN_NONCOMPLIANT, "ean8_cc_2addon_cca_4x3_gws.png", "" }, + /* 85*/ { BARCODE_EAN8_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9876543+74083", "[91]123456789012345678", ZINT_WARN_NONCOMPLIANT, "ean8_cc_5addon_ccb_8x3.png", "" }, + /* 86*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9876543+74083", "[91]123456789012345678", ZINT_WARN_NONCOMPLIANT, "ean8_cc_5addon_ccb_8x3.png", "" }, + /* 87*/ { BARCODE_EAN8_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9876543+74083", "[91]123456789012345678", ZINT_WARN_NONCOMPLIANT, "ean8_cc_5addon_ccb_8x3_gws.png", "" }, + /* 88*/ { BARCODE_EANX_CC, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, 2, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "9876543+74083", "[91]123456789012345678", ZINT_WARN_NONCOMPLIANT, "ean8_cc_5addon_ccb_8x3_gws.png", "" }, + /* 89*/ { BARCODE_EAN_5ADDON, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5.png", "" }, + /* 90*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5.png", "" }, + /* 91*/ { BARCODE_EAN_5ADDON, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5_gws.png", "" }, + /* 92*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5_gws.png", "" }, + /* 93*/ { BARCODE_EAN_5ADDON, -1, 2, BARCODE_BIND, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5_bind2.png", "" }, + /* 94*/ { BARCODE_EANX, -1, 2, BARCODE_BIND, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ean5_bind2.png", "" }, + /* 95*/ { BARCODE_EAN_2ADDON, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2.png", "" }, + /* 96*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2.png", "" }, + /* 97*/ { BARCODE_EAN_2ADDON, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2_gws.png", "" }, + /* 98*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2_gws.png", "" }, + /* 99*/ { BARCODE_EAN_2ADDON, -1, 1, BARCODE_BOX, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2_box1.png", "" }, + /*100*/ { BARCODE_EANX, -1, 1, BARCODE_BOX, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12", "", 0, "ean2_box1.png", "" }, + /*101*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "123", "", 0, "code39_small.png", "" }, + /*102*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 3.5f, 0.0f, { 0, 0, "" }, "", "", 1, "12345", "", 0, "postnet_zip.png", "300 dpi, using 1/43in X, 300 / 43 / 2 = ~3.5 scale" }, + /*103*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "CFCECDCC", 1, "12345", "", 0, "pdf417_bgalpha.png", "" }, + /*104*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "30313233", "", 1, "12345", "", 0, "pdf417_fgalpha.png", "" }, + /*105*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "20212244", "CFCECDCC", 1, "12345", "", 0, "pdf417_bgfgalpha.png", "" }, + /*106*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "0000007F", "FF000033", 1, "12345", "", 0, "ultra_bgfgalpha.png", "" }, + /*107*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "FF000033", 1, "12345", "", 0, "ultra_bgalpha.png", "" }, + /*108*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "0000007F", "FF0000", 1, "12345", "", 0, "ultra_fgalpha.png", "" }, + /*109*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "0000007F", "", 1, "12345", "", 0, "ultra_fgalpha_nobg.png", "" }, + /*110*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345", "", 0, "ultra_hvwsp1_box1.png", "" }, + /*111*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "00FF007F", "BABDB6", 1, "12345", "", 0, "ultra_fgalpha_hvwsp1_box1.png", "" }, + /*112*/ { BARCODE_ULTRA, -1, 1, BARCODE_BIND_TOP, 1, 1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "00FF007F", "BABDB6", 1, "12345", "", 0, "ultra_fgalpha_hvwsp1_bindtop1.png", "" }, + /*113*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.5f, 0.0f, { 0, 0, "" }, "", "", 1, "1", "", 0, "ultra_odd.png", "" }, + /*114*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.5f, 0.0f, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_0.5.png", "6 dpmm, 150 dpi" }, + /*115*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0.0f, 0.7f, 0.0f, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" }, + /*116*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 1.4f, 0.0f, { 0, 0, "" }, "1111117F", "EEEEEEEE", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" }, + /*117*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 2.1f, 0.0f, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_2.1.png", "24 dpmm, 600 dpi" }, + /*118*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_hvwsp1_box2.png", "" }, + /*119*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_vwsp1_bind1.png", "" }, + /*120*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0.0f, 2.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234", "", 0, "datamatrix_2.0_bind1_dotty.png", "" }, + /*121*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0.0f, 2.0f, 0.0f, { 0, 0, "" }, "", "", 1, "1234", "", 0, "datamatrix_2.0_hvwsp1_bind1_dotty.png", "" }, + /*122*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345678909", "", 0, "dbar_ltd.png", "" }, + /*123*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 5.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "Your Data Here!", "", ZINT_WARN_NONCOMPLIANT, "pdf417_height5.png", "" }, + /*124*/ { BARCODE_USPS_IMAIL, -1, -1, -1, -1, -1, -1, -1, -1, 7.75f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "12345678901234567890", "", 0, "imail_height7.75.png", "" }, + /*125*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 4, 7, "Z1.txt" }, "", "", 1, "3456", "", 0, "aztec_z1_seq4of7.png", "" }, + /*126*/ { BARCODE_PDF417, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, 5, 8, 16.0f, 1.5f, 0.0f, { 0, 0, "" }, "", "", 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "", ZINT_WARN_NONCOMPLIANT, "pdf417_#204.png", "Ticket #204 Blank line in PDF417" }, + /*127*/ { BARCODE_DPD, -1, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "", "", 1, "008182709980000020028101276", "", 0, "dpd_compliant.png", "Now with bind top 3X default" }, + /*128*/ { BARCODE_CHANNEL, -1, -1, CMYK_COLOUR | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0.0f, 0.0f, 0.0f, { 0, 0, "" }, "100,85,0,20", "FFFFFF00", 1, "123", "", 0, "channel_cmyk_nobg.png", "" }, + /*129*/ { BARCODE_TELEPEN, UNICODE_MODE, -1, COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0.0f, 0.0f, 300.0f / 25.4f, { 0, 0, "" }, "", "", 1, "ABC", "", 0, "telepen_compliant_dpmm_300dpi.png", "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -325,6 +327,11 @@ static void test_print(const testCtx *const p_ctx) { if (data[i].scale) { symbol->scale = data[i].scale; } + if (data[i].dpmm) { + symbol->dpmm = data[i].dpmm; + symbol->scale = ZBarcode_Scale_From_XdimDp(symbol->symbology, ZBarcode_Default_Xdim(symbol->symbology), + symbol->dpmm, "PNG"); + } if (data[i].border_width != -1) { symbol->border_width = data[i].border_width; } @@ -366,11 +373,12 @@ static void test_print(const testCtx *const p_ctx) { "i:%d testUtilDataPath == 0\n", i); if (p_ctx->generate) { - printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.5g, %.5g, { %d, %d, \"%s\" }, \"%s\", \"%s\", %.5g, \"%s\", \"%s\", %s, \"%s\", \"%s\" },\n", + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.5g, %.5g, %.5g," + " { %d, %d, \"%s\" }, \"%s\", \"%s\", %.5g, \"%s\", \"%s\", %s, \"%s\", \"%s\" },\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, - data[i].option_1, data[i].option_2, data[i].height, data[i].scale, + data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].dpmm, data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, data[i].fgcolour, data[i].bgcolour, data[i].text_gap, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, @@ -471,18 +479,19 @@ static void test_outfile(const testCtx *const p_ctx) { #include #include -struct wpng_error_type { +/* As defined in "png.c" */ +struct zpng_error_type { struct zint_symbol *symbol; jmp_buf jmpbuf; }; -INTERNAL void zint_test_wpng_error_handler(png_structp png_ptr, png_const_charp msg); +INTERNAL void zint_test_zpng_error_handler(png_structp png_ptr, png_const_charp msg); -static void test_wpng_error_handler(const testCtx *const p_ctx) { +static void test_zpng_error_handler(const testCtx *const p_ctx) { int ret; char filename[] = "out.png"; FILE *fp; - struct wpng_error_type wpng_error; + struct zpng_error_type zpng_error; struct zint_symbol symbol = {0}; png_structp png_ptr; png_infop info_ptr; @@ -491,7 +500,7 @@ static void test_wpng_error_handler(const testCtx *const p_ctx) { testStart(p_ctx->func_name); - wpng_error.symbol = &symbol; + zpng_error.symbol = &symbol; /* Create empty file */ (void) testUtilRemove(filename); /* In case junk hanging around */ @@ -504,13 +513,13 @@ static void test_wpng_error_handler(const testCtx *const p_ctx) { fp = testUtilOpen(filename, "r"); assert_nonnull(fp, "testUtilOpen(%s) for read failed\n", filename); - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &wpng_error, zint_test_wpng_error_handler, NULL); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &zpng_error, zint_test_zpng_error_handler, NULL); assert_nonnull(png_ptr, "png_create_write_struct failed\n"); info_ptr = png_create_info_struct(png_ptr); assert_nonnull(info_ptr, "png_create_info_struct failed\n"); - if (setjmp(wpng_error.jmpbuf)) { + if (setjmp(zpng_error.jmpbuf)) { png_destroy_write_struct(&png_ptr, &info_ptr); ret = fclose(fp); assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret); @@ -527,6 +536,29 @@ static void test_wpng_error_handler(const testCtx *const p_ctx) { testFinish(); } +static void test_zpng_flush(const testCtx *const p_ctx) { + int ret; + struct zint_symbol *symbol = NULL; + + (void)p_ctx; + + testStart(p_ctx->func_name); + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + symbol->symbology = BARCODE_ULTRA; + symbol->output_options |= BARCODE_MEMORY_FILE; + symbol->debug |= ZINT_DEBUG_TEST_PNG_FLUSH; + + ret = ZBarcode_Encode_and_Print(symbol, ZCUCP("1234"), -1, 0); + assert_zero(ret, "ZBarcode_Encode_and_Print ret %d != 0 (%s)\n", ret, symbol->errtxt); + + ZBarcode_Delete(symbol); + + testFinish(); +} + /* Check compliant height printable for max CODABLOCKF with 44 rows * ((62 cols) * 0.55 + 3)) = 1632.4 */ static void test_large_compliant_height(const testCtx *const p_ctx) { int ret; @@ -557,14 +589,78 @@ static void test_large_compliant_height(const testCtx *const p_ctx) { testFinish(); } +#include "filemem.h" + +static void test_fm(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + int debug; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_ULTRA, -1, 0, "123", ZINT_ERROR_FILE_ACCESS, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_OPEN }, + /* 1*/ { BARCODE_ULTRA, -1, 0, "123", ZINT_ERROR_FILE_WRITE, { 5, 11, 0, 0, 0 }, 2, FM_FAIL_ID_WRITE }, + /* 2*/ { BARCODE_ULTRA, -1, ZINT_DEBUG_TEST_PNG_FLUSH, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_FLUSH }, + /* 2*/ { BARCODE_ULTRA, BARCODE_MEMORY_FILE, ZINT_DEBUG_TEST_PNG_FLUSH, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_FLUSH }, + /* 3*/ { BARCODE_ULTRA, -1, 0, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.png"); + symbol->debug |= data[i].debug; + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ { "test_pixel_plot", test_pixel_plot }, { "test_print", test_print }, { "test_outfile", test_outfile }, - { "test_wpng_error_handler", test_wpng_error_handler }, + { "test_zpng_error_handler", test_zpng_error_handler }, + { "test_zpng_flush", test_zpng_flush }, { "test_large_compliant_height", test_large_compliant_height }, + { "test_fm", test_fm }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_ps.c b/backend/tests/test_ps.c index 9010f71e..84193379 100644 --- a/backend/tests/test_ps.c +++ b/backend/tests/test_ps.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2025 Robin Stuart + Copyright (C) 2020-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -321,12 +321,73 @@ static void test_outfile(const testCtx *const p_ctx) { testFinish(); } +#include "filemem.h" + +static void test_fm(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_ACCESS, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_OPEN }, + /* 1*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 5, 11, 0, 0, 0 }, 2, FM_FAIL_ID_PUTS }, + /* 2*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 2, 0, 0, 0 }, 2, FM_FAIL_ID_PUTSF }, + /* 3*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 2, 0, 0, 0 }, 2, FM_FAIL_ID_PRINTF }, + /* 4*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.eps"); + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ { "test_print", test_print }, { "test_ps_convert", test_ps_convert }, { "test_outfile", test_outfile }, + { "test_fm", test_fm }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_qr.c b/backend/tests/test_qr.c index 78be2097..de1dbdc1 100644 --- a/backend/tests/test_qr.c +++ b/backend/tests/test_qr.c @@ -6780,6 +6780,9 @@ static void test_upnqr_input(const testCtx *const p_ctx) { /* 7*/ { DATA_MODE, 0, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", 0, "(415) 70 44 01 9B 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 32 33 34", 3 << 8, 4, "Length 411" }, /* 8*/ { DATA_MODE, 0, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012", ZINT_ERROR_TOO_LONG, "Error 573: Input too long, requires 416 codewords (maximum 415)", 0, 4, "Length 412" }, /* 9*/ { UNICODE_MODE, ZINT_FULL_MULTIBYTE, "ĄŔ", 0, "(415) 70 44 00 02 A1 C0 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC", ZINT_FULL_MULTIBYTE | (3 << 8), 1, "option_3 mask" }, + /* 10*/ { UNICODE_MODE, 8 << 8, "ĄŔ", 0, "(415) 70 44 00 02 A1 C0 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC", 8 << 8, 1, "Manual mask 8" }, + /* 11*/ { UNICODE_MODE, 9 << 8, "ĄŔ", 0, "(415) 70 44 00 02 A1 C0 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC", 3 << 8, 1, "Manual mask > 8 ignored" }, + /* 12*/ { UNICODE_MODE, ZINT_FULL_MULTIBYTE | (8 << 8), "ĄŔ", 0, "(415) 70 44 00 02 A1 C0 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC", ZINT_FULL_MULTIBYTE | (8 << 8), 1, "Manual mask 8" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_random.c b/backend/tests/test_random.c index 013fffe8..cc80251b 100644 --- a/backend/tests/test_random.c +++ b/backend/tests/test_random.c @@ -248,7 +248,7 @@ static void test_dotcode(const testCtx *const p_ctx) { static void test_hanxin(const testCtx *const p_ctx) { struct random_item rdata = { - FLAG_FULL_8BIT, BARCODE_HANXIN, DATA_MODE, 899, 1, 0, 0, -1, 3261 + FLAG_FULL_8BIT, BARCODE_HANXIN, DATA_MODE, 899, 1, 0, 0, -1, 3258 }; test_random(p_ctx, &rdata); diff --git a/backend/tests/test_raster.c b/backend/tests/test_raster.c index 3d373aa1..6a0c9865 100644 --- a/backend/tests/test_raster.c +++ b/backend/tests/test_raster.c @@ -3428,6 +3428,129 @@ static void test_hrt_content_segs(const testCtx *const p_ctx) { testFinish(); } +/* TODO: add new "raster.h" & put these (plus decl.) in it */ +#define RAST_FAIL_ID_BITMAP 1 +#define RAST_FAIL_ID_ALPHA 2 +#define RAST_FAIL_ID_ROTATED 3 +#define RAST_FAIL_ID_MC_PIXELBUF 4 +#define RAST_FAIL_ID_MC_HEXAGON 5 +#define RAST_FAIL_ID_DOTTY_SCALED 6 +#define RAST_FAIL_ID_PIXELBUF 7 +#define RAST_FAIL_ID_SCALED 8 + +INTERNAL void zint_test_raster_set_fail(const int id, const int at); + +static void test_alloc(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + const char *fgcolour; + float scale; + int rotate_angle; + const char *data; + int ret; + int ats[6]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_CODE128, -1, NULL, 0.0f, 0, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, RAST_FAIL_ID_BITMAP }, + /* 1*/ { BARCODE_CODE128, -1, "80808080", 0.0f, 0, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, RAST_FAIL_ID_ALPHA }, + /* 2*/ { BARCODE_CODE128, -1, NULL, 0.0f, 90, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, RAST_FAIL_ID_ROTATED }, + /* 3*/ { BARCODE_MAXICODE, -1, NULL, 0.0f, 0, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, RAST_FAIL_ID_MC_PIXELBUF }, + /* 4*/ { BARCODE_MAXICODE, -1, NULL, 0.0f, 180, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, RAST_FAIL_ID_MC_HEXAGON }, + /* 5*/ { BARCODE_DATAMATRIX, BARCODE_DOTTY_MODE, NULL, 0.0f, 0, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, RAST_FAIL_ID_DOTTY_SCALED }, + /* 6*/ { BARCODE_CODE128, -1, NULL, 0.0f, 0, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, RAST_FAIL_ID_PIXELBUF }, + /* 7*/ { BARCODE_CODE128, -1, NULL, 1.75f, 0, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, RAST_FAIL_ID_SCALED }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + if (data[i].fgcolour) { + strcpy(symbol->fgcolour, data[i].fgcolour); + } + if (data[i].scale) { + symbol->scale = data[i].scale; + } + ret = ZBarcode_Encode(symbol, ZCUCP(data[i].data), length); + assert_nonzero(ret < ZINT_ERROR, "i:%d %s ZBarcode_Encode ret %d >= ZINT_ERROR %s\n", + i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt); + + zint_test_raster_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Buffer(symbol, data[i].rotate_angle); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_raster_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + +#include + +INTERNAL int zint_plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type); + +static void test_plot_raster(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + int ret; + + struct zint_symbol s_symbol = {0}; + struct zint_symbol *symbol = &s_symbol; + const unsigned char data[] = "123"; + + testStart(p_ctx->func_name); + + ZBarcode_Reset(symbol); + symbol->debug = debug; + strcpy(symbol->fgcolour, "80808080"); + + ret = ZBarcode_Encode(symbol, data, -1); + assert_zero(ret, "ZBarcode_Encode ret %d != 0 (%s)\n", ret, symbol->errtxt); + + /* Call twice without clearing */ + ret = zint_plot_raster(symbol, 0 /*rotate_angle*/, OUT_BUFFER); + assert_zero(ret, "zint_plot_raster ret %d != 0 (%s)\n", ret, symbol->errtxt); + + ret = zint_plot_raster(symbol, 0 /*rotate_angle*/, OUT_BUFFER); + assert_zero(ret, "zint_plot_raster ret %d != 0 (%s)\n", ret, symbol->errtxt); + + symbol->output_options |= OUT_BUFFER_INTERMEDIATE; + ret = zint_plot_raster(symbol, 0 /*rotate_angle*/, OUT_BUFFER); + assert_zero(ret, "zint_plot_raster ret %d != 0 (%s)\n", ret, symbol->errtxt); + + symbol->rows = 0; /* Trigger row guard */ + ret = zint_plot_raster(symbol, 0 /*rotate_angle*/, OUT_BUFFER); + assert_equal(ret, ZINT_ERROR_INVALID_OPTION, "zint_plot_raster ret %d != ZINT_ERROR_INVALID_OPTION (%s)\n", + ret, symbol->errtxt); + + ZBarcode_Clear(symbol); + + testFinish(); +} + #include #define TEST_PERF_ITER_MILLES 1 @@ -3568,6 +3691,8 @@ int main(int argc, char *argv[]) { { "test_height", test_height }, { "test_height_per_row", test_height_per_row }, { "test_hrt_content_segs", test_hrt_content_segs }, + { "test_alloc", test_alloc }, + { "test_plot_raster", test_plot_raster }, { "test_perf_scale", test_perf_scale }, }; diff --git a/backend/tests/test_reedsol.c b/backend/tests/test_reedsol.c index 6597465e..04a366ba 100644 --- a/backend/tests/test_reedsol.c +++ b/backend/tests/test_reedsol.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2025 Robin Stuart + Copyright (C) 2020-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -143,6 +143,7 @@ static void test_encoding(const testCtx *const p_ctx) { /* 16*/ { 0x11d, 10, 0, 16, { 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, { 0x55, 0x2C, 0x87, 0xC7, 0x36, 0xED, 0xC1, 0xD4, 0x24, 0xA5 } }, /* QRCODE Annex I.2 */ /* 17*/ { 0x11d, 5, 0, 5, { 0x40, 0x18, 0xAC, 0xC3, 0x00 }, { 0x30, 0xAE, 0x22, 0x0D, 0x86 } }, /* QRCODE Annex I.3 */ /* 18*/ { 0x163, 256, 0, 1, { 0xFF }, { 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255 } }, + /* 19*/ { 0x163, 256, 1, 7, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0 } }, }; int data_size = ARRAY_SIZE(data); int i; @@ -209,6 +210,7 @@ static void test_encoding_uint(const testCtx *const p_ctx) { /* 16*/ { 0x11d, 10, 0, 16, { 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, { 0x55, 0x2C, 0x87, 0xC7, 0x36, 0xED, 0xC1, 0xD4, 0x24, 0xA5 } }, /* QRCODE Annex I.2 */ /* 17*/ { 0x11d, 5, 0, 5, { 0x40, 0x18, 0xAC, 0xC3, 0x00 }, { 0x30, 0xAE, 0x22, 0x0D, 0x86 } }, /* QRCODE Annex I.3 */ /* 18*/ { 0x163, 256, 0, 1, { 0xFF }, { 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255 } }, + /* 19*/ { 0x163, 256, 1, 7, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0 } }, }; int data_size = ARRAY_SIZE(data); int i; @@ -261,6 +263,7 @@ static void test_uint_encoding(const testCtx *const p_ctx) { /* 1*/ { 0x1069, 4095, 4, 1, 7, { 0xFFF, 0x000, 0x700, 0x7FF, 0xFFF, 0x000, 0x123 }, { 575, 3494, 2350, 3472 } }, /* 2*/ { 0x1000, 4095, 4, 0, 7, { 0xFFF, 0x000, 0x700, 0x7FF, 0xFFF, 0x000, 0x123 }, { 64, 0, 65, 1 } }, /* 3*/ { 0x1000, 4095, 256, 0, 1, { 0xFFF }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2048, 0, 512, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }, + /* 4*/ { 0x409, 1023, 4, 0, 7, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0 } }, }; int data_size = ARRAY_SIZE(data); int i; @@ -314,6 +317,51 @@ static void test_uint_encoding(const testCtx *const p_ctx) { testFinish(); } +static void test_alloc(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int option_2; + const char *data; + int ret; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_AZTEC, 13, "123", ZINT_ERROR_MEMORY, RS_FAIL_ID_LOGT }, + /* 1*/ { BARCODE_AZTEC, 13, "123", ZINT_ERROR_MEMORY, RS_FAIL_ID_ALOG }, + /* 2*/ { BARCODE_AZTEC, 27, "123", ZINT_ERROR_MEMORY, RS_FAIL_ID_LOGT }, + /* 3*/ { BARCODE_AZTEC, 27, "123", ZINT_ERROR_MEMORY, RS_FAIL_ID_ALOG }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, -1 /*output_options*/, + data[i].data, -1, debug); + zint_test_rs_set_fail(data[i].id); + ret = ZBarcode_Encode(symbol, ZCUCP(data[i].data), length); + assert_equal(ret, data[i].ret, "i:%d %s ZBarcode_Encode ret %d != %d (%s)\n", + i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt); + zint_test_rs_set_fail(0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ @@ -321,6 +369,7 @@ int main(int argc, char *argv[]) { { "test_encoding", test_encoding }, { "test_encoding_uint", test_encoding_uint }, { "test_uint_encoding", test_uint_encoding }, + { "test_alloc", test_alloc }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_rss.c b/backend/tests/test_rss.c index b898cf92..848bbc8b 100644 --- a/backend/tests/test_rss.c +++ b/backend/tests/test_rss.c @@ -150,30 +150,38 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) { } else { text = data[i].data; } - length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1, -1, -1 /*output_options*/, + text, -1, debug); ret = ZBarcode_Encode(symbol, TCU(text), length); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, \"%s\", %.0f, %.0f, %d, %d, ", - i, testUtilBarcodeName(data[i].symbology), data[i].data, data[i].w, data[i].h, symbol->rows, symbol->width); + i, testUtilBarcodeName(data[i].symbology), data[i].data, data[i].w, data[i].h, + symbol->rows, symbol->width); testUtilModulesPrintRow(symbol, symbol->rows - 1, "", " },\n"); } else { int width; - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", + i, symbol->rows, data[i].expected_rows); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", + i, symbol->width, data[i].expected_width); ret = testUtilModulesCmpRow(symbol, symbol->rows - 1, data[i].expected, &width); - assert_zero(ret, "i:%d testUtilModulesCmpRow ret %d != 0 width %d row %d\n", i, ret, width, symbol->rows - 1); + assert_zero(ret, "i:%d testUtilModulesCmpRow ret %d != 0 width %d row %d\n", + i, ret, width, symbol->rows - 1); ret = ZBarcode_Buffer_Vector(symbol, 0); assert_zero(ret, "i:%d ZBarcode_Buffer_Vector ret %d != 0\n", i, ret); if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { - ret = testUtilBwipp(i, symbol, -1, -1, -1, text, length, symbol->primary, cmp_buf, sizeof(cmp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + ret = testUtilBwipp(i, symbol, -1, -1, -1, text, length, symbol->primary, cmp_buf, sizeof(cmp_buf), + NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilBwippCmpRow(symbol, symbol->rows - 1, cmp_msg, cmp_buf, data[i].expected); assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", @@ -182,9 +190,12 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { int cmp_len, ret_len; char modules_dump[8192 + 1]; - assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); - ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len); - assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, + "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, + sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, + testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); @@ -889,10 +900,13 @@ static void test_examples(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, + -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, + data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, %s, %d, %d, \"%s\", %d, %d, %d, %d, \"%s\",\n", @@ -904,33 +918,47 @@ static void test_examples(const testCtx *const p_ctx) { } else { int width, row; - assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data); - assert_equal(symbol->width, data[i].expected_width, "i:%d %s symbol->width %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width, data[i].data); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", + i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, + data[i].data); + assert_equal(symbol->width, data[i].expected_width, "i:%d %s symbol->width %d != %d (%s)\n", + i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width, + data[i].data); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); - assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data); + assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", + i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data); if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) { 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); + 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, data[i].option_3, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL, + cmp_buf, sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_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, cmp_msg, cmp_buf, data[i].expected); + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, + data[i].expected); } } if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { int cmp_len, ret_len; char modules_dump[8192 + 1]; - assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); - ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len); - assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, + "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, + sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, - escaped, &ret_len); + escaped, &ret_len); assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); @@ -1218,24 +1246,32 @@ static void test_general_field(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1, -1, -1 /*output_options*/, + data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%2d*/ { %s, \"%s\", %d, %d, %d, \"%s\",\n", - i, testUtilBarcodeName(symbol->symbology), data[i].data, ret, symbol->rows, symbol->width, data[i].comment); + i, testUtilBarcodeName(symbol->symbology), data[i].data, ret, symbol->rows, symbol->width, + data[i].comment); testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { int width, row; - assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data); - assert_equal(symbol->width, data[i].expected_width, "i:%d %s symbol->width %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width, data[i].data); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", + i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, + data[i].data); + assert_equal(symbol->width, data[i].expected_width, "i:%d %s symbol->width %d != %d (%s)\n", + i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width, + data[i].data); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); - assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data); + assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", + i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data); } ZBarcode_Delete(symbol); @@ -1284,20 +1320,27 @@ static void test_binary_buffer_size(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, BARCODE_DBAR_EXP, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, BARCODE_DBAR_EXP, data[i].input_mode, -1 /*eci*/, + -1 /*option_1*/, -1, -1, -1 /*output_options*/, + data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); + 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->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", + i, ret ? "set" : "empty", symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n", i, testUtilInputModeName(data[i].input_mode), data[i].data, testUtilErrorName(ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_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); + assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", + i, symbol->errtxt, data[i].expected_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); } ZBarcode_Delete(symbol); @@ -1356,13 +1399,14 @@ static void test_hrt(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, - -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, - data[i].data, -1, debug); + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); expected_length = (int) strlen(data[i].expected); expected_content_length = (int) strlen(data[i].expected_content); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, data[i].ret, ret, symbol->errtxt); assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n", i, symbol->text_length, expected_length); @@ -1396,6 +1440,8 @@ static void test_input(const testCtx *const p_ctx) { int input_mode; int option_2; int option_3; + int output_options; + float height; const char *data; int ret; int expected_rows; @@ -1406,153 +1452,158 @@ static void test_input(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_DBAR_OMN, -1, -1, -1, "1234567890123", 0, 1, 96, "", 0, 0 }, - /* 1*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 2*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 3*/ { BARCODE_DBAR_OMN, -1, -1, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'", 0, 0 }, - /* 4*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'", 0, 0 }, /* Still checked */ - /* 5*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, - /* 6*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, - /* 7*/ { BARCODE_DBAR_OMN, -1, -1, -1, "01345678901235", 0, 1, 96, "", 0, 0 }, - /* 8*/ { BARCODE_DBAR_OMN, -1, -1, -1, "0134567890123", 0, 1, 96, "", 0, 0 }, - /* 9*/ { BARCODE_DBAR_OMN, -1, -1, -1, "0112345678901231", 0, 1, 96, "", 0, 0 }, /* Allow '01' prefix if check digit given */ - /* 10*/ { BARCODE_DBAR_OMN, -1, -1, -1, "011234567890123", 0, 1, 96, "", 0, 0 }, /* Or not */ - /* 11*/ { BARCODE_DBAR_OMN, -1, -1, -1, "[01]12345678901231", 0, 1, 96, "", 0, 0 }, /* Allow '[01]' prefix if check digit given */ - /* 12*/ { BARCODE_DBAR_OMN, -1, -1, -1, "[01]1234567890123", 0, 1, 96, "", 0, 0 }, /* Or not */ - /* 13*/ { BARCODE_DBAR_OMN, -1, -1, -1, "(01)12345678901231", 0, 1, 96, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */ - /* 14*/ { BARCODE_DBAR_OMN, -1, -1, -1, "(01)1234567890123", 0, 1, 96, "", 0, 0 }, /* Or not */ - /* 15*/ { BARCODE_DBAR_OMN, -1, -1, -1, "[01)12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 18 too long (maximum 14)", 0, 0 }, - /* 16*/ { BARCODE_DBAR_LTD, -1, -1, -1, "1234567890123", 0, 1, 79, "", 0, 0 }, - /* 17*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 18*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 19*/ { BARCODE_DBAR_LTD, -1, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'", 0, 0 }, - /* 20*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'", 0, 0 }, /* Still checked */ - /* 21*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)", 0, 0 }, - /* 22*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)", 0, 0 }, - /* 23*/ { BARCODE_DBAR_LTD, -1, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 }, - /* 24*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 }, - /* 25*/ { BARCODE_DBAR_LTD, -1, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 }, - /* 26*/ { BARCODE_DBAR_LTD, -1, -1, -1, "01345678901235", 0, 1, 79, "", 0, 0 }, - /* 27*/ { BARCODE_DBAR_LTD, -1, -1, -1, "0134567890123", 0, 1, 79, "", 0, 0 }, - /* 28*/ { BARCODE_DBAR_LTD, -1, -1, -1, "0112345678901231", 0, 1, 79, "", 0, 0 }, /* Allow '01' prefix if check digit given */ - /* 29*/ { BARCODE_DBAR_LTD, -1, -1, -1, "011234567890123", 0, 1, 79, "", 0, 0 }, /* Or not */ - /* 30*/ { BARCODE_DBAR_LTD, -1, -1, -1, "[01]12345678901231", 0, 1, 79, "", 0, 0 }, /* Allow '[01]' prefix if check digit given */ - /* 31*/ { BARCODE_DBAR_LTD, -1, -1, -1, "[01]1234567890123", 0, 1, 79, "", 0, 0 }, /* Or not */ - /* 32*/ { BARCODE_DBAR_LTD, -1, -1, -1, "(01)12345678901231", 0, 1, 79, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */ - /* 33*/ { BARCODE_DBAR_LTD, -1, -1, -1, "(01)1234567890123", 0, 1, 79, "", 0, 0 }, /* Or not */ - /* 34*/ { BARCODE_DBAR_LTD, -1, -1, -1, "[01)12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 18 too long (maximum 14)", 0, 0 }, - /* 35*/ { BARCODE_DBAR_LTD, -1, -1, -1, "[10]12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 18 too long (maximum 14)", 0, 0 }, - /* 36*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 }, - /* 37*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 0, 0 }, - /* 38*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "", 0, 0 }, - /* 39*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231", 0, 1, 134, "", 0, 0 }, - /* 40*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 }, - /* 41*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 }, - /* 42*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01) at position 1", 0, 0 }, - /* 43*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]123456789012315", 0, 1, 151, "", 0, 0 }, - /* 44*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 0, 0 }, - /* 45*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "", 0, 0 }, - /* 46*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", ZINT_WARN_NONCOMPLIANT, 1, 526, "Warning 261: AI (91) data position 21: Invalid CSET 82 character ' '", 0, 0 }, /* ISOIEC punc */ - /* 47*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", 0, 1, 526, "", 0, 0 }, - /* 48*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "", 0, 0 }, /* ISOIEC punc less space */ - /* 49*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "", 0, 0 }, - /* 50*/ { BARCODE_DBAR_STK, -1, -1, -1, "1234567890123", 0, 3, 50, "", 0, 0 }, - /* 51*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 52*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 53*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 54*/ { BARCODE_DBAR_STK, -1, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'", 0, 0 }, - /* 55*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'", 0, 0 }, /* Still checked */ - /* 56*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, - /* 57*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, - /* 58*/ { BARCODE_DBAR_STK, -1, -1, -1, "01345678901235", 0, 3, 50, "", 0, 0 }, - /* 59*/ { BARCODE_DBAR_STK, -1, -1, -1, "0134567890123", 0, 3, 50, "", 0, 0 }, - /* 60*/ { BARCODE_DBAR_STK, -1, -1, -1, "0112345678901231", 0, 3, 50, "", 0, 0 }, /* Allow '01' prefix if check digit given */ - /* 61*/ { BARCODE_DBAR_STK, -1, -1, -1, "011234567890123", 0, 3, 50, "", 0, 0 }, /* Or not */ - /* 62*/ { BARCODE_DBAR_STK, -1, -1, -1, "[01]12345678901231", 0, 3, 50, "", 0, 0 }, /* Allow '[01]' prefix if check digit given */ - /* 63*/ { BARCODE_DBAR_STK, -1, -1, -1, "[01]1234567890123", 0, 3, 50, "", 0, 0 }, /* Or not */ - /* 64*/ { BARCODE_DBAR_STK, -1, -1, -1, "(01)12345678901231", 0, 3, 50, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */ - /* 65*/ { BARCODE_DBAR_STK, -1, -1, -1, "(01)1234567890123", 0, 3, 50, "", 0, 0 }, /* Or not */ - /* 66*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "1234567890123", 0, 5, 50, "", 0, 0 }, - /* 67*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 68*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, - /* 69*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'", 0, 0 }, - /* 70*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'", 0, 0 }, /* Still checked */ - /* 71*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, - /* 72*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, - /* 73*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "01345678901235", 0, 5, 50, "", 0, 0 }, - /* 74*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "0134567890123", 0, 5, 50, "", 0, 0 }, - /* 75*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "0112345678901231", 0, 5, 50, "", 0, 0 }, /* Allow '01' prefix if check digit given */ - /* 76*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "011234567890123", 0, 5, 50, "", 0, 0 }, /* Or not */ - /* 77*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "[01]12345678901231", 0, 5, 50, "", 0, 0 }, /* Allow '[01]' prefix if check digit given */ - /* 78*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "[01]1234567890123", 0, 5, 50, "", 0, 0 }, /* Or not */ - /* 79*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "(01)12345678901231", 0, 5, 50, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */ - /* 80*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "(01)1234567890123", 0, 5, 50, "", 0, 0 }, /* Or not */ - /* 81*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "(00)12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 18 too long (maximum 14)", 0, 0 }, - /* 82*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 2, 0 }, - /* 83*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 5, 102, "", 2, 0 }, - /* 84*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, - /* 85*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 }, - /* 86*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 }, - /* 87*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01) at position 1", 0, 0 }, - /* 88*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]123456789012315", 0, 5, 102, "", 2, 0 }, - /* 89*/ { BARCODE_DBAR_EXPSTK, -1, 12, -1, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, /* Cols > 11 ignored */ - /* 90*/ { BARCODE_DBAR_EXPSTK, -1, -1, 12, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, /* Rows > 11 ignored */ - /* 91*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[01]12345678901231", 0, 9, 53, "", 1, 0 }, - /* 92*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, - /* 93*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[01]12345678901231", 0, 1, 134, "", 3, 0 }, - /* 94*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[01]12345678901231", 0, 1, 134, "", 4, 0 }, - /* 95*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[01]12345678901231", 0, 5, 102, "", 2, 2 }, - /* 96*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[01]12345678901231", 0, 5, 102, "", 2, 3 }, - /* 97*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 0 }, - /* 98*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[8110]106141416543213500110000310123196000", 0, 25, 53, "", 1, 0 }, - /* 99*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 0 }, - /*100*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[8110]106141416543213500110000310123196000", 0, 9, 151, "", 3, 0 }, - /*101*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[8110]106141416543213500110000310123196000", 0, 5, 200, "", 4, 0 }, - /*102*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[8110]106141416543213500110000310123196000", 0, 5, 249, "", 5, 0 }, - /*103*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]106141416543213500110000310123196000", 0, 5, 200, "", 4, 2 }, - /*104*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[8110]106141416543213500110000310123196000", 0, 9, 151, "", 3, 3 }, - /*105*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 4 }, - /*106*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 5 }, - /*107*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 }, - /*108*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]123456789012345678901", 0, 17, 53, "", 1, 0 }, - /*109*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 }, - /*110*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]123456789012345678901", 0, 5, 151, "", 3, 0 }, - /*111*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]123456789012345678901", 0, 5, 200, "", 4, 0 }, - /*112*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]123456789012345678901", 0, 5, 151, "", 3, 2 }, - /*113*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]123456789012345678901", 0, 9, 102, "", 2, 3 }, - /*114*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]123456789012345678901", 0, 9, 102, "", 2, 4 }, - /*115*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 }, - /*116*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 0 }, - /*117*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 33, 53, "", 1, 0 }, - /*118*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 0 }, - /*119*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 0 }, - /*120*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 200, "", 4, 0 }, - /*121*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 200, "", 4, 0 }, - /*122*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 249, "", 5, 0 }, - /*123*/ { BARCODE_DBAR_EXPSTK, -1, 6, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 298, "", 6, 0 }, - /*124*/ { BARCODE_DBAR_EXPSTK, -1, 7, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 347, "", 7, 0 }, - /*125*/ { BARCODE_DBAR_EXPSTK, -1, 8, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 396, "", 8, 0 }, - /*126*/ { BARCODE_DBAR_EXPSTK, -1, 9, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 1, 428, "", 9, 0 }, - /*127*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 249, "", 5, 2 }, - /*128*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 3 }, - /*129*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 4 }, - /*130*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 5 }, - /*131*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 6 }, - /*132*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 }, - /*133*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 41, 53, "", 1, 0 }, - /*134*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 }, - /*135*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 0 }, - /*136*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 200, "", 4, 0 }, - /*137*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 249, "", 5, 0 }, - /*138*/ { BARCODE_DBAR_EXPSTK, -1, 6, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 298, "", 6, 0 }, - /*139*/ { BARCODE_DBAR_EXPSTK, -1, 7, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 347, "", 7, 0 }, - /*140*/ { BARCODE_DBAR_EXPSTK, -1, -1, 1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 }, - /*141*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 298, "", 6, 2 }, - /*142*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 200, "", 4, 3 }, - /*143*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 4 }, - /*144*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 5 }, - /*145*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 6 }, - /*146*/ { BARCODE_DBAR_EXPSTK, -1, -1, 7, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 7 }, + /* 0*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "1234567890123", 0, 1, 96, "", 0, 0 }, + /* 1*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 2*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 3*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'", 0, 0 }, + /* 4*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'", 0, 0 }, /* Still checked */ + /* 5*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, + /* 6*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, + /* 7*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "01345678901235", 0, 1, 96, "", 0, 0 }, + /* 8*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "0134567890123", 0, 1, 96, "", 0, 0 }, + /* 9*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "0112345678901231", 0, 1, 96, "", 0, 0 }, /* Allow '01' prefix if check digit given */ + /* 10*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "011234567890123", 0, 1, 96, "", 0, 0 }, /* Or not */ + /* 11*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "[01]12345678901231", 0, 1, 96, "", 0, 0 }, /* Allow '[01]' prefix if check digit given */ + /* 12*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "[01]1234567890123", 0, 1, 96, "", 0, 0 }, /* Or not */ + /* 13*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "(01)12345678901231", 0, 1, 96, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */ + /* 14*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "(01)1234567890123", 0, 1, 96, "", 0, 0 }, /* Or not */ + /* 15*/ { BARCODE_DBAR_OMN, -1, -1, -1, -1, 0.0f, "[01)12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 18 too long (maximum 14)", 0, 0 }, + /* 16*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "1234567890123", 0, 1, 79, "", 0, 0 }, + /* 17*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 18*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 19*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'", 0, 0 }, + /* 20*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'", 0, 0 }, /* Still checked */ + /* 21*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)", 0, 0 }, + /* 22*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)", 0, 0 }, + /* 23*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 }, + /* 24*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 }, + /* 25*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 }, + /* 26*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "01345678901235", 0, 1, 79, "", 0, 0 }, + /* 27*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "0134567890123", 0, 1, 79, "", 0, 0 }, + /* 28*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "0112345678901231", 0, 1, 79, "", 0, 0 }, /* Allow '01' prefix if check digit given */ + /* 29*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "011234567890123", 0, 1, 79, "", 0, 0 }, /* Or not */ + /* 30*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "[01]12345678901231", 0, 1, 79, "", 0, 0 }, /* Allow '[01]' prefix if check digit given */ + /* 31*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "[01]1234567890123", 0, 1, 79, "", 0, 0 }, /* Or not */ + /* 32*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "(01)12345678901231", 0, 1, 79, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */ + /* 33*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "(01)1234567890123", 0, 1, 79, "", 0, 0 }, /* Or not */ + /* 34*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "[01)12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 18 too long (maximum 14)", 0, 0 }, + /* 35*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, 0.0f, "[10]12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 18 too long (maximum 14)", 0, 0 }, + /* 36*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 }, + /* 37*/ { BARCODE_DBAR_EXP, -1, -1, -1, -1, 0.0f, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 0, 0 }, + /* 38*/ { BARCODE_DBAR_EXP, -1, -1, -1, COMPLIANT_HEIGHT, 1.0f, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 0, 0 }, + /* 39*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]12345678901234", 0, 1, 134, "", 0, 0 }, + /* 40*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, COMPLIANT_HEIGHT, 1.0f, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 247: Height not compliant with standards (too small)", 0, 0 }, + /* 41*/ { BARCODE_DBAR_EXP, -1, -1, -1, -1, 0.0f, "[01]12345678901231", 0, 1, 134, "", 0, 0 }, + /* 42*/ { BARCODE_DBAR_EXP, -1, -1, -1, -1, 0.0f, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 }, + /* 43*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 }, + /* 44*/ { BARCODE_DBAR_EXP, -1, -1, -1, -1, 0.0f, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01) at position 1", 0, 0 }, + /* 45*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]123456789012315", 0, 1, 151, "", 0, 0 }, + /* 46*/ { BARCODE_DBAR_EXP, -1, -1, -1, -1, 0.0f, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 0, 0 }, + /* 47*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]12345678901234", 0, 1, 134, "", 0, 0 }, + /* 48*/ { BARCODE_DBAR_EXP, -1, -1, -1, -1, 0.0f, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", ZINT_WARN_NONCOMPLIANT, 1, 526, "Warning 261: AI (91) data position 21: Invalid CSET 82 character ' '", 0, 0 }, /* ISOIEC punc */ + /* 49*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", 0, 1, 526, "", 0, 0 }, + /* 50*/ { BARCODE_DBAR_EXP, -1, -1, -1, -1, 0.0f, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "", 0, 0 }, /* ISOIEC punc less space */ + /* 51*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "", 0, 0 }, + /* 52*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "1234567890123", 0, 3, 50, "", 0, 0 }, + /* 53*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 54*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 55*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 56*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'", 0, 0 }, + /* 57*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'", 0, 0 }, /* Still checked */ + /* 58*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, + /* 59*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, + /* 60*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 2.2f, "1234567890123", 0, 3, 50, "", 0, 0 }, + /* 61*/ { BARCODE_DBAR_STK, -1, -1, -1, COMPLIANT_HEIGHT, 2.2f, "1234567890123", ZINT_WARN_NONCOMPLIANT, 3, 50, "Warning 379: Height not compliant with standards", 0, 0 }, + /* 62*/ { BARCODE_DBAR_STK, -1, -1, -1, COMPLIANT_HEIGHT, 2.2f, "12345678901234", ZINT_ERROR_INVALID_CHECK, 3, 50, "Error 388: Invalid check digit '4', expecting '1'", 0, 0 }, + /* 63*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "01345678901235", 0, 3, 50, "", 0, 0 }, + /* 64*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "0134567890123", 0, 3, 50, "", 0, 0 }, + /* 65*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "0112345678901231", 0, 3, 50, "", 0, 0 }, /* Allow '01' prefix if check digit given */ + /* 66*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "011234567890123", 0, 3, 50, "", 0, 0 }, /* Or not */ + /* 67*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "[01]12345678901231", 0, 3, 50, "", 0, 0 }, /* Allow '[01]' prefix if check digit given */ + /* 68*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "[01]1234567890123", 0, 3, 50, "", 0, 0 }, /* Or not */ + /* 69*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "(01)12345678901231", 0, 3, 50, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */ + /* 70*/ { BARCODE_DBAR_STK, -1, -1, -1, -1, 0.0f, "(01)1234567890123", 0, 3, 50, "", 0, 0 }, /* Or not */ + /* 71*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "1234567890123", 0, 5, 50, "", 0, 0 }, + /* 72*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 73*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 }, + /* 74*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'", 0, 0 }, + /* 75*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'", 0, 0 }, /* Still checked */ + /* 76*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, + /* 77*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 }, + /* 78*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "01345678901235", 0, 5, 50, "", 0, 0 }, + /* 79*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "0134567890123", 0, 5, 50, "", 0, 0 }, + /* 80*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "0112345678901231", 0, 5, 50, "", 0, 0 }, /* Allow '01' prefix if check digit given */ + /* 81*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "011234567890123", 0, 5, 50, "", 0, 0 }, /* Or not */ + /* 82*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "[01]12345678901231", 0, 5, 50, "", 0, 0 }, /* Allow '[01]' prefix if check digit given */ + /* 83*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "[01]1234567890123", 0, 5, 50, "", 0, 0 }, /* Or not */ + /* 84*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "(01)12345678901231", 0, 5, 50, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */ + /* 85*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "(01)1234567890123", 0, 5, 50, "", 0, 0 }, /* Or not */ + /* 86*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, -1, 0.0f, "(00)12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 18 too long (maximum 14)", 0, 0 }, + /* 87*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 2, 0 }, + /* 88*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]12345678901234", 0, 5, 102, "", 2, 0 }, + /* 89*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, + /* 90*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 }, + /* 91*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 }, + /* 92*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01) at position 1", 0, 0 }, + /* 93*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, -1, 0.0f, "[01]123456789012315", 0, 5, 102, "", 2, 0 }, + /* 94*/ { BARCODE_DBAR_EXPSTK, -1, 12, -1, -1, 0.0f, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, /* Cols > 11 ignored */ + /* 95*/ { BARCODE_DBAR_EXPSTK, -1, -1, 12, -1, 0.0f, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, /* Rows > 11 ignored */ + /* 96*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, -1, 0.0f, "[01]12345678901231", 0, 9, 53, "", 1, 0 }, + /* 97*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, -1, 0.0f, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, + /* 98*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, -1, 0.0f, "[01]12345678901231", 0, 1, 134, "", 3, 0 }, + /* 99*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, -1, 0.0f, "[01]12345678901231", 0, 1, 134, "", 4, 0 }, + /*100*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, -1, 0.0f, "[01]12345678901231", 0, 5, 102, "", 2, 2 }, + /*101*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, -1, 0.0f, "[01]12345678901231", 0, 5, 102, "", 2, 3 }, + /*102*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 0 }, + /*103*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 25, 53, "", 1, 0 }, + /*104*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 0 }, + /*105*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 9, 151, "", 3, 0 }, + /*106*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 5, 200, "", 4, 0 }, + /*107*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 5, 249, "", 5, 0 }, + /*108*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 5, 200, "", 4, 2 }, + /*109*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 9, 151, "", 3, 3 }, + /*110*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 4 }, + /*111*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, -1, 0.0f, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 5 }, + /*112*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 }, + /*113*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, -1, 0.0f, "[91]123456789012345678901", 0, 17, 53, "", 1, 0 }, + /*114*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, -1, 0.0f, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 }, + /*115*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, -1, 0.0f, "[91]123456789012345678901", 0, 5, 151, "", 3, 0 }, + /*116*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, -1, 0.0f, "[91]123456789012345678901", 0, 5, 200, "", 4, 0 }, + /*117*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, -1, 0.0f, "[91]123456789012345678901", 0, 5, 151, "", 3, 2 }, + /*118*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, -1, 0.0f, "[91]123456789012345678901", 0, 9, 102, "", 2, 3 }, + /*119*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, -1, 0.0f, "[91]123456789012345678901", 0, 9, 102, "", 2, 4 }, + /*120*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 }, + /*121*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 0 }, + /*122*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 33, 53, "", 1, 0 }, + /*123*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 0 }, + /*124*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 0 }, + /*125*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 200, "", 4, 0 }, + /*126*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 200, "", 4, 0 }, + /*127*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 249, "", 5, 0 }, + /*128*/ { BARCODE_DBAR_EXPSTK, -1, 6, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 298, "", 6, 0 }, + /*129*/ { BARCODE_DBAR_EXPSTK, -1, 7, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 347, "", 7, 0 }, + /*130*/ { BARCODE_DBAR_EXPSTK, -1, 8, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 396, "", 8, 0 }, + /*131*/ { BARCODE_DBAR_EXPSTK, -1, 9, -1, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 1, 428, "", 9, 0 }, + /*132*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 249, "", 5, 2 }, + /*133*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 3 }, + /*134*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 4 }, + /*135*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 5 }, + /*136*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, -1, 0.0f, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 6 }, + /*137*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 }, + /*138*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 41, 53, "", 1, 0 }, + /*139*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 }, + /*140*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 0 }, + /*141*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 200, "", 4, 0 }, + /*142*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 249, "", 5, 0 }, + /*143*/ { BARCODE_DBAR_EXPSTK, -1, 6, -1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 298, "", 6, 0 }, + /*144*/ { BARCODE_DBAR_EXPSTK, -1, 7, -1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 347, "", 7, 0 }, + /*145*/ { BARCODE_DBAR_EXPSTK, -1, -1, 1, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 }, + /*146*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 298, "", 6, 2 }, + /*147*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 200, "", 4, 3 }, + /*148*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 4 }, + /*149*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 5 }, + /*150*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 6 }, + /*151*/ { BARCODE_DBAR_EXPSTK, -1, -1, 7, -1, 0.0f, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 7 }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -1568,11 +1619,15 @@ static void test_input(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, - -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, + -1 /*option_1*/, data[i].option_2, data[i].option_3, data[i].output_options, data[i].data, -1, debug); + if (data[i].height) { + symbol->height = data[i].height; + } ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); @@ -1595,6 +1650,56 @@ static void test_input(const testCtx *const p_ctx) { testFinish(); } +/* `combins()` in ISO/IEC 24724:2011 Annex B */ +/**************************************************************************** + * dbar_combins(n,r): returns the number of Combinations of r selected from n: + * Combinations = n! / (n - r)! * r! + ****************************************************************************/ +static int test_generate_dbar_combins(const int n, const int r) { + int i; + int maxDenom, minDenom; + int val = 1, j = 1; + + if (n - r > r) { + minDenom = r; + maxDenom = n - r; + } else { + minDenom = n - r; + maxDenom = r; + } + for (i = n; i > maxDenom; i--) { + val *= i; + if (j <= minDenom) { + val /= j; + j++; + } + } + for (; j <= minDenom; j++) { + val /= j; + } + return val; +} + +/* Dummy to generate `combins()` */ +static void test_generate_combins(const testCtx *const p_ctx) { + int i, j; + + if (!p_ctx->generate) { + return; + } + + printf(" static const short combins[18][6] = {\n"); + for (i = 0; i < 18; i++) { + printf(" {% 2d,% 3d,", test_generate_dbar_combins(i, 0), test_generate_dbar_combins(i, 1)); + for (j = 2; j < 4; j++) { + printf("% 4d,", test_generate_dbar_combins(i, j)); + } + printf("% 5d,% 5d }%c /*% 3d */\n", + test_generate_dbar_combins(i, 4), test_generate_dbar_combins(i, 5), i == 17 ? ' ' : ',', i); + } + printf(" };\n"); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ @@ -1604,6 +1709,7 @@ int main(int argc, char *argv[]) { { "test_binary_buffer_size", test_binary_buffer_size }, { "test_hrt", test_hrt }, { "test_input", test_input }, + { "test_generate_combins", test_generate_combins }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_svg.c b/backend/tests/test_svg.c index 1aa35f31..6e7d669f 100644 --- a/backend/tests/test_svg.c +++ b/backend/tests/test_svg.c @@ -202,7 +202,7 @@ static void test_print(const testCtx *const p_ctx) { have_vnu = testUtilHaveVnu(); assert_nonzero(testUtilDataPath(data_dir_path, sizeof(data_dir_path), data_dir, NULL), - "testUtilDataPath(%s) == 0\n", data_dir); + "testUtilDataPath(%s) == 0\n", data_dir); if (!testUtilDirExists(data_dir_path)) { ret = testUtilMkDir(data_dir_path); assert_zero(ret, "testUtilMkDir(%s) ret %d != 0 (%d: %s)\n", data_dir_path, ret, errno, strerror(errno)); @@ -218,8 +218,8 @@ static void test_print(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, - data[i].option_1, data[i].option_2, data[i].option_3, data[i].output_options, - data[i].data, -1, debug); + data[i].option_1, data[i].option_2, data[i].option_3, data[i].output_options, + data[i].data, -1, debug); if (data[i].show_hrt != -1) { symbol->show_hrt = data[i].show_hrt; } @@ -252,23 +252,23 @@ static void test_print(const testCtx *const p_ctx) { ret = ZBarcode_Encode(symbol, TCU(text), text_length); assert_equal(ret, data[i].ret, "i:%d %s ZBarcode_Encode ret %d != %d (%s)\n", - i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt); + i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt); strcpy(symbol->outfile, svg); ret = ZBarcode_Print(symbol, data[i].rotate_angle); assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", - i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); + i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), - "i:%d testUtilDataPath == 0\n", i); + "i:%d testUtilDataPath == 0\n", i); if (p_ctx->generate) { printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %d, %.8g, \"%s\", \"%s\", %d, \"%s\", \"%s\", %s, \"%s\", \"%s\" },\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), - data[i].border_width, testUtilOutputOptionsName(data[i].output_options), - data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, + data[i].border_width, testUtilOutputOptionsName(data[i].output_options), + data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].option_3, data[i].height, - data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle, + data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, testUtilErrorName(data[i].ret), data[i].expected_file, data[i].comment); ret = testUtilRename(symbol->outfile, expected_file); @@ -276,12 +276,12 @@ static void test_print(const testCtx *const p_ctx) { if (have_libreoffice) { ret = testUtilVerifyLibreOffice(expected_file, debug); assert_zero(ret, "i:%d %s libreoffice %s ret %d != 0\n", - i, testUtilBarcodeName(data[i].symbology), expected_file, ret); + i, testUtilBarcodeName(data[i].symbology), expected_file, ret); } if (have_vnu) { ret = testUtilVerifyVnu(expected_file, debug); /* Very slow */ assert_zero(ret, "i:%d %s vnu libreoffice %s ret %d != 0\n", - i, testUtilBarcodeName(data[i].symbology), expected_file, ret); + i, testUtilBarcodeName(data[i].symbology), expected_file, ret); } } else { assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile); @@ -289,7 +289,7 @@ static void test_print(const testCtx *const p_ctx) { ret = testUtilCmpSvgs(symbol->outfile, expected_file); assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", - i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); symbol->output_options |= BARCODE_MEMORY_FILE; ret = ZBarcode_Print(symbol, data[i].rotate_angle); @@ -297,7 +297,7 @@ static void test_print(const testCtx *const p_ctx) { i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret, symbol->errtxt); assert_nonnull(symbol->memfile, "i:%d %s memfile NULL\n", i, testUtilBarcodeName(data[i].symbology)); assert_nonzero(symbol->memfile_size, "i:%d %s memfile_size 0\n", - i, testUtilBarcodeName(data[i].symbology)); + i, testUtilBarcodeName(data[i].symbology)); ret = testUtilWriteFile(memfile, symbol->memfile, symbol->memfile_size, "wb"); assert_zero(ret, "%d: testUtilWriteFile(%s) fail ret %d != 0\n", i, memfile, ret); @@ -338,20 +338,20 @@ static void test_outfile(const testCtx *const p_ctx) { skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */ #endif if (!skip_readonly_test) { - /* Excluding OS-dependent `errno` stuff */ + /* Excluding OS-dependent `errno` stuff */ static char expected_errtxt[] = "680: Could not open SVG output file ("; (void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */ assert_nonzero(testUtilCreateROFile(symbol.outfile), "zint_svg_plot testUtilCreateROFile(%s) fail (%d: %s)\n", - symbol.outfile, errno, strerror(errno)); + symbol.outfile, errno, strerror(errno)); ret = zint_svg_plot(&symbol, 0); assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "zint_svg_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", - ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); assert_zero(testUtilRmROFile(symbol.outfile), "zint_svg_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", - symbol.outfile, errno, strerror(errno)); + symbol.outfile, errno, strerror(errno)); assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", - symbol.errtxt, expected_errtxt); + symbol.errtxt, expected_errtxt); } symbol.output_options |= BARCODE_STDOUT; @@ -364,7 +364,71 @@ static void test_outfile(const testCtx *const p_ctx) { symbol.vector = NULL; ret = zint_svg_plot(&symbol, 0); assert_equal(ret, ZINT_ERROR_INVALID_DATA, "zint_svg_plot ret %d != ZINT_ERROR_INVALID_DATA (%d) (%s)\n", - ret, ZINT_ERROR_INVALID_DATA, symbol.errtxt); + ret, ZINT_ERROR_INVALID_DATA, symbol.errtxt); + + testFinish(); +} + +#include "filemem.h" + +static void test_fm(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_ACCESS, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_OPEN }, + /* 1*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 5, 11, 0, 0, 0 }, 2, FM_FAIL_ID_PUTS }, + /* 1*/ { BARCODE_DATAMATRIX, BARCODE_MEMORY_FILE, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_PUTS }, + /* 2*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 3, 0, 0, 0 }, 2, FM_FAIL_ID_PUTC }, + /* 3*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 10, 21, 0, 0 }, 3, FM_FAIL_ID_PUTSF }, + /* 3*/ { BARCODE_DATAMATRIX, BARCODE_MEMORY_FILE, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_PUTSF }, + /* 4*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 3, 0, 0, 0 }, 2, FM_FAIL_ID_PRINTF }, + /* 4*/ { BARCODE_DATAMATRIX, BARCODE_MEMORY_FILE, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_PRINTF }, + /* 5*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.svg"); + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } testFinish(); } @@ -374,6 +438,7 @@ int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ { "test_print", test_print }, { "test_outfile", test_outfile }, + { "test_fm", test_fm }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_telepen.c b/backend/tests/test_telepen.c index 2947a91a..ab84cbf5 100644 --- a/backend/tests/test_telepen.c +++ b/backend/tests/test_telepen.c @@ -319,15 +319,16 @@ static void test_input(const testCtx *const p_ctx) { /* 5*/ { BARCODE_TELEPEN, 1, "\020", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 397: DLE (ASCII 16) cannot be first character in Full ASCII + Compressed Numeric Mode" }, /* 6*/ { BARCODE_TELEPEN, -1, "A\020B", -1, 0, 1, 96, "" }, /* 7*/ { BARCODE_TELEPEN, 1, "A\020B", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 396: Invalid character at position 3 in input (digits and \"X\" only)" }, - /* 8*/ { BARCODE_TELEPEN_NUM, -1, "1234567890", -1, 0, 1, 128, "" }, - /* 9*/ { BARCODE_TELEPEN_NUM, -1, "123456789A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 393: Invalid character at position 10 in input (digits and \"X\" only)" }, - /* 10*/ { BARCODE_TELEPEN_NUM, -1, "123456789X", -1, 0, 1, 128, "" }, /* [0-9]X allowed */ - /* 11*/ { BARCODE_TELEPEN_NUM, -1, "12345678X9", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 394: Invalid odd position 9 of \"X\" in Telepen data" }, /* X[0-9] not allowed */ - /* 12*/ { BARCODE_TELEPEN_NUM, -1, "1X34567X9X", -1, 0, 1, 128, "" }, /* [0-9]X allowed multiple times */ - /* 13*/ { BARCODE_TELEPEN_NUM, -1, "\020", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 398: DLE (ASCII 16) cannot be first character in Compressed Numeric Mode" }, - /* 14*/ { BARCODE_TELEPEN_NUM, 1, "\020", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 398: DLE (ASCII 16) cannot be first character in Compressed Numeric Mode" }, - /* 15*/ { BARCODE_TELEPEN_NUM, -1, "12\020é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 395: Invalid character at position 4 in input, extended ASCII not allowed" }, - /* 16*/ { BARCODE_TELEPEN_NUM, 1, "12\020é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 395: Invalid character at position 4 in input, extended ASCII not allowed" }, + /* 8*/ { BARCODE_TELEPEN, 1, "A\02012X3", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 394: Invalid odd position 4 of \"X\" in Telepen data" }, + /* 9*/ { BARCODE_TELEPEN_NUM, -1, "1234567890", -1, 0, 1, 128, "" }, + /* 10*/ { BARCODE_TELEPEN_NUM, -1, "123456789A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 393: Invalid character at position 10 in input (digits and \"X\" only)" }, + /* 11*/ { BARCODE_TELEPEN_NUM, -1, "123456789X", -1, 0, 1, 128, "" }, /* [0-9]X allowed */ + /* 12*/ { BARCODE_TELEPEN_NUM, -1, "12345678X9", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 394: Invalid odd position 9 of \"X\" in Telepen data" }, /* X[0-9] not allowed */ + /* 13*/ { BARCODE_TELEPEN_NUM, -1, "1X34567X9X", -1, 0, 1, 128, "" }, /* [0-9]X allowed multiple times */ + /* 14*/ { BARCODE_TELEPEN_NUM, -1, "\020", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 398: DLE (ASCII 16) cannot be first character in Compressed Numeric Mode" }, + /* 15*/ { BARCODE_TELEPEN_NUM, 1, "\020", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 398: DLE (ASCII 16) cannot be first character in Compressed Numeric Mode" }, + /* 16*/ { BARCODE_TELEPEN_NUM, -1, "12\020é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 395: Invalid character at position 4 in input, extended ASCII not allowed" }, + /* 17*/ { BARCODE_TELEPEN_NUM, 1, "12\020é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 395: Invalid character at position 4 in input, extended ASCII not allowed" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_tif.c b/backend/tests/test_tif.c index ccd0e82a..257c2801 100644 --- a/backend/tests/test_tif.c +++ b/backend/tests/test_tif.c @@ -175,6 +175,7 @@ static void test_print(const testCtx *const p_ctx) { int option_2; int height; float scale; + float dpmm; const char *fgcolour; const char *bgcolour; const char *data; @@ -183,32 +184,33 @@ static void test_print(const testCtx *const p_ctx) { const char *comment; }; static const struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "112233", "EEDDCC", "A", "", "code128_fgbg.tif", "" }, - /* 1*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "FFFFFF", "000000", "A", "", "code128_reverse.tif", "" }, - /* 2*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "112233", "CCDDEE", "A", "", "code128_cmyk_fgbg.tif", "" }, - /* 3*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "A", "", "code128_bgalpha.tif", "" }, - /* 4*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "00000099", "FEDCBA", "A", "", "code128_fgalpha.tif", "" }, - /* 5*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "00000099", "FEDCBACC", "A", "", "code128_fgbgalpha.tif", "" }, - /* 6*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBA", "A", "", "code128_cmyk.tif", "" }, - /* 7*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C0000099", "FEDCBACC", "A", "", "code128_cmyk_fgbgalpha.tif", "" }, - /* 8*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "71,0,40,44", "10,0,20,5", "A", "", "code128_cmyk_fgbgcmyk.tif", "" }, - /* 9*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_bgalpha.tif", "" }, - /* 10*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_cmyk_bgalpha.tif", "" }, - /* 11*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "FEDCBA", "1234", "", "ultra_fgalpha.tif", "" }, - /* 12*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "FEDCBACC", "1234", "", "ultra_fgbgalpha.tif", "" }, - /* 13*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "", "1234", "", "ultra_fgalpha_nobg.tif", "" }, - /* 14*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "", "FEDCBACC", "1234", "", "ultra_bgalpha_nofg.tif", "" }, - /* 15*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "ultra_odd.tif", "" }, - /* 16*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "", "", "1234", "", "ultra_cmyk.tif", "" }, - /* 17*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "FF0000", "0000FF", "1234", "", "ultra_fgbg_hvwsp1_box1.tif", "" }, - /* 18*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, -1, -1, -1, 4, 84, 0, 2, "", "", "1", "", "hanxin_v84_l4_scale2.tif", "" }, - /* 19*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, 32, 0, 0, "4BE055", "", "1", "", "aztec_v32_fg.tif", "" }, - /* 20*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0.5f, "", "", "F", "", "daft_height8_scale0.5.tif", "" }, - /* 21*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0.5f, "", "", "DAFT", "", "daft_height1_scale0.5.tif", "" }, - /* 22*/ { BARCODE_EAN8, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9501234", "", "ean8_gss_5.2.2.2-1.tif", "" }, - /* 23*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9501234", "", "ean8_gss_5.2.2.2-1.tif", "" }, - /* 24*/ { BARCODE_EAN8, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, "", "", "9501234", "", "ean8_gss_5.2.2.2-1_gws.tif", "" }, - /* 25*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, "", "", "9501234", "", "ean8_gss_5.2.2.2-1_gws.tif", "" }, + /* 0*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "112233", "EEDDCC", "A", "", "code128_fgbg.tif", "" }, + /* 1*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "FFFFFF", "000000", "A", "", "code128_reverse.tif", "" }, + /* 2*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "112233", "CCDDEE", "A", "", "code128_cmyk_fgbg.tif", "" }, + /* 3*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "C00000", "FEDCBACC", "A", "", "code128_bgalpha.tif", "" }, + /* 4*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "00000099", "FEDCBA", "A", "", "code128_fgalpha.tif", "" }, + /* 5*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "00000099", "FEDCBACC", "A", "", "code128_fgbgalpha.tif", "" }, + /* 6*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "C00000", "FEDCBA", "A", "", "code128_cmyk.tif", "" }, + /* 7*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "C0000099", "FEDCBACC", "A", "", "code128_cmyk_fgbgalpha.tif", "" }, + /* 8*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "71,0,40,44", "10,0,20,5", "A", "", "code128_cmyk_fgbgcmyk.tif", "" }, + /* 9*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "C00000", "FEDCBACC", "1234", "", "ultra_bgalpha.tif", "" }, + /* 10*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "C00000", "FEDCBACC", "1234", "", "ultra_cmyk_bgalpha.tif", "" }, + /* 11*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "000000BB", "FEDCBA", "1234", "", "ultra_fgalpha.tif", "" }, + /* 12*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "000000BB", "FEDCBACC", "1234", "", "ultra_fgbgalpha.tif", "" }, + /* 13*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "000000BB", "", "1234", "", "ultra_fgalpha_nobg.tif", "" }, + /* 14*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "", "FEDCBACC", "1234", "", "ultra_bgalpha_nofg.tif", "" }, + /* 15*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, 0.0f, "", "", "1", "", "ultra_odd.tif", "" }, + /* 16*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "", "", "1234", "", "ultra_cmyk.tif", "" }, + /* 17*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0.0f, 0.0f, "FF0000", "0000FF", "1234", "", "ultra_fgbg_hvwsp1_box1.tif", "" }, + /* 18*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, -1, -1, -1, 4, 84, 0, 2.0f, 0.0f, "", "", "1", "", "hanxin_v84_l4_scale2.tif", "" }, + /* 19*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, 32, 0, 0.0f, 0.0f, "4BE055", "", "1", "", "aztec_v32_fg.tif", "" }, + /* 20*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0.5f, 0.0f, "", "", "F", "", "daft_height8_scale0.5.tif", "" }, + /* 21*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0.5f, 0.0f, "", "", "DAFT", "", "daft_height1_scale0.5.tif", "" }, + /* 22*/ { BARCODE_EAN8, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "", "", "9501234", "", "ean8_gss_5.2.2.2-1.tif", "" }, + /* 23*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "", "", "9501234", "", "ean8_gss_5.2.2.2-1.tif", "" }, + /* 24*/ { BARCODE_EAN8, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "", "", "9501234", "", "ean8_gss_5.2.2.2-1_gws.tif", "" }, + /* 25*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0.0f, 0.0f, "", "", "9501234", "", "ean8_gss_5.2.2.2-1_gws.tif", "" }, + /* 26*/ { BARCODE_CODE32, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.0f, 200.0f / 25.4f, "", "", "14352312", "", "code32_dpmm_200dpi.tif", "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -258,6 +260,11 @@ static void test_print(const testCtx *const p_ctx) { if (data[i].scale) { symbol->scale = data[i].scale; } + if (data[i].dpmm) { + symbol->dpmm = data[i].dpmm; + symbol->scale = ZBarcode_Scale_From_XdimDp(symbol->symbology, ZBarcode_Default_Xdim(symbol->symbology), + symbol->dpmm, "TIF"); + } if (data[i].border_width != -1) { symbol->border_width = data[i].border_width; } @@ -294,12 +301,13 @@ static void test_print(const testCtx *const p_ctx) { "i:%d testUtilDataPath == 0\n", i); if (p_ctx->generate) { - printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n", + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %d, %.5g, %.5g," + " \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, - data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour, + data[i].height, data[i].scale, data[i].dpmm, data[i].fgcolour, data[i].bgcolour, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file, data[i].comment); ret = testUtilRename(symbol->outfile, expected_file); @@ -394,12 +402,84 @@ static void test_outfile(const testCtx *const p_ctx) { testFinish(); } +#include "filemem.h" + +#ifndef NDEBUG +#define TEST_TIF_FM_TELL_NUM 4 +#else +#define TEST_TIF_FM_TELL_NUM 2 +#endif + +static void test_fm(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int output_options; + const char *data; + int ret; + int ats[5]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 5, 11, 0, 0, 0 }, 2, FM_FAIL_ID_PUTC }, + /* 1*/ { BARCODE_DATAMATRIX, BARCODE_MEMORY_FILE, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_PUTC }, + /* 2*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 3, 0, 0, 0 }, 2, FM_FAIL_ID_WRITE }, + /* 3*/ { BARCODE_DATAMATRIX, BARCODE_MEMORY_FILE, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_WRITE }, + /* 4*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 2, 3, 4, 0 }, TEST_TIF_FM_TELL_NUM, FM_FAIL_ID_TELL }, + /* 5*/ { BARCODE_DATAMATRIX, BARCODE_MEMORY_FILE, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_TELL }, + /* 6*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 2, 0, 0, 0 }, 2, FM_FAIL_ID_SEEK }, + /* 7*/ { BARCODE_DATAMATRIX, BARCODE_MEMORY_FILE, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_SEEK }, + /* 8*/ { BARCODE_DATAMATRIX, -1, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + /* 9*/ { BARCODE_DATAMATRIX, BARCODE_MEMORY_FILE, "123", ZINT_ERROR_FILE_WRITE, { 1, 0, 0, 0, 0 }, 1, FM_FAIL_ID_CLOSE }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.tif"); + ret = ZBarcode_Encode(symbol, ZCUCP(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); + + zint_test_fm_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_fm_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ { "test_pixel_plot", test_pixel_plot }, { "test_print", test_print }, { "test_outfile", test_outfile }, + { "test_fm", test_fm }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_upcean.c b/backend/tests/test_upcean.c index 124dc027..e7e39778 100644 --- a/backend/tests/test_upcean.c +++ b/backend/tests/test_upcean.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2025 Robin Stuart + Copyright (C) 2019-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -119,6 +119,8 @@ static void test_upce_input(const testCtx *const p_ctx) { /* 73*/ { BARCODE_UPCE, "000000", 0, "", "00000000" }, /* 74*/ { BARCODE_UPCE, "000001", 0, "", "00000019" }, /* 75*/ { BARCODE_UPCE, "000002", 0, "", "00000028" }, + /* 76*/ { BARCODE_UPCE, "2001234000055", ZINT_ERROR_TOO_LONG, "Error 290: Input length 13 too long (maximum 8)", "" }, + /* 77*/ { BARCODE_UPCE, "0001234000040", ZINT_ERROR_TOO_LONG, "Error 290: Input length 13 too long (maximum 8)", "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_vector.c b/backend/tests/test_vector.c index 2bd7f8ac..bc45e729 100644 --- a/backend/tests/test_vector.c +++ b/backend/tests/test_vector.c @@ -3430,6 +3430,91 @@ static void test_hrt_content_segs(const testCtx *const p_ctx) { testFinish(); } +/* TODO: add new "raster.h" & put these in it */ +#define VECT_FAIL_ID_RECT 1 +#define VECT_FAIL_ID_HEXAGON 2 +#define VECT_FAIL_ID_CIRCLE 3 +#define VECT_FAIL_ID_STR 4 +#define VECT_FAIL_ID_SUBSTR 5 +#define VECT_FAIL_ID_HDR 6 + +INTERNAL void zint_test_vector_set_fail(const int op, const int at); + +static void test_alloc(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int border_width; + int output_options; + const char *data; + int ret; + int ats[6]; + int at_cnt; + int id; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, -1, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_HDR }, + /* 1*/ { BARCODE_DATAMATRIX, -1, -1, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_RECT }, + /* 2*/ { BARCODE_DATAMATRIX, -1, BARCODE_DOTTY_MODE, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_CIRCLE }, + /* 3*/ { BARCODE_ULTRA, -1, -1, "123", ZINT_ERROR_MEMORY, { 3, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_RECT }, + /* 4*/ { BARCODE_MAXICODE, -1, -1, "123", ZINT_ERROR_MEMORY, { 5, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_HEXAGON }, + /* 5*/ { BARCODE_MAXICODE, -1, -1, "123", ZINT_ERROR_MEMORY, { 1, 2, 3, 0, 0, 0 }, 3, VECT_FAIL_ID_CIRCLE }, + /* 6*/ { BARCODE_TELEPEN, -1, -1, "AB", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_STR }, + /* 7*/ { BARCODE_TELEPEN, -1, -1, "AB", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_SUBSTR }, + /* 8*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "123456+12", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 5, 0 }, 5, VECT_FAIL_ID_STR }, + /* 9*/ { BARCODE_UPCE, -1, -1, "123456+12", ZINT_ERROR_MEMORY, { 1, 20, 0, 0, 0, 0 }, 2, VECT_FAIL_ID_RECT }, + /* 10*/ { BARCODE_EAN8, -1, EANUPC_GUARD_WHITESPACE, "123456", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 0, 0 }, 4, VECT_FAIL_ID_STR }, + /* 11*/ { BARCODE_EAN8, -1, EANUPC_GUARD_WHITESPACE, "123456+12", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 5, 0 }, 5, VECT_FAIL_ID_STR }, + /* 12*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "123456+12", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 5, 6 }, 6, VECT_FAIL_ID_STR }, + /* 13*/ { BARCODE_EAN13, -1, EANUPC_GUARD_WHITESPACE, "123456+12", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 5, 0 }, 5, VECT_FAIL_ID_STR }, + /* 14*/ { BARCODE_EAN13, -1, EANUPC_GUARD_WHITESPACE, "123456", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 0, 0 }, 4, VECT_FAIL_ID_STR }, + /* 15*/ { BARCODE_EAN_2ADDON, -1, EANUPC_GUARD_WHITESPACE, "12", ZINT_ERROR_MEMORY, { 1, 2, 0, 0, 0, 0 }, 2, VECT_FAIL_ID_STR }, + /* 16*/ { BARCODE_CODABLOCKF, -1, -1, "12", ZINT_ERROR_MEMORY, { 57, 58, 0, 0, 0, 0 }, 2, VECT_FAIL_ID_RECT }, + /* 17*/ { BARCODE_CHANNEL, 1, BARCODE_BOX, "12", ZINT_ERROR_MEMORY, { 10, 11, 12, 0, 0, 0 }, 3, VECT_FAIL_ID_RECT }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol(p_ctx->func_name, &symbol); + + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + for (j = 0; j < data[i].at_cnt; j++) { + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, + data[i].data, -1, debug); + strcpy(symbol->outfile, "out.svg"); + if (data[i].border_width != -1) { + symbol->border_width = data[i].border_width; + } + ret = ZBarcode_Encode(symbol, ZCUCP(data[i].data), length); + assert_nonzero(ret < ZINT_ERROR, "i:%d %s ZBarcode_Encode ret %d >= ZINT_ERROR %s\n", + i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt); + + zint_test_vector_set_fail(data[i].id, data[i].ats[j]); + ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); + assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n", + i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt); + ZBarcode_Reset(symbol); + } + zint_test_vector_set_fail(0, 0); + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ @@ -3449,6 +3534,7 @@ int main(int argc, char *argv[]) { { "test_height", test_height }, { "test_height_per_row", test_height_per_row }, { "test_hrt_content_segs", test_hrt_content_segs }, + { "test_alloc", test_alloc }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index b1360977..0b7ad600 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -70,6 +70,7 @@ struct zint_symbol **testAssertPPSymbol = NULL; const char *testAssertFilename = ""; static const char *testName = NULL; static const char *testFunc = NULL; +static const char *testFailedFuncs[128] = {0}; /* Visual C++ 6 doesn't support variadic args to macros, so make do with functions, which have inferior behaviour, e.g. don't exit on failure, `assert_equal()` type-specific */ @@ -167,6 +168,9 @@ void testFinish(void) { } if (testAssertFailed) { printf("FAILED. (%d assertions failed)\n", testAssertFailed); + if (testFailed < ARRAY_SIZE(testFailedFuncs)) { + testFailedFuncs[testFailed] = testFunc; + } testFailed++; } else if (testDataset) { if (testAssertNum) { @@ -206,12 +210,21 @@ void testSkip(const char *msg) { /* End test program */ void testReport(void) { + int i; if (testFailed && testSkipped) { - printf("Total %d tests, %d skipped, %d **fails**.\n", testTests, testSkipped, testFailed); + printf("Total %d tests, %d skipped, %d **fails**: ", testTests, testSkipped, testFailed); + for (i = 0; i < testFailed; i++) { + printf(i == 0 ? "%s" : ", %s", testFailedFuncs[i]); + } + fputs("\n", stdout); exit(-1); } if (testFailed) { - printf("Total %d tests, %d **fails**.\n", testTests, testFailed); + printf("Total %d tests, %d **fails**: ", testTests, testFailed); + for (i = 0; i < testFailed; i++) { + printf(i == 0 ? "%s" : ", %s", testFailedFuncs[i]); + } + fputs("\n", stdout); exit(-1); } if (testSkipped) { @@ -1640,6 +1653,18 @@ int testUtilRename(const char *oldpath, const char *newpath) { #endif } +/* Create file. Returns 1 if successful, 0 if not */ +int testUtilCreateFile(const char *filename) { + FILE *fp = testUtilOpen(filename, "w+"); + if (fp == NULL) { + return 0; + } + if (fclose(fp) != 0) { + return 0; + } + return 1; +} + /* Create read-only file. Returns 1 if successful, 0 if not */ int testUtilCreateROFile(const char *filename) { #ifdef _WIN32 @@ -2677,7 +2702,6 @@ static int supports_extra_escape_mode(const struct zint_symbol *const symbol) { && (symbol->input_mode & 0x07) != GS1_MODE); } -#define z_isxdigit(c) (z_isdigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) #define z_isodigit(c) ((c) <= '7' && (c) >= '0') /* Convert data to Ghostscript format for passing to bwipp_dump.ps */ diff --git a/backend/tests/testcommon.h b/backend/tests/testcommon.h index ca49ad0d..ddae4a93 100644 --- a/backend/tests/testcommon.h +++ b/backend/tests/testcommon.h @@ -49,6 +49,7 @@ extern "C" { #define ZINT_DEBUG_TEST_ZXINGCPP 512 #define ZINT_DEBUG_TEST_BWIPP_ZXINGCPP 1024 #define ZINT_DEBUG_TEST_AZTEC_SKIP_ALL 2048 +#define ZINT_DEBUG_TEST_PNG_FLUSH 4096 #ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positives */ #define ZINT_TESTUTIL_SANITIZEM_INIT = {0} @@ -190,6 +191,7 @@ int testUtilDirExists(const char *dirname); int testUtilMkDir(const char *dirname); int testUtilRmDir(const char *dirname); int testUtilRename(const char *oldpath, const char *newpath); +int testUtilCreateFile(const char *filename); int testUtilCreateROFile(const char *filename); int testUtilRmROFile(const char *filename); int testUtilReadFile(const char *filename, unsigned char *buffer, int buffer_size, int *p_size); diff --git a/backend/tests/tools/bwipp_dump.ps.tar.xz b/backend/tests/tools/bwipp_dump.ps.tar.xz index 4de6e205..a9cac3b4 100644 Binary files a/backend/tests/tools/bwipp_dump.ps.tar.xz and b/backend/tests/tools/bwipp_dump.ps.tar.xz differ diff --git a/backend/tests/tools/run_coverage.sh b/backend/tests/tools/run_coverage.sh new file mode 100755 index 00000000..a4a3ab0b --- /dev/null +++ b/backend/tests/tools/run_coverage.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Copyright (C) 2026 Robin Stuart +# SPDX-License-Identifier: BSD-3-Clause +# vim: set ts=4 sw=4 et : +# +# Compile zint with gcc and "-DZINT_COVERAGE=ON -DZINT_DEBUG=ON -DZINT_TEST=ON" +# Run this script in the build directory (same as ctest but with debug flag set): +# ../backend/tests/tools/run_coverage.sh +# will produce "html_report/index.html" +# +set -e + +backend/tests/test_2of5 -d 1 +backend/tests/test_auspost -d 1 +backend/tests/test_aztec -d 1 +backend/tests/test_bc412 -d 1 +backend/tests/test_big5 -d 1 +backend/tests/test_bmp -d 1 +backend/tests/test_bwipp -d 1 +backend/tests/test_channel -d 1 +backend/tests/test_codabar -d 1 +backend/tests/test_codablock -d 1 +backend/tests/test_code -d 1 +backend/tests/test_code1 -d 1 +backend/tests/test_code11 -d 1 +backend/tests/test_code128 -d 1 +backend/tests/test_code16k -d 1 +backend/tests/test_code49 -d 1 +backend/tests/test_common -d 1 +backend/tests/test_composite -d 1 +backend/tests/test_dmatrix -d 1 +backend/tests/test_dotcode -d 1 +backend/tests/test_dxfilmedge -d 1 +backend/tests/test_eci -d 1 +backend/tests/test_emf -d 1 +backend/tests/test_filemem -d 1 +backend/tests/test_gb18030 -d 1 +backend/tests/test_gb2312 -d 1 +backend/tests/test_gif -d 1 +backend/tests/test_gridmtx -d 1 +backend/tests/test_gs1 -d 1 +backend/tests/test_gs1se -d 1 +backend/tests/test_hanxin -d 1 +backend/tests/test_imail -d 1 +backend/tests/test_iso3166 -d 1 +backend/tests/test_iso4217 -d 1 +backend/tests/test_ksx1001 -d 1 +backend/tests/test_large -d 1 +backend/tests/test_library -d 1 +backend/tests/test_mailmark -d 1 +backend/tests/test_maxicode -d 1 +backend/tests/test_medical -d 1 +backend/tests/test_output -d 1 +backend/tests/test_pcx -d 1 +backend/tests/test_pdf417 -d 1 +backend/tests/test_perf -d 1 +backend/tests/test_plessey -d 1 +backend/tests/test_png -d 1 +backend/tests/test_postal -d 1 +backend/tests/test_print -d 1 +backend/tests/test_ps -d 1 +backend/tests/test_qr -d 1 +backend/tests/test_random -d 1 +backend/tests/test_raster -d 1 +backend/tests/test_reedsol -d 1 +backend/tests/test_rss -d 1 +backend/tests/test_sjis -d 1 +backend/tests/test_svg -d 1 +backend/tests/test_telepen -d 1 +backend/tests/test_tif -d 1 +backend/tests/test_ultra -d 1 +backend/tests/test_upcean -d 1 +backend/tests/test_vector -d 1 +frontend/tests/test_args +backend_qt/tests/test_qzint + +lcov --capture --directory . --output-file coverage.info --exclude 'build/*' --exclude 'usr/*' --exclude 'tests/*' +genhtml -o html_report coverage.info diff --git a/backend/tif.c b/backend/tif.c index 3d4cfc47..82d5d976 100644 --- a/backend/tif.c +++ b/backend/tif.c @@ -222,7 +222,6 @@ INTERNAL int zint_tif_pixel_plot(struct zint_symbol *symbol, const unsigned char struct filemem *const fmp = &fm; const unsigned char *pb; int compression = TIF_NO_COMPRESSION; - long file_pos; const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; uint32_t *strip_offset; uint32_t *strip_bytes; @@ -497,12 +496,23 @@ INTERNAL int zint_tif_pixel_plot(struct zint_symbol *symbol, const unsigned char /* End of strip */ if (compression == TIF_LZW) { #ifndef NDEBUG - file_pos = zint_fm_tell(fmp); + long before_file_pos, after_file_pos; + if ((before_file_pos = zint_fm_tell(fmp)) == -1L) { + (void) zint_fm_close(fmp, symbol); + return z_errtxt(ZINT_ERROR_FILE_WRITE, symbol, 671, "Failed to get file position in TIF output"); + } #endif + bytes_put = tif_lzw_compress(fmp, strip_buf, bytes_put); + #ifndef NDEBUG - assert(bytes_put == (unsigned int) (zint_fm_tell(fmp) - file_pos)); + if ((after_file_pos = zint_fm_tell(fmp)) == -1L) { + (void) zint_fm_close(fmp, symbol); + return z_errtxt(ZINT_ERROR_FILE_WRITE, symbol, 673, "Failed to get file position in TIF output"); + } + assert(bytes_put == (unsigned int) (after_file_pos - before_file_pos)); #endif + if (bytes_put != strip_bytes[strip]) { const int diff = bytes_put - strip_bytes[strip]; strip_bytes[strip] = bytes_put; @@ -528,7 +538,11 @@ INTERNAL int zint_tif_pixel_plot(struct zint_symbol *symbol, const unsigned char } if (compression == TIF_LZW) { - file_pos = zint_fm_tell(fmp); + long file_pos; + if ((file_pos = zint_fm_tell(fmp)) == -1L) { + (void) zint_fm_close(fmp, symbol); + return z_errtxt(ZINT_ERROR_FILE_WRITE, symbol, 675, "Failed to get file position in TIF output"); + } zint_fm_seek(fmp, 4, SEEK_SET); free_memory = file_pos; temp32 = (uint32_t) free_memory; diff --git a/backend/ultra.c b/backend/ultra.c index 92033570..804f265b 100644 --- a/backend/ultra.c +++ b/backend/ultra.c @@ -250,23 +250,15 @@ static int ult_find_fragment(const unsigned char source[], const int length, con static float ult_look_ahead_eightbit(const unsigned char source[], const int length, const int in_locn, const int current_mode, const int end_char, int cw[], int *cw_len, const int gs1) { int codeword_count = 0; - int i; int letters_encoded = 0; + int i; if (current_mode != ULT_EIGHTBIT_MODE) { - cw[codeword_count] = 282; /* Unlatch */ - codeword_count += 1; + cw[codeword_count++] = 282; /* Unlatch */ } - i = in_locn; - while (i < length && i < end_char) { - if (gs1 && source[i] == '\x1D') { - cw[codeword_count] = 268; /* FNC1 */ - } else { - cw[codeword_count] = source[i]; - } - i++; - codeword_count++; + for (i = in_locn; i < length && i < end_char; i++) { + cw[codeword_count++] = gs1 && source[i] == '\x1D' ? 268 /*FNC1*/ : source[i]; } letters_encoded = i - in_locn; @@ -284,28 +276,24 @@ static float ult_look_ahead_ascii(unsigned char source[], const int length, cons const int current_mode, const int symbol_mode, const int end_char, int cw[], int *cw_len, int *encoded, const int gs1) { int codeword_count = 0; - int i; - int done; int letters_encoded = 0; + int i; if (current_mode == ULT_EIGHTBIT_MODE) { - cw[codeword_count] = 267; /* Latch ASCII Submode */ - codeword_count++; + cw[codeword_count++] = 267; /* Latch ASCII Submode */ } if (current_mode == ULT_C43_MODE) { - cw[codeword_count] = 282; /* Unlatch */ - codeword_count++; + cw[codeword_count++] = 282; /* Unlatch */ if (symbol_mode == ULT_EIGHTBIT_MODE) { - cw[codeword_count] = 267; /* Latch ASCII Submode */ - codeword_count++; + cw[codeword_count++] = 267; /* Latch ASCII Submode */ } } i = in_locn; do { /* Check for double digits */ - done = 0; + int done = 0; if (i + 1 < length) { const int first_digit = z_posn(ult_digit, source[i]); const int second_digit = z_posn(ult_digit, source[i + 1]); @@ -313,32 +301,27 @@ static float ult_look_ahead_ascii(unsigned char source[], const int length, cons /* Double digit can be encoded */ if (first_digit >= 0 && first_digit <= 9 && second_digit >= 0 && second_digit <= 9) { /* Double digit numerics */ - cw[codeword_count] = (10 * first_digit) + second_digit + 128; - codeword_count++; + cw[codeword_count++] = (10 * first_digit) + second_digit + 128; i += 2; done = 1; } else if (first_digit >= 0 && first_digit <= 9 && second_digit == 10) { /* Single digit followed by selected decimal point character */ - cw[codeword_count] = first_digit + 228; - codeword_count++; + cw[codeword_count++] = first_digit + 228; i += 2; done = 1; } else if (first_digit == 10 && second_digit >= 0 && second_digit <= 9) { /* Selected decimal point character followed by single digit */ - cw[codeword_count] = second_digit + 238; - codeword_count++; + cw[codeword_count++] = second_digit + 238; i += 2; done = 1; } else if (first_digit >= 0 && first_digit <= 9 && second_digit == 11) { /* Single digit or decimal point followed by field deliminator */ - cw[codeword_count] = first_digit + 248; - codeword_count++; + cw[codeword_count++] = first_digit + 248; i += 2; done = 1; } else if (first_digit == 11 && second_digit >= 0 && second_digit <= 9) { /* Field deliminator followed by single digit or decimal point */ - cw[codeword_count] = second_digit + 259; - codeword_count++; + cw[codeword_count++] = second_digit + 259; i += 2; done = 1; } @@ -346,12 +329,7 @@ static float ult_look_ahead_ascii(unsigned char source[], const int length, cons } if (!done && z_isascii(source[i])) { - if (gs1 && source[i] == '\x1D') { - cw[codeword_count] = 272; /* FNC1 */ - } else { - cw[codeword_count] = source[i]; - } - codeword_count++; + cw[codeword_count++] = gs1 && source[i] == '\x1D' ? 272 /*FNC1*/ : source[i]; i++; } } while (i < length && i < end_char && z_isascii(source[i])); @@ -467,53 +445,43 @@ static float ult_look_ahead_c43(const unsigned char source[], const int length, switch (fragno) { case 17: /* mailto: */ - cw[codeword_count] = 276; + cw[codeword_count++] = 276; sublocn += (int) strlen(ult_fragment[fragno]); - codeword_count++; break; case 18: /* tel: */ - cw[codeword_count] = 277; + cw[codeword_count++] = 277; sublocn += (int) strlen(ult_fragment[fragno]); - codeword_count++; break; case 26: /* file: */ - cw[codeword_count] = 278; + cw[codeword_count++] = 278; sublocn += (int) strlen(ult_fragment[fragno]); - codeword_count++; break; case 0: /* http:// */ - cw[codeword_count] = 279; + cw[codeword_count++] = 279; sublocn += (int) strlen(ult_fragment[fragno]); - codeword_count++; break; case 1: /* https:// */ - cw[codeword_count] = 280; + cw[codeword_count++] = 280; sublocn += (int) strlen(ult_fragment[fragno]); - codeword_count++; break; case 4: /* ftp:// */ - cw[codeword_count] = 281; + cw[codeword_count++] = 281; sublocn += (int) strlen(ult_fragment[fragno]); - codeword_count++; break; default: if (subset == 1) { - cw[codeword_count] = 260; /* C43 Compaction Submode C1 */ - codeword_count++; + cw[codeword_count++] = 260; /* C43 Compaction Submode C1 */ } else if (subset == 2 || subset == 3) { - cw[codeword_count] = 266; /* C43 Compaction Submode C2 */ - codeword_count++; + cw[codeword_count++] = 266; /* C43 Compaction Submode C2 */ } break; } } else if (current_mode == ULT_ASCII_MODE) { if (subset == 1) { - cw[codeword_count] = 278; /* C43 Compaction Submode C1 */ - codeword_count++; + cw[codeword_count++] = 278; /* C43 Compaction Submode C1 */ } else if (subset == 2 || subset == 3) { - cw[codeword_count] = 280; /* C43 Compaction Submode C2 */ - codeword_count++; + cw[codeword_count++] = 280; /* C43 Compaction Submode C2 */ } } unshift_set = subset; @@ -532,14 +500,11 @@ static float ult_look_ahead_c43(const unsigned char source[], const int length, if (new_subset != subset && (new_subset == 1 || new_subset == 2)) { if (ult_c43_should_latch_other(source, length, sublocn, subset)) { - subcw[subcodeword_count] = 42; /* Latch to other C43 set */ - subcodeword_count++; + subcw[subcodeword_count++] = 42; /* Latch to other C43 set */ unshift_set = new_subset; } else { - subcw[subcodeword_count] = 40; /* Shift to other C43 set for 1 char */ - subcodeword_count++; - subcw[subcodeword_count] = z_posn(new_subset == 1 ? ult_c43_set1 : ult_c43_set2, source[sublocn]); - subcodeword_count++; + subcw[subcodeword_count++] = 40; /* Shift to other C43 set for 1 char */ + subcw[subcodeword_count++] = z_posn(new_subset == 1 ? ult_c43_set1 : ult_c43_set2, source[sublocn]); sublocn++; continue; } @@ -548,32 +513,26 @@ static float ult_look_ahead_c43(const unsigned char source[], const int length, subset = new_subset; if (subset == 1) { - subcw[subcodeword_count] = z_posn(ult_c43_set1, source[sublocn]); - subcodeword_count++; + subcw[subcodeword_count++] = z_posn(ult_c43_set1, source[sublocn]); sublocn++; } else if (subset == 2) { - subcw[subcodeword_count] = z_posn(ult_c43_set2, source[sublocn]); - subcodeword_count++; + subcw[subcodeword_count++] = z_posn(ult_c43_set2, source[sublocn]); sublocn++; } else if (subset == 3) { - subcw[subcodeword_count] = 41; /* Shift to set 3 */ - subcodeword_count++; + subcw[subcodeword_count++] = 41; /* Shift to set 3 */ fragno = ult_find_fragment(source, length, sublocn); if (fragno != -1 && fragno != 26) { if (fragno <= 18) { - subcw[subcodeword_count] = fragno; /* C43 Set 3 codewords 0 to 18 */ - subcodeword_count++; + subcw[subcodeword_count++] = fragno; /* C43 Set 3 codewords 0 to 18 */ sublocn += (int) strlen(ult_fragment[fragno]); } else { - subcw[subcodeword_count] = fragno + 17; /* C43 Set 3 codewords 36 to 42 */ - subcodeword_count++; + subcw[subcodeword_count++] = fragno + 17; /* C43 Set 3 codewords 36 to 42 */ sublocn += (int) strlen(ult_fragment[fragno]); } } else { /* C43 Set 3 codewords 19 to 35 */ - subcw[subcodeword_count] = z_posn(ult_c43_set3, source[sublocn]) + 19; - subcodeword_count++; + subcw[subcodeword_count++] = z_posn(ult_c43_set3, source[sublocn]) + 19; sublocn++; } subset = unshift_set; @@ -586,8 +545,7 @@ static float ult_look_ahead_c43(const unsigned char source[], const int length, } for (i = 0; i < pad; i++) { - subcw[subcodeword_count] = 42; /* Latch to other C43 set used as pad */ - subcodeword_count++; + subcw[subcodeword_count++] = 42; /* Latch to other C43 set used as pad */ } if (debug_print) { @@ -603,10 +561,8 @@ static float ult_look_ahead_c43(const unsigned char source[], const int length, for (i = 0; i < subcodeword_count; i += 3) { base43_value = (43 * 43 * subcw[i]) + (43 * subcw[i + 1]) + subcw[i + 2]; - cw[codeword_count] = base43_value / 282; - codeword_count++; - cw[codeword_count] = base43_value % 282; - codeword_count++; + cw[codeword_count++] = base43_value / 282; + cw[codeword_count++] = base43_value % 282; } *cw_len = codeword_count; @@ -796,7 +752,7 @@ static int ult_generate_codewords(struct zint_symbol *symbol, const unsigned cha /* Call `ult_generate_codewords()` for each segment, dealing with symbol mode and start codeword beforehand */ static int ult_generate_codewords_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, - int codewords[], int *p_data_cw_count) { + int codewords[]) { int i; int codeword_count = 0; int symbol_mode; @@ -926,13 +882,11 @@ static int ult_generate_codewords_segs(struct zint_symbol *symbol, struct zint_s } } - *p_data_cw_count = codeword_count; - - return 0; + return codeword_count; } INTERNAL int zint_ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) { - int data_cw_count = 0; + int data_cw_count; int acc, qcc; int scr[3] = {0}, scr_cw_count = 0; /* Symbol Control Region (only if have Structured Append) */ int dr_count; @@ -1008,9 +962,7 @@ INTERNAL int zint_ultra(struct zint_symbol *symbol, struct zint_seg segs[], cons data_codewords = (int *) z_alloca(sizeof(int) * cw_alloc); - if (ult_generate_codewords_segs(symbol, segs, seg_count, data_codewords, &data_cw_count)) { - return ZINT_ERROR_MEMORY; /* `ult_generate_codewords_segs()` only returns non-zero if OOM */ - } + data_cw_count = ult_generate_codewords_segs(symbol, segs, seg_count, data_codewords); if (debug_print) { printf("Codewords (%d):", data_cw_count); diff --git a/backend/upcean.c b/backend/upcean.c index b0d6930f..ebf17efb 100644 --- a/backend/upcean.c +++ b/backend/upcean.c @@ -559,9 +559,7 @@ static int isbnx(struct zint_symbol *symbol, unsigned char source[], const int l char check_digit; z_to_upper(source, length); - if (z_not_sane(ISBNX_SANE_F, source, length)) { /* As source has been zero-padded, don't report position */ - return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 277, "Invalid character in input (digits and \"X\" only)"); - } + assert(!z_not_sane(ISBNX_SANE_F, source, length)); /* Prior checks ensure this */ /* Input must be 9, 10 or 13 characters */ if (length != 9 && length != 10 && length != 13) { @@ -942,6 +940,9 @@ INTERNAL int zint_eanx_cc(struct zint_symbol *symbol, unsigned char source[], in case BARCODE_EANX: case BARCODE_EANX_CHK: case BARCODE_EAN13: + /* Checks in `zint_ean_leading_zeroes()` ensure following */ + assert(first_part_len == 2 || first_part_len == 5 || first_part_len == 7 || first_part_len == 8 + || first_part_len == 12 || first_part_len == 13); switch (first_part_len) { case 2: case 5: @@ -963,18 +964,15 @@ INTERNAL int zint_eanx_cc(struct zint_symbol *symbol, unsigned char source[], in case 13: error_number = ean13(symbol, first_part, first_part_len, dest); break; - default: - assert(symbol->symbology == BARCODE_EANX || symbol->symbology == BARCODE_EANX_CHK); - return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 286, - "Input length %d wrong (2, 5, 7, 8, 12 or 13 characters required)", - first_part_len); - break; } break; case BARCODE_EANX_CC: case BARCODE_EAN8_CC: case BARCODE_EAN13_CC: - switch (first_part_len) { /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */ + /* Checks in `zint_ean_leading_zeroes()` ensure following */ + assert(first_part_len == 7 || first_part_len == 8 || first_part_len == 12 || first_part_len == 13); + switch (first_part_len) { + /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */ case 7: case 8: z_set_module(symbol, symbol->rows, 1); @@ -1003,11 +1001,6 @@ INTERNAL int zint_eanx_cc(struct zint_symbol *symbol, unsigned char source[], in symbol->rows += 3; error_number = ean13_cc(symbol, first_part, first_part_len, dest, cc_rows); break; - default: - assert(symbol->symbology == BARCODE_EANX_CC); - return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 287, - "Input length %d wrong (7, 12 or 13 characters required)", first_part_len); - break; } break; case BARCODE_UPCA: diff --git a/backend/vector.c b/backend/vector.c index 00e4623d..62388168 100644 --- a/backend/vector.c +++ b/backend/vector.c @@ -36,6 +36,43 @@ #include "output.h" #include "zfiletypes.h" +#ifdef ZINT_TEST +/* For testing `malloc()` failure */ + +static int vector_fail_id = 0; /* VECT_FAIL_ID_XXX below */ +static int vector_fail_at = 0; /* Number of times before failure */ + +INTERNAL void zint_test_vector_set_fail(const int id, const int at) { + vector_fail_id = id; + vector_fail_at = at; +} + +/* TODO: add new "vector.h" & put these in it */ +#define VECT_FAIL_ID_RECT 1 +#define VECT_FAIL_ID_HEXAGON 2 +#define VECT_FAIL_ID_CIRCLE 3 +#define VECT_FAIL_ID_STR 4 +#define VECT_FAIL_ID_SUBSTR 5 +#define VECT_FAIL_ID_HDR 6 + +#define vect_malloc(id, sz) (vector_fail_at > 0 && vector_fail_id == (id) && --vector_fail_at == 0 \ + ? NULL : malloc(sz)) + +#define vect_malloc_rect(sz) vect_malloc(VECT_FAIL_ID_RECT, sz) +#define vect_malloc_hexagon(sz) vect_malloc(VECT_FAIL_ID_HEXAGON, sz) +#define vect_malloc_circle(sz) vect_malloc(VECT_FAIL_ID_CIRCLE, sz) +#define vect_malloc_str(sz) vect_malloc(VECT_FAIL_ID_STR, sz) +#define vect_malloc_substr(sz) vect_malloc(VECT_FAIL_ID_SUBSTR, sz) +#define vect_malloc_hdr(sz) vect_malloc(VECT_FAIL_ID_HDR, sz) +#else +#define vect_malloc_rect(sz) malloc(sz) +#define vect_malloc_hexagon(sz) malloc(sz) +#define vect_malloc_circle(sz) malloc(sz) +#define vect_malloc_str(sz) malloc(sz) +#define vect_malloc_substr(sz) malloc(sz) +#define vect_malloc_hdr(sz) malloc(sz) +#endif + INTERNAL int zint_ps_plot(struct zint_symbol *symbol); INTERNAL int zint_svg_plot(struct zint_symbol *symbol); INTERNAL int zint_emf_plot(struct zint_symbol *symbol, int rotate_angle); @@ -49,7 +86,7 @@ static int vector_add_rect(struct zint_symbol *symbol, const float x, const floa assert(width >= 0.0f); assert(height >= 0.0f); - if (!(rect = (struct zint_vector_rect *) malloc(sizeof(struct zint_vector_rect)))) { + if (!(rect = (struct zint_vector_rect *) vect_malloc_rect(sizeof(struct zint_vector_rect)))) { /* NOTE: clang-tidy-20 gets confused about return value of function returning a function unfortunately, so put on 2 lines (see also "postal.c" `postnet_enc()` & `planet_enc()`, same issue) */ z_errtxt(0, symbol, 691, "Insufficient memory for vector rectangle"); @@ -84,7 +121,7 @@ static int vector_add_hexagon(struct zint_symbol *symbol, const float x, const f assert(y >= 0.0f); assert(diameter >= 0.0f); - if (!(hexagon = (struct zint_vector_hexagon *) malloc(sizeof(struct zint_vector_hexagon)))) { + if (!(hexagon = (struct zint_vector_hexagon *) vect_malloc_hexagon(sizeof(struct zint_vector_hexagon)))) { return z_errtxt(0, symbol, 692, "Insufficient memory for vector hexagon"); } #ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */ @@ -107,7 +144,7 @@ static int vector_add_hexagon(struct zint_symbol *symbol, const float x, const f } static int vector_add_circle(struct zint_symbol *symbol, const float x, const float y, const float diameter, - const float width, const int colour, struct zint_vector_circle **last_circle) { + const float width, struct zint_vector_circle **last_circle) { struct zint_vector_circle *circle; assert(x >= 0.0f); @@ -115,7 +152,7 @@ static int vector_add_circle(struct zint_symbol *symbol, const float x, const fl assert(diameter >= 0.0f); assert(width >= 0.0f); - if (!(circle = (struct zint_vector_circle *) malloc(sizeof(struct zint_vector_circle)))) { + if (!(circle = (struct zint_vector_circle *) vect_malloc_circle(sizeof(struct zint_vector_circle)))) { return z_errtxt(0, symbol, 693, "Insufficient memory for vector circle"); } #ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */ @@ -126,7 +163,7 @@ static int vector_add_circle(struct zint_symbol *symbol, const float x, const fl circle->y = y; circle->diameter = diameter; circle->width = width; - circle->colour = colour; + circle->colour = 0; /* Legacy (was zero for draw with foreground colour (else draw with background colour) */ if (*last_circle) (*last_circle)->next = circle; @@ -147,7 +184,7 @@ static int vector_add_string(struct zint_symbol *symbol, const unsigned char *te assert(y >= 0.0f); assert(width >= 0.0f); - if (!(string = (struct zint_vector_string *) malloc(sizeof(struct zint_vector_string)))) { + if (!(string = (struct zint_vector_string *) vect_malloc_str(sizeof(struct zint_vector_string)))) { return z_errtxt(0, symbol, 694, "Insufficient memory for vector string"); } #ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */ @@ -161,7 +198,7 @@ static int vector_add_string(struct zint_symbol *symbol, const unsigned char *te string->length = length == -1 ? (int) z_ustrlen(text) : length; string->rotation = 0; string->halign = halign; - if (!(string->text = (unsigned char *) malloc(string->length + 1))) { + if (!(string->text = (unsigned char *) vect_malloc_substr(string->length + 1))) { free(string); return z_errtxt(0, symbol, 695, "Insufficient memory for vector string text"); } @@ -478,7 +515,7 @@ INTERNAL int zint_plot_vector(struct zint_symbol *symbol, int rotate_angle, int } /* Allocate memory */ - if (!(vector = symbol->vector = (struct zint_vector *) malloc(sizeof(struct zint_vector)))) { + if (!(vector = symbol->vector = (struct zint_vector *) vect_malloc_hdr(sizeof(struct zint_vector)))) { return z_errtxt(ZINT_ERROR_MEMORY, symbol, 696, "Insufficient memory for vector header"); } #ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */ @@ -562,9 +599,7 @@ INTERNAL int zint_plot_vector(struct zint_symbol *symbol, int rotate_angle, int if (addon_len && large_bar_height + textoffset - (font_height + text_gap_antialias) < 1.0f) { addon_min_row_height = 1.0f - (large_bar_height + textoffset - (font_height + text_gap_antialias)); - if (addon_min_row_height > 1.0f) { - addon_min_row_height = 1.0f; - } + assert(addon_min_row_height <= 1.0f); /* Due to checks above */ } vector->height = symbol->height + textoffset + addon_min_row_height + dot_overspill + (yoffset + boffset); @@ -593,15 +628,15 @@ INTERNAL int zint_plot_vector(struct zint_symbol *symbol, int rotate_angle, int bull_d_incr = (hex_diameter * 9 - hex_ydiameter) / 5.0f; bull_width = bull_d_incr / 2.0f; - if (!vector_add_circle(symbol, bull_x, bull_y, hex_ydiameter + bull_d_incr * 5 - bull_width, bull_width, 0, + if (!vector_add_circle(symbol, bull_x, bull_y, hex_ydiameter + bull_d_incr * 5 - bull_width, bull_width, &last_circle)) { return ZINT_ERROR_MEMORY; } - if (!vector_add_circle(symbol, bull_x, bull_y, hex_ydiameter + bull_d_incr * 3 - bull_width, bull_width, 0, + if (!vector_add_circle(symbol, bull_x, bull_y, hex_ydiameter + bull_d_incr * 3 - bull_width, bull_width, &last_circle)) { return ZINT_ERROR_MEMORY; } - if (!vector_add_circle(symbol, bull_x, bull_y, hex_ydiameter + bull_d_incr - bull_width, bull_width, 0, + if (!vector_add_circle(symbol, bull_x, bull_y, hex_ydiameter + bull_d_incr - bull_width, bull_width, &last_circle)) { return ZINT_ERROR_MEMORY; } @@ -626,7 +661,7 @@ INTERNAL int zint_plot_vector(struct zint_symbol *symbol, int rotate_angle, int for (i = 0; i < symbol->width; i++) { if (z_module_is_set(symbol, r, i)) { if (!vector_add_circle(symbol, i + dot_offset + xoffset, r + dot_offset + yoffset, - symbol->dot_size, 0, 0, &last_circle)) { + symbol->dot_size, 0 /*diameter*/, &last_circle)) { return ZINT_ERROR_MEMORY; } } @@ -666,9 +701,7 @@ INTERNAL int zint_plot_vector(struct zint_symbol *symbol, int rotate_angle, int if (r == symbol->rows - 1 && i > main_width && addon_latch == 0) { addon_text_yposn = yposn + font_height - digit_ascender; - if (addon_text_yposn < 0.0f) { - addon_text_yposn = 0.0f; - } + assert(addon_text_yposn >= 0.0f); addon_row_yposn = yposn + font_height + text_gap_antialias; addon_row_height = row_height - (addon_row_yposn - yposn); /* Following ISO/IEC 15420:2009 Figure 5 — UPC-A bar code symbol with 2-digit add-on (contrary to diff --git a/backend/zint.h b/backend/zint.h index 27eef85f..bec95839 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -77,7 +77,7 @@ extern "C" { float x, y; /* Centre */ float diameter; /* Circle diameter. Does not include width (if any) */ float width; /* Width of circle perimeter (circumference). 0 for fill (disc) */ - int colour; /* Zero for draw with foreground colour (else draw with background colour (legacy)) */ + int colour; /* Legacy, no longer used (set to 0) */ struct zint_vector_circle *next; /* Pointer to next circle */ }; @@ -366,7 +366,6 @@ extern "C" { #define ZINT_CAP_HRT 0x0001 /* Prints Human Readable Text? */ #define ZINT_CAP_STACKABLE 0x0002 /* Is stackable? */ #define ZINT_CAP_EANUPC 0x0004 /* Is EAN/UPC? */ -#define ZINT_CAP_EXTENDABLE 0x0004 /* Legacy */ #define ZINT_CAP_COMPOSITE 0x0008 /* Can have composite data? */ #define ZINT_CAP_ECI 0x0010 /* Supports Extended Channel Interpretations? */ #define ZINT_CAP_GS1 0x0020 /* Supports GS1 data? */ @@ -380,6 +379,9 @@ extern "C" { #define ZINT_CAP_COMPLIANT_HEIGHT 0x2000 /* Has compliant height? */ #define ZINT_CAP_BINDABLE 0x4000 /* Can set row separators? */ +/* Legacy capability flag name */ +#define ZINT_CAP_EXTENDABLE ZINT_CAP_EANUPC + /* The largest amount of data that can be encoded is 4350 4-byte UTF-8 chars in Han Xin Code */ #define ZINT_MAX_DATA_LEN 17400 /* Maximum number of segments allowed for (`seg_count`) */ diff --git a/backend_qt/qzint.cpp b/backend_qt/qzint.cpp index 5361fa2e..0665553e 100644 --- a/backend_qt/qzint.cpp +++ b/backend_qt/qzint.cpp @@ -125,25 +125,6 @@ namespace Zint { return color; } - /* Helper to convert ECI combo index to ECI value */ - static int ECIIndexToECI(const int ECIIndex) { - int ret; - if (ECIIndex >= 1 && ECIIndex <= 11) { - ret = ECIIndex + 2; - } else if (ECIIndex >= 12 && ECIIndex <= 15) { - ret = ECIIndex + 3; - } else if (ECIIndex >= 16 && ECIIndex <= 31) { - ret = ECIIndex + 4; - } else if (ECIIndex == 32) { - ret = 170; /* ISO 646 Invariant */ - } else if (ECIIndex == 33) { - ret = 899; /* 8-bit binary data */ - } else { - ret = 0; - } - return ret; - } - /* Helper to calculate max right and bottom of elements for fudging `render()` */ static void getMaxRectsRightBottom(struct zint_vector *vector, int &maxRight, int &maxBottom) { struct zint_vector_rect *rect; @@ -184,7 +165,8 @@ namespace Zint { /* Segment constructors */ QZintSeg::QZintSeg() : m_eci(0) {} - QZintSeg::QZintSeg(const QString& text, const int ECIIndex) : m_text(text), m_eci(ECIIndexToECI(ECIIndex)) {} + QZintSeg::QZintSeg(const QString& text, const int ECIIndex) + : m_text(text), m_eci(QZint::ECIIndexToECIValue(ECIIndex)) {} QZint::QZint() : m_zintSymbol(nullptr), m_symbol(BARCODE_CODE128), m_input_mode(UNICODE_MODE), @@ -224,6 +206,7 @@ namespace Zint { ZBarcode_Delete(m_zintSymbol); } + /* private: Reset the symbol structure for encoding using member fields */ bool QZint::resetSymbol() { m_error = 0; m_lastError.clear(); @@ -302,6 +285,7 @@ namespace Zint { return true; } + /* private: `ZBarcode_Encode_and_Buffer_Vector()` or `ZBarcode_Encode_Segs_and_Buffer_Vector()` */ void QZint::encode() { if (resetSymbol()) { if (m_segs.empty()) { @@ -344,6 +328,49 @@ namespace Zint { } } + /* private: Helper to convert `m_segs` to `struct zint_seg[]` */ + int QZint::convertSegs(struct zint_seg segs[], std::vector& bstrs) { + bstrs.reserve(m_segs.size()); + int i; + for (i = 0; i < (int) m_segs.size() && i < maxSegs && !m_segs[i].m_text.isEmpty(); i++) { + segs[i].eci = m_segs[i].m_eci; + bstrs.push_back(m_segs[i].m_text.toUtf8()); + segs[i].source = (unsigned char *) bstrs.back().data(); + segs[i].length = (int) bstrs.back().length(); + } + return i; + } + + /* private: static: Convert `zint_vector_rect->colour` to Qt color */ + Qt::GlobalColor QZint::colourToQtColor(int colour) { + switch (colour) { + case 1: // Cyan + return Qt::cyan; + break; + case 2: // Blue + return Qt::blue; + break; + case 3: // Magenta + return Qt::magenta; + break; + case 4: // Red + return Qt::red; + break; + case 5: // Yellow + return Qt::yellow; + break; + case 6: // Green + return Qt::green; + break; + case 8: // White + return Qt::white; + break; + default: + return Qt::black; + break; + } + } + /* Symbology to use (see BARCODE_XXX) */ int QZint::symbol() const { return m_symbol; @@ -577,6 +604,13 @@ namespace Zint { } } + void QZint::setBorderTypeValue(int borderType) { // Sets literal value + if (borderType != BARCODE_BIND && borderType != BARCODE_BOX && borderType != BARCODE_BIND_TOP) { + borderType = 0; + } + m_borderType = borderType; + } + /* Size of border in X-dimensions */ int QZint::borderWidth() const { return m_borderWidth; @@ -721,7 +755,7 @@ namespace Zint { } void QZint::setECI(int ECIIndex) { // Sets from comboBox index - m_eci = ECIIndexToECI(ECIIndex); + m_eci = ECIIndexToECIValue(ECIIndex); } void QZint::setECIValue(int eci) { // Sets literal value @@ -849,6 +883,14 @@ namespace Zint { return m_encodedOption3; } + int QZint::encodedInputMode() const { // Read-only, `input_mode` + return m_input_mode; + } + + int QZint::encodedOutputOptions() const { // Read-only, `output_options` + return m_zintSymbol->output_options; + } + /* Legacy property getters/setters */ void QZint::setWidth(int width) { setOption2(width); } int QZint::width() const { return m_option_2; } @@ -941,7 +983,7 @@ namespace Zint { break; default: return (symbology >= BARCODE_EANX_CC && symbology <= BARCODE_DBAR_EXPSTK_CC) - || symbology == BARCODE_EAN8_CC || symbology == BARCODE_EAN13_CC; + || symbology == BARCODE_EAN8_CC || symbology == BARCODE_EAN13_CC; break; } } @@ -961,6 +1003,7 @@ namespace Zint { return m_lastError.length(); } + /* Encode and print barcode to file `filename`. Only sets `getError()` on error, not on warning */ bool QZint::save_to_file(const QString& filename) { if (resetSymbol()) { cpy_bytearray_left(m_zintSymbol->outfile, filename.toUtf8(), ARRAY_SIZE(m_zintSymbol->outfile) - 1); @@ -985,6 +1028,8 @@ namespace Zint { return true; } + /* Encode and print barcode to memory file `filename` (only the extension is used, to determine output format). + Only sets `getError()` on error, not on warning */ bool QZint::save_to_memfile(const QString& filename, QByteArray& data) { if (resetSymbol()) { m_zintSymbol->output_options |= BARCODE_MEMORY_FILE; @@ -1012,49 +1057,6 @@ namespace Zint { return true; } - /* Convert `zint_vector_rect->colour` to Qt color */ - Qt::GlobalColor QZint::colourToQtColor(int colour) { - switch (colour) { - case 1: // Cyan - return Qt::cyan; - break; - case 2: // Blue - return Qt::blue; - break; - case 3: // Magenta - return Qt::magenta; - break; - case 4: // Red - return Qt::red; - break; - case 5: // Yellow - return Qt::yellow; - break; - case 6: // Green - return Qt::green; - break; - case 8: // White - return Qt::white; - break; - default: - return Qt::black; - break; - } - } - - /* Helper to convert `m_segs` to `struct zint_seg[]` */ - int QZint::convertSegs(struct zint_seg segs[], std::vector& bstrs) { - bstrs.reserve(m_segs.size()); - int i; - for (i = 0; i < (int) m_segs.size() && i < maxSegs && !m_segs[i].m_text.isEmpty(); i++) { - segs[i].eci = m_segs[i].m_eci; - bstrs.push_back(m_segs[i].m_text.toUtf8()); - segs[i].source = (unsigned char *) bstrs.back().data(); - segs[i].length = (int) bstrs.back().length(); - } - return i; - } - /* Encode and display barcode in `paintRect` using `painter`. Note: legacy argument `mode` is not used */ void QZint::render(QPainter& painter, const QRectF& paintRect, AspectRatioMode /*mode*/) { @@ -1276,7 +1278,45 @@ namespace Zint { return true; } - /* Return the BARCODE_XXX name of `symbology` */ + /* static: Convert literal ECI to ECI combobox index */ + int QZint::ECIValueToECIIndex(const int eci) { + int ret; + if (eci >= 3 && eci <= 13) { + ret = eci - 2; + } else if (eci >= 15 && eci <= 18) { + ret = eci - 3; + } else if (eci >= 20 && eci <= 35) { + ret = eci - 4; + } else if (eci == 170) { + ret = 32; + } else if (eci == 899) { + ret = 33; + } else { + ret = 0; + } + return ret; + } + + /* static: Convert ECI combo index to literal ECI */ + int QZint::ECIIndexToECIValue(const int ECIIndex) { + int ret; + if (ECIIndex >= 1 && ECIIndex <= 11) { + ret = ECIIndex + 2; + } else if (ECIIndex >= 12 && ECIIndex <= 15) { + ret = ECIIndex + 3; + } else if (ECIIndex >= 16 && ECIIndex <= 31) { + ret = ECIIndex + 4; + } else if (ECIIndex == 32) { + ret = 170; /* ISO 646 Invariant */ + } else if (ECIIndex == 33) { + ret = 899; /* 8-bit binary data */ + } else { + ret = 0; + } + return ret; + } + + /* static: Return the BARCODE_XXX name of `symbology` */ QString QZint::barcodeName(const int symbology) { char buf[32]; if (ZBarcode_BarcodeName(symbology, buf) == 0) { @@ -1285,17 +1325,17 @@ namespace Zint { return QSEmpty; } - /* Whether Zint library "libzint" built with PNG support or not */ + /* static: Whether Zint library "libzint" built with PNG support or not */ bool QZint::noPng() { return ZBarcode_NoPng() == 1; } - /* Whether Zint library "libzint" built with PNG support or not */ + /* static: Whether Zint library "libzint" built with PNG support or not */ bool QZint::haveGS1SyntaxEngine() { return ZBarcode_HaveGS1SyntaxEngine() == 1; } - /* Version of Zint library "libzint" linked to */ + /* static: Version of Zint library "libzint" linked to */ int QZint::getVersion() { return ZBarcode_Version(); } @@ -1545,7 +1585,7 @@ namespace Zint { return cmd; } - /* `getAsCLI()` helpers */ + /* private: static: `getAsCLI()` helpers */ void QZint::arg_str(QString& cmd, const char *const opt, const QString& val) { if (!val.isEmpty()) { QByteArray bstr = val.toUtf8(); @@ -1553,18 +1593,21 @@ namespace Zint { } } + /* private: static: */ void QZint::arg_int(QString& cmd, const char *const opt, const int val, const bool allowZero) { if (val > 0 || (val == 0 && allowZero)) { cmd += QString::asprintf(" %s%d", opt, val); } } + /* private: static: */ void QZint::arg_bool(QString& cmd, const char *const opt, const bool val) { if (val) { cmd += QString::asprintf(" %s", opt); } } + /* private: static: */ void QZint::arg_data(QString& cmd, const char *const opt, const QString& val, const bool win) { if (!val.isEmpty()) { QString text(val); @@ -1572,12 +1615,14 @@ namespace Zint { } } + /* private: static: */ void QZint::arg_seg(QString& cmd, const int seg_no, const QZintSeg& val, const bool win) { QString text(val.m_text); QString opt = QString::asprintf("--seg%d=%d,", seg_no, val.m_eci); arg_data_esc(cmd, opt.toUtf8(), text, win); } + /* private: static: */ void QZint::arg_data_esc(QString& cmd, const char *const opt, QString& text, const bool win) { const char delim = win ? '"' : '\''; if (win) { @@ -1594,12 +1639,14 @@ namespace Zint { } } + /* private: static: */ void QZint::arg_float(QString& cmd, const char *const opt, const float val, const bool allowZero) { if (val > 0 || (val == 0 && allowZero)) { cmd += QString::asprintf(" %s%g", opt, val); } } + /* private: static: */ void QZint::arg_structapp(QString& cmd, const char *const opt, const int count, const int index, const QString& id, const bool win) { if (count >= 2 && index >= 1) { @@ -1613,6 +1660,7 @@ namespace Zint { } } + /* private: static: */ void QZint::arg_scalexdimdp(QString& cmd, const char *const opt, const float scale, const float dpmm, const int symbol, const QZintXdimDpVars *xdimdpVars) { if (dpmm) { @@ -1635,7 +1683,7 @@ namespace Zint { } } - /* Helper to return "GIF"/"SVG"(/"EMF") if `msg` false, "raster"/"vector"(/"EMF") otherwise + /* static: Helper to return "GIF"/"SVG"(/"EMF") if `msg` false, "raster"/"vector"(/"EMF") otherwise (EMF only if `symbol` is MaxiCode) */ const char *QZintXdimDpVars::getFileType(int symbol, const struct QZintXdimDpVars *vars, bool msg) { static const char *filetypes[3] = { "GIF", "SVG", "EMF" }; @@ -1643,8 +1691,9 @@ namespace Zint { if (!vars) return ""; - const int idx = std::max(std::min(symbol == BARCODE_MAXICODE ? vars->filetype_maxicode - : vars->filetype, 2), 0); + const int filetype = symbol == BARCODE_MAXICODE ? vars->filetype_maxicode : vars->filetype; + const int max = symbol == BARCODE_MAXICODE ? 2 : 1; + const int idx = std::max(std::min(filetype, max), 0); return msg ? msg_types[idx] : filetypes[idx]; } } /* namespace Zint */ diff --git a/backend_qt/qzint.h b/backend_qt/qzint.h index 294b0363..f4741a83 100644 --- a/backend_qt/qzint.h +++ b/backend_qt/qzint.h @@ -146,7 +146,8 @@ public: /* Type of border above/below/around barcode */ int borderType() const; // `symbol->output_options | BARCODE_BIND | BARCODE_BOX | BARCODE_BIND_TOP` - void setBorderType(int borderTypeIndex); + void setBorderType(int borderTypeIndex); // Sets from comboBox index + void setBorderTypeValue(int borderType); // Sets literal value /* Size of border in X-dimensions */ int borderWidth() const; // `symbol->border_width` @@ -246,6 +247,8 @@ public: int encodedOption1() const; // Read-only, encoded `option_1` int encodedOption2() const; // Read-only, encoded `option_2` int encodedOption3() const; // Read-only, encoded `option_3` + int encodedInputMode() const; // Read-only, `input_mode` + int encodedOutputOptions() const; // Read-only, `output_options` /* Legacy property getters/setters */ @@ -323,6 +326,12 @@ public: bool getWidthHeightXdim(float x_dim, float &width_x_dim, float &height_x_dim) const; + /* Convert literal ECI to ECI combobox index */ + static int ECIValueToECIIndex(const int eci); + + /* Convert ECI combo index to literal ECI */ + static int ECIIndexToECIValue(const int ECIIndex); + /* Return the BARCODE_XXX name of `symbology` */ static QString barcodeName(const int symbology); // `ZBarcode_BarcodeName()` diff --git a/backend_qt/tests/test_qzint.cpp b/backend_qt/tests/test_qzint.cpp index 9a8f5ef2..ea90c146 100644 --- a/backend_qt/tests/test_qzint.cpp +++ b/backend_qt/tests/test_qzint.cpp @@ -94,8 +94,7 @@ private slots: std::vector segs; for (int i = 0; i < (int) segTexts.size(); i++) { - segs.push_back(Zint::QZintSeg(segTexts[i])); - segs.back().m_eci = segECIs[i]; + segs.push_back({segTexts[i], Zint::QZint::ECIValueToECIIndex(segECIs[i])}); } bc.setSegs(segs); @@ -191,11 +190,16 @@ private slots: for (int i = 0; i < ARRAY_SIZE(borderTypes); i++) { bc.setBorderType(i); QCOMPARE(bc.borderType(), borderTypes[i]); + + bc.setBorderTypeValue(borderTypes[i]); + QCOMPARE(bc.borderType(), borderTypes[i]); } int borderWidth = 4; bc.setBorderWidth(borderWidth); QCOMPARE(bc.borderWidth(), borderWidth); + bc.setBorderWidth(-1); + QCOMPARE(bc.borderWidth(), 0); int whitespace = 5; bc.setWhitespace(whitespace); @@ -328,6 +332,26 @@ private slots: QCOMPARE(bc.takesGS1AIData(BARCODE_CODE128), false); QCOMPARE(bc.takesGS1AIData(BARCODE_GS1_128), true); + QCOMPARE(bc.takesGS1AIData(BARCODE_EAN8_CC), true); + QCOMPARE(bc.takesGS1AIData(0), false); + + QCOMPARE(symbology, BARCODE_CODE11); + + float defaultXdim = 0.495f; + QCOMPARE(bc.defaultXdim(), defaultXdim); + QCOMPARE(bc.defaultXdim(symbology), defaultXdim); + + scale = 3.0f; + QString fileType(Zint::QZint::noPng() ? "gif" : "png"); + float x_dim_mm = 0.5f; + dpmm = 12.0f; + QCOMPARE(bc.getScaleFromXdimDp(x_dim_mm, dpmm, fileType, symbology), scale); + + QCOMPARE(bc.getXdimDpFromScale(scale, x_dim_mm, fileType), dpmm); + QCOMPARE(bc.getXdimDpFromScale(scale, dpmm, fileType), x_dim_mm); + + float width_x_dim, height_x_dim; + QCOMPARE(bc.getWidthHeightXdim(x_dim_mm, width_x_dim, height_x_dim), false); } void setGetECIValueTest_data() @@ -452,10 +476,21 @@ private slots: void renderTest_data() { QTest::addColumn("symbology"); + QTest::addColumn("inputMode"); QTest::addColumn("text"); QTest::addColumn("scale"); + QTest::addColumn("fgStr"); + QTest::addColumn("bgStr"); + QTest::addColumn("borderType"); + QTest::addColumn("borderWidth"); + QTest::addColumn("quietZones"); + QTest::addColumn("rotateAngle"); + QTest::addColumn("getError"); QTest::addColumn("error_message"); + + QTest::addColumn("encodedInputMode"); + QTest::addColumn("encodedOutputOptions"); QTest::addColumn("encodedWidth"); QTest::addColumn("encodedRows"); QTest::addColumn("encodedHeight"); @@ -465,21 +500,54 @@ private slots: QTest::addColumn("vectorWidth"); QTest::addColumn("vectorHeight"); - QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128 << "1234" << 0.0f << 0 << "" << 57 << 1 << 50.0f << -1 << 0 << 0 << 114.0f << 100.0f; - QTest::newRow("BARCODE_CODE128 Scale 2") << BARCODE_CODE128 << "1234" << 2.0f << 0 << "" << 57 << 1 << 50.0f << -1 << 0 << 0 << 228.0f << 200.0f; - QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0.0f << 0 << "" << 21 << 21 << 21.0f << 4 << 1 << (7 << 8) << 42.0f << 42.0f; - QTest::newRow("BARCODE_QRCODE Scale 1.5") << BARCODE_QRCODE << "1234" << 1.5f << 0 << "" << 21 << 21 << 21.0f << 4 << 1 << (7 << 8) << 63.0f << 63.0f; + QTest::addColumn("getWidthHeightXdim"); + QTest::addColumn("xdimWidth"); + QTest::addColumn("xdimHeight"); + + QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128 << UNICODE_MODE << "1234" << 0.0f + << "" << "" << 0 << 0 << false << 0 << 0 << "" + << UNICODE_MODE << 0 << 57 << 1 << 50.0f << -1 << 0 << 0 << 114.0f << 100.0f + << true << 28.215f << 24.75f; + QTest::newRow("BARCODE_CODE128 Scale 2") << BARCODE_CODE128 << UNICODE_MODE << "1234" << 2.0f + << "" << "" << 0 << 0 << false << 0 << 0 << "" + << UNICODE_MODE << 0 << 57 << 1 << 50.0f << -1 << 0 << 0 << 228.0f << 200.0f + << true << 28.215f << 24.75f; + QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << UNICODE_MODE << "1234" << 0.0f + << "" << "" << 0 << 0 << false << 0 << 0 << "" + << UNICODE_MODE << 0 << 21 << 21 << 21.0f << 4 << 1 << (7 << 8) << 42.0f << 42.0f + << true << 13.125f << 13.125f; + QTest::newRow("BARCODE_QRCODE Scale 1.5") << BARCODE_QRCODE << UNICODE_MODE << "1234" << 1.5f + << "" << "" << 0 << 0 << false << 0 << 0 << "" + << UNICODE_MODE << 0 << 21 << 21 << 21.0f << 4 << 1 << (7 << 8) << 63.0f << 63.0f + << true << 13.125f << 13.125f; if (!m_skipIfFontUsed) { - QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << 0.0f << ZINT_ERROR_INVALID_DATA << "Error 228: No input data (segment 0 empty)" << 0 << 0 << 0.0f << -1 << 0 << 0 << 0.0f << 0.0f; + QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << UNICODE_MODE << "" << 0.0f + << "" << "" << 0 << 0 << false << 0 << ZINT_ERROR_INVALID_DATA + << "Error 228: No input data (segment 0 empty)" + << UNICODE_MODE << 0 << 0 << 0 << 0.0f << -1 << 0 << 0 << 0.0f << 0.0f + << false << 0.0f << 0.0f; } - QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << "1234" << 0.0f << 0 << "" << 30 << 33 << 28.578f << 4 << 0 << 0 << 60.0f << 57.7334f; - QTest::newRow("BARCODE_MAXICODE Scale 2") << BARCODE_MAXICODE << "1234" << 2.0f << 0 << "" << 30 << 33 << 28.578f << 4 << 0 << 0 << 120.0f << 115.467f; + QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << UNICODE_MODE << "1234" << 0.0f + << "808080" << "" << BARCODE_BOX << 1 << true << 0 << 0 << "" + << UNICODE_MODE << (BARCODE_BOX | BARCODE_QUIET_ZONES) << 30 << 33 << 28.578f + << 4 << 0 << 0 << 68.0f << 65.7334f + << true << 29.92f << 28.9227f; + QTest::newRow("BARCODE_MAXICODE Scale 2") << BARCODE_MAXICODE << UNICODE_MODE << "1234" << 2.0f + << "" << "808080" << 0 << 0 << false << 90 << 0 << "" + << UNICODE_MODE << 0 << 30 << 33 << 28.578f << 4 << 0 << 0 << 120.0f << 115.467f + << true << 25.4027f << 26.4f; + QTest::newRow("BARCODE_ULTRA") << BARCODE_ULTRA << UNICODE_MODE << "1234" << 0.0f + << "808080" << "" << BARCODE_BIND << 2 << true << 0 << 0 << "" + << UNICODE_MODE << (BARCODE_BIND | BARCODE_QUIET_ZONES) << 15 << 13 << 13.0f + << 3 << 0 << 0 << 34.0f << 38.0f + << true << 10.625f << 11.875f; } void renderTest() { #ifdef TESTQZINT_GUILESS - QSKIP("disabled on Linux for Qt5 > 5.15.13 & Qt6 > 6.4.2 due to memory leaks (ZINT_SANITIZE)", "" /*Dummy arg to suppress -Wc++20-extensions*/); + QSKIP("disabled on Linux for Qt5 > 5.15.13 & Qt6 > 6.4.2 due to memory leaks (ZINT_SANITIZE)", + "" /*Dummy arg to suppress -Wc++20-extensions*/); #endif Zint::QZint bc; @@ -495,10 +563,19 @@ private slots: mode = Zint::QZint::AspectRatioMode::KeepAspectRatio; // Legacy - ignored QFETCH(int, symbology); + QFETCH(int, inputMode); QFETCH(QString, text); QFETCH(float, scale); + QFETCH(QString, fgStr); + QFETCH(QString, bgStr); + QFETCH(int, borderType); + QFETCH(int, borderWidth); + QFETCH(bool, quietZones); + QFETCH(int, rotateAngle); QFETCH(int, getError); QFETCH(QString, error_message); + QFETCH(int, encodedInputMode); + QFETCH(int, encodedOutputOptions); QFETCH(int, encodedWidth); QFETCH(int, encodedRows); QFETCH(float, encodedHeight); @@ -507,13 +584,23 @@ private slots: QFETCH(int, encodedOption3); QFETCH(float, vectorWidth); QFETCH(float, vectorHeight); + QFETCH(bool, getWidthHeightXdim); + QFETCH(float, xdimWidth); + QFETCH(float, xdimHeight); bc.setSymbol(symbology); + bc.setInputMode(inputMode); bc.setText(text); bc.setShowText(false); if (scale) { bc.setScale(scale); } + bc.setFgStr(fgStr); + bc.setBgStr(bgStr); + bc.setBorderTypeValue(borderType); + bc.setBorderWidth(borderWidth); + bc.setQuietZones(quietZones); + bc.setRotateAngleValue(rotateAngle); bRet = painter.begin(&paintDevice); QCOMPARE(bRet, true); @@ -527,6 +614,8 @@ private slots: QCOMPARE(bc.error_message(), error_message); QCOMPARE(bc.lastError(), error_message); QCOMPARE(bc.hasErrors(), getError != 0); + QCOMPARE(bc.encodedInputMode(), encodedInputMode); + QCOMPARE(bc.encodedOutputOptions(), encodedOutputOptions); QCOMPARE(bc.encodedWidth(), encodedWidth); QCOMPARE(bc.encodedRows(), encodedRows); QCOMPARE(bc.encodedHeight(), encodedHeight); @@ -543,22 +632,36 @@ private slots: QCOMPARE(spyEncoded.count(), 1); QCOMPARE(spyErrored.count(), 0); } + + float x_dim = bc.defaultXdim(); + float width_x_dim, height_x_dim; + QCOMPARE(bc.getWidthHeightXdim(x_dim, width_x_dim, height_x_dim), getWidthHeightXdim); + QCOMPARE(width_x_dim, xdimWidth); + QCOMPARE(height_x_dim, xdimHeight); } void saveToFileTest_data() { QTest::addColumn("symbology"); QTest::addColumn("text"); + QTest::addColumn("eci"); + QTest::addColumn("seg1"); + QTest::addColumn("seg1_eci"); QTest::addColumn("fileName"); QTest::addColumn("expected_bRet"); - QTest::newRow("BARCODE_DATAMATRIX gif") << BARCODE_DATAMATRIX << "1234" << "test_save_to_file.gif" << true; - QTest::newRow("BARCODE_DATAMATRIX unknown format") << BARCODE_DATAMATRIX << "1234" << "test_save_to_file.ext" << false; - QTest::newRow("BARCODE_DATAMATRIX UTF8 gif") << BARCODE_DATAMATRIX << "1234" << "test_save_to_file_τ.gif" << true; - QTest::newRow("BARCODE_DATAMATRIX too long (unknown format)") << BARCODE_DATAMATRIX << "1234" + QTest::newRow("BARCODE_DATAMATRIX gif") << BARCODE_DATAMATRIX << "1234" << 0 << "" << 0 + << "test_save_to_file.gif" << true; + QTest::newRow("BARCODE_DATAMATRIX segs gif") << BARCODE_DATAMATRIX << "1234" << 26 << "5678" << 3 + << "test_save_to_file_segs.gif" << true; + QTest::newRow("BARCODE_DATAMATRIX unknown format") << BARCODE_DATAMATRIX << "1234" << 0 << "" << 0 + << "test_save_to_file.ext" << false; + QTest::newRow("BARCODE_DATAMATRIX UTF8 gif") << BARCODE_DATAMATRIX << "1234" << 0 << "" << 0 + << "test_save_to_file_τ.gif" << true; + QTest::newRow("BARCODE_DATAMATRIX too long (unknown format)") << BARCODE_DATAMATRIX << "1234" << 0 << "" << 0 << "test_67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012.gif" // 256 long so should be truncated to end in ".gi" + "1234567890123456789012345678901234567890123456789012.gif" // 256 long so truncates to end in ".gi" << false; } @@ -570,11 +673,22 @@ private slots: QFETCH(int, symbology); QFETCH(QString, text); + QFETCH(int, eci); + QFETCH(QString, seg1); + QFETCH(int, seg1_eci); QFETCH(QString, fileName); QFETCH(bool, expected_bRet); bc.setSymbol(symbology); - bc.setText(text); + if (!seg1.isEmpty()) { + std::vector segs; + segs.push_back({text, Zint::QZint::ECIValueToECIIndex(eci)}); + segs.push_back({seg1, Zint::QZint::ECIValueToECIIndex(seg1_eci)}); + bc.setSegs(segs); + } else { + bc.setText(text); + bc.setECIValue(eci); + } bRet = bc.save_to_file(fileName); QCOMPARE(bRet, expected_bRet); @@ -589,18 +703,24 @@ private slots: { QTest::addColumn("symbology"); QTest::addColumn("text"); + QTest::addColumn("eci"); + QTest::addColumn("seg1"); + QTest::addColumn("seg1_eci"); QTest::addColumn("fileName"); QTest::addColumn("expected_bRet"); QTest::addColumn("expected_strData"); - QTest::newRow("BARCODE_DATAMATRIX gif") << BARCODE_DATAMATRIX << "1234" << "test_memfile.gif" << true + QTest::newRow("BARCODE_DATAMATRIX gif") << BARCODE_DATAMATRIX << "1234" << 0 << "" << 0 + << "test_memfile.gif" << true << "47494638376114001400f00000ffffff0000002c00000000140014000002" "3c4c00869ad7eb988c942168b2cef7eecf794e37594f776a285a862b8485" "ea49caf66a4ef10ca7204e010a69a24f6ff7231a5f351db3580149a7d44c" "01003b"; - QTest::newRow("BARCODE_DATAMATRIX svg") << BARCODE_DATAMATRIX << "1234" << "test_memfile.svg" << true + QTest::newRow("BARCODE_DATAMATRIX svg") << BARCODE_DATAMATRIX << "1234" << 0 << "" << 0 + << "test_memfile.svg" << true << "\n" - "\n" + "\n" "\n" " Zint Generated Symbol\n" " \n" @@ -611,6 +731,16 @@ private slots: " 14h2v2h-2ZM16 14h4v2h-4ZM0 16h2v2h-2ZM14 16h4v2h-4ZM0 18h20v2h-20Z\"/>\n" " \n" "\n"; + QTest::newRow("BARCODE_AZTEC gif") << BARCODE_AZTEC << "1234" << 3 << "5678" << 4 + << "test_memfile.gif" << true + << "47494638376126002600f00000ffffff0000002c00000000260026000002" + "b58411a97918b65a636e2e652196bacbfb3814a58d217980e519ae9ea972" + "622ba36b546f72b57fa09ecbf47e400eca96da1c81b85ed26459225d33a2" + "9565545eb79e1dd499a47ab1e0179346bda6b559d86ffdbd91854d9e94ed" + "13dbf1df3ed96d16b82788e3972528478836c803f7678538b3265738d718" + "76e9b4d4853915d4f948b905082a3a3a8969baa82ac49a4394985acae8b6" + "9947bb88747728cbc959f79b2b4cc7524ba37bfc681c5356e9c90ce6bc0a" + "5000003b"; } void saveToMemfileTest() @@ -621,24 +751,38 @@ private slots: QFETCH(int, symbology); QFETCH(QString, text); + QFETCH(int, eci); + QFETCH(QString, seg1); + QFETCH(int, seg1_eci); QFETCH(QString, fileName); QFETCH(bool, expected_bRet); QFETCH(QString, expected_strData); bc.setSymbol(symbology); - bc.setText(text); + if (!seg1.isEmpty()) { + std::vector segs; + segs.push_back({text, Zint::QZint::ECIValueToECIIndex(eci)}); + segs.push_back({seg1, Zint::QZint::ECIValueToECIIndex(seg1_eci)}); + bc.setSegs(segs); + } else { + bc.setText(text); + bc.setECIValue(eci); + } QByteArray data; bRet = bc.save_to_memfile(fileName, data); QCOMPARE(bRet, expected_bRet); if (bRet) { - QCOMPARE(bRet, true); if (fileName.endsWith(".eps") || fileName.endsWith(".svg") || fileName.endsWith(".txt")) { QCOMPARE(data, expected_strData); + QCOMPARE(bc.save_to_memfile(fileName, data), true); + QCOMPARE(data, expected_strData); } else { QByteArray expected_data = QByteArray::fromHex(expected_strData.toUtf8()); QCOMPARE(data, expected_data); + QCOMPARE(bc.save_to_memfile(fileName, data), true); + QCOMPARE(data, expected_data); } } } @@ -765,10 +909,10 @@ private slots: << 7 << false << false << false << false // eci-gs1SyntaxEngine << false << false << false << WARN_DEFAULT << false // readerInit-debug << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp - << "zint -b 92 --bg=0,0,0,0 --cmyk --eci=7 -d '12345678Ж0%var%' --dotsize=0.9 --dotty --fg=71,0,40,44 --scale=4" - " --secure=1 --structapp='1,2,as\"dfa'\\''sdf' --vwhitesp=3 -w 2" - << "zint.exe -b 92 --bg=0,0,0,0 --cmyk --eci=7 -d \"12345678Ж0%var%\" --dotsize=0.9 --dotty --fg=71,0,40,44 --scale=4" - " --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2" + << "zint -b 92 --bg=0,0,0,0 --cmyk --eci=7 -d '12345678Ж0%var%' --dotsize=0.9 --dotty" + " --fg=71,0,40,44 --scale=4 --secure=1 --structapp='1,2,as\"dfa'\\''sdf' --vwhitesp=3 -w 2" + << "zint.exe -b 92 --bg=0,0,0,0 --cmyk --eci=7 -d \"12345678Ж0%var%\" --dotsize=0.9 --dotty" + " --fg=71,0,40,44 --scale=4 --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2" << "" << "" << "" << ""; QTest::newRow("BARCODE_C25INTER") << true << 0.0f << "" @@ -921,10 +1065,10 @@ private slots: << 0 << false << false << false << false // eci-gs1SyntaxEngine << true << false << false << WARN_DEFAULT << false // readerInit-debug << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp - << "zint -b 74 --binary --border=4 --box --cols=5 --compliantheight -d 'T\\n\\xA0t\\\"' --esc --init" - " --rows=2 --scale=3 --separator=3" - << "zint.exe -b 74 --binary --border=4 --box --cols=5 --compliantheight -d \"T\\n\\xA0t\\\\\"\" --esc --init" - " --rows=2 --scale=3 --separator=3" + << "zint -b 74 --binary --border=4 --box --cols=5 --compliantheight -d 'T\\n\\xA0t\\\"' --esc" + " --init --rows=2 --scale=3 --separator=3" + << "zint.exe -b 74 --binary --border=4 --box --cols=5 --compliantheight -d \"T\\n\\xA0t\\\\\"\" --esc" + " --init --rows=2 --scale=3 --separator=3" << "" << "" << "" << ""; QTest::newRow("BARCODE_DAFT") << false << 0.0f << "" @@ -1019,8 +1163,10 @@ private slots: << 0 << false << false << true << true // eci-gs1SyntaxEngine << false << false << false << WARN_DEFAULT << false // readerInit-debug << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp - << "zint -b 71 -d '010952012345678810BATCH4\\G2107' --dmb256=2 --esc --gs1raw --gs1strict --gssep --square" - << "zint.exe -b 71 -d \"010952012345678810BATCH4\\G2107\" --dmb256=2 --esc --gs1raw --gs1strict --gssep --square" + << "zint -b 71 -d '010952012345678810BATCH4\\G2107' --dmb256=2 --esc --gs1raw --gs1strict --gssep" + " --square" + << "zint.exe -b 71 -d \"010952012345678810BATCH4\\G2107\" --dmb256=2 --esc --gs1raw --gs1strict --gssep" + " --square" << "" << "" << "" << ""; QTest::newRow("BARCODE_DATAMATRIX") << false << 0.0f << "" @@ -1040,7 +1186,7 @@ private slots: << "" << "" << "" << ""; QTest::newRow("BARCODE_MAILMARK_2D") << false << 0.0f << "" - << BARCODE_DATAMATRIX << UNICODE_MODE // symbology-inputMode + << BARCODE_MAILMARK_2D << UNICODE_MODE // symbology-inputMode << "JGB 012100123412345678AB19XY1A 0 www.xyz.com" << "" // text-primary << 0.0f << 0 << 0 << DM_C40_START << 1.0f // height-scale << 0.0f << false << 0.7f << 1.0f // dpmm-textGap @@ -1051,8 +1197,8 @@ private slots: << 0 << false << false << false << false // eci-gs1SyntaxEngine << false << false << false << WARN_DEFAULT << false // readerInit-debug << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp - << "zint -b 71 -d 'JGB 012100123412345678AB19XY1A 0 www.xyz.com' --dmc40=0 --rotate=90" - << "zint.exe -b 71 -d \"JGB 012100123412345678AB19XY1A 0 www.xyz.com\" --dmc40=0 --rotate=90" + << "zint -b 119 -d 'JGB 012100123412345678AB19XY1A 0 www.xyz.com' --dmc40=0 --rotate=90" + << "zint.exe -b 119 -d \"JGB 012100123412345678AB19XY1A 0 www.xyz.com\" --dmc40=0 --rotate=90" << "" << "" << "" << ""; QTest::newRow("BARCODE_DBAR_EXPSTK_CC") << false << 40.8f << "" @@ -1122,6 +1268,23 @@ private slots: << "" << "" << "" << "zint -b 96 --compliantheight -d '1234567890123456789012345678' --scalexdimdp=0.375mm,600dpi"; + QTest::newRow("BARCODE_DPD") << true << 0.0f << "" + << BARCODE_DPD << UNICODE_MODE // symbology-inputMode + << "1234567890123456789012345678" << "" // text-primary + << 0.0f << -1 << 0 << 0 << 4.5f // height-scale + << 24.0f << true << 0.8f << 1.0f // dpmm-textGap + << 0.0f << 0 << 0 << "" // guardDescent-structAppID + << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk + << 3 << 3 << 0 << 0 << 0 // borderTypeIndex-fontSetting + << true << false << false << false << true << 0 // showText-rotateAngle + << 0 << false << false << false << false // eci-gs1SyntaxEngine + << false << false << false << WARN_DEFAULT << false // readerInit-debug + << 0.375 << 0 << 600 << 1 << 0 << 0 // xdimdp + << "zint -b 96 --compliantheight -d '1234567890123456789012345678' --scalexdimdp=0.375,24" + << "zint.exe -b 96 --compliantheight -d \"1234567890123456789012345678\" --scalexdimdp=0.375,24" + << "" << "" << "" + << "zint -b 96 --compliantheight -d '1234567890123456789012345678' --scalexdimdp=0.375mm,600dpi"; + QTest::newRow("BARCODE_EAN13") << true << 0.0f << "" << BARCODE_EAN13 << UNICODE_MODE // symbology-inputMode << "123456789012+12" << "" // text-primary @@ -1166,8 +1329,10 @@ private slots: << 0 << false << false << false << false // eci-gs1SyntaxEngine << false << true << true << WARN_DEFAULT << false // readerInit-debug << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp - << "zint -b 15 --addongap=8 --compliantheight -d '123456789012+12' --embedfont --guarddescent=0 --guardwhitespace" - << "zint.exe -b 15 --addongap=8 --compliantheight -d \"123456789012+12\" --embedfont --guarddescent=0 --guardwhitespace" + << "zint -b 15 --addongap=8 --compliantheight -d '123456789012+12' --embedfont --guarddescent=0" + " --guardwhitespace" + << "zint.exe -b 15 --addongap=8 --compliantheight -d \"123456789012+12\" --embedfont --guarddescent=0" + " --guardwhitespace" << "" << "" << "" << ""; QTest::newRow("BARCODE_EANX (guardWhitespace/embedVectorFont") << true << 0.0f << "" @@ -1182,8 +1347,10 @@ private slots: << 0 << false << false << false << false // eci-gs1SyntaxEngine << false << true << true << WARN_DEFAULT << false // readerInit-debug << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp - << "zint -b 13 --addongap=8 --compliantheight -d '123456789012+12' --embedfont --guarddescent=0 --guardwhitespace" - << "zint.exe -b 13 --addongap=8 --compliantheight -d \"123456789012+12\" --embedfont --guarddescent=0 --guardwhitespace" + << "zint -b 13 --addongap=8 --compliantheight -d '123456789012+12' --embedfont --guarddescent=0" + " --guardwhitespace" + << "zint.exe -b 13 --addongap=8 --compliantheight -d \"123456789012+12\" --embedfont --guarddescent=0" + " --guardwhitespace" << "" << "" << "" << ""; QTest::newRow("BARCODE_GRIDMATRIX") << false << 0.0f << "" @@ -1284,6 +1451,22 @@ private slots: << "zint.exe -b 89 --border=1 --compliantheight -d \"9212320967145\"" << "" << "" << "" << ""; + QTest::newRow("BARCODE_ITF14 (border)") << true << 0.0f << "" + << BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode + << "9212320967145" << "" // text-primary + << 30.0f << -1 << 0 << 0 << 1.0f // height-scale + << 0.0f << false << 0.8f << 1.0f // dpmm-textGap + << 5.0f << 0 << 0 << "" // guardDescent-structAppID + << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk + << 2 << 5 << 0 << 0 << 0 // borderTypeIndex-fontSetting + << true << false << false << false << true << 0 // showText-rotateAngle + << 0 << false << false << false << false // eci-gs1SyntaxEngine + << false << false << false << WARN_DEFAULT << false // readerInit-debug + << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp + << "zint -b 89 --compliantheight -d '9212320967145'" + << "zint.exe -b 89 --compliantheight -d \"9212320967145\"" + << "" << "" << "" << ""; + QTest::newRow("BARCODE_MAXICODE") << true << 0.0f << "" << BARCODE_MAXICODE << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode << "152382802840001" @@ -1297,10 +1480,10 @@ private slots: << 0 << false << false << false << false // eci-gs1SyntaxEngine << false << false << false << WARN_DEFAULT << false // readerInit-debug << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp - << "zint -b 57 -d '1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E'" - " --esc --primary='152382802840001' --quietzones --scale=2.5 --scmvv=96" - << "zint.exe -b 57 -d \"1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E\"" - " --esc --primary=\"152382802840001\" --quietzones --scale=2.5 --scmvv=96" + << "zint -b 57 -d '1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY" + "\\R\\E' --esc --primary='152382802840001' --quietzones --scale=2.5 --scmvv=96" + << "zint.exe -b 57 -d \"1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY" + "\\R\\E\" --esc --primary=\"152382802840001\" --quietzones --scale=2.5 --scmvv=96" << "" << "" << "" << ""; QTest::newRow("BARCODE_MICROQR") << false << 0.0f << "" @@ -1421,10 +1604,12 @@ private slots: << 0 << false << true << true << true // eci-gs1SyntaxEngine << false << false << false << WARN_FAIL_ALL << false // readerInit-debug << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp - << "zint -b 136 --compliantheight -d '1190122299ABCDE' --fg=EF2929 --gs1nocheck --gs1raw --gs1strict --guarddescent=6.5" - " --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror" - << "zint.exe -b 136 --compliantheight -d \"1190122299ABCDE\" --fg=EF2929 --gs1nocheck --gs1raw --gs1strict --guarddescent=6.5" - " --noquietzones -o \"out.svg\" --primary=\"12345670+1234\" --small --werror" + << "zint -b 136 --compliantheight -d '1190122299ABCDE' --fg=EF2929 --gs1nocheck --gs1raw" + " --gs1strict --guarddescent=6.5 --noquietzones -o 'out.svg' --primary='12345670+1234' --small" + " --werror" + << "zint.exe -b 136 --compliantheight -d \"1190122299ABCDE\" --fg=EF2929 --gs1nocheck --gs1raw" + " --gs1strict --guarddescent=6.5 --noquietzones -o \"out.svg\" --primary=\"12345670+1234\" --small" + " --werror" << "" << "" << "" << ""; QTest::newRow("BARCODE_VIN") << false << 2.0f << "" @@ -1643,19 +1828,20 @@ private slots: std::vector segs; for (int i = 0; i < (int) segTexts.size(); i++) { - segs.push_back(Zint::QZintSeg(segTexts[i])); - segs.back().m_eci = segECIs[i]; + segs.push_back({segTexts[i], Zint::QZint::ECIValueToECIIndex(segECIs[i])}); } bc.setSymbol(BARCODE_QRCODE); bc.setSegs(segs); bc.setDotty(true); - expected_cmd = "zint -b 58 --eci=9 -d 'Τεχτ' --seg1=3,'Téxt' --seg2=13,'กขฯ' --seg3=20,'貫やぐ禁' --dotty"; + expected_cmd = "zint -b 58 --eci=9 -d 'Τεχτ' --seg1=3,'Téxt' --seg2=13,'กขฯ' --seg3=20,'貫やぐ禁'" + " --dotty"; cmd = bc.getAsCLI(false /*win*/); QCOMPARE(cmd, expected_cmd); - expected_win = "zint.exe -b 58 --eci=9 -d \"Τεχτ\" --seg1=3,\"Téxt\" --seg2=13,\"กขฯ\" --seg3=20,\"貫やぐ禁\" --dotty"; + expected_win = "zint.exe -b 58 --eci=9 -d \"Τεχτ\" --seg1=3,\"Téxt\" --seg2=13,\"กขฯ\" --seg3=20,\"貫やぐ禁\"" + " --dotty"; cmd = bc.getAsCLI(true /*win*/); QCOMPARE(cmd, expected_win); } @@ -1666,11 +1852,16 @@ private slots: QTest::addColumn("rotateAngles"); QTest::addColumn("text"); - QTest::newRow("symbology=BARCODE_DATAMATRIX rotateAngles=0 text=1234") << BARCODE_DATAMATRIX << 0 << "1234"; - QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=0 text=Hello%20World") << BARCODE_QRCODE << 0 << "Hello%20World"; - QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=90 text=Hello%20World") << BARCODE_QRCODE << 90 << "Hello%20World"; - QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=180 text=Hello%20World") << BARCODE_QRCODE << 180 << "Hello%20World"; - QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=270 text=Hello%20World") << BARCODE_QRCODE << 270 << "Hello%20World"; + QTest::newRow("symbology=BARCODE_DATAMATRIX rotateAngles=0 text=1234") << BARCODE_DATAMATRIX + << 0 << "1234"; + QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=0 text=Hello%20World") << BARCODE_QRCODE + << 0 << "Hello%20World"; + QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=90 text=Hello%20World") << BARCODE_QRCODE + << 90 << "Hello%20World"; + QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=180 text=Hello%20World") << BARCODE_QRCODE + << 180 << "Hello%20World"; + QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=270 text=Hello%20World") << BARCODE_QRCODE + << 270 << "Hello%20World"; } void qZintAndLibZintEqualTest() @@ -1694,7 +1885,8 @@ private slots: qstrcpy(symbol->outfile, qUtf8Printable(fileNameForLibZint)); bc.save_to_file(fileNameForQZint); - ZBarcode_Encode_and_Print(symbol.data(), reinterpret_cast(qUtf8Printable(text)), 0, rotateAngles); + ZBarcode_Encode_and_Print(symbol.data(), reinterpret_cast(qUtf8Printable(text)), 0, + rotateAngles); QImage imageWrittenByVanilla(fileNameForLibZint); QImage imageWrittenByQZint(fileNameForQZint); @@ -1716,6 +1908,7 @@ private slots: QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << "BARCODE_MAXICODE"; QTest::newRow("BARCODE_CODE128AB") << BARCODE_CODE128AB << "BARCODE_CODE128AB"; QTest::newRow("BARCODE_CODE128B") << BARCODE_CODE128B << "BARCODE_CODE128AB"; + QTest::newRow("BARCODE_LAST") << 0 << ""; } void barcodeNameTest() @@ -1726,6 +1919,67 @@ private slots: QString name = Zint::QZint::barcodeName(symbology); QCOMPARE(name, expected_name); } + + void ECIIndexTest() + { + for (int i = 0; i < 900; i++) { + int eciIndex = Zint::QZint::ECIValueToECIIndex(i); + int eci = Zint::QZint::ECIIndexToECIValue(eciIndex); + QCOMPARE(eciIndex, Zint::QZint::ECIValueToECIIndex(eci)); + QCOMPARE(eci, Zint::QZint::ECIIndexToECIValue(eciIndex)); + if (i < 3 || (i > 35 && i != 170 && i != 899) || i == 14 || i == 19) { + QCOMPARE(eci, 0); + } else { + QCOMPARE(eci, i); + } + if (i == 40) { + i = 170 - 1; + } else if (i == 170) { + i = 899 - 1; + } + } + } + + void XdimDpVarsTest() + { + struct Zint::QZintXdimDpVars vars; + + int symbol = BARCODE_CODE128; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "GIF"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "raster"); + + vars.filetype = 1; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "SVG"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "vector"); + + vars.filetype = 2; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "SVG"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "vector"); + + vars.filetype = -1; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "GIF"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "raster"); + + symbol = BARCODE_MAXICODE; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "GIF"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "raster"); + + vars.filetype_maxicode = 1; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "SVG"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "vector"); + + vars.filetype_maxicode = 2; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "EMF"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "EMF"); + + vars.filetype_maxicode = 3; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "EMF"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "EMF"); + + vars.filetype_maxicode = -1; + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, false /*msg*/), "GIF"); + QCOMPARE(Zint::QZintXdimDpVars::getFileType(symbol, &vars, true /*msg*/), "raster"); + } }; #ifdef TESTQZINT_GUILESS diff --git a/docs/Makefile b/docs/Makefile index 73d13dc5..da8c1666 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -184,14 +184,14 @@ $(OUT_TXT) : $(SOURCE) $(SOURCE_MAN_PAGE) $(INCLUDES_TXT) $(INFRASTRUCTURE) -V $(MAIN_FONT) -V $(MONO_FONT) -V $(CJK_FONT) \ $(TXT_OPTS) \ -o $(OUT_TXT) - # Indent Man Page sections in TOC, remove trailing spaces, echoed image tags, tbl: hashes - # & clean up Table captions + # Indent Man Page sections in TOC, remove trailing spaces, tbl: hashes, + # clean up Table captions & prefix Figure nos. (https://stackoverflow.com/a/60073027) sed -i \ -e 's/^\(- [A-Z][A-Z ]*\)$$/ \1/' \ -e 's/ *$$//' \ - -e '/^\[.*\]$$/{N;N;s/\[\(.*\)\]\n\n\1/[\1]/;p;d}' \ -e 's/ *{#tbl:[^}]*}//' \ -e 's/^ : Table/ Table/' \ + -e '/^\[[^1-9].*$$/{x;s/.*/expr & + 1/e;x;G;s/^\[\(.*\)\n\(.*\)/[Figure \2: \1/}' \ $(OUT_TXT) # Wrap sed -i '/.\{81\}/{s/.\{80\}/&\n/}' $(OUT_TXT) diff --git a/docs/images/datamatrix_big5.svg b/docs/images/datamatrix_big5.svg index d24f457c..4457d37a 100644 --- a/docs/images/datamatrix_big5.svg +++ b/docs/images/datamatrix_big5.svg @@ -4,6 +4,6 @@ Zint Generated Symbol - + diff --git a/docs/images/gui_aztec.png b/docs/images/gui_aztec.png index 63523ac3..ddb77042 100644 Binary files a/docs/images/gui_aztec.png and b/docs/images/gui_aztec.png differ diff --git a/docs/images/qrcode_binary_utf8.svg b/docs/images/qrcode_binary_utf8.svg index 977f1496..34288ee5 100644 --- a/docs/images/qrcode_binary_utf8.svg +++ b/docs/images/qrcode_binary_utf8.svg @@ -4,6 +4,6 @@ Zint Generated Symbol - + diff --git a/docs/inc_header_pdf.tex b/docs/inc_header_pdf.tex index edd00c3e..e22030f0 100644 --- a/docs/inc_header_pdf.tex +++ b/docs/inc_header_pdf.tex @@ -43,3 +43,7 @@ %% Make footnotes go to bottom of page \usepackage[bottom]{footmisc} + +%% Stop xeCJK putting space before CJK char in double quotes +\newXeTeXintercharclass\dquote +\XeTeXcharclass`"=\dquote diff --git a/docs/manual.html b/docs/manual.html index e44a59d0..15e6671c 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -1246,15 +1246,15 @@ Characters -$ +$ (dollar) Insert leading zeroes -# +# (hash) Insert leading spaces -* +* (asterisk) Insert leading asterisks @@ -1303,10 +1303,9 @@ your PATHEXT environment variable, i.e.:

class="sourceCode bash">zint.exe -d "This Text"

For compatibility with Windows the examples use double quotes to delimit data, though on Unix single quotes are generally preferable as -they stop the shell from processing any characters such as backslash or -dollar. A single quote itself is dealt with by terminating the -single-quoted text, backslashing the single quote, and then -continuing:

+they stop the shell from processing characters such as backslash. A +single quote itself is dealt with by terminating the single-quoted text, +backslashing the single quote, and then continuing:

zint -d 'Text containing a single quote '\'' in the middle'

Some examples use backslash (\) to continue commands @@ -1324,6 +1323,10 @@ class="sourceCode bash">zint --data "This Text"

The examples use a space separator for short option names, and an equals sign for long option names.

+

Long options may be abbreviated up to nonambiguity. For instance +--compliantheight may be shortened to +--compliant, or even --com, but note that +future additions may necessitate longer abbreviations.

4.1 Inputting Data

The data to encode can be entered at the command line using the -d or --data option, for example

@@ -1331,14 +1334,14 @@ equals sign for long option names.

class="sourceCode bash">zint -d "This Text"

This will encode the text "This Text". Zint will use the default symbology, Code 128, and output to the default file -"out.png" in the current directory. Alternatively, if -libpng was not present when Zint was built, the default -output file will be "out.gif".

+"out.png" in the current directory. Alternatively, if Zint +was not built with libpng, the default output file will be +"out.gif".

The data input to the Zint CLI is assumed to be encoded in UTF-8 -(Unicode) format (Zint will correctly handle UTF-8 data on Windows). If -you are encoding characters beyond the 7-bit ASCII set using a scheme -other than UTF-8 then you will need to set the appropriate input options -as shown in 4.11 Input Modes below.

+(Unicode) (Zint will correctly handle UTF-8 data on Windows). If you are +encoding characters beyond the 7-bit ASCII set using a scheme other than +UTF-8 then you will need to set the appropriate input options as shown +in 4.11 Input Modes below.

Non-printing characters can be entered on the command line using backslash (\) as an escape character in combination with the --esc switch. Permissible sequences are shown in the @@ -1563,8 +1566,8 @@ sequence “\^^”, i.e. by doubling the caret.

(ISO 15417) for the details on manually switching Code Sets.

Input data can be read directly from file using the -i or --input switch as shown below. The input file is assumed -to be UTF-8 formatted unless an alternative mode is selected. This -option replaces the use of the -d switch.

+to be in UTF-8 unless --binary is selected. This option +replaces the use of the -d switch.

zint -i somefile.txt

To read from stdin specify a single hyphen "-" as the @@ -1640,6 +1643,9 @@ will be created if they don’t already exist:

zint -o "dir/subdir/filename.eps" -d "This Text"

Note that on Windows, filenames are assumed to be UTF-8 encoded.

+

For another way to name output files, using the --mirror +option, see 4.14 Automatic +Filenames.

4.3 Selecting Barcode Type

Selecting which type of barcode you wish to produce (i.e. which symbology to use) can be done at the command line using the @@ -2382,8 +2388,8 @@ being applied to the X-dimension. For MaxiCode, it is multiplied by 10 for raster output, by 40 for EMF vector output, and by 2 otherwise (non-EMF vector output).

For non-MaxiCode raster output, the default scale of 1 results in an -X-dimension of 2 pixels. For example for non-MaxiCode PNG images a scale -of 5 will increase the X-dimension to 10 pixels. For MaxiCode, see 4.9.3 MaxiCode Raster Scaling below.

Scales for non-MaxiCode raster output should be given in increments @@ -2484,12 +2490,12 @@ the approximate equivalent of 300 dpi (dpi = dpmm * 25.4), specify a scale of 2, since 0.33 * 12 = 3.96 pixels, or 4 pixels rounding to the nearest pixel:

zint -b EAN13 -d "501234567890" --compliantheight --scale=2
+class="sourceCode bash">zint -b EAN13 -d "501234567890" --compliant --scale=2

This will result in output of 37.29mm x 25.56mm (WxH) at 12 dpmm. The same result can be achieved using the --scalexdimdp option with

zint -b EAN13 -d "501234567890" --compliantheight --scalexdimdp
+class="sourceCode bash">zint -b EAN13 -d "501234567890" --compliant --scalexdimdp

as 0.33mm is the default X-dimension for EAN, and 12 dpmm the default resolution.

4.9.3 MaxiCode Raster Scaling

@@ -2547,12 +2553,12 @@ alt="zint -d "Áccent" --embedfont" />

4.11 Input Modes

4.11.1 Unicode, Data, and GS1 Modes

-

By default all CLI input data is assumed to be encoded in UTF-8 -format. Many barcode symbologies encode data using the Latin-1 (ISO/IEC -8859-1 plus ASCII) character set, so input is converted from UTF-8 to -Latin-1 before being put in the symbol. In addition QR Code and its -variants and Han Xin Code can by default encode Japanese (Kanji) or -Chinese (Hanzi) characters which are also converted from UTF-8.

+

By default all CLI input data is assumed to be encoded in UTF-8. Many +barcode symbologies encode data using the Latin-1 (ISO/IEC 8859-1 plus +ASCII) character set, so input is converted from UTF-8 to Latin-1 before +being put in the symbol. In addition QR Code and its variants and Han +Xin Code can by default encode Japanese (Kanji) or Chinese (Hanzi) +characters which are also converted from UTF-8.

There are two exceptions to the Latin-1 default: Grid Matrix, whose default character set is GB 2312 (Chinese); and UPNQR, whose default character set is Latin-2 (ISO/IEC 8859-2 plus ASCII).

@@ -2891,22 +2897,24 @@ not usually required, as this is the default encoding for most barcodes, which is also active without any ECI information.

4.11.2.1 Input Modes and ECI Example 1

-

The Euro sign U+20AC can be encoded in ISO/IEC 8859-15. The Euro sign -has the ISO/IEC 8859-15 codepoint hex "A4". It is encoded -in UTF-8 as the hex sequence: "E2 82 AC". Those 3 bytes are -contained in the file "utf8euro.txt". This command will -generate the corresponding code:

+

The Euro sign "€" (U+20AC) can be encoded in ISO/IEC +8859-15 (ECI 17) as the hex byte "A4". It is encoded in +UTF-8 as the hex sequence: "E2 82 AC". Those 3 bytes are +contained in the file "utf8euro.txt", e.g. on Unix

zint -b DATAMATRIX --scale=10 --eci=17 -i utf8euro.txt
+class="sourceCode bash">echo -ne '\xE2\x82\xAC' > utf8euro.txt +

This command will generate the corresponding code:

+
zint -b DATAMATRIX --eci=17 -i utf8euro.txt

This is equivalent to the commands (using the --esc switch):

-
zint -b DATAMATRIX --scale=10 --eci=17 --esc -d "\xE2\x82\xAC"
-
-zint -b DATAMATRIX --scale=10 --eci=17 --esc -d "\u20AC"
-

and to the command:

zint -b DATAMATRIX --scale=10 --eci=17 -d "€"
+class="sourceCode bash">zint -b DATAMATRIX --eci=17 --esc -d "\xE2\x82\xAC" + +zint -b DATAMATRIX --eci=17 --esc -d "\u20AC" +

and to the command:

+
zint -b DATAMATRIX --eci=17 -d "€"
zint -b DATAMATRIX --eci=17 -d "€" @@ -2915,30 +2923,29 @@ alt="zint -b DATAMATRIX --eci=17 -d "€"" />

4.11.2.2 Input Modes and ECI Example 2

-

The Chinese character with the Unicode codepoint U+5E38 can be -encoded in Big5 encoding. The Big5 representation of this character is -the two hex bytes: "B1 60" (contained in the file -"big5char.txt"). The generation command for Data Matrix -is:

-
zint -b DATAMATRIX --scale=10 --eci=28 --binary -i big5char.txt
+

The Chinese character "碼" (U+78BC) can be encoded in +Big5 encoding (ECI 28) as the hex sequence: "BD 58". Those +2 bytes are contained in the file "big5char.txt". The +generation command is:

+
zint -b DATAMATRIX --eci=28 --binary -i big5char.txt

This is equivalent to the command (using the --esc switch):

-
zint -b DATAMATRIX --scale=10 --eci=28 --binary --esc -d "\xB1\x60"
+
zint -b DATAMATRIX --eci=28 --binary --esc -d "\xBD\x58"

and to the commands (no --binary switch so conversion occurs):

-
zint -b DATAMATRIX --scale=10 --eci=28 --esc -d "\xE5\xB8\xB8"
-
-zint -b DATAMATRIX --scale=10 --eci=28 --esc -d "\u5E38"
-
-zint -b DATAMATRIX --scale=10 --eci=28 -d "常"
+
zint -b DATAMATRIX --eci=28 --esc -d "\xE7\xA2\xBC"
+
+zint -b DATAMATRIX --eci=28 --esc -d "\u78BC"
+
+zint -b DATAMATRIX --eci=28 -d "碼"
+alt="zint -b DATAMATRIX --eci=28 --binary --esc -d "\xBD\x58"" />
Figure 24: -zint -b DATAMATRIX --eci=28 -d "\u5E38" --esc
+zint -b DATAMATRIX --eci=28 --binary --esc -d "\xBD\x58"

4.11.2.3 Input Modes and ECI Example 3

@@ -2946,31 +2953,31 @@ Example 3 UTF-8 encoding by default and do not support ECI. In this case supply UTF-8 data and use the --binary switch so that the data will be encoded as UTF-8 without conversion:

-
zint -b QRCODE --binary -d "UTF-8 data"
+
zint -b QRCODE --binary -d "€"
+alt="zint -b QRCODE --binary -d "€"" />
Figure 25: -zint -b QRCODE --binary -d "\xE2\x82\xAC\xE5\xB8\xB8" --esc
+zint -b QRCODE --binary -d "€"

4.11.3 GS1 Data Entry and Options

The following symbologies accept GS1 data:

- +
--++ - + @@ -2978,98 +2985,98 @@ Symbologies - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + @@ -3084,37 +3091,37 @@ all of which can encode multiple AIs, require markup in the data to distinguish AIs.

The traditional way in Zint of specifying GS1 data for these cases is to delimit the GS1 AIs in square brackets:

-
zint -b AZTEC -d "[01]09520123456788[10]BCH4[21]07" --gs1
+
zint -b AZTEC -d "[01]09520123456788[10]BCH4[21]07" --gs1

(Note that for the matrix symbologies the --gs1 option must be given.)

Parentheses (round brackets) may be used instead by giving the --gs1parens option:

-
zint -b AZTEC -d "(01)09520123456788(10)BCH4(21)07" --gs1parens
+
zint -b AZTEC -d "(01)09520123456788(10)BCH4(21)07" --gs1parens

If the data includes opening parentheses when using the latter format, they must be escaped and the --esc option given:

-
zint -b AZTEC -d "(01)09520123456788(90)Var\(34)" --esc --gs1parens
+
zint -b AZTEC -d "(01)09520123456788(90)Var\(34)" --esc --gs1parens

Closing parentheses may also be escaped for clarity.

For matrix symbologies, a GS1 Digital Link URI may be used:

-
zint -b AZTEC -d "https://example.com/01/09520123456788/10/BCH4/21/07" --gs1
+
zint -b AZTEC -d "https://example.com/01/09520123456788/10/BCH4/21/07" --gs1

A further way to specify GS1 input is “Unbracketed AI”, a GS1 Syntax Engine format10 that uses carets (^) to indicate any required FNC1s.11 The data must start with a caret:

-
zint -b AZTEC -d "^010952012345678810BCH4^2107" --gs1
+
zint -b AZTEC -d "^010952012345678810BCH4^2107" --gs1

The final way to specify input is the related “raw” mode using the --gs1raw option. Here FNC1s are indicated by Group Separators (GS, ASCII 29, escape sequence \G). It does not start with a GS:

-
zint -b AZTEC -d "010952012345678810BCH4\G2107" --esc --gs1raw
+
zint -b AZTEC -d "010952012345678810BCH4\G2107" --esc --gs1raw

4.11.3.2 GS1 Options

Apart from --gs1, --gs1parens and --gs1raw discussed above, there are two other GS1 @@ -3123,8 +3130,8 @@ options.

  • --gs1strict, which enables the use the GS1 Syntax Engine to strictly validate GS1 data, including GS1 Digital Link URIs (by default Zint does not validate Digital Links at all). It requires -that the gs1encoders library was present when Zint was -built, otherwise the default built-in validation will be used.

  • +that Zint was built with the gs1encoders library, otherwise +the default built-in validation will be used.

  • --gs1nocheck, for use with legacy systems that have data that does not conform to the current GS1 standard. Printable ASCII input is still checked for, as is the validity of GS1 data specified @@ -3143,8 +3150,8 @@ Setting the Input Mode).

    a separate barcode image for each line of text in that file. To do this use the --batch switch together with -i to select the input file from which to read data. For example

    -
    zint -b EAN13 --batch -i ean13nos.txt
    +
    zint -b EAN13 --batch -i ean13nos.txt

    where "ean13nos.txt" contains a list of EAN-13 numbers (GTINs), each on its own line. Zint will automatically detect the end of a line of text (in either Unix or Windows formatted text files) and @@ -3167,15 +3174,15 @@ Formatting

  • - + - + - + @@ -3186,8 +3193,8 @@ Formatting
    Table 10: GS1-Enabled Symbologies
    Symbology Implicit AI?GS1 Data Assumed?GS1 Data Assumed? Supports GS1 Composite?
    Aztec Code NoNoNo No
    Code 16K NoNoNo No
    Code 49 NoNoNo No
    Code One NoNoNo No
    Data Matrix NoNoNo No
    DotCode NoNoNo No
    EAN-13, EAN-8 Yes (01)YesYes Yes
    EAN-14 Yes (01)YesYes No
    GS1-128 NoYesYes Yes
    GS1 DataBar Expanded (including +GS1 DataBar Expanded (including Expanded Stacked) NoYesYes Yes
    GS1 DataBar (all others) Yes (01)YesYes Yes
    NVE-18 Yes (00)YesYes No
    QR Code NoNoNo No
    rMQR NoNoNo No
    Ultracode NoNoNo No
    UPC-A, UPC-E Yes (01)YesYes Yes
    ~~ (tilde) Insert a number or 0
    ## (hash) Insert a number or space
    @@ (ampersand) Insert a number or * (or + on Windows)

    For instance

    -
    zint -b EAN13 --batch -i ean13nos.txt -o "file~~~.svg"
    +
    zint -b EAN13 --batch -i ean13nos.txt -o "file~~~.svg"

    The following table shows some examples to clarify this method:

    +fixed width-to-height symbols.14 @@ -3746,8 +3766,8 @@ resulting barcode symbol to. Must end in .png, .gif, .bmp, .emf, .eps, .pcx, .svg, .tif or .txt followed by a terminating -NUL.14 +NUL.15 @@ -3962,22 +3982,22 @@ see 5.16 Feedback.

    To alter these values use the syntax shown in the example below. This code has the same result as the previous example except the output is now taller and plotted in green.

    -
    #include <zint.h>
    -#include <string.h>
    -int main(int argc, char **argv)
    -{
    -    struct zint_symbol *symbol;
    -    symbol = ZBarcode_Create();
    -    strcpy(symbol->fgcolour, "00ff00");
    -    symbol->height = 400.0f;
    -    ZBarcode_Encode_and_Print(symbol, argv[1], 0, 0);
    -    ZBarcode_Delete(symbol);
    -    return 0;
    -}
    +
    #include <zint.h>
    +#include <string.h>
    +int main(int argc, char **argv)
    +{
    +    struct zint_symbol *symbol;
    +    symbol = ZBarcode_Create();
    +    strcpy(symbol->fgcolour, "00ff00");
    +    symbol->height = 400.0f;
    +    ZBarcode_Encode_and_Print(symbol, argv[1], 0, 0);
    +    ZBarcode_Delete(symbol);
    +    return 0;
    +}

    Note that background removal for all outputs except BMP can be achieved by setting the background alpha to "00" where the values for R, G and B will be ignored:

    -
        strcpy(symbol->bgcolour, "55555500");
    +
        strcpy(symbol->bgcolour, "55555500");

    This is what the CLI option --nobackground does - see 4.7 Using Colour.

    5.8 Handling Errors

    @@ -4096,30 +4116,30 @@ occurs.
    Table 12: Batch Filename @@ -3257,12 +3264,12 @@ Automatic Filenames below.

    The finished image files can be output directly to stdout for use as part of a pipe by using the --direct option. By default --direct will output data as a PNG image (or GIF image if -libpng is not present), but this can be altered by +Zint not built with libpng), but this can be altered by supplementing the --direct option with a --filetype option followed by the suffix of the file type required. For example:

    -
    zint -b MICROPDF417 --direct --filetype=pcx -d "Data to encode"
    +
    zint -b MICROPDF417 --direct --filetype=pcx -d "Data to encode"

    This command will output the symbol as a PCX file to stdout. For the supported output file formats see Table 4: Output File @@ -3280,14 +3287,27 @@ useful if you are processing batch data. For example the input data "1234567.png".

    There are restrictions, however, on what characters can be stored in a filename, so the filename may vary from the data if the data includes -non-printable characters, for example, and may be shortened if the data -input is long.

    +non-printable characters, for example,
    12 +and may be shortened if the data input is long. So in batch mode your +data must be unique given these restrictions otherwise files will +overwrite each other.

    To set the output file format use the --filetype option as detailed above in 4.13 Direct -Output to stdout. To output to a specific directory use the --o option giving the name of the directory (any filename -will be ignored, unless --filetype is not specified, in -which case the filename’s extension will be used).

    +Output to stdout. For instance

    +
    zint -d "1234567" --mirror --filetype=eps
    +

    will output to the file "1234567.eps":

    +

    To output to a specific directory use the -o option +giving the name of the directory, indicated by a terminating slash +/ (backslash \ may be used on Windows). Any +filename after the last slash will be ignored, unless +--filetype is not specified, in which case the filename’s +extension will be used - e.g.

    +
    zint -d "1234567" --mirror -o "dir/subdir/mir.eps"
    +

    will output to the file "1234567.eps" in the +"dir/subdir" directory.

    4.15 Working with Dots

    Matrix codes can be rendered as a series of dots or circles rather than the normal squares by using the --dotty option. This @@ -3314,8 +3334,8 @@ and data is the data to which this applies. This is in addition to the ECI and data specified using the --eci and -d options which must still be present and which in effect constitute segment 0. For instance

    -
    zint -b AZTEC_CODE --eci=9 -d "Κείμενο" --seg1=7,"Текст" --seg2=20,"文章"
    +
    zint -b AZTEC_CODE --eci=9 -d "Κείμενο" --seg1=7,"Текст" --seg2=20,"文章"

    specifies 3 segments: segment 0 with ECI 9 (Greek), segment 1 with ECI 7 (Cyrillic), and segment 2 with ECI 20 (Shift JIS). Segments must be consecutive.

    @@ -3341,8 +3361,8 @@ Data Matrix, DotCode, Grid Matrix, MaxiCode, MicroPDF417, PDF417, QR Code and Ultracode.

    The --structapp option marks a symbol as part of a Structured Append sequence, and has the format

    -
    --structapp=I,C[,ID]
    +
    --structapp=I,C[,ID]
    zint -b DATAMATRIX -d "2nd of 3" --structapp="2,3,5006" @@ -3400,22 +3420,22 @@ These symbol structures are created with the ZBarcode_Create() function and deleted using the ZBarcode_Delete() function. For example the following code creates and then deletes a symbol:

    -
    #include <zint.h>
    -#include <stdio.h>
    -int main()
    -{
    -    struct zint_symbol *symbol;
    -    symbol = ZBarcode_Create();
    -    if (symbol != NULL) {
    -        printf("Symbol successfully created!\n");
    -        ZBarcode_Delete(symbol);
    -    }
    -    return 0;
    -}
    +
    #include <zint.h>
    +#include <stdio.h>
    +int main()
    +{
    +    struct zint_symbol *symbol;
    +    symbol = ZBarcode_Create();
    +    if (symbol != NULL) {
    +        printf("Symbol successfully created!\n");
    +        ZBarcode_Delete(symbol);
    +    }
    +    return 0;
    +}

    When compiling this code it will need to be linked with the libzint library using the -lzint option:

    -
    gcc -o simple simple.c -lzint
    +
    gcc -o simple simple.c -lzint

    5.2 Encoding and Saving to File

    To encode data in a barcode use the ZBarcode_Encode() @@ -3423,30 +3443,30 @@ function. To write the symbol to a file use the ZBarcode_Print() function. For example the following code takes a string from the command line and outputs a Code 128 symbol to a PNG file named "out.png" (or a GIF file -"out.gif" if libpng is not present) in the -current working directory:

    -
    #include <zint.h>
    -int main(int argc, char **argv)
    -{
    -    struct zint_symbol *symbol;
    -    symbol = ZBarcode_Create();
    -    ZBarcode_Encode(symbol, argv[1], 0);
    -    ZBarcode_Print(symbol, 0);
    -    ZBarcode_Delete(symbol);
    -    return 0;
    -}
    +"out.gif" if Zint not built with libpng) in +the current working directory:

    +
    #include <zint.h>
    +int main(int argc, char **argv)
    +{
    +    struct zint_symbol *symbol;
    +    symbol = ZBarcode_Create();
    +    ZBarcode_Encode(symbol, argv[1], 0);
    +    ZBarcode_Print(symbol, 0);
    +    ZBarcode_Delete(symbol);
    +    return 0;
    +}

    This can also be done in one stage using the ZBarcode_Encode_and_Print() function as shown in the next example:

    -
    #include <zint.h>
    -int main(int argc, char **argv)
    -{
    -    struct zint_symbol *symbol;
    -    symbol = ZBarcode_Create();
    -    ZBarcode_Encode_and_Print(symbol, argv[1], 0, 0);
    -    ZBarcode_Delete(symbol);
    -    return 0;
    -}
    +
    #include <zint.h>
    +int main(int argc, char **argv)
    +{
    +    struct zint_symbol *symbol;
    +    symbol = ZBarcode_Create();
    +    ZBarcode_Encode_and_Print(symbol, argv[1], 0, 0);
    +    ZBarcode_Delete(symbol);
    +    return 0;
    +}

    Note that when using the API, the input data is assumed to be 8-bit binary unless the input_mode member of the zint_symbol structure is set - see

    5.3 Encoding and Printing Functions in Depth

    The functions for encoding and printing barcodes are defined as:

    -
    int ZBarcode_Encode(struct zint_symbol *symbol,
    -      const unsigned char *source, int length);
    -
    -int ZBarcode_Encode_File(struct zint_symbol *symbol,
    -      const char *filename);
    -
    -int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
    -
    -int ZBarcode_Encode_and_Print(struct zint_symbol *symbol,
    -      const unsigned char *source, int length, int rotate_angle);
    -
    -int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol,
    -      const char *filename, int rotate_angle);
    +
    int ZBarcode_Encode(struct zint_symbol *symbol,
    +      const unsigned char *source, int length);
    +
    +int ZBarcode_Encode_File(struct zint_symbol *symbol,
    +      const char *filename);
    +
    +int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
    +
    +int ZBarcode_Encode_and_Print(struct zint_symbol *symbol,
    +      const unsigned char *source, int length, int rotate_angle);
    +
    +int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol,
    +      const char *filename, int rotate_angle);

    In these definitions length can be used to set the length of the input string. This allows the encoding of NUL (ASCII 0) characters in those symbologies which allow this. A value of 0 @@ -3494,13 +3514,13 @@ Memory (raster)

    In addition to saving barcode images to file Zint allows you to access a representation of the resulting bitmap image in memory. The following functions allow you to do this:

    -
    int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
    -
    -int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol,
    -      const unsigned char *source, int length, int rotate_angle);
    -
    -int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol,
    -      const char *filename, int rotate_angle);
    +
    int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
    +
    +int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol,
    +      const unsigned char *source, int length, int rotate_angle);
    +
    +int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol,
    +      const char *filename, int rotate_angle);

    The arguments here are the same as above, and rotation and colour options can be used with the buffer functions in the same way as when saving to a file. The difference is that instead of saving the image to @@ -3522,23 +3542,23 @@ method shown in the example below, where render_rgb() and render_rgba() are assumed to be functions for drawing an RGB and RGBA pixel on the screen implemented by the client application:

    -
    int row, col, i = 0, j = 0;
    -
    -for (row = 0; row < symbol->bitmap_height; row++) {
    -     for (col = 0; col < symbol->bitmap_width; col++) {
    -          int red = (int) symbol->bitmap[i];
    -          int green = (int) symbol->bitmap[i + 1];
    -          int blue = (int) symbol->bitmap[i + 2];
    -          if (symbol->alphamap) {
    -              int alpha = (int) symbol->alphamap[j];
    -              render_rgba(row, col, red, green, blue, alpha);
    -              j++;
    -          } else {
    -              render_rgb(row, col, red, green, blue);
    -          }
    -          i += 3;
    -     }
    -}
    +
    int row, col, i = 0, j = 0;
    +
    +for (row = 0; row < symbol->bitmap_height; row++) {
    +     for (col = 0; col < symbol->bitmap_width; col++) {
    +          int red = (int) symbol->bitmap[i];
    +          int green = (int) symbol->bitmap[i + 1];
    +          int blue = (int) symbol->bitmap[i + 2];
    +          if (symbol->alphamap) {
    +              int alpha = (int) symbol->alphamap[j];
    +              render_rgba(row, col, red, green, blue, alpha);
    +              j++;
    +          } else {
    +              render_rgb(row, col, red, green, blue);
    +          }
    +          i += 3;
    +     }
    +}

    Where speed is important, the buffer can be returned instead in a more compact intermediate form using the output option OUT_BUFFER_INTERMEDIATE. Here each byte is an ASCII value: @@ -3550,26 +3570,26 @@ for blue, 'M' for magenta, 'R' for red, 'K' for black. Alpha values are not reported (alphamap will always be NULL). The loop for accessing the data is then:

    -
    int row, col, i = 0;
    -
    -for (row = 0; row < symbol->bitmap_height; row++) {
    -     for (col = 0; col < symbol->bitmap_width; col++) {
    -          render_pixel(row, col, symbol->bitmap[i]);
    -          i++;
    -     }
    -}
    +
    int row, col, i = 0;
    +
    +for (row = 0; row < symbol->bitmap_height; row++) {
    +     for (col = 0; col < symbol->bitmap_width; col++) {
    +          render_pixel(row, col, symbol->bitmap[i]);
    +          i++;
    +     }
    +}

    5.5 Buffering Symbols in Memory (vector)

    Symbols can also be saved to memory in a vector representation as well as a bitmap one. The following functions, exactly analogous to the ones above, allow you to do this:

    -
    int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
    -
    -int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol,
    -      const unsigned char *source, int length, int rotate_angle);
    -
    -int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol,
    -      const char *filename, int rotate_angle);
    +
    int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
    +
    +int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol,
    +      const unsigned char *source, int length, int rotate_angle);
    +
    +int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol,
    +      const char *filename, int rotate_angle);

    Here the vector member is set to point to a zint_vector header structure which contains pointers to lists of structures representing the various elements of the barcode: @@ -3580,30 +3600,30 @@ rendering system with prepare_canvas(), draw_rect(), draw_hexagon(), draw_string(), and draw_circle() routines available:

    -
    struct zint_vector_rect *rect;
    -struct zint_vector_hexagon *hex;
    -struct zint_vector_string *string;
    -struct zint_vector_circle *circle;
    -
    -prepare_canvas(symbol->vector->width, symbol->vector->height,
    -               symbol->scale, symbol->fgcolour, symbol->bgcolour,
    -               rotate_angle);
    -
    -for (rect = symbol->vector->rectangles; rect; rect = rect->next) {
    -    draw_rect(rect->x, rect->y, rect->width, rect->height,
    -              rect->colour);
    -}
    -for (hex = symbol->vector->hexagons; hex; hex = hex->next) {
    -    draw_hexagon(hex->x, hex->y, hex->diameter, hex->rotation);
    -}
    -for (string = symbol->vector->strings; string; string = string->next) {
    -    draw_string(string->x, string->y, string->fsize,
    -                string->rotation, string->halign,
    -                string->text, string->length);
    -}
    -for (circle = symbol->vector->circles; circle; circle = circle->next) {
    -    draw_circle(circle->x, circle->y, circle->diameter, circle->width);
    -}
    +
    struct zint_vector_rect *rect;
    +struct zint_vector_hexagon *hex;
    +struct zint_vector_string *string;
    +struct zint_vector_circle *circle;
    +
    +prepare_canvas(symbol->vector->width, symbol->vector->height,
    +               symbol->scale, symbol->fgcolour, symbol->bgcolour,
    +               rotate_angle);
    +
    +for (rect = symbol->vector->rectangles; rect; rect = rect->next) {
    +    draw_rect(rect->x, rect->y, rect->width, rect->height,
    +              rect->colour);
    +}
    +for (hex = symbol->vector->hexagons; hex; hex = hex->next) {
    +    draw_hexagon(hex->x, hex->y, hex->diameter, hex->rotation);
    +}
    +for (string = symbol->vector->strings; string; string = string->next) {
    +    draw_string(string->x, string->y, string->fsize,
    +                string->rotation, string->halign,
    +                string->text, string->length);
    +}
    +for (circle = symbol->vector->circles; circle; circle = circle->next) {
    +    draw_circle(circle->x, circle->y, circle->diameter, circle->width);
    +}

    5.6 Buffering Symbols in Memory (memfile)

    Symbols can also be stored as “in-memory” file buffers by giving the @@ -3612,26 +3632,26 @@ Memory (memfile) member memfile instead of to the output file outfile. The length of the buffer is given in memfile_size. For instance:

    -
    #include <zint.h>
    -#include <stdio.h>
    -#include <string.h>
    -int main(int argc, char **argv)
    -{
    -    struct zint_symbol *symbol;
    -    symbol = ZBarcode_Create();
    -    symbol->output_options |= BARCODE_MEMORY_FILE;
    -    /* Only the extension is used, to determine output format */
    -    strcpy(symbol->outfile, "mem.svg");
    -    ZBarcode_Encode_and_Print(symbol, argv[1], 0, 0);
    -    /* `symbol->memfile` now contains the SVG output */
    -    fwrite(symbol->memfile, 1, symbol->memfile_size, stdout);
    -    ZBarcode_Delete(symbol);
    -    return 0;
    -}
    +
    #include <zint.h>
    +#include <stdio.h>
    +#include <string.h>
    +int main(int argc, char **argv)
    +{
    +    struct zint_symbol *symbol;
    +    symbol = ZBarcode_Create();
    +    symbol->output_options |= BARCODE_MEMORY_FILE;
    +    /* Only the extension is used, to determine output format */
    +    strcpy(symbol->outfile, "mem.svg");
    +    ZBarcode_Encode_and_Print(symbol, argv[1], 0, 0);
    +    /* `symbol->memfile` now contains the SVG output */
    +    fwrite(symbol->memfile, 1, symbol->memfile_size, stdout);
    +    ZBarcode_Delete(symbol);
    +    return 0;
    +}

    will print the SVG output to stdout (the file "mem.svg" is not created). This is particularly useful for -the textual formats EPS and SVG,12 allowing the output to +the textual formats EPS and SVG,13 allowing the output to be manipulated and processed by the client.

    5.7 Setting Options

    So far our application is not very useful unless we plan to only make @@ -3670,8 +3690,8 @@ href="#specifying-a-symbology">5.9 Specifying a Symbology.

    height float Symbol height in X-dimensions, excluding -fixed width-to-height symbols.13 Symbol dependent
    "out.png"

    To catch errors use an integer variable as shown in the code below:

    -
    #include <zint.h>
    -#include <stdio.h>
    -#include <string.h>
    -int main(int argc, char **argv)
    -{
    -    struct zint_symbol *symbol;
    -    int error;
    -    symbol = ZBarcode_Create();
    -    /* Set invalid foreground colour */
    -    strcpy(symbol->fgcolour, "nonsense");
    -    error = ZBarcode_Encode_and_Print(symbol, argv[1], 0, 0);
    -    if (error != 0) {
    -        /* Some warning or error occurred */
    -        printf("%s\n", symbol->errtxt);
    -        if (error >= ZINT_ERROR) {
    -            /* Stop now */
    -            ZBarcode_Delete(symbol);
    -            return 1;
    -        }
    -    }
    -    /* Otherwise carry on with the rest of the application */
    -    ZBarcode_Delete(symbol);
    -    return 0;
    -}
    +
    #include <zint.h>
    +#include <stdio.h>
    +#include <string.h>
    +int main(int argc, char **argv)
    +{
    +    struct zint_symbol *symbol;
    +    int error;
    +    symbol = ZBarcode_Create();
    +    /* Set invalid foreground colour */
    +    strcpy(symbol->fgcolour, "nonsense");
    +    error = ZBarcode_Encode_and_Print(symbol, argv[1], 0, 0);
    +    if (error != 0) {
    +        /* Some warning or error occurred */
    +        printf("%s\n", symbol->errtxt);
    +        if (error >= ZINT_ERROR) {
    +            /* Stop now */
    +            ZBarcode_Delete(symbol);
    +            return 1;
    +        }
    +    }
    +    /* Otherwise carry on with the rest of the application */
    +    ZBarcode_Delete(symbol);
    +    return 0;
    +}

    This code will exit with the appropriate message:

    Error 881: Malformed foreground RGB colour 'nonsense' (hexadecimal only)

    To treat all warnings as errors, set @@ -4129,13 +4149,13 @@ below:

    class="cross-ref-group">Table 5: Barcode Types (Symbologies). For example

    -
    symbol->symbology = BARCODE_LOGMARS;
    +
    symbol->symbology = BARCODE_LOGMARS;

    5.10 Adjusting Output Options

    The output_options member can be used to adjust various aspects of the output file. To select more than one option from the table below simply OR them together when adjusting this value:

    -
    symbol->output_options |= BARCODE_BIND | READER_INIT;
    +
    symbol->output_options |= BARCODE_BIND | READER_INIT;
    @@ -4157,15 +4177,15 @@ value:

    +href="#fn16" class="footnote-ref" id="fnref16" +role="doc-noteref">16 +and between rows if stacking multiple symbols.17 @@ -4215,8 +4235,8 @@ Memory (raster). +any specified whitespace).18 @@ -4348,11 +4368,11 @@ CLI and GUI, which is UNICODE_MODE.)

    FAST_MODE, EXTRA_ESCAPE_MODE, GS1SYNTAXENGINE_MODE and GS1RAW_MODE are optional. So, for example, you can set

    -
    symbol->input_mode = UNICODE_MODE | ESCAPE_MODE;
    +
    symbol->input_mode = UNICODE_MODE | ESCAPE_MODE;

    or

    -
    symbol->input_mode = GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE;
    +
    symbol->input_mode = GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE;

    whereas

    -
    symbol->input_mode = DATA_MODE | GS1_MODE;
    +
    symbol->input_mode = DATA_MODE | GS1_MODE;

    is not valid.

    Permissible escape sequences (ESCAPE_MODE) are listed in 6.6.3 QR Code (ISO 18004) for details.

    5.12 Multiple Segments

    For input data requiring multiple ECIs, the following functions may be used:

    -
    int ZBarcode_Encode_Segs(struct zint_symbol *symbol,
    -      const struct zint_seg segs[], const int seg_count);
    -
    -int ZBarcode_Encode_Segs_and_Print(struct zint_symbol *symbol,
    -      const struct zint_seg segs[], const int seg_count, int rotate_angle);
    -
    -int ZBarcode_Encode_Segs_and_Buffer(struct zint_symbol *symbol,
    -      const struct zint_seg segs[], const int seg_count, int rotate_angle);
    -
    -int ZBarcode_Encode_Segs_and_Buffer_Vector(struct zint_symbol *symbol,
    -      const struct zint_seg segs[], const int seg_count, int rotate_angle);
    +
    int ZBarcode_Encode_Segs(struct zint_symbol *symbol,
    +      const struct zint_seg segs[], const int seg_count);
    +
    +int ZBarcode_Encode_Segs_and_Print(struct zint_symbol *symbol,
    +      const struct zint_seg segs[], const int seg_count, int rotate_angle);
    +
    +int ZBarcode_Encode_Segs_and_Buffer(struct zint_symbol *symbol,
    +      const struct zint_seg segs[], const int seg_count, int rotate_angle);
    +
    +int ZBarcode_Encode_Segs_and_Buffer_Vector(struct zint_symbol *symbol,
    +      const struct zint_seg segs[], const int seg_count, int rotate_angle);

    These are direct analogues of the previously mentioned ZBarcode_Encode(), ZBarcode_Encode_and_Print(), @@ -4400,44 +4420,44 @@ consisting of "segs, seg_count" is given, with segs being an array of struct zint_seg segments and seg_count being the number of elements it contains. The zint_seg structure is of the form:

    -
    struct zint_seg {
    -    unsigned char *source; /* Data to encode */
    -    int length;            /* Length of `source`. If 0 or negative, `source`
    -                              must be NUL-terminated */
    -    int eci;               /* Extended Channel Interpretation */
    -};
    +
    struct zint_seg {
    +    unsigned char *source; /* Data to encode */
    +    int length;            /* Length of `source`. If 0 or negative, `source`
    +                              must be NUL-terminated */
    +    int eci;               /* Extended Channel Interpretation */
    +};

    The symbology must support ECIs (see Table 8: ECI-Aware Symbologies). For example:

    -
    #include <zint.h>
    -int main(int argc, char **argv)
    -{
    -    struct zint_seg segs[] = {
    -        { "Κείμενο", 0, 9 },
    -        { "Текст", 0, 7 },
    -        { "文章", 0, 20 }
    -    };
    -    struct zint_symbol *symbol;
    -    symbol = ZBarcode_Create();
    -    symbol->symbology = BARCODE_AZTEC;
    -    symbol->input_mode = UNICODE_MODE;
    -    ZBarcode_Encode_Segs(symbol, segs, 3);
    -    ZBarcode_Print(symbol, 0);
    -    ZBarcode_Delete(symbol);
    -    return 0;
    -}
    +
    #include <zint.h>
    +int main(int argc, char **argv)
    +{
    +    struct zint_seg segs[] = {
    +        { "Κείμενο", 0, 9 },
    +        { "Текст", 0, 7 },
    +        { "文章", 0, 20 }
    +    };
    +    struct zint_symbol *symbol;
    +    symbol = ZBarcode_Create();
    +    symbol->symbology = BARCODE_AZTEC;
    +    symbol->input_mode = UNICODE_MODE;
    +    ZBarcode_Encode_Segs(symbol, segs, 3);
    +    ZBarcode_Print(symbol, 0);
    +    ZBarcode_Delete(symbol);
    +    return 0;
    +}

    A maximum of 256 segments may be specified. Use of multiple segments with GS1 data is not currently supported.

    5.13 Scaling Helpers

    To help with scaling the output, the following three function are available:

    -
    float ZBarcode_Default_Xdim(int symbol_id);
    -
    -float ZBarcode_Scale_From_XdimDp(int symbol_id, float x_dim_mm, float dpmm,
    -        const char *filetype);
    -
    -float ZBarcode_XdimDP_From_Scale(int symbol_id, float scale,
    -        float x_dim_mm_or_dpmm, const char *filetype);
    +
    float ZBarcode_Default_Xdim(int symbol_id);
    +
    +float ZBarcode_Scale_From_XdimDp(int symbol_id, float x_dim_mm, float dpmm,
    +        const char *filetype);
    +
    +float ZBarcode_XdimDP_From_Scale(int symbol_id, float scale,
    +        float x_dim_mm_or_dpmm, const char *filetype);

    The first ZBarcode_Default_Xdim() returns the default X-dimension suggested by Zint for symbology symbol_id.

    The second ZBarcode_Scale_From_XdimDp() returns the @@ -4449,13 +4469,13 @@ however dpmm may be zero and defaults to 12 dpmm, and is assumed. For raster output (BMP/GIF/PCX/PNG/TIF) the scale is rounded to half-integer increments.

    For example:

    -
    /* Royal Mail 4-State Customer Code */
    -symbol->symbology = BARCODE_RM4SCC;
    -symbol->dpmm = 600.0f / 25.4f; /* 600 dpi */
    -symbol->scale = ZBarcode_Scale_From_XdimDp(
    -                        symbol->symbology,
    -                        ZBarcode_Default_Xdim(symbol->symbology),
    -                        symbol->dpmm, "PNG"); /* Returns 7.5 */
    +
    /* Royal Mail 4-State Customer Code */
    +symbol->symbology = BARCODE_RM4SCC;
    +symbol->dpmm = 600.0f / 25.4f; /* 600 dpi */
    +symbol->scale = ZBarcode_Scale_From_XdimDp(
    +                        symbol->symbology,
    +                        ZBarcode_Default_Xdim(symbol->symbology),
    +                        symbol->dpmm, "PNG"); /* Returns 7.5 */

    The third function ZBarcode_XdimDP_From_Scale() is the “reverse” of ZBarcode_Scale_From_XdimDp(), returning the X-dimension (in mm) or the dot density (in dpmm) given a scale @@ -4470,30 +4490,30 @@ the type of scanner used, the intended scanning distance, and what media

    5.14 Verifying Symbology Availability

    An additional function available in the API is:

    -
    int ZBarcode_ValidID(int symbol_id);
    +
    int ZBarcode_ValidID(int symbol_id);

    which allows you to check whether a given symbology is available, returning a non-zero value if so. For example:

    -
    if (ZBarcode_ValidID(BARCODE_PDF417) != 0) {
    -    printf("PDF417 available\n");
    -} else {
    -    printf("PDF417 not available\n");
    -}
    +
    if (ZBarcode_ValidID(BARCODE_PDF417) != 0) {
    +    printf("PDF417 available\n");
    +} else {
    +    printf("PDF417 not available\n");
    +}

    Another function that may be useful is:

    -
    int ZBarcode_BarcodeName(int symbol_id, char name[32]);
    +
    int ZBarcode_BarcodeName(int symbol_id, char name[32]);

    which copies the name of a symbology into the supplied name buffer, which should be 32 characters in length. The name is NUL-terminated, and zero is returned on success. For instance:

    -
    char name[32];
    -if (ZBarcode_BarcodeName(BARCODE_PDF417, name) == 0) {
    -    printf("%s\n", name);
    -}
    +
    char name[32];
    +if (ZBarcode_BarcodeName(BARCODE_PDF417, name) == 0) {
    +    printf("%s\n", name);
    +}

    will print “BARCODE_PDF417”.

    5.15 Checking Symbology Capabilities

    It can be useful for frontend programs to know the capabilities of a symbology. This can be determined using another additional function:

    -
    unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);
    +
    unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);

    by OR-ing the flags below in the cap_flag argument and checking the return to see which are set.

    Table 16: API output_options Values
    BARCODE_BIND_TOP Boundary bar above the symbol only.15
    BARCODE_BIND Boundary bars above and below the symbol -and between rows if stacking multiple symbols.16
    BARCODE_BOX
    BARCODE_QUIET_ZONES Add compliant quiet zones (additional to -any specified whitespace).17
    BARCODE_NO_QUIET_ZONES
    @@ -4522,8 +4542,8 @@ stacked symbologies are not stackable. +href="#fn19" class="footnote-ref" id="fnref19" +role="doc-noteref">19 @@ -4590,26 +4610,26 @@ symbologies.
    ZINT_CAP_EANUPC18 Is the symbology EAN/UPC?

    For example:

    -
    unsigned int cap;
    -cap = ZBarcode_Cap(BARCODE_PDF417, ZINT_CAP_HRT | ZINT_CAP_ECI);
    -if (cap & ZINT_CAP_HRT) {
    -    printf("PDF417 supports HRT\n");
    -} else {
    -    printf("PDF417 does not support HRT\n");
    -}
    -if (cap & ZINT_CAP_ECI) {
    -    printf("PDF417 supports ECI\n");
    -} else {
    -    printf("PDF417 does not support ECI\n");
    -}
    +
    unsigned int cap;
    +cap = ZBarcode_Cap(BARCODE_PDF417, ZINT_CAP_HRT | ZINT_CAP_ECI);
    +if (cap & ZINT_CAP_HRT) {
    +    printf("PDF417 supports HRT\n");
    +} else {
    +    printf("PDF417 does not support HRT\n");
    +}
    +if (cap & ZINT_CAP_ECI) {
    +    printf("PDF417 supports ECI\n");
    +} else {
    +    printf("PDF417 does not support ECI\n");
    +}

    5.16 Feedback

    On successful encodation (after using ZBarcode_Encode() etc.) the option_1, option_2 and option_3 members will be set to the values used by Zint to create the barcode. This is useful for feedback if the values were left as defaults or were overridden by Zint.

    -

    In particular for symbologies that have masks,19 +

    In particular for symbologies that have masks,20 option_3 will contain the mask used as (N + 1) << 8, N being the mask. Also Aztec Code will return the actual ECC percentage used in option_1 as @@ -4633,8 +4653,8 @@ members of zint_seg will be set accordingly - the unconverted data in source, the data length in length, and the character set the data was converted to in eci. Any check characters encoded will be included,20 and for GS1 data any +href="#fn21" class="footnote-ref" id="fnref21" +role="doc-noteref">21 and for GS1 data any FNC1 separators will be represented as GS (ASCII 29) characters. UPC-A and UPC-E data will be expanded to EAN-13, as will EAN-8 but only if it has an add-on (otherwise it will remain at @@ -4651,15 +4671,15 @@ member using the two helper functions discussed next.

    convenience functions

    As a convenience the conversion done by Zint from UTF-8 to ECIs is exposed in two helper functions (compatible with the -libzueci21 functions +libzueci22 functions zueci_utf8_to_eci() and zueci_dest_len_eci()):

    -
    int ZBarcode_UTF8_To_ECI(int eci, const unsigned char *source, int length,
    -      unsigned char dest[], int *p_dest_length);
    -
    -int ZBarcode_Dest_Len_ECI(int eci, const unsigned char *source, int length,
    -      int *p_dest_length);
    +
    int ZBarcode_UTF8_To_ECI(int eci, const unsigned char *source, int length,
    +      unsigned char dest[], int *p_dest_length);
    +
    +int ZBarcode_Dest_Len_ECI(int eci, const unsigned char *source, int length,
    +      int *p_dest_length);

    Call ZBarcode_Dest_Len_ECI() to get the size of buffer sufficient to accommodate the conversion, then call ZBarcode_UTF8_To_ECI() with an appropriately sized buffer @@ -4671,17 +4691,17 @@ is not NUL-terminated. The obsolete ECIs 0, 1 and 2 are supported.

    5.18 Zint Version

    Whether the Zint library was built without PNG support may be determined with:

    -
    int ZBarcode_NoPng(void);
    +
    int ZBarcode_NoPng(void);

    which returns 1 if PNG support is not available, else zero.

    Similarly, but with opposite sense, whether the Zint library was built with GS1 Syntax Engine support may be determined with:

    -
    int ZBarcode_HaveGS1SyntaxEngine(void);
    +
    int ZBarcode_HaveGS1SyntaxEngine(void);

    which returns 1 if GS1 Syntax Engine support is available, else zero.

    Lastly, the version of the Zint library linked to is returned by:

    -
    int ZBarcode_Version(void);
    +
    int ZBarcode_Version(void);

    The version parts are separated by hundreds. For instance, version "2.9.1" is returned as "20901".

    5.19 Debug Info

    @@ -4759,9 +4779,9 @@ entered a leading zero is added by Zint. A maximum of 62 pairs (124 digits) can be encoded.

    +alt="zint -b C25INTER --compliant -d "9212320967"" />
    Figure 33: -zint -b C25INTER --compliantheight -d "9212320967"
    +zint -b C25INTER --compliant -d "9212320967"

    No check digit is added by default, but can be set the same as for 6.1.2.1 Standard Code 2 of 5.

    @@ -4785,9 +4805,9 @@ check digit is given, in which case the check digit will be verified. A standard GS1 check digit is added by Zint unless already given.

    +alt="zint -b ITF14 --compliant -d "9212320967145"" />
    Figure 35: -zint -b ITF14 --compliantheight -d "9212320967145"
    +zint -b ITF14 --compliant -d "9212320967145"

    If no border option is specified Zint defaults to adding a bounding box with a border width of 5. This behaviour can be overridden by using @@ -4799,9 +4819,9 @@ can be achieved by explicitly setting the border type to box (or bind or bindtop) and leaving the border width 0.

    +alt="zint -b ITF14 --box --compliant -d "9212320967145"" />
    Figure 36: -zint -b ITF14 --box --compliantheight -d "9212320967145"
    +zint -b ITF14 --box --compliant -d "9212320967145"

    6.1.2.7 Deutsche Post Leitcode

    Leitcode is based on Interleaved Code 2 of 5 and is used by Deutsche @@ -4831,9 +4851,9 @@ encodes a GTIN-12, a 12-digit Global Trade Item Number that includes a standard GS1 check digit.

    +alt="zint -b UPCA --compliant -d "01234500005"" />
    Figure 39: -zint -b UPCA --compliantheight -d "01234500005"
    +zint -b UPCA --compliant -d "01234500005"

    Input up to 11 digits may be given, to which a check digit will be added by Zint. A 12-digit input including the check digit may also be @@ -4845,35 +4865,36 @@ zero-filled.

    data separated from the main data by a '+' character or a space. For example, to draw a UPC-A symbol with the data “01234500005” and 5-digit add-on data “12345” use the command:

    -
    zint -b UPCA -d "01234500005+12345"
    +
    zint -b UPCA -d "01234500005+12345"

    or using the API:

    -
    symbol->symbology = BARCODE_UPCA;
    -/* Using '+' */
    -error = ZBarcode_Encode_and_Print(symbol, "01234500005+12345", 0, 0);
    -/* Or a space */
    -error = ZBarcode_Encode_and_Print(symbol, "01234500005 12345", 0, 0);
    +
    symbol->symbology = BARCODE_UPCA;
    +/* Using '+' */
    +error = ZBarcode_Encode_and_Print(symbol, "01234500005+12345", 0, 0);
    +/* Or a space */
    +error = ZBarcode_Encode_and_Print(symbol, "01234500005 12345", 0, 0);
    +alt="zint -b UPCA --compliant -d "01234500005+12345"" />
    Figure 40: -zint -b UPCA --compliantheight -d "01234500005+12345"
    +zint -b UPCA --compliant -d "01234500005+12345"

    A quiet zone indicator can be added to the HRT by setting --guardwhitespace (API output_options |= EANUPC_GUARD_WHITESPACE). For UPC, this is only relevant when there is an add-on:

    -
    zint -b UPCA -d "01234500005+12345" --guardwhitespace
    +
    zint -b UPCA -d "01234500005+12345" --guardwhitespace

    or using the API:

    -
    symbol->symbology = BARCODE_UPCA;
    -symbol->output_options |= EANUPC_GUARD_WHITESPACE;
    -error = ZBarcode_Encode_and_Print(symbol, "01234500005+12345", 0, 0);
    +
    symbol->symbology = BARCODE_UPCA;
    +symbol->output_options |= EANUPC_GUARD_WHITESPACE;
    +error = ZBarcode_Encode_and_Print(symbol, "01234500005+12345", 0, 0);
    +alt="zint -b UPCA --compliant -d "01234500005+12345" --guardwhitespace" />
    Figure 41: -zint -b UPCA --compliantheight -d "01234500005+12345" --guardwhitespace
    +zint -b UPCA --compliant -d "01234500005+12345" --guardwhitespace

    You can adjust the gap between the main symbol and an add-on in integral multiples of the X-dimension by setting --addongap @@ -4890,9 +4911,9 @@ be ‘0’ or ‘1’ (the latter is known as number system 1 and is non-standard). Input less than 7 digits will be zero-filled.

    +alt="zint -b UPCE --compliant -d "123455"" />
    Figure 42: -zint -b UPCE --compliantheight -d "123455"
    +zint -b UPCE --compliant -d "123455"

    An 8-digit input including the check digit may also be supplied, in which case Zint will verify the check digit, or the symbology @@ -4903,13 +4924,13 @@ a '+' character or a space as a separator, and a quiet zone indicator can be added when there is an add-on by setting --guardwhitespace (API output_options |= EANUPC_GUARD_WHITESPACE):

    -
    zint -b UPCE -d "123455+12" --guardwhitespace
    +
    zint -b UPCE -d "123455+12" --guardwhitespace
    +alt="zint -b UPCE --compliant -d "123455+12" --guardwhitespace" />
    Figure 43: -zint -b UPCE --compliantheight -d "123455+12" --guardwhitespace
    +zint -b UPCE --compliant -d "123455+12" --guardwhitespace

    You can adjust the gap between the main symbol and an add-on in integral multiples of the X-dimension by setting --addongap @@ -4929,9 +4950,9 @@ defines the symbologies EAN-13, EAN-8 and ISBN (a subset of EAN-13).

    includes a standard GS1 check digit.

    +alt="zint -b EAN13 --compliant -d "952012345678"" />
    Figure 44: -zint -b EAN13 --compliantheight -d "952012345678"
    +zint -b EAN13 --compliant -d "952012345678"

    Input up to 12 digits may be given, to which a check digit will be added by Zint, or a 13-digit input can be supplied in which case Zint @@ -4939,39 +4960,38 @@ will validate the check digit. Input less than 12 digits will be zero-filled.

    A 2-digit or 5-digit add-on can be added by using a ‘+’ or space character as with UPC symbols. For example:

    -
    zint -b EAN13 -d "952012345678+21"
    +
    zint -b EAN13 -d "952012345678+21"

    will encode an EAN-13 symbol with a 2-digit add-on. As before these results can be achieved using the API:

    -
    symbol->symbology = BARCODE_EAN13;
    -error = ZBarcode_Encode_and_Print(symbol, "952012345678+21", 0, 0);
    +
    symbol->symbology = BARCODE_EAN13;
    +error = ZBarcode_Encode_and_Print(symbol, "952012345678+21", 0, 0);
    +alt="zint -b EAN13 --compliant -d "952012345678+21"" />
    Figure 45: -zint -b EAN13 --compliantheight -d "952012345678+21"
    +zint -b EAN13 --compliant -d "952012345678+21"

    Options to add quiet zone indicators and to adjust the add-on gap and the guard bar descent height are the same as for 6.1.3.2 UPC Version E. For instance:

    -
    zint -b EAN13 -d "9520123456788" --guarddescent=2.5 --guardwhitespace
    +
    zint -b EAN13 -d "9520123456788" --guarddescent=2.5 --guardwhitespace
    +alt="zint -b EAN13 --compliant -d "9520123456788" --guarddescent=2.5 --guardwhitespace" />
    Figure 46: -zint -b EAN13 --compliantheight -d "9520123456788" -–guarddescent=2.5 –guardwhitespace
    +zint -b EAN13 --compliant -d "9520123456788" --guarddescent=2.5 --guardwhitespace

    6.1.4.2 EAN-8

    EAN-8 is a shortened version of EAN-13, encoding a GTIN-8 (a GTIN-13 with 5 leading zeroes implied), for use with small packages.

    +alt="zint -b EAN8 --compliant -d "9520000"" />
    Figure 47: -zint -b EAN8 --compliantheight -d "9520000"
    +zint -b EAN8 --compliant -d "9520000"

    Input up to 7 digits may be supplied, to which Zint will add a standard GS1 check digit. An 8-digit input including the check digit may @@ -4980,18 +5000,18 @@ less than 7 digits will be zero-filled.

    Options to add quiet zone indicators and to adjust the guard bar descent height are the same as for 6.1.3.2 UPC Version E. For instance:

    -
    zint -b EAN8 -d "9520000" --guardwhitespace
    +
    zint -b EAN8 -d "9520000" --guardwhitespace

    or using the API:

    -
    symbol->symbology = BARCODE_EAN8;
    -symbol->output_options |= EANUPC_GUARD_WHITESPACE;
    -error = ZBarcode_Encode_and_Print(symbol, "9520000", 0, 0);
    +
    symbol->symbology = BARCODE_EAN8;
    +symbol->output_options |= EANUPC_GUARD_WHITESPACE;
    +error = ZBarcode_Encode_and_Print(symbol, "9520000", 0, 0);
    +alt="zint -b EAN8 --compliant -d "9520000" –guardwhitespace" />
    Figure 48: -zint -b EAN8 --compliantheight -d "9520000" +zint -b EAN8 --compliant -d "9520000" –guardwhitespace

    2-digit and 5-digit add-ons may also be added, and the gap adjusted, @@ -5005,17 +5025,17 @@ check digit needs to be present in the input data and will be verified before the symbol is generated.

    +alt="zint -b ISBNX --compliant -d "9789295055124"" />
    Figure 49: -zint -b ISBNX --compliantheight -d "9789295055124"
    +zint -b ISBNX --compliant -d "9789295055124"

    As with EAN-13, a quiet zone indicator can be added using --guardwhitespace:

    +alt="zint -b ISBNX --compliant -d "9789295055124" --guardwhitespace" />
    Figure 50: -zint -b ISBNX --compliantheight -d "9789295055124" --guardwhitespace
    +zint -b ISBNX --compliant -d "9789295055124" --guardwhitespace

    2-digit and 5-digit add-on symbols can be added using a + or space character, and there are options to adjust the @@ -5028,25 +5048,25 @@ standalone symbols using the symbologies BARCODE_EAN_2ADDON (11) and BARCODE_EAN_5ADDON (12).

    +alt="zint -b EAN_2ADDON --compliant -d "12"" />
    Figure 51: -zint -b EAN_2ADDON --compliantheight -d "12"
    +zint -b EAN_2ADDON --compliant -d "12"

    As with the main EAN/UPC symbols a quiet zone indicator can be added using ---guardwhitespace. For instance

    -
    zint -b EAN_5ADDON -d "54321" --guardwhitespace
    +
    zint -b EAN_5ADDON -d "54321" --guardwhitespace

    will generate a standalone 5-digit add-on with quiet zone guards, or using the API:

    -
    symbol->symbology = BARCODE_EAN_5ADDON;
    -symbol->output_options |= EANUPC_GUARD_WHITESPACE;
    -error = ZBarcode_Encode_and_Print(symbol, "54321", 0, 0);
    +
    symbol->symbology = BARCODE_EAN_5ADDON;
    +symbol->output_options |= EANUPC_GUARD_WHITESPACE;
    +error = ZBarcode_Encode_and_Print(symbol, "54321", 0, 0);
    +alt="zint -b EAN_5ADDON --compliant -d "54321" –guardwhitespace" />
    Figure 52: -zint -b EAN_5ADDON --compliantheight -d "54321" +zint -b EAN_5ADDON --compliant -d "54321" –guardwhitespace

    6.1.5 Plessey

    @@ -5127,9 +5147,9 @@ and can encode ASCII text input, up to a maximum of 69 characters. Telepen includes a hidden modulo-127 check digit, added by Zint.

    +alt="zint -b TELEPEN --compliant -d "Z8000"" />
    Figure 55: -zint -b TELEPEN --compliantheight -d "Z8000"
    +zint -b TELEPEN --compliant -d "Z8000"

    AIM-defined Start/Stop characters may be enabled by setting --vers=1 (API option_2 = 1). In this mode @@ -5139,9 +5159,9 @@ Numeric, where each symbol character encodes a digit pair (or a “digit X” pair - see Telepen Numeric below):

    +alt="zint -b TELEPEN --compliant -d "Z\L8000" -esc --vers=1" />
    Figure 56: -zint -b TELEPEN --compliantheight -d "Z\L8000" -esc --vers=1
    +zint -b TELEPEN --compliant -d "Z\L8000" -esc --vers=1

    However not all barcode readers recognise this mode so check before using.

    @@ -5155,26 +5175,26 @@ digits is supplied, Zint will add a leading zero. Up to 138 digits can be encoded. A hidden modulo-127 check digit is added by Zint.

    +alt="zint -b TELEPEN_NUM --compliant -d "466X33"" />
    Figure 57: -zint -b TELEPEN_NUM --compliantheight -d "466X33"
    +zint -b TELEPEN_NUM --compliant -d "466X33"

    Additionally trailing ASCII characters may be encoded by prefixing them with a DLE control character (ASCII 16, escape sequence \L) and appending them to the numeric data:

    +alt="zint -b TELEPEN_NUM --compliant -d "12\LAB" --esc" />
    Figure 58: -zint -b TELEPEN_NUM --compliantheight -d "12\LAB" --esc
    +zint -b TELEPEN_NUM --compliant -d "12\LAB" --esc

    This method allows odd numbers to be encoded without a leading zero:

    +alt="zint -b TELEPEN_NUM --compliant -d "123\L4" --esc" />
    Figure 59: -zint -b TELEPEN_NUM --compliantheight -d "123\L4" --esc
    +zint -b TELEPEN_NUM --compliant -d "123\L4" --esc

    AIM-defined Start/Stop characters may be enabled by setting --vers=1 (API option_2 = 1). This allows @@ -5192,9 +5212,9 @@ A-Z, dash (-), full stop (.), space, asterisk (+) and percent (%).

    +alt="zint -b CODE39 --compliant -d "1A" --vers=1" />
    Figure 60: -zint -b CODE39 --compliantheight -d "1A" --vers=1
    +zint -b CODE39 --compliant -d "1A" --vers=1

    The standard does not require a check digit but a modulo-43 check digit can be added if desired by setting --vers=1 (API @@ -5207,9 +5227,9 @@ Standard Code 39 to provide support for the full 7-bit ASCII character set.

    +alt="zint -b EXCODE39 --compliant -d "123.45#@fd"" />
    Figure 61: -zint -b EXCODE39 --compliantheight -d "123.45#@fd"
    +zint -b EXCODE39 --compliant -d "123.45#@fd"

    The check digit options are the same as for 6.1.7.1 Standard Code 39 (ISO @@ -5222,9 +5242,9 @@ Readable Text, but may be shown by setting --vers=1 (API option_2 = 1).

    +alt="zint -b CODE93 --compliant -d "C93"" />
    Figure 62: -zint -b CODE93 --compliantheight -d "C93"
    +zint -b CODE93 --compliant -d "C93"

    6.1.7.4 PZN (Pharmazentralnummer)

    PZN is a Code 39 based symbology used by the pharmaceutical industry @@ -5234,9 +5254,9 @@ zero-filled. An 8-digit input can be supplied in which case Zint will validate the check digit.

    +alt="zint -b PZN --compliant -d "2758089"" />
    Figure 63: -zint -b PZN --compliantheight -d "2758089"
    +zint -b PZN --compliant -d "2758089"

    To encode a PZN7 (obsolete since 2013) instead set --vers=1 (API option_2 = 1) and supply up to 7 @@ -5251,9 +5271,9 @@ href="#standard-code-39-iso-16388">6.1.7.1 Standard Code 39 (ISO restricted to a maximum of 30 characters.

    +alt="zint -b LOGMARS --compliant -d "12345/ABCDE" --vers=1" />
    Figure 64: -zint -b LOGMARS --compliantheight -d "12345/ABCDE" --vers=1
    +zint -b LOGMARS --compliant -d "12345/ABCDE" --vers=1

    6.1.7.6 Code 32

    A variation of Code 39 used by the Italian Ministry of Health @@ -5262,9 +5282,9 @@ products. This symbology requires a numeric input up to 8 digits in length. A check digit is added by Zint.

    +alt="zint -b CODE32 --compliant -d "14352312"" />
    Figure 65: -zint -b CODE32 --compliantheight -d "14352312"
    +zint -b CODE32 --compliant -d "14352312"

    6.1.7.7 HIBC Code 39

    This variant adds a leading '+' character and a trailing @@ -5272,9 +5292,9 @@ modulo-49 check digit to a standard Code 39 symbol as required by the Health Industry Barcode standards.

    +alt="zint -b HIBC_39 --compliant -d "14352312"" />
    Figure 66: -zint -b HIBC_39 --compliantheight -d "14352312"
    +zint -b HIBC_39 --compliant -d "14352312"

    6.1.7.8 Vehicle Identification Number (VIN)

    @@ -5299,9 +5319,9 @@ American Blood Commission adopted Codabar in 1979 as the standard barcode for blood products.

    +alt="zint -b CODABAR --compliant -d "A37859B"" />
    Figure 68: -zint -b CODABAR --compliantheight -d "A37859B"
    +zint -b CODABAR --compliant -d "A37859B"

    Codabar can encode up to 103 characters starting and ending with the letters A-D and containing between these letters the numbers 0-9, dash @@ -5319,9 +5339,9 @@ identification of pharmaceuticals. The symbology is able to encode whole numbers between 3 and 131070.

    +alt="zint -b PHARMA --compliant -d "130170"" />
    Figure 69: -zint -b PHARMA --compliantheight -d "130170"
    +zint -b PHARMA --compliant -d "130170"

    6.1.10 Code 128

    6.1.10.1 Standard Code 128 (ISO @@ -5349,23 +5369,23 @@ processing normal escape sequences also processes the extra escape sequences given in Table 3: Extra Escape Sequences. For instance

    -
    zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc
    +
    zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc

    encodes the data "A<FNC1>BC<FNC1>DEF", where <FNC1> represents the FNC1 character.

    If the data contains an extra escape sequence, it can be escaped by doubling the caret (^). For instance

    -
    zint -b CODE128 -d "A\^1BC\^^1DEF" --extraesc
    +
    zint -b CODE128 -d "A\^1BC\^^1DEF" --extraesc

    will encode the data "A<FNC1>BC\^1DEF".

    Manual switching of Code Sets is possible using the Code 128-specific extra escapes \^A, \^B, \^C and \^@ (the latter turns off manual Code Set selection). For instance the following will force switching to Code Set B for the data "5678" (normally Code Set C would be used throughout):

    -
    zint -b CODE128 -d "1234\^B5678" --extraesc
    +
    zint -b CODE128 -d "1234\^B5678" --extraesc

    The manually selected Code Set will apply until the next Code Set escape sequence or until a \^@, with the exception that data that cannot be represented in that Code Set will be switched as @@ -5377,8 +5397,8 @@ digits (60 alphanumerics) are not recommended.

    Code 128 Suppress Code Set C (Code Sets A and B only)

    It is sometimes advantageous to stop Code 128 from using Code Set C which compresses numerical data. The BARCODE_CODE128AB22 variant (symbology 60) suppresses +href="#fn23" class="footnote-ref" id="fnref23" +role="doc-noteref">23 variant (symbology 60) suppresses Code Set C in favour of Code Sets A and B.

    4.11.3.1 GS1 Data Entry. Here we will use the square bracket format.

    +alt="zint -b GS1_128 --compliant -d "[01]98898765432106[3202]012345[15]991231"" />
    Figure 72: -zint -b GS1_128 --compliantheight -d "[01]98898765432106[3202]012345[15]991231"
    +zint -b GS1_128 --compliant -d "[01]98898765432106[3202]012345[15]991231"

    Fixed length data should be entered at the appropriate length for correct encoding. GS1-128 does not support extended ASCII (ISO/IEC 8859-1) characters. Check digits for GTIN data AI (01) are not generated and need to be included in the input data. The following is an example of a valid GS1-128 input:

    -
    zint -b GS1_128 -d "[01]98898765432106[3202]012345[15]991231"
    +
    zint -b GS1_128 -d "[01]98898765432106[3202]012345[15]991231"

    6.1.10.4 EAN-14

    A shorter version of GS1-128 which encodes GTIN-14 data only, EAN-14 takes a 13-digit input, which will be prefixed with leading zeroes if @@ -5415,9 +5435,9 @@ The GS1 check digit (if not given) and HRT-only AI "(01)" are added by Zint.

    +alt="zint -b EAN14 --compliant -d "9889876543210"" />
    Figure 73: -zint -b EAN14 --compliantheight -d "9889876543210"
    +zint -b EAN14 --compliant -d "9889876543210"

    6.1.10.5 NVE-18 (SSCC-18)

    A variation of Code 128 the ‘Nummer der Versandeinheit’ standard, @@ -5429,9 +5449,9 @@ digit is included, in which case the check digit will be verified. Check digit(s) and HRT-only AI "(00)" are added by Zint.

    +alt="zint -b NVE18 --compliant -d "37612345000001003"" />
    Figure 74: -zint -b NVE18 --compliantheight -d "37612345000001003"
    +zint -b NVE18 --compliant -d "37612345000001003"

    6.1.10.6 HIBC Code 128

    This variation adds a leading '+' character and a @@ -5448,9 +5468,9 @@ alt="zint -b HIBC_128 -d "A123BJC5D6E71"" /> Paketdienst).

    +alt="zint -b DPD --compliant -d "000393206219912345678101040"" />
    Figure 76: -zint -b DPD --compliantheight -d "000393206219912345678101040"
    +zint -b DPD --compliant -d "000393206219912345678101040"

    DPD Code requires a 27 or 28 character input. For 28 character input, the first character is an identification tag (Barcode ID), which should @@ -5509,9 +5529,9 @@ a modulo-11 check digit, and "CC" is a two-character ISO 3166-1 country code.

    +alt="zint -b UPU_S10 --compliant -d "EE876543216CA"" />
    Figure 77: -zint -b UPU_S10 --compliantheight -d "EE876543216CA"
    +zint -b UPU_S10 --compliant -d "EE876543216CA"

    The check digit may be omitted in which case Zint will add it. Warnings will be generated if the service indicator is non-standard or @@ -5534,9 +5554,9 @@ standard GS1 check digit may be given, in which case the check digit will be verified.) Input less than 13 digits will be zero-filled.

    +alt="zint -b DBAR_OMN --compliant -d "0950110153001"" />
    Figure 78: -zint -b DBAR_OMN --compliantheight -d "0950110153001"
    +zint -b DBAR_OMN --compliant -d "0950110153001"

    GS1 DataBar Omnidirectional symbols should have a height of 33 or greater. To produce a GS1 DataBar Truncated symbol set the symbol height @@ -5559,9 +5579,9 @@ may be given in which case the check digit will be verified. Input less than 13 digits will be zero-filled.

    +alt="zint -b DBAR_LTD --compliant -d "0950110153001"" />
    Figure 80: -zint -b DBAR_LTD --compliantheight -d "0950110153001"
    +zint -b DBAR_LTD --compliant -d "0950110153001"

    6.1.11.3 GS1 DataBar Expanded

    Previously known as RSS Expanded this is a variable length symbology @@ -5571,17 +5591,17 @@ Data Entry, and will be displayed using parentheses (round brackets) in the Human Readable Text.

    +alt="zint -b DBAR_EXP --compliant -d "[01]98898765432106[3202]012345[15]991231"" />
    Figure 81: -zint -b DBAR_EXP --compliantheight -d "[01]98898765432106[3202]012345[15]991231"
    +zint -b DBAR_EXP --compliant -d "[01]98898765432106[3202]012345[15]991231"

    The GTIN-14 data for AI (01) must include the standard GS1 check digit as this is not calculated by Zint when this symbology is encoded. Data for fixed-length AIs must be entered at the appropriate length. The maximum capacity is 74 numerics or 41 alphanumerics. The following is an example of a valid GS1 DataBar Expanded input:

    -
    zint -b DBAR_EXP -d "[01]98898765432106[3202]012345[15]991231"
    +
    zint -b DBAR_EXP -d "[01]98898765432106[3202]012345[15]991231"

    6.1.12 Korea Post Barcode

    The Korean Postal Barcode is used to encode a 6-digit number and includes one check digit.

    @@ -5600,9 +5620,9 @@ input data: e.g. a three character input string generates a 4 channel code by default.

    +alt="zint -b CHANNEL -d "453678" --compliant" />
    Figure 83: -zint -b CHANNEL -d "453678" --compliantheight
    +zint -b CHANNEL -d "453678" --compliant

    The maximum values permitted depend on the number of channels used as shown in the table below:

    @@ -5659,9 +5679,9 @@ single check character is added by Zint, appearing in the 2nd character position. Lowercase input is automatically made uppercase.

    +alt="zint -b BC412 -d "AQ45670" --compliant" />
    Figure 84: -zint -b BC412 -d "AQ45670" --compliantheight
    +zint -b BC412 -d "AQ45670" --compliant

    6.2 Stacked Symbologies

    6.2.1 Basic Symbol Stacking

    @@ -5669,17 +5689,17 @@ alt="zint -b BC412 -d "AQ45670" --compliantheight" /> primarily in the vehicle industry, is to simply stack one-dimensional codes on top of each other. This can be achieved at the command prompt by giving more than one set of input data. For example

    -
    zint -d "This" -d "That"
    +
    zint -d "This" -d "That"

    will draw two Code 128 symbols, one on top of the other. The same result can be achieved using the API by executing the ZBarcode_Encode() function more than once on a symbol. For example:

    -
    symbol->symbology = BARCODE_CODE128;
    -error = ZBarcode_Encode(symbol, "This", 0);
    -error = ZBarcode_Encode(symbol, "That", 0);
    -error = ZBarcode_Print(symbol);
    +
    symbol->symbology = BARCODE_CODE128;
    +error = ZBarcode_Encode(symbol, "This", 0);
    +error = ZBarcode_Encode(symbol, "That", 0);
    +error = ZBarcode_Print(symbol);
    zint -d "This" -d "That" @@ -5695,8 +5715,8 @@ specifying --bind (API separator bars in integral multiples of the X-dimension (minimum and default 1, maximum 4) can be set by --separator (API option_3):

    -
    zint --bind --notext --separator=2 -d "This" -d "That"
    +
    zint --bind --notext --separator=2 -d "This" -d "That"
    zint --notext --bind --separator=2 -d "This" -d "That" @@ -5738,9 +5758,9 @@ use can be set using the --rows option (API option_1), with values from 2 to 16.

    +alt="zint -b CODE16K --compliant -d "ab0123456789"" />
    Figure 88: -zint -b CODE16K --compliantheight -d "ab0123456789"
    +zint -b CODE16K --compliant -d "ab0123456789"

    6.2.4 PDF417 (ISO 15438)

    Heavily used in the parcel industry, the PDF417 symbology can encode @@ -5831,9 +5851,9 @@ row, making it suitable for small items when omnidirectional scanning is not required.

    +alt="zint -b DBAR_STK --compliant -d "9889876543210"" />
    Figure 92: -zint -b DBAR_STK --compliantheight -d "9889876543210"
    +zint -b DBAR_STK --compliant -d "9889876543210"

    6.2.7.2 GS1 DataBar Stacked Omnidirectional

    @@ -5844,9 +5864,9 @@ GS1 DataBar Omnidirectional and GS1 DataBar Truncated). The data is encoded in two rows of bars with a central 3-row separator.

    +alt="zint -b DBAR_OMNSTK --compliant -d "9889876543210"" />
    Figure 93: -zint -b DBAR_OMNSTK --compliantheight -d "9889876543210"
    +zint -b DBAR_OMNSTK --compliant -d "9889876543210"

    6.2.7.3 GS1 DataBar Expanded Stacked

    @@ -5856,9 +5876,9 @@ href="#gs1-databar-expanded">6.1.11.3 GS1 DataBar Expanded), with the same maximum capacity.

    +alt="zint -b DBAR_EXPSTK --compliant -d "[01]98898765432106[3202]012345[15]991231"" />
    Figure 94: -zint -b DBAR_EXPSTK --compliantheight -d "[01]98898765432106[3202]012345[15]991231"
    +zint -b DBAR_EXPSTK --compliant -d "[01]98898765432106[3202]012345[15]991231"

    The width of the symbol can be altered using the --cols switch (API option_2). In this case the number of columns @@ -5880,9 +5900,9 @@ set using the --rows option (API option_1), with values from 2 to 8.

    +alt="zint -b CODE49 --compliant -d "MULTIPLE ROWS IN CODE 49"" />
    Figure 95: -zint -b CODE49 --compliantheight -d "MULTIPLE ROWS IN CODE 49"
    +zint -b CODE49 --compliant -d "MULTIPLE ROWS IN CODE 49"

    6.3 GS1 Composite Symbols (ISO 24723)

    @@ -5985,18 +6005,18 @@ should be entered into a primary string with the data for the 2D component being entered in the normal way. To do this at the command prompt use the --primary switch (API primary). For example:

    -
    zint -b EAN13_CC --mode=1 --primary=331234567890 -d "[99]1234-abcd"
    +
    zint -b EAN13_CC --mode=1 --primary=331234567890 -d "[99]1234-abcd"

    This creates an EAN-13 linear component with the data "331234567890" and a 2D CC-A (see below) component with the data "(99)1234-abcd". The same results can be achieved using the API as shown below:

    -
    symbol->symbology = BARCODE_EAN13_CC;
    -symbol->option_1 = 1;
    -strcpy(symbol->primary, "331234567890");
    -ZBarcode_Encode_and_Print(symbol, "[99]1234-abcd", 0, 0);
    +
    symbol->symbology = BARCODE_EAN13_CC;
    +symbol->option_1 = 1;
    +strcpy(symbol->primary, "331234567890");
    +ZBarcode_Encode_and_Print(symbol, "[99]1234-abcd", 0, 0);

    2-digit and 5-digit add-on data can be used with EAN and UPC symbols using the '+' character as described in sections 6.1.3 UPC (Universal @@ -6019,9 +6039,9 @@ length (e.g. if all capitals, at most 30, excluding AI). To select CC-A use --mode=1 (API option_1 = 1).

    +alt="zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=1 --primary=331234567890" />
    Figure 96: -zint -b EAN13_CC --compliantheight -d "[99]1234-abcd" --mode=1 --primary=331234567890
    +zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=1 --primary=331234567890

    6.3.2 CC-B

    This system uses MicroPDF417 to encode the 2D component. The size of @@ -6032,9 +6052,9 @@ string of shorter length. To select CC-B use --mode=2 (API option_1 = 2).

    +alt="zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=2 --primary=331234567890" />
    Figure 97: -zint -b EAN13_CC --compliantheight -d "[99]1234-abcd" --mode=2 --primary=331234567890
    +zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=2 --primary=331234567890

    6.3.3 CC-C

    This system uses PDF417 and can only be used in conjunction with a @@ -6043,9 +6063,9 @@ an alphanumeric string of shorter length. To select CC-C use --mode=3 (API option_1 = 3).

    +alt="zint -b GS1_128_CC --compliant -d "[99]1234-abcd" --mode=3 --primary="[01]03312345678903"" />
    Figure 98: -zint -b GS1_128_CC --compliantheight -d "[99]1234-abcd" --mode=3 --primary="[01]03312345678903"
    +zint -b GS1_128_CC --compliant -d "[99]1234-abcd" --mode=3 --primary="[01]03312345678903"

    6.4 Two-Track Symbols

    6.4.1 Pharmacode Two-Track

    @@ -6056,9 +6076,9 @@ pharmaceuticals. The symbology is able to encode whole numbers between 4 and 64570080.

    +alt="zint -b PHARMA_TWO --compliant -d "29876543"" />
    Figure 99: -zint -b PHARMA_TWO --compliantheight -d "29876543"
    +zint -b PHARMA_TWO --compliant -d "29876543"

    6.4.2 POSTNET

    Used by the United States Postal Service until 2009, the POSTNET @@ -6071,9 +6091,9 @@ lengths as used by USPS were PostNet6 (5-digit ZIP input), will be issued if the input length is not one of these.

    +alt="zint -b POSTNET --compliant -d "12345678901"" />
    Figure 100: -zint -b POSTNET --compliantheight -d "12345678901"
    +zint -b POSTNET --compliant -d "12345678901"

    6.4.3 PLANET

    Used by the United States Postal Service until 2009, the PLANET @@ -6086,9 +6106,9 @@ of up to 38 digits in length, standard lengths used by USPS were length is not one of these.

    +alt="zint -b PLANET --compliant -d "4012345235636"" />
    Figure 101: -zint -b PLANET --compliantheight -d "4012345235636"
    +zint -b PLANET --compliant -d "4012345235636"

    6.4.4 Brazilian CEPNet

    Based on POSTNET, the CEPNet symbol is used by Correios, the @@ -6097,9 +6117,9 @@ numbers on mail items. Input should consist of eight digits with the check digit being automatically added by Zint.

    +alt="zint -b CEPNET --compliant -d "12345678"" />
    Figure 102: -zint -b CEPNET --compliantheight -d "12345678"
    +zint -b CEPNET --compliant -d "12345678"

    6.4.5 DX Film Edge Barcode

    Introduced by Kodak in the 1980s, the DX (Digital Index) barcode is @@ -6107,9 +6127,9 @@ printed on the bottom edge of 35mm film to aid in the reordering and post-processing of prints.

    +alt="zint -b DXFILMEDGE --compliant -d "112-1/10A"" />
    Figure 103: -zint -b DXFILMEDGE --compliantheight -d "112-1/10A"
    +zint -b DXFILMEDGE --compliant -d "112-1/10A"

    The data can be in two parts. The first part (required) is the “DX number”, identifying the manufacturer and film type - the National @@ -6123,8 +6143,8 @@ the 6-digit version the first and last digit are ignored, leaving a 2047. The second format "NNN-NN" represents the DX Extract as two numbers separated by a dash (-), the first number being 1 to 3 digits (range 1 to 127) and the second 1 to 2 digits (range -0 to 15).23

    +0 to 15).24

    The optional frame number is a number in the range 0 to 63, and may have a half frame indicator "A" appended. Special character sequences (with or without a half frame indicator appended) may also be @@ -6142,9 +6162,9 @@ respectively, developed by Australia Post for printing Delivery Point ID (DPID) and customer information on mail items.

    +alt="zint -b AUSPOST --compliant -d "96184209"" />
    Figure 104: -zint -b AUSPOST --compliantheight -d "96184209"
    +zint -b AUSPOST --compliant -d "96184209"

    Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format Control Code (FCC) is added by Zint and should not be included in the @@ -6223,27 +6243,27 @@ input lengths) if the DPID is all zeroes.

    which requires an 8-digit DPID input.

    +alt="zint -b AUSREPLY --compliant -d "12345678"" />
    Figure 105: -zint -b AUSREPLY --compliantheight -d "12345678"
    +zint -b AUSREPLY --compliant -d "12345678"

    6.5.1.3 Routing Barcode

    A Routing version of the Australia Post 4-State Barcode (FCC 87) which requires an 8-digit DPID input.

    +alt="zint -b AUSROUTE --compliant -d "34567890"" />
    Figure 106: -zint -b AUSROUTE --compliantheight -d "34567890"
    +zint -b AUSROUTE --compliant -d "34567890"

    6.5.1.4 Redirect Barcode

    A Redirection version of the Australia Post 4-State Barcode (FCC 92) which requires an 8-digit DPID input.

    +alt="zint -b AUSREDIRECT --compliant -d "98765432"" />
    Figure 107: -zint -b AUSREDIRECT --compliantheight -d "98765432"
    +zint -b AUSREDIRECT --compliant -d "98765432"

    6.5.2 Dutch Post KIX Code

    This symbology is used by Royal Dutch TPG Post (Netherlands) for @@ -6252,9 +6272,9 @@ numbers 0-9 and letters A-Z and needs to be 11 characters in length. No check digit is included.

    +alt="zint -b KIX --compliant -d "2500GG30250"" />
    Figure 108: -zint -b KIX --compliantheight -d "2500GG30250"
    +zint -b KIX --compliant -d "2500GG30250"

    6.5.3 Royal Mail 4-State Customer Code (RM4SCC)

    @@ -6265,9 +6285,9 @@ followed by house number. For example "W1J0TR01" for 1 Piccadilly Circus in London. Check digit data is generated by Zint.

    +alt="zint -b RM4SCC --compliant -d "W1J0TR01"" />
    Figure 109: -zint -b RM4SCC --compliantheight -d "W1J0TR01"
    +zint -b RM4SCC --compliant -d "W1J0TR01"

    6.5.4 Royal Mail 4-State Mailmark

    @@ -6275,9 +6295,9 @@ Mailmark includes Reed- Solomon error correction.

    +alt="zint -b MAILMARK_4S --compliant -d "21B2254800659JW5O9QA6Y"" />
    Figure 110: -zint -b MAILMARK_4S --compliantheight -d "21B2254800659JW5O9QA6Y"
    +zint -b MAILMARK_4S --compliant -d "21B2254800659JW5O9QA6Y"

    Input is a pre-formatted alphanumeric string of 22 (for Barcode C) or 26 (for Barcode L) characters, producing a symbol with 66 or 78 bars @@ -6348,9 +6368,9 @@ States Postal Service (USPS), the Intelligent Mail system replaced the POSTNET and PLANET symbologies in 2009.

    +alt="zint -b USPS_IMAIL --compliant -d "01234567094987654321-01234"" />
    Figure 111: -zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234"
    +zint -b USPS_IMAIL --compliant -d "01234567094987654321-01234"

    Intelligent Mail is a fixed length 65-bar symbol which combines routing and customer information in a single symbol. Input data consists @@ -6370,9 +6390,9 @@ are 0-9, A-Z and dash (-). A modulo 19 check digit is added by Zint.

    +alt="zint -b JAPANPOST --compliant -d "15400233-16-4-205"" />
    Figure 112: -zint -b JAPANPOST --compliantheight -d "15400233-16-4-205"
    +zint -b JAPANPOST --compliant -d "15400233-16-4-205"

    6.5.7 DAFT Code

    This is a method for creating 4-state codes where the data encoding @@ -6391,13 +6411,13 @@ alt="zint -b DAFT -d "AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF" --height thousandths (permille) using the --vers option (API option_2). The default value is 250 (25%).

    For example the following

    -
    zint -b DAFT -d AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF --height=8.494 --vers=256
    +
    zint -b DAFT -d AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF --height=8.494 --vers=256

    produces the same barcode (see 6.5.3 Royal Mail 4-State Customer Code (RM4SCC)) as

    -
    zint -b RM4SCC --compliantheight -d "W1J0TR01"
    +
    zint -b RM4SCC --compliant -d "W1J0TR01"

    6.6 Matrix Symbols

    6.6.1 Data Matrix (ISO 16022)

    Also known as Semacode this symbology was developed in 1989 by Acuity @@ -6632,15 +6652,15 @@ processing normal escape sequences also processes the extra escape sequences given in Table 3: Extra Escape Sequences. For instance

    -
    zint -b DATAMATRIX -d "A\^1BC\^1DEF" --extraesc
    +
    zint -b DATAMATRIX -d "A\^1BC\^1DEF" --extraesc

    encodes the data "A<FNC1>BC<FNC1>DEF", where <FNC1> represents the FNC1 character. If the data contains an extra escape sequence, it can be escaped by doubling the caret (^), i.e. "\^^" encodes "\^". Note that if using ECIs with manual FNC1s then the -ECIs must be ASCII compatible.24

    +ECIs must be ASCII compatible.25

    By default Zint uses a “de facto” codeword placement for symbols of size 144 x 144 (version 24). To override this and use the now clarified ISO/IEC standard placement, use option --dmiso144 (API @@ -7069,8 +7089,8 @@ be manually specified by using the --mask switch with values 0-7, or in the API by setting option_3 = (N + 1) << 8 where N is 0-7. To use with ZINT_FULL_MULTIBYTE set

    -
    option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8
    +
    option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8

    The --fast option (API input_mode |= FAST_MODE) may be used when leaving Zint to automatically select a mask to reduce the number of masks to try to four @@ -7202,8 +7222,8 @@ be manually specified by using the --mask switch with values 0-3, or in the API by setting option_3 = (N + 1) << 8 where N is 0-3. To use with ZINT_FULL_MULTIBYTE set

    -
    option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8
    +
    option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8

    6.6.5 Rectangular Micro QR Code (rMQR) (ISO 23941)

    A rectangular version of QR Code, rMQR supports encoding of GS1 data, @@ -7468,8 +7488,8 @@ or if your data is already Latin-2 formatted use the input_mode = DATA_MODE).

    The following example creates a symbol from data saved as a Latin-2 file:

    -
    zint -o upnqr.png -b UPNQR --scale=3 --binary -i upn.txt
    +
    zint -o upnqr.png -b UPNQR --binary -i upn.txt

    A mask may be manually specified and the --fast option used as with 6.6.3 QR Code (ISO 18004).

    @@ -7527,9 +7547,9 @@ your parcel courier.

    The primary message can be set at the command prompt using the --primary switch (API primary). The secondary message uses the normal data entry method. For example:

    -
    zint -o test.eps -b MAXICODE --primary="999999999840012" \
    -    -d "Secondary Message Here"
    +
    zint -o test.eps -b MAXICODE --primary="999999999840012" \
    +    -d "Secondary Message Here"

    When using the API the primary message must be placed in the primary string. The secondary is entered in the same way as described in 5.2 Encoding and @@ -7542,9 +7562,9 @@ to be prefixed by the ISO/IEC 15434 Format "01" vv is a 2-digit version, by using the --scmvv switch (API option_2 = vv + 1). For example to use the common version "96" (ASC MH10/SC 8):

    -
    zint -b MAXICODE --primary="152382802840001" --scmvv=96 --esc -d \
    -  "1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN ST\GNY\GNY\R\E"
    +
    zint -b MAXICODE --primary="152382802840001" --scmvv=96 --esc -d \
    +  "1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN ST\GNY\GNY\R\E"

    will prefix "[)>\R01\G96" to the secondary message. (\R, \G and \E are the escape sequences for Record Separator, Group Separator and End of Transmission @@ -7554,8 +7574,8 @@ Sequences.)

    Modes 4 to 6 can be accessed using the --mode switch (API option_1). Modes 4 to 6 do not have a primary message. For example:

    -
    zint -o test.eps -b MAXICODE --mode=4 -d "A MaxiCode Message in Mode 4"
    +
    zint -o test.eps -b MAXICODE --mode=4 -d "A MaxiCode Message in Mode 4"

    Mode 6 is reserved for the maintenance of scanner hardware and should not be used to encode user data.

    This symbology uses Latin-1 character encoding by default but also @@ -8488,8 +8508,8 @@ be manually specified by using the --mask switch with values 0-3, or in the API by setting option_3 = (N + 1) << 8 where N is 0-3. To use with ZINT_FULL_MULTIBYTE set

    -
    option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8
    +
    option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8

    6.6.14 Ultracode

    This symbology uses a grid of coloured elements to encode data. ECI and GS1 modes are supported.

    @@ -8547,8 +8567,8 @@ Correction Values

    Zint does not currently implement data compression by default, but this can be initiated through the API by setting

    -
    symbol->option_3 = ULTRA_COMPRESSION;
    +
    symbol->option_3 = ULTRA_COMPRESSION;

    With compression, up to 504 digits, 375 alphanumerics or 252 bytes can be encoded.

    Revision 2 of Ultracode (2023) may be specified using @@ -8570,9 +8590,9 @@ Markings used to assist automated mail processing.

    +alt="zint -b FIM --compliant -d "C"" />
    Figure 128: -zint -b FIM --compliantheight -d "C"
    +zint -b FIM --compliant -d "C"

    There are only 5 valid symbols which can be generated using the characters A-E as shown in the table below.

    @@ -9208,28 +9228,28 @@ properties that correspond to the zint_symbol structure method render() which takes a Qt QPainter to paint with, and a QRectF rectangular area specifying where to paint into:

    -
    /* Encode and display barcode in `paintRect` using `painter`.
    -   Note: legacy argument `mode` is not used */
    -void render(QPainter& painter, const QRectF& paintRect,
    -            AspectRatioMode mode = IgnoreAspectRatio);
    +
    /* Encode and display barcode in `paintRect` using `painter`.
    +   Note: legacy argument `mode` is not used */
    +void render(QPainter& painter, const QRectF& paintRect,
    +            AspectRatioMode mode = IgnoreAspectRatio);

    render() will emit one of two Qt signals - encoded on successful encoding and drawing, or errored on failure. The client can connect and act appropriately, for instance:

    -
    connect(qzint, SIGNAL(encoded()), SLOT(on_encoded()));
    -connect(qzint, SIGNAL(errored()), SLOT(on_errored()));
    +
    connect(qzint, SIGNAL(encoded()), SLOT(on_encoded()));
    +connect(qzint, SIGNAL(errored()), SLOT(on_errored()));

    where qzint is an instance of Zint::QZint and on_encoded() and on_error() are Qt slot methods provided by the caller. On error, the error value and message can be retrieved by the methods getError() and lastError() respectively.

    The other main method is save_to_file():

    -
    /* Encode and print barcode to file `filename`.
    -   Only sets `getError()` on error, not on warning */
    -bool save_to_file(const QString& filename); // `ZBarcode_Print()`
    +
    /* Encode and print barcode to file `filename`.
    +   Only sets `getError()` on error, not on warning */
    +bool save_to_file(const QString& filename); // `ZBarcode_Print()`

    which takes a filename to output to. It too will emit an errored signal on failure, returning false (but nothing on success, which just returns true). Note @@ -9242,14 +9262,14 @@ symbology capabilities, and utility methods such as defaultXdim() and getAsCLI().

    For full details, see "backend_qt/qzint.h".

    Annex C. Tcl Backend Binding

    -

    A Tcl binding is available in the "backend_tcl” +

    A Tcl binding is available in the "backend_tcl" sub-directory. To make on Unix:

    -
    cd backend_tcl
    -autoconf
    -./configure
    -make
    -sudo make install
    +
    cd backend_tcl
    +autoconf
    +./configure
    +make
    +sudo make install

    For Windows, a Microsoft Visual C++ project file is available at "backend_tcl\zint_tcl.vcxproj". Note that this assumes that Tcl/Tk is available in "C:\Tcl" and that the libraries are @@ -9260,21 +9280,21 @@ to match your setup. There is also a Visual Studio makefile available at "backend_tcl\win\README.txt".

    Once built and installed, invoke the Tcl/Tk CLI "wish":

    -
    wish
    +
    wish

    and ignoring the Tk window click back to the command prompt "%" and type:

    -
    package require zint
    -zint help
    +
    package require zint
    +zint help

    which will show the usage message, with options very similar to the Zint CLI. (One notable difference is that boolean options such as -bold take a 1 or 0 as an argument.)

    A demonstration Tcl/Tk program which is also useful in itself is available at "backend_tcl/demo/demo.tcl". To run type:

    -
    wish demo/demo.tcl
    +
    wish demo/demo.tcl

    which will display the following window.

    --mirror
    -

    Use the batch data to determine the filename in batch mode -(--batch). The -o | --output -option can be used to specify an output directory (any filename will be -ignored).

    +

    Use the data to determine the filename. This is particularly useful +in batch mode (--batch), but also works in standard mode. +The -o | --output option can be used to +specify an output directory (any filename will be ignored).

    --mode=INTEGER
    @@ -10058,17 +10078,17 @@ Error counterpart of warning if --werror given

    EXAMPLES

    Create “out.png” (or “out.gif” if zint built without PNG support) in the current directory, as a Code 128 symbol.

    -
    zint -d 'This Text'
    +
    zint -d 'This Text'

    Create “qr.svg” in the current directory, as a QR Code symbol.

    -
    zint -b QRCode -d 'This Text' -o 'qr.svg'
    +
    zint -b QRCode -d 'This Text' -o 'qr.svg'

    Use batch mode to read from an input file “ean13nos.txt” containing a list of 13-digit GTINs, each on a separate line, to create a series of EAN-13 barcodes, formatting the output filenames to “ean001.gif”, “ean002.gif” etc. using the special character “~”.

    -
    zint -b EAN13 --batch -i 'ean13nos.txt' -o 'ean~~~.gif'
    +
    zint -b EAN13 --batch -i 'ean13nos.txt' -o 'ean~~~.gif'

    BUGS

    Please send bug reports to https://sourceforge.net/p/zint/tickets/.

    @@ -10154,7 +10174,7 @@ characters undefined: #, $, @, ~ (tilde).↩︎

  • Note that unless the --binary switch is -used, 8-bit binary data for ECI 899 must be given as UTF-8, e.g. a byte +used, 8-bit binary data for ECI 899 must be given as UTF-8, e.g. byte "\x80" must be represented as the 2 bytes "\xC2\x80"; similarly "\xC0" as "\xC3\x80", etc.FNC1 (except when the last AI).↩︎

  • -
  • BARCODE_MEMORY_FILE textual formats EPS and SVG will -have Unix newlines (LF) on both Windows and Unix, i.e. not CR+LF on -Windows.

    The --mirror option will replace control +characters (including DEL) and slash (/) with +an underscore (_). Additionally on Windows the characters +!, ", *, :, +<, >, ?, \ and +| will also be replaced with underscores, as they are +prohibited in filenames.↩︎

  • -
  • The height value is ignored for Aztec +

  • BARCODE_MEMORY_FILE textual formats EPS and SVG will +have Unix newlines (LF) on both Windows and Unix, i.e. not CR+LF on +Windows.↩︎

  • +
  • The height value is ignored for Aztec (including HIBC and Aztec Rune), Code One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode, QR Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which have a fixed width-to-height ratio (or, in the case of Code One, a fixed height).↩︎

  • -
  • For Windows, outfile is assumed to be -UTF-8 encoded.↩︎

  • +
  • For Windows, outfile is assumed to be +UTF-8 encoded.↩︎

  • -
  • The BARCODE_BIND_TOP flag is set by +

  • The BARCODE_BIND_TOP flag is set by default for DPD - see 6.1.10.7 DPD Code.↩︎

  • -
  • The BARCODE_BIND flag is always set for +href="#fnref16" class="footnote-back" role="doc-backlink">↩︎

  • +
  • The BARCODE_BIND flag is always set for Codablock F, Code 16K and Code 49. Special considerations apply to -ITF-14 - see 6.1.2.6 ITF-14.6.1.2.6 ITF-14.↩︎

  • -
  • Codablock F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC +

  • Codablock F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN, ITF-14, UPC-A and UPC-E have compliant quiet zones added -by default.↩︎

  • -
  • ZINT_CAP_EANUPC was previously named +

  • ZINT_CAP_EANUPC was previously named ZINT_CAP_EXTENDABLE, which is still recognised.↩︎

  • -
  • DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have -variable masks. Rectangular Micro QR Code has a fixed mask (4).↩︎

  • -
  • Except for Japanese Postal Code, whose check character -is not truly representable in the encoded data.

    DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have +variable masks. Rectangular Micro QR Code has a fixed mask (4).↩︎

  • +
  • Except for Japanese Postal Code, whose check character +is not truly representable in the encoded data.↩︎

  • -
  • The library libzueci, which can convert +

  • The library libzueci, which can convert both to and from UTF-8 and ECI, is available at https://sourceforge.net/projects/libzueci/.↩︎

  • -
  • BARCODE_CODE128AB previously used the name -BARCODE_CODE128B, which is still recognised.↩︎

  • -
  • The DX number may be looked up in The (Modified) Big +

  • BARCODE_CODE128AB previously used the name +BARCODE_CODE128B, which is still recognised.↩︎

  • +
  • The DX number may be looked up in The (Modified) Big Film Database at https://thebigfilmdatabase.merinorus.com.↩︎

  • -
  • ASCII-compatible ECIs are ECIs 3 to 18 and 21 to 27 +href="#fnref24" class="footnote-back" role="doc-backlink">↩︎

  • +
  • ASCII-compatible ECIs are ECIs 3 to 18 and 21 to 27 (see Table 9: ECI Codes). Note in particular that ECI 899, 8-bit binary, is not considered ASCII-compatible.↩︎

  • +href="#fnref25" class="footnote-back" role="doc-backlink">↩︎

    diff --git a/docs/manual.pmd b/docs/manual.pmd index 41e77d35..49034d0a 100644 --- a/docs/manual.pmd +++ b/docs/manual.pmd @@ -444,9 +444,9 @@ meanings as given below: | Character | Effect | |:-------------------|:------------------------| -|`$` | Insert leading zeroes | -|`#` | Insert leading spaces | -|`*` | Insert leading asterisks| +|`$` (dollar) | Insert leading zeroes | +|`#` (hash) | Insert leading spaces | +|`*` (asterisk) | Insert leading asterisks| |Any other character | Interpreted literally | Table: Sequence Format Characters {#tbl:sequence_format_characters} @@ -488,9 +488,9 @@ zint.exe -d "This Text" For compatibility with Windows the examples use double quotes to delimit data, though on Unix single quotes are generally preferable as they stop the shell -from processing any characters such as backslash or dollar. A single quote -itself is dealt with by terminating the single-quoted text, backslashing the -single quote, and then continuing: +from processing characters such as backslash. A single quote itself is dealt +with by terminating the single-quoted text, backslashing the single quote, and +then continuing: ```bash zint -d 'Text containing a single quote '\'' in the middle' @@ -514,6 +514,10 @@ zint --data "This Text" The examples use a space separator for short option names, and an equals sign for long option names. +Long options may be abbreviated up to nonambiguity. For instance +`--compliantheight` may be shortened to `--compliant`, or even `--com`, but note +that future additions may necessitate longer abbreviations. + ## 4.1 Inputting Data The data to encode can be entered at the command line using the `-d` or `--data` @@ -525,11 +529,11 @@ zint -d "This Text" This will encode the text `"This Text"`. Zint will use the default symbology, Code 128, and output to the default file `"out.png"` in the current directory. -Alternatively, if `libpng` was not present when Zint was built, the default -output file will be `"out.gif"`. +Alternatively, if Zint was not built with `libpng`, the default output file will +be `"out.gif"`. The data input to the Zint CLI is assumed to be encoded in UTF-8 (Unicode) -format (Zint will correctly handle UTF-8 data on Windows). If you are encoding +(Zint will correctly handle UTF-8 data on Windows). If you are encoding characters beyond the 7-bit ASCII set using a scheme other than UTF-8 then you will need to set the appropriate input options as shown in [4.11 Input Modes] below. @@ -633,8 +637,8 @@ See [6.1.10.1 Standard Code 128 (ISO 15417)] for the details on manually switching Code Sets. Input data can be read directly from file using the `-i` or `--input` switch as -shown below. The input file is assumed to be UTF-8 formatted unless an -alternative mode is selected. This option replaces the use of the `-d` switch. +shown below. The input file is assumed to be in UTF-8 unless `--binary` is +selected. This option replaces the use of the `-d` switch. ```bash zint -i somefile.txt @@ -688,6 +692,9 @@ zint -o "dir/subdir/filename.eps" -d "This Text" Note that on Windows, filenames are assumed to be UTF-8 encoded. +For another way to name output files, using the `--mirror` option, see [4.14 +Automatic Filenames]. + ## 4.3 Selecting Barcode Type Selecting which type of barcode you wish to produce (i.e. which symbology to @@ -1139,9 +1146,8 @@ applied to the X-dimension. For MaxiCode, it is multiplied by 10 for raster output, by 40 for EMF vector output, and by 2 otherwise (non-EMF vector output). For non-MaxiCode raster output, the default scale of 1 results in an X-dimension -of 2 pixels. For example for non-MaxiCode PNG images a scale of 5 will increase -the X-dimension to 10 pixels. For MaxiCode, see [4.9.3 MaxiCode Raster Scaling] -below. +of 2 pixels, e.g. for PNG images a scale of 5 will increase the X-dimension to +10 pixels. For MaxiCode, see [4.9.3 MaxiCode Raster Scaling] below. Scales for non-MaxiCode raster output should be given in increments of 0.5, i.e. 0.5, 1, 1.5, 2, 2.5, 3, 3.5, etc., to avoid the X-dimension varying across the @@ -1211,14 +1217,14 @@ nominal size" gives an example of an EAN-13 barcode using the X-dimension of pixels, or 4 pixels rounding to the nearest pixel: ```bash -zint -b EAN13 -d "501234567890" --compliantheight --scale=2 +zint -b EAN13 -d "501234567890" --compliant --scale=2 ``` This will result in output of 37.29mm x 25.56mm (WxH) at 12 dpmm. The same result can be achieved using the `--scalexdimdp` option with ```bash -zint -b EAN13 -d "501234567890" --compliantheight --scalexdimdp +zint -b EAN13 -d "501234567890" --compliant --scalexdimdp ``` as 0.33mm is the default X-dimension for EAN, and 12 dpmm the default @@ -1280,12 +1286,12 @@ matrix barcodes. ### 4.11.1 Unicode, Data, and GS1 Modes -By default all CLI input data is assumed to be encoded in UTF-8 format. Many -barcode symbologies encode data using the Latin-1 (ISO/IEC 8859-1 plus ASCII) -character set, so input is converted from UTF-8 to Latin-1 before being put in -the symbol. In addition QR Code and its variants and Han Xin Code can by default -encode Japanese (Kanji) or Chinese (Hanzi) characters which are also converted -from UTF-8. +By default all CLI input data is assumed to be encoded in UTF-8. Many barcode +symbologies encode data using the Latin-1 (ISO/IEC 8859-1 plus ASCII) character +set, so input is converted from UTF-8 to Latin-1 before being put in the symbol. +In addition QR Code and its variants and Han Xin Code can by default encode +Japanese (Kanji) or Chinese (Hanzi) characters which are also converted from +UTF-8. There are two exceptions to the Latin-1 default: Grid Matrix, whose default character set is GB 2312 (Chinese); and UPNQR, whose default character set is @@ -1412,7 +1418,7 @@ Table: ECI Codes {#tbl:eci_codes} `#`, `$`, `@`, `[`, `\`, `]`, `^`, `` ` ``, `{`, `|`, `}`, `~` (tilde). [^9]: Note that unless the `--binary` switch is used, 8-bit binary data for ECI -899 must be given as UTF-8, e.g. a byte `"\x80"` must be represented as the 2 +899 must be given as UTF-8, e.g. byte `"\x80"` must be represented as the 2 bytes `"\xC2\x80"`; similarly `"\xC0"` as `"\xC3\x80"`, etc. An ECI value of 0 does not encode any ECI information in the code symbol (unless @@ -1436,60 +1442,64 @@ information. #### 4.11.2.1 Input Modes and ECI Example 1 -The Euro sign U+20AC can be encoded in ISO/IEC 8859-15. The Euro sign has the -ISO/IEC 8859-15 codepoint hex `"A4"`. It is encoded in UTF-8 as the hex -sequence: `"E2 82 AC"`. Those 3 bytes are contained in the file -`"utf8euro.txt"`. This command will generate the corresponding code: +The Euro sign `"€"` (U+20AC) can be encoded in ISO/IEC 8859-15 (ECI 17) as the +hex byte `"A4"`. It is encoded in UTF-8 as the hex sequence: `"E2 82 AC"`. Those +3 bytes are contained in the file `"utf8euro.txt"`, e.g. on Unix ```bash -zint -b DATAMATRIX --scale=10 --eci=17 -i utf8euro.txt +echo -ne '\xE2\x82\xAC' > utf8euro.txt +``` + +This command will generate the corresponding code: + +```bash +zint -b DATAMATRIX --eci=17 -i utf8euro.txt ``` This is equivalent to the commands (using the `--esc` switch): ```bash -zint -b DATAMATRIX --scale=10 --eci=17 --esc -d "\xE2\x82\xAC" +zint -b DATAMATRIX --eci=17 --esc -d "\xE2\x82\xAC" -zint -b DATAMATRIX --scale=10 --eci=17 --esc -d "\u20AC" +zint -b DATAMATRIX --eci=17 --esc -d "\u20AC" ``` and to the command: ```bash -zint -b DATAMATRIX --scale=10 --eci=17 -d "€" +zint -b DATAMATRIX --eci=17 -d "€" ``` ![`zint -b DATAMATRIX --eci=17 -d "€"`](images/datamatrix_euro.svg){.i2d} #### 4.11.2.2 Input Modes and ECI Example 2 -The Chinese character with the Unicode codepoint U+5E38 can be encoded in Big5 -encoding. The Big5 representation of this character is the two hex bytes: -`"B1 60"` (contained in the file `"big5char.txt"`). The generation command for -Data Matrix is: +The Chinese character `"碼"` (U+78BC) can be encoded in Big5 encoding (ECI 28) +as the hex sequence: `"BD 58"`. Those 2 bytes are contained in the file +`"big5char.txt"`. The generation command is: ```bash -zint -b DATAMATRIX --scale=10 --eci=28 --binary -i big5char.txt +zint -b DATAMATRIX --eci=28 --binary -i big5char.txt ``` This is equivalent to the command (using the `--esc` switch): ```bash -zint -b DATAMATRIX --scale=10 --eci=28 --binary --esc -d "\xB1\x60" +zint -b DATAMATRIX --eci=28 --binary --esc -d "\xBD\x58" ``` and to the commands (no `--binary` switch so conversion occurs): ```bash -zint -b DATAMATRIX --scale=10 --eci=28 --esc -d "\xE5\xB8\xB8" +zint -b DATAMATRIX --eci=28 --esc -d "\xE7\xA2\xBC" -zint -b DATAMATRIX --scale=10 --eci=28 --esc -d "\u5E38" +zint -b DATAMATRIX --eci=28 --esc -d "\u78BC" -zint -b DATAMATRIX --scale=10 --eci=28 -d "常" +zint -b DATAMATRIX --eci=28 -d "碼" ``` -![`zint -b DATAMATRIX --eci=28 -d "\u5E38" ---esc`](images/datamatrix_big5.svg){.i2d} +![`zint -b DATAMATRIX --eci=28 --binary --esc -d +"\xBD\x58"`](images/datamatrix_big5.svg){.i2d} #### 4.11.2.3 Input Modes and ECI Example 3 @@ -1498,53 +1508,53 @@ by default and do not support ECI. In this case supply UTF-8 data and use the `--binary` switch so that the data will be encoded as UTF-8 without conversion: ```bash -zint -b QRCODE --binary -d "UTF-8 data" +zint -b QRCODE --binary -d "€" ``` -![`zint -b QRCODE --binary -d "\xE2\x82\xAC\xE5\xB8\xB8" ---esc`](images/qrcode_binary_utf8.svg){.i2d} +![`zint -b QRCODE --binary -d "€"`](images/qrcode_binary_utf8.svg){.i2d} ### 4.11.3 GS1 Data Entry and Options The following symbologies accept GS1 data: ----------------------------------------------------------- -Symbology Implicit GS1 Data Supports GS1 - AI? Assumed? Composite? -------------- -------- -------- ------------ -Aztec Code No No No +------------------------------------------------------------ +Symbology Implicit GS1 Data Supports GS1 + AI? Assumed? Composite? +------------------------ --------- --------- ------------ +Aztec Code No No No -Code 16K No No No +Code 16K No No No -Code 49 No No No +Code 49 No No No -Code One No No No +Code One No No No -Data Matrix No No No +Data Matrix No No No -DotCode No No No +DotCode No No No -EAN-13, EAN-8 Yes (01) Yes Yes +EAN-13, EAN-8 Yes (01) Yes Yes -EAN-14 Yes (01) Yes No +EAN-14 Yes (01) Yes No -GS1-128 No Yes Yes +GS1-128 No Yes Yes -GS1 DataBar Expanded No Yes Yes -(including Stacked) +GS1 DataBar Expanded No Yes Yes +(including Expanded +Stacked) -GS1 DataBar (all others) Yes (01) Yes Yes +GS1 DataBar (all others) Yes (01) Yes Yes -NVE-18 Yes (00) Yes No +NVE-18 Yes (00) Yes No -QR Code No No No +QR Code No No No -rMQR No No No +rMQR No No No -Ultracode No No No +Ultracode No No No -UPC-A, UPC-E Yes (01) Yes Yes ----------------------------------------------------------- +UPC-A, UPC-E Yes (01) Yes Yes +------------------------------------------------------------ Table: GS1-Enabled Symbologies @@ -1623,9 +1633,9 @@ other GS1 options. - `--gs1strict`, which enables the use the GS1 Syntax Engine to strictly validate GS1 data, including GS1 Digital Link URIs (by default Zint -does not validate Digital Links at all). It requires that the `gs1encoders` -library was present when Zint was built, otherwise the default built-in -validation will be used. +does not validate Digital Links at all). It requires that Zint was built with +the `gs1encoders` library, otherwise the default built-in validation will be +used. - `--gs1nocheck`, for use with legacy systems that have data that does not conform to the current GS1 standard. Printable ASCII input is still checked for, @@ -1665,9 +1675,9 @@ characters in the output filename as shown in the table below: Input Character Interpretation --------------- ------------------------------------------ -`~` Insert a number or 0 -`#` Insert a number or space -`@` Insert a number or `*` (or `+` on Windows) +`~` (tilde) Insert a number or 0 +`#` (hash) Insert a number or space +`@` (ampersand) Insert a number or `*` (or `+` on Windows) Any other Insert literally Table: Batch Filename Formatting {#tbl:batch_filename_formatting} @@ -1707,9 +1717,9 @@ For an alternative method of naming output files see the `--mirror` option in The finished image files can be output directly to stdout for use as part of a pipe by using the `--direct` option. By default `--direct` will output data as a -PNG image (or GIF image if `libpng` is not present), but this can be altered by -supplementing the `--direct` option with a `--filetype` option followed by the -suffix of the file type required. For example: +PNG image (or GIF image if Zint not built with `libpng`), but this can be +altered by supplementing the `--direct` option with a `--filetype` option +followed by the suffix of the file type required. For example: ```bash zint -b MICROPDF417 --direct --filetype=pcx -d "Data to encode" @@ -1733,13 +1743,34 @@ file named `"1234567.png"`. There are restrictions, however, on what characters can be stored in a filename, so the filename may vary from the data if the data includes non-printable -characters, for example, and may be shortened if the data input is long. +characters, for example,[^12] and may be shortened if the data input is long. So +in batch mode your data must be unique given these restrictions otherwise files +will overwrite each other. To set the output file format use the `--filetype` option as detailed above in -[4.13 Direct Output to stdout]. To output to a specific directory use the `-o` -option giving the name of the directory (any filename will be ignored, unless -`--filetype` is not specified, in which case the filename's extension will be -used). +[4.13 Direct Output to stdout]. For instance + +```bash +zint -d "1234567" --mirror --filetype=eps +``` + +will output to the file `"1234567.eps"`: + +To output to a specific directory use the `-o` option giving the name of the +directory, indicated by a terminating slash `/` (backslash `\` may be used on +Windows). Any filename after the last slash will be ignored, unless `--filetype` +is not specified, in which case the filename's extension will be used - e.g. + +```bash +zint -d "1234567" --mirror -o "dir/subdir/mir.eps" +``` + +will output to the file `"1234567.eps"` in the `"dir/subdir"` directory. + +[^12]: The `--mirror` option will replace control characters (including `DEL`) +and slash (`/`) with an underscore (`_`). Additionally on Windows the characters +`!`, `"`, `*`, `:`, `<`, `>`, `?`, `\` and `|` will also be replaced with +underscores, as they are prohibited in filenames. ## 4.15 Working with Dots @@ -1880,8 +1911,8 @@ gcc -o simple simple.c -lzint To encode data in a barcode use the `ZBarcode_Encode()` function. To write the symbol to a file use the `ZBarcode_Print()` function. For example the following code takes a string from the command line and outputs a Code 128 symbol to a PNG -file named `"out.png"` (or a GIF file `"out.gif"` if `libpng` is not present) in -the current working directory: +file named `"out.png"` (or a GIF file `"out.gif"` if Zint not built with +`libpng`) in the current working directory: ```c #include @@ -2108,10 +2139,10 @@ int main(int argc, char **argv) ``` will print the SVG output to `stdout` (the file `"mem.svg"` is not created). -This is particularly useful for the textual formats EPS and SVG,[^12] allowing +This is particularly useful for the textual formats EPS and SVG,[^13] allowing the output to be manipulated and processed by the client. -[^12]: BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines +[^13]: BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines (LF) on both Windows and Unix, i.e. not CR+LF on Windows. ## 5.7 Setting Options @@ -2132,7 +2163,7 @@ Member Name Type Meaning Default Value `height` float Symbol height in Symbol dependent X-dimensions, excluding fixed width-to-height - symbols.[^13] + symbols.[^14] `scale` float Scale factor for 1.0 adjusting size of image @@ -2182,7 +2213,7 @@ Member Name Type Meaning Default Value `.eps`, `.pcx`, `.svg`, `.tif` or `.txt` followed by a terminating - `NUL`.[^14] + `NUL`.[^15] `primary` character Primary message data for `""` (empty) string more complex symbols, @@ -2310,13 +2341,13 @@ Member Name Type Meaning Default Value Table: API Structure `zint_symbol` {#tbl:api_structure_zint_symbol} -[^13]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune), +[^14]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune), Code One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode, QR Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which have a fixed width-to-height ratio (or, in the case of Code One, a fixed height). -[^14]: For Windows, `outfile` is assumed to be UTF-8 encoded. +[^15]: For Windows, `outfile` is assumed to be UTF-8 encoded. To alter these values use the syntax shown in the example below. This code has the same result as the previous example except the output is now taller and @@ -2482,10 +2513,10 @@ Value Effect ------------------------- --------------------------------------------------- 0 No options selected. -`BARCODE_BIND_TOP` Boundary bar above the symbol only.[^15] +`BARCODE_BIND_TOP` Boundary bar above the symbol only.[^16] `BARCODE_BIND` Boundary bars above and below the symbol and - between rows if stacking multiple symbols.[^16] + between rows if stacking multiple symbols.[^17] `BARCODE_BOX` Add a box surrounding the symbol and whitespace. @@ -2512,7 +2543,7 @@ Value Effect Symbols in Memory (raster)]. `BARCODE_QUIET_ZONES` Add compliant quiet zones (additional to any - specified whitespace).[^17] + specified whitespace).[^18] `BARCODE_NO_QUIET_ZONES` Disable quiet zones, notably those with defaults. @@ -2534,13 +2565,13 @@ Value Effect Table: API `output_options` Values {#tbl:api_output_options} -[^15]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD +[^16]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD Code]. -[^16]: The `BARCODE_BIND` flag is always set for Codablock F, Code 16K and Code +[^17]: The `BARCODE_BIND` flag is always set for Codablock F, Code 16K and Code 49. Special considerations apply to ITF-14 - see [6.1.2.6 ITF-14]. -[^17]: Codablock F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN, +[^18]: Codablock F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN, ITF-14, UPC-A and UPC-E have compliant quiet zones added by default. ## 5.11 Setting the Input Mode @@ -2568,7 +2599,7 @@ Value Effect `GS1NOCHECK_MODE` Do not check GS1 data for validity, i.e. suppress checks for valid AIs and data lengths. Invalid - characters (e.g. control characters, extended ASCII + characters (e.g. control characters, extended ASCII characters) are still checked for. `HEIGHTPERROW_MODE` Interpret the `height` member as per-row rather than @@ -2799,7 +2830,7 @@ Value Meaning `ZINT_CAP_STACKABLE` Is the symbology stackable? Note that stacked symbologies are not stackable. -`ZINT_CAP_EANUPC`[^18] Is the symbology EAN/UPC? +`ZINT_CAP_EANUPC`[^19] Is the symbology EAN/UPC? `ZINT_CAP_COMPOSITE` Does the symbology support composite data? (see [6.3 GS1 Composite Symbols (ISO 24723)] below) @@ -2835,7 +2866,7 @@ Value Meaning Table: API Capability Flags {#tbl:api_cap} -[^18]: `ZINT_CAP_EANUPC` was previously named `ZINT_CAP_EXTENDABLE`, which is +[^19]: `ZINT_CAP_EANUPC` was previously named `ZINT_CAP_EXTENDABLE`, which is still recognised. For example: @@ -2862,7 +2893,7 @@ On successful encodation (after using `ZBarcode_Encode()` etc.) the `option_1`, create the barcode. This is useful for feedback if the values were left as defaults or were overridden by Zint. -In particular for symbologies that have masks,[^19] `option_3` will contain the +In particular for symbologies that have masks,[^20] `option_3` will contain the mask used as `(N + 1) << 8`, N being the mask. Also Aztec Code will return the actual ECC percentage used in `option_1` as `P << 8`, where P is the integer percentage, the low byte containing the values given in [#tbl:aztec_eccs] (with @@ -2880,7 +2911,7 @@ least one. The `source`, `length` and `eci` members of `zint_seg` will be set accordingly - the unconverted data in `source`, the data length in `length`, and the character set the data was converted to in `eci`. Any check characters encoded will be -included,[^20] and for GS1 data any `FNC1` separators will be represented as +included,[^21] and for GS1 data any `FNC1` separators will be represented as `GS` (ASCII 29) characters. UPC-A and UPC-E data will be expanded to EAN-13, as will EAN-8 but only if it has an add-on (otherwise it will remain at 8 digits), and any add-ons will follow the 13 digits directly (no separator). GS1 Composite @@ -2892,16 +2923,16 @@ is `DATA_MODE`, it remains in binary; otherwise it will be in UTF-8. The UTF-8 source may be converted to the character set of the corresponding `eci` member using the two helper functions discussed next. -[^19]: DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have variable masks. +[^20]: DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have variable masks. Rectangular Micro QR Code has a fixed mask (4). -[^20]: Except for Japanese Postal Code, whose check character is not truly +[^21]: Except for Japanese Postal Code, whose check character is not truly representable in the encoded data. ## 5.17 UTF-8 to ECI convenience functions As a convenience the conversion done by Zint from UTF-8 to ECIs is exposed in -two helper functions (compatible with the `libzueci`[^21] functions +two helper functions (compatible with the `libzueci`[^22] functions `zueci_utf8_to_eci()` and `zueci_dest_len_eci()`): @@ -2921,7 +2952,7 @@ returned in `p_dest_length`, may be smaller than the estimate given by NUL-terminated. The destination buffer is not NUL-terminated. The obsolete ECIs 0, 1 and 2 are supported. -[^21]: The library `libzueci`, which can convert both to and from UTF-8 and ECI, +[^22]: The library `libzueci`, which can convert both to and from UTF-8 and ECI, is available at [https://sourceforge.net/projects/libzueci/]( https://sourceforge.net/projects/libzueci/). @@ -3026,8 +3057,7 @@ A high-density barcode that encodes pairs of numbers, and so can only encode an even number of digits (0-9). If an odd number of digits is entered a leading zero is added by Zint. A maximum of 62 pairs (124 digits) can be encoded. -![`zint -b C25INTER --compliantheight -d -"9212320967"`](images/c25inter.svg){.lin} +![`zint -b C25INTER --compliant -d "9212320967"`](images/c25inter.svg){.lin} No check digit is added by default, but can be set the same as for [6.1.2.1 Standard Code 2 of 5]. @@ -3051,7 +3081,7 @@ entered, or a 14-digit input if the standard GS1 check digit is given, in which case the check digit will be verified. A standard GS1 check digit is added by Zint unless already given. -![`zint -b ITF14 --compliantheight -d "9212320967145"`](images/itf14.svg){.lin} +![`zint -b ITF14 --compliant -d "9212320967145"`](images/itf14.svg){.lin} If no border option is specified Zint defaults to adding a bounding box with a border width of 5. This behaviour can be overridden by using the `--bind` option @@ -3060,7 +3090,7 @@ overridden using `--border` (API `border_width`). If a symbol with no border is required this can be achieved by explicitly setting the border type to box (or bind or bindtop) and leaving the border width 0. -![`zint -b ITF14 --box --compliantheight -d +![`zint -b ITF14 --box --compliant -d "9212320967145"`](images/itf14_border0.svg){.lin} #### 6.1.2.7 Deutsche Post Leitcode @@ -3089,7 +3119,7 @@ UPC-A is used in the United States for retail applications, and encodes a GTIN-12, a 12-digit Global Trade Item Number that includes a standard GS1 check digit. -![`zint -b UPCA --compliantheight -d "01234500005"`](images/upca.svg){.upcean} +![`zint -b UPCA --compliant -d "01234500005"`](images/upca.svg){.upcean} Input up to 11 digits may be given, to which a check digit will be added by Zint. A 12-digit input including the check digit may also be supplied, in which @@ -3116,8 +3146,7 @@ error = ZBarcode_Encode_and_Print(symbol, "01234500005+12345", 0, 0); error = ZBarcode_Encode_and_Print(symbol, "01234500005 12345", 0, 0); ``` -![`zint -b UPCA --compliantheight -d -"01234500005+12345"`](images/upca_5.svg){.upcean} +![`zint -b UPCA --compliant -d "01234500005+12345"`](images/upca_5.svg){.upcean} A quiet zone indicator can be added to the HRT by setting `--guardwhitespace` (API `output_options |= EANUPC_GUARD_WHITESPACE`). For UPC, this is only @@ -3135,7 +3164,7 @@ symbol->output_options |= EANUPC_GUARD_WHITESPACE; error = ZBarcode_Encode_and_Print(symbol, "01234500005+12345", 0, 0); ``` -![`zint -b UPCA --compliantheight -d "01234500005+12345" +![`zint -b UPCA --compliant -d "01234500005+12345" --guardwhitespace`](images/upca_5_gws.svg){.upcean} You can adjust the gap between the main symbol and an add-on in integral @@ -3152,7 +3181,7 @@ Zint. If 7 digits are given then the first must be '0' or '1' (the latter is known as number system 1 and is non-standard). Input less than 7 digits will be zero-filled. -![`zint -b UPCE --compliantheight -d "123455"`](images/upce.svg){.upcean} +![`zint -b UPCE --compliant -d "123455"`](images/upce.svg){.upcean} An 8-digit input including the check digit may also be supplied, in which case Zint will verify the check digit, or the symbology `BARCODE_UPCE_CHK` (38) may @@ -3167,7 +3196,7 @@ EANUPC_GUARD_WHITESPACE`): zint -b UPCE -d "123455+12" --guardwhitespace ``` -![`zint -b UPCE --compliantheight -d "123455+12" +![`zint -b UPCE --compliant -d "123455+12" --guardwhitespace`](images/upce_2_gws.svg){.upcean} You can adjust the gap between the main symbol and an add-on in integral @@ -3188,8 +3217,7 @@ EAN-8 and ISBN (a subset of EAN-13). EAN-13 encodes a GTIN-13, a 13-digit Global Trade Item Number that includes a standard GS1 check digit. -![`zint -b EAN13 --compliantheight -d -"952012345678"`](images/ean13.svg){.upcean} +![`zint -b EAN13 --compliant -d "952012345678"`](images/ean13.svg){.upcean} Input up to 12 digits may be given, to which a check digit will be added by Zint, or a 13-digit input can be supplied in which case Zint will validate the @@ -3210,8 +3238,7 @@ symbol->symbology = BARCODE_EAN13; error = ZBarcode_Encode_and_Print(symbol, "952012345678+21", 0, 0); ``` -![`zint -b EAN13 --compliantheight -d -"952012345678+21"`](images/ean13_2.svg){.upcean} +![`zint -b EAN13 --compliant -d "952012345678+21"`](images/ean13_2.svg){.upcean} Options to add quiet zone indicators and to adjust the add-on gap and the guard bar descent height are the same as for [6.1.3.2 UPC Version E]. For instance: @@ -3220,15 +3247,15 @@ bar descent height are the same as for [6.1.3.2 UPC Version E]. For instance: zint -b EAN13 -d "9520123456788" --guarddescent=2.5 --guardwhitespace ``` -![`zint -b EAN13 --compliantheight -d "9520123456788"` ---guarddescent=2.5 --guardwhitespace](images/ean13_gd_gws.svg){.upcean} +![`zint -b EAN13 --compliant -d "9520123456788" --guarddescent=2.5 +--guardwhitespace`](images/ean13_gd_gws.svg){.upcean} #### 6.1.4.2 EAN-8 EAN-8 is a shortened version of EAN-13, encoding a GTIN-8 (a GTIN-13 with 5 leading zeroes implied), for use with small packages. -![`zint -b EAN8 --compliantheight -d "9520000"`](images/ean8.svg){.upcean} +![`zint -b EAN8 --compliant -d "9520000"`](images/ean8.svg){.upcean} Input up to 7 digits may be supplied, to which Zint will add a standard GS1 check digit. An 8-digit input including the check digit may also be given, in @@ -3250,7 +3277,7 @@ symbol->output_options |= EANUPC_GUARD_WHITESPACE; error = ZBarcode_Encode_and_Print(symbol, "9520000", 0, 0); ``` -![`zint -b EAN8 --compliantheight -d "9520000"` +![`zint -b EAN8 --compliant -d "9520000"` --guardwhitespace](images/ean8_gws.svg){.upcean} 2-digit and 5-digit add-ons may also be added, and the gap adjusted, as with @@ -3263,12 +3290,11 @@ SBN, 10-digit ISBN or 13-digit ISBN-13 data. The relevant check digit needs to be present in the input data and will be verified before the symbol is generated. -![`zint -b ISBNX --compliantheight -d -"9789295055124"`](images/isbnx.svg){.upcean} +![`zint -b ISBNX --compliant -d "9789295055124"`](images/isbnx.svg){.upcean} As with EAN-13, a quiet zone indicator can be added using `--guardwhitespace`: -![`zint -b ISBNX --compliantheight -d "9789295055124" +![`zint -b ISBNX --compliant -d "9789295055124" --guardwhitespace`](images/isbnx_gws.svg){.upcean} 2-digit and 5-digit add-on symbols can be added using a `+` or space character, @@ -3281,8 +3307,7 @@ As a convenience, 2-digit and 5-digit add-ons may be generated as standalone symbols using the symbologies `BARCODE_EAN_2ADDON` (11) and `BARCODE_EAN_5ADDON` (12). -![`zint -b EAN_2ADDON --compliantheight --d "12"`](images/ean_2addon.svg){.upcean} +![`zint -b EAN_2ADDON --compliant -d "12"`](images/ean_2addon.svg){.upcean} As with the main EAN/UPC symbols a quiet zone indicator can be added using `---guardwhitespace`. For instance @@ -3300,7 +3325,7 @@ symbol->output_options |= EANUPC_GUARD_WHITESPACE; error = ZBarcode_Encode_and_Print(symbol, "54321", 0, 0); ``` -![`zint -b EAN_5ADDON --compliantheight -d "54321"` +![`zint -b EAN_5ADDON --compliant -d "54321"` --guardwhitespace](images/ean_5addon_gws.svg){.upcean} ### 6.1.5 Plessey @@ -3350,7 +3375,7 @@ Telepen Alpha was developed in 1972 by SB Electronic Systems Limited and can encode ASCII text input, up to a maximum of 69 characters. Telepen includes a hidden modulo-127 check digit, added by Zint. -![`zint -b TELEPEN --compliantheight -d "Z8000"`](images/telepen.svg){.lin} +![`zint -b TELEPEN --compliant -d "Z8000"`](images/telepen.svg){.lin} AIM-defined Start/Stop characters may be enabled by setting `--vers=1` (API `option_2 = 1`). In this mode control character `DLE` (ASCII 16, escape sequence @@ -3358,7 +3383,7 @@ AIM-defined Start/Stop characters may be enabled by setting `--vers=1` (API symbol character encodes a digit pair (or a "digit X" pair - see Telepen Numeric below): -![`zint -b TELEPEN --compliantheight -d +![`zint -b TELEPEN --compliant -d "Z\L8000" -esc --vers=1`](images/telepen_aim.svg){.lin} However not all barcode readers recognise this mode so check before using. @@ -3372,19 +3397,18 @@ character. For example: `"466333"` and `"466X33"` are valid codes whereas supplied, Zint will add a leading zero. Up to 138 digits can be encoded. A hidden modulo-127 check digit is added by Zint. -![`zint -b TELEPEN_NUM --compliantheight -d -"466X33"`](images/telepen_num.svg){.lin} +![`zint -b TELEPEN_NUM --compliant -d "466X33"`](images/telepen_num.svg){.lin} Additionally trailing ASCII characters may be encoded by prefixing them with a `DLE` control character (ASCII 16, escape sequence `\L`) and appending them to the numeric data: -![`zint -b TELEPEN_NUM --compliantheight -d +![`zint -b TELEPEN_NUM --compliant -d "12\LAB" --esc`](images/telepen_num_asc.svg){.lin} This method allows odd numbers to be encoded without a leading zero: -![`zint -b TELEPEN_NUM --compliantheight -d +![`zint -b TELEPEN_NUM --compliant -d "123\L4" --esc`](images/telepen_num_odd.svg){.lin} AIM-defined Start/Stop characters may be enabled by setting `--vers=1` (API @@ -3402,7 +3426,7 @@ characters in length and can include the characters 0-9, A-Z, dash (`-`), full stop (`.`), space, asterisk (`*`), dollar (`$`), slash (`/`), plus (`+`) and percent (`%`). -![`zint -b CODE39 --compliantheight -d "1A" --vers=1`](images/code39.svg){.lin} +![`zint -b CODE39 --compliant -d "1A" --vers=1`](images/code39.svg){.lin} The standard does not require a check digit but a modulo-43 check digit can be added if desired by setting `--vers=1` (API `option_2 = 1`). To add a check @@ -3414,8 +3438,7 @@ digit but not show it in the Human Readable Text, set `--vers=2` (API Also known as Code 39e and Code39+, this symbology expands on Standard Code 39 to provide support for the full 7-bit ASCII character set. -![`zint -b EXCODE39 --compliantheight -d -"123.45#@fd"`](images/excode39.svg){.lin} +![`zint -b EXCODE39 --compliant -d "123.45#@fd"`](images/excode39.svg){.lin} The check digit options are the same as for [6.1.7.1 Standard Code 39 (ISO 16388)]. @@ -3427,7 +3450,7 @@ accepting up to 123 characters. Two check characters are added by Zint. By default these check characters are not shown in the Human Readable Text, but may be shown by setting `--vers=1` (API `option_2 = 1`). -![`zint -b CODE93 --compliantheight -d "C93"`](images/code93.svg){.lin} +![`zint -b CODE93 --compliant -d "C93"`](images/code93.svg){.lin} #### 6.1.7.4 PZN (Pharmazentralnummer) @@ -3436,7 +3459,7 @@ PZN encodes a 7-digit number to which Zint will add a modulo-11 check digit (PZN8). Input less than 7 digits will be zero-filled. An 8-digit input can be supplied in which case Zint will validate the check digit. -![`zint -b PZN --compliantheight -d "2758089"`](images/pzn.svg){.lin} +![`zint -b PZN --compliant -d "2758089"`](images/pzn.svg){.lin} To encode a PZN7 (obsolete since 2013) instead set `--vers=1` (API `option_2 = 1`) and supply up to 7 digits. As with PZN8, a modulo-11 check digit @@ -3450,7 +3473,7 @@ LOGMARS encodes the same character set as [6.1.7.1 Standard Code 39 (ISO 16388)], and the check digit options are also the same. Input is restricted to a maximum of 30 characters. -![`zint -b LOGMARS --compliantheight -d "12345/ABCDE" +![`zint -b LOGMARS --compliant -d "12345/ABCDE" --vers=1`](images/logmars.svg){.lin} #### 6.1.7.6 Code 32 @@ -3460,7 +3483,7 @@ Sanità") for encoding identifiers on pharmaceutical products. This symbology requires a numeric input up to 8 digits in length. A check digit is added by Zint. -![`zint -b CODE32 --compliantheight -d "14352312"`](images/code32.svg){.lin} +![`zint -b CODE32 --compliant -d "14352312"`](images/code32.svg){.lin} #### 6.1.7.7 HIBC Code 39 @@ -3468,7 +3491,7 @@ This variant adds a leading `'+'` character and a trailing modulo-49 check digit to a standard Code 39 symbol as required by the Health Industry Barcode standards. -![`zint -b HIBC_39 --compliantheight -d "14352312"`](images/hibc_39.svg){.lin} +![`zint -b HIBC_39 --compliant -d "14352312"`](images/hibc_39.svg){.lin} #### 6.1.7.8 Vehicle Identification Number (VIN) @@ -3489,7 +3512,7 @@ and Monarch, this symbology was developed in 1972 from earlier versions by Pitney Bowes-Alpex for retail price marking. The American Blood Commission adopted Codabar in 1979 as the standard barcode for blood products. -![`zint -b CODABAR --compliantheight -d "A37859B"`](images/codabar.svg){.lin} +![`zint -b CODABAR --compliant -d "A37859B"`](images/codabar.svg){.lin} Codabar can encode up to 103 characters starting and ending with the letters A-D and containing between these letters the numbers 0-9, dash (`-`), dollar (`$`), @@ -3505,7 +3528,7 @@ Developed by Laetus, Pharmacode One-Track is used for the identification of pharmaceuticals. The symbology is able to encode whole numbers between 3 and 131070. -![`zint -b PHARMA --compliantheight -d "130170"`](images/pharma.svg){.lin} +![`zint -b PHARMA --compliant -d "130170"`](images/pharma.svg){.lin} ### 6.1.10 Code 128 @@ -3565,7 +3588,7 @@ alphanumerics) are not recommended. #### 6.1.10.2 Code 128 Suppress Code Set C (Code Sets A and B only) It is sometimes advantageous to stop Code 128 from using Code Set C which -compresses numerical data. The `BARCODE_CODE128AB`[^22] variant (symbology 60) +compresses numerical data. The `BARCODE_CODE128AB`[^23] variant (symbology 60) suppresses Code Set C in favour of Code Sets A and B. ![`zint -b CODE128AB -d "130170X178"`](images/code128ab.svg){.lin} @@ -3573,7 +3596,7 @@ suppresses Code Set C in favour of Code Sets A and B. Note that the special extra escapes mentioned above are not available for this variant (nor for any other). -[^22]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is +[^23]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is still recognised. #### 6.1.10.3 GS1-128 @@ -3583,7 +3606,7 @@ defined by the GS1 General Specifications. Data should be in one of the formats described in [4.11.3.1 GS1 Data Entry]. Here we will use the square bracket format. -![`zint -b GS1_128 --compliantheight -d +![`zint -b GS1_128 --compliant -d "[01]98898765432106[3202]012345[15]991231"`](images/gs1_128.svg){.lin} Fixed length data should be entered at the appropriate length for correct @@ -3603,7 +3626,7 @@ digits entered, or a 14-digit number if the standard GS1 check digit is given, in which case the check digit will be verified. The GS1 check digit (if not given) and HRT-only AI `"(01)"` are added by Zint. -![`zint -b EAN14 --compliantheight -d "9889876543210"`](images/ean14.svg){.lin} +![`zint -b EAN14 --compliant -d "9889876543210"`](images/ean14.svg){.lin} #### 6.1.10.5 NVE-18 (SSCC-18) @@ -3614,8 +3637,7 @@ which will be prefixed with leading zeros if less than 17 digits given, or an 18-digit input if the GS1 check digit is included, in which case the check digit will be verified. Check digit(s) and HRT-only AI `"(00)"` are added by Zint. -![`zint -b NVE18 --compliantheight -d -"37612345000001003"`](images/nve18.svg){.lin} +![`zint -b NVE18 --compliant -d "37612345000001003"`](images/nve18.svg){.lin} #### 6.1.10.6 HIBC Code 128 @@ -3629,7 +3651,7 @@ standards. Another variation of Code 128 as used by DPD (Deutscher Paketdienst). -![`zint -b DPD --compliantheight -d +![`zint -b DPD --compliant -d "000393206219912345678101040"`](images/dpd.svg){.lin} DPD Code requires a 27 or 28 character input. For 28 character input, the first @@ -3673,8 +3695,7 @@ format `"SSNNNNNNNNXCC"`, where `"SS"` is a two-character alphabetic service indicator, `"NNNNNNNN"` is an 8-digit serial number, `"X"` is a modulo-11 check digit, and `"CC"` is a two-character ISO 3166-1 country code. -![`zint -b UPU_S10 --compliantheight -d -"EE876543216CA"`](images/upu_s10.svg){.lin} +![`zint -b UPU_S10 --compliant -d "EE876543216CA"`](images/upu_s10.svg){.lin} The check digit may be omitted in which case Zint will add it. Warnings will be generated if the service indicator is non-standard or the country code is not @@ -3698,8 +3719,7 @@ digit and HRT-only Application Identifier of `"(01)"` are added by Zint. (A case the check digit will be verified.) Input less than 13 digits will be zero-filled. -![`zint -b DBAR_OMN --compliantheight -d -"0950110153001"`](images/dbar_omn.svg){.lin} +![`zint -b DBAR_OMN --compliant -d "0950110153001"`](images/dbar_omn.svg){.lin} GS1 DataBar Omnidirectional symbols should have a height of 33 or greater. To produce a GS1 DataBar Truncated symbol set the symbol height to a value between @@ -3718,8 +3738,7 @@ digit and HRT-only Application Identifier of `"(01)"` are added by Zint, and a 14-digit code may be given in which case the check digit will be verified. Input less than 13 digits will be zero-filled. -![`zint -b DBAR_LTD --compliantheight -d -"0950110153001"`](images/dbar_ltd.svg){.lin} +![`zint -b DBAR_LTD --compliant -d "0950110153001"`](images/dbar_ltd.svg){.lin} #### 6.1.11.3 GS1 DataBar Expanded @@ -3728,7 +3747,7 @@ encoding multiple AIs in a single symbol. Data should be in one of the formats described in [4.11.3.1 GS1 Data Entry], and will be displayed using parentheses (round brackets) in the Human Readable Text. -![`zint -b DBAR_EXP --compliantheight -d +![`zint -b DBAR_EXP --compliant -d "[01]98898765432106[3202]012345[15]991231"`](images/dbar_exp.svg){.lin} The GTIN-14 data for AI (01) must include the standard GS1 check digit as this @@ -3756,7 +3775,7 @@ the `--vers` option (API `option_2`). It can also be determined by the length of the input data: e.g. a three character input string generates a 4 channel code by default. -![`zint -b CHANNEL -d "453678" --compliantheight`](images/channel.svg){.lin} +![`zint -b CHANNEL -d "453678" --compliant`](images/channel.svg){.lin} The maximum values permitted depend on the number of channels used as shown in the table below: @@ -3781,7 +3800,7 @@ input must be alphanumeric, excluding the letter `O`, and must be from 7 to 18 characters in length. A single check character is added by Zint, appearing in the 2nd character position. Lowercase input is automatically made uppercase. -![`zint -b BC412 -d "AQ45670" --compliantheight`](images/bc412.svg){.lin} +![`zint -b BC412 -d "AQ45670" --compliant`](images/bc412.svg){.lin} \clearpage @@ -3859,8 +3878,7 @@ character encoding in the same manner as Code 128. GS1 data encoding is also supported. The minimum number of rows to use can be set using the `--rows` option (API `option_1`), with values from 2 to 16. -![`zint -b CODE16K --compliantheight -d -"ab0123456789"`](images/code16k.svg){.lin} +![`zint -b CODE16K --compliant -d "ab0123456789"`](images/code16k.svg){.lin} ### 6.2.4 PDF417 (ISO 15438) @@ -3939,8 +3957,7 @@ except that its height is reduced and its central separator is a single row, making it suitable for small items when omnidirectional scanning is not required. -![`zint -b DBAR_STK --compliantheight -d -"9889876543210"`](images/dbar_stk.svg){.lin} +![`zint -b DBAR_STK --compliant -d "9889876543210"`](images/dbar_stk.svg){.lin} #### 6.2.7.2 GS1 DataBar Stacked Omnidirectional @@ -3948,7 +3965,7 @@ A stacked variation of the GS1 DataBar Omnidirectional symbol requiring the same input (see [6.1.11.1 GS1 DataBar Omnidirectional and GS1 DataBar Truncated]). The data is encoded in two rows of bars with a central 3-row separator. -![`zint -b DBAR_OMNSTK --compliantheight -d +![`zint -b DBAR_OMNSTK --compliant -d "9889876543210"`](images/dbar_omnstk.svg){.lin} #### 6.2.7.3 GS1 DataBar Expanded Stacked @@ -3957,7 +3974,7 @@ A stacked variation of the GS1 DataBar Expanded symbol for smaller packages. Input is the same as for GS1 DataBar Expanded (see [6.1.11.3 GS1 DataBar Expanded]), with the same maximum capacity. -![`zint -b DBAR_EXPSTK --compliantheight -d +![`zint -b DBAR_EXPSTK --compliant -d "[01]98898765432106[3202]012345[15]991231"`](images/dbar_expstk.svg){.lin} The width of the symbol can be altered using the `--cols` switch (API @@ -3978,7 +3995,7 @@ or 81 numeric digits. GS1 data encoding is also supported. The minimum number of fixed-width rows to use can be set using the `--rows` option (API `option_1`), with values from 2 to 8. -![`zint -b CODE49 --compliantheight -d +![`zint -b CODE49 --compliant -d "MULTIPLE ROWS IN CODE 49"`](images/code49.svg){.lin} \clearpage @@ -4073,7 +4090,7 @@ which is being used. CC-A can encode up to 56 numeric digits (including AIs) or an alphanumeric string of shorter length (e.g. if all capitals, at most 30, excluding AI). To select CC-A use `--mode=1` (API `option_1 = 1`). -![`zint -b EAN13_CC --compliantheight -d "[99]1234-abcd" --mode=1 +![`zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=1 --primary=331234567890`](images/ean13_cc_a.svg){.upcean} ### 6.3.2 CC-B @@ -4084,7 +4101,7 @@ to be encoded and the type of linear component which is being used. CC-B can encode up to 338 numeric digits or an alphanumeric string of shorter length. To select CC-B use `--mode=2` (API `option_1 = 2`). -![`zint -b EAN13_CC --compliantheight -d "[99]1234-abcd" --mode=2 +![`zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=2 --primary=331234567890`](images/ean13_cc_b.svg){.upcean} ### 6.3.3 CC-C @@ -4093,7 +4110,7 @@ This system uses PDF417 and can only be used in conjunction with a GS1-128 linear component. CC-C can encode up to 2361 numeric digits or an alphanumeric string of shorter length. To select CC-C use `--mode=3` (API `option_1 = 3`). -![`zint -b GS1_128_CC --compliantheight -d "[99]1234-abcd" --mode=3 +![`zint -b GS1_128_CC --compliant -d "[99]1234-abcd" --mode=3 --primary="[01]03312345678903"`](images/gs1_128_cc_c.svg){.upcean} \clearpage @@ -4107,8 +4124,7 @@ One-Track (see [6.1.9 Pharmacode One-Track]) used for the identification of pharmaceuticals. The symbology is able to encode whole numbers between 4 and 64570080. -![`zint -b PHARMA_TWO --compliantheight -d -"29876543"`](images/pharma_two.svg){.trk} +![`zint -b PHARMA_TWO --compliant -d "29876543"`](images/pharma_two.svg){.trk} ### 6.4.2 POSTNET @@ -4120,8 +4136,7 @@ to 38 digits in length, standard lengths as used by USPS were `PostNet6` `PostNet12` (5-digit ZIP + 6-digit user data), and a warning will be issued if the input length is not one of these. -![`zint -b POSTNET --compliantheight -d -"12345678901"`](images/postnet.svg){.trk} +![`zint -b POSTNET --compliant -d "12345678901"`](images/postnet.svg){.trk} ### 6.4.3 PLANET @@ -4133,8 +4148,7 @@ lengths used by USPS were `Planet12` (11-digit input) and `Planet14` (13-digit input), and as with POSTNET a warning will be issued if the length is not one of these. -![`zint -b PLANET --compliantheight -d -"4012345235636"`](images/planet.svg){.trk} +![`zint -b PLANET --compliant -d "4012345235636"`](images/planet.svg){.trk} ### 6.4.4 Brazilian CEPNet @@ -4143,7 +4157,7 @@ service, to encode CEP (Código de Endereçamento Postal) numbers on mail items. Input should consist of eight digits with the check digit being automatically added by Zint. -![`zint -b CEPNET --compliantheight -d "12345678"`](images/cepnet.svg){.trk} +![`zint -b CEPNET --compliant -d "12345678"`](images/cepnet.svg){.trk} ### 6.4.5 DX Film Edge Barcode @@ -4151,8 +4165,7 @@ Introduced by Kodak in the 1980s, the DX (Digital Index) barcode is printed on the bottom edge of 35mm film to aid in the reordering and post-processing of prints. -![`zint -b DXFILMEDGE --compliantheight -d -"112-1/10A"`](images/dxfilmedge.svg){.trk} +![`zint -b DXFILMEDGE --compliant -d "112-1/10A"`](images/dxfilmedge.svg){.trk} The data can be in two parts. The first part (required) is the "DX number", identifying the manufacturer and film type - the National Association of @@ -4166,7 +4179,7 @@ first and last digit are ignored, leaving a 4-digit DX Extract number in any case, which must be in the range 16 to 2047. The second format `"NNN-NN"` represents the DX Extract as two numbers separated by a dash (`-`), the first number being 1 to 3 digits (range 1 to 127) and the second 1 to 2 digits (range -0 to 15).[^23] +0 to 15).[^24] The optional frame number is a number in the range 0 to 63, and may have a half frame indicator `"A"` appended. Special character sequences (with or without a @@ -4176,7 +4189,7 @@ number 62, `"K"` or `"00"` means frame number 63, and `"F"` means frame number A parity bit is automatically added by Zint. -[^23]: The DX number may be looked up in The (Modified) Big Film Database at +[^24]: The DX number may be looked up in The (Modified) Big Film Database at [https://thebigfilmdatabase.merinorus.com]( https://thebigfilmdatabase.merinorus.com). @@ -4193,7 +4206,7 @@ Barcode 3 are 37-bar, 52-bar and 67-bar specifications respectively, developed by Australia Post for printing Delivery Point ID (DPID) and customer information on mail items. -![`zint -b AUSPOST --compliantheight -d "96184209"`](images/auspost.svg){.trk} +![`zint -b AUSPOST --compliant -d "96184209"`](images/auspost.svg){.trk} Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format Control Code (FCC) is added by Zint and should not be included in the input data. @@ -4226,22 +4239,21 @@ lengths) if the DPID is all zeroes. A Reply Paid version of the Australia Post 4-State Barcode (FCC 45) which requires an 8-digit DPID input. -![`zint -b AUSREPLY --compliantheight -d "12345678"`](images/ausreply.svg){.trk} +![`zint -b AUSREPLY --compliant -d "12345678"`](images/ausreply.svg){.trk} #### 6.5.1.3 Routing Barcode A Routing version of the Australia Post 4-State Barcode (FCC 87) which requires an 8-digit DPID input. -![`zint -b AUSROUTE --compliantheight -d "34567890"`](images/ausroute.svg){.trk} +![`zint -b AUSROUTE --compliant -d "34567890"`](images/ausroute.svg){.trk} #### 6.5.1.4 Redirect Barcode A Redirection version of the Australia Post 4-State Barcode (FCC 92) which requires an 8-digit DPID input. -![`zint -b AUSREDIRECT --compliantheight -d -"98765432"`](images/ausredirect.svg){.trk} +![`zint -b AUSREDIRECT --compliant -d "98765432"`](images/ausredirect.svg){.trk} ### 6.5.2 Dutch Post KIX Code @@ -4249,7 +4261,7 @@ This symbology is used by Royal Dutch TPG Post (Netherlands) for Postal code and automatic mail sorting. Data input can consist of numbers 0-9 and letters A-Z and needs to be 11 characters in length. No check digit is included. -![`zint -b KIX --compliantheight -d "2500GG30250"`](images/kix.svg){.trk} +![`zint -b KIX --compliant -d "2500GG30250"`](images/kix.svg){.trk} ### 6.5.3 Royal Mail 4-State Customer Code (RM4SCC) @@ -4259,14 +4271,14 @@ A-Z and usually includes delivery postcode followed by house number. For example `"W1J0TR01"` for 1 Piccadilly Circus in London. Check digit data is generated by Zint. -![`zint -b RM4SCC --compliantheight -d "W1J0TR01"`](images/rm4scc.svg){.trk} +![`zint -b RM4SCC --compliant -d "W1J0TR01"`](images/rm4scc.svg){.trk} ### 6.5.4 Royal Mail 4-State Mailmark Developed in 2014 as a replacement for RM4SCC this 4-state symbol includes Reed- Solomon error correction. -![`zint -b MAILMARK_4S --compliantheight -d +![`zint -b MAILMARK_4S --compliant -d "21B2254800659JW5O9QA6Y"`](images/mailmark_4s.svg){.trk} Input is a pre-formatted alphanumeric string of 22 (for Barcode C) or 26 (for @@ -4310,7 +4322,7 @@ Also known as the OneCode barcode and used in the U.S. by the United States Postal Service (USPS), the Intelligent Mail system replaced the POSTNET and PLANET symbologies in 2009. -![`zint -b USPS_IMAIL --compliantheight -d +![`zint -b USPS_IMAIL --compliant -d "01234567094987654321-01234"`](images/usps_imail.svg){.trk} Intelligent Mail is a fixed length 65-bar symbol which combines routing and @@ -4329,7 +4341,7 @@ inputs are valid data entries: Used for address data on mail items for Japan Post. Accepted values are 0-9, A-Z and dash (`-`). A modulo 19 check digit is added by Zint. -![`zint -b JAPANPOST --compliantheight -d +![`zint -b JAPANPOST --compliant -d "15400233-16-4-205"`](images/japanpost.svg){.trk} ### 6.5.7 DAFT Code @@ -4357,7 +4369,7 @@ produces the same barcode (see [6.5.3 Royal Mail 4-State Customer Code (RM4SCC)]) as ```bash -zint -b RM4SCC --compliantheight -d "W1J0TR01" +zint -b RM4SCC --compliant -d "W1J0TR01" ``` \clearpage @@ -4439,7 +4451,7 @@ zint -b DATAMATRIX -d "A\^1BC\^1DEF" --extraesc encodes the data `"ABCDEF"`, where `` represents the `FNC1` character. If the data contains an extra escape sequence, it can be escaped by doubling the caret (`^`), i.e. `"\^^"` encodes `"\^"`. Note that if using ECIs -with manual FNC1s then the ECIs must be ASCII compatible.[^24] +with manual FNC1s then the ECIs must be ASCII compatible.[^25] By default Zint uses a "de facto" codeword placement for symbols of size 144 x 144 (version 24). To override this and use the now clarified ISO/IEC standard @@ -4463,7 +4475,7 @@ be given as `"123234"`. Note that both `ID1` and `ID2` must be non-zero, so e.g. `"123000"` or `"000123"` would be invalid IDs. If an ID is not given it defaults to `"001001"`. -[^24]: ASCII-compatible ECIs are ECIs 3 to 18 and 21 to 27 (see +[^25]: ASCII-compatible ECIs are ECIs 3 to 18 and 21 to 27 (see [#tbl:eci_codes]). Note in particular that ECI 899, 8-bit binary, is not considered ASCII-compatible. @@ -4768,7 +4780,7 @@ already Latin-2 formatted use the `--binary` switch (API The following example creates a symbol from data saved as a Latin-2 file: ```bash -zint -o upnqr.png -b UPNQR --scale=3 --binary -i upn.txt +zint -o upnqr.png -b UPNQR --binary -i upn.txt ``` A mask may be manually specified and the `--fast` option used as with [6.6.3 QR @@ -5217,7 +5229,7 @@ is not given, no ID is encoded. Used by the United States Postal Service (USPS), the FIM symbology is used to assist automated mail processing. -![`zint -b FIM --compliantheight -d "C"`](images/fim.svg){.trk} +![`zint -b FIM --compliant -d "C"`](images/fim.svg){.trk} There are only 5 valid symbols which can be generated using the characters A-E as shown in the table below. @@ -5514,7 +5526,7 @@ For full details, see `"backend_qt/qzint.h"`. # Annex C. Tcl Backend Binding -A Tcl binding is available in the `"backend_tcl`" sub-directory. To make on +A Tcl binding is available in the `"backend_tcl"` sub-directory. To make on Unix: ```bash diff --git a/docs/manual.txt b/docs/manual.txt index 0bcb7027..98f08945 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -450,7 +450,7 @@ Below is a brief guide to Zint Barcode Studio. 3.1 Main Window and Data Tab -[Zint Barcode Studio on startup - main window with Data tab] +[Figure 1: Zint Barcode Studio on startup - main window with Data tab] This is the main window of Zint Barcode Studio. The top of the window shows a preview of the barcode that the current settings would create. These settings @@ -483,11 +483,11 @@ available by clicking the "Menu" button, along with "CLI Equivalent...", options. Most of the options are also available in a context menu by right-clicking the preview. -[Main menu (left) and context menu (right)] +[Figure 2: Main menu (left) and context menu (right)] 3.2 GS1 Composite Groupbox -[Encoding GS1 Composite data] +[Figure 3: Encoding GS1 Composite data] In the middle of the Data tab is an area for creating composite symbologies which appears when the currently selected symbology supports the GS1 Composite @@ -503,7 +503,7 @@ discussed. 3.3 Additional ECI/Data Segments Groupbox -[Encoding multiple segments] +[Figure 4: Encoding multiple segments] For symbologies that support ECIs (Extended Channel Interpretations) the middle of the Data tab is an area for entering additional data segments with their own @@ -512,7 +512,7 @@ specified. See 4.16 Multiple Segments for details. 3.4 Symbology-specific Groupbox -[Code 2 of 5 Interleaved Groupbox] +[Figure 5: Code 2 of 5 Interleaved Groupbox] Many symbologies have extra options to change the content, format and appearance of the symbol generated. For those with few additional options (and no support @@ -527,7 +527,7 @@ a second Symbology-specific tab, shown next. 3.5 Symbology-specific Tab -[Aztec Code Tab] +[Figure 6: Aztec Code Tab] A second tab appears for those symbologies with more than a few extra options. @@ -539,7 +539,7 @@ as part of a Structured Append sequence of symbols (see 4.17 Structured Append). 3.6 Appearance Tab -[Appearance Tab] +[Figure 7: Appearance Tab] The Appearance tab can be used to adjust the dimensions and other properties of the symbol. @@ -559,14 +559,14 @@ The size of the saved image can be specified with "Printing Scale", and also by clicking the [scaling] icon to invoke the Set Printing Scale Dialog - see 4.9 Adjusting Image Size (X-dimension) for further details. -[Adjusting the Print Size] +[Figure 8: Adjusting the Print Size] The foreground and background colours can be set either using the text boxes which accept "RRGGBBAA" hexadecimal values and "C,M,Y,K" decimal percentage values, or by clicking the foreground eye [eye] and background eye [eye] buttons which invoke a colour picker. -[The colour picker tool] +[Figure 9: The colour picker tool] (Note that to change the colours visually, the luminance slider, the long narrow column on the right, must be adjusted.) The color picker only deals in RGB(A), @@ -578,7 +578,7 @@ the swap [swap] button next to it. 3.7 Data Dialog -[Entering longer text input] +[Figure 10: Entering longer text input] Clicking on the ellipsis "..." button next to the "Data to Encode" text box in the Data tab opens a larger window which can be used to enter longer strings of @@ -597,7 +597,7 @@ escape sequences, see 4.1 Inputting Data.) 3.8 Sequence Dialog -[Creating a sequence of barcode symbols] +[Figure 11: Creating a sequence of barcode symbols] Clicking on the sequence button (labelled "1234..") in the Data tab opens the Sequence Dialog. This allows you to create multiple barcode images by entering a @@ -610,9 +610,9 @@ meanings as given below: Character Effect --------------------- -------------------------- - $ Insert leading zeroes - # Insert leading spaces - * Insert leading asterisks + $ (dollar) Insert leading zeroes + # (hash) Insert leading spaces + * (asterisk) Insert leading asterisks Any other character Interpreted literally Table 1: Sequence Format Characters @@ -622,7 +622,7 @@ up the Export Dialog, discussed next. 3.9 Export Dialog -[Setting filenames for an exported sequence of barcode symbols] +[Figure 12: Setting filenames for an exported sequence of barcode symbols] The Export Dialog invoked by pressing the "Export..." button in the Sequence Dialog sets the parameters for exporting the sequence of barcode images. Here @@ -632,7 +632,7 @@ information are taken from the main window. 3.10 CLI Equivalent Dialog -[Replicating via the command line] +[Figure 13: Replicating via the command line] The CLI Equivalent Dialog can be invoked from the main menu or the context menu (Figure 2: Main menu (left) and context menu (right)) and displays the CLI @@ -651,9 +651,9 @@ if ".EXE" is not in your PATHEXT environment variable, i.e.: For compatibility with Windows the examples use double quotes to delimit data, though on Unix single quotes are generally preferable as they stop the shell -from processing any characters such as backslash or dollar. A single quote -itself is dealt with by terminating the single-quoted text, backslashing the -single quote, and then continuing: +from processing characters such as backslash. A single quote itself is dealt +with by terminating the single-quoted text, backslashing the single quote, and +then continuing: zint -d 'Text containing a single quote '\'' in the middle' @@ -672,6 +672,10 @@ ambiguity. For long names a space or an equals sign may be used. For instance: The examples use a space separator for short option names, and an equals sign for long option names. +Long options may be abbreviated up to nonambiguity. For instance +--compliantheight may be shortened to --compliant, or even --com, but note that +future additions may necessitate longer abbreviations. + 4.1 Inputting Data The data to encode can be entered at the command line using the -d or --data @@ -681,14 +685,13 @@ option, for example This will encode the text "This Text". Zint will use the default symbology, Code 128, and output to the default file "out.png" in the current directory. -Alternatively, if libpng was not present when Zint was built, the default output -file will be "out.gif". +Alternatively, if Zint was not built with libpng, the default output file will +be "out.gif". -The data input to the Zint CLI is assumed to be encoded in UTF-8 (Unicode) -format (Zint will correctly handle UTF-8 data on Windows). If you are encoding -characters beyond the 7-bit ASCII set using a scheme other than UTF-8 then you -will need to set the appropriate input options as shown in 4.11 Input Modes -below. +The data input to the Zint CLI is assumed to be encoded in UTF-8 (Unicode) (Zint +will correctly handle UTF-8 data on Windows). If you are encoding characters +beyond the 7-bit ASCII set using a scheme other than UTF-8 then you will need to +set the appropriate input options as shown in 4.11 Input Modes below. Non-printing characters can be entered on the command line using backslash (\) as an escape character in combination with the --esc switch. Permissible @@ -785,8 +788,8 @@ See 6.1.10.1 Standard Code 128 (ISO 15417) for the details on manually switching Code Sets. Input data can be read directly from file using the -i or --input switch as -shown below. The input file is assumed to be UTF-8 formatted unless an -alternative mode is selected. This option replaces the use of the -d switch. +shown below. The input file is assumed to be in UTF-8 unless --binary is +selected. This option replaces the use of the -d switch. zint -i somefile.txt @@ -832,6 +835,9 @@ created if they don’t already exist: Note that on Windows, filenames are assumed to be UTF-8 encoded. +For another way to name output files, using the --mirror option, see 4.14 +Automatic Filenames. + 4.3 Selecting Barcode Type Selecting which type of barcode you wish to produce (i.e. which symbology to @@ -1106,7 +1112,7 @@ are. For instance zint -b PDF417 -d "This Text" --height=4 --heightperrow -[zint -b PDF417 -d "This Text" --height=4 --heightperrow] +[Figure 14: zint -b PDF417 -d "This Text" --height=4 --heightperrow] will produce a barcode of height 32X, with each of the 8 rows 4X high. @@ -1154,7 +1160,7 @@ X-dimension, must be specified using the --border switch. For example: zint --box --border=10 -w 10 -d "This Text" -[zint --border=10 --box -d "This Text" -w 10] +[Figure 15: zint --border=10 --box -d "This Text" -w 10] gives a box with a width 10 times the X-dimension of the symbol. Note that when specifying a box, horizontal whitespace is usually required in order to create a @@ -1166,7 +1172,7 @@ inside any vertical whitespace (or text). For matrix symbols, however, where they are decorative rather than functional, boundary bars appear outside any whitespace. -[zint -b QRCODE --border=1 --box -d "This Text" --quietzones] +[Figure 16: zint -b QRCODE --border=1 --box -d "This Text" --quietzones] Codablock F, Code 16K and Code 49 always have boundary bars, and default to particular horizontal whitespace values. Special considerations apply to ITF-14 @@ -1195,7 +1201,7 @@ below). For example the command alters the symbol to a bright green. -[zint -d "This Text" --fg=00FF00] +[Figure 17: zint -d "This Text" --fg=00FF00] Zint also supports RGBA colour information for those output file formats which support alpha channels (currently only GIF, PCX, PNG, SVG and TIF, with GIF @@ -1204,7 +1210,7 @@ format. For example: zint --fg=00ff0055 -d "This Text" -[zint -d "This Text" --fg=00FF0055] +[Figure 18: zint -d "This Text" --fg=00FF0055] will produce a semi-transparent green foreground with a standard (white) background. Note that transparency is treated differently by raster and vector @@ -1230,7 +1236,7 @@ The symbol can be rotated through four orientations using the --rotate option followed by the angle of rotation, valid values being 0 (the default), 90, 180 and 270. -[zint -d "This Text" --rotate=90] +[Figure 19: zint -d "This Text" --rotate=90] 4.9 Adjusting Image Size (X-dimension) @@ -1242,9 +1248,8 @@ applied to the X-dimension. For MaxiCode, it is multiplied by 10 for raster output, by 40 for EMF vector output, and by 2 otherwise (non-EMF vector output). For non-MaxiCode raster output, the default scale of 1 results in an X-dimension -of 2 pixels. For example for non-MaxiCode PNG images a scale of 5 will increase -the X-dimension to 10 pixels. For MaxiCode, see 4.9.3 MaxiCode Raster Scaling -below. +of 2 pixels, e.g. for PNG images a scale of 5 will increase the X-dimension to +10 pixels. For MaxiCode, see 4.9.3 MaxiCode Raster Scaling below. Scales for non-MaxiCode raster output should be given in increments of 0.5, i.e. 0.5, 1, 1.5, 2, 2.5, 3, 3.5, etc., to avoid the X-dimension varying across the @@ -1307,12 +1312,12 @@ nominal size” gives an example of an EAN-13 barcode using the X-dimension of 300 dpi (dpi = dpmm * 25.4), specify a scale of 2, since 0.33 * 12 = 3.96 pixels, or 4 pixels rounding to the nearest pixel: - zint -b EAN13 -d "501234567890" --compliantheight --scale=2 + zint -b EAN13 -d "501234567890" --compliant --scale=2 This will result in output of 37.29mm x 25.56mm (WxH) at 12 dpmm. The same result can be achieved using the --scalexdimdp option with - zint -b EAN13 -d "501234567890" --compliantheight --scalexdimdp + zint -b EAN13 -d "501234567890" --compliant --scalexdimdp as 0.33mm is the default X-dimension for EAN, and 12 dpmm the default resolution. @@ -1343,32 +1348,32 @@ Text can be set to bold using the --bold option, or a smaller font can be substituted using the --small option. The --bold and --small options can be used together if required, but only for vector output. -[zint --bold -d "This Text" --small] +[Figure 20: zint --bold -d "This Text" --small] The gap between the barcode and the text can be adjusted using the --textgap option, where the gap is given in X-dimensions, and may be negative (minimum -5.0X, maximum 10.0X). The default gap is 1X. Note that a very small gap may cause accented texts to overlap with the barcode: -[zint -d "Áccent" --textgap=0.1] +[Figure 21: zint -d "Áccent" --textgap=0.1] For SVG output, the font preferred by Zint (monospaced “OCR-B” for EAN/UPC, “Arimo” - a proportional sans-serif font metrically compatible with “Arial” - for all others) can be embedded in the file for portability using the --embedfont option: -[zint -d "Áccent" --embedfont] +[Figure 22: zint -d "Áccent" --embedfont] 4.11 Input Modes 4.11.1 Unicode, Data, and GS1 Modes -By default all CLI input data is assumed to be encoded in UTF-8 format. Many -barcode symbologies encode data using the Latin-1 (ISO/IEC 8859-1 plus ASCII) -character set, so input is converted from UTF-8 to Latin-1 before being put in -the symbol. In addition QR Code and its variants and Han Xin Code can by default -encode Japanese (Kanji) or Chinese (Hanzi) characters which are also converted -from UTF-8. +By default all CLI input data is assumed to be encoded in UTF-8. Many barcode +symbologies encode data using the Latin-1 (ISO/IEC 8859-1 plus ASCII) character +set, so input is converted from UTF-8 to Latin-1 before being put in the symbol. +In addition QR Code and its variants and Han Xin Code can by default encode +Japanese (Kanji) or Chinese (Hanzi) characters which are also converted from +UTF-8. There are two exceptions to the Latin-1 default: Grid Matrix, whose default character set is GB 2312 (Chinese); and UPNQR, whose default character set is @@ -1509,47 +1514,49 @@ information. 4.11.2.1 Input Modes and ECI Example 1 -The Euro sign U+20AC can be encoded in ISO/IEC 8859-15. The Euro sign has the -ISO/IEC 8859-15 codepoint hex "A4". It is encoded in UTF-8 as the hex sequence: -"E2 82 AC". Those 3 bytes are contained in the file "utf8euro.txt". This command -will generate the corresponding code: +The Euro sign "€" (U+20AC) can be encoded in ISO/IEC 8859-15 (ECI 17) as the hex +byte "A4". It is encoded in UTF-8 as the hex sequence: "E2 82 AC". Those 3 bytes +are contained in the file "utf8euro.txt", e.g. on Unix - zint -b DATAMATRIX --scale=10 --eci=17 -i utf8euro.txt + echo -ne '\xE2\x82\xAC' > utf8euro.txt + +This command will generate the corresponding code: + + zint -b DATAMATRIX --eci=17 -i utf8euro.txt This is equivalent to the commands (using the --esc switch): - zint -b DATAMATRIX --scale=10 --eci=17 --esc -d "\xE2\x82\xAC" + zint -b DATAMATRIX --eci=17 --esc -d "\xE2\x82\xAC" - zint -b DATAMATRIX --scale=10 --eci=17 --esc -d "\u20AC" + zint -b DATAMATRIX --eci=17 --esc -d "\u20AC" and to the command: - zint -b DATAMATRIX --scale=10 --eci=17 -d "€" + zint -b DATAMATRIX --eci=17 -d "€" -[zint -b DATAMATRIX --eci=17 -d "€"] +[Figure 23: zint -b DATAMATRIX --eci=17 -d "€"] 4.11.2.2 Input Modes and ECI Example 2 -The Chinese character with the Unicode codepoint U+5E38 can be encoded in Big5 -encoding. The Big5 representation of this character is the two hex bytes: -"B1 60" (contained in the file "big5char.txt"). The generation command for Data -Matrix is: +The Chinese character "碼" (U+78BC) can be encoded in Big5 encoding (ECI 28) as +the hex sequence: "BD 58". Those 2 bytes are contained in the file +"big5char.txt". The generation command is: - zint -b DATAMATRIX --scale=10 --eci=28 --binary -i big5char.txt + zint -b DATAMATRIX --eci=28 --binary -i big5char.txt This is equivalent to the command (using the --esc switch): - zint -b DATAMATRIX --scale=10 --eci=28 --binary --esc -d "\xB1\x60" + zint -b DATAMATRIX --eci=28 --binary --esc -d "\xBD\x58" and to the commands (no --binary switch so conversion occurs): - zint -b DATAMATRIX --scale=10 --eci=28 --esc -d "\xE5\xB8\xB8" + zint -b DATAMATRIX --eci=28 --esc -d "\xE7\xA2\xBC" - zint -b DATAMATRIX --scale=10 --eci=28 --esc -d "\u5E38" + zint -b DATAMATRIX --eci=28 --esc -d "\u78BC" - zint -b DATAMATRIX --scale=10 --eci=28 -d "常" + zint -b DATAMATRIX --eci=28 -d "碼" -[zint -b DATAMATRIX --eci=28 -d "\u5E38" --esc] +[Figure 24: zint -b DATAMATRIX --eci=28 --binary --esc -d "\xBD\x58"] 4.11.2.3 Input Modes and ECI Example 3 @@ -1557,9 +1564,9 @@ Some decoders (in particular mobile app ones) for QR Code assume UTF-8 encoding by default and do not support ECI. In this case supply UTF-8 data and use the --binary switch so that the data will be encoded as UTF-8 without conversion: - zint -b QRCODE --binary -d "UTF-8 data" + zint -b QRCODE --binary -d "€" -[zint -b QRCODE --binary -d "\xE2\x82\xAC\xE5\xB8\xB8" --esc] +[Figure 25: zint -b QRCODE --binary -d "€"] 4.11.3 GS1 Data Entry and Options @@ -1588,7 +1595,8 @@ The following symbologies accept GS1 data: GS1-128 No Yes Yes GS1 DataBar Expanded No Yes Yes - (including Stacked) + (including Expanded + Stacked) GS1 DataBar (all others) Yes (01) Yes Yes @@ -1656,9 +1664,8 @@ GS1 options. - --gs1strict, which enables the use the GS1 Syntax Engine to strictly validate GS1 data, including GS1 Digital Link URIs (by default Zint does not - validate Digital Links at all). It requires that the gs1encoders library was - present when Zint was built, otherwise the default built-in validation will - be used. + validate Digital Links at all). It requires that Zint was built with the + gs1encoders library, otherwise the default built-in validation will be used. - --gs1nocheck, for use with legacy systems that have data that does not conform to the current GS1 standard. Printable ASCII input is still checked @@ -1695,9 +1702,9 @@ characters in the output filename as shown in the table below: Input Character Interpretation ----------------- ---------------------------------------- - ~ Insert a number or 0 - # Insert a number or space - @ Insert a number or * (or + on Windows) + ~ (tilde) Insert a number or 0 + # (hash) Insert a number or space + @ (ampersand) Insert a number or * (or + on Windows) Any other Insert literally Table 11: Batch Filename Formatting @@ -1735,7 +1742,7 @@ Automatic Filenames below. The finished image files can be output directly to stdout for use as part of a pipe by using the --direct option. By default --direct will output data as a PNG -image (or GIF image if libpng is not present), but this can be altered by +image (or GIF image if Zint not built with libpng), but this can be altered by supplementing the --direct option with a --filetype option followed by the suffix of the file type required. For example: @@ -1760,13 +1767,25 @@ batch data. For example the input data "1234567" will result in a file named There are restrictions, however, on what characters can be stored in a filename, so the filename may vary from the data if the data includes non-printable -characters, for example, and may be shortened if the data input is long. +characters, for example,[12] and may be shortened if the data input is long. So +in batch mode your data must be unique given these restrictions otherwise files +will overwrite each other. To set the output file format use the --filetype option as detailed above in -4.13 Direct Output to stdout. To output to a specific directory use the -o -option giving the name of the directory (any filename will be ignored, unless ---filetype is not specified, in which case the filename’s extension will be -used). +4.13 Direct Output to stdout. For instance + + zint -d "1234567" --mirror --filetype=eps + +will output to the file "1234567.eps": + +To output to a specific directory use the -o option giving the name of the +directory, indicated by a terminating slash / (backslash \ may be used on +Windows). Any filename after the last slash will be ignored, unless --filetype +is not specified, in which case the filename’s extension will be used - e.g. + + zint -d "1234567" --mirror -o "dir/subdir/mir.eps" + +will output to the file "1234567.eps" in the "dir/subdir" directory. 4.15 Working with Dots @@ -1779,7 +1798,7 @@ maximum is 20. The default size is 0.8. The default and minimum scale for raster output in dotty mode is 1. -[zint -b CODEONE -d "123456789012345678" --dotty --vers=9] +[Figure 26: zint -b CODEONE -d "123456789012345678" --dotty --vers=9] 4.16 Multiple Segments @@ -1797,7 +1816,7 @@ specifies 3 segments: segment 0 with ECI 9 (Greek), segment 1 with ECI 7 Naturally the symbology must be ECI-aware (see Table 8: ECI-Aware Symbologies). -[zint -b AZTEC --eci=9 -d "Κείμενο" --seg1=7,"Текст" --seg2=20,"文章"] +[Figure 27: zint -b AZTEC --eci=9 -d "Κείμενο" --seg1=7,"Текст" --seg2=20,"文章"] ECIs of zero may be given, in which case Zint will automatically determine an ECI if necessary, as described in section 4.11.2 Input Modes and ECI. @@ -1816,7 +1835,7 @@ and has the format --structapp=I,C[,ID] -[zint -b DATAMATRIX -d "2nd of 3" --structapp="2,3,5006"] +[Figure 28: zint -b DATAMATRIX -d "2nd of 3" --structapp="2,3,5006"] where I is the index (position) of the symbol in the Structured Append sequence, C is the count or total number of symbols in the sequence, and ID is an optional @@ -1894,8 +1913,8 @@ using the -lzint option: To encode data in a barcode use the ZBarcode_Encode() function. To write the symbol to a file use the ZBarcode_Print() function. For example the following code takes a string from the command line and outputs a Code 128 symbol to a PNG -file named "out.png" (or a GIF file "out.gif" if libpng is not present) in the -current working directory: +file named "out.png" (or a GIF file "out.gif" if Zint not built with libpng) in +the current working directory: #include int main(int argc, char **argv) @@ -2103,7 +2122,7 @@ the buffer is given in memfile_size. For instance: } will print the SVG output to stdout (the file "mem.svg" is not created). This is -particularly useful for the textual formats EPS and SVG,[12] allowing the output +particularly useful for the textual formats EPS and SVG,[13] allowing the output to be manipulated and processed by the client. 5.7 Setting Options @@ -2124,7 +2143,7 @@ the following members: height float Symbol height in Symbol dependent X-dimensions, excluding fixed width-to-height - symbols.[13] + symbols.[14] scale float Scale factor for adjusting 1.0 size of image (sets @@ -2171,7 +2190,7 @@ the following members: end in .png, .gif, .bmp, .emf, .eps, .pcx, .svg, .tif or .txt followed by a - terminating NUL.[14] + terminating NUL.[15] primary character Primary message data for "" (empty) string more complex symbols, with @@ -2447,10 +2466,10 @@ together when adjusting this value: -------------------------- --------------------------------------------------- 0 No options selected. - BARCODE_BIND_TOP Boundary bar above the symbol only.[15] + BARCODE_BIND_TOP Boundary bar above the symbol only.[16] BARCODE_BIND Boundary bars above and below the symbol and - between rows if stacking multiple symbols.[16] + between rows if stacking multiple symbols.[17] BARCODE_BOX Add a box surrounding the symbol and whitespace. @@ -2477,7 +2496,7 @@ together when adjusting this value: Symbols in Memory (raster). BARCODE_QUIET_ZONES Add compliant quiet zones (additional to any - specified whitespace).[17] + specified whitespace).[18] BARCODE_NO_QUIET_ZONES Disable quiet zones, notably those with defaults. @@ -2728,7 +2747,7 @@ see which are set. ZINT_CAP_STACKABLE Is the symbology stackable? Note that stacked symbologies are not stackable. - ZINT_CAP_EANUPC[18] Is the symbology EAN/UPC? + ZINT_CAP_EANUPC[19] Is the symbology EAN/UPC? ZINT_CAP_COMPOSITE Does the symbology support composite data? (see 6.3 GS1 Composite Symbols (ISO 24723) below) @@ -2786,7 +2805,7 @@ option_2 and option_3 members will be set to the values used by Zint to create the barcode. This is useful for feedback if the values were left as defaults or were overridden by Zint. -In particular for symbologies that have masks,[19] option_3 will contain the +In particular for symbologies that have masks,[20] option_3 will contain the mask used as (N + 1) << 8, N being the mask. Also Aztec Code will return the actual ECC percentage used in option_1 as P << 8, where P is the integer percentage, the low byte containing the values given in Table 41: Aztec Code @@ -2802,7 +2821,7 @@ being set in content_seg_count - which will always be at least one. The source, length and eci members of zint_seg will be set accordingly - the unconverted data in source, the data length in length, and the character set the -data was converted to in eci. Any check characters encoded will be included,[20] +data was converted to in eci. Any check characters encoded will be included,[21] and for GS1 data any FNC1 separators will be represented as GS (ASCII 29) characters. UPC-A and UPC-E data will be expanded to EAN-13, as will EAN-8 but only if it has an add-on (otherwise it will remain at 8 digits), and any add-ons @@ -2818,7 +2837,7 @@ two helper functions discussed next. 5.17 UTF-8 to ECI convenience functions As a convenience the conversion done by Zint from UTF-8 to ECIs is exposed in -two helper functions (compatible with the libzueci[21] functions +two helper functions (compatible with the libzueci[22] functions zueci_utf8_to_eci() and zueci_dest_len_eci()): int ZBarcode_UTF8_To_ECI(int eci, const unsigned char *source, int length, @@ -2877,7 +2896,7 @@ Developed by Intermec in 1977 for Bell Labs as a high-density barcode to track small telephone components, Code 11 can encode data consisting of the digits 0-9 and the dash character (-) up to a maximum of 140 characters. -[zint -b CODE11 -d "9212320967"] +[Figure 29: zint -b CODE11 -d "9212320967"] Two modulo-11 check digits are added by default. To add just one check digit, set --vers=1 (API option_2 = 1). To add no check digits, set --vers=2 (API @@ -2896,7 +2915,7 @@ Also known as Code 2 of 5 Matrix, and used in industrial applications and photo development, Standard Code 2 of 5 will encode numeric input (digits 0-9) up to a maximum of 112 digits. -[zint -b C25STANDARD -d "9212320967"] +[Figure 30: zint -b C25STANDARD -d "9212320967"] No check digit is added by default. To add a check digit, set --vers=1 (API option_2 = 1). To add a check digit but not show it in the Human Readable Text, @@ -2907,7 +2926,7 @@ set --vers=2 (API option_2 = 2). Used by the International Air Transport Agency (IATA) for baggage handling, this barcode will encode numeric input (digits 0-9) up to a maximum of 80 digits. -[zint -b C25IATA -d "9212320967"] +[Figure 31: zint -b C25IATA -d "9212320967"] No check digit is added by default, but can be set the same as for 6.1.2.1 Standard Code 2 of 5. @@ -2917,7 +2936,7 @@ Standard Code 2 of 5. Industrial Code 2 of 5 can encode numeric input (digits 0-9) up to a maximum of 79 digits. -[zint -b C25IND -d "9212320967"] +[Figure 32: zint -b C25IND -d "9212320967"] No check digit is added by default, but can be set the same as for 6.1.2.1 Standard Code 2 of 5. @@ -2928,7 +2947,7 @@ A high-density barcode that encodes pairs of numbers, and so can only encode an even number of digits (0-9). If an odd number of digits is entered a leading zero is added by Zint. A maximum of 62 pairs (124 digits) can be encoded. -[zint -b C25INTER --compliantheight -d "9212320967"] +[Figure 33: zint -b C25INTER --compliant -d "9212320967"] No check digit is added by default, but can be set the same as for 6.1.2.1 Standard Code 2 of 5. @@ -2938,7 +2957,7 @@ Standard Code 2 of 5. Data Logic, also known as China Post or Hong Kong 2 of 5, can encode numeric input (digits 0-9) up to a maximum of 113 digits. -[zint -b C25LOGIC -d "9212320967"] +[Figure 34: zint -b C25LOGIC -d "9212320967"] No check digit is added by default, but can be set the same as for 6.1.2.1 Standard Code 2 of 5. @@ -2952,7 +2971,7 @@ entered, or a 14-digit input if the standard GS1 check digit is given, in which case the check digit will be verified. A standard GS1 check digit is added by Zint unless already given. -[zint -b ITF14 --compliantheight -d "9212320967145"] +[Figure 35: zint -b ITF14 --compliant -d "9212320967145"] If no border option is specified Zint defaults to adding a bounding box with a border width of 5. This behaviour can be overridden by using the --bind option @@ -2961,7 +2980,7 @@ overridden using --border (API border_width). If a symbol with no border is required this can be achieved by explicitly setting the border type to box (or bind or bindtop) and leaving the border width 0. -[zint -b ITF14 --box --compliantheight -d "9212320967145"] +[Figure 36: zint -b ITF14 --box --compliant -d "9212320967145"] 6.1.2.7 Deutsche Post Leitcode @@ -2969,7 +2988,7 @@ Leitcode is based on Interleaved Code 2 of 5 and is used by Deutsche Post for routing purposes. Leitcode requires a 13-digit numerical input to which Zint adds a check digit. -[zint -b DPLEIT -d "9212320967145"] +[Figure 37: zint -b DPLEIT -d "9212320967145"] 6.1.2.8 Deutsche Post Identcode @@ -2977,7 +2996,7 @@ Identcode is based on Interleaved Code 2 of 5 and is used by Deutsche Post for identification purposes. Identcode requires an 11-digit numerical input to which Zint adds a check digit. -[zint -b DPIDENT -d "91232096712"] +[Figure 38: zint -b DPIDENT -d "91232096712"] 6.1.3 UPC (Universal Product Code) (ISO 15420) @@ -2987,7 +3006,7 @@ UPC-A is used in the United States for retail applications, and encodes a GTIN-12, a 12-digit Global Trade Item Number that includes a standard GS1 check digit. -[zint -b UPCA --compliantheight -d "01234500005"] +[Figure 39: zint -b UPCA --compliant -d "01234500005"] Input up to 11 digits may be given, to which a check digit will be added by Zint. A 12-digit input including the check digit may also be supplied, in which @@ -3010,7 +3029,7 @@ or using the API: /* Or a space */ error = ZBarcode_Encode_and_Print(symbol, "01234500005 12345", 0, 0); -[zint -b UPCA --compliantheight -d "01234500005+12345"] +[Figure 40: zint -b UPCA --compliant -d "01234500005+12345"] A quiet zone indicator can be added to the HRT by setting --guardwhitespace (API output_options |= EANUPC_GUARD_WHITESPACE). For UPC, this is only relevant when @@ -3024,7 +3043,7 @@ or using the API: symbol->output_options |= EANUPC_GUARD_WHITESPACE; error = ZBarcode_Encode_and_Print(symbol, "01234500005+12345", 0, 0); -[zint -b UPCA --compliantheight -d "01234500005+12345" --guardwhitespace] +[Figure 41: zint -b UPCA --compliant -d "01234500005+12345" --guardwhitespace] You can adjust the gap between the main symbol and an add-on in integral multiples of the X-dimension by setting --addongap (API option_2) to a value @@ -3040,7 +3059,7 @@ Zint. If 7 digits are given then the first must be ‘0’ or ‘1’ (the latte known as number system 1 and is non-standard). Input less than 7 digits will be zero-filled. -[zint -b UPCE --compliantheight -d "123455"] +[Figure 42: zint -b UPCE --compliant -d "123455"] An 8-digit input including the check digit may also be supplied, in which case Zint will verify the check digit, or the symbology BARCODE_UPCE_CHK (38) may be @@ -3053,7 +3072,7 @@ output_options |= EANUPC_GUARD_WHITESPACE): zint -b UPCE -d "123455+12" --guardwhitespace -[zint -b UPCE --compliantheight -d "123455+12" --guardwhitespace] +[Figure 43: zint -b UPCE --compliant -d "123455+12" --guardwhitespace] You can adjust the gap between the main symbol and an add-on in integral multiples of the X-dimension by setting --addongap (API option_2) to a value @@ -3073,7 +3092,7 @@ EAN-8 and ISBN (a subset of EAN-13). EAN-13 encodes a GTIN-13, a 13-digit Global Trade Item Number that includes a standard GS1 check digit. -[zint -b EAN13 --compliantheight -d "952012345678"] +[Figure 44: zint -b EAN13 --compliant -d "952012345678"] Input up to 12 digits may be given, to which a check digit will be added by Zint, or a 13-digit input can be supplied in which case Zint will validate the @@ -3090,22 +3109,22 @@ be achieved using the API: symbol->symbology = BARCODE_EAN13; error = ZBarcode_Encode_and_Print(symbol, "952012345678+21", 0, 0); -[zint -b EAN13 --compliantheight -d "952012345678+21"] +[Figure 45: zint -b EAN13 --compliant -d "952012345678+21"] Options to add quiet zone indicators and to adjust the add-on gap and the guard bar descent height are the same as for 6.1.3.2 UPC Version E. For instance: zint -b EAN13 -d "9520123456788" --guarddescent=2.5 --guardwhitespace -[zint -b EAN13 --compliantheight -d "9520123456788" –guarddescent=2.5 -–guardwhitespace] +[Figure 46: zint -b EAN13 --compliant -d "9520123456788" --guarddescent=2.5 --gu +ardwhitespace] 6.1.4.2 EAN-8 EAN-8 is a shortened version of EAN-13, encoding a GTIN-8 (a GTIN-13 with 5 leading zeroes implied), for use with small packages. -[zint -b EAN8 --compliantheight -d "9520000"] +[Figure 47: zint -b EAN8 --compliant -d "9520000"] Input up to 7 digits may be supplied, to which Zint will add a standard GS1 check digit. An 8-digit input including the check digit may also be given, in @@ -3123,7 +3142,7 @@ or using the API: symbol->output_options |= EANUPC_GUARD_WHITESPACE; error = ZBarcode_Encode_and_Print(symbol, "9520000", 0, 0); -[zint -b EAN8 --compliantheight -d "9520000" –guardwhitespace] +[Figure 48: zint -b EAN8 --compliant -d "9520000" –guardwhitespace] 2-digit and 5-digit add-ons may also be added, and the gap adjusted, as with EAN-13, but this usage is non-standard and Zint will issue a warning on use. @@ -3135,11 +3154,11 @@ SBN, 10-digit ISBN or 13-digit ISBN-13 data. The relevant check digit needs to be present in the input data and will be verified before the symbol is generated. -[zint -b ISBNX --compliantheight -d "9789295055124"] +[Figure 49: zint -b ISBNX --compliant -d "9789295055124"] As with EAN-13, a quiet zone indicator can be added using --guardwhitespace: -[zint -b ISBNX --compliantheight -d "9789295055124" --guardwhitespace] +[Figure 50: zint -b ISBNX --compliant -d "9789295055124" --guardwhitespace] 2-digit and 5-digit add-on symbols can be added using a + or space character, and there are options to adjust the add-on gap and the guard bar descent @@ -3151,7 +3170,7 @@ As a convenience, 2-digit and 5-digit add-ons may be generated as standalone symbols using the symbologies BARCODE_EAN_2ADDON (11) and BARCODE_EAN_5ADDON (12). -[zint -b EAN_2ADDON --compliantheight -d "12"] +[Figure 51: zint -b EAN_2ADDON --compliant -d "12"] As with the main EAN/UPC symbols a quiet zone indicator can be added using ---guardwhitespace. For instance @@ -3165,7 +3184,7 @@ API: symbol->output_options |= EANUPC_GUARD_WHITESPACE; error = ZBarcode_Encode_and_Print(symbol, "54321", 0, 0); -[zint -b EAN_5ADDON --compliantheight -d "54321" –guardwhitespace] +[Figure 52: zint -b EAN_5ADDON --compliant -d "54321" –guardwhitespace] 6.1.5 Plessey @@ -3175,7 +3194,7 @@ Also known as Plessey Code, this symbology was developed by the Plessey Company Ltd. in the UK. The symbol can encode data consisting of digits (0-9) or letters A-F (i.e. hexadecimal digits) up to a maximum of 67 characters. -[zint -b PLESSEY -d "C64"] +[Figure 53: zint -b PLESSEY -d "C64"] The symbol includes two hidden CRC check digits, which may be shown in the Human Readable Text by setting --vers=1 (API option_2 = 1). @@ -3185,7 +3204,7 @@ Readable Text by setting --vers=1 (API option_2 = 1). Based on UK Plessey and developed by MSI Data Corporation, MSI Plessey can encode numeric (digits 0-9) input of up to 92 digits. -[zint -b MSI_PLESSEY -d "6502" --vers=2] +[Figure 54: zint -b MSI_PLESSEY -d "6502" --vers=2] MSI Plessey has a range of check digit options that are selectable by setting --vers (API option_2), shown in the table below: @@ -3214,7 +3233,7 @@ Telepen Alpha was developed in 1972 by SB Electronic Systems Limited and can encode ASCII text input, up to a maximum of 69 characters. Telepen includes a hidden modulo-127 check digit, added by Zint. -[zint -b TELEPEN --compliantheight -d "Z8000"] +[Figure 55: zint -b TELEPEN --compliant -d "Z8000"] AIM-defined Start/Stop characters may be enabled by setting --vers=1 (API option_2 = 1). In this mode control character DLE (ASCII 16, escape sequence \L) @@ -3222,7 +3241,7 @@ indicates a switch from Full ASCII to Compressed Numeric, where each symbol character encodes a digit pair (or a “digit X” pair - see Telepen Numeric below): -[zint -b TELEPEN --compliantheight -d "Z\L8000" -esc --vers=1] +[Figure 56: zint -b TELEPEN --compliant -d "Z\L8000" -esc --vers=1] However not all barcode readers recognise this mode so check before using. @@ -3235,17 +3254,17 @@ is not (the pair "X3" is not valid). If an odd number of digits is supplied, Zint will add a leading zero. Up to 138 digits can be encoded. A hidden modulo-127 check digit is added by Zint. -[zint -b TELEPEN_NUM --compliantheight -d "466X33"] +[Figure 57: zint -b TELEPEN_NUM --compliant -d "466X33"] Additionally trailing ASCII characters may be encoded by prefixing them with a DLE control character (ASCII 16, escape sequence \L) and appending them to the numeric data: -[zint -b TELEPEN_NUM --compliantheight -d "12\LAB" --esc] +[Figure 58: zint -b TELEPEN_NUM --compliant -d "12\LAB" --esc] This method allows odd numbers to be encoded without a leading zero: -[zint -b TELEPEN_NUM --compliantheight -d "123\L4" --esc] +[Figure 59: zint -b TELEPEN_NUM --compliant -d "123\L4" --esc] AIM-defined Start/Stop characters may be enabled by setting --vers=1 (API option_2 = 1). This allows barcode readers to detect Compressed Numeric data @@ -3261,7 +3280,7 @@ Standard Code 39 was introduced in 1975 by Intermec. Input data can be up to 86 characters in length and can include the characters 0-9, A-Z, dash (-), full stop (.), space, asterisk (*), dollar ($), slash (/), plus (+) and percent (%). -[zint -b CODE39 --compliantheight -d "1A" --vers=1] +[Figure 60: zint -b CODE39 --compliant -d "1A" --vers=1] The standard does not require a check digit but a modulo-43 check digit can be added if desired by setting --vers=1 (API option_2 = 1). To add a check digit @@ -3272,7 +3291,7 @@ but not show it in the Human Readable Text, set --vers=2 (API option_2 = 2). Also known as Code 39e and Code39+, this symbology expands on Standard Code 39 to provide support for the full 7-bit ASCII character set. -[zint -b EXCODE39 --compliantheight -d "123.45#@fd"] +[Figure 61: zint -b EXCODE39 --compliant -d "123.45#@fd"] The check digit options are the same as for 6.1.7.1 Standard Code 39 (ISO 16388). @@ -3284,7 +3303,7 @@ accepting up to 123 characters. Two check characters are added by Zint. By default these check characters are not shown in the Human Readable Text, but may be shown by setting --vers=1 (API option_2 = 1). -[zint -b CODE93 --compliantheight -d "C93"] +[Figure 62: zint -b CODE93 --compliant -d "C93"] 6.1.7.4 PZN (Pharmazentralnummer) @@ -3293,7 +3312,7 @@ PZN encodes a 7-digit number to which Zint will add a modulo-11 check digit (PZN8). Input less than 7 digits will be zero-filled. An 8-digit input can be supplied in which case Zint will validate the check digit. -[zint -b PZN --compliantheight -d "2758089"] +[Figure 63: zint -b PZN --compliant -d "2758089"] To encode a PZN7 (obsolete since 2013) instead set --vers=1 (API option_2 = 1) and supply up to 7 digits. As with PZN8, a modulo-11 check digit will be added @@ -3307,7 +3326,7 @@ LOGMARS encodes the same character set as 6.1.7.1 Standard Code 39 (ISO 16388), and the check digit options are also the same. Input is restricted to a maximum of 30 characters. -[zint -b LOGMARS --compliantheight -d "12345/ABCDE" --vers=1] +[Figure 64: zint -b LOGMARS --compliant -d "12345/ABCDE" --vers=1] 6.1.7.6 Code 32 @@ -3316,7 +3335,7 @@ Sanità”) for encoding identifiers on pharmaceutical products. This symbology requires a numeric input up to 8 digits in length. A check digit is added by Zint. -[zint -b CODE32 --compliantheight -d "14352312"] +[Figure 65: zint -b CODE32 --compliant -d "14352312"] 6.1.7.7 HIBC Code 39 @@ -3324,7 +3343,7 @@ This variant adds a leading '+' character and a trailing modulo-49 check digit to a standard Code 39 symbol as required by the Health Industry Barcode standards. -[zint -b HIBC_39 --compliantheight -d "14352312"] +[Figure 66: zint -b HIBC_39 --compliant -d "14352312"] 6.1.7.8 Vehicle Identification Number (VIN) @@ -3332,7 +3351,7 @@ A variation of Code 39 that for vehicle identification numbers used in North America (first character '1' to '5') has a check character verification stage. A 17 character input (0-9, and A-Z excluding 'I', 'O' and 'Q') is required. -[zint -b VIN -d "2FTPX28L0XCA15511" --vers=1] +[Figure 67: zint -b VIN -d "2FTPX28L0XCA15511" --vers=1] An invisible Import character prefix 'I' can be added by setting --vers=1 (API option_2 = 1). @@ -3344,7 +3363,7 @@ and Monarch, this symbology was developed in 1972 from earlier versions by Pitney Bowes-Alpex for retail price marking. The American Blood Commission adopted Codabar in 1979 as the standard barcode for blood products. -[zint -b CODABAR --compliantheight -d "A37859B"] +[Figure 68: zint -b CODABAR --compliant -d "A37859B"] Codabar can encode up to 103 characters starting and ending with the letters A-D and containing between these letters the numbers 0-9, dash (-), dollar ($), @@ -3360,7 +3379,7 @@ Developed by Laetus, Pharmacode One-Track is used for the identification of pharmaceuticals. The symbology is able to encode whole numbers between 3 and 131070. -[zint -b PHARMA --compliantheight -d "130170"] +[Figure 69: zint -b PHARMA --compliant -d "130170"] 6.1.10 Code 128 @@ -3372,7 +3391,7 @@ and uses a three-Code Set system to compress the data into a smaller symbol. Zint automatically switches between Code Sets A, B and C (but see below) and adds a hidden modulo-103 check digit. -[zint -b CODE128 --bind -d "130170X178"] +[Figure 70: zint -b CODE128 --bind -d "130170X178"] Code 128 is the default barcode symbology used by Zint. In addition Zint supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128 @@ -3414,10 +3433,10 @@ alphanumerics) are not recommended. 6.1.10.2 Code 128 Suppress Code Set C (Code Sets A and B only) It is sometimes advantageous to stop Code 128 from using Code Set C which -compresses numerical data. The BARCODE_CODE128AB[22] variant (symbology 60) +compresses numerical data. The BARCODE_CODE128AB[23] variant (symbology 60) suppresses Code Set C in favour of Code Sets A and B. -[zint -b CODE128AB -d "130170X178"] +[Figure 71: zint -b CODE128AB -d "130170X178"] Note that the special extra escapes mentioned above are not available for this variant (nor for any other). @@ -3429,8 +3448,8 @@ defined by the GS1 General Specifications. Data should be in one of the formats described in 4.11.3.1 GS1 Data Entry. Here we will use the square bracket format. -[zint -b GS1_128 --compliantheight -d "[01]98898765432106[3202]012345[15]991231" -] +[Figure 72: zint -b GS1_128 --compliant -d "[01]98898765432106[3202]012345[15]99 +1231"] Fixed length data should be entered at the appropriate length for correct encoding. GS1-128 does not support extended ASCII (ISO/IEC 8859-1) characters. @@ -3447,7 +3466,7 @@ digits entered, or a 14-digit number if the standard GS1 check digit is given, in which case the check digit will be verified. The GS1 check digit (if not given) and HRT-only AI "(01)" are added by Zint. -[zint -b EAN14 --compliantheight -d "9889876543210"] +[Figure 73: zint -b EAN14 --compliant -d "9889876543210"] 6.1.10.5 NVE-18 (SSCC-18) @@ -3458,7 +3477,7 @@ which will be prefixed with leading zeros if less than 17 digits given, or an 18-digit input if the GS1 check digit is included, in which case the check digit will be verified. Check digit(s) and HRT-only AI "(00)" are added by Zint. -[zint -b NVE18 --compliantheight -d "37612345000001003"] +[Figure 74: zint -b NVE18 --compliant -d "37612345000001003"] 6.1.10.6 HIBC Code 128 @@ -3466,13 +3485,13 @@ This variation adds a leading '+' character and a trailing modulo-49 check digit to a standard Code 128 symbol as required by the Health Industry Barcode standards. -[zint -b HIBC_128 -d "A123BJC5D6E71"] +[Figure 75: zint -b HIBC_128 -d "A123BJC5D6E71"] 6.1.10.7 DPD Code Another variation of Code 128 as used by DPD (Deutscher Paketdienst). -[zint -b DPD --compliantheight -d "000393206219912345678101040"] +[Figure 76: zint -b DPD --compliant -d "000393206219912345678101040"] DPD Code requires a 27 or 28 character input. For 28 character input, the first character is an identification tag (Barcode ID), which should usually be "%" @@ -3516,7 +3535,7 @@ format "SSNNNNNNNNXCC", where "SS" is a two-character alphabetic service indicator, "NNNNNNNN" is an 8-digit serial number, "X" is a modulo-11 check digit, and "CC" is a two-character ISO 3166-1 country code. -[zint -b UPU_S10 --compliantheight -d "EE876543216CA"] +[Figure 77: zint -b UPU_S10 --compliant -d "EE876543216CA"] The check digit may be omitted in which case Zint will add it. Warnings will be generated if the service indicator is non-standard or the country code is not @@ -3540,13 +3559,13 @@ digit and HRT-only Application Identifier of "(01)" are added by Zint. (A case the check digit will be verified.) Input less than 13 digits will be zero-filled. -[zint -b DBAR_OMN --compliantheight -d "0950110153001"] +[Figure 78: zint -b DBAR_OMN --compliant -d "0950110153001"] GS1 DataBar Omnidirectional symbols should have a height of 33 or greater. To produce a GS1 DataBar Truncated symbol set the symbol height to a value between 13 and 32. Truncated symbols may not be scannable by omnidirectional scanners. -[zint -b DBAR_OMN -d "0950110153001" --height=13] +[Figure 79: zint -b DBAR_OMN -d "0950110153001" --height=13] 6.1.11.2 GS1 DataBar Limited @@ -3558,7 +3577,7 @@ digit and HRT-only Application Identifier of "(01)" are added by Zint, and a 14-digit code may be given in which case the check digit will be verified. Input less than 13 digits will be zero-filled. -[zint -b DBAR_LTD --compliantheight -d "0950110153001"] +[Figure 80: zint -b DBAR_LTD --compliant -d "0950110153001"] 6.1.11.3 GS1 DataBar Expanded @@ -3567,8 +3586,8 @@ encoding multiple AIs in a single symbol. Data should be in one of the formats described in 4.11.3.1 GS1 Data Entry, and will be displayed using parentheses (round brackets) in the Human Readable Text. -[zint -b DBAR_EXP --compliantheight -d "[01]98898765432106[3202]012345[15]991231 -"] +[Figure 81: zint -b DBAR_EXP --compliant -d "[01]98898765432106[3202]012345[15]9 +91231"] The GTIN-14 data for AI (01) must include the standard GS1 check digit as this is not calculated by Zint when this symbology is encoded. Data for fixed-length @@ -3583,7 +3602,7 @@ Expanded input: The Korean Postal Barcode is used to encode a 6-digit number and includes one check digit. -[zint -b KOREAPOST -d "923457"] +[Figure 82: zint -b KOREAPOST -d "923457"] 6.1.13 Channel Code @@ -3593,7 +3612,7 @@ the --vers option (API option_2). It can also be determined by the length of the input data: e.g. a three character input string generates a 4 channel code by default. -[zint -b CHANNEL -d "453678" --compliantheight] +[Figure 83: zint -b CHANNEL -d "453678" --compliant] The maximum values permitted depend on the number of channels used as shown in the table below: @@ -3618,7 +3637,7 @@ input must be alphanumeric, excluding the letter O, and must be from 7 to 18 characters in length. A single check character is added by Zint, appearing in the 2nd character position. Lowercase input is automatically made uppercase. -[zint -b BC412 -d "AQ45670" --compliantheight] +[Figure 84: zint -b BC412 -d "AQ45670" --compliant] 6.2 Stacked Symbologies @@ -3640,7 +3659,7 @@ once on a symbol. For example: error = ZBarcode_Encode(symbol, "That", 0); error = ZBarcode_Print(symbol); -[zint -d "This" -d "That"] +[Figure 85: zint -d "This" -d "That"] Note that the Human Readable Text will be that of the last data, so it’s best to use the option --notext (API show_hrt = 0). @@ -3652,7 +3671,7 @@ can be set by --separator (API option_3): zint --bind --notext --separator=2 -d "This" -d "That" -[zint --notext --bind --separator=2 -d "This" -d "That"] +[Figure 86: zint --notext --bind --separator=2 -d "This" -d "That"] A more sophisticated method is to use some type of line indexing which indicates to the barcode reader which order the stacked symbols should be read in. This is @@ -3665,7 +3684,7 @@ to a maximum length of 2726 symbol characters, meaning for instance up to 2726 all ASCII characters, or 5452 all numeric, or up to 1363 all extended ASCII (ISO/IEC 8859-1). -[zint -b CODABLOCKF -d "CODABLOCK F Symbology" --rows=3] +[Figure 87: zint -b CODABLOCKF -d "CODABLOCK F Symbology" --rows=3] The width of the Codablock F symbol can be set using the --cols option (API option_2), to a value between 9 and 67. The height (number of rows) can be set @@ -3686,7 +3705,7 @@ character encoding in the same manner as Code 128. GS1 data encoding is also supported. The minimum number of rows to use can be set using the --rows option (API option_1), with values from 2 to 16. -[zint -b CODE16K --compliantheight -d "ab0123456789"] +[Figure 88: zint -b CODE16K --compliant -d "ab0123456789"] 6.2.4 PDF417 (ISO 15438) @@ -3695,7 +3714,7 @@ amount of data into a small space. Zint supports encoding up to the ISO standard maximum symbol size of 925 codewords which (at error correction level 0) allows a maximum data size of 1850 text characters, or 2710 digits. -[zint -b PDF417 -d "PDF417"] +[Figure 89: zint -b PDF417 -d "PDF417"] The width of the generated PDF417 symbol can be specified at the command line using the --cols switch (API option_2) followed by a number between 1 and 30, @@ -3727,7 +3746,7 @@ Previously known as Truncated PDF417, Compact PDF417 omits some per-row overhead to produce a narrower but less robust symbol. Options are the same as for PDF417 above. -[zint -b PDF417COMP -d "PDF417"] +[Figure 90: zint -b PDF417COMP -d "PDF417"] 6.2.6 MicroPDF417 (ISO 24728) @@ -3739,7 +3758,7 @@ dependent on symbol size. The number of data columns used can be determined using the --cols switch (API option_2) as with PDF417. The amount of data determines the number of rows. -[zint -b MICROPDF417 -d "12345678"] +[Figure 91: zint -b MICROPDF417 -d "12345678"] MicroPDF417 uses Latin-1 character encoding by default but also supports the ECI encoding mechanism. A separate symbology ID (BARCODE_HIBC_MICPDF) can be used to @@ -3765,7 +3784,7 @@ except that its height is reduced and its central separator is a single row, making it suitable for small items when omnidirectional scanning is not required. -[zint -b DBAR_STK --compliantheight -d "9889876543210"] +[Figure 92: zint -b DBAR_STK --compliant -d "9889876543210"] 6.2.7.2 GS1 DataBar Stacked Omnidirectional @@ -3773,7 +3792,7 @@ A stacked variation of the GS1 DataBar Omnidirectional symbol requiring the same input (see 6.1.11.1 GS1 DataBar Omnidirectional and GS1 DataBar Truncated). The data is encoded in two rows of bars with a central 3-row separator. -[zint -b DBAR_OMNSTK --compliantheight -d "9889876543210"] +[Figure 93: zint -b DBAR_OMNSTK --compliant -d "9889876543210"] 6.2.7.3 GS1 DataBar Expanded Stacked @@ -3781,8 +3800,8 @@ A stacked variation of the GS1 DataBar Expanded symbol for smaller packages. Input is the same as for GS1 DataBar Expanded (see 6.1.11.3 GS1 DataBar Expanded), with the same maximum capacity. -[zint -b DBAR_EXPSTK --compliantheight -d "[01]98898765432106[3202]012345[15]991 -231"] +[Figure 94: zint -b DBAR_EXPSTK --compliant -d "[01]98898765432106[3202]012345[1 +5]991231"] The width of the symbol can be altered using the --cols switch (API option_2). In this case the number of columns (values 1 to 11) relates to the number of @@ -3802,7 +3821,7 @@ or 81 numeric digits. GS1 data encoding is also supported. The minimum number of fixed-width rows to use can be set using the --rows option (API option_1), with values from 2 to 8. -[zint -b CODE49 --compliantheight -d "MULTIPLE ROWS IN CODE 49"] +[Figure 95: zint -b CODE49 --compliant -d "MULTIPLE ROWS IN CODE 49"] 6.3 GS1 Composite Symbols (ISO 24723) @@ -3890,8 +3909,8 @@ which is being used. CC-A can encode up to 56 numeric digits (including AIs) or an alphanumeric string of shorter length (e.g. if all capitals, at most 30, excluding AI). To select CC-A use --mode=1 (API option_1 = 1). -[zint -b EAN13_CC --compliantheight -d "[99]1234-abcd" --mode=1 --primary=331234 -567890] +[Figure 96: zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=1 --primary=3 +31234567890] 6.3.2 CC-B @@ -3901,8 +3920,8 @@ to be encoded and the type of linear component which is being used. CC-B can encode up to 338 numeric digits or an alphanumeric string of shorter length. To select CC-B use --mode=2 (API option_1 = 2). -[zint -b EAN13_CC --compliantheight -d "[99]1234-abcd" --mode=2 --primary=331234 -567890] +[Figure 97: zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=2 --primary=3 +31234567890] 6.3.3 CC-C @@ -3910,8 +3929,8 @@ This system uses PDF417 and can only be used in conjunction with a GS1-128 linear component. CC-C can encode up to 2361 numeric digits or an alphanumeric string of shorter length. To select CC-C use --mode=3 (API option_1 = 3). -[zint -b GS1_128_CC --compliantheight -d "[99]1234-abcd" --mode=3 --primary="[01 -]03312345678903"] +[Figure 98: zint -b GS1_128_CC --compliant -d "[99]1234-abcd" --mode=3 --primary +="[01]03312345678903"] 6.4 Two-Track Symbols @@ -3922,7 +3941,7 @@ One-Track (see 6.1.9 Pharmacode One-Track) used for the identification of pharmaceuticals. The symbology is able to encode whole numbers between 4 and 64570080. -[zint -b PHARMA_TWO --compliantheight -d "29876543"] +[Figure 99: zint -b PHARMA_TWO --compliant -d "29876543"] 6.4.2 POSTNET @@ -3934,7 +3953,7 @@ ZIP input), PostNet10 (5-digit ZIP + 4-digit user data) and PostNet12 (5-digit ZIP + 6-digit user data), and a warning will be issued if the input length is not one of these. -[zint -b POSTNET --compliantheight -d "12345678901"] +[Figure 100: zint -b POSTNET --compliant -d "12345678901"] 6.4.3 PLANET @@ -3946,7 +3965,7 @@ lengths used by USPS were Planet12 (11-digit input) and Planet14 (13-digit input), and as with POSTNET a warning will be issued if the length is not one of these. -[zint -b PLANET --compliantheight -d "4012345235636"] +[Figure 101: zint -b PLANET --compliant -d "4012345235636"] 6.4.4 Brazilian CEPNet @@ -3955,7 +3974,7 @@ service, to encode CEP (Código de Endereçamento Postal) numbers on mail items. Input should consist of eight digits with the check digit being automatically added by Zint. -[zint -b CEPNET --compliantheight -d "12345678"] +[Figure 102: zint -b CEPNET --compliant -d "12345678"] 6.4.5 DX Film Edge Barcode @@ -3963,7 +3982,7 @@ Introduced by Kodak in the 1980s, the DX (Digital Index) barcode is printed on the bottom edge of 35mm film to aid in the reordering and post-processing of prints. -[zint -b DXFILMEDGE --compliantheight -d "112-1/10A"] +[Figure 103: zint -b DXFILMEDGE --compliant -d "112-1/10A"] The data can be in two parts. The first part (required) is the “DX number”, identifying the manufacturer and film type - the National Association of @@ -3976,7 +3995,7 @@ first and last digit are ignored, leaving a 4-digit DX Extract number in any case, which must be in the range 16 to 2047. The second format "NNN-NN" represents the DX Extract as two numbers separated by a dash (-), the first number being 1 to 3 digits (range 1 to 127) and the second 1 to 2 digits (range -0 to 15).[23] +0 to 15).[24] The optional frame number is a number in the range 0 to 63, and may have a half frame indicator "A" appended. Special character sequences (with or without a @@ -3996,7 +4015,7 @@ Barcode 3 are 37-bar, 52-bar and 67-bar specifications respectively, developed by Australia Post for printing Delivery Point ID (DPID) and customer information on mail items. -[zint -b AUSPOST --compliantheight -d "96184209"] +[Figure 104: zint -b AUSPOST --compliant -d "96184209"] Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format Control Code (FCC) is added by Zint and should not be included in the input data. @@ -4029,21 +4048,21 @@ lengths) if the DPID is all zeroes. A Reply Paid version of the Australia Post 4-State Barcode (FCC 45) which requires an 8-digit DPID input. -[zint -b AUSREPLY --compliantheight -d "12345678"] +[Figure 105: zint -b AUSREPLY --compliant -d "12345678"] 6.5.1.3 Routing Barcode A Routing version of the Australia Post 4-State Barcode (FCC 87) which requires an 8-digit DPID input. -[zint -b AUSROUTE --compliantheight -d "34567890"] +[Figure 106: zint -b AUSROUTE --compliant -d "34567890"] 6.5.1.4 Redirect Barcode A Redirection version of the Australia Post 4-State Barcode (FCC 92) which requires an 8-digit DPID input. -[zint -b AUSREDIRECT --compliantheight -d "98765432"] +[Figure 107: zint -b AUSREDIRECT --compliant -d "98765432"] 6.5.2 Dutch Post KIX Code @@ -4051,7 +4070,7 @@ This symbology is used by Royal Dutch TPG Post (Netherlands) for Postal code and automatic mail sorting. Data input can consist of numbers 0-9 and letters A-Z and needs to be 11 characters in length. No check digit is included. -[zint -b KIX --compliantheight -d "2500GG30250"] +[Figure 108: zint -b KIX --compliant -d "2500GG30250"] 6.5.3 Royal Mail 4-State Customer Code (RM4SCC) @@ -4061,14 +4080,14 @@ A-Z and usually includes delivery postcode followed by house number. For example "W1J0TR01" for 1 Piccadilly Circus in London. Check digit data is generated by Zint. -[zint -b RM4SCC --compliantheight -d "W1J0TR01"] +[Figure 109: zint -b RM4SCC --compliant -d "W1J0TR01"] 6.5.4 Royal Mail 4-State Mailmark Developed in 2014 as a replacement for RM4SCC this 4-state symbol includes Reed- Solomon error correction. -[zint -b MAILMARK_4S --compliantheight -d "21B2254800659JW5O9QA6Y"] +[Figure 110: zint -b MAILMARK_4S --compliant -d "21B2254800659JW5O9QA6Y"] Input is a pre-formatted alphanumeric string of 22 (for Barcode C) or 26 (for Barcode L) characters, producing a symbol with 66 or 78 bars respectively. The @@ -4113,7 +4132,7 @@ Also known as the OneCode barcode and used in the U.S. by the United States Postal Service (USPS), the Intelligent Mail system replaced the POSTNET and PLANET symbologies in 2009. -[zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234"] +[Figure 111: zint -b USPS_IMAIL --compliant -d "01234567094987654321-01234"] Intelligent Mail is a fixed length 65-bar symbol which combines routing and customer information in a single symbol. Input data consists of a 20-digit @@ -4131,7 +4150,7 @@ inputs are valid data entries: Used for address data on mail items for Japan Post. Accepted values are 0-9, A-Z and dash (-). A modulo 19 check digit is added by Zint. -[zint -b JAPANPOST --compliantheight -d "15400233-16-4-205"] +[Figure 112: zint -b JAPANPOST --compliant -d "15400233-16-4-205"] 6.5.7 DAFT Code @@ -4141,8 +4160,8 @@ and 'T' where these refer to descender, ascender, full (ascender and descender) and tracker (neither ascender nor descender) respectively. All other characters are invalid. -[zint -b DAFT -d "AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF" --height=8.494 --vers= -256] +[Figure 113: zint -b DAFT -d "AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF" --height=8 +.494 --vers=256] The ratio of the tracker size to full height can be given in thousandths (permille) using the --vers option (API option_2). The default value is 250 @@ -4156,7 +4175,7 @@ For example the following produces the same barcode (see 6.5.3 Royal Mail 4-State Customer Code (RM4SCC)) as - zint -b RM4SCC --compliantheight -d "W1J0TR01" + zint -b RM4SCC --compliant -d "W1J0TR01" 6.6 Matrix Symbols @@ -4166,7 +4185,7 @@ Also known as Semacode this symbology was developed in 1989 by Acuity CiMatrix in partnership with the U.S. DoD and NASA. The symbol can encode a large amount of data in a small area. -[zint -b HIBC_DM -d "/ACMRN123456/V200912190833" --fast --square] +[Figure 114: zint -b HIBC_DM -d "/ACMRN123456/V200912190833" --fast --square] Data Matrix encodes characters in the Latin-1 set by default but also supports encoding in other character sets using the ECI mechanism. It can also encode GS1 @@ -4232,7 +4251,7 @@ Escape Sequences. For instance encodes the data "ABCDEF", where represents the FNC1 character. If the data contains an extra escape sequence, it can be escaped by doubling the caret (^), i.e. "\^^" encodes "\^". Note that if using ECIs with -manual FNC1s then the ECIs must be ASCII compatible.[24] +manual FNC1s then the ECIs must be ASCII compatible.[25] By default Zint uses a “de facto” codeword placement for symbols of size 144 x 144 (version 24). To override this and use the now clarified ISO/IEC standard @@ -4256,7 +4275,8 @@ as "123234". Note that both ID1 and ID2 must be non-zero, so e.g. "123000" or 6.6.2 Royal Mail 2D Mailmark (CMDM) (Data Matrix) -[zint -b MAILMARK_2D -d "JGB 01Z999999900000001EC1A1AA1A0SN35TQ" --vers=30] +[Figure 115: zint -b MAILMARK_2D -d "JGB 01Z999999900000001EC1A1AA1A0SN35TQ" --v +ers=30] This variant of Data Matrix, also known as “Complex Mail Data Mark” (CMDM), was introduced by Royal Mail along with 6.5.4 Royal Mail 4-State Mailmark, and @@ -4330,7 +4350,7 @@ GS1 data, the ECI mechanism, and Structured Append are not supported. Also known as Quick Response Code this symbology was developed by Denso. -[zint -b QRCODE -d "QR Code Symbol" --mask=5] +[Figure 116: zint -b QRCODE -d "QR Code Symbol" --mask=5] Four levels of error correction are available using the --secure option (API option_1) as shown in the following table. @@ -4406,7 +4426,7 @@ symbols can encode either Latin-1 characters or Shift JIS characters. Input should be entered as a UTF-8 stream with conversion to Latin-1 or Shift JIS being carried out automatically by Zint. -[zint -b MICROQR -d "01234567"] +[Figure 117: zint -b MICROQR -d "01234567"] A preferred symbol size can be selected by using the --vers option (API option_2), as shown in the table below. Note that versions M1 and M2 have @@ -4467,7 +4487,7 @@ Latin-1 characters or Shift JIS characters, and other encodings using the ECI mechanism. As with other symbologies data should be entered as UTF-8 with conversion being handled by Zint. -[zint -b RMQR -d "0123456"] +[Figure 118: zint -b RMQR -d "0123456"] The amount of ECC codewords can be adjusted using the --secure option (API option_1), however only ECC levels M and H are valid for this type of symbol. @@ -4540,7 +4560,7 @@ A variation of QR Code used by Združenje Bank Slovenije (Bank Association of Slovenia). The size, error correction level and ECI are set by Zint and do not need to be specified. -[zint -b UPNQR -i upn_utf8.txt --quietzones] +[Figure 119: zint -b UPNQR -i upn_utf8.txt --quietzones] UPNQR is unusual in that it uses Latin-2 (ISO/IEC 8859-2 plus ASCII) formatted data. Zint will accept UTF-8 data and convert it to Latin-2, or if your data is @@ -4548,7 +4568,7 @@ already Latin-2 formatted use the --binary switch (API input_mode = DATA_MODE). The following example creates a symbol from data saved as a Latin-2 file: - zint -o upnqr.png -b UPNQR --scale=3 --binary -i upn.txt + zint -o upnqr.png -b UPNQR --binary -i upn.txt A mask may be manually specified and the --fast option used as with 6.6.3 QR Code (ISO 18004). @@ -4559,8 +4579,8 @@ Developed by UPS the MaxiCode symbology employs a grid of hexagons surrounding a bullseye finder pattern. This symbology is designed for the identification of parcels. -[zint -b MAXICODE -d "1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN S -T\GNY\GNY\R\E" --esc --primary="152382802000000" --scmvv=96] +[Figure 120: zint -b MAXICODE -d "1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\ +GY\G1 MAIN ST\GNY\GNY\R\E" --esc --primary="152382802000000" --scmvv=96] MaxiCode symbols can be encoded in one of five modes. In modes 2 and 3 MaxiCode symbols are composed of two parts named the primary and secondary messages. The @@ -4655,7 +4675,7 @@ multiplied by 20 instead of 2. Invented by Andrew Longacre at Welch Allyn Inc in 1995 the Aztec Code symbol is a matrix symbol with a distinctive square bullseye finder pattern. -[zint -b AZTEC -d "123456789012"] +[Figure 121: zint -b AZTEC -d "123456789012"] Zint can generate Compact Aztec Code (sometimes called Small Aztec Code) as well as ‘full-range’ Aztec Code symbols and by default will automatically select @@ -4735,7 +4755,7 @@ A truncated version of compact Aztec Code for encoding whole integers between 0 and 255, as defined in ISO/IEC 24778 Annex A. Includes Reed-Solomon error correction. It does not support Structured Append. -[zint -b AZRUNE -d "125"] +[Figure 122: zint -b AZRUNE -d "125"] 6.6.10 Code One @@ -4743,7 +4763,7 @@ 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, and also supports the ECI mechanism. -[zint -b CODEONE -d "1234567890123456789012"] +[Figure 123: zint -b CODEONE -d "1234567890123456789012"] There are two types of Code One symbol - fixed-ratio symbols which are roughly square (versions A through to H) and variable-width versions (versions S and T). @@ -4794,8 +4814,8 @@ GB 2312 being carried out automatically by Zint. Up to around 1529 alphanumeric characters or 2751 digits may be encoded. The symbology also supports the ECI mechanism. Support for GS1 data has not yet been implemented. -[zint -b GRIDMATRIX --eci=29 -d "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 825127 -38"] +[Figure 124: zint -b GRIDMATRIX --eci=29 -d "AAT2556 电池充电器+降压转换器 200mA至2A tel:8 +6 019 82512738"] The size of the symbol and the error correction capacity can be specified. If you specify both of these values then Zint will make a ‘best-fit’ attempt to @@ -4845,7 +4865,8 @@ setting the scale of the image to a larger value than the default (e.g. approximately 10) for the dots to be plotted correctly. Approximately 33% of the resulting symbol is comprised of error correction codewords. -[zint -b DOTCODE -d "[01]00012345678905[17]201231[10]ABC123456" --gs1] +[Figure 125: zint -b DOTCODE -d "[01]00012345678905[17]201231[10]ABC123456" --gs +1] DotCode has two sets of 4 masks, designated 0-3 and 0’-3’, the second "prime" set being the same as the first with corners lit. The best mask to use is @@ -4865,7 +4886,7 @@ UTF, i.e. includes all Unicode characters, optimized for Chinese characters) an is also able to support the ECI mechanism. Support for the encoding of GS1 data has not yet been implemented. -[zint -b HANXIN -d "Hanxin Code symbol"] +[Figure 126: zint -b HANXIN -d "Hanxin Code symbol"] The size of the symbol can be specified using the --vers option (API option_2) to a value between 1 and 84 according to the following table. @@ -4936,7 +4957,7 @@ option_3 = (N + 1) << 8 where N is 0-3. To use with ZINT_FULL_MULTIBYTE set This symbology uses a grid of coloured elements to encode data. ECI and GS1 modes are supported. -[zint -b ULTRA -d "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS"] +[Figure 127: zint -b ULTRA -d "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS"] The amount of error correction can be set using the --secure option (API option_1) to a value as shown in the following table. @@ -4982,7 +5003,7 @@ not given, no ID is encoded. Used by the United States Postal Service (USPS), the FIM symbology is used to assist automated mail processing. -[zint -b FIM --compliantheight -d "C"] +[Figure 128: zint -b FIM --compliant -d "C"] There are only 5 valid symbols which can be generated using the characters A-E as shown in the table below. @@ -5005,7 +5026,7 @@ not a true barcode symbol and requires precise knowledge of the position of the mark on the page. The Flattermarken system can encode numeric data up to a maximum of 128 digits and does not include a check digit. -[zint -b FLAT -d "1304056"] +[Figure 129: zint -b FLAT -d "1304056"] 7. Legal and Version Information @@ -5269,7 +5290,7 @@ For full details, see "backend_qt/qzint.h". Annex C. Tcl Backend Binding -A Tcl binding is available in the "backend_tcl” sub-directory. To make on Unix: +A Tcl binding is available in the "backend_tcl" sub-directory. To make on Unix: cd backend_tcl autoconf @@ -5304,7 +5325,7 @@ A demonstration Tcl/Tk program which is also useful in itself is available at which will display the following window. -[Tcl/Tk demonstration program window] +[Figure 130: Tcl/Tk demonstration program window] You can select the symbology, enter the data to encode, and set options (which are the same as those given in the usage message). The raster preview of the @@ -5628,9 +5649,9 @@ OPTIONS --mirror - Use the batch data to determine the filename in batch mode (--batch). The -o - | --output option can be used to specify an output directory (any filename - will be ignored). + Use the data to determine the filename. This is particularly useful in batch + mode (--batch), but also works in standard mode. The -o | --output option + can be used to specify an output directory (any filename will be ignored). --mode=INTEGER @@ -6109,7 +6130,7 @@ the yen sign (¥), and tilde (~) to overline (‾, U+203E). $, @, [, \, ], ^, `, {, |, }, ~ (tilde). [9] Note that unless the --binary switch is used, 8-bit binary data for ECI 899 -must be given as UTF-8, e.g. a byte "\x80" must be represented as the 2 bytes +must be given as UTF-8, e.g. byte "\x80" must be represented as the 2 bytes "\xC2\x80"; similarly "\xC0" as "\xC3\x80", etc. [10] For more information on the “Unbracketed AI” format for GS1 data entry, see @@ -6123,44 +6144,49 @@ using GS1 Application Identifiers”. Note that this applies even to AIs with fixed lengths, so e.g. the data for AI 3940, which has a fixed length of 4, must have a terminating FNC1 (except when the last AI). -[12] BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines +[12] The --mirror option will replace control characters (including DEL) and +slash (/) with an underscore (_). Additionally on Windows the characters !, ", +*, :, <, >, ?, \ and | will also be replaced with underscores, as they are +prohibited in filenames. + +[13] BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines (LF) on both Windows and Unix, i.e. not CR+LF on Windows. -[13] The height value is ignored for Aztec (including HIBC and Aztec Rune), Code +[14] The height value is ignored for Aztec (including HIBC and Aztec Rune), Code One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode, QR Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which have a fixed width-to-height ratio (or, in the case of Code One, a fixed height). -[14] For Windows, outfile is assumed to be UTF-8 encoded. +[15] For Windows, outfile is assumed to be UTF-8 encoded. -[15] The BARCODE_BIND_TOP flag is set by default for DPD - see 6.1.10.7 DPD +[16] The BARCODE_BIND_TOP flag is set by default for DPD - see 6.1.10.7 DPD Code. -[16] The BARCODE_BIND flag is always set for Codablock F, Code 16K and Code 49. +[17] The BARCODE_BIND flag is always set for Codablock F, Code 16K and Code 49. Special considerations apply to ITF-14 - see 6.1.2.6 ITF-14. -[17] Codablock F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN, +[18] Codablock F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN, ITF-14, UPC-A and UPC-E have compliant quiet zones added by default. -[18] ZINT_CAP_EANUPC was previously named ZINT_CAP_EXTENDABLE, which is still +[19] ZINT_CAP_EANUPC was previously named ZINT_CAP_EXTENDABLE, which is still recognised. -[19] DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have variable masks. +[20] DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have variable masks. Rectangular Micro QR Code has a fixed mask (4). -[20] Except for Japanese Postal Code, whose check character is not truly +[21] Except for Japanese Postal Code, whose check character is not truly representable in the encoded data. -[21] The library libzueci, which can convert both to and from UTF-8 and ECI, is +[22] The library libzueci, which can convert both to and from UTF-8 and ECI, is available at https://sourceforge.net/projects/libzueci/. -[22] BARCODE_CODE128AB previously used the name BARCODE_CODE128B, which is still +[23] BARCODE_CODE128AB previously used the name BARCODE_CODE128B, which is still recognised. -[23] The DX number may be looked up in The (Modified) Big Film Database at +[24] The DX number may be looked up in The (Modified) Big Film Database at https://thebigfilmdatabase.merinorus.com. -[24] ASCII-compatible ECIs are ECIs 3 to 18 and 21 to 27 (see Table 9: ECI +[25] ASCII-compatible ECIs are ECIs 3 to 18 and 21 to 27 (see Table 9: ECI Codes). Note in particular that ECI 899, 8-bit binary, is not considered ASCII-compatible. diff --git a/docs/zint.1 b/docs/zint.1 index 4bbcdc6f..2b8f2b7a 100644 --- a/docs/zint.1 +++ b/docs/zint.1 @@ -325,8 +325,9 @@ Set the masking pattern to use for DotCode, Han Xin or QR Code to \f[I]\f[CI]INTEGER\f[I]\f[R], overriding the automatic selection. .TP \f[B]\f[CB]\-\-mirror\f[B]\f[R] -Use the batch data to determine the filename in batch mode -(\f[CR]\-\-batch\f[R]). +Use the data to determine the filename. +This is particularly useful in batch mode (\f[CR]\-\-batch\f[R]), but +also works in standard mode. The \f[CR]\-o\f[R] | \f[CR]\-\-output\f[R] option can be used to specify an output directory (any filename will be ignored). .TP diff --git a/docs/zint.1.pmd b/docs/zint.1.pmd index 7b65f17a..2221d5c3 100644 --- a/docs/zint.1.pmd +++ b/docs/zint.1.pmd @@ -285,8 +285,9 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S **`--mirror`** -: Use the batch data to determine the filename in batch mode (`--batch`). The `-o` | `--output` option can be used - to specify an output directory (any filename will be ignored). +: Use the data to determine the filename. This is particularly useful in batch mode (`--batch`), but also works in + standard mode. The `-o` | `--output` option can be used to specify an output directory (any filename will be + ignored). **`--mode=`***`INTEGER`* diff --git a/docs/zint_images.sh b/docs/zint_images.sh index 21e77f2f..0d543c44 100755 --- a/docs/zint_images.sh +++ b/docs/zint_images.sh @@ -28,8 +28,8 @@ zint -d "This Text" --fg=00FF00 --scale=$SCALE_LINEAR -o images/code128_green.sv zint -d "This Text" --fg=00FF0055 --scale=$SCALE_LINEAR -o images/code128_green_alpha.svg zint -d "This Text" --rotate=90 --scale=$SCALE_LINEAR -o images/code128_rotate90.svg zint -b DATAMATRIX --eci=17 -d "€" --scale=$SCALE_2D -o images/datamatrix_euro.svg -zint -b DATAMATRIX --eci=28 -d "\u5E38" --esc --scale=$SCALE_2D -o images/datamatrix_big5.svg -zint -b QRCODE --binary -d "\xE2\x82\xAC\xE5\xB8\xB8" --esc --scale=$SCALE_2D -o images/qrcode_binary_utf8.svg +zint -b DATAMATRIX --eci=28 --binary --esc -d "\xBD\x58" --scale=$SCALE_2D -o images/datamatrix_big5.svg +zint -b QRCODE --binary -d "€" --scale=$SCALE_2D -o images/qrcode_binary_utf8.svg zint -b CODEONE -d "123456789012345678" --dotty --vers=9 --scale=$SCALE_DOTTY -o images/codeone_s_dotty.svg zint -b AZTEC --eci=9 -d "Κείμενο" --seg1=7,"Текст" --seg2=20,"文章" --scale=$SCALE_2D -o images/aztec_segs.svg zint -b DATAMATRIX -d "2nd of 3" --structapp="2,3,5006" --scale=$SCALE_2D -o images/datamatrix_structapp.svg @@ -40,86 +40,86 @@ zint -b CODE11 -d "9212320967" --scale=$SCALE_LINEAR -o images/code11.svg zint -b C25STANDARD -d "9212320967" --scale=$SCALE_LINEAR -o images/c25standard.svg zint -b C25IATA -d "9212320967" --scale=$SCALE_LINEAR -o images/c25iata.svg zint -b C25IND -d "9212320967" --scale=$SCALE_LINEAR -o images/c25ind.svg -zint -b C25INTER --compliantheight -d "9212320967" --scale=$SCALE_LINEAR -o images/c25inter.svg +zint -b C25INTER --compliant -d "9212320967" --scale=$SCALE_LINEAR -o images/c25inter.svg zint -b C25LOGIC -d "9212320967" --scale=$SCALE_LINEAR -o images/c25logic.svg -zint -b ITF14 --compliantheight -d "9212320967145" --scale=$SCALE_LINEAR -o images/itf14.svg -zint -b ITF14 --box --compliantheight -d "9212320967145" --scale=$SCALE_LINEAR -o images/itf14_border0.svg +zint -b ITF14 --compliant -d "9212320967145" --scale=$SCALE_LINEAR -o images/itf14.svg +zint -b ITF14 --box --compliant -d "9212320967145" --scale=$SCALE_LINEAR -o images/itf14_border0.svg zint -b DPLEIT -d "9212320967145" --scale=$SCALE_LINEAR -o images/dpleit.svg zint -b DPIDENT -d "91232096712" --scale=$SCALE_LINEAR -o images/dpident.svg -zint -b UPCA --compliantheight -d "01234500005" --scale=$SCALE_UPCEAN -o images/upca.svg -zint -b UPCA --compliantheight -d "01234500005+12345" --scale=$SCALE_UPCEAN -o images/upca_5.svg -zint -b UPCA --compliantheight -d "01234500005+12345" --guardwhitespace --scale=$SCALE_UPCEAN -o images/upca_5_gws.svg -zint -b UPCE --compliantheight -d "123455" --scale=$SCALE_UPCEAN -o images/upce.svg -zint -b UPCE --compliantheight -d "123455+12" --guardwhitespace --scale=$SCALE_UPCEAN -o images/upce_2_gws.svg -zint -b EAN13 --compliantheight -d "952012345678" --scale=$SCALE_UPCEAN -o images/ean13.svg -zint -b EAN13 --compliantheight -d "952012345678+21" --scale=$SCALE_UPCEAN -o images/ean13_2.svg -zint -b EAN13 --compliantheight -d "952012345678" --guarddescent=2.5 --guardwhitespace --scale=$SCALE_UPCEAN -o images/ean13_gd_gws.svg -zint -b EAN8 --compliantheight -d "9520000" --scale=$SCALE_UPCEAN -o images/ean8.svg -zint -b EAN8 --compliantheight -d "9520000" --guardwhitespace --scale=$SCALE_UPCEAN -o images/ean8_gws.svg -zint -b ISBNX --compliantheight -d "9789295055124" --scale=$SCALE_UPCEAN -o images/isbnx.svg -zint -b ISBNX --compliantheight -d "9789295055124" --guardwhitespace --scale=$SCALE_UPCEAN -o images/isbnx_gws.svg -zint -b EAN_2ADDON --compliantheight -d "12" --scale=$SCALE_UPCEAN -o images/ean_2addon.svg -zint -b EAN_5ADDON --compliantheight -d "54321" --guardwhitespace --scale=$SCALE_UPCEAN -o images/ean_5addon_gws.svg +zint -b UPCA --compliant -d "01234500005" --scale=$SCALE_UPCEAN -o images/upca.svg +zint -b UPCA --compliant -d "01234500005+12345" --scale=$SCALE_UPCEAN -o images/upca_5.svg +zint -b UPCA --compliant -d "01234500005+12345" --guardwhitespace --scale=$SCALE_UPCEAN -o images/upca_5_gws.svg +zint -b UPCE --compliant -d "123455" --scale=$SCALE_UPCEAN -o images/upce.svg +zint -b UPCE --compliant -d "123455+12" --guardwhitespace --scale=$SCALE_UPCEAN -o images/upce_2_gws.svg +zint -b EAN13 --compliant -d "952012345678" --scale=$SCALE_UPCEAN -o images/ean13.svg +zint -b EAN13 --compliant -d "952012345678+21" --scale=$SCALE_UPCEAN -o images/ean13_2.svg +zint -b EAN13 --compliant -d "952012345678" --guarddescent=2.5 --guardwhitespace --scale=$SCALE_UPCEAN -o images/ean13_gd_gws.svg +zint -b EAN8 --compliant -d "9520000" --scale=$SCALE_UPCEAN -o images/ean8.svg +zint -b EAN8 --compliant -d "9520000" --guardwhitespace --scale=$SCALE_UPCEAN -o images/ean8_gws.svg +zint -b ISBNX --compliant -d "9789295055124" --scale=$SCALE_UPCEAN -o images/isbnx.svg +zint -b ISBNX --compliant -d "9789295055124" --guardwhitespace --scale=$SCALE_UPCEAN -o images/isbnx_gws.svg +zint -b EAN_2ADDON --compliant -d "12" --scale=$SCALE_UPCEAN -o images/ean_2addon.svg +zint -b EAN_5ADDON --compliant -d "54321" --guardwhitespace --scale=$SCALE_UPCEAN -o images/ean_5addon_gws.svg zint -b PLESSEY -d "C64" --scale=$SCALE_LINEAR -o images/plessey.svg zint -b MSI_PLESSEY -d "6502" --vers=2 --scale=$SCALE_LINEAR -o images/msi_plessey.svg -zint -b TELEPEN --compliantheight -d "Z8000" --scale=$SCALE_LINEAR -o images/telepen.svg -zint -b TELEPEN --compliantheight -d "Z\L8000" --esc --vers=1 --scale=$SCALE_LINEAR -o images/telepen_aim.svg -zint -b TELEPEN_NUM --compliantheight -d "466X33" --scale=$SCALE_LINEAR -o images/telepen_num.svg -zint -b TELEPEN_NUM --compliantheight -d "12\LAB" --esc --scale=$SCALE_LINEAR -o images/telepen_num_asc.svg -zint -b TELEPEN_NUM --compliantheight -d "12\L3" --esc --scale=$SCALE_LINEAR -o images/telepen_num_odd.svg -zint -b CODE39 --compliantheight -d "1A" --vers=1 --scale=$SCALE_LINEAR -o images/code39.svg -zint -b EXCODE39 --compliantheight -d "123.45#@fd" --scale=$SCALE_LINEAR -o images/excode39.svg -zint -b CODE93 --compliantheight -d "C93" --scale=$SCALE_LINEAR -o images/code93.svg -zint -b PZN --compliantheight -d "2758089" --scale=$SCALE_LINEAR -o images/pzn.svg -zint -b LOGMARS --compliantheight -d "12345/ABCDE" --vers=1 --scale=$SCALE_LINEAR -o images/logmars.svg -zint -b CODE32 --compliantheight -d "14352312" --scale=$SCALE_LINEAR -o images/code32.svg -zint -b HIBC_39 --compliantheight -d "14352312" --scale=$SCALE_LINEAR -o images/hibc_39.svg +zint -b TELEPEN --compliant -d "Z8000" --scale=$SCALE_LINEAR -o images/telepen.svg +zint -b TELEPEN --compliant -d "Z\L8000" --esc --vers=1 --scale=$SCALE_LINEAR -o images/telepen_aim.svg +zint -b TELEPEN_NUM --compliant -d "466X33" --scale=$SCALE_LINEAR -o images/telepen_num.svg +zint -b TELEPEN_NUM --compliant -d "12\LAB" --esc --scale=$SCALE_LINEAR -o images/telepen_num_asc.svg +zint -b TELEPEN_NUM --compliant -d "12\L3" --esc --scale=$SCALE_LINEAR -o images/telepen_num_odd.svg +zint -b CODE39 --compliant -d "1A" --vers=1 --scale=$SCALE_LINEAR -o images/code39.svg +zint -b EXCODE39 --compliant -d "123.45#@fd" --scale=$SCALE_LINEAR -o images/excode39.svg +zint -b CODE93 --compliant -d "C93" --scale=$SCALE_LINEAR -o images/code93.svg +zint -b PZN --compliant -d "2758089" --scale=$SCALE_LINEAR -o images/pzn.svg +zint -b LOGMARS --compliant -d "12345/ABCDE" --vers=1 --scale=$SCALE_LINEAR -o images/logmars.svg +zint -b CODE32 --compliant -d "14352312" --scale=$SCALE_LINEAR -o images/code32.svg +zint -b HIBC_39 --compliant -d "14352312" --scale=$SCALE_LINEAR -o images/hibc_39.svg zint -b VIN -d "2FTPX28L0XCA15511" --vers=1 --scale=$SCALE_LINEAR -o images/vin.svg -zint -b CODABAR --compliantheight -d "A37859B" --scale=$SCALE_LINEAR -o images/codabar.svg -zint -b PHARMA --compliantheight -d "130170" --scale=$SCALE_LINEAR -o images/pharma.svg +zint -b CODABAR --compliant -d "A37859B" --scale=$SCALE_LINEAR -o images/codabar.svg +zint -b PHARMA --compliant -d "130170" --scale=$SCALE_LINEAR -o images/pharma.svg zint -b CODE128 --bind -d "130170X178" --scale=$SCALE_LINEAR -o images/code128.svg zint -b CODE128AB -d "130170X178" --scale=$SCALE_LINEAR -o images/code128ab.svg -zint -b GS1_128 --compliantheight -d "[01]98898765432106[3202]012345[15]991231" --scale=$SCALE_LINEAR -o images/gs1_128.svg -zint -b EAN14 --compliantheight -d "9889876543210" --scale=$SCALE_LINEAR -o images/ean14.svg -zint -b NVE18 --compliantheight -d "37612345000001003" --scale=$SCALE_LINEAR -o images/nve18.svg +zint -b GS1_128 --compliant -d "[01]98898765432106[3202]012345[15]991231" --scale=$SCALE_LINEAR -o images/gs1_128.svg +zint -b EAN14 --compliant -d "9889876543210" --scale=$SCALE_LINEAR -o images/ean14.svg +zint -b NVE18 --compliant -d "37612345000001003" --scale=$SCALE_LINEAR -o images/nve18.svg zint -b HIBC_128 -d "A123BJC5D6E71" --scale=$SCALE_LINEAR -o images/hibc_128.svg -zint -b DPD --compliantheight -d "000393206219912345678101040" --scale=$SCALE_LINEAR -o images/dpd.svg -zint -b UPU_S10 --compliantheight -d "EE876543216CA" --scale=$SCALE_LINEAR -o images/upu_s10.svg -zint -b DBAR_OMN --compliantheight -d "0950110153001" --scale=$SCALE_LINEAR -o images/dbar_omn.svg +zint -b DPD --compliant -d "000393206219912345678101040" --scale=$SCALE_LINEAR -o images/dpd.svg +zint -b UPU_S10 --compliant -d "EE876543216CA" --scale=$SCALE_LINEAR -o images/upu_s10.svg +zint -b DBAR_OMN --compliant -d "0950110153001" --scale=$SCALE_LINEAR -o images/dbar_omn.svg zint -b DBAR_OMN -d "0950110153001" --height=13 --scale=$SCALE_LINEAR -o images/dbar_truncated.svg -zint -b DBAR_LTD --compliantheight -d "0950110153001" --scale=$SCALE_LINEAR -o images/dbar_ltd.svg -zint -b DBAR_EXP --compliantheight -d "[01]98898765432106[3202]012345[15]991231" --scale=$SCALE_LINEAR -o images/dbar_exp.svg +zint -b DBAR_LTD --compliant -d "0950110153001" --scale=$SCALE_LINEAR -o images/dbar_ltd.svg +zint -b DBAR_EXP --compliant -d "[01]98898765432106[3202]012345[15]991231" --scale=$SCALE_LINEAR -o images/dbar_exp.svg zint -b KOREAPOST -d "923457" --scale=$SCALE_LINEAR -o images/koreapost.svg -zint -b CHANNEL -d "453678" --compliantheight --scale=$SCALE_LINEAR -o images/channel.svg -zint -b BC412 -d "AQ45670" --compliantheight --scale=$SCALE_LINEAR -o images/bc412.svg +zint -b CHANNEL -d "453678" --compliant --scale=$SCALE_LINEAR -o images/channel.svg +zint -b BC412 -d "AQ45670" --compliant --scale=$SCALE_LINEAR -o images/bc412.svg zint -d "This" -d "That" --scale=$SCALE_LINEAR -o images/code128_stacked.svg zint --notext --bind --separator=2 -d "This" -d "That" --scale=$SCALE_LINEAR -o images/code128_stacked_sep2.svg zint -b CODABLOCKF -d "CODABLOCK F Symbology" --rows=3 --scale=$SCALE_LINEAR -o images/codablockf.svg -zint -b CODE16K --compliantheight -d "ab0123456789" --scale=$SCALE_LINEAR -o images/code16k.svg +zint -b CODE16K --compliant -d "ab0123456789" --scale=$SCALE_LINEAR -o images/code16k.svg zint -b PDF417 -d "PDF417" --scale=$SCALE_LINEAR -o images/pdf417.svg zint -b PDF417COMP -d "PDF417" --scale=$SCALE_LINEAR -o images/pdf417comp.svg zint -b MICROPDF417 -d "12345678" --scale=$SCALE_LINEAR -o images/micropdf417.svg -zint -b DBAR_STK --compliantheight -d "9889876543210" --scale=$SCALE_LINEAR -o images/dbar_stk.svg -zint -b DBAR_OMNSTK --compliantheight -d "9889876543210" --scale=$SCALE_LINEAR -o images/dbar_omnstk.svg -zint -b DBAR_EXPSTK --compliantheight -d "[01]98898765432106[3202]012345[15]991231" --scale=$SCALE_LINEAR -o images/dbar_expstk.svg -zint -b CODE49 --compliantheight -d "MULTIPLE ROWS IN CODE 49" --scale=$SCALE_LINEAR -o images/code49.svg -zint -b EAN13_CC --compliantheight -d "[99]1234-abcd" --mode=1 --primary=331234567890 --scale=$SCALE_UPCEAN -o images/ean13_cc_a.svg -zint -b EAN13_CC --compliantheight -d "[99]1234-abcd" --mode=2 --primary=331234567890 --scale=$SCALE_UPCEAN -o images/ean13_cc_b.svg -zint -b GS1_128_CC --compliantheight -d "[99]1234-abcd" --mode=3 --primary="[01]03312345678903" --scale=$SCALE_UPCEAN -o images/gs1_128_cc_c.svg -zint -b PHARMA_TWO --compliantheight -d "29876543" --scale=$SCALE_TRACK -o images/pharma_two.svg -zint -b POSTNET --compliantheight -d "12345678901" --scale=$SCALE_TRACK -o images/postnet.svg -zint -b PLANET --compliantheight -d "4012345235636" --scale=$SCALE_TRACK -o images/planet.svg -zint -b CEPNET --compliantheight -d "12345678" --scale=$SCALE_TRACK -o images/cepnet.svg -zint -b DXFILMEDGE --compliantheight -d "112-1/10A" --scale=$SCALE_TRACK -o images/dxfilmedge.svg -zint -b AUSPOST --compliantheight -d "96184209" --scale=$SCALE_TRACK -o images/auspost.svg -zint -b AUSROUTE --compliantheight -d "34567890" --scale=$SCALE_TRACK -o images/ausroute.svg -zint -b AUSREPLY --compliantheight -d "12345678" --scale=$SCALE_TRACK -o images/ausreply.svg -zint -b AUSREDIRECT --compliantheight -d "98765432" --scale=$SCALE_TRACK -o images/ausredirect.svg -zint -b KIX --compliantheight -d "2500GG30250" --scale=$SCALE_TRACK -o images/kix.svg -zint -b RM4SCC --compliantheight -d "W1J0TR01" --scale=$SCALE_TRACK -o images/rm4scc.svg -zint -b MAILMARK_4S --compliantheight -d "21B2254800659JW5O9QA6Y" --scale=$SCALE_TRACK -o images/mailmark_4s.svg -zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234" --scale=$SCALE_TRACK -o images/usps_imail.svg -zint -b JAPANPOST --compliantheight -d "15400233-16-4-205" --scale=$SCALE_TRACK -o images/japanpost.svg +zint -b DBAR_STK --compliant -d "9889876543210" --scale=$SCALE_LINEAR -o images/dbar_stk.svg +zint -b DBAR_OMNSTK --compliant -d "9889876543210" --scale=$SCALE_LINEAR -o images/dbar_omnstk.svg +zint -b DBAR_EXPSTK --compliant -d "[01]98898765432106[3202]012345[15]991231" --scale=$SCALE_LINEAR -o images/dbar_expstk.svg +zint -b CODE49 --compliant -d "MULTIPLE ROWS IN CODE 49" --scale=$SCALE_LINEAR -o images/code49.svg +zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=1 --primary=331234567890 --scale=$SCALE_UPCEAN -o images/ean13_cc_a.svg +zint -b EAN13_CC --compliant -d "[99]1234-abcd" --mode=2 --primary=331234567890 --scale=$SCALE_UPCEAN -o images/ean13_cc_b.svg +zint -b GS1_128_CC --compliant -d "[99]1234-abcd" --mode=3 --primary="[01]03312345678903" --scale=$SCALE_UPCEAN -o images/gs1_128_cc_c.svg +zint -b PHARMA_TWO --compliant -d "29876543" --scale=$SCALE_TRACK -o images/pharma_two.svg +zint -b POSTNET --compliant -d "12345678901" --scale=$SCALE_TRACK -o images/postnet.svg +zint -b PLANET --compliant -d "4012345235636" --scale=$SCALE_TRACK -o images/planet.svg +zint -b CEPNET --compliant -d "12345678" --scale=$SCALE_TRACK -o images/cepnet.svg +zint -b DXFILMEDGE --compliant -d "112-1/10A" --scale=$SCALE_TRACK -o images/dxfilmedge.svg +zint -b AUSPOST --compliant -d "96184209" --scale=$SCALE_TRACK -o images/auspost.svg +zint -b AUSROUTE --compliant -d "34567890" --scale=$SCALE_TRACK -o images/ausroute.svg +zint -b AUSREPLY --compliant -d "12345678" --scale=$SCALE_TRACK -o images/ausreply.svg +zint -b AUSREDIRECT --compliant -d "98765432" --scale=$SCALE_TRACK -o images/ausredirect.svg +zint -b KIX --compliant -d "2500GG30250" --scale=$SCALE_TRACK -o images/kix.svg +zint -b RM4SCC --compliant -d "W1J0TR01" --scale=$SCALE_TRACK -o images/rm4scc.svg +zint -b MAILMARK_4S --compliant -d "21B2254800659JW5O9QA6Y" --scale=$SCALE_TRACK -o images/mailmark_4s.svg +zint -b USPS_IMAIL --compliant -d "01234567094987654321-01234" --scale=$SCALE_TRACK -o images/usps_imail.svg +zint -b JAPANPOST --compliant -d "15400233-16-4-205" --scale=$SCALE_TRACK -o images/japanpost.svg zint -b HIBC_DM -d "/ACMRN123456/V200912190833" --fast --square --scale=$SCALE_2D_BIGGER -o images/hibc_dm.svg zint -b MAILMARK_2D -d "JGB 01Z999999900000001EC1A1AA1A0SN35TQ" --vers=30 --scale=$SCALE_2D_BIGGER -o images/mailmark_2d.svg zint -b QRCODE -d "QR Code Symbol" --mask=5 --scale=$SCALE_2D_BIGGER -o images/qrcode.svg @@ -134,6 +134,6 @@ zint -b GRIDMATRIX --eci=29 -d "AAT2556 电池充电器+降压转换器 200mA至 zint -b DOTCODE -d "[01]00012345678905[17]201231[10]ABC123456" --gs1 --scale=$SCALE_2D -o images/dotcode.svg zint -b HANXIN -d "Hanxin Code symbol" --scale=$SCALE_2D -o images/hanxin.svg zint -b ULTRA -d "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS" --scale=$SCALE_ULTRA -o images/ultra.svg -zint -b FIM --compliantheight -d "C" --scale=$SCALE_TRACK -o images/fim.svg +zint -b FIM --compliant -d "C" --scale=$SCALE_TRACK -o images/fim.svg zint -b FLAT -d "1304056" --scale=$SCALE_LINEAR -o images/flat.svg zint -b DAFT -d "AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF" --height=8.494 --vers=256 --scale=$SCALE_TRACK -o images/daft_rm4scc.svg diff --git a/frontend/main.c b/frontend/main.c index e96bfe25..a51b048a 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -67,8 +67,10 @@ typedef char static_assert_int_at_least_32bits[sizeof(int) * CHAR_BIT < 32 ? -1 #define z_isdigit(ch) ((ch) <= '9' && (ch) >= '0') #define z_isupper(ch) ((ch) >= 'A' && (ch) <= 'Z') #define z_islower(ch) ((ch) >= 'a' && (ch) <= 'z') +#define z_iscntrl(ch) (!((ch) & ~0x1F) || (ch) == 127) #define ZUCP(p) ((unsigned char *) (p)) +#define ZCUCP(p) ((const unsigned char *) (p)) #define ZCCP(p) ((const char *) (p)) /* End of copy from "backend/common.h" */ @@ -216,7 +218,7 @@ if (have_gs1syntaxengine) { " -i, --input=FILE Read input data from FILE\n" " --init Create Reader Initialisation (Programming) symbol\n" " --mask=INTEGER Set masking pattern to use (QR/Han Xin/DotCode)\n" - " --mirror Use batch data to determine filename\n", stdout); + " --mirror Use data to determine filename\n", stdout); fputs( " --mode=INTEGER Set encoding mode (MaxiCode/Composite)\n", stdout); printf(" --nobackground Remove background (EMF/EPS/GIF%s/SVG/TIF only)\n", no_png_type); fputs( " --noquietzones Disable default quiet zones\n" @@ -373,23 +375,20 @@ static int validate_float(const char source[], const int allow_neg, float *const const char *e; for (e = dot + strlen(dot) - 1; e > dot && *e == '0'; e--); /* Ignore trailing zeroes */ fract_len = (int) (e + 1 - dot); - if (fract_len) { - if (fract_len > 7) { - cpy_str(errbuf, ERRBUF_SIZE, "fractional part must be 7 digits maximum"); - return 0; - } - if (!validate_int(dot, fract_len, &val2)) { - cpy_str(errbuf, ERRBUF_SIZE, "fractional part must be digits only"); - return 0; - } - if (val2 && int_len + fract_len > 7) { - cpy_str(errbuf, ERRBUF_SIZE, "7 significant digits maximum"); - return 0; - } - *p_val = val + val2 * fract_muls[fract_len - 1]; - } else { - *p_val = (float) val; + assert(fract_len); + if (fract_len > 7) { + cpy_str(errbuf, ERRBUF_SIZE, "fractional part must be 7 digits maximum"); + return 0; } + if (!validate_int(dot, fract_len, &val2)) { + cpy_str(errbuf, ERRBUF_SIZE, "fractional part must be digits only"); + return 0; + } + if (val2 && int_len + fract_len > 7) { + cpy_str(errbuf, ERRBUF_SIZE, "7 significant digits maximum"); + return 0; + } + *p_val = val + val2 * fract_muls[fract_len - 1]; } else { *p_val = (float) val; } @@ -417,6 +416,13 @@ static int is_composite(const int symbology) { || symbology == BARCODE_EAN8_CC || symbology == BARCODE_EAN13_CC; } +/* Returns 1 if `symbol` can process EXTRA_ESCAPE_MODE (copied from "library.c") */ +static int supports_extra_escape_mode(const struct zint_symbol *const symbol) { + return symbol->symbology == BARCODE_CODE128 + || ((symbol->symbology == BARCODE_AZTEC || symbol->symbology == BARCODE_DATAMATRIX) + && (symbol->input_mode & 0x07) != GS1_MODE); +} + /* Return symbology id if `barcode_name` a barcode name */ #ifdef ZINT_TEST static int get_barcode_name(const char *const barcode_name, const int test) { @@ -451,7 +457,7 @@ static int get_barcode_name(const char *const barcode_name) { { BARCODE_C25INTER, "c25inter" }, { BARCODE_C25INTER, "c25interleaved" }, /* Synonym */ { BARCODE_C25LOGIC, "c25logic" }, - { BARCODE_C25STANDARD, "c25matrix" }, + { BARCODE_C25STANDARD, "c25matrix" }, /* Synonym */ { BARCODE_C25STANDARD, "c25standard" }, { BARCODE_CEPNET, "cepnet" }, { BARCODE_CHANNEL, "channel" }, @@ -656,6 +662,7 @@ static int get_barcode_name(const char *const barcode_name) { int i, j, length; #ifdef ZINT_TEST +/* LCOV_EXCL_START */ if (test) { /* Ensure array sorted */ for (i = 0; i < e; i++) { @@ -667,6 +674,7 @@ static int get_barcode_name(const char *const barcode_name) { } return 1; } +/* LCOV_EXCL_STOP */ #endif /* Ignore case and any "BARCODE" prefix */ @@ -982,6 +990,104 @@ static int validate_seg(const char *const arg, const int N, struct zint_seg segs return 1; } +/* Use directory if any from `symbol->outfile`, returning length in `p_mirror_start_o` */ +static int mirror_start(const struct zint_symbol *const symbol, const int output_given, int *p_mirror_start_o) { + int warn_number = 0; + + *p_mirror_start_o = 0; + + /* Use directory if any from outfile */ + if (output_given && symbol->outfile[0]) { +#ifndef _WIN32 + const char *dir = strrchr(symbol->outfile, '/'); +#else + const char *dir = strrchr(symbol->outfile, '\\'); + if (!dir) { + dir = strrchr(symbol->outfile, '/'); + } +#endif + if (dir) { + *p_mirror_start_o = (int) (dir + 1 - symbol->outfile); + if (*p_mirror_start_o > 221) { /* Insist on leaving at least ~30 chars for filename */ + fprintf(stderr, "Warning 188: Directory for mirrored output too long (greater than 220)," + " **IGNORED**\n"); + fflush(stderr); + warn_number = ZINT_WARN_INVALID_OPTION; /* TODO: maybe new warning ZINT_WARN_INVALID_INPUT? */ + *p_mirror_start_o = 0; + } + } + } + + return warn_number; +} + +/* Name the output file from the data being processed */ +static void mirror_outfile(struct zint_symbol *const symbol, const unsigned char source[], const int length, + const char *const filetype, char *output_file, int o) { + const int extra_escape_mode = (symbol->input_mode & EXTRA_ESCAPE_MODE) && supports_extra_escape_mode(symbol); + const int escape_mode = (symbol->input_mode & ESCAPE_MODE) || extra_escape_mode; + int i = 0; + + if (output_file == NULL) { + output_file = symbol->outfile; + } + + do { + if (z_iscntrl(source[i])) { + output_file[o] = '_'; + } else { + switch (source[i]) { +#ifndef _WIN32 + case '/': + output_file[o] = '_'; + break; + case '\\': + output_file[o] = escape_mode ? '_' : '\\'; + break; +#else /* These are all forbidden on Windows */ + case '!': + case '"': + case '*': + case '/': + case ':': + case '<': + case '>': + case '?': + case '\\': + case '|': + output_file[o] = '_'; + break; +#endif + default: + output_file[o] = source[i]; + break; + } + } + + /* Skip escape characters */ + if (source[i] == '\\' && escape_mode) { + i++; + if (source[i] == 'x') { + i += 2; + } else if (source[i] == 'd' || source[i] == 'o') { + i += 3; + } else if (source[i] == 'u') { + i += 4; + } else if (source[i] == 'U') { + i += 6; + } else if (extra_escape_mode && source[i] == '^') { + i++; + } + } + i++; + o++; + } while (i < length && o < 251); + + /* Add file extension */ + output_file[o] = '.'; + ncpy_str(output_file + o + 1, ARRAY_SIZE(symbol->outfile) - o - 1, filetype, 3); +} + #ifdef _WIN32 static FILE *win_fopen(const char *const filename, const char *const mode); /* Forward ref */ #endif @@ -992,7 +1098,9 @@ static int batch_process(struct zint_symbol *const symbol, const char *const fil FILE *file; unsigned char buffer[ZINT_MAX_DATA_LEN] = {0}; /* Maximum HanXin input */ unsigned char character = 0; - int buf_posn = 0, error_number = 0, warn_number = 0, line_count = 1; + int buf_posn = 0; + int error_number = 0, warn_number = 0; + int line_count = 1; char output_file[ARRAY_SIZE(symbol->outfile)]; char format_string[ARRAY_SIZE(symbol->outfile)]; int i, mirror_start_o = 0; @@ -1000,27 +1108,9 @@ static int batch_process(struct zint_symbol *const symbol, const char *const fil if (mirror_mode) { /* Use directory if any from outfile */ - if (output_given && symbol->outfile[0]) { -#ifndef _WIN32 - const char *dir = strrchr(symbol->outfile, '/'); -#else - const char *dir = strrchr(symbol->outfile, '\\'); - if (!dir) { - dir = strrchr(symbol->outfile, '/'); - } -#endif - if (dir) { - mirror_start_o = (int) (dir + 1 - symbol->outfile); - if (mirror_start_o > 221) { /* Insist on leaving at least ~30 chars for filename */ - fprintf(stderr, "Warning 188: directory for mirrored batch output too long (greater than 220)," - " **IGNORED**\n"); - fflush(stderr); - warn_number = ZINT_WARN_INVALID_OPTION; /* TODO: maybe new warning ZINT_WARN_INVALID_INPUT? */ - mirror_start_o = 0; - } else { - memcpy(output_file, symbol->outfile, mirror_start_o); - } - } + warn_number = mirror_start(symbol, output_given, &mirror_start_o); + if (mirror_start_o) { + memcpy(output_file, symbol->outfile, mirror_start_o); } } else { if (symbol->outfile[0] == '\0' || !output_given) { @@ -1121,52 +1211,7 @@ static int batch_process(struct zint_symbol *const symbol, const char *const fil } } else { /* Name the output file from the data being processed */ - int o = mirror_start_o; - i = 0; - do { - if (buffer[i] < 0x20) { - output_file[o] = '_'; - } else { - switch (buffer[i]) { - case '!': - case '"': - case '*': - case '/': - case ':': - case '<': - case '>': - case '?': - case '\\': - case '|': - case 0x7f: /* DEL */ - output_file[o] = '_'; - break; - default: - output_file[o] = buffer[i]; - break; - } - } - - /* Skip escape characters */ - if (buffer[i] == '\\' && (symbol->input_mode & ESCAPE_MODE)) { - i++; - if (buffer[i] == 'x') { - i += 2; - } else if (buffer[i] == 'd' || buffer[i] == 'o') { - i += 3; - } else if (buffer[i] == 'u') { - i += 4; - } else if (buffer[i] == 'U') { - i += 6; - } - } - i++; - o++; - } while (i < buf_posn && o < 251); - - /* Add file extension */ - output_file[o] = '.'; - ncpy_str(output_file + o + 1, ARRAY_SIZE(output_file) - o - 1, filetype, 3); + mirror_outfile(symbol, buffer, buf_posn, filetype, output_file, mirror_start_o); } cpy_str(symbol->outfile, ARRAY_SIZE(symbol->outfile), output_file); @@ -1188,6 +1233,9 @@ static int batch_process(struct zint_symbol *const symbol, const char *const fil if (buf_posn >= ARRAY_SIZE(buffer)) { fprintf(stderr, "On line %d: Error 103: Input data too long\n", line_count); fflush(stderr); + if (error_number == 0) { + error_number = ZINT_ERROR_TOO_LONG; + } do { if ((intChar = fgetc(file)) == EOF) { break; @@ -1211,10 +1259,7 @@ static int batch_process(struct zint_symbol *const symbol, const char *const fil warn_number = ZINT_WARN_INVALID_OPTION; /* TODO: maybe new warning e.g. ZINT_WARN_INVALID_INPUT? */ } } - if (error_number == 0) { - error_number = warn_number; - } - return error_number; + return error_number ? error_number : warn_number; } /* Stuff to convert args on Windows command line to UTF-8 */ @@ -1525,7 +1570,6 @@ int main(int argc, char **argv) { int val; int i; int ret; - const char *outfile_extension; int data_arg_num = 0; int seg_count = 0; float x_dim_mm = 0.0f, dpmm = 0.0f; @@ -1685,7 +1729,7 @@ int main(int argc, char **argv) { my_symbol->option_3 = ZINT_AZTEC_FULL | (my_symbol->option_3 & ~0xFF); break; case OPT_BATCH: - if (data_cnt == 0) { + if (data_cnt == 0 && seg_count == 0) { /* Switch to batch processing mode */ batch_mode = 1; } else { @@ -1714,10 +1758,10 @@ int main(int argc, char **argv) { fprintf(stderr, "Error 107: Invalid border width value (digits only)\n"); return do_exit(ZINT_ERROR_INVALID_OPTION); } - if (val <= 1000) { /* `val` >= 0 always */ + if (val <= 100) { /* `val` >= 0 always */ my_symbol->border_width = val; } else { - fprintf(stderr, "Warning 108: Border width '%d' out of range (0 to 1000), **IGNORED**\n", val); + fprintf(stderr, "Warning 108: Border width '%d' out of range (0 to 100), **IGNORED**\n", val); fflush(stderr); warn_number = ZINT_WARN_INVALID_OPTION; } @@ -1774,7 +1818,7 @@ int main(int argc, char **argv) { } /* C40 overwrites Base 256 */ if ((my_symbol->option_3 & DM_B256_C40_START_MASK) == DM_B256_START) { - fprintf(stderr, "Warning 161: previous '--dmb256' overwritten by '--dmc40'\n"); + fprintf(stderr, "Warning 161: Previous '--dmb256' overwritten by '--dmc40'\n"); fflush(stderr); warn_number = ZINT_WARN_INVALID_OPTION; } @@ -2115,7 +2159,7 @@ int main(int argc, char **argv) { case OPT_SQUARE: /* Square overwrites DMRE */ if ((my_symbol->option_3 & DM_SQUARE_DMRE_MASK) == DM_DMRE) { - fprintf(stderr, "Warning 157: previous '--dmre' overwritten by '--square'\n"); + fprintf(stderr, "Warning 157: Previous '--dmre' overwritten by '--square'\n"); fflush(stderr); warn_number = ZINT_WARN_INVALID_OPTION; } @@ -2129,12 +2173,14 @@ int main(int argc, char **argv) { } break; #ifdef ZINT_TEST +/* LCOV_EXCL_START */ case OPT_TEST: if (!test()) { return do_exit(ZINT_ERROR_ENCODING_PROBLEM); } help = 1; /* Mark as help to avoid "No data" warning */ break; +/* LCOV_EXCL_STOP */ #endif case OPT_TEXTGAP: if (!validate_float(optarg, 1 /*allow_neg*/, &float_opt, errbuf)) { @@ -2171,11 +2217,11 @@ int main(int argc, char **argv) { fprintf(stderr, "Error 153: Invalid vertical whitespace value '%s' (digits only)\n", optarg); return do_exit(ZINT_ERROR_INVALID_OPTION); } - if (val <= 1000) { /* `val` >= 0 always */ + if (val <= 100) { /* `val` >= 0 always */ my_symbol->whitespace_height = val; } else { fprintf(stderr, - "Warning 154: Vertical whitespace value '%d' out of range (0 to 1000), **IGNORED**\n", + "Warning 154: Vertical whitespace value '%d' out of range (0 to 100), **IGNORED**\n", val); fflush(stderr); warn_number = ZINT_WARN_INVALID_OPTION; @@ -2219,11 +2265,11 @@ int main(int argc, char **argv) { fprintf(stderr, "Error 120: Invalid horizontal whitespace value '%s' (digits only)\n", optarg); return do_exit(ZINT_ERROR_INVALID_OPTION); } - if (val <= 1000) { /* `val` >= 0 always */ + if (val <= 100) { /* `val` >= 0 always */ my_symbol->whitespace_width = val; } else { fprintf(stderr, - "Warning 121: Horizontal whitespace value '%d' out of range (0 to 1000), **IGNORED**\n", + "Warning 121: Horizontal whitespace value '%d' out of range (0 to 100), **IGNORED**\n", val); fflush(stderr); warn_number = ZINT_WARN_INVALID_OPTION; @@ -2289,14 +2335,14 @@ int main(int argc, char **argv) { return do_exit(ZINT_ERROR_ENCODING_PROBLEM); } if (long_options[i].has_arg) { - fprintf(stderr, "Error 109: option '%s' requires an argument\n", arg); + fprintf(stderr, "Error 109: Option '%s' requires an argument\n", arg); } else { const char *const eqs = strchr(arg, '='); const int optlen = eqs ? (int) (eqs - arg) : (int) strlen(arg); - fprintf(stderr, "Error 126: option '%.*s' does not take an argument\n", optlen, arg); + fprintf(stderr, "Error 126: Option '%.*s' does not take an argument\n", optlen, arg); } } else { - fprintf(stderr, "Error 101: unknown option '%s'\n", arg); + fprintf(stderr, "Error 101: Unknown option '%s'\n", arg); } } return do_exit(ZINT_ERROR_INVALID_OPTION); @@ -2310,9 +2356,9 @@ int main(int argc, char **argv) { } if (optind != argc) { if (optind + 1 == argc) { - fprintf(stderr, "Warning 191: extra argument '%s' **IGNORED**\n", argv[optind]); + fprintf(stderr, "Warning 191: Extra argument '%s' **IGNORED**\n", argv[optind]); } else { - fprintf(stderr, "Warning 192: extra arguments beginning with '%s' **IGNORED**\n", argv[optind]); + fprintf(stderr, "Warning 192: Extra arguments beginning with '%s' **IGNORED**\n", argv[optind]); } fflush(stderr); warn_number = ZINT_WARN_INVALID_OPTION; @@ -2320,7 +2366,7 @@ int main(int argc, char **argv) { if (data_arg_num) { const int symbology = my_symbol->symbology; - const unsigned int cap = ZBarcode_Cap(symbology, ZINT_CAP_EXTENDABLE | ZINT_CAP_FULL_MULTIBYTE + const unsigned int cap = ZBarcode_Cap(symbology, ZINT_CAP_EANUPC | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK | ZINT_CAP_BINDABLE); if (fullmultibyte && (cap & ZINT_CAP_FULL_MULTIBYTE)) { my_symbol->option_3 = ZINT_FULL_MULTIBYTE; @@ -2331,7 +2377,7 @@ int main(int argc, char **argv) { if (separator && (cap & ZINT_CAP_BINDABLE)) { my_symbol->option_3 = separator; } - if (addon_gap && (cap & ZINT_CAP_EXTENDABLE)) { + if (addon_gap && (cap & ZINT_CAP_EANUPC)) { my_symbol->option_2 = addon_gap; } if (rows) { @@ -2356,6 +2402,14 @@ int main(int argc, char **argv) { fflush(stderr); warn_number = ZINT_WARN_INVALID_OPTION; } + if (filetype[0] == '\0') { + const char *outfile_extension = get_extension(my_symbol->outfile); + if (outfile_extension && supported_filetype(outfile_extension, no_png, NULL /*png_refused*/)) { + cpy_str(filetype, ARRAY_SIZE(filetype), outfile_extension); + } else { + cpy_str(filetype, ARRAY_SIZE(filetype), no_png ? "gif" : "png"); + } + } if (batch_mode) { /* Take each line of text as a separate data set */ if (data_arg_num > 1) { @@ -2365,34 +2419,16 @@ int main(int argc, char **argv) { fflush(stderr); warn_number = ZINT_WARN_INVALID_OPTION; } - if (seg_count) { - fprintf(stderr, "Warning 169: Segment arguments **IGNORED**\n"); - fflush(stderr); - warn_number = ZINT_WARN_INVALID_OPTION; - } - if (filetype[0] == '\0') { - outfile_extension = get_extension(my_symbol->outfile); - if (outfile_extension && supported_filetype(outfile_extension, no_png, NULL /*png_refused*/)) { - cpy_str(filetype, ARRAY_SIZE(filetype), outfile_extension); - } else { - cpy_str(filetype, ARRAY_SIZE(filetype), no_png ? "gif" : "png"); - } - } - if (dpmm) { /* Allow `x_dim_mm` to be zero */ + assert(seg_count == 0); /* Previous checks ensure this */ + if (dpmm) { + /* Allow `x_dim_mm` to be zero */ if (x_dim_mm == 0.0f) { x_dim_mm = ZBarcode_Default_Xdim(symbology); } float_opt = ZBarcode_Scale_From_XdimDp(symbology, x_dim_mm, dpmm, filetype); - if (float_opt > 0.0f) { - my_symbol->scale = float_opt; - my_symbol->dpmm = dpmm; - } else { - fprintf(stderr, - "Warning 187: Invalid scalexdimdp X-dim '%g', resolution '%g' combo, **IGNORED**\n", - x_dim_mm, dpmm); - fflush(stderr); - warn_number = ZINT_WARN_INVALID_OPTION; - } + assert(float_opt > 0.0f); /* Can't fail due to previous checks */ + my_symbol->scale = float_opt; + my_symbol->dpmm = dpmm; } if (((symbology != BARCODE_MAXICODE && my_symbol->scale < 0.5f) || my_symbol->scale < 0.2f) && is_raster(filetype, no_png)) { @@ -2424,24 +2460,30 @@ int main(int argc, char **argv) { } } } + if (mirror_mode) { + if (arg_opts[0].opt != 'd') { + fprintf(stderr, "Warning 163: '--mirror' given but no data argument, **IGNORED**\n"); + fflush(stderr); + warn_number = ZINT_WARN_INVALID_OPTION; + } else { + int mirror_start_o; + warn_number = mirror_start(my_symbol, output_given, &mirror_start_o); + mirror_outfile(my_symbol, ZUCP(arg_opts[0].arg), (int) strlen(arg_opts[0].arg), filetype, NULL, + mirror_start_o); + } + } if (filetype[0] != '\0') { set_extension(my_symbol->outfile, filetype); } - if (dpmm) { /* Allow `x_dim_mm` to be zero */ + if (dpmm) { + /* Allow `x_dim_mm` to be zero */ if (x_dim_mm == 0.0f) { x_dim_mm = ZBarcode_Default_Xdim(symbology); } float_opt = ZBarcode_Scale_From_XdimDp(symbology, x_dim_mm, dpmm, get_extension(my_symbol->outfile)); - if (float_opt > 0.0f) { - my_symbol->scale = float_opt; - my_symbol->dpmm = dpmm; - } else { - fprintf(stderr, - "Warning 190: Invalid scalexdimdp X-dim '%g', resolution '%g' combo **IGNORED**\n", - x_dim_mm, dpmm); - fflush(stderr); - warn_number = ZINT_WARN_INVALID_OPTION; - } + assert(float_opt > 0.0f); /* Can't fail due to previous checks */ + my_symbol->scale = float_opt; + my_symbol->dpmm = dpmm; } if (((symbology != BARCODE_MAXICODE && my_symbol->scale < 0.5f) || my_symbol->scale < 0.2f) && is_raster(get_extension(my_symbol->outfile), no_png)) { @@ -2500,6 +2542,7 @@ int main(int argc, char **argv) { } #ifdef ZINT_TEST +/* LCOV_EXCL_START */ static int test_cpy_str(void) { /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ @@ -2624,11 +2667,12 @@ static int test_validate_float(void) { /* 19*/ { "1234.5670", 0, 1234.567f, "", 1 }, /* 20*/ { "1234.56700", 0, 1234.567f, "", 1 }, /* 21*/ { "0.", 0, 0.0f, "", 1 }, - /* 22*/ { "-0", 1, 0.0f, "", 1 }, - /* 23*/ { ".0", 0, 0.0f, "", 1 }, - /* 24*/ { ".", 0, 0.0f, "", 1 }, - /* 25*/ { "+.", 0, 0.0f, "", 1 }, - /* 26*/ { "-.", 1, 0.0f, "", 1 }, + /* 22*/ { "0.0", 0, 0.0f, "", 1 }, + /* 23*/ { "-0", 1, 0.0f, "", 1 }, + /* 24*/ { ".0", 0, 0.0f, "", 1 }, + /* 25*/ { ".", 0, 0.0f, "", 1 }, + /* 26*/ { "+.", 0, 0.0f, "", 1 }, + /* 27*/ { "-.", 1, 0.0f, "", 1 }, }; int i; for (i = 0; i < ARRAY_SIZE(data); i++) { @@ -2929,18 +2973,20 @@ static int test_validate_structapp(void) { /* 1*/ { ",", { -1, -1, "" }, 0, "Structured Append index too short" }, /* 2*/ { "1234567890,", { -1, -1, "" }, 0, "Structured Append index too long" }, /* 3*/ { "123456789,", { -1, -1, "" }, 0, "Structured Append count too short" }, - /* 4*/ { "1,1234567890", { -1, -1, "" }, 0, "Structured Append count too long" }, - /* 5*/ { "1,123456789,", { -1, -1, "" }, 0, "Structured Append ID too short" }, - /* 6*/ { "123456789,123456789,123456789012345678901234567890123", { -1, -1, "" }, 0, "Structured Append ID too long" }, - /* 7*/ { "123456789,123456789,12345678901234567890123456789012", { 123456789, 123456789, {'1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2'} }, 1, "" }, - /* 8*/ { "2,3,5006", { 2, 3, "5006" }, 1, "" }, - /* 9*/ { "2,3,,", { 2, 3, "," }, 1, "" }, - /* 10*/ { "1.2,1", { -1, -1, "" }, 0, "Invalid Structured Append index (digits only)" }, - /* 11*/ { "12,1.0", { 12, -1, "" }, 0, "Invalid Structured Append count (digits only)" }, - /* 12*/ { "12,1", { 12, 1, "" }, 0, "Invalid Structured Append count '1', must be greater than or equal to 2" }, - /* 13*/ { "12,11", { 12, 11, "" }, 0, "Structured Append index '12' out of range (1 to count '11')" }, - /* 14*/ { "12,12", { 12, 12, "" }, 1, "" }, - /* 15*/ { "0,2", { 0, 2, "" }, 0, "Structured Append index '0' out of range (1 to count '2')" }, + /* 4*/ { "123456789,,", { -1, -1, "" }, 0, "Structured Append count too short" }, + /* 5*/ { "1,1234567890", { -1, -1, "" }, 0, "Structured Append count too long" }, + /* 6*/ { "1,1234567890,", { -1, -1, "" }, 0, "Structured Append count too long" }, + /* 7*/ { "1,123456789,", { -1, -1, "" }, 0, "Structured Append ID too short" }, + /* 8*/ { "123456789,123456789,123456789012345678901234567890123", { -1, -1, "" }, 0, "Structured Append ID too long" }, + /* 9*/ { "123456789,123456789,12345678901234567890123456789012", { 123456789, 123456789, {'1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2'} }, 1, "" }, + /* 10*/ { "2,3,5006", { 2, 3, "5006" }, 1, "" }, + /* 11*/ { "2,3,,", { 2, 3, "," }, 1, "" }, + /* 12*/ { "1.2,1", { -1, -1, "" }, 0, "Invalid Structured Append index (digits only)" }, + /* 13*/ { "12,1.0", { 12, -1, "" }, 0, "Invalid Structured Append count (digits only)" }, + /* 14*/ { "12,1", { 12, 1, "" }, 0, "Invalid Structured Append count '1', must be greater than or equal to 2" }, + /* 15*/ { "12,11", { 12, 11, "" }, 0, "Structured Append index '12' out of range (1 to count '11')" }, + /* 16*/ { "12,12", { 12, 12, "" }, 1, "" }, + /* 17*/ { "0,2", { 0, 2, "" }, 0, "Structured Append index '0' out of range (1 to count '2')" }, }; int i; for (i = 0; i < ARRAY_SIZE(data); i++) { @@ -3034,6 +3080,172 @@ static int test_validate_seg(void) { return 1; } +#define TEST_MIRRORED_LONG "test_67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" /* 250 chars */ + +#define TEST_MIRRORED_DIR_LONG "testdir_9012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/" /* 220 chars */ +#define TEST_MIRRORED_DIR_TOO_LONG "testdir_901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901/" /* 222 chars */ + +static int test_mirror_start(void) { + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct { const char *outfile; int output_given; int ret; int mirror_start_o; } data[] = { + /* 0*/ { NULL, 0, 0, 0 }, + /* 1*/ { "", 0, 0, 0 }, + /* 2*/ { "123.svg", 1, 0, 0 }, + /* 3*/ { "ABCDF/123.svg", 1, 0, 6 }, + /* 4*/ { "ABCDF/", 1, 0, 6 }, + /* 5*/ { TEST_MIRRORED_DIR_LONG, 1, 0, 220 }, + /* 6*/ { TEST_MIRRORED_DIR_TOO_LONG, 1, ZINT_WARN_INVALID_OPTION, 0 }, + }; + int i, ret; + struct zint_symbol s_symbol = {0}; + struct zint_symbol *symbol = &s_symbol; + + for (i = 0; i < ARRAY_SIZE(data); i++) { + int mirror_start_o = -1; + + ZBarcode_Reset(symbol); + + if (data[i].outfile) { + cpy_str(symbol->outfile, ARRAY_SIZE(symbol->outfile), data[i].outfile); + } + + if (data[i].ret) { + printf("++++ Following warning expected, ignore: "); + fflush(stdout); + } + ret = mirror_start(symbol, data[i].output_given, &mirror_start_o); + if (ret != data[i].ret) { + fprintf(stderr, "%d: ret %d != %d\n", i, ret, data[i].ret); + assert(0); + return 0; + } + if (mirror_start_o != data[i].mirror_start_o) { + fprintf(stderr, "%d: mirror_start_o %d != %d\n", i, mirror_start_o, data[i].mirror_start_o); + assert(0); + return 0; + } + } + return 1; +} + +#ifndef _WIN32 +#define TEST_MIRROR_BSLASH "\\" +#define TEST_MIRROR_EXCLAIM "!" +#define TEST_MIRROR_DQUOTE "\"" +#define TEST_MIRROR_ASTERISK "*" +#define TEST_MIRROR_COLON ":" +#define TEST_MIRROR_LANGLE "<" +#define TEST_MIRROR_RANGLE ">" +#define TEST_MIRROR_QUESTION "?" +#define TEST_MIRROR_PIPE "|" +#else +#define TEST_MIRROR_BSLASH "_" +#define TEST_MIRROR_EXCLAIM "_" +#define TEST_MIRROR_DQUOTE "_" +#define TEST_MIRROR_ASTERISK "_" +#define TEST_MIRROR_COLON "_" +#define TEST_MIRROR_LANGLE "_" +#define TEST_MIRROR_RANGLE "_" +#define TEST_MIRROR_QUESTION "_" +#define TEST_MIRROR_PIPE "_" +#endif + +static int test_mirror_outfile(void) { + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct { + int symbology; int input_mode; + const char *source; const char *outfile; const char *filetype; int use_symbol_outfile; int o; + const char *expected_outfile; + } data[] = { + /* 0*/ { -1, -1, "123", NULL, "png", 1, 0, "123.png" }, + /* 1*/ { -1, -1, "123", NULL, "png", 0, 0, "123.png" }, + /* 2*/ { -1, -1, "\001", NULL, "png", 0, 0, "_.png" }, + /* 3*/ { -1, -1, "1!!2", NULL, "png", 0, 0, "1" TEST_MIRROR_EXCLAIM TEST_MIRROR_EXCLAIM "2.png" }, + /* 4*/ { -1, -1, "1!2\"3*4/5:6<7>8?9\\0|1\1772\0173", NULL, "png", 0, 0, "1" TEST_MIRROR_EXCLAIM "2" TEST_MIRROR_DQUOTE "3" TEST_MIRROR_ASTERISK "4_5" TEST_MIRROR_COLON "6" TEST_MIRROR_LANGLE "7" TEST_MIRROR_RANGLE "8" TEST_MIRROR_QUESTION "9" TEST_MIRROR_BSLASH "0" TEST_MIRROR_PIPE "1_2_3.png" }, + /* 5*/ { -1, -1, "ABC\\d123\\o123\\x12\\u1234\\U123456\\0\\E\\a\\N\\U1234", NULL, "png", 1, 0, "ABC" TEST_MIRROR_BSLASH "d123" TEST_MIRROR_BSLASH "o123" TEST_MIRROR_BSLASH "x12" TEST_MIRROR_BSLASH "u1234" TEST_MIRROR_BSLASH "U123456" TEST_MIRROR_BSLASH "0" TEST_MIRROR_BSLASH "E" TEST_MIRROR_BSLASH "a" TEST_MIRROR_BSLASH "N" TEST_MIRROR_BSLASH "U1234.png" }, + /* 6*/ { -1, ESCAPE_MODE, "ABC\\d123\\o123\\x12\\u1234\\U123456\\0\\E\\a\\N\\U1234", NULL, "png", 1, 0, "ABC__________.png" }, /* 10 escape sequences, 10 underscores */ + /* 7*/ { -1, -1, "1!2\\d1233*4\\^15", NULL, "png", 0, 0, "1" TEST_MIRROR_EXCLAIM "2" TEST_MIRROR_BSLASH "d1233" TEST_MIRROR_ASTERISK "4" TEST_MIRROR_BSLASH "^15.png" }, + /* 8*/ { -1, ESCAPE_MODE, "1!2\\d1233*4\\^15", NULL, "png", 0, 0, "1" TEST_MIRROR_EXCLAIM "2_3" TEST_MIRROR_ASTERISK "4_15.png" }, + /* 9*/ { -1, ESCAPE_MODE | EXTRA_ESCAPE_MODE, "1!2\\d1233*4\\^15", NULL, "png", 0, 0, "1" TEST_MIRROR_EXCLAIM "2_3" TEST_MIRROR_ASTERISK "4_5.png" }, + /* 10*/ { -1, EXTRA_ESCAPE_MODE, "1!2\\d1233*4\\^15", NULL, "png", 0, 0, "1" TEST_MIRROR_EXCLAIM "2_3" TEST_MIRROR_ASTERISK "4_5.png" }, + /* 11*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, "1!2\\d1233*4\\^15", NULL, "png", 0, 0, "1" TEST_MIRROR_EXCLAIM "2" TEST_MIRROR_BSLASH "d1233" TEST_MIRROR_ASTERISK "4" TEST_MIRROR_BSLASH "^15.png" }, + /* 12*/ { -1, -1, "ABC123", "test_dir/out.png", "png", 1, 0, "test_dir/ABC123.png" }, + /* 13*/ { -1, -1, "ABC123", "test_dir/out.png", "png", 0, 9, "test_dir/ABC123.png" }, + /* 14*/ { -1, -1, TEST_MIRRORED_LONG "123456", NULL, "pcx", 1, 0, TEST_MIRRORED_LONG "1.pcx" }, + /* 15*/ { -1, -1, TEST_MIRRORED_LONG "123456", NULL, "pcx", 0, 0, TEST_MIRRORED_LONG "1.pcx" }, + /* 16*/ { -1, -1, TEST_MIRRORED_LONG, TEST_MIRRORED_DIR_LONG, "eps", 1, 0, TEST_MIRRORED_DIR_LONG "test_67890123456789012345678901.eps" }, + /* 17*/ { -1, -1, TEST_MIRRORED_LONG, TEST_MIRRORED_DIR_LONG, "eps", 0, 220, TEST_MIRRORED_DIR_LONG "test_67890123456789012345678901.eps" }, + }; + int i; + struct zint_symbol s_symbol = {0}; + struct zint_symbol *symbol = &s_symbol; + + for (i = 0; i < ARRAY_SIZE(data); i++) { + const int length = (int) strlen(data[i].source); + char output_file[256] = {0}; + + ZBarcode_Reset(symbol); + + if (data[i].symbology != -1) { + symbol->symbology = data[i].symbology; + } + if (data[i].input_mode != -1) { + symbol->input_mode = data[i].input_mode; + } + + if (data[i].use_symbol_outfile) { + int mirror_start_o; + if (data[i].outfile) { + cpy_str(symbol->outfile, ARRAY_SIZE(symbol->outfile), data[i].outfile); + } + mirror_start(symbol, 1 /*output_given*/, &mirror_start_o); + mirror_outfile(symbol, ZCUCP(data[i].source), length, data[i].filetype, NULL, mirror_start_o); + if (strcmp(symbol->outfile, data[i].expected_outfile) != 0) { + fprintf(stderr, "%d: symbol->outfile \"%s\" != \"%s\"\n", + i, symbol->outfile, data[i].expected_outfile); + assert(0); + return 0; + } + } else { + if (data[i].outfile) { + cpy_str(output_file, ARRAY_SIZE(output_file), data[i].outfile); + } + mirror_outfile(symbol, ZCUCP(data[i].source), length, data[i].filetype, output_file, data[i].o); + if (strcmp(output_file, data[i].expected_outfile) != 0) { + fprintf(stderr, "%d: output_file \"%s\" != \"%s\"\n", i, output_file, data[i].expected_outfile); + assert(0); + return 0; + } + } + } + return 1; +} + +static int test_batch_process(void) { + int ret; + struct zint_symbol s_symbol = {0}; + struct zint_symbol *symbol = &s_symbol; + + const char filename[] = "test_nosuch.file"; + const char filetype[] = "gif"; + int mirror_mode = 0; + int output_given = 0; + int rotate_angle = 0; + + printf("++++ Following error expected, ignore: "); + fflush(stdout); + + ret = batch_process(symbol, filename, mirror_mode, filetype, output_given, rotate_angle); + + if (ret != ZINT_ERROR_INVALID_DATA) { + fprintf(stderr, "batch_process \"%s\", ret %d != \n", filename, ret); + assert(0); + return 0; + } + + return 1; +} + #ifdef _WIN32 static int test_win_CommandLineToArgvW(void) { @@ -3163,6 +3375,9 @@ static int test(void) { ret &= test_validate_scalexdimdp(); ret &= test_validate_structapp(); ret &= test_validate_seg(); + ret &= test_mirror_start(); + ret &= test_mirror_outfile(); + ret &= test_batch_process(); #ifdef _WIN32 ret &= test_win_CommandLineToArgvW(); ret &= test_utf8_to_wide(); @@ -3170,6 +3385,7 @@ static int test(void) { return ret; } +/* LCOV_EXCL_STOP */ #endif /* ZINT_TEST */ /* vim: set ts=4 sw=4 et : */ diff --git a/frontend/tests/test_args.c b/frontend/tests/test_args.c index 299ee30f..5926e805 100644 --- a/frontend/tests/test_args.c +++ b/frontend/tests/test_args.c @@ -191,7 +191,8 @@ static int arg_input(char *cmd, const char *filename, const char *input) { } cnt = (int) fwrite(input, 1, strlen(input), fp); if (cnt != (int) strlen(input)) { - fprintf(stderr, "arg_input: failed to write %d bytes, cnt %d written (%s)\n", (int) strlen(input), cnt, filename); + fprintf(stderr, "arg_input: failed to write %d bytes, cnt %d written (%s)\n", + (int) strlen(input), cnt, filename); fclose(fp); return 0; } @@ -328,43 +329,48 @@ static void test_dump_args(const testCtx *const p_ctx) { /* 13*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, /* 14*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, 10, -1, -1, 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" }, /* 15*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, - /* 16*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "B2 D6 96 CA B5 6D 64" }, - /* 17*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 1, "B2 D6 96 CA B5 64" }, - /* 18*/ { BARCODE_CODE11, "123", NULL, "456", NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2" }, - /* 19*/ { BARCODE_CODE11, "123", "456", "789", "012", -1, -1, 0, -1, -1, -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" }, - /* 20*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, 0, 0, -1, "FF 54 7A BC 3A 9C 1D 5C 0F E8 A4\nFF 54 7E AE 3C 11 5F AB 8F E8 A4\nFF 54 6A F8 29 9F 1D 5F 8F E8 A4\nFF 54 57 9E 37 BA 1A F7 CF E8 A4\nFF 54 75 CC 36 F0 5D 73 0F E8 A4" }, - /* 21*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, - /* 22*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, READER_INIT, 0, -1, -1, -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" }, - /* 23*/ { BARCODE_DATAMATRIX, "ABCDEFGH", NULL, NULL, NULL, FAST_MODE, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nA6 8C\nB2 F0\n98 B4\nB9 A8\nB8 CC\nF0 78\nA0 3C\n99 70\n85 1C\nDA B0\nE5 94\nA7 50\nFF FC" }, - /* 24*/ { BARCODE_DATAMATRIX, "ABCDEFGH", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\n80 04\n82 60\nC5 24\n98 A8\nA3 9C\nCB B8\nAF DC\n86 58\nF6 44\nAC 18\n90 54\nCF 30\nFF FC" }, - /* 25*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\n80 09 F9 BD\n82 4A E2 58\nC5 CD C9 A5\nD8 5C A5 FC\nE0 35 88 69\nCC FC B3 E6\nFF FF FF FF" }, - /* 26*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA\n80 25\n82 24\nC5 5D\n98 90\nA4 C7\nC8 A6\nB9 E9\n8E 02\nDE 91\nCD 6C\nA0 BB\n85 80\n98 2D\nE4 CA\nFF FF" }, - /* 27*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA A8\nBA 5A 44\n8B 4D 28\nBF 77 64\n97 85 50\nBA D8 AC\nCD ED B8\nD4 B5 2C\nD1 A8 00\n81 FB 2C\nE4 75 78\n96 E8 2C\nF3 75 78\nEE 1D 04\nCA BA 98\nB1 8F B4\nA0 4F 00\nE4 A7 74\nF1 D3 90\nEF E1 BC\n91 10 38\nFF FF FC" }, - /* 28*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA AA AA AA AA\nBA 03 BA 7D E5 31 B0 0D\n8B 6A 93 B6 E0 0A B8 3C\nBF 1D EA A7 EB ED A1 FB\n96 66 86 B6 C9 AE 92 40\nBF 65 E7 95 BC B7 FA E3\nCC 7C 90 CC D1 24 AB 5A\nFF FF FF FF FF FF FF FF" }, - /* 29*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "Warning 157: previous '--dmre' overwritten by '--square'\nAA AA A8\nBA 5A 44\n8B 4D 28\nBF 77 64\n97 85 50\nBA D8 AC\nCD ED B8\nD4 B5 2C\nD1 A8 00\n81 FB 2C\nE4 75 78\n96 E8 2C\nF3 75 78\nEE 1D 04\nCA BA 98\nB1 8F B4\nA0 4F 00\nE4 A7 74\nF1 D3 90\nEF E1 BC\n91 10 38\nFF FF FC" }, - /* 30*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, -1, 0, -1, -1, -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" }, - /* 31*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, GS1_GS_SEPARATOR, 0, -1, -1, -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" }, - /* 32*/ { BARCODE_DATAMATRIX, "[9\\x31]12[92]34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE, GS1_GS_SEPARATOR, 0, -1, -1, -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" }, - /* 33*/ { BARCODE_DATAMATRIX, "(9\\x31)12(92)34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, GS1_GS_SEPARATOR, 0, -1, -1, -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" }, - /* 34*/ { BARCODE_DATAMATRIX, "abc", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA 8\nB3 C\nC6 0\nBA C\nBD 0\nB4 C\nDC 0\nEB C\nD1 8\nFF C" }, - /* 35*/ { BARCODE_DATAMATRIX, "abc", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\n8B F\nD4 C\nC2 7\n9E C\nCF 3\n8E 8\nBB F\n86 2\n95 D\nCB A\nFF F" }, - /* 36*/ { BARCODE_DATAMATRIX, "abc", NULL, NULL, NULL, -1, -1, 0, -1, -1, 1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\n8C F\n9E 4\nC5 7\nA9 6\n9F F\n97 0\nFA 9\nAA C\nDD D\nD2 2\nFF F" }, - /* 37*/ { BARCODE_DATAMATRIX, "abc", NULL, NULL, NULL, -1, -1, 0, -1, 0, 1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "Warning 161: previous '--dmb256' overwritten by '--dmc40'\nAA A\n8C F\n9E 4\nC5 7\nA9 6\n9F F\n97 0\nFA 9\nAA C\nDD D\nD2 2\nFF F" }, - /* 38*/ { BARCODE_DATAMATRIX, "A\\^1BC\\^^1DEF", NULL, NULL, NULL, EXTRA_ESCAPE_MODE, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\nE0 B9 88 59\nD0 08 A3 14\n8D 9D DD DB\n8E 3E E5 E8\nDF 3B A5 A1\nB6 20 A6 02\nFF FF FF FF" }, - /* 39*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, - /* 40*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, - /* 41*/ { BARCODE_MAXICODE, "abc", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, "1234567", -1, -1, 0, -1, "C0 55 55 5C\nC0 00 00 08\nE7 AA AA A0\n55 55 55 58\n00 00 00 0C\nAA AA AA A8\n55 55 55 50\n00 00 00 08\nAA AA AA A4\n55 B1 35 50\n00 90 08 0C\nAA C0 52 A0\n54 40 05 58\n01 00 08 00\nAA C0 0A A0\n55 00 01 58\n02 80 08 08\nAB 80 1E A8\n54 00 05 54\n03 80 0C 00\nA8 00 02 AC\n55 40 25 50\n00 60 40 0C\nAA 60 66 A0\n55 55 53 B0\n00 00 07 A0\nAA AA AE 0C\nA3 CE E2 C8\nB3 F4 AB 20\n47 0F 3C 48\nD0 6C C5 D8\nE4 CD BF 18\n81 5F 38 58" }, - /* 42*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "Warning 760: Converted to Shift JIS but no ECI specified\nFE 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" }, - /* 43*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, - /* 44*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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" }, - /* 45*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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" }, - /* 46*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, -1, -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" }, - /* 47*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "Warning 760: Converted to Shift JIS but no ECI specified\nFE 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" }, - /* 48*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 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" }, - /* 49*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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 80\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\n03 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" }, - /* 50*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 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" }, - /* 51*/ { BARCODE_TELEPEN, "ABC\020123", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -1, 0, -1, -1, -1, -1, NULL, -1, -1, 0, 1, "AB A8 BB B8 E3 B8 AE EA EE BA EA BA E2 22 BA B8 EA 2A" }, - /* 52*/ { BARCODE_TELEPEN_NUM, "123\020ABC", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -1, 0, -1, -1, -1, -1, NULL, -1, -1, 0, 1, "AA E8 EA BA E2 22 EE BA BB B8 E3 B8 AE EA BA B8 E8 AA" }, + /* 16*/ { BARCODE_PDF417, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, 3, -1, 0, -1, "FF 54 75 70 3D 4F 1E AF 0A 73 86 82 C3 A9 C1 FD 14 8\nFF 54 7A 84 39 76 1F 6A 0F D2 E7 26 0B EA C1 FD 14 8\nFF 54 6A 7C 20 C5 D0 CD E8 76 E6 1D 72 A1 E1 FD 14 8" }, + /* 17*/ { BARCODE_CODE16K, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, 3, -1, 0, -1, "E5 73 6B 9D D3 BB 94 EE 34\nCD 72 EE 74 BD 97 B2 F6 64\nD9 2F 65 EC BD BC B4 8E 4C" }, + /* 18*/ { BARCODE_CODE49, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, 3, -1, 0, -1, "BF 6C A7 B0 A1 10 B2 C1 BC\nB3 CB AB BF 33 CB AE 41 BC\nB3 CB BA 0B AA 38 34 7B BC" }, + /* 19*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "B2 D6 96 CA B5 6D 64" }, + /* 20*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "B2 D6 96 CA B5 6D 64" }, + /* 21*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 1, "B2 D6 96 CA B5 64" }, + /* 22*/ { BARCODE_CODE11, "123", NULL, "456", NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2" }, + /* 23*/ { BARCODE_CODE11, "123", "456", "789", "012", -1, -1, 0, -1, -1, -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" }, + /* 24*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, 0, 0, -1, "FF 54 7A BC 3A 9C 1D 5C 0F E8 A4\nFF 54 7E AE 3C 11 5F AB 8F E8 A4\nFF 54 6A F8 29 9F 1D 5F 8F E8 A4\nFF 54 57 9E 37 BA 1A F7 CF E8 A4\nFF 54 75 CC 36 F0 5D 73 0F E8 A4" }, + /* 25*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, + /* 26*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, READER_INIT, 0, -1, -1, -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" }, + /* 27*/ { BARCODE_DATAMATRIX, "ABCDEFGH", NULL, NULL, NULL, FAST_MODE, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nA6 8C\nB2 F0\n98 B4\nB9 A8\nB8 CC\nF0 78\nA0 3C\n99 70\n85 1C\nDA B0\nE5 94\nA7 50\nFF FC" }, + /* 28*/ { BARCODE_DATAMATRIX, "ABCDEFGH", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\n80 04\n82 60\nC5 24\n98 A8\nA3 9C\nCB B8\nAF DC\n86 58\nF6 44\nAC 18\n90 54\nCF 30\nFF FC" }, + /* 29*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\n80 09 F9 BD\n82 4A E2 58\nC5 CD C9 A5\nD8 5C A5 FC\nE0 35 88 69\nCC FC B3 E6\nFF FF FF FF" }, + /* 30*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA\n80 25\n82 24\nC5 5D\n98 90\nA4 C7\nC8 A6\nB9 E9\n8E 02\nDE 91\nCD 6C\nA0 BB\n85 80\n98 2D\nE4 CA\nFF FF" }, + /* 31*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA A8\nBA 5A 44\n8B 4D 28\nBF 77 64\n97 85 50\nBA D8 AC\nCD ED B8\nD4 B5 2C\nD1 A8 00\n81 FB 2C\nE4 75 78\n96 E8 2C\nF3 75 78\nEE 1D 04\nCA BA 98\nB1 8F B4\nA0 4F 00\nE4 A7 74\nF1 D3 90\nEF E1 BC\n91 10 38\nFF FF FC" }, + /* 32*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA AA AA AA AA\nBA 03 BA 7D E5 31 B0 0D\n8B 6A 93 B6 E0 0A B8 3C\nBF 1D EA A7 EB ED A1 FB\n96 66 86 B6 C9 AE 92 40\nBF 65 E7 95 BC B7 FA E3\nCC 7C 90 CC D1 24 AB 5A\nFF FF FF FF FF FF FF FF" }, + /* 33*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "Warning 157: Previous '--dmre' overwritten by '--square'\nAA AA A8\nBA 5A 44\n8B 4D 28\nBF 77 64\n97 85 50\nBA D8 AC\nCD ED B8\nD4 B5 2C\nD1 A8 00\n81 FB 2C\nE4 75 78\n96 E8 2C\nF3 75 78\nEE 1D 04\nCA BA 98\nB1 8F B4\nA0 4F 00\nE4 A7 74\nF1 D3 90\nEF E1 BC\n91 10 38\nFF FF FC" }, + /* 34*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, -1, 0, -1, -1, -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" }, + /* 35*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, GS1_GS_SEPARATOR, 0, -1, -1, -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" }, + /* 36*/ { BARCODE_DATAMATRIX, "[9\\x31]12[92]34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE, GS1_GS_SEPARATOR, 0, -1, -1, -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" }, + /* 37*/ { BARCODE_DATAMATRIX, "(9\\x31)12(92)34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, GS1_GS_SEPARATOR, 0, -1, -1, -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" }, + /* 38*/ { BARCODE_DATAMATRIX, "abc", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA 8\nB3 C\nC6 0\nBA C\nBD 0\nB4 C\nDC 0\nEB C\nD1 8\nFF C" }, + /* 39*/ { BARCODE_DATAMATRIX, "abc", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\n8B F\nD4 C\nC2 7\n9E C\nCF 3\n8E 8\nBB F\n86 2\n95 D\nCB A\nFF F" }, + /* 40*/ { BARCODE_DATAMATRIX, "abc", NULL, NULL, NULL, -1, -1, 0, -1, -1, 1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\n8C F\n9E 4\nC5 7\nA9 6\n9F F\n97 0\nFA 9\nAA C\nDD D\nD2 2\nFF F" }, + /* 41*/ { BARCODE_DATAMATRIX, "abc", NULL, NULL, NULL, -1, -1, 0, -1, 0, 1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "Warning 161: Previous '--dmb256' overwritten by '--dmc40'\nAA A\n8C F\n9E 4\nC5 7\nA9 6\n9F F\n97 0\nFA 9\nAA C\nDD D\nD2 2\nFF F" }, + /* 42*/ { BARCODE_DATAMATRIX, "A\\^1BC\\^^1DEF", NULL, NULL, NULL, EXTRA_ESCAPE_MODE, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\nE0 B9 88 59\nD0 08 A3 14\n8D 9D DD DB\n8E 3E E5 E8\nDF 3B A5 A1\nB6 20 A6 02\nFF FF FF FF" }, + /* 43*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, + /* 44*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, + /* 45*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, 2, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, -1, 0, -1, "Warning 115: Primary data string too long (127 character maximum), **TRUNCATING**\nError 449: Input length 127 wrong (linear component)" }, + /* 46*/ { BARCODE_MAXICODE, "abc", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, "1234567", -1, -1, 0, -1, "C0 55 55 5C\nC0 00 00 08\nE7 AA AA A0\n55 55 55 58\n00 00 00 0C\nAA AA AA A8\n55 55 55 50\n00 00 00 08\nAA AA AA A4\n55 B1 35 50\n00 90 08 0C\nAA C0 52 A0\n54 40 05 58\n01 00 08 00\nAA C0 0A A0\n55 00 01 58\n02 80 08 08\nAB 80 1E A8\n54 00 05 54\n03 80 0C 00\nA8 00 02 AC\n55 40 25 50\n00 60 40 0C\nAA 60 66 A0\n55 55 53 B0\n00 00 07 A0\nAA AA AE 0C\nA3 CE E2 C8\nB3 F4 AB 20\n47 0F 3C 48\nD0 6C C5 D8\nE4 CD BF 18\n81 5F 38 58" }, + /* 47*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "Warning 760: Converted to Shift JIS but no ECI specified\nFE 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" }, + /* 48*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, -1, -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" }, + /* 49*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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" }, + /* 50*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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" }, + /* 51*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, -1, -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" }, + /* 52*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "Warning 760: Converted to Shift JIS but no ECI specified\nFE 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" }, + /* 53*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 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" }, + /* 54*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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 80\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\n03 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" }, + /* 55*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -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 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 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" }, + /* 56*/ { BARCODE_TELEPEN, "ABC\020123", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -1, 0, -1, -1, -1, -1, NULL, -1, -1, 0, 1, "AB A8 BB B8 E3 B8 AE EA EE BA EA BA E2 22 BA B8 EA 2A" }, + /* 57*/ { BARCODE_TELEPEN_NUM, "123\020ABC", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, -1, -1, 0, -1, -1, -1, -1, NULL, -1, -1, 0, 1, "AA E8 EA BA E2 22 EE BA BB B8 E3 B8 AE EA BA B8 E8 AA" }, }; int data_size = ARRAY_SIZE(data); int i; @@ -413,13 +419,16 @@ static void test_dump_args(const testCtx *const p_ctx) { strcat(cmd, " 2>&1"); assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); - assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + 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(testUtilRemove(input1_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input1_filename, errno, strerror(errno)); + assert_zero(testUtilRemove(input1_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, input1_filename, errno, strerror(errno)); } if (have_input2) { - assert_zero(testUtilRemove(input2_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input2_filename, errno, strerror(errno)); + assert_zero(testUtilRemove(input2_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, input2_filename, errno, strerror(errno)); } } @@ -432,30 +441,35 @@ static void test_dump_segs(const testCtx *const p_ctx) { struct item { int b; + int batch; const char *data; const char *data_seg1; const char *data_seg2; int eci; int eci_seg1; int eci_seg2; + int num_seg2; const char *expected; }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ struct item data[] = { - /* 0*/ { -1, "123", NULL, NULL, -1, -1, -1, "D3 96 72 F7 65 C9 61 8E B" }, - /* 1*/ { -1, "123", NULL, NULL, -1, 3, -1, "Error 166: Invalid segment argument, expect \"ECI,DATA\"" }, - /* 2*/ { -1, "123", "456", NULL, -1, -1, -1, "Error 166: Invalid segment ECI (digits only)" }, - /* 3*/ { -1, "123", "456", NULL, -1, 1000000, -1, "Error 166: Segment ECI code '1000000' out of range (0 to 999999)" }, - /* 4*/ { -1, "123", "456", NULL, -1, 3, -1, "Error 775: Symbology does not support multiple segments" }, - /* 5*/ { BARCODE_AZTEC, "123", "456", NULL, -1, 3, -1, "2B 7A\nC7 02\nF0 6E\n3F FE\n70 1C\nB7 D6\nB4 58\n15 54\n94 56\nB7 DC\n30 1A\n1F FC\n4C 66\n22 DA\n1E C6" }, - /* 6*/ { BARCODE_AZTEC, "123", NULL, "789", -1, -1, 3, "Error 172: Segments must be consecutive - segment 1 missing" }, + /* 0*/ { -1, 0, "123", NULL, NULL, -1, -1, -1, -1, "D3 96 72 F7 65 C9 61 8E B" }, + /* 1*/ { -1, 0, "123", NULL, NULL, -1, 3, -1, -1, "Error 166: Invalid segment argument, expect \"ECI,DATA\"" }, + /* 2*/ { -1, 0, "123", "456", NULL, -1, -1, -1, -1, "Error 166: Invalid segment ECI (digits only)" }, + /* 3*/ { -1, 0, "123", "456", NULL, -1, 1000000, -1, -1, "Error 166: Segment ECI code '1000000' out of range (0 to 999999)" }, + /* 4*/ { -1, 0, "123", "456", NULL, -1, 3, -1, -1, "Error 775: Symbology does not support multiple segments" }, + /* 5*/ { BARCODE_AZTEC, 0, "123", "456", NULL, -1, 3, -1, -1, "2B 7A\nC7 02\nF0 6E\n3F FE\n70 1C\nB7 D6\nB4 58\n15 54\n94 56\nB7 DC\n30 1A\n1F FC\n4C 66\n22 DA\n1E C6" }, + /* 6*/ { BARCODE_AZTEC, 0, "123", NULL, "789", -1, -1, 3, -1, "Error 172: Segments must be consecutive - segment 1 missing" }, + /* 7*/ { BARCODE_AZTEC, 1, "123", "456", NULL, -1, 3, -1, -1, "Warning 122: Can't define data in batch mode, **IGNORED** '123'\nWarning 165: Can't define segments in batch mode, **IGNORED** '3,456'\nWarning 124: No data received, no symbol generated" }, + /* 8*/ { BARCODE_AZTEC, 0, "123", "456", "789", -1, 3, 4, 1, "Error 164: Duplicate segment 1" }, }; int data_size = ARRAY_SIZE(data); int i; char cmd[4096]; char buf[4096]; + char seg2_buf[16]; testStart("test_dump_segs"); @@ -470,6 +484,9 @@ static void test_dump_segs(const testCtx *const p_ctx) { arg_int(cmd, "-b ", data[i].b); + if (data[i].batch) { + strcat(cmd, " --batch"); + } if (data[i].data && data[i].data[0]) { arg_data(cmd, "-d ", data[i].data); } @@ -483,16 +500,18 @@ static void test_dump_segs(const testCtx *const p_ctx) { arg_seg(cmd, "--seg1=", NULL, data[i].eci_seg1); } + sprintf(seg2_buf, "--seg%d=", data[i].num_seg2 != -1 ? data[i].num_seg2 : 2); if (data[i].data_seg2 && data[i].data_seg2[0]) { - arg_seg(cmd, "--seg2=", data[i].data_seg2, data[i].eci_seg2); + arg_seg(cmd, seg2_buf, data[i].data_seg2, data[i].eci_seg2); } else if (data[i].eci_seg2 >= 0) { - arg_seg(cmd, "--seg2=", NULL, data[i].eci_seg2); + arg_seg(cmd, seg2_buf, NULL, data[i].eci_seg2); } strcat(cmd, " 2>&1"); assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); - assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); } testFinish(); @@ -501,15 +520,33 @@ static void test_dump_segs(const testCtx *const p_ctx) { static void test_input(const testCtx *const p_ctx) { int debug = p_ctx->debug; -#define TEST_INPUT_LONG "test_67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +#define TEST_INPUT_LONG "test_67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" /* 250 chars */ -#define TEST_MIRRORED_DIR_LONG "testdir_9012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/" -#define TEST_MIRRORED_DIR_TOO_LONG "testdir_901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901/" +#define TEST_MIRRORED_DIR_LONG "testdir_9012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/" /* 220 chars */ +#define TEST_MIRRORED_DIR_TOO_LONG "testdir_901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901/" /* 222 chars */ #ifndef _WIN32 #define TEST_INPUT_AMPERSAND_EXPECTED "***1.gif\000***2.gif" +#define TEST_INPUT_BSLASH "\\" +#define TEST_INPUT_EXCLAIM "!" +#define TEST_INPUT_DQUOTE "\"" +#define TEST_INPUT_ASTERISK "*" +#define TEST_INPUT_COLON ":" +#define TEST_INPUT_LANGLE "<" +#define TEST_INPUT_RANGLE ">" +#define TEST_INPUT_QUESTION "?" +#define TEST_INPUT_PIPE "|" #else #define TEST_INPUT_AMPERSAND_EXPECTED "+++1.gif\000+++2.gif" +#define TEST_INPUT_BSLASH "_" +#define TEST_INPUT_EXCLAIM "_" +#define TEST_INPUT_DQUOTE "_" +#define TEST_INPUT_ASTERISK "_" +#define TEST_INPUT_COLON "_" +#define TEST_INPUT_LANGLE "_" +#define TEST_INPUT_RANGLE "_" +#define TEST_INPUT_QUESTION "_" +#define TEST_INPUT_PIPE "_" #endif struct item { @@ -517,6 +554,7 @@ static void test_input(const testCtx *const p_ctx) { int batch; int input_mode; int mirror; + const char *opt; const char *filetype; const char *input_filename; const char *input; @@ -525,57 +563,69 @@ static void test_input(const testCtx *const p_ctx) { int num_expected; const char *expected; }; - /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ struct item data[] = { - /* 0*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "123\n456\n", "", 2, "00001.gif\00000002.gif" }, - /* 1*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", "~~~.gif", 10, "001.gif\000002.gif\000003.gif\000004.gif\000005.gif\000006.gif\000007.gif\000008.gif\000009.gif\000010.gif" }, - /* 2*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "123\n456\n", "@@@@.gif", 2, TEST_INPUT_AMPERSAND_EXPECTED }, - /* 3*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "123\n456\n789\n", "#####.gif", 3, " 1.gif\000 2.gif\000 3.gif" }, - /* 4*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "123\n456\n", "test_batch~.gif", 2, "test_batch1.gif\000test_batch2.gif" }, - /* 5*/ { BARCODE_CODE128, 1, -1, 1, "gif", NULL, "123\n456\n7890123456789\n", NULL, 3, "123.gif\000456.gif\0007890123456789.gif" }, - /* 6*/ { BARCODE_CODE128, 1, -1, 1, "gif", NULL, "123\n456\n7890123456789\n", "test_input_dir/", 3, "test_input_dir/123.gif\000test_input_dir/456.gif\000test_input_dir/7890123456789.gif" }, - /* 7*/ { BARCODE_CODE128, 1, -1, 1, "svg", NULL, "123\n456\n7890123456789\n", NULL, 3, "123.svg\000456.svg\0007890123456789.svg" }, - /* 8*/ { BARCODE_CODE128, 1, -1, 1, "gif", NULL, "123\n456\n7890123456789\nA\\xA0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_xA0B.gif" }, - /* 9*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, "gif", NULL, "123\n456\n7890123456789\nA\\xA0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_B.gif" }, - /* 10*/ { BARCODE_CODE128, 1, -1, 1, "gif", NULL, "123\n456\n7890123456789\nA\\u00A0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_u00A0B.gif" }, - /* 11*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, "gif", NULL, "123\n456\n7890123456789\nA\\u00A0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_B.gif" }, - /* 12*/ { BARCODE_CODE128, 1, -1, 1, "gif", NULL, "1!2\"3*\n/:45<6>\n?7890\\\\12345|6789\177\nA\\U0000A0B\n", NULL, 4, "1_2_3_.gif\000__45_6_.gif\000_7890__12345_6789_.gif\000A_U0000A0B.gif" }, - /* 13*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, "gif", NULL, "!\"*\n/:45<6>\n?7890\\\\12345|6789\177\nA\\U0000A0B\n", NULL, 4, "___.gif\000__45_6_.gif\000_7890_12345_6789_.gif\000A_B.gif" }, - /* 14*/ { BARCODE_CODE128, 1, -1, 1, "gif", NULL, "1\\d123*9\n\\o1234:5\n#$%&'()+,-.;=@[]^`{}\n", NULL, 3, "1_d123_9.gif\000_o1234_5.gif\000#$%&'()+,-.;=@[]^`{}.gif" }, - /* 15*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, "gif", NULL, "1\\d123*2\n\\o1234:5\n#$%&'()+,-.;=@[]^`{}\n", NULL, 3, "1__2.gif\000_4_5.gif\000#$%&'()+,-.;=@[]^`{}.gif" }, - /* 16*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "\n", "test_batch.gif", 0, NULL }, - /* 17*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "123\n456\n", TEST_INPUT_LONG "~.gif", 2, TEST_INPUT_LONG "1.gif\000" TEST_INPUT_LONG "2.gif" }, - /* 18*/ { BARCODE_CODE128, 0, -1, 0, "svg", NULL, "123", TEST_INPUT_LONG "1.gif", 1, TEST_INPUT_LONG "1.svg" }, - /* 19*/ { BARCODE_CODE128, 1, -1, 0, "svg", NULL, "123\n", TEST_INPUT_LONG "1.gif", 1, TEST_INPUT_LONG "1.svg" }, - /* 20*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "123\n", "test_batch.jpeg", 1, "test_batch.gif" }, - /* 21*/ { BARCODE_CODE128, 1, -1, 0, "gif", NULL, "123\n", "test_batch.jpg", 1, "test_batch.gif" }, - /* 22*/ { BARCODE_CODE128, 1, -1, 0, "emf", NULL, "123\n", "test_batch.jpegg", 1, "test_batch.jpegg.emf" }, - /* 23*/ { BARCODE_CODE128, 1, -1, 0, "emf", NULL, "123\n", "test_batch.jpg", 1, "test_batch.emf" }, - /* 24*/ { BARCODE_CODE128, 1, -1, 0, "eps", NULL, "123\n", "test_batch.ps", 1, "test_batch.eps" }, - /* 25*/ { BARCODE_CODE128, 1, -1, 1, "gif", NULL, "1234567890123456789012345678901\n1234567890123456789012345678902\n", TEST_MIRRORED_DIR_LONG, 2, TEST_MIRRORED_DIR_LONG "1234567890123456789012345678901.gif\000" TEST_MIRRORED_DIR_LONG "1234567890123456789012345678902.gif" }, - /* 26*/ { BARCODE_CODE128, 1, -1, 1, "gif", NULL, "123\n456\n", TEST_MIRRORED_DIR_TOO_LONG, 2, "123.gif\000456.gif" }, - /* 27*/ { BARCODE_CODE128, 1, -1, 0, "gif", "testé_input.txt", "123\n456\n", "", 2, "00001.gif\00000002.gif" }, - /* 28*/ { BARCODE_CODE128, 1, -1, 0, "gif", "testก_input.txt", "123\n456\n", "test_input_δir/testé~~~.gif", 2, "test_input_δir/testé001.gif\000test_input_δir/testé002.gif" }, + /* 0*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "123\n456\n", "", 2, "00001.gif\00000002.gif" }, + /* 1*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", "~~~.gif", 10, "001.gif\000002.gif\000003.gif\000004.gif\000005.gif\000006.gif\000007.gif\000008.gif\000009.gif\000010.gif" }, + /* 2*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "123\n456\n", "@@@@.gif", 2, TEST_INPUT_AMPERSAND_EXPECTED }, + /* 3*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "123\n456\n789\n", "#####.gif", 3, " 1.gif\000 2.gif\000 3.gif" }, + /* 4*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "123\n456\n", "test_batch~.gif", 2, "test_batch1.gif\000test_batch2.gif" }, + /* 5*/ { BARCODE_CODE128, 1, -1, 1, NULL, "gif", NULL, "123\n456\n7890123456789\n", NULL, 3, "123.gif\000456.gif\0007890123456789.gif" }, + /* 6*/ { BARCODE_CODE128, 1, -1, 1, NULL, "gif", NULL, "123\n456\n7890123456789\n", "test_input_dir/", 3, "test_input_dir/123.gif\000test_input_dir/456.gif\000test_input_dir/7890123456789.gif" }, + /* 7*/ { BARCODE_CODE128, 1, -1, 1, NULL, "svg", NULL, "123\n456\n7890123456789\n", NULL, 3, "123.svg\000456.svg\0007890123456789.svg" }, + /* 8*/ { BARCODE_CODE128, 1, -1, 1, NULL, "gif", NULL, "123\n456\n7890123456789\nA\\xA0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A" TEST_INPUT_BSLASH "xA0B.gif" }, + /* 9*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, NULL, "gif", NULL, "123\n456\n7890123456789\nA\\xA0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_B.gif" }, + /* 10*/ { BARCODE_CODE128, 1, -1, 1, NULL, "gif", NULL, "1!2\"3*\n/:45<6>\n?7890\\\\12345|6789\177\nA\\U0000A0B\n", NULL, 4, "1" TEST_INPUT_EXCLAIM "2" TEST_INPUT_DQUOTE "3" TEST_INPUT_ASTERISK ".gif\000_" TEST_INPUT_COLON "45" TEST_INPUT_LANGLE "6" TEST_INPUT_RANGLE ".gif\000" TEST_INPUT_QUESTION "7890" TEST_INPUT_BSLASH TEST_INPUT_BSLASH "12345" TEST_INPUT_PIPE "6789_.gif\000A" TEST_INPUT_BSLASH "U0000A0B.gif" }, + /* 11*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, NULL, "gif", NULL, "!\"*\n/:45<6>\n?7890\\\\12345|6789\177\nA\\U0000A0B\n", NULL, 4, TEST_INPUT_EXCLAIM TEST_INPUT_DQUOTE TEST_INPUT_ASTERISK ".gif\000_" TEST_INPUT_COLON "45" TEST_INPUT_LANGLE "6" TEST_INPUT_RANGLE ".gif\000" TEST_INPUT_QUESTION "7890_12345" TEST_INPUT_PIPE "6789_.gif\000A_B.gif" }, + /* 12*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "\n", "test_batch.gif", 0, NULL }, + /* 13*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "123\n456\n", TEST_INPUT_LONG "~.gif", 2, TEST_INPUT_LONG "1.gif\000" TEST_INPUT_LONG "2.gif" }, + /* 14*/ { BARCODE_CODE128, 0, -1, 0, NULL, "svg", NULL, "123", TEST_INPUT_LONG "1.gif", 1, TEST_INPUT_LONG "1.svg" }, + /* 15*/ { BARCODE_CODE128, 1, -1, 0, NULL, "svg", NULL, "123\n", TEST_INPUT_LONG "1.gif", 1, TEST_INPUT_LONG "1.svg" }, + /* 16*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "123\n", "test_batch.jpeg", 1, "test_batch.gif" }, + /* 17*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", NULL, "123\n", "test_batch.jpg", 1, "test_batch.gif" }, + /* 18*/ { BARCODE_CODE128, 1, -1, 0, NULL, "emf", NULL, "123\n", "test_batch.jpegg", 1, "test_batch.jpegg.emf" }, + /* 19*/ { BARCODE_CODE128, 1, -1, 0, NULL, "emf", NULL, "123\n", "test_batch.jpg", 1, "test_batch.emf" }, + /* 20*/ { BARCODE_CODE128, 1, -1, 0, NULL, "eps", NULL, "123\n", "test_batch.ps", 1, "test_batch.eps" }, + /* 21*/ { BARCODE_CODE128, 1, -1, 1, NULL, "gif", NULL, "1234567890123456789012345678901\n1234567890123456789012345678902\n", TEST_MIRRORED_DIR_LONG, 2, TEST_MIRRORED_DIR_LONG "1234567890123456789012345678901.gif\000" TEST_MIRRORED_DIR_LONG "1234567890123456789012345678902.gif" }, + /* 22*/ { BARCODE_CODE128, 1, -1, 1, NULL, "gif", NULL, "123\n456\n", TEST_MIRRORED_DIR_TOO_LONG, 2, "123.gif\000456.gif" }, + /* 23*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", "testé_input.txt", "123\n456\n", "", 2, "00001.gif\00000002.gif" }, + /* 24*/ { BARCODE_CODE128, 1, -1, 0, NULL, "gif", "testก_input.txt", "123\n456\n", "test_input_δir/testé~~~.gif", 2, "test_input_δir/testé001.gif\000test_input_δir/testé002.gif" }, + /* 25*/ { BARCODE_CODE128, 0, -1, 1, NULL, NULL, "", "123", "out", 1, "123.XXX" }, + /* 26*/ { BARCODE_CODE128, 0, -1, 1, NULL, NULL, "", "123", "out.jpg", 1, "123.XXX" }, + /* 27*/ { BARCODE_CODE128, 0, -1, 1, NULL, "svg", "", "123", NULL, 1, "123.svg" }, + /* 28*/ { BARCODE_CODE128, 0, -1, 1, NULL, "svg", "", "!é?", NULL, 1, TEST_INPUT_EXCLAIM "é" TEST_INPUT_QUESTION ".svg" }, + /* 29*/ { BARCODE_CODE128, 1, -1, 1, " --scale=0.4", "gif", NULL, "123\n", NULL, 1, "123.gif" }, + /* 30*/ { BARCODE_QRCODE, 0, -1, 1, NULL, "svg", "", TEST_INPUT_LONG "1", NULL, 1, TEST_INPUT_LONG "1.svg" }, + /* 31*/ { BARCODE_QRCODE, 0, -1, 1, NULL, "svg", "", TEST_INPUT_LONG "12", NULL, 1, TEST_INPUT_LONG "1.svg" }, }; int data_size = ARRAY_SIZE(data); int i; char cmd[4096]; - char buf[4096]; + char buf[8192]; const char *input_filename; const char *outfile; + char outfile_buf[256] = {0}; testStart("test_input"); for (i = 0; i < data_size; i++) { int j; const char *slash; + int expected_len; if (testContinue(p_ctx, i)) continue; #ifdef _WIN32 if (data[i].outfile && (int) strlen(data[i].outfile) > 50) { - if (debug & ZINT_DEBUG_TEST_PRINT) printf("%d not Windows compatible (outfile length %d > 50)\n", i, (int) strlen(data[i].outfile)); + if (debug & ZINT_DEBUG_TEST_PRINT) { + printf("%d not Windows compatible (outfile length %d > 50)\n", i, (int) strlen(data[i].outfile)); + } + continue; + } + if (!data[i].outfile && data[i].num_expected == 1 && strlen(data[i].expected) > 50) { + if (debug & ZINT_DEBUG_TEST_PRINT) { + printf("%d not Windows compatible (expected length %d > 50)\n", i, (int) strlen(data[i].expected)); + } continue; } #endif @@ -589,35 +639,56 @@ static void test_input(const testCtx *const p_ctx) { arg_bool(cmd, "--batch", data[i].batch); arg_input_mode(cmd, data[i].input_mode); arg_bool(cmd, "--mirror", data[i].mirror); + if (data[i].opt) { + strcat(cmd, data[i].opt); + } arg_data(cmd, "--filetype=", data[i].filetype); input_filename = data[i].input_filename ? data[i].input_filename : "test_input.txt"; - arg_input(cmd, input_filename, data[i].input); + if (*input_filename) { + arg_input(cmd, input_filename, data[i].input); + } else { + arg_data(cmd, "-d ", data[i].input); + } arg_data(cmd, "-o ", data[i].outfile); if (!data[i].expected || (data[i].batch && data[i].mirror && data[i].outfile && data[i].outfile[0] - && strcmp(data[i].outfile, TEST_MIRRORED_DIR_LONG) == 0)) { + && strcmp(data[i].outfile, TEST_MIRRORED_DIR_LONG) == 0) + || (data[i].opt && strncmp(data[i].opt, " --scale", 8) == 0)) { printf("++++ Following %s expected, ignore: ", data[i].expected ? "warning" : "error"); fflush(stdout); } assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); outfile = data[i].expected; + if (data[i].num_expected == 1 && (expected_len = (int) strlen(outfile)) > 3 + && strcmp(outfile + expected_len - 3, "XXX") == 0) { + strcpy(outfile_buf, outfile); + strcpy(outfile_buf + expected_len - 3, ZBarcode_NoPng() ? "gif" : "png"); + outfile = outfile_buf; + } for (j = 0; j < data[i].num_expected; j++) { assert_nonzero(testUtilExists(outfile), "i:%d j:%d testUtilExists(%s) != 1\n", i, j, outfile); - assert_zero(testUtilRemove(outfile), "i:%d j:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, j, outfile, errno, strerror(errno)); + assert_zero(testUtilRemove(outfile), "i:%d j:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, j, outfile, errno, strerror(errno)); outfile += strlen(outfile) + 1; } - assert_zero(testUtilRemove(input_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input_filename, errno, strerror(errno)); + if (*input_filename) { + assert_zero(testUtilRemove(input_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, input_filename, errno, strerror(errno)); + } /* Remove directory if any */ - if (data[i].outfile && (slash = strrchr(data[i].outfile, '/')) != NULL && strcmp(data[i].outfile, TEST_MIRRORED_DIR_TOO_LONG) != 0) { + if (data[i].outfile && (slash = strrchr(data[i].outfile, '/')) != NULL + && strcmp(data[i].outfile, TEST_MIRRORED_DIR_TOO_LONG) != 0) { char dirpath[256]; - assert_nonzero((size_t) (slash - data[i].outfile) < sizeof(dirpath), "i: %d output directory too long\n", i); + assert_nonzero((size_t) (slash - data[i].outfile) < sizeof(dirpath), "i: %d output directory too long\n", + i); strncpy(dirpath, data[i].outfile, slash - data[i].outfile); dirpath[slash - data[i].outfile] = '\0'; - assert_zero(testUtilRmDir(dirpath), "i:%d testUtilRmDir(%s) != 0 (%d: %s)\n", i, dirpath, errno, strerror(errno)); + assert_zero(testUtilRmDir(dirpath), "i:%d testUtilRmDir(%s) != 0 (%d: %s)\n", + i, dirpath, errno, strerror(errno)); } } @@ -663,7 +734,8 @@ static void test_stdin_input(const testCtx *const p_ctx) { assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); assert_nonzero(testUtilExists(data[i].outfile), "i:%d testUtilExists(%s) != 1\n", i, data[i].outfile); - assert_zero(testUtilRemove(data[i].outfile), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, data[i].outfile, errno, strerror(errno)); + assert_zero(testUtilRemove(data[i].outfile), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, data[i].outfile, errno, strerror(errno)); } testFinish(); @@ -678,14 +750,19 @@ static void test_batch_input(const testCtx *const p_ctx) { const char *data; const char *input; const char *input2; + const char *opt; const char *expected; }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ struct item data[] = { - /* 0*/ { BARCODE_CODE128, "123", NULL, NULL, "Warning 122: Can't define data in batch mode, **IGNORED** '123'\nWarning 124: No data received, no symbol generated" }, - /* 1*/ { BARCODE_CODE128, "123", "123\n456\n", NULL, "Warning 122: Can't define data in batch mode, **IGNORED** '123'\nD3 96 72 F7 65 C9 61 8E B\nD3 97 62 F7 67 49 19 8E B" }, - /* 2*/ { BARCODE_CODE128, NULL, "123\n456\n", "789\n", "Warning 143: Can only define one input file in batch mode, **IGNORED** 'test_batch_input2.txt'\nD3 96 72 F7 65 C9 61 8E B\nD3 97 62 F7 67 49 19 8E B" }, + /* 0*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, "Warning 122: Can't define data in batch mode, **IGNORED** '123'\nWarning 124: No data received, no symbol generated" }, + /* 1*/ { BARCODE_CODE128, "123", "123\n456\n", NULL, NULL, "Warning 122: Can't define data in batch mode, **IGNORED** '123'\nD3 96 72 F7 65 C9 61 8E B\nD3 97 62 F7 67 49 19 8E B" }, + /* 2*/ { BARCODE_CODE128, NULL, "123\n456\n", "789\n", NULL, "Warning 143: Can only define one input file in batch mode, **IGNORED** 'test_batch_input2.txt'\nD3 96 72 F7 65 C9 61 8E B\nD3 97 62 F7 67 49 19 8E B" }, + /* 3*/ { BARCODE_CODE128, NULL, "123\r\n456\n", NULL, NULL, "D3 96 72 F7 65 C9 61 8E B\nD3 97 62 F7 67 49 19 8E B" }, + /* 4*/ { BARCODE_CODE128, NULL, "123\r\n456\r\n", NULL, NULL, "D3 96 72 F7 65 C9 61 8E B\nD3 97 62 F7 67 49 19 8E B" }, + /* 5*/ { BARCODE_CODE128, NULL, "123\n456", NULL, NULL, "D3 96 72 F7 65 C9 61 8E B\nWarning 104: No newline at end of input file, last line **IGNORED**" }, + /* 6*/ { BARCODE_EAN13, NULL, "123\r\n456\n", NULL, " --scalexdimdp", "A3 46 8D 1A 34 6A B9 72 CD B2 15 0A\nA3 46 8D 1A 34 6A B9 72 B9 3A 84 EA" }, }; int data_size = ARRAY_SIZE(data); int i; @@ -713,6 +790,9 @@ static void test_batch_input(const testCtx *const p_ctx) { arg_data(cmd, "-d ", data[i].data); have_input1 = arg_input(cmd, input1_filename, data[i].input); have_input2 = arg_input(cmd, input2_filename, data[i].input2); + if (data[i].opt) { + strcat(cmd, data[i].opt); + } strcat(cmd, " 2>&1"); @@ -720,10 +800,12 @@ static void test_batch_input(const testCtx *const p_ctx) { assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s)\n", i, buf, data[i].expected); if (have_input1) { - assert_zero(testUtilRemove(input1_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input1_filename, errno, strerror(errno)); + assert_zero(testUtilRemove(input1_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, input1_filename, errno, strerror(errno)); } if (have_input2) { - assert_zero(testUtilRemove(input2_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input2_filename, errno, strerror(errno)); + assert_zero(testUtilRemove(input2_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, input2_filename, errno, strerror(errno)); } } @@ -738,20 +820,23 @@ static void test_batch_large(const testCtx *const p_ctx) { int mirror; const char *pattern; int length; + int noeol; const char *expected; }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ struct item data[] = { - /* 0*/ { BARCODE_HANXIN, 0, "1", 7827, "00001.gif" }, - /* 1*/ { BARCODE_HANXIN, 1, "1", 7827, "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.gif" }, - /* 2*/ { BARCODE_HANXIN, 0, "1", 7828, NULL }, + /* 0*/ { BARCODE_HANXIN, 0, "1", 7827, 0, "00001.gif" }, + /* 1*/ { BARCODE_HANXIN, 1, "1", 7827, 0, "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.gif" }, + /* 2*/ { BARCODE_HANXIN, 0, "1", 7828, 0, NULL }, + /* 3*/ { BARCODE_HANXIN, 0, "1", ZINT_MAX_DATA_LEN, 0, NULL }, + /* 4*/ { BARCODE_HANXIN, 0, "1", ZINT_MAX_DATA_LEN + 1, 1, NULL }, }; int data_size = ARRAY_SIZE(data); int i; char cmd[16384]; - char data_buf[8192]; + char data_buf[ZINT_MAX_DATA_LEN + 4]; char buf[16384]; const char *input_filename = "test_batch_large.txt"; @@ -777,22 +862,31 @@ static void test_batch_large(const testCtx *const p_ctx) { arg_bool(cmd, "--mirror", data[i].mirror); testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length); - strcat(data_buf, "\n"); + if (!data[i].noeol) { + strcat(data_buf, "\n"); + } have_input = arg_input(cmd, input_filename, data_buf); if (!data[i].expected) { - printf("++++ Following error expected, ignore: "); + if (data[i].noeol) { + printf("++++ Following error and warning expected, ignore: "); + } else { + printf("++++ Following error expected, ignore: "); + } fflush(stdout); } assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); if (data[i].expected) { - assert_zero(testUtilRemove(data[i].expected), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, data[i].expected, errno, strerror(errno)); + assert_zero(testUtilRemove(data[i].expected), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, data[i].expected, errno, strerror(errno)); } else { - assert_zero(testUtilExists("out.gif"), "i:%d testUtilExists(out.gif) != 0 (%d: %s) (%s)\n", i, errno, strerror(errno), cmd); + assert_zero(testUtilExists("out.gif"), "i:%d testUtilExists(out.gif) != 0 (%d: %s) (%s)\n", + i, errno, strerror(errno), cmd); } - if (have_input) { - assert_zero(testUtilRemove(input_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input_filename, errno, strerror(errno)); + if (have_input && (p_ctx->index == -1 || data[i].expected)) { + assert_zero(testUtilRemove(input_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, input_filename, errno, strerror(errno)); } } @@ -831,45 +925,59 @@ static void test_checks(const testCtx *const p_ctx) { /* 0*/ { -2, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 139: Invalid add-on gap value (digits only)" }, /* 1*/ { 6, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Add-on gap '6' out of range (7 to 12), **IGNORED**" }, /* 2*/ { 13, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Add-on gap '13' out of range (7 to 12), **IGNORED**" }, - /* 3*/ { -1, -2, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 107: Invalid border width value (digits only)" }, - /* 4*/ { -1, 1001, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 108: Border width '1001' out of range (0 to 1000), **IGNORED**" }, - /* 5*/ { -1, -1, -1, -1, -5.1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 195: Text gap '-5.1' out of range (-5 to 10), **IGNORED**" }, - /* 6*/ { -1, -1, -1, -1, 10.01, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 195: Text gap '10.01' out of range (-5 to 10), **IGNORED**" }, - /* 7*/ { -1, -1, -1, 12345678, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 181: Invalid dot radius floating point (integer part must be 7 digits maximum)" }, - /* 8*/ { -1, -1, -1, 0.009, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 106: Invalid dot radius value (less than 0.01), **IGNORED**" }, - /* 9*/ { -1, -1, -2, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 131: Invalid columns value (digits only)" }, - /* 10*/ { -1, -1, 201, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 111: Number of columns '201' out of range (1 to 200), **IGNORED**" }, - /* 11*/ { -1, -1, -1, -1, -1, -2, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 138: Invalid ECI code (digits only)" }, - /* 12*/ { -1, -1, -1, -1, -1, 1000000, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 118: ECI code '1000000' out of range (0 to 999999), **IGNORED**" }, - /* 13*/ { -1, -1, -1, -1, -1, -1, "jpg", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'jpg' not supported, **IGNORED**" }, - /* 14*/ { -1, -1, -1, -1, -1, -1, "giff", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'giff' not supported, **IGNORED**" }, - /* 15*/ { -1, -1, -1, -1, -1, -1, "tiff", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, /* Allow "tiff" */ - /* 16*/ { -1, -1, -1, -1, -1, -1, NULL, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 183: Invalid symbol height floating point (negative value not permitted)" }, - /* 17*/ { -1, -1, -1, -1, -1, -1, NULL, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height '0' out of range (0.5 to 2000), **IGNORED**" }, - /* 18*/ { -1, -1, -1, -1, -1, -1, NULL, 2001, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height '2001' out of range (0.5 to 2000), **IGNORED**" }, - /* 19*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 182: Invalid guard bar descent floating point (negative value not permitted)" }, - /* 20*/ { -1, -1, -1, -1, -1, -1, NULL, -1, 50.1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 135: Guard bar descent '50.1' out of range (0 to 50), **IGNORED**" }, - /* 21*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 148: Invalid mask value (digits only)" }, - /* 22*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 147: Mask value '8' out of range (0 to 7), **IGNORED**" }, - /* 23*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 116: Mode value '7' out of range (0 to 6), **IGNORED**" }, - /* 24*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value (digits only)" }, - /* 25*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 137: Rotation value '45' out of range (0, 90, 180 or 270 only), **IGNORED**" }, - /* 26*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, "Error 132: Invalid rows value (digits only)" }, - /* 27*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, -1, -1, "Warning 112: Number of rows '91' out of range (1 to 90), **IGNORED**" }, - /* 28*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Error 184: Invalid scale floating point (negative value not permitted)" }, - /* 29*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 0.49, -1, -1, -1, -1, -1, -1, "Warning 146: Scaling less than 0.5 will be set to 0.5 for 'gif' output" }, - /* 30*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Error 149: Invalid Structured Carrier Message version value (digits only)" }, - /* 31*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, 100, -1, -1, -1, -1, -1, "Warning 150: Structured Carrier Message version '100' out of range (0 to 99), **IGNORED**" }, - /* 32*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, "Error 134: Invalid ECC value (digits only)" }, - /* 33*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, -1, "Warning 114: ECC level '9' out of range (0 to 8), **IGNORED**" }, - /* 34*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 128: Invalid separator value (digits only)" }, - /* 35*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, "Warning 127: Separator value '5' out of range (0 to 4), **IGNORED**" }, - /* 36*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 133: Invalid version value (digits only)" }, - /* 37*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1000, -1, -1, "Warning 113: Version value '1000' out of range (1 to 999), **IGNORED**" }, - /* 38*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 153: Invalid vertical whitespace value '-2' (digits only)" }, - /* 39*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1001, -1, "Warning 154: Vertical whitespace value '1001' out of range (0 to 1000), **IGNORED**" }, - /* 40*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid horizontal whitespace value '-2' (digits only)" }, - /* 41*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1001, "Warning 121: Horizontal whitespace value '1001' out of range (0 to 1000), **IGNORED**" }, + /* 3*/ { 12, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, + /* 4*/ { -1, -2, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 107: Invalid border width value (digits only)" }, + /* 5*/ { -1, 101, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 108: Border width '101' out of range (0 to 100), **IGNORED**" }, + /* 6*/ { -1, 100, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, + /* 7*/ { -1, -1, -1, -1, .12345678, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 194: Invalid text gap floating point (fractional part must be 7 digits maximum)" }, + /* 8*/ { -1, -1, -1, -1, -5.1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 195: Text gap '-5.1' out of range (-5 to 10), **IGNORED**" }, + /* 9*/ { -1, -1, -1, -1, 10.01, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 195: Text gap '10.01' out of range (-5 to 10), **IGNORED**" }, + /* 10*/ { -1, -1, -1, -1, 10.0, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, + /* 11*/ { -1, -1, -1, 12345678, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 181: Invalid dot radius floating point (integer part must be 7 digits maximum)" }, + /* 12*/ { -1, -1, -1, 0.009, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 106: Invalid dot radius value (less than 0.01), **IGNORED**" }, + /* 13*/ { -1, -1, -1, 0.01, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, + /* 14*/ { -1, -1, -2, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 131: Invalid columns value (digits only)" }, + /* 15*/ { -1, -1, 201, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 111: Number of columns '201' out of range (1 to 200), **IGNORED**" }, + /* 16*/ { -1, -1, -1, -1, -1, -2, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 138: Invalid ECI code (digits only)" }, + /* 17*/ { -1, -1, -1, -1, -1, 1000000, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 118: ECI code '1000000' out of range (0 to 999999), **IGNORED**" }, + /* 18*/ { -1, -1, -1, -1, -1, -1, "jpg", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'jpg' not supported, **IGNORED**" }, + /* 19*/ { -1, -1, -1, -1, -1, -1, "giff", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'giff' not supported, **IGNORED**" }, + /* 20*/ { -1, -1, -1, -1, -1, -1, "tiff", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, /* Allow "tiff" */ + /* 21*/ { -1, -1, -1, -1, -1, -1, NULL, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 183: Invalid symbol height floating point (negative value not permitted)" }, + /* 22*/ { -1, -1, -1, -1, -1, -1, NULL, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height '0' out of range (0.5 to 2000), **IGNORED**" }, + /* 23*/ { -1, -1, -1, -1, -1, -1, NULL, 2001, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height '2001' out of range (0.5 to 2000), **IGNORED**" }, + /* 24*/ { -1, -1, -1, -1, -1, -1, NULL, 2000, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, + /* 25*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 182: Invalid guard bar descent floating point (negative value not permitted)" }, + /* 26*/ { -1, -1, -1, -1, -1, -1, NULL, -1, 50.1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 135: Guard bar descent '50.1' out of range (0 to 50), **IGNORED**" }, + /* 27*/ { -1, -1, -1, -1, -1, -1, NULL, -1, 50.0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, + /* 28*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 148: Invalid mask value (digits only)" }, + /* 29*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 147: Mask value '8' out of range (0 to 7), **IGNORED**" }, + /* 30*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 116: Mode value '7' out of range (0 to 6), **IGNORED**" }, + /* 31*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 136: Invalid mode value (digits only)" }, + /* 32*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, "" }, + /* 33*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value (digits only)" }, + /* 34*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 137: Rotation value '45' out of range (0, 90, 180 or 270 only), **IGNORED**" }, + /* 35*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, "" }, + /* 36*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, "Error 132: Invalid rows value (digits only)" }, + /* 37*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, -1, -1, "Warning 112: Number of rows '91' out of range (1 to 90), **IGNORED**" }, + /* 38*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Error 184: Invalid scale floating point (negative value not permitted)" }, + /* 39*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 0.49, -1, -1, -1, -1, -1, -1, "Warning 146: Scaling less than 0.5 will be set to 0.5 for 'gif' output" }, + /* 40*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 0.009, -1, -1, -1, -1, -1, -1, "Warning 105: Invalid scale value '0.009' (less than 0.01), **IGNORED**" }, + /* 41*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Error 149: Invalid Structured Carrier Message version value (digits only)" }, + /* 42*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, 100, -1, -1, -1, -1, -1, "Warning 150: Structured Carrier Message version '100' out of range (0 to 99), **IGNORED**" }, + /* 43*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, "Error 134: Invalid ECC value (digits only)" }, + /* 44*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, -1, "Warning 114: ECC level '9' out of range (0 to 8), **IGNORED**" }, + /* 45*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 128: Invalid separator value (digits only)" }, + /* 46*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, "Warning 127: Separator value '5' out of range (0 to 4), **IGNORED**" }, + /* 47*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, "" }, + /* 48*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 133: Invalid version value (digits only)" }, + /* 49*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1000, -1, -1, "Warning 113: Version value '1000' out of range (1 to 999), **IGNORED**" }, + /* 50*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 153: Invalid vertical whitespace value '-2' (digits only)" }, + /* 51*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 101, -1, "Warning 154: Vertical whitespace value '101' out of range (0 to 100), **IGNORED**" }, + /* 52*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, "" }, + /* 53*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid horizontal whitespace value '-2' (digits only)" }, + /* 54*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 101, "Warning 121: Horizontal whitespace value '101' out of range (0 to 100), **IGNORED**" }, + /* 55*/ { -1, -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 100, "" }, }; int data_size = ARRAY_SIZE(data); int i; @@ -889,7 +997,10 @@ static void test_checks(const testCtx *const p_ctx) { strcat(cmd, " --verbose"); } - arg_int(cmd, "--addongap=", data[i].addongap); + if (data[i].addongap != -1) { + arg_int(cmd, "--addongap=", data[i].addongap); + arg_int(cmd, "-b ", BARCODE_EAN8); + } arg_int(cmd, "--border=", data[i].border); arg_int(cmd, "--cols=", data[i].cols); arg_double(cmd, "--dotsize=", data[i].dotsize); @@ -913,10 +1024,12 @@ static void test_checks(const testCtx *const p_ctx) { strcat(cmd, " 2>&1"); assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); - assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); if (strncmp(data[i].expected, "Warning", 7) == 0) { - assert_zero(testUtilRemove(outfilename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, outfilename, errno, strerror(errno)); + assert_zero(testUtilRemove(outfilename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, outfilename, errno, strerror(errno)); } } @@ -992,9 +1105,11 @@ static void test_barcode_symbology(const testCtx *const p_ctx) { assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); if (!data[i].fail) { - assert_zero(testUtilRemove(outfilename), "i:%d testUtilRemove(%s) != 0 (%d: %s) (%s)\n", i, outfilename, errno, strerror(errno), cmd); + assert_zero(testUtilRemove(outfilename), "i:%d testUtilRemove(%s) != 0 (%d: %s) (%s)\n", + i, outfilename, errno, strerror(errno), cmd); } - assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr(%s, %s) == NULL (%s)\n", i, buf, data[i].expected, cmd); + assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr(%s, %s) == NULL (%s)\n", + i, buf, data[i].expected, cmd); } testFinish(); @@ -1021,8 +1136,8 @@ static void test_other_opts(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ struct item data[] = { - /* 0*/ { BARCODE_CODE128, "1", -1, " --test", "", "", 0 }, /* Do internal test */ - /* 1*/ { BARCODE_AZTEC, "1", -1, " --azfull", "", "", 0 }, + /* 0*/ { BARCODE_CODE128, "1", -1, " --test", NULL, "++++ Following warning expected, ignore: Warning 188: Directory for mirrored output too long (greater than 220), **IGNORED**\n++++ Following error expected, ignore: Error 102: Unable to read input file 'test_nosuch.file' (", 1 }, /* Do internal test */ + /* 1*/ { BARCODE_AZTEC, "1", -1, " --azfull", NULL, "", 0 }, /* 2*/ { BARCODE_CODE128, "1", -1, " --bg=", "EF9900", "", 0 }, /* 3*/ { BARCODE_CODE128, "1", -1, " -bg=", "EF9900", "", 0 }, /* 4*/ { BARCODE_CODE128, "1", -1, " --bg=", "EF9900AA", "", 0 }, @@ -1036,15 +1151,15 @@ static void test_other_opts(const testCtx *const p_ctx) { /* 12*/ { BARCODE_CODE128, "1", -1, " --fg=", "0,0,0,100", "", 0 }, /* 13*/ { BARCODE_CODE128, "1", -1, " --fgcolor=", "111111", "", 0 }, /* 14*/ { BARCODE_CODE128, "1", -1, " --fgcolour=", "111111", "", 0 }, - /* 15*/ { BARCODE_CODE128, "1", -1, " --compliantheight", "", "", 0 }, - /* 16*/ { BARCODE_DATAMATRIX, "1", -1, " --dmiso144", "", "", 0 }, - /* 17*/ { BARCODE_EANX, "123456", -1, " --guardwhitespace", "", "", 0 }, - /* 18*/ { BARCODE_EANX, "123456", -1, " --embedfont", "", "", 0 }, - /* 19*/ { BARCODE_CODE128, "1", -1, " --nobackground", "", "", 0 }, - /* 20*/ { BARCODE_CODE128, "1", -1, " --noquietzones", "", "", 0 }, - /* 21*/ { BARCODE_CODE128, "1", -1, " --notext", "", "", 0 }, - /* 22*/ { BARCODE_CODE128, "1", -1, " --quietzones", "", "", 0 }, - /* 23*/ { BARCODE_CODE128, "1", -1, " --reverse", "", "", 0 }, + /* 15*/ { BARCODE_CODE128, "1", -1, " --compliantheight", NULL, "", 0 }, + /* 16*/ { BARCODE_DATAMATRIX, "1", -1, " --dmiso144", NULL, "", 0 }, + /* 17*/ { BARCODE_EANX, "123456", -1, " --guardwhitespace", NULL, "", 0 }, + /* 18*/ { BARCODE_EANX, "123456", -1, " --embedfont", NULL, "", 0 }, + /* 19*/ { BARCODE_CODE128, "1", -1, " --nobackground", NULL, "", 0 }, + /* 20*/ { BARCODE_CODE128, "1", -1, " --noquietzones", NULL, "", 0 }, + /* 21*/ { BARCODE_CODE128, "1", -1, " --notext", NULL, "", 0 }, + /* 22*/ { BARCODE_CODE128, "1", -1, " --quietzones", NULL, "", 0 }, + /* 23*/ { BARCODE_CODE128, "1", -1, " --reverse", NULL, "", 0 }, /* 24*/ { BARCODE_CODE128, "1", -1, " --werror", NULL, "", 0 }, /* 25*/ { 19, "1", -1, " --werror", NULL, "Error 207: Codabar 18 not supported", 0 }, /* 26*/ { BARCODE_GS1_128, "[01]12345678901231", -1, "", NULL, "", 0 }, @@ -1072,7 +1187,7 @@ static void test_other_opts(const testCtx *const p_ctx) { /* 48*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "0,2,12345678901234567890123456789012", "Error 155: Structured Append index '0' out of range (1 to count '2')", 0 }, /* 49*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "3,2,12345678901234567890123456789012", "Error 155: Structured Append index '3' out of range (1 to count '2')", 0 }, /* 50*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "2,3,12345678901234567890123456789012", "", 0 }, - /* 51*/ { BARCODE_PDF417, "1", -1, " --heightperrow", "", "", 0 }, + /* 51*/ { BARCODE_PDF417, "1", -1, " --heightperrow", NULL, "", 0 }, /* 52*/ { -1, NULL, -1, " -v", NULL, "Zint version ", 1 }, /* 53*/ { -1, NULL, -1, " --version", NULL, "Zint version ", 1 }, /* 54*/ { -1, NULL, -1, " -h", NULL, "Encode input data in a barcode ", 1 }, @@ -1118,11 +1233,14 @@ static void test_other_opts(const testCtx *const p_ctx) { assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); if (data[i].strstr_cmp) { - assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); } else { - assert_zero(strcmp(buf, data[i].expected), "i:%d strcmp buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_zero(strcmp(buf, data[i].expected), "i:%d strcmp buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); if (strstr(data[i].expected, "Error") == NULL) { - assert_zero(testUtilRemove(outfilename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, outfilename, errno, strerror(errno)); + assert_zero(testUtilRemove(outfilename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, outfilename, errno, strerror(errno)); } } } @@ -1168,12 +1286,15 @@ static void test_combos(const testCtx *const p_ctx) { assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); if (data[i].strstr_cmp) { - assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); } else { - assert_zero(strcmp(buf, data[i].expected), "i:%d strcmp buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_zero(strcmp(buf, data[i].expected), "i:%d strcmp buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); } if (data[i].outfilename != NULL) { - assert_zero(remove(data[i].outfilename), "i:%d remove(%s) != 0 (%d: %s)\n", i, data[i].outfilename, errno, strerror(errno)); + assert_zero(remove(data[i].outfilename), "i:%d remove(%s) != 0 (%d: %s)\n", + i, data[i].outfilename, errno, strerror(errno)); } } @@ -1232,9 +1353,11 @@ static void test_exit_status(const testCtx *const p_ctx) { strcat(cmd, " 2>&1"); assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, &exit_status), "i:%d exec(%s) NULL\n", i, cmd); - assert_equal(exit_status, data[i].expected, "i:%d exit_status %d != expected (%d) (%s), (cmd: %s)\n", i, exit_status, data[i].expected, buf, cmd); + assert_equal(exit_status, data[i].expected, "i:%d exit_status %d != expected (%d) (%s), (cmd: %s)\n", + i, exit_status, data[i].expected, buf, cmd); if (data[i].expected < ZINT_ERROR) { - assert_zero(testUtilRemove(outfilename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, outfilename, errno, strerror(errno)); + assert_zero(testUtilRemove(outfilename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", + i, outfilename, errno, strerror(errno)); } } @@ -1255,9 +1378,9 @@ static void test_bad_args(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ struct item data[] = { - /* 0*/ { BARCODE_CODE128, NULL, -1, NULL, NULL, "Error 109: option '-d' requires an argument" }, - /* 1*/ { BARCODE_CODE128, "1", -1, " -o", NULL, "Error 109: option '-o' requires an argument" }, - /* 2*/ { BARCODE_CODE128, "1", -1, " --fast=", "1", "Error 126: option '--fast' does not take an argument" }, + /* 0*/ { BARCODE_CODE128, NULL, -1, NULL, NULL, "Error 109: Option '-d' requires an argument" }, + /* 1*/ { BARCODE_CODE128, "1", -1, " -o", NULL, "Error 109: Option '-o' requires an argument" }, + /* 2*/ { BARCODE_CODE128, "1", -1, " --fast=", "1", "Error 126: Option '--fast' does not take an argument" }, }; int data_size = ARRAY_SIZE(data); int i; @@ -1293,7 +1416,8 @@ static void test_bad_args(const testCtx *const p_ctx) { strcat(cmd, " 2>&1"); assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, &exit_status), "i:%d exec(%s) NULL\n", i, cmd); - assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); } testFinish(); @@ -1334,6 +1458,55 @@ static void test_too_many_args(const testCtx *const p_ctx) { " -d 300", "Error 129: Too many data args (maximum 300)" }, + /* 2*/ { BARCODE_CODE128, + " -d 000 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 010 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 020 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 030 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 040 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 050 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 060 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 070 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 080 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 090 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9", + " -d 100 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 110 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 120 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 130 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 140 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 150 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 160 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 170 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 180 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 190 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9", + " -d 200 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 210 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 220 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 230 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 240 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 250 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 260 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 270 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 280 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9 -d 290 -d 1 -d 2 -d 3 -d 4 -d 5 -d 6 -d 7 -d 8 -d 9", + " -i 300", + "Error 130: Too many data args (maximum 300)" + }, + /* 3*/ { BARCODE_CODE16K, + " -d 000 -d 1", + "", + "", + "", + "Error 173: Symbology must be stackable if multiple data arguments given" + }, + /* 4*/ { BARCODE_CODE128, + " -d 000 blah", + "", + "", + "", + "Warning 191: Extra argument 'blah' **IGNORED**" + }, + /* 5*/ { BARCODE_CODE128, + " -d 000 blah blah", + "", + "", + "", + "Warning 192: Extra arguments beginning with 'blah' **IGNORED**" + }, + /* 6*/ { BARCODE_CODE128, + " -d 000 -d 1 --seg1=0,1", + "", + "", + "", + "Error 170: Cannot specify segments and multiple data arguments together" + }, + /* 7*/ { BARCODE_CODE128, + " -i gosh.txt --seg1=0,1", + "", + "", + "", + "Error 171: Cannot use input argument with segment arguments" + }, + /* 8*/ { BARCODE_CODE128, + " -i gosh.txt --mirror", + "", + "", + "", + "Warning 163: '--mirror' given but no data argument, **IGNORED**\nError 229: Unable to read input file \"gosh.txt\" (2: No such file or directory)" + }, }; int data_size = ARRAY_SIZE(data); int i; @@ -1360,7 +1533,8 @@ static void test_too_many_args(const testCtx *const p_ctx) { strcat(cmd, " 2>&1"); assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, &exit_status), "i:%d exec(%s) == NULL\n", i, cmd); - assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); } testFinish(); @@ -1380,9 +1554,15 @@ static void test_optional_args(const testCtx *const p_ctx) { /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ struct item data[] = { /* 0*/ { BARCODE_DATAMATRIX, "123", NULL, " --dmb256", "AA A\n88 F\nD0 C\nC7 F\nAF A\nFF 3\nF5 4\nA1 B\nB5 0\nE1 D\nE9 A\nFF F" }, - /* 1*/ { BARCODE_DATAMATRIX, "123", NULL, " --dmc40", "AA 8\n80 4\nC0 8\n81 C\nB7 0\nAB C\nE1 0\nE5 4\nBC 0\nFF C" }, - /* 2*/ { BARCODE_EAN13, "123", NULL, " --scalexdimdp", "A3 46 8D 1A 34 6A B9 72 CD B2 15 0A" }, - /* 3*/ { BARCODE_MAXICODE, "123", "1234567", " --scmvv", "D7 6F BF FC\n55 70 D8 08\nDB 12 A6 78\n55 55 55 50\n00 00 00 08\nAA AA AA A8\n55 55 55 54\n00 00 00 00\nAA AA AA AC\n55 B1 35 58\n00 90 08 0C\nAA C0 52 A8\n54 40 05 50\n01 00 08 00\nAA C0 0A AC\n55 00 01 58\n02 80 08 0C\nAB 80 1E A0\n54 00 05 5C\n03 80 0C 08\nA8 00 02 A4\n55 40 25 58\n00 60 40 08\nAA 60 66 A0\n55 55 5B FC\n00 00 02 30\nAA AA A1 E0\n5E CF C1 E8\nD0 62 E5 84\n20 1B 10 D8\nDB 8E B6 80\n21 96 26 C0\nC3 C9 89 F8" }, + /* 1*/ { BARCODE_DATAMATRIX, "123", NULL, " --dmb256=", "AA A\n88 F\nD0 C\nC7 F\nAF A\nFF 3\nF5 4\nA1 B\nB5 0\nE1 D\nE9 A\nFF F" }, + /* 2*/ { BARCODE_DATAMATRIX, "123", NULL, " --dmb256=A", "Error 158: Invalid Data Matrix Base 256 mode length value (digits only)" }, + /* 3*/ { BARCODE_DATAMATRIX, "123", NULL, " --dmc40", "AA 8\n80 4\nC0 8\n81 C\nB7 0\nAB C\nE1 0\nE5 4\nBC 0\nFF C" }, + /* 4*/ { BARCODE_DATAMATRIX, "123", NULL, " --dmc40=", "AA 8\n80 4\nC0 8\n81 C\nB7 0\nAB C\nE1 0\nE5 4\nBC 0\nFF C" }, + /* 5*/ { BARCODE_DATAMATRIX, "123", NULL, " --dmc40=-1", "Error 160: Invalid Data Matrix C40 mode length value (digits only)" }, + /* 6*/ { BARCODE_DATAMATRIX, "123", NULL, " --dmc40 --dmb256", "Warning 159: '--dmc40' already set, '--dmb256' **IGNORED**\nAA 8\n80 4\nC0 8\n81 C\nB7 0\nAB C\nE1 0\nE5 4\nBC 0\nFF C" }, + /* 7*/ { BARCODE_DATAMATRIX, "123", NULL, " --square --dmre", "Warning 156: '--square' already set, '--dmre' **IGNORED**\nAA 8\n85 4\nE5 8\nC9 4\nCC 0\nB1 C\n98 0\nB6 4\nA2 0\nFF C" }, + /* 8*/ { BARCODE_EAN13, "123", NULL, " --scalexdimdp", "A3 46 8D 1A 34 6A B9 72 CD B2 15 0A" }, + /* 9*/ { BARCODE_MAXICODE, "123", "1234567", " --scmvv", "D7 6F BF FC\n55 70 D8 08\nDB 12 A6 78\n55 55 55 50\n00 00 00 08\nAA AA AA A8\n55 55 55 54\n00 00 00 00\nAA AA AA AC\n55 B1 35 58\n00 90 08 0C\nAA C0 52 A8\n54 40 05 50\n01 00 08 00\nAA C0 0A AC\n55 00 01 58\n02 80 08 0C\nAB 80 1E A0\n54 00 05 5C\n03 80 0C 08\nA8 00 02 A4\n55 40 25 58\n00 60 40 08\nAA 60 66 A0\n55 55 5B FC\n00 00 02 30\nAA AA A1 E0\n5E CF C1 E8\nD0 62 E5 84\n20 1B 10 D8\nDB 8E B6 80\n21 96 26 C0\nC3 C9 89 F8" }, }; int data_size = ARRAY_SIZE(data); int i; @@ -1411,7 +1591,8 @@ static void test_optional_args(const testCtx *const p_ctx) { strcat(cmd, " 2>&1"); assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i, NULL), "i:%d exec(%s) NULL\n", i, cmd); - assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", i, buf, data[i].expected, cmd); + assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s) (%s)\n", + i, buf, data[i].expected, cmd); } testFinish();