mirror of
https://github.com/woo-j/zint.git
synced 2024-12-23 01:33:55 +03:00
library: compat symbology 39 fix; ISBN: "X" check
WARN_FAIL_ALL: always return error: ZINT_ERROR_USES_ECI/NON_COMPLIANT Fuller error messages; more comments zint.h mainwindow.cpp: replace metaobject ENUM with array (suppresses virtual in constructor warning)
This commit is contained in:
parent
7cd0d9ae22
commit
3c1869b032
@ -35,10 +35,6 @@
|
||||
#include "common.h"
|
||||
#include "gs1.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define inline _inline
|
||||
#endif
|
||||
|
||||
static const char *C25MatrixTable[10] = {
|
||||
"113311", "311131", "131131", "331111", "113131",
|
||||
"313111", "133111", "111331", "311311", "131311"
|
||||
@ -60,7 +56,7 @@ static const char *C25InterTable[10] = {
|
||||
"31311", "13311", "11133", "31131", "13131"
|
||||
};
|
||||
|
||||
static inline char check_digit(const unsigned int count) {
|
||||
static char check_digit(const unsigned int count) {
|
||||
return itoc((10 - (count % 10)) % 10);
|
||||
}
|
||||
|
||||
@ -74,12 +70,12 @@ static int c25_common(struct zint_symbol *symbol, const unsigned char source[],
|
||||
int have_checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2;
|
||||
|
||||
if (length > max) {
|
||||
sprintf(symbol->errtxt, "%d: Input too long (maximum %d)", error_base, max);
|
||||
sprintf(symbol->errtxt, "%d: Input too long (%d character maximum)", error_base, max);
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
sprintf(symbol->errtxt, "%d: Invalid characters in data", error_base + 1);
|
||||
sprintf(symbol->errtxt, "%d: Invalid character in data (digits only)", error_base + 1);
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -142,12 +138,12 @@ static int c25inter_common(struct zint_symbol *symbol, unsigned char source[], i
|
||||
float height;
|
||||
|
||||
if (length > 90) {
|
||||
strcpy(symbol->errtxt, "309: Input too long");
|
||||
strcpy(symbol->errtxt, "309: Input too long (90 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "310: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "310: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -230,13 +226,13 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
unsigned char localstr[16] = {0};
|
||||
|
||||
if (length > 13) {
|
||||
strcpy(symbol->errtxt, "311: Input too long");
|
||||
strcpy(symbol->errtxt, "311: Input too long (13 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "312: Invalid character in data");
|
||||
strcpy(symbol->errtxt, "312: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -285,12 +281,12 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
|
||||
count = 0;
|
||||
if (length > 13) {
|
||||
strcpy(symbol->errtxt, "313: Input wrong length");
|
||||
strcpy(symbol->errtxt, "313: Input wrong length (13 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "314: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "314: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -324,12 +320,12 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
|
||||
count = 0;
|
||||
if (length > 11) {
|
||||
strcpy(symbol->errtxt, "315: Input wrong length");
|
||||
strcpy(symbol->errtxt, "315: Input wrong length (11 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "316: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "316: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,10 @@ if(MSVC)
|
||||
target_compile_definitions(zint PRIVATE DLL_EXPORT)
|
||||
endif()
|
||||
|
||||
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
if(ZINT_STATIC)
|
||||
install(TARGETS zint-static ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
endif()
|
||||
install(FILES zint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
|
||||
|
||||
if(ZINT_TEST)
|
||||
|
@ -58,11 +58,8 @@ static const char *AusBarTable[64] = {
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#include "reedsol.h"
|
||||
#ifdef _MSC_VER
|
||||
#define inline _inline
|
||||
#endif
|
||||
|
||||
static inline char convert_pattern(char data, int shift) {
|
||||
static char convert_pattern(char data, int shift) {
|
||||
return (data - '0') << shift;
|
||||
}
|
||||
|
||||
@ -113,7 +110,7 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
/* Check input immediately to catch nuls */
|
||||
error_number = is_sane(GDSET, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "404: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "404: Invalid character in data (alphanumerics, space and \"#\" only)");
|
||||
return error_number;
|
||||
}
|
||||
strcpy(localstr, "");
|
||||
@ -140,17 +137,17 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
error_number = is_sane(NEON, source, length);
|
||||
break;
|
||||
default:
|
||||
strcpy(symbol->errtxt, "401: Auspost input is wrong length");
|
||||
strcpy(symbol->errtxt, "401: Auspost input is wrong length (8, 13, 16, 18 or 23 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "402: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "402: Invalid character in data (digits only for lengths 16 and 23)");
|
||||
return error_number;
|
||||
}
|
||||
} else {
|
||||
int zeroes;
|
||||
if (length > 8) {
|
||||
strcpy(symbol->errtxt, "403: Auspost input is too long");
|
||||
strcpy(symbol->errtxt, "403: Auspost input is too long (8 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
switch (symbol->symbology) {
|
||||
@ -174,12 +171,12 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
|
||||
ustrncat(localstr, source, length);
|
||||
h = (int) strlen(localstr);
|
||||
/* Verifiy that the first 8 characters are numbers */
|
||||
/* Verify that the first 8 characters are numbers */
|
||||
memcpy(dpid, localstr, 8);
|
||||
dpid[8] = '\0';
|
||||
error_number = is_sane(NEON, (unsigned char *) dpid, 8);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "405: Invalid characters in DPID");
|
||||
strcpy(symbol->errtxt, "405: Invalid character in DPID (first 8 characters) (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
|
@ -1430,12 +1430,12 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
|
||||
|
||||
input_value = 0;
|
||||
if (length > 3) {
|
||||
strcpy(symbol->errtxt, "507: Input too large");
|
||||
strcpy(symbol->errtxt, "507: Input too large (3 character maximum)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number != 0) {
|
||||
strcpy(symbol->errtxt, "508: Invalid characters in input");
|
||||
strcpy(symbol->errtxt, "508: Invalid character in data (digits only)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
switch (length) {
|
||||
@ -1451,7 +1451,7 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
|
||||
if (input_value > 255) {
|
||||
strcpy(symbol->errtxt, "509: Input too large");
|
||||
strcpy(symbol->errtxt, "509: Input out of range (0 to 255)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
}
|
||||
error_number = is_sane(SODIUM, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
sprintf(symbol->errtxt, "321: Invalid characters in data (\"%s\" only)", SODIUM);
|
||||
strcpy(symbol->errtxt, "321: Invalid character in data (digits and \"-\" only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -233,9 +233,9 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
strcpy(symbol->errtxt, "322: Input too long (30 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
/* Prevent encoded_data out-of-bounds >= 143 for BARCODE_HIBC_39 due to wider 'wide' bars */
|
||||
} else if ((symbol->symbology == BARCODE_HIBC_39) && (length > 68)) {
|
||||
} else if ((symbol->symbology == BARCODE_HIBC_39) && (length > 69)) {
|
||||
/* Note use 319 (2of5 range) as 340 taken by CODE128 */
|
||||
strcpy(symbol->errtxt, "319: Input too long (68 character maximum)");
|
||||
strcpy(symbol->errtxt, "319: Input too long (67 character maximum)"); /* 69 less '+' and check */
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
} else if (length > 85) {
|
||||
strcpy(symbol->errtxt, "323: Input too long (85 character maximum)");
|
||||
@ -244,7 +244,7 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
to_upper(source);
|
||||
error_number = is_sane(SILVER, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "324: Invalid characters in data (alphanumerics and \"-. $/+%\" only)");
|
||||
strcpy(symbol->errtxt, "324: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], i
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "326: Invalid characters in data (digits only)");
|
||||
strcpy(symbol->errtxt, "326: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -426,7 +426,7 @@ INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length
|
||||
for (i = 0; i < length; i++) {
|
||||
if (source[i] > 127) {
|
||||
/* Cannot encode extended ASCII */
|
||||
strcpy(symbol->errtxt, "329: Invalid characters in data, extended ASCII not allowed");
|
||||
strcpy(symbol->errtxt, "329: Invalid character in data, extended ASCII not allowed");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
ustrcat(buffer, EC39Ctrl[source[i]]);
|
||||
@ -467,7 +467,7 @@ INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
for (i = 0; i < length; i++) {
|
||||
if (source[i] > 127) {
|
||||
/* Cannot encode extended ASCII */
|
||||
strcpy(symbol->errtxt, "331: Invalid characters in data, extended ASCII not allowed");
|
||||
strcpy(symbol->errtxt, "331: Invalid character in data, extended ASCII not allowed");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
strcat(buffer, C93Ctrl[source[i]]);
|
||||
@ -690,7 +690,7 @@ INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], in
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "334: Invalid characters in data (digits only)");
|
||||
strcpy(symbol->errtxt, "334: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -724,7 +724,11 @@ INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], in
|
||||
}
|
||||
|
||||
if (target_value > max_ranges[channels]) {
|
||||
sprintf(symbol->errtxt, "335: Value out of range (0 to %d) for %d channels", max_ranges[channels], channels);
|
||||
if (channels == 8) {
|
||||
sprintf(symbol->errtxt, "305: Value out of range (0 to %d)", max_ranges[channels]);
|
||||
} else {
|
||||
sprintf(symbol->errtxt, "335: Value out of range (0 to %d) for %d channels", max_ranges[channels], channels);
|
||||
}
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -786,7 +790,7 @@ INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
|
||||
// Check input characters, I, O and Q are not allowed
|
||||
if (is_sane(ARSENIC, source, length) == ZINT_ERROR_INVALID_DATA) {
|
||||
sprintf(symbol->errtxt, "337: Invalid characters in data (\"%s\" only)", ARSENIC);
|
||||
sprintf(symbol->errtxt, "337: Invalid character in data (\"%s\" only)", ARSENIC);
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ INTERNAL int code_128(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
if (sourcelen > C128_MAX) {
|
||||
/* This only blocks ridiculously long input - the actual length of the
|
||||
resulting barcode depends on the type of data, so this is trapped later */
|
||||
strcpy(symbol->errtxt, "340: Input too long");
|
||||
sprintf(symbol->errtxt, "340: Input too long (%d character maximum)", C128_MAX);
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ INTERNAL int code_128(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
}
|
||||
}
|
||||
if (glyph_count > 60.0f) {
|
||||
strcpy(symbol->errtxt, "341: Input too long");
|
||||
strcpy(symbol->errtxt, "341: Input too long (60 symbol character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -725,7 +725,7 @@ INTERNAL int ean_128_cc(struct zint_symbol *symbol, unsigned char source[], int
|
||||
if (length > C128_MAX) {
|
||||
/* This only blocks ridiculously long input - the actual length of the
|
||||
resulting barcode depends on the type of data, so this is trapped later */
|
||||
strcpy(symbol->errtxt, "342: Input too long");
|
||||
sprintf(symbol->errtxt, "342: Input too long (%d character maximum)", C128_MAX);
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -857,7 +857,7 @@ INTERNAL int ean_128_cc(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
}
|
||||
if (glyph_count > 60.0f) {
|
||||
strcpy(symbol->errtxt, "344: Input too long");
|
||||
strcpy(symbol->errtxt, "344: Input too long (60 symbol character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -1057,13 +1057,13 @@ INTERNAL int nve_18(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
unsigned char ean128_equiv[23];
|
||||
|
||||
if (length > 17) {
|
||||
strcpy(symbol->errtxt, "345: Input too long");
|
||||
strcpy(symbol->errtxt, "345: Input too long (17 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "346: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "346: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -1095,13 +1095,13 @@ INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
unsigned char ean128_equiv[19];
|
||||
|
||||
if (length > 13) {
|
||||
strcpy(symbol->errtxt, "347: Input wrong length");
|
||||
strcpy(symbol->errtxt, "347: Input too long (13 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "348: Invalid character in data");
|
||||
strcpy(symbol->errtxt, "348: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -1137,26 +1137,24 @@ INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int
|
||||
int cd; // Check digit
|
||||
|
||||
if (length != 28) {
|
||||
strcpy(symbol->errtxt, "349: DPD input wrong length");
|
||||
strcpy(symbol->errtxt, "349: DPD input wrong length (28 characters required)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
identifier = source[0];
|
||||
source[0] = 'A';
|
||||
|
||||
to_upper(source);
|
||||
error_number = is_sane(KRSET, source, length);
|
||||
to_upper(source + 1);
|
||||
error_number = is_sane(KRSET, source + 1, length - 1);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "350: Invalid character in DPD data");
|
||||
strcpy(symbol->errtxt, "300: Invalid character in DPD data (alphanumerics only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
if ((identifier < 32) || (identifier > 127)) {
|
||||
strcpy(symbol->errtxt, "351: Invalid DPD identifier");
|
||||
strcpy(symbol->errtxt, "301: Invalid DPD identifier (first character), ASCII values 32 to 127 only");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
source[0] = identifier;
|
||||
error_number = code_128(symbol, source, length); /* Only returns errors, not warnings */
|
||||
|
||||
if (error_number < ZINT_ERROR) {
|
||||
|
@ -54,7 +54,7 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
int error_number = 0;
|
||||
|
||||
if (length > 81) {
|
||||
strcpy(symbol->errtxt, "430: Input too long");
|
||||
strcpy(symbol->errtxt, "430: Input too long (81 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
if ((symbol->input_mode & 0x07) == GS1_MODE) {
|
||||
@ -66,7 +66,7 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (source[i] > 127) {
|
||||
strcpy(symbol->errtxt, "431: Invalid characters in input data");
|
||||
strcpy(symbol->errtxt, "431: Invalid character in input data, extended ASCII not allowed");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
if (gs1 && (source[i] == '['))
|
||||
|
@ -57,17 +57,17 @@
|
||||
#define ustrncat(target, source, count) strncat((char *) (target), (const char *) (source), (count))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if _MSC_VER < 1800 /* ceilf, floorf, roundf (C99) not before MSVC 2013 (C++ 12.0) */
|
||||
# if _MSC_VER == 1200 /* VC6 */
|
||||
# define ceilf (float) ceil
|
||||
# define floorf (float) floor
|
||||
# define roundf (float) round
|
||||
# define fmodf (float) fmod
|
||||
# if _MSC_VER == 1200 /* VC6 */
|
||||
# define round(arg) floor((arg) + 0.5f)
|
||||
# endif
|
||||
# endif
|
||||
# if _MSC_VER < 1800 /* round (C99) not before MSVC 2013 (C++ 12.0) */
|
||||
# define round(arg) floor((arg) + 0.5)
|
||||
# define roundf(arg) floorf((arg) + 0.5f)
|
||||
# endif
|
||||
# pragma warning(disable: 4244) /* conversion from int to float */
|
||||
# if _MSC_VER >= 1800 /* MSVC 2013 */
|
||||
# if _MSC_VER != 1200 /* VC6 */
|
||||
# pragma warning(disable: 4996) /* function or variable may be unsafe */
|
||||
# endif
|
||||
#endif
|
||||
|
@ -114,7 +114,7 @@ static int encode928(const UINT bitString[], UINT codeWords[], const int bitLng)
|
||||
}
|
||||
|
||||
/* CC-A 2D component */
|
||||
static int cc_a(struct zint_symbol *symbol, const char source[], const int cc_width) {
|
||||
static void cc_a(struct zint_symbol *symbol, const char source[], const int cc_width) {
|
||||
int i, segment, bitlen, cwCnt, variant, rows;
|
||||
int k, offset, j, total, rsCodeWords[8] = {0};
|
||||
int LeftRAPStart, RightRAPStart, CentreRAPStart, StartCluster;
|
||||
@ -127,7 +127,7 @@ static int cc_a(struct zint_symbol *symbol, const char source[], const int cc_wi
|
||||
|
||||
variant = 0;
|
||||
|
||||
bitlen = (int)strlen(source);
|
||||
bitlen = (int) strlen(source);
|
||||
|
||||
for (segment = 0; segment < 13; segment++) {
|
||||
int strpos = segment * 16;
|
||||
@ -296,12 +296,10 @@ static int cc_a(struct zint_symbol *symbol, const char source[], const int cc_wi
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("CC-A Columns: %d, Rows: %d\n", cc_width, symbol->rows);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* CC-B 2D component */
|
||||
static int cc_b(struct zint_symbol *symbol, const char source[], const int cc_width) {
|
||||
static void cc_b(struct zint_symbol *symbol, const char source[], const int cc_width) {
|
||||
int length = (int) strlen(source) / 8;
|
||||
int i;
|
||||
#ifndef _MSC_VER
|
||||
@ -521,12 +519,10 @@ static int cc_b(struct zint_symbol *symbol, const char source[], const int cc_wi
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("CC-B Columns: %d, Rows: %d\n", cc_width, symbol->rows);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* CC-C 2D component - byte compressed PDF417 */
|
||||
static int cc_c(struct zint_symbol *symbol, const char source[], const int cc_width, const int ecc_level) {
|
||||
static void cc_c(struct zint_symbol *symbol, const char source[], const int cc_width, const int ecc_level) {
|
||||
int length = (int) strlen(source) / 8;
|
||||
int i, p;
|
||||
#ifndef _MSC_VER
|
||||
@ -662,8 +658,6 @@ static int cc_c(struct zint_symbol *symbol, const char source[], const int cc_wi
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("CC-C Columns: %d, Rows: %d\n", cc_width, symbol->rows);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int calc_padding_cca(const int binary_length, const int cc_width) {
|
||||
@ -1161,8 +1155,8 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
|
||||
alpha_pad = 0;
|
||||
|
||||
if (!general_field_encode(general_field, j, &mode, &last_digit, binary_string, &bp)) {
|
||||
/* Invalid characters in input data */
|
||||
strcpy(symbol->errtxt, "441: Invalid characters in input data");
|
||||
/* Invalid character in input data */
|
||||
strcpy(symbol->errtxt, "441: Invalid character in input data");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
@ -1288,7 +1282,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
|
||||
|
||||
/* Perform sanity checks on input options first */
|
||||
error_number = 0;
|
||||
pri_len = (int)strlen(symbol->primary);
|
||||
pri_len = (int) strlen(symbol->primary);
|
||||
if (pri_len == 0) {
|
||||
strcpy(symbol->errtxt, "445: No primary (linear) message in 2D composite");
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
@ -1413,18 +1407,14 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
|
||||
|
||||
switch (cc_mode) {
|
||||
/* Note that ecc_level is only relevant to CC-C */
|
||||
case 1: error_number = cc_a(symbol, binary_string, cc_width);
|
||||
case 1: cc_a(symbol, binary_string, cc_width);
|
||||
break;
|
||||
case 2: error_number = cc_b(symbol, binary_string, cc_width);
|
||||
case 2: cc_b(symbol, binary_string, cc_width);
|
||||
break;
|
||||
case 3: error_number = cc_c(symbol, binary_string, cc_width, ecc_level);
|
||||
case 3: cc_c(symbol, binary_string, cc_width, ecc_level);
|
||||
break;
|
||||
}
|
||||
|
||||
if (error_number != 0) {
|
||||
return ZINT_ERROR_ENCODING_PROBLEM;
|
||||
}
|
||||
|
||||
/* 2D component done, now calculate linear component */
|
||||
linear = ZBarcode_Create(); /* Symbol contains the 2D component and Linear contains the rest */
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int
|
||||
if (error_number == 0) {
|
||||
done = 1;
|
||||
} else if (symbol->eci) {
|
||||
strcpy(symbol->errtxt, "575: Invalid characters in input data");
|
||||
sprintf(symbol->errtxt, "535: Invalid character in input data for ECI %d", symbol->eci);
|
||||
return error_number;
|
||||
}
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ static int pcenc(const unsigned char *data, int data_len, int offset, int min, i
|
||||
if (strchr(hex_chars, *(++d)) == NULL || strchr(hex_chars, *(++d)) == NULL) {
|
||||
*p_err_no = 3;
|
||||
*p_err_posn = d - data + 1;
|
||||
strcpy(err_msg, "Invalid characters for percent encoding");
|
||||
strcpy(err_msg, "Invalid character for percent encoding");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1491,7 +1491,7 @@ INTERNAL int han_xin(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
if (error_number == 0) {
|
||||
done = 1;
|
||||
} else if (symbol->eci) {
|
||||
strcpy(symbol->errtxt, "575: Invalid characters in input data");
|
||||
sprintf(symbol->errtxt, "545: Invalid character in input data for ECI %d", symbol->eci);
|
||||
return error_number;
|
||||
}
|
||||
}
|
||||
|
@ -259,12 +259,12 @@ INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
int zip_len, len;
|
||||
|
||||
if (length > 32) {
|
||||
strcpy(symbol->errtxt, "450: Input too long");
|
||||
strcpy(symbol->errtxt, "450: Input too long (32 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(SODIUM, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "451: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "451: Invalid character in data (digits and \"-\" only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -299,17 +299,17 @@ INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
}
|
||||
|
||||
if (strlen(tracker) != 20) {
|
||||
strcpy(symbol->errtxt, "452: Invalid length tracking code");
|
||||
strcpy(symbol->errtxt, "452: Invalid length for tracking code (20 characters required)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
if (tracker[1] > '4') {
|
||||
strcpy(symbol->errtxt, "454: Invalid Barcode Identifier");
|
||||
strcpy(symbol->errtxt, "454: Barcode Identifier (second character) out of range (0 to 4)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
zip_len = (int) strlen(zip);
|
||||
if (zip_len != 0 && zip_len != 5 && zip_len != 9 && zip_len != 11) {
|
||||
strcpy(symbol->errtxt, "453: Invalid ZIP code");
|
||||
strcpy(symbol->errtxt, "453: Invalid length for ZIP code (5, 9 or 11 characters required)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
* https://stackoverflow.com/a/1980056/664741 */
|
||||
typedef int static_assert_int_at_least_32bits[CHAR_BIT != 8 || sizeof(int) < 4 ? -1 : 1];
|
||||
|
||||
/* Create and initialize a symbol structure */
|
||||
struct zint_symbol *ZBarcode_Create() {
|
||||
struct zint_symbol *symbol;
|
||||
|
||||
@ -82,6 +83,7 @@ struct zint_symbol *ZBarcode_Create() {
|
||||
|
||||
INTERNAL void vector_free(struct zint_symbol *symbol); /* Free vector structures */
|
||||
|
||||
/* Free any output buffers that may have been created and initialize output fields */
|
||||
void ZBarcode_Clear(struct zint_symbol *symbol) {
|
||||
int i, j;
|
||||
|
||||
@ -94,6 +96,7 @@ void ZBarcode_Clear(struct zint_symbol *symbol) {
|
||||
}
|
||||
symbol->rows = 0;
|
||||
symbol->width = 0;
|
||||
memset(symbol->row_height, 0, sizeof(symbol->row_height));
|
||||
memset(symbol->text, 0, sizeof(symbol->text));
|
||||
symbol->errtxt[0] = '\0';
|
||||
if (symbol->bitmap != NULL) {
|
||||
@ -106,11 +109,13 @@ void ZBarcode_Clear(struct zint_symbol *symbol) {
|
||||
}
|
||||
symbol->bitmap_width = 0;
|
||||
symbol->bitmap_height = 0;
|
||||
symbol->bitmap_byte_length = 0;
|
||||
|
||||
// If there is a rendered version, ensure its memory is released
|
||||
vector_free(symbol);
|
||||
}
|
||||
|
||||
/* Free a symbol structure, including any output buffers */
|
||||
void ZBarcode_Delete(struct zint_symbol *symbol) {
|
||||
if (!symbol) return;
|
||||
|
||||
@ -205,13 +210,27 @@ INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to EPS/EMF/SVG */
|
||||
|
||||
/* Prefix error message with Error/Warning */
|
||||
STATIC_UNLESS_ZINT_TEST int error_tag(char error_string[100], int error_number) {
|
||||
STATIC_UNLESS_ZINT_TEST int error_tag(struct zint_symbol *symbol, int error_number, const char *error_string) {
|
||||
|
||||
if (error_number != 0) {
|
||||
const char *fmt = error_number >= ZINT_ERROR ? "Error %.93s" : "Warning %.91s"; /* Truncate if too long */
|
||||
static const char *error_fmt = "Error %.93s"; /* Truncate if too long */
|
||||
static const char *warn_fmt = "Warning %.91s"; /* Truncate if too long */
|
||||
const char *fmt = error_number >= ZINT_ERROR ? error_fmt : warn_fmt;
|
||||
char error_buffer[100];
|
||||
sprintf(error_buffer, fmt, error_string);
|
||||
strcpy(error_string, error_buffer);
|
||||
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
/* Convert to error equivalent */
|
||||
if (error_number == ZINT_WARN_NONCOMPLIANT) {
|
||||
error_number = ZINT_ERROR_NONCOMPLIANT;
|
||||
} else if (error_number == ZINT_WARN_USES_ECI) {
|
||||
error_number = ZINT_ERROR_USES_ECI;
|
||||
} else { /* ZINT_WARN_INVALID_OPTION */
|
||||
error_number = ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
fmt = error_fmt;
|
||||
}
|
||||
sprintf(error_buffer, fmt, error_string ? error_string : symbol->errtxt);
|
||||
strcpy(symbol->errtxt, error_buffer);
|
||||
}
|
||||
|
||||
return error_number;
|
||||
@ -284,13 +303,13 @@ static int hibc(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
|
||||
/* without "+" and check: max 110 characters in HIBC 2.6 */
|
||||
if (length > 110) {
|
||||
strcpy(symbol->errtxt, "202: Data too long for HIBC LIC");
|
||||
strcpy(symbol->errtxt, "202: Data too long for HIBC LIC (110 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
to_upper(source);
|
||||
error_number = is_sane(TECHNETIUM, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "203: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -373,26 +392,22 @@ static int hibc(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
static int check_force_gs1(const int symbology) {
|
||||
/* Returns 1 if symbology MUST have GS1 data */
|
||||
|
||||
int result = is_composite(symbology);
|
||||
|
||||
switch (symbology) {
|
||||
case BARCODE_GS1_128:
|
||||
case BARCODE_EAN14:
|
||||
case BARCODE_NVE18:
|
||||
case BARCODE_DBAR_EXP:
|
||||
case BARCODE_DBAR_EXPSTK:
|
||||
result = 1;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
return is_composite(symbology);
|
||||
}
|
||||
|
||||
static int gs1_compliant(const int symbology) {
|
||||
/* Returns 1 if symbology supports GS1 data */
|
||||
|
||||
int result = check_force_gs1(symbology);
|
||||
|
||||
switch (symbology) {
|
||||
case BARCODE_CODE16K:
|
||||
case BARCODE_AZTEC:
|
||||
@ -403,18 +418,16 @@ static int gs1_compliant(const int symbology) {
|
||||
case BARCODE_DOTCODE:
|
||||
case BARCODE_RMQR:
|
||||
case BARCODE_ULTRA:
|
||||
result = 1;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
return check_force_gs1(symbology);
|
||||
}
|
||||
|
||||
static int is_dotty(const int symbology) {
|
||||
/* Returns 1 if symbology is a matrix design renderable as dots */
|
||||
|
||||
int result = 0;
|
||||
|
||||
switch (symbology) {
|
||||
/* Note MAXICODE and ULTRA absent */
|
||||
case BARCODE_QRCODE:
|
||||
@ -431,18 +444,16 @@ static int is_dotty(const int symbology) {
|
||||
case BARCODE_DOTCODE:
|
||||
case BARCODE_UPNQR:
|
||||
case BARCODE_RMQR:
|
||||
result = 1;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_fixed_ratio(const int symbology) {
|
||||
/* Returns 1 if symbology has fixed aspect ratio (matrix design) */
|
||||
|
||||
int result = 0;
|
||||
|
||||
if (is_dotty(symbology)) {
|
||||
return 1;
|
||||
}
|
||||
@ -450,18 +461,16 @@ static int is_fixed_ratio(const int symbology) {
|
||||
switch (symbology) {
|
||||
case BARCODE_MAXICODE:
|
||||
case BARCODE_ULTRA:
|
||||
result = 1;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int supports_eci(const int symbology) {
|
||||
/* Returns 1 if symbology can encode the ECI character */
|
||||
|
||||
int result = 0;
|
||||
|
||||
switch (symbology) {
|
||||
case BARCODE_AZTEC:
|
||||
case BARCODE_DATAMATRIX:
|
||||
@ -475,11 +484,11 @@ static int supports_eci(const int symbology) {
|
||||
case BARCODE_GRIDMATRIX:
|
||||
case BARCODE_HANXIN:
|
||||
case BARCODE_ULTRA:
|
||||
result = 1;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int has_hrt(const int symbology) {
|
||||
@ -528,6 +537,7 @@ static int has_hrt(const int symbology) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
|
||||
unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
|
||||
unsigned int result = 0;
|
||||
|
||||
@ -632,7 +642,7 @@ int ZBarcode_ValidID(int symbol_id) {
|
||||
return ids[symbol_id] != 0;
|
||||
}
|
||||
|
||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int in_length);
|
||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length);
|
||||
|
||||
static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char *source, const int length) {
|
||||
int error_number = 0;
|
||||
@ -658,12 +668,12 @@ static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char
|
||||
return error_number;
|
||||
}
|
||||
|
||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int in_length) {
|
||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length) {
|
||||
/* These are the "norm" standards which only support Latin-1 at most, though a few support ECI */
|
||||
int error_number = 0;
|
||||
unsigned char *preprocessed = source;
|
||||
|
||||
int eci_length = get_eci_length(symbol->eci, source, in_length);
|
||||
int eci_length = get_eci_length(symbol->eci, source, length);
|
||||
#ifndef _MSC_VER
|
||||
unsigned char preprocessed_buf[eci_length + 1];
|
||||
#else
|
||||
@ -673,27 +683,31 @@ static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, in
|
||||
if ((symbol->input_mode & 0x07) == UNICODE_MODE && is_eci_convertible(symbol->eci)) {
|
||||
/* Prior check ensures ECI only set for those that support it */
|
||||
preprocessed = preprocessed_buf;
|
||||
error_number = utf8_to_eci(symbol->eci, source, preprocessed, &in_length);
|
||||
error_number = utf8_to_eci(symbol->eci, source, preprocessed, &length);
|
||||
if (error_number != 0) {
|
||||
strcpy(symbol->errtxt, "204: Invalid characters in input data");
|
||||
if (symbol->eci) {
|
||||
sprintf(symbol->errtxt, "244: Invalid character in input data for ECI %d", symbol->eci);
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "204: Invalid character in input data (ISO/IEC 8859-1 only)");
|
||||
}
|
||||
return error_number;
|
||||
}
|
||||
}
|
||||
|
||||
switch (symbol->symbology) {
|
||||
case BARCODE_C25STANDARD: error_number = matrix_two_of_five(symbol, preprocessed, in_length);
|
||||
case BARCODE_C25STANDARD: error_number = matrix_two_of_five(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_C25IND: error_number = industrial_two_of_five(symbol, preprocessed, in_length);
|
||||
case BARCODE_C25IND: error_number = industrial_two_of_five(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_C25INTER: error_number = interleaved_two_of_five(symbol, preprocessed, in_length);
|
||||
case BARCODE_C25INTER: error_number = interleaved_two_of_five(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_C25IATA: error_number = iata_two_of_five(symbol, preprocessed, in_length);
|
||||
case BARCODE_C25IATA: error_number = iata_two_of_five(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_C25LOGIC: error_number = logic_two_of_five(symbol, preprocessed, in_length);
|
||||
case BARCODE_C25LOGIC: error_number = logic_two_of_five(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DPLEIT: error_number = dpleit(symbol, preprocessed, in_length);
|
||||
case BARCODE_DPLEIT: error_number = dpleit(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DPIDENT: error_number = dpident(symbol, preprocessed, in_length);
|
||||
case BARCODE_DPIDENT: error_number = dpident(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_UPCA:
|
||||
case BARCODE_UPCA_CHK:
|
||||
@ -701,76 +715,75 @@ static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, in
|
||||
case BARCODE_UPCE_CHK:
|
||||
case BARCODE_EANX:
|
||||
case BARCODE_EANX_CHK:
|
||||
error_number = eanx(symbol, preprocessed, in_length);
|
||||
case BARCODE_ISBNX:
|
||||
error_number = eanx(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_GS1_128: error_number = ean_128(symbol, preprocessed, in_length);
|
||||
case BARCODE_GS1_128: error_number = ean_128(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODE39: error_number = c39(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODE39: error_number = c39(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_PZN: error_number = pharmazentral(symbol, preprocessed, in_length);
|
||||
case BARCODE_PZN: error_number = pharmazentral(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_EXCODE39: error_number = ec39(symbol, preprocessed, in_length);
|
||||
case BARCODE_EXCODE39: error_number = ec39(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODABAR: error_number = codabar(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODABAR: error_number = codabar(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODE93: error_number = c93(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODE93: error_number = c93(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_LOGMARS: error_number = c39(symbol, preprocessed, in_length);
|
||||
case BARCODE_LOGMARS: error_number = c39(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODE128:
|
||||
case BARCODE_CODE128B:
|
||||
error_number = code_128(symbol, preprocessed, in_length);
|
||||
error_number = code_128(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_NVE18: error_number = nve_18(symbol, preprocessed, in_length);
|
||||
case BARCODE_NVE18: error_number = nve_18(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODE11: error_number = code_11(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODE11: error_number = code_11(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_MSI_PLESSEY: error_number = msi_handle(symbol, preprocessed, in_length);
|
||||
case BARCODE_MSI_PLESSEY: error_number = msi_handle(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_TELEPEN: error_number = telepen(symbol, preprocessed, in_length);
|
||||
case BARCODE_TELEPEN: error_number = telepen(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_TELEPEN_NUM: error_number = telepen_num(symbol, preprocessed, in_length);
|
||||
case BARCODE_TELEPEN_NUM: error_number = telepen_num(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_PHARMA: error_number = pharma_one(symbol, preprocessed, in_length);
|
||||
case BARCODE_PHARMA: error_number = pharma_one(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_PLESSEY: error_number = plessey(symbol, preprocessed, in_length);
|
||||
case BARCODE_PLESSEY: error_number = plessey(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_ITF14: error_number = itf14(symbol, preprocessed, in_length);
|
||||
case BARCODE_ITF14: error_number = itf14(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_FLAT: error_number = flattermarken(symbol, preprocessed, in_length);
|
||||
case BARCODE_FLAT: error_number = flattermarken(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_FIM: error_number = fim(symbol, preprocessed, in_length);
|
||||
case BARCODE_FIM: error_number = fim(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_POSTNET: error_number = post_plot(symbol, preprocessed, in_length);
|
||||
case BARCODE_POSTNET: error_number = post_plot(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_PLANET: error_number = planet_plot(symbol, preprocessed, in_length);
|
||||
case BARCODE_PLANET: error_number = planet_plot(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_RM4SCC: error_number = royal_plot(symbol, preprocessed, in_length);
|
||||
case BARCODE_RM4SCC: error_number = royal_plot(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_AUSPOST:
|
||||
case BARCODE_AUSREPLY:
|
||||
case BARCODE_AUSROUTE:
|
||||
case BARCODE_AUSREDIRECT:
|
||||
error_number = australia_post(symbol, preprocessed, in_length);
|
||||
error_number = australia_post(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODE16K: error_number = code16k(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODE16K: error_number = code16k(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_PHARMA_TWO: error_number = pharma_two(symbol, preprocessed, in_length);
|
||||
case BARCODE_PHARMA_TWO: error_number = pharma_two(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_USPS_IMAIL: error_number = imail(symbol, preprocessed, in_length);
|
||||
break;
|
||||
case BARCODE_ISBNX: error_number = eanx(symbol, preprocessed, in_length);
|
||||
case BARCODE_USPS_IMAIL: error_number = imail(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DBAR_OMN:
|
||||
case BARCODE_DBAR_STK:
|
||||
case BARCODE_DBAR_OMNSTK:
|
||||
error_number = rss14(symbol, preprocessed, in_length);
|
||||
error_number = rss14(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DBAR_LTD: error_number = rsslimited(symbol, preprocessed, in_length);
|
||||
case BARCODE_DBAR_LTD: error_number = rsslimited(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DBAR_EXP:
|
||||
case BARCODE_DBAR_EXPSTK:
|
||||
error_number = rssexpanded(symbol, preprocessed, in_length);
|
||||
error_number = rssexpanded(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_EANX_CC:
|
||||
case BARCODE_GS1_128_CC:
|
||||
@ -782,20 +795,20 @@ static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, in
|
||||
case BARCODE_DBAR_STK_CC:
|
||||
case BARCODE_DBAR_OMNSTK_CC:
|
||||
case BARCODE_DBAR_EXPSTK_CC:
|
||||
error_number = composite(symbol, preprocessed, in_length);
|
||||
error_number = composite(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_KIX: error_number = kix_code(symbol, preprocessed, in_length);
|
||||
case BARCODE_KIX: error_number = kix_code(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODE32: error_number = code32(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODE32: error_number = code32(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DAFT: error_number = daft_code(symbol, preprocessed, in_length);
|
||||
case BARCODE_DAFT: error_number = daft_code(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_EAN14:
|
||||
error_number = ean_14(symbol, preprocessed, in_length);
|
||||
error_number = ean_14(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_AZRUNE: error_number = aztec_runes(symbol, preprocessed, in_length);
|
||||
case BARCODE_AZRUNE: error_number = aztec_runes(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_KOREAPOST: error_number = korea_post(symbol, preprocessed, in_length);
|
||||
case BARCODE_KOREAPOST: error_number = korea_post(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_HIBC_128:
|
||||
case BARCODE_HIBC_39:
|
||||
@ -805,39 +818,43 @@ static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, in
|
||||
case BARCODE_HIBC_MICPDF:
|
||||
case BARCODE_HIBC_AZTEC:
|
||||
case BARCODE_HIBC_BLOCKF:
|
||||
error_number = hibc(symbol, preprocessed, in_length);
|
||||
error_number = hibc(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_JAPANPOST: error_number = japan_post(symbol, preprocessed, in_length);
|
||||
case BARCODE_JAPANPOST: error_number = japan_post(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODE49: error_number = code_49(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODE49: error_number = code_49(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CHANNEL: error_number = channel_code(symbol, preprocessed, in_length);
|
||||
case BARCODE_CHANNEL: error_number = channel_code(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODEONE: error_number = code_one(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODEONE: error_number = code_one(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DATAMATRIX: error_number = dmatrix(symbol, preprocessed, in_length);
|
||||
case BARCODE_DATAMATRIX: error_number = dmatrix(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_PDF417:
|
||||
case BARCODE_PDF417COMP:
|
||||
error_number = pdf417enc(symbol, preprocessed, in_length);
|
||||
error_number = pdf417enc(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_MICROPDF417: error_number = micro_pdf417(symbol, preprocessed, in_length);
|
||||
case BARCODE_MICROPDF417: error_number = micro_pdf417(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_MAXICODE: error_number = maxicode(symbol, preprocessed, in_length);
|
||||
case BARCODE_MAXICODE: error_number = maxicode(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_AZTEC: error_number = aztec(symbol, preprocessed, in_length);
|
||||
case BARCODE_AZTEC: error_number = aztec(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DOTCODE: error_number = dotcode(symbol, preprocessed, in_length);
|
||||
case BARCODE_DOTCODE: error_number = dotcode(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_CODABLOCKF: error_number = codablock(symbol, preprocessed, in_length);
|
||||
case BARCODE_CODABLOCKF: error_number = codablock(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_VIN: error_number = vin(symbol, preprocessed, in_length);
|
||||
case BARCODE_VIN: error_number = vin(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_MAILMARK: error_number = mailmark(symbol, preprocessed, in_length);
|
||||
case BARCODE_MAILMARK: error_number = mailmark(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_ULTRA: error_number = ultracode(symbol, preprocessed, in_length);
|
||||
case BARCODE_ULTRA: error_number = ultracode(symbol, preprocessed, length);
|
||||
break;
|
||||
case BARCODE_DPD: error_number = dpd_parcel(symbol, preprocessed, in_length);
|
||||
case BARCODE_DPD: error_number = dpd_parcel(symbol, preprocessed, length);
|
||||
break;
|
||||
default: /* Should never happen */
|
||||
strcpy(symbol->errtxt, "001: Internal error"); /* Not reached */
|
||||
error_number = ZINT_ERROR_ENCODING_PROBLEM;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -858,7 +875,6 @@ STATIC_UNLESS_ZINT_TEST void strip_bom(unsigned char *source, int *input_length)
|
||||
}
|
||||
|
||||
static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_string, int *length) {
|
||||
int error_number;
|
||||
int in_posn, out_posn;
|
||||
int hex1, hex2;
|
||||
int i, unicode;
|
||||
@ -981,12 +997,11 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_
|
||||
input_string[out_posn] = '\0';
|
||||
*length = out_posn;
|
||||
|
||||
error_number = 0;
|
||||
|
||||
return error_number;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int in_length) {
|
||||
/* Encode a barcode. If `length` is 0, `source` must be NUL-terminated. */
|
||||
int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int length) {
|
||||
int error_number, warn_number;
|
||||
#ifdef _MSC_VER
|
||||
unsigned char *local_source;
|
||||
@ -997,40 +1012,37 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("ZBarcode_Encode: symbology: %d, input_mode: 0x%X, ECI: %d, option_1: %d, option_2: %d,"
|
||||
" option_3: %d, scale: %g\n output_options: 0x%X, fg: %s, bg: %s,"
|
||||
" in_length: %d, First 10 source: \"%.10s\", First 10 primary: \"%.10s\"\n",
|
||||
" length: %d, First 10 source: \"%.10s\", First 10 primary: \"%.10s\"\n",
|
||||
symbol->symbology, symbol->input_mode, symbol->eci, symbol->option_1, symbol->option_2,
|
||||
symbol->option_3, symbol->scale, symbol->output_options, symbol->fgcolour, symbol->bgcolour,
|
||||
in_length, source ? (const char *) source : "<NULL>", symbol->primary);
|
||||
length, source ? (const char *) source : "<NULL>", symbol->primary);
|
||||
}
|
||||
|
||||
warn_number = 0;
|
||||
|
||||
if (source == NULL) {
|
||||
strcpy(symbol->errtxt, "200: Input data NULL");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "200: Input data NULL");
|
||||
}
|
||||
if (in_length <= 0) {
|
||||
in_length = (int) ustrlen(source);
|
||||
if (length <= 0) {
|
||||
length = (int) ustrlen(source);
|
||||
}
|
||||
if (in_length <= 0) {
|
||||
strcpy(symbol->errtxt, "205: No input data");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
|
||||
if (length <= 0) {
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "205: No input data");
|
||||
}
|
||||
if (in_length > ZINT_MAX_DATA_LEN) {
|
||||
strcpy(symbol->errtxt, "243: Input data too long");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_TOO_LONG);
|
||||
if (length > ZINT_MAX_DATA_LEN) {
|
||||
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "243: Input data too long");
|
||||
}
|
||||
|
||||
/* First check the symbology field */
|
||||
if (!ZBarcode_ValidID(symbol->symbology)) {
|
||||
int orig_symbology = symbol->symbology; /* For self-check */
|
||||
if (symbol->symbology < 1) {
|
||||
strcpy(symbol->errtxt, "206: Symbology out of range");
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "206: Symbology out of range");
|
||||
if (warn_number >= ZINT_ERROR) {
|
||||
return warn_number;
|
||||
}
|
||||
symbol->symbology = BARCODE_CODE128;
|
||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||
/* symbol->symbologys 1 to 86 are defined by tbarcode */
|
||||
/* symbol->symbologys 1 to 126 are defined by tbarcode */
|
||||
} else if (symbol->symbology == 5) {
|
||||
symbol->symbology = BARCODE_C25STANDARD;
|
||||
} else if ((symbol->symbology >= 10) && (symbol->symbology <= 12)) {
|
||||
@ -1040,34 +1052,33 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
} else if (symbol->symbology == 17) {
|
||||
symbol->symbology = BARCODE_UPCA;
|
||||
} else if (symbol->symbology == 19) {
|
||||
strcpy(symbol->errtxt, "207: Codabar 18 not supported");
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "207: Codabar 18 not supported");
|
||||
if (warn_number >= ZINT_ERROR) {
|
||||
return warn_number;
|
||||
}
|
||||
symbol->symbology = BARCODE_CODABAR;
|
||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||
} else if (symbol->symbology == 26) {
|
||||
} else if (symbol->symbology == 26) { /* UPC-A up to tbarcode 9, ISSN for tbarcode 10+ */
|
||||
symbol->symbology = BARCODE_UPCA;
|
||||
} else if (symbol->symbology == 27) {
|
||||
strcpy(symbol->errtxt, "208: UPCD1 not supported");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
} else if (symbol->symbology == 27) { /* UPCD1 up to tbarcode 9, ISSN + 2 digit add-on for tbarcode 10+ */
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "208: UPCD1 not supported");
|
||||
} else if (symbol->symbology == 33) {
|
||||
symbol->symbology = BARCODE_GS1_128;
|
||||
} else if (symbol->symbology == 36) {
|
||||
symbol->symbology = BARCODE_UPCA;
|
||||
} else if (symbol->symbology == 39) {
|
||||
symbol->symbology = BARCODE_UPCE;
|
||||
} else if ((symbol->symbology >= 41) && (symbol->symbology <= 45)) {
|
||||
symbol->symbology = BARCODE_POSTNET;
|
||||
} else if (symbol->symbology == 46) {
|
||||
symbol->symbology = BARCODE_PLESSEY;
|
||||
} else if (symbol->symbology == 48) {
|
||||
symbol->symbology = BARCODE_NVE18;
|
||||
} else if (symbol->symbology == 54) {
|
||||
strcpy(symbol->errtxt, "210: General Parcel Code not supported");
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
} else if (symbol->symbology == 54) { /* General Parcel up to tbarcode 9, Brazelian CEPNet for tbarcode 10+ */
|
||||
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "210: General Parcel Code not supported");
|
||||
if (warn_number >= ZINT_ERROR) {
|
||||
return warn_number;
|
||||
}
|
||||
symbol->symbology = BARCODE_CODE128;
|
||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||
} else if ((symbol->symbology == 59) || (symbol->symbology == 61)) {
|
||||
symbol->symbology = BARCODE_CODE128;
|
||||
} else if (symbol->symbology == 62) {
|
||||
@ -1080,20 +1091,18 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
symbol->symbology = BARCODE_PLANET;
|
||||
} else if (symbol->symbology == 88) {
|
||||
symbol->symbology = BARCODE_GS1_128;
|
||||
} else if (symbol->symbology == 91) {
|
||||
strcpy(symbol->errtxt, "212: Symbology out of range");
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
} else if (symbol->symbology == 91) { /* BC412 up to tbarcode 9, Code 32 for tbarcode 10+ */
|
||||
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "212: Symbology out of range");
|
||||
if (warn_number >= ZINT_ERROR) {
|
||||
return warn_number;
|
||||
}
|
||||
symbol->symbology = BARCODE_CODE128;
|
||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||
} else if ((symbol->symbology >= 94) && (symbol->symbology <= 95)) {
|
||||
strcpy(symbol->errtxt, "213: Symbology out of range");
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "213: Symbology out of range");
|
||||
if (warn_number >= ZINT_ERROR) {
|
||||
return warn_number;
|
||||
}
|
||||
symbol->symbology = BARCODE_CODE128;
|
||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||
} else if (symbol->symbology == 100) {
|
||||
symbol->symbology = BARCODE_HIBC_128;
|
||||
} else if (symbol->symbology == 101) {
|
||||
@ -1109,78 +1118,72 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
} else if (symbol->symbology == 111) {
|
||||
symbol->symbology = BARCODE_HIBC_BLOCKF;
|
||||
} else if ((symbol->symbology == 113) || (symbol->symbology == 114)) {
|
||||
strcpy(symbol->errtxt, "214: Symbology out of range");
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "214: Symbology out of range");
|
||||
if (warn_number >= ZINT_ERROR) {
|
||||
return warn_number;
|
||||
}
|
||||
symbol->symbology = BARCODE_CODE128;
|
||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||
} else if (symbol->symbology == 115) {
|
||||
symbol->symbology = BARCODE_DOTCODE;
|
||||
} else if ((symbol->symbology >= 117) && (symbol->symbology <= 127)) {
|
||||
if (symbol->symbology != 121) {
|
||||
strcpy(symbol->errtxt, "215: Symbology out of range");
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
if (symbol->symbology != 121) { /* BARCODE_MAILMARK */
|
||||
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "215: Symbology out of range");
|
||||
if (warn_number >= ZINT_ERROR) {
|
||||
return warn_number;
|
||||
}
|
||||
symbol->symbology = BARCODE_CODE128;
|
||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||
}
|
||||
/* Everything from 128 up is Zint-specific */
|
||||
} else if (symbol->symbology > 145) {
|
||||
strcpy(symbol->errtxt, "216: Symbology out of range");
|
||||
if (symbol->warn_level == WARN_FAIL_ALL) {
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "216: Symbology out of range");
|
||||
if (warn_number >= ZINT_ERROR) {
|
||||
return warn_number;
|
||||
}
|
||||
symbol->symbology = BARCODE_CODE128;
|
||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||
}
|
||||
if (symbol->symbology == orig_symbology) { /* Should never happen */
|
||||
return error_tag(symbol, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error"); /* Not reached */
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol->eci != 0) {
|
||||
if (!(supports_eci(symbol->symbology))) {
|
||||
strcpy(symbol->errtxt, "217: Symbology does not support ECI switching");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "217: Symbology does not support ECI switching");
|
||||
}
|
||||
if ((symbol->eci < 0) || (symbol->eci == 1) || (symbol->eci == 2) || (symbol->eci > 999999)) {
|
||||
strcpy(symbol->errtxt, "218: Invalid ECI mode");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "218: Invalid ECI mode");
|
||||
}
|
||||
}
|
||||
|
||||
if ((symbol->dot_size < 0.01f) || (symbol->dot_size > 20.0f)) {
|
||||
strcpy(symbol->errtxt, "221: Invalid dot size");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
}
|
||||
|
||||
if ((symbol->input_mode & 0x07) == UNICODE_MODE && !is_valid_utf8(source, in_length)) {
|
||||
strcpy(symbol->errtxt, "245: Invalid UTF-8");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "221: Invalid dot size");
|
||||
}
|
||||
|
||||
if ((symbol->input_mode & 0x07) > 2) {
|
||||
symbol->input_mode = DATA_MODE; /* Reset completely */
|
||||
symbol->input_mode = DATA_MODE; /* Reset completely TODO: in future, warn/error */
|
||||
}
|
||||
|
||||
if ((symbol->input_mode & 0x07) == UNICODE_MODE && !is_valid_utf8(source, length)) {
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "245: Invalid UTF-8 in input data");
|
||||
}
|
||||
|
||||
#ifndef _MSC_VER
|
||||
unsigned char local_source[in_length + 1];
|
||||
unsigned char local_source[length + 1];
|
||||
#else
|
||||
local_source = (unsigned char *) _alloca(in_length + 1);
|
||||
local_source = (unsigned char *) _alloca(length + 1);
|
||||
#endif
|
||||
|
||||
memcpy(local_source, source, in_length);
|
||||
local_source[in_length] = '\0';
|
||||
memcpy(local_source, source, length);
|
||||
local_source[length] = '\0';
|
||||
|
||||
/* Start acting on input mode */
|
||||
if (symbol->input_mode & ESCAPE_MODE) {
|
||||
error_number = escape_char_process(symbol, local_source, &in_length);
|
||||
error_number = escape_char_process(symbol, local_source, &length); /* Only returns errors, not warnings */
|
||||
if (error_number != 0) {
|
||||
return error_tag(symbol->errtxt, error_number);
|
||||
return error_tag(symbol, error_number, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if ((symbol->input_mode & 0x07) == UNICODE_MODE) {
|
||||
strip_bom(local_source, &in_length);
|
||||
strip_bom(local_source, &length);
|
||||
}
|
||||
|
||||
if (((symbol->input_mode & 0x07) == GS1_MODE) || (check_force_gs1(symbol->symbology))) {
|
||||
@ -1189,42 +1192,43 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
// handle it themselves
|
||||
if (is_composite(symbol->symbology) || !check_force_gs1(symbol->symbology)) {
|
||||
#ifndef _MSC_VER
|
||||
unsigned char reduced[in_length + 1];
|
||||
unsigned char reduced[length + 1];
|
||||
#else
|
||||
unsigned char *reduced = (unsigned char *) _alloca(in_length + 1);
|
||||
unsigned char *reduced = (unsigned char *) _alloca(length + 1);
|
||||
#endif
|
||||
error_number = gs1_verify(symbol, local_source, in_length, reduced);
|
||||
if (error_number >= ZINT_ERROR) {
|
||||
error_number = gs1_verify(symbol, local_source, length, reduced);
|
||||
if (error_number) {
|
||||
const char in_2d_comp[] = " in 2D component";
|
||||
if (is_composite(symbol->symbology) && strlen(symbol->errtxt) < 100 - strlen(in_2d_comp)) {
|
||||
strcat(symbol->errtxt, in_2d_comp);
|
||||
}
|
||||
return error_tag(symbol->errtxt, error_number);
|
||||
error_number = error_tag(symbol, error_number, NULL);
|
||||
if (error_number >= ZINT_ERROR) {
|
||||
return error_number;
|
||||
}
|
||||
warn_number = error_number; /* Override any previous warning (errtxt has been overwritten) */
|
||||
}
|
||||
if (error_number && warn_number == 0) {
|
||||
warn_number = error_number;
|
||||
}
|
||||
ustrcpy(local_source, reduced); // Cannot contain nul char
|
||||
in_length = (int) ustrlen(local_source);
|
||||
ustrcpy(local_source, reduced); // Cannot contain NUL char
|
||||
length = (int) ustrlen(local_source);
|
||||
}
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "220: Selected symbology does not support GS1 mode");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "220: Selected symbology does not support GS1 mode");
|
||||
}
|
||||
}
|
||||
|
||||
error_number = extended_or_reduced_charset(symbol, local_source, in_length);
|
||||
error_number = extended_or_reduced_charset(symbol, local_source, length);
|
||||
|
||||
if ((error_number == ZINT_ERROR_INVALID_DATA) && symbol->eci == 0 && supports_eci(symbol->symbology)
|
||||
&& (symbol->input_mode & 0x07) == UNICODE_MODE) {
|
||||
/* Try another ECI mode */
|
||||
symbol->eci = get_best_eci(local_source, in_length);
|
||||
symbol->eci = get_best_eci(local_source, length);
|
||||
if (symbol->eci != 0) {
|
||||
error_number = extended_or_reduced_charset(symbol, local_source, in_length);
|
||||
if (error_number == 0) {
|
||||
error_number = extended_or_reduced_charset(symbol, local_source, length);
|
||||
/* Inclusion of ECI more noteworthy than other warnings, so overwrite (if any) */
|
||||
if (error_number < ZINT_ERROR) {
|
||||
error_number = ZINT_WARN_USES_ECI;
|
||||
if (!(symbol->debug & ZINT_DEBUG_TEST)) {
|
||||
strcpy(symbol->errtxt, "222: Encoded data includes ECI");
|
||||
sprintf(symbol->errtxt, "222: Encoded data includes ECI %d", symbol->eci);
|
||||
}
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) printf("Added ECI %d\n", symbol->eci);
|
||||
}
|
||||
@ -1232,9 +1236,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
}
|
||||
|
||||
if (error_number == 0) {
|
||||
error_number = warn_number;
|
||||
error_number = warn_number; /* Already tagged */
|
||||
} else {
|
||||
error_number = error_tag(symbol, error_number, NULL);
|
||||
}
|
||||
(void) error_tag(symbol->errtxt, error_number);
|
||||
|
||||
if (error_number < ZINT_ERROR) {
|
||||
if (symbol->height < 0.5f) { /* Absolute minimum */
|
||||
@ -1245,8 +1250,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Output a previously encoded symbol to file `symbol->outfile` */
|
||||
int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
|
||||
int error_number;
|
||||
int len;
|
||||
|
||||
if (!symbol) return ZINT_ERROR_INVALID_DATA;
|
||||
|
||||
@ -1257,23 +1264,22 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
|
||||
case 270:
|
||||
break;
|
||||
default:
|
||||
strcpy(symbol->errtxt, "223: Invalid rotation angle");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "223: Invalid rotation angle");
|
||||
break;
|
||||
}
|
||||
|
||||
if (symbol->output_options & BARCODE_DOTTY_MODE) {
|
||||
if (!(is_dotty(symbol->symbology))) {
|
||||
strcpy(symbol->errtxt, "224: Selected symbology cannot be rendered as dots");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "224: Selected symbology cannot be rendered as dots");
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(symbol->outfile) > 3) {
|
||||
len = (int) strlen(symbol->outfile);
|
||||
if (len > 3) {
|
||||
char output[4];
|
||||
output[0] = symbol->outfile[strlen(symbol->outfile) - 3];
|
||||
output[1] = symbol->outfile[strlen(symbol->outfile) - 2];
|
||||
output[2] = symbol->outfile[strlen(symbol->outfile) - 1];
|
||||
output[0] = symbol->outfile[len - 3];
|
||||
output[1] = symbol->outfile[len - 2];
|
||||
output[2] = symbol->outfile[len - 1];
|
||||
output[3] = '\0';
|
||||
to_upper((unsigned char *) output);
|
||||
|
||||
@ -1305,15 +1311,13 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
|
||||
error_number = plot_vector(symbol, rotate_angle, OUT_EMF_FILE);
|
||||
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "225: Unknown output format");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "225: Unknown output format");
|
||||
}
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "226: Unknown output format");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "226: Unknown output format");
|
||||
}
|
||||
|
||||
return error_tag(symbol->errtxt, error_number);
|
||||
return error_tag(symbol, error_number, NULL);
|
||||
}
|
||||
|
||||
int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
|
||||
@ -1328,20 +1332,18 @@ int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
|
||||
case 270:
|
||||
break;
|
||||
default:
|
||||
strcpy(symbol->errtxt, "228: Invalid rotation angle");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "228: Invalid rotation angle");
|
||||
break;
|
||||
}
|
||||
|
||||
if (symbol->output_options & BARCODE_DOTTY_MODE) {
|
||||
if (!(is_dotty(symbol->symbology))) {
|
||||
strcpy(symbol->errtxt, "237: Selected symbology cannot be rendered as dots");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "237: Selected symbology cannot be rendered as dots");
|
||||
}
|
||||
}
|
||||
|
||||
error_number = plot_raster(symbol, rotate_angle, OUT_BUFFER);
|
||||
return error_tag(symbol->errtxt, error_number);
|
||||
return error_tag(symbol, error_number, NULL);
|
||||
}
|
||||
|
||||
int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
|
||||
@ -1356,27 +1358,26 @@ int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
|
||||
case 270:
|
||||
break;
|
||||
default:
|
||||
strcpy(symbol->errtxt, "219: Invalid rotation angle");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "219: Invalid rotation angle");
|
||||
break;
|
||||
}
|
||||
|
||||
if (symbol->output_options & BARCODE_DOTTY_MODE) {
|
||||
if (!(is_dotty(symbol->symbology))) {
|
||||
strcpy(symbol->errtxt, "238: Selected symbology cannot be rendered as dots");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "238: Selected symbology cannot be rendered as dots");
|
||||
}
|
||||
}
|
||||
|
||||
error_number = plot_vector(symbol, rotate_angle, OUT_BUFFER);
|
||||
return error_tag(symbol->errtxt, error_number);
|
||||
return error_tag(symbol, error_number, NULL);
|
||||
}
|
||||
|
||||
int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle) {
|
||||
/* Encode and output a symbol to file `symbol->outfile` */
|
||||
int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *source, int length, int rotate_angle) {
|
||||
int error_number;
|
||||
int first_err;
|
||||
|
||||
error_number = ZBarcode_Encode(symbol, input, length);
|
||||
error_number = ZBarcode_Encode(symbol, source, length);
|
||||
if (error_number >= ZINT_ERROR) {
|
||||
return error_number;
|
||||
}
|
||||
@ -1389,11 +1390,11 @@ int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input,
|
||||
return error_number;
|
||||
}
|
||||
|
||||
int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle) {
|
||||
int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *source, int length, int rotate_angle) {
|
||||
int error_number;
|
||||
int first_err;
|
||||
|
||||
error_number = ZBarcode_Encode(symbol, input, length);
|
||||
error_number = ZBarcode_Encode(symbol, source, length);
|
||||
if (error_number >= ZINT_ERROR) {
|
||||
return error_number;
|
||||
}
|
||||
@ -1407,12 +1408,12 @@ int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input,
|
||||
return error_number;
|
||||
}
|
||||
|
||||
int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char *input, int length,
|
||||
int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char *source, int length,
|
||||
int rotate_angle) {
|
||||
int error_number;
|
||||
int first_err;
|
||||
|
||||
error_number = ZBarcode_Encode(symbol, input, length);
|
||||
error_number = ZBarcode_Encode(symbol, source, length);
|
||||
if (error_number >= ZINT_ERROR) {
|
||||
return error_number;
|
||||
}
|
||||
@ -1426,6 +1427,7 @@ int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Encode a barcode using input data from file `filename` */
|
||||
int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
||||
FILE *file;
|
||||
int file_opened = 0;
|
||||
@ -1438,8 +1440,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
||||
if (!symbol) return ZINT_ERROR_INVALID_DATA;
|
||||
|
||||
if (!filename) {
|
||||
strcpy(symbol->errtxt, "239: Filename NULL");
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "239: Filename NULL");
|
||||
}
|
||||
|
||||
if (!strcmp(filename, "-")) {
|
||||
@ -1449,7 +1450,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
||||
file = fopen(filename, "rb");
|
||||
if (!file) {
|
||||
sprintf(symbol->errtxt, "229: Unable to read input file (%d: %.30s)", errno, strerror(errno));
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
|
||||
}
|
||||
file_opened = 1;
|
||||
|
||||
@ -1460,25 +1461,22 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
||||
|
||||
/* On many Linux distros ftell() returns LONG_MAX not -1 on error */
|
||||
if (fileLen <= 0 || fileLen == LONG_MAX) {
|
||||
strcpy(symbol->errtxt, "235: Input file empty or unseekable");
|
||||
fclose(file);
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "235: Input file empty or unseekable");
|
||||
}
|
||||
if (fileLen > ZINT_MAX_DATA_LEN) {
|
||||
strcpy(symbol->errtxt, "230: Input file too long");
|
||||
fclose(file);
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_TOO_LONG);
|
||||
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "230: Input file too long");
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory */
|
||||
buffer = (unsigned char *) malloc(fileLen);
|
||||
if (!buffer) {
|
||||
strcpy(symbol->errtxt, "231: Internal memory error");
|
||||
if (file_opened) {
|
||||
fclose(file);
|
||||
}
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_MEMORY);
|
||||
return error_tag(symbol, ZINT_ERROR_MEMORY, "231: Insufficient memory for file read buffer");
|
||||
}
|
||||
|
||||
/* Read file contents into buffer */
|
||||
@ -1491,7 +1489,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
||||
fclose(file);
|
||||
}
|
||||
free(buffer);
|
||||
return error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
|
||||
}
|
||||
nRead += n;
|
||||
} while (!feof(file) && (0 < n) && ((long) nRead < fileLen));
|
||||
@ -1504,6 +1502,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Encode a symbol using input data from file `filename` and output to file `symbol->outfile` */
|
||||
int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle) {
|
||||
int error_number;
|
||||
int first_err;
|
||||
@ -1522,6 +1521,7 @@ int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, i
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`) */
|
||||
int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle) {
|
||||
int error_number;
|
||||
int first_err;
|
||||
@ -1540,6 +1540,7 @@ int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename,
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`) */
|
||||
int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, char *filename, int rotate_angle) {
|
||||
int error_number;
|
||||
int first_err;
|
||||
@ -1558,6 +1559,7 @@ int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, char *fil
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Return the version of Zint linked to */
|
||||
int ZBarcode_Version() {
|
||||
if (ZINT_VERSION_BUILD) {
|
||||
return (ZINT_VERSION_MAJOR * 10000) + (ZINT_VERSION_MINOR * 100) + ZINT_VERSION_RELEASE * 10
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "large.h"
|
||||
#include "reedsol.h"
|
||||
|
||||
#define RUBIDIUM "01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||
#define RUBIDIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||
|
||||
// Allowed character values from Table 3
|
||||
#define SET_F "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
@ -148,7 +148,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
int error_number = 0;
|
||||
|
||||
if (length > 26) {
|
||||
strcpy(symbol->errtxt, "580: Input too long");
|
||||
strcpy(symbol->errtxt, "580: Input too long (26 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -175,28 +175,28 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
}
|
||||
|
||||
if (is_sane(RUBIDIUM, (unsigned char *) local_source, length) != 0) {
|
||||
strcpy(symbol->errtxt, "581: Invalid characters in input data");
|
||||
strcpy(symbol->errtxt, "581: Invalid character in data (alphanumerics and space only)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
// Format is in the range 0-4
|
||||
format = ctoi(local_source[0]);
|
||||
if ((format < 0) || (format > 4)) {
|
||||
strcpy(symbol->errtxt, "582: Invalid format");
|
||||
strcpy(symbol->errtxt, "582: Format out of range (0 to 4)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
// Version ID is in the range 1-4
|
||||
version_id = ctoi(local_source[1]) - 1;
|
||||
if ((version_id < 0) || (version_id > 3)) {
|
||||
strcpy(symbol->errtxt, "583: Invalid Version ID");
|
||||
strcpy(symbol->errtxt, "583: Version ID out of range (1 to 4)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
// Class is in the range 0-9,A-E
|
||||
mail_class = ctoi(local_source[2]);
|
||||
if ((mail_class < 0) || (mail_class > 14)) {
|
||||
strcpy(symbol->errtxt, "584: Invalid Class");
|
||||
strcpy(symbol->errtxt, "584: Class out of range (0 to 9 and A to E)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
supply_chain_id *= 10;
|
||||
supply_chain_id += ctoi(local_source[i]);
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "585: Invalid Supply Chain ID");
|
||||
strcpy(symbol->errtxt, "585: Invalid Supply Chain ID (digits only)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
@ -219,7 +219,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
item_id *= 10;
|
||||
item_id += ctoi(local_source[i]);
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "586: Invalid Item ID");
|
||||
strcpy(symbol->errtxt, "586: Invalid Item ID (digits only)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ INTERNAL int maxicode(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
for (i = 0; i < 6; i++) {
|
||||
/* Don't allow Code Set A control characters CR, RS, GS and RS */
|
||||
if (postcode[i] < ' ' || maxiCodeSet[postcode[i]] > 1) {
|
||||
strcpy(symbol->errtxt, "556: Invalid characters in postcode in Primary Message");
|
||||
strcpy(symbol->errtxt, "556: Invalid character in postcode in Primary Message");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "351: Invalid characters in data (digits only)");
|
||||
strcpy(symbol->errtxt, "351: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "355: Invalid characters in data (digits only)");
|
||||
strcpy(symbol->errtxt, "355: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
error_number = pharma_two_calc(symbol, source, height_pattern);
|
||||
@ -249,7 +249,7 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
if (is_sane(CALCIUM, source + 1, length - 2) == 0) {
|
||||
strcpy(symbol->errtxt, "363: Cannot contain \"A\", \"B\", \"C\" or \"D\"");
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "357: Invalid characters in data");
|
||||
sprintf(symbol->errtxt, "357: Invalid character in data (\"%s\" only)", CALCIUM);
|
||||
}
|
||||
return error_number;
|
||||
}
|
||||
@ -314,7 +314,7 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "361: Invalid characters in data (digits only)");
|
||||
strcpy(symbol->errtxt, "361: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
|
@ -58,12 +58,12 @@ INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
int error_number;
|
||||
|
||||
if (length > 65) {
|
||||
strcpy(symbol->errtxt, "370: Input too long");
|
||||
strcpy(symbol->errtxt, "370: Input too long (65 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(SSET, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "371: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "371: Invalid character in data (digits and \"ABCDEF\" only)");
|
||||
return error_number;
|
||||
}
|
||||
if (!(checkptr = (unsigned char *) calloc(1, length * 4 + 8))) {
|
||||
@ -301,12 +301,12 @@ INTERNAL int msi_handle(struct zint_symbol *symbol, unsigned char source[], int
|
||||
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number != 0) {
|
||||
strcpy(symbol->errtxt, "377: Invalid characters in input data");
|
||||
strcpy(symbol->errtxt, "377: Invalid character in data (digits only)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (length > 65) {
|
||||
strcpy(symbol->errtxt, "372: Input too long");
|
||||
strcpy(symbol->errtxt, "372: Input too long (65 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
|
@ -130,12 +130,12 @@ static int postnet(struct zint_symbol *symbol, unsigned char source[], char dest
|
||||
int error_number;
|
||||
|
||||
if (length != 5 && length != 9 && length != 11) {
|
||||
strcpy(symbol->errtxt, "480: Input wrong length");
|
||||
strcpy(symbol->errtxt, "480: Input wrong length (5, 9 or 11 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "481: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "481: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
sum = 0;
|
||||
@ -191,12 +191,12 @@ static int planet(struct zint_symbol *symbol, unsigned char source[], char dest[
|
||||
int error_number;
|
||||
|
||||
if (length != 11 && length != 13) {
|
||||
strcpy(symbol->errtxt, "482: Input wrong length");
|
||||
strcpy(symbol->errtxt, "482: Input wrong length (11 or 13 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "483: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "483: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
sum = 0;
|
||||
@ -252,12 +252,12 @@ INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int
|
||||
char localstr[8], dest[80];
|
||||
|
||||
if (length > 6) {
|
||||
strcpy(symbol->errtxt, "484: Input too long");
|
||||
strcpy(symbol->errtxt, "484: Input too long (6 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "485: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "485: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
zeroes = 6 - length;
|
||||
@ -294,7 +294,7 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
char dest[16] = {0};
|
||||
|
||||
if (length > 1) {
|
||||
strcpy(symbol->errtxt, "486: Input too long");
|
||||
strcpy(symbol->errtxt, "486: Input too long (1 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
strcpy(dest, "1111131311111");
|
||||
break;
|
||||
default:
|
||||
strcpy(symbol->errtxt, "487: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "487: Invalid character in data (\"A\", \"B\", \"C\" or \"D\" only)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
break;
|
||||
}
|
||||
@ -416,13 +416,13 @@ INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int
|
||||
strcpy(height_pattern, "");
|
||||
|
||||
if (length > 50) {
|
||||
strcpy(symbol->errtxt, "488: Input too long");
|
||||
strcpy(symbol->errtxt, "488: Input too long (50 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
to_upper(source);
|
||||
error_number = is_sane(KRSET, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "489: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "489: Invalid character in data (alphanumerics only)");
|
||||
return error_number;
|
||||
}
|
||||
/*check = */rm4scc(source, height_pattern, length);
|
||||
@ -472,13 +472,13 @@ INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
strcpy(height_pattern, "");
|
||||
|
||||
if (length > 18) {
|
||||
strcpy(symbol->errtxt, "490: Input too long");
|
||||
strcpy(symbol->errtxt, "490: Input too long (18 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
to_upper(source);
|
||||
error_number = is_sane(KRSET, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "491: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "491: Invalid character in data (alphanumerics only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -527,14 +527,14 @@ INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int l
|
||||
strcpy(height_pattern, "");
|
||||
|
||||
if (length > 50) {
|
||||
strcpy(symbol->errtxt, "492: Input too long");
|
||||
strcpy(symbol->errtxt, "492: Input too long (50 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
to_upper((unsigned char*) source);
|
||||
error_number = is_sane(DAFTSET, (unsigned char*) source, length);
|
||||
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "493: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "493: Invalid character in data (\"D\", \"A\", \"F\" and \"T\" only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -593,12 +593,12 @@ INTERNAL int flattermarken(struct zint_symbol *symbol, unsigned char source[], i
|
||||
char dest[512]; /* 90 * 4 + 1 ~ */
|
||||
|
||||
if (length > 90) {
|
||||
strcpy(symbol->errtxt, "494: Input too long");
|
||||
strcpy(symbol->errtxt, "494: Input too long (90 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "495: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "495: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
*dest = '\0';
|
||||
@ -628,7 +628,7 @@ INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int
|
||||
#endif
|
||||
|
||||
if (length > 20) {
|
||||
strcpy(symbol->errtxt, "496: Input too long");
|
||||
strcpy(symbol->errtxt, "496: Input too long (20 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -636,7 +636,7 @@ INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int
|
||||
to_upper((unsigned char*) local_source);
|
||||
|
||||
if (is_sane(SHKASUTSET, (unsigned char*) local_source, length) == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "497: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "497: Invalid character in data (alphanumerics and \"-\" only)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
memset(inter, 'd', 20); /* Pad character CC4 */
|
||||
|
@ -1562,7 +1562,7 @@ INTERNAL int qr_code(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
if (error_number == 0) {
|
||||
done = 1;
|
||||
} else if (symbol->eci) {
|
||||
strcpy(symbol->errtxt, "575: Invalid characters in input data");
|
||||
sprintf(symbol->errtxt, "575: Invalid character in input data for ECI %d", symbol->eci);
|
||||
return error_number;
|
||||
}
|
||||
}
|
||||
@ -2707,7 +2707,7 @@ INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
case UNICODE_MODE:
|
||||
error_number = utf8_to_eci(4, source, preprocessed, &length);
|
||||
if (error_number != 0) {
|
||||
strcpy(symbol->errtxt, "572: Invalid characters in input data");
|
||||
strcpy(symbol->errtxt, "572: Invalid character in input data for ECI 4");
|
||||
return error_number;
|
||||
}
|
||||
for (i = 0; i < length; i++) {
|
||||
|
@ -177,7 +177,7 @@ static int save_raster_image_to_file(struct zint_symbol *symbol, const int image
|
||||
if (rotate_angle) {
|
||||
if (!(rotated_pixbuf = (unsigned char *) malloc((size_t) image_width * image_height))) {
|
||||
strcpy(symbol->errtxt, "650: Insufficient memory for pixel buffer");
|
||||
return ZINT_ERROR_ENCODING_PROBLEM;
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
@ -693,14 +693,14 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, const int rotate_ang
|
||||
|
||||
if (!(pixelbuf = (unsigned char *) malloc((size_t) image_width * image_height))) {
|
||||
strcpy(symbol->errtxt, "655: Insufficient memory for pixel buffer");
|
||||
return ZINT_ERROR_ENCODING_PROBLEM;
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
memset(pixelbuf, DEFAULT_PAPER, (size_t) image_width * image_height);
|
||||
|
||||
if (!(scaled_hexagon = (unsigned char *) malloc((size_t) hex_width * hex_height))) {
|
||||
strcpy(symbol->errtxt, "656: Insufficient memory for pixel buffer");
|
||||
free(pixelbuf);
|
||||
return ZINT_ERROR_ENCODING_PROBLEM;
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
memset(scaled_hexagon, DEFAULT_PAPER, (size_t) hex_width * hex_height);
|
||||
|
||||
@ -829,7 +829,7 @@ static int plot_raster_dotty(struct zint_symbol *symbol, const int rotate_angle,
|
||||
/* Apply scale options by creating another pixel buffer */
|
||||
if (!(scaled_pixelbuf = (unsigned char *) malloc((size_t) scale_width * scale_height))) {
|
||||
strcpy(symbol->errtxt, "657: Insufficient memory for pixel buffer");
|
||||
return ZINT_ERROR_ENCODING_PROBLEM;
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
memset(scaled_pixelbuf, DEFAULT_PAPER, (size_t) scale_width * scale_height);
|
||||
|
||||
@ -987,7 +987,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
|
||||
if (!(pixelbuf = (unsigned char *) malloc((size_t) image_width * image_height))) {
|
||||
strcpy(symbol->errtxt, "658: Insufficient memory for pixel buffer");
|
||||
return ZINT_ERROR_ENCODING_PROBLEM;
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
memset(pixelbuf, DEFAULT_PAPER, (size_t) image_width * image_height);
|
||||
|
||||
@ -1326,7 +1326,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
if (!(scaled_pixelbuf = (unsigned char *) malloc((size_t) scale_width * scale_height))) {
|
||||
free(pixelbuf);
|
||||
strcpy(symbol->errtxt, "659: Insufficient memory for pixel buffer");
|
||||
return ZINT_ERROR_ENCODING_PROBLEM;
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
memset(scaled_pixelbuf, DEFAULT_PAPER, (size_t) scale_width * scale_height);
|
||||
|
||||
|
@ -308,7 +308,7 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
|
||||
}
|
||||
error_number = is_sane(NEON, source, src_len);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "381: Invalid characters in data (digits only)");
|
||||
strcpy(symbol->errtxt, "381: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -646,7 +646,7 @@ INTERNAL int rsslimited_cc(struct zint_symbol *symbol, unsigned char source[], i
|
||||
}
|
||||
error_number = is_sane(NEON, source, src_len);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "383: Invalid characters in data (digits only)");
|
||||
strcpy(symbol->errtxt, "383: Invalid character in data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -975,7 +975,7 @@ static int rssexp_binary_string(struct zint_symbol *symbol, const unsigned char
|
||||
if ((source[i] < '0') || (source[i] > '9')) {
|
||||
if (source[i] != '[') {
|
||||
/* Something is wrong */
|
||||
strcpy(symbol->errtxt, "385: Invalid characters in input data"); // TODO: Better error message
|
||||
strcpy(symbol->errtxt, "385: Invalid character in input data"); // TODO: Better error message
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
@ -1075,8 +1075,8 @@ static int rssexp_binary_string(struct zint_symbol *symbol, const unsigned char
|
||||
if (j != 0) { /* If general field not empty */
|
||||
|
||||
if (!general_field_encode(general_field, j, &mode, &last_digit, binary_string, &bp)) {
|
||||
/* Invalid characters in input data */
|
||||
strcpy(symbol->errtxt, "386: Invalid characters in input data"); // TODO: Better error message
|
||||
/* Invalid character in input data */
|
||||
strcpy(symbol->errtxt, "386: Invalid character in input data"); // TODO: Better error message
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
count = 0;
|
||||
|
||||
if (src_len > 30) {
|
||||
strcpy(symbol->errtxt, "390: Input too long");
|
||||
strcpy(symbol->errtxt, "390: Input too long (30 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
/* Start character */
|
||||
@ -77,7 +77,7 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
for (i = 0; i < src_len; i++) {
|
||||
if (source[i] > 127) {
|
||||
/* Cannot encode extended ASCII */
|
||||
strcpy(symbol->errtxt, "391: Invalid characters in input data");
|
||||
strcpy(symbol->errtxt, "391: Invalid character in input data, extended ASCII not allowed");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
strcat(dest, TeleTable[source[i]]);
|
||||
@ -124,14 +124,14 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int
|
||||
count = 0;
|
||||
|
||||
if (src_len > 60) {
|
||||
strcpy(symbol->errtxt, "392: Input too long");
|
||||
strcpy(symbol->errtxt, "392: Input too long (60 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
ustrcpy(temp, source);
|
||||
to_upper(temp);
|
||||
error_number = is_sane(SODIUM, temp, src_len);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "393: Invalid characters in data");
|
||||
strcpy(symbol->errtxt, "393: Invalid character in data (digits and \"X\" only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
|
@ -140,27 +140,31 @@ static void test_input(int index, int debug) {
|
||||
int ret;
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
char *expected_errtxt;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_AUSPOST, "12345678", 0, 3, 73 },
|
||||
/* 1*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 2*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103 },
|
||||
/* 3*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 4*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103 },
|
||||
/* 5*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103 },
|
||||
/* 6*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 7*/ { BARCODE_AUSPOST, "12345678ABCDefgh #", 0, 3, 133 }, // Length 18
|
||||
/* 8*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133 },
|
||||
/* 9*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 10*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73 },
|
||||
/* 11*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73 }, // Leading zeroes added
|
||||
/* 12*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73 },
|
||||
/* 13*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73 },
|
||||
/* 14*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73 },
|
||||
/* 15*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73 },
|
||||
/* 16*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73 },
|
||||
/* 17*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1 }, // No leading zeroes added
|
||||
/* 0*/ { BARCODE_AUSPOST, "12345678", 0, 3, 73, "" },
|
||||
/* 1*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character in DPID (first 8 characters) (digits only)" },
|
||||
/* 2*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" },
|
||||
/* 3*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character in data (alphanumerics, space and \"#\" only)" },
|
||||
/* 4*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" },
|
||||
/* 5*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103, "" },
|
||||
/* 6*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character in data (digits only for lengths 16 and 23)" },
|
||||
/* 7*/ { BARCODE_AUSPOST, "12345678ABCDefgh #", 0, 3, 133, "" }, // Length 18
|
||||
/* 8*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133, "" },
|
||||
/* 9*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character in data (digits only for lengths 16 and 23)" },
|
||||
/* 10*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Auspost input is wrong length (8, 13, 16, 18 or 23 characters only)" }, // No leading zeroes added
|
||||
/* 11*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "" },
|
||||
/* 12*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73, "" }, // Leading zeroes added
|
||||
/* 13*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Auspost input is too long (8 character maximum)" },
|
||||
/* 14*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73, "" },
|
||||
/* 15*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73, "" },
|
||||
/* 16*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Auspost input is too long (8 character maximum)" },
|
||||
/* 17*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73, "" },
|
||||
/* 18*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73, "" },
|
||||
/* 19*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73, "" },
|
||||
/* 20*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Auspost input is too long (8 character maximum)" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@ -184,6 +188,7 @@ static void test_input(int index, int debug) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ static void test_large(int index, int debug) {
|
||||
/* 19*/ { BARCODE_VIN, -1, "1", 18, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 20*/ { BARCODE_VIN, -1, "1", 16, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 21*/ { BARCODE_VIN, 1, "1", 17, 0, 1, 259 },
|
||||
/* 22*/ { BARCODE_HIBC_39, -1, "1", 66, 0, 1, 1119 }, // 68 - 2 ('+' and check digit)
|
||||
/* 23*/ { BARCODE_HIBC_39, -1, "1", 67, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 22*/ { BARCODE_HIBC_39, -1, "1", 67, 0, 1, 1135 }, // 69 - 2 ('+' and check digit)
|
||||
/* 23*/ { BARCODE_HIBC_39, -1, "1", 68, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -138,7 +138,7 @@ static void test_hrt_cpy_iso8859_1(int index, int debug) {
|
||||
|
||||
testStart("test_hrt_cpy_iso8859_1");
|
||||
|
||||
symbol.debug |= debug;
|
||||
symbol.debug = debug;
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int j;
|
||||
@ -264,8 +264,8 @@ static void test_reader_init(int index, int generate, int debug) {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -294,7 +294,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
// ß U+00DF (\337, 223), UTF-8 C39F, CodeA and CodeB extended ASCII
|
||||
// é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
|
||||
struct item data[] = {
|
||||
/* 0*/ { UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA, 0, "Error 204: Invalid characters in input data", "PAD not in ISO 8859-1" },
|
||||
/* 0*/ { UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA, 0, "Error 204: Invalid character in input data (ISO/IEC 8859-1 only)", "PAD not in ISO 8859-1" },
|
||||
/* 1*/ { DATA_MODE, "\200", -1, 0, 57, "(5) 103 101 64 23 106", "PAD ok using binary" },
|
||||
/* 2*/ { UNICODE_MODE, "AIM1234", -1, 0, 101, "(9) 104 33 41 45 99 12 34 87 106", "Example from Annex A.1, check char value 87" },
|
||||
/* 3*/ { GS1_MODE, "[90]12", -1, ZINT_ERROR_INVALID_OPTION, 0, "Error 220: Selected symbology does not support GS1 mode", "" },
|
||||
@ -358,8 +358,8 @@ static void test_input(int index, int generate, int debug) {
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -432,8 +432,8 @@ static void test_ean128_input(int index, int generate, int debug) {
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -452,7 +452,7 @@ static void test_hibc_input(int index, int generate, int debug) {
|
||||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, "", "" },
|
||||
/* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, "Error 203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)", "" },
|
||||
/* 1*/ { "A99912345/$$52001510X3", 0, 255, "(23) 104 11 33 99 99 91 23 45 100 15 4 4 99 52 0 15 10 100 56 19 19 53 106", "Check digit 3" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
@ -484,8 +484,64 @@ static void test_hibc_input(int index, int generate, int debug) {
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_dpd_input(int index, int generate, int debug) {
|
||||
|
||||
struct item {
|
||||
char *data;
|
||||
int ret;
|
||||
int expected_width;
|
||||
char *expected;
|
||||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { "123456789012345678901234567", ZINT_ERROR_TOO_LONG, -1, "Error 349: DPD input wrong length (28 characters required)", "" },
|
||||
/* 1*/ { "12345678901234567890123456789", ZINT_ERROR_TOO_LONG, -1, "Error 349: DPD input wrong length (28 characters required)", "" },
|
||||
/* 2*/ { "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, "Error 300: Invalid character in DPD data (alphanumerics only)", "Alphanumerics only in body" },
|
||||
/* 3*/ { ",234567890123456789012345678", 0, 211, "(19) 104 12 18 99 34 56 78 90 12 34 56 78 90 12 34 56 78 64 106", "Non-alphanumeric DPD Identifier (Barcode ID) allowed" },
|
||||
/* 4*/ { "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, "Error 301: Invalid DPD identifier (first character), ASCII values 32 to 127 only", "Control char <US> as DPD Identifier" },
|
||||
/* 5*/ { "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, "Error 301: Invalid DPD identifier (first character), ASCII values 32 to 127 only", "Extended ASCII as DPD Identifier" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol;
|
||||
|
||||
char escaped[1024];
|
||||
|
||||
testStart("test_dpd_input");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_DPD, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (generate) {
|
||||
printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n",
|
||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -631,8 +687,8 @@ static void test_encode(int index, int generate, int debug) {
|
||||
/* 39*/ { BARCODE_DPD, UNICODE_MODE, "%000393206219912345678101040", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustrations 2, 7, 8, same; NOTE: correct HRT given by Illustration 7 only",
|
||||
"1101001000010001001100100111011001011101111011011001100110100010001100011011010011001000110111001001011101111010110011100100010110001110001011011000010100110010001001100100010011000101000101011110001100011101011"
|
||||
},
|
||||
/* 40*/ { BARCODE_DPD, UNICODE_MODE, "%000393206219912345678101040", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustration 6 **NOT SAME** HRT incorrect, also uses CodeA and inefficient encoding; verified against tec-it",
|
||||
"1101001000010001001100100111011001011101111011011001100110100010001100011011010011001000110111001001011101111010110011100100010110001110001011011000010100110010001001100100010011000101000101011110001100011101011"
|
||||
/* 40*/ { BARCODE_DPD, UNICODE_MODE, "%007110601782532948375101276", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustration 6 **NOT SAME** HRT incorrect, also uses CodeA and inefficient encoding; verified against tec-it",
|
||||
"1101001000010001001100100111011001011101111010011000100110001001001001100100011001101100110000101001110010110011000110110100010111101011110010011000010010110010001001011001110011001010000100010111101100011101011"
|
||||
},
|
||||
/* 41*/ { BARCODE_DPD, UNICODE_MODE, "0123456789012345678901234567", 0, 1, 189, 1, "DPDAPPD 4.0.2 - Illustration 9, same (allowing for literal HRT)",
|
||||
"110100111001100110110011101101110101110110001000010110011011011110110011011001110110111010111011000100001011001101101111011001101100111011011101011101100010000101100101011110001100011101011"
|
||||
@ -709,6 +765,7 @@ int main(int argc, char *argv[]) {
|
||||
{ "test_input", test_input, 1, 1, 1 },
|
||||
{ "test_ean128_input", test_ean128_input, 1, 1, 1 },
|
||||
{ "test_hibc_input", test_hibc_input, 1, 1, 1 },
|
||||
{ "test_dpd_input", test_dpd_input, 1, 1, 1 },
|
||||
{ "test_encode", test_encode, 1, 1, 1 },
|
||||
};
|
||||
|
||||
|
@ -96,7 +96,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
// NUL U+0000, S1 SP (39)
|
||||
// US U+001F (\037, 31), S1 5
|
||||
struct item data[] = {
|
||||
/* 0*/ { UNICODE_MODE, "é", -1, ZINT_ERROR_INVALID_DATA, 0, 0, "Error 431: Invalid characters in input data", "ASCII only" },
|
||||
/* 0*/ { UNICODE_MODE, "é", -1, ZINT_ERROR_INVALID_DATA, 0, 0, "Error 431: Invalid character in input data", "ASCII only" },
|
||||
/* 1*/ { UNICODE_MODE, "EXAMPLE 2", -1, 0, 2, 70, "(16) 14 33 10 22 25 21 14 41 38 2 35 14 18 13 0 22", "2.3.7 Symbol Example" },
|
||||
/* 2*/ { UNICODE_MODE, "12345", -1, 0, 2, 70, "(16) 5 17 9 48 48 48 48 27 48 48 13 23 0 13 2 0", "2.3 Example 1: Numeric Encodation (Start 2, Numeric)" },
|
||||
/* 3*/ { UNICODE_MODE, "123456", -1, 0, 2, 70, "(16) 5 17 9 6 48 48 48 34 48 48 36 9 23 41 2 11", "2.3 Example 1: Numeric Encodation" },
|
||||
|
@ -58,7 +58,7 @@ static void test_utf8_to_unicode(int index, int debug) {
|
||||
|
||||
testStart("test_utf8_to_unicode");
|
||||
|
||||
symbol.debug |= debug;
|
||||
symbol.debug = debug;
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int ret_length;
|
||||
@ -136,11 +136,11 @@ static void test_debug_test_codeword_dump_int(int index, int debug) {
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i;
|
||||
|
||||
struct zint_symbol symbol;
|
||||
struct zint_symbol symbol = {0};
|
||||
|
||||
testStart("test_debug_test_codeword_dump_int");
|
||||
|
||||
symbol.debug |= debug;
|
||||
symbol.debug = debug;
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
|
@ -523,8 +523,8 @@ static void test_reader_init(int index, int generate, int debug) {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -680,8 +680,10 @@ static void test_input(int index, int generate, int debug) {
|
||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) {
|
||||
if (!data[i].bwipp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
|
@ -164,7 +164,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 20*/ { UNICODE_MODE, -1, "[)>\03606A\004", -1, 0, "6A 64 10 16 21", "[)>RS 06 A EOT; LatchB (0x6A) Macro100 (0x64) 0 6 A" },
|
||||
/* 21*/ { UNICODE_MODE, -1, "[)>\036991\036\004", -1, 0, "6A 64 19 19 11 64", "[)>RS 99 1 RS EOT; LatchB (0x6A) Macro100 (0x64) 9 9 1 RS" },
|
||||
/* 22*/ { UNICODE_MODE, -1, "1712345610", -1, 0, "6B 64 0C 22 38", "FNC1 (0x6B) 17..10 12 34 56" },
|
||||
/* 23*/ { GS1_MODE, -1, "[17]123456[10]123", -1, ZINT_WARN_NONCOMPLIANT, "Warning 64 0C 22 38 0C 66 13", "17..10 12 34 56 12 ShiftB (0x66) 3" },
|
||||
/* 23*/ { GS1_MODE, -1, "[17]123456[10]123", -1, ZINT_WARN_NONCOMPLIANT, "64 0C 22 38 0C 66 13", "17..10 12 34 56 12 ShiftB (0x66) 3" },
|
||||
/* 24*/ { GS1_MODE, -1, "[90]ABC[90]abc[90]123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17", "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23" },
|
||||
/* 25*/ { GS1_MODE | GS1PARENS_MODE, -1, "(90)ABC(90)abc(90)123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17", "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23" },
|
||||
/* 26*/ { UNICODE_MODE, -1, "99aA[{00\000", 9, 0, "6B 63 6A 41 21 3B 5B 10 10 65 40", "FNC1 (0x6B) 99 LatchB (0x6A) a A [ { 0 0 ShiftA (0x65) NUL" },
|
||||
|
@ -125,7 +125,7 @@ static void test_gb2312_utf8(int index) {
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
||||
struct zint_symbol symbol;
|
||||
struct zint_symbol symbol = {0};
|
||||
unsigned int gbdata[20];
|
||||
|
||||
testStart("test_gb2312_utf8");
|
||||
|
@ -34,6 +34,7 @@
|
||||
static void test_large(int index, int debug) {
|
||||
|
||||
struct item {
|
||||
int option_2;
|
||||
char *pattern;
|
||||
int length;
|
||||
int ret;
|
||||
@ -42,12 +43,18 @@ static void test_large(int index, int debug) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { "1", 2751, 0, 162, 162 },
|
||||
/* 1*/ { "1", 2752, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 1*/ { "A", 1836, 0, 162, 162 },
|
||||
/* 2*/ { "A", 1837, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 3*/ { "\200", 1143, 0, 162, 162 },
|
||||
/* 4*/ { "\200", 1144, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 0*/ { -1, "1", 2751, 0, 162, 162 },
|
||||
/* 1*/ { -1, "1", 2752, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { -1, "A", 1836, 0, 162, 162 },
|
||||
/* 3*/ { -1, "A", 1837, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 4*/ { -1, "\200", 1143, 0, 162, 162 },
|
||||
/* 5*/ { -1, "\200", 1144, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 6*/ { 1, "1", 18, 0, 18, 18 },
|
||||
/* 7*/ { 1, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 8*/ { 1, "A", 13, 0, 18, 18 },
|
||||
/* 9*/ { 1, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 10*/ { 1, "\200", 7, 0, 18, 18 },
|
||||
/* 11*/ { 1, "\200", 8, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@ -67,7 +74,7 @@ static void test_large(int index, int debug) {
|
||||
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
|
||||
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@ -245,6 +252,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 85*/ { UNICODE_MODE, 170, -1, "?", 0, 170, "60 55 0F 77 26 60", "ECI-170 L1 (ASCII invariant)" },
|
||||
/* 86*/ { DATA_MODE, 899, -1, "\200", 0, 899, "63 41 58 00 40 00", "ECI-899 B1 (8-bit binary)" },
|
||||
/* 87*/ { UNICODE_MODE, 900, -1, "é", 0, 900, "63 42 18 01 61 6A 20", "ECI-900 B2 (no conversion)" },
|
||||
/* 88*/ { UNICODE_MODE, 3, -1, "β", ZINT_ERROR_INVALID_DATA, 3, "Error 535: Invalid character in input data for ECI 3", "" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@ -275,10 +283,9 @@ static void test_input(int index, int generate, int debug) {
|
||||
testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
|
||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
@ -1527,7 +1527,7 @@ static void test_gs1_lint(int index, int debug) {
|
||||
/*174*/ { "[4300]%1", ZINT_WARN_NONCOMPLIANT, "4300%1", "261: AI (4300) position 1: Invalid % escape" }, // pcenc
|
||||
/*175*/ { "[4300]%", ZINT_WARN_NONCOMPLIANT, "4300%", "261: AI (4300) position 1: Invalid % escape" }, // pcenc
|
||||
/*176*/ { "[4300]12%1212", 0, "430012%1212", "" }, // pcenc
|
||||
/*177*/ { "[4300]12%1G12", ZINT_WARN_NONCOMPLIANT, "430012%1G12", "261: AI (4300) position 5: Invalid characters for percent encoding" }, // pcenc
|
||||
/*177*/ { "[4300]12%1G12", ZINT_WARN_NONCOMPLIANT, "430012%1G12", "261: AI (4300) position 5: Invalid character for percent encoding" }, // pcenc
|
||||
/*178*/ { "[4308]ABCDEFGHIJKLMNOPQRSTUVWXYZ%+12", 0, "4308ABCDEFGHIJKLMNOPQRSTUVWXYZ%+12", "" }, // no pcenc
|
||||
/*179*/ { "[4308]ABCDEFGHIJKLMNOPQRSTUVWXYZ%+123", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (4308)" }, // no pcenc
|
||||
/*180*/ { "[4321]1", 0, "43211", "" }, // yesno
|
||||
|
@ -34,6 +34,8 @@
|
||||
static void test_large(int index, int debug) {
|
||||
|
||||
struct item {
|
||||
int option_1;
|
||||
int option_2;
|
||||
char *pattern;
|
||||
int length;
|
||||
int ret;
|
||||
@ -42,12 +44,24 @@ static void test_large(int index, int debug) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { "1", 7827, 0, 189, 189 },
|
||||
/* 1*/ { "1", 7828, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 1*/ { "A", 4349, 0, 189, 189 }, // TODO: should be 4350 according to spec, investigate
|
||||
/* 2*/ { "A", 4351, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 3*/ { "\200", 3260, 0, 189, 189 }, // TODO: should be 3261 according to spec, investigate
|
||||
/* 4*/ { "\200", 3262, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 0*/ { -1, -1, "1", 7827, 0, 189, 189 },
|
||||
/* 1*/ { -1, -1, "1", 7828, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { -1, -1, "A", 4349, 0, 189, 189 }, // TODO: should be 4350 according to spec, investigate
|
||||
/* 3*/ { -1, -1, "A", 4350, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 4*/ { -1, -1, "\200", 3260, 0, 189, 189 }, // TODO: should be 3261 according to spec, investigate
|
||||
/* 5*/ { -1, -1, "\200", 3261, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 6*/ { -1, 1, "1", 42, 0, 23, 23 },
|
||||
/* 7*/ { -1, 1, "1", 43, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 8*/ { -1, 1, "A", 25, 0, 23, 23 },
|
||||
/* 9*/ { -1, 1, "A", 26, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 10*/ { -1, 1, "\200", 17, 0, 23, 23 },
|
||||
/* 11*/ { -1, 1, "\200", 18, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 12*/ { 2, 1, "A", 19, 0, 23, 23 },
|
||||
/* 13*/ { 2, 1, "A", 20, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 14*/ { 3, 1, "A", 14, 0, 23, 23 },
|
||||
/* 15*/ { 3, 1, "A", 15, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 16*/ { 4, 1, "A", 9, 0, 23, 23 },
|
||||
/* 17*/ { 4, 1, "A", 10, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@ -67,7 +81,7 @@ static void test_large(int index, int debug) {
|
||||
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
|
||||
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_HANXIN, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, BARCODE_HANXIN, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@ -241,6 +255,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 76*/ { UNICODE_MODE, 170, -1, "?", -1, 0, 170, "88 0A A2 FB 1F C0 00 00 00", "ECI-170 L1 (ASCII invariant)" },
|
||||
/* 77*/ { DATA_MODE, 899, -1, "\200", -1, 0, 899, "88 38 33 00 0C 00 00 00 00", "ECI-899 B1 (8-bit binary)" },
|
||||
/* 78*/ { UNICODE_MODE, 900, -1, "é", -1, 0, 900, "88 38 43 00 16 1D 48 00 00", "ECI-900 B2 (no conversion)" },
|
||||
/* 79*/ { UNICODE_MODE, 3, -1, "β", -1, ZINT_ERROR_INVALID_DATA, 3, "Error 545: Invalid character in input data for ECI 3", "" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@ -272,8 +287,8 @@ static void test_input(int index, int generate, int debug) {
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
@ -38,6 +38,7 @@ static void test_checks(int index, int debug) {
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
int option_1;
|
||||
char *data;
|
||||
int length;
|
||||
int input_mode;
|
||||
@ -51,49 +52,146 @@ static void test_checks(int index, int debug) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, "1234", -1, -1, 3, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", -1 },
|
||||
/* 1*/ { BARCODE_CODE128, "1234", -1, -1, 0, -1, -1, 0, "", -1 },
|
||||
/* 2*/ { BARCODE_QRCODE, "1234", -1, -1, 3, -1, -1, 0, "", -1 },
|
||||
/* 3*/ { BARCODE_QRCODE, "1234", -1, -1, 999999 + 1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: Invalid ECI mode", -1 },
|
||||
/* 4*/ { BARCODE_CODE128, "1234", -1, -1, -1, 20.1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Invalid dot size", -1 },
|
||||
/* 5*/ { BARCODE_CODE128, "1234", -1, GS1_MODE, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 220: Selected symbology does not support GS1 mode", -1 },
|
||||
/* 6*/ { BARCODE_GS1_128, "[21]12\0004", 8, GS1_MODE, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 262: NUL characters not permitted in GS1 mode", -1 },
|
||||
/* 7*/ { BARCODE_GS1_128, "[21]12é4", -1, GS1_MODE, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1", -1 },
|
||||
/* 8*/ { BARCODE_GS1_128, "[21]12\0074", -1, GS1_MODE, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 251: Control characters are not supported by GS1", -1 },
|
||||
/* 9*/ { BARCODE_GS1_128, "[21]1234", -1, GS1_MODE, -1, -1, -1, 0, "", -1 },
|
||||
/* 10*/ { 0, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 11*/ { 0, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
|
||||
/* 12*/ { 0, "1", -1, -1, 1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", BARCODE_CODE128 }, // Not supporting beats invalid ECI
|
||||
/* 13*/ { 0, "1", -1, -1, 1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
|
||||
/* 14*/ { 0, "1", -1, -1, -1, 0.009, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Invalid dot size", BARCODE_CODE128 },
|
||||
/* 15*/ { 0, "1", -1, -1, -1, 0.009, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
|
||||
/* 16*/ { 0, "1", -1, -1, 1, 0.009, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", BARCODE_CODE128 }, // Invalid dot size no longer beats invalid ECI
|
||||
/* 17*/ { 0, "1", -1, -1, -1, 0.009, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
|
||||
/* 18*/ { 5, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_C25STANDARD },
|
||||
/* 19*/ { 5, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_C25STANDARD },
|
||||
/* 20*/ { 12, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_EANX },
|
||||
/* 21*/ { 12, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_EANX },
|
||||
/* 22*/ { 19, "1", -1, -1, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 362: Input too short (3 character minimum)", BARCODE_CODABAR },
|
||||
/* 23*/ { 19, "A1B", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 207: Codabar 18 not supported", BARCODE_CODABAR },
|
||||
/* 24*/ { 19, "A1B", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 207: Codabar 18 not supported", -1 },
|
||||
/* 25*/ { 26, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_UPCA },
|
||||
/* 26*/ { 26, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA },
|
||||
/* 27*/ { 27, "1", -1, -1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 208: UPCD1 not supported", 27 },
|
||||
/* 28*/ { 54, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 210: General Parcel Code not supported", BARCODE_CODE128 },
|
||||
/* 29*/ { 54, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 210: General Parcel Code not supported", -1 },
|
||||
/* 30*/ { 91, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 212: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 31*/ { 91, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 212: Symbology out of range", -1 },
|
||||
/* 32*/ { 95, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 213: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 33*/ { 95, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 213: Symbology out of range", -1 },
|
||||
/* 34*/ { 111, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_HIBC_BLOCKF },
|
||||
/* 35*/ { 111, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_BLOCKF },
|
||||
/* 36*/ { 114, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 214: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 37*/ { 114, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 214: Symbology out of range", -1 },
|
||||
/* 38*/ { 120, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 39*/ { 120, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/* 40*/ { 146, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 216: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 41*/ { 146, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 216: Symbology out of range", -1 },
|
||||
/* 42*/ { BARCODE_CODE128, "\200", -1, UNICODE_MODE, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8", -1 },
|
||||
/* 0*/ { BARCODE_CODE128, -1, "1234", -1, -1, 3, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", -1 },
|
||||
/* 1*/ { BARCODE_CODE128, -1, "1234", -1, -1, 0, -1, -1, 0, "", -1 },
|
||||
/* 2*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 3, -1, -1, 0, "", -1 },
|
||||
/* 3*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 999999 + 1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: Invalid ECI mode", -1 },
|
||||
/* 4*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 20.1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Invalid dot size", -1 },
|
||||
/* 5*/ { BARCODE_CODE128, -1, "1234", -1, GS1_MODE, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 220: Selected symbology does not support GS1 mode", -1 },
|
||||
/* 6*/ { BARCODE_GS1_128, -1, "[21]12\0004", 8, GS1_MODE, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 262: NUL characters not permitted in GS1 mode", -1 },
|
||||
/* 7*/ { BARCODE_GS1_128, -1, "[21]12é4", -1, GS1_MODE, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1", -1 },
|
||||
/* 8*/ { BARCODE_GS1_128, -1, "[21]12\0074", -1, GS1_MODE, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 251: Control characters are not supported by GS1", -1 },
|
||||
/* 9*/ { BARCODE_GS1_128, -1, "[21]1234", -1, GS1_MODE, -1, -1, -1, 0, "", -1 },
|
||||
/* 10*/ { 0, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 11*/ { 0, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
|
||||
/* 12*/ { 0, -1, "1", -1, -1, 1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", BARCODE_CODE128 }, // Not supporting beats invalid ECI
|
||||
/* 13*/ { 0, -1, "1", -1, -1, 1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
|
||||
/* 14*/ { 0, -1, "1", -1, -1, -1, 0.009, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Invalid dot size", BARCODE_CODE128 },
|
||||
/* 15*/ { 0, -1, "1", -1, -1, -1, 0.009, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
|
||||
/* 16*/ { 0, -1, "1", -1, -1, 1, 0.009, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", BARCODE_CODE128 }, // Invalid dot size no longer beats invalid ECI
|
||||
/* 17*/ { 0, -1, "1", -1, -1, -1, 0.009, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
|
||||
/* 18*/ { 5, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_C25STANDARD },
|
||||
/* 19*/ { 5, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_C25STANDARD },
|
||||
/* 20*/ { 10, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_EANX },
|
||||
/* 21*/ { 10, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_EANX },
|
||||
/* 22*/ { 11, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_EANX },
|
||||
/* 23*/ { 11, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_EANX },
|
||||
/* 24*/ { 12, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_EANX },
|
||||
/* 25*/ { 12, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_EANX },
|
||||
/* 26*/ { 15, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_EANX },
|
||||
/* 27*/ { 15, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_EANX },
|
||||
/* 28*/ { 17, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_UPCA },
|
||||
/* 29*/ { 17, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA },
|
||||
/* 30*/ { 19, -1, "1", -1, -1, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 362: Input too short (3 character minimum)", BARCODE_CODABAR },
|
||||
/* 31*/ { 19, -1, "A1B", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 207: Codabar 18 not supported", BARCODE_CODABAR },
|
||||
/* 32*/ { 19, -1, "A1B", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 207: Codabar 18 not supported", -1 },
|
||||
/* 33*/ { 26, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_UPCA },
|
||||
/* 34*/ { 26, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA },
|
||||
/* 35*/ { 27, -1, "1", -1, -1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 208: UPCD1 not supported", 27 },
|
||||
/* 36*/ { 33, -1, "1", -1, -1, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI", BARCODE_GS1_128 },
|
||||
/* 37*/ { 33, -1, "[10]23", -1, -1, -1, -1, -1, 0, "", BARCODE_GS1_128 },
|
||||
/* 38*/ { 33, -1, "[10]23", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_GS1_128 },
|
||||
/* 39*/ { 36, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_UPCA },
|
||||
/* 40*/ { 36, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA },
|
||||
/* 41*/ { 39, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_UPCE },
|
||||
/* 42*/ { 39, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCE },
|
||||
/* 43*/ { 41, -1, "1", -1, -1, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 480: Input wrong length (5, 9 or 11 characters only)", BARCODE_POSTNET },
|
||||
/* 44*/ { 41, -1, "12345", -1, -1, -1, -1, -1, 0, "", BARCODE_POSTNET },
|
||||
/* 45*/ { 41, -1, "12345", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET },
|
||||
/* 46*/ { 42, -1, "12345", -1, -1, -1, -1, -1, 0, "", BARCODE_POSTNET },
|
||||
/* 47*/ { 42, -1, "12345", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET },
|
||||
/* 48*/ { 43, -1, "12345", -1, -1, -1, -1, -1, 0, "", BARCODE_POSTNET },
|
||||
/* 49*/ { 43, -1, "12345", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET },
|
||||
/* 50*/ { 44, -1, "12345", -1, -1, -1, -1, -1, 0, "", BARCODE_POSTNET },
|
||||
/* 51*/ { 44, -1, "12345", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET },
|
||||
/* 52*/ { 45, -1, "12345", -1, -1, -1, -1, -1, 0, "", BARCODE_POSTNET },
|
||||
/* 53*/ { 45, -1, "12345", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET },
|
||||
/* 54*/ { 46, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_PLESSEY },
|
||||
/* 55*/ { 46, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_PLESSEY },
|
||||
/* 56*/ { 48, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_NVE18 },
|
||||
/* 57*/ { 48, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_NVE18 },
|
||||
/* 58*/ { 54, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 210: General Parcel Code not supported", BARCODE_CODE128 },
|
||||
/* 59*/ { 54, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 210: General Parcel Code not supported", -1 },
|
||||
/* 60*/ { 59, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_CODE128 },
|
||||
/* 61*/ { 59, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_CODE128 },
|
||||
/* 62*/ { 61, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_CODE128 },
|
||||
/* 63*/ { 61, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_CODE128 },
|
||||
/* 64*/ { 62, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_CODE93 },
|
||||
/* 65*/ { 62, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_CODE93 },
|
||||
/* 66*/ { 64, -1, "12345678", -1, -1, -1, -1, -1, 0, "", BARCODE_AUSPOST },
|
||||
/* 67*/ { 64, -1, "12345678", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_AUSPOST },
|
||||
/* 68*/ { 65, -1, "12345678", -1, -1, -1, -1, -1, 0, "", BARCODE_AUSPOST },
|
||||
/* 69*/ { 65, -1, "12345678", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_AUSPOST },
|
||||
/* 70*/ { 78, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_DBAR_OMN },
|
||||
/* 71*/ { 78, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_DBAR_OMN },
|
||||
/* 72*/ { 83, -1, "12345678901", -1, -1, -1, -1, -1, 0, "", BARCODE_PLANET },
|
||||
/* 73*/ { 83, -1, "12345678901", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_PLANET },
|
||||
/* 74*/ { 88, -1, "1", -1, -1, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI", BARCODE_GS1_128 },
|
||||
/* 75*/ { 88, -1, "[10]12", -1, -1, -1, -1, -1, 0, "", BARCODE_GS1_128 },
|
||||
/* 76*/ { 88, -1, "[10]12", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_GS1_128 },
|
||||
/* 77*/ { 91, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 212: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 78*/ { 91, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 212: Symbology out of range", -1 },
|
||||
/* 79*/ { 94, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 213: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 80*/ { 94, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 213: Symbology out of range", -1 },
|
||||
/* 81*/ { 95, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 213: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 82*/ { 95, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 213: Symbology out of range", -1 },
|
||||
/* 83*/ { 100, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_HIBC_128 },
|
||||
/* 84*/ { 100, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_128 },
|
||||
/* 85*/ { 101, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_HIBC_39 },
|
||||
/* 86*/ { 101, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_39 },
|
||||
/* 87*/ { 103, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_HIBC_DM },
|
||||
/* 88*/ { 103, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_DM },
|
||||
/* 89*/ { 105, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_HIBC_QR },
|
||||
/* 90*/ { 105, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_QR },
|
||||
/* 91*/ { 107, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_HIBC_PDF },
|
||||
/* 92*/ { 107, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_PDF },
|
||||
/* 93*/ { 109, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_HIBC_MICPDF },
|
||||
/* 94*/ { 109, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_MICPDF },
|
||||
/* 95*/ { 111, -1, "1", -1, -1, -1, -1, -1, 0, "", BARCODE_HIBC_BLOCKF },
|
||||
/* 96*/ { 111, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, 0, "", BARCODE_HIBC_BLOCKF },
|
||||
/* 97*/ { 113, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 214: Symbology out of range", BARCODE_CODE128 },
|
||||
/* 98*/ { 113, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 214: Symbology out of range", -1 },
|
||||
/* 99*/ { 114, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 214: Symbology out of range", BARCODE_CODE128 },
|
||||
/*100*/ { 114, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 214: Symbology out of range", -1 },
|
||||
/*101*/ { 117, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*102*/ { 117, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*103*/ { 118, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*104*/ { 118, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*105*/ { 119, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*106*/ { 119, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*107*/ { 120, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*108*/ { 120, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*109*/ { 122, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*110*/ { 122, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*111*/ { 123, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*112*/ { 123, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*113*/ { 124, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*114*/ { 124, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*115*/ { 125, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*116*/ { 125, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*117*/ { 126, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*118*/ { 126, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*119*/ { 127, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 215: Symbology out of range", BARCODE_CODE128 },
|
||||
/*120*/ { 127, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 215: Symbology out of range", -1 },
|
||||
/*121*/ { 146, -1, "1", -1, -1, -1, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 216: Symbology out of range", BARCODE_CODE128 },
|
||||
/*122*/ { 146, -1, "1", -1, -1, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 216: Symbology out of range", -1 },
|
||||
/*123*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input data", -1 },
|
||||
/*124*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 },
|
||||
/*125*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 },
|
||||
/*126*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, 13, -1, -1, 0, "", -1 },
|
||||
/*127*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 },
|
||||
/*128*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 },
|
||||
/*129*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 },
|
||||
/*130*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 512: ECI ignored for GS1 mode", -1 },
|
||||
/*131*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, // Warning in encoder overrides library warnings
|
||||
/*132*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 }, // But not errors
|
||||
/*133*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, 13, -1, -1, 0, "", -1 },
|
||||
/*134*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 },
|
||||
/*135*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 },
|
||||
/*136*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 503: Invalid error correction level - using default instead", -1 },
|
||||
/*137*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Invalid error correction level - using default instead", -1 },
|
||||
/*138*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, // ECI warning trumps all other warnings
|
||||
/*139*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Invalid error correction level - using default instead", -1 }, // But not errors
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@ -108,7 +206,7 @@ static void test_checks(int index, int debug) {
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
if (data[i].dot_size != -1) {
|
||||
symbol->dot_size = data[i].dot_size;
|
||||
}
|
||||
@ -134,6 +232,21 @@ static void test_checks(int index, int debug) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_symbologies(void) {
|
||||
int i, ret;
|
||||
struct zint_symbol symbol = {0};
|
||||
|
||||
testStart("test_symbologies");
|
||||
|
||||
for (i = -1; i < 148; i++) {
|
||||
symbol.symbology = i;
|
||||
ret = ZBarcode_Encode(&symbol, (unsigned char *) "1", 0);
|
||||
assert_notequal(ret, ZINT_ERROR_ENCODING_PROBLEM, "i:%d Encoding problem (%s)\n", i, symbol.errtxt);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_input_mode(int index, int debug) {
|
||||
|
||||
struct item {
|
||||
@ -583,40 +696,55 @@ static void test_valid_id(void) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
STATIC_UNLESS_ZINT_TEST int error_tag(char error_string[100], int error_number);
|
||||
STATIC_UNLESS_ZINT_TEST int error_tag(struct zint_symbol *symbol, int error_number, const char *error_string);
|
||||
|
||||
static void test_error_tag(int index) {
|
||||
|
||||
struct item {
|
||||
int error_number;
|
||||
int warn_level;
|
||||
char* data;
|
||||
int ret;
|
||||
char* expected;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { ZINT_WARN_INVALID_OPTION, "", ZINT_WARN_INVALID_OPTION, "Warning " },
|
||||
/* 1*/ { ZINT_ERROR_TOO_LONG, "", ZINT_ERROR_TOO_LONG, "Error " },
|
||||
/* 2*/ { ZINT_WARN_USES_ECI, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
|
||||
/* 3*/ { ZINT_ERROR_INVALID_DATA, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
|
||||
/* 0*/ { ZINT_WARN_INVALID_OPTION, -1, "", ZINT_WARN_INVALID_OPTION, "Warning " },
|
||||
/* 1*/ { ZINT_WARN_INVALID_OPTION, WARN_FAIL_ALL, "", ZINT_ERROR_INVALID_OPTION, "Error " },
|
||||
/* 2*/ { ZINT_WARN_USES_ECI, -1, "", ZINT_WARN_USES_ECI, "Warning " },
|
||||
/* 3*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "", ZINT_ERROR_USES_ECI, "Error " },
|
||||
/* 4*/ { ZINT_WARN_NONCOMPLIANT, -1, "", ZINT_WARN_NONCOMPLIANT, "Warning " },
|
||||
/* 5*/ { ZINT_WARN_NONCOMPLIANT, WARN_FAIL_ALL, "", ZINT_ERROR_NONCOMPLIANT, "Error " },
|
||||
/* 6*/ { ZINT_ERROR_TOO_LONG, WARN_DEFAULT, "", ZINT_ERROR_TOO_LONG, "Error " },
|
||||
/* 7*/ { ZINT_WARN_USES_ECI, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
|
||||
/* 8*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
|
||||
/* 9*/ { ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
|
||||
/* 10*/ { ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
|
||||
/* 11*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
|
||||
/* 12*/ { ZINT_ERROR_INVALID_DATA, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, ret;
|
||||
|
||||
char errtxt[100];
|
||||
|
||||
testStart("test_error_tag");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
struct zint_symbol symbol = {0};
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
assert_nonzero((int) strlen(data[i].data) < 100, "i:%d strlen(data) %d >= 100\n", i, (int) strlen(data[i].data));
|
||||
strcpy(errtxt, data[i].data);
|
||||
ret = error_tag(errtxt, data[i].error_number);
|
||||
symbol.warn_level = data[i].warn_level;
|
||||
|
||||
ret = error_tag(&symbol, data[i].error_number, data[i].data);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
assert_zero(strcmp(errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, errtxt, data[i].expected);
|
||||
assert_nonzero(strlen(errtxt) >= strlen(data[i].data), "i:%d strlen(errtxt) %d < %d\n", i, (int) strlen(errtxt), (int) strlen(data[i].data));
|
||||
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol.errtxt, data[i].expected);
|
||||
|
||||
if ((int) strlen(data[i].data) < 100) {
|
||||
strcpy(symbol.errtxt, data[i].data);
|
||||
ret = error_tag(&symbol, data[i].error_number, NULL);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol.errtxt, data[i].expected);
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
@ -682,10 +810,103 @@ static void test_zero_outfile(void) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_clear(void) {
|
||||
|
||||
int ret;
|
||||
struct zint_symbol *symbol;
|
||||
char *data = "1234";
|
||||
|
||||
testStart("test_clear");
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
symbol->symbology = BARCODE_MAXICODE;
|
||||
symbol->whitespace_width = 5;
|
||||
symbol->whitespace_height = 5;
|
||||
symbol->border_width = 2;
|
||||
symbol->output_options = BARCODE_BOX;
|
||||
strcpy(symbol->fgcolour, "000000AA");
|
||||
strcpy(symbol->bgcolour, "FFFFFFAA");
|
||||
|
||||
// Raster
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data, 0);
|
||||
assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt);
|
||||
|
||||
assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n");
|
||||
assert_nonzero(symbol->width, "ZBarcode_Encode() width 0\n");
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
assert_zero(ret, "ZBarcode_Buffer() ret %d != 0 (%s)\n", ret, symbol->errtxt);
|
||||
|
||||
assert_nonnull(symbol->bitmap, "ZBarcode_Buffer() bitmap NULL\n");
|
||||
assert_nonnull(symbol->alphamap, "ZBarcode_Buffer() alphamap NULL\n");
|
||||
assert_nonzero(symbol->bitmap_width, "ZBarcode_Buffer() bitmap_width 0\n");
|
||||
assert_nonzero(symbol->bitmap_height, "ZBarcode_Buffer() bitmap_height 0\n");
|
||||
|
||||
assert_nonzero(symbol->rows, "ZBarcode_Buffer() rows 0\n");
|
||||
assert_nonzero(symbol->width, "ZBarcode_Buffer() width 0\n");
|
||||
assert_zero(symbol->bitmap_byte_length, "ZBarcode_Buffer() bitmap_byte_length %d != 0\n", symbol->bitmap_byte_length);
|
||||
assert_null(symbol->vector, "ZBarcode_Buffer() vector != NULL\n");
|
||||
|
||||
ZBarcode_Clear(symbol);
|
||||
|
||||
assert_null(symbol->bitmap, "ZBarcode_Buffer() bitmap != NULL\n");
|
||||
assert_null(symbol->alphamap, "ZBarcode_Buffer() alphamap != NULL\n");
|
||||
assert_zero(symbol->bitmap_width, "ZBarcode_Buffer() bitmap_width %d != 0\n", symbol->bitmap_width);
|
||||
assert_zero(symbol->bitmap_height, "ZBarcode_Buffer() bitmap_height %d != 0\n", symbol->bitmap_height);
|
||||
|
||||
assert_zero(symbol->rows, "ZBarcode_Buffer() rows %d != 0\n", symbol->rows);
|
||||
assert_zero(symbol->width, "ZBarcode_Buffer() width %d != 0\n", symbol->width);
|
||||
assert_zero(symbol->bitmap_byte_length, "ZBarcode_Buffer() bitmap_byte_length %d != 0\n", symbol->bitmap_byte_length);
|
||||
assert_null(symbol->vector, "ZBarcode_Buffer() vector != NULL\n");
|
||||
|
||||
// Vector
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data, 0);
|
||||
assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt);
|
||||
|
||||
assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n");
|
||||
assert_nonzero(symbol->width, "ZBarcode_Encode() width 0\n");
|
||||
|
||||
ret = ZBarcode_Buffer_Vector(symbol, 0);
|
||||
assert_zero(ret, "ZBarcode_Buffer_Vector() ret %d != 0 (%s)\n", ret, symbol->errtxt);
|
||||
|
||||
assert_nonnull(symbol->vector, "ZBarcode_Buffer_Vector() vector NULL\n");
|
||||
assert_nonnull(symbol->vector->rectangles, "ZBarcode_Buffer_Vector() vector->rectangles NULL\n");
|
||||
assert_nonnull(symbol->vector->hexagons, "ZBarcode_Buffer_Vector() vector->hexagons NULL\n");
|
||||
assert_null(symbol->vector->strings, "ZBarcode_Buffer_Vector() vector->strings != NULL\n"); // MAXICODE no text
|
||||
assert_nonnull(symbol->vector->circles, "ZBarcode_Buffer_Vector() vector->circles NULL\n");
|
||||
|
||||
assert_nonzero(symbol->rows, "ZBarcode_Buffer_Vector() rows 0\n");
|
||||
assert_nonzero(symbol->width, "ZBarcode_Buffer_Vector() width 0\n");
|
||||
assert_null(symbol->bitmap, "ZBarcode_Buffer_Vector() bitmap != NULL\n");
|
||||
assert_null(symbol->alphamap, "ZBarcode_Buffer_Vector() alphamap != NULL\n");
|
||||
assert_zero(symbol->bitmap_byte_length, "ZBarcode_Buffer_Vector() bitmap_byte_length %d != 0\n", symbol->bitmap_byte_length);
|
||||
|
||||
ZBarcode_Clear(symbol);
|
||||
|
||||
assert_null(symbol->vector, "ZBarcode_Buffer_Vector() vector != NULL\n");
|
||||
|
||||
assert_zero(symbol->rows, "ZBarcode_Buffer_Vector() rows %d != 0\n", symbol->rows);
|
||||
assert_zero(symbol->width, "ZBarcode_Buffer_Vector() width %d != 0\n", symbol->width);
|
||||
assert_zero(symbol->bitmap_byte_length, "ZBarcode_Buffer_Vector() bitmap_byte_length %d != 0\n", symbol->bitmap_byte_length);
|
||||
assert_null(symbol->bitmap, "ZBarcode_Buffer_Vector() bitmap != NULL\n");
|
||||
assert_null(symbol->alphamap, "ZBarcode_Buffer_Vector() alphamap != NULL\n");
|
||||
assert_zero(symbol->bitmap_width, "ZBarcode_Buffer_Vector() bitmap_width %d != 0\n", symbol->bitmap_width);
|
||||
assert_zero(symbol->bitmap_height, "ZBarcode_Buffer_Vector() bitmap_height %d != 0\n", symbol->bitmap_height);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
{ "test_checks", test_checks, 1, 0, 1 },
|
||||
{ "test_symbologies", test_symbologies, 0, 0, 0 },
|
||||
{ "test_input_mode", test_input_mode, 1, 0, 1 },
|
||||
{ "test_escape_char_process", test_escape_char_process, 1, 1, 1 },
|
||||
{ "test_cap", test_cap, 1, 0, 0 },
|
||||
@ -698,6 +919,7 @@ int main(int argc, char *argv[]) {
|
||||
{ "test_error_tag", test_error_tag, 1, 0, 0 },
|
||||
{ "test_strip_bom", test_strip_bom, 0, 0, 0 },
|
||||
{ "test_zero_outfile", test_zero_outfile, 0, 0, 0 },
|
||||
{ "test_clear", test_clear, 0, 0, 0 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
@ -149,7 +149,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 17*/ { UNICODE_MODE, -1, -1, -1, "A", -1, "ABCDE123456", 0, 30, "(144) 03 18 01 31 20 10 30 1E 20 1C 0F 38 38 1A 39 10 2F 37 22 12 01 21 21 21 21 21 21 21", "5-alphanumeric postcode" },
|
||||
/* 18*/ { UNICODE_MODE, -1, -1, -1, "A", -1, "AAAAAA 840001", 0, 30, "(144) 13 10 10 10 10 10 00 12 07 00 17 36 2E 38 04 29 16 0D 27 16 01 21 21 21 21 21 21 21", "6-alphanumeric postcode with padding" },
|
||||
/* 19*/ { UNICODE_MODE, -1, -1, -1, "A", -1, "AAAAA A840001", 0, 30, "(144) 03 18 10 10 10 10 00 12 07 00 19 07 29 31 26 01 23 2C 2E 07 01 21 21 21 21 21 21 21", "7-alphanumeric with embedded padding truncated" },
|
||||
/* 20*/ { UNICODE_MODE, -1, -1, -1, "A", -1, "AA\015AAA840001", ZINT_ERROR_INVALID_DATA, 0, "Error 556: Invalid characters in postcode in Primary Message", "Alphanumeric postcode with CR" },
|
||||
/* 20*/ { UNICODE_MODE, -1, -1, -1, "A", -1, "AA\015AAA840001", ZINT_ERROR_INVALID_DATA, 0, "Error 556: Invalid character in postcode in Primary Message", "Alphanumeric postcode with CR" },
|
||||
/* 21*/ { UNICODE_MODE, -1, -1, -1, "A", -1, "A#%-/A840001", 0, 30, "(144) 13 30 1B 1B 39 18 00 12 07 00 3F 1E 25 07 2A 1E 14 3C 28 2D 01 21 21 21 21 21 21 21", "Alphanumeric postcode with non-control Code A chars" },
|
||||
/* 22*/ { UNICODE_MODE, -1, -1, -1, "A", -1, "1A23456", ZINT_ERROR_INVALID_DATA, 0, "Error 552: Non-numeric country code or service class in Primary Message", "Non-numeric country code" },
|
||||
/* 23*/ { UNICODE_MODE, -1, -1, -1, "A", -1, "12345678912345A", ZINT_ERROR_INVALID_DATA, 0, "Error 552: Non-numeric country code or service class in Primary Message", "Non-numeric service class" },
|
||||
|
@ -151,7 +151,7 @@ static void test_input(int index, int debug) {
|
||||
/* 2*/ { BARCODE_CODABAR, "A1234", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 359: Does not end with \"A\", \"B\", \"C\" or \"D\"" },
|
||||
/* 3*/ { BARCODE_CODABAR, "A1234E", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 359: Does not end with \"A\", \"B\", \"C\" or \"D\"" },
|
||||
/* 4*/ { BARCODE_CODABAR, "C123.D", 0, 1, 63, "" },
|
||||
/* 5*/ { BARCODE_CODABAR, "C123,D", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 357: Invalid characters in data" },
|
||||
/* 5*/ { BARCODE_CODABAR, "C123,D", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 357: Invalid character in data (\"0123456789-$:/.+ABCD\" only)" },
|
||||
/* 6*/ { BARCODE_CODABAR, "D:C", 0, 1, 33, "" },
|
||||
/* 7*/ { BARCODE_CODABAR, "DCC", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 363: Cannot contain \"A\", \"B\", \"C\" or \"D\"" },
|
||||
/* 8*/ { BARCODE_CODABAR, "AB", ZINT_ERROR_TOO_LONG, -1, -1, "Error 362: Input too short (3 character minimum)" },
|
||||
@ -160,18 +160,18 @@ static void test_input(int index, int debug) {
|
||||
/* 11*/ { BARCODE_PHARMA, "3", 0, 1, 4, "" },
|
||||
/* 12*/ { BARCODE_PHARMA, "2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Data out of range (3 to 131070)" },
|
||||
/* 13*/ { BARCODE_PHARMA, "1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Data out of range (3 to 131070)" },
|
||||
/* 14*/ { BARCODE_PHARMA, "12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 351: Invalid characters in data (digits only)" },
|
||||
/* 14*/ { BARCODE_PHARMA, "12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 351: Invalid character in data (digits only)" },
|
||||
/* 15*/ { BARCODE_PHARMA_TWO, "64570080", 0, 2, 31, "" },
|
||||
/* 16*/ { BARCODE_PHARMA_TWO, "64570081", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)" },
|
||||
/* 17*/ { BARCODE_PHARMA_TWO, "4", 0, 2, 3, "" },
|
||||
/* 18*/ { BARCODE_PHARMA_TWO, "3", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)" },
|
||||
/* 19*/ { BARCODE_PHARMA_TWO, "2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)" },
|
||||
/* 20*/ { BARCODE_PHARMA_TWO, "1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)" },
|
||||
/* 21*/ { BARCODE_PHARMA_TWO, "123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 355: Invalid characters in data (digits only)" },
|
||||
/* 21*/ { BARCODE_PHARMA_TWO, "123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 355: Invalid character in data (digits only)" },
|
||||
/* 22*/ { BARCODE_CODE32, "12345678", 0, 1, 103, "" },
|
||||
/* 23*/ { BARCODE_CODE32, "9", 0, 1, 103, "" },
|
||||
/* 24*/ { BARCODE_CODE32, "0", 0, 1, 103, "" },
|
||||
/* 25*/ { BARCODE_CODE32, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 361: Invalid characters in data (digits only)" },
|
||||
/* 25*/ { BARCODE_CODE32, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 361: Invalid character in data (digits only)" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -160,8 +160,8 @@ static void test_reader_init(int index, int generate, int debug) {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -192,7 +192,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 2*/ { BARCODE_PDF417, UNICODE_MODE, 26, "é", 0, 26, 7, 103, "(14) 6 927 26 901 195 169 574 701 519 908 84 241 360 642", "" },
|
||||
/* 3*/ { BARCODE_PDF417, UNICODE_MODE, 9, "β", 0, 9, 7, 103, "(14) 6 927 9 913 226 900 487 92 418 278 838 500 576 84", "" },
|
||||
/* 4*/ { BARCODE_PDF417, UNICODE_MODE, -1, "β", ZINT_WARN_USES_ECI, 9, 7, 103, "Warning (14) 6 927 9 913 226 900 487 92 418 278 838 500 576 84", "" },
|
||||
/* 5*/ { BARCODE_PDF417, UNICODE_MODE, 3, "β", ZINT_ERROR_INVALID_DATA, 3, 0, 0, "Error 204: Invalid characters in input data", "" },
|
||||
/* 5*/ { BARCODE_PDF417, UNICODE_MODE, 3, "β", ZINT_ERROR_INVALID_DATA, 3, 0, 0, "Error 244: Invalid character in input data for ECI 3", "" },
|
||||
/* 6*/ { BARCODE_PDF417, UNICODE_MODE, 899, "A", 0, 899, 7, 103, "(14) 6 927 899 900 29 900 727 69 915 482 371 771 641 35", "" },
|
||||
/* 7*/ { BARCODE_PDF417, UNICODE_MODE, 900, "A", 0, 900, 7, 103, "(14) 6 926 0 0 900 29 56 795 921 763 468 267 410 129", "" },
|
||||
/* 8*/ { BARCODE_PDF417, UNICODE_MODE, 810899, "A", 0, 810899, 7, 103, "(14) 6 926 899 899 900 29 847 901 749 718 89 792 660 273", "" },
|
||||
@ -204,14 +204,14 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 14*/ { BARCODE_MICROPDF417, UNICODE_MODE, 26, "é", 0, 26, 6, 82, "(18) 927 26 901 195 169 900 288 96 509 365 709 784 713 403 219 81 851 866", "" },
|
||||
/* 15*/ { BARCODE_MICROPDF417, UNICODE_MODE, 9, "β", 0, 9, 11, 38, "(11) 927 9 913 226 23 103 74 194 394 667 324", "" },
|
||||
/* 16*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, "β", ZINT_WARN_USES_ECI, 9, 11, 38, "Warning (11) 927 9 913 226 23 103 74 194 394 667 324", "" },
|
||||
/* 17*/ { BARCODE_MICROPDF417, UNICODE_MODE, 3, "β", ZINT_ERROR_INVALID_DATA, 3, 0, 0, "Error 204: Invalid characters in input data", "" },
|
||||
/* 17*/ { BARCODE_MICROPDF417, UNICODE_MODE, 3, "β", ZINT_ERROR_INVALID_DATA, 3, 0, 0, "Error 244: Invalid character in input data for ECI 3", "" },
|
||||
/* 18*/ { BARCODE_MICROPDF417, UNICODE_MODE, 899, "A", 0, 899, 11, 38, "(11) 927 899 900 29 533 437 884 3 617 241 747", "" },
|
||||
/* 19*/ { BARCODE_MICROPDF417, UNICODE_MODE, 900, "A", 0, 900, 6, 82, "(18) 926 0 0 900 29 900 913 543 414 141 214 886 461 1 419 422 54 495", "" },
|
||||
/* 20*/ { BARCODE_MICROPDF417, UNICODE_MODE, 810899, "A", 0, 810899, 6, 82, "(18) 926 899 899 900 29 900 351 555 241 509 787 583 3 326 41 628 534 151", "" },
|
||||
/* 21*/ { BARCODE_MICROPDF417, UNICODE_MODE, 810900, "A", 0, 810900, 11, 38, "(11) 925 0 900 29 233 533 43 483 708 659 704", "" },
|
||||
/* 22*/ { BARCODE_MICROPDF417, UNICODE_MODE, 811800, "A", ZINT_ERROR_INVALID_OPTION, 811800, 0, 0, "Error 473: Invalid ECI", "" },
|
||||
/* 23*/ { BARCODE_HIBC_PDF, UNICODE_MODE, -1, ",", ZINT_ERROR_INVALID_DATA, 0, 0, 0, "Error 203: Invalid characters in data", "" },
|
||||
/* 24*/ { BARCODE_HIBC_MICPDF, UNICODE_MODE, -1, ",", ZINT_ERROR_INVALID_DATA, 0, 0, 0, "Error 203: Invalid characters in data", "" },
|
||||
/* 23*/ { BARCODE_HIBC_PDF, UNICODE_MODE, -1, ",", ZINT_ERROR_INVALID_DATA, 0, 0, 0, "Error 203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)", "" },
|
||||
/* 24*/ { BARCODE_HIBC_MICPDF, UNICODE_MODE, -1, ",", ZINT_ERROR_INVALID_DATA, 0, 0, 0, "Error 203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)", "" },
|
||||
/* 25*/ { BARCODE_PDF417, UNICODE_MODE, -1, "AB{} C#+ de{} {}F 12{} G{} H", 0, 0, 12, 120, "(36) 28 1 865 807 896 782 855 626 807 94 865 807 896 808 776 839 176 808 32 776 839 806 208", "" },
|
||||
/* 26*/ { BARCODE_PDF417, UNICODE_MODE, -1, "{} #+ de{} 12{} {} H", 0, 0, 10, 120, "(30) 22 865 807 896 808 470 807 94 865 807 896 808 32 776 839 806 865 807 896 787 900 900", "" },
|
||||
};
|
||||
@ -247,8 +247,8 @@ static void test_input(int index, int generate, int debug) {
|
||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d symbol->eci %d != %d (%s)\n", i, symbol->eci, data[i].expected_eci, data[i].data);
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
@ -178,7 +178,7 @@ static void test_qr_input(int index, int generate, int debug) {
|
||||
/* 32*/ { UNICODE_MODE, 26, -1, "¥", 0, 26, "71 A4 02 C2 A5 00 EC 11 EC", "ECI-26 B2 (UTF-8)" },
|
||||
/* 33*/ { DATA_MODE, 0, -1, "¥", 0, 0, "40 2C 2A 50 EC 11 EC 11 EC", "B2 (UTF-8)" },
|
||||
/* 34*/ { UNICODE_MODE, 0, -1, "・", 0, 0, "40 1A 50 EC 11 EC 11 EC 11", "B1 (Shift JIS) single-byte codepoint A5 (same bytes as ¥ ISO 8859-1 above, so ambiguous)" },
|
||||
/* 35*/ { UNICODE_MODE, 3, -1, "・", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid characters in input data", "" },
|
||||
/* 35*/ { UNICODE_MODE, 3, -1, "・", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid character in input data for ECI 3", "" },
|
||||
/* 36*/ { UNICODE_MODE, 20, -1, "・", 0, 20, "71 44 01 A5 00 EC 11 EC 11", "ECI-20 B1 (Shift JIS) single-byte codepoint A5" },
|
||||
/* 37*/ { UNICODE_MODE, 26, -1, "・", 0, 26, "71 A4 03 EF BD A5 00 EC 11", "ECI-26 B3 (UTF-8)" },
|
||||
/* 38*/ { DATA_MODE, 0, -1, "・", 0, 0, "40 3E FB DA 50 EC 11 EC 11", "B3 (UTF-8)" },
|
||||
@ -188,7 +188,7 @@ static void test_qr_input(int index, int generate, int debug) {
|
||||
/* 42*/ { UNICODE_MODE, 26, -1, "¿", 0, 26, "71 A4 02 C2 BF 00 EC 11 EC", "ECI-26 B2 (UTF-8)" },
|
||||
/* 43*/ { DATA_MODE, 0, -1, "¿", 0, 0, "40 2C 2B F0 EC 11 EC 11 EC", "B2 (UTF-8)" },
|
||||
/* 44*/ { UNICODE_MODE, 0, -1, "ソ", 0, 0, "40 1B F0 EC 11 EC 11 EC 11", "B1 (Shift JIS) single-byte codepoint BF (same bytes as ¿ ISO 8859-1 above, so ambiguous)" },
|
||||
/* 45*/ { UNICODE_MODE, 3, -1, "ソ", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid characters in input data", "" },
|
||||
/* 45*/ { UNICODE_MODE, 3, -1, "ソ", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid character in input data for ECI 3", "" },
|
||||
/* 46*/ { UNICODE_MODE, 20, -1, "ソ", 0, 20, "71 44 01 BF 00 EC 11 EC 11", "ECI-20 B1 (Shift JIS) single-byte codepoint BF" },
|
||||
/* 47*/ { UNICODE_MODE, 26, -1, "ソ", 0, 26, "71 A4 03 EF BD BF 00 EC 11", "ECI-26 B3 (UTF-8)" },
|
||||
/* 48*/ { DATA_MODE, 0, -1, "ソ", 0, 0, "40 3E FB DB F0 EC 11 EC 11", "B3 (UTF-8)" },
|
||||
@ -196,19 +196,19 @@ static void test_qr_input(int index, int generate, int debug) {
|
||||
/* 50*/ { UNICODE_MODE, 3, -1, "~", 0, 3, "70 34 01 7E 00 EC 11 EC 11", "ECI-3 B1 (ASCII)" },
|
||||
/* 51*/ { UNICODE_MODE, 20, -1, "~", ZINT_ERROR_INVALID_DATA, -1, "Error 800: Invalid character in input data", "tilde not in Shift JIS (codepoint used for overline)" },
|
||||
/* 52*/ { UNICODE_MODE, 0, -1, "‾", 0, 0, "40 17 E0 EC 11 EC 11 EC 11", "B1 (Shift JIS) single-byte codepoint 7E (same bytes as ~ ASCII above, so ambiguous)" },
|
||||
/* 53*/ { UNICODE_MODE, 3, -1, "‾", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid characters in input data", "" },
|
||||
/* 53*/ { UNICODE_MODE, 3, -1, "‾", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid character in input data for ECI 3", "" },
|
||||
/* 54*/ { UNICODE_MODE, 20, -1, "‾", 0, 20, "71 44 01 7E 00 EC 11 EC 11", "ECI-20 B1 (Shift JIS) (to single-byte tilde codepoint 7E, so byte mode)" },
|
||||
/* 55*/ { UNICODE_MODE, 26, -1, "‾", 0, 26, "71 A4 03 E2 80 BE 00 EC 11", "ECI-26 B3 (UTF-8)" },
|
||||
/* 56*/ { DATA_MODE, 0, -1, "‾", 0, 0, "40 3E 28 0B E0 EC 11 EC 11", "B3 (UTF-8)" },
|
||||
/* 57*/ { UNICODE_MODE, 0, -1, "点", 0, 0, "80 16 CF 80 EC 11 EC 11 EC", "K1 (Shift JIS)" },
|
||||
/* 58*/ { UNICODE_MODE, 3, -1, "点", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid characters in input data", "" },
|
||||
/* 58*/ { UNICODE_MODE, 3, -1, "点", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid character in input data for ECI 3", "" },
|
||||
/* 59*/ { UNICODE_MODE, 20, -1, "点", 0, 20, "71 48 01 6C F8 00 EC 11 EC", "ECI-20 K1 (Shift JIS)" },
|
||||
/* 60*/ { UNICODE_MODE, 26, -1, "点", 0, 26, "71 A4 03 E7 82 B9 00 EC 11", "ECI-26 B3 (UTF-8)" },
|
||||
/* 61*/ { DATA_MODE, 0, -1, "点", 0, 0, "40 3E 78 2B 90 EC 11 EC 11", "B3 (UTF-8)" },
|
||||
/* 62*/ { DATA_MODE, 0, -1, "\223\137", 0, 0, "40 29 35 F0 EC 11 EC 11 EC", "B2 (Shift JIS) (not full multibyte)" },
|
||||
/* 63*/ { DATA_MODE, 0, ZINT_FULL_MULTIBYTE, "\223\137", 0, 0, "80 16 CF 80 EC 11 EC 11 EC", "K1 (Shift JIS)" },
|
||||
/* 64*/ { UNICODE_MODE, 0, -1, "¥・点", 0, 0, "40 45 CA 59 35 F0 EC 11 EC", "B4 (Shift JIS) (optimized to byte mode only)" },
|
||||
/* 65*/ { UNICODE_MODE, 3, -1, "¥・点", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid characters in input data", "" },
|
||||
/* 65*/ { UNICODE_MODE, 3, -1, "¥・点", ZINT_ERROR_INVALID_DATA, -1, "Error 575: Invalid character in input data for ECI 3", "" },
|
||||
/* 66*/ { UNICODE_MODE, 20, -1, "¥・点", 0, 20, "71 44 04 5C A5 93 5F 00 EC", "ECI-20 B4 (Shift JIS)" },
|
||||
/* 67*/ { UNICODE_MODE, 26, -1, "¥・点", 0, 26, "71 A4 08 C2 A5 EF BD A5 E7 82 B9 00 EC", "ECI-26 B8 (UTF-8)" },
|
||||
/* 68*/ { DATA_MODE, 0, -1, "\134\245\223\137", 0, 0, "40 45 CA 59 35 F0 EC 11 EC", "B8 (Shift JIS)" },
|
||||
@ -300,10 +300,9 @@ static void test_qr_input(int index, int generate, int debug) {
|
||||
testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
|
||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -362,9 +361,7 @@ static void test_qr_gs1(int index, int generate, int debug) {
|
||||
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
|
||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -1585,9 +1582,7 @@ static void test_microqr_input(int index, int generate, int debug) {
|
||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -1666,9 +1661,7 @@ static void test_microqr_padding(int index, int generate, int debug) {
|
||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].option_1,
|
||||
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -2145,7 +2138,7 @@ static void test_upnqr_input(int index, int generate, int debug) {
|
||||
struct item data[] = {
|
||||
/* 0*/ { UNICODE_MODE, "ĄŔ", 0, "(415) 70 44 00 02 A1 C0 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC", "ECI-4 B2 (ISO 8859-2)" },
|
||||
/* 1*/ { UNICODE_MODE, "é", 0, "(415) 70 44 00 01 E9 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11", "ECI-4 B1 (ISO 8859-2)" },
|
||||
/* 2*/ { UNICODE_MODE, "β", ZINT_ERROR_INVALID_DATA, "Error 572: Invalid characters in input data", "β not in ISO 8859-2" },
|
||||
/* 2*/ { UNICODE_MODE, "β", ZINT_ERROR_INVALID_DATA, "Error 572: Invalid character in input data for ECI 4", "β not in ISO 8859-2" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@ -2175,9 +2168,7 @@ static void test_upnqr_input(int index, int generate, int debug) {
|
||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
||||
symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -2496,9 +2487,7 @@ static void test_rmqr_input(int index, int generate, int debug) {
|
||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -2557,9 +2546,7 @@ static void test_rmqr_gs1(int index, int generate, int debug) {
|
||||
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
|
||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
@ -834,6 +834,7 @@ static void test_draw_string_wrap(int index, int debug) {
|
||||
|
||||
ret = ZBarcode_Print(symbol, 0);
|
||||
assert_zero(ret, "i:%d ZBarcode_Print(%d) ret %d != 0\n", i, data[i].symbology, ret);
|
||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||
|
||||
text_bits_set = 0;
|
||||
row = data[i].expected_no_text_row;
|
||||
@ -902,6 +903,7 @@ static void test_code128_utf8(int index, int debug) {
|
||||
|
||||
ret = ZBarcode_Print(symbol, 0);
|
||||
assert_zero(ret, "i:%d ZBarcode_Print(%d) ret %d != 0\n", i, BARCODE_CODE128, ret);
|
||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||
|
||||
text_bits_set = 0;
|
||||
row = data[i].expected_text_row;
|
||||
@ -1014,6 +1016,7 @@ static void test_scale(int index, int debug) {
|
||||
|
||||
ret = ZBarcode_Print(symbol, 0);
|
||||
assert_zero(ret, "i:%d ZBarcode_Print(%d) ret %d != 0\n", i, data[i].symbology, ret);
|
||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||
|
||||
assert_nonzero(symbol->bitmap_height >= data[i].expected_set_rows, "i:%d (%d) symbol->bitmap_height %d < expected_set_rows %d\n",
|
||||
i, data[i].symbology, symbol->bitmap_height, data[i].expected_set_rows);
|
||||
|
@ -79,8 +79,8 @@ static void test_reader_init(int index, int generate, int debug) {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
@ -176,9 +176,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, testUtilOption3Name(data[i].option_3),
|
||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
@ -415,60 +415,107 @@ static void test_isbn_input(int index, int debug) {
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { "0", 0, 0 }, // Left zero-padded if < 10 chars
|
||||
/* 1*/ { "12345678", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 2*/ { "12345679", 0, 0 }, // 9 is correct check digit
|
||||
/* 3*/ { "98765434", 0, 0 }, // 4 is correct check digit
|
||||
/* 4*/ { "123456789", 0, 0 },
|
||||
/* 5*/ { "340013817", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 6*/ { "340013818", 0, 0 }, // 8 is correct check digit
|
||||
/* 7*/ { "902888455", 0, 0 }, // 5 is correct check digit
|
||||
/* 8*/ { "0123456789", 0, 0 },
|
||||
/* 9*/ { "1234567890", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 10*/ { "123456789X", 0, 0 }, // X is correct check digit
|
||||
/* 11*/ { "123456789x", 0, 0 }, // x is correct check digit
|
||||
/* 12*/ { "8175257660", 0, 0 }, // 0 is correct check digit
|
||||
/* 13*/ { "0590764845", 0, 0 }, // 5 is correct check digit
|
||||
/* 14*/ { "0906495741", 0, 0 }, // 1 is correct check digit
|
||||
/* 15*/ { "0140430016", 0, 0 }, // 6 is correct check digit
|
||||
/* 16*/ { "0571086187", 0, 0 }, // 7 is correct check digit
|
||||
/* 17*/ { "0486600882", 0, 0 }, // 2 is correct check digit
|
||||
/* 18*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 19*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 20*/ { "1234567890123", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 21*/ { "9784567890123", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 22*/ { "9784567890120", 0, 0 }, // 0 is correct check digit
|
||||
/* 23*/ { "9783161484100", 0, 0 }, // 0 is correct check digit
|
||||
/* 24*/ { "9781846688225", 0, 0 }, // 5 is correct check digit
|
||||
/* 25*/ { "9781847657954", 0, 0 }, // 4 is correct check digit
|
||||
/* 26*/ { "9781846688188", 0, 0 }, // 8 is correct check digit
|
||||
/* 27*/ { "9781847659293", 0, 0 }, // 3 is correct check digit
|
||||
/* 28*/ { "97845678901201", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 29*/ { "3954994+12", 0, 0 },
|
||||
/* 30*/ { "3954994+12345", 0, 0 },
|
||||
/* 31*/ { "3954994+123456", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 32*/ { "3954994+", 0, 0 },
|
||||
/* 33*/ { "61954993+1", 0, 0 },
|
||||
/* 34*/ { "61954992+123", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 35*/ { "61954993+123", 0, 0 },
|
||||
/* 36*/ { "361954990+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 37*/ { "361954999+12", 0, 0 },
|
||||
/* 38*/ { "361954999+1234", 0, 0 },
|
||||
/* 39*/ { "361954999+12", 0, 0 },
|
||||
/* 40*/ { "1999000030+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 41*/ { "199900003X+12", 0, 0 },
|
||||
/* 42*/ { "199900003x+12", 0, 0 },
|
||||
/* 43*/ { "1999000031+12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 44*/ { "199900003X+12345", 0, 0 },
|
||||
/* 45*/ { "199900003x+12345", 0, 0 },
|
||||
/* 46*/ { "9791234567895+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 47*/ { "9791234567896+12", 0, 0 },
|
||||
/* 48*/ { "9791234567897+12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 49*/ { "9791234567896+12345", 0, 0 },
|
||||
/* 50*/ { "9791234567892+", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 51*/ { "9791234567896+", 0, 0 },
|
||||
/* 52*/ { "97912345678961+", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 53*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 54*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 1*/ { "1", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 2*/ { "X", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 3*/ { "12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 4*/ { "19", 0, 0, },
|
||||
/* 5*/ { "X9", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 6*/ { "123", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 7*/ { "124", 0, 0, },
|
||||
/* 8*/ { "1X4", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 9*/ { "1234", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 10*/ { "1236", 0, 0, },
|
||||
/* 11*/ { "12X6", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 12*/ { "12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 13*/ { "12343", 0, 0, },
|
||||
/* 14*/ { "123X3", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 15*/ { "123456", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 16*/ { "123455", 0, 0, },
|
||||
/* 17*/ { "1234X5", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 18*/ { "1234567", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 19*/ { "1234560", 0, 0, },
|
||||
/* 20*/ { "12345X0", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 21*/ { "12345678", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 22*/ { "12345679", 0, 0 }, // 9 is correct check digit
|
||||
/* 23*/ { "98765434", 0, 0 }, // 4 is correct check digit
|
||||
/* 24*/ { "123456X9", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 25*/ { "123456789", 0, 0 },
|
||||
/* 26*/ { "340013817", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 27*/ { "340013818", 0, 0 }, // 8 is correct check digit
|
||||
/* 28*/ { "902888455", 0, 0 }, // 5 is correct check digit
|
||||
/* 29*/ { "9028884X5", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 30*/ { "0123456789", 0, 0 },
|
||||
/* 31*/ { "1234567890", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 32*/ { "123456789X", 0, 0 }, // X is correct check digit
|
||||
/* 33*/ { "123456789x", 0, 0 }, // x is correct check digit
|
||||
/* 34*/ { "8175257660", 0, 0 }, // 0 is correct check digit
|
||||
/* 35*/ { "0590764845", 0, 0 }, // 5 is correct check digit
|
||||
/* 36*/ { "0906495741", 0, 0 }, // 1 is correct check digit
|
||||
/* 37*/ { "0140430016", 0, 0 }, // 6 is correct check digit
|
||||
/* 38*/ { "0571086187", 0, 0 }, // 7 is correct check digit
|
||||
/* 39*/ { "0486600882", 0, 0 }, // 2 is correct check digit
|
||||
/* 40*/ { "04866008X2", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 41*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 42*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 43*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 44*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 45*/ { "1234567890123", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 46*/ { "9784567890123", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 47*/ { "9784567890120", 0, 0 }, // 0 is correct check digit
|
||||
/* 48*/ { "9783161484100", 0, 0 }, // 0 is correct check digit
|
||||
/* 49*/ { "9781846688225", 0, 0 }, // 5 is correct check digit
|
||||
/* 50*/ { "9781847657954", 0, 0 }, // 4 is correct check digit
|
||||
/* 51*/ { "9781846688188", 0, 0 }, // 8 is correct check digit
|
||||
/* 52*/ { "9781847659293", 0, 0 }, // 3 is correct check digit
|
||||
/* 53*/ { "97845678901201", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 54*/ { "978456789012012", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 55*/ { "3954994+12", 0, 0 },
|
||||
/* 56*/ { "3954994+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 57*/ { "39549X4+12", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 58*/ { "3954994+12345", 0, 0 },
|
||||
/* 59*/ { "3954994+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 60*/ { "39549X4+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 61*/ { "3954994+123456", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 62*/ { "3954994+", 0, 0 },
|
||||
/* 63*/ { "3954X94+", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 64*/ { "61954993+1", 0, 0 },
|
||||
/* 65*/ { "61954993+X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 66*/ { "619549X3+1", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 67*/ { "61954992+123", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 68*/ { "61954993+123", 0, 0 },
|
||||
/* 69*/ { "61954993+12X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 70*/ { "619549X3+123", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 71*/ { "361954990+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 72*/ { "361954999+12", 0, 0 },
|
||||
/* 73*/ { "361954999+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 74*/ { "3619549X9+12", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 75*/ { "361954999+1234", 0, 0 },
|
||||
/* 76*/ { "361954999+123X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 77*/ { "3619549X9+1234", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 78*/ { "1999000030+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 79*/ { "199900003X+12", 0, 0 },
|
||||
/* 80*/ { "199900003x+12", 0, 0 },
|
||||
/* 81*/ { "19990000XX+12", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 82*/ { "199900003X+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 83*/ { "1999000031+12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 84*/ { "199900003X+12345", 0, 0 },
|
||||
/* 85*/ { "199900003x+12345", 0, 0 },
|
||||
/* 86*/ { "199900003X+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 87*/ { "19990000XX+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 88*/ { "9791234567895+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 89*/ { "9791234567896+12", 0, 0 },
|
||||
/* 90*/ { "9791234567896+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 91*/ { "97912345678X6+12", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 92*/ { "9791234567897+12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 93*/ { "9791234567896+12345", 0, 0 },
|
||||
/* 94*/ { "9791234567896+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 95*/ { "979123456X896+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 96*/ { "9791234567892+", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||
/* 97*/ { "9791234567896+", 0, 0 },
|
||||
/* 98*/ { "97912345678X6+", ZINT_ERROR_INVALID_DATA, -1 },
|
||||
/* 99*/ { "97912345678961+", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/*100*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 },
|
||||
/*101*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#define SODIUM "0123456789+"
|
||||
#define ISBN_SANE "0123456789X"
|
||||
#define ISBN_CC_SANE "0123456789Xx+"
|
||||
#define ISBN_ADDON_SANE "0123456789Xx+"
|
||||
|
||||
#define EAN2 102
|
||||
#define EAN5 105
|
||||
@ -538,7 +538,7 @@ static int isbn(struct zint_symbol *symbol, unsigned char source[], const int sr
|
||||
to_upper(source);
|
||||
error_number = is_sane(ISBN_SANE, source, src_len);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
sprintf(symbol->errtxt, "277: Invalid characters in data (\"%s\" only)", ISBN_SANE);
|
||||
strcpy(symbol->errtxt, "277: Invalid character in data (digits and \"X\" only)");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -555,27 +555,40 @@ static int isbn(struct zint_symbol *symbol, unsigned char source[], const int sr
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
/* "X" can only occur in last position */
|
||||
error_number = is_sane(NEON, source, 12);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "277: Invalid character in data, \"X\" allowed in last position only");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
check_digit = gs1_check_digit(source, 12);
|
||||
if (source[src_len - 1] != check_digit) {
|
||||
sprintf(symbol->errtxt, "280: Incorrect ISBN check '%c', expecting '%c'",
|
||||
sprintf(symbol->errtxt, "280: Invalid ISBN check digit '%c', expecting '%c'",
|
||||
source[src_len - 1], check_digit);
|
||||
return ZINT_ERROR_INVALID_CHECK;
|
||||
}
|
||||
source[12] = '\0';
|
||||
}
|
||||
|
||||
if (src_len == 9) /* Using 9 digit SBN */ {
|
||||
/* Add leading zero */
|
||||
for (i = 10; i > 0; i--) {
|
||||
source[i] = source[i - 1];
|
||||
} else { /* Using 10 digit ISBN or 9 digit SBN padded with leading zero */
|
||||
if (src_len == 9) /* Using 9 digit SBN */ {
|
||||
/* Add leading zero */
|
||||
for (i = 10; i > 0; i--) {
|
||||
source[i] = source[i - 1];
|
||||
}
|
||||
source[0] = '0';
|
||||
}
|
||||
|
||||
/* "X" can only occur in last position */
|
||||
error_number = is_sane(NEON, source, 9);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "277: Invalid character in data, \"X\" allowed in last position only");
|
||||
return error_number;
|
||||
}
|
||||
source[0] = '0';
|
||||
}
|
||||
|
||||
if (src_len == 9 || src_len == 10) /* Using 10 digit ISBN or 9 digit SBN padded with leading zero */ {
|
||||
check_digit = isbn_check(source, 9);
|
||||
if (check_digit != source[9]) {
|
||||
sprintf(symbol->errtxt, "281: Incorrect %s check '%c', expecting '%c'", src_len == 9 ? "SBN" : "ISBN",
|
||||
sprintf(symbol->errtxt, "281: Invalid %s check digit '%c', expecting '%c'", src_len == 9 ? "SBN" : "ISBN",
|
||||
source[9], check_digit);
|
||||
return ZINT_ERROR_INVALID_CHECK;
|
||||
}
|
||||
@ -611,6 +624,9 @@ INTERNAL int ean_leading_zeroes(struct zint_symbol *symbol, const unsigned char
|
||||
}
|
||||
}
|
||||
if (first_len > 13 || second_len > 5) {
|
||||
if (p_with_addon) {
|
||||
*p_with_addon = second_len > 5 ? with_addon : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -747,22 +763,23 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
writer = 0;
|
||||
|
||||
if (src_len > 19) {
|
||||
strcpy(symbol->errtxt, "283: Input too long"); // TODO: Better error message
|
||||
strcpy(symbol->errtxt, "283: Input too long (19 character maximum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
if (symbol->symbology != BARCODE_ISBNX) {
|
||||
/* ISBN has its own checking routine */
|
||||
/* ISBN has its own sanity routine */
|
||||
error_number = is_sane(SODIUM, source, src_len);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
sprintf(symbol->errtxt, "284: Invalid characters in data (\"%s\" only)", SODIUM);
|
||||
strcpy(symbol->errtxt, "284: Invalid character in data (digits and \"+\" only)");
|
||||
return error_number;
|
||||
}
|
||||
} else {
|
||||
error_number = is_sane(ISBN_CC_SANE, source, src_len);
|
||||
error_number = is_sane(ISBN_ADDON_SANE, source, src_len);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
sprintf(symbol->errtxt, "285: Invalid characters in data (\"%s\" only)", ISBN_CC_SANE);
|
||||
strcpy(symbol->errtxt, "285: Invalid character in data (digits, \"X\" and \"+\" only)");
|
||||
return error_number;
|
||||
}
|
||||
/* Add-on will be checked separately to be numeric only below */
|
||||
}
|
||||
|
||||
/* Check for multiple '+' characters */
|
||||
@ -779,7 +796,8 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
|
||||
/* Add leading zeroes, checking max lengths of parts */
|
||||
if (!ean_leading_zeroes(symbol, source, local_source, &with_addon)) {
|
||||
strcpy(symbol->errtxt, "294: Input too long"); // TODO: Better error message
|
||||
sprintf(symbol->errtxt, "294: Input too long (%s)",
|
||||
with_addon ? "5 character maximum for add-on" : "13 character maximum");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -849,7 +867,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
case 12:
|
||||
case 13: error_number = ean13(symbol, first_part, first_part_len, dest);
|
||||
break;
|
||||
default: strcpy(symbol->errtxt, "286: Input wrong length"); // TODO: Better error message
|
||||
default: strcpy(symbol->errtxt, "286: Input wrong length (2, 5, 7, 8, 12 or 13 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
break;
|
||||
@ -880,7 +898,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
symbol->rows += 3;
|
||||
error_number = ean13_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
||||
break;
|
||||
default: strcpy(symbol->errtxt, "287: Input wrong length"); // TODO: Better error message
|
||||
default: strcpy(symbol->errtxt, "287: Input wrong length (6, 12 or 13 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
break;
|
||||
@ -889,7 +907,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
if ((first_part_len == 11) || (first_part_len == 12)) {
|
||||
error_number = upca(symbol, first_part, first_part_len, dest);
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "288: Input wrong length"); // TODO: Better error message
|
||||
strcpy(symbol->errtxt, "288: Input wrong length (11 or 12 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
break;
|
||||
@ -907,7 +925,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
symbol->rows += 3;
|
||||
error_number = upca_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "289: Input wrong length"); // TODO: Better error message
|
||||
strcpy(symbol->errtxt, "289: Input wrong length (11 or 12 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
break;
|
||||
@ -916,7 +934,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
if ((first_part_len >= 6) && (first_part_len <= (symbol->symbology == BARCODE_UPCE ? 7 : 8))) {
|
||||
error_number = upce(symbol, first_part, first_part_len, dest);
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "290: Input wrong length"); // TODO: Better error message
|
||||
strcpy(symbol->errtxt, "290: Input wrong length (7 or 8 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
break;
|
||||
@ -934,7 +952,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
symbol->rows += 3;
|
||||
error_number = upce_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "291: Input wrong length"); // TODO: Better error message
|
||||
strcpy(symbol->errtxt, "291: Input wrong length (7 or 8 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
break;
|
||||
@ -949,6 +967,14 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
|
||||
second_part_len = (int) ustrlen(second_part);
|
||||
|
||||
if (symbol->symbology == BARCODE_ISBNX) { /* Need to further check that add-on numeric only */
|
||||
error_number = is_sane(NEON, second_part, second_part_len);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "295: Invalid add-on data (digits only)");
|
||||
return error_number;
|
||||
}
|
||||
}
|
||||
|
||||
switch (second_part_len) {
|
||||
case 0: break;
|
||||
case 2:
|
||||
@ -962,7 +988,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
||||
ustrcat(symbol->text, second_part);
|
||||
break;
|
||||
default:
|
||||
strcpy(symbol->errtxt, "292: Add-on input wrong length"); // TODO: Better error message
|
||||
strcpy(symbol->errtxt, "292: Add-on data wrong length (2 or 5 characters only)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
|
491
backend/zint.h
491
backend/zint.h
@ -29,6 +29,10 @@
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
/*
|
||||
* For version, see "zintconfig.h"
|
||||
* For documentation, see "../docs/manual.txt"
|
||||
*/
|
||||
|
||||
#ifndef ZINT_H
|
||||
#define ZINT_H
|
||||
@ -39,271 +43,276 @@ extern "C" {
|
||||
|
||||
struct zint_vector_rect {
|
||||
float x, y, height, width;
|
||||
int colour;
|
||||
int colour; /* -1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White */
|
||||
struct zint_vector_rect *next;
|
||||
};
|
||||
|
||||
struct zint_vector_string {
|
||||
float x, y, fsize;
|
||||
float width; /* Suggested string width, may be 0 if none recommended */
|
||||
int length;
|
||||
int rotation;
|
||||
int halign; /* Horizontal alignment: 0 for centre (middle), 1 for left (start), 2 for right (end) */
|
||||
unsigned char *text;
|
||||
struct zint_vector_string *next; /* Pointer to next character */
|
||||
};
|
||||
|
||||
struct zint_vector_circle {
|
||||
float x, y, diameter;
|
||||
int colour; /* Non-zero for draw with background colour */
|
||||
struct zint_vector_circle *next; /* Pointer to next circle */
|
||||
};
|
||||
|
||||
struct zint_vector_hexagon {
|
||||
float x, y, diameter;
|
||||
int rotation;
|
||||
int rotation; /* 0, 90, 180, 270 degrees */
|
||||
struct zint_vector_hexagon *next; /* Pointer to next hexagon */
|
||||
};
|
||||
|
||||
struct zint_vector_string {
|
||||
float x, y, fsize; /* x, y position relative to halign; font size */
|
||||
float width; /* Suggested string width, may be 0 if none recommended */
|
||||
int length; /* Number of characters */
|
||||
int rotation; /* 0, 90, 180, 270 degrees */
|
||||
int halign; /* Horizontal alignment: 0 for centre, 1 for left, 2 for right (end) */
|
||||
unsigned char *text;
|
||||
struct zint_vector_string *next; /* Pointer to next string */
|
||||
};
|
||||
|
||||
struct zint_vector_circle {
|
||||
float x, y, diameter;
|
||||
int colour; /* Non-zero for draw with background colour */
|
||||
struct zint_vector_circle *next; /* Pointer to next circle */
|
||||
};
|
||||
|
||||
/* Vector header */
|
||||
struct zint_vector {
|
||||
float width, height;
|
||||
float width, height; /* Width, height of barcode image (including text, whitespace) */
|
||||
struct zint_vector_rect *rectangles; /* Pointer to first rectangle */
|
||||
struct zint_vector_hexagon *hexagons; /* Pointer to first hexagon */
|
||||
struct zint_vector_string *strings; /* Points to first string */
|
||||
struct zint_vector_circle *circles; /* Points to first circle */
|
||||
struct zint_vector_string *strings; /* Pointer to first string */
|
||||
struct zint_vector_circle *circles; /* Pointer to first circle */
|
||||
};
|
||||
|
||||
/* Main symbol structure */
|
||||
struct zint_symbol {
|
||||
int symbology;
|
||||
float height; /* Height in X-dims (ignored for fixed-width barcodes) */
|
||||
int whitespace_width; /* Width in X-dims of whitespace to left/right of barcode */
|
||||
int whitespace_height; /* Height in X-dims of whitespace above and below the barcode */
|
||||
int border_width; /* Size of border in X-dims */
|
||||
int output_options;
|
||||
char fgcolour[10]; /* Foreground as RGB/RGBA hexadecimal string */
|
||||
char bgcolour[10]; /* Background as RGB/RGBA hexadecimal string */
|
||||
char *fgcolor; /* Pointer to fgcolour */
|
||||
char *bgcolor; /* Pointer to bgcolour */
|
||||
char outfile[256];
|
||||
float scale;
|
||||
int option_1;
|
||||
int option_2;
|
||||
int option_3;
|
||||
int show_hrt;
|
||||
int fontsize;
|
||||
int input_mode;
|
||||
int eci;
|
||||
unsigned char text[128]; /* UTF-8 */
|
||||
int rows;
|
||||
int width;
|
||||
char primary[128];
|
||||
unsigned char encoded_data[200][143];
|
||||
float row_height[200]; /* Allow for 200 row DotCode */
|
||||
char errtxt[100];
|
||||
unsigned char *bitmap;
|
||||
int bitmap_width;
|
||||
int bitmap_height;
|
||||
unsigned char *alphamap;
|
||||
unsigned int bitmap_byte_length;
|
||||
float dot_size;
|
||||
struct zint_vector *vector;
|
||||
int debug;
|
||||
int warn_level;
|
||||
int symbology; /* Symbol to use (see BARCODE_XXX below) */
|
||||
float height; /* Height in X-dimensions (ignored for fixed-width barcodes) */
|
||||
int whitespace_width; /* Width in X-dimensions of whitespace to left & right of barcode */
|
||||
int whitespace_height; /* Height in X-dimensions of whitespace above & below the barcode */
|
||||
int border_width; /* Size of border in X-dimensions */
|
||||
int output_options; /* Various output parameters (bind, box etc, see below) */
|
||||
char fgcolour[10]; /* Foreground as RGB/RGBA hexadecimal string, 6 or 8 characters */
|
||||
char bgcolour[10]; /* Background as RGB/RGBA hexadecimal string, 6 or 8 characters */
|
||||
char *fgcolor; /* Pointer to fgcolour (alternate spelling) */
|
||||
char *bgcolor; /* Pointer to bgcolour (alternate spelling) */
|
||||
char outfile[256]; /* Name of file to output to. Default "out.png" ("out.gif" if NO_PNG) */
|
||||
float scale; /* Scale factor when printing barcode */
|
||||
int option_1; /* Symbol-specific options (see "../docs/manual.txt") */
|
||||
int option_2; /* Symbol-specific options */
|
||||
int option_3; /* Symbol-specific options */
|
||||
int show_hrt; /* Show (1) or hide (0) Human Readable Text. Default 1 */
|
||||
int fontsize; /* Unused */
|
||||
int input_mode; /* Encoding of input data (see DATA_MODE etc below). Default DATA_MODE */
|
||||
int eci; /* Extended Channel Interpretation. Default 0 (none) */
|
||||
unsigned char text[128]; /* Human Readable Text (if any), UTF-8 */
|
||||
int rows; /* Number of rows used by the symbol (output only) */
|
||||
int width; /* Width of the generated symbol (output only) */
|
||||
char primary[128]; /* Primary message data (MaxiCode, Composite) */
|
||||
unsigned char encoded_data[200][143]; /* Encoded data (output only). Allows for rows of 1144 modules */
|
||||
float row_height[200]; /* Heights of rows (output only). Allows for 200 row DotCode */
|
||||
char errtxt[100]; /* Error message if an error or warning occurs (output only) */
|
||||
unsigned char *bitmap; /* Stored bitmap image (raster output only) */
|
||||
int bitmap_width; /* Width of bitmap image (raster output only) */
|
||||
int bitmap_height; /* Height of bitmap image (raster output only) */
|
||||
unsigned char *alphamap; /* Array of alpha values used (raster output only) */
|
||||
unsigned int bitmap_byte_length; /* Size of BMP bitmap data (raster output only) */
|
||||
float dot_size; /* Size of dots used in BARCODE_DOTTY_MODE */
|
||||
struct zint_vector *vector; /* Pointer to vector header (vector output only) */
|
||||
int debug; /* Debugging flags */
|
||||
int warn_level; /* Affects error/warning value returned by Zint API (see WARN_XXX below) */
|
||||
};
|
||||
|
||||
// Symbologies (symbology)
|
||||
/* Symbologies (`symbol->symbology`) */
|
||||
/* Tbarcode 7 codes */
|
||||
#define BARCODE_CODE11 1
|
||||
#define BARCODE_C25STANDARD 2
|
||||
#define BARCODE_C25MATRIX 2 // Legacy
|
||||
#define BARCODE_C25INTER 3
|
||||
#define BARCODE_C25IATA 4
|
||||
#define BARCODE_C25LOGIC 6
|
||||
#define BARCODE_C25IND 7
|
||||
#define BARCODE_CODE39 8
|
||||
#define BARCODE_EXCODE39 9
|
||||
#define BARCODE_EANX 13
|
||||
#define BARCODE_EANX_CHK 14
|
||||
#define BARCODE_GS1_128 16
|
||||
#define BARCODE_EAN128 16 // Legacy
|
||||
#define BARCODE_CODABAR 18
|
||||
#define BARCODE_CODE128 20
|
||||
#define BARCODE_DPLEIT 21
|
||||
#define BARCODE_DPIDENT 22
|
||||
#define BARCODE_CODE16K 23
|
||||
#define BARCODE_CODE49 24
|
||||
#define BARCODE_CODE93 25
|
||||
#define BARCODE_FLAT 28
|
||||
#define BARCODE_DBAR_OMN 29
|
||||
#define BARCODE_RSS14 29 // Legacy
|
||||
#define BARCODE_DBAR_LTD 30
|
||||
#define BARCODE_RSS_LTD 30 // Legacy
|
||||
#define BARCODE_DBAR_EXP 31
|
||||
#define BARCODE_RSS_EXP 31 // Legacy
|
||||
#define BARCODE_TELEPEN 32
|
||||
#define BARCODE_UPCA 34
|
||||
#define BARCODE_UPCA_CHK 35
|
||||
#define BARCODE_UPCE 37
|
||||
#define BARCODE_UPCE_CHK 38
|
||||
#define BARCODE_POSTNET 40
|
||||
#define BARCODE_MSI_PLESSEY 47
|
||||
#define BARCODE_FIM 49
|
||||
#define BARCODE_LOGMARS 50
|
||||
#define BARCODE_PHARMA 51
|
||||
#define BARCODE_PZN 52
|
||||
#define BARCODE_PHARMA_TWO 53
|
||||
#define BARCODE_PDF417 55
|
||||
#define BARCODE_PDF417COMP 56
|
||||
#define BARCODE_PDF417TRUNC 56 // Legacy
|
||||
#define BARCODE_MAXICODE 57
|
||||
#define BARCODE_QRCODE 58
|
||||
#define BARCODE_CODE128B 60
|
||||
#define BARCODE_AUSPOST 63
|
||||
#define BARCODE_AUSREPLY 66
|
||||
#define BARCODE_AUSROUTE 67
|
||||
#define BARCODE_AUSREDIRECT 68
|
||||
#define BARCODE_ISBNX 69
|
||||
#define BARCODE_RM4SCC 70
|
||||
#define BARCODE_DATAMATRIX 71
|
||||
#define BARCODE_EAN14 72
|
||||
#define BARCODE_VIN 73
|
||||
#define BARCODE_CODABLOCKF 74
|
||||
#define BARCODE_NVE18 75
|
||||
#define BARCODE_JAPANPOST 76
|
||||
#define BARCODE_KOREAPOST 77
|
||||
#define BARCODE_DBAR_STK 79
|
||||
#define BARCODE_RSS14STACK 79 // Legacy
|
||||
#define BARCODE_DBAR_OMNSTK 80
|
||||
#define BARCODE_RSS14STACK_OMNI 80 // Legacy
|
||||
#define BARCODE_DBAR_EXPSTK 81
|
||||
#define BARCODE_RSS_EXPSTACK 81 // Legacy
|
||||
#define BARCODE_PLANET 82
|
||||
#define BARCODE_MICROPDF417 84
|
||||
#define BARCODE_USPS_IMAIL 85
|
||||
#define BARCODE_ONECODE 85 // Legacy
|
||||
#define BARCODE_PLESSEY 86
|
||||
#define BARCODE_CODE11 1 /* Code 11 */
|
||||
#define BARCODE_C25STANDARD 2 /* 2 of 5 Standard (Matrix) */
|
||||
#define BARCODE_C25MATRIX 2 /* Legacy */
|
||||
#define BARCODE_C25INTER 3 /* 2 of 5 Interleaved */
|
||||
#define BARCODE_C25IATA 4 /* 2 of 5 IATA */
|
||||
#define BARCODE_C25LOGIC 6 /* 2 of 5 Data Logic */
|
||||
#define BARCODE_C25IND 7 /* 2 of 5 Industrial */
|
||||
#define BARCODE_CODE39 8 /* Code 39 */
|
||||
#define BARCODE_EXCODE39 9 /* Extended Code 39 */
|
||||
#define BARCODE_EANX 13 /* EAN (European Article Number) */
|
||||
#define BARCODE_EANX_CHK 14 /* EAN + Check Digit */
|
||||
#define BARCODE_GS1_128 16 /* GS1-128 */
|
||||
#define BARCODE_EAN128 16 /* Legacy */
|
||||
#define BARCODE_CODABAR 18 /* Codabar */
|
||||
#define BARCODE_CODE128 20 /* Code 128 */
|
||||
#define BARCODE_DPLEIT 21 /* Deutsche Post Leitcode */
|
||||
#define BARCODE_DPIDENT 22 /* Deutsche Post Identcode */
|
||||
#define BARCODE_CODE16K 23 /* Code 16k */
|
||||
#define BARCODE_CODE49 24 /* Code 49 */
|
||||
#define BARCODE_CODE93 25 /* Code 93 */
|
||||
#define BARCODE_FLAT 28 /* Flattermarken */
|
||||
#define BARCODE_DBAR_OMN 29 /* GS1 DataBar Omnidirectional */
|
||||
#define BARCODE_RSS14 29 /* Legacy */
|
||||
#define BARCODE_DBAR_LTD 30 /* GS1 DataBar Limited */
|
||||
#define BARCODE_RSS_LTD 30 /* Legacy */
|
||||
#define BARCODE_DBAR_EXP 31 /* GS1 DataBar Expanded */
|
||||
#define BARCODE_RSS_EXP 31 /* Legacy */
|
||||
#define BARCODE_TELEPEN 32 /* Telepen Alpha */
|
||||
#define BARCODE_UPCA 34 /* UPC-A */
|
||||
#define BARCODE_UPCA_CHK 35 /* UPC-A + Check Digit */
|
||||
#define BARCODE_UPCE 37 /* UPC-E */
|
||||
#define BARCODE_UPCE_CHK 38 /* UPC-E + Check Digit */
|
||||
#define BARCODE_POSTNET 40 /* USPS POSTNET */
|
||||
#define BARCODE_MSI_PLESSEY 47 /* MSI Plessey */
|
||||
#define BARCODE_FIM 49 /* Facing Identification Mark */
|
||||
#define BARCODE_LOGMARS 50 /* LOGMARS */
|
||||
#define BARCODE_PHARMA 51 /* Pharmacode One-Track */
|
||||
#define BARCODE_PZN 52 /* Pharmazentralnummer */
|
||||
#define BARCODE_PHARMA_TWO 53 /* Pharmacode Two-Track */
|
||||
#define BARCODE_PDF417 55 /* PDF417 */
|
||||
#define BARCODE_PDF417COMP 56 /* Compact PDF417 (Truncated PDF417) */
|
||||
#define BARCODE_PDF417TRUNC 56 /* Legacy */
|
||||
#define BARCODE_MAXICODE 57 /* MaxiCode */
|
||||
#define BARCODE_QRCODE 58 /* QR Code */
|
||||
#define BARCODE_CODE128B 60 /* Code 128 (Subset B) */
|
||||
#define BARCODE_AUSPOST 63 /* Australia Post Standard Customer */
|
||||
#define BARCODE_AUSREPLY 66 /* Australia Post Reply Paid */
|
||||
#define BARCODE_AUSROUTE 67 /* Australia Post Routing */
|
||||
#define BARCODE_AUSREDIRECT 68 /* Australia Post Redirection */
|
||||
#define BARCODE_ISBNX 69 /* ISBN */
|
||||
#define BARCODE_RM4SCC 70 /* Royal Mail 4 State */
|
||||
#define BARCODE_DATAMATRIX 71 /* Data Matrix (ECC200) */
|
||||
#define BARCODE_EAN14 72 /* EAN-14 */
|
||||
#define BARCODE_VIN 73 /* Vehicle Identification Number */
|
||||
#define BARCODE_CODABLOCKF 74 /* Codablock-F */
|
||||
#define BARCODE_NVE18 75 /* NVE-18 (SSCC-18) */
|
||||
#define BARCODE_JAPANPOST 76 /* Japanese Postal Code */
|
||||
#define BARCODE_KOREAPOST 77 /* Korea Post */
|
||||
#define BARCODE_DBAR_STK 79 /* GS1 DataBar Stacked */
|
||||
#define BARCODE_RSS14STACK 79 /* Legacy */
|
||||
#define BARCODE_DBAR_OMNSTK 80 /* GS1 DataBar Stacked Omnidirectional */
|
||||
#define BARCODE_RSS14STACK_OMNI 80 /* Legacy */
|
||||
#define BARCODE_DBAR_EXPSTK 81 /* GS1 DataBar Expanded Stacked */
|
||||
#define BARCODE_RSS_EXPSTACK 81 /* Legacy */
|
||||
#define BARCODE_PLANET 82 /* USPS PLANET */
|
||||
#define BARCODE_MICROPDF417 84 /* MicroPDF417 */
|
||||
#define BARCODE_USPS_IMAIL 85 /* USPS Intelligent Mail (OneCode) */
|
||||
#define BARCODE_ONECODE 85 /* Legacy */
|
||||
#define BARCODE_PLESSEY 86 /* Plessey Code */
|
||||
|
||||
/* Tbarcode 8 codes */
|
||||
#define BARCODE_TELEPEN_NUM 87
|
||||
#define BARCODE_ITF14 89
|
||||
#define BARCODE_KIX 90
|
||||
#define BARCODE_AZTEC 92
|
||||
#define BARCODE_DAFT 93
|
||||
#define BARCODE_DPD 96
|
||||
#define BARCODE_MICROQR 97
|
||||
#define BARCODE_TELEPEN_NUM 87 /* Telepen Numeric */
|
||||
#define BARCODE_ITF14 89 /* ITF-14 */
|
||||
#define BARCODE_KIX 90 /* Dutch Post KIX Code */
|
||||
#define BARCODE_AZTEC 92 /* Aztec Code */
|
||||
#define BARCODE_DAFT 93 /* DAFT Code */
|
||||
#define BARCODE_DPD 96 /* DPD Code */
|
||||
#define BARCODE_MICROQR 97 /* Micro QR Code */
|
||||
|
||||
/* Tbarcode 9 codes */
|
||||
#define BARCODE_HIBC_128 98
|
||||
#define BARCODE_HIBC_39 99
|
||||
#define BARCODE_HIBC_DM 102
|
||||
#define BARCODE_HIBC_QR 104
|
||||
#define BARCODE_HIBC_PDF 106
|
||||
#define BARCODE_HIBC_MICPDF 108
|
||||
#define BARCODE_HIBC_BLOCKF 110
|
||||
#define BARCODE_HIBC_AZTEC 112
|
||||
#define BARCODE_HIBC_128 98 /* HIBC Code 128 */
|
||||
#define BARCODE_HIBC_39 99 /* HIBC Code 39 */
|
||||
#define BARCODE_HIBC_DM 102 /* HIBC Data Matrix */
|
||||
#define BARCODE_HIBC_QR 104 /* HIBC QR Code */
|
||||
#define BARCODE_HIBC_PDF 106 /* HIBC PDF417 */
|
||||
#define BARCODE_HIBC_MICPDF 108 /* HIBC MicroPDF417 */
|
||||
#define BARCODE_HIBC_BLOCKF 110 /* HIBC Codablock-F */
|
||||
#define BARCODE_HIBC_AZTEC 112 /* HIBC Aztec Code */
|
||||
|
||||
/* Tbarcode 10 codes */
|
||||
#define BARCODE_DOTCODE 115
|
||||
#define BARCODE_HANXIN 116
|
||||
#define BARCODE_DOTCODE 115 /* DotCode */
|
||||
#define BARCODE_HANXIN 116 /* Han Xin (Chinese Sensible) Code */
|
||||
|
||||
/*Tbarcode 11 codes*/
|
||||
#define BARCODE_MAILMARK 121
|
||||
/* Tbarcode 11 codes */
|
||||
#define BARCODE_MAILMARK 121 /* Royal Mail 4-state Mailmark */
|
||||
|
||||
/* Zint specific */
|
||||
#define BARCODE_AZRUNE 128
|
||||
#define BARCODE_CODE32 129
|
||||
#define BARCODE_EANX_CC 130
|
||||
#define BARCODE_GS1_128_CC 131
|
||||
#define BARCODE_EAN128_CC 131 // Legacy
|
||||
#define BARCODE_DBAR_OMN_CC 132
|
||||
#define BARCODE_RSS14_CC 132 // Legacy
|
||||
#define BARCODE_DBAR_LTD_CC 133
|
||||
#define BARCODE_RSS_LTD_CC 133 // Legacy
|
||||
#define BARCODE_DBAR_EXP_CC 134
|
||||
#define BARCODE_RSS_EXP_CC 134 // Legacy
|
||||
#define BARCODE_UPCA_CC 135
|
||||
#define BARCODE_UPCE_CC 136
|
||||
#define BARCODE_DBAR_STK_CC 137
|
||||
#define BARCODE_RSS14STACK_CC 137 // Legacy
|
||||
#define BARCODE_DBAR_OMNSTK_CC 138
|
||||
#define BARCODE_RSS14_OMNI_CC 138 // Legacy
|
||||
#define BARCODE_DBAR_EXPSTK_CC 139
|
||||
#define BARCODE_RSS_EXPSTACK_CC 139 // Legacy
|
||||
#define BARCODE_CHANNEL 140
|
||||
#define BARCODE_CODEONE 141
|
||||
#define BARCODE_GRIDMATRIX 142
|
||||
#define BARCODE_UPNQR 143
|
||||
#define BARCODE_ULTRA 144
|
||||
#define BARCODE_RMQR 145
|
||||
#define BARCODE_AZRUNE 128 /* Aztec Runes */
|
||||
#define BARCODE_CODE32 129 /* Code 32 */
|
||||
#define BARCODE_EANX_CC 130 /* EAN Composite */
|
||||
#define BARCODE_GS1_128_CC 131 /* GS1-128 Composite */
|
||||
#define BARCODE_EAN128_CC 131 /* Legacy */
|
||||
#define BARCODE_DBAR_OMN_CC 132 /* GS1 DataBar Omnidirectional Composite */
|
||||
#define BARCODE_RSS14_CC 132 /* Legacy */
|
||||
#define BARCODE_DBAR_LTD_CC 133 /* GS1 DataBar Limited Composite */
|
||||
#define BARCODE_RSS_LTD_CC 133 /* Legacy */
|
||||
#define BARCODE_DBAR_EXP_CC 134 /* GS1 DataBar Expanded Composite */
|
||||
#define BARCODE_RSS_EXP_CC 134 /* Legacy */
|
||||
#define BARCODE_UPCA_CC 135 /* UPC-A Composite */
|
||||
#define BARCODE_UPCE_CC 136 /* UPC-E Composite */
|
||||
#define BARCODE_DBAR_STK_CC 137 /* GS1 DataBar Stacked Composite */
|
||||
#define BARCODE_RSS14STACK_CC 137 /* Legacy */
|
||||
#define BARCODE_DBAR_OMNSTK_CC 138 /* GS1 DataBar Stacked Omnidirectional Composite */
|
||||
#define BARCODE_RSS14_OMNI_CC 138 /* Legacy */
|
||||
#define BARCODE_DBAR_EXPSTK_CC 139 /* GS1 DataBar Expanded Stacked Composite */
|
||||
#define BARCODE_RSS_EXPSTACK_CC 139 /* Legacy */
|
||||
#define BARCODE_CHANNEL 140 /* Channel Code */
|
||||
#define BARCODE_CODEONE 141 /* Code One */
|
||||
#define BARCODE_GRIDMATRIX 142 /* Grid Matrix */
|
||||
#define BARCODE_UPNQR 143 /* UPNQR (Univerzalnega Plačilnega Naloga QR) */
|
||||
#define BARCODE_ULTRA 144 /* Ultracode */
|
||||
#define BARCODE_RMQR 145 /* Rectangular Micro QR Code (rMQR) */
|
||||
|
||||
// Output options (output_options)
|
||||
#define BARCODE_NO_ASCII 1
|
||||
#define BARCODE_BIND 2
|
||||
#define BARCODE_BOX 4
|
||||
#define BARCODE_STDOUT 8
|
||||
#define READER_INIT 16
|
||||
#define SMALL_TEXT 32
|
||||
#define BOLD_TEXT 64
|
||||
#define CMYK_COLOUR 128
|
||||
#define BARCODE_DOTTY_MODE 256
|
||||
#define GS1_GS_SEPARATOR 512
|
||||
#define OUT_BUFFER_INTERMEDIATE 1024
|
||||
/* Output options (`symbol->output_options`) */
|
||||
#define BARCODE_NO_ASCII 1 /* Legacy (no-op) */
|
||||
#define BARCODE_BIND 2 /* Boundary bars above & below the symbol and between stacked symbols */
|
||||
#define BARCODE_BOX 4 /* Box around symbol */
|
||||
#define BARCODE_STDOUT 8 /* Output to stdout */
|
||||
#define READER_INIT 16 /* Reader Initialisation (Programming) */
|
||||
#define SMALL_TEXT 32 /* Use smaller font */
|
||||
#define BOLD_TEXT 64 /* Use bold font */
|
||||
#define CMYK_COLOUR 128 /* CMYK colour space (Encapsulated PostScript and TIF) */
|
||||
#define BARCODE_DOTTY_MODE 256 /* Plot a matrix symbol using dots rather than squares */
|
||||
#define GS1_GS_SEPARATOR 512 /* Use GS instead of FNC1 as GS1 separator (Data Matrix) */
|
||||
#define OUT_BUFFER_INTERMEDIATE 1024 /* Return ASCII values in bitmap buffer (OUT_BUFFER only) */
|
||||
|
||||
// Input data types (input_mode)
|
||||
#define DATA_MODE 0
|
||||
#define UNICODE_MODE 1
|
||||
#define GS1_MODE 2
|
||||
#define ESCAPE_MODE 8
|
||||
#define GS1PARENS_MODE 16
|
||||
/* Input data types (`symbol->input_mode`) */
|
||||
#define DATA_MODE 0 /* Binary */
|
||||
#define UNICODE_MODE 1 /* UTF-8 */
|
||||
#define GS1_MODE 2 /* GS1 */
|
||||
/* The following may be OR-ed with above */
|
||||
#define ESCAPE_MODE 8 /* Process escape sequences */
|
||||
#define GS1PARENS_MODE 16 /* Process parentheses as GS1 AI delimiters (instead of square brackets) */
|
||||
|
||||
// Data Matrix specific options (option_3)
|
||||
#define DM_SQUARE 100
|
||||
#define DM_DMRE 101
|
||||
/* Data Matrix specific options (`symbol->option_3`) */
|
||||
#define DM_SQUARE 100 /* Only consider square versions on automatic symbol size selection */
|
||||
#define DM_DMRE 101 /* Consider DMRE versions on automatic symbol size selection */
|
||||
|
||||
// QR, Han Xin, Grid Matrix specific options (option_3)
|
||||
#define ZINT_FULL_MULTIBYTE 200
|
||||
/* QR, Han Xin, Grid Matrix specific options (`symbol->option_3`) */
|
||||
#define ZINT_FULL_MULTIBYTE 200 /* Enable Kanji/Hanzi compression for Latin-1 & binary data */
|
||||
|
||||
// Ultracode specific option (option_3)
|
||||
#define ULTRA_COMPRESSION 128
|
||||
/* Ultracode specific option (`symbol->option_3`) */
|
||||
#define ULTRA_COMPRESSION 128 /* Enable Ultracode compression (experimental) */
|
||||
|
||||
// Warning and error conditions (return values)
|
||||
#define ZINT_WARN_INVALID_OPTION 2
|
||||
#define ZINT_WARN_USES_ECI 3
|
||||
#define ZINT_WARN_NONCOMPLIANT 4
|
||||
#define ZINT_ERROR 5 /* Warn/error marker, not returned */
|
||||
#define ZINT_ERROR_TOO_LONG 5
|
||||
#define ZINT_ERROR_INVALID_DATA 6
|
||||
#define ZINT_ERROR_INVALID_CHECK 7
|
||||
#define ZINT_ERROR_INVALID_OPTION 8
|
||||
#define ZINT_ERROR_ENCODING_PROBLEM 9
|
||||
#define ZINT_ERROR_FILE_ACCESS 10
|
||||
#define ZINT_ERROR_MEMORY 11
|
||||
#define ZINT_ERROR_FILE_WRITE 12
|
||||
/* Warning and error conditions (API return values) */
|
||||
#define ZINT_WARN_INVALID_OPTION 2 /* Invalid option given but overridden by Zint */
|
||||
#define ZINT_WARN_USES_ECI 3 /* Automatic ECI inserted by Zint */
|
||||
#define ZINT_WARN_NONCOMPLIANT 4 /* Symbol created not compliant with standards */
|
||||
#define ZINT_ERROR 5 /* Warn/error marker, not returned */
|
||||
#define ZINT_ERROR_TOO_LONG 5 /* Input data wrong length */
|
||||
#define ZINT_ERROR_INVALID_DATA 6 /* Input data incorrect */
|
||||
#define ZINT_ERROR_INVALID_CHECK 7 /* Input check digit incorrect */
|
||||
#define ZINT_ERROR_INVALID_OPTION 8 /* Incorrect option given */
|
||||
#define ZINT_ERROR_ENCODING_PROBLEM 9 /* Internal error (should not happen) */
|
||||
#define ZINT_ERROR_FILE_ACCESS 10 /* Error opening output file */
|
||||
#define ZINT_ERROR_MEMORY 11 /* Memory allocation (malloc) failure */
|
||||
#define ZINT_ERROR_FILE_WRITE 12 /* Error writing to output file */
|
||||
#define ZINT_ERROR_USES_ECI 13 /* Error counterpart of warning if WARN_FAIL_ALL set (see below) */
|
||||
#define ZINT_ERROR_NONCOMPLIANT 14 /* Error counterpart of warning if WARN_FAIL_ALL set */
|
||||
|
||||
// Warning warn (warn_level)
|
||||
#define WARN_DEFAULT 0
|
||||
#define WARN_ZPL_COMPAT 1
|
||||
#define WARN_FAIL_ALL 2
|
||||
/* Warning warn (`symbol->warn_level`) */
|
||||
#define WARN_DEFAULT 0 /* Default behaviour */
|
||||
#define WARN_ZPL_COMPAT 1 /* ZPL compatible behaviour */
|
||||
#define WARN_FAIL_ALL 2 /* Treat warning as error */
|
||||
|
||||
// Capability flags (cap_flag)
|
||||
#define ZINT_CAP_HRT 0x0001
|
||||
#define ZINT_CAP_STACKABLE 0x0002
|
||||
#define ZINT_CAP_EXTENDABLE 0x0004
|
||||
#define ZINT_CAP_COMPOSITE 0x0008
|
||||
#define ZINT_CAP_ECI 0x0010
|
||||
#define ZINT_CAP_GS1 0x0020
|
||||
#define ZINT_CAP_DOTTY 0x0040
|
||||
#define ZINT_CAP_FIXED_RATIO 0x0100 /* Aspect ratio */
|
||||
#define ZINT_CAP_READER_INIT 0x0200
|
||||
#define ZINT_CAP_FULL_MULTIBYTE 0x0400
|
||||
#define ZINT_CAP_MASK 0x0800
|
||||
/* Capability flags (ZBarcode_Cap() `cap_flag`) */
|
||||
#define ZINT_CAP_HRT 0x0001 /* Prints Human Readable Text? */
|
||||
#define ZINT_CAP_STACKABLE 0x0002 /* Is stackable? */
|
||||
#define ZINT_CAP_EXTENDABLE 0x0004 /* Is extendable with add-on data? (Is UPC/EAN?) */
|
||||
#define ZINT_CAP_COMPOSITE 0x0008 /* Can have composite data? */
|
||||
#define ZINT_CAP_ECI 0x0010 /* Supports Extended Channel Interpretations? */
|
||||
#define ZINT_CAP_GS1 0x0020 /* Supports GS1 data? */
|
||||
#define ZINT_CAP_DOTTY 0x0040 /* Can be output as dots? */
|
||||
#define ZINT_CAP_FIXED_RATIO 0x0100 /* Has fixed width-to-height (aspect) ratio? */
|
||||
#define ZINT_CAP_READER_INIT 0x0200 /* Supports Reader Initialisation? */
|
||||
#define ZINT_CAP_FULL_MULTIBYTE 0x0400 /* Supports full-multibyte option? */
|
||||
#define ZINT_CAP_MASK 0x0800 /* Is mask selectable? */
|
||||
|
||||
// The largest amount of data that can be encoded is 4350 4-byte UTF-8 chars in Han Xin Code
|
||||
/* The largest amount of data that can be encoded is 4350 4-byte UTF-8 chars in Han Xin Code */
|
||||
#define ZINT_MAX_DATA_LEN 17400
|
||||
|
||||
// Debug flags (debug)
|
||||
#define ZINT_DEBUG_PRINT 1
|
||||
#define ZINT_DEBUG_TEST 2
|
||||
/* Debug flags (debug) */
|
||||
#define ZINT_DEBUG_PRINT 1 /* Print debug info (if any) to stdout */
|
||||
#define ZINT_DEBUG_TEST 2 /* For internal test use only */
|
||||
|
||||
#ifdef _WIN32
|
||||
# if defined(DLL_EXPORT) || defined(PIC) || defined(_USRDLL)
|
||||
@ -317,29 +326,47 @@ extern "C" {
|
||||
# define ZINT_EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Create and initialize a symbol structure */
|
||||
ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
|
||||
/* Free any output buffers that may have been created and initialize output fields */
|
||||
ZINT_EXTERN void ZBarcode_Clear(struct zint_symbol *symbol);
|
||||
/* Free a symbol structure, including any output buffers */
|
||||
ZINT_EXTERN void ZBarcode_Delete(struct zint_symbol *symbol);
|
||||
|
||||
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int in_length);
|
||||
/* Encode a barcode. If `length` is 0, `source` must be NUL-terminated. */
|
||||
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int length);
|
||||
/* Encode a barcode using input data from file `filename` */
|
||||
ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename);
|
||||
|
||||
/* Output a previously encoded symbol to file `symbol->outfile` */
|
||||
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
|
||||
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length,
|
||||
/* Encode and output a symbol to file `symbol->outfile` */
|
||||
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *source, int length,
|
||||
int rotate_angle);
|
||||
/* Encode a symbol using input data from file `filename` and output to file `symbol->outfile` */
|
||||
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
|
||||
|
||||
/* Output a previously encoded symbol to memory as raster (`symbol->bitmap`) */
|
||||
ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
|
||||
/* Output a previously encoded symbol to memory as vector (`symbol->vector`) */
|
||||
ZINT_EXTERN int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
|
||||
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length,
|
||||
/* Encode and output a symbol to memory as raster (`symbol->bitmap`) */
|
||||
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *source, int length,
|
||||
int rotate_angle);
|
||||
ZINT_EXTERN int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char *input, int length,
|
||||
/* Encode and output a symbol to memory as vector (`symbol->vector`) */
|
||||
ZINT_EXTERN int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char *source, int length,
|
||||
int rotate_angle);
|
||||
/* Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`) */
|
||||
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle);
|
||||
/* Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`) */
|
||||
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, char *filename,
|
||||
int rotate_angle);
|
||||
|
||||
/* Is `symbol_id` a recognized symbology? */
|
||||
ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
|
||||
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
|
||||
ZINT_EXTERN unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);
|
||||
/* Return the version of Zint linked to */
|
||||
ZINT_EXTERN int ZBarcode_Version();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,4 +1,4 @@
|
||||
// the configured options and settings for libzint
|
||||
/* The configured options and settings for libzint */
|
||||
#define ZINT_VERSION_MAJOR 2
|
||||
#define ZINT_VERSION_MINOR 9
|
||||
#define ZINT_VERSION_RELEASE 1
|
||||
|
@ -1,4 +1,4 @@
|
||||
// the configured options and settings for libzint
|
||||
/* The configured options and settings for libzint */
|
||||
#define ZINT_VERSION_MAJOR @ZINT_VERSION_MAJOR@
|
||||
#define ZINT_VERSION_MINOR @ZINT_VERSION_MINOR@
|
||||
#define ZINT_VERSION_RELEASE @ZINT_VERSION_RELEASE@
|
||||
|
151
docs/manual.txt
151
docs/manual.txt
@ -10,7 +10,7 @@ Zint Barcode Generator and Zint Barcode Studio User Manual
|
||||
1. Introduction
|
||||
===============
|
||||
The Zint project aims to provide a complete cross-platform open source barcode
|
||||
generating solution. The package currently consists of a Qt based GUI, a
|
||||
generating solution. The package currently consists of a Qt based GUI, a CLI
|
||||
command line executable and a library with an API to allow developers access to
|
||||
the capabilities of Zint. It is hoped that Zint provides a solution which is
|
||||
flexible enough for professional users while at the same time takes care of as
|
||||
@ -80,6 +80,11 @@ ECI: The ECI mechanism allows for multi-language data to be encoded in
|
||||
Cyrillic characters, but should be used with caution as not all scanners
|
||||
support this method.
|
||||
|
||||
Two other concepts that are important are raster and vector. Raster is a low
|
||||
level bitmap representation of an image. BMP, GIF, PCX, PNG and TIF are raster
|
||||
file formats. Vector is a high level command- or data-based representation of an
|
||||
image. EMF, EPS and SVG are vector file formats. They require renderers to turn
|
||||
them into bitmaps.
|
||||
|
||||
2. Installing Zint
|
||||
==================
|
||||
@ -195,10 +200,10 @@ Code 128, and output to the default file out.png in the current directory.
|
||||
Alternatively, if libpng was not present when Zint was built, the default
|
||||
output file will be out.gif.
|
||||
|
||||
The data input to Zint is assumed to be encoded in Unicode (UTF-8) format (Zint
|
||||
will correctly handle UTF-8 data on Windows). If you are encoding characters
|
||||
beyond the 7-bit ASCII set using a scheme other than UTF-8 then you will need to
|
||||
set the appropriate input options as shown in section 4.10 below.
|
||||
The data input to the Zint CLI is assumed to be encoded in Unicode (UTF-8)
|
||||
format (Zint will correctly handle UTF-8 data on Windows). If you are encoding
|
||||
characters beyond the 7-bit ASCII set using a scheme other than UTF-8 then you
|
||||
will need to set the appropriate input options as shown in section 4.10 below.
|
||||
|
||||
Non-printing characters can be entered on the command line using the backslash
|
||||
(\) as an escape character in combination with the --esc switch. Permissible
|
||||
@ -804,9 +809,9 @@ Zint can output a representation of the symbol data as a set of hexadecimal
|
||||
values if asked to output to a text file (*.txt) or if given the option
|
||||
--filetype=txt. This can be used for test and diagnostic purposes.
|
||||
|
||||
The --cmyk option is specific to output in encapsulated PostScript, and
|
||||
converts the RGB colours used to the CMYK colour space. Setting custom
|
||||
colours at the command line will still need to be done in RRGGBB format.
|
||||
The --cmyk option is specific to output in encapsulated PostScript and TIF, and
|
||||
converts the RGB colours used to the CMYK colour space. Setting custom colours
|
||||
at the command line will still need to be done in RRGGBB format.
|
||||
|
||||
Additional options are available which are specific to certain symbologies.
|
||||
These may, for example, control the amount of error correction data or the
|
||||
@ -883,20 +888,20 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
Note that when using the API, the input data is assumed to be Latin-1 or binary
|
||||
unless the input_mode field is set - see section 5.9 for details.
|
||||
unless the input_mode field is set - see section 5.10 for details.
|
||||
|
||||
5.3 Encoding and Printing Functions in Depth
|
||||
--------------------------------------------
|
||||
The functions for encoding and printing barcodes are defined as:
|
||||
|
||||
int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source,
|
||||
int in_length);
|
||||
int length);
|
||||
|
||||
int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename);
|
||||
|
||||
int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
|
||||
|
||||
int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input,
|
||||
int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *source,
|
||||
int length, int rotate_angle);
|
||||
|
||||
int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename,
|
||||
@ -914,15 +919,19 @@ The ZBarcode_Encode_File() and ZBarcode_Encode_File_and_Print() functions can
|
||||
be used to encode data read directly from a text file where the filename is
|
||||
given in the "filename" string.
|
||||
|
||||
5.4 Buffering Symbols in Memory
|
||||
-------------------------------
|
||||
If printing more than one barcode, the zint_symbol structure may be re-used by
|
||||
calling the ZBarcode_Clear() function after each barcode to free any output
|
||||
buffers allocated. The symbol structure input fields must be reset.
|
||||
|
||||
5.4 Buffering Symbols in Memory (raster)
|
||||
----------------------------------------
|
||||
In addition to saving barcode images to file Zint allows you to access a
|
||||
representation of the resulting bitmap image in memory. The following functions
|
||||
allow you to do this:
|
||||
|
||||
int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
|
||||
|
||||
int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input,
|
||||
int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *source,
|
||||
int length, int rotate_angle);
|
||||
|
||||
int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename,
|
||||
@ -967,19 +976,74 @@ for (row = 0; row < my_symbol->bitmap_height; row++) {
|
||||
}
|
||||
}
|
||||
|
||||
5.5 Setting Options
|
||||
5.5 Buffering Symbols in Memory (vector)
|
||||
----------------------------------------
|
||||
Symbols can also be saved to memory in a vector representation as well as a
|
||||
bitmap one. The following functions, exactly analogous to the ones above, allow
|
||||
you to do this:
|
||||
|
||||
int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
|
||||
|
||||
int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol,
|
||||
unsigned char *source, int length, int rotate_angle);
|
||||
|
||||
int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol,
|
||||
char *filename, int rotate_angle);
|
||||
|
||||
Here the "vector" pointer is set to a header which contains pointers to lists
|
||||
of structures representing the various elements of the barcode: rectangles,
|
||||
hexagons, strings and circles. To draw the barcode, each of the element types is
|
||||
iterated in turn, and using the information stored is drawn by a rendering
|
||||
system. For instance, to draw a barcode using a rendering system with
|
||||
"prepare_canvas()", "draw_rect()", "draw_hexagon()", "draw_string()", and
|
||||
"draw_circle()" routines available:
|
||||
|
||||
struct zint_vector_rect *rect;
|
||||
struct zint_vector_hexagon *hexagon;
|
||||
struct zint_vector_string *string;
|
||||
struct zint_vector_circle *circle;
|
||||
|
||||
prepare_canvas(symbol->vector->width, symbol->vector->height, symbol->scale,
|
||||
symbol->fgcolour, symbol->bgcolor, rotate_angle);
|
||||
|
||||
rect = symbol->vector->rectangles;
|
||||
while (rect) {
|
||||
draw_rect(rect->x, rect->y, rect->width, rect->height, rect->colour);
|
||||
rect = rect->next;
|
||||
}
|
||||
|
||||
hexagon = symbol->vector->hexagons;
|
||||
while (hexagon) {
|
||||
draw_hexagon(hexagon->x, hexagon->y, hexagon->diameter, hexagon->rotation):
|
||||
hexagon = hexagon->next;
|
||||
}
|
||||
|
||||
string = symbol->vector->strings;
|
||||
while (string) {
|
||||
draw_string(string->x, string->y, string->fsize, string->rotation,
|
||||
string->halign, string->text, string->length):
|
||||
string = string->next;
|
||||
}
|
||||
|
||||
circle = symbol->vector->circles;
|
||||
while (circle) {
|
||||
draw_circle(circle->x, circle->y, circle->diameter, circle->colour):
|
||||
circle = circle->next;
|
||||
}
|
||||
|
||||
5.6 Setting Options
|
||||
-------------------
|
||||
So far our application is not very useful unless we plan to only make Code 128
|
||||
symbols and we don't mind that they only save to out.png. As with the CLI
|
||||
program, of course, these options can be altered. The way this is done is
|
||||
by altering the contents of the zint_symbol structure between the creation and
|
||||
program, of course, these options can be altered. The way this is done is by
|
||||
altering the contents of the zint_symbol structure between the creation and
|
||||
encoding stages. The zint_symbol structure consists of the following variables:
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Variable Name | Type | Meaning | Default Value
|
||||
--------------------------------------------------------------------------------
|
||||
symbology | integer | Symbol to use (see section | BARCODE_CODE128
|
||||
| | 5.7). |
|
||||
| | 5.8). |
|
||||
height | float | Symbol height, excluding | Symbol
|
||||
| | fixed width-to-height | dependent
|
||||
| | symbols. [1] |
|
||||
@ -988,7 +1052,7 @@ whitespace_height | integer | Vertical whitespace height. | 0
|
||||
border_width | integer | Border width. | 0
|
||||
output_options | integer | Set various output file | 0 (none)
|
||||
| | parameters (see section |
|
||||
| | 5.8). |
|
||||
| | 5.9). |
|
||||
fgcolour | character | Foreground (ink) colour as | "000000"
|
||||
| string | RGB/RGBA hexadecimal |
|
||||
| | string. Must be 6 or 8 |
|
||||
@ -1016,10 +1080,10 @@ option_2 | integer | Symbol specific options. | 0
|
||||
option_3 | integer | Symbol specific options. | 0
|
||||
show_hrt | integer | Set to 0 to hide text. | 1
|
||||
input_mode | integer | Set encoding of input data | DATA_MODE
|
||||
| | (see section 5.9) |
|
||||
| | (see section 5.10) |
|
||||
eci | integer | Extended Channel Interpre- | 0 (none)
|
||||
| | tation code. |
|
||||
text | unsigned | Human readable text, which | "" (empty)
|
||||
text | unsigned | Human Readable Text, which | "" (empty)
|
||||
| character | usually consists of in- |
|
||||
| string | put data plus one more |
|
||||
| | check digit. Uses UTF-8 |
|
||||
@ -1055,6 +1119,8 @@ bitmap_byte_length| integer | Size of BMP bitmap data. | (output only)
|
||||
vector | pointer to | Pointer to vector header | (output only)
|
||||
| vector | containing pointers to |
|
||||
| structure | vector elements. |
|
||||
warn_level | integer | Affects error/warning value | WARN_DEFAULT
|
||||
| | returned by Zint API. |
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
[1] This value is ignored for Aztec (including HIBC and Aztec Rune), Code One,
|
||||
@ -1107,7 +1173,8 @@ ZINT_WARN_NONCOMPLIANT | The symbol was created but is not compliant with
|
||||
| (e.g. height, GS1 AI data lengths).
|
||||
ZINT_ERROR | Marks the divide between warnings and errors.
|
||||
| For return values greater than or equal to
|
||||
| this no symbol is generated.
|
||||
| this no symbol (or only an incomplete symbol)
|
||||
| is generated.
|
||||
ZINT_ERROR_TOO_LONG | The input data is too long or too short for the
|
||||
| selected symbology. No symbol has been
|
||||
| generated.
|
||||
@ -1133,6 +1200,10 @@ ZINT_ERROR_MEMORY | Zint ran out of memory. This should only be a
|
||||
ZINT_ERROR_FILE_WRITE | Zint failed to write all contents to the
|
||||
| requested output file. This should only occur
|
||||
| if the output device becomes full.
|
||||
ZINT_ERROR_USES_ECI | Returned if warn level set to WARN_FAIL_ALL and
|
||||
| ZINT_WARN_USES_ECI occurs.
|
||||
ZINT_ERROR_NONCOMPLIANT | Returned if warn level set to WARN_FAIL_ALL and
|
||||
| ZINT_WARN_NONCOMPLIANT occurs.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
To catch errors use an integer variable as shown in the code below:
|
||||
@ -1167,7 +1238,9 @@ This code will exit with the appropriate message:
|
||||
|
||||
Error 653: Malformed foreground colour target
|
||||
|
||||
5.7 Specifying a Symbology
|
||||
To treat all warnings as errors, set symbol->warn_level to WARN_FAIL_ALL.
|
||||
|
||||
5.8 Specifying a Symbology
|
||||
--------------------------
|
||||
Symbologies can be specified by number or by name as shown in the following
|
||||
table. For example
|
||||
@ -1292,7 +1365,7 @@ names in Zint before version 2.9.0. For example, symbology 29 used the name
|
||||
"BARCODE_RSS14". These names are now deprecated but are still recognised by Zint
|
||||
and will continue to be supported in future versions.
|
||||
|
||||
5.8 Adjusting other output options
|
||||
5.9 Adjusting other output options
|
||||
----------------------------------
|
||||
The output_options variable can be used to adjust various aspects of the output
|
||||
file. To select more than one option from the table below simply or them
|
||||
@ -1310,10 +1383,10 @@ BARCODE_BOX | Add a box surrounding the symbol and whitespace.
|
||||
BARCODE_STDOUT | Output the file to stdout.
|
||||
READER_INIT | Add a reader initialisation symbol to the data before
|
||||
| encoding.
|
||||
SMALL_TEXT | Use a smaller font for the human readable text.
|
||||
BOLD_TEXT | Embolden the human readable text.
|
||||
SMALL_TEXT | Use a smaller font for the Human Readable Text.
|
||||
BOLD_TEXT | Embolden the Human Readable Text.
|
||||
CMYK_COLOUR | Select the CMYK colour space option for encapsulated
|
||||
| PostScript files.
|
||||
| PostScript and TIF files.
|
||||
BARCODE_DOTTY_MODE | Plot a matrix symbol using dots rather than squares.
|
||||
GS1_GS_SEPARATOR | Use GS instead of FNC1 as GS1 separator (Data Matrix)
|
||||
OUT_BUFFER_INTERMEDIATE | Return the bitmap buffer as ASCII values instead of
|
||||
@ -1324,8 +1397,8 @@ OUT_BUFFER_INTERMEDIATE | Return the bitmap buffer as ASCII values instead of
|
||||
considerations apply to ITF-14 - see the specific section 6.1.2.6 for that
|
||||
symbology.
|
||||
|
||||
5.9 Setting the Input Mode
|
||||
--------------------------
|
||||
5.10 Setting the Input Mode
|
||||
---------------------------
|
||||
The way in which the input data is encoded can be set using the input_mode
|
||||
property. Valid values are shown in the table below.
|
||||
|
||||
@ -1360,7 +1433,7 @@ my_symbol->input_mode = DATA_MODE | GS1_MODE;
|
||||
is not valid. Permissible escape sequences are listed in section 4.1. An
|
||||
example of GS1PARENS_MODE usage is given in section 6.1.11.3.
|
||||
|
||||
5.10 Verifying Symbology Availability
|
||||
5.11 Verifying Symbology Availability
|
||||
-------------------------------------
|
||||
An additional function available in the API is defined as:
|
||||
|
||||
@ -1376,7 +1449,7 @@ if (ZBarcode_ValidID(BARCODE_PDF417) != 0) {
|
||||
printf("PDF417 not available\n");
|
||||
}
|
||||
|
||||
5.11 Checking Symbology Capabilities
|
||||
5.12 Checking Symbology Capabilities
|
||||
------------------------------------
|
||||
It can be useful for frontend programs to know the capabilities of a symbology.
|
||||
This can be determined using another additional function:
|
||||
@ -1420,7 +1493,7 @@ if (cap & ZINT_CAP_ECI) {
|
||||
printf("PDF417 does not support ECI\n");
|
||||
}
|
||||
|
||||
5.12 Zint Version
|
||||
5.13 Zint Version
|
||||
-----------------
|
||||
Lastly, the version of the Zint library linked to is returned by:
|
||||
|
||||
@ -1458,7 +1531,7 @@ Also known as Code 2 of 5 Matrix this is a self-checking code used in industrial
|
||||
applications and photo development. Standard Code 2 of 5 will encode any length
|
||||
numeric input (digits 0-9). No check digit is added by default. To add a check
|
||||
digit, set option_2 = 1 or --vers=1. To add a check digit but not show it in
|
||||
the human readable text, set option_2 = 2 or --vers=2.
|
||||
the Human Readable Text, set option_2 = 2 or --vers=2.
|
||||
|
||||
6.1.2.2 IATA Code 2 of 5
|
||||
------------------------
|
||||
@ -1472,7 +1545,7 @@ readable text, set option_2 = 2 or --vers=2.
|
||||
------------------------------
|
||||
Industrial Code 2 of 5 can encode any length numeric input (digits 0-9). No
|
||||
check digit is added by default. To add a check digit, set option_2 = 1 or
|
||||
--vers=1. To add a check digit but not show it in the human readable text, set
|
||||
--vers=1. To add a check digit but not show it in the Human Readable Text, set
|
||||
option_2 = 2 or --vers=2.
|
||||
|
||||
6.1.2.4 Interleaved Code 2 of 5 (ISO 16390)
|
||||
@ -1487,7 +1560,7 @@ readable text, set option_2 = 2 or --vers=2.
|
||||
------------------------------
|
||||
Data Logic does not include a check digit by default and can encode any length
|
||||
numeric input (digits 0-9). To add a check digit, set option_2 = 1 or --vers=1.
|
||||
To add a check digit but not show it in the human readable text, set option_2 =
|
||||
To add a check digit but not show it in the Human Readable Text, set option_2 =
|
||||
2 or --vers=2.
|
||||
|
||||
6.1.2.6 ITF-14
|
||||
@ -1635,7 +1708,7 @@ Value of option_2 | Check Digits
|
||||
6 | Modulo-11 (NCR) & Modulo-10
|
||||
-------------------------------------------
|
||||
|
||||
To not show the check digit or digits in the human readable text, add 10 to the
|
||||
To not show the check digit or digits in the Human Readable Text, add 10 to the
|
||||
option_2 value.
|
||||
|
||||
6.1.7 Telepen
|
||||
@ -1748,7 +1821,7 @@ mode C in favour of mode B.
|
||||
A variation of Code 128 previously known as UCC/EAN-128, this symbology is
|
||||
defined by the GS1 General Specifications. Application Identifiers (AIs) should
|
||||
be entered using [square bracket] notation. These will be converted to
|
||||
parentheses (round brackets) for the human readable text. This will allow round
|
||||
parentheses (round brackets) for the Human Readable Text. This will allow round
|
||||
brackets to be used in the data strings to be encoded.
|
||||
|
||||
For compatibility with data entry in other systems, if the data does not include
|
||||
@ -1787,7 +1860,7 @@ standards.
|
||||
6.1.11.7 DPD Code
|
||||
-----------------
|
||||
Another variation of Code 128 as used by DPD (Deutsher Paket Dienst). Requires
|
||||
a 28 character alphanumeric input. Zint formats human readable text as
|
||||
a 28 character alphanumeric input. Zint formats Human Readable Text as
|
||||
specified by DPD and adds a modulo-36 check character.
|
||||
|
||||
6.1.12 GS1 DataBar (ISO 24724)
|
||||
@ -1822,7 +1895,7 @@ case the check digit will be verified.
|
||||
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
|
||||
[square brackets] in the input data. This will be converted to parentheses
|
||||
(round brackets) before it is included in the human readable text attached to
|
||||
(round brackets) before it is included in the Human Readable Text attached to
|
||||
the symbol. This method allows the inclusion of parentheses in the data to be
|
||||
encoded. If the data does not include parentheses, the AIs may alternatively
|
||||
be encased in parentheses using the --gs1parens switch. See section 6.1.11.3.
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <malloc.h>
|
||||
#include "../getopt/getopt.h"
|
||||
#include "zint.h"
|
||||
#if _MSC_VER >= 1800 /* MSVC 2013 */
|
||||
#if _MSC_VER != 1200 /* VC6 */
|
||||
#pragma warning(disable: 4996) /* function or variable may be unsafe */
|
||||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
@ -47,11 +47,11 @@ typedef int static_assert_int_at_least_32bits[CHAR_BIT != 8 || sizeof(int) < 4 ?
|
||||
/* Print list of supported symbologies */
|
||||
static void types(void) {
|
||||
printf( " 1 CODE11 Code 11 74 CODABLOCKF Codablock-F\n"
|
||||
" 2 C25STANDARD Standard 2of5 75 NVE18 NVE-18\n"
|
||||
" 3 C25INTER Interleaved 2of5 76 JAPANPOST Japanese Post\n"
|
||||
" 4 C25IATA IATA 2of5 77 KOREAPOST Korea Post\n"
|
||||
" 6 C25LOGIC Data Logic 2of5 79 DBAR_STK GS1 DataBar Stacked\n"
|
||||
" 7 C25IND Industrial 2of5 80 DBAR_OMNSTK GS1 DataBar Stack Omni\n"
|
||||
" 2 C25STANDARD Standard 2 of 5 75 NVE18 NVE-18\n"
|
||||
" 3 C25INTER Interleaved 2 of 5 76 JAPANPOST Japanese Post\n"
|
||||
" 4 C25IATA IATA 2 of 5 77 KOREAPOST Korea Post\n"
|
||||
" 6 C25LOGIC Data Logic 2 of 5 79 DBAR_STK GS1 DataBar Stacked\n"
|
||||
" 7 C25IND Industrial 2 of 5 80 DBAR_OMNSTK GS1 DataBar Stack Omni\n"
|
||||
" 8 CODE39 Code 39 81 DBAR_EXPSTK GS1 DataBar Exp Stack\n"
|
||||
" 9 EXCODE39 Extended Code 39 82 PLANET USPS PLANET\n"
|
||||
"13 EANX EAN 84 MICROPDF417 MicroPDF417\n"
|
||||
|
@ -914,7 +914,7 @@ static void test_other_opts(int index, int debug) {
|
||||
/* 17*/ { BARCODE_GS1_128, "[00]376104250021234569", -1, "", NULL, "" },
|
||||
/* 18*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, "", NULL, "Warning 261: AI (00) position 18: Bad checksum '8', expected '9'" },
|
||||
/* 19*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --wzpl", NULL, "Warning 261: AI (00) position 18: Bad checksum '8', expected '9'" },
|
||||
/* 20*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --werror", NULL, "Warning 261: AI (00) position 18: Bad checksum '8', expected '9'" },
|
||||
/* 20*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --werror", NULL, "Error 261: AI (00) position 18: Bad checksum '8', expected '9'" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i;
|
||||
|
@ -595,7 +595,7 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QCheckBox" name="chkGS1Parens">
|
||||
<property name="toolTip">
|
||||
<string>Process parentheses "()" instead of square brackets "[]"
|
||||
as GS1 application identifiers delimiters
|
||||
as delimiters for GS1 Application Identifiers
|
||||
(ignored if disabled)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -666,7 +666,7 @@ as GS1 application identifiers delimiters
|
||||
<cstring>heightb</cstring>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Overall symbol height
|
||||
<string>Overall symbol height in X-dimensions
|
||||
(ignored if disabled)</string>
|
||||
</property>
|
||||
</widget>
|
||||
@ -677,7 +677,7 @@ as GS1 application identifiers delimiters
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Overall symbol height
|
||||
<string>Overall symbol height in X-dimensions
|
||||
(ignored if disabled)</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
@ -715,14 +715,14 @@ as GS1 application identifiers delimiters
|
||||
<cstring>bwidth</cstring>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Width of boundary bars or border</string>
|
||||
<string>Width of boundary bars or border in X-dimensions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="bwidth">
|
||||
<property name="toolTip">
|
||||
<string>Width of boundary bars or border</string>
|
||||
<string>Width of boundary bars or border in X-dimensions</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> X</string>
|
||||
@ -791,7 +791,7 @@ as GS1 application identifiers delimiters
|
||||
<cstring>spnWhitespace</cstring>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Horizontal whitespace, Vertical whitespace</string>
|
||||
<string>Horizontal whitespace, Vertical whitespace, in X-dimensions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -800,7 +800,8 @@ as GS1 application identifiers delimiters
|
||||
<item row="0" column="0">
|
||||
<widget class="QSpinBox" name="spnWhitespace">
|
||||
<property name="toolTip">
|
||||
<string>Width of horizontal whitespace on either side of barcode</string>
|
||||
<string>Width of horizontal whitespace on either side of barcode
|
||||
in X-dimensions</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> X</string>
|
||||
@ -810,7 +811,8 @@ as GS1 application identifiers delimiters
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spnVWhitespace">
|
||||
<property name="toolTip">
|
||||
<string>Height of vertical whitespace above and below the barcode</string>
|
||||
<string>Height of vertical whitespace above and below the barcode
|
||||
in X-dimensions</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> X</string>
|
||||
|
@ -36,7 +36,86 @@
|
||||
#include "sequencewindow.h"
|
||||
#include <stdio.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
|
||||
struct bstyle_item {
|
||||
const char *text;
|
||||
int symbology;
|
||||
};
|
||||
|
||||
static const struct bstyle_item bstyle_items[] = {
|
||||
{ "Australia Post Redirect Code", BARCODE_AUSREDIRECT },
|
||||
{ "Australia Post Reply-Paid", BARCODE_AUSREPLY },
|
||||
{ "Australia Post Routing Code", BARCODE_AUSROUTE },
|
||||
{ "Australia Post Standard Customer", BARCODE_AUSPOST },
|
||||
{ "Aztec Code (ISO 24778) (and HIBC)", BARCODE_AZTEC },
|
||||
{ "Aztec Runes", BARCODE_AZRUNE },
|
||||
{ "Channel Code", BARCODE_CHANNEL },
|
||||
{ "Codabar", BARCODE_CODABAR },
|
||||
{ "Codablock-F (and HIBC)", BARCODE_CODABLOCKF },
|
||||
{ "Code 11", BARCODE_CODE11 },
|
||||
{ "Code 128 (ISO 15417) (and GS1-128 and HIBC)", BARCODE_CODE128 },
|
||||
{ "Code 16k (ISO 12323)", BARCODE_CODE16K },
|
||||
{ "Code 2 of 5 Data Logic", BARCODE_C25LOGIC },
|
||||
{ "Code 2 of 5 IATA", BARCODE_C25IATA },
|
||||
{ "Code 2 of 5 Industrial", BARCODE_C25IND },
|
||||
{ "Code 2 of 5 Interleaved (ISO 16390)", BARCODE_C25INTER },
|
||||
{ "Code 2 of 5 Standard (Matrix)", BARCODE_C25STANDARD },
|
||||
{ "Code 32 (Italian Pharmacode)", BARCODE_CODE32 },
|
||||
{ "Code 39 (ISO 16388) (and HIBC)", BARCODE_CODE39 },
|
||||
{ "Code 39 Extended", BARCODE_EXCODE39 },
|
||||
{ "Code 49", BARCODE_CODE49 },
|
||||
{ "Code 93", BARCODE_CODE93 },
|
||||
{ "Code One", BARCODE_CODEONE },
|
||||
{ "DAFT Code", BARCODE_DAFT },
|
||||
{ "Data Matrix (ISO 16022) (and HIBC)", BARCODE_DATAMATRIX },
|
||||
{ "Deutsche Post Identcode", BARCODE_DPIDENT },
|
||||
{ "Deutsche Post Leitcode", BARCODE_DPLEIT },
|
||||
{ "DotCode", BARCODE_DOTCODE },
|
||||
{ "DPD Code", BARCODE_DPD },
|
||||
{ "Dutch Post KIX", BARCODE_KIX },
|
||||
{ "EAN-14", BARCODE_EAN14 },
|
||||
{ "European Article Number (EAN)", BARCODE_EANX },
|
||||
{ "Facing Identification Mark (FIM)", BARCODE_FIM },
|
||||
{ "Flattermarken", BARCODE_FLAT },
|
||||
{ "Grid Matrix", BARCODE_GRIDMATRIX },
|
||||
{ "GS1 DataBar Expanded", BARCODE_DBAR_EXP },
|
||||
{ "GS1 DataBar Expanded Stacked", BARCODE_DBAR_EXPSTK },
|
||||
{ "GS1 DataBar Limited", BARCODE_DBAR_LTD },
|
||||
{ "GS1 DataBar Omnidirectional (and Truncated)", BARCODE_DBAR_OMN },
|
||||
{ "GS1 DataBar Stacked", BARCODE_DBAR_STK },
|
||||
{ "GS1 DataBar Stacked Omnidirectional", BARCODE_DBAR_OMNSTK },
|
||||
{ "Han Xin (Chinese Sensible) Code", BARCODE_HANXIN },
|
||||
{ "International Standard Book Number (ISBN)", BARCODE_ISBNX },
|
||||
{ "ITF-14", BARCODE_ITF14 },
|
||||
{ "Japanese Postal Barcode", BARCODE_JAPANPOST },
|
||||
{ "Korean Postal Barcode", BARCODE_KOREAPOST },
|
||||
{ "LOGMARS", BARCODE_LOGMARS },
|
||||
{ "MaxiCode (ISO 16023)", BARCODE_MAXICODE },
|
||||
{ "MicroPDF417 (ISO 24728) (and HIBC)", BARCODE_MICROPDF417 },
|
||||
{ "Micro QR Code", BARCODE_MICROQR },
|
||||
{ "MSI Plessey", BARCODE_MSI_PLESSEY },
|
||||
{ "NVE-18 (SSCC-18)", BARCODE_NVE18 },
|
||||
{ "PDF417 (ISO 15438) (and Compact and HIBC)", BARCODE_PDF417 },
|
||||
{ "Pharmacode", BARCODE_PHARMA },
|
||||
{ "Pharmacode 2-track", BARCODE_PHARMA_TWO },
|
||||
{ "Pharma Zentralnummer (PZN)", BARCODE_PZN },
|
||||
{ "PLANET", BARCODE_PLANET },
|
||||
{ "POSTNET", BARCODE_POSTNET },
|
||||
{ "QR Code (ISO 18004) (and HIBC)", BARCODE_QRCODE },
|
||||
{ "Rectangular Micro QR (rMQR)", BARCODE_RMQR },
|
||||
{ "Royal Mail 4-state Barcode", BARCODE_RM4SCC },
|
||||
{ "Royal Mail 4-state Mailmark", BARCODE_MAILMARK },
|
||||
{ "Telepen", BARCODE_TELEPEN },
|
||||
{ "Telepen Numeric", BARCODE_TELEPEN_NUM },
|
||||
{ "UK Plessey", BARCODE_PLESSEY },
|
||||
{ "Ultracode", BARCODE_ULTRA },
|
||||
{ "Universal Product Code (UPC-A)", BARCODE_UPCA },
|
||||
{ "Universal Product Code (UPC-E)", BARCODE_UPCE },
|
||||
{ "UPNQR", BARCODE_UPNQR },
|
||||
{ "USPS Intelligent Mail (OneCode)", BARCODE_USPS_IMAIL },
|
||||
{ "VIN (Vehicle Identification Number)", BARCODE_VIN },
|
||||
};
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags fl)
|
||||
: QWidget(parent, fl), m_optionWidget(nullptr), m_symbology(0)
|
||||
{
|
||||
m_bc.bc.setDebug(QCoreApplication::arguments().contains("--verbose")); // Undocumented command line debug flag
|
||||
@ -50,80 +129,6 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
|
||||
settings.setIniCodec("UTF-8");
|
||||
#endif
|
||||
|
||||
char bstyle_text[][50] = {
|
||||
"Australia Post Redirect Code",
|
||||
"Australia Post Reply-Paid",
|
||||
"Australia Post Routing Code",
|
||||
"Australia Post Standard Customer",
|
||||
"Aztec Code (ISO 24778) (and HIBC)",
|
||||
"Aztec Runes",
|
||||
"Channel Code",
|
||||
"Codabar",
|
||||
"Codablock-F (and HIBC)",
|
||||
"Code 11",
|
||||
"Code 128 (ISO 15417) (and GS1-128 and HIBC)",
|
||||
"Code 16k (ISO 12323)",
|
||||
"Code 2 of 5 Data Logic",
|
||||
"Code 2 of 5 IATA",
|
||||
"Code 2 of 5 Industrial",
|
||||
"Code 2 of 5 Interleaved (ISO 16390)",
|
||||
"Code 2 of 5 Standard (Matrix)",
|
||||
"Code 32 (Italian Pharmacode)",
|
||||
"Code 39 (ISO 16388) (and HIBC)",
|
||||
"Code 39 Extended",
|
||||
"Code 49",
|
||||
"Code 93",
|
||||
"Code One",
|
||||
"DAFT Code",
|
||||
"Data Matrix (ISO 16022) (and HIBC)",
|
||||
"Deutsche Post Identcode",
|
||||
"Deutsche Post Leitcode",
|
||||
"DotCode",
|
||||
"DPD Code",
|
||||
"Dutch Post KIX",
|
||||
"EAN-14",
|
||||
"European Article Number (EAN)",
|
||||
"Facing Identification Mark (FIM)",
|
||||
"Flattermarken",
|
||||
"Grid Matrix",
|
||||
"GS1 DataBar Expanded",
|
||||
"GS1 DataBar Expanded Stacked",
|
||||
"GS1 DataBar Limited",
|
||||
"GS1 DataBar Omnidirectional (and Truncated)",
|
||||
"GS1 DataBar Stacked",
|
||||
"GS1 DataBar Stacked Omnidirectional",
|
||||
"Han Xin (Chinese Sensible) Code",
|
||||
"International Standard Book Number (ISBN)",
|
||||
"ITF-14",
|
||||
"Japanese Postal Barcode",
|
||||
"Korean Postal Barcode",
|
||||
"LOGMARS",
|
||||
"MaxiCode (ISO 16023)",
|
||||
"MicroPDF417 (ISO 24728) (and HIBC)",
|
||||
"Micro QR Code",
|
||||
"MSI Plessey",
|
||||
"NVE-18 (SSCC-18)",
|
||||
"PDF417 (ISO 15438) (and Compact and HIBC)",
|
||||
"Pharmacode",
|
||||
"Pharmacode 2-track",
|
||||
"Pharma Zentralnummer (PZN)",
|
||||
"PLANET",
|
||||
"POSTNET",
|
||||
"QR Code (ISO 18004) (and HIBC)",
|
||||
"Rectangular Micro QR (rMQR)",
|
||||
"Royal Mail 4-state Barcode",
|
||||
"Royal Mail 4-state Mailmark",
|
||||
"Telepen",
|
||||
"Telepen Numeric",
|
||||
"UK Plessey",
|
||||
"Ultracode",
|
||||
"Universal Product Code (UPC-A)",
|
||||
"Universal Product Code (UPC-E)",
|
||||
"UPNQR",
|
||||
"USPS Intelligent Mail (OneCode)",
|
||||
"VIN (Vehicle Identification Number)"
|
||||
};
|
||||
|
||||
scene = new QGraphicsScene(this);
|
||||
|
||||
setupUi(this);
|
||||
@ -140,10 +145,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
|
||||
settings.value("studio/paper/blue", 0xff).toInt(),
|
||||
settings.value("studio/paper/alpha", 0xff).toInt());
|
||||
|
||||
int cnt = metaObject()->enumerator(0).keyCount();
|
||||
int cnt = (int) (sizeof(bstyle_items) / sizeof(bstyle_items[0]));
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
bstyle->addItem(metaObject()->enumerator(0).key(i));
|
||||
bstyle->setItemText(i, tr(bstyle_text[i]));
|
||||
bstyle->addItem(bstyle_items[i].text);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
bstyle->setMaxVisibleItems(cnt); /* Apart from increasing combo size, seems to be needed for filter to work */
|
||||
@ -461,7 +465,7 @@ void MainWindow::HRTShow_ui_set()
|
||||
|
||||
void MainWindow::dotty_ui_set()
|
||||
{
|
||||
int symbology = metaObject()->enumerator(0).value(bstyle->currentIndex());
|
||||
int symbology = bstyle_items[bstyle->currentIndex()].symbology;
|
||||
|
||||
if (symbology == BARCODE_DOTCODE) {
|
||||
chkDotty->setEnabled(false);
|
||||
@ -508,7 +512,7 @@ void MainWindow::filter_symbologies()
|
||||
filter_list << filter.mid(i);
|
||||
}
|
||||
int filter_cnt = filter_list.size();
|
||||
int cnt = metaObject()->enumerator(0).keyCount();
|
||||
int cnt = (int) (sizeof(bstyle_items) / sizeof(bstyle_items[0]));
|
||||
|
||||
if (filter_cnt) {
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
@ -604,7 +608,7 @@ void MainWindow::change_options()
|
||||
bool initial_load = m_symbology == 0;
|
||||
int original_tab_count = tabMain->count();
|
||||
int original_tab_index = tabMain->currentIndex();
|
||||
int symbology = metaObject()->enumerator(0).value(bstyle->currentIndex());
|
||||
int symbology = bstyle_items[bstyle->currentIndex()].symbology;
|
||||
|
||||
if (m_symbology) {
|
||||
save_sub_settings(settings, m_symbology);
|
||||
@ -614,6 +618,7 @@ void MainWindow::change_options()
|
||||
tabMain->removeTab(1);
|
||||
|
||||
chkComposite->setText(tr("Add &2D Component"));
|
||||
combobox_item_enabled(cmbCompType, 3, false); // CC-C
|
||||
cmbECI->setItemText(25, tr("29: GB 2312 (PRC)"));
|
||||
btype->setItemText(0, tr("No border"));
|
||||
combobox_item_enabled(cmbFontSetting, 1, true);
|
||||
@ -626,6 +631,7 @@ void MainWindow::change_options()
|
||||
file.close();
|
||||
tabMain->insertTab(1, m_optionWidget, tr("Cod&e 128"));
|
||||
chkComposite->setText(tr("Add &2D Component (GS1-128 only)"));
|
||||
combobox_item_enabled(cmbCompType, 3, true); // CC-C
|
||||
connect(m_optionWidget->findChild<QObject*>("radC128EAN"), SIGNAL(toggled( bool )), SLOT(composite_ean_check()));
|
||||
connect(m_optionWidget->findChild<QObject*>("radC128Stand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("radC128CSup"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
@ -1035,7 +1041,7 @@ void MainWindow::composite_ui_set()
|
||||
cmbCompType->setEnabled(true);
|
||||
lblComposite->setEnabled(true);
|
||||
txtComposite->setEnabled(true);
|
||||
if (metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODE128) {
|
||||
if (bstyle_items[bstyle->currentIndex()].symbology == BARCODE_CODE128) {
|
||||
QRadioButton *radioButton = m_optionWidget->findChild<QRadioButton*>("radC128EAN");
|
||||
if (radioButton) {
|
||||
radioButton->setChecked(true);
|
||||
@ -1051,7 +1057,7 @@ void MainWindow::composite_ui_set()
|
||||
|
||||
void MainWindow::composite_ean_check()
|
||||
{
|
||||
if (metaObject()->enumerator(0).value(bstyle->currentIndex()) != BARCODE_CODE128)
|
||||
if (bstyle_items[bstyle->currentIndex()].symbology != BARCODE_CODE128)
|
||||
return;
|
||||
QRadioButton *radioButton = m_optionWidget->findChild<QRadioButton*>("radC128EAN");
|
||||
if (radioButton && !radioButton->isChecked())
|
||||
@ -1060,7 +1066,7 @@ void MainWindow::composite_ean_check()
|
||||
|
||||
void MainWindow::maxi_primary()
|
||||
{
|
||||
if (metaObject()->enumerator(0).value(bstyle->currentIndex()) != BARCODE_MAXICODE)
|
||||
if (bstyle_items[bstyle->currentIndex()].symbology != BARCODE_MAXICODE)
|
||||
return;
|
||||
QCheckBox *chkMaxiSCMVV = m_optionWidget->findChild<QCheckBox*>("chkMaxiSCMVV");
|
||||
if (m_optionWidget->findChild<QComboBox*>("cmbMaxiMode")->currentIndex() == 0) {
|
||||
@ -1080,7 +1086,7 @@ void MainWindow::maxi_primary()
|
||||
|
||||
void MainWindow::msi_plessey_ui_set()
|
||||
{
|
||||
if (metaObject()->enumerator(0).value(bstyle->currentIndex()) != BARCODE_MSI_PLESSEY)
|
||||
if (bstyle_items[bstyle->currentIndex()].symbology != BARCODE_MSI_PLESSEY)
|
||||
return;
|
||||
QCheckBox *checkBox = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>("chkMSICheckText") : nullptr;
|
||||
if (checkBox) {
|
||||
@ -1130,7 +1136,7 @@ void MainWindow::set_gs1_mode(bool gs1_mode)
|
||||
|
||||
void MainWindow::update_preview()
|
||||
{
|
||||
int symbology = metaObject()->enumerator(0).value(bstyle->currentIndex());
|
||||
int symbology = bstyle_items[bstyle->currentIndex()].symbology;
|
||||
int recheck_eci = true;
|
||||
int width = view->geometry().width();
|
||||
int height = view->geometry().height();
|
||||
|
@ -31,89 +31,10 @@ class MainWindow : public QWidget, private Ui::mainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS(BarcodeTypes)
|
||||
|
||||
public:
|
||||
enum BarcodeTypes
|
||||
{
|
||||
AUSREDIRECT = 68,
|
||||
AUSREPLY = 66,
|
||||
AUSROUTE = 67,
|
||||
AUSPOST = 63,
|
||||
AZTEC = 92,
|
||||
AZRUNE = 128,
|
||||
CHANNEL = 140,
|
||||
CODABAR = 18,
|
||||
CODABLOCK = 74,
|
||||
CODE11 = 1,
|
||||
CODE128 = 20,
|
||||
CODE16K = 23,
|
||||
C25LOGIC = 6,
|
||||
C25IATA = 4,
|
||||
C25IND = 7,
|
||||
C25INTER = 3,
|
||||
C25MATRIX = 2,
|
||||
CODE32 = 129,
|
||||
CODE39 = 8,
|
||||
EXCODE39 = 9,
|
||||
CODE49 = 24,
|
||||
CODE93 = 25,
|
||||
CODE_ONE = 141,
|
||||
DAFT = 93,
|
||||
DATAMATRIX = 71,
|
||||
DPIDENT = 22,
|
||||
DPLEIT = 21,
|
||||
DOTCODE = 115,
|
||||
DPD = 96,
|
||||
KIX = 90,
|
||||
EAN14 = 72,
|
||||
EANX = 13,
|
||||
FIM = 49,
|
||||
FLAT = 28,
|
||||
GRIDMATRIX = 142,
|
||||
RSS_EXP = 31,
|
||||
RSS_EXPSTACK = 81,
|
||||
RSS_LTD = 30,
|
||||
RSS14 = 29,
|
||||
RSS14STACK = 79,
|
||||
RSS14STACK_OMNI = 80,
|
||||
HANXIN = 116,
|
||||
ISBNX = 69,
|
||||
ITF14 = 89,
|
||||
JAPANPOST = 76,
|
||||
KOREAPOST = 77,
|
||||
LOGMARS = 50,
|
||||
MAXICODE = 57,
|
||||
MICROPDF417 = 84,
|
||||
MICROQR = 97,
|
||||
MSI_PLESSEY = 47,
|
||||
NVE18 = 75,
|
||||
PDF417 = 55,
|
||||
PHARMA = 51,
|
||||
PHARMA_TWO = 53,
|
||||
PZN = 52,
|
||||
PLANET = 82,
|
||||
POSTNET = 40,
|
||||
QRCODE = 58,
|
||||
RMQR = 145,
|
||||
RM4SCC = 70,
|
||||
MAILMARK = 121,
|
||||
TELEPEN = 32,
|
||||
TELEPEN_NUM = 87,
|
||||
PLESSEY = 86,
|
||||
ULTRA = 144,
|
||||
UPCA = 34,
|
||||
UPCE = 37,
|
||||
UPNQR = 143,
|
||||
ONECODE = 85,
|
||||
VIN = 73
|
||||
};
|
||||
|
||||
public:
|
||||
MainWindow(QWidget* parent = 0, Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
MainWindow(QWidget *parent = 0, Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
~MainWindow();
|
||||
|
||||
|
||||
public slots:
|
||||
void update_preview();
|
||||
void change_options();
|
||||
|
17
win32/README
17
win32/README
@ -19,7 +19,6 @@ Download zint, zlib and libpng by going to the directory you want to clone them
|
||||
into:
|
||||
|
||||
cd <project-directory>
|
||||
set "PROJECT_DIR=%cd%"
|
||||
|
||||
and cloning each:
|
||||
|
||||
@ -48,7 +47,7 @@ and then lpng:
|
||||
|
||||
cd ..
|
||||
|
||||
If you now open "%PROJECT_DIR%\zint\win32\zint.sln" with Visual Studio 2017, you
|
||||
If you now open "%cd%\zint\win32\zint.sln" with Visual Studio 2017, you
|
||||
should be able to build the Release configuration for Win32.
|
||||
|
||||
"zint.dll" and "zint.exe" will be in "zint\win32\Release".
|
||||
@ -90,7 +89,7 @@ Then Zint Studio "qtZint.exe":
|
||||
This creates "zint\frontend_qt\release\qtZint.exe". It requires the Zint DLL to
|
||||
run, so add its location to your PATH:
|
||||
|
||||
set "PATH=%PROJECT_DIR%\zint\win32\Release;%PATH%"
|
||||
set "PATH=%cd%\zint\win32\Release;%PATH%"
|
||||
|
||||
You should now be able to run Zint Studio:
|
||||
|
||||
@ -141,7 +140,7 @@ CMake and Visual Studio
|
||||
Zint can also be built using CMake with Visual Studio 2019, 2017 or 2015. The
|
||||
following example uses Visual Studio 2019 to build for x86/Win32:
|
||||
|
||||
As above, set %PROJECT_DIR% and clone lpng, zlib and zint into it. Then
|
||||
As above, cd <project-directory> and clone lpng, zlib and zint into it. Then
|
||||
|
||||
cd zlib
|
||||
ml /safeseh /coff /c contrib/masmx86/match686.asm
|
||||
@ -182,13 +181,18 @@ Now build zint:
|
||||
|
||||
You should be able to run zint CLI and Zint Studio:
|
||||
|
||||
set "PATH=%PROJECT_DIR%\zint\build\backend\Release;%PATH%"
|
||||
set "PATH=%cd%\zint\build\backend\Release;%PATH%"
|
||||
zint\build\frontend\Release\zint.exe
|
||||
zint\build\frontend_qt\Release\zint-qt.exe
|
||||
|
||||
Note that the program name for Zint Studio when built using CMake is not
|
||||
"qtZint.exe" but "zint-qt.exe".
|
||||
|
||||
For MSVC 2015 32 bit and MSVC 2017 32 bit, the zint cmake equivalents are:
|
||||
|
||||
cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=Release -B build
|
||||
cmake -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release -B build
|
||||
|
||||
|
||||
Visual C++ 6
|
||||
------------
|
||||
@ -233,7 +237,6 @@ differ):
|
||||
Go into the directory you want to use and clone zint and libpng:
|
||||
|
||||
cd <project-directory>
|
||||
PROJECT_DIR="$(pwd)"
|
||||
|
||||
git clone https://git.code.sf.net/p/zint/code zint
|
||||
git clone https://git.code.sf.net/p/libpng/code lpng
|
||||
@ -291,7 +294,7 @@ zint/build/frontend_qt/zint-qt.exe
|
||||
The Zint command line tool "zint.exe" and Zint Studio "zint-qt.exe" need
|
||||
"libzint.dll" to run so add its location to your PATH:
|
||||
|
||||
export PATH="${PROJECT_DIR}/zint/build/backend":${PATH}
|
||||
export PATH="$(pwd)/zint/build/backend":${PATH}
|
||||
|
||||
You should now be able to run the command line tool:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user