rss.c: some fixes for separators, allow check digit, refactoring; bwipp_dump.ps

This commit is contained in:
gitlost 2020-07-10 19:39:32 +01:00
parent 9768cd004a
commit c1fb51ba42
33 changed files with 4451 additions and 1360 deletions

View File

@ -196,6 +196,10 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
} }
} }
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Check digit (%d): %s\n", num_check_digits, num_check_digits ? checkstr : "<none>");
}
/* Stop character */ /* Stop character */
strcat(dest, "11221"); strcat(dest, "11221");

View File

@ -33,7 +33,6 @@
/* vim: set ts=4 sw=4 et : */ /* vim: set ts=4 sw=4 et : */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <malloc.h> #include <malloc.h>
#endif #endif
@ -648,7 +647,8 @@ INTERNAL int code_128(struct zint_symbol *symbol, const unsigned char source[],
for (i = 0; i < bar_characters; i++) { for (i = 0; i < bar_characters; i++) {
printf(" %d", values[i]); printf(" %d", values[i]);
} }
printf("\n"); printf(" (%d)\n", bar_characters);
printf("Barspaces: %s\n", dest);
} }
#ifdef ZINT_TEST #ifdef ZINT_TEST
if (symbol->debug & ZINT_DEBUG_TEST) { if (symbol->debug & ZINT_DEBUG_TEST) {
@ -951,7 +951,8 @@ INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], const s
for (i = 0; i < bar_characters; i++) { for (i = 0; i < bar_characters; i++) {
printf(" %d", values[i]); printf(" %d", values[i]);
} }
printf("\n"); printf(" (%d)\n", bar_characters);
printf("Barspaces: %s\n", dest);
} }
#ifdef ZINT_TEST #ifdef ZINT_TEST
if (symbol->debug & ZINT_DEBUG_TEST) { if (symbol->debug & ZINT_DEBUG_TEST) {

View File

@ -135,18 +135,6 @@ INTERNAL int posn(const char set_string[], const char data) {
return -1; return -1;
} }
/* Returns the number of times a character occurs in a string */
INTERNAL int ustrchr_cnt(const unsigned char string[], const size_t length, const unsigned char c) {
int count = 0;
unsigned int i;
for (i = 0; i < length; i++) {
if (string[i] == c) {
count++;
}
}
return count;
}
/* Return true (1) if a module is dark/black/colour, otherwise false (0) */ /* Return true (1) if a module is dark/black/colour, otherwise false (0) */
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) { INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
if (symbol->symbology == BARCODE_ULTRA) { if (symbol->symbology == BARCODE_ULTRA) {
@ -272,7 +260,7 @@ INTERNAL int istwodigits(const unsigned char source[], const int length, const i
} }
/* State machine to decode UTF-8 to Unicode codepoints (state 0 means done, state 12 means error) */ /* State machine to decode UTF-8 to Unicode codepoints (state 0 means done, state 12 means error) */
INTERNAL unsigned int decode_utf8(unsigned int* state, unsigned int* codep, const unsigned char byte) { INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte) {
/* /*
Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de> Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
@ -375,8 +363,9 @@ INTERNAL void set_minimum_height(struct zint_symbol *symbol, const int min_heigh
} }
/* Calculate optimized encoding modes. Adapted from Project Nayuki */ /* Calculate optimized encoding modes. Adapted from Project Nayuki */
INTERNAL void pn_define_mode(char* mode, const unsigned int data[], const size_t length, const int debug, INTERNAL void pn_define_mode(char *mode, const unsigned int data[], const size_t length, const int debug,
unsigned int state[], const char mode_types[], const int num_modes, pn_head_costs head_costs, pn_switch_cost switch_cost, pn_eod_cost eod_cost, pn_cur_cost cur_cost) { unsigned int state[], const char mode_types[], const int num_modes,
pn_head_costs head_costs, pn_switch_cost switch_cost, pn_eod_cost eod_cost, pn_cur_cost cur_cost) {
/* /*
* Copyright (c) Project Nayuki. (MIT License) * Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library * https://www.nayuki.io/page/qr-code-generator-library
@ -398,12 +387,12 @@ INTERNAL void pn_define_mode(char* mode, const unsigned int data[], const size_t
char char_modes[length * num_modes]; char char_modes[length * num_modes];
unsigned int cur_costs[num_modes]; unsigned int cur_costs[num_modes];
#else #else
unsigned int* prev_costs; unsigned int *prev_costs;
char* char_modes; char *char_modes;
unsigned int* cur_costs; unsigned int *cur_costs;
prev_costs = (unsigned int*) _alloca(num_modes * sizeof(unsigned int)); prev_costs = (unsigned int *) _alloca(num_modes * sizeof(unsigned int));
char_modes = (char*) _alloca(length * num_modes); char_modes = (char *) _alloca(length * num_modes);
cur_costs = (unsigned int*) _alloca(num_modes * sizeof(unsigned int)); cur_costs = (unsigned int *) _alloca(num_modes * sizeof(unsigned int));
#endif #endif
/* char_modes[i * num_modes + j] represents the mode to encode the code point at index i such that the final /* char_modes[i * num_modes + j] represents the mode to encode the code point at index i such that the final
@ -462,13 +451,13 @@ INTERNAL void pn_define_mode(char* mode, const unsigned int data[], const size_t
} }
if (debug & ZINT_DEBUG_PRINT) { if (debug & ZINT_DEBUG_PRINT) {
printf(" Mode: %.*s\n", (int)length, mode); printf(" Mode: %.*s\n", (int) length, mode);
} }
} }
#ifdef ZINT_TEST #ifdef ZINT_TEST
/* Dumps hex-formatted codewords in symbol->errtxt (for use in testing) */ /* Dumps hex-formatted codewords in symbol->errtxt (for use in testing) */
void debug_test_codeword_dump(struct zint_symbol *symbol, unsigned char* codewords, int length) { void debug_test_codeword_dump(struct zint_symbol *symbol, unsigned char *codewords, int length) {
int i, max = length, cnt_len = 0; int i, max = length, cnt_len = 0;
if (length > 30) { /* 30*3 < errtxt 92 (100 - "Warning ") chars */ if (length > 30) { /* 30*3 < errtxt 92 (100 - "Warning ") chars */
sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */ sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */
@ -481,7 +470,7 @@ void debug_test_codeword_dump(struct zint_symbol *symbol, unsigned char* codewor
symbol->errtxt[strlen(symbol->errtxt) - 1] = '\0'; /* Zap last space */ symbol->errtxt[strlen(symbol->errtxt) - 1] = '\0'; /* Zap last space */
} }
void debug_test_codeword_dump_int(struct zint_symbol *symbol, int* codewords, int length) { void debug_test_codeword_dump_int(struct zint_symbol *symbol, int *codewords, int length) {
int i, max = 0, cnt_len, errtxt_len; int i, max = 0, cnt_len, errtxt_len;
char temp[20]; char temp[20];
errtxt_len = sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */ errtxt_len = sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */

View File

@ -79,7 +79,6 @@ extern "C" {
INTERNAL void bin_append(const int arg, const int length, char *binary); INTERNAL void bin_append(const int arg, const int length, char *binary);
INTERNAL void bin_append_posn(const int arg, const int length, char *binary, size_t posn); INTERNAL void bin_append_posn(const int arg, const int length, char *binary, size_t posn);
INTERNAL int posn(const char set_string[], const char data); INTERNAL int posn(const char set_string[], const char data);
INTERNAL int ustrchr_cnt(const unsigned char string[], const size_t length, const unsigned char c);
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord); INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord); INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, const int x_coord, const int colour); INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, const int x_coord, const int colour);
@ -89,20 +88,22 @@ extern "C" {
INTERNAL int is_extendable(const int symbology); INTERNAL int is_extendable(const int symbology);
INTERNAL int is_composite(const int symbology); INTERNAL int is_composite(const int symbology);
INTERNAL int istwodigits(const unsigned char source[], int length, const int position); INTERNAL int istwodigits(const unsigned char source[], int length, const int position);
INTERNAL unsigned int decode_utf8(unsigned int* state, unsigned int* codep, const unsigned char byte); INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte);
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[], size_t *length, int disallow_4byte); INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[], size_t *length, int disallow_4byte);
INTERNAL void set_minimum_height(struct zint_symbol *symbol, const int min_height); INTERNAL void set_minimum_height(struct zint_symbol *symbol, const int min_height);
typedef unsigned int* (*pn_head_costs)(unsigned int state[]); typedef unsigned int *(*pn_head_costs)(unsigned int state[]);
typedef unsigned int (*pn_switch_cost)(unsigned int state[], const int k, const int j); typedef unsigned int (*pn_switch_cost)(unsigned int state[], const int k, const int j);
typedef unsigned int (*pn_eod_cost)(unsigned int state[], const int k); typedef unsigned int (*pn_eod_cost)(unsigned int state[], const int k);
typedef void (*pn_cur_cost)(unsigned int state[], const unsigned int data[], const size_t length, const int i, char* char_modes, unsigned int prev_costs[], unsigned int cur_costs[]); typedef void (*pn_cur_cost)(unsigned int state[], const unsigned int data[], const size_t length, const int i,
INTERNAL void pn_define_mode(char* mode, const unsigned int data[], const size_t length, const int debug, char *char_modes, unsigned int prev_costs[], unsigned int cur_costs[]);
unsigned int state[], const char mode_types[], const int num_modes, pn_head_costs head_costs, pn_switch_cost switch_cost, pn_eod_cost eod_cost, pn_cur_cost cur_cost); INTERNAL void pn_define_mode(char *mode, const unsigned int data[], const size_t length, const int debug,
unsigned int state[], const char mode_types[], const int num_modes,
pn_head_costs head_costs, pn_switch_cost switch_cost, pn_eod_cost eod_cost, pn_cur_cost cur_cost);
#ifdef ZINT_TEST #ifdef ZINT_TEST
void debug_test_codeword_dump(struct zint_symbol *symbol, unsigned char* codewords, int length); void debug_test_codeword_dump(struct zint_symbol *symbol, unsigned char *codewords, int length);
void debug_test_codeword_dump_int(struct zint_symbol *symbol, int* codewords, int length); void debug_test_codeword_dump_int(struct zint_symbol *symbol, int *codewords, int length);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -2,7 +2,7 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -50,20 +50,18 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <malloc.h> #include <malloc.h>
#endif #endif
#include "common.h" #include "common.h"
#include "composite.h"
#include "pdf417.h" #include "pdf417.h"
#include "gs1.h" #include "gs1.h"
#include "general_field.h" #include "general_field.h"
#define UINT unsigned short #define UINT unsigned short
#include "composite.h"
INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int length); INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], const size_t length); INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], const size_t length);
@ -72,8 +70,6 @@ INTERNAL int rss14(struct zint_symbol *symbol, unsigned char source[], int lengt
INTERNAL int rsslimited(struct zint_symbol *symbol, unsigned char source[], int length); INTERNAL int rsslimited(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int length); INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int length);
static UINT pwr928[69][7];
static int _min(int first, int second) { static int _min(int first, int second) {
if (first <= second) if (first <= second)
@ -87,26 +83,6 @@ static int getBit(UINT *bitStr, int bitPos) {
return !!(bitStr[bitPos >> 4] & (0x8000 >> (bitPos & 15))); return !!(bitStr[bitPos >> 4] & (0x8000 >> (bitPos & 15)));
} }
/* initialize pwr928 encoding table */
static void init928(void) {
int i, j, v;
int cw[7];
cw[6] = 1L;
for (i = 5; i >= 0; i--)
cw[i] = 0;
for (i = 0; i < 7; i++)
pwr928[0][i] = cw[i];
for (j = 1; j < 69; j++) {
for (v = 0, i = 6; i >= 1; i--) {
v = (2 * cw[i]) + (v / 928);
pwr928[j][i] = cw[i] = v % 928;
}
pwr928[j][0] = cw[0] = (2 * cw[0]) + (v / 928);
}
return;
}
/* converts bit string to base 928 values, codeWords[0] is highest order */ /* converts bit string to base 928 values, codeWords[0] is highest order */
static int encode928(UINT bitString[], UINT codeWords[], int bitLng) { static int encode928(UINT bitString[], UINT codeWords[], int bitLng) {
int i, j, b, cwNdx, cwLng; int i, j, b, cwNdx, cwLng;
@ -171,7 +147,6 @@ static int cc_a(struct zint_symbol *symbol, char source[], int cc_width) {
} }
} }
init928();
/* encode codeWords from bitStr */ /* encode codeWords from bitStr */
cwCnt = encode928(bitStr, codeWords, bitlen); cwCnt = encode928(bitStr, codeWords, bitlen);
@ -332,6 +307,10 @@ static int cc_a(struct zint_symbol *symbol, char source[], int cc_width) {
} }
} }
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("CC-A Columns: %d, Rows: %d\n", cc_width, symbol->rows);
}
return 0; return 0;
} }
@ -341,7 +320,7 @@ static int cc_b(struct zint_symbol *symbol, char source[], int cc_width) {
#ifndef _MSC_VER #ifndef _MSC_VER
unsigned char data_string[(strlen(source) / 8) + 3]; unsigned char data_string[(strlen(source) / 8) + 3];
#else #else
unsigned char* data_string = (unsigned char*) _alloca((strlen(source) / 8) + 3); unsigned char *data_string = (unsigned char *) _alloca((strlen(source) / 8) + 3);
#endif #endif
int chainemc[180], mclength; int chainemc[180], mclength;
int k, j, p, longueur, mccorrection[50], offset; int k, j, p, longueur, mccorrection[50], offset;
@ -584,6 +563,10 @@ static int cc_b(struct zint_symbol *symbol, char source[], int cc_width) {
} }
} }
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("CC-B Columns: %d, Rows: %d\n", cc_width, symbol->rows);
}
return 0; return 0;
} }
@ -593,7 +576,7 @@ static int cc_c(struct zint_symbol *symbol, char source[], int cc_width, int ecc
#ifndef _MSC_VER #ifndef _MSC_VER
unsigned char data_string[(strlen(source) / 8) + 4]; unsigned char data_string[(strlen(source) / 8) + 4];
#else #else
unsigned char* data_string = (unsigned char*) _alloca((strlen(source) / 8) + 4); unsigned char *data_string = (unsigned char *) _alloca((strlen(source) / 8) + 4);
#endif #endif
int chainemc[1000], mclength, k; int chainemc[1000], mclength, k;
int offset, longueur, loop, total, j, mccorrection[520]; int offset, longueur, loop, total, j, mccorrection[520];
@ -724,6 +707,10 @@ static int cc_c(struct zint_symbol *symbol, char source[], int cc_width, int ecc
symbol->rows = (mclength / cc_width); symbol->rows = (mclength / cc_width);
symbol->width = (int)strlen(pattern); symbol->width = (int)strlen(pattern);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("CC-C Columns: %d, Rows: %d\n", cc_width, symbol->rows);
}
return 0; return 0;
} }
@ -788,9 +775,9 @@ static int calc_padding_cca(int binary_length, int cc_width) {
target_bitsize = 78; target_bitsize = 78;
} }
break; break;
} }
return target_bitsize; return target_bitsize;
} }
static int calc_padding_ccb(int binary_length, int cc_width) { static int calc_padding_ccb(int binary_length, int cc_width) {
@ -957,7 +944,8 @@ static int calc_padding_ccc(int binary_length, int *cc_width, int lin_width, int
return target_bitsize; return target_bitsize;
} }
static int cc_binary_string(struct zint_symbol *symbol, const char source[], char binary_string[], int cc_mode, int *cc_width, int *ecc, int lin_width) { /* Handles all data encodation from section 5 of ISO/IEC 24723 */ /* Handles all data encodation from section 5 of ISO/IEC 24723 */
static int cc_binary_string(struct zint_symbol *symbol, const char source[], char binary_string[], int cc_mode, int *cc_width, int *ecc, int lin_width) {
int encoding_method, read_posn, alpha_pad; int encoding_method, read_posn, alpha_pad;
int i, j, ai_crop, ai_crop_posn, fnc1_latch; int i, j, ai_crop, ai_crop_posn, fnc1_latch;
int ai90_mode, last_digit, remainder, binary_length; int ai90_mode, last_digit, remainder, binary_length;
@ -966,9 +954,10 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
#ifndef _MSC_VER #ifndef _MSC_VER
char general_field[source_len + 1]; char general_field[source_len + 1];
#else #else
char* general_field = (char*) _alloca(source_len + 1); char *general_field = (char *) _alloca(source_len + 1);
#endif #endif
int target_bitsize; int target_bitsize;
int debug = symbol->debug & ZINT_DEBUG_PRINT;
encoding_method = 1; encoding_method = 1;
read_posn = 0; read_posn = 0;
@ -976,7 +965,6 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
ai_crop_posn = -1; ai_crop_posn = -1;
fnc1_latch = 0; fnc1_latch = 0;
alpha_pad = 0; alpha_pad = 0;
ai90_mode = 0;
*ecc = 0; *ecc = 0;
target_bitsize = 0; target_bitsize = 0;
mode = NUMERIC; mode = NUMERIC;
@ -993,6 +981,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
if (encoding_method == 1) { if (encoding_method == 1) {
strcat(binary_string, "0"); strcat(binary_string, "0");
if (debug) printf("CC-%c Encodation Method: 0\n", 'A' + (cc_mode - 1));
} }
if (encoding_method == 2) { if (encoding_method == 2) {
@ -1046,6 +1035,8 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
/* Note an alphanumeric FNC1 is also a numeric latch, so now in numeric mode */ /* Note an alphanumeric FNC1 is also a numeric latch, so now in numeric mode */
} }
} }
if (debug) printf("CC-%c Encodation Method: 10, Compaction Field: %.*s\n", 'A' + (cc_mode - 1), read_posn, source);
} }
if (encoding_method == 3) { if (encoding_method == 3) {
@ -1053,7 +1044,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
#ifndef _MSC_VER #ifndef _MSC_VER
char ninety[source_len + 1]; char ninety[source_len + 1];
#else #else
char* ninety = (char*) _alloca(source_len + 1); char *ninety = (char *) _alloca(source_len + 1);
#endif #endif
int ninety_len, alpha, alphanum, numeric, test1, test2, test3; int ninety_len, alpha, alphanum, numeric, test1, test2, test3;
@ -1126,30 +1117,30 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
/* Alpha mode is a special mode for AI 90 */ /* Alpha mode is a special mode for AI 90 */
if (alphanum == 0 && alpha > numeric) { if (alphanum == 0 && alpha > numeric) {
/* Alphabetic mode */ /* Alpha mode */
strcat(binary_string, "11"); strcat(binary_string, "11");
ai90_mode = 2; ai90_mode = 2;
} else if (alphanum == 0 && alpha == 0) { } else if (alphanum == 0 && alpha == 0) {
/* Numeric mode */ /* Numeric mode */
strcat(binary_string, "10"); strcat(binary_string, "10");
ai90_mode = 3; ai90_mode = 3;
} else { } else { /* Note if first 4 are digits then it would be shorter to go into NUMERIC mode first; not implemented */
/* Alphanumeric mode */ /* Alphanumeric mode */
strcat(binary_string, "0"); strcat(binary_string, "0");
ai90_mode = 1; ai90_mode = 1;
mode = ALPHA; mode = ALPHANUMERIC;
} }
next_ai_posn = 2 + ninety_len; next_ai_posn = 2 + ninety_len;
if (source[next_ai_posn] == '[') { if (next_ai_posn < source_len && source[next_ai_posn] == '[') {
/* There are more AIs afterwards */ /* There are more AIs afterwards */
if ((source[next_ai_posn + 1] == '2') && (source[next_ai_posn + 2] == '1')) { if (next_ai_posn + 2 < source_len && (source[next_ai_posn + 1] == '2') && (source[next_ai_posn + 2] == '1')) {
/* AI 21 follows */ /* AI 21 follows */
ai_crop = 1; ai_crop = 1;
} } else if (next_ai_posn + 4 < source_len
&& (source[next_ai_posn + 1] == '8') && (source[next_ai_posn + 2] == '0')
if ((source[next_ai_posn + 1] == '8') && (source[next_ai_posn + 2] == '0') && (source[next_ai_posn + 3] == '0') && (source[next_ai_posn + 4] == '4')) { && (source[next_ai_posn + 3] == '0') && (source[next_ai_posn + 4] == '4')) {
/* AI 8004 follows */ /* AI 8004 follows */
ai_crop = 3; ai_crop = 3;
} }
@ -1220,10 +1211,15 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
alpha_pad = 1; /* This is overwritten if a general field is encoded */ alpha_pad = 1; /* This is overwritten if a general field is encoded */
} }
if (debug) {
printf("CC-%c Encodation Method: 11, Compaction Field: %.*s, Binary: %s (%d)\n",
'A' + (cc_mode - 1), read_posn, source, binary_string, (int) strlen(binary_string));
}
} else { } else {
/* Use general field encodation instead */ /* Use general field encodation instead */
strcat(binary_string, "0"); strcat(binary_string, "0");
read_posn = 0; read_posn = 0;
if (debug) printf("CC-%c Encodation Method: 0\n", 'A' + (cc_mode - 1));
} }
} }
@ -1249,6 +1245,12 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
} }
general_field[j] = '\0'; general_field[j] = '\0';
if (debug) {
printf("Mode %s, General Field: %.40s%s\n",
mode == NUMERIC ? "NUMERIC" : mode == ALPHANUMERIC ? "ALPHANUMERIC" : "ISO646",
general_field, strlen(general_field) > 40 ? "..." : "");
}
if (strlen(general_field) != 0) { if (strlen(general_field) != 0) {
alpha_pad = 0; alpha_pad = 0;
} }
@ -1322,7 +1324,6 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
/* Now add padding to binary string */ /* Now add padding to binary string */
if (alpha_pad == 1) { if (alpha_pad == 1) {
strcat(binary_string, "11111"); strcat(binary_string, "11111");
alpha_pad = 0;
/* Extra FNC1 character required after Alpha encodation (section 5.3.3) */ /* Extra FNC1 character required after Alpha encodation (section 5.3.3) */
} }
@ -1339,6 +1340,11 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
} }
} }
if (debug) {
printf("ECC: %d, CC width %d\n", *ecc, *cc_width);
printf("Binary: %s (%d)\n", binary_string, (int) strlen(binary_string));
}
return 0; return 0;
} }
@ -1368,7 +1374,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
#ifndef _MSC_VER #ifndef _MSC_VER
char binary_string[bs]; char binary_string[bs];
#else #else
char* binary_string = (char*) _alloca(bs); char *binary_string = (char *) _alloca(bs);
#endif #endif
unsigned int pri_len; unsigned int pri_len;
struct zint_symbol *linear; struct zint_symbol *linear;
@ -1402,6 +1408,9 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
strcpy(symbol->errtxt, "448: Invalid data"); strcpy(symbol->errtxt, "448: Invalid data");
return ZINT_ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("GS1-128 linear width: %d\n", linear_width);
}
} }
switch (symbol->symbology) { switch (symbol->symbology) {
@ -1412,7 +1421,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
int padded_pri_len; int padded_pri_len;
char padded_pri[20]; char padded_pri[20];
padded_pri[0] = '\0'; padded_pri[0] = '\0';
ean_leading_zeroes(symbol, (unsigned char*) symbol->primary, (unsigned char*) padded_pri); ean_leading_zeroes(symbol, (unsigned char *) symbol->primary, (unsigned char *) padded_pri);
padded_pri_len = strlen(padded_pri); padded_pri_len = strlen(padded_pri);
if (padded_pri_len <= 7) { /* EAN-8 */ if (padded_pri_len <= 7) { /* EAN-8 */
cc_width = 3; cc_width = 3;
@ -1511,6 +1520,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
linear = ZBarcode_Create(); /* Symbol contains the 2D component and Linear contains the rest */ linear = ZBarcode_Create(); /* Symbol contains the 2D component and Linear contains the rest */
linear->symbology = symbol->symbology; linear->symbology = symbol->symbology;
linear->debug = symbol->debug;
if (linear->symbology != BARCODE_EAN128_CC) { if (linear->symbology != BARCODE_EAN128_CC) {
/* Set the "component linkage" flag in the linear component */ /* Set the "component linkage" flag in the linear component */
@ -1627,6 +1637,10 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
break; break;
} }
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Top shift: %d, Bottom shift: %d\n", top_shift, bottom_shift);
}
if (top_shift != 0) { if (top_shift != 0) {
/* Move the 2d component of the symbol horizontally */ /* Move the 2d component of the symbol horizontally */
for (i = 0; i <= symbol->rows; i++) { for (i = 0; i <= symbol->rows; i++) {
@ -1660,7 +1674,8 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
symbol->width += top_shift; symbol->width += top_shift;
} }
symbol->rows += linear->rows; symbol->rows += linear->rows;
ustrcpy(symbol->text, (unsigned char *) linear->text);
ustrcpy(symbol->text, linear->text);
ZBarcode_Delete(linear); ZBarcode_Delete(linear);

View File

@ -2,7 +2,7 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -65,3 +65,76 @@ static const char aRAPTable[68] = {
}; };
/* Row Address Patterns are as defined in pdf417.h */ /* Row Address Patterns are as defined in pdf417.h */
/* Generated by tools/gen_pwr928_table.php */
static UINT pwr928[69][7] = {
{ 0, 0, 0, 0, 0, 0, 1, },
{ 0, 0, 0, 0, 0, 0, 2, },
{ 0, 0, 0, 0, 0, 0, 4, },
{ 0, 0, 0, 0, 0, 0, 8, },
{ 0, 0, 0, 0, 0, 0, 16, },
{ 0, 0, 0, 0, 0, 0, 32, },
{ 0, 0, 0, 0, 0, 0, 64, },
{ 0, 0, 0, 0, 0, 0, 128, },
{ 0, 0, 0, 0, 0, 0, 256, },
{ 0, 0, 0, 0, 0, 0, 512, },
{ 0, 0, 0, 0, 0, 1, 96, },
{ 0, 0, 0, 0, 0, 2, 192, },
{ 0, 0, 0, 0, 0, 4, 384, },
{ 0, 0, 0, 0, 0, 8, 768, },
{ 0, 0, 0, 0, 0, 17, 608, },
{ 0, 0, 0, 0, 0, 35, 288, },
{ 0, 0, 0, 0, 0, 70, 576, },
{ 0, 0, 0, 0, 0, 141, 224, },
{ 0, 0, 0, 0, 0, 282, 448, },
{ 0, 0, 0, 0, 0, 564, 896, },
{ 0, 0, 0, 0, 1, 201, 864, },
{ 0, 0, 0, 0, 2, 403, 800, },
{ 0, 0, 0, 0, 4, 807, 672, },
{ 0, 0, 0, 0, 9, 687, 416, },
{ 0, 0, 0, 0, 19, 446, 832, },
{ 0, 0, 0, 0, 38, 893, 736, },
{ 0, 0, 0, 0, 77, 859, 544, },
{ 0, 0, 0, 0, 155, 791, 160, },
{ 0, 0, 0, 0, 311, 654, 320, },
{ 0, 0, 0, 0, 623, 380, 640, },
{ 0, 0, 0, 1, 318, 761, 352, },
{ 0, 0, 0, 2, 637, 594, 704, },
{ 0, 0, 0, 5, 347, 261, 480, },
{ 0, 0, 0, 10, 694, 523, 32, },
{ 0, 0, 0, 21, 461, 118, 64, },
{ 0, 0, 0, 42, 922, 236, 128, },
{ 0, 0, 0, 85, 916, 472, 256, },
{ 0, 0, 0, 171, 905, 16, 512, },
{ 0, 0, 0, 343, 882, 33, 96, },
{ 0, 0, 0, 687, 836, 66, 192, },
{ 0, 0, 1, 447, 744, 132, 384, },
{ 0, 0, 2, 895, 560, 264, 768, },
{ 0, 0, 5, 863, 192, 529, 608, },
{ 0, 0, 11, 798, 385, 131, 288, },
{ 0, 0, 23, 668, 770, 262, 576, },
{ 0, 0, 47, 409, 612, 525, 224, },
{ 0, 0, 94, 819, 297, 122, 448, },
{ 0, 0, 189, 710, 594, 244, 896, },
{ 0, 0, 379, 493, 260, 489, 864, },
{ 0, 0, 759, 58, 521, 51, 800, },
{ 0, 1, 590, 117, 114, 103, 672, },
{ 0, 3, 252, 234, 228, 207, 416, },
{ 0, 6, 504, 468, 456, 414, 832, },
{ 0, 13, 81, 8, 912, 829, 736, },
{ 0, 26, 162, 17, 897, 731, 544, },
{ 0, 52, 324, 35, 867, 535, 160, },
{ 0, 104, 648, 71, 807, 142, 320, },
{ 0, 209, 368, 143, 686, 284, 640, },
{ 0, 418, 736, 287, 444, 569, 352, },
{ 0, 837, 544, 574, 889, 210, 704, },
{ 1, 747, 161, 221, 850, 421, 480, },
{ 3, 566, 322, 443, 772, 843, 32, },
{ 7, 204, 644, 887, 617, 758, 64, },
{ 14, 409, 361, 847, 307, 588, 128, },
{ 28, 818, 723, 766, 615, 248, 256, },
{ 57, 709, 519, 605, 302, 496, 512, },
{ 115, 491, 111, 282, 605, 65, 96, },
{ 231, 54, 222, 565, 282, 130, 192, },
{ 462, 108, 445, 202, 564, 260, 384, },
};

View File

@ -2,7 +2,7 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -31,7 +31,6 @@
*/ */
/* vim: set ts=4 sw=4 et : */ /* vim: set ts=4 sw=4 et : */
#include <string.h>
#include "common.h" #include "common.h"
#include "general_field.h" #include "general_field.h"
@ -39,12 +38,12 @@ static char alphanum_puncs[] = "*,-./";
static char isoiec_puncs[] = "!\"%&'()*+,-./:;<=>?_ "; static char isoiec_puncs[] = "!\"%&'()*+,-./:;<=>?_ ";
/* Returns type of char at `i`. FNC1 counted as NUMERIC. Returns 0 if invalid char */ /* Returns type of char at `i`. FNC1 counted as NUMERIC. Returns 0 if invalid char */
static int general_field_type(char* general_field, int i) { static int general_field_type(char *general_field, int i) {
if (general_field[i] == '[' || (general_field[i] >= '0' && general_field[i] <= '9')) { if (general_field[i] == '[' || (general_field[i] >= '0' && general_field[i] <= '9')) {
return NUMERIC; return NUMERIC;
} }
if ((general_field[i] >= 'A' && general_field[i] <= 'Z') || strchr(alphanum_puncs, general_field[i])) { if ((general_field[i] >= 'A' && general_field[i] <= 'Z') || strchr(alphanum_puncs, general_field[i])) {
return ALPHA; return ALPHANUMERIC;
} }
if ((general_field[i] >= 'a' && general_field[i] <= 'z') || strchr(isoiec_puncs, general_field[i])) { if ((general_field[i] >= 'a' && general_field[i] <= 'z') || strchr(isoiec_puncs, general_field[i])) {
return ISOIEC; return ISOIEC;
@ -53,7 +52,7 @@ static int general_field_type(char* general_field, int i) {
} }
/* Returns true if next (including `i`) `num` chars of type `type`, or if given (non-zero), `type2` */ /* Returns true if next (including `i`) `num` chars of type `type`, or if given (non-zero), `type2` */
static int general_field_next(char* general_field, int i, int general_field_len, int num, int type, int type2) { static int general_field_next(char *general_field, int i, int general_field_len, int num, int type, int type2) {
if (i + num > general_field_len) { if (i + num > general_field_len) {
return 0; return 0;
} }
@ -67,7 +66,7 @@ static int general_field_next(char* general_field, int i, int general_field_len,
} }
/* Returns true if next (including `i`) `num` up to `max_num` chars of type `type` and occur at end */ /* Returns true if next (including `i`) `num` up to `max_num` chars of type `type` and occur at end */
static int general_field_next_terminate(char* general_field, int i, int general_field_len, int num, int max_num, int type) { static int general_field_next_terminate(char *general_field, int i, int general_field_len, int num, int max_num, int type) {
if (i + max_num < general_field_len) { if (i + max_num < general_field_len) {
return 0; return 0;
} }
@ -80,7 +79,7 @@ static int general_field_next_terminate(char* general_field, int i, int general_
} }
/* Returns true if none of the next (including `i`) `num` chars (or end occurs) of type `type` */ /* Returns true if none of the next (including `i`) `num` chars (or end occurs) of type `type` */
static int general_field_next_none(char* general_field, int i, int general_field_len, int num, int type) { static int general_field_next_none(char *general_field, int i, int general_field_len, int num, int type) {
for (; i < general_field_len && num; i++, num--) { for (; i < general_field_len && num; i++, num--) {
if (general_field_type(general_field, i) == type) { if (general_field_type(general_field, i) == type) {
return 0; return 0;
@ -91,7 +90,7 @@ static int general_field_next_none(char* general_field, int i, int general_field
/* Attempts to apply encoding rules from sections 7.2.5.5.1 to 7.2.5.5.3 /* Attempts to apply encoding rules from sections 7.2.5.5.1 to 7.2.5.5.3
* of ISO/IEC 24724:2011 (same as sections 5.4.1 to 5.4.3 of ISO/IEC 24723:2010) */ * of ISO/IEC 24724:2011 (same as sections 5.4.1 to 5.4.3 of ISO/IEC 24723:2010) */
INTERNAL int general_field_encode(char* general_field, int* p_mode, int* p_last_digit, char binary_string[]) { INTERNAL int general_field_encode(char *general_field, int *p_mode, int *p_last_digit, char binary_string[]) {
int i, d1, d2; int i, d1, d2;
int mode = *p_mode; int mode = *p_mode;
int last_digit = 0; /* Set to odd remaining digit at end if any */ int last_digit = 0; /* Set to odd remaining digit at end if any */
@ -107,7 +106,7 @@ INTERNAL int general_field_encode(char* general_field, int* p_mode, int* p_last_
if (i < general_field_len - 1) { /* If at least 2 characters remain */ if (i < general_field_len - 1) { /* If at least 2 characters remain */
if (type != NUMERIC || general_field_type(general_field, i + 1) != NUMERIC) { /* 7.2.5.5.1/5.4.1 a) */ if (type != NUMERIC || general_field_type(general_field, i + 1) != NUMERIC) { /* 7.2.5.5.1/5.4.1 a) */
strcat(binary_string, "0000"); /* Alphanumeric latch */ strcat(binary_string, "0000"); /* Alphanumeric latch */
mode = ALPHA; mode = ALPHANUMERIC;
} else { } else {
d1 = general_field[i] == '[' ? 10 : ctoi(general_field[i]); d1 = general_field[i] == '[' ? 10 : ctoi(general_field[i]);
d2 = general_field[i + 1] == '[' ? 10 : ctoi(general_field[i + 1]); d2 = general_field[i + 1] == '[' ? 10 : ctoi(general_field[i + 1]);
@ -117,14 +116,14 @@ INTERNAL int general_field_encode(char* general_field, int* p_mode, int* p_last_
} else { /* If 1 character remains */ } else { /* If 1 character remains */
if (type != NUMERIC) { /* 7.2.5.5.1/5.4.1 b) */ if (type != NUMERIC) { /* 7.2.5.5.1/5.4.1 b) */
strcat(binary_string, "0000"); /* Alphanumeric latch */ strcat(binary_string, "0000"); /* Alphanumeric latch */
mode = ALPHA; mode = ALPHANUMERIC;
} else { } else {
last_digit = general_field[i]; /* Ending with single digit. 7.2.5.5.1 c) and 5.4.1 c) dealt with separately outside this procedure */ last_digit = general_field[i]; /* Ending with single digit. 7.2.5.5.1 c) and 5.4.1 c) dealt with separately outside this procedure */
i++; i++;
} }
} }
break; break;
case ALPHA: case ALPHANUMERIC:
if (general_field[i] == '[') { /* 7.2.5.5.2/5.4.2 a) */ if (general_field[i] == '[') { /* 7.2.5.5.2/5.4.2 a) */
strcat(binary_string, "01111"); strcat(binary_string, "01111");
mode = NUMERIC; mode = NUMERIC;
@ -132,7 +131,7 @@ INTERNAL int general_field_encode(char* general_field, int* p_mode, int* p_last_
} else if (type == ISOIEC) { /* 7.2.5.5.2/5.4.2 b) */ } else if (type == ISOIEC) { /* 7.2.5.5.2/5.4.2 b) */
strcat(binary_string, "00100"); /* ISO/IEC 646 latch */ strcat(binary_string, "00100"); /* ISO/IEC 646 latch */
mode = ISOIEC; mode = ISOIEC;
} else if (general_field_next(general_field, i, general_field_len, 6, NUMERIC, 0)) { /* 7.2.5.5.2/5.4.2 c) */ } else if (general_field_next(general_field, i, general_field_len, 6, NUMERIC, 0)) { /* 7.2.5.5.2/5.4.2 c) */
strcat(binary_string, "000"); /* Numeric latch */ strcat(binary_string, "000"); /* Numeric latch */
mode = NUMERIC; mode = NUMERIC;
} else if (general_field_next_terminate(general_field, i, general_field_len, 4, 5 /*Can limit to 5 max due to above*/, NUMERIC)) { /* 7.2.5.5.2/5.4.2 d) */ } else if (general_field_next_terminate(general_field, i, general_field_len, 4, 5 /*Can limit to 5 max due to above*/, NUMERIC)) { /* 7.2.5.5.2/5.4.2 d) */
@ -159,10 +158,10 @@ INTERNAL int general_field_encode(char* general_field, int* p_mode, int* p_last_
if (next_10_not_isoiec && general_field_next(general_field, i, general_field_len, 4, NUMERIC, 0)) { /* 7.2.5.5.3/5.4.3 b) */ if (next_10_not_isoiec && general_field_next(general_field, i, general_field_len, 4, NUMERIC, 0)) { /* 7.2.5.5.3/5.4.3 b) */
strcat(binary_string, "000"); /* Numeric latch */ strcat(binary_string, "000"); /* Numeric latch */
mode = NUMERIC; mode = NUMERIC;
} else if (next_10_not_isoiec && general_field_next(general_field, i, general_field_len, 5, ALPHA, NUMERIC)) { /* 7.2.5.5.3/5.4.3 c) */ } else if (next_10_not_isoiec && general_field_next(general_field, i, general_field_len, 5, ALPHANUMERIC, NUMERIC)) { /* 7.2.5.5.3/5.4.3 c) */
/* Note this rule can produce longer bitstreams if most of the alphanumerics are numeric */ /* Note this rule can produce longer bitstreams if most of the alphanumerics are numeric */
strcat(binary_string, "00100"); /* Alphanumeric latch */ strcat(binary_string, "00100"); /* Alphanumeric latch */
mode = ALPHA; mode = ALPHANUMERIC;
} else if ((general_field[i] >= '0') && (general_field[i] <= '9')) { } else if ((general_field[i] >= '0') && (general_field[i] <= '9')) {
bin_append(general_field[i] - 43, 5, binary_string); bin_append(general_field[i] - 43, 5, binary_string);
i++; i++;

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2007-2017 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -33,13 +33,13 @@
#define __GENERAL_FIELD_H #define __GENERAL_FIELD_H
#define NUMERIC 110 #define NUMERIC 110
#define ALPHA 97 #define ALPHANUMERIC 97
#define ISOIEC 105 #define ISOIEC 105
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
INTERNAL int general_field_encode(char* general_field, int* p_mode, int* p_last_digit, char binary_string[]); INTERNAL int general_field_encode(char *general_field, int *p_mode, int *p_last_digit, char binary_string[]);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -31,7 +31,6 @@
*/ */
/* vim: set ts=4 sw=4 et : */ /* vim: set ts=4 sw=4 et : */
#include <string.h>
#include <stdio.h> #include <stdio.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <malloc.h> #include <malloc.h>
@ -69,6 +68,18 @@ static void itostr(char ai_string[], int ai_value) {
strcat(ai_string, ")"); strcat(ai_string, ")");
} }
/* Returns the number of times a character occurs in a string */
static int ustrchr_cnt(const unsigned char string[], const size_t length, const unsigned char c) {
int count = 0;
unsigned int i;
for (i = 0; i < length; i++) {
if (string[i] == c) {
count++;
}
}
return count;
}
INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const size_t src_len, char reduced[]) { INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const size_t src_len, char reduced[]) {
int i, j, last_ai, ai_latch; int i, j, last_ai, ai_latch;
char ai_string[7]; /* 6 char max "(NNNN)" */ char ai_string[7]; /* 6 char max "(NNNN)" */

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2007-2017 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2007 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -56,7 +56,6 @@ static const char widest_even[9] = {
1, 3, 5, 6, 8, 7, 5, 3, 1 1, 3, 5, 6, 8, 7, 5, 3, 1
}; };
static int widths[8];
static const char finder_pattern[45] = { static const char finder_pattern[45] = {
3, 8, 2, 1, 1, 3, 8, 2, 1, 1,
3, 5, 5, 1, 1, 3, 5, 5, 1, 1,

View File

@ -22,6 +22,14 @@ else()
add_definitions(-DNO_PNG) add_definitions(-DNO_PNG)
endif() endif()
set(BWIPP_TAR ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps.tar.xz)
set(BWIPP_PS ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps)
if(NOT EXISTS ${BWIPP_PS})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${BWIPP_TAR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools)
endif()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if(ZINT_DEBUG) if(ZINT_DEBUG)
add_compile_options("-g") add_compile_options("-g")

View File

@ -122,6 +122,8 @@ static void test_encode(int index, int generate, int debug) {
testStart(""); testStart("");
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise
int ret; int ret;
struct item { struct item {
int option_2; int option_2;
@ -348,6 +350,8 @@ static void test_encode(int index, int generate, int debug) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
char escaped[1024]; char escaped[1024];
char bwipp_buf[8192];
char bwipp_msg[1024];
for (int i = 0; i < data_size; i++) { for (int i = 0; i < data_size; i++) {
@ -377,6 +381,15 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); 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(symbol->symbology, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
}
} }
} }

View File

@ -320,6 +320,8 @@ static void test_encode(int index, int generate, int debug) {
testStart(""); testStart("");
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise
int ret; int ret;
struct item { struct item {
int symbology; int symbology;
@ -330,54 +332,55 @@ static void test_encode(int index, int generate, int debug) {
int expected_rows; int expected_rows;
int expected_width; int expected_width;
int bwipp_cmp;
char *comment; char *comment;
char *expected; char *expected;
}; };
struct item data[] = { struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, 1, -1, "AIM", 0, 1, 68, "Same as CODE128", /* 0*/ { BARCODE_CODABLOCKF, 1, -1, "AIM", 0, 1, 68, 1, "Same as CODE128 (not supported by BWIPP)",
"11010010000101000110001100010001010111011000101110110001100011101011" "11010010000101000110001100010001010111011000101110110001100011101011"
}, },
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAA", 0, 3, 101, "Defaults to rows 3, columns 9 (4 data); verified manually against bwipp and tec-it", /* 1*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAA", 0, 3, 101, 1, "Defaults to rows 3, columns 9 (4 data); verified manually against tec-it",
"11010000100101111011101001011000010100011000101000110001010001100010100011000110110011001100011101011" "11010000100101111011101001011000010100011000101000110001010001100010100011000110110011001100011101011"
"11010000100101111011101100010010010100011000101000110001010001100010111011110100100111101100011101011" "11010000100101111011101100010010010100011000101000110001010001100010111011110100100111101100011101011"
"11010000100101111011101011001110010111011110101111011101100001010011011101110111100101001100011101011" "11010000100101111011101011001110010111011110101111011101100001010011011101110111100101001100011101011"
}, },
/* 2*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAA", 0, 3, 101, "Defaults to rows 3, columns 9 (4 data); verified manually against bwipp and tec-it", /* 2*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAA", 0, 3, 101, 1, "Defaults to rows 3, columns 9 (4 data); verified manually against tec-it",
"11010000100101111011101001011000010100011000101000110001010001100010100011000110110011001100011101011" "11010000100101111011101001011000010100011000101000110001010001100010100011000110110011001100011101011"
"11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011" "11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011"
"11010000100101111011101011001110010100011000101000110001110110010010010110000111000101101100011101011" "11010000100101111011101011001110010100011000101000110001110110010010010110000111000101101100011101011"
}, },
/* 3*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAA", 0, 4, 101, "Defaults to rows 4, columns 9 (4 data); verified manually against bwipp and tec-it", /* 3*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAA", 0, 4, 101, 1, "Defaults to rows 4, columns 9 (4 data); verified manually against tec-it",
"11010000100101111011101001000011010100011000101000110001010001100010100011000110011001101100011101011" "11010000100101111011101001000011010100011000101000110001010001100010100011000110011001101100011101011"
"11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011" "11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011"
"11010000100101111011101011001110010100011000101000110001010001100010111011110100111101001100011101011" "11010000100101111011101011001110010100011000101000110001010001100010111011110100111101001100011101011"
"11010000100101111011101001101110010111011110101111011101110101100011101100100110010111001100011101011" "11010000100101111011101001101110010111011110101111011101110101100011101100100110010111001100011101011"
}, },
/* 4*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAAAAA", 0, 4, 101, "Defaults to rows 4, columns 9 (4 data); verified manually against bwipp and tec-it", /* 4*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAAAAA", 0, 4, 101, 1, "Defaults to rows 4, columns 9 (4 data); verified manually against tec-it",
"11010000100101111011101001000011010100011000101000110001010001100010100011000110011001101100011101011" "11010000100101111011101001000011010100011000101000110001010001100010100011000110011001101100011101011"
"11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011" "11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011"
"11010000100101111011101011001110010100011000101000110001010001100010100011000101111011101100011101011" "11010000100101111011101011001110010100011000101000110001010001100010100011000101111011101100011101011"
"11010000100101111011101001101110010100011000101000110001011110100010111011000100110000101100011101011" "11010000100101111011101001101110010100011000101000110001011110100010111011000100110000101100011101011"
}, },
/* 5*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAAAAAA", 0, 5, 101, "Defaults to rows 5, columns 9 (4 data); verified manually against bwipp (columns=4) and tec-it", /* 5*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAAAAAA", 0, 5, 101, 1, "Defaults to rows 5, columns 9 (4 data); verified manually against tec-it",
"11010000100101111011101000010110010100011000101000110001010001100010100011000100100011001100011101011" "11010000100101111011101000010110010100011000101000110001010001100010100011000100100011001100011101011"
"11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011" "11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011"
"11010000100101111011101011001110010100011000101000110001010001100010100011000101111011101100011101011" "11010000100101111011101011001110010100011000101000110001010001100010100011000101111011101100011101011"
"11010000100101111011101001101110010100011000101000110001010001100010111011110111101001001100011101011" "11010000100101111011101001101110010100011000101000110001010001100010111011110111101001001100011101011"
"11010000100101111011101001100111010111011110101111011101000110001010111101000110001010001100011101011" "11010000100101111011101001100111010111011110101111011101000110001010111101000110001010001100011101011"
}, },
/* 6*/ { BARCODE_CODABLOCKF, -1, 14, "AAAAAAAAAAAAAAA", 0, 2, 156, "Rows 2, columns 14 (9 data); verified manually against bwipp (columns=9) and tec-it", /* 6*/ { BARCODE_CODABLOCKF, -1, 14, "AAAAAAAAAAAAAAA", 0, 2, 156, 1, "Rows 2, columns 14 (9 data); verified manually against tec-it",
"110100001001011110111010100001100101000110001010001100010100011000101000110001010001100010100011000101000110001010001100010100011000110001000101100011101011" "110100001001011110111010100001100101000110001010001100010100011000101000110001010001100010100011000101000110001010001100010100011000110001000101100011101011"
"110100001001011110111011000100100101000110001010001100010100011000101000110001010001100010100011000101110111101110111101011011000110111000101101100011101011" "110100001001011110111011000100100101000110001010001100010100011000101000110001010001100010100011000101110111101110111101011011000110111000101101100011101011"
}, },
/* 7*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAAAAAAA", 0, 5, 101, "Defaults to rows 5, columns 9 (4 data); verified manually against bwipp (columns=4) and tec-it", /* 7*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAAAAAAA", 0, 5, 101, 1, "Defaults to rows 5, columns 9 (4 data); verified manually against tec-it",
"11010000100101111011101000010110010100011000101000110001010001100010100011000100100011001100011101011" "11010000100101111011101000010110010100011000101000110001010001100010100011000100100011001100011101011"
"11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011" "11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011"
"11010000100101111011101011001110010100011000101000110001010001100010100011000101111011101100011101011" "11010000100101111011101011001110010100011000101000110001010001100010100011000101111011101100011101011"
"11010000100101111011101001101110010100011000101000110001010001100010100011000111101011101100011101011" "11010000100101111011101001101110010100011000101000110001010001100010100011000111101011101100011101011"
"11010000100101111011101001100111010111011110101111011101011100011010001100010100011101101100011101011" "11010000100101111011101001100111010111011110101111011101011100011010001100010100011101101100011101011"
}, },
/* 8*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAA", 0, 6, 112, "Defaults to rows 6, columns 10 (5 data); verified manually against bwipp (columns=5) and tec-it", /* 8*/ { BARCODE_CODABLOCKF, -1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAA", 0, 6, 112, 1, "Defaults to rows 6, columns 10 (5 data); verified manually against tec-it",
"1101000010010111101110100001001101010001100010100011000101000110001010001100010100011000110110001101100011101011" "1101000010010111101110100001001101010001100010100011000101000110001010001100010100011000110110001101100011101011"
"1101000010010111101110110001001001010001100010100011000101000110001010001100010100011000110010011101100011101011" "1101000010010111101110110001001001010001100010100011000101000110001010001100010100011000110010011101100011101011"
"1101000010010111101110101100111001010001100010100011000101000110001010001100010100011000110011101001100011101011" "1101000010010111101110101100111001010001100010100011000101000110001010001100010100011000110011101001100011101011"
@ -385,23 +388,23 @@ static void test_encode(int index, int generate, int debug) {
"1101000010010111101110100110011101010001100010100011000101000110001010001100010100011000111001001101100011101011" "1101000010010111101110100110011101010001100010100011000101000110001010001100010100011000111001001101100011101011"
"1101000010010111101110101110011001011101111010111101110101110111101110100011010100001100110001010001100011101011" "1101000010010111101110101110011001011101111010111101110101110111101110100011010100001100110001010001100011101011"
}, },
/* 9*/ { BARCODE_CODABLOCKF, 4, -1, "CODABLOCK F 34567890123456789010040digit", 0, 4, 145, "AIM ISS-X-24 Figure 1", /* 9*/ { BARCODE_CODABLOCKF, 4, -1, "CODABLOCK F 34567890123456789010040digit", 0, 4, 145, 1, "AIM ISS-X-24 Figure 1",
"1101000010010111101110100100001101000100011010001110110101100010001010001100010001011000100011011101000111011010001000110110110011001100011101011" "1101000010010111101110100100001101000100011010001110110101100010001010001100010001011000100011011101000111011010001000110110110011001100011101011"
"1101000010010111101110110001001001011000111011011001100100011000101101100110010111011110100010110001110001011011000010100101100111001100011101011" "1101000010010111101110110001001001011000111011011001100100011000101101100110010111011110100010110001110001011011000010100101100111001100011101011"
"1101000010010111011110100011011101101111011010110011100100010110001110001011011000010100110111101101100100010010010001100100011000101100011101011" "1101000010010111011110100011011101101111011010110011100100010110001110001011011000010100110111101101100100010010010001100100011000101100011101011"
"1101000010010111101110100110111001001110110010000100110100001101001001101000010000110100100111101001101110111010111000110110010000101100011101011" "1101000010010111101110100110111001001110110010000100110100001101001001101000010000110100100111101001101110111010111000110110010000101100011101011"
}, },
/* 10*/ { BARCODE_CODABLOCKF, 3, -1, "CODABLOCK F Symbology", 0, 3, 145, "AIM ISS-X-24 Figure on front page", /* 10*/ { BARCODE_CODABLOCKF, 3, -1, "CODABLOCK F Symbology", 0, 3, 145, 1, "AIM ISS-X-24 Figure on front page",
"1101000010010111101110100101100001000100011010001110110101100010001010001100010001011000100011011101000111011010001000110111010111101100011101011" "1101000010010111101110100101100001000100011010001110110101100010001010001100010001011000100011011101000111011010001000110111010111101100011101011"
"1101000010010111101110110001001001011000111011011001100100011000101101100110011011101000110110111101111011101010010000110100100111101100011101011" "1101000010010111101110110001001001011000111011011001100100011000101101100110011011101000110110111101111011101010010000110100100111101100011101011"
"1101000010010111101110101100111001000111101011001010000100011110101001101000011011011110101110111101000011001011011101110101001111001100011101011" "1101000010010111101110101100111001000111101011001010000100011110101001101000011011011110101110111101000011001011011101110101001111001100011101011"
}, },
/* 11*/ { BARCODE_HIBC_BLOCKF, 3, -1, "A123BJC5D6E71", 0, 3, 123, "Verified manually against tec-it; differs from bwipp (columns=6) which uses Code C for final 71 (same no. of codewords)", /* 11*/ { BARCODE_HIBC_BLOCKF, 3, -1, "A123BJC5D6E71", 0, 3, 123, 0, "Verified manually against tec-it; differs from BWIPP (columns=6) which uses Code C for final 71 (same no. of codewords)",
"110100001001011110111010010110000110001001001010001100010011100110110011100101100101110010001011000100100001101100011101011" "110100001001011110111010010110000110001001001010001100010011100110110011100101100101110010001011000100100001101100011101011"
"110100001001011110111011000100100101101110001000100011011011100100101100010001100111010010001101000111001001101100011101011" "110100001001011110111011000100100101101110001000100011011011100100101100010001100111010010001101000111001001101100011101011"
"110100001001011110111010110011100111011011101001110011011010001000101110111101011100011011001110100100100110001100011101011" "110100001001011110111010110011100111011011101001110011011010001000101110111101011100011011001110100100100110001100011101011"
}, },
/* 12*/ { BARCODE_HIBC_BLOCKF, -1, -1, "$$52001510X3G", 0, 4, 101, "Verified manually against bwipp (columns=4); tec-it differs as adds unnecessary Code C at end of 1st line", /* 12*/ { BARCODE_HIBC_BLOCKF, -1, -1, "$$52001510X3G", 0, 4, 101, 1, "tec-it differs as adds unnecessary Code C at end of 1st line",
"11010000100101111011101001000011011000100100100100011001001000110011011100100101110011001100011101011" "11010000100101111011101001000011011000100100100100011001001000110011011100100101110011001100011101011"
"11010000100101110111101011000111011001001110110011011001101110100010111101110100001100101100011101011" "11010000100101110111101011000111011001001110110011011001101110100010111101110100001100101100011101011"
"11010000100101111011101011001110010011101100111000101101100101110011010001000100100011001100011101011" "11010000100101111011101011001110010011101100111000101101100101110011010001000100100011001100011101011"
@ -411,6 +414,8 @@ static void test_encode(int index, int generate, int debug) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
char escaped[1024]; char escaped[1024];
char bwipp_buf[8192];
char bwipp_msg[1024];
for (int i = 0; i < data_size; i++) { for (int i = 0; i < data_size; i++) {
@ -425,9 +430,9 @@ static void test_encode(int index, int generate, int debug) {
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) { if (generate) {
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, \"%s\",\n", printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); testUtilErrorName(data[i].ret), symbol->rows, data[i].bwipp_cmp, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n"); testUtilModulesDump(symbol, " ", "\n");
printf(" },\n"); printf(" },\n");
} else { } else {
@ -440,6 +445,19 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); 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(symbol->symbology, data[i].option_1, data[i].option_2, -1, debug)) {
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("%d: %s skipped, not BWIPP compatible\n", i, testUtilBarcodeName(symbol->symbology));
} else {
ret = testUtilBwipp(symbol, data[i].option_1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].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(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
}
}
} }
} }

View File

@ -241,6 +241,8 @@ static void test_encode(int index, int generate, int debug) {
testStart(""); testStart("");
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise
int ret; int ret;
struct item { struct item {
int symbology; int symbology;
@ -337,6 +339,8 @@ static void test_encode(int index, int generate, int debug) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
char escaped[1024]; char escaped[1024];
char bwipp_buf[8192];
char bwipp_msg[1024];
for (int i = 0; i < data_size; i++) { for (int i = 0; i < data_size; i++) {
@ -366,6 +370,15 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); 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(symbol->symbology, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].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(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
}
} }
} }

View File

@ -432,6 +432,8 @@ static void test_encode(int index, int generate, int debug) {
testStart(""); testStart("");
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise
int ret; int ret;
struct item { struct item {
int symbology; int symbology;
@ -521,10 +523,10 @@ static void test_encode(int index, int generate, int debug) {
/* 24*/ { BARCODE_EAN128, GS1_MODE, "[00]340433935039756615", 0, 1, 156, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", /* 24*/ { BARCODE_EAN128, GS1_MODE, "[00]340433935039756615", 0, 1, 156, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html",
"110100111001111010111011011001100100010110001001000110010100011000101000111101100010111011010001000110000100101001000011010111001100100111001101100011101011" "110100111001111010111011011001100100010110001001000110010100011000101000111101100010111011010001000110000100101001000011010111001100100111001101100011101011"
}, },
/* 25*/ { BARCODE_EAN14, GS1_MODE, "4070071967072", 0, 1, 134, "Verified manually against bwipp and tec-it", /* 25*/ { BARCODE_EAN14, GS1_MODE, "4070071967072", 0, 1, 134, "Verified manually against tec-it",
"11010011100111101011101100110110011000101000101100001001001100010011001011100100001011001001100010011001001110110111001001100011101011" "11010011100111101011101100110110011000101000101100001001001100010011001011100100001011001001100010011001001110110111001001100011101011"
}, },
/* 26*/ { BARCODE_NVE18, GS1_MODE, "40700000071967072", 0, 1, 156, "Verified manually against bwipp (sscc18) and tec-it", /* 26*/ { BARCODE_NVE18, GS1_MODE, "40700000071967072", 0, 1, 156, "Verified manually against tec-it",
"110100111001111010111011011001100110001010001011000010011011001100110110011001001100010011001011100100001011001001100010011001001110110111011101100011101011" "110100111001111010111011011001100110001010001011000010011011001100110110011001001100010011001011100100001011001001100010011001001110110111011101100011101011"
}, },
/* 27*/ { BARCODE_HIBC_128, UNICODE_MODE, "83278F8G9H0J2G", 0, 1, 211, "ANSI/HIBC 2.6 - 2016 Section 4.1, not same, uses different encoding (eg begins StartA instead of StartB)", /* 27*/ { BARCODE_HIBC_128, UNICODE_MODE, "83278F8G9H0J2G", 0, 1, 211, "ANSI/HIBC 2.6 - 2016 Section 4.1, not same, uses different encoding (eg begins StartA instead of StartB)",
@ -540,6 +542,8 @@ static void test_encode(int index, int generate, int debug) {
int data_size = sizeof(data) / sizeof(struct item); int data_size = sizeof(data) / sizeof(struct item);
char escaped[1024]; char escaped[1024];
char bwipp_buf[8192];
char bwipp_msg[1024];
for (int i = 0; i < data_size; i++) { for (int i = 0; i < data_size; i++) {
@ -569,6 +573,15 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); 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(symbol->symbology, -1, -1, -1, debug)) {
ret = testUtilBwipp(symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].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(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,8 @@ static void test_gs1_reduce(int index, int generate, int debug) {
testStart(""); testStart("");
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise
int ret; int ret;
struct item { struct item {
int symbology; int symbology;
@ -51,7 +53,7 @@ static void test_gs1_reduce(int index, int generate, int debug) {
}; };
struct item data[] = { struct item data[] = {
/* 0*/ { BARCODE_EAN128, -1, "12345678901234", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" }, /* 0*/ { BARCODE_EAN128, -1, "12345678901234", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/* 1*/ { BARCODE_EAN128, -1, "[01]12345678901234", "", 0, "Input mode ignored; verified manually against bwipp and tec-it", /* 1*/ { BARCODE_EAN128, -1, "[01]12345678901234", "", 0, "Input mode ignored; verified manually against tec-it",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110010001011000111010111101100011101011" "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110010001011000111010111101100011101011"
}, },
/* 2*/ { BARCODE_EAN128, GS1_MODE, "[01]12345678901234", "", 0, "Input mode ignored", /* 2*/ { BARCODE_EAN128, GS1_MODE, "[01]12345678901234", "", 0, "Input mode ignored",
@ -81,7 +83,7 @@ static void test_gs1_reduce(int index, int generate, int debug) {
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110111010011100010100001011010000110011100010100" "0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110111010011100010100001011010000110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001000101100011101011110100101111001100011101011" "1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001000101100011101011110100101111001100011101011"
}, },
/* 7*/ { BARCODE_EAN14, -1, "1234567890123", "", 0, "Input mode ignored; verified manually against bwipp and tec-it", /* 7*/ { BARCODE_EAN14, -1, "1234567890123", "", 0, "Input mode ignored; verified manually against tec-it",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011" "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
}, },
/* 8*/ { BARCODE_EAN14, GS1_MODE, "1234567890123", "", 0, "Input mode ignored", /* 8*/ { BARCODE_EAN14, GS1_MODE, "1234567890123", "", 0, "Input mode ignored",
@ -90,7 +92,7 @@ static void test_gs1_reduce(int index, int generate, int debug) {
/* 9*/ { BARCODE_EAN14, UNICODE_MODE, "1234567890123", "", 0, "Input mode ignored", /* 9*/ { BARCODE_EAN14, UNICODE_MODE, "1234567890123", "", 0, "Input mode ignored",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011" "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
}, },
/*10*/ { BARCODE_NVE18, -1, "12345678901234567", "", 0, "Input mode ignored; verified manually against bwipp (sscc18) and tec-it", /*10*/ { BARCODE_NVE18, -1, "12345678901234567", "", 0, "Input mode ignored; verified manually against tec-it",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011" "110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
}, },
/*11*/ { BARCODE_NVE18, GS1_MODE, "12345678901234567", "", 0, "Input mode ignored", /*11*/ { BARCODE_NVE18, GS1_MODE, "12345678901234567", "", 0, "Input mode ignored",
@ -109,25 +111,25 @@ static void test_gs1_reduce(int index, int generate, int debug) {
/*16*/ { BARCODE_RSS_EXP, UNICODE_MODE, "[20]12", "", 0, "Input mode ignored", /*16*/ { BARCODE_RSS_EXP, UNICODE_MODE, "[20]12", "", 0, "Input mode ignored",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101" "010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
}, },
/*17*/ { BARCODE_RSS_EXP_CC, -1, "[20]12", "[21]1234", 0, "Input mode ignored", /*17*/ { BARCODE_RSS_EXP_CC, -1, "[20]12", "[21]1234", 0, "Input mode ignored; verified manually against tec-it",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010" "001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010" "001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010" "001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001100100001010101001010000011110100000" "000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101" "010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
}, },
/*18*/ { BARCODE_RSS_EXP_CC, GS1_MODE, "[20]12", "[21]1234", 0, "Input mode ignored", /*18*/ { BARCODE_RSS_EXP_CC, GS1_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010" "001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010" "001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010" "001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001100100001010101001010000011110100000" "000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101" "010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
}, },
/*19*/ { BARCODE_RSS_EXP_CC, UNICODE_MODE, "[20]12", "[21]1234", 0, "Input mode ignored", /*19*/ { BARCODE_RSS_EXP_CC, UNICODE_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010" "001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010" "001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010" "001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001100100001010101001010000011110100000" "000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101" "010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
}, },
/*20*/ { BARCODE_RSS_EXPSTACK, -1, "12", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" }, /*20*/ { BARCODE_RSS_EXPSTACK, -1, "12", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
@ -141,25 +143,25 @@ static void test_gs1_reduce(int index, int generate, int debug) {
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101" "010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
}, },
/*24*/ { BARCODE_RSS_EXPSTACK_CC, -1, "12", "[21]1234", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" }, /*24*/ { BARCODE_RSS_EXPSTACK_CC, -1, "12", "[21]1234", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*25*/ { BARCODE_RSS_EXPSTACK_CC, -1, "[20]12", "[21]1234", 0, "Input mode ignored", /*25*/ { BARCODE_RSS_EXPSTACK_CC, -1, "[20]12", "[21]1234", 0, "Input mode ignored; verified manually against tec-it (same as BARCODE_RSS_EXP_CC above)",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010" "001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010" "001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010" "001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001100100001010101001010000011110100000" "000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101" "010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
}, },
/*26*/ { BARCODE_RSS_EXPSTACK_CC, GS1_MODE, "[20]12", "[21]1234", 0, "Input mode ignored", /*26*/ { BARCODE_RSS_EXPSTACK_CC, GS1_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010" "001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010" "001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010" "001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001100100001010101001010000011110100000" "000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101" "010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
}, },
/*27*/ { BARCODE_RSS_EXPSTACK_CC, UNICODE_MODE, "[20]12", "[21]1234", 0, "Input mode ignored", /*27*/ { BARCODE_RSS_EXPSTACK_CC, UNICODE_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010" "001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010" "001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010" "001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001100100001010101001010000011110100000" "000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101" "010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
}, },
}; };
@ -167,6 +169,9 @@ static void test_gs1_reduce(int index, int generate, int debug) {
char *text; char *text;
char bwipp_buf[8196];
char bwipp_msg[1024];
for (int i = 0; i < data_size; i++) { for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue; if (index != -1 && i != index) continue;
@ -207,6 +212,15 @@ static void test_gs1_reduce(int index, int generate, int debug) {
int width, row; int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); 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(symbol->symbology, -1, -1, -1, debug)) {
ret = testUtilBwipp(symbol, -1, -1, -1, text, length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].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(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -184,6 +184,8 @@ static void test_encode(int index, int generate, int debug) {
testStart(""); testStart("");
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise
int ret; int ret;
struct item { struct item {
int symbology; int symbology;
@ -228,6 +230,8 @@ static void test_encode(int index, int generate, int debug) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
char escaped[1024]; char escaped[1024];
char bwipp_buf[8192];
char bwipp_msg[1024];
for (int i = 0; i < data_size; i++) { for (int i = 0; i < data_size; i++) {
@ -257,6 +261,15 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); 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(symbol->symbology, -1, -1, -1, debug)) {
ret = testUtilBwipp(symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].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(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
}
} }
} }

View File

@ -120,7 +120,7 @@ static void test_pixel_plot(int index, int debug) {
ret = testUtilVerifyIdentify(symbol->outfile, debug); ret = testUtilVerifyIdentify(symbol->outfile, debug);
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
if (!(debug & 8)) { if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
} }

View File

@ -225,157 +225,157 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
char *testUtilBarcodeName(int symbology) { char *testUtilBarcodeName(int symbology) {
struct item { struct item {
int define;
char *name; char *name;
int define;
int val; int val;
}; };
struct item data[] = { struct item data[] = {
{ -1, "", 0 }, { "", -1, 0 },
{ BARCODE_CODE11, "BARCODE_CODE11", 1 }, { "BARCODE_CODE11", BARCODE_CODE11, 1 },
{ BARCODE_C25MATRIX, "BARCODE_C25MATRIX", 2 }, { "BARCODE_C25MATRIX", BARCODE_C25MATRIX, 2 },
{ BARCODE_C25INTER, "BARCODE_C25INTER", 3 }, { "BARCODE_C25INTER", BARCODE_C25INTER, 3 },
{ BARCODE_C25IATA, "BARCODE_C25IATA", 4 }, { "BARCODE_C25IATA", BARCODE_C25IATA, 4 },
{ -1, "", 5 }, { "", -1, 5 },
{ BARCODE_C25LOGIC, "BARCODE_C25LOGIC", 6 }, { "BARCODE_C25LOGIC", BARCODE_C25LOGIC, 6 },
{ BARCODE_C25IND, "BARCODE_C25IND", 7 }, { "BARCODE_C25IND", BARCODE_C25IND, 7 },
{ BARCODE_CODE39, "BARCODE_CODE39", 8 }, { "BARCODE_CODE39", BARCODE_CODE39, 8 },
{ BARCODE_EXCODE39, "BARCODE_EXCODE39", 9 }, { "BARCODE_EXCODE39", BARCODE_EXCODE39, 9 },
{ -1, "", 10 }, { "", -1, 10 },
{ -1, "", 11 }, { "", -1, 11 },
{ -1, "", 12 }, { "", -1, 12 },
{ BARCODE_EANX, "BARCODE_EANX", 13 }, { "BARCODE_EANX", BARCODE_EANX, 13 },
{ BARCODE_EANX_CHK, "BARCODE_EANX_CHK", 14 }, { "BARCODE_EANX_CHK", BARCODE_EANX_CHK, 14 },
{ -1, "", 15 }, { "", -1, 15 },
{ BARCODE_EAN128, "BARCODE_EAN128", 16 }, { "BARCODE_EAN128", BARCODE_EAN128, 16 },
{ -1, "", 17 }, { "", -1, 17 },
{ BARCODE_CODABAR, "BARCODE_CODABAR", 18 }, { "BARCODE_CODABAR", BARCODE_CODABAR, 18 },
{ -1, "", 19 }, { "", -1, 19 },
{ BARCODE_CODE128, "BARCODE_CODE128", 20 }, { "BARCODE_CODE128", BARCODE_CODE128, 20 },
{ BARCODE_DPLEIT, "BARCODE_DPLEIT", 21 }, { "BARCODE_DPLEIT", BARCODE_DPLEIT, 21 },
{ BARCODE_DPIDENT, "BARCODE_DPIDENT", 22 }, { "BARCODE_DPIDENT", BARCODE_DPIDENT, 22 },
{ BARCODE_CODE16K, "BARCODE_CODE16K", 23 }, { "BARCODE_CODE16K", BARCODE_CODE16K, 23 },
{ BARCODE_CODE49, "BARCODE_CODE49", 24 }, { "BARCODE_CODE49", BARCODE_CODE49, 24 },
{ BARCODE_CODE93, "BARCODE_CODE93", 25 }, { "BARCODE_CODE93", BARCODE_CODE93, 25 },
{ -1, "", 26 }, { "", -1, 26 },
{ -1, "", 27 }, { "", -1, 27 },
{ BARCODE_FLAT, "BARCODE_FLAT", 28 }, { "BARCODE_FLAT", BARCODE_FLAT, 28 },
{ BARCODE_RSS14, "BARCODE_RSS14", 29 }, { "BARCODE_RSS14", BARCODE_RSS14, 29 },
{ BARCODE_RSS_LTD, "BARCODE_RSS_LTD", 30 }, { "BARCODE_RSS_LTD", BARCODE_RSS_LTD, 30 },
{ BARCODE_RSS_EXP, "BARCODE_RSS_EXP", 31 }, { "BARCODE_RSS_EXP", BARCODE_RSS_EXP, 31 },
{ BARCODE_TELEPEN, "BARCODE_TELEPEN", 32 }, { "BARCODE_TELEPEN", BARCODE_TELEPEN, 32 },
{ -1, "", 33 }, { "", -1, 33 },
{ BARCODE_UPCA, "BARCODE_UPCA", 34 }, { "BARCODE_UPCA", BARCODE_UPCA, 34 },
{ BARCODE_UPCA_CHK, "BARCODE_UPCA_CHK", 35 }, { "BARCODE_UPCA_CHK", BARCODE_UPCA_CHK, 35 },
{ -1, "", 36 }, { "", -1, 36 },
{ BARCODE_UPCE, "BARCODE_UPCE", 37 }, { "BARCODE_UPCE", BARCODE_UPCE, 37 },
{ BARCODE_UPCE_CHK, "BARCODE_UPCE_CHK", 38 }, { "BARCODE_UPCE_CHK", BARCODE_UPCE_CHK, 38 },
{ -1, "", 39 }, { "", -1, 39 },
{ BARCODE_POSTNET, "BARCODE_POSTNET", 40 }, { "BARCODE_POSTNET", BARCODE_POSTNET, 40 },
{ -1, "", 41 }, { "", -1, 41 },
{ -1, "", 42 }, { "", -1, 42 },
{ -1, "", 43 }, { "", -1, 43 },
{ -1, "", 44 }, { "", -1, 44 },
{ -1, "", 45 }, { "", -1, 45 },
{ -1, "", 46 }, { "", -1, 46 },
{ BARCODE_MSI_PLESSEY, "BARCODE_MSI_PLESSEY", 47 }, { "BARCODE_MSI_PLESSEY", BARCODE_MSI_PLESSEY, 47 },
{ -1, "", 48 }, { "", -1, 48 },
{ BARCODE_FIM, "BARCODE_FIM", 49 }, { "BARCODE_FIM", BARCODE_FIM, 49 },
{ BARCODE_LOGMARS, "BARCODE_LOGMARS", 50 }, { "BARCODE_LOGMARS", BARCODE_LOGMARS, 50 },
{ BARCODE_PHARMA, "BARCODE_PHARMA", 51 }, { "BARCODE_PHARMA", BARCODE_PHARMA, 51 },
{ BARCODE_PZN, "BARCODE_PZN", 52 }, { "BARCODE_PZN", BARCODE_PZN, 52 },
{ BARCODE_PHARMA_TWO, "BARCODE_PHARMA_TWO", 53 }, { "BARCODE_PHARMA_TWO", BARCODE_PHARMA_TWO, 53 },
{ -1, "", 54 }, { "", -1, 54 },
{ BARCODE_PDF417, "BARCODE_PDF417", 55 }, { "BARCODE_PDF417", BARCODE_PDF417, 55 },
{ BARCODE_PDF417TRUNC, "BARCODE_PDF417TRUNC", 56 }, { "BARCODE_PDF417TRUNC", BARCODE_PDF417TRUNC, 56 },
{ BARCODE_MAXICODE, "BARCODE_MAXICODE", 57 }, { "BARCODE_MAXICODE", BARCODE_MAXICODE, 57 },
{ BARCODE_QRCODE, "BARCODE_QRCODE", 58 }, { "BARCODE_QRCODE", BARCODE_QRCODE, 58 },
{ -1, "", 59 }, { "", -1, 59 },
{ BARCODE_CODE128B, "BARCODE_CODE128B", 60 }, { "BARCODE_CODE128B", BARCODE_CODE128B, 60 },
{ -1, "", 61 }, { "", -1, 61 },
{ -1, "", 62 }, { "", -1, 62 },
{ BARCODE_AUSPOST, "BARCODE_AUSPOST", 63 }, { "BARCODE_AUSPOST", BARCODE_AUSPOST, 63 },
{ -1, "", 64 }, { "", -1, 64 },
{ -1, "", 65 }, { "", -1, 65 },
{ BARCODE_AUSREPLY, "BARCODE_AUSREPLY", 66 }, { "BARCODE_AUSREPLY", BARCODE_AUSREPLY, 66 },
{ BARCODE_AUSROUTE, "BARCODE_AUSROUTE", 67 }, { "BARCODE_AUSROUTE", BARCODE_AUSROUTE, 67 },
{ BARCODE_AUSREDIRECT, "BARCODE_AUSREDIRECT", 68 }, { "BARCODE_AUSREDIRECT", BARCODE_AUSREDIRECT, 68 },
{ BARCODE_ISBNX, "BARCODE_ISBNX", 69 }, { "BARCODE_ISBNX", BARCODE_ISBNX, 69 },
{ BARCODE_RM4SCC, "BARCODE_RM4SCC", 70 }, { "BARCODE_RM4SCC", BARCODE_RM4SCC, 70 },
{ BARCODE_DATAMATRIX, "BARCODE_DATAMATRIX", 71 }, { "BARCODE_DATAMATRIX", BARCODE_DATAMATRIX, 71 },
{ BARCODE_EAN14, "BARCODE_EAN14", 72 }, { "BARCODE_EAN14", BARCODE_EAN14, 72 },
{ BARCODE_VIN, "BARCODE_VIN", 73 }, { "BARCODE_VIN", BARCODE_VIN, 73 },
{ BARCODE_CODABLOCKF, "BARCODE_CODABLOCKF", 74 }, { "BARCODE_CODABLOCKF", BARCODE_CODABLOCKF, 74 },
{ BARCODE_NVE18, "BARCODE_NVE18", 75 }, { "BARCODE_NVE18", BARCODE_NVE18, 75 },
{ BARCODE_JAPANPOST, "BARCODE_JAPANPOST", 76 }, { "BARCODE_JAPANPOST", BARCODE_JAPANPOST, 76 },
{ BARCODE_KOREAPOST, "BARCODE_KOREAPOST", 77 }, { "BARCODE_KOREAPOST", BARCODE_KOREAPOST, 77 },
{ -1, "", 78 }, { "", -1, 78 },
{ BARCODE_RSS14STACK, "BARCODE_RSS14STACK", 79 }, { "BARCODE_RSS14STACK", BARCODE_RSS14STACK, 79 },
{ BARCODE_RSS14STACK_OMNI, "BARCODE_RSS14STACK_OMNI", 80 }, { "BARCODE_RSS14STACK_OMNI", BARCODE_RSS14STACK_OMNI, 80 },
{ BARCODE_RSS_EXPSTACK, "BARCODE_RSS_EXPSTACK", 81 }, { "BARCODE_RSS_EXPSTACK", BARCODE_RSS_EXPSTACK, 81 },
{ BARCODE_PLANET, "BARCODE_PLANET", 82 }, { "BARCODE_PLANET", BARCODE_PLANET, 82 },
{ -1, "", 83 }, { "", -1, 83 },
{ BARCODE_MICROPDF417, "BARCODE_MICROPDF417", 84 }, { "BARCODE_MICROPDF417", BARCODE_MICROPDF417, 84 },
{ BARCODE_ONECODE, "BARCODE_ONECODE", 85 }, { "BARCODE_ONECODE", BARCODE_ONECODE, 85 },
{ BARCODE_PLESSEY, "BARCODE_PLESSEY", 86 }, { "BARCODE_PLESSEY", BARCODE_PLESSEY, 86 },
{ BARCODE_TELEPEN_NUM, "BARCODE_TELEPEN_NUM", 87 }, { "BARCODE_TELEPEN_NUM", BARCODE_TELEPEN_NUM, 87 },
{ -1, "", 88 }, { "", -1, 88 },
{ BARCODE_ITF14, "BARCODE_ITF14", 89 }, { "BARCODE_ITF14", BARCODE_ITF14, 89 },
{ BARCODE_KIX, "BARCODE_KIX", 90 }, { "BARCODE_KIX", BARCODE_KIX, 90 },
{ -1, "", 91 }, { "", -1, 91 },
{ BARCODE_AZTEC, "BARCODE_AZTEC", 92 }, { "BARCODE_AZTEC", BARCODE_AZTEC, 92 },
{ BARCODE_DAFT, "BARCODE_DAFT", 93 }, { "BARCODE_DAFT", BARCODE_DAFT, 93 },
{ -1, "", 94 }, { "", -1, 94 },
{ -1, "", 95 }, { "", -1, 95 },
{ -1, "", 96 }, { "", -1, 96 },
{ BARCODE_MICROQR, "BARCODE_MICROQR", 97 }, { "BARCODE_MICROQR", BARCODE_MICROQR, 97 },
{ BARCODE_HIBC_128, "BARCODE_HIBC_128", 98 }, { "BARCODE_HIBC_128", BARCODE_HIBC_128, 98 },
{ BARCODE_HIBC_39, "BARCODE_HIBC_39", 99 }, { "BARCODE_HIBC_39", BARCODE_HIBC_39, 99 },
{ -1, "", 100 }, { "", -1, 100 },
{ -1, "", 101 }, { "", -1, 101 },
{ BARCODE_HIBC_DM, "BARCODE_HIBC_DM", 102 }, { "BARCODE_HIBC_DM", BARCODE_HIBC_DM, 102 },
{ -1, "", 103 }, { "", -1, 103 },
{ BARCODE_HIBC_QR, "BARCODE_HIBC_QR", 104 }, { "BARCODE_HIBC_QR", BARCODE_HIBC_QR, 104 },
{ -1, "", 105 }, { "", -1, 105 },
{ BARCODE_HIBC_PDF, "BARCODE_HIBC_PDF", 106 }, { "BARCODE_HIBC_PDF", BARCODE_HIBC_PDF, 106 },
{ -1, "", 107 }, { "", -1, 107 },
{ BARCODE_HIBC_MICPDF, "BARCODE_HIBC_MICPDF", 108 }, { "BARCODE_HIBC_MICPDF", BARCODE_HIBC_MICPDF, 108 },
{ -1, "", 109 }, { "", -1, 109 },
{ BARCODE_HIBC_BLOCKF, "BARCODE_HIBC_BLOCKF", 110 }, { "BARCODE_HIBC_BLOCKF", BARCODE_HIBC_BLOCKF, 110 },
{ -1, "", 111 }, { "", -1, 111 },
{ BARCODE_HIBC_AZTEC, "BARCODE_HIBC_AZTEC", 112 }, { "BARCODE_HIBC_AZTEC", BARCODE_HIBC_AZTEC, 112 },
{ -1, "", 113 }, { "", -1, 113 },
{ -1, "", 114 }, { "", -1, 114 },
{ BARCODE_DOTCODE, "BARCODE_DOTCODE", 115 }, { "BARCODE_DOTCODE", BARCODE_DOTCODE, 115 },
{ BARCODE_HANXIN, "BARCODE_HANXIN", 116 }, { "BARCODE_HANXIN", BARCODE_HANXIN, 116 },
{ -1, "", 117 }, { "", -1, 117 },
{ -1, "", 118 }, { "", -1, 118 },
{ -1, "", 119 }, { "", -1, 119 },
{ -1, "", 120 }, { "", -1, 120 },
{ BARCODE_MAILMARK, "BARCODE_MAILMARK", 121 }, { "BARCODE_MAILMARK", BARCODE_MAILMARK, 121 },
{ -1, "", 122 }, { "", -1, 122 },
{ -1, "", 123 }, { "", -1, 123 },
{ -1, "", 124 }, { "", -1, 124 },
{ -1, "", 125 }, { "", -1, 125 },
{ -1, "", 126 }, { "", -1, 126 },
{ -1, "", 127 }, { "", -1, 127 },
{ BARCODE_AZRUNE, "BARCODE_AZRUNE", 128 }, { "BARCODE_AZRUNE", BARCODE_AZRUNE, 128 },
{ BARCODE_CODE32, "BARCODE_CODE32", 129 }, { "BARCODE_CODE32", BARCODE_CODE32, 129 },
{ BARCODE_EANX_CC, "BARCODE_EANX_CC", 130 }, { "BARCODE_EANX_CC", BARCODE_EANX_CC, 130 },
{ BARCODE_EAN128_CC, "BARCODE_EAN128_CC", 131 }, { "BARCODE_EAN128_CC", BARCODE_EAN128_CC, 131 },
{ BARCODE_RSS14_CC, "BARCODE_RSS14_CC", 132 }, { "BARCODE_RSS14_CC", BARCODE_RSS14_CC, 132 },
{ BARCODE_RSS_LTD_CC, "BARCODE_RSS_LTD_CC", 133 }, { "BARCODE_RSS_LTD_CC", BARCODE_RSS_LTD_CC, 133 },
{ BARCODE_RSS_EXP_CC, "BARCODE_RSS_EXP_CC", 134 }, { "BARCODE_RSS_EXP_CC", BARCODE_RSS_EXP_CC, 134 },
{ BARCODE_UPCA_CC, "BARCODE_UPCA_CC", 135 }, { "BARCODE_UPCA_CC", BARCODE_UPCA_CC, 135 },
{ BARCODE_UPCE_CC, "BARCODE_UPCE_CC", 136 }, { "BARCODE_UPCE_CC", BARCODE_UPCE_CC, 136 },
{ BARCODE_RSS14STACK_CC, "BARCODE_RSS14STACK_CC", 137 }, { "BARCODE_RSS14STACK_CC", BARCODE_RSS14STACK_CC, 137 },
{ BARCODE_RSS14_OMNI_CC, "BARCODE_RSS14_OMNI_CC", 138 }, { "BARCODE_RSS14_OMNI_CC", BARCODE_RSS14_OMNI_CC, 138 },
{ BARCODE_RSS_EXPSTACK_CC, "BARCODE_RSS_EXPSTACK_CC", 139 }, { "BARCODE_RSS_EXPSTACK_CC", BARCODE_RSS_EXPSTACK_CC, 139 },
{ BARCODE_CHANNEL, "BARCODE_CHANNEL", 140 }, { "BARCODE_CHANNEL", BARCODE_CHANNEL, 140 },
{ BARCODE_CODEONE, "BARCODE_CODEONE", 141 }, { "BARCODE_CODEONE", BARCODE_CODEONE, 141 },
{ BARCODE_GRIDMATRIX, "BARCODE_GRIDMATRIX", 142 }, { "BARCODE_GRIDMATRIX", BARCODE_GRIDMATRIX, 142 },
{ BARCODE_UPNQR, "BARCODE_UPNQR", 143 }, { "BARCODE_UPNQR", BARCODE_UPNQR, 143 },
{ BARCODE_ULTRA, "BARCODE_ULTRA", 144 }, { "BARCODE_ULTRA", BARCODE_ULTRA, 144 },
{ BARCODE_RMQR, "BARCODE_RMQR", 145 }, { "BARCODE_RMQR", BARCODE_RMQR, 145 },
}; };
int data_size = sizeof(data) / sizeof(struct item); int data_size = sizeof(data) / sizeof(struct item);
@ -419,23 +419,23 @@ int testUtilSetSymbol(struct zint_symbol *symbol, int symbology, int input_mode,
char *testUtilErrorName(int error_number) { char *testUtilErrorName(int error_number) {
struct item { struct item {
int define;
char *name; char *name;
int define;
int val; int val;
}; };
struct item data[] = { struct item data[] = {
{ 0, "0", 0 }, { "0", 0, 0 },
{ -1, "", 1 }, { "", -1, 1 },
{ ZINT_WARN_INVALID_OPTION, "ZINT_WARN_INVALID_OPTION", 2 }, { "ZINT_WARN_INVALID_OPTION", ZINT_WARN_INVALID_OPTION, 2 },
{ ZINT_WARN_USES_ECI, "ZINT_WARN_USES_ECI", 3 }, { "ZINT_WARN_USES_ECI", ZINT_WARN_USES_ECI, 3 },
{ -1, "", 4 }, { "", -1, 4 },
{ ZINT_ERROR_TOO_LONG, "ZINT_ERROR_TOO_LONG", 5 }, { "ZINT_ERROR_TOO_LONG", ZINT_ERROR_TOO_LONG, 5 },
{ ZINT_ERROR_INVALID_DATA, "ZINT_ERROR_INVALID_DATA", 6 }, { "ZINT_ERROR_INVALID_DATA", ZINT_ERROR_INVALID_DATA, 6 },
{ ZINT_ERROR_INVALID_CHECK, "ZINT_ERROR_INVALID_CHECK", 7 }, { "ZINT_ERROR_INVALID_CHECK", ZINT_ERROR_INVALID_CHECK, 7 },
{ ZINT_ERROR_INVALID_OPTION, "ZINT_ERROR_INVALID_OPTION", 8 }, { "ZINT_ERROR_INVALID_OPTION", ZINT_ERROR_INVALID_OPTION, 8 },
{ ZINT_ERROR_ENCODING_PROBLEM, "ZINT_ERROR_ENCODING_PROBLEM", 9 }, { "ZINT_ERROR_ENCODING_PROBLEM", ZINT_ERROR_ENCODING_PROBLEM, 9 },
{ ZINT_ERROR_FILE_ACCESS, "ZINT_ERROR_FILE_ACCESS", 10 }, { "ZINT_ERROR_FILE_ACCESS", ZINT_ERROR_FILE_ACCESS, 10 },
{ ZINT_ERROR_MEMORY, "ZINT_ERROR_MEMORY", 11 }, { "ZINT_ERROR_MEMORY", ZINT_ERROR_MEMORY, 11 },
}; };
int data_size = sizeof(data) / sizeof(struct item); int data_size = sizeof(data) / sizeof(struct item);
@ -451,22 +451,22 @@ char *testUtilErrorName(int error_number) {
char *testUtilInputModeName(int input_mode) { char *testUtilInputModeName(int input_mode) {
struct item { struct item {
int define;
char *name; char *name;
int define;
int val; int val;
}; };
struct item data[] = { struct item data[] = {
{ DATA_MODE, "DATA_MODE", 0 }, { "DATA_MODE", DATA_MODE, 0 },
{ UNICODE_MODE, "UNICODE_MODE", 1 }, { "UNICODE_MODE", UNICODE_MODE, 1 },
{ GS1_MODE, "GS1_MODE", 2 }, { "GS1_MODE", GS1_MODE, 2 },
{ -1, "", 3 }, { "", -1, 3 },
{ -1, "", 4 }, { "", -1, 4 },
{ -1, "", 5 }, { "", -1, 5 },
{ -1, "", 6 }, { "", -1, 6 },
{ -1, "", 7 }, { "", -1, 7 },
{ DATA_MODE | ESCAPE_MODE, "DATA_MODE | ESCAPE_MODE", 8 }, { "DATA_MODE | ESCAPE_MODE", DATA_MODE | ESCAPE_MODE, 8 },
{ UNICODE_MODE | ESCAPE_MODE, "UNICODE_MODE | ESCAPE_MODE", 9 }, { "UNICODE_MODE | ESCAPE_MODE", UNICODE_MODE | ESCAPE_MODE, 9 },
{ GS1_MODE | ESCAPE_MODE, "GS1_MODE | ESCAPE_MODE", 10 }, { "GS1_MODE | ESCAPE_MODE", GS1_MODE | ESCAPE_MODE, 10 },
}; };
int data_size = sizeof(data) / sizeof(struct item); int data_size = sizeof(data) / sizeof(struct item);
@ -1391,9 +1391,9 @@ int testUtilVerifyIdentify(char *filename, int debug) {
return -1; return -1;
} }
// Verbose option does a more thorough check // Verbose option does a more thorough check
if (debug & ZINT_DEBUG_PRINT) { if (debug & ZINT_DEBUG_TEST_PRINT) {
// Verbose very noisy though so for quick check just return default output // Verbose very noisy though so for quick check just return default output
if (debug & 4) { if (debug & ZINT_DEBUG_TEST_LESS_NOISY) {
sprintf(buf, "identify %s", filename); sprintf(buf, "identify %s", filename);
} else { } else {
sprintf(buf, "identify -verbose %s", filename); sprintf(buf, "identify -verbose %s", filename);
@ -1416,7 +1416,7 @@ int testUtilVerifyInkscape(char *filename, int debug) {
if (strlen(filename) > 512) { if (strlen(filename) > 512) {
return -1; return -1;
} }
if (debug & ZINT_DEBUG_PRINT) { if (debug & ZINT_DEBUG_TEST_PRINT) {
sprintf(buf, "inkscape -z -f %s", filename); // Prints nothing unless bad sprintf(buf, "inkscape -z -f %s", filename); // Prints nothing unless bad
printf("%s\n", buf); printf("%s\n", buf);
} else { } else {
@ -1437,12 +1437,522 @@ int testUtilVerifyGhostscript(char *filename, int debug) {
if (strlen(filename) > 512) { if (strlen(filename) > 512) {
return -1; return -1;
} }
if (debug & ZINT_DEBUG_PRINT) { if (debug & ZINT_DEBUG_TEST_PRINT) {
sprintf(buf, "gs -dNOPAUSE -dBATCH -sDEVICE=nullpage -q %s", filename); // Prints nothing of interest with or without -q unless bad sprintf(buf, "gs -dNOPAUSE -dBATCH -dNODISPLAY -q %s", filename); // Prints nothing of interest with or without -q unless bad
printf("%s\n", buf); printf("%s\n", buf);
} else { } else {
sprintf(buf, "gs -dNOPAUSE -dBATCH -sDEVICE=nullpage -q %s", filename); sprintf(buf, "gs -dNOPAUSE -dBATCH -dNODISPLAY -q %s", filename);
} }
return system(buf); return system(buf);
} }
static char *testUtilBwippName(int symbology, int option_1, int option_2, int option_3, int *linear_row_height, int *gs1_cvt) {
struct item {
char *name;
int define;
int val;
int can_option_1;
int can_option_2;
int can_option_3;
int linear_row_height;
int gs1_cvt;
};
struct item data[] = {
{ "", -1, 0, 0, 0, 0, 0, 0, },
{ "code11", BARCODE_CODE11, 1, 0, 1, 0, 0, 0, },
{ "matrix2of5", BARCODE_C25MATRIX, 2, 0, 0, 0, 0, 0, },
{ "interleaved2of5", BARCODE_C25INTER, 3, 0, 0, 0, 0, 0, },
{ "iata2of5", BARCODE_C25IATA, 4, 0, 0, 0, 0, 0, },
{ "", -1, 5, 0, 0, 0, 0, 0, },
{ "datalogic2of5", BARCODE_C25LOGIC, 6, 0, 0, 0, 0, 0, },
{ "industrial2of5", BARCODE_C25IND, 7, 0, 0, 0, 0, 0, },
{ "code39", BARCODE_CODE39, 8, 0, 1, 0, 0, 0, },
{ "code39ext", BARCODE_EXCODE39, 9, 0, 1, 0, 0, 0, },
{ "", -1, 10, 0, 0, 0, 0, 0, },
{ "", -1, 11, 0, 0, 0, 0, 0, },
{ "", -1, 12, 0, 0, 0, 0, 0, },
{ "ean13", BARCODE_EANX, 13, 0, 0, 0, 0, 0, },
{ "ean13", BARCODE_EANX_CHK, 14, 0, 0, 0, 0, 0, },
{ "", -1, 15, 0, 0, 0, 0, 0, },
{ "gs1-128", BARCODE_EAN128, 16, 0, 0, 0, 0, 1 /*gs1_cnt*/, },
{ "", -1, 17, 0, 0, 0, 0, 0, },
{ "rationalizedCodabar", BARCODE_CODABAR, 18, 0, 0, 0, 0, 0, },
{ "", -1, 19, 0, 0, 0, 0, 0, },
{ "code128", BARCODE_CODE128, 20, 0, 0, 0, 0, 0, },
{ "leitcode", BARCODE_DPLEIT, 21, 0, 0, 0, 0, 0, },
{ "identcode", BARCODE_DPIDENT, 22, 0, 0, 0, 0, 0, },
{ "code16k", BARCODE_CODE16K, 23, 0, 0, 0, 0, 0, },
{ "code49", BARCODE_CODE49, 24, 0, 0, 0, 0, 0, },
{ "code93", BARCODE_CODE93, 25, 0, 0, 0, 0, 0, },
{ "", -1, 26, 0, 0, 0, 0, 0, },
{ "", -1, 27, 0, 0, 0, 0, 0, },
{ "flattermarken", BARCODE_FLAT, 28, 0, 0, 0, 0, 0, },
{ "databaromni", BARCODE_RSS14, 29, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "databarlimited", BARCODE_RSS_LTD, 30, 0, 0, 0, 0, 1, },
{ "databarexpanded", BARCODE_RSS_EXP, 31, 0, 1, 0, 1 /*linear_row_height*/, 1, },
{ "telepen", BARCODE_TELEPEN, 32, 0, 0, 0, 0, 0, },
{ "", -1, 33, 0, 0, 0, 0, 0, },
{ "upca", BARCODE_UPCA, 34, 0, 0, 0, 0, 0, },
{ "upca", BARCODE_UPCA_CHK, 35, 0, 0, 0, 0, 0, },
{ "", -1, 36, 0, 0, 0, 0, 0, },
{ "upce", BARCODE_UPCE, 37, 0, 0, 0, 0, 0, },
{ "upce", BARCODE_UPCE_CHK, 38, 0, 0, 0, 0, 0, },
{ "", -1, 39, 0, 0, 0, 0, 0, },
{ "postnet", BARCODE_POSTNET, 40, 0, 0, 0, 0, 0, },
{ "", -1, 41, 0, 0, 0, 0, 0, },
{ "", -1, 42, 0, 0, 0, 0, 0, },
{ "", -1, 43, 0, 0, 0, 0, 0, },
{ "", -1, 44, 0, 0, 0, 0, 0, },
{ "", -1, 45, 0, 0, 0, 0, 0, },
{ "", -1, 46, 0, 0, 0, 0, 0, },
{ "msi", BARCODE_MSI_PLESSEY, 47, 0, 0, 0, 0, 0, },
{ "", -1, 48, 0, 0, 0, 0, 0, },
{ "symbol", BARCODE_FIM, 49, 0, 0, 0, 0, 0, },
{ "code39", BARCODE_LOGMARS, 50, 0, 1, 0, 0, 0, },
{ "pharmacode", BARCODE_PHARMA, 51, 0, 0, 0, 0, 0, },
{ "pzn", BARCODE_PZN, 52, 0, 0, 0, 0, 0, },
{ "pharmacode2", BARCODE_PHARMA_TWO, 53, 0, 0, 0, 0, 0, },
{ "", -1, 54, 0, 0, 0, 0, 0, },
{ "pdf417", BARCODE_PDF417, 55, 0, 0, 0, 0, 0, },
{ "pdf417compact", BARCODE_PDF417TRUNC, 56, 0, 0, 0, 0, 0, },
{ "maxicode", BARCODE_MAXICODE, 57, 0, 0, 0, 0, 0, },
{ "qrcode", BARCODE_QRCODE, 58, 0, 0, 0, 0, 0, },
{ "", -1, 59, 0, 0, 0, 0, 0, },
{ "", BARCODE_CODE128B, 60, 0, 0, 0, 0, 0, },
{ "", -1, 61, 0, 0, 0, 0, 0, },
{ "", -1, 62, 0, 0, 0, 0, 0, },
{ "auspost", BARCODE_AUSPOST, 63, 0, 0, 0, 0, 0, },
{ "", -1, 64, 0, 0, 0, 0, 0, },
{ "", -1, 65, 0, 0, 0, 0, 0, },
{ "", BARCODE_AUSREPLY, 66, 0, 0, 0, 0, 0, },
{ "", BARCODE_AUSROUTE, 67, 0, 0, 0, 0, 0, },
{ "", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, },
{ "isbn", BARCODE_ISBNX, 69, 0, 0, 0, 0, 0, },
{ "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, },
{ "datamatrix", BARCODE_DATAMATRIX, 71, 0, 0, 0, 0, 0, },
{ "ean14", BARCODE_EAN14, 72, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "code39", BARCODE_VIN, 73, 0, 0, 0, 0, 0, },
{ "codablockf", BARCODE_CODABLOCKF, 74, 1, 1, 0, 0, 0, },
{ "sscc18", BARCODE_NVE18, 75, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "japanpost", BARCODE_JAPANPOST, 76, 0, 0, 0, 0, 0, },
{ "", BARCODE_KOREAPOST, 77, 0, 0, 0, 0, 0, },
{ "", -1, 78, 0, 0, 0, 0, 0, },
{ "databarstacked", BARCODE_RSS14STACK, 79, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "databarstackedomni", BARCODE_RSS14STACK_OMNI, 80, 0, 0, 0, 0, 1, },
{ "databarexpandedstacked", BARCODE_RSS_EXPSTACK, 81, 0, 1, 0, 0, 1, },
{ "planet", BARCODE_PLANET, 82, 0, 0, 0, 0, 0, },
{ "", -1, 83, 0, 0, 0, 0, 0, },
{ "micropdf417", BARCODE_MICROPDF417, 84, 0, 0, 0, 0, 0, },
{ "onecode", BARCODE_ONECODE, 85, 0, 0, 0, 0, 0, },
{ "plessey", BARCODE_PLESSEY, 86, 0, 0, 0, 0, 0, },
{ "telepennumeric", BARCODE_TELEPEN_NUM, 87, 0, 0, 0, 0, 0, },
{ "", -1, 88, 0, 0, 0, 0, 0, },
{ "itf14", BARCODE_ITF14, 89, 0, 0, 0, 0, 0, },
{ "kix", BARCODE_KIX, 90, 0, 0, 0, 0, 0, },
{ "", -1, 91, 0, 0, 0, 0, 0, },
{ "azteccode", BARCODE_AZTEC, 92, 0, 0, 0, 0, 0, },
{ "daft", BARCODE_DAFT, 93, 0, 0, 0, 0, 0, },
{ "", -1, 94, 0, 0, 0, 0, 0, },
{ "", -1, 95, 0, 0, 0, 0, 0, },
{ "", -1, 96, 0, 0, 0, 0, 0, },
{ "microqrcode", BARCODE_MICROQR, 97, 0, 0, 0, 0, 0, },
{ "hibccode128", BARCODE_HIBC_128, 98, 0, 0, 0, 0, 0, },
{ "hibccode39", BARCODE_HIBC_39, 99, 0, 0, 0, 0, 0, },
{ "", -1, 100, 0, 0, 0, 0, 0, },
{ "", -1, 101, 0, 0, 0, 0, 0, },
{ "hibcdatamatrix", BARCODE_HIBC_DM, 102, 0, 0, 0, 0, 0, },
{ "", -1, 103, 0, 0, 0, 0, 0, },
{ "hibcqrcode", BARCODE_HIBC_QR, 104, 0, 0, 0, 0, 0, },
{ "", -1, 105, 0, 0, 0, 0, 0, },
{ "hibcpdf417", BARCODE_HIBC_PDF, 106, 0, 0, 0, 0, 0, },
{ "", -1, 107, 0, 0, 0, 0, 0, },
{ "hibcmicropdf417", BARCODE_HIBC_MICPDF, 108, 0, 0, 0, 0, 0, },
{ "", -1, 109, 0, 0, 0, 0, 0, },
{ "hibccodablockf", BARCODE_HIBC_BLOCKF, 110, 1, 1, 0, 0, 0, },
{ "", -1, 111, 0, 0, 0, 0, 0, },
{ "hibcazteccode", BARCODE_HIBC_AZTEC, 112, 0, 0, 0, 0, 0, },
{ "", -1, 113, 0, 0, 0, 0, 0, },
{ "", -1, 114, 0, 0, 0, 0, 0, },
{ "dotcode", BARCODE_DOTCODE, 115, 0, 0, 0, 0, 0, },
{ "hanxin", BARCODE_HANXIN, 116, 0, 0, 0, 0, 0, },
{ "", -1, 117, 0, 0, 0, 0, 0, },
{ "", -1, 118, 0, 0, 0, 0, 0, },
{ "", -1, 119, 0, 0, 0, 0, 0, },
{ "", -1, 120, 0, 0, 0, 0, 0, },
{ "mailmark", BARCODE_MAILMARK, 121, 0, 0, 0, 0, 0, },
{ "", -1, 122, 0, 0, 0, 0, 0, },
{ "", -1, 123, 0, 0, 0, 0, 0, },
{ "", -1, 124, 0, 0, 0, 0, 0, },
{ "", -1, 125, 0, 0, 0, 0, 0, },
{ "", -1, 126, 0, 0, 0, 0, 0, },
{ "", -1, 127, 0, 0, 0, 0, 0, },
{ "aztecrune", BARCODE_AZRUNE, 128, 0, 0, 0, 0, 0, },
{ "code32", BARCODE_CODE32, 129, 0, 0, 0, 0, 0, },
{ "ean13composite", BARCODE_EANX_CC, 130, 1, 0, 0, 72 /*linear_row_height*/, 1 /*gs1_cvt*/, },
{ "gs1-128composite", BARCODE_EAN128_CC, 131, 1, 0, 0, 36, 1, },
{ "databaromnicomposite", BARCODE_RSS14_CC, 132, 1, 0, 0, 33, 1, },
{ "databarlimitedcomposite", BARCODE_RSS_LTD_CC, 133, 1, 0, 0, 0, 1, },
{ "databarexpandedcomposite", BARCODE_RSS_EXP_CC, 134, 1, 1, 0, 0, 1, },
{ "upcacomposite", BARCODE_UPCA_CC, 135, 1, 0, 0, 72, 1, },
{ "upcecomposite", BARCODE_UPCE_CC, 136, 1, 0, 0, 72, 1, },
{ "databarstackedcomposite", BARCODE_RSS14STACK_CC, 137, 1, 0, 0, 0, 1, },
{ "databarstackedomnicomposite", BARCODE_RSS14_OMNI_CC, 138, 1, 0, 0, 0, 1, },
{ "databarexpandedstackedcomposite", BARCODE_RSS_EXPSTACK_CC, 139, 1, 1, 0, 0, 1, },
{ "channelcode", BARCODE_CHANNEL, 140, 0, 0, 0, 0, 0, },
{ "codeone", BARCODE_CODEONE, 141, 0, 0, 0, 0, 0, },
{ "", BARCODE_GRIDMATRIX, 142, 0, 0, 0, 0, 0, },
{ "", BARCODE_UPNQR, 143, 0, 0, 0, 0, 0, },
{ "ultracode", BARCODE_ULTRA, 144, 0, 0, 0, 0, 0, },
{ "rectangularmicroqrcode", BARCODE_RMQR, 145, 0, 0, 0, 0, 0, },
};
int data_size = ARRAY_SIZE(data);
if (symbology < 0 || symbology >= data_size) {
return NULL;
}
if (data[symbology].val != symbology || (data[symbology].define != -1 && data[symbology].define != symbology)) { // Self-check
fprintf(stderr, "testUtilBarcodeName data table out of sync (%d)\n", symbology);
abort();
}
if (data[symbology].name[0] == '\0') {
return NULL;
}
if ((option_1 != -1 && !data[symbology].can_option_1) || (option_2 != -1 && !data[symbology].can_option_2)
|| (option_3 != -1 && !data[symbology].can_option_3)) {
return NULL;
}
if (symbology == BARCODE_CODE11) {
if (option_2 != 1 && option_2 != 2) { /* 2 check digits (Zint default) not supported */
return NULL;
}
} else if (symbology == BARCODE_CODABLOCKF || symbology == BARCODE_HIBC_BLOCKF) {
if (option_1 == 1) { /* Single row i.e. CODE128 not supported */
return NULL;
}
}
if (linear_row_height) {
*linear_row_height = data[symbology].linear_row_height;
}
if (gs1_cvt) {
*gs1_cvt = data[symbology].gs1_cvt;
}
return data[symbology].name;
}
int testUtilCanBwipp(int symbology, int option_1, int option_2, int option_3, int debug) {
if (testUtilBwippName(symbology, option_1, option_2, option_3, NULL, NULL) != NULL) {
return 1;
}
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("testUtilCanBwipp: not supported %s, option_1 %d, option_2 %d, option_3 %d\n", testUtilBarcodeName(symbology), option_1, option_2, option_3);
}
return 0;
}
static void testUtilBwippCvtGS1Data(char *bwipp_data) {
char *b;
for (b = bwipp_data; *b; b++) {
if (*b == '[') {
*b = '(';
} else if (*b == ']') {
*b = ')';
}
}
}
static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const char *data, int length, int *parse) {
char *b = bwipp_data;
char *be = b + bwipp_data_size;
unsigned char *d = (unsigned char *) data;
unsigned char *de = (unsigned char *) data + length;
*parse = 0;
while (b < be && d < de) {
if (*d < 0x20 || *d >= 0x7F || *d == '\'') { /* Escape single quote also to avoid having to do proper shell escaping TODO: proper shell escaping */
sprintf(b, "^%03u", *d++);
b += 4;
*parse = 1;
} else {
*b++ = *d++;
}
}
if (b == be && d < de) {
fprintf(stderr, "testUtilBwippEscape: bwipp_data buffer full\n");
return NULL;
}
*b = '\0';
return bwipp_data;
}
#define GS_INITIAL_LEN 35 /* Length of cmd up to -q */
int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, int option_3, const char *data, int length, const char *primary, char *buffer, int buffer_size) {
const char *cmd_fmt = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s' ../tools/bwipp_dump.ps";
const char *cmd_opts_fmt = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s' -so='%s' ../tools/bwipp_dump.ps";
const char *cmd_fmt2 = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2043s' -sd2='%s' ../tools/bwipp_dump.ps"; // If data > 2K
const char *cmd_opts_fmt2 = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2043s' -sd2='%s' -so='%s' ../tools/bwipp_dump.ps";
int symbology = symbol->symbology;
int data_len = length == -1 ? (int) strlen(data) : length;
int primary_len = primary ? (int) strlen(primary) : 0;
int max_data_len = 4 + primary_len + 1 + 1 + data_len * 4; /* 4 AI prefix + primary + '|' + leading zero + escaped data */
char cmd[max_data_len + 1024];
char *bwipp_barcode = NULL;
char *bwipp_opts = NULL;
char bwipp_data[max_data_len + 1];
char bwipp_opts_buf[512];
int bwipp_row_height[symbol->rows];
int linear_row_height;
int gs1_cvt;
FILE *fp = NULL;
int cnt;
char *b = buffer;
char *be = buffer + buffer_size;
int r, h;
int parse;
bwipp_data[0] = bwipp_opts_buf[0] = '\0';
bwipp_barcode = testUtilBwippName(symbology, option_1, option_2, option_3, &linear_row_height, &gs1_cvt);
if (!bwipp_barcode) {
fprintf(stderr, "testUtilBwipp: no mapping for %s, option_1 %d, option_2 %d, option_3 %d\n", testUtilBarcodeName(symbology), option_1, option_2, option_3);
return -1;
}
for (r = 0; r < symbol->rows; r++) {
bwipp_row_height[r] = symbol->row_height[r];
}
if (linear_row_height) {
bwipp_row_height[symbol->rows - 1] = linear_row_height;
}
if (is_composite(symbology)) {
if (symbology == BARCODE_EANX_CC && primary_len <= 7) {
bwipp_barcode = "ean8composite";
}
if (!primary) {
fprintf(stderr, "testUtilBwipp: no primary data given %s\n", testUtilBarcodeName(symbology));
return -1;
}
if (*primary != '[' && symbology != BARCODE_EANX_CC && symbology != BARCODE_UPCE_CC && symbology != BARCODE_UPCA_CC) {
strcat(bwipp_data, "(01)");
}
strcat(bwipp_data, primary);
strcat(bwipp_data, "|");
strcat(bwipp_data, data);
testUtilBwippCvtGS1Data(bwipp_data);
if (option_1 > 0) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sccversion=%c", strlen(bwipp_opts_buf) ? " " : "", option_1 == 1 ? 'a' : option_1 == 2 ? 'b' : 'c');
bwipp_opts = bwipp_opts_buf;
}
if (option_2 > 0) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%ssegments=%d", strlen(bwipp_opts_buf) ? " " : "", option_2 * 2);
bwipp_opts = bwipp_opts_buf;
}
} else {
if (gs1_cvt) {
if (*data != '[') {
strcat(bwipp_data, symbology == BARCODE_NVE18 ? "(00)" : "(01)");
}
strcat(bwipp_data, data);
testUtilBwippCvtGS1Data(bwipp_data);
if (option_2 > 0) {
if (symbology == BARCODE_RSS_EXP || symbology == BARCODE_RSS_EXPSTACK) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%ssegments=%d", strlen(bwipp_opts_buf) ? " " : "", option_2 * 2);
bwipp_opts = bwipp_opts_buf;
}
}
} else {
testUtilBwippEscape(bwipp_data, sizeof(bwipp_data), data, data_len, &parse);
if (parse) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sparse", strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
}
if (symbology == BARCODE_CODE93) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sincludecheck", strlen(bwipp_opts_buf) ? " " : "");
if (parse) {
bwipp_barcode = "code93ext";
}
bwipp_opts = bwipp_opts_buf;
} else if (symbology == BARCODE_PZN) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%spzn8", strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
} else if (symbology == BARCODE_TELEPEN_NUM) {
if (data_len & 1) { // Add leading zero
memmove(bwipp_data + 1, bwipp_data, strlen(bwipp_data) + 1);
*bwipp_data = '0';
}
} else if (symbology == BARCODE_CODABLOCKF || symbology == BARCODE_HIBC_BLOCKF) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%ssepheight=0", strlen(bwipp_opts_buf) ? " " : "");
if (option_1 > 0) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%srows=%d", strlen(bwipp_opts_buf) ? " " : "", option_1);
}
//} else { /* BWIPP does not really support both row and column given */
if (option_2 > 0) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%scolumns=%d", strlen(bwipp_opts_buf) ? " " : "", option_2 - 5);
} else {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%scolumns=%d", strlen(bwipp_opts_buf) ? " " : "", (symbol->width - 57) / 11);
}
//}
bwipp_opts = bwipp_opts_buf;
} else if (symbology == BARCODE_CODE11 || symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_LOGMARS) {
if (option_2 > 0) {
if (option_2 == 1) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sincludecheck", strlen(bwipp_opts_buf) ? " " : "");
}
bwipp_opts = bwipp_opts_buf; /* Set always as option_2 == 2 is bwipp default */
}
}
}
}
if ((option_1 != -1 || option_2 != -1 || option_3 != -1) && !bwipp_opts) {
fprintf(stderr, "testUtilBwipp: no mapping option_1 %d, option_2 %d, option_3 %d for symbology %s\n", option_1, option_2, option_3, testUtilBarcodeName(symbology));
return -1;
}
if (bwipp_opts) {
if (data_len >= 2043) { /* Ghostscript's `arg_str_max` 2048 less "-sd=" */
sprintf(cmd, cmd_opts_fmt2, bwipp_barcode, bwipp_data, bwipp_data + 2043, bwipp_opts);
} else {
sprintf(cmd, cmd_opts_fmt, bwipp_barcode, bwipp_data, bwipp_opts);
}
} else {
if (data_len >= 2043) {
sprintf(cmd, cmd_fmt2, bwipp_barcode, bwipp_data, bwipp_data + 2043);
} else {
sprintf(cmd, cmd_fmt, bwipp_barcode, bwipp_data);
}
}
/* Hack in various adjustments */
if (symbology == BARCODE_RSS14 || symbology == BARCODE_RSS_LTD || symbology == BARCODE_RSS_EXP) {
/* Begin with space */
memmove(cmd + GS_INITIAL_LEN + 5, cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN);
memcpy(cmd + GS_INITIAL_LEN, " -sbs", 5);
}
if (symbology == BARCODE_CODE11 || symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_PZN || symbology == BARCODE_VIN) {
/* Ratio 3 width bar/space -> 2 width */
memmove(cmd + GS_INITIAL_LEN + 8, cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN);
memcpy(cmd + GS_INITIAL_LEN, " -sr=0.6", 8);
}
if (symbology == BARCODE_CODE11 || symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_HIBC_39
|| symbology == BARCODE_LOGMARS || symbology == BARCODE_PZN || symbology == BARCODE_VIN) {
/* End sbs loop on bar */
memmove(cmd + GS_INITIAL_LEN + 6, cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN);
memcpy(cmd + GS_INITIAL_LEN, " -selb", 6);
}
if (symbol->debug & ZINT_DEBUG_TEST_PRINT) {
printf("testUtilBwipp: cmd %s\n", cmd);
}
fp = popen(cmd, "r");
if (!fp) {
fprintf(stderr, "testUtilBwipp: failed to run '%s'\n", cmd);
return -1;
}
for (r = 0; r < symbol->rows; r++) {
if (b + symbol->width > be) {
fprintf(stderr, "testUtilBwipp: row %d, width %d, row width iteration overrun (%s)\n", r, symbol->width, cmd);
pclose(fp);
return -1;
}
cnt = fread(b, 1, symbol->width, fp);
if (cnt != symbol->width) {
fprintf(stderr, "testUtilBwipp: failed to read symbol->width %d bytes, cnt %d (%s)\n", symbol->width, cnt, cmd);
pclose(fp);
return -1;
}
b += cnt;
for (h = bwipp_row_height[r]; h > 1; h--) { /* Ignore row copies if any */
cnt = fread(b, 1, symbol->width, fp);
if (cnt != symbol->width) {
fprintf(stderr, "testUtilBwipp: failed to read/ignore symbol->width %d bytes, cnt %d (%s)\n", symbol->width, cnt, cmd);
pclose(fp);
return -1;
}
}
}
*b = '\0';
if (fgetc(fp) != EOF) {
fprintf(stderr, "testUtilBwipp: failed to read full stream (%s)\n", cmd);
pclose(fp);
return -1;
}
pclose(fp);
return 0;
}
int testUtilBwippCmp(const struct zint_symbol *symbol, char *msg, const char *bwipp_buf, const char *expected) {
int bwipp_len = strlen(bwipp_buf);
int expected_len = strlen(expected);
int ret_memcmp;
int i;
(void)symbol;
if (bwipp_len != expected_len) {
sprintf(msg, "bwipp_len %d != expected_len %d", bwipp_len, expected_len);
return 2;
}
ret_memcmp = memcmp(bwipp_buf, expected, expected_len);
if (ret_memcmp != 0) {
for (i = 0; i < expected_len; i++) {
if (bwipp_buf[i] != expected[i]) {
break;
}
}
sprintf(msg, "bwipp memcmp %d != 0, at %d, len %d", ret_memcmp, i, expected_len);
return ret_memcmp;
}
return 0;
}
int testUtilBwippCmpRow(const struct zint_symbol *symbol, int row, char *msg, const char *bwipp_buf, const char *expected) {
int bwipp_len = strlen(bwipp_buf);
int expected_len = strlen(expected);
int ret_memcmp;
int i, j;
(void)symbol;
if (bwipp_len != expected_len * symbol->rows) {
sprintf(msg, "bwipp_len %d != expected_len %d * symbol->rows %d", bwipp_len, expected_len, symbol->rows);
return 2;
}
ret_memcmp = memcmp(bwipp_buf + expected_len * row, expected, expected_len);
if (ret_memcmp != 0) {
for (i = 0, j = expected_len * row; i < expected_len; i++, j++) {
if (bwipp_buf[j] != expected[i]) {
break;
}
}
sprintf(msg, "bwipp memcmp %d != 0, at %d (%d), len %d", ret_memcmp, i, j, expected_len);
return ret_memcmp;
}
return 0;
}

View File

@ -69,6 +69,11 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size);
#define assert_fail(...) assert_exp(0, __VA_ARGS__) #define assert_fail(...) assert_exp(0, __VA_ARGS__)
#define assert_nothing(__exp__, ...) {printf(__VA_ARGS__); __exp__;} #define assert_nothing(__exp__, ...) {printf(__VA_ARGS__); __exp__;}
#define ZINT_DEBUG_TEST_PRINT 16
#define ZINT_DEBUG_TEST_LESS_NOISY 32
#define ZINT_DEBUG_TEST_KEEP_OUTFILE 64
#define ZINT_DEBUG_TEST_BWIPP 128
extern void vector_free(struct zint_symbol *symbol); /* Free vector structures */ extern void vector_free(struct zint_symbol *symbol); /* Free vector structures */
int testUtilSetSymbol(struct zint_symbol *symbol, int symbology, int input_mode, int eci, int option_1, int option_2, int option_3, int output_options, char *data, int length, int debug); int testUtilSetSymbol(struct zint_symbol *symbol, int symbology, int input_mode, int eci, int option_1, int option_2, int option_3, int output_options, char *data, int length, int debug);
@ -104,5 +109,9 @@ int testUtilHaveInkscape();
int testUtilVerifyInkscape(char *filename, int debug); int testUtilVerifyInkscape(char *filename, int debug);
int testUtilHaveGhostscript(); int testUtilHaveGhostscript();
int testUtilVerifyGhostscript(char *filename, int debug); int testUtilVerifyGhostscript(char *filename, int debug);
int testUtilCanBwipp(int symbology, int option_1, int option_2, int option_3, int debug);
int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, int option_3, const char *data, int length, const char *primary, char *buffer, int buffer_size);
int testUtilBwippCmp(const struct zint_symbol *symbol, char *msg, const char *bwipp_buf, const char *expected);
int testUtilBwippCmpRow(const struct zint_symbol *symbol, int row, char *msg, const char *bwipp_buf, const char *expected);
#endif /* TESTCOMMON_H */ #endif /* TESTCOMMON_H */

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,7 +1,7 @@
/* upcean.c - Handles UPC, EAN and ISBN /* upcean.c - Handles UPC, EAN and ISBN
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -30,13 +30,11 @@
*/ */
/* vim: set ts=4 sw=4 et : */ /* vim: set ts=4 sw=4 et : */
#define SODIUM "0123456789+" #define SODIUM "0123456789+"
#define EAN2 102 #define EAN2 102
#define EAN5 105 #define EAN5 105
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common.h" #include "common.h"
/* UPC and EAN tables checked against EN 797:1996 */ /* UPC and EAN tables checked against EN 797:1996 */
@ -265,6 +263,10 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
check_digit = upc_check(equivalent); check_digit = upc_check(equivalent);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("UPC-E: %s, Check digit: %c\n", equivalent, check_digit);
}
/* Use the number system and check digit information to choose a parity scheme */ /* Use the number system and check digit information to choose a parity scheme */
if (num_system == 1) { if (num_system == 1) {
strcpy(parity, UPCParity1[ctoi(check_digit)]); strcpy(parity, UPCParity1[ctoi(check_digit)]);

View File

@ -267,14 +267,14 @@ Numeric Value | Barcode Name
24 | Code 49 24 | Code 49
25 | Code 93 25 | Code 93
28 | Flattermarken 28 | Flattermarken
29 | GS1 DataBar-14 29 | GS1 DataBar Omnidirectional (including GS1 DataBar Truncated)
30 | GS1 DataBar Limited 30 | GS1 DataBar Limited
31 | GS1 DataBar Expanded 31 | GS1 DataBar Expanded
32 | Telepen Alpha 32 | Telepen Alpha
34 | UPC A 34 | UPC-A
35 | UPC A + Check Digit 35 | UPC-A + Check Digit
37 | UPC E 37 | UPC-E
38 | UPC E + Check Digit 38 | UPC-E + Check Digit
40 | PostNet 40 | PostNet
47 | MSI Plessey 47 | MSI Plessey
49 | FIM 49 | FIM
@ -295,17 +295,17 @@ Numeric Value | Barcode Name
70 | Royal Mail 4 State (RM4SCC) 70 | Royal Mail 4 State (RM4SCC)
71 | Data Matrix (ECC200) 71 | Data Matrix (ECC200)
72 | EAN-14 72 | EAN-14
73 | Vehicle Identification Number (America) 73 | Vehicle Identification Number
74 | Codablock-F 74 | Codablock-F
75 | NVE-18 75 | NVE-18
76 | Japanese Postal Code 76 | Japanese Postal Code
77 | Korea Post 77 | Korea Post
79 | GS1 DataBar-14 Stacked 79 | GS1 DataBar Stacked (stacked version of GS1 DataBar Truncated)
80 | GS1 DataBar-14 Stacked Omnidirectional 80 | GS1 DataBar Stacked Omnidirectional
81 | GS1 DataBar Expanded Stacked 81 | GS1 DataBar Expanded Stacked
82 | PLANET 82 | PLANET
84 | MicroPDF417 84 | MicroPDF417
85 | USPS OneCode 85 | USPS Intelligent Mail (OneCode)
86 | Plessey Code 86 | Plessey Code
87 | Telepen Numeric 87 | Telepen Numeric
89 | ITF-14 89 | ITF-14
@ -327,13 +327,14 @@ Numeric Value | Barcode Name
129 | Code 32 129 | Code 32
130 | Composite Symbol with EAN linear component 130 | Composite Symbol with EAN linear component
131 | Composite Symbol with GS1-128 linear component 131 | Composite Symbol with GS1-128 linear component
132 | Composite Symbol with GS1 DataBar-14 linear component 132 | Composite Symbol with GS1 DataBar Omnidirectional linear
133 | Composite Symbol with GS1 DataBar Limited component | component
134 | Composite Symbol with GS1 DataBar Expanded component 133 | Composite Symbol with GS1 DataBar Limited linear component
135 | Composite Symbol with UPC A linear component 134 | Composite Symbol with GS1 DataBar Expanded linear component
136 | Composite Symbol with UPC E linear component 135 | Composite Symbol with UPC-A linear component
137 | Composite Symbol with GS1 DataBar-14 Stacked component 136 | Composite Symbol with UPC-E linear component
138 | Composite Symbol with GS1 DataBar-14 Stacked Omnidirectional 137 | Composite Symbol with GS1 DataBar Stacked component
138 | Composite Symbol with GS1 DataBar Stacked Omnidirectional
| component | component
139 | Composite Symbol with GS1 DataBar Expanded Stacked component 139 | Composite Symbol with GS1 DataBar Expanded Stacked component
140 | Channel Code 140 | Channel Code
@ -434,8 +435,9 @@ have been inserted into a symbol.
GS1 data can be encoded in a number of symbologies. Application identifiers GS1 data can be encoded in a number of symbologies. Application identifiers
should be enclosed in [square brackets] followed by the data to be encoded (see should be enclosed in [square brackets] followed by the data to be encoded (see
5.1.12.3). To encode GS1 data use the --gs1 option. GS1 mode is assumed (and 5.1.12.3). To encode GS1 data use the --gs1 option. GS1 mode is assumed (and
doesn't need to be set) for EAN-128, DataBar and Composite symbologies but is doesn't need to be set) for GS1-128, EAN-14, DataBar and Composite symbologies
also available for Code 16k, Data Matrix, Aztec Code, DotCode and QR Code. but is also available for Aztec Code, Code 16k, Code 49, Code One, Data Matrix,
DotCode, QR Code and Ultracode.
HIBC data may also be encoded in the symbologies Code 39, Code128, Codablock-F, HIBC data may also be encoded in the symbologies Code 39, Code128, Codablock-F,
Data Matrix, QR Code, PDF417 and Aztec Code. Within this mode, the leading '+' Data Matrix, QR Code, PDF417 and Aztec Code. Within this mode, the leading '+'
@ -999,14 +1001,14 @@ Value |
24 | BARCODE_CODE49 | Code 49 24 | BARCODE_CODE49 | Code 49
25 | BARCODE_CODE93 | Code 93 25 | BARCODE_CODE93 | Code 93
28 | BARCODE_FLAT | Flattermarken 28 | BARCODE_FLAT | Flattermarken
29 | BARCODE_RSS14 | GS1 DataBar-14 29 | BARCODE_RSS14 | GS1 DataBar Omnidirectional
30 | BARCODE_RSS_LTD | GS1 DataBar Limited 30 | BARCODE_RSS_LTD | GS1 DataBar Limited
31 | BARCODE_RSS_EXP | GS1 DataBar Expanded 31 | BARCODE_RSS_EXP | GS1 DataBar Expanded
32 | BARCODE_TELEPEN | Telepen Alpha 32 | BARCODE_TELEPEN | Telepen Alpha
34 | BARCODE_UPCA | UPC A 34 | BARCODE_UPCA | UPC-A
35 | BARCODE_UPCA_CHK | UPC A + Check Digit 35 | BARCODE_UPCA_CHK | UPC-A + Check Digit
37 | BARCODE_UPCE | UPC E 37 | BARCODE_UPCE | UPC-E
38 | BARCODE_UPCE_CHK | UPC E + Check Digit 38 | BARCODE_UPCE_CHK | UPC-E + Check Digit
40 | BARCODE_POSTNET | PostNet 40 | BARCODE_POSTNET | PostNet
47 | BARCODE_MSI_PLESSEY | MSI Plessey 47 | BARCODE_MSI_PLESSEY | MSI Plessey
49 | BARCODE_FIM | FIM 49 | BARCODE_FIM | FIM
@ -1032,12 +1034,12 @@ Value |
75 | BARCODE_NVE18 | NVE-18 75 | BARCODE_NVE18 | NVE-18
76 | BARCODE_JAPANPOST | Japanese Postal Code 76 | BARCODE_JAPANPOST | Japanese Postal Code
77 | BARCODE_KOREAPOST | Korea Post 77 | BARCODE_KOREAPOST | Korea Post
79 | BARCODE_RSS14STACK | GS1 DataBar-14 Stacked 79 | BARCODE_RSS14STACK | GS1 DataBar Stacked
80 | BARCODE_RSS14STACK_OMNI | GS1 DataBar-14 Stacked Omnidirectional 80 | BARCODE_RSS14STACK_OMNI | GS1 DataBar Stacked Omnidirectional
81 | BARCODE_RSS_EXPSTACK | GS1 DataBar Expanded Stacked 81 | BARCODE_RSS_EXPSTACK | GS1 DataBar Expanded Stacked
82 | BARCODE_PLANET | PLANET 82 | BARCODE_PLANET | PLANET
84 | BARCODE_MICROPDF417 | MicroPDF417 84 | BARCODE_MICROPDF417 | MicroPDF417
85 | BARCODE_ONECODE | USPS OneCode 85 | BARCODE_ONECODE | USPS Intelligent Mail (OneCode)
86 | BARCODE_PLESSEY | Plessey Code 86 | BARCODE_PLESSEY | Plessey Code
87 | BARCODE_TELEPEN_NUM | Telepen Numeric 87 | BARCODE_TELEPEN_NUM | Telepen Numeric
89 | BARCODE_ITF14 | ITF-14 89 | BARCODE_ITF14 | ITF-14
@ -1061,18 +1063,18 @@ Value |
130 | BARCODE_EANX_CC | Composite Symbol with EAN linear component 130 | BARCODE_EANX_CC | Composite Symbol with EAN linear component
131 | BARCODE_EAN128_CC | Composite Symbol with GS1-128 linear 131 | BARCODE_EAN128_CC | Composite Symbol with GS1-128 linear
| | component | | component
132 | BARCODE_RSS14_CC | Composite Symbol with GS1 DataBar-14 linear 132 | BARCODE_RSS14_CC | Composite Symbol with GS1 DataBar
| | component | | Omnidirectional linear component
133 | BARCODE_RSS_LTD_CC | Composite Symbol with GS1 DataBar Limited 133 | BARCODE_RSS_LTD_CC | Composite Symbol with GS1 DataBar Limited
| | component | | linear component
134 | BARCODE_RSS_EXP_CC | Composite Symbol with GS1 DataBar Expanded 134 | BARCODE_RSS_EXP_CC | Composite Symbol with GS1 DataBar Expanded
| | linear component
135 | BARCODE_UPCA_CC | Composite Symbol with UPC-A linear component
136 | BARCODE_UPCE_CC | Composite Symbol with UPC-E linear component
137 | BARCODE_RSS14STACK_CC | Composite Symbol with GS1 DataBar Stacked
| | component | | component
135 | BARCODE_UPCA_CC | Composite Symbol with UPC A linear component 138 | BARCODE_RSS14_OMNI_CC | Composite Symbol with GS1 DataBar Stacked
136 | BARCODE_UPCE_CC | Composite Symbol with UPC E linear component | | Omnidirectional component
137 | BARCODE_RSS14STACK_CC | Composite Symbol with GS1 DataBar-14
| | Stacked component
138 | BARCODE_RSS14_OMNI_CC | Composite Symbol with GS1 DataBar-14
| | Stacked Omnidirectional component
139 | BARCODE_RSS_EXPSTACK_CC | Composite Symbol with GS1 DataBar Expanded 139 | BARCODE_RSS_EXPSTACK_CC | Composite Symbol with GS1 DataBar Expanded
| | Stacked component | | Stacked component
140 | BARCODE_CHANNEL | Channel Code 140 | BARCODE_CHANNEL | Channel Code
@ -1152,8 +1154,8 @@ if (ZBarcode_ValidID(BARCODE_PDF417) != 0) {
} }
[1] This value is ignored for Australia Post 4-State Barcodes, PostNet, PLANET, [1] This value is ignored for Australia Post 4-State Barcodes, PostNet, PLANET,
USPS OneCode, RM4SCC, PDF417, Data Matrix, Maxicode, QR Code, GS1 USPS Intelligent Mail, RM4SCC, PDF417, Data Matrix, Maxicode, QR Code, GS1
DataBar-14 Stacked, PDF417 and MicroPDF417 - all of which have a fixed height. DataBar Stacked, PDF417 and MicroPDF417 - all of which have a fixed height.
[2] This value is ignored for Code 16k, Codablock-F and ITF-14 symbols. [2] This value is ignored for Code 16k, Codablock-F and ITF-14 symbols.
@ -1435,15 +1437,15 @@ suppresses mode C in favour of mode B.
6.1.11.3 GS1-128 6.1.11.3 GS1-128
---------------- ----------------
A variation of Code 128 also known as UCC/EAN-128, this symbology is defined by A variation of Code 128 previously known as UCC/EAN-128, this symbology is
the GS1 General Specification. Application Identifiers (AIs) should be entered defined by the GS1 General Specifications. Application Identifiers (AIs) should
using [square bracket] notation. These will be converted to (round brackets) be entered using [square bracket] notation. These will be converted to (round
for the human readable text. This will allow round brackets to be used in the brackets) for the human readable text. This will allow round brackets to be used
data strings to be encoded. Fixed length data should be entered at the in the data strings to be encoded. Fixed length data should be entered at the
appropriate length for correct encoding. GS1-128 does not support extended appropriate length for correct encoding. GS1-128 does not support extended ASCII
ASCII characters. Check digits for GTIN data (AI 01) are not generated and characters. Check digits for GTIN data (AI 01) are not generated and need to be
need to be included in the input data. The following is an example of a valid included in the input data. The following is an example of a valid GS1-128
GS1-128 input: input:
zint --barcode=16 -d "[01]98898765432106[3202]012345[15]991231" zint --barcode=16 -d "[01]98898765432106[3202]012345[15]991231"
@ -1466,39 +1468,42 @@ standards.
6.1.12 GS1 DataBar (ISO 24724) 6.1.12 GS1 DataBar (ISO 24724)
------------------------------ ------------------------------
Also known as RSS (Reduced Spaced Symbology) these symbols are due to replace Previously known as RSS (Reduced Spaced Symbology) these symbols are due to
GS1-128 symbols in accordance with the GS1 General Specification. If a GS1 replace GS1-128 symbols in accordance with the GS1 General Specifications. If a
DataBar symbol is to be printed with a 2D component as specified in ISO 24723 GS1 DataBar symbol is to be printed with a 2D component as specified in ISO
set option_1 = 2 or use the option --mode=2 at the command prompt. See section 24723 set option_1 = 2 or use the option --mode=2 at the command prompt. See
6.3 of this manual to find out how to generate DataBar symbols with 2D section 6.3 of this manual to find out how to generate DataBar symbols with 2D
components. components.
6.1.12.1 DataBar-14 and DataBar-14 Truncated 6.1.12.1 DataBar Omnidirectional and DataBar Truncated
-------------------------------------------- ------------------------------------------------------
Also known as RSS-14 this standard encodes a 13 digit item code. A check digit Previously known as RSS-14 this standard encodes a 13 digit item code. A check
and application identifier of (01) are added by Zint. To produce a truncated digit and application identifier of (01) are added by Zint. (A 14 digit code
symbol set the symbol height to a value between 32 and 13. Normal DataBar-14 that appends the check digit may be given, in which case the check digit will be
symbols should have a height of 33 or greater. verified.) To produce a truncated symbol set the symbol height to a value
between 32 and 13. Normal DataBar Omnidirectional symbols should have a height
of 33 or greater.
6.1.12.2 DataBar Limited 6.1.12.2 DataBar Limited
------------------------ ------------------------
Also known as RSS Limited this standard encodes a 13 digit item code and can be Previously known as RSS Limited this standard encodes a 13 digit item code and
used in the same way as DataBar-14 above. DataBar Limited, however, is limited can be used in the same way as DataBar above. DataBar Limited, however, is
to data starting with digits 0 and 1 (i.e. numbers in the range 0 to limited to data starting with digits 0 and 1 (i.e. numbers in the range 0 to
1999999999999). As with DataBar-14 a check digit and application identifier of 1999999999999). As with DataBar Omnidirectional a check digit and application
(01) are added by Zint. identifier of (01) are added by Zint, and a 14 digit code may be given in which
case the check digit will be verified.
6.1.12.3 DataBar Expanded 6.1.12.3 DataBar Expanded
------------------------- -------------------------
Also known as RSS Expanded this is a variable length symbology capable of Previously known as RSS Expanded this is a variable length symbology capable of
encoding data from a number of AIs in a single symbol. AIs should be encased in encoding data from a number of AIs in a single symbol. AIs should be encased in
[square brackets] in the input data. This will be converted to (rounded [square brackets] in the input data. This will be converted to (rounded
brackets) before it is included in the human readable text attached to the brackets) before it is included in the human readable text attached to the
symbol. This method allows the inclusion of rounded brackets in the data to be symbol. This method allows the inclusion of rounded brackets in the data to be
encoded. GTIN data (AI 01) should also include the check digit data as this is encoded. GTIN data (AI 01) should also include the check digit data as this is
not calculated by Zint when this symbology is encoded. Fixed length data should not calculated by Zint when this symbology is encoded. Fixed length data should
be entered at the appropriate length for correct encoding. The following is be entered at the appropriate length for correct encoding. The following is an
an example of a valid DataBar Expanded input: example of a valid DataBar Expanded input:
zint --barcode=31 -d "[01]98898765432106[3202]012345[15]991231" zint --barcode=31 -d "[01]98898765432106[3202]012345[15]991231"
@ -1612,19 +1617,19 @@ mechanism. A separate symbology ID can be used to encode Health Industry
Barcode (HIBC) data which adds a leading '+' character and a modulo-49 check Barcode (HIBC) data which adds a leading '+' character and a modulo-49 check
digit to the encoded data. digit to the encoded data.
6.2.7 GS1 DataBar-14 Stacked (ISO 24724) 6.2.7 GS1 DataBar Stacked (ISO 24724)
---------------------------------------- -------------------------------------
A stacked variation of the GS1 DataBar-14 symbol requiring the same input (see A stacked variation of the GS1 DataBar Truncated symbol requiring the same input
section 6.1.12.1). The height of this symbol is fixed. The data is encoded in (see section 6.1.12.1). The height of this symbol is fixed. The data is encoded
two rows of bars with a central finder pattern. This symbol can be generated in two rows of bars with a central finder pattern. This symbol can be generated
with a two-dimensional component to make a composite symbol. with a two-dimensional component to make a composite symbol.
6.2.8 GS1 DataBar-14 Stacked Omnidirectional (ISO 24724) 6.2.8 GS1 DataBar Stacked Omnidirectional (ISO 24724)
-------------------------------------------------------- -----------------------------------------------------
Another variation of the GS1 DataBar-14 symbol requiring the same input (see A stacked variation of the GS1 DataBar Omnidirectional symbol requiring the same
section 6.1.12.1). The data is encoded in two rows of bars with a central input (see section 6.1.12.1). The data is encoded in two rows of bars with a
finder pattern. This symbol can be generated with a two-dimensional component central finder pattern. This symbol can be generated with a two-dimensional
to make a composite symbol. component to make a composite symbol.
6.2.9 GS1 DataBar Expanded Stacked (ISO 24724) 6.2.9 GS1 DataBar Expanded Stacked (ISO 24724)
---------------------------------------------- ----------------------------------------------
@ -1647,7 +1652,7 @@ characters or 81 numeric digits. GS1 data encoding is also supported.
--------------------------------- ---------------------------------
Composite symbols employ a mixture of components to give more comprehensive Composite symbols employ a mixture of components to give more comprehensive
information about a product. The permissible contents of a composite symbol is information about a product. The permissible contents of a composite symbol is
determined by the terms of the GS1 General Specification. Composite symbols determined by the terms of the GS1 General Specifications. Composite symbols
consist of a linear component which can be an EAN, UPC, GS1-128 or GS1 DataBar consist of a linear component which can be an EAN, UPC, GS1-128 or GS1 DataBar
symbol, a 2D component which is based on PDF417 or MicroPDF417, and a separator symbol, a 2D component which is based on PDF417 or MicroPDF417, and a separator
pattern. The type of linear component to be used is determined using the -b or pattern. The type of linear component to be used is determined using the -b or
@ -1661,18 +1666,18 @@ Value |
130 | BARCODE_EANX_CC | Composite Symbol with EAN linear component 130 | BARCODE_EANX_CC | Composite Symbol with EAN linear component
131 | BARCODE_EAN128_CC | Composite Symbol with GS1-128 linear 131 | BARCODE_EAN128_CC | Composite Symbol with GS1-128 linear
| | component | | component
132 | BARCODE_RSS14_CC | Composite Symbol with GS1 DataBar-14 linear 132 | BARCODE_RSS14_CC | Composite Symbol with GS1 DataBar
| | component | | Omnidirectional linear component
133 | BARCODE_RSS_LTD_CC | Composite Symbol with GS1 DataBar Limited 133 | BARCODE_RSS_LTD_CC | Composite Symbol with GS1 DataBar Limited
| | component | | linear component
134 | BARCODE_RSS_EXP_CC | Composite Symbol with GS1 DataBar Expanded 134 | BARCODE_RSS_EXP_CC | Composite Symbol with GS1 DataBar Expanded
| | linear component
135 | BARCODE_UPCA_CC | Composite Symbol with UPC-A linear component
136 | BARCODE_UPCE_CC | Composite Symbol with UPC-E linear component
137 | BARCODE_RSS14STACK_CC | Composite Symbol with GS1 DataBar Stacked
| | component | | component
135 | BARCODE_UPCA_CC | Composite Symbol with UPC A linear component 138 | BARCODE_RSS14_OMNI_CC | Composite Symbol with GS1 DataBar Stacked
136 | BARCODE_UPCE_CC | Composite Symbol with UPC E linear component | | Omnidirectional component
137 | BARCODE_RSS14STACK_CC | Composite Symbol with GS1 DataBar-14
| | Stacked component
138 | BARCODE_RSS14_OMNI_CC | Composite Symbol with GS1 DataBar-14
| | Stacked Omnidirectional component
139 | BARCODE_RSS_EXPSTACK_CC | Composite Symbol with GS1 DataBar Expanded 139 | BARCODE_RSS_EXPSTACK_CC | Composite Symbol with GS1 DataBar Expanded
| | Stacked component | | Stacked component
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -1817,15 +1822,15 @@ Reed Solomon error correction. Input is a pre-formatted alphanumeric string of
trailing space characters - these will be appended by Zint if not included in trailing space characters - these will be appended by Zint if not included in
the input data. the input data.
6.5.5 USPS OneCode 6.5.5 USPS Intelligent Mail
------------------ ---------------------------
Also known as the Intelligent Mail Barcode and used in the US by the United Also known as the OneCode barcode and used in the US by the United States Postal
States Postal Service (USPS), the OneCode system replaced the PostNet and Service (USPS), the Intelligent Mail system replaced the PostNet and PLANET
PLANET symbologies in 2009. OneCode is a fixed length (65-bar) symbol which symbologies in 2009. Intelligent Mail is a fixed length (65-bar) symbol which
combines routing and customer information in a single symbol. Input data combines routing and customer information in a single symbol. Input data
consists of a 20 digit tracking code, followed by a dash (-), followed by a consists of a 20 digit tracking code, followed by a dash (-), followed by a
delivery point zip-code which can be 0, 5, 9 or 11 digits in length. For delivery point zip-code which can be 0, 5, 9 or 11 digits in length. For example
example all of the following inputs are valid data entries: all of the following inputs are valid data entries:
"01234567094987654321" "01234567094987654321"

View File

@ -53,17 +53,17 @@ static void types(void) {
"20: Code 128 70: RM4SCC 128: Aztec Runes\n" "20: Code 128 70: RM4SCC 128: Aztec Runes\n"
"21: Leitcode 71: Data Matrix 129: Code 32\n" "21: Leitcode 71: Data Matrix 129: Code 32\n"
"22: Identcode 72: EAN-14 130: Comp EAN\n" "22: Identcode 72: EAN-14 130: Comp EAN\n"
"23: Code 16k 73: VIN (North America) 131: Comp GS1-128\n" "23: Code 16k 73: VIN 131: Comp GS1-128\n"
"24: Code 49 74: Codablock-F 132: Comp DataBar Omni\n" "24: Code 49 74: Codablock-F 132: Comp DataBar Omni\n"
"25: Code 93 75: NVE-18 133: Comp DataBar Ltd\n" "25: Code 93 75: NVE-18 133: Comp DataBar Ltd\n"
"28: Flattermarken 76: Japanese Post 134: Comp DataBar ExpOm\n" "28: Flattermarken 76: Japanese Post 134: Comp DataBar Exp\n"
"29: GS1 DataBar Omni 77: Korea Post 135: Comp UPC-A\n" "29: GS1 DataBar Omni 77: Korea Post 135: Comp UPC-A\n"
"30: GS1 DataBar Ltd 79: GS1 DataBar Stack 136: Comp UPC-E\n" "30: GS1 DataBar Ltd 79: GS1 DataBar Stack 136: Comp UPC-E\n"
"31: GS1 DataBar ExpOm 80: GS1 DataBar Stack Omni 137: Comp DataBar Stack\n" "31: GS1 DataBar Exp 80: GS1 DataBar Stack Omni 137: Comp DataBar Stack\n"
"32: Telepen Alpha 81: GS1 DataBar ESO 138: Comp DataBar Stack Omni\n" "32: Telepen Alpha 81: GS1 DataBar Exp Stack 138: Comp DataBar Stack Omni\n"
"34: UPC-A 82: Planet 139: Comp DataBar ESO\n" "34: UPC-A 82: Planet 139: Comp DataBar Exp Stack\n"
"35: UPC-A + Check 84: MicroPDF 140: Channel Code\n" "35: UPC-A + Check 84: MicroPDF 140: Channel Code\n"
"37: UPC-E 85: USPS OneCode 141: Code One\n" "37: UPC-E 85: USPS Intelligent Mail 141: Code One\n"
"38: UPC-E + Check 86: UK Plessey 142: Grid Matrix\n" "38: UPC-E + Check 86: UK Plessey 142: Grid Matrix\n"
"40: Postnet 87: Telepen Numeric 143: UPNQR\n" "40: Postnet 87: Telepen Numeric 143: UPNQR\n"
"47: MSI Plessey 89: ITF-14 144: Ultracode\n" "47: MSI Plessey 89: ITF-14 144: Ultracode\n"

View File

@ -9,6 +9,12 @@
<height>78</height> <height>78</height>
</rect> </rect>
</property> </property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle" > <property name="windowTitle" >
<string>Form</string> <string>Form</string>
</property> </property>

View File

@ -44,47 +44,57 @@
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>1</string> <string>1 (2 segments)</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>2</string> <string>2 (4 segments)</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>3</string> <string>3 (6 segments)</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>4</string> <string>4 (8 segments)</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>5</string> <string>5 (10 segments)</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>6</string> <string>6 (12 segments)</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>7</string> <string>7 (14 segments)</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>8</string> <string>8 (16 segments)</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>9</string> <string>9 (18 segments)</string>
</property>
</item>
<item>
<property name="text">
<string>10 (20 segments)</string>
</property>
</item>
<item>
<property name="text">
<string>11 (22 segments)</string>
</property> </property>
</item> </item>
</widget> </widget>

View File

@ -454,7 +454,7 @@ p, li { white-space: pre-wrap; }
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="lblWhitespace"> <widget class="QLabel" name="lblWhitespace">
<property name="text"> <property name="text">
<string>&amp;Whitespace:</string> <string>Horizontal &amp;Whitespace:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>

View File

@ -37,7 +37,7 @@
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl) MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl), m_optionWidget(0) : QWidget(parent, fl), m_optionWidget(0)
{ {
m_bc.bc.setDebug(QCoreApplication::arguments().contains("--verbose")); m_bc.bc.setDebug(QCoreApplication::arguments().contains("--verbose")); // Undocumented command line debug flag
QCoreApplication::setOrganizationName("zint"); QCoreApplication::setOrganizationName("zint");
QCoreApplication::setOrganizationDomain("zint.org.uk"); QCoreApplication::setOrganizationDomain("zint.org.uk");
@ -80,15 +80,15 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
"Facing Identification Mark (FIM)", "Facing Identification Mark (FIM)",
"Flattermarken", "Flattermarken",
"Grid Matrix", "Grid Matrix",
"GS1 DataBar Expanded Omnidirectional", "GS1 DataBar Expanded",
"GS1 DataBar Expanded Stacked Omnidirectional", "GS1 DataBar Expanded Stacked",
"GS1 DataBar Limited", "GS1 DataBar Limited",
"GS1 DataBar Omnidirectional", "GS1 DataBar Omnidirectional (and Truncated)",
"GS1 DataBar Stacked", "GS1 DataBar Stacked",
"GS1 DataBar Stacked Omnidirectional", "GS1 DataBar Stacked Omnidirectional",
"Han Xin (Chinese Sensible) Code", "Han Xin (Chinese Sensible) Code",
"ITF-14",
"International Standard Book Number (ISBN)", "International Standard Book Number (ISBN)",
"ITF-14",
"Japanese Postal Barcode", "Japanese Postal Barcode",
"Korean Postal Barcode", "Korean Postal Barcode",
"LOGMARS", "LOGMARS",
@ -111,10 +111,10 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
"Telepen Numeric", "Telepen Numeric",
"UK Plessey", "UK Plessey",
"Ultracode", "Ultracode",
"UPNQR",
"Universal Product Code (UPC-A)", "Universal Product Code (UPC-A)",
"Universal Product Code (UPC-E)", "Universal Product Code (UPC-E)",
"USPS Intelligent Mail", "UPNQR",
"USPS Intelligent Mail (OneCode)",
"VIN (Vehicle Identification Number)" "VIN (Vehicle Identification Number)"
}; };
@ -124,26 +124,32 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
view->setScene(scene); view->setScene(scene);
m_fgcolor=qRgb(settings.value("studio/ink/red", 0).toInt(), m_fgcolor=qRgb(settings.value("studio/ink/red", 0).toInt(),
settings.value("studio/ink/green", 0).toInt(), settings.value("studio/ink/green", 0).toInt(),
settings.value("studio/ink/blue", 0).toInt()); settings.value("studio/ink/blue", 0).toInt());
m_bgcolor=qRgb(settings.value("studio/paper/red", 0xff).toInt(), m_bgcolor=qRgb(settings.value("studio/paper/red", 0xff).toInt(),
settings.value("studio/paper/green", 0xff).toInt(), settings.value("studio/paper/green", 0xff).toInt(),
settings.value("studio/paper/blue", 0xff).toInt()); settings.value("studio/paper/blue", 0xff).toInt());
for (int i=0;i<metaObject()->enumerator(0).keyCount();i++) {
for (int i = 0; i < metaObject()->enumerator(0).keyCount(); i++) {
bstyle->addItem(metaObject()->enumerator(0).key(i)); bstyle->addItem(metaObject()->enumerator(0).key(i));
bstyle->setItemText(i,bstyle_text[i]); bstyle->setItemText(i, bstyle_text[i]);
} }
bstyle->setCurrentIndex(settings.value("studio/symbology", 10).toInt()); bstyle->setCurrentIndex(settings.value("studio/symbology", 10).toInt());
txtData->setText(settings.value("studio/data", "Your Data Here!").toString());
txtComposite->setText(settings.value("studio/composite_text", "Your Data Here!").toString()); txtData->setText(settings.value("studio/data", "Your Data Here!").toString());
heightb->setValue(settings.value("studio/appearance/height", 50).toInt()); txtComposite->setText(settings.value("studio/composite_text", "Your Data Here!").toString());
bwidth->setValue(settings.value("studio/appearance/border", 50).toInt()); heightb->setValue(settings.value("studio/appearance/height", 50).toInt());
spnWhitespace->setValue(settings.value("studio/appearance/whitespace", 0).toInt()); bwidth->setValue(settings.value("studio/appearance/border", 50).toInt());
spnScale->setValue(settings.value("studio/appearance/scale", 1.0).toFloat()); spnWhitespace->setValue(settings.value("studio/appearance/whitespace", 0).toInt());
btype->setCurrentIndex(settings.value("studio/appearance/border_type", 0).toInt()); spnScale->setValue(settings.value("studio/appearance/scale", 1.0).toFloat());
btype->setCurrentIndex(settings.value("studio/appearance/border_type", 0).toInt());
change_options(); change_options();
scene->addItem(&m_bc); scene->addItem(&m_bc);
update_preview(); update_preview();
connect(bstyle, SIGNAL(currentIndexChanged( int )), SLOT(change_options())); connect(bstyle, SIGNAL(currentIndexChanged( int )), SLOT(change_options()));
connect(bstyle, SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); connect(bstyle, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(heightb, SIGNAL(valueChanged( int )), SLOT(update_preview())); connect(heightb, SIGNAL(valueChanged( int )), SLOT(update_preview()));
@ -253,17 +259,17 @@ bool MainWindow::save()
} }
if(m_bc.bc.save_to_file(filename) == false) { if(m_bc.bc.save_to_file(filename) == false) {
if (m_bc.bc.getError() > 4) { if (m_bc.bc.getError() > 4) {
QMessageBox::critical(this,tr("Save Error"),m_bc.bc.error_message()); QMessageBox::critical(this, tr("Save Error"), m_bc.bc.error_message());
return false; return false;
} else { } else {
QMessageBox::warning(this, tr("Save Warning"),m_bc.bc.error_message()); QMessageBox::warning(this, tr("Save Warning"), m_bc.bc.error_message());
return true; return true;
} }
} }
settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator()))); settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator())));
settings.setValue("studio/default_suffix", suffix); settings.setValue("studio/default_suffix", suffix);
return true; return true;
} }
@ -1092,12 +1098,10 @@ void MainWindow::update_preview()
if(m_optionWidget->findChild<QRadioButton*>("radQRGS1")->isChecked()) if(m_optionWidget->findChild<QRadioButton*>("radQRGS1")->isChecked())
m_bc.bc.setInputMode(GS1_MODE); m_bc.bc.setInputMode(GS1_MODE);
printf("cmbQRSize stylesheet %s\n", (const char *) m_optionWidget->findChild<QComboBox*>("cmbQRSize")->styleSheet().toLatin1());
item_val = m_optionWidget->findChild<QComboBox*>("cmbQRSize")->currentIndex(); item_val = m_optionWidget->findChild<QComboBox*>("cmbQRSize")->currentIndex();
if (item_val) { if (item_val) {
m_bc.bc.setOption2(item_val); m_bc.bc.setOption2(item_val);
} }
printf("cmbQRECC stylesheet %s\n", (const char *) m_optionWidget->findChild<QComboBox*>("cmbQRECC")->styleSheet().toLatin1());
item_val = m_optionWidget->findChild<QComboBox*>("cmbQRECC")->currentIndex(); item_val = m_optionWidget->findChild<QComboBox*>("cmbQRECC")->currentIndex();
if (item_val) { if (item_val) {
m_bc.bc.setSecurityLevel(item_val); m_bc.bc.setSecurityLevel(item_val);

View File

@ -80,8 +80,8 @@ public:
RSS14STACK = 79, RSS14STACK = 79,
RSS14STACK_OMNI = 80, RSS14STACK_OMNI = 80,
HANXIN = 116, HANXIN = 116,
ITF14 = 89,
ISBNX = 69, ISBNX = 69,
ITF14 = 89,
JAPANPOST = 76, JAPANPOST = 76,
KOREAPOST = 77, KOREAPOST = 77,
LOGMARS = 50, LOGMARS = 50,
@ -104,9 +104,9 @@ public:
TELEPEN_NUM = 87, TELEPEN_NUM = 87,
PLESSEY = 86, PLESSEY = 86,
ULTRA = 144, ULTRA = 144,
UPNQR = 143,
UPCA = 34, UPCA = 34,
UPCE = 37, UPCE = 37,
UPNQR = 143,
ONECODE = 85, ONECODE = 85,
VIN = 73 VIN = 73
}; };