diff --git a/backend/code128.c b/backend/code128.c index 33abbb5a..eeeb37d4 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2020 Robin Stuart + Copyright (C) 2008-2021 Robin Stuart Bugfixes thanks to Christian Sakowski and BogDan Vatra Redistribution and use in source and binary forms, with or without @@ -734,7 +734,7 @@ INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], int len } error_number = gs1_verify(symbol, source, length, reduced); - if (error_number != 0) { + if (error_number >= ZINT_ERROR) { return error_number; } reduced_length = (int) ustrlen(reduced); diff --git a/backend/composite.c b/backend/composite.c index 6e7a03e2..09240e6c 100644 --- a/backend/composite.c +++ b/backend/composite.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2008 - 2020 Robin Stuart + Copyright (C) 2008 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -1257,16 +1257,15 @@ static int linear_dummy_run(unsigned char *source, const int length, char *errtx dummy->option_1 = 3; error_number = ean_128(dummy, source, length); linear_width = dummy->width; - if (error_number != 0) { + if (error_number >= ZINT_ERROR) { strcpy(errtxt, dummy->errtxt); } ZBarcode_Delete(dummy); - if (error_number == 0) { - return linear_width; - } else { + if (error_number >= ZINT_ERROR) { return 0; } + return linear_width; } INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int length) { @@ -1456,7 +1455,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l break; } - if (error_number != 0) { + if (error_number >= ZINT_ERROR) { strcpy(symbol->errtxt, linear->errtxt); strcat(symbol->errtxt, " in linear component"); ZBarcode_Delete(linear); diff --git a/backend/gs1.c b/backend/gs1.c index 7f65d0f4..76c847f9 100644 --- a/backend/gs1.c +++ b/backend/gs1.c @@ -38,58 +38,1105 @@ #include "common.h" #include "gs1.h" -/* This code does some checks on the integrity of GS1 data. It is not intended - to be bulletproof, nor does it report very accurately what problem was found - or where, but should prevent some of the more common encoding errors */ +/* gs1_lint() validators and checkers */ -static void itostr(char ai_string[], int ai_value) { - int thou, hund, ten, unit; - char temp[2]; +/* Validate numeric */ +static int numeric(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50]) { - strcpy(ai_string, "("); - thou = ai_value / 1000; - hund = (ai_value - (1000 * thou)) / 100; - ten = (ai_value - ((1000 * thou) + (100 * hund))) / 10; - unit = ai_value - ((1000 * thou) + (100 * hund) + (10 * ten)); + data_len -= offset; - temp[1] = '\0'; - if (ai_value >= 1000) { - temp[0] = itoc(thou); - strcat(ai_string, temp); + if (data_len < min) { + return 0; } - if (ai_value >= 100) { - temp[0] = itoc(hund); - strcat(ai_string, temp); + + if (data_len) { + const unsigned char *d = data + offset; + const unsigned char *de = d + (data_len > max ? max : data_len); + + for (; d < de; d++) { + if (*d < '0' || *d > '9') { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Non-numeric character '%c'", *d); + return 0; + } + } } - temp[0] = itoc(ten); - strcat(ai_string, temp); - temp[0] = itoc(unit); - strcat(ai_string, temp); - strcat(ai_string, ")"); + + return 1; } +/* Validate of character set 82 (GS1 General Spec Figure 7.11-1) */ +static int cset82(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50]) { + + /* These 13 characters plus all <= ' ' = 13 + 33 = 46 + 82 = 128 */ + static const char not_in_set82[] = "#$@[\\]^`{|}~\177"; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (data_len) { + const unsigned char *d = data + offset; + const unsigned char *de = d + (data_len > max ? max : data_len); + + for (; d < de; d++) { + if (*d <= ' ' || strchr(not_in_set82, *d) != NULL) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Invalid CSET 82 character '%c'", *d); + return 0; + } + } + } + + return 1; +} + +/* Validate of character set 39 (GS1 General Spec Figure 7.11-2) */ +static int cset39(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50]) { + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (data_len) { + const unsigned char *d = data + offset; + const unsigned char *de = d + (data_len > max ? max : data_len); + + for (; d < de; d++) { + /* 0-9, A-Z and "#", "-", "/" */ + if ((*d < '0' && *d != '#' && *d != '-' && *d != '/') || (*d > '9' && *d < 'A') || *d > 'Z') { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Invalid CSET 39 character '%c'", *d); + return 0; + } + } + } + + return 1; +} + +/* Check a check digit (GS1 General Spec 7.9.1) */ +static int csum(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (!length_only && data_len) { + const unsigned char *d = data + offset; + const unsigned char *de = d + (data_len > max ? max : data_len) - 1; /* Note less last character */ + int checksum = 0; + int factor = (min & 1) ? 1 : 3; + + for (; d < de; d++) { + checksum += (*d - '0') * factor; + factor = factor == 3 ? 1 : 3; + } + checksum = 10 - checksum % 10; + if (checksum == 10) { + checksum = 0; + } + if (checksum != *d - '0') { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Bad checksum '%c', expected '%c'", *d, checksum + '0'); + return 0; + } + } + + return 1; +} + +/* Check for a GS1 Prefix (GS1 General Spec GS1 1.4.2) */ +static int key(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + if (data_len && data_len < 2) { /* Do this check separately for backward compatibility */ + *p_err_no = 4; + return 0; + } + + if (!length_only && data_len) { + data += offset; + + if (data[0] < '0' || data[0] > '9' || data[1] < '0' || data[1] > '9') { + *p_err_no = 3; + *p_err_posn = offset + (data[0] < '0' || data[0] > '9' ? 0 : 1) + 1; + sprintf(err_msg, "Non-numeric company prefix '%c'", data[0] < '0' || data[0] > '9' ? data[0] : data[1]); + return 0; + } + } + + return 1; +} + +/* Check for a date YYMMDD with zero day allowed */ +static int yymmd0(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + static char days_in_month[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + + (void)max; + + data_len -= offset; + + if (data_len < min || (data_len && data_len < 6)) { + return 0; + } + + if (!length_only && data_len) { + int month, day; + + month = to_int(data + offset + 2, 2); + if (month == 0 || month > 12) { + *p_err_no = 3; + *p_err_posn = offset + 2 + 1; + sprintf(err_msg, "Invalid month '%.2s'", data + offset + 2); + return 0; + } + + day = to_int(data + offset + 4, 2); + if (day && day > days_in_month[month]) { + *p_err_no = 3; + *p_err_posn = offset + 4 + 1; + sprintf(err_msg, "Invalid day '%.2s'", data + offset + 4); + return 0; + } + if (month == 2 && day == 29) { /* Leap year check */ + int year = to_int(data + offset, 2); + if (year & 3) { /* Good until 2050 when 00 will mean 2100 (GS1 General Spec 7.12) */ + *p_err_no = 3; + *p_err_posn = offset + 4 + 1; + sprintf(err_msg, "Invalid day '%.2s'", data + offset + 4); + return 0; + } + } + } + + return 1; +} + +/* Check for a date YYMMDD. Zero day NOT allowed */ +static int yymmdd(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + if (!yymmd0(data, data_len, offset, min, max, p_err_no, p_err_posn, err_msg, length_only)) { + return 0; + } + + data_len -= offset; + + if (!length_only && data_len) { + int day = to_int(data + offset + 4, 2); + if (day == 0) { + *p_err_no = 3; + *p_err_posn = offset + 4 + 1; + sprintf(err_msg, "Invalid day '%.2s'", data + offset + 4); + return 0; + } + } + + return 1; +} + +/* Check for a date and hours YYMMDDHH */ +static int yymmddhh(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + if (data_len < min || (data_len && data_len < 8)) { + return 0; + } + + if (!yymmdd(data, data_len, offset, min, max, p_err_no, p_err_posn, err_msg, length_only)) { + return 0; + } + + data_len -= offset; + + if (!length_only && data_len) { + int hour = to_int(data + offset + 6, 2); + if (hour > 23) { + *p_err_no = 3; + *p_err_posn = offset + 6 + 1; + sprintf(err_msg, "Invalid hour of day '%.2s'", data + offset + 6); + return 0; + } + } + + return 1; +} + +/* Check for a time HHMM */ +static int hhmm(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min || (data_len && data_len < 4)) { + return 0; + } + + if (!length_only && data_len) { + int hour, mins; + + hour = to_int(data + offset, 2); + if (hour > 23) { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Invalid hour of day '%.2s'", data + offset); + return 0; + } + mins = to_int(data + offset + 2, 2); + if (mins > 59) { + *p_err_no = 3; + *p_err_posn = offset + 2 + 1; + sprintf(err_msg, "Invalid minutes in the hour '%.2s'", data + offset + 2); + return 0; + } + } + + return 1; +} + +/* Check for a time MMSS with seconds optional */ +static int mmoptss(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min || (data_len && data_len < 2) + || (data_len > 2 && data_len < 4)) { + return 0; + } + + if (!length_only && data_len) { + int mins = to_int(data + offset, 2); + if (mins > 59) { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Invalid minutes in the hour '%.2s'", data + offset); + return 0; + } + if (data_len > 2) { + int secs = to_int(data + offset + 2, 2); + if (secs > 59) { + *p_err_no = 3; + *p_err_posn = offset + 2 + 1; + sprintf(err_msg, "Invalid seconds in the minute '%.2s'", data + offset + 2); + return 0; + } + } + } + + return 1; +} + +/* Generated by "php backend/tools/gen_iso3166_h.php > backend/iso3166.h" */ +#include "iso3166.h" + +/* Check for an ISO 3166-1 numeric country code */ +static int iso3166(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min || (data_len && data_len < 3)) { + return 0; + } + + if (!length_only && data_len) { + if (!iso3166_numeric(to_int(data + offset, 3))) { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Unknown country code '%.3s'", data + offset); + return 0; + } + } + + return 1; +} + +/* Check for a list of ISO 3166-1 numeric country codes */ +static int iso3166list(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + int data_len_max; + + data_len -= offset; + data_len_max = data_len > max ? max : data_len; + + if (data_len < min || (data_len && data_len < 3)) { + return 0; + } + if (data_len && data_len_max % 3) { /* Do this check separately for backward compatibility */ + *p_err_no = 4; + return 0; + } + + if (!length_only && data_len) { + int i; + for (i = 0; i < data_len_max; i += 3) { + if (!iso3166(data, offset + data_len, offset + i, 3, 3, p_err_no, p_err_posn, err_msg, length_only)) { + return 0; + } + } + } + + return 1; +} + +/* Check for an ISO 3166-1 numeric country code allowing "999" */ +static int iso3166999(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min || (data_len && data_len < 3)) { + return 0; + } + + if (!length_only && data_len) { + int cc = to_int(data + offset, 3); + if (cc != 999 && !iso3166_numeric(cc)) { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Unknown country code '%.3s'", data + offset); + return 0; + } + } + + return 1; +} + +/* Check for an ISO 3166-1 alpha2 country code */ +static int iso3166alpha2(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min || (data_len && data_len < 2)) { + return 0; + } + + if (!length_only && data_len) { + if (!iso3166_alpha2((const char *) (data + offset))) { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Unknown country code '%.2s'", data + offset); + return 0; + } + } + + return 1; +} + +/* Generated by "php backend/tools/gen_iso4217_h.php > backend/iso4217.h" */ +#include "iso4217.h" + +/* Check for an ISO 4217 currency code */ +static int iso4217(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min || (data_len && data_len < 3)) { + return 0; + } + + if (!length_only && data_len) { + if (!iso4217_numeric(to_int(data + offset, 3))) { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Unknown currency code '%.3s'", data + offset); + return 0; + } + } + + return 1; +} + +/* Check for percent encoded */ +static int pcenc(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + static const char hex_chars[] = "0123456789ABCDEFabcdef"; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (!length_only && data_len) { + const unsigned char *d = data + offset; + const unsigned char *de = d + (data_len > max ? max : data_len); + + for (; d < de; d++) { + if (*d == '%') { + if (de - d < 3) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + strcpy(err_msg, "Invalid % escape"); + return 0; + } + 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"); + return 0; + } + } + } + } + + return 1; +} + +/* Check for yes/no (1/0) indicator */ +static int yesno(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (!length_only && data_len) { + if (data[offset] != '0' && data[offset] != '1') { + *p_err_no = 3; + *p_err_posn = offset + 1; + strcpy(err_msg, "Neither 0 nor 1 for yes or no"); + return 0; + } + } + + return 1; +} + +/* Check for importer index (GS1 General Spec 3.8.17) */ +static int importeridx(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (!length_only && data_len) { + const unsigned char *d = data + offset; + + /* 0-9, A-Z, a-z and "-", "_" */ + if ((*d < '0' && *d != '-') || (*d > '9' && *d < 'A') || (*d > 'Z' && *d < 'a' && *d != '_') || *d > 'z') { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Invalid importer index '%c'", *d); + return 0; + } + } + + return 1; +} + +/* Check non-zero */ +static int nonzero(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (!length_only && data_len) { + int val = to_int(data + offset, data_len > max ? max : data_len); + + if (val == 0) { + *p_err_no = 3; + *p_err_posn = offset + 1; + strcpy(err_msg, "Zero not permitted"); + return 0; + } + } + + return 1; +} + +/* Check winding direction (0/1/9) (GS1 General Spec 3.9.1) */ +static int winding(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (!length_only && data_len) { + if (data[offset] != '0' && data[offset] != '1' && data[offset] != '9') { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Invalid winding direction '%c'", data[offset]); + return 0; + } + } + + return 1; +} + +/* Check zero */ +static int zero(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (!length_only && data_len) { + if (data[offset] != '0') { + *p_err_no = 3; + *p_err_posn = offset + 1; + strcpy(err_msg, "Zero is required"); + return 0; + } + } + + return 1; +} + +/* Check piece of a trade item (GS1 General Spec 3.9.6 and 3.9.17) */ +static int pieceoftotal(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min || (data_len && data_len < 4)) { + return 0; + } + + if (!length_only && data_len) { + int pieces, total; + + pieces = to_int(data + offset, 2); + if (pieces == 0) { + *p_err_no = 3; + *p_err_posn = offset + 1; + strcpy(err_msg, "Piece number cannot be zero"); + return 0; + } + total = to_int(data + offset + 2, 2); + if (total == 0) { + *p_err_no = 3; + *p_err_posn = offset + 1; + strcpy(err_msg, "Total number cannot be zero"); + return 0; + } + if (pieces > total) { + *p_err_no = 3; + *p_err_posn = offset + 1; + sprintf(err_msg, "Piece number '%.2s' exceeds total '%.2s'", data + offset, data + offset + 2); + return 0; + } + } + + return 1; +} + +/* Check IBAN (ISO 13616) */ +static int iban(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + data_len -= offset; + + if (data_len < min) { + return 0; + } + if (data_len && data_len < 5) { /* Do this check separately for backward compatibility */ + *p_err_no = 4; + return 0; + } + + if (!length_only && data_len) { + const unsigned char *d = data + offset; + const unsigned char *de = d + (data_len > max ? max : data_len); + int checksum = 0; + int given_checksum; + + if (d[0] < 'A' || d[0] > 'Z' || d[1] < 'A' || d[1] > 'Z') { /* 1st 2 chars alphabetic country code */ + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Non-alphabetic IBAN country code '%.2s'", d); + return 0; + } + if (!iso3166_alpha2((const char *) d)) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Invalid IBAN country code '%.2s'", d); + return 0; + } + d += 2; + if (d[0] < '0' || d[0] > '9' || d[1] < '0' || d[1] > '9') { /* 2nd 2 chars numeric checksum */ + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Non-numeric IBAN checksum '%.2s'", d); + return 0; + } + given_checksum = to_int(d, 2); + d += 2; + for (; d < de; d++) { + /* 0-9, A-Z */ + if (*d < '0' || (*d > '9' && *d < 'A') || *d > 'Z') { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Invalid IBAN character '%c'", *d); + return 0; + } + if (*d >= 'A') { + checksum = checksum * 100 + *d - 'A' + 10; + } else { + checksum = checksum * 10 + *d - '0'; + } + checksum %= 97; + } + + /* Add in country code */ + checksum = (((checksum * 100) % 97) + (data[offset] - 'A' + 10)) * 100 + data[offset + 1] - 'A' + 10; + checksum %= 97; + + checksum *= 100; /* Allow for checksum "00" */ + checksum %= 97; + + checksum = 98 - checksum; + + if (checksum != given_checksum) { + *p_err_no = 3; + *p_err_posn = offset + 2 + 1; + sprintf(err_msg, "Bad IBAN checksum '%.2s', expected '%02d'", data + offset + 2, checksum); + return 0; + } + } + + return 1; +} + +/* Check CPID does not begin with zero */ +static int nozeroprefix(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + (void)max; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + + if (!length_only && data_len) { + /* GS1 General Specifications 3.9.11 "The C/P serial number SHALL NOT begin with a "0" digit, unless the + entire serial number consists of the single digit '0'." */ + if (data[0] == '0' && data_len != 1) { + *p_err_no = 3; + *p_err_posn = offset + 1; + strcpy(err_msg, "Zero prefix is not permitted"); + return 0; + } + } + + return 1; +} + +/* Helper to parse coupon Variable Length Indicator (VLI) and associated field. If `vli_nine` set + * then a VLI of '9' means no field present */ +static const unsigned char *coupon_vli(const unsigned char *data, const int data_len, const unsigned char *d, + const char *name, const int vli_offset, const int vli_min, const int vli_max, const int vli_nine, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + const unsigned char *de; + int vli; + + if (d - data + 1 > data_len) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "%s VLI missing", name); + return NULL; + } + vli = to_int(d, 1); + if ((vli < vli_min || vli > vli_max) && (vli != 9 || !vli_nine)) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, vli < 0 ? "Non-numeric %s VLI '%c'" : "Invalid %s VLI '%c'", name, *d); + return NULL; + } + d++; + if (vli != 9 || !vli_nine) { + if (d - data + vli + vli_offset > data_len) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "%s incomplete", name); + return NULL; + } + de = d + vli + vli_offset; + for (; d < de; d++) { + if (*d < '0' || *d > '9') { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Non-numeric %s '%c'", name, *d); + return NULL; + } + } + } + + return d; +} + +/* Helper to parse coupon value field (numeric) */ +static const unsigned char *coupon_val(const unsigned char *data, const int data_len, const unsigned char *d, + const char *name, const int val_len, int *p_val, int *p_err_no, int *p_err_posn, char err_msg[50]) { + int val; + + if (d - data + val_len > data_len) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "%s incomplete", name); + return NULL; + } + val = to_int(d, val_len); + if (val < 0) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + sprintf(err_msg, "Non-numeric %s", name); + return NULL; + } + d += val_len; + + if (p_val) { + *p_val = val; + } + return d; +} + +/* Check North American Coupon Code */ +/* Note all fields including optional must be numeric so type could be N..70 */ +static int couponcode(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + /* Minimum possible required fields length = 21 + * (from "North American Coupon Application Guideline Using GS1 DataBar Expanded Symbols R2.0 (Feb 13 2015)") + * VLI - Variable Length Indicator; GCP - GS1 Company Prefix; OC - Offer Code; SV - Save Value; + * PPR - Primary Purchase Requirement; PPFC - Primary Purchase Family Code */ + const int min_req_len = 1 /*GCP VLI*/ + 6 /*GCP*/ + 6 /*OC*/ + 1 /*SV VLI*/ + 1 /*SV*/ + + 1 /*PPR VLI*/ + 1 /*PPR*/ + 1 /*PPR Code*/ + 3 /*PPFC*/; + + (void)max; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + if (data_len && data_len < min_req_len) { /* Do separately for backward compatibility */ + *p_err_no = 4; + return 0; + } + + if (!length_only && data_len) { + const unsigned char *d = data + offset; + int val; + + data_len += offset; + + /* Required fields */ + d = coupon_vli(data, data_len, d, "Primary GS1 Co. Prefix", 6, 0, 6, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_val(data, data_len, d, "Offer Code", 6, NULL, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_vli(data, data_len, d, "Save Value", 0, 1, 5, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_vli(data, data_len, d, "Primary Purch. Req.", 0, 1, 5, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_val(data, data_len, d, "Primary Purch. Req. Code", 1, &val, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (val > 5 && val < 9) { + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + sprintf(err_msg, "Invalid Primary Purch. Req. Code '%c'", *(d - 1)); + return 0; + } + d = coupon_val(data, data_len, d, "Primary Purch. Family Code", 3, NULL, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + + /* Optional fields */ + while (d - data < data_len) { + int data_field = to_int(d, 1); + d++; + + if (data_field == 1) { + + d = coupon_val(data, data_len, d, "Add. Purch. Rules Code", 1, &val, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (val > 3) { + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + sprintf(err_msg, "Invalid Add. Purch. Rules Code '%c'", *(d - 1)); + return 0; + } + d = coupon_vli(data, data_len, d, "2nd Purch. Req.", 0, 1, 5, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_val(data, data_len, d, "2nd Purch. Req. Code", 1, &val, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (val > 4 && val < 9) { + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + sprintf(err_msg, "Invalid 2nd Purch. Req. Code '%c'", *(d - 1)); + return 0; + } + d = coupon_val(data, data_len, d, "2nd Purch. Family Code", 3, NULL, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_vli(data, data_len, d, "2nd Purch. GS1 Co. Prefix", 6, 0, 6, 1, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + + } else if (data_field == 2) { + + d = coupon_vli(data, data_len, d, "3rd Purch. Req.", 0, 1, 5, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_val(data, data_len, d, "3rd Purch. Req. Code", 1, &val, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (val > 4 && val < 9) { + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + sprintf(err_msg, "Invalid 3rd Purch. Req. Code '%c'", *(d - 1)); + return 0; + } + d = coupon_val(data, data_len, d, "3rd Purch. Family Code", 3, NULL, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_vli(data, data_len, d, "3rd Purch. GS1 Co. Prefix", 6, 0, 6, 1, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + + } else if (data_field == 3) { + + d = coupon_val(data, data_len, d, "Expiration Date", 6, NULL, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (!yymmd0(data, data_len, d - 6 - data, 6, 6, p_err_no, p_err_posn, err_msg, 0)) { + return 0; + } + + } else if (data_field == 4) { + + d = coupon_val(data, data_len, d, "Start Date", 6, NULL, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (!yymmd0(data, data_len, d - 6 - data, 6, 6, p_err_no, p_err_posn, err_msg, 0)) { + return 0; + } + + } else if (data_field == 5) { + + d = coupon_vli(data, data_len, d, "Serial Number", 6, 0, 9, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + + } else if (data_field == 6) { + + d = coupon_vli(data, data_len, d, "Retailer ID", 6, 1, 7, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + + } else if (data_field == 9) { + + d = coupon_val(data, data_len, d, "Save Value Code", 1, &val, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if ((val > 2 && val < 5) || val > 6) { + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + sprintf(err_msg, "Invalid Save Value Code '%c'", *(d - 1)); + return 0; + } + d = coupon_val(data, data_len, d, "Save Value Applies To", 1, &val, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (val > 2) { + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + sprintf(err_msg, "Invalid Save Value Applies To '%c'", *(d - 1)); + return 0; + } + d = coupon_val(data, data_len, d, "Store Coupon Flag", 1, NULL, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_val(data, data_len, d, "Don't Multiply Flag", 1, &val, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (val > 1) { + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + sprintf(err_msg, "Invalid Don't Multiply Flag '%c'", *(d - 1)); + return 0; + } + + } else { + + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + sprintf(err_msg, data_field < 0 ? "Non-numeric Data Field '%c'" : "Invalid Data Field '%c'", *(d - 1)); + return 0; + } + } + } + + return 1; +} + +/* Check North American Positive Offer File */ +/* Note max is currently set at 36 numeric digits with remaining 34 characters reserved */ +static int couponposoffer(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, + int *p_err_posn, char err_msg[50], const int length_only) { + + /* Minimum possible length = 21 + * (from "GS1 AI (8112) Coupon Data Specifications Release 1.0 (March 2020)") + * CFMT - Coupon Format; CFID - Coupon Funder ID; VLI - Variable Length Indicator; + * OC - Offer Code; SN - Serial Number */ + const int min_len = 1 /*CFMT*/ + 1 /*CFID VLI*/ + 6 /*CFID*/ + 6 /*OC*/ + 1 /*SN VLI*/ + 6 /*SN*/; + const int max_len = 36; + + (void)max; + + data_len -= offset; + + if (data_len < min) { + return 0; + } + if (data_len && (data_len < min_len || data_len > max_len)) { /* Do separately for backward compatibility */ + *p_err_no = 4; + return 0; + } + + if (!length_only && data_len) { + const unsigned char *d = data + offset; + int val; + + d = coupon_val(data, data_len, d, "Coupon Format", 1, &val, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (val != 0 && val != 1) { + *p_err_no = 3; + *p_err_posn = d - 1 - data + 1; + strcpy(err_msg, "Coupon Format must be 0 or 1"); + return 0; + } + d = coupon_vli(data, data_len, d, "Coupon Funder ID", 6, 0, 6, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_val(data, data_len, d, "Offer Code", 6, NULL, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + d = coupon_vli(data, data_len, d, "Serial Number", 6, 0, 9, 0, p_err_no, p_err_posn, err_msg); + if (d == NULL) { + return 0; + } + if (d - data != data_len) { + *p_err_no = 3; + *p_err_posn = d - data + 1; + strcpy(err_msg, "Reserved trailing characters"); + return 0; + } + } + + return 1; +} + +/* Generated by "php backend/tools/gen_gs1_linter.php > backend/gs1_lint.h" */ +#include "gs1_lint.h" + +/* Verify a GS1 input string */ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int src_len, unsigned char reduced[]) { int i, j, last_ai, ai_latch; - char ai_string[7]; /* 6 char max "(NNNN)" */ + char ai_string[5]; /* 4 char max "NNNN" */ int bracket_level, max_bracket_level, ai_length, max_ai_length, min_ai_length; int ai_count; - int error_latch; int error_value = 0; -#ifdef _MSC_VER - int *ai_value; - int *ai_location; - int *data_location; - int *data_length; -#endif int ai_max = chr_cnt(source, src_len, '[') + 1; /* Plus 1 so non-zero */ #ifndef _MSC_VER int ai_value[ai_max], ai_location[ai_max], data_location[ai_max], data_length[ai_max]; #else - ai_value = (int*) _alloca(ai_max * sizeof(int)); - ai_location = (int*) _alloca(ai_max * sizeof(int)); - data_location = (int*) _alloca(ai_max * sizeof(int)); - data_length = (int*) _alloca(ai_max * sizeof(int)); + int *ai_value = (int *) _alloca(ai_max * sizeof(int)); + int *ai_location = (int *) _alloca(ai_max * sizeof(int)); + int *data_location = (int *) _alloca(ai_max * sizeof(int)); + int *data_length = (int *) _alloca(ai_max * sizeof(int)); #endif /* Detect extended ASCII characters */ @@ -204,474 +1251,42 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] data_location[i] = ai_location[i] + 3; if (ai_value[i] >= 100) { data_location[i]++; - } - if (ai_value[i] >= 1000) { - data_location[i]++; + if (ai_value[i] >= 1000) { + data_location[i]++; + } } data_length[i] = 0; - do { + while ((data_location[i] + data_length[i] < src_len) + && (source[data_location[i] + data_length[i]] != '[')) { data_length[i]++; - } while ((source[data_location[i] + data_length[i] - 1] != '[') - && (data_location[i] + data_length[i] <= src_len)); - data_length[i]--; - } - - for (i = 0; i < ai_count; i++) { + } if (data_length[i] == 0) { /* No data for given AI */ strcpy(symbol->errtxt, "258: Empty data field in input data"); return ZINT_ERROR_INVALID_DATA; } } - + strcpy(ai_string, ""); - + // Check for valid AI values and data lengths according to GS1 General - // Specification Release 19, January 2019 + // Specifications Release 20.0, January 2020 for (i = 0; i < ai_count; i++) { - - error_latch = 2; - switch (ai_value[i]) { - // Length 2 Fixed - case 20: // VARIANT - if (data_length[i] != 2) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 3 Fixed - case 422: // ORIGIN - case 424: // COUNTRY PROCESS - case 426: // COUNTRY FULL PROCESS - if (data_length[i] != 3) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 4 Fixed - case 7040: // UIC+EXT - case 8111: // POINTS - if (data_length[i] != 4) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 6 Fixed - case 11: // PROD DATE - case 12: // DUE DATE - case 13: // PACK DATE - case 15: // BEST BY - case 16: // SELL BY - case 17: // USE BY - case 7006: // FIRST FREEZE DATE - case 8005: // PRICE PER UNIT - if (data_length[i] != 6) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 10 Fixed - case 7003: // EXPIRY TIME - if (data_length[i] != 10) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 13 Fixed - case 410: // SHIP TO LOC - case 411: // BILL TO - case 412: // PURCHASE FROM - case 413: // SHIP FOR LOC - case 414: // LOC NO - case 415: // PAY TO - case 416: // PROD/SERV LOC - case 417: // PARTY GLN - case 7001: // NSN - if (data_length[i] != 13) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 14 Fixed - case 1: // GTIN - case 2: // CONTENT - case 8001: // DIMENSIONS - if (data_length[i] != 14) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 17 Fixed - case 402: // GSIN - if (data_length[i] != 17) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 18 Fixed - case 0: // SSCC - case 8006: // ITIP - case 8017: // GSRN PROVIDER - case 8018: // GSRN RECIPIENT - case 8026: // ITIP CONTENT - if (data_length[i] != 18) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 2 Max - case 7010: // PROD METHOD - if (data_length[i] > 2) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 3 Max - case 427: // ORIGIN SUBDIVISION - case 7008: // AQUATIC SPECIES - if (data_length[i] > 3) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 4 Max - case 7004: // ACTIVE POTENCY - if (data_length[i] > 4) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 6 Max - case 242: // MTO VARIANT - if (data_length[i] > 6) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 8 Max - case 30: // VAR COUNT - case 37: // COUNT - if (data_length[i] > 8) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 10 Max - case 7009: // FISHING GEAR TYPE - case 8019: // SRIN - if (data_length[i] > 10) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 12 Max - case 7005: // CATCH AREA - case 8011: // CPID SERIAL - if (data_length[i] > 12) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 20 Max - case 10: // BATCH/LOT - case 21: // SERIAL - case 22: // CPV - case 243: // PCN - case 254: // GLN EXTENSION COMPONENT - case 420: // SHIP TO POST - case 7020: // REFURB LOT - case 7021: // FUNC STAT - case 7022: // REV STAT - case 710: // NHRN PZN - case 711: // NHRN CIP - case 712: // NHRN CN - case 713: // NHRN DRN - case 714: // NHRN AIM - case 7240: // PROTOCOL - case 8002: // CMT NO - case 8012: // VERSION - if (data_length[i] > 20) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 25 Max - case 8020: // REF NO - if (data_length[i] > 25) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 28 Max - case 235: // TPX - if (data_length[i] > 28) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 30 Max - case 240: // ADDITIONAL ID - case 241: // CUST PART NO - case 250: // SECONDARY SERIAL - case 251: // REF TO SOURCE - case 400: // ORDER NUMBER - case 401: // GINC - case 403: // ROUTE - case 7002: // MEAT CUT - case 7023: // GIAI ASSEMBLY - case 8004: // GIAI - case 8010: // CPID - case 8013: // BUDI-DI - case 90: // INTERNAL - if (data_length[i] > 30) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 34 Max - case 8007: // IBAN - if (data_length[i] > 34) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 50 Max - case 8009: // OPTSEN - if (data_length[i] > 50) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - // Length 70 Max - case 8110: // Coupon code - case 8112: // Paperless coupon code - case 8200: // PRODUCT URL - if (data_length[i] > 70) { - error_latch = 1; - } else { - error_latch = 0; - } - break; - - } - - if (ai_value[i] == 253) { // GDTI - if ((data_length[i] < 13) || (data_length[i] > 30)) { - error_latch = 1; + int err_no, err_posn; + char err_msg[50]; + if (!gs1_lint(ai_value[i], source + data_location[i], data_length[i], &err_no, &err_posn, err_msg)) { + if (err_no == 1) { + sprintf(symbol->errtxt, "260: Invalid AI (%02d)", ai_value[i]); + } else if (err_no == 2 || err_no == 4) { /* 4 is backward-incompatible bad length */ + sprintf(symbol->errtxt, "259: Invalid data length for AI (%02d)", ai_value[i]); } else { - error_latch = 0; + sprintf(symbol->errtxt, "261: AI (%02d) position %d: %s", ai_value[i], err_posn, err_msg); } - } - - if (ai_value[i] == 255) { // GCN - if ((data_length[i] < 13) || (data_length[i] > 25)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3100) && (ai_value[i] <= 3169)) { - if (data_length[i] != 6) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3200) && (ai_value[i] <= 3379)) { - if (data_length[i] != 6) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3400) && (ai_value[i] <= 3579)) { - if (data_length[i] != 6) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3600) && (ai_value[i] <= 3699)) { - if (data_length[i] != 6) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3900) && (ai_value[i] <= 3909)) { // AMOUNT - if (data_length[i] > 15) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3910) && (ai_value[i] <= 3919)) { // AMOUNT - if ((data_length[i] < 4) || (data_length[i] > 18)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3920) && (ai_value[i] <= 3929)) { // PRICE - if (data_length[i] > 15) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3930) && (ai_value[i] <= 3939)) { // PRICE - if ((data_length[i] < 4) || (data_length[i] > 18)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 3940) && (ai_value[i] <= 3949)) { // PRCNT OFF - if (data_length[i] != 4) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if (ai_value[i] == 421) { // SHIP TO POST - if ((data_length[i] < 4) || (data_length[i] > 12)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] == 423) || (ai_value[i] == 425)) { - // COUNTRY INITIAL PROCESS || COUNTRY DISASSEMBLY - if ((data_length[i] < 4) || (data_length[i] > 15)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if (ai_value[i] == 7007) { // HARVEST DATE - if ((data_length[i] != 6) && (data_length[i] != 12)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 7030) && (ai_value[i] <= 7039)) { // PROCESSOR # - if ((data_length[i] < 4) || (data_length[i] > 30)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 7230) && (ai_value[i] <= 7239)) { // CERT # - if ((data_length[i] < 3) || (data_length[i] > 30)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if (ai_value[i] == 8003) { // GRAI - if ((data_length[i] < 15) || (data_length[i] > 30)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if (ai_value[i] == 8008) { // PROD TIME - if ((data_length[i] != 8) && (data_length[i] != 10) && (data_length[i] != 12)) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if ((ai_value[i] >= 91) && (ai_value[i] <= 99)) { // INTERNAL - if (data_length[i] > 90) { - error_latch = 1; - } else { - error_latch = 0; - } - } - - if (error_latch == 1) { - itostr(ai_string, ai_value[i]); - strcpy(symbol->errtxt, "259: Invalid data length for AI "); - strcat(symbol->errtxt, ai_string); - if (symbol->warn_level != WARN_ZPL_COMPAT) { + /* For backward compatibility only error on unknown AI or bad length */ + if ((err_no == 1 || err_no == 2) && symbol->warn_level != WARN_ZPL_COMPAT) { return ZINT_ERROR_INVALID_DATA; - } else { - error_value = ZINT_WARN_NONCOMPLIANT; - } - } - - if (error_latch == 2) { - itostr(ai_string, ai_value[i]); - strcpy(symbol->errtxt, "260: Invalid AI value "); - strcat(symbol->errtxt, ai_string); - if (symbol->warn_level != WARN_ZPL_COMPAT) { - return ZINT_ERROR_INVALID_DATA; - } else { - error_value = ZINT_WARN_NONCOMPLIANT; } + error_value = ZINT_WARN_NONCOMPLIANT; } } @@ -692,8 +1307,8 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] ai_string[2] = '\0'; last_ai = atoi(ai_string); ai_latch = 0; - /* The following values from "GS-1 General Specification Release 20.0" - figure 7.8.4-2 "Element Strings with Predefined Length Using Application Identifiers" */ + /* The following values from "GS1 General Specifications Release 20.0" + Figure 7.8.4-2 "Element strings with predefined length using GS1 Application Identifiers" */ if ( ((last_ai >= 0) && (last_ai <= 4)) || ((last_ai >= 11) && (last_ai <= 20)) diff --git a/backend/gs1_lint.h b/backend/gs1_lint.h new file mode 100644 index 00000000..a07e449c --- /dev/null +++ b/backend/gs1_lint.h @@ -0,0 +1,841 @@ +/* + * GS1 AI checker generated by "backend/tools/gen_gs1_lint.php" from + * https://raw.githubusercontent.com/bwipp/postscriptbarcode/master/contrib/development/gs1-format-spec.txt + */ +/* + libzint - the open source barcode library + Copyright (C) 2021 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ + +#ifndef GS1_LINT_H +#define GS1_LINT_H + +/* N18,csum,key */ +static int n18_csum_key(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 18 + && csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && key(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 0) + && key(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 0); +} + +/* N14,csum,key */ +static int n14_csum_key(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 14 + && csum(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && key(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 0) + && key(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..20 */ +static int x__20(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 20 + && cset82(data, data_len, 0, 1, 20, p_err_no, p_err_posn, err_msg); +} + +/* N6,yymmd0 */ +static int n6_yymmd0(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 6 + && yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg) + && yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0); +} + +/* N2 */ +static int n2(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 2 + && numeric(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg); +} + +/* X..28 */ +static int x__28(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 28 + && cset82(data, data_len, 0, 1, 28, p_err_no, p_err_posn, err_msg); +} + +/* X..30 */ +static int x__30(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 30 + && cset82(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg); +} + +/* N..6 */ +static int n__6(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 6 + && numeric(data, data_len, 0, 1, 6, p_err_no, p_err_posn, err_msg); +} + +/* N13,csum,key X0..17 */ +static int n13_csum_key_x0__17(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 13 && data_len <= 30 + && csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0) + && key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0) + && cset82(data, data_len, 13, 0, 17, p_err_no, p_err_posn, err_msg); +} + +/* N13,csum,key N0..12 */ +static int n13_csum_key_n0__12(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 13 && data_len <= 25 + && csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0) + && key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 13, 0, 12, p_err_no, p_err_posn, err_msg); +} + +/* N..8 */ +static int n__8(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 8 + && numeric(data, data_len, 0, 1, 8, p_err_no, p_err_posn, err_msg); +} + +/* N6 */ +static int n6(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 6 + && numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg); +} + +/* N..15 */ +static int n__15(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 15 + && numeric(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg); +} + +/* N3,iso4217 N..15 */ +static int n3_iso4217_n__15(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 4 && data_len <= 18 + && iso4217(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg) + && iso4217(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 3, 1, 15, p_err_no, p_err_posn, err_msg); +} + +/* N4 */ +static int n4(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 4 + && numeric(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg); +} + +/* X..30,key */ +static int x__30_key(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 30 + && key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset82(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg) + && key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 0); +} + +/* N17,csum,key */ +static int n17_csum_key(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 17 + && csum(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && key(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg, 0) + && key(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg, 0); +} + +/* N13,csum,key */ +static int n13_csum_key(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 13 + && csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0) + && key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0); +} + +/* N3,iso3166 X..9 */ +static int n3_iso3166_x__9(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 4 && data_len <= 12 + && iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg) + && iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0) + && cset82(data, data_len, 3, 1, 9, p_err_no, p_err_posn, err_msg); +} + +/* N3,iso3166 */ +static int n3_iso3166(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 3 + && iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg) + && iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0); +} + +/* N..15,iso3166list */ +static int n__15_iso3166list(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 15 + && iso3166list(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg) + && iso3166list(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..3 */ +static int x__3(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 3 + && cset82(data, data_len, 0, 1, 3, p_err_no, p_err_posn, err_msg); +} + +/* X..35,pcenc */ +static int x__35_pcenc(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 35 + && pcenc(data, data_len, 0, 1, 35, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset82(data, data_len, 0, 1, 35, p_err_no, p_err_posn, err_msg) + && pcenc(data, data_len, 0, 1, 35, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..70,pcenc */ +static int x__70_pcenc(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 70 + && pcenc(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg) + && pcenc(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 0); +} + +/* X2,iso3166alpha2 */ +static int x2_iso3166alpha2(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 2 + && iso3166alpha2(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset82(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg) + && iso3166alpha2(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..30,pcenc */ +static int x__30_pcenc(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 30 + && pcenc(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset82(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg) + && pcenc(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 0); +} + +/* N1,yesno */ +static int n1_yesno(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 1 + && yesno(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg) + && yesno(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 0); +} + +/* N6,yymmd0 N4,hhmm */ +static int n6_yymmd0_n4_hhmm(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 10 + && yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg) + && yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg) + && hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0); +} + +/* N6,yymmdd */ +static int n6_yymmdd(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 6 + && yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg) + && yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0); +} + +/* N13 */ +static int n13(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 13 + && numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg); +} + +/* N6,yymmdd N4,hhmm */ +static int n6_yymmdd_n4_hhmm(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 10 + && yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg) + && yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg) + && hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0); +} + +/* N..4 */ +static int n__4(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 4 + && numeric(data, data_len, 0, 1, 4, p_err_no, p_err_posn, err_msg); +} + +/* X..12 */ +static int x__12(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 12 + && cset82(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg); +} + +/* N6,yymmdd N0..6,yymmdd */ +static int n6_yymmdd_n0__6_yymmdd(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 6 && data_len <= 12 + && yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && yymmdd(data, data_len, 6, 0, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg) + && yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 6, 0, 6, p_err_no, p_err_posn, err_msg) + && yymmdd(data, data_len, 6, 0, 6, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..10 */ +static int x__10(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 10 + && cset82(data, data_len, 0, 1, 10, p_err_no, p_err_posn, err_msg); +} + +/* X..2 */ +static int x__2(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 2 + && cset82(data, data_len, 0, 1, 2, p_err_no, p_err_posn, err_msg); +} + +/* N3,iso3166999 X..27 */ +static int n3_iso3166999_x__27(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 4 && data_len <= 30 + && iso3166999(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg) + && iso3166999(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0) + && cset82(data, data_len, 3, 1, 27, p_err_no, p_err_posn, err_msg); +} + +/* N1 X1 X1 X1,importeridx */ +static int n1_x1_x1_x1_importeridx(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 4 + && importeridx(data, data_len, 3, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg) + && cset82(data, data_len, 1, 1, 1, p_err_no, p_err_posn, err_msg) + && cset82(data, data_len, 2, 1, 1, p_err_no, p_err_posn, err_msg) + && cset82(data, data_len, 3, 1, 1, p_err_no, p_err_posn, err_msg) + && importeridx(data, data_len, 3, 1, 1, p_err_no, p_err_posn, err_msg, 0); +} + +/* X2 X..28 */ +static int x2_x__28(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 3 && data_len <= 30 + && cset82(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg) + && cset82(data, data_len, 2, 1, 28, p_err_no, p_err_posn, err_msg); +} + +/* N4,nonzero N5,nonzero N3,nonzero N1,winding N1 */ +static int n4_nonzero_n5_nonzero_n3_nonzero_n1_winding_n1(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 14 + && nonzero(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && nonzero(data, data_len, 4, 5, 5, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && nonzero(data, data_len, 9, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && winding(data, data_len, 12, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg) + && nonzero(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 4, 5, 5, p_err_no, p_err_posn, err_msg) + && nonzero(data, data_len, 4, 5, 5, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 9, 3, 3, p_err_no, p_err_posn, err_msg) + && nonzero(data, data_len, 9, 3, 3, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 12, 1, 1, p_err_no, p_err_posn, err_msg) + && winding(data, data_len, 12, 1, 1, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 13, 1, 1, p_err_no, p_err_posn, err_msg); +} + +/* N1,zero N13,csum,key X0..16 */ +static int n1_zero_n13_csum_key_x0__16(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 14 && data_len <= 30 + && zero(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && csum(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && key(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg) + && zero(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg, 0) + && key(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg, 0) + && cset82(data, data_len, 14, 0, 16, p_err_no, p_err_posn, err_msg); +} + +/* N14,csum N4,pieceoftotal */ +static int n14_csum_n4_pieceoftotal(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 18 + && csum(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && pieceoftotal(data, data_len, 14, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 14, 4, 4, p_err_no, p_err_posn, err_msg) + && pieceoftotal(data, data_len, 14, 4, 4, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..34,iban */ +static int x__34_iban(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 34 + && iban(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset82(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg) + && iban(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg, 0); +} + +/* N8,yymmddhh N0..4,mmoptss */ +static int n8_yymmddhh_n0__4_mmoptss(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 8 && data_len <= 12 + && yymmddhh(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && mmoptss(data, data_len, 8, 0, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg) + && yymmddhh(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg, 0) + && numeric(data, data_len, 8, 0, 4, p_err_no, p_err_posn, err_msg) + && mmoptss(data, data_len, 8, 0, 4, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..50 */ +static int x__50(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 50 + && cset82(data, data_len, 0, 1, 50, p_err_no, p_err_posn, err_msg); +} + +/* C..30,key */ +static int c__30_key(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 30 + && key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset39(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg) + && key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 0); +} + +/* N..12,nozeroprefix */ +static int n__12_nozeroprefix(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 12 + && nozeroprefix(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg) + && nozeroprefix(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg, 0); +} + +/* N18,csum */ +static int n18_csum(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len == 18 + && csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && numeric(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg) + && csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 0); +} + +/* N..10 */ +static int n__10(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 10 + && numeric(data, data_len, 0, 1, 10, p_err_no, p_err_posn, err_msg); +} + +/* X..25 */ +static int x__25(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 25 + && cset82(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg); +} + +/* X..70,couponcode */ +static int x__70_couponcode(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 70 + && couponcode(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg) + && couponcode(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..70,couponposoffer */ +static int x__70_couponposoffer(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 70 + && couponposoffer(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/) + && cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg) + && couponposoffer(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 0); +} + +/* X..70 */ +static int x__70(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 70 + && cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg); +} + +/* X..90 */ +static int x__90(const unsigned char *data, const int data_len, + int *p_err_no, int *p_err_posn, char err_msg[50]) { + return data_len >= 1 && data_len <= 90 + && cset82(data, data_len, 0, 1, 90, p_err_no, p_err_posn, err_msg); +} + +/* Entry point. Returns 1 on success, 0 on failure: `*p_err_no` set to 1 if unknown AI, 2 if bad data length */ +static int gs1_lint(const int ai, const unsigned char *data, const int data_len, int *p_err_no, int *p_err_posn, + char err_msg[50]) { + + /* Assume data length failure */ + *p_err_no = 2; + + if (ai < 100) { + + if (ai == 0) { + return n18_csum_key(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 1 || ai == 2) { + return n14_csum_key(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 10 || ai == 21 || ai == 22) { + return x__20(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai >= 11 && ai <= 17) { + return n6_yymmd0(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 20) { + return n2(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 30 || ai == 37) { + return n__8(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 90) { + return x__30(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai >= 91) { + return x__90(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 300) { + + if (ai == 235) { + return x__28(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 240 || ai == 241 || ai == 250 || ai == 251) { + return x__30(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 242) { + return n__6(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 243 || ai == 254) { + return x__20(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 253) { + return n13_csum_key_x0__17(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 255) { + return n13_csum_key_n0__12(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 500) { + + if (ai == 400 || ai == 403) { + return x__30(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 401) { + return x__30_key(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 402) { + return n17_csum_key(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai >= 410 && ai <= 417) { + return n13_csum_key(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 420) { + return x__20(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 421) { + return n3_iso3166_x__9(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 422 || ai == 424 || ai == 426) { + return n3_iso3166(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 423 || ai == 425) { + return n__15_iso3166list(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 427) { + return x__3(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 800) { + + if (ai >= 710 && ai <= 714) { + return x__20(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 3200) { + + if ((ai >= 3100 && ai <= 3105) || (ai >= 3110 && ai <= 3115) || (ai >= 3120 && ai <= 3125) + || (ai >= 3130 && ai <= 3135) || (ai >= 3140 && ai <= 3145) || (ai >= 3150 && ai <= 3155) + || (ai >= 3160 && ai <= 3165)) { + return n6(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 3300) { + + if (ai <= 3205 || (ai >= 3210 && ai <= 3215) || (ai >= 3220 && ai <= 3225) || (ai >= 3230 && ai <= 3235) + || (ai >= 3240 && ai <= 3245) || (ai >= 3250 && ai <= 3255) || (ai >= 3260 && ai <= 3265) + || (ai >= 3270 && ai <= 3275) || (ai >= 3280 && ai <= 3285) || (ai >= 3290 && ai <= 3295)) { + return n6(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 3400) { + + if (ai <= 3305 || (ai >= 3310 && ai <= 3315) || (ai >= 3320 && ai <= 3325) || (ai >= 3330 && ai <= 3335) + || (ai >= 3340 && ai <= 3345) || (ai >= 3350 && ai <= 3355) || (ai >= 3360 && ai <= 3365) + || (ai >= 3370 && ai <= 3375)) { + return n6(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 3500) { + + if (ai <= 3405 || (ai >= 3410 && ai <= 3415) || (ai >= 3420 && ai <= 3425) || (ai >= 3430 && ai <= 3435) + || (ai >= 3440 && ai <= 3445) || (ai >= 3450 && ai <= 3455) || (ai >= 3460 && ai <= 3465) + || (ai >= 3470 && ai <= 3475) || (ai >= 3480 && ai <= 3485) || (ai >= 3490 && ai <= 3495)) { + return n6(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 3600) { + + if (ai <= 3505 || (ai >= 3510 && ai <= 3515) || (ai >= 3520 && ai <= 3525) || (ai >= 3530 && ai <= 3535) + || (ai >= 3540 && ai <= 3545) || (ai >= 3550 && ai <= 3555) || (ai >= 3560 && ai <= 3565) + || (ai >= 3570 && ai <= 3575)) { + return n6(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 3700) { + + if (ai <= 3605 || (ai >= 3610 && ai <= 3615) || (ai >= 3620 && ai <= 3625) || (ai >= 3630 && ai <= 3635) + || (ai >= 3640 && ai <= 3645) || (ai >= 3650 && ai <= 3655) || (ai >= 3660 && ai <= 3665) + || (ai >= 3670 && ai <= 3675) || (ai >= 3680 && ai <= 3685) || (ai >= 3690 && ai <= 3695)) { + return n6(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 4000) { + + if ((ai >= 3900 && ai <= 3909) || (ai >= 3920 && ai <= 3929)) { + return n__15(data, data_len, p_err_no, p_err_posn, err_msg); + } + if ((ai >= 3910 && ai <= 3919) || (ai >= 3930 && ai <= 3939)) { + return n3_iso4217_n__15(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai >= 3940 && ai <= 3943) { + return n4(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai >= 3950 && ai <= 3955) { + return n6(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 4400) { + + if (ai == 4300 || ai == 4301 || ai == 4310 || ai == 4311 || ai == 4320) { + return x__35_pcenc(data, data_len, p_err_no, p_err_posn, err_msg); + } + if ((ai >= 4302 && ai <= 4306) || (ai >= 4312 && ai <= 4316)) { + return x__70_pcenc(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 4307 || ai == 4317) { + return x2_iso3166alpha2(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 4308) { + return x__30_pcenc(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 4318) { + return x__20(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 4319) { + return x__30(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai >= 4321 && ai <= 4323) { + return n1_yesno(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 4324 || ai == 4325) { + return n6_yymmd0_n4_hhmm(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 4326) { + return n6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 7100) { + + if (ai == 7001) { + return n13(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7002) { + return x__30(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7003) { + return n6_yymmdd_n4_hhmm(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7004) { + return n__4(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7005) { + return x__12(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7006) { + return n6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7007) { + return n6_yymmdd_n0__6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7008) { + return x__3(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7009) { + return x__10(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7010) { + return x__2(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai >= 7020 && ai <= 7022) { + return x__20(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7023) { + return x__30_key(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai >= 7030 && ai <= 7039) { + return n3_iso3166999_x__27(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7040) { + return n1_x1_x1_x1_importeridx(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 7300) { + + if (ai >= 7230 && ai <= 7239) { + return x2_x__28(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 7240) { + return x__20(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 8100) { + + if (ai == 8001) { + return n4_nonzero_n5_nonzero_n3_nonzero_n1_winding_n1(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8002 || ai == 8012) { + return x__20(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8003) { + return n1_zero_n13_csum_key_x0__16(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8004 || ai == 8013) { + return x__30_key(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8005) { + return n6(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8006 || ai == 8026) { + return n14_csum_n4_pieceoftotal(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8007) { + return x__34_iban(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8008) { + return n8_yymmddhh_n0__4_mmoptss(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8009) { + return x__50(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8010) { + return c__30_key(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8011) { + return n__12_nozeroprefix(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8017 || ai == 8018) { + return n18_csum(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8019) { + return n__10(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8020) { + return x__25(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 8200) { + + if (ai == 8110) { + return x__70_couponcode(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8111) { + return n4(data, data_len, p_err_no, p_err_posn, err_msg); + } + if (ai == 8112) { + return x__70_couponposoffer(data, data_len, p_err_no, p_err_posn, err_msg); + } + + } else if (ai < 8300) { + + if (ai == 8200) { + return x__70(data, data_len, p_err_no, p_err_posn, err_msg); + } + } + + /* Unknown AI */ + *p_err_no = 1; + return 0; +} + +#endif /* GS1_LINT_H */ diff --git a/backend/iso3166.h b/backend/iso3166.h new file mode 100644 index 00000000..0a5b221a --- /dev/null +++ b/backend/iso3166.h @@ -0,0 +1,88 @@ +/* + * ISO 3166 country codes generated by "backend/tools/gen_iso3166_h.php" + */ +/* + libzint - the open source barcode library + Copyright (C) 2021 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ + +#ifndef ISO3166_H +#define ISO3166_H + +/* Whether ISO 3166-1 numeric */ +static int iso3166_numeric(int cc) { + static const unsigned char codes[112] = { + 0x10, 0x15, 0x11, 0x91, 0x11, 0x11, 0x1D, 0x11, + 0x51, 0x15, 0x50, 0x14, 0x11, 0x11, 0x11, 0x11, + 0x10, 0x11, 0x11, 0x51, 0x44, 0xC4, 0x14, 0x91, + 0x11, 0x18, 0x51, 0x44, 0x84, 0xC7, 0x44, 0x45, + 0x54, 0x54, 0x18, 0x00, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x51, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x41, 0x11, 0x45, 0x46, 0x54, 0x44, 0x45, + 0x44, 0x44, 0x44, 0x44, 0x11, 0x10, 0x1D, 0x11, + 0x11, 0x11, 0xE9, 0x10, 0x10, 0x44, 0x44, 0x44, + 0xB4, 0x87, 0x40, 0x11, 0x11, 0x11, 0x45, 0x44, + 0x4C, 0x50, 0xD8, 0x44, 0x44, 0x44, 0x45, 0xC0, + 0x47, 0x10, 0x10, 0x13, 0x10, 0x11, 0x11, 0x15, + 0x11, 0x11, 0x11, 0x59, 0x91, 0x00, 0x04, 0x84, + 0x07, 0x01, 0x44, 0x54, 0x00, 0x10, 0x84, 0x40, + }; + int b = cc >> 3; + + if (b < 0 || b >= 112) { + return 0; + } + return codes[b] & (1 << (cc & 0x7)) ? 1 : 0; +} + +/* Whether ISO 3166-1 alpha2 */ +static int iso3166_alpha2(const char *cc) { + static const unsigned char codes[85] = { + 0x78, 0x59, 0xDF, 0xEE, 0xEF, 0xBD, 0xDD, 0xDE, + 0x27, 0x3F, 0x84, 0x15, 0x80, 0xD4, 0x00, 0x0E, + 0x00, 0x5C, 0x09, 0xB0, 0x9F, 0xFB, 0x15, 0x00, + 0x8D, 0x06, 0x18, 0x78, 0x0F, 0x40, 0x40, 0x03, + 0x00, 0x1D, 0x2B, 0xF4, 0x41, 0x81, 0x4F, 0xFD, + 0xFC, 0xFF, 0xD7, 0x25, 0x4B, 0x08, 0x00, 0x01, + 0x40, 0x3C, 0x8F, 0x53, 0x01, 0x00, 0x00, 0x40, + 0x00, 0x51, 0xF1, 0xFD, 0xE7, 0x3A, 0xBB, 0x9F, + 0x9A, 0x41, 0x10, 0x04, 0x57, 0x85, 0x40, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x08, 0x04, 0x40, 0x00, 0x01, + }; + int cc_int; + + if (cc[0] < 'A' || cc[0] > 'Z' || cc[1] < 'A' || cc[1] > 'Z') { + return 0; + } + cc_int = (cc[0] - 'A') * 26 + (cc[1] - 'A'); + + return codes[cc_int >> 3] & (1 << (cc_int & 0x7)) ? 1 : 0; +} + +#endif /* ISO3166_H */ diff --git a/backend/iso4217.h b/backend/iso4217.h new file mode 100644 index 00000000..6959d17c --- /dev/null +++ b/backend/iso4217.h @@ -0,0 +1,65 @@ +/* + * ISO 4217 currency codes generated by "backend/tools/gen_iso4217_h.php" + */ +/* + libzint - the open source barcode library + Copyright (C) 2021 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ + +#ifndef ISO4217_H +#define ISO4217_H + +/* Whether ISO 4217-1 numeric */ +static int iso4217_numeric(int cc) { + static const unsigned char codes[125] = { + 0x00, 0x11, 0x00, 0x00, 0x11, 0x10, 0x1D, 0x10, + 0x11, 0x01, 0x10, 0x04, 0x01, 0x11, 0x10, 0x10, + 0x10, 0x01, 0x01, 0x11, 0x00, 0x44, 0x00, 0x90, + 0x01, 0x08, 0x41, 0x40, 0x40, 0x41, 0x04, 0x00, + 0x40, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x11, 0x11, 0x10, 0x11, 0x11, 0x11, 0x01, 0x01, + 0x10, 0x41, 0x11, 0x45, 0x46, 0x44, 0x04, 0x40, + 0x40, 0x44, 0x00, 0x00, 0x11, 0x00, 0x05, 0x01, + 0x11, 0x10, 0x30, 0x00, 0x10, 0x44, 0x40, 0x00, + 0x04, 0x44, 0x40, 0x11, 0x01, 0x00, 0x00, 0x04, + 0x48, 0x40, 0x00, 0x00, 0x00, 0x04, 0x44, 0x40, + 0x45, 0x00, 0x00, 0x01, 0x00, 0x10, 0x11, 0x11, + 0x00, 0x11, 0x11, 0x00, 0x81, 0x00, 0x04, 0x04, + 0x04, 0x01, 0x00, 0x14, 0x00, 0x00, 0x44, 0x00, + 0x20, 0x00, 0x00, 0x80, 0x7F, 0xB5, 0xFD, 0xFB, + 0xBF, 0xBF, 0x3F, 0x47, 0xA4, + }; + int b = cc >> 3; + + if (b < 0 || b >= 125) { + return 0; + } + return codes[b] & (1 << (cc & 0x7)) ? 1 : 0; +} + +#endif /* ISO4217_H */ diff --git a/backend/library.c b/backend/library.c index 25b2bdde..ab1d193e 100644 --- a/backend/library.c +++ b/backend/library.c @@ -1300,7 +1300,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int unsigned char *reduced = (unsigned char *) _alloca(in_length + 1); #endif error_number = gs1_verify(symbol, local_source, in_length, reduced); - if (error_number != 0) { + if (error_number >= ZINT_ERROR) { 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); diff --git a/backend/rss.c b/backend/rss.c index 3635cd84..6577adca 100644 --- a/backend/rss.c +++ b/backend/rss.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2020 Robin Stuart + Copyright (C) 2008-2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -1191,6 +1191,7 @@ static void rssexp_separator(struct zint_symbol *symbol, int width, const int co /* GS1 DataBar Expanded */ INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len) { + int error_number; int i, j, k, p, codeblocks, data_chars, vs, group, v_odd, v_even; int latch; int char_widths[21][8], checksum, check_widths[8], c_group; @@ -1210,9 +1211,9 @@ INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int separator_row = 0; - i = gs1_verify(symbol, source, src_len, reduced); - if (i != 0) { - return i; + error_number = gs1_verify(symbol, source, src_len, reduced); + if (error_number >= ZINT_ERROR) { + return error_number; } if (symbol->debug & ZINT_DEBUG_PRINT) { @@ -1527,5 +1528,5 @@ INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int } } - return 0; + return error_number; } diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index d54d6deb..a7a0d42d 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -102,6 +102,8 @@ zint_add_test(gridmtx, test_gridmtx) zint_add_test(gs1, test_gs1) zint_add_test(hanxin, test_hanxin) zint_add_test(imail, test_imail) +zint_add_test(iso3166, test_iso3166) +zint_add_test(iso4217, test_iso4217) zint_add_test(ksx1001, test_ksx1001) zint_add_test(large, test_large) zint_add_test(library, test_library) diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index 75c59088..e8a85a46 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -228,8 +228,8 @@ static void test_reader_init(int index, int generate, int debug) { /* 1*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "12", 0, 1, 68, "(6) 104 96 99 12 22 106", "StartB FNC3 CodeC 12" }, /* 2*/ { BARCODE_CODE128B, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" }, /* 3*/ { BARCODE_GS1_128, GS1_MODE, READER_INIT, "[90]12", 0, 1, 68, "(6) 105 102 90 12 11 106", "StartC FNC1 90 12 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, - /* 4*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", 0, 1, 134, "(12) 105 102 1 0 0 0 0 0 1 25 30 106", "StartC FNC1 01 00 (5) 01 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, - /* 5*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", 0, 1, 156, "(14) 105 102 0 0 0 0 0 0 0 0 1 25 80 106", "StartC FNC1 00 (8) 01 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, + /* 4*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning (12) 105 102 1 0 0 0 0 0 1 25 30 106", "StartC FNC1 01 00 (5) 01 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, + /* 5*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", ZINT_WARN_NONCOMPLIANT, 1, 156, "Warning (14) 105 102 0 0 0 0 0 0 0 0 1 25 80 106", "StartC FNC1 00 (8) 01 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, /* 6*/ { BARCODE_HIBC_128, UNICODE_MODE, READER_INIT, "A", 0, 1, 79, "(7) 104 96 11 33 24 5 106", "StartA FNC3 + A 8 (check) (Not sensible, use CODE128)" }, }; int data_size = ARRAY_SIZE(data); diff --git a/backend/tests/test_composite.c b/backend/tests/test_composite.c index f718e888..8e95d38b 100644 --- a/backend/tests/test_composite.c +++ b/backend/tests/test_composite.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -1608,8 +1608,8 @@ static void test_ean128_cc_width(int index, int generate, int debug) { /* 8*/ { "[91]123A1234A", "[02]13012345678909", 0, 5, 174, "" }, /* 9*/ { "[91]123A1234A1", "[02]13012345678909", 0, 5, 188, "" }, /*10*/ { "[91]123A1234A12", "[02]13012345678909", 0, 5, 205, "" }, - /*11*/ { "[00]123456789012345678", "[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[91]1234567890", 0, 32, 579, "With composite 2372 digits == max" }, - /*12*/ { "[00]123456789012345678", "[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[00]123456789012345678[91]12345678901", ZINT_ERROR_TOO_LONG, 0, 0, "With composite 2373 digits > max" }, + /*11*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345678[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]1234567890", 0, 32, 579, "With composite 2372 digits == max" }, + /*12*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]12345678901", ZINT_ERROR_TOO_LONG, 0, 0, "With composite 2373 digits > max" }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -2574,12 +2574,13 @@ static void test_encodation_11(int index, int generate, int debug) { "0001000000000000000000000000000000000000000000000000010" "0001010010011011110101000110111001000010100100010101010" }, - /*26*/ { BARCODE_UPCE_CC, 1, "1234567", "[90]AB[8004]1[10]12", 0, 9, 55, "Mode '11', alpha [90], with [8004], other data", - "1101100110100111110011001001100101111110010011110101001" - "1101101110101000100000100001101100011100111011100101001" - "1101101100100010011111011001100110011110001011101101001" - "1101101000110101100111111001000011001000111011101001001" - "1101001000100010000010100001101001111011111011101001101" + /*26*/ { BARCODE_UPCE_CC, 1, "1234567", "[90]AB[8004]12[10]12", 0, 10, 55, "Mode '11', alpha [90], with [8004], other data", + "1100100010110000110000101001101111011101000011100101101" + "1110100010110100011110001101001110001011111011000101101" + "1110110010100011100110111001011101101110000011000101001" + "1100110010100000100010001001010000010000100011001101001" + "1101110010111010000110000101101011100010000011011101001" + "1101111010110011110010001101000111101100110011011001001" "0001000000000000000000000000000000000000000000000000010" "0010000000000000000000000000000000000000000000000000001" "0001000000000000000000000000000000000000000000000000010" diff --git a/backend/tests/test_gs1.c b/backend/tests/test_gs1.c index 66b4ca0c..82a42e5b 100644 --- a/backend/tests/test_gs1.c +++ b/backend/tests/test_gs1.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -53,35 +53,35 @@ static void test_gs1_reduce(int index, int generate, int debug) { }; struct item data[] = { /* 0*/ { BARCODE_GS1_128, -1, "12345678901234", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" }, - /* 1*/ { BARCODE_GS1_128, -1, "[01]12345678901234", "", 0, "Input mode ignored; verified manually against tec-it", - "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110010001011000111010111101100011101011" + /* 1*/ { BARCODE_GS1_128, -1, "[01]12345678901231", "", 0, "Input mode ignored; verified manually against tec-it", + "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011" }, - /* 2*/ { BARCODE_GS1_128, GS1_MODE, "[01]12345678901234", "", 0, "Input mode ignored", - "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110010001011000111010111101100011101011" + /* 2*/ { BARCODE_GS1_128, GS1_MODE, "[01]12345678901231", "", 0, "Input mode ignored", + "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011" }, - /* 3*/ { BARCODE_GS1_128, UNICODE_MODE, "[01]12345678901234", "", 0, "Input mode ignored", - "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110010001011000111010111101100011101011" + /* 3*/ { BARCODE_GS1_128, UNICODE_MODE, "[01]12345678901231", "", 0, "Input mode ignored", + "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011" }, - /* 4*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901234", "[21]1234", 0, "Input mode ignored", + /* 4*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[21]1234", 0, "Input mode ignored", "0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000" "0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000" "0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000" - "0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110111010011100010100001011010000110011100010100" - "1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001000101100011101011110100101111001100011101011" + "0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100" + "1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011" }, - /* 5*/ { BARCODE_GS1_128_CC, GS1_MODE, "[01]12345678901234", "[21]1234", 0, "Input mode ignored", + /* 5*/ { BARCODE_GS1_128_CC, GS1_MODE, "[01]12345678901231", "[21]1234", 0, "Input mode ignored", "0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000" "0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000" "0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000" - "0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110111010011100010100001011010000110011100010100" - "1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001000101100011101011110100101111001100011101011" + "0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100" + "1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011" }, - /* 6*/ { BARCODE_GS1_128_CC, UNICODE_MODE, "[01]12345678901234", "[21]1234", 0, "Input mode ignored", + /* 6*/ { BARCODE_GS1_128_CC, UNICODE_MODE, "[01]12345678901231", "[21]1234", 0, "Input mode ignored", "0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000" "0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000" "0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000" - "0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110111010011100010100001011010000110011100010100" - "1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001000101100011101011110100101111001100011101011" + "0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100" + "1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011" }, /* 7*/ { BARCODE_EAN14, -1, "1234567890123", "", 0, "Input mode ignored; verified manually against tec-it", "11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011" @@ -165,7 +165,7 @@ static void test_gs1_reduce(int index, int generate, int debug) { "010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char *text; @@ -240,20 +240,27 @@ static void test_hrt(int index, int debug) { char *data; char *composite; + int ret; char *expected; }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_GS1_128, "[01]12345678901234[20]12", "", "(01)12345678901234(20)12" }, - /* 1*/ { BARCODE_GS1_128_CC, "[01]12345678901234[20]12", "[21]12345", "(01)12345678901234(20)12" }, - /* 2*/ { BARCODE_EAN14, "1234567890123", "", "(01)12345678901231" }, - /* 3*/ { BARCODE_NVE18, "12345678901234567", "", "(00)123456789012345675" }, - /* 4*/ { BARCODE_DBAR_EXP, "[01]12345678901234[20]12", "", "(01)12345678901234(20)12" }, - /* 5*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901234", "[21]12345", "(01)12345678901234" }, - /* 6*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901234[20]12", "", "" }, - /* 7*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901234[20]12", "[21]12345", "" }, + /* 0*/ { BARCODE_GS1_128, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, + /* 1*/ { BARCODE_GS1_128, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12" }, + /* 2*/ { BARCODE_GS1_128_CC, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, + /* 3*/ { BARCODE_GS1_128_CC, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12" }, + /* 4*/ { BARCODE_EAN14, "1234567890123", "", 0, "(01)12345678901231" }, + /* 5*/ { BARCODE_NVE18, "12345678901234567", "", 0, "(00)123456789012345675" }, + /* 6*/ { BARCODE_DBAR_EXP, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, + /* 7*/ { BARCODE_DBAR_EXP, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12" }, + /* 8*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234" }, + /* 9*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231" }, + /* 10*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "" }, + /* 11*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901231[20]12", "", 0, "" }, + /* 12*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" }, + /* 13*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901231[20]12", "[21]12345", 0, "" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char *text; @@ -276,7 +283,7 @@ static void test_hrt(int index, int debug) { int length = strlen(text); ret = ZBarcode_Encode(symbol, (unsigned char *) text, length); - assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt); assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected); @@ -288,7 +295,7 @@ static void test_hrt(int index, int debug) { #include "../gs1.h" -static void test_gs1_verify(int index) { +static void test_gs1_verify(int index, int debug) { testStart(""); @@ -309,492 +316,979 @@ static void test_gs1_verify(int index) { /* 6*/ { "[90]\n", ZINT_ERROR_INVALID_DATA, "" }, /* 7*/ { "[90]\x7F", ZINT_ERROR_INVALID_DATA, "" }, /* 8*/ { "[90]\x80", ZINT_ERROR_INVALID_DATA, "" }, - /* 9*/ { "[00]123456789012345678", 0, "00123456789012345678" }, - /* 10*/ { "[00]12345678901234567", ZINT_ERROR_INVALID_DATA, "" }, - /* 11*/ { "[01]12345678901234", 0, "0112345678901234" }, - /* 12*/ { "[01]123456789012345", ZINT_ERROR_INVALID_DATA, "" }, - /* 13*/ { "[02]12345678901234", 0, "0212345678901234" }, - /* 14*/ { "[02]1234567890123", ZINT_ERROR_INVALID_DATA, "" }, - /* 15*/ { "[03]12345678901234", ZINT_ERROR_INVALID_DATA, "" }, - /* 16*/ { "[04]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 17*/ { "[05]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 18*/ { "[06]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 19*/ { "[07]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 20*/ { "[08]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 21*/ { "[09]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 22*/ { "[10]ABCD123456", 0, "10ABCD123456" }, - /* 23*/ { "[10]123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /* 24*/ { "[100]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 25*/ { "[11]990102", 0, "11990102" }, - /* 26*/ { "[11]9901023", ZINT_ERROR_INVALID_DATA, "" }, - /* 27*/ { "[12]000100", 0, "12000100" }, - /* 28*/ { "[12]00010", ZINT_ERROR_INVALID_DATA, "" }, - /* 29*/ { "[13]991301", 0, "13991301" }, - /* 30*/ { "[13]9913011", ZINT_ERROR_INVALID_DATA, "" }, - /* 31*/ { "[14]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 32*/ { "[15]021231", 0, "15021231" }, - /* 33*/ { "[15]02123", ZINT_ERROR_INVALID_DATA, "" }, - /* 34*/ { "[16]000000", 0, "16000000" }, - /* 35*/ { "[16]00000", ZINT_ERROR_INVALID_DATA, "" }, - /* 36*/ { "[17]010200", 0, "17010200" }, - /* 37*/ { "[17]0102000", ZINT_ERROR_INVALID_DATA, "" }, - /* 38*/ { "[18]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 39*/ { "[19]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 40*/ { "[20]12", 0, "2012" }, - /* 41*/ { "[20]1", ZINT_ERROR_INVALID_DATA, "" }, - /* 42*/ { "[200]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 43*/ { "[21]A12345678", 0, "21A12345678" }, - /* 44*/ { "[21]123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /* 45*/ { "[22]abcdefghijklmnopqrst", 0, "22abcdefghijklmnopqrst" }, - /* 46*/ { "[22]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /* 47*/ { "[23]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 48*/ { "[235]1abcdefghijklmnopqrstuvwxyz0", 0, "2351abcdefghijklmnopqrstuvwxyz0" }, - /* 49*/ { "[235]1abcdefghijklmnopqrstuvwxyz01", ZINT_ERROR_INVALID_DATA, "" }, - /* 50*/ { "[24]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 51*/ { "[240]abcdefghijklmnopqrstuvwxyz1234", 0, "240abcdefghijklmnopqrstuvwxyz1234" }, - /* 52*/ { "[240]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, - /* 53*/ { "[241]abcdefghijklmnopqrstuvwxyz1234", 0, "241abcdefghijklmnopqrstuvwxyz1234" }, - /* 54*/ { "[241]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, - /* 55*/ { "[242]12345", 0, "24212345" }, - /* 56*/ { "[242]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /* 57*/ { "[243]abcdefghijklmnopqrst", 0, "243abcdefghijklmnopqrst" }, - /* 58*/ { "[243]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /* 59*/ { "[244]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 60*/ { "[249]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 61*/ { "[25]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 62*/ { "[250]abcdefghijklmnopqrstuvwxyz1234", 0, "250abcdefghijklmnopqrstuvwxyz1234" }, - /* 63*/ { "[250]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, - /* 64*/ { "[251]abcdefghijklmnopqrstuvwxyz1234", 0, "251abcdefghijklmnopqrstuvwxyz1234" }, - /* 65*/ { "[251]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, - /* 66*/ { "[252]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 67*/ { "[253]131313131313", ZINT_ERROR_INVALID_DATA, "" }, - /* 68*/ { "[253]1313131313134", 0, "2531313131313134" }, - /* 69*/ { "[253]131313131313412345678901234567", 0, "253131313131313412345678901234567" }, - /* 70*/ { "[253]1313131313134123456789012345678", ZINT_ERROR_INVALID_DATA, "" }, - /* 71*/ { "[254]abcdefghijklmnopqrst", 0, "254abcdefghijklmnopqrst" }, - /* 72*/ { "[254]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /* 73*/ { "[255]131313131313", ZINT_ERROR_INVALID_DATA, "" }, - /* 74*/ { "[255]1313131313134", 0, "2551313131313134" }, - /* 75*/ { "[255]1313131313134123456789012", 0, "2551313131313134123456789012" }, - /* 76*/ { "[255]13131313131341234567890123", ZINT_ERROR_INVALID_DATA, "" }, - /* 77*/ { "[256]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 78*/ { "[259]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 79*/ { "[26]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 80*/ { "[27]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 81*/ { "[28]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 82*/ { "[29]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 83*/ { "[30]12345678", 0, "3012345678" }, - /* 84*/ { "[30]123456789", ZINT_ERROR_INVALID_DATA, "" }, - /* 85*/ { "[3000]1234", ZINT_ERROR_INVALID_DATA, "" }, - /* 86*/ { "[31]123456", ZINT_ERROR_INVALID_DATA, "" }, - /* 87*/ { "[3100]123456", 0, "3100123456" }, - /* 88*/ { "[3100]12345", ZINT_ERROR_INVALID_DATA, "" }, - /* 89*/ { "[3101]123456", 0, "3101123456" }, - /* 90*/ { "[3101]12345", ZINT_ERROR_INVALID_DATA, "" }, - /* 91*/ { "[3109]123456", 0, "3109123456" }, - /* 92*/ { "[3110]123456", 0, "3110123456" }, - /* 93*/ { "[3110]12345", ZINT_ERROR_INVALID_DATA, "" }, - /* 94*/ { "[3119]123456", 0, "3119123456" }, - /* 95*/ { "[3120]123456", 0, "3120123456" }, - /* 96*/ { "[3120]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /* 97*/ { "[3129]123456", 0, "3129123456" }, - /* 98*/ { "[3130]123456", 0, "3130123456" }, - /* 99*/ { "[3130]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*100*/ { "[3139]123456", 0, "3139123456" }, - /*101*/ { "[3140]123456", 0, "3140123456" }, - /*102*/ { "[3140]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*103*/ { "[3149]123456", 0, "3149123456" }, - /*104*/ { "[3150]123456", 0, "3150123456" }, - /*105*/ { "[3150]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*106*/ { "[3159]123456", 0, "3159123456" }, - /*107*/ { "[3160]123456", 0, "3160123456" }, - /*108*/ { "[3160]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*109*/ { "[3169]123456", 0, "3169123456" }, - /*110*/ { "[3170]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*111*/ { "[3180]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*112*/ { "[3190]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*113*/ { "[32]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*114*/ { "[3200]123456", 0, "3200123456" }, - /*115*/ { "[3200]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*116*/ { "[3210]123456", 0, "3210123456" }, - /*117*/ { "[3210]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*118*/ { "[3220]123456", 0, "3220123456" }, - /*119*/ { "[3220]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*120*/ { "[3230]123456", 0, "3230123456" }, - /*121*/ { "[3240]123456", 0, "3240123456" }, - /*122*/ { "[3250]123456", 0, "3250123456" }, - /*123*/ { "[3260]123456", 0, "3260123456" }, - /*124*/ { "[3270]123456", 0, "3270123456" }, - /*125*/ { "[3280]123456", 0, "3280123456" }, - /*126*/ { "[3290]123456", 0, "3290123456" }, - /*127*/ { "[3290]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*128*/ { "[3299]123456", 0, "3299123456" }, - /*129*/ { "[33]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*130*/ { "[3300]123456", 0, "3300123456" }, - /*131*/ { "[3300]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*132*/ { "[3310]123456", 0, "3310123456" }, - /*133*/ { "[3310]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*134*/ { "[3320]123456", 0, "3320123456" }, - /*135*/ { "[3330]123456", 0, "3330123456" }, - /*136*/ { "[3340]123456", 0, "3340123456" }, - /*137*/ { "[3350]123456", 0, "3350123456" }, - /*138*/ { "[3360]123456", 0, "3360123456" }, - /*139*/ { "[3370]123456", 0, "3370123456" }, - /*140*/ { "[3370]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*141*/ { "[3379]123456", 0, "3379123456" }, - /*142*/ { "[3380]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*143*/ { "[3390]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*144*/ { "[34]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*145*/ { "[3400]123456", 0, "3400123456" }, - /*146*/ { "[3400]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*147*/ { "[3410]123456", 0, "3410123456" }, - /*148*/ { "[3410]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*149*/ { "[3420]123456", 0, "3420123456" }, - /*150*/ { "[3430]123456", 0, "3430123456" }, - /*151*/ { "[3440]123456", 0, "3440123456" }, - /*152*/ { "[3450]123456", 0, "3450123456" }, - /*153*/ { "[3460]123456", 0, "3460123456" }, - /*154*/ { "[3470]123456", 0, "3470123456" }, - /*155*/ { "[3480]123456", 0, "3480123456" }, - /*156*/ { "[3490]123456", 0, "3490123456" }, - /*157*/ { "[3490]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*158*/ { "[3499]123456", 0, "3499123456" }, - /*159*/ { "[35]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*160*/ { "[3500]123456", 0, "3500123456" }, - /*161*/ { "[3500]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*162*/ { "[3510]123456", 0, "3510123456", }, - /*163*/ { "[3510]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*164*/ { "[3520]123456", 0, "3520123456", }, - /*165*/ { "[3530]123456", 0, "3530123456", }, - /*166*/ { "[3540]123456", 0, "3540123456", }, - /*167*/ { "[3550]123456", 0, "3550123456", }, - /*168*/ { "[3560]123456", 0, "3560123456", }, - /*169*/ { "[3570]123456", 0, "3570123456", }, - /*170*/ { "[3579]123456", 0, "3579123456" }, - /*171*/ { "[3580]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*172*/ { "[3590]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*173*/ { "[36]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*174*/ { "[3600]123456", 0, "3600123456" }, - /*175*/ { "[3600]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*176*/ { "[3610]123456", 0, "3610123456" }, - /*177*/ { "[3610]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*178*/ { "[3620]123456", 0, "3620123456", }, - /*179*/ { "[3630]123456", 0, "3630123456", }, - /*180*/ { "[3640]123456", 0, "3640123456", }, - /*181*/ { "[3650]123456", 0, "3650123456", }, - /*182*/ { "[3660]123456", 0, "3660123456", }, - /*183*/ { "[3670]123456", 0, "3670123456", }, - /*184*/ { "[3680]123456", 0, "3680123456", }, - /*185*/ { "[3680]123456", 0, "3680123456", }, - /*186*/ { "[3680]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*187*/ { "[3690]123456", 0, "3690123456" }, - /*188*/ { "[3699]123456", 0, "3699123456" }, - /*189*/ { "[37]12345678", 0, "3712345678" }, - /*190*/ { "[37]123456789", ZINT_ERROR_INVALID_DATA, "" }, - /*191*/ { "[3700]12345678", ZINT_ERROR_INVALID_DATA, "" }, - /*192*/ { "[38]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*193*/ { "[3800]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*194*/ { "[39]123456", ZINT_ERROR_INVALID_DATA, "" }, - /*195*/ { "[3900]123456789012345", 0, "3900123456789012345" }, - /*196*/ { "[3900]1234567890123456", ZINT_ERROR_INVALID_DATA, "" }, - /*197*/ { "[3909]123456789012345", 0, "3909123456789012345" }, - /*198*/ { "[3910]123123456789012345", 0, "3910123123456789012345" }, - /*199*/ { "[3910]1231234567890123456", ZINT_ERROR_INVALID_DATA, "" }, - /*200*/ { "[3910]123", ZINT_ERROR_INVALID_DATA, "" }, - /*201*/ { "[3920]123456789012345", 0, "3920123456789012345" }, - /*202*/ { "[3920]1234567890123456", ZINT_ERROR_INVALID_DATA, "" }, - /*203*/ { "[3930]123123456789012345", 0, "3930123123456789012345" }, - /*204*/ { "[3930]1231234567890123456", ZINT_ERROR_INVALID_DATA, "" }, - /*205*/ { "[3930]123", ZINT_ERROR_INVALID_DATA, "" }, - /*206*/ { "[3940]1234", 0, "39401234" }, - /*207*/ { "[3940]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*208*/ { "[3940]123", ZINT_ERROR_INVALID_DATA, "" }, - /*209*/ { "[3949]1234", 0, "39491234" }, - /*210*/ { "[3950]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*211*/ { "[3960]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*212*/ { "[3970]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*213*/ { "[3980]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*214*/ { "[3999]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*215*/ { "[40]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*216*/ { "[400]123456789012345678901234567890", 0, "400123456789012345678901234567890" }, - /*217*/ { "[400]1234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*218*/ { "[401]1234abcdefghijklmnopqrstuvwxyz", 0, "4011234abcdefghijklmnopqrstuvwxyz" }, - /*219*/ { "[401]1234abcdefghijklmnopqrstuvwxyz1", ZINT_ERROR_INVALID_DATA, "" }, - /*220*/ { "[402]13131313131313132", 0, "40213131313131313132" }, - /*221*/ { "[402]1313131313131313", ZINT_ERROR_INVALID_DATA, "" }, - /*222*/ { "[403]abcdefghijklmnopqrstuvwxyz1234", 0, "403abcdefghijklmnopqrstuvwxyz1234" }, - /*223*/ { "[403]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, - /*224*/ { "[404]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*225*/ { "[409]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*226*/ { "[410]3898765432108", 0, "4103898765432108" }, - /*227*/ { "[410]12345678901234", ZINT_ERROR_INVALID_DATA, "" }, - /*228*/ { "[411]1313131313134", 0, "4111313131313134" }, - /*229*/ { "[411]13131313131", ZINT_ERROR_INVALID_DATA, "" }, - /*230*/ { "[412]1313131313134", 0, "4121313131313134" }, - /*231*/ { "[412]13131313131", ZINT_ERROR_INVALID_DATA, "" }, - /*232*/ { "[413]1313131313134", 0, "4131313131313134" }, - /*233*/ { "[413]13131313131", ZINT_ERROR_INVALID_DATA, "" }, - /*234*/ { "[414]1313131313134", 0, "4141313131313134" }, - /*235*/ { "[414]13131313131", ZINT_ERROR_INVALID_DATA, "" }, - /*236*/ { "[415]1313131313134", 0, "4151313131313134" }, - /*237*/ { "[415]13131313131", ZINT_ERROR_INVALID_DATA, "" }, - /*238*/ { "[416]1313131313134", 0, "4161313131313134" }, - /*239*/ { "[416]13131313131", ZINT_ERROR_INVALID_DATA, "" }, - /*240*/ { "[417]1313131313134", 0, "4171313131313134" }, - /*241*/ { "[417]13131313131", ZINT_ERROR_INVALID_DATA, "" }, - /*242*/ { "[418]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*243*/ { "[419]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*244*/ { "[420]abcdefghijklmnopqrst", 0, "420abcdefghijklmnopqrst" }, - /*245*/ { "[420]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*246*/ { "[421]123abcdefghi", 0, "421123abcdefghi" }, - /*247*/ { "[421]123abcdefghij", ZINT_ERROR_INVALID_DATA, "" }, - /*248*/ { "[422]123", 0, "422123" }, - /*249*/ { "[422]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*250*/ { "[422]12", ZINT_ERROR_INVALID_DATA, "" }, - /*251*/ { "[423]123123123123123", 0, "423123123123123123" }, - /*252*/ { "[423]1231231231231231", ZINT_ERROR_INVALID_DATA, "" }, - /*253*/ { "[423]12", ZINT_ERROR_INVALID_DATA, "" }, - /*254*/ { "[424]123", 0, "424123" }, - /*255*/ { "[424]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*256*/ { "[424]12", ZINT_ERROR_INVALID_DATA, "" }, - /*257*/ { "[425]123123123123123", 0, "425123123123123123" }, - /*258*/ { "[425]1231231231231231", ZINT_ERROR_INVALID_DATA, "" }, - /*259*/ { "[425]12", ZINT_ERROR_INVALID_DATA, "" }, - /*260*/ { "[426]123", 0, "426123" }, - /*261*/ { "[426]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*262*/ { "[426]12", ZINT_ERROR_INVALID_DATA, "" }, - /*263*/ { "[427]abc", 0, "427abc" }, - /*264*/ { "[427]abcd", ZINT_ERROR_INVALID_DATA, "" }, - /*265*/ { "[428]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*266*/ { "[429]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*267*/ { "[430]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*268*/ { "[499]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*269*/ { "[50]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*270*/ { "[500]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*271*/ { "[5000]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*272*/ { "[51]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*273*/ { "[59]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*274*/ { "[60]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*275*/ { "[600]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*276*/ { "[6000]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*277*/ { "[61]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*278*/ { "[69]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*279*/ { "[70]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*280*/ { "[700]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*281*/ { "[7000]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*282*/ { "[7001]1234567890123", 0, "70011234567890123" }, - /*283*/ { "[7001]123456789012", ZINT_ERROR_INVALID_DATA, "" }, - /*284*/ { "[7002]abcdefghijklmnopqrstuvwxyz1234", 0, "7002abcdefghijklmnopqrstuvwxyz1234" }, - /*285*/ { "[7002]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, - /*286*/ { "[7003]1212121212", 0, "70031212121212" }, - /*287*/ { "[7003]121212121", ZINT_ERROR_INVALID_DATA, "" }, - /*288*/ { "[7004]1234", 0, "70041234" }, - /*289*/ { "[7004]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*290*/ { "[7005]abcdefghijkl", 0, "7005abcdefghijkl" }, - /*291*/ { "[7005]abcdefghijklm", ZINT_ERROR_INVALID_DATA, "" }, - /*292*/ { "[7006]200132", 0, "7006200132" }, - /*293*/ { "[7006]2001320", ZINT_ERROR_INVALID_DATA, "" }, - /*294*/ { "[7007]010101121212", 0, "7007010101121212" }, - /*295*/ { "[7007]01010112121", ZINT_ERROR_INVALID_DATA, "" }, - /*296*/ { "[7007]121212", 0, "7007121212" }, - /*297*/ { "[7007]12121", ZINT_ERROR_INVALID_DATA, "" }, - /*298*/ { "[7007]1212121", ZINT_ERROR_INVALID_DATA, "" }, - /*299*/ { "[7008]abc", 0, "7008abc" }, - /*300*/ { "[7008]abcd", ZINT_ERROR_INVALID_DATA, "" }, - /*301*/ { "[7009]abcdefghij", 0, "7009abcdefghij" }, - /*302*/ { "[7009]abcdefghijk", ZINT_ERROR_INVALID_DATA, "" }, - /*303*/ { "[7010]01", 0, "701001" }, - /*304*/ { "[7010]1", 0, "70101" }, - /*305*/ { "[7010]012", ZINT_ERROR_INVALID_DATA, "" }, - /*306*/ { "[7011]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*307*/ { "[7012]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*308*/ { "[7019]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*309*/ { "[7020]abcdefghijklmnopqrst", 0, "7020abcdefghijklmnopqrst" }, - /*310*/ { "[7020]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*311*/ { "[7021]abcdefghijklmnopqrst", 0, "7021abcdefghijklmnopqrst" }, - /*312*/ { "[7021]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*313*/ { "[7022]abcdefghijklmnopqrst", 0, "7022abcdefghijklmnopqrst" }, - /*314*/ { "[7022]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*315*/ { "[7023]1234abcdefghijklmnopqrstuvwxyz", 0, "70231234abcdefghijklmnopqrstuvwxyz" }, - /*316*/ { "[7023]1234abcdefghijklmnopqrstuvwxyza", ZINT_ERROR_INVALID_DATA, "" }, - /*317*/ { "[7024]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*318*/ { "[7025]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*319*/ { "[7029]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*320*/ { "[7030]123abcdefghijklmnopqrstuvwxyza", 0, "7030123abcdefghijklmnopqrstuvwxyza" }, - /*321*/ { "[7030]123abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, - /*322*/ { "[7031]123abcdefghijklmnopqrstuvwxyza", 0, "7031123abcdefghijklmnopqrstuvwxyza" }, - /*323*/ { "[7031]123abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, - /*324*/ { "[7032]123abcdefghijklmnopqrstuvwxyza", 0, "7032123abcdefghijklmnopqrstuvwxyza" }, - /*325*/ { "[7033]123abcdefghijklmnopqrstuvwxyza", 0, "7033123abcdefghijklmnopqrstuvwxyza" }, - /*326*/ { "[7034]123abcdefghijklmnopqrstuvwxyza", 0, "7034123abcdefghijklmnopqrstuvwxyza" }, - /*327*/ { "[7035]123abcdefghijklmnopqrstuvwxyza", 0, "7035123abcdefghijklmnopqrstuvwxyza" }, - /*328*/ { "[7036]123abcdefghijklmnopqrstuvwxyza", 0, "7036123abcdefghijklmnopqrstuvwxyza" }, - /*329*/ { "[7037]123abcdefghijklmnopqrstuvwxyza", 0, "7037123abcdefghijklmnopqrstuvwxyza" }, - /*330*/ { "[7038]123abcdefghijklmnopqrstuvwxyza", 0, "7038123abcdefghijklmnopqrstuvwxyza" }, - /*331*/ { "[7039]123abcdefghijklmnopqrstuvwxyza", 0, "7039123abcdefghijklmnopqrstuvwxyza" }, - /*332*/ { "[7039]123abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, - /*333*/ { "[7040]1abc", 0, "70401abc" }, - /*334*/ { "[7040]1ab", ZINT_ERROR_INVALID_DATA, "" }, - /*335*/ { "[7040]1abcd", ZINT_ERROR_INVALID_DATA, "" }, - /*336*/ { "[7041]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*337*/ { "[7042]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*338*/ { "[7050]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*339*/ { "[7090]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*340*/ { "[7099]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*341*/ { "[71]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*342*/ { "[710]abcdefghijklmnopqrst", 0, "710abcdefghijklmnopqrst" }, - /*343*/ { "[710]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*344*/ { "[711]abcdefghijklmnopqrst", 0, "711abcdefghijklmnopqrst" }, - /*345*/ { "[711]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*346*/ { "[712]abcdefghijklmnopqrst", 0, "712abcdefghijklmnopqrst" }, - /*347*/ { "[712]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*348*/ { "[713]abcdefghijklmnopqrst", 0, "713abcdefghijklmnopqrst" }, - /*349*/ { "[713]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*350*/ { "[714]abcdefghijklmnopqrst", 0, "714abcdefghijklmnopqrst" }, - /*351*/ { "[714]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*352*/ { "[715]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*353*/ { "[716]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*354*/ { "[719]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*355*/ { "[7100]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*356*/ { "[72]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*357*/ { "[7200]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*358*/ { "[7210]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*359*/ { "[7220]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*360*/ { "[7230]EMabcdefghijklmnopqrstuvwxyzab", 0, "7230EMabcdefghijklmnopqrstuvwxyzab" }, - /*361*/ { "[7230]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, - /*362*/ { "[7230]EM", ZINT_ERROR_INVALID_DATA, "" }, - /*363*/ { "[7231]EMabcdefghijklmnopqrstuvwxyzab", 0, "7231EMabcdefghijklmnopqrstuvwxyzab" }, - /*364*/ { "[7232]EMabcdefghijklmnopqrstuvwxyzab", 0, "7232EMabcdefghijklmnopqrstuvwxyzab" }, - /*365*/ { "[7233]EMabcdefghijklmnopqrstuvwxyzab", 0, "7233EMabcdefghijklmnopqrstuvwxyzab" }, - /*366*/ { "[7234]EMabcdefghijklmnopqrstuvwxyzab", 0, "7234EMabcdefghijklmnopqrstuvwxyzab" }, - /*367*/ { "[7235]EMabcdefghijklmnopqrstuvwxyzab", 0, "7235EMabcdefghijklmnopqrstuvwxyzab" }, - /*368*/ { "[7236]EMabcdefghijklmnopqrstuvwxyzab", 0, "7236EMabcdefghijklmnopqrstuvwxyzab" }, - /*369*/ { "[7237]EMabcdefghijklmnopqrstuvwxyzab", 0, "7237EMabcdefghijklmnopqrstuvwxyzab" }, - /*370*/ { "[7238]EMabcdefghijklmnopqrstuvwxyzab", 0, "7238EMabcdefghijklmnopqrstuvwxyzab" }, - /*371*/ { "[7239]EMabcdefghijklmnopqrstuvwxyzab", 0, "7239EMabcdefghijklmnopqrstuvwxyzab" }, - /*372*/ { "[7239]E", ZINT_ERROR_INVALID_DATA, "" }, - /*373*/ { "[7240]abcdefghijklmnopqrst", 0, "7240abcdefghijklmnopqrst" }, - /*374*/ { "[7240]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, - /*375*/ { "[7241]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*376*/ { "[7249]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*377*/ { "[7250]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*378*/ { "[7299]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*379*/ { "[73]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*380*/ { "[7300]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*381*/ { "[74]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*382*/ { "[7400]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*383*/ { "[79]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*384*/ { "[7900]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*385*/ { "[7999]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*386*/ { "[80]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*387*/ { "[800]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*388*/ { "[8000]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*389*/ { "[8001]12345678901234", 0, "800112345678901234" }, - /*390*/ { "[8001]1234123456789012345", ZINT_ERROR_INVALID_DATA, "" }, - /*391*/ { "[8002]abcdefghijklmnopqrst", 0, "8002abcdefghijklmnopqrst" }, - /*392*/ { "[8002]abcdefghijklmnopqrstuv", ZINT_ERROR_INVALID_DATA, "" }, - /*393*/ { "[8003]01234567890123abcdefghijklmnop", 0, "800301234567890123abcdefghijklmnop" }, - /*394*/ { "[8004]abcdefghijklmnopqrstuvwxyz1234", 0, "8004abcdefghijklmnopqrstuvwxyz1234" }, - /*395*/ { "[8004]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, - /*396*/ { "[8005]123456", 0, "8005123456" }, - /*397*/ { "[8005]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*398*/ { "[8005]1234567", ZINT_ERROR_INVALID_DATA, "" }, - /*399*/ { "[8006]123456789012341212", 0, "8006123456789012341212" }, - /*400*/ { "[8006]12345678901234121", ZINT_ERROR_INVALID_DATA, "" }, - /*401*/ { "[8006]1234567890123412123", ZINT_ERROR_INVALID_DATA, "" }, - /*402*/ { "[8007]abcdefghijklmnopqrstuvwxyz12345678", 0, "8007abcdefghijklmnopqrstuvwxyz12345678" }, - /*403*/ { "[8007]abcdefghijklmnopqrstuvwxyz123456789", ZINT_ERROR_INVALID_DATA, "" }, - /*404*/ { "[8008]123456121212", 0, "8008123456121212" }, - /*405*/ { "[8008]1234561212", 0, "80081234561212" }, - /*406*/ { "[8008]12345612", 0, "800812345612" }, - /*407*/ { "[8008]1234561", ZINT_ERROR_INVALID_DATA, "" }, - /*408*/ { "[8008]123456121", ZINT_ERROR_INVALID_DATA, "" }, - /*409*/ { "[8008]12345612121", ZINT_ERROR_INVALID_DATA, "" }, - /*410*/ { "[8008]1234561212123", ZINT_ERROR_INVALID_DATA, "" }, - /*411*/ { "[8009]12345678901234567890123456789012345678901234567890", 0, "800912345678901234567890123456789012345678901234567890" }, - /*412*/ { "[8009]123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*413*/ { "[8010]1234abcdefghijklmnopqrstuvwxyz1", ZINT_ERROR_INVALID_DATA, "" }, - /*414*/ { "[8011]123456789012", 0, "8011123456789012" }, - /*415*/ { "[8011]1234567890123", ZINT_ERROR_INVALID_DATA, "" }, - /*416*/ { "[8012]abcdefghijklmnopqrst", 0, "8012abcdefghijklmnopqrst" }, - /*417*/ { "[8012]abcdefghijklmnopqrstuv", ZINT_ERROR_INVALID_DATA, "" }, - /*418*/ { "[8013]1234abcdefghijklmnopqrstuvwxyz", 0, "80131234abcdefghijklmnopqrstuvwxyz" }, - /*419*/ { "[8013]1234abcdefghijklmnopqrstuvwxyz1", ZINT_ERROR_INVALID_DATA, "" }, - /*420*/ { "[8014]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*421*/ { "[8016]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*422*/ { "[8017]313131313131313139", 0, "8017313131313131313139" }, - /*423*/ { "[8017]31313131313131313", ZINT_ERROR_INVALID_DATA, "" }, - /*424*/ { "[8017]3131313131313131390", ZINT_ERROR_INVALID_DATA, "" }, - /*425*/ { "[8018]313131313131313139", 0, "8018313131313131313139" }, - /*426*/ { "[8018]31313131313131313", ZINT_ERROR_INVALID_DATA, "" }, - /*427*/ { "[8018]3131313131313131390", ZINT_ERROR_INVALID_DATA, "" }, - /*428*/ { "[8019]1234567890", 0, "80191234567890" }, - /*429*/ { "[8019]12345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*430*/ { "[8020]abcdefghijklmnopqrstuvwxy", 0, "8020abcdefghijklmnopqrstuvwxy" }, - /*431*/ { "[8020]abcdefghijklmnopqrstuvwxyz", ZINT_ERROR_INVALID_DATA, "" }, - /*432*/ { "[8021]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*433*/ { "[8025]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*434*/ { "[8026]123456789012341212", 0, "8026123456789012341212" }, - /*435*/ { "[8026]1234567890123451212", ZINT_ERROR_INVALID_DATA, "" }, - /*436*/ { "[8026]12345678901234512", ZINT_ERROR_INVALID_DATA, "" }, - /*437*/ { "[8027]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*438*/ { "[8030]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*439*/ { "[8040]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*440*/ { "[8090]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*441*/ { "[8099]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*442*/ { "[81]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*443*/ { "[8100]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*444*/ { "[8109]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*445*/ { "[8110]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "81101234567890123456789012345678901234567890123456789012345678901234567890" }, - /*446*/ { "[8110]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*447*/ { "[8111]1234", 0, "81111234" }, - /*448*/ { "[8111]12345", ZINT_ERROR_INVALID_DATA, "" }, - /*449*/ { "[8111]123", ZINT_ERROR_INVALID_DATA, "" }, - /*450*/ { "[8112]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "81121234567890123456789012345678901234567890123456789012345678901234567890" }, - /*451*/ { "[8112]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*452*/ { "[8113]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*453*/ { "[8120]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*454*/ { "[8190]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*455*/ { "[8199]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*456*/ { "[82]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*457*/ { "[8200]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "82001234567890123456789012345678901234567890123456789012345678901234567890" }, - /*458*/ { "[8201]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*459*/ { "[8210]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*460*/ { "[8290]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*461*/ { "[8299]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*462*/ { "[83]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*463*/ { "[8300]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*464*/ { "[89]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*465*/ { "[8900]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*466*/ { "[90]abcdefghijklmnopqrstuvwxyz1234", 0, "90abcdefghijklmnopqrstuvwxyz1234" }, - /*467*/ { "[9000]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*468*/ { "[90]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, - /*469*/ { "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "91123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, - /*470*/ { "[91]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*471*/ { "[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "92123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, - /*472*/ { "[92]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*473*/ { "[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "93123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, - /*474*/ { "[93]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*475*/ { "[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "94123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, - /*476*/ { "[94]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*477*/ { "[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "98123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, - /*478*/ { "[98]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*479*/ { "[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "99123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, - /*480*/ { "[99]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, - /*481*/ { "[9900]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*482*/ { "[9999]1234", ZINT_ERROR_INVALID_DATA, "" }, - /*483*/ { "[01]12345678901234[7006]200101", 0, "01123456789012347006200101" }, - /*484*/ { "[3900]1234567890[01]12345678901234", 0, "39001234567890[0112345678901234" }, - /*485*/ { "[253]12345678901234[3901]12345678901234[20]12", 0, "25312345678901234[390112345678901234[2012" }, - /*486*/ { "[253]12345678901234[01]12345678901234[3901]12345678901234[20]12", 0, "25312345678901234[0112345678901234390112345678901234[2012" }, + /* 9*/ { "[00]123456789012345678", ZINT_WARN_NONCOMPLIANT, "00123456789012345678" }, + /* 10*/ { "[00]123456789012345675", 0, "00123456789012345675" }, + /* 11*/ { "[00]12345678901234567", ZINT_ERROR_INVALID_DATA, "" }, + /* 12*/ { "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, "0112345678901234" }, + /* 13*/ { "[01]12345678901231", 0, "0112345678901231" }, + /* 14*/ { "[01]123456789012345", ZINT_ERROR_INVALID_DATA, "" }, + /* 15*/ { "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, "0212345678901234" }, + /* 16*/ { "[02]12345678901231", 0, "0212345678901231" }, + /* 17*/ { "[02]1234567890123", ZINT_ERROR_INVALID_DATA, "" }, + /* 18*/ { "[03]12345678901234", ZINT_ERROR_INVALID_DATA, "" }, + /* 19*/ { "[04]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 20*/ { "[05]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 21*/ { "[06]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 22*/ { "[07]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 23*/ { "[08]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 24*/ { "[09]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 25*/ { "[10]ABCD123456", 0, "10ABCD123456" }, + /* 26*/ { "[10]123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /* 27*/ { "[100]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 28*/ { "[1000]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 29*/ { "[11]990102", 0, "11990102" }, + /* 30*/ { "[11]9901023", ZINT_ERROR_INVALID_DATA, "" }, + /* 31*/ { "[110]990102", ZINT_ERROR_INVALID_DATA, "" }, + /* 32*/ { "[1100]990102", ZINT_ERROR_INVALID_DATA, "" }, + /* 33*/ { "[12]000100", 0, "12000100" }, + /* 34*/ { "[12]00010", ZINT_ERROR_INVALID_DATA, "" }, + /* 35*/ { "[120]000100", ZINT_ERROR_INVALID_DATA, "" }, + /* 36*/ { "[1200]000100", ZINT_ERROR_INVALID_DATA, "" }, + /* 37*/ { "[13]991301", ZINT_WARN_NONCOMPLIANT, "13991301" }, + /* 38*/ { "[13]991201", 0, "13991201" }, + /* 39*/ { "[13]9913011", ZINT_ERROR_INVALID_DATA, "" }, + /* 40*/ { "[130]991301", ZINT_ERROR_INVALID_DATA, "" }, + /* 41*/ { "[1300]991301", ZINT_ERROR_INVALID_DATA, "" }, + /* 42*/ { "[14]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 43*/ { "[140]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 44*/ { "[1400]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 45*/ { "[15]021231", 0, "15021231" }, + /* 46*/ { "[15]02123", ZINT_ERROR_INVALID_DATA, "" }, + /* 47*/ { "[150]021231", ZINT_ERROR_INVALID_DATA, "" }, + /* 48*/ { "[1500]021231", ZINT_ERROR_INVALID_DATA, "" }, + /* 49*/ { "[16]000000", ZINT_WARN_NONCOMPLIANT, "16000000" }, + /* 50*/ { "[16]000100", 0, "16000100" }, + /* 51*/ { "[16]00000", ZINT_ERROR_INVALID_DATA, "" }, + /* 52*/ { "[160]000000", ZINT_ERROR_INVALID_DATA, "" }, + /* 53*/ { "[1600]000000", ZINT_ERROR_INVALID_DATA, "" }, + /* 54*/ { "[17]010200", 0, "17010200" }, + /* 55*/ { "[17]0102000", ZINT_ERROR_INVALID_DATA, "" }, + /* 56*/ { "[170]010200", ZINT_ERROR_INVALID_DATA, "" }, + /* 57*/ { "[1700]010200", ZINT_ERROR_INVALID_DATA, "" }, + /* 58*/ { "[18]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 59*/ { "[180]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 60*/ { "[1800]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 61*/ { "[19]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 62*/ { "[190]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 63*/ { "[1900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 64*/ { "[20]12", 0, "2012" }, + /* 65*/ { "[20]1", ZINT_ERROR_INVALID_DATA, "" }, + /* 66*/ { "[200]12", ZINT_ERROR_INVALID_DATA, "" }, + /* 67*/ { "[2000]12", ZINT_ERROR_INVALID_DATA, "" }, + /* 68*/ { "[21]A12345678", 0, "21A12345678" }, + /* 69*/ { "[21]123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /* 70*/ { "[210]A12345678", ZINT_ERROR_INVALID_DATA, "" }, + /* 71*/ { "[2100]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 72*/ { "[22]abcdefghijklmnopqrst", 0, "22abcdefghijklmnopqrst" }, + /* 73*/ { "[22]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /* 74*/ { "[220]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 75*/ { "[2200]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 76*/ { "[23]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 77*/ { "[230]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 78*/ { "[2300]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 79*/ { "[235]1abcdefghijklmnopqrstuvwxyz0", 0, "2351abcdefghijklmnopqrstuvwxyz0" }, + /* 80*/ { "[235]1abcdefghijklmnopqrstuvwxyz01", ZINT_ERROR_INVALID_DATA, "" }, + /* 81*/ { "[24]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 82*/ { "[240]abcdefghijklmnopqrstuvwxyz1234", 0, "240abcdefghijklmnopqrstuvwxyz1234" }, + /* 83*/ { "[240]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, + /* 84*/ { "[2400]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 85*/ { "[241]abcdefghijklmnopqrstuvwxyz1234", 0, "241abcdefghijklmnopqrstuvwxyz1234" }, + /* 86*/ { "[241]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, + /* 87*/ { "[2410]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 88*/ { "[242]12345", 0, "24212345" }, + /* 89*/ { "[242]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /* 90*/ { "[2420]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 91*/ { "[243]abcdefghijklmnopqrst", 0, "243abcdefghijklmnopqrst" }, + /* 92*/ { "[243]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /* 93*/ { "[2430]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 94*/ { "[244]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 95*/ { "[2440]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 96*/ { "[249]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 97*/ { "[2490]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 98*/ { "[25]1234", ZINT_ERROR_INVALID_DATA, "" }, + /* 99*/ { "[250]abcdefghijklmnopqrstuvwxyz1234", 0, "250abcdefghijklmnopqrstuvwxyz1234" }, + /*100*/ { "[250]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, + /*101*/ { "[2500]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*102*/ { "[251]abcdefghijklmnopqrstuvwxyz1234", 0, "251abcdefghijklmnopqrstuvwxyz1234" }, + /*103*/ { "[251]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, + /*104*/ { "[2510]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*105*/ { "[252]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*106*/ { "[2520]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*107*/ { "[253]131313131313", ZINT_ERROR_INVALID_DATA, "" }, + /*108*/ { "[253]1313131313134", ZINT_WARN_NONCOMPLIANT, "2531313131313134" }, + /*109*/ { "[253]1313131313130", 0, "2531313131313130" }, + /*110*/ { "[253]131313131313412345678901234567", ZINT_WARN_NONCOMPLIANT, "253131313131313412345678901234567" }, + /*111*/ { "[253]131313131313012345678901234567", 0, "253131313131313012345678901234567" }, + /*112*/ { "[253]1313131313134123456789012345678", ZINT_ERROR_INVALID_DATA, "" }, + /*113*/ { "[2530]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*114*/ { "[254]abcdefghijklmnopqrst", 0, "254abcdefghijklmnopqrst" }, + /*115*/ { "[254]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*116*/ { "[2540]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*117*/ { "[255]131313131313", ZINT_ERROR_INVALID_DATA, "" }, + /*118*/ { "[255]1313131313134", ZINT_WARN_NONCOMPLIANT, "2551313131313134" }, + /*119*/ { "[255]1313131313130", 0, "2551313131313130" }, + /*120*/ { "[255]1313131313134123456789012", ZINT_WARN_NONCOMPLIANT, "2551313131313134123456789012" }, + /*121*/ { "[255]1313131313130123456789012", 0, "2551313131313130123456789012" }, + /*122*/ { "[255]13131313131341234567890123", ZINT_ERROR_INVALID_DATA, "" }, + /*123*/ { "[2550]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*124*/ { "[256]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*125*/ { "[2560]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*126*/ { "[259]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*127*/ { "[2590]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*128*/ { "[26]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*129*/ { "[260]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*130*/ { "[2600]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*131*/ { "[27]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*132*/ { "[270]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*133*/ { "[2700]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*134*/ { "[28]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*135*/ { "[280]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*136*/ { "[2800]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*137*/ { "[29]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*138*/ { "[290]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*139*/ { "[2900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*140*/ { "[30]12345678", 0, "3012345678" }, + /*141*/ { "[30]123456789", ZINT_ERROR_INVALID_DATA, "" }, + /*142*/ { "[300]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*143*/ { "[3000]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*144*/ { "[31]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*145*/ { "[310]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*146*/ { "[3100]123456", 0, "3100123456" }, + /*147*/ { "[3100]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*148*/ { "[3101]123456", 0, "3101123456" }, + /*149*/ { "[3101]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*150*/ { "[3105]123456", 0, "3105123456" }, + /*151*/ { "[3105]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*152*/ { "[3106]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*153*/ { "[3109]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*154*/ { "[3110]123456", 0, "3110123456" }, + /*155*/ { "[3110]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*156*/ { "[3115]123456", 0, "3115123456" }, + /*157*/ { "[3115]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*158*/ { "[3116]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*159*/ { "[3119]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*160*/ { "[3120]123456", 0, "3120123456" }, + /*161*/ { "[3120]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*162*/ { "[3125]123456", 0, "3125123456" }, + /*163*/ { "[3125]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*164*/ { "[3126]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*165*/ { "[3129]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*166*/ { "[3130]123456", 0, "3130123456" }, + /*167*/ { "[3130]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*168*/ { "[3135]123456", 0, "3135123456" }, + /*169*/ { "[3135]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*170*/ { "[3136]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*171*/ { "[3139]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*172*/ { "[3140]123456", 0, "3140123456" }, + /*173*/ { "[3140]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*174*/ { "[3145]123456", 0, "3145123456" }, + /*175*/ { "[3145]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*176*/ { "[3146]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*177*/ { "[3149]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*178*/ { "[3150]123456", 0, "3150123456" }, + /*179*/ { "[3150]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*180*/ { "[3155]123456", 0, "3155123456" }, + /*181*/ { "[3155]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*182*/ { "[3156]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*183*/ { "[3159]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*184*/ { "[3160]123456", 0, "3160123456" }, + /*185*/ { "[3160]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*186*/ { "[3165]123456", 0, "3165123456" }, + /*187*/ { "[3165]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*188*/ { "[3166]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*189*/ { "[3169]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*190*/ { "[3170]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*191*/ { "[3179]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*192*/ { "[3180]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*193*/ { "[3189]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*194*/ { "[3190]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*195*/ { "[3199]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*196*/ { "[32]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*197*/ { "[320]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*198*/ { "[3200]123456", 0, "3200123456" }, + /*199*/ { "[3200]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*200*/ { "[3205]123456", 0, "3205123456" }, + /*201*/ { "[3205]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*202*/ { "[3206]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*203*/ { "[3209]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*204*/ { "[3210]123456", 0, "3210123456" }, + /*205*/ { "[3210]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*206*/ { "[3215]123456", 0, "3215123456" }, + /*207*/ { "[3215]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*208*/ { "[3216]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*209*/ { "[3219]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*210*/ { "[3220]123456", 0, "3220123456" }, + /*211*/ { "[3220]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*212*/ { "[3225]123456", 0, "3225123456" }, + /*213*/ { "[3225]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*214*/ { "[3229]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*215*/ { "[3230]123456", 0, "3230123456" }, + /*216*/ { "[3230]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*217*/ { "[3235]123456", 0, "3235123456" }, + /*218*/ { "[3235]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*219*/ { "[3239]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*220*/ { "[3240]123456", 0, "3240123456" }, + /*221*/ { "[3240]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*222*/ { "[3245]123456", 0, "3245123456" }, + /*223*/ { "[3245]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*224*/ { "[3249]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*225*/ { "[3250]123456", 0, "3250123456" }, + /*226*/ { "[3250]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*227*/ { "[3255]123456", 0, "3255123456" }, + /*228*/ { "[3255]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*229*/ { "[3259]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*230*/ { "[3260]123456", 0, "3260123456" }, + /*231*/ { "[3260]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*232*/ { "[3265]123456", 0, "3265123456" }, + /*233*/ { "[3265]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*234*/ { "[3269]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*235*/ { "[3270]123456", 0, "3270123456" }, + /*236*/ { "[3270]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*237*/ { "[3275]123456", 0, "3275123456" }, + /*238*/ { "[3275]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*239*/ { "[3279]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*240*/ { "[3280]123456", 0, "3280123456" }, + /*241*/ { "[3280]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*242*/ { "[3285]123456", 0, "3285123456" }, + /*243*/ { "[3285]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*244*/ { "[3289]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*245*/ { "[3290]123456", 0, "3290123456" }, + /*246*/ { "[3290]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*247*/ { "[3295]123456", 0, "3295123456" }, + /*248*/ { "[3295]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*249*/ { "[3296]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*250*/ { "[3299]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*251*/ { "[33]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*252*/ { "[330]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*253*/ { "[3300]123456", 0, "3300123456" }, + /*254*/ { "[3300]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*255*/ { "[3305]123456", 0, "3305123456" }, + /*256*/ { "[3305]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*257*/ { "[3306]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*258*/ { "[3309]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*259*/ { "[3310]123456", 0, "3310123456" }, + /*260*/ { "[3310]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*261*/ { "[3319]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*262*/ { "[3320]123456", 0, "3320123456" }, + /*263*/ { "[3320]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*264*/ { "[3329]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*265*/ { "[3330]123456", 0, "3330123456" }, + /*266*/ { "[3330]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*267*/ { "[3339]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*268*/ { "[3340]123456", 0, "3340123456" }, + /*269*/ { "[3340]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*270*/ { "[3349]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*271*/ { "[3350]123456", 0, "3350123456" }, + /*272*/ { "[3350]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*273*/ { "[3359]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*274*/ { "[3360]123456", 0, "3360123456" }, + /*275*/ { "[3360]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*276*/ { "[3369]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*277*/ { "[3370]123456", 0, "3370123456" }, + /*278*/ { "[3370]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*279*/ { "[3375]123456", 0, "3375123456" }, + /*280*/ { "[3375]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*281*/ { "[3376]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*282*/ { "[3379]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*283*/ { "[3380]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*284*/ { "[3390]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*285*/ { "[3399]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*286*/ { "[34]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*287*/ { "[340]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*288*/ { "[3400]123456", 0, "3400123456" }, + /*289*/ { "[3400]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*290*/ { "[3405]123456", 0, "3405123456" }, + /*291*/ { "[3405]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*292*/ { "[3406]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*293*/ { "[3409]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*294*/ { "[3410]123456", 0, "3410123456" }, + /*295*/ { "[3410]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*296*/ { "[3419]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*297*/ { "[3420]123456", 0, "3420123456" }, + /*298*/ { "[3420]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*299*/ { "[3429]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*300*/ { "[3430]123456", 0, "3430123456" }, + /*301*/ { "[3430]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*302*/ { "[3439]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*303*/ { "[3440]123456", 0, "3440123456" }, + /*304*/ { "[3440]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*305*/ { "[3449]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*306*/ { "[3450]123456", 0, "3450123456" }, + /*307*/ { "[3450]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*308*/ { "[3459]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*309*/ { "[3460]123456", 0, "3460123456" }, + /*310*/ { "[3460]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*311*/ { "[3469]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*312*/ { "[3470]123456", 0, "3470123456" }, + /*313*/ { "[3470]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*314*/ { "[3479]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*315*/ { "[3480]123456", 0, "3480123456" }, + /*316*/ { "[3480]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*317*/ { "[3489]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*318*/ { "[3490]123456", 0, "3490123456" }, + /*319*/ { "[3490]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*320*/ { "[3495]123456", 0, "3495123456" }, + /*321*/ { "[3495]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*322*/ { "[3496]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*323*/ { "[3499]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*324*/ { "[35]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*325*/ { "[350]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*326*/ { "[3500]123456", 0, "3500123456" }, + /*327*/ { "[3500]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*328*/ { "[3505]123456", 0, "3505123456" }, + /*329*/ { "[3505]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*330*/ { "[3506]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*331*/ { "[3509]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*332*/ { "[3510]123456", 0, "3510123456", }, + /*333*/ { "[3510]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*334*/ { "[3519]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*335*/ { "[3520]123456", 0, "3520123456", }, + /*336*/ { "[3520]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*337*/ { "[3529]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*338*/ { "[3530]123456", 0, "3530123456", }, + /*339*/ { "[3530]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*340*/ { "[3539]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*341*/ { "[3540]123456", 0, "3540123456", }, + /*342*/ { "[3540]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*343*/ { "[3549]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*344*/ { "[3550]123456", 0, "3550123456", }, + /*345*/ { "[3550]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*346*/ { "[3559]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*347*/ { "[3560]123456", 0, "3560123456", }, + /*348*/ { "[3560]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*349*/ { "[3569]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*350*/ { "[3570]123456", 0, "3570123456", }, + /*351*/ { "[3570]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*352*/ { "[3575]123456", 0, "3575123456" }, + /*353*/ { "[3376]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*354*/ { "[3579]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*355*/ { "[3580]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*356*/ { "[3590]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*357*/ { "[3599]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*358*/ { "[36]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*359*/ { "[360]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*360*/ { "[3600]123456", 0, "3600123456" }, + /*361*/ { "[3600]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*362*/ { "[3605]123456", 0, "3605123456" }, + /*363*/ { "[3605]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*364*/ { "[3606]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*365*/ { "[3609]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*366*/ { "[3610]123456", 0, "3610123456" }, + /*367*/ { "[3610]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*368*/ { "[3619]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*369*/ { "[3620]123456", 0, "3620123456", }, + /*370*/ { "[3620]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*371*/ { "[3629]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*372*/ { "[3630]123456", 0, "3630123456", }, + /*373*/ { "[3630]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*374*/ { "[3639]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*375*/ { "[3640]123456", 0, "3640123456", }, + /*376*/ { "[3640]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*377*/ { "[3649]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*378*/ { "[3650]123456", 0, "3650123456", }, + /*379*/ { "[3650]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*380*/ { "[3659]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*381*/ { "[3660]123456", 0, "3660123456", }, + /*382*/ { "[3660]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*383*/ { "[3669]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*384*/ { "[3670]123456", 0, "3670123456", }, + /*385*/ { "[3670]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*386*/ { "[3679]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*387*/ { "[3680]123456", 0, "3680123456", }, + /*388*/ { "[3680]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*389*/ { "[3689]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*390*/ { "[3690]123456", 0, "3690123456" }, + /*391*/ { "[3690]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*392*/ { "[3695]123456", 0, "3695123456" }, + /*393*/ { "[3695]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*394*/ { "[3696]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*395*/ { "[3699]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*396*/ { "[37]12345678", 0, "3712345678" }, + /*397*/ { "[37]123456789", ZINT_ERROR_INVALID_DATA, "" }, + /*398*/ { "[370]12345678", ZINT_ERROR_INVALID_DATA, "" }, + /*399*/ { "[3700]12345678", ZINT_ERROR_INVALID_DATA, "" }, + /*400*/ { "[38]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*401*/ { "[380]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*402*/ { "[3800]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*403*/ { "[39]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*404*/ { "[390]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*405*/ { "[3900]123456789012345", 0, "3900123456789012345" }, + /*406*/ { "[3900]1234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*407*/ { "[3900]12345678901234", 0, "390012345678901234" }, + /*408*/ { "[3901]123456789012345", 0, "3901123456789012345" }, + /*409*/ { "[3901]1234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*410*/ { "[3905]123456789012345", 0, "3905123456789012345" }, + /*411*/ { "[3909]123456789012345", 0, "3909123456789012345" }, + /*412*/ { "[3909]1234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*413*/ { "[3910]123123456789012345", ZINT_WARN_NONCOMPLIANT, "3910123123456789012345" }, + /*414*/ { "[3910]997123456789012345", 0, "3910997123456789012345" }, + /*415*/ { "[3910]1231234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*416*/ { "[3910]123", ZINT_ERROR_INVALID_DATA, "" }, + /*417*/ { "[3915]123123456789012345", ZINT_WARN_NONCOMPLIANT, "3915123123456789012345" }, + /*418*/ { "[3915]997123456789012345", 0, "3915997123456789012345" }, + /*419*/ { "[3915]1231234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*420*/ { "[3919]123123456789012345", ZINT_WARN_NONCOMPLIANT, "3919123123456789012345" }, + /*421*/ { "[3919]997123456789012345", 0, "3919997123456789012345" }, + /*422*/ { "[3919]1231234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*423*/ { "[3920]123456789012345", 0, "3920123456789012345" }, + /*424*/ { "[3920]1234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*425*/ { "[3925]123456789012345", 0, "3925123456789012345" }, + /*426*/ { "[3925]1234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*427*/ { "[3929]123456789012345", 0, "3929123456789012345" }, + /*428*/ { "[3929]1234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*429*/ { "[3930]123123456789012345", ZINT_WARN_NONCOMPLIANT, "3930123123456789012345" }, + /*430*/ { "[3930]997123456789012345", 0, "3930997123456789012345" }, + /*431*/ { "[3930]1231234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*432*/ { "[3930]123", ZINT_ERROR_INVALID_DATA, "" }, + /*433*/ { "[3935]123123456789012345", ZINT_WARN_NONCOMPLIANT, "3935123123456789012345" }, + /*434*/ { "[3935]997123456789012345", 0, "3935997123456789012345" }, + /*435*/ { "[3935]1231234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*436*/ { "[3939]123123456789012345", ZINT_WARN_NONCOMPLIANT, "3939123123456789012345" }, + /*437*/ { "[3939]997123456789012345", 0, "3939997123456789012345" }, + /*438*/ { "[3939]1231234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*439*/ { "[3940]1234", 0, "39401234" }, + /*440*/ { "[3940]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*441*/ { "[3940]123", ZINT_ERROR_INVALID_DATA, "" }, + /*442*/ { "[3941]1234", 0, "39411234" }, + /*443*/ { "[3941]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*444*/ { "[3941]123", ZINT_ERROR_INVALID_DATA, "" }, + /*445*/ { "[3942]1234", 0, "39421234" }, + /*446*/ { "[3942]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*447*/ { "[3943]1234", 0, "39431234" }, + /*448*/ { "[3943]123", ZINT_ERROR_INVALID_DATA, "" }, + /*449*/ { "[3944]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*450*/ { "[3945]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*451*/ { "[3949]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*452*/ { "[3950]123456", 0, "3950123456" }, + /*453*/ { "[3950]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*454*/ { "[3950]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*455*/ { "[3951]123456", 0, "3951123456" }, + /*456*/ { "[3951]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*457*/ { "[3952]123456", 0, "3952123456" }, + /*458*/ { "[3952]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*459*/ { "[3953]123456", 0, "3953123456" }, + /*460*/ { "[3953]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*461*/ { "[3954]123456", 0, "3954123456" }, + /*462*/ { "[3954]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*463*/ { "[3955]123456", 0, "3955123456" }, + /*464*/ { "[3955]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*465*/ { "[3956]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*466*/ { "[3959]123456", ZINT_ERROR_INVALID_DATA, "" }, + /*467*/ { "[3960]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*468*/ { "[3970]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*469*/ { "[3980]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*470*/ { "[3999]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*471*/ { "[40]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*472*/ { "[400]123456789012345678901234567890", 0, "400123456789012345678901234567890" }, + /*473*/ { "[400]1234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*474*/ { "[4000]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*475*/ { "[401]1234abcdefghijklmnopqrstuvwxyz", 0, "4011234abcdefghijklmnopqrstuvwxyz" }, + /*476*/ { "[401]1234abcdefghijklmnopqrstuvwxyz1", ZINT_ERROR_INVALID_DATA, "" }, + /*477*/ { "[4010]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*478*/ { "[402]13131313131313132", ZINT_WARN_NONCOMPLIANT, "40213131313131313132" }, + /*479*/ { "[402]13131313131313130", 0, "40213131313131313130" }, + /*480*/ { "[402]1313131313131313", ZINT_ERROR_INVALID_DATA, "" }, + /*481*/ { "[4020]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*482*/ { "[403]abcdefghijklmnopqrstuvwxyz1234", 0, "403abcdefghijklmnopqrstuvwxyz1234" }, + /*483*/ { "[403]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, + /*484*/ { "[4030]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*485*/ { "[404]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*486*/ { "[4040]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*487*/ { "[409]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*488*/ { "[4090]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*489*/ { "[41]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*490*/ { "[410]3898765432108", 0, "4103898765432108" }, + /*491*/ { "[410]12345678901234", ZINT_ERROR_INVALID_DATA, "" }, + /*492*/ { "[4100]12345678901234", ZINT_ERROR_INVALID_DATA, "" }, + /*493*/ { "[411]1313131313134", ZINT_WARN_NONCOMPLIANT, "4111313131313134" }, + /*494*/ { "[411]1313131313130", 0, "4111313131313130" }, + /*495*/ { "[411]13131313131", ZINT_ERROR_INVALID_DATA, "" }, + /*496*/ { "[4110]1313131313134", ZINT_ERROR_INVALID_DATA, "" }, + /*497*/ { "[412]1313131313130", 0, "4121313131313130" }, + /*498*/ { "[412]13131313131", ZINT_ERROR_INVALID_DATA, "" }, + /*499*/ { "[4120]1313131313134", ZINT_ERROR_INVALID_DATA, "" }, + /*500*/ { "[413]1313131313130", 0, "4131313131313130" }, + /*501*/ { "[413]13131313131", ZINT_ERROR_INVALID_DATA, "" }, + /*502*/ { "[4130]1313131313134", ZINT_ERROR_INVALID_DATA, "" }, + /*503*/ { "[414]1313131313130", 0, "4141313131313130" }, + /*504*/ { "[414]13131313131", ZINT_ERROR_INVALID_DATA, "" }, + /*505*/ { "[4140]1313131313134", ZINT_ERROR_INVALID_DATA, "" }, + /*506*/ { "[415]1313131313130", 0, "4151313131313130" }, + /*507*/ { "[415]13131313131", ZINT_ERROR_INVALID_DATA, "" }, + /*508*/ { "[4150]1313131313134", ZINT_ERROR_INVALID_DATA, "" }, + /*509*/ { "[416]1313131313130", 0, "4161313131313130" }, + /*510*/ { "[416]13131313131", ZINT_ERROR_INVALID_DATA, "" }, + /*511*/ { "[4160]1313131313134", ZINT_ERROR_INVALID_DATA, "" }, + /*512*/ { "[417]1313131313130", 0, "4171313131313130" }, + /*513*/ { "[417]13131313131", ZINT_ERROR_INVALID_DATA, "" }, + /*514*/ { "[4170]1313131313134", ZINT_ERROR_INVALID_DATA, "" }, + /*515*/ { "[418]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*516*/ { "[4180]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*517*/ { "[419]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*518*/ { "[4190]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*519*/ { "[42]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*520*/ { "[420]abcdefghijklmnopqrst", 0, "420abcdefghijklmnopqrst" }, + /*521*/ { "[420]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*522*/ { "[4200]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*523*/ { "[421]123abcdefghi", ZINT_WARN_NONCOMPLIANT, "421123abcdefghi" }, + /*524*/ { "[421]434abcdefghi", 0, "421434abcdefghi" }, + /*525*/ { "[421]123abcdefghij", ZINT_ERROR_INVALID_DATA, "" }, + /*526*/ { "[421]1231", ZINT_WARN_NONCOMPLIANT, "4211231" }, + /*527*/ { "[421]4341", 0, "4214341" }, + /*528*/ { "[421]123", ZINT_ERROR_INVALID_DATA, "" }, + /*529*/ { "[4210]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*530*/ { "[422]123", ZINT_WARN_NONCOMPLIANT, "422123" }, + /*531*/ { "[422]004", 0, "422004" }, + /*532*/ { "[422]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*533*/ { "[422]12", ZINT_ERROR_INVALID_DATA, "" }, + /*534*/ { "[4220]123", ZINT_ERROR_INVALID_DATA, "" }, + /*535*/ { "[423]123123123123123", ZINT_WARN_NONCOMPLIANT, "423123123123123123" }, + /*536*/ { "[423]470004012887123", ZINT_WARN_NONCOMPLIANT, "423470004012887123" }, + /*537*/ { "[423]470004012887438", 0, "423470004012887438" }, + /*538*/ { "[423]1231231231231231", ZINT_ERROR_INVALID_DATA, "4231231231231231231" }, + /*539*/ { "[423]12312312312312", ZINT_WARN_NONCOMPLIANT, "42312312312312312" }, + /*540*/ { "[423]1231231231231", ZINT_WARN_NONCOMPLIANT, "4231231231231231" }, + /*541*/ { "[423]12312312312", ZINT_WARN_NONCOMPLIANT, "42312312312312" }, + /*542*/ { "[423]1231231231", ZINT_WARN_NONCOMPLIANT, "4231231231231" }, + /*543*/ { "[423]123", ZINT_WARN_NONCOMPLIANT, "423123" }, + /*544*/ { "[423]004", 0, "423004" }, + /*545*/ { "[423]12", ZINT_ERROR_INVALID_DATA, "" }, + /*546*/ { "[4230]123123123123123", ZINT_ERROR_INVALID_DATA, "" }, + /*547*/ { "[424]123", ZINT_WARN_NONCOMPLIANT, "424123" }, + /*548*/ { "[424]004", 0, "424004" }, + /*549*/ { "[424]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*550*/ { "[424]12", ZINT_ERROR_INVALID_DATA, "" }, + /*551*/ { "[4240]123", ZINT_ERROR_INVALID_DATA, "" }, + /*552*/ { "[425]123123123123123", ZINT_WARN_NONCOMPLIANT, "425123123123123123" }, + /*553*/ { "[425]010500276634894", 0, "425010500276634894" }, + /*554*/ { "[425]010500276123894", ZINT_WARN_NONCOMPLIANT, "425010500276123894" }, + /*555*/ { "[425]1231231231231231", ZINT_ERROR_INVALID_DATA, "" }, + /*556*/ { "[425]12", ZINT_ERROR_INVALID_DATA, "" }, + /*557*/ { "[4250]123123123123123", ZINT_ERROR_INVALID_DATA, "" }, + /*558*/ { "[426]123", ZINT_WARN_NONCOMPLIANT, "426123" }, + /*559*/ { "[426]426", 0, "426426" }, + /*560*/ { "[426]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*561*/ { "[426]12", ZINT_ERROR_INVALID_DATA, "" }, + /*562*/ { "[4260]123", ZINT_ERROR_INVALID_DATA, "" }, + /*563*/ { "[427]abc", 0, "427abc" }, + /*564*/ { "[427]abcd", ZINT_ERROR_INVALID_DATA, "" }, + /*565*/ { "[4270]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*566*/ { "[428]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*567*/ { "[4280]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*568*/ { "[429]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*569*/ { "[4290]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*570*/ { "[43]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*571*/ { "[430]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*572*/ { "[4300]1", 0, "43001" }, + /*573*/ { "[4300]12345678901234567890123456789012345", 0, "430012345678901234567890123456789012345" }, + /*574*/ { "[4300]123456789012345678901234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*575*/ { "[4301]1", 0, "43011" }, + /*576*/ { "[4301]12345678901234567890123456789012345", 0, "430112345678901234567890123456789012345" }, + /*577*/ { "[4301]123456789012345678901234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*578*/ { "[4302]1", 0, "43021" }, + /*579*/ { "[4302]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43021234567890123456789012345678901234567890123456789012345678901234567890" }, + /*580*/ { "[4302]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*581*/ { "[4303]1", 0, "43031" }, + /*582*/ { "[4303]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43031234567890123456789012345678901234567890123456789012345678901234567890" }, + /*583*/ { "[4303]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*584*/ { "[4304]1", 0, "43041" }, + /*585*/ { "[4304]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43041234567890123456789012345678901234567890123456789012345678901234567890" }, + /*586*/ { "[4304]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*587*/ { "[4305]1", 0, "43051" }, + /*588*/ { "[4305]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43051234567890123456789012345678901234567890123456789012345678901234567890" }, + /*589*/ { "[4305]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*590*/ { "[4306]1", 0, "43061" }, + /*591*/ { "[4306]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43061234567890123456789012345678901234567890123456789012345678901234567890" }, + /*592*/ { "[4306]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*593*/ { "[4307]FR", 0, "4307FR" }, + /*594*/ { "[4307]F", ZINT_ERROR_INVALID_DATA, "" }, + /*595*/ { "[4307]FRR", ZINT_ERROR_INVALID_DATA, "" }, + /*596*/ { "[4308]1", 0, "43081" }, + /*597*/ { "[4308]123456789012345678901234567890", 0, "4308123456789012345678901234567890" }, + /*598*/ { "[4308]1234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*599*/ { "[4309]1", ZINT_ERROR_INVALID_DATA, "" }, + /*600*/ { "[431]1", ZINT_ERROR_INVALID_DATA, "" }, + /*601*/ { "[4310]1", 0, "43101" }, + /*602*/ { "[4310]12345678901234567890123456789012345", 0, "431012345678901234567890123456789012345" }, + /*603*/ { "[4310]123456789012345678901234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*604*/ { "[4311]1", 0, "43111" }, + /*605*/ { "[4311]12345678901234567890123456789012345", 0, "431112345678901234567890123456789012345" }, + /*606*/ { "[4311]123456789012345678901234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*607*/ { "[4312]1", 0, "43121" }, + /*608*/ { "[4312]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43121234567890123456789012345678901234567890123456789012345678901234567890" }, + /*609*/ { "[4312]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*610*/ { "[4313]1", 0, "43131" }, + /*611*/ { "[4313]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43131234567890123456789012345678901234567890123456789012345678901234567890" }, + /*612*/ { "[4313]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*613*/ { "[4314]1", 0, "43141" }, + /*614*/ { "[4314]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43141234567890123456789012345678901234567890123456789012345678901234567890" }, + /*615*/ { "[4314]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*616*/ { "[4315]1", 0, "43151" }, + /*617*/ { "[4315]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43151234567890123456789012345678901234567890123456789012345678901234567890" }, + /*618*/ { "[4315]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*619*/ { "[4316]1", 0, "43161" }, + /*620*/ { "[4316]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "43161234567890123456789012345678901234567890123456789012345678901234567890" }, + /*621*/ { "[4316]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*622*/ { "[4317]FR", 0, "4317FR" }, + /*623*/ { "[4317]F", ZINT_ERROR_INVALID_DATA, "" }, + /*624*/ { "[4317]FRF", ZINT_ERROR_INVALID_DATA, "" }, + /*625*/ { "[4318]1", 0, "43181" }, + /*626*/ { "[4318]12345678901234567890", 0, "431812345678901234567890" }, + /*627*/ { "[4318]123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*628*/ { "[4319]1", 0, "43191" }, + /*629*/ { "[4319]123456789012345678901234567890", 0, "4319123456789012345678901234567890" }, + /*630*/ { "[4319]1234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*631*/ { "[432]1", ZINT_ERROR_INVALID_DATA, "" }, + /*632*/ { "[4320]1", 0, "43201" }, + /*633*/ { "[4320]12345678901234567890123456789012345", 0, "432012345678901234567890123456789012345" }, + /*634*/ { "[4320]123456789012345678901234567890123456", ZINT_ERROR_INVALID_DATA, "" }, + /*635*/ { "[4321]1", 0, "43211" }, + /*636*/ { "[4321]10", ZINT_ERROR_INVALID_DATA, "" }, + /*637*/ { "[4322]1", 0, "43221" }, + /*638*/ { "[4322]10", ZINT_ERROR_INVALID_DATA, "" }, + /*639*/ { "[4323]1", 0, "43231" }, + /*640*/ { "[4323]10", ZINT_ERROR_INVALID_DATA, "" }, + /*641*/ { "[4324]1212120000", 0, "43241212120000" }, + /*642*/ { "[4324]121212000", ZINT_ERROR_INVALID_DATA, "" }, + /*643*/ { "[4324]12121200000", ZINT_ERROR_INVALID_DATA, "" }, + /*644*/ { "[4325]1212120000", 0, "43251212120000" }, + /*645*/ { "[4325]121212000", ZINT_ERROR_INVALID_DATA, "" }, + /*646*/ { "[4325]12121200000", ZINT_ERROR_INVALID_DATA, "" }, + /*647*/ { "[4326]121212", 0, "4326121212" }, + /*648*/ { "[4326]12121", ZINT_ERROR_INVALID_DATA, "" }, + /*649*/ { "[4326]1212120", ZINT_ERROR_INVALID_DATA, "" }, + /*650*/ { "[4327]121212", ZINT_ERROR_INVALID_DATA, "" }, + /*651*/ { "[4328]121212", ZINT_ERROR_INVALID_DATA, "" }, + /*652*/ { "[4329]121212", ZINT_ERROR_INVALID_DATA, "" }, + /*653*/ { "[433]121212", ZINT_ERROR_INVALID_DATA, "" }, + /*654*/ { "[4330]121212", ZINT_ERROR_INVALID_DATA, "" }, + /*655*/ { "[44]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*656*/ { "[440]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*657*/ { "[4400]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*658*/ { "[49]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*659*/ { "[490]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*660*/ { "[4900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*661*/ { "[499]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*662*/ { "[4990]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*663*/ { "[50]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*664*/ { "[500]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*665*/ { "[5000]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*666*/ { "[51]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*667*/ { "[510]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*668*/ { "[5100]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*669*/ { "[59]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*670*/ { "[590]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*671*/ { "[5900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*672*/ { "[60]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*673*/ { "[600]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*674*/ { "[6000]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*675*/ { "[61]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*676*/ { "[610]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*677*/ { "[6100]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*678*/ { "[69]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*679*/ { "[690]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*680*/ { "[6900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*681*/ { "[70]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*682*/ { "[700]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*683*/ { "[7000]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*684*/ { "[7001]1234567890123", 0, "70011234567890123" }, + /*685*/ { "[7001]123456789012", ZINT_ERROR_INVALID_DATA, "" }, + /*686*/ { "[7002]abcdefghijklmnopqrstuvwxyz1234", 0, "7002abcdefghijklmnopqrstuvwxyz1234" }, + /*687*/ { "[7002]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, + /*688*/ { "[7003]1212121212", 0, "70031212121212" }, + /*689*/ { "[7003]121212121", ZINT_ERROR_INVALID_DATA, "" }, + /*690*/ { "[7004]1234", 0, "70041234" }, + /*691*/ { "[7004]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*692*/ { "[7005]abcdefghijkl", 0, "7005abcdefghijkl" }, + /*693*/ { "[7005]abcdefghijklm", ZINT_ERROR_INVALID_DATA, "" }, + /*694*/ { "[7006]200132", ZINT_WARN_NONCOMPLIANT, "7006200132" }, + /*695*/ { "[7006]200100", ZINT_WARN_NONCOMPLIANT, "7006200100" }, + /*696*/ { "[7006]200120", 0, "7006200120" }, + /*697*/ { "[7006]2001320", ZINT_ERROR_INVALID_DATA, "" }, + /*698*/ { "[7007]010101121212", 0, "7007010101121212" }, + /*699*/ { "[7007]01010112121", ZINT_ERROR_INVALID_DATA, "" }, + /*700*/ { "[7007]A1010112121", ZINT_ERROR_INVALID_DATA, "" }, + /*701*/ { "[7007]121212", 0, "7007121212" }, + /*702*/ { "[7007]12121", ZINT_ERROR_INVALID_DATA, "" }, + /*703*/ { "[7007]1212121", ZINT_ERROR_INVALID_DATA, "" }, + /*704*/ { "[7008]abc", 0, "7008abc" }, + /*705*/ { "[7008]abcd", ZINT_ERROR_INVALID_DATA, "" }, + /*706*/ { "[7009]abcdefghij", 0, "7009abcdefghij" }, + /*707*/ { "[7009]abcdefghijk", ZINT_ERROR_INVALID_DATA, "" }, + /*708*/ { "[7010]01", 0, "701001" }, + /*709*/ { "[7010]1", 0, "70101" }, + /*710*/ { "[7010]012", ZINT_ERROR_INVALID_DATA, "" }, + /*711*/ { "[7011]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*712*/ { "[7012]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*713*/ { "[7019]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*714*/ { "[7020]abcdefghijklmnopqrst", 0, "7020abcdefghijklmnopqrst" }, + /*715*/ { "[7020]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*716*/ { "[7021]abcdefghijklmnopqrst", 0, "7021abcdefghijklmnopqrst" }, + /*717*/ { "[7021]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*718*/ { "[7022]abcdefghijklmnopqrst", 0, "7022abcdefghijklmnopqrst" }, + /*719*/ { "[7022]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*720*/ { "[7023]1234abcdefghijklmnopqrstuvwxyz", 0, "70231234abcdefghijklmnopqrstuvwxyz" }, + /*721*/ { "[7023]1234abcdefghijklmnopqrstuvwxyza", ZINT_ERROR_INVALID_DATA, "" }, + /*722*/ { "[7024]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*723*/ { "[7025]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*724*/ { "[7029]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*725*/ { "[7030]123abcdefghijklmnopqrstuvwxyza", ZINT_WARN_NONCOMPLIANT, "7030123abcdefghijklmnopqrstuvwxyza" }, + /*726*/ { "[7030]004abcdefghijklmnopqrstuvwxyza", 0, "7030004abcdefghijklmnopqrstuvwxyza" }, + /*727*/ { "[7030]123abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*728*/ { "[7031]123abcdefghijklmnopqrstuvwxyza", ZINT_WARN_NONCOMPLIANT, "7031123abcdefghijklmnopqrstuvwxyza" }, + /*729*/ { "[7031]004abcdefghijklmnopqrstuvwxyza", 0, "7031004abcdefghijklmnopqrstuvwxyza" }, + /*730*/ { "[7031]123abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*731*/ { "[7032]004abcdefghijklmnopqrstuvwxyza", 0, "7032004abcdefghijklmnopqrstuvwxyza" }, + /*732*/ { "[7032]004abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*733*/ { "[7033]004abcdefghijklmnopqrstuvwxyza", 0, "7033004abcdefghijklmnopqrstuvwxyza" }, + /*734*/ { "[7033]004abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*735*/ { "[7034]004abcdefghijklmnopqrstuvwxyza", 0, "7034004abcdefghijklmnopqrstuvwxyza" }, + /*736*/ { "[7034]004abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*737*/ { "[7035]004abcdefghijklmnopqrstuvwxyza", 0, "7035004abcdefghijklmnopqrstuvwxyza" }, + /*738*/ { "[7035]004abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*739*/ { "[7036]004abcdefghijklmnopqrstuvwxyza", 0, "7036004abcdefghijklmnopqrstuvwxyza" }, + /*740*/ { "[7036]004abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*741*/ { "[7037]004abcdefghijklmnopqrstuvwxyza", 0, "7037004abcdefghijklmnopqrstuvwxyza" }, + /*742*/ { "[7037]004abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*743*/ { "[7038]004abcdefghijklmnopqrstuvwxyza", 0, "7038004abcdefghijklmnopqrstuvwxyza" }, + /*744*/ { "[7038]004abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*745*/ { "[7039]004abcdefghijklmnopqrstuvwxyza", 0, "7039004abcdefghijklmnopqrstuvwxyza" }, + /*746*/ { "[7039]123abcdefghijklmnopqrstuvwxyzab", ZINT_ERROR_INVALID_DATA, "" }, + /*747*/ { "[7040]1abc", 0, "70401abc" }, + /*748*/ { "[7040]1ab", ZINT_ERROR_INVALID_DATA, "" }, + /*749*/ { "[7040]1abcd", ZINT_ERROR_INVALID_DATA, "" }, + /*750*/ { "[7041]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*751*/ { "[7042]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*752*/ { "[7050]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*753*/ { "[7090]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*754*/ { "[7099]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*755*/ { "[71]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*756*/ { "[710]abcdefghijklmnopqrst", 0, "710abcdefghijklmnopqrst" }, + /*757*/ { "[710]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*758*/ { "[7100]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*759*/ { "[711]abcdefghijklmnopqrst", 0, "711abcdefghijklmnopqrst" }, + /*760*/ { "[711]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*761*/ { "[712]abcdefghijklmnopqrst", 0, "712abcdefghijklmnopqrst" }, + /*762*/ { "[712]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*763*/ { "[713]abcdefghijklmnopqrst", 0, "713abcdefghijklmnopqrst" }, + /*764*/ { "[713]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*765*/ { "[714]abcdefghijklmnopqrst", 0, "714abcdefghijklmnopqrst" }, + /*766*/ { "[714]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*767*/ { "[715]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*768*/ { "[716]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*769*/ { "[719]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*770*/ { "[72]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*771*/ { "[720]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*772*/ { "[7200]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*773*/ { "[721]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*774*/ { "[7210]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*775*/ { "[7220]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*776*/ { "[7230]EMabcdefghijklmnopqrstuvwxyzab", 0, "7230EMabcdefghijklmnopqrstuvwxyzab" }, + /*777*/ { "[7230]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*778*/ { "[7230]EM", ZINT_ERROR_INVALID_DATA, "" }, + /*779*/ { "[7231]EMabcdefghijklmnopqrstuvwxyzab", 0, "7231EMabcdefghijklmnopqrstuvwxyzab" }, + /*780*/ { "[7231]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*781*/ { "[7232]EMabcdefghijklmnopqrstuvwxyzab", 0, "7232EMabcdefghijklmnopqrstuvwxyzab" }, + /*782*/ { "[7232]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*783*/ { "[7233]EMabcdefghijklmnopqrstuvwxyzab", 0, "7233EMabcdefghijklmnopqrstuvwxyzab" }, + /*784*/ { "[7233]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*785*/ { "[7234]EMabcdefghijklmnopqrstuvwxyzab", 0, "7234EMabcdefghijklmnopqrstuvwxyzab" }, + /*786*/ { "[7234]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*787*/ { "[7235]EMabcdefghijklmnopqrstuvwxyzab", 0, "7235EMabcdefghijklmnopqrstuvwxyzab" }, + /*788*/ { "[7235]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*789*/ { "[7236]EMabcdefghijklmnopqrstuvwxyzab", 0, "7236EMabcdefghijklmnopqrstuvwxyzab" }, + /*790*/ { "[7236]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*791*/ { "[7237]EMabcdefghijklmnopqrstuvwxyzab", 0, "7237EMabcdefghijklmnopqrstuvwxyzab" }, + /*792*/ { "[7237]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*793*/ { "[7238]EMabcdefghijklmnopqrstuvwxyzab", 0, "7238EMabcdefghijklmnopqrstuvwxyzab" }, + /*794*/ { "[7238]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*795*/ { "[7239]EMabcdefghijklmnopqrstuvwxyzab", 0, "7239EMabcdefghijklmnopqrstuvwxyzab" }, + /*796*/ { "[7239]EMabcdefghijklmnopqrstuvwxyzabc", ZINT_ERROR_INVALID_DATA, "" }, + /*797*/ { "[7239]E", ZINT_ERROR_INVALID_DATA, "" }, + /*798*/ { "[7240]abcdefghijklmnopqrst", 0, "7240abcdefghijklmnopqrst" }, + /*799*/ { "[7240]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*800*/ { "[7241]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*801*/ { "[7249]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*802*/ { "[7250]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*803*/ { "[7299]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*804*/ { "[73]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*805*/ { "[7300]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*806*/ { "[74]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*807*/ { "[7400]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*808*/ { "[79]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*809*/ { "[7900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*810*/ { "[7999]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*811*/ { "[80]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*812*/ { "[800]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*813*/ { "[8000]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*814*/ { "[8001]12345678901234", ZINT_WARN_NONCOMPLIANT, "800112345678901234" }, + /*815*/ { "[8001]12345678901204", 0, "800112345678901204" }, + /*816*/ { "[8001]1234123456789012345", ZINT_ERROR_INVALID_DATA, "" }, + /*817*/ { "[8002]abcdefghijklmnopqrst", 0, "8002abcdefghijklmnopqrst" }, + /*818*/ { "[8002]abcdefghijklmnopqrstu", ZINT_ERROR_INVALID_DATA, "" }, + /*819*/ { "[8003]01234567890123abcdefghijklmnop", ZINT_WARN_NONCOMPLIANT, "800301234567890123abcdefghijklmnop" }, + /*820*/ { "[8003]01234567890128abcdefghijklmnop", 0, "800301234567890128abcdefghijklmnop" }, + /*821*/ { "[8003]01234567890128abcdefghijklmnopq", ZINT_ERROR_INVALID_DATA, "" }, + /*822*/ { "[8004]abcdefghijklmnopqrstuvwxyz1234", ZINT_WARN_NONCOMPLIANT, "8004abcdefghijklmnopqrstuvwxyz1234" }, + /*823*/ { "[8004]12cdefghijklmnopqrstuvwxyz1234", 0, "800412cdefghijklmnopqrstuvwxyz1234" }, + /*824*/ { "[8004]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, + /*825*/ { "[8005]123456", 0, "8005123456" }, + /*826*/ { "[8005]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*827*/ { "[8005]1234567", ZINT_ERROR_INVALID_DATA, "" }, + /*828*/ { "[8006]123456789012341212", ZINT_WARN_NONCOMPLIANT, "8006123456789012341212" }, + /*829*/ { "[8006]123456789012311212", 0, "8006123456789012311212" }, + /*830*/ { "[8006]12345678901234121", ZINT_ERROR_INVALID_DATA, "" }, + /*831*/ { "[8006]1234567890123412123", ZINT_ERROR_INVALID_DATA, "" }, + /*832*/ { "[8007]abcdefghijklmnopqrstuvwxyz12345678", ZINT_WARN_NONCOMPLIANT, "8007abcdefghijklmnopqrstuvwxyz12345678" }, + /*833*/ { "[8007]AD95EFGHIJKLMNOPQRSTUVWXYZ12345678", 0, "8007AD95EFGHIJKLMNOPQRSTUVWXYZ12345678" }, + /*834*/ { "[8007]AD95EFGHIJKLMNOPQRSTUVWXYZ123456789", ZINT_ERROR_INVALID_DATA, "" }, + /*835*/ { "[8008]123456121212", ZINT_WARN_NONCOMPLIANT, "8008123456121212" }, + /*836*/ { "[8008]121256121212", ZINT_WARN_NONCOMPLIANT, "8008121256121212" }, + /*837*/ { "[8008]121231121212", 0, "8008121231121212" }, + /*838*/ { "[8008]1234561212", ZINT_WARN_NONCOMPLIANT, "80081234561212" }, + /*839*/ { "[8008]1212311212", 0, "80081212311212" }, + /*840*/ { "[8008]12345612", ZINT_WARN_NONCOMPLIANT, "800812345612" }, + /*841*/ { "[8008]12010112", 0, "800812010112" }, + /*842*/ { "[8008]1234561", ZINT_ERROR_INVALID_DATA, "" }, + /*843*/ { "[8008]123456121", ZINT_ERROR_INVALID_DATA, "" }, + /*844*/ { "[8008]12345612121", ZINT_ERROR_INVALID_DATA, "" }, + /*845*/ { "[8008]1234561212123", ZINT_ERROR_INVALID_DATA, "" }, + /*846*/ { "[8009]12345678901234567890123456789012345678901234567890", 0, "800912345678901234567890123456789012345678901234567890" }, + /*847*/ { "[8009]123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*848*/ { "[8010]1234abcdefghijklmnopqrstuvwxyz1", ZINT_ERROR_INVALID_DATA, "" }, + /*849*/ { "[8011]123456789012", 0, "8011123456789012" }, + /*850*/ { "[8011]1234567890123", ZINT_ERROR_INVALID_DATA, "" }, + /*851*/ { "[8012]abcdefghijklmnopqrst", 0, "8012abcdefghijklmnopqrst" }, + /*852*/ { "[8012]abcdefghijklmnopqrstuv", ZINT_ERROR_INVALID_DATA, "" }, + /*853*/ { "[8013]1234abcdefghijklmnopqrstuvwxyz", 0, "80131234abcdefghijklmnopqrstuvwxyz" }, + /*854*/ { "[8013]1234abcdefghijklmnopqrstuvwxyz1", ZINT_ERROR_INVALID_DATA, "" }, + /*855*/ { "[8014]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*856*/ { "[8016]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*857*/ { "[8017]313131313131313139", ZINT_WARN_NONCOMPLIANT, "8017313131313131313139" }, + /*858*/ { "[8017]313131313131313131", 0, "8017313131313131313131" }, + /*859*/ { "[8017]31313131313131313", ZINT_ERROR_INVALID_DATA, "" }, + /*860*/ { "[8017]3131313131313131390", ZINT_ERROR_INVALID_DATA, "" }, + /*861*/ { "[8018]313131313131313139", ZINT_WARN_NONCOMPLIANT, "8018313131313131313139" }, + /*862*/ { "[8018]313131313131313131", 0, "8018313131313131313131" }, + /*863*/ { "[8018]31313131313131313", ZINT_ERROR_INVALID_DATA, "" }, + /*864*/ { "[8018]3131313131313131390", ZINT_ERROR_INVALID_DATA, "" }, + /*865*/ { "[8019]1234567890", 0, "80191234567890" }, + /*866*/ { "[8019]12345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*867*/ { "[8020]abcdefghijklmnopqrstuvwxy", 0, "8020abcdefghijklmnopqrstuvwxy" }, + /*868*/ { "[8020]abcdefghijklmnopqrstuvwxyz", ZINT_ERROR_INVALID_DATA, "" }, + /*869*/ { "[8021]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*870*/ { "[8025]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*871*/ { "[8026]123456789012341212", ZINT_WARN_NONCOMPLIANT, "8026123456789012341212" }, + /*872*/ { "[8026]123456789012311212", 0, "8026123456789012311212" }, + /*873*/ { "[8026]1234567890123451212", ZINT_ERROR_INVALID_DATA, "" }, + /*874*/ { "[8026]12345678901234512", ZINT_ERROR_INVALID_DATA, "" }, + /*875*/ { "[8027]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*876*/ { "[8030]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*877*/ { "[8040]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*878*/ { "[8050]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*879*/ { "[8060]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*880*/ { "[8070]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*881*/ { "[8080]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*882*/ { "[8090]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*883*/ { "[8099]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*884*/ { "[81]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*885*/ { "[8100]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*886*/ { "[8109]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*887*/ { "[8110]5123456789011234565123455123450123105123450123512345678901320123190000", 0, "81105123456789011234565123455123450123105123450123512345678901320123190000" }, + /*888*/ { "[8110]51234567890112345651234551234501231051234501235123456789013201231900001", ZINT_ERROR_INVALID_DATA, "" }, + /*889*/ { "[8111]1234", 0, "81111234" }, + /*890*/ { "[8111]12345", ZINT_ERROR_INVALID_DATA, "" }, + /*891*/ { "[8111]123", ZINT_ERROR_INVALID_DATA, "" }, + /*892*/ { "[8112]1234567890123456789012345678901234567890123456789012345678901234567890", ZINT_WARN_NONCOMPLIANT, "81121234567890123456789012345678901234567890123456789012345678901234567890" }, + /*893*/ { "[8112]12345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*894*/ { "[8112]061234567890121234569123456789012345", 0, "8112061234567890121234569123456789012345" }, + /*895*/ { "[8113]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*896*/ { "[8120]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*897*/ { "[8130]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*898*/ { "[8140]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*899*/ { "[8150]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*900*/ { "[8190]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*901*/ { "[8199]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*902*/ { "[82]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*903*/ { "[8200]1234567890123456789012345678901234567890123456789012345678901234567890", 0, "82001234567890123456789012345678901234567890123456789012345678901234567890" }, + /*904*/ { "[8201]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*905*/ { "[8210]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*906*/ { "[8220]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*907*/ { "[8230]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*908*/ { "[8240]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*909*/ { "[8250]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*910*/ { "[8290]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*911*/ { "[8299]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*912*/ { "[83]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*913*/ { "[830]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*914*/ { "[8300]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*915*/ { "[84]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*916*/ { "[840]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*917*/ { "[8400]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*918*/ { "[85]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*919*/ { "[850]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*920*/ { "[8500]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*921*/ { "[89]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*922*/ { "[890]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*923*/ { "[8900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*924*/ { "[90]abcdefghijklmnopqrstuvwxyz1234", 0, "90abcdefghijklmnopqrstuvwxyz1234" }, + /*925*/ { "[90]abcdefghijklmnopqrstuvwxyz12345", ZINT_ERROR_INVALID_DATA, "" }, + /*926*/ { "[900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*927*/ { "[9000]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*928*/ { "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "91123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*929*/ { "[91]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*930*/ { "[910]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*931*/ { "[9100]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*932*/ { "[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "92123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*933*/ { "[92]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*934*/ { "[920]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*935*/ { "[9200]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*936*/ { "[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "93123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*937*/ { "[93]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*938*/ { "[930]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*939*/ { "[9300]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*940*/ { "[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "94123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*941*/ { "[94]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*942*/ { "[940]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*943*/ { "[9400]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*944*/ { "[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "95123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*945*/ { "[95]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*946*/ { "[950]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*947*/ { "[9500]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*948*/ { "[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "96123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*949*/ { "[96]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*950*/ { "[960]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*951*/ { "[9600]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*952*/ { "[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "97123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*953*/ { "[97]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*954*/ { "[970]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*955*/ { "[9700]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*956*/ { "[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "98123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*957*/ { "[98]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*958*/ { "[980]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*959*/ { "[9800]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*960*/ { "[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, "99123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" }, + /*961*/ { "[99]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_INVALID_DATA, "" }, + /*962*/ { "[990]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*963*/ { "[9900]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*964*/ { "[9999]1234", ZINT_ERROR_INVALID_DATA, "" }, + /*965*/ { "[01]12345678901234[7006]200101", ZINT_WARN_NONCOMPLIANT, "01123456789012347006200101" }, + /*966*/ { "[01]12345678901231[7006]200101", 0, "01123456789012317006200101" }, + /*967*/ { "[3900]1234567890[01]12345678901234", ZINT_WARN_NONCOMPLIANT, "39001234567890[0112345678901234" }, + /*968*/ { "[3900]1234567890[01]12345678901231", 0, "39001234567890[0112345678901231" }, + /*969*/ { "[253]12345678901234[3901]12345678901234[20]12", ZINT_WARN_NONCOMPLIANT, "25312345678901234[390112345678901234[2012" }, + /*970*/ { "[253]12345678901284[3901]12345678901234[20]12", 0, "25312345678901284[390112345678901234[2012" }, + /*971*/ { "[253]12345678901234[01]12345678901234[3901]12345678901234[20]12", ZINT_WARN_NONCOMPLIANT, "25312345678901234[0112345678901234390112345678901234[2012" }, + /*972*/ { "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12", 0, "25312345678901284[0112345678901231390112345678901234[2012" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char reduced[1024]; for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -804,7 +1298,7 @@ static void test_gs1_verify(int index) { ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, (unsigned char *) reduced); assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") %s\n", i, ret, data[i].ret, length, data[i].data, symbol->errtxt); - if (ret == 0) { + if (ret < ZINT_ERROR) { assert_zero(strcmp(reduced, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, reduced, data[i].expected); } @@ -814,6 +1308,367 @@ static void test_gs1_verify(int index) { testFinish(); } +static void test_gs1_lint(int index, int debug) { + + testStart(""); + + int ret; + struct item { + char *data; + int ret; + char *expected; + char *expected_errtxt; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { "[00]123456789012345675", 0, "00123456789012345675", "" }, // numeric + /* 1*/ { "[00]12345678901234567.", ZINT_WARN_NONCOMPLIANT, "0012345678901234567.", "261: AI (00) position 18: Non-numeric character '.'" }, // numeric + /* 2*/ { "[00]123456789012345678", ZINT_WARN_NONCOMPLIANT, "00123456789012345678", "261: AI (00) position 18: Bad checksum '8', expected '5'" }, // csum + /* 3*/ { "[91]!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz", 0, "91!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz", "" }, // cset82 + /* 4*/ { "[91] ", ZINT_WARN_NONCOMPLIANT, "91 ", "261: AI (91) position 1: Invalid CSET 82 character ' '" }, // cset82 + /* 5*/ { "[91]#", ZINT_WARN_NONCOMPLIANT, "91#", "261: AI (91) position 1: Invalid CSET 82 character '#'" }, // cset82 + /* 6*/ { "[91]a^", ZINT_WARN_NONCOMPLIANT, "91a^", "261: AI (91) position 2: Invalid CSET 82 character '^'" }, // cset82 + /* 7*/ { "[91]!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxy{", ZINT_WARN_NONCOMPLIANT, "91!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxy{", "261: AI (91) position 82: Invalid CSET 82 character '{'" }, // cset82 + /* 8*/ { "[8010]01#-/23456789ABCDEFGHIJKLMNOPQ", 0, "801001#-/23456789ABCDEFGHIJKLMNOPQ", "" }, // cset39 + /* 9*/ { "[8010]6789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, "80106789ABCDEFGHIJKLMNOPQRSTUVWXYZ", "" }, // cset39 + /* 10*/ { "[8010]01!", ZINT_WARN_NONCOMPLIANT, "801001!", "261: AI (8010) position 3: Invalid CSET 39 character '!'" }, // cset39 + /* 11*/ { "[8010]01a", ZINT_WARN_NONCOMPLIANT, "801001a", "261: AI (8010) position 3: Invalid CSET 39 character 'a'" }, // cset39 + /* 12*/ { "[8010]6789ABCDEFGHIJKLMNOPQRSTUVWXY}", ZINT_WARN_NONCOMPLIANT, "80106789ABCDEFGHIJKLMNOPQRSTUVWXY}", "261: AI (8010) position 30: Invalid CSET 39 character '}'" }, // cset39 + /* 13*/ { "[8010]#-/0123456789ABCDEFGHIJKLMNOPQ", ZINT_WARN_NONCOMPLIANT, "8010#-/0123456789ABCDEFGHIJKLMNOPQ", "261: AI (8010) position 1: Non-numeric company prefix '#'" }, // key + /* 14*/ { "[8010]0#-/123456789ABCDEFGHIJKLMNOPQ", ZINT_WARN_NONCOMPLIANT, "80100#-/123456789ABCDEFGHIJKLMNOPQ", "261: AI (8010) position 2: Non-numeric company prefix '#'" }, // key + /* 15*/ { "[11]120100", 0, "11120100", "" }, // yymmd0 + /* 16*/ { "[11]120131", 0, "11120131", "" }, // yymmd0 + /* 17*/ { "[11]120132", ZINT_WARN_NONCOMPLIANT, "11120132", "261: AI (11) position 5: Invalid day '32'" }, // yymmd0 + /* 18*/ { "[11]120229", 0, "11120229", "" }, // yymmd0 + /* 19*/ { "[11]110229", ZINT_WARN_NONCOMPLIANT, "11110229", "261: AI (11) position 5: Invalid day '29'" }, // yymmd0 + /* 20*/ { "[11]000229", 0, "11000229", "" }, // yymmd0 NOTE: will be false in 2050 + /* 21*/ { "[11]480229", 0, "11480229", "" }, // yymmd0 + /* 22*/ { "[11]500229", ZINT_WARN_NONCOMPLIANT, "11500229", "261: AI (11) position 5: Invalid day '29'" }, // yymmd0 + /* 23*/ { "[11]980229", ZINT_WARN_NONCOMPLIANT, "11980229", "261: AI (11) position 5: Invalid day '29'" }, // yymmd0 + /* 24*/ { "[11]110228", 0, "11110228", "" }, // yymmd0 + /* 25*/ { "[11]120230", ZINT_WARN_NONCOMPLIANT, "11120230", "261: AI (11) position 5: Invalid day '30'" }, // yymmd0 + /* 26*/ { "[11]120331", 0, "11120331", "" }, // yymmd0 + /* 27*/ { "[11]120332", ZINT_WARN_NONCOMPLIANT, "11120332", "261: AI (11) position 5: Invalid day '32'" }, // yymmd0 + /* 28*/ { "[11]120430", 0, "11120430", "" }, // yymmd0 + /* 29*/ { "[11]120431", ZINT_WARN_NONCOMPLIANT, "11120431", "261: AI (11) position 5: Invalid day '31'" }, // yymmd0 + /* 30*/ { "[11]120531", 0, "11120531", "" }, // yymmd0 + /* 31*/ { "[11]120532", ZINT_WARN_NONCOMPLIANT, "11120532", "261: AI (11) position 5: Invalid day '32'" }, // yymmd0 + /* 32*/ { "[11]120630", 0, "11120630", "" }, // yymmd0 + /* 33*/ { "[11]120631", ZINT_WARN_NONCOMPLIANT, "11120631", "261: AI (11) position 5: Invalid day '31'" }, // yymmd0 + /* 34*/ { "[11]120731", 0, "11120731", "" }, // yymmd0 + /* 35*/ { "[11]120732", ZINT_WARN_NONCOMPLIANT, "11120732", "261: AI (11) position 5: Invalid day '32'" }, // yymmd0 + /* 36*/ { "[11]120831", 0, "11120831", "" }, // yymmd0 + /* 37*/ { "[11]120832", ZINT_WARN_NONCOMPLIANT, "11120832", "261: AI (11) position 5: Invalid day '32'" }, // yymmd0 + /* 38*/ { "[11]120930", 0, "11120930", "" }, // yymmd0 + /* 39*/ { "[11]120931", ZINT_WARN_NONCOMPLIANT, "11120931", "261: AI (11) position 5: Invalid day '31'" }, // yymmd0 + /* 40*/ { "[11]121031", 0, "11121031", "" }, // yymmd0 + /* 41*/ { "[11]121032", ZINT_WARN_NONCOMPLIANT, "11121032", "261: AI (11) position 5: Invalid day '32'" }, // yymmd0 + /* 42*/ { "[11]121130", 0, "11121130", "" }, // yymmd0 + /* 43*/ { "[11]121131", ZINT_WARN_NONCOMPLIANT, "11121131", "261: AI (11) position 5: Invalid day '31'" }, // yymmd0 + /* 44*/ { "[11]121200", 0, "11121200", "" }, // yymmd0 + /* 45*/ { "[11]121231", 0, "11121231", "" }, // yymmd0 + /* 46*/ { "[11]121232", ZINT_WARN_NONCOMPLIANT, "11121232", "261: AI (11) position 5: Invalid day '32'" }, // yymmd0 + /* 47*/ { "[11]120031", ZINT_WARN_NONCOMPLIANT, "11120031", "261: AI (11) position 3: Invalid month '00'" }, // yymmd0 + /* 48*/ { "[11]121331", ZINT_WARN_NONCOMPLIANT, "11121331", "261: AI (11) position 3: Invalid month '13'" }, // yymmd0 + /* 49*/ { "[4326]121231", 0, "4326121231", "" }, // yymmdd + /* 50*/ { "[4326]121200", ZINT_WARN_NONCOMPLIANT, "4326121200", "261: AI (4326) position 5: Invalid day '00'" }, // yymmdd + /* 51*/ { "[4326]120031", ZINT_WARN_NONCOMPLIANT, "4326120031", "261: AI (4326) position 3: Invalid month '00'" }, // yymmdd + /* 52*/ { "[4326]129931", ZINT_WARN_NONCOMPLIANT, "4326129931", "261: AI (4326) position 3: Invalid month '99'" }, // yymmdd + /* 53*/ { "[4326]121299", ZINT_WARN_NONCOMPLIANT, "4326121299", "261: AI (4326) position 5: Invalid day '99'" }, // yymmdd + /* 54*/ { "[4326]120230", ZINT_WARN_NONCOMPLIANT, "4326120230", "261: AI (4326) position 5: Invalid day '30'" }, // yymmdd + /* 55*/ { "[4326]110229", ZINT_WARN_NONCOMPLIANT, "4326110229", "261: AI (4326) position 5: Invalid day '29'" }, // yymmdd + /* 56*/ { "[4326]000229", 0, "4326000229", "" }, // yymmdd NOTE: will be false in 2050 + /* 57*/ { "[4326]940229", ZINT_WARN_NONCOMPLIANT, "4326940229", "261: AI (4326) position 5: Invalid day '29'" }, // yymmdd + /* 58*/ { "[4324]1212310000", 0, "43241212310000", "" }, // hhmm + /* 59*/ { "[4324]1212312359", 0, "43241212312359", "" }, // hhmm + /* 60*/ { "[4324]1212312400", ZINT_WARN_NONCOMPLIANT, "43241212312400", "261: AI (4324) position 7: Invalid hour of day '24'" }, // hhmm + /* 61*/ { "[4324]1212312360", ZINT_WARN_NONCOMPLIANT, "43241212312360", "261: AI (4324) position 9: Invalid minutes in the hour '60'" }, // hhmm + /* 62*/ { "[8008]121231000000", 0, "8008121231000000", "" }, // hhoptmmss + /* 63*/ { "[8008]1212310000", 0, "80081212310000", "" }, // hhoptmmss + /* 64*/ { "[8008]12123100", 0, "800812123100", "" }, // hhoptmmss + /* 65*/ { "[8008]12123123", 0, "800812123123", "" }, // hhoptmmss + /* 66*/ { "[8008]12123124", ZINT_WARN_NONCOMPLIANT, "800812123124", "261: AI (8008) position 7: Invalid hour of day '24'" }, // hhoptmmss + /* 67*/ { "[8008]1212312359", 0, "80081212312359", "" }, // hhoptmmss + /* 68*/ { "[8008]1212312360", ZINT_WARN_NONCOMPLIANT, "80081212312360", "261: AI (8008) position 9: Invalid minutes in the hour '60'" }, // hhoptmmss + /* 69*/ { "[8008]121231235959", 0, "8008121231235959", "" }, // hhoptmmss + /* 70*/ { "[8008]121231235960", ZINT_WARN_NONCOMPLIANT, "8008121231235960", "261: AI (8008) position 11: Invalid seconds in the minute '60'" }, // hhoptmmss + /* 71*/ { "[422]004", 0, "422004", "" }, // iso3166 + /* 72*/ { "[422]894", 0, "422894", "" }, // iso3166 + /* 73*/ { "[422]00", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (422)" }, // iso3166 + /* 74*/ { "[422]0A", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (422)" }, // iso3166 + /* 75*/ { "[422]003", ZINT_WARN_NONCOMPLIANT, "422003", "261: AI (422) position 1: Unknown country code '003'" }, // iso3166 + /* 76*/ { "[422]895", ZINT_WARN_NONCOMPLIANT, "422895", "261: AI (422) position 1: Unknown country code '895'" }, // iso3166 + /* 77*/ { "[422]999", ZINT_WARN_NONCOMPLIANT, "422999", "261: AI (422) position 1: Unknown country code '999'" }, // iso3166 + /* 78*/ { "[423]004", 0, "423004", "" }, // iso3166list + /* 79*/ { "[423]004894", 0, "423004894", "" }, // iso3166list + /* 80*/ { "[423]004894004", 0, "423004894004", "" }, // iso3166list + /* 81*/ { "[423]004894004894", 0, "423004894004894", "" }, // iso3166list + /* 82*/ { "[423]004894004894004", 0, "423004894004894004", "" }, // iso3166list + /* 83*/ { "[423]004894004894004894", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (423)" }, // iso3166list + /* 84*/ { "[423]123894004894004894", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (423)" }, // iso3166list + /* 85*/ { "[423]A04894004894004894", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (423)" }, // iso3166list + /* 86*/ { "[423]00489400489400489", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (423)" }, // iso3166list + /* 87*/ { "[423]0048940048940048", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (423)" }, // iso3166list + /* 88*/ { "[423]00489400489400", ZINT_WARN_NONCOMPLIANT, "42300489400489400", "259: Invalid data length for AI (423)" }, // iso3166list + /* 89*/ { "[423]0048940048940", ZINT_WARN_NONCOMPLIANT, "4230048940048940", "259: Invalid data length for AI (423)" }, // iso3166list + /* 90*/ { "[423]00489400489", ZINT_WARN_NONCOMPLIANT, "42300489400489", "259: Invalid data length for AI (423)" }, // iso3166list + /* 91*/ { "[423]0048940048", ZINT_WARN_NONCOMPLIANT, "4230048940048", "259: Invalid data length for AI (423)" }, // iso3166list + /* 92*/ { "[423]00489400", ZINT_WARN_NONCOMPLIANT, "42300489400", "259: Invalid data length for AI (423)" }, // iso3166list + /* 93*/ { "[423]0048940", ZINT_WARN_NONCOMPLIANT, "4230048940", "259: Invalid data length for AI (423)" }, // iso3166list + /* 94*/ { "[423]00489", ZINT_WARN_NONCOMPLIANT, "42300489", "259: Invalid data length for AI (423)" }, // iso3166list + /* 95*/ { "[423]0048", ZINT_WARN_NONCOMPLIANT, "4230048", "259: Invalid data length for AI (423)" }, // iso3166list + /* 96*/ { "[423]00", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (423)" }, // iso3166list + /* 97*/ { "[423]0", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (423)" }, // iso3166list + /* 98*/ { "[423]004894004894003", ZINT_WARN_NONCOMPLIANT, "423004894004894003", "261: AI (423) position 13: Unknown country code '003'" }, // iso3166list + /* 99*/ { "[423]004894004895004", ZINT_WARN_NONCOMPLIANT, "423004894004895004", "261: AI (423) position 10: Unknown country code '895'" }, // iso3166list + /*100*/ { "[423]004894004999004", ZINT_WARN_NONCOMPLIANT, "423004894004999004", "261: AI (423) position 10: Unknown country code '999'" }, // iso3166list + /*101*/ { "[423]004894005894004", ZINT_WARN_NONCOMPLIANT, "423004894005894004", "261: AI (423) position 7: Unknown country code '005'" }, // iso3166list + /*102*/ { "[423]004893004894004", ZINT_WARN_NONCOMPLIANT, "423004893004894004", "261: AI (423) position 4: Unknown country code '893'" }, // iso3166list + /*103*/ { "[423]004999004894004", ZINT_WARN_NONCOMPLIANT, "423004999004894004", "261: AI (423) position 4: Unknown country code '999'" }, // iso3166list + /*104*/ { "[423]003894004894004", ZINT_WARN_NONCOMPLIANT, "423003894004894004", "261: AI (423) position 1: Unknown country code '003'" }, // iso3166list + /*105*/ { "[423]004894004433", ZINT_WARN_NONCOMPLIANT, "423004894004433", "261: AI (423) position 10: Unknown country code '433'" }, // iso3166list + /*106*/ { "[423]004894435894", ZINT_WARN_NONCOMPLIANT, "423004894435894", "261: AI (423) position 7: Unknown country code '435'" }, // iso3166list + /*107*/ { "[423]004433004894", ZINT_WARN_NONCOMPLIANT, "423004433004894", "261: AI (423) position 4: Unknown country code '433'" }, // iso3166list + /*108*/ { "[423]432894004894", ZINT_WARN_NONCOMPLIANT, "423432894004894", "261: AI (423) position 1: Unknown country code '432'" }, // iso3166list + /*109*/ { "[423]004894003", ZINT_WARN_NONCOMPLIANT, "423004894003", "261: AI (423) position 7: Unknown country code '003'" }, // iso3166list + /*110*/ { "[423]004895004", ZINT_WARN_NONCOMPLIANT, "423004895004", "261: AI (423) position 4: Unknown country code '895'" }, // iso3166list + /*111*/ { "[423]004999004", ZINT_WARN_NONCOMPLIANT, "423004999004", "261: AI (423) position 4: Unknown country code '999'" }, // iso3166list + /*112*/ { "[423]003894004", ZINT_WARN_NONCOMPLIANT, "423003894004", "261: AI (423) position 1: Unknown country code '003'" }, // iso3166list + /*113*/ { "[423]004999", ZINT_WARN_NONCOMPLIANT, "423004999", "261: AI (423) position 4: Unknown country code '999'" }, // iso3166list + /*114*/ { "[423]000894", ZINT_WARN_NONCOMPLIANT, "423000894", "261: AI (423) position 1: Unknown country code '000'" }, // iso3166list + /*115*/ { "[423]003", ZINT_WARN_NONCOMPLIANT, "423003", "261: AI (423) position 1: Unknown country code '003'" }, // iso3166list + /*116*/ { "[7030]999A", 0, "7030999A", "" }, // iso3166999 + /*117*/ { "[7030]894A", 0, "7030894A", "" }, // iso3166999 + /*118*/ { "[7030]004A", 0, "7030004A", "" }, // iso3166999 + /*119*/ { "[7030]004", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (7030)" }, // iso3166999 + /*120*/ { "[7030]04", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (7030)" }, // iso3166999 + /*121*/ { "[7030]001A", ZINT_WARN_NONCOMPLIANT, "7030001A", "261: AI (7030) position 1: Unknown country code '001'" }, // iso3166999 + /*122*/ { "[7030]998A", ZINT_WARN_NONCOMPLIANT, "7030998A", "261: AI (7030) position 1: Unknown country code '998'" }, // iso3166999 + /*123*/ { "[3910]0081", 0, "39100081", "" }, // iso4217 + /*124*/ { "[3910]9991", 0, "39109991", "" }, // iso4217 + /*125*/ { "[3910]9971", 0, "39109971", "" }, // iso4217 + /*126*/ { "[3910]01", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (3910)" }, // iso4217 + /*127*/ { "[3910]001", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (3910)" }, // iso4217 + /*128*/ { "[3910]9981", ZINT_WARN_NONCOMPLIANT, "39109981", "261: AI (3910) position 1: Unknown currency code '998'" }, // iso4217 + /*129*/ { "[3910]0041", ZINT_WARN_NONCOMPLIANT, "39100041", "261: AI (3910) position 1: Unknown currency code '004'" }, // iso4217 + /*130*/ { "[3910]8941", ZINT_WARN_NONCOMPLIANT, "39108941", "261: AI (3910) position 1: Unknown currency code '894'" }, // iso4217 + /*131*/ { "[4300]%12", 0, "4300%12", "" }, // pcenc + /*132*/ { "[4300]%1", ZINT_WARN_NONCOMPLIANT, "4300%1", "261: AI (4300) position 1: Invalid % escape" }, // pcenc + /*133*/ { "[4300]%", ZINT_WARN_NONCOMPLIANT, "4300%", "261: AI (4300) position 1: Invalid % escape" }, // pcenc + /*134*/ { "[4300]12%1212", 0, "430012%1212", "" }, // pcenc + /*135*/ { "[4300]12%1G12", ZINT_WARN_NONCOMPLIANT, "430012%1G12", "261: AI (4300) position 5: Invalid characters for percent encoding" }, // pcenc + /*136*/ { "[4321]1", 0, "43211", "" }, // yesno + /*137*/ { "[4321]0", 0, "43210", "" }, // yesno + /*138*/ { "[4321]2", ZINT_WARN_NONCOMPLIANT, "43212", "261: AI (4321) position 1: Neither 0 nor 1 for yes or no" }, // yesno + /*139*/ { "[4321]9", ZINT_WARN_NONCOMPLIANT, "43219", "261: AI (4321) position 1: Neither 0 nor 1 for yes or no" }, // yesno + /*140*/ { "[7040]1234", 0, "70401234", "" }, // importeridx + /*141*/ { "[7040]123A", 0, "7040123A", "" }, // importeridx + /*142*/ { "[7040]123Z", 0, "7040123Z", "" }, // importeridx + /*143*/ { "[7040]123a", 0, "7040123a", "" }, // importeridx + /*144*/ { "[7040]123z", 0, "7040123z", "" }, // importeridx + /*145*/ { "[7040]123-", 0, "7040123-", "" }, // importeridx + /*146*/ { "[7040]123_", 0, "7040123_", "" }, // importeridx + /*147*/ { "[7040]123!", ZINT_WARN_NONCOMPLIANT, "7040123!", "261: AI (7040) position 4: Invalid importer index '!'" }, // importeridx + /*148*/ { "[7040]123/", ZINT_WARN_NONCOMPLIANT, "7040123/", "261: AI (7040) position 4: Invalid importer index '/'" }, // importeridx + /*149*/ { "[7040]123:", ZINT_WARN_NONCOMPLIANT, "7040123:", "261: AI (7040) position 4: Invalid importer index ':'" }, // importeridx + /*150*/ { "[7040]123?", ZINT_WARN_NONCOMPLIANT, "7040123?", "261: AI (7040) position 4: Invalid importer index '?'" }, // importeridx + /*151*/ { "[8001]12341234512311", 0, "800112341234512311", "" }, // nonzero + /*152*/ { "[8001]00010000100100", 0, "800100010000100100", "" }, // nonzero + /*153*/ { "[8001]00001234512311", ZINT_WARN_NONCOMPLIANT, "800100001234512311", "261: AI (8001) position 1: Zero not permitted" }, // nonzero + /*154*/ { "[8001]12340000012311", ZINT_WARN_NONCOMPLIANT, "800112340000012311", "261: AI (8001) position 5: Zero not permitted" }, // nonzero + /*155*/ { "[8001]00010000100011", ZINT_WARN_NONCOMPLIANT, "800100010000100011", "261: AI (8001) position 10: Zero not permitted" }, // nonzero + /*156*/ { "[8001]00010000100101", 0, "800100010000100101", "" }, // winding + /*157*/ { "[8001]00010000100111", 0, "800100010000100111", "" }, // winding + /*158*/ { "[8001]00010000100191", 0, "800100010000100191", "" }, // winding + /*159*/ { "[8001]00010000100121", ZINT_WARN_NONCOMPLIANT, "800100010000100121", "261: AI (8001) position 13: Invalid winding direction '2'" }, // winding + /*160*/ { "[8001]00010000100131", ZINT_WARN_NONCOMPLIANT, "800100010000100131", "261: AI (8001) position 13: Invalid winding direction '3'" }, // winding + /*161*/ { "[8001]00010000100171", ZINT_WARN_NONCOMPLIANT, "800100010000100171", "261: AI (8001) position 13: Invalid winding direction '7'" }, // winding + /*162*/ { "[8001]00010000100181", ZINT_WARN_NONCOMPLIANT, "800100010000100181", "261: AI (8001) position 13: Invalid winding direction '8'" }, // winding + /*163*/ { "[8003]01234567890128", 0, "800301234567890128", "" }, // zero + /*164*/ { "[8003]11234567890128", ZINT_WARN_NONCOMPLIANT, "800311234567890128", "261: AI (8003) position 1: Zero is required" }, // zero + /*165*/ { "[8003]91234567890128", ZINT_WARN_NONCOMPLIANT, "800391234567890128", "261: AI (8003) position 1: Zero is required" }, // zero + /*166*/ { "[8006]123456789012310101", 0, "8006123456789012310101", "" }, // pieceoftotal + /*167*/ { "[8006]123456789012310199", 0, "8006123456789012310199", "" }, // pieceoftotal + /*168*/ { "[8006]123456789012319999", 0, "8006123456789012319999", "" }, // pieceoftotal + /*169*/ { "[8006]123456789012310001", ZINT_WARN_NONCOMPLIANT, "8006123456789012310001", "261: AI (8006) position 15: Piece number cannot be zero" }, // pieceoftotal + /*170*/ { "[8006]123456789012310100", ZINT_WARN_NONCOMPLIANT, "8006123456789012310100", "261: AI (8006) position 15: Total number cannot be zero" }, // pieceoftotal + /*171*/ { "[8006]123456789012310201", ZINT_WARN_NONCOMPLIANT, "8006123456789012310201", "261: AI (8006) position 15: Piece number '02' exceeds total '01'" }, // pieceoftotal + /*172*/ { "[8006]123456789012319998", ZINT_WARN_NONCOMPLIANT, "8006123456789012319998", "261: AI (8006) position 15: Piece number '99' exceeds total '98'" }, // pieceoftotal + /*173*/ { "[8007]GB82WEST12345698765432", 0, "8007GB82WEST12345698765432", "" }, // iban + /*174*/ { "[8007]GB83WEST12345698765432", ZINT_WARN_NONCOMPLIANT, "8007GB83WEST12345698765432", "261: AI (8007) position 3: Bad IBAN checksum '83', expected '82'" }, // iban + /*175*/ { "[8007]BE71096123456769", 0, "8007BE71096123456769", "" }, // iban + /*176*/ { "[8007]BE71096123456760", ZINT_WARN_NONCOMPLIANT, "8007BE71096123456760", "261: AI (8007) position 3: Bad IBAN checksum '71', expected '23'" }, // iban + /*177*/ { "[8007]BE01096123456760", ZINT_WARN_NONCOMPLIANT, "8007BE01096123456760", "261: AI (8007) position 3: Bad IBAN checksum '01', expected '23'" }, // iban + /*178*/ { "[8007]BE00096123456760", ZINT_WARN_NONCOMPLIANT, "8007BE00096123456760", "261: AI (8007) position 3: Bad IBAN checksum '00', expected '23'" }, // iban + /*179*/ { "[8007]LC14BOSL123456789012345678901234", 0, "8007LC14BOSL123456789012345678901234", "" }, // iban + /*180*/ { "[8007]LC14BOSL123456789012345678901230", ZINT_WARN_NONCOMPLIANT, "8007LC14BOSL123456789012345678901230", "261: AI (8007) position 3: Bad IBAN checksum '14', expected '25'" }, // iban + /*181*/ { "[8007]A114BOSL123456789012345678901230", ZINT_WARN_NONCOMPLIANT, "8007A114BOSL123456789012345678901230", "261: AI (8007) position 1: Non-alphabetic IBAN country code 'A1'" }, // iban + /*182*/ { "[8007]1A14BOSL123456789012345678901230", ZINT_WARN_NONCOMPLIANT, "80071A14BOSL123456789012345678901230", "261: AI (8007) position 1: Non-alphabetic IBAN country code '1A'" }, // iban + /*183*/ { "[8007]AA14BOSL123456789012345678901230", ZINT_WARN_NONCOMPLIANT, "8007AA14BOSL123456789012345678901230", "261: AI (8007) position 1: Invalid IBAN country code 'AA'" }, // iban + /*184*/ { "[8007]ZZ14BOSL123456789012345678901230", ZINT_WARN_NONCOMPLIANT, "8007ZZ14BOSL123456789012345678901230", "261: AI (8007) position 1: Invalid IBAN country code 'ZZ'" }, // iban + /*185*/ { "[8007]ZW33BOSL123456789012345678901230", 0, "8007ZW33BOSL123456789012345678901230", "" }, // iban + /*186*/ { "[8007]ZWA3BOSL123456789012345678901230", ZINT_WARN_NONCOMPLIANT, "8007ZWA3BOSL123456789012345678901230", "261: AI (8007) position 3: Non-numeric IBAN checksum 'A3'" }, // iban + /*187*/ { "[8007]ZW3ABOSL123456789012345678901230", ZINT_WARN_NONCOMPLIANT, "8007ZW3ABOSL123456789012345678901230", "261: AI (8007) position 3: Non-numeric IBAN checksum '3A'" }, // iban + /*188*/ { "[8007]ZW33bOSL123456789012345678901230", ZINT_WARN_NONCOMPLIANT, "8007ZW33bOSL123456789012345678901230", "261: AI (8007) position 5: Invalid IBAN character 'b'" }, // iban + /*189*/ { "[8007]FR7630006000011234567890189", 0, "8007FR7630006000011234567890189", "" }, // iban + /*190*/ { "[8007]DE91100000000123456789", 0, "8007DE91100000000123456789", "" }, // iban + /*191*/ { "[8007]GR9608100010000001234567890", 0, "8007GR9608100010000001234567890", "" }, // iban + /*192*/ { "[8007]MU43BOMM0101123456789101000MUR", 0, "8007MU43BOMM0101123456789101000MUR", "" }, // iban + /*193*/ { "[8007]PL10105000997603123456789123", 0, "8007PL10105000997603123456789123", "" }, // iban + /*194*/ { "[8007]RO09BCYP0000001234567890", 0, "8007RO09BCYP0000001234567890", "" }, // iban + /*195*/ { "[8007]SA4420000001234567891234", 0, "8007SA4420000001234567891234", "" }, // iban + /*196*/ { "[8007]ES7921000813610123456789", 0, "8007ES7921000813610123456789", "" }, // iban + /*197*/ { "[8007]CH5604835012345678009", 0, "8007CH5604835012345678009", "" }, // iban + /*198*/ { "[8007]GB98MIDL07009312345678", 0, "8007GB98MIDL07009312345678", "" }, // iban + /*199*/ { "[8011]1", 0, "80111", "" }, // nozeroprefix + /*200*/ { "[8011]11", 0, "801111", "" }, // nozeroprefix + /*201*/ { "[8011]0", 0, "80110", "" }, // nozeroprefix + /*202*/ { "[8011]01", ZINT_WARN_NONCOMPLIANT, "801101", "261: AI (8011) position 1: Zero prefix is not permitted" }, // nozeroprefix + /*203*/ { "[8110]106141416543213150110120", 0, "8110106141416543213150110120", "" }, // couponcode (first part of NACAG Appendix C: Example 1 - see test_rss.c test_examples) + /*204*/ { "[8110]012345612345610104123", 0, "8110012345612345610104123", "" }, // couponcode + /*205*/ { "[8110]01234561234561010412", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412", "259: Invalid data length for AI (8110)" }, // couponcode + /*206*/ { "[8110]12345678901234567890", ZINT_WARN_NONCOMPLIANT, "811012345678901234567890", "259: Invalid data length for AI (8110)" }, // couponcode + /*207*/ { "[8110]712345612345610104123", ZINT_WARN_NONCOMPLIANT, "8110712345612345610104123", "261: AI (8110) position 1: Invalid Primary GS1 Co. Prefix VLI '7'" }, // couponcode + /*208*/ { "[8110]A12345612345610104123", ZINT_WARN_NONCOMPLIANT, "8110A12345612345610104123", "261: AI (8110) position 1: Non-numeric Primary GS1 Co. Prefix VLI 'A'" }, // couponcode + /*209*/ { "[8110]012345A12345610104123", ZINT_WARN_NONCOMPLIANT, "8110012345A12345610104123", "261: AI (8110) position 7: Non-numeric Primary GS1 Co. Prefix 'A'" }, // couponcode + /*210*/ { "[8110]012345612345A10104123", ZINT_WARN_NONCOMPLIANT, "8110012345612345A10104123", "261: AI (8110) position 8: Non-numeric Offer Code" }, // couponcode + /*211*/ { "[8110]012345612345600104123", ZINT_WARN_NONCOMPLIANT, "8110012345612345600104123", "261: AI (8110) position 14: Invalid Save Value VLI '0'" }, // couponcode + /*212*/ { "[8110]012345612345660104123", ZINT_WARN_NONCOMPLIANT, "8110012345612345660104123", "261: AI (8110) position 14: Invalid Save Value VLI '6'" }, // couponcode + /*213*/ { "[8110]01234561234561A104123", ZINT_WARN_NONCOMPLIANT, "811001234561234561A104123", "261: AI (8110) position 15: Non-numeric Save Value 'A'" }, // couponcode + /*214*/ { "[8110]012345612345610004123", ZINT_WARN_NONCOMPLIANT, "8110012345612345610004123", "261: AI (8110) position 16: Invalid Primary Purch. Req. VLI '0'" }, // couponcode + /*215*/ { "[8110]012345612345610604123", ZINT_WARN_NONCOMPLIANT, "8110012345612345610604123", "261: AI (8110) position 16: Invalid Primary Purch. Req. VLI '6'" }, // couponcode + /*216*/ { "[8110]0123456123456101A4123", ZINT_WARN_NONCOMPLIANT, "81100123456123456101A4123", "261: AI (8110) position 17: Non-numeric Primary Purch. Req. 'A'" }, // couponcode + /*217*/ { "[8110]012345612345621251234", ZINT_WARN_NONCOMPLIANT, "8110012345612345621251234", "261: AI (8110) position 18: Primary Purch. Req. incomplete" }, // couponcode + /*218*/ { "[8110]012345612345610106123", ZINT_WARN_NONCOMPLIANT, "8110012345612345610106123", "261: AI (8110) position 18: Invalid Primary Purch. Req. Code '6'" }, // couponcode + /*219*/ { "[8110]012345612345610212412", ZINT_WARN_NONCOMPLIANT, "8110012345612345610212412", "261: AI (8110) position 20: Primary Purch. Family Code incomplete" }, // couponcode + /*220*/ { "[8110]0123456123456103123412", ZINT_WARN_NONCOMPLIANT, "81100123456123456103123412", "261: AI (8110) position 21: Primary Purch. Family Code incomplete" }, // couponcode + /*221*/ { "[8110]0123456123456103123412A", ZINT_WARN_NONCOMPLIANT, "81100123456123456103123412A", "261: AI (8110) position 21: Non-numeric Primary Purch. Family Code" }, // couponcode + /*222*/ { "[8110]01234561234561031234123", 0, "811001234561234561031234123", "" }, // couponcode + /*223*/ { "[8110]612345678901212345651", ZINT_WARN_NONCOMPLIANT, "8110612345678901212345651", "261: AI (8110) position 21: Save Value incomplete" }, // couponcode + /*224*/ { "[8110]6123456789012123456512345", ZINT_WARN_NONCOMPLIANT, "81106123456789012123456512345", "261: AI (8110) position 26: Primary Purch. Req. VLI missing" }, // couponcode + /*225*/ { "[8110]61234567890121234565123455123454123", 0, "811061234567890121234565123455123454123", "" }, // couponcode + /*226*/ { "[8110]61234567890121234565123455123454123A", ZINT_WARN_NONCOMPLIANT, "811061234567890121234565123455123454123A", "261: AI (8110) position 36: Non-numeric Data Field 'A'" }, // couponcode + /*227*/ { "[8110]612345678901212345651234551234541237", ZINT_WARN_NONCOMPLIANT, "8110612345678901212345651234551234541237", "261: AI (8110) position 36: Invalid Data Field '7'" }, // couponcode + /*228*/ { "[8110]612345678901212345651234551234541238", ZINT_WARN_NONCOMPLIANT, "8110612345678901212345651234551234541238", "261: AI (8110) position 36: Invalid Data Field '8'" }, // couponcode + /*229*/ { "[8110]0123456123456101041231", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041231", "261: AI (8110) position 23: Add. Purch. Rules Code incomplete" }, // couponcode + /*230*/ { "[8110]0123456123456101041231A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041231A", "261: AI (8110) position 23: Non-numeric Add. Purch. Rules Code" }, // couponcode + /*231*/ { "[8110]01234561234561010412314", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412314", "261: AI (8110) position 23: Invalid Add. Purch. Rules Code '4'" }, // couponcode + /*232*/ { "[8110]01234561234561010412313", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412313", "261: AI (8110) position 24: 2nd Purch. Req. VLI missing" }, // couponcode + /*233*/ { "[8110]01234561234561010412313A", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412313A", "261: AI (8110) position 24: Non-numeric 2nd Purch. Req. VLI 'A'" }, // couponcode + /*234*/ { "[8110]012345612345610104123130", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123130", "261: AI (8110) position 24: Invalid 2nd Purch. Req. VLI '0'" }, // couponcode + /*235*/ { "[8110]012345612345610104123131", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123131", "261: AI (8110) position 25: 2nd Purch. Req. incomplete" }, // couponcode + /*236*/ { "[8110]012345612345610104123131A", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123131A", "261: AI (8110) position 25: Non-numeric 2nd Purch. Req. 'A'" }, // couponcode + /*237*/ { "[8110]0123456123456101041231310", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041231310", "261: AI (8110) position 26: 2nd Purch. Req. Code incomplete" }, // couponcode + /*238*/ { "[8110]0123456123456101041231310A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041231310A", "261: AI (8110) position 26: Non-numeric 2nd Purch. Req. Code" }, // couponcode + /*239*/ { "[8110]01234561234561010412313108", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412313108", "261: AI (8110) position 26: Invalid 2nd Purch. Req. Code '8'" }, // couponcode + /*240*/ { "[8110]01234561234561010412313100", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412313100", "261: AI (8110) position 27: 2nd Purch. Family Code incomplete" }, // couponcode + /*241*/ { "[8110]01234561234561010412313100123", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412313100123", "261: AI (8110) position 30: 2nd Purch. GS1 Co. Prefix VLI missing" }, // couponcode + /*242*/ { "[8110]01234561234561010412313100123A", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412313100123A", "261: AI (8110) position 30: Non-numeric 2nd Purch. GS1 Co. Prefix VLI 'A'" }, // couponcode + /*243*/ { "[8110]012345612345610104123131001239", 0, "8110012345612345610104123131001239", "" }, // couponcode + /*244*/ { "[8110]01234561234561010412313100123012345", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412313100123012345", "261: AI (8110) position 31: 2nd Purch. GS1 Co. Prefix incomplete" }, // couponcode + /*245*/ { "[8110]0123456123456101041231310012311234567", 0, "81100123456123456101041231310012311234567", "" }, // couponcode + /*246*/ { "[8110]0123456123456101041232", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041232", "261: AI (8110) position 23: 3rd Purch. Req. VLI missing" }, // couponcode + /*247*/ { "[8110]0123456123456101041232A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041232A", "261: AI (8110) position 23: Non-numeric 3rd Purch. Req. VLI 'A'" }, // couponcode + /*248*/ { "[8110]01234561234561010412326", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412326", "261: AI (8110) position 23: Invalid 3rd Purch. Req. VLI '6'" }, // couponcode + /*249*/ { "[8110]01234561234561010412321", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412321", "261: AI (8110) position 24: 3rd Purch. Req. incomplete" }, // couponcode + /*250*/ { "[8110]012345612345610104123210", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123210", "261: AI (8110) position 25: 3rd Purch. Req. Code incomplete" }, // couponcode + /*251*/ { "[8110]0123456123456101041232105", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041232105", "261: AI (8110) position 25: Invalid 3rd Purch. Req. Code '5'" }, // couponcode + /*252*/ { "[8110]0123456123456101041232104", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041232104", "261: AI (8110) position 26: 3rd Purch. Family Code incomplete" }, // couponcode + /*253*/ { "[8110]012345612345610104123210412A", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123210412A", "261: AI (8110) position 26: Non-numeric 3rd Purch. Family Code" }, // couponcode + /*254*/ { "[8110]0123456123456101041232104123", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041232104123", "261: AI (8110) position 29: 3rd Purch. GS1 Co. Prefix VLI missing" }, // couponcode + /*255*/ { "[8110]01234561234561010412321041230", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412321041230", "261: AI (8110) position 30: 3rd Purch. GS1 Co. Prefix incomplete" }, // couponcode + /*256*/ { "[8110]0123456123456101041232104123A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041232104123A", "261: AI (8110) position 29: Non-numeric 3rd Purch. GS1 Co. Prefix VLI 'A'" }, // couponcode + /*257*/ { "[8110]0123456123456101041232104123012345", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041232104123012345", "261: AI (8110) position 30: 3rd Purch. GS1 Co. Prefix incomplete" }, // couponcode + /*258*/ { "[8110]0123456123456101041232104123012345A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041232104123012345A", "261: AI (8110) position 35: Non-numeric 3rd Purch. GS1 Co. Prefix 'A'" }, // couponcode + /*259*/ { "[8110]01234561234561010412321041230123456", 0, "811001234561234561010412321041230123456", "" }, // couponcode + /*260*/ { "[8110]0123456123456101041233", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041233", "261: AI (8110) position 23: Expiration Date incomplete" }, // couponcode + /*261*/ { "[8110]01234561234561010412332012", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412332012", "261: AI (8110) position 23: Expiration Date incomplete" }, // couponcode + /*262*/ { "[8110]012345612345610104123320123A", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123320123A", "261: AI (8110) position 23: Non-numeric Expiration Date" }, // couponcode + /*263*/ { "[8110]0123456123456101041233201232", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041233201232", "261: AI (8110) position 27: Invalid day '32'" }, // couponcode + /*264*/ { "[8110]0123456123456101041233200031", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041233200031", "261: AI (8110) position 25: Invalid month '00'" }, // couponcode + /*265*/ { "[8110]0123456123456101041233201231", 0, "81100123456123456101041233201231", "" }, // couponcode + /*266*/ { "[8110]0123456123456101041234", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041234", "261: AI (8110) position 23: Start Date incomplete" }, // couponcode + /*267*/ { "[8110]01234561234561010412342012", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412342012", "261: AI (8110) position 23: Start Date incomplete" }, // couponcode + /*268*/ { "[8110]012345612345610104123420123A", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123420123A", "261: AI (8110) position 23: Non-numeric Start Date" }, // couponcode + /*269*/ { "[8110]0123456123456101041234200230", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041234200230", "261: AI (8110) position 27: Invalid day '30'" }, // couponcode + /*270*/ { "[8110]0123456123456101041234201329", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041234201329", "261: AI (8110) position 25: Invalid month '13'" }, // couponcode + /*271*/ { "[8110]0123456123456101041234200229", 0, "81100123456123456101041234200229", "" }, // couponcode + /*272*/ { "[8110]0123456123456101041235", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041235", "261: AI (8110) position 23: Serial Number VLI missing" }, // couponcode + /*273*/ { "[8110]0123456123456101041235A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041235A", "261: AI (8110) position 23: Non-numeric Serial Number VLI 'A'" }, // couponcode + /*274*/ { "[8110]01234561234561010412350", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412350", "261: AI (8110) position 24: Serial Number incomplete" }, // couponcode + /*275*/ { "[8110]0123456123456101041235012345", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041235012345", "261: AI (8110) position 24: Serial Number incomplete" }, // couponcode + /*276*/ { "[8110]0123456123456101041235912345678901234", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041235912345678901234", "261: AI (8110) position 24: Serial Number incomplete" }, // couponcode + /*277*/ { "[8110]0123456123456101041235912345678901234A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041235912345678901234A", "261: AI (8110) position 38: Non-numeric Serial Number 'A'" }, // couponcode + /*278*/ { "[8110]01234561234561010412359123456789012345", 0, "811001234561234561010412359123456789012345", "" }, // couponcode + /*279*/ { "[8110]0123456123456101041236", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041236", "261: AI (8110) position 23: Retailer ID VLI missing" }, // couponcode + /*280*/ { "[8110]0123456123456101041236A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041236A", "261: AI (8110) position 23: Non-numeric Retailer ID VLI 'A'" }, // couponcode + /*281*/ { "[8110]01234561234561010412360", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412360", "261: AI (8110) position 23: Invalid Retailer ID VLI '0'" }, // couponcode + /*282*/ { "[8110]01234561234561010412368", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412368", "261: AI (8110) position 23: Invalid Retailer ID VLI '8'" }, // couponcode + /*283*/ { "[8110]01234561234561010412361", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412361", "261: AI (8110) position 24: Retailer ID incomplete" }, // couponcode + /*284*/ { "[8110]01234561234561010412361123456", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412361123456", "261: AI (8110) position 24: Retailer ID incomplete" }, // couponcode + /*285*/ { "[8110]01234561234561010412361123456A", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412361123456A", "261: AI (8110) position 30: Non-numeric Retailer ID 'A'" }, // couponcode + /*286*/ { "[8110]012345612345610104123671234567890123", 0, "8110012345612345610104123671234567890123", "" }, // couponcode + /*287*/ { "[8110]0123456123456101041239", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041239", "261: AI (8110) position 23: Save Value Code incomplete" }, // couponcode + /*288*/ { "[8110]0123456123456101041239A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041239A", "261: AI (8110) position 23: Non-numeric Save Value Code" }, // couponcode + /*289*/ { "[8110]01234561234561010412393", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412393", "261: AI (8110) position 23: Invalid Save Value Code '3'" }, // couponcode + /*290*/ { "[8110]01234561234561010412394", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412394", "261: AI (8110) position 23: Invalid Save Value Code '4'" }, // couponcode + /*291*/ { "[8110]01234561234561010412397", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412397", "261: AI (8110) position 23: Invalid Save Value Code '7'" }, // couponcode + /*292*/ { "[8110]01234561234561010412390", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412390", "261: AI (8110) position 24: Save Value Applies To incomplete" }, // couponcode + /*293*/ { "[8110]01234561234561010412390A", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412390A", "261: AI (8110) position 24: Non-numeric Save Value Applies To" }, // couponcode + /*294*/ { "[8110]012345612345610104123903", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123903", "261: AI (8110) position 24: Invalid Save Value Applies To '3'" }, // couponcode + /*295*/ { "[8110]012345612345610104123902", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123902", "261: AI (8110) position 25: Store Coupon Flag incomplete" }, // couponcode + /*296*/ { "[8110]012345612345610104123902A", ZINT_WARN_NONCOMPLIANT, "8110012345612345610104123902A", "261: AI (8110) position 25: Non-numeric Store Coupon Flag" }, // couponcode + /*297*/ { "[8110]0123456123456101041239029", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041239029", "261: AI (8110) position 26: Don't Multiply Flag incomplete" }, // couponcode + /*298*/ { "[8110]0123456123456101041239029A", ZINT_WARN_NONCOMPLIANT, "81100123456123456101041239029A", "261: AI (8110) position 26: Non-numeric Don't Multiply Flag" }, // couponcode + /*299*/ { "[8110]01234561234561010412390292", ZINT_WARN_NONCOMPLIANT, "811001234561234561010412390292", "261: AI (8110) position 26: Invalid Don't Multiply Flag '2'" }, // couponcode + /*300*/ { "[8110]01234561234561010412390291", 0, "811001234561234561010412390291", "" }, // couponcode + /*301*/ { "[8110]177777776666663100120444101105551888888821109991222222232012314200601522345678961345678990000", ZINT_ERROR_INVALID_DATA, "", "259: Invalid data length for AI (8110)" }, // couponcode (example from GS1 AI (8112) Coupon Data Specifications Appendix A: AI (8110) vs AI (8112)) + /*302*/ { "[8110]177777776666663100120444101105551888888821109991222222232012314200601", 0, "8110177777776666663100120444101105551888888821109991222222232012314200601", "" }, // couponcode + /*303*/ { "[8112]017777777666666223456789", 0, "8112017777777666666223456789", "" }, // couponposoffer (example from GS1 AI (8112) Coupon Data Specifications Appendix A: AI (8110) vs AI (8112)) + /*304*/ { "[8112]001234561234560123456", 0, "8112001234561234560123456", "" }, // couponposoffer + /*305*/ { "[8112]00123456123456012345", ZINT_WARN_NONCOMPLIANT, "811200123456123456012345", "259: Invalid data length for AI (8112)" }, // couponposoffer + /*306*/ { "[8112]0012345612345601234561", ZINT_WARN_NONCOMPLIANT, "81120012345612345601234561", "261: AI (8112) position 22: Reserved trailing characters" }, // couponposoffer + /*307*/ { "[8112]061234567890121234569123456789012345", 0, "8112061234567890121234569123456789012345", "" }, // couponposoffer + /*308*/ { "[8112]0612345678901212345691234567890123456", ZINT_WARN_NONCOMPLIANT, "81120612345678901212345691234567890123456", "259: Invalid data length for AI (8112)" }, // couponposoffer + /*309*/ { "[8112]06123456789012123456912345678901234A", ZINT_WARN_NONCOMPLIANT, "811206123456789012123456912345678901234A", "261: AI (8112) position 36: Non-numeric Serial Number 'A'" }, // couponposoffer + /*310*/ { "[8112]06123456789012123456912345678901234", ZINT_WARN_NONCOMPLIANT, "811206123456789012123456912345678901234", "261: AI (8112) position 22: Serial Number incomplete" }, // couponposoffer + /*311*/ { "[8112]06123456789012123456812345678901234", 0, "811206123456789012123456812345678901234", "" }, // couponposoffer + /*312*/ { "[8112]0612345678901212345681234567890123", ZINT_WARN_NONCOMPLIANT, "81120612345678901212345681234567890123", "261: AI (8112) position 22: Serial Number incomplete" }, // couponposoffer + /*313*/ { "[8112]0612345678901212345A0123456", ZINT_WARN_NONCOMPLIANT, "81120612345678901212345A0123456", "261: AI (8112) position 15: Non-numeric Offer Code" }, // couponposoffer + /*314*/ { "[8112]0612345678901A1234560123456", ZINT_WARN_NONCOMPLIANT, "81120612345678901A1234560123456", "261: AI (8112) position 14: Non-numeric Coupon Funder ID 'A'" }, // couponposoffer + /*315*/ { "[8112]071234567890121234560123456", ZINT_WARN_NONCOMPLIANT, "8112071234567890121234560123456", "261: AI (8112) position 2: Invalid Coupon Funder ID VLI '7'" }, // couponposoffer + /*316*/ { "[8112]0A1234567890121234560123456", ZINT_WARN_NONCOMPLIANT, "81120A1234567890121234560123456", "261: AI (8112) position 2: Non-numeric Coupon Funder ID VLI 'A'" }, // couponposoffer + /*317*/ { "[8112]261234567890121234560123456", ZINT_WARN_NONCOMPLIANT, "8112261234567890121234560123456", "261: AI (8112) position 1: Coupon Format must be 0 or 1" }, // couponposoffer + /*318*/ { "[8112]A61234567890121234560123456", ZINT_WARN_NONCOMPLIANT, "8112A61234567890121234560123456", "261: AI (8112) position 1: Non-numeric Coupon Format" }, // couponposoffer + }; + int data_size = ARRAY_SIZE(data); + + char reduced[1024]; + + for (int i = 0; i < data_size; i++) { + + if (index != -1 && i != index) continue; + if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); + + struct zint_symbol *symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + int length = strlen(data[i].data); + + ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, (unsigned char *) reduced); + assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") %s\n", i, ret, data[i].ret, length, data[i].data, symbol->errtxt); + + if (ret < ZINT_ERROR) { + assert_zero(strcmp(reduced, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, reduced, data[i].expected); + } + 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); + } + + testFinish(); +} + static void test_input_mode(int index, int debug) { testStart(""); @@ -867,7 +1722,7 @@ static void test_input_mode(int index, int debug) { /* 34*/ { BARCODE_QRCODE, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 }, /* 35*/ { BARCODE_QRCODE, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char *text; struct zint_symbol previous_symbol; @@ -913,7 +1768,8 @@ int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_gs1_reduce", test_gs1_reduce, 1, 1, 1 }, { "test_hrt", test_hrt, 1, 0, 1 }, - { "test_gs1_verify", test_gs1_verify, 1, 0, 0 }, + { "test_gs1_verify", test_gs1_verify, 1, 0, 1 }, + { "test_gs1_lint", test_gs1_lint, 1, 0, 1 }, { "test_input_mode", test_input_mode, 1, 0, 1 }, }; diff --git a/backend/tests/test_iso3166.c b/backend/tests/test_iso3166.c new file mode 100644 index 00000000..1e1ff829 --- /dev/null +++ b/backend/tests/test_iso3166.c @@ -0,0 +1,776 @@ +/* + libzint - the open source barcode library + Copyright (C) 2021 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ +/* vim: set ts=4 sw=4 et : */ + +#include "testcommon.h" +#include "../iso3166.h" + +static void test_numeric(int index) { + + testStart(""); + + int ret; + struct item { + int data; + int ret; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { -1, 0 }, + /* 1*/ { 0, 0 }, + /* 2*/ { 1, 0 }, + /* 3*/ { 2, 0 }, + /* 4*/ { 3, 0 }, + /* 5*/ { 4, 1 }, + /* 6*/ { 5, 0 }, + /* 7*/ { 6, 0 }, + /* 8*/ { 7, 0 }, + /* 9*/ { 8, 1 }, + /* 10*/ { 9, 0 }, + /* 11*/ { 10, 1 }, + /* 12*/ { 11, 0 }, + /* 13*/ { 12, 1 }, + /* 14*/ { 13, 0 }, + /* 15*/ { 14, 0 }, + /* 16*/ { 15, 0 }, + /* 17*/ { 16, 1 }, + /* 18*/ { 17, 0 }, + /* 19*/ { 18, 0 }, + /* 20*/ { 19, 0 }, + /* 21*/ { 20, 1 }, + /* 22*/ { 21, 0 }, + /* 23*/ { 22, 0 }, + /* 24*/ { 23, 0 }, + /* 25*/ { 24, 1 }, + /* 26*/ { 25, 0 }, + /* 27*/ { 26, 0 }, + /* 28*/ { 27, 0 }, + /* 29*/ { 28, 1 }, + /* 30*/ { 29, 0 }, + /* 31*/ { 30, 0 }, + /* 32*/ { 31, 1 }, + /* 33*/ { 32, 1 }, + /* 34*/ { 33, 0 }, + /* 35*/ { 34, 0 }, + /* 36*/ { 35, 0 }, + /* 37*/ { 36, 1 }, + /* 38*/ { 37, 0 }, + /* 39*/ { 38, 0 }, + /* 40*/ { 39, 0 }, + /* 41*/ { 40, 1 }, + /* 42*/ { 41, 0 }, + /* 43*/ { 47, 0 }, + /* 44*/ { 48, 1 }, + /* 45*/ { 49, 0 }, + /* 46*/ { 50, 1 }, + /* 47*/ { 51, 1 }, + /* 48*/ { 52, 1 }, + /* 49*/ { 53, 0 }, + /* 50*/ { 67, 0 }, + /* 51*/ { 68, 1 }, + /* 52*/ { 69, 0 }, + /* 53*/ { 70, 1 }, + /* 54*/ { 71, 0 }, + /* 55*/ { 72, 1 }, + /* 56*/ { 73, 0 }, + /* 57*/ { 74, 1 }, + /* 58*/ { 75, 0 }, + /* 59*/ { 76, 1 }, + /* 60*/ { 77, 0 }, + /* 61*/ { 83, 0 }, + /* 62*/ { 84, 1 }, + /* 63*/ { 85, 0 }, + /* 64*/ { 86, 1 }, + /* 65*/ { 87, 0 }, + /* 66*/ { 99, 0 }, + /* 67*/ { 100, 1 }, + /* 68*/ { 101, 0 }, + /* 69*/ { 110, 0 }, + /* 70*/ { 119, 0 }, + /* 71*/ { 120, 1 }, + /* 72*/ { 121, 0 }, + /* 73*/ { 130, 0 }, + /* 74*/ { 131, 0 }, + /* 75*/ { 132, 1 }, + /* 76*/ { 133, 0 }, + /* 77*/ { 147, 0 }, + /* 78*/ { 148, 1 }, + /* 79*/ { 149, 0 }, + /* 80*/ { 150, 0 }, + /* 81*/ { 151, 0 }, + /* 82*/ { 152, 1 }, + /* 83*/ { 153, 0 }, + /* 84*/ { 154, 0 }, + /* 85*/ { 155, 0 }, + /* 86*/ { 156, 1 }, + /* 87*/ { 157, 0 }, + /* 88*/ { 158, 1 }, + /* 89*/ { 159, 0 }, + /* 90*/ { 160, 0 }, + /* 91*/ { 161, 0 }, + /* 92*/ { 162, 1 }, + /* 93*/ { 163, 0 }, + /* 94*/ { 169, 0 }, + /* 95*/ { 170, 1 }, + /* 96*/ { 171, 0 }, + /* 97*/ { 177, 0 }, + /* 98*/ { 178, 1 }, + /* 99*/ { 179, 0 }, + /*100*/ { 180, 1 }, + /*101*/ { 181, 0 }, + /*102*/ { 190, 0 }, + /*103*/ { 191, 1 }, + /*104*/ { 192, 1 }, + /*105*/ { 193, 0 }, + /*106*/ { 200, 0 }, + /*107*/ { 210, 0 }, + /*108*/ { 220, 0 }, + /*109*/ { 230, 0 }, + /*110*/ { 231, 1 }, + /*111*/ { 232, 1 }, + /*112*/ { 233, 1 }, + /*113*/ { 234, 1 }, + /*114*/ { 235, 0 }, + /*115*/ { 236, 0 }, + /*116*/ { 237, 0 }, + /*117*/ { 238, 1 }, + /*118*/ { 239, 1 }, + /*119*/ { 240, 0 }, + /*120*/ { 241, 0 }, + /*121*/ { 242, 1 }, + /*122*/ { 243, 0 }, + /*123*/ { 244, 0 }, + /*124*/ { 245, 0 }, + /*125*/ { 246, 1 }, + /*126*/ { 247, 0 }, + /*127*/ { 248, 1 }, + /*128*/ { 249, 0 }, + /*129*/ { 250, 1 }, + /*130*/ { 251, 0 }, + /*131*/ { 259, 0 }, + /*132*/ { 260, 1 }, + /*133*/ { 261, 0 }, + /*134*/ { 269, 0 }, + /*135*/ { 270, 1 }, + /*136*/ { 271, 0 }, + /*137*/ { 280, 0 }, + /*138*/ { 287, 0 }, + /*139*/ { 288, 1 }, + /*140*/ { 289, 0 }, + /*141*/ { 290, 0 }, + /*142*/ { 291, 0 }, + /*143*/ { 292, 1 }, + /*144*/ { 293, 0 }, + /*145*/ { 299, 0 }, + /*146*/ { 300, 1 }, + /*147*/ { 301, 0 }, + /*148*/ { 310, 0 }, + /*149*/ { 319, 0 }, + /*150*/ { 320, 1 }, + /*151*/ { 321, 0 }, + /*152*/ { 322, 0 }, + /*153*/ { 323, 0 }, + /*154*/ { 324, 1 }, + /*155*/ { 325, 0 }, + /*156*/ { 330, 0 }, + /*157*/ { 339, 0 }, + /*158*/ { 340, 1 }, + /*159*/ { 341, 0 }, + /*160*/ { 350, 0 }, + /*161*/ { 367, 0 }, + /*162*/ { 368, 1 }, + /*163*/ { 369, 0 }, + /*164*/ { 370, 0 }, + /*165*/ { 379, 0 }, + /*166*/ { 380, 1 }, + /*167*/ { 381, 0 }, + /*168*/ { 397, 0 }, + /*169*/ { 398, 1 }, + /*170*/ { 399, 0 }, + /*171*/ { 400, 1 }, + /*172*/ { 401, 0 }, + /*173*/ { 409, 0 }, + /*174*/ { 410, 1 }, + /*175*/ { 411, 0 }, + /*176*/ { 426, 1 }, + /*177*/ { 427, 0 }, + /*178*/ { 428, 1 }, + /*179*/ { 429, 0 }, + /*180*/ { 430, 1 }, + /*181*/ { 431, 0 }, + /*182*/ { 432, 0 }, + /*183*/ { 433, 0 }, + /*184*/ { 434, 1 }, + /*185*/ { 435, 0 }, + /*186*/ { 436, 0 }, + /*187*/ { 437, 0 }, + /*188*/ { 438, 1 }, + /*189*/ { 439, 0 }, + /*190*/ { 440, 1 }, + /*191*/ { 441, 0 }, + /*192*/ { 442, 1 }, + /*193*/ { 443, 0 }, + /*194*/ { 449, 0 }, + /*195*/ { 450, 1 }, + /*196*/ { 451, 0 }, + /*197*/ { 460, 0 }, + /*198*/ { 469, 0 }, + /*199*/ { 470, 1 }, + /*200*/ { 471, 0 }, + /*201*/ { 479, 0 }, + /*202*/ { 480, 1 }, + /*203*/ { 481, 0 }, + /*204*/ { 490, 0 }, + /*205*/ { 497, 0 }, + /*206*/ { 498, 1 }, + /*207*/ { 499, 1 }, + /*208*/ { 500, 1 }, + /*209*/ { 501, 0 }, + /*210*/ { 502, 0 }, + /*211*/ { 503, 0 }, + /*212*/ { 504, 1 }, + /*213*/ { 505, 0 }, + /*214*/ { 510, 0 }, + /*215*/ { 519, 0 }, + /*216*/ { 520, 1 }, + /*217*/ { 521, 0 }, + /*218*/ { 530, 0 }, + /*219*/ { 531, 1 }, + /*220*/ { 532, 0 }, + /*221*/ { 539, 0 }, + /*222*/ { 540, 1 }, + /*223*/ { 541, 0 }, + /*224*/ { 550, 0 }, + /*225*/ { 561, 0 }, + /*226*/ { 562, 1 }, + /*227*/ { 563, 0 }, + /*228*/ { 564, 0 }, + /*229*/ { 565, 0 }, + /*230*/ { 566, 1 }, + /*231*/ { 567, 0 }, + /*232*/ { 568, 0 }, + /*233*/ { 569, 0 }, + /*234*/ { 570, 1 }, + /*235*/ { 571, 0 }, + /*236*/ { 579, 0 }, + /*237*/ { 580, 1 }, + /*238*/ { 581, 1 }, + /*239*/ { 582, 0 }, + /*240*/ { 590, 0 }, + /*241*/ { 599, 0 }, + /*242*/ { 600, 1 }, + /*243*/ { 601, 0 }, + /*244*/ { 611, 0 }, + /*245*/ { 612, 1 }, + /*246*/ { 613, 0 }, + /*247*/ { 614, 0 }, + /*248*/ { 615, 0 }, + /*249*/ { 616, 1 }, + /*250*/ { 617, 0 }, + /*251*/ { 618, 0 }, + /*252*/ { 619, 0 }, + /*253*/ { 620, 1 }, + /*254*/ { 621, 0 }, + /*255*/ { 630, 1 }, + /*256*/ { 640, 0 }, + /*257*/ { 650, 0 }, + /*258*/ { 658, 0 }, + /*259*/ { 659, 1 }, + /*260*/ { 660, 1 }, + /*261*/ { 661, 0 }, + /*262*/ { 677, 0 }, + /*263*/ { 678, 1 }, + /*264*/ { 679, 0 }, + /*265*/ { 680, 0 }, + /*266*/ { 690, 1 }, + /*267*/ { 700, 0 }, + /*268*/ { 701, 0 }, + /*269*/ { 702, 1 }, + /*270*/ { 703, 1 }, + /*271*/ { 704, 1 }, + /*272*/ { 705, 1 }, + /*273*/ { 706, 1 }, + /*274*/ { 707, 0 }, + /*275*/ { 708, 0 }, + /*276*/ { 709, 0 }, + /*277*/ { 710, 1 }, + /*278*/ { 711, 0 }, + /*279*/ { 747, 0 }, + /*280*/ { 748, 1 }, + /*281*/ { 749, 0 }, + /*282*/ { 750, 0 }, + /*283*/ { 751, 0 }, + /*284*/ { 752, 1 }, + /*285*/ { 753, 0 }, + /*286*/ { 791, 0 }, + /*287*/ { 792, 1 }, + /*288*/ { 793, 0 }, + /*289*/ { 794, 0 }, + /*290*/ { 795, 1 }, + /*291*/ { 796, 1 }, + /*292*/ { 797, 0 }, + /*293*/ { 798, 1 }, + /*294*/ { 799, 0 }, + /*295*/ { 800, 1 }, + /*296*/ { 801, 0 }, + /*297*/ { 802, 0 }, + /*298*/ { 803, 0 }, + /*299*/ { 804, 1 }, + /*300*/ { 805, 0 }, + /*301*/ { 806, 0 }, + /*302*/ { 807, 1 }, + /*303*/ { 808, 0 }, + /*304*/ { 830, 0 }, + /*305*/ { 831, 1 }, + /*306*/ { 832, 1 }, + /*307*/ { 833, 1 }, + /*308*/ { 834, 1 }, + /*309*/ { 835, 0 }, + /*310*/ { 880, 0 }, + /*311*/ { 881, 0 }, + /*312*/ { 882, 1 }, + /*313*/ { 883, 0 }, + /*314*/ { 884, 0 }, + /*315*/ { 885, 0 }, + /*316*/ { 886, 0 }, + /*317*/ { 887, 1 }, + /*318*/ { 888, 0 }, + /*319*/ { 889, 0 }, + /*320*/ { 890, 0 }, + /*321*/ { 891, 0 }, + /*322*/ { 892, 0 }, + /*323*/ { 893, 0 }, + /*324*/ { 894, 1 }, + /*325*/ { 895, 0 }, + /*326*/ { 896, 0 }, + /*327*/ { 897, 0 }, + /*328*/ { 898, 0 }, + /*329*/ { 899, 0 }, + /*330*/ { 900, 0 }, + /*331*/ { 999, 0 }, + /*332*/ { 2000, 0 }, + }; + int data_size = ARRAY_SIZE(data); + + for (int i = 0; i < data_size; i++) { + + if (index != -1 && i != index) continue; + + ret = iso3166_numeric(data[i].data); + assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); + } + + testFinish(); +} + +/* Binary chop version: Whether ISO 3166-1 numeric */ +static int bc_iso3166_numeric(int cc) { + static const short codes[249] = { + /*AFG*/ 4, /*ALB*/ 8, /*ATA*/ 10, /*DZA*/ 12, /*ASM*/ 16, /*AND*/ 20, /*AGO*/ 24, /*ATG*/ 28, /*AZE*/ 31, /*ARG*/ 32, + /*AUS*/ 36, /*AUT*/ 40, /*BHS*/ 44, /*BHR*/ 48, /*BGD*/ 50, /*ARM*/ 51, /*BRB*/ 52, /*BEL*/ 56, /*BMU*/ 60, /*BTN*/ 64, + /*BOL*/ 68, /*BIH*/ 70, /*BWA*/ 72, /*BVT*/ 74, /*BRA*/ 76, /*BLZ*/ 84, /*IOT*/ 86, /*SLB*/ 90, /*VGB*/ 92, /*BRN*/ 96, + /*BGR*/ 100, /*MMR*/ 104, /*BDI*/ 108, /*BLR*/ 112, /*KHM*/ 116, /*CMR*/ 120, /*CAN*/ 124, /*CPV*/ 132, /*CYM*/ 136, /*CAF*/ 140, + /*LKA*/ 144, /*TCD*/ 148, /*CHL*/ 152, /*CHN*/ 156, /*TWN*/ 158, /*CXR*/ 162, /*CCK*/ 166, /*COL*/ 170, /*COM*/ 174, /*MYT*/ 175, + /*COG*/ 178, /*COD*/ 180, /*COK*/ 184, /*CRI*/ 188, /*HRV*/ 191, /*CUB*/ 192, /*CYP*/ 196, /*CZE*/ 203, /*BEN*/ 204, /*DNK*/ 208, + /*DMA*/ 212, /*DOM*/ 214, /*ECU*/ 218, /*SLV*/ 222, /*GNQ*/ 226, /*ETH*/ 231, /*ERI*/ 232, /*EST*/ 233, /*FRO*/ 234, /*FLK*/ 238, + /*SGS*/ 239, /*FJI*/ 242, /*FIN*/ 246, /*ALA*/ 248, /*FRA*/ 250, /*GUF*/ 254, /*PYF*/ 258, /*ATF*/ 260, /*DJI*/ 262, /*GAB*/ 266, + /*GEO*/ 268, /*GMB*/ 270, /*PSE*/ 275, /*DEU*/ 276, /*GHA*/ 288, /*GIB*/ 292, /*KIR*/ 296, /*GRC*/ 300, /*GRL*/ 304, /*GRD*/ 308, + /*GLP*/ 312, /*GUM*/ 316, /*GTM*/ 320, /*GIN*/ 324, /*GUY*/ 328, /*HTI*/ 332, /*HMD*/ 334, /*VAT*/ 336, /*HND*/ 340, /*HKG*/ 344, + /*HUN*/ 348, /*ISL*/ 352, /*IND*/ 356, /*IDN*/ 360, /*IRN*/ 364, /*IRQ*/ 368, /*IRL*/ 372, /*ISR*/ 376, /*ITA*/ 380, /*CIV*/ 384, + /*JAM*/ 388, /*JPN*/ 392, /*KAZ*/ 398, /*JOR*/ 400, /*KEN*/ 404, /*PRK*/ 408, /*KOR*/ 410, /*KWT*/ 414, /*KGZ*/ 417, /*LAO*/ 418, + /*LBN*/ 422, /*LSO*/ 426, /*LVA*/ 428, /*LBR*/ 430, /*LBY*/ 434, /*LIE*/ 438, /*LTU*/ 440, /*LUX*/ 442, /*MAC*/ 446, /*MDG*/ 450, + /*MWI*/ 454, /*MYS*/ 458, /*MDV*/ 462, /*MLI*/ 466, /*MLT*/ 470, /*MTQ*/ 474, /*MRT*/ 478, /*MUS*/ 480, /*MEX*/ 484, /*MCO*/ 492, + /*MNG*/ 496, /*MDA*/ 498, /*MNE*/ 499, /*MSR*/ 500, /*MAR*/ 504, /*MOZ*/ 508, /*OMN*/ 512, /*NAM*/ 516, /*NRU*/ 520, /*NPL*/ 524, + /*NLD*/ 528, /*CUW*/ 531, /*ABW*/ 533, /*SXM*/ 534, /*BES*/ 535, /*NCL*/ 540, /*VUT*/ 548, /*NZL*/ 554, /*NIC*/ 558, /*NER*/ 562, + /*NGA*/ 566, /*NIU*/ 570, /*NFK*/ 574, /*NOR*/ 578, /*MNP*/ 580, /*UMI*/ 581, /*FSM*/ 583, /*MHL*/ 584, /*PLW*/ 585, /*PAK*/ 586, + /*PAN*/ 591, /*PNG*/ 598, /*PRY*/ 600, /*PER*/ 604, /*PHL*/ 608, /*PCN*/ 612, /*POL*/ 616, /*PRT*/ 620, /*GNB*/ 624, /*TLS*/ 626, + /*PRI*/ 630, /*QAT*/ 634, /*REU*/ 638, /*ROU*/ 642, /*RUS*/ 643, /*RWA*/ 646, /*BLM*/ 652, /*SHN*/ 654, /*KNA*/ 659, /*AIA*/ 660, + /*LCA*/ 662, /*MAF*/ 663, /*SPM*/ 666, /*VCT*/ 670, /*SMR*/ 674, /*STP*/ 678, /*SAU*/ 682, /*SEN*/ 686, /*SRB*/ 688, /*SYC*/ 690, + /*SLE*/ 694, /*SGP*/ 702, /*SVK*/ 703, /*VNM*/ 704, /*SVN*/ 705, /*SOM*/ 706, /*ZAF*/ 710, /*ZWE*/ 716, /*ESP*/ 724, /*SSD*/ 728, + /*SDN*/ 729, /*ESH*/ 732, /*SUR*/ 740, /*SJM*/ 744, /*SWZ*/ 748, /*SWE*/ 752, /*CHE*/ 756, /*SYR*/ 760, /*TJK*/ 762, /*THA*/ 764, + /*TGO*/ 768, /*TKL*/ 772, /*TON*/ 776, /*TTO*/ 780, /*ARE*/ 784, /*TUN*/ 788, /*TUR*/ 792, /*TKM*/ 795, /*TCA*/ 796, /*TUV*/ 798, + /*UGA*/ 800, /*UKR*/ 804, /*MKD*/ 807, /*EGY*/ 818, /*GBR*/ 826, /*GGY*/ 831, /*JEY*/ 832, /*IMN*/ 833, /*TZA*/ 834, /*USA*/ 840, + /*VIR*/ 850, /*BFA*/ 854, /*URY*/ 858, /*UZB*/ 860, /*VEN*/ 862, /*WLF*/ 876, /*WSM*/ 882, /*YEM*/ 887, /*ZMB*/ 894, + }; + + int s = 0, e = sizeof(codes) / sizeof(codes[0]) - 1; + + while (s <= e) { + int m = (s + e) / 2; + if (codes[m] == cc) { + return 1; + } + if (codes[m] < cc) { + s = m + 1; + } else { + e = m - 1; + } + } + + return 0; +} + +static void test_numeric_bc(void) { + + testStart(""); + + int ret, bc_ret; + + for (int i = 0; i < 1001; i++) { + ret = iso3166_numeric(i); + bc_ret = bc_iso3166_numeric(i); + assert_equal(ret, bc_ret, "i:%d ret %d != bc_ret %d\n", i, ret, bc_ret); + } + + testFinish(); +} + +static void test_alpha2(int index) { + + testStart(""); + + int ret; + struct item { + const char *data; + int ret; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { "", 0 }, + /* 1*/ { "A", 0 }, + /* 2*/ { "aa", 0 }, + /* 3*/ { "AA", 0 }, + /* 4*/ { "AB", 0 }, + /* 5*/ { "AC", 0 }, + /* 6*/ { "AD", 1 }, + /* 7*/ { "ad", 0 }, + /* 8*/ { "AE", 1 }, + /* 9*/ { "AF", 1 }, + /* 10*/ { "AG", 1 }, + /* 11*/ { "AH", 0 }, + /* 12*/ { "AI", 1 }, + /* 13*/ { "AJ", 0 }, + /* 14*/ { "AP", 0 }, + /* 15*/ { "AQ", 1 }, + /* 16*/ { "AR", 1 }, + /* 17*/ { "AS", 1 }, + /* 18*/ { "AT", 1 }, + /* 19*/ { "AU", 1 }, + /* 20*/ { "AV", 0 }, + /* 21*/ { "AW", 1 }, + /* 22*/ { "AX", 1 }, + /* 23*/ { "AY", 0 }, + /* 24*/ { "AZ", 1 }, + /* 25*/ { "BA", 1 }, + /* 26*/ { "BB", 1 }, + /* 27*/ { "BC", 0 }, + /* 28*/ { "BD", 1 }, + /* 29*/ { "BX", 0 }, + /* 30*/ { "BY", 1 }, + /* 31*/ { "BZ", 1 }, + /* 32*/ { "CA", 1 }, + /* 33*/ { "CB", 0 }, + /* 34*/ { "CC", 1 }, + /* 35*/ { "CD", 1 }, + /* 36*/ { "CE", 0 }, + /* 37*/ { "CT", 0 }, + /* 38*/ { "CU", 1 }, + /* 39*/ { "CV", 1 }, + /* 40*/ { "CW", 1 }, + /* 41*/ { "CX", 1 }, + /* 42*/ { "CY", 1 }, + /* 43*/ { "CZ", 1 }, + /* 44*/ { "DA", 0 }, + /* 45*/ { "DD", 0 }, + /* 46*/ { "DE", 1 }, + /* 47*/ { "DF", 0 }, + /* 48*/ { "DY", 0 }, + /* 49*/ { "DZ", 1 }, + /* 50*/ { "EA", 0 }, + /* 51*/ { "EB", 0 }, + /* 52*/ { "EC", 1 }, + /* 53*/ { "ED", 0 }, + /* 54*/ { "EZ", 0 }, + /* 55*/ { "FA", 0 }, + /* 56*/ { "FQ", 0 }, + /* 57*/ { "FR", 1 }, + /* 58*/ { "FS", 0 }, + /* 59*/ { "FZ", 0 }, + /* 60*/ { "GA", 1 }, + /* 61*/ { "GB", 1 }, + /* 62*/ { "GC", 0 }, + /* 63*/ { "GX", 0 }, + /* 64*/ { "GY", 1 }, + /* 65*/ { "GZ", 0 }, + /* 66*/ { "HA", 0 }, + /* 67*/ { "HI", 0 }, + /* 68*/ { "HJ", 0 }, + /* 69*/ { "HK", 1 }, + /* 70*/ { "HL", 0 }, + /* 71*/ { "HZ", 0 }, + /* 72*/ { "IA", 0 }, + /* 73*/ { "IC", 0 }, + /* 74*/ { "ID", 1 }, + /* 75*/ { "IE", 1 }, + /* 76*/ { "IF", 0 }, + /* 77*/ { "IZ", 0 }, + /* 78*/ { "JA", 0 }, + /* 79*/ { "JD", 0 }, + /* 80*/ { "JE", 1 }, + /* 81*/ { "JF", 0 }, + /* 82*/ { "JZ", 0 }, + /* 83*/ { "KA", 0 }, + /* 84*/ { "KD", 0 }, + /* 85*/ { "KE", 1 }, + /* 86*/ { "KF", 0 }, + /* 87*/ { "KG", 1 }, + /* 88*/ { "KH", 1 }, + /* 89*/ { "KI", 1 }, + /* 90*/ { "KJ", 0 }, + /* 91*/ { "KX", 0 }, + /* 92*/ { "KY", 1 }, + /* 93*/ { "KZ", 1 }, + /* 94*/ { "LA", 1 }, + /* 95*/ { "LB", 1 }, + /* 96*/ { "LC", 1 }, + /* 97*/ { "LD", 0 }, + /* 98*/ { "LE", 0 }, + /* 99*/ { "LX", 0 }, + /*100*/ { "LY", 1 }, + /*101*/ { "LZ", 0 }, + /*102*/ { "MA", 1 }, + /*103*/ { "MB", 0 }, + /*104*/ { "MI", 0 }, + /*105*/ { "MJ", 0 }, + /*106*/ { "MK", 1 }, + /*107*/ { "ML", 1 }, + /*108*/ { "MM", 1 }, + /*109*/ { "MN", 1 }, + /*110*/ { "MO", 1 }, + /*111*/ { "MP", 1 }, + /*112*/ { "MQ", 1 }, + /*113*/ { "MR", 1 }, + /*114*/ { "MS", 1 }, + /*115*/ { "MT", 1 }, + /*116*/ { "MU", 1 }, + /*117*/ { "MV", 1 }, + /*118*/ { "MW", 1 }, + /*119*/ { "MX", 1 }, + /*120*/ { "MY", 1 }, + /*121*/ { "MZ", 1 }, + /*122*/ { "NA", 1 }, + /*123*/ { "NB", 0 }, + /*124*/ { "NC", 1 }, + /*125*/ { "NY", 0 }, + /*126*/ { "NZ", 1 }, + /*127*/ { "OA", 0 }, + /*128*/ { "OL", 0 }, + /*129*/ { "OM", 1 }, + /*130*/ { "ON", 0 }, + /*131*/ { "OZ", 0 }, + /*132*/ { "PA", 1 }, + /*133*/ { "PB", 0 }, + /*134*/ { "PQ", 0 }, + /*135*/ { "PR", 1 }, + /*136*/ { "PS", 1 }, + /*137*/ { "PT", 1 }, + /*138*/ { "PU", 0 }, + /*139*/ { "PV", 0 }, + /*140*/ { "PW", 1 }, + /*141*/ { "PX", 0 }, + /*142*/ { "PY", 1 }, + /*143*/ { "PZ", 0 }, + /*144*/ { "QA", 1 }, + /*145*/ { "QB", 0 }, + /*146*/ { "QZ", 0 }, + /*147*/ { "RA", 0 }, + /*148*/ { "RC", 0 }, + /*149*/ { "RD", 0 }, + /*150*/ { "RE", 1 }, + /*151*/ { "RF", 0 }, + /*152*/ { "RZ", 0 }, + /*153*/ { "SA", 1 }, + /*154*/ { "SB", 1 }, + /*155*/ { "SC", 1 }, + /*156*/ { "SD", 1 }, + /*157*/ { "SE", 1 }, + /*158*/ { "SF", 0 }, + /*159*/ { "SW", 0 }, + /*160*/ { "SX", 1 }, + /*161*/ { "SY", 1 }, + /*162*/ { "SZ", 1 }, + /*163*/ { "TA", 0 }, + /*164*/ { "TB", 0 }, + /*165*/ { "TC", 1 }, + /*166*/ { "TD", 1 }, + /*167*/ { "TE", 0 }, + /*168*/ { "TU", 0 }, + /*169*/ { "TV", 1 }, + /*170*/ { "TW", 1 }, + /*171*/ { "TX", 0 }, + /*172*/ { "TY", 0 }, + /*173*/ { "TZ", 1 }, + /*174*/ { "UA", 1 }, + /*175*/ { "UB", 0 }, + /*176*/ { "UX", 0 }, + /*177*/ { "UY", 1 }, + /*178*/ { "UZ", 1 }, + /*179*/ { "VA", 1 }, + /*180*/ { "VB", 0 }, + /*181*/ { "VC", 1 }, + /*182*/ { "VD", 0 }, + /*183*/ { "VZ", 0 }, + /*184*/ { "WA", 0 }, + /*185*/ { "WE", 0 }, + /*186*/ { "WF", 1 }, + /*187*/ { "WG", 0 }, + /*188*/ { "WZ", 0 }, + /*189*/ { "XA", 0 }, + /*190*/ { "XZ", 0 }, + /*191*/ { "YA", 0 }, + /*192*/ { "YC", 0 }, + /*193*/ { "YD", 0 }, + /*194*/ { "YE", 1 }, + /*195*/ { "YF", 0 }, + /*196*/ { "YZ", 0 }, + /*197*/ { "ZA", 1 }, + /*198*/ { "ZB", 0 }, + /*199*/ { "ZL", 0 }, + /*200*/ { "ZM", 1 }, + /*201*/ { "ZN", 0 }, + /*202*/ { "ZV", 0 }, + /*203*/ { "ZW", 1 }, + /*204*/ { "ZX", 0 }, + /*205*/ { "ZY", 0 }, + /*206*/ { "ZZ", 0 }, + /*207*/ { "Z", 0 }, + /*208*/ { "zz", 0 }, + /*209*/ { "0", 0 }, + /*210*/ { "\001", 0 }, + /*211*/ { "\177", 0 }, + /*212*/ { "\200", 0 }, + /*213*/ { "\377", 0 }, + }; + int data_size = ARRAY_SIZE(data); + + for (int i = 0; i < data_size; i++) { + + if (index != -1 && i != index) continue; + + ret = iso3166_alpha2(data[i].data); + assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); + } + + testFinish(); +} + +/* Binary chop version: Whether ISO 3166-1 alpha2 */ +static int bc_iso3166_alpha2(const char *cc) { + static const char codes[249][2] = { + {'A','D'}, {'A','E'}, {'A','F'}, {'A','G'}, {'A','I'}, {'A','L'}, {'A','M'}, {'A','O'}, {'A','Q'}, {'A','R'}, + {'A','S'}, {'A','T'}, {'A','U'}, {'A','W'}, {'A','X'}, {'A','Z'}, {'B','A'}, {'B','B'}, {'B','D'}, {'B','E'}, + {'B','F'}, {'B','G'}, {'B','H'}, {'B','I'}, {'B','J'}, {'B','L'}, {'B','M'}, {'B','N'}, {'B','O'}, {'B','Q'}, + {'B','R'}, {'B','S'}, {'B','T'}, {'B','V'}, {'B','W'}, {'B','Y'}, {'B','Z'}, {'C','A'}, {'C','C'}, {'C','D'}, + {'C','F'}, {'C','G'}, {'C','H'}, {'C','I'}, {'C','K'}, {'C','L'}, {'C','M'}, {'C','N'}, {'C','O'}, {'C','R'}, + {'C','U'}, {'C','V'}, {'C','W'}, {'C','X'}, {'C','Y'}, {'C','Z'}, {'D','E'}, {'D','J'}, {'D','K'}, {'D','M'}, + {'D','O'}, {'D','Z'}, {'E','C'}, {'E','E'}, {'E','G'}, {'E','H'}, {'E','R'}, {'E','S'}, {'E','T'}, {'F','I'}, + {'F','J'}, {'F','K'}, {'F','M'}, {'F','O'}, {'F','R'}, {'G','A'}, {'G','B'}, {'G','D'}, {'G','E'}, {'G','F'}, + {'G','G'}, {'G','H'}, {'G','I'}, {'G','L'}, {'G','M'}, {'G','N'}, {'G','P'}, {'G','Q'}, {'G','R'}, {'G','S'}, + {'G','T'}, {'G','U'}, {'G','W'}, {'G','Y'}, {'H','K'}, {'H','M'}, {'H','N'}, {'H','R'}, {'H','T'}, {'H','U'}, + {'I','D'}, {'I','E'}, {'I','L'}, {'I','M'}, {'I','N'}, {'I','O'}, {'I','Q'}, {'I','R'}, {'I','S'}, {'I','T'}, + {'J','E'}, {'J','M'}, {'J','O'}, {'J','P'}, {'K','E'}, {'K','G'}, {'K','H'}, {'K','I'}, {'K','M'}, {'K','N'}, + {'K','P'}, {'K','R'}, {'K','W'}, {'K','Y'}, {'K','Z'}, {'L','A'}, {'L','B'}, {'L','C'}, {'L','I'}, {'L','K'}, + {'L','R'}, {'L','S'}, {'L','T'}, {'L','U'}, {'L','V'}, {'L','Y'}, {'M','A'}, {'M','C'}, {'M','D'}, {'M','E'}, + {'M','F'}, {'M','G'}, {'M','H'}, {'M','K'}, {'M','L'}, {'M','M'}, {'M','N'}, {'M','O'}, {'M','P'}, {'M','Q'}, + {'M','R'}, {'M','S'}, {'M','T'}, {'M','U'}, {'M','V'}, {'M','W'}, {'M','X'}, {'M','Y'}, {'M','Z'}, {'N','A'}, + {'N','C'}, {'N','E'}, {'N','F'}, {'N','G'}, {'N','I'}, {'N','L'}, {'N','O'}, {'N','P'}, {'N','R'}, {'N','U'}, + {'N','Z'}, {'O','M'}, {'P','A'}, {'P','E'}, {'P','F'}, {'P','G'}, {'P','H'}, {'P','K'}, {'P','L'}, {'P','M'}, + {'P','N'}, {'P','R'}, {'P','S'}, {'P','T'}, {'P','W'}, {'P','Y'}, {'Q','A'}, {'R','E'}, {'R','O'}, {'R','S'}, + {'R','U'}, {'R','W'}, {'S','A'}, {'S','B'}, {'S','C'}, {'S','D'}, {'S','E'}, {'S','G'}, {'S','H'}, {'S','I'}, + {'S','J'}, {'S','K'}, {'S','L'}, {'S','M'}, {'S','N'}, {'S','O'}, {'S','R'}, {'S','S'}, {'S','T'}, {'S','V'}, + {'S','X'}, {'S','Y'}, {'S','Z'}, {'T','C'}, {'T','D'}, {'T','F'}, {'T','G'}, {'T','H'}, {'T','J'}, {'T','K'}, + {'T','L'}, {'T','M'}, {'T','N'}, {'T','O'}, {'T','R'}, {'T','T'}, {'T','V'}, {'T','W'}, {'T','Z'}, {'U','A'}, + {'U','G'}, {'U','M'}, {'U','S'}, {'U','Y'}, {'U','Z'}, {'V','A'}, {'V','C'}, {'V','E'}, {'V','G'}, {'V','I'}, + {'V','N'}, {'V','U'}, {'W','F'}, {'W','S'}, {'Y','E'}, {'Y','T'}, {'Z','A'}, {'Z','M'}, {'Z','W'}, + }; + + int s = 0, e = sizeof(codes) / sizeof(codes[0]) - 1; + + while (s <= e) { + int m = (s + e) / 2; + int cmp = strncmp(codes[m], cc, 2); + if (cmp == 0) { + return 1; + } + if (cmp < 0) { + s = m + 1; + } else { + e = m - 1; + } + } + + return 0; +} + +static void test_alpha2_bc(void) { + + testStart(""); + + int ret, bc_ret; + char data[2]; + + for (int i = 0; i < 128; i++) { + for (int j = 0; j < 128; j++) { + data[0] = i; + data[1] = j; + ret = iso3166_alpha2(data); + bc_ret = bc_iso3166_alpha2(data); + assert_equal(ret, bc_ret, "i:%d ret %d != bc_ret %d\n", i, ret, bc_ret); + } + } + + testFinish(); +} + +int main(int argc, char *argv[]) { + + testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ + { "test_numeric", test_numeric, 1, 0, 0 }, + { "test_alpha2", test_alpha2, 1, 0, 0 }, + { "test_numeric_bc", test_numeric_bc, 0, 0, 0 }, + { "test_alpha2_bc", test_alpha2_bc, 0, 0, 0 }, + }; + + testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); + + testReport(); + + return 0; +} diff --git a/backend/tests/test_iso4217.c b/backend/tests/test_iso4217.c new file mode 100644 index 00000000..422c9ef7 --- /dev/null +++ b/backend/tests/test_iso4217.c @@ -0,0 +1,513 @@ +/* + libzint - the open source barcode library + Copyright (C) 2021 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ +/* vim: set ts=4 sw=4 et : */ + +#include "testcommon.h" +#include "../iso4217.h" + +static void test_numeric(int index) { + + testStart(""); + + int ret; + struct item { + int data; + int ret; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { -1, 0 }, + /* 1*/ { 0, 0 }, + /* 2*/ { 1, 0 }, + /* 3*/ { 2, 0 }, + /* 4*/ { 3, 0 }, + /* 5*/ { 4, 0 }, + /* 6*/ { 5, 0 }, + /* 7*/ { 6, 0 }, + /* 8*/ { 7, 0 }, + /* 9*/ { 8, 1 }, + /* 10*/ { 9, 0 }, + /* 11*/ { 10, 0 }, + /* 12*/ { 11, 0 }, + /* 13*/ { 12, 1 }, + /* 14*/ { 13, 0 }, + /* 15*/ { 14, 0 }, + /* 16*/ { 15, 0 }, + /* 17*/ { 16, 0 }, + /* 18*/ { 17, 0 }, + /* 19*/ { 18, 0 }, + /* 20*/ { 19, 0 }, + /* 21*/ { 20, 0 }, + /* 22*/ { 21, 0 }, + /* 23*/ { 31, 0 }, + /* 24*/ { 32, 1 }, + /* 25*/ { 33, 0 }, + /* 26*/ { 34, 0 }, + /* 27*/ { 35, 0 }, + /* 28*/ { 36, 1 }, + /* 29*/ { 37, 0 }, + /* 30*/ { 43, 0 }, + /* 31*/ { 44, 1 }, + /* 32*/ { 45, 0 }, + /* 33*/ { 49, 0 }, + /* 34*/ { 50, 1 }, + /* 35*/ { 51, 1 }, + /* 36*/ { 52, 1 }, + /* 37*/ { 53, 0 }, + /* 38*/ { 59, 0 }, + /* 39*/ { 60, 1 }, + /* 40*/ { 61, 0 }, + /* 41*/ { 62, 0 }, + /* 42*/ { 63, 0 }, + /* 43*/ { 64, 1 }, + /* 44*/ { 65, 0 }, + /* 45*/ { 66, 0 }, + /* 46*/ { 67, 0 }, + /* 47*/ { 68, 1 }, + /* 48*/ { 69, 0 }, + /* 49*/ { 70, 0 }, + /* 50*/ { 71, 0 }, + /* 51*/ { 72, 1 }, + /* 52*/ { 73, 0 }, + /* 53*/ { 80, 0 }, + /* 54*/ { 81, 0 }, + /* 55*/ { 82, 0 }, + /* 56*/ { 83, 0 }, + /* 57*/ { 84, 1 }, + /* 58*/ { 85, 0 }, + /* 59*/ { 89, 0 }, + /* 60*/ { 90, 1 }, + /* 61*/ { 91, 0 }, + /* 62*/ { 99, 0 }, + /* 63*/ { 100, 0 }, + /* 64*/ { 101, 0 }, + /* 65*/ { 102, 0 }, + /* 66*/ { 103, 0 }, + /* 67*/ { 104, 1 }, + /* 68*/ { 105, 0 }, + /* 69*/ { 110, 0 }, + /* 70*/ { 120, 0 }, + /* 71*/ { 130, 0 }, + /* 72*/ { 131, 0 }, + /* 73*/ { 132, 1 }, + /* 74*/ { 133, 0 }, + /* 75*/ { 143, 0 }, + /* 76*/ { 144, 1 }, + /* 77*/ { 145, 0 }, + /* 78*/ { 146, 0 }, + /* 79*/ { 147, 0 }, + /* 80*/ { 148, 0 }, + /* 81*/ { 149, 0 }, + /* 82*/ { 150, 0 }, + /* 83*/ { 160, 0 }, + /* 84*/ { 169, 0 }, + /* 85*/ { 170, 1 }, + /* 86*/ { 171, 0 }, + /* 87*/ { 180, 0 }, + /* 88*/ { 190, 0 }, + /* 89*/ { 191, 1 }, + /* 90*/ { 192, 1 }, + /* 91*/ { 193, 0 }, + /* 92*/ { 200, 0 }, + /* 93*/ { 210, 0 }, + /* 94*/ { 220, 0 }, + /* 95*/ { 221, 0 }, + /* 96*/ { 222, 1 }, + /* 97*/ { 223, 0 }, + /* 98*/ { 229, 0 }, + /* 99*/ { 230, 1 }, + /*100*/ { 231, 0 }, + /*101*/ { 232, 1 }, + /*102*/ { 233, 0 }, + /*103*/ { 234, 0 }, + /*104*/ { 235, 0 }, + /*105*/ { 236, 0 }, + /*106*/ { 237, 0 }, + /*107*/ { 238, 1 }, + /*108*/ { 239, 0 }, + /*109*/ { 240, 0 }, + /*110*/ { 241, 0 }, + /*111*/ { 242, 1 }, + /*112*/ { 243, 0 }, + /*113*/ { 250, 0 }, + /*114*/ { 260, 0 }, + /*115*/ { 269, 0 }, + /*116*/ { 270, 1 }, + /*117*/ { 271, 0 }, + /*118*/ { 280, 0 }, + /*119*/ { 290, 0 }, + /*120*/ { 291, 0 }, + /*121*/ { 292, 1 }, + /*122*/ { 293, 0 }, + /*123*/ { 300, 0 }, + /*124*/ { 310, 0 }, + /*125*/ { 319, 0 }, + /*126*/ { 320, 1 }, + /*127*/ { 321, 0 }, + /*128*/ { 322, 0 }, + /*129*/ { 323, 0 }, + /*130*/ { 324, 1 }, + /*131*/ { 325, 0 }, + /*132*/ { 330, 0 }, + /*133*/ { 331, 0 }, + /*134*/ { 332, 1 }, + /*135*/ { 333, 0 }, + /*136*/ { 339, 0 }, + /*137*/ { 340, 1 }, + /*138*/ { 341, 0 }, + /*139*/ { 350, 0 }, + /*140*/ { 351, 0 }, + /*141*/ { 352, 1 }, + /*142*/ { 353, 0 }, + /*143*/ { 359, 0 }, + /*144*/ { 360, 1 }, + /*145*/ { 361, 0 }, + /*146*/ { 367, 0 }, + /*147*/ { 368, 1 }, + /*148*/ { 369, 0 }, + /*149*/ { 370, 0 }, + /*150*/ { 380, 0 }, + /*151*/ { 390, 0 }, + /*152*/ { 391, 0 }, + /*153*/ { 392, 1 }, + /*154*/ { 393, 0 }, + /*155*/ { 397, 0 }, + /*156*/ { 398, 1 }, + /*157*/ { 399, 0 }, + /*158*/ { 400, 1 }, + /*159*/ { 401, 0 }, + /*160*/ { 409, 0 }, + /*161*/ { 410, 1 }, + /*162*/ { 411, 0 }, + /*163*/ { 425, 0 }, + /*164*/ { 426, 1 }, + /*165*/ { 427, 0 }, + /*166*/ { 428, 0 }, + /*167*/ { 429, 0 }, + /*168*/ { 430, 1 }, + /*169*/ { 431, 0 }, + /*170*/ { 432, 0 }, + /*171*/ { 433, 0 }, + /*172*/ { 434, 1 }, + /*173*/ { 435, 0 }, + /*174*/ { 436, 0 }, + /*175*/ { 437, 0 }, + /*176*/ { 438, 0 }, + /*177*/ { 439, 0 }, + /*178*/ { 440, 0 }, + /*179*/ { 441, 0 }, + /*180*/ { 442, 0 }, + /*181*/ { 443, 0 }, + /*182*/ { 450, 0 }, + /*183*/ { 460, 0 }, + /*184*/ { 470, 0 }, + /*185*/ { 479, 0 }, + /*186*/ { 480, 1 }, + /*187*/ { 481, 0 }, + /*188*/ { 495, 0 }, + /*189*/ { 496, 1 }, + /*190*/ { 497, 0 }, + /*191*/ { 498, 1 }, + /*192*/ { 499, 0 }, + /*193*/ { 500, 0 }, + /*194*/ { 501, 0 }, + /*195*/ { 502, 0 }, + /*196*/ { 503, 0 }, + /*197*/ { 504, 1 }, + /*198*/ { 505, 0 }, + /*199*/ { 510, 0 }, + /*200*/ { 520, 0 }, + /*201*/ { 530, 0 }, + /*202*/ { 540, 0 }, + /*203*/ { 550, 0 }, + /*204*/ { 557, 0 }, + /*205*/ { 558, 1 }, + /*206*/ { 559, 0 }, + /*207*/ { 560, 0 }, + /*208*/ { 561, 0 }, + /*209*/ { 562, 0 }, + /*210*/ { 563, 0 }, + /*211*/ { 564, 0 }, + /*212*/ { 565, 0 }, + /*213*/ { 566, 1 }, + /*214*/ { 567, 0 }, + /*215*/ { 570, 0 }, + /*216*/ { 580, 0 }, + /*217*/ { 589, 0 }, + /*218*/ { 590, 1 }, + /*219*/ { 591, 0 }, + /*220*/ { 597, 0 }, + /*221*/ { 598, 1 }, + /*222*/ { 599, 0 }, + /*223*/ { 600, 1 }, + /*224*/ { 601, 0 }, + /*225*/ { 610, 0 }, + /*226*/ { 611, 0 }, + /*227*/ { 612, 0 }, + /*228*/ { 613, 0 }, + /*229*/ { 620, 0 }, + /*230*/ { 630, 0 }, + /*231*/ { 640, 0 }, + /*232*/ { 650, 0 }, + /*233*/ { 660, 0 }, + /*234*/ { 670, 0 }, + /*235*/ { 677, 0 }, + /*236*/ { 678, 0 }, + /*237*/ { 679, 0 }, + /*238*/ { 680, 0 }, + /*239*/ { 681, 0 }, + /*240*/ { 682, 1 }, + /*241*/ { 683, 0 }, + /*242*/ { 689, 0 }, + /*243*/ { 690, 1 }, + /*244*/ { 691, 0 }, + /*245*/ { 700, 0 }, + /*246*/ { 701, 0 }, + /*247*/ { 702, 1 }, + /*248*/ { 703, 0 }, + /*249*/ { 704, 1 }, + /*250*/ { 705, 0 }, + /*251*/ { 706, 1 }, + /*252*/ { 707, 0 }, + /*253*/ { 708, 0 }, + /*254*/ { 709, 0 }, + /*255*/ { 710, 1 }, + /*256*/ { 711, 0 }, + /*257*/ { 720, 0 }, + /*258*/ { 730, 0 }, + /*259*/ { 740, 0 }, + /*260*/ { 750, 0 }, + /*261*/ { 751, 0 }, + /*262*/ { 752, 1 }, + /*263*/ { 753, 0 }, + /*264*/ { 759, 0 }, + /*265*/ { 760, 1 }, + /*266*/ { 761, 0 }, + /*267*/ { 770, 0 }, + /*268*/ { 779, 0 }, + /*269*/ { 780, 1 }, + /*270*/ { 781, 0 }, + /*271*/ { 790, 0 }, + /*272*/ { 799, 0 }, + /*273*/ { 800, 1 }, + /*274*/ { 801, 0 }, + /*275*/ { 810, 0 }, + /*276*/ { 820, 0 }, + /*277*/ { 830, 0 }, + /*278*/ { 839, 0 }, + /*279*/ { 840, 1 }, + /*280*/ { 841, 0 }, + /*281*/ { 857, 0 }, + /*282*/ { 858, 1 }, + /*283*/ { 859, 0 }, + /*284*/ { 860, 1 }, + /*285*/ { 861, 0 }, + /*286*/ { 870, 0 }, + /*287*/ { 880, 0 }, + /*288*/ { 881, 0 }, + /*289*/ { 882, 1 }, + /*290*/ { 883, 0 }, + /*291*/ { 884, 0 }, + /*292*/ { 885, 0 }, + /*293*/ { 886, 1 }, + /*294*/ { 887, 0 }, + /*295*/ { 888, 0 }, + /*296*/ { 889, 0 }, + /*297*/ { 890, 0 }, + /*298*/ { 891, 0 }, + /*299*/ { 892, 0 }, + /*300*/ { 893, 0 }, + /*301*/ { 894, 0 }, + /*302*/ { 895, 0 }, + /*303*/ { 896, 0 }, + /*304*/ { 897, 0 }, + /*305*/ { 898, 0 }, + /*306*/ { 899, 0 }, + /*307*/ { 900, 0 }, + /*308*/ { 901, 1 }, + /*309*/ { 902, 0 }, + /*310*/ { 926, 0 }, + /*311*/ { 927, 1 }, + /*312*/ { 928, 1 }, + /*313*/ { 929, 1 }, + /*314*/ { 930, 1 }, + /*315*/ { 931, 1 }, + /*316*/ { 932, 1 }, + /*317*/ { 933, 1 }, + /*318*/ { 934, 1 }, + /*319*/ { 935, 0 }, + /*320*/ { 936, 1 }, + /*321*/ { 937, 0 }, + /*322*/ { 938, 1 }, + /*323*/ { 939, 0 }, + /*324*/ { 940, 1 }, + /*325*/ { 941, 1 }, + /*326*/ { 942, 0 }, + /*327*/ { 943, 1 }, + /*328*/ { 944, 1 }, + /*329*/ { 945, 0 }, + /*330*/ { 946, 1 }, + /*331*/ { 947, 1 }, + /*332*/ { 948, 1 }, + /*333*/ { 949, 1 }, + /*334*/ { 950, 1 }, + /*335*/ { 951, 1 }, + /*336*/ { 952, 1 }, + /*337*/ { 953, 1 }, + /*338*/ { 954, 0 }, + /*339*/ { 955, 1 }, + /*340*/ { 956, 1 }, + /*341*/ { 957, 1 }, + /*342*/ { 958, 1 }, + /*343*/ { 959, 1 }, + /*344*/ { 960, 1 }, + /*345*/ { 961, 1 }, + /*346*/ { 962, 1 }, + /*347*/ { 963, 1 }, + /*348*/ { 964, 1 }, + /*349*/ { 965, 1 }, + /*350*/ { 966, 0 }, + /*351*/ { 967, 1 }, + /*352*/ { 968, 1 }, + /*353*/ { 969, 1 }, + /*354*/ { 970, 1 }, + /*355*/ { 971, 1 }, + /*356*/ { 972, 1 }, + /*357*/ { 973, 1 }, + /*358*/ { 974, 0 }, + /*359*/ { 975, 1 }, + /*360*/ { 976, 1 }, + /*361*/ { 977, 1 }, + /*362*/ { 978, 1 }, + /*363*/ { 979, 1 }, + /*364*/ { 980, 1 }, + /*365*/ { 981, 1 }, + /*366*/ { 982, 0 }, + /*367*/ { 983, 0 }, + /*368*/ { 984, 1 }, + /*369*/ { 985, 1 }, + /*370*/ { 986, 1 }, + /*371*/ { 987, 0 }, + /*372*/ { 988, 0 }, + /*373*/ { 989, 0 }, + /*374*/ { 990, 1 }, + /*375*/ { 991, 0 }, + /*376*/ { 992, 0 }, + /*377*/ { 993, 0 }, + /*378*/ { 994, 1 }, + /*379*/ { 995, 0 }, + /*380*/ { 996, 0 }, + /*381*/ { 997, 1 }, + /*382*/ { 998, 0 }, + /*383*/ { 999, 1 }, + /*384*/ { 1000, 0 }, + /*385*/ { 2000, 0 }, + }; + int data_size = ARRAY_SIZE(data); + + for (int i = 0; i < data_size; i++) { + + if (index != -1 && i != index) continue; + + ret = iso4217_numeric(data[i].data); + assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); + } + + testFinish(); +} + +/* Binary chop version: Whether ISO 4217 numeric */ +static int bc_iso4217_numeric(int cc) { + static const short codes[179] = { + /*ALL*/ 8, /*DZD*/ 12, /*ARS*/ 32, /*AUD*/ 36, /*BSD*/ 44, /*BHD*/ 48, /*BDT*/ 50, /*AMD*/ 51, /*BBD*/ 52, /*BMD*/ 60, + /*BTN*/ 64, /*BOB*/ 68, /*BWP*/ 72, /*BZD*/ 84, /*SBD*/ 90, /*BND*/ 96, /*MMK*/ 104, /*BIF*/ 108, /*KHR*/ 116, /*CAD*/ 124, + /*CVE*/ 132, /*KYD*/ 136, /*LKR*/ 144, /*CLP*/ 152, /*CNY*/ 156, /*COP*/ 170, /*KMF*/ 174, /*CRC*/ 188, /*HRK*/ 191, /*CUP*/ 192, + /*CZK*/ 203, /*DKK*/ 208, /*DOP*/ 214, /*SVC*/ 222, /*ETB*/ 230, /*ERN*/ 232, /*FKP*/ 238, /*FJD*/ 242, /*DJF*/ 262, /*GMD*/ 270, + /*GIP*/ 292, /*GTQ*/ 320, /*GNF*/ 324, /*GYD*/ 328, /*HTG*/ 332, /*HNL*/ 340, /*HKD*/ 344, /*HUF*/ 348, /*ISK*/ 352, /*INR*/ 356, + /*IDR*/ 360, /*IRR*/ 364, /*IQD*/ 368, /*ILS*/ 376, /*JMD*/ 388, /*JPY*/ 392, /*KZT*/ 398, /*JOD*/ 400, /*KES*/ 404, /*KPW*/ 408, + /*KRW*/ 410, /*KWD*/ 414, /*KGS*/ 417, /*LAK*/ 418, /*LBP*/ 422, /*LSL*/ 426, /*LRD*/ 430, /*LYD*/ 434, /*MOP*/ 446, /*MWK*/ 454, + /*MYR*/ 458, /*MVR*/ 462, /*MUR*/ 480, /*MXN*/ 484, /*MNT*/ 496, /*MDL*/ 498, /*MAD*/ 504, /*OMR*/ 512, /*NAD*/ 516, /*NPR*/ 524, + /*ANG*/ 532, /*AWG*/ 533, /*VUV*/ 548, /*NZD*/ 554, /*NIO*/ 558, /*NGN*/ 566, /*NOK*/ 578, /*PKR*/ 586, /*PAB*/ 590, /*PGK*/ 598, + /*PYG*/ 600, /*PEN*/ 604, /*PHP*/ 608, /*QAR*/ 634, /*RUB*/ 643, /*RWF*/ 646, /*SHP*/ 654, /*SAR*/ 682, /*SCR*/ 690, /*SLL*/ 694, + /*SGD*/ 702, /*VND*/ 704, /*SOS*/ 706, /*ZAR*/ 710, /*SSP*/ 728, /*SZL*/ 748, /*SEK*/ 752, /*CHF*/ 756, /*SYP*/ 760, /*THB*/ 764, + /*TOP*/ 776, /*TTD*/ 780, /*AED*/ 784, /*TND*/ 788, /*UGX*/ 800, /*MKD*/ 807, /*EGP*/ 818, /*GBP*/ 826, /*TZS*/ 834, /*USD*/ 840, + /*UYU*/ 858, /*UZS*/ 860, /*WST*/ 882, /*YER*/ 886, /*TWD*/ 901, /*UYW*/ 927, /*VES*/ 928, /*MRU*/ 929, /*STN*/ 930, /*CUC*/ 931, + /*ZWL*/ 932, /*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944, /*RON*/ 946, + /*CHE*/ 947, /*CHW*/ 948, /*TRY*/ 949, /*XAF*/ 950, /*XCD*/ 951, /*XOF*/ 952, /*XPF*/ 953, /*XBA*/ 955, /*XBB*/ 956, /*XBC*/ 957, + /*XBD*/ 958, /*XAU*/ 959, /*XDR*/ 960, /*XAG*/ 961, /*XPT*/ 962, /*XTS*/ 963, /*XPD*/ 964, /*XUA*/ 965, /*ZMW*/ 967, /*SRD*/ 968, + /*MGA*/ 969, /*COU*/ 970, /*AFN*/ 971, /*TJS*/ 972, /*AOA*/ 973, /*BGN*/ 975, /*CDF*/ 976, /*BAM*/ 977, /*EUR*/ 978, /*MXV*/ 979, + /*UAH*/ 980, /*GEL*/ 981, /*BOV*/ 984, /*PLN*/ 985, /*BRL*/ 986, /*CLF*/ 990, /*XSU*/ 994, /*USN*/ 997, /*XXX*/ 999, + }; + + int s = 0, e = sizeof(codes) / sizeof(codes[0]) - 1; + + while (s <= e) { + int m = (s + e) / 2; + if (codes[m] == cc) { + return 1; + } + if (codes[m] < cc) { + s = m + 1; + } else { + e = m - 1; + } + } + + return 0; +} + +static void test_numeric_bc(void) { + + testStart(""); + + int ret, bc_ret; + + for (int i = 0; i < 1001; i++) { + ret = iso4217_numeric(i); + bc_ret = bc_iso4217_numeric(i); + assert_equal(ret, bc_ret, "i:%d ret %d != bc_ret %d\n", i, ret, bc_ret); + } + + testFinish(); +} + +int main(int argc, char *argv[]) { + + testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ + { "test_numeric", test_numeric, 1, 0, 0 }, + { "test_numeric_bc", test_numeric_bc, 0, 0, 0 }, + }; + + testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); + + testReport(); + + return 0; +} diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index fc3e133c..7b516a54 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -158,7 +158,7 @@ static void test_input_mode(int index, int debug) { /* 7*/ { "1234", -1, 0, DATA_MODE }, /* 8*/ { "1234", DATA_MODE | 0x10, 0, DATA_MODE | 0x10 }, // Unknown flags kept (but ignored) /* 9*/ { "1234", UNICODE_MODE | 0x10, 0, UNICODE_MODE | 0x10 }, - /* 10*/ { "[01]12345678901234", GS1_MODE | 0x20, 0, GS1_MODE | 0x20 }, + /* 10*/ { "[01]12345678901231", GS1_MODE | 0x20, 0, GS1_MODE | 0x20 }, }; int data_size = ARRAY_SIZE(data); diff --git a/backend/tests/test_raster.c b/backend/tests/test_raster.c index ebebb53f..781f6d1f 100644 --- a/backend/tests/test_raster.c +++ b/backend/tests/test_raster.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -145,7 +145,7 @@ static void test_buffer(int index, int generate, int debug) { /* 21*/ { BARCODE_EANX_CHK, "1234", "", 50, 1, 47, 118, 116 }, /* 22*/ { BARCODE_EANX, "12", "", 50, 1, 20, 64, 116 }, /* 23*/ { BARCODE_EANX_CHK, "12", "", 50, 1, 20, 64, 116 }, - /* 24*/ { BARCODE_GS1_128, "[01]12345678901234", "", 50, 1, 134, 268, 116 }, + /* 24*/ { BARCODE_GS1_128, "[01]12345678901231", "", 50, 1, 134, 268, 116 }, /* 25*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 116 }, /* 26*/ { BARCODE_CODE128, "1234567890", "", 50, 1, 90, 180, 116 }, /* 27*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 116 }, @@ -156,7 +156,7 @@ static void test_buffer(int index, int generate, int debug) { /* 32*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180, 100 }, /* 33*/ { BARCODE_DBAR_OMN, "1234567890123", "", 50, 1, 96, 192, 116 }, /* 34*/ { BARCODE_DBAR_LTD, "1234567890123", "", 50, 1, 79, 158, 116 }, - /* 35*/ { BARCODE_DBAR_EXP, "[01]12345678901234", "", 34, 1, 134, 268, 84 }, + /* 35*/ { BARCODE_DBAR_EXP, "[01]12345678901231", "", 34, 1, 134, 268, 84 }, /* 36*/ { BARCODE_TELEPEN, "1234567890", "", 50, 1, 208, 416, 116 }, /* 37*/ { BARCODE_UPCA, "12345678901", "", 50, 1, 95, 226, 116 }, /* 38*/ { BARCODE_UPCA_CHK, "123456789012", "", 50, 1, 95, 226, 116 }, @@ -199,7 +199,7 @@ static void test_buffer(int index, int generate, int debug) { /* 75*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334, 116 }, /* 76*/ { BARCODE_DBAR_STK, "1234567890123", "", 13, 3, 50, 100, 26 }, /* 77*/ { BARCODE_DBAR_OMNSTK, "1234567890123", "", 69, 5, 50, 100, 138 }, - /* 78*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901234", "", 71, 5, 102, 204, 142 }, + /* 78*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901231", "", 71, 5, 102, 204, 142 }, /* 79*/ { BARCODE_PLANET, "12345678901", "", 12, 2, 123, 246, 24 }, /* 80*/ { BARCODE_MICROPDF417, "1234567890", "", 12, 6, 82, 164, 24 }, /* 81*/ { BARCODE_USPS_IMAIL, "12345678901234567890", "", 8, 3, 129, 258, 16 }, @@ -230,10 +230,10 @@ static void test_buffer(int index, int generate, int debug) { /*106*/ { BARCODE_EANX_CC, "1234567", "[20]01", 50, 8, 72, 172, 116 }, /*107*/ { BARCODE_EANX_CC, "1234567+12", "[20]01", 50, 8, 99, 226, 116 }, /*108*/ { BARCODE_EANX_CC, "1234567+12345", "[20]01", 50, 8, 126, 280, 116 }, - /*109*/ { BARCODE_GS1_128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 116 }, + /*109*/ { BARCODE_GS1_128_CC, "[01]12345678901231", "[20]01", 50, 5, 145, 290, 116 }, /*110*/ { BARCODE_DBAR_OMN_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 58 }, /*111*/ { BARCODE_DBAR_LTD_CC, "1234567890123", "[20]01", 19, 6, 79, 158, 54 }, - /*112*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 98 }, + /*112*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901231", "[20]01", 41, 5, 134, 268, 98 }, /*113*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 116 }, /*114*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 116 }, /*115*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 116 }, @@ -242,7 +242,7 @@ static void test_buffer(int index, int generate, int debug) { /*118*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 116 }, /*119*/ { BARCODE_DBAR_STK_CC, "1234567890123", "[20]01", 24, 9, 56, 112, 48 }, /*120*/ { BARCODE_DBAR_OMNSTK_CC, "1234567890123", "[20]01", 80, 11, 56, 112, 160 }, - /*121*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, + /*121*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901231", "[20]01", 78, 9, 102, 204, 156 }, /*122*/ { BARCODE_CHANNEL, "01", "", 50, 1, 19, 38, 116 }, /*123*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, /*124*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, diff --git a/backend/tests/test_rss.c b/backend/tests/test_rss.c index bb392409..da687df8 100644 --- a/backend/tests/test_rss.c +++ b/backend/tests/test_rss.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -193,6 +193,7 @@ static void test_examples(int index, int generate, int debug) { int option_2; char *data; + int ret; int expected_rows; int expected_width; int bwipp_cmp; @@ -201,109 +202,109 @@ static void test_examples(int index, int generate, int debug) { }; // Verified manually against GS1 General Specifications 20.0 (GGS) and ISO/IEC 24724:2011, and verified via bwipp_dump.ps against BWIPP struct item data[] = { - /* 0*/ { BARCODE_DBAR_OMN, -1, "0950110153001", 1, 96, 1, "GGS Figure 5.5.2.1.1-1. GS1 DataBar Omnidirectional", + /* 0*/ { BARCODE_DBAR_OMN, -1, "0950110153001", 0, 1, 96, 1, "GGS Figure 5.5.2.1.1-1. GS1 DataBar Omnidirectional", "010000010100000101000111110000010111101101011100100011011101000101100000000111001110110111001101" }, - /* 1*/ { BARCODE_DBAR_EXP, -1, "[01]90614141000015[3202]000150", 1, 151, 1, "GGS Figure 5.5.2.3.1-1. GS1 DataBar Expanded", + /* 1*/ { BARCODE_DBAR_EXP, -1, "[01]90614141000015[3202]000150", 0, 1, 151, 1, "GGS Figure 5.5.2.3.1-1. GS1 DataBar Expanded", "0101100011001100001011111111000010100100010000111101110011100010100010111100000011100111010111111011010100000100000110001111110000101000000100011010010" }, - /* 2*/ { BARCODE_DBAR_EXPSTK, -1, "[01]90614141000015[3202]000150", 5, 102, 1, "GGS Figure 5.5.2.3.2-1. GS1 DataBar Expanded Stacked, same (tec-it separator differs)", + /* 2*/ { BARCODE_DBAR_EXPSTK, -1, "[01]90614141000015[3202]000150", 0, 5, 102, 1, "GGS Figure 5.5.2.3.2-1. GS1 DataBar Expanded Stacked, same (tec-it separator differs)", "010110001100110000101111111100001010010001000011110111001110001010001011110000001110011101011111101101" "000001110011001111010000000010100101101110111100001000110001110101110100001010100001100010100000010000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "000001011111011111001010000001010010111111011100100000000000000000000000000000000000000000000000000000" "001010100000100000110001111110000101000000100011010010000000000000000000000000000000000000000000000000" }, - /* 3*/ { BARCODE_DBAR_OMN, -1, "2001234567890", 1, 96, 1, "24724:2011 Figure 1 — GS1 DataBar Omnidirectional", + /* 3*/ { BARCODE_DBAR_OMN, -1, "2001234567890", 0, 1, 96, 1, "24724:2011 Figure 1 — GS1 DataBar Omnidirectional", "010100011101000001001111111000010100110110111110110000010010100101100000000111000110110110001101" }, - /* 4*/ { BARCODE_DBAR_OMN, -1, "0441234567890", 1, 96, 1, "24724:2011 Figure 2 — GS1 DataBar Omnidirectional", + /* 4*/ { BARCODE_DBAR_OMN, -1, "0441234567890", 0, 1, 96, 1, "24724:2011 Figure 2 — GS1 DataBar Omnidirectional", "010010001000010001000111000000010101000001100110101100100100000101111110000011000010100011100101" }, - /* 5*/ { BARCODE_DBAR_OMN, -1, "0001234567890", 1, 96, 1, "24724:2011 Figure 4 — GS1 DataBar Truncated", + /* 5*/ { BARCODE_DBAR_OMN, -1, "0001234567890", 0, 1, 96, 1, "24724:2011 Figure 4 — GS1 DataBar Truncated", "010101001000000001001111111000010111001011011110111001010110000101111111000111001100111101110101" }, - /* 6*/ { BARCODE_DBAR_STK, -1, "0001234567890", 3, 50, 1, "24724:2011 Figure 5 — GS1 DataBar Stacked NOTE: Figure 5 separator differs from GGS Figure 5.5.2.1.3-1. which has ends set", + /* 6*/ { BARCODE_DBAR_STK, -1, "0001234567890", 0, 3, 50, 1, "24724:2011 Figure 5 — GS1 DataBar Stacked NOTE: Figure 5 separator differs from GGS Figure 5.5.2.1.3-1. which has ends set", "01010100100000000100111111100001011100101101111010" "00001010101011111010000000111010100011010010000000" "10111001010110000101111111000111001100111101110101" }, - /* 7*/ { BARCODE_DBAR_OMNSTK, -1, "0003456789012", 5, 50, 1, "24724:2011 Figure 6 — GS1 DataBar Stacked Omnidirectional", + /* 7*/ { BARCODE_DBAR_OMNSTK, -1, "0003456789012", 0, 5, 50, 1, "24724:2011 Figure 6 — GS1 DataBar Stacked Omnidirectional", "01010100100000000100111110000001010011100110011010" "00001011011111111010000001010100101100011001100000" "00000101010101010101010101010101010101010101010000" "00001000100010111010010101010000111101001101110000" "10110111011101000101100000000111000010110010001101" }, - /* 8*/ { BARCODE_DBAR_LTD, -1, "1501234567890", 1, 79, 1, "24724:2011 Figure 7 — GS1 DataBar Limited", + /* 8*/ { BARCODE_DBAR_LTD, -1, "1501234567890", 0, 1, 79, 1, "24724:2011 Figure 7 — GS1 DataBar Limited", "0100011001100011011010100111010010101101001101001001011000110111001100110100000" }, - /* 9*/ { BARCODE_DBAR_LTD, -1, "0031234567890", 1, 79, 1, "24724:2011 Figure 8 — (a) GS1 DataBar Limited", + /* 9*/ { BARCODE_DBAR_LTD, -1, "0031234567890", 0, 1, 79, 1, "24724:2011 Figure 8 — (a) GS1 DataBar Limited", "0101010000010010001000010111001010110110100101011000001010010010110000010100000" }, - /* 10*/ { BARCODE_DBAR_EXP, -1, "[01]98898765432106[3202]012345[15]991231", 1, 200, 1, "24724:2011 Figure 10 — GS1 DataBar Expanded", + /* 10*/ { BARCODE_DBAR_EXP, -1, "[01]98898765432106[3202]012345[15]991231", 0, 1, 200, 1, "24724:2011 Figure 10 — GS1 DataBar Expanded", "01001000011000110110111111110000101110000110010100011010000001100010101111110000111010011100000010010100111110111001100011111100001011101100000100100100011110010110001011111111001110001101111010000101" }, - /* 11*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]001750", 1, 151, 1, "24724:2011 Figure 11 — GS1 DataBar Expanded", + /* 11*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]001750", 0, 1, 151, 1, "24724:2011 Figure 11 — GS1 DataBar Expanded", "0101110010000010011011111111000010111000010011000101011110111001100010111100000011100101110001110111011110101111000110001111110000101011000010011111010" }, - /* 12*/ { BARCODE_DBAR_EXPSTK, -1, "[01]98898765432106[3202]012345[15]991231", 5, 102, 1, "24724:2011 Figure 12 — GS1 DataBar Expanded Stacked symbol", + /* 12*/ { BARCODE_DBAR_EXPSTK, -1, "[01]98898765432106[3202]012345[15]991231", 0, 5, 102, 1, "24724:2011 Figure 12 — GS1 DataBar Expanded Stacked symbol", "010010000110001101101111111100001011100001100101000110100000011000101011111100001110100111000000100101" "000001111001110010010000000010100100011110011010111001011111100111010100000010100001011000111111010000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "000011101000010011100001000000001011100101100001110110110111110010001001010000001010011000100000110000" "101000010111101100011100111111110100011010011110001001001000001101110100001111110001100111011111001010" }, - /* 13*/ { BARCODE_DBAR_EXPSTK, -1, "[01]95012345678903[3103]000123", 5, 102, 1, "24724:2011 Figure 13 — GS1 DataBar Expanded Stacked", + /* 13*/ { BARCODE_DBAR_EXPSTK, -1, "[01]95012345678903[3103]000123", 0, 5, 102, 1, "24724:2011 Figure 13 — GS1 DataBar Expanded Stacked", "010100010001111000101111111100001010111000001100010111000110001001101011110000001110010111000111011101" "000011101110000111010000000010100101000111110011101000111001110110010100001010100001101000111000100000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "000000001010000111001010000001010010111011011111100000000000000000000000000000000000000000000000000000" "001011110101111000110001111110000101000100100000011010000000000000000000000000000000000000000000000000" }, - /* 14*/ { BARCODE_DBAR_LTD, -1, "0009876543210", 1, 79, 1, "24724:2011 Figure F.2 — GS1 DataBar Limited", + /* 14*/ { BARCODE_DBAR_LTD, -1, "0009876543210", 0, 1, 79, 1, "24724:2011 Figure F.2 — GS1 DataBar Limited", "0101010010010011000011000001010110100101100101000100010100010000010010010100000" }, - /* 15*/ { BARCODE_DBAR_EXP, -1, "[10]12A", 1, 102, 1, "24724:2011 Figure F.3 — GS1 DataBar Expanded", + /* 15*/ { BARCODE_DBAR_EXP, -1, "[10]12A", 0, 1, 102, 1, "24724:2011 Figure F.3 — GS1 DataBar Expanded", "010100000110100000101111111100001010001000000010110101111100100111001011110000000010011101111111010101" }, - /* 16*/ { BARCODE_DBAR_STK, -1, "0000000000000", 3, 50, 1, "#183 GS1 DataBar Stacked separator alternation; verified manually against tec-it.com", + /* 16*/ { BARCODE_DBAR_STK, -1, "0000000000000", 0, 3, 50, 1, "#183 GS1 DataBar Stacked separator alternation; verified manually against tec-it.com", "01010100100000000100011111111001011111110010101010" "00000101011111111010100000001010100000001101010000" "10101010110000000101111111110111011111111011010101" }, - /* 17*/ { BARCODE_DBAR_EXP, -1, "[255]95011015340010123456789", 1, 232, 1, "GGS 2.6.2.1 Example 1", + /* 17*/ { BARCODE_DBAR_EXP, -1, "[255]95011015340010123456789", 0, 1, 232, 1, "GGS 2.6.2.1 Example 1", "0100011000110001011011111111000010100000010101100001100001100111001010111110000001100100001110100001001000011011111010001111110000101001011111100111011001000111100100101111111100111011111001100100110010011100010111100011110000001010" }, - /* 18*/ { BARCODE_DBAR_EXP, -1, "[255]95011015340010123456789[3900]000", 1, 298, 1, "GGS 2.6.2.1 Example 2", + /* 18*/ { BARCODE_DBAR_EXP, -1, "[255]95011015340010123456789[3900]000", 0, 1, 298, 1, "GGS 2.6.2.1 Example 2", "0101100011111010001011111111000010100001000001001101100001100111001010111110000001100100001110100001001000011011111010001111110000101001011111100111011001000111100100101111111100111011111001100100110010011100010111100011000000001010111111011101000100001000110001101011111111100110011110010010001101" }, - /* 19*/ { BARCODE_DBAR_EXP, -1, "[255]9501101534001[17]160531[3902]050", 1, 281, 1, "GGS 2.6.2.1 Example 3", + /* 19*/ { BARCODE_DBAR_EXP, -1, "[255]9501101534001[17]160531[3902]050", 0, 1, 281, 1, "GGS 2.6.2.1 Example 3", "01011001000110011110111111110000101000000101011000011000011001110010101111100000011001000011101000010010000110111110100011111100001010010111111001110111000010010100001011111111001110000100001100110100010000001101001000110000000010111010011110011101110010110001100010111111111001101" }, - /* 20*/ { BARCODE_DBAR_EXPSTK, 3, "[255]9501101534001012345[8111]0500", 5, 151, 1, "GGS 2.6.2.1 Example 4, same (tec-it separator differs)", + /* 20*/ { BARCODE_DBAR_EXPSTK, 3, "[255]9501101534001012345[8111]0500", 0, 5, 151, 1, "GGS 2.6.2.1 Example 4, same (tec-it separator differs)", "0101100111100011001011111111000010100000010101100001100001100111001010111110000001100100001110100001001000011011111010001111110000101001011111100111010" "0000011000011100110100000000101001011111101010011110011110011000110101000001010100011011110001011110110111100100000101010000001010010110100000011000000" "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" "0000110111000011011010000000010000100000100111011001100001100100010010100101010100101110110001111001011101100011101110100000000010000000000000000000000" "1011001000111100100101111111100111011111011000100110011110011011101100011000000001010001001110000110100010011100010001011111111100110100000000000000000" }, - /* 21*/ { BARCODE_DBAR_EXPSTK, 3, "[255]9501101534001[3941]0035", 5, 151, 1, "GGS 2.6.2.1 Example 5, same (tec-it separator differs)", + /* 21*/ { BARCODE_DBAR_EXPSTK, 3, "[255]9501101534001[3941]0035", 0, 5, 151, 1, "GGS 2.6.2.1 Example 5, same (tec-it separator differs)", "0100001101011000011011111111000010100000010101100001100001100111001010111110000001100100001110100001001000011011111010001111110000101001011111100111010" "0000110010100111100100000000101001011111101010011110011110011000110101000001010100011011110001011110110111100100000101010000001010010110100000011000000" "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" "0000011011111011111010000000010000111100101011111001000100011100111010100001010100000000000000000000000000000000000000000000000000000000000000000000000" "1010100100000100000101111111100111000011010100000110111011100011000100011110000001010000000000000000000000000000000000000000000000000000000000000000000" }, - /* 22*/ { BARCODE_DBAR_OMN, -1, "0950110153000", 1, 96, 1, "https://www.gs1.org/standards/barcodes/databar, same, verified manually against tec-it", + /* 22*/ { BARCODE_DBAR_OMN, -1, "0950110153000", 0, 1, 96, 1, "https://www.gs1.org/standards/barcodes/databar, same, verified manually against tec-it", "010000010100000101000111111110010111101101011100100011011011000101111110000011001110110111001101" }, - /* 23*/ { BARCODE_DBAR_STK, -1, "0950110153000", 3, 50, 1, "https://www.gs1.org/standards/barcodes/databar, same, verified manually against tec-it", + /* 23*/ { BARCODE_DBAR_STK, -1, "0950110153000", 0, 3, 50, 1, "https://www.gs1.org/standards/barcodes/databar, same, verified manually against tec-it", "01000001010000010100011111111001011110110101110010" "00001100101101101010100001010100100001001010100000" "10100011011011000101111110000011001110110111001101" }, - /* 24*/ { BARCODE_DBAR_EXPSTK, -1, "[01]09501101530003[17]140704[10]AB-123", 9, 102, 1, "https://www.gs1.org/standards/barcodes/databar, same (tec-it separator differs)", + /* 24*/ { BARCODE_DBAR_EXPSTK, -1, "[01]09501101530003[17]140704[10]AB-123", 0, 9, 102, 1, "https://www.gs1.org/standards/barcodes/databar, same (tec-it separator differs)", "010101111100001001101111111100001011100001110110010100000011011010001011111000000110011010000001001101" "000010000011110110010000000010100100011110001001101011111100100101110100000101010001100101111110110000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" @@ -314,64 +315,64 @@ static void test_examples(int index, int generate, int debug) { "000010111101011110010100101010100100111100110010111001001100011111010100000000010000000000000000000000" "010001000010100001100011000000001011000011001101000110110011100000101011111111100110100000000000000000" }, - /* 25*/ { BARCODE_DBAR_EXP, -1, "[01]09501101530003[17]140704[10]AB-123", 1, 281, 1, "https://www.gs1.org/standards/barcodes/databar, same, verified manually against tec-it", + /* 25*/ { BARCODE_DBAR_EXP, -1, "[01]09501101530003[17]140704[10]AB-123", 0, 1, 281, 1, "https://www.gs1.org/standards/barcodes/databar, same, verified manually against tec-it", "01010111110000100110111111110000101110000111011001010000001101101000101111100000011001101000000100110001110100010001100011111100001010100000111100100100100111000001001011111111001110000011011001000100010000101000011000110000000010110000110011010001101100111000001010111111111001101" }, - /* 26*/ { BARCODE_DBAR_STK, -1, "07010001234567", 3, 50, 1, "https://www.gs1.no/support/standardbibliotek/datafangst/gs1-databar, same, verified manually against tec-it", + /* 26*/ { BARCODE_DBAR_STK, -1, "07010001234567", 0, 3, 50, 1, "https://www.gs1.no/support/standardbibliotek/datafangst/gs1-databar, same, verified manually against tec-it", "01000100001010000100011100000001011000100110001010" "00000011010101011010101011111010100111010101010000" "10111100101110100101100000000111011000001000110101" }, - /* 27*/ { BARCODE_DBAR_OMNSTK, -1, "12380000000008", 5, 50, 1, "Example with finder values 3 & 3; for bottom row see 5.3.2.2, same as BWIPP (tec-it and IDAutomation differ (ie no shift))", + /* 27*/ { BARCODE_DBAR_OMNSTK, -1, "12380000000008", 0, 5, 50, 1, "Example with finder values 3 & 3; for bottom row see 5.3.2.2, same as BWIPP (tec-it and IDAutomation differ (ie no shift))", "01011101001000000100010000000001010000001101011010" "00000010110111111010101010101010101111110010100000" "00000101010101010101010101010101010101010101010000" "00001101100011001010000000000100101100111011110000" "10100010011100110101111111110111010011000100001101" }, - /* 28*/ { BARCODE_DBAR_OMNSTK, -1, "99991234912372", 5, 50, 1, "Example with finder values 8 & 6, same as BWIPP, verified manually against tec-it and IDAutomation", + /* 28*/ { BARCODE_DBAR_OMNSTK, -1, "99991234912372", 0, 5, 50, 1, "Example with finder values 8 & 6, same as BWIPP, verified manually against tec-it and IDAutomation", "01001011101110000101110000000001011111011100101010" "00000100010001111010001010101010100000100011010000" "00000101010101010101010101010101010101010101010000" "00001000100011001010000000010100100001000100100000" "10100111011100110101111111100011011110111011011101" }, - /* 29*/ { BARCODE_DBAR_OMNSTK, -1, "32219876543217", 5, 50, 1, "Example with finder values 6 & 1, same as BWIPP, verified manually against tec-it and IDAutomation", + /* 29*/ { BARCODE_DBAR_OMNSTK, -1, "32219876543217", 0, 5, 50, 1, "Example with finder values 6 & 1, same as BWIPP, verified manually against tec-it and IDAutomation", "01001011000010001100111000000001011100010101000010" "00000100111101110010000101010100100011101010110000" "00000101010101010101010101010101010101010101010000" "00001110011100101010000010101000110100001000010000" "10110001100011010101111100000111001011110111100101" }, - /* 30*/ { BARCODE_DBAR_OMNSTK, -1, "32219876543255", 5, 50, 1, "Example with finder values 7 & 7, same as BWIPP, verified manually against tec-it and IDAutomation", + /* 30*/ { BARCODE_DBAR_OMNSTK, -1, "32219876543255", 0, 5, 50, 1, "Example with finder values 7 & 7, same as BWIPP, verified manually against tec-it and IDAutomation", "01001011000010001101111100000001011100010101000010" "00000100111101110010000010101010100011101010110000" "00000101010101010101010101010101010101010101010000" "00000111001110101010000000101010110100001000010000" "10111000110001010101111111000001001011110111100101" }, - /* 31*/ { BARCODE_DBAR_OMNSTK, -1, "04072912296211", 5, 50, 1, "Example with finder values 7 & 8, same as BWIPP, verified manually against tec-it and IDAutomation", + /* 31*/ { BARCODE_DBAR_OMNSTK, -1, "04072912296211", 0, 5, 50, 1, "Example with finder values 7 & 8, same as BWIPP, verified manually against tec-it and IDAutomation", "01001001000000010101111100000001011111000100101010" "00000110111111101010000010101010100000111011010000" "00000101010101010101010101010101010101010101010000" "00001110100010111010000000001010111010000111010000" "10110001011101000101111111110001000101111000101101" }, - /* 32*/ { BARCODE_DBAR_OMNSTK, -1, "06666666666666", 5, 50, 1, "Example with finder values 6 & 4, same as BWIPP, verified manually against tec-it and IDAutomation", + /* 32*/ { BARCODE_DBAR_OMNSTK, -1, "06666666666666", 0, 5, 50, 1, "Example with finder values 6 & 4, same as BWIPP, verified manually against tec-it and IDAutomation", "01000100010010000100111000000001011110111100101010" "00001011101101111010000101010100100001000011010000" "00000101010101010101010101010101010101010101010000" "00000100011111001010000101010100101001100001110000" "10101011100000110101111000000011010110011110000101" }, - /* 33*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12345678901234567", 5, 102, 1, "Example with 7 chars, 1 full row, bottom 3 chars", + /* 33*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12345678901234567", 0, 5, 102, 1, "Example with 7 chars, 1 full row, bottom 3 chars", "010010100001111000101111111100001010000010001110110100111110001011101011111100001110001111010011000101" "000001011110000111010000000010100101111101110001001011000001110100010100000010100001110000101100110000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "000000100000000101111110110001101011110001110011010100101000000101000010010111000000000000000000000000" "101110011111111010000001001110010100001110001100101010000111111000111101101000111101000000000000000000" }, - /* 34*/ { BARCODE_DBAR_EXPSTK, -1, "[90]123456789012345678901234567", 9, 102, 1, "Example with 10 chars, 2 full rows, bottom 2 chars", + /* 34*/ { BARCODE_DBAR_EXPSTK, -1, "[90]123456789012345678901234567", 0, 9, 102, 1, "Example with 10 chars, 2 full rows, bottom 2 chars", "010000111100100010101111111100001010001000100000110100111110001011101011111000000110001111010011000101" "000011000011011101010000000010100101110111011111001011000001110100010100000101010001110000101100110000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" @@ -382,7 +383,7 @@ static void test_examples(int index, int generate, int debug) { "000010000110110001010100001010100100000111010011000000000000000000000000000000000000000000000000000000" "010001111001001110100011110000001011111000101100100100000000000000000000000000000000000000000000000000" }, - /* 35*/ { BARCODE_DBAR_EXPSTK, -1, "[90]123456789012345678901234567890", 9, 102, 1, "Example with 11 chars, 2 full rows, bottom 3 chars", + /* 35*/ { BARCODE_DBAR_EXPSTK, -1, "[90]123456789012345678901234567890", 0, 9, 102, 1, "Example with 11 chars, 2 full rows, bottom 3 chars", "010111011100010001101111111100001010000010001110110100111110001011101011111000000110001111010011000101" "000000100011101110010000000010100101111101110001001011000001110100010100000101010001110000101100110000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" @@ -393,7 +394,7 @@ static void test_examples(int index, int generate, int debug) { "000010000110110001010100101010100100111000100011011011000110001101110100000000010000000000000000000000" "010001111001001110100011000000001011000111011100100100111001110010001011111111100110100000000000000000" }, - /* 36*/ { BARCODE_DBAR_EXPSTK, -1, "[91]1234567890123456789012345678901234", 9, 102, 1, "Example with 12 chars, 3 full rows", + /* 36*/ { BARCODE_DBAR_EXPSTK, -1, "[91]1234567890123456789012345678901234", 0, 9, 102, 1, "Example with 12 chars, 3 full rows", "010100010011111001101111111100001011001000010000010100111110001011101011111000000110001111010011000101" "000011101100000110010000000010100100110111101111101011000001110100010100000101010001110000101100110000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" @@ -404,7 +405,7 @@ static void test_examples(int index, int generate, int debug) { "000010000110110001010100101010100100111000100011011011000110001110110100000000010001101110100001000000" "010001111001001110100011000000001011000111011100100100111001110001001011111111100110010001011110111101" }, - /* 37*/ { BARCODE_DBAR_EXPSTK, -1, "[91]123456789012345678901234567890123456789012", 13, 102, 1, "Example with 15 chars, 3 full rows, bottom 7 chars", + /* 37*/ { BARCODE_DBAR_EXPSTK, -1, "[91]123456789012345678901234567890123456789012", 0, 13, 102, 1, "Example with 15 chars, 3 full rows, bottom 7 chars", "010010000111101011101111111100001011100000101100010100111110001011101011110000000010001111010011000101" "000001111000010100010000000010100100011111010011101011000001110100010100001010101001110000101100110000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" @@ -419,7 +420,7 @@ static void test_examples(int index, int generate, int debug) { "000000100000000101001001111101100011000010000110010100101010100101011111011100100000000000000000000000" "101110011111111010110110000010011100111101111001101010000000011000100000100011011101000000000000000000" }, - /* 38*/ { BARCODE_DBAR_EXPSTK, 3, "[91]123456789012345678901234567890123456789012", 9, 151, 1, "Example with 15 chars, 2 full rows, bottom 3 chars", + /* 38*/ { BARCODE_DBAR_EXPSTK, 3, "[91]123456789012345678901234567890123456789012", 0, 9, 151, 1, "Example with 15 chars, 2 full rows, bottom 3 chars", "0100100001111010111011111111000010111000001011000101001111100010111010111100000000100011110100110001011110001011011110001111110000101010011000111000010" "0000011110000101000100000000101001000111110100111010110000011101000101000010101010011100001011001110100001110100100001010000001010010101100111000110000" "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" @@ -430,7 +431,7 @@ static void test_examples(int index, int generate, int debug) { "0000001001110111110101001010101001010011000010000110001101111100100101000000001000000000000000000000000000000000000000000000000000000000000000000000000" "0101110110001000001000110000000010101100111101111001110010000011011010111111110011101000000000000000000000000000000000000000000000000000000000000000000" }, - /* 39*/ { BARCODE_DBAR_EXPSTK, -1, "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG", 17, 102, 1, "Example with 19 chars, 4 full rows, bottom 3 chars", + /* 39*/ { BARCODE_DBAR_EXPSTK, -1, "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG", 0, 17, 102, 1, "Example with 19 chars, 4 full rows, bottom 3 chars", "010101111100011101101111111100001011100000101100010101111110011110101011110000000010111000111110010101" "000010000011100010010000000010100100011111010011101010000001100001010100001010101001000111000001100000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" @@ -449,7 +450,7 @@ static void test_examples(int index, int generate, int debug) { "000010011111000111010001010101010101000111001111011011110100110000110100000000010000000000000000000000" "010101100000111000100110000000001010111000110000100100001011001111001011111111100110100000000000000000" }, - /* 40*/ { BARCODE_DBAR_EXPSTK, -1, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 21, 102, 1, "Example with 22 chars, 5 full rows, bottom 2 chars", + /* 40*/ { BARCODE_DBAR_EXPSTK, -1, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 21, 102, 1, "Example with 22 chars, 5 full rows, bottom 2 chars", "010101011110111111101111111100001011001000000101000100111110001011101011110000000010001111010011000101" "000010100001000000010000000010100100110111111010111011000001110100010100001010101001110000101100110000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" @@ -472,7 +473,7 @@ static void test_examples(int index, int generate, int debug) { "000001000111010000101000101010101010100001011000110000000000000000000000000000000000000000000000000000" "001000111000101111010011000000000101011110100111000010000000000000000000000000000000000000000000000000" }, - /* 41*/ { BARCODE_DBAR_EXPSTK, 3, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 13, 151, 1, "Example with 22 chars, 3 full rows, bottom 4 chars", + /* 41*/ { BARCODE_DBAR_EXPSTK, 3, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 13, 151, 1, "Example with 22 chars, 3 full rows, bottom 4 chars", "0101010111101111111011111111000010110010000001010001001111100010111010111100000000100011110100110001011110001011011110001111110000101010011000111000010" "0000101000010000000100000000101001001101111110101110110000011101000101000010101010011100001011001110100001110100100001010000001010010101100111000110000" "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" @@ -487,7 +488,7 @@ static void test_examples(int index, int generate, int debug) { "0000101110001000111010000000001000101111101000110001110001110100001010001010101010101000010110001100000000000000000000000000000000000000000000000000000" "1010010001110111000101111111110011010000010111001110001110001011110100110000000001010111101001110000100000000000000000000000000000000000000000000000000" }, - /* 42*/ { BARCODE_DBAR_EXPSTK, 4, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 9, 200, 1, "Example with 22 chars, 2 full rows, bottom 6 chars", + /* 42*/ { BARCODE_DBAR_EXPSTK, 4, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 9, 200, 1, "Example with 22 chars, 2 full rows, bottom 6 chars", "01010101111011111110111111110000101100100000010100010011111000101110101111000000001000111101001100010111100010110111100011111100001010100110001110000101001110000010001011110000001110001110001000100101" "00001010000100000001000000001010010011011111101011101100000111010001010000101010100111000010110011101000011101001000010100000010100101011001110001111010110001111101110100001010100001110001110111010000" "00000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" @@ -498,7 +499,7 @@ static void test_examples(int index, int generate, int debug) { "00000011000110001001000000010101010000011110011010101101110001000111010000000001000101111101000110001110001110100001010001010101010101000010110001100000000000000000000000000000000000000000000000000000" "01011100111001110110011111100000101111100001100101010010001110111000101111111110011010000010111001110001110001011110100110000000001010111101001110000100000000000000000000000000000000000000000000000000" }, - /* 43*/ { BARCODE_DBAR_EXPSTK, 5, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 9, 249, 1, "Example with 22 chars, 2 full rows, bottom 2 chars", + /* 43*/ { BARCODE_DBAR_EXPSTK, 5, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 9, 249, 1, "Example with 22 chars, 2 full rows, bottom 2 chars", "010101011110111111101111111100001011001000000101000100111110001011101011110000000010001111010011000101111000101101111000111111000010101001100011100001010011100000100010111100000011100011100010001001000111100100111010001111000000101100011101110010010" "000010100001000000010000000010100100110111111010111011000001110100010100001010101001110000101100111010000111010010000101000000101001010110011100011110101100011111011101000010101000011100011101110110111000011011000101010000101010010011100010001100000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" @@ -509,45 +510,45 @@ static void test_examples(int index, int generate, int debug) { "000010001110100001010001010101010101000010110001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "010001110001011110100110000000001010111101001110000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, - /* 44*/ { BARCODE_DBAR_EXPSTK, 6, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 5, 298, 1, "Example with 22 chars, 1 full row, bottom 10 chars", + /* 44*/ { BARCODE_DBAR_EXPSTK, 6, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 5, 298, 1, "Example with 22 chars, 1 full row, bottom 10 chars", "0101010111101111111011111111000010110010000001010001001111100010111010111100000000100011110100110001011110001011011110001111110000101010011000111000010100111000001000101111000000111000111000100010010001111001001110100011110000001011000111011100100100111001110001001011111111001110100001011110111101" "0000101000010000000100000000101001001101111110101110110000011101000101000010101010011100001011001110100001110100100001010000001010010101100111000111101011000111110111010000101010000111000111011101101110000110110001010100001010100100111000100011011011000110001110110100000000100001011110100001000000" "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "0000000100111011111010100101010100101001100001000011000100010111101110100000101010001100000110011010010001100011000100100000001010101000001111001101010110111000100011101000000000100010111110100011000111000111010000101000101010101010100001011000110000000000000000000000000000000000000000000000000000" "0010111011000100000100011000000001010110011110111100111011101000010001011111000000110011111001100101101110011100111011001111110000010111110000110010101001000111011100010111111111001101000001011100111000111000101111010011000000000101011110100111000010000000000000000000000000000000000000000000000000" }, - /* 45*/ { BARCODE_DBAR_EXPSTK, 7, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 5, 347, 1, "Example with 22 chars, 1 full row, bottom 8 chars", + /* 45*/ { BARCODE_DBAR_EXPSTK, 7, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 5, 347, 1, "Example with 22 chars, 1 full row, bottom 8 chars", "01010101111011111110111111110000101100100000010100010011111000101110101111000000001000111101001100010111100010110111100011111100001010100110001110000101001110000010001011110000001110001110001000100100011110010011101000111100000010110001110111001001001110011100010010111111110011101000010111101111011101100010000010001100000000101011001111011110010" "00001010000100000001000000001010010011011111101011101100000111010001010000101010100111000010110011101000011101001000010100000010100101011001110001111010110001111101110100001010100001110001110111011011100001101100010101000010101001001110001000110110110001100011101101000000001000010111101000010000100010011101111101010010101010010100110000100000000" "00000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" "00000100010111101110100000101010001100000110011010010001100011000100100000001010101000001111001101010110111000100011101000000000100010111110100011000111000111010000101000101010101010100001011000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "10111011101000010001011111000000110011111001100101101110011100111011001111110000010111110000110010101001000111011100010111111111001101000001011100111000111000101111010011000000000101011110100111000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, - /* 46*/ { BARCODE_DBAR_EXPSTK, 8, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 5, 396, 1, "Example with 22 chars, 1 full row, bottom 6 chars", + /* 46*/ { BARCODE_DBAR_EXPSTK, 8, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 5, 396, 1, "Example with 22 chars, 1 full row, bottom 6 chars", "010101011110111111101111111100001011001000000101000100111110001011101011110000000010001111010011000101111000101101111000111111000010101001100011100001010011100000100010111100000011100011100010001001000111100100111010001111000000101100011101110010010011100111000100101111111100111010000101111011110111011000100000100011000000001010110011110111100111011101000010001011111000000110011111001100101101" "000010100001000000010000000010100100110111111010111011000001110100010100001010101001110000101100111010000111010010000101000000101001010110011100011110101100011111011101000010101000011100011101110110111000011011000101010000101010010011100010001101101100011000111011010000000010000101111010000100001000100111011111010100101010100101001100001000011000100010111101110100000101010001100000110011010000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "000000011000110001001000000010101010000011110011010101101110001000111010000000001000101111101000110001110001110100001010001010101010101000010110001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "001011100111001110110011111100000101111100001100101010010001110111000101111111110011010000010111001110001110001011110100110000000001010111101001110000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, - /* 47*/ { BARCODE_DBAR_EXPSTK, 9, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 5, 445, 1, "Example with 22 chars, 1 full row, bottom 4 chars", + /* 47*/ { BARCODE_DBAR_EXPSTK, 9, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 5, 445, 1, "Example with 22 chars, 1 full row, bottom 4 chars", "0101010111101111111011111111000010110010000001010001001111100010111010111100000000100011110100110001011110001011011110001111110000101010011000111000010100111000001000101111000000111000111000100010010001111001001110100011110000001011000111011100100100111001110001001011111111001110100001011110111101110110001000001000110000000010101100111101111001110111010000100010111110000001100111110011001011011100111001110110011111100000101111100001100101010" "0000101000010000000100000000101001001101111110101110110000011101000101000010101010011100001011001110100001110100100001010000001010010101100111000111101011000111110111010000101010000111000111011101101110000110110001010100001010100100111000100011011011000110001110110100000000100001011110100001000010001001110111110101001010101001010011000010000110001000101111011101000001010100011000001100110100100011000110001001000000010101010000011110011010000" "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" "0000101110001000111010000000001000101111101000110001110001110100001010001010101010101000010110001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "1010010001110111000101111111110011010000010111001110001110001011110100110000000001010111101001110000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, - /* 48*/ { BARCODE_DBAR_EXPSTK, 10, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 5, 494, 1, "Example with 22 chars, 1 full row, bottom 2 chars", + /* 48*/ { BARCODE_DBAR_EXPSTK, 10, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 5, 494, 1, "Example with 22 chars, 1 full row, bottom 2 chars", "01010101111011111110111111110000101100100000010100010011111000101110101111000000001000111101001100010111100010110111100011111100001010100110001110000101001110000010001011110000001110001110001000100100011110010011101000111100000010110001110111001001001110011100010010111111110011101000010111101111011101100010000010001100000000101011001111011110011101110100001000101111100000011001111100110010110111001110011101100111111000001011111000011001010100100011101110001011111111100110100000101110011101" "00001010000100000001000000001010010011011111101011101100000111010001010000101010100111000010110011101000011101001000010100000010100101011001110001111010110001111101110100001010100001110001110111011011100001101100010101000010101001001110001000110110110001100011101101000000001000010111101000010000100010011101111101010010101010010100110000100001100010001011110111010000010101000110000011001101001000110001100010010000000101010100000111100110101011011100010001110100000000010001011111010001100000" "00000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "00000100011101000010100010101010101010000101100011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "00100011100010111101001100000000010101111010011100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, - /* 49*/ { BARCODE_DBAR_EXPSTK, 11, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 1, 543, 1, "Example with 22 chars, 1 row", + /* 49*/ { BARCODE_DBAR_EXPSTK, 11, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 1, 543, 1, "Example with 22 chars, 1 row", "010101011110111111101111111100001011001000000101000100111110001011101011110000000010001111010011000101111000101101111000111111000010101001100011100001010011100000100010111100000011100011100010001001000111100100111010001111000000101100011101110010010011100111000100101111111100111010000101111011110111011000100000100011000000001010110011110111100111011101000010001011111000000110011111001100101101110011100111011001111110000010111110000110010101001000111011100010111111111001101000001011100111000111000101111010011000000000101011110100111000010" }, - /* 50*/ { BARCODE_DBAR_EXPSTK, 1, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 41, 53, 1, "Example with 22 chars, 11 rows", + /* 50*/ { BARCODE_DBAR_EXPSTK, 1, "[91]12345678901234567890123456789012345678901234567890123456789012345678", 0, 41, 53, 1, "Example with 22 chars, 11 rows", "01010101111011111110111111110000101100100000010100010" "00001010000100000001000000001010010011011111101010000" "00000101010101010101010101010101010101010101010100000" @@ -590,14 +591,14 @@ static void test_examples(int index, int generate, int debug) { "00001000111010000101000101010101010100001011000110000" "01000111000101111010011000000000101011110100111000010" }, - /* 51*/ { BARCODE_DBAR_EXPSTK, 6, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 5, 298, 1, "#200 Daniel Gredler mostly empty last row, 16 chars, 2 rows, bottom row 4 chars", + /* 51*/ { BARCODE_DBAR_EXPSTK, 6, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 0, 5, 298, 1, "#200 Daniel Gredler mostly empty last row, 16 chars, 2 rows, bottom row 4 chars", "0100011101110001011011111111000010110000100101111101101000000110001010111100000000101001110000001001010011111011100110001111110000101110101000011000011010011100011000101111000000111001111000111101010111110010110000100011110000001010110010000010000111011111000100101011111100001110011110011000100101" "0000100010001110100100000000101001001111011010000010010111111001110101000010101010010110001111110110101100000100011001010000001010010001010111100111100101100011100111010000101010000110000111000010101000001101001111010100001010100101001101111101111000100000111011010100000010100001100001100111010000" "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "0000110000010010011000010000000010111110011010001001111010011011100010010101010010101110100011111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "1010001111101101100111001111111101000001100101110110000101100100011101000000001100010001011100000110100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, - /* 52*/ { BARCODE_DBAR_EXPSTK, 3, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 9, 151, 1, "#200 16 chars, 3 rows, bottom row 4 chars", + /* 52*/ { BARCODE_DBAR_EXPSTK, 3, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 0, 9, 151, 1, "#200 16 chars, 3 rows, bottom row 4 chars", "0100011101110001011011111111000010110000100101111101101000000110001010111100000000101001110000001001010011111011100110001111110000101110101000011000010" "0000100010001110100100000000101001001111011010000010010111111001110101000010101010010110001111110110101100000100011001010000001010010001010111100110000" "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" @@ -608,114 +609,170 @@ static void test_examples(int index, int generate, int debug) { "0000011111000101110101001010101001000111011001011110010001011001111101000000001000011001001000001100000000000000000000000000000000000000000000000000000" "0101100000111010001000110000000010111000100110100001101110100110000010111111110011100110110111110001010000000000000000000000000000000000000000000000000" }, - /* 53*/ { BARCODE_DBAR_EXPSTK, 4, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 5, 200, 1, "#200 16 chars, 2 full rows", + /* 53*/ { BARCODE_DBAR_EXPSTK, 4, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 0, 5, 200, 1, "#200 16 chars, 2 full rows", "01000111011100010110111111110000101100001001011111011010000001100010101111000000001010011100000010010100111110111001100011111100001011101010000110000110100111000110001011110000001110011110001111010101" "00001000100011101001000000001010010011110110100000100101111110011101010000101010100101100011111101101011000001000110010100000010100100010101111001111001011000111001110100001010100001100001110000100000" "00000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" "00001100000100100110000100000000101111100110100010011110100110111000100101010100101011101000111110010110111001100001100001010000001010110111000001000111101111101100101001010100001010111100101100000000" "10100011111011011001110011111111010000011001011101100001011001000111010000000011000100010111000001101001000110011110011100001111110101001000111110111000010000010011010100000011110001000011010011111010" }, - /* 54*/ { BARCODE_DBAR_EXPSTK, 5, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 5, 249, 1, "#200 16 chars, 2 rows, bottom row 6 chars", + /* 54*/ { BARCODE_DBAR_EXPSTK, 5, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 0, 5, 249, 1, "#200 16 chars, 2 rows, bottom row 6 chars", "010001110111000101101111111100001011000010010111110110100000011000101011110000000010100111000000100101001111101110011000111111000010111010100001100001101001110001100010111100000011100111100011110101011111001011000010001111000000101011001000001000010" "000010001000111010010000000010100100111101101000001001011111100111010100001010101001011000111111011010110000010001100101000000101001000101011110011110010110001110011101000010101000011000011100001010100000110100111101010000101010010100110111110110000" "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" "000001000001110110101000000101000011000011001110110100111110001011101010010101010010001110110010111100100010110011111010000000010000110010010000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "101110111110001001010111111000011100111100110001001011000001110100010001100000000101110001001101000011011101001100000101111111100111001101101111100010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, - /* 55*/ { BARCODE_DBAR_EXPSTK, 7, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 5, 347, 1, "#200 16 chars, 2 rows, bottom row 2 chars", + /* 55*/ { BARCODE_DBAR_EXPSTK, 7, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 0, 5, 347, 1, "#200 16 chars, 2 rows, bottom row 2 chars", "01000111011100010110111111110000101100001001011111011010000001100010101111000000001010011100000010010100111110111001100011111100001011101010000110000110100111000110001011110000001110011110001111010101111100101100001000111100000010101100100000100001110111110001001010111111000011100111100110001001011000001110100010001100000000101110001001101000010" "00001000100011101001000000001010010011110110100000100101111110011101010000101010100101100011111101101011000001000110010100000010100100010101111001111001011000111001110100001010100001100001110000101010000011010011110101000010101001010011011111011110001000001110110101000000101000011000011001110110100111110001011101010010101010010001110110010110000" "00000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" "00001000101100111110100000000100001100100100000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "10110111010011000001011111111001110011011011111000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, - /* 56*/ { BARCODE_DBAR_EXPSTK, 8, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 1, 396, 1, "#200 16 chars, 1 row", + /* 56*/ { BARCODE_DBAR_EXPSTK, 8, "[01]98898765432106[3202]012345[15]991231[3203]001234[17]010203", 0, 1, 396, 1, "#200 16 chars, 1 row", "010001110111000101101111111100001011000010010111110110100000011000101011110000000010100111000000100101001111101110011000111111000010111010100001100001101001110001100010111100000011100111100011110101011111001011000010001111000000101011001000001000011101111100010010101111110000111001111001100010010110000011101000100011000000001011100010011010000110111010011000001011111111001110011011011111000101" }, - /* 57*/ { BARCODE_DBAR_EXP, -1, "[01]00012345678905[10]ABC123", 1, 232, 1, "24724:2011 7.2.5.4.1, encoding method 1 '1'", + /* 57*/ { BARCODE_DBAR_EXP, -1, "[01]00012345678905[10]ABC123", 0, 1, 232, 1, "24724:2011 7.2.5.4.1, encoding method 1 '1'", "0100011000001011011011111111000010110011000010111101011110011011111010111110000001100010110000110111000111101101011110001111110000101110001100100001010011101111110110101111111100111001011011111101110011011100101111100011110000001010" }, - /* 58*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]001750", 1, 151, 1, "24724:2011 7.2.5.4.2, encoding method 3 '0100'", + /* 58*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]001750", 0, 1, 151, 1, "24724:2011 7.2.5.4.2, encoding method 3 '0100'", "0101110010000010011011111111000010111000010011000101011110111001100010111100000011100101110001110111011110101111000110001111110000101011000010011111010" }, - /* 59*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]032767", 1, 151, 1, "Encoding method 3 '0100' with weight = 32767", + /* 59*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]032767", 0, 1, 151, 1, "Encoding method 3 '0100' with weight = 32767", "0101001000111000011011111111000010111000010011000101011110111001100010111100000011100101110001110111011110111011000110001111110000101101111101110111010" }, - /* 60*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]032768", 1, 200, 1, "Possible encoding method 3 '0100' but weight > 32767 so encoding method 7 '0111000' with dummy date", + /* 60*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]032768", 0, 1, 200, 1, "Possible encoding method 3 '0100' but weight > 32767 so encoding method 7 '0111000' with dummy date", "01001100000101001110111111110000101000110111000010010111100110111110101111110000111000101100001101110001111011010111100011111100001011000110100110000110100000100110001011111111001110011001111010000101" }, - /* 61*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3202]000156", 1, 151, 1, "24724:2011 7.2.5.4.3, encoding method 4 '0101'", + /* 61*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3202]000156", 0, 1, 151, 1, "24724:2011 7.2.5.4.3, encoding method 4 '0101'", "0101001000111100001011111111000010100111000100001101011110111001100010111100000011100101110001110111011110101111000110001111110000101100001000001010010" }, - /* 62*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3202]009999", 1, 151, 1, "Encoding method 4 '0101' with weight = 9999", + /* 62*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3202]009999", 0, 1, 151, 1, "Encoding method 4 '0101' with weight = 9999", "0101110001000100011011111111000010100111000100001101011110111001100010111100000011100101110001110111011110110100011110001111110000101100111110010001010" }, - /* 63*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3202]010000", 1, 200, 1, "Possible encoding method 4 '0101' but weight > 9999 so encoding method 8 with dummy date", + /* 63*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3202]010000", 0, 1, 200, 1, "Possible encoding method 4 '0101' but weight > 9999 so encoding method 8 with dummy date", "01001000101110000110111111110000101110100011000010010111100110111110101111110000111000101100001101110001111011010111100011111100001010000011101001100111101101001110001011111111001110011001111010000101" }, - /* 64*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3203]022767", 1, 151, 1, "Encoding method 4 '0101' with weight = 22767", + /* 64*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3203]022767", 0, 1, 151, 1, "Encoding method 4 '0101' with weight = 22767", "0101110010011000001011111111000010100111000100001101011110111001100010111100000011100101110001110111011110111011000110001111110000101101111101110111010" }, - /* 65*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3203]022768", 1, 200, 1, "Possible encoding method 4 '0101' but weight > 22767 so encoding method 8 with dummy date", + /* 65*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3203]022768", 0, 1, 200, 1, "Possible encoding method 4 '0101' but weight > 22767 so encoding method 8 with dummy date", "01000110111000100010111111110000101110100011000010010111100110111110101111110000111000101100001101110001111011010111100011111100001010011100010110000100001101000001101011111111001110011001111010000101" }, - /* 66*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3922]795", 1, 183, 1, "24724:2011 7.2.5.4.5, encoding method 5 '01100XX', no following AIs", + /* 66*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3922]795", 0, 1, 183, 1, "24724:2011 7.2.5.4.5, encoding method 5 '01100XX', no following AIs", "010110000010001011101111111100001010011100000101100101111001101111101011111100001110001011000011011100011110110101111000111111000010100111101110100001100011011100100010111111110011101" }, - /* 67*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3922]795[20]01", 1, 200, 1, "Encoding method 5 '01100XX' with following AI", + /* 67*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3922]795[20]01", 0, 1, 200, 1, "Encoding method 5 '01100XX' with following AI", "01000110110000110010111111110000101111000100001010010111100110111110101111110000111000101100001101110001111011010111100011111100001010011110111010000110001110001011001011111111001110100111110001110101" }, - /* 68*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3932]0401234", 1, 200, 1, "24724:2011 7.2.5.4.6, encoding method 6 '01101XX', no following AIs", - "01000111101010000010111111110000101110100000110010010111100110111110101111110000111000101100001101110001111011010111100011111100001011100011001101100100111110001011101011111111001110001101111001011101" + /* 68*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3932]0081234", 0, 1, 200, 1, "24724:2011 7.2.5.4.6, encoding method 6 '01101XX', no following AIs", + "01001110000101100010111111110000101110100000110010010111100110111110101111110000111000101100001101110001111011010111100011111100001011000011010111100100111110001011101011111111001110001101111001011101" }, - /* 69*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3932]0401234[20]01", 1, 232, 1, "Encoding method 6 '01101XX' with following AI", - "0100010001000110111011111111000010110000101000111001011110011011111010111110000001100010110000110111000111101101011110001111110000101110001100110110010011111000101110101111111100111000100110011110010011101111001000100011110000001010" + /* 69*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3932]0081234[20]01", 0, 1, 232, 1, "Encoding method 6 '01101XX' with following AI", + "0100001101000100111011111111000010110000101000111001011110011011111010111110000001100010110000110111000111101101011110001111110000101100001101011110010011111000101110101111111100111000100110011110010011101111001000100011110000001010" }, - /* 70*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3932]A401234", 1, 232, 0, "Possible encoding method 6 '01101XX' but invalid currency code so encoding method 1; BWIPP no check", + /* 70*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3932]A401234", ZINT_WARN_NONCOMPLIANT, 1, 232, 0, "Possible encoding method 6 '01101XX' but invalid currency code so encoding method 1; BWIPP no check", "0100011000010011011011111111000010100100011111001101011110011011111010111110000001100010110000110111000111101101011110001111110000101100011001111001010001011011000000101111111100111001101011111110110001111001001110100011110000001010" }, - /* 71*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3102]099999[11]201209", 1, 200, 1, "Encoding method 7 '0111000' with weight <= 99999 and valid date", + /* 71*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3102]099999[11]201209", 0, 1, 200, 1, "Encoding method 7 '0111000' with weight <= 99999 and valid date", "01000101111001000010111111110000101000110111000010010111100110111110101111110000111000101100001101110001111011010111100011111100001010111100100001000100000011100101001011111111001110010000100100011101" }, - /* 72*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3102]099999", 1, 200, 1, "Encoding method 7 '0111000' with weight <= 99999 but no date", + /* 72*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3102]099999", 0, 1, 200, 1, "Encoding method 7 '0111000' with weight <= 99999 but no date", "01000111011000010010111111110000101000110111000010010111100110111110101111110000111000101100001101110001111011010111100011111100001010111100100001000110100100011000001011111111001110011001111010000101" }, - /* 73*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3102]100000[11]201209", 1, 281, 1, "Possible encoding method 7 '0111000' but weight > 99999 so encoding method 1", + /* 73*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3102]100000[11]201209", 0, 1, 281, 1, "Possible encoding method 7 '0111000' but weight > 99999 so encoding method 1", "01010011110001110010111111110000101001000111110011010111100110111110101111100000011000101100001101110001111011010111100011111100001010010110001110000110010000011110101011111111001110000011100110101100001001110100011000110000000010100101100000100001011100011001111010111111111001101" }, - /* 74*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3102]099999[11]200000", 1, 281, 1, "Possible encoding method 7 '0111000' with weight <= 99999 but date invalid so encoding method 1", + /* 74*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3102]099999[11]200000", ZINT_WARN_NONCOMPLIANT, 1, 281, 0, "Possible encoding method 7 '0111000' with weight <= 99999 but date invalid so encoding method 1; BWIPP need method to pass `dontlint` option", "01011001110001001110111111110000101001000111110011010111100110111110101111100000011000101100001101110001111011010111100011111100001010010110001110000110010011110100001011111111001110110011100010111100001001110100011000110000000010101100001000000101010111101111110010111111111001101" }, - /* 75*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3201]099999[11]201209", 1, 200, 1, "Encoding method 8 '0111001' with weight <= 99999 and valid date", + /* 75*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3201]099999[11]201209", 0, 1, 200, 1, "Encoding method 8 '0111001' with weight <= 99999 and valid date", "01001000001101001110111111110000101110100011000010010111100110111110101111110000111000101100001101110001111011010111100011111100001011000100001101100111010111001110001011111111001110010000100100011101" }, - /* 76*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3201]099999", 1, 200, 1, "Encoding method 8 '0111001' with weight <= 99999 but no date", + /* 76*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3201]099999", 0, 1, 200, 1, "Encoding method 8 '0111001' with weight <= 99999 but no date", "01000101110010000110111111110000101110100011000010010111100110111110101111110000111000101100001101110001111011010111100011111100001011000100001101100111010000111011101011111111001110011001111010000101" }, - /* 77*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3201]100000[11]201209", 1, 281, 1, "Possible encoding method 8 '0111001' but weight > 99999 so encoding method 1", + /* 77*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3201]100000[11]201209", 0, 1, 281, 1, "Possible encoding method 8 '0111001' but weight > 99999 so encoding method 1", "01011101100011000110111111110000101001000111110011010111100110111110101111100000011000101100001101110001111011010111100011111100001011101010000110000111011110001100101011111111001110000011100110101100001001110100011000110000000010100101100000100001011100011001111010111111111001101" }, - /* 78*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3201]099999[11]000000", 1, 281, 1, "Possible encoding method 8 '0111001' but date invalid so encoding method 1", + /* 78*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3201]099999[11]000000", ZINT_WARN_NONCOMPLIANT, 1, 281, 0, "Possible encoding method 8 '0111001' but date invalid so encoding method 1; BWIPP need method to pass `dontlint` option", "01011110100001001110111111110000101001000111110011010111100110111110101111100000011000101100001101110001111011010111100011111100001011101010000110000111000011110101101011111111001110110011100010111100001110100001011000110000000010101100001000000101010111101111110010111111111001101" }, - /* 79*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3100]099999[13]201209", 1, 200, 1, "Encoding method 9 '0111010' with weight <= 99999 and valid date", + /* 79*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3100]099999[13]201209", 0, 1, 200, 1, "Encoding method 9 '0111010' with weight <= 99999 and valid date", "01001000001101001110111111110000101111001010000010010111100110111110101111110000111000101100001101110001111011010111100011111100001011000111000001010111010000110110001011111111001110010000100100011101" }, - /* 80*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3204]099999[13]201209", 1, 200, 1, "Encoding method 10 '0111011' with weight <= 99999 and valid date", + /* 80*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3204]099999[13]201209", 0, 1, 200, 1, "Encoding method 10 '0111011' with weight <= 99999 and valid date", "01001000111000010110111111110000101100101000001110010111100110111110101111110000111000101100001101110001111011010111100011111100001010011101000011110101110000101111101011111111001110010000100100011101" }, - /* 81*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]012233[15]991231", 1, 200, 1, "24724:2011 7.2.5.4.4, encoding method 11 '0111100' with weight <= 99999 and valid date", + /* 81*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3103]012233[15]991231", 0, 1, 200, 1, "24724:2011 7.2.5.4.4, encoding method 11 '0111100' with weight <= 99999 and valid date", "01001100000100111010111111110000101011100100000110010111100110111110101111110000111000101100001101110001111011010111100011111100001011000011010110000111001100110001001011111111001110001101111010000101" }, - /* 82*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3205]099999[15]201209", 1, 200, 1, "Encoding method 12 '0111101' with weight <= 99999 and valid date", + /* 82*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3205]099999[15]201209", 0, 1, 200, 1, "Encoding method 12 '0111101' with weight <= 99999 and valid date", "01001110000010011010111111110000101000001101110100010111100110111110101111110000111000101100001101110001111011010111100011111100001011110011010001100101001100011000001011111111001110010000100100011101" }, - /* 83*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3109]099999[17]201209", 1, 200, 1, "Encoding method 13 '0111110' with weight <= 99999 and valid date", - "01001110000010100110111111110000101110000100110100010111100110111110101111110000111000101100001101110001111011010111100011111100001011011101111101000111010111001110001011111111001110010000100100011101" + /* 83*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3105]099999[17]201209", 0, 1, 200, 1, "Encoding method 13 '0111110' with weight <= 99999 and valid date", + "01000111010000110010111111110000101110000100110100010111100110111110101111110000111000101100001101110001111011010111100011111100001011110011010001100101001100011000001011111111001110010000100100011101" }, - /* 84*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3200]099999[17]201209", 1, 200, 1, "Encoding method 14 '0111111' with weight <= 99999 and valid date", + /* 84*/ { BARCODE_DBAR_EXP, -1, "[01]90012345678908[3200]099999[17]201209", 0, 1, 200, 1, "Encoding method 14 '0111111' with weight <= 99999 and valid date", "01001110000010100110111111110000101111000100010100010111100110111110101111110000111000101100001101110001111011010111100011111100001011000111000001010111010000110110001011111111001110010000100100011101" }, + /* 85*/ { BARCODE_DBAR_EXPSTK, 4, "[8110]106141416543213500110000310123196000", 0, 5, 200, 1, "North American Coupon Application Guideline (NACAG) Figure 1 (& Appendix C: Example 6)", + "01001100101110001110111111110000101000001101000001010111100110111000101111100000011011010001000000110000111100001010100011111100001010000010101111000111010000011001101011111111001110000001101101000101" + "00000011010001110001000000001010010111110010111110101000011001000111010000010101000100101110111111001111000011110101010100000010100101111101010000111000101111100110010100000000100001111110010010110000" + "00000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" + "00000100010110000110100000001010101010111100111101110010110001110011101000000000100010000011010010000100011110111011001000101010101010011101111111010000000000000000000000000000000000000000000000000000" + "00100011101001111001001111110000010101000011000010001101001110001100010111111111001101111100101101111011100001000100110011000000000101100010000000101010000000000000000000000000000000000000000000000000" + }, + /* 86*/ { BARCODE_DBAR_EXPSTK, 3, "[8110]10614141011111275110111", 0, 5, 151, 1, "NACAG Figure 3", + "0101011110011100001011111111000010100000110100000101011110011011100010111110000001101101000100000011000011100001101010001111110000101010000011000111010" + "0000100001100011110100000000101001011111001011111010100001100100011101000001010100010010111011111100111100011110010101010000001010010101111100111000000" + "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" + "0000001000100001011010000000010000111001101101100001100111100100100010100001010100100001101011111000000000000000000000000000000000000000000000000000000" + "1011110111011110100101111111100111000110010010011110011000011011011100011110000001011110010100000100100000000000000000000000000000000000000000000000000" + }, + /* 87*/ { BARCODE_DBAR_EXPSTK, 6, "[8110]106141410222223100110222111101231023456721104561045678991201", 0, 5, 298, 1, "NACAG Figure 4", + "0100101111101001111011111111000010110010000011001101011110011011100010111100000000101101000100000011000011100001101010001111110000101011000011100001010111000011011110101111000000111010011111000101110001110110011001100011110000001011100110000101000110101111110111001011111111001110011010011100001101" + "0000010000010110000100000000101001001101111100110010100001100100011101000010101010010010111011111100111100011110010101010000001010010100111100011110101000111100100001010000101010000101100000111010001110001001100110010100001010100100011001111010111001010000001000110100000000100001100101100011110000" + "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" + "0000011010011011100010100101010100100111000100000101010000111000110010100000101010001111000101110100011001110001101000100000001010101011011110000111010111110001101011101000000000100011110100100010000110101100111000001000101010101000000000000000000000000000000000000000000000000000000000000000000000" + "0010000101100100011100011000000001011000111011111010101111000111001101011111000000110000111010001011100110001110010111001111110000010100100001111000101000001110010100010111111111001100001011011101111001010011000111110011000000000101000000000000000000000000000000000000000000000000000000000000000000" + }, + /* 88*/ { BARCODE_DBAR_EXPSTK, 5, "[8110]1061414165432131501101201211014092110256100126663101231", 0, 5, 249, 1, "NACAG Appendix C: Example 1", + "010111101100011011101111111100001011001000001100110101111001101110001011110000000010110100010000001100001111000010101000111111000010100000101011110001110100000110011010111100000011101001111000101111000111011001001110001111000000101011001000001110010" + "000000010011100100010000000010100100110111110011001010000110010001110100001010101001001011101111110011110000111101010101000000101001011111010100001110001011111001100101000010101000010110000111010000111000100110110001010000101010010100110111110000000" + "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" + "000001110000100101101000000101000011110100100011100111100001001101001010010101010010011111110101101100010010110011111010000010101000111101010000010001110001001100110010001010101010100011000111001011000010011010000010100000000010000000000000000000000" + "101110001111011010010111111000011100001011011100011000011110110010110001100000000101100000001010010011101101001100000101111100000011000010101111101110001110110011001100110000000001011100111000110100111101100101111101011111111100110100000000000000000" + }, + /* 89*/ { BARCODE_DBAR_EXPSTK, 4, "[8110]106141410012342501106501013085093101231", 0, 5, 200, 1, "NACAG Appendix C: Example 2", + "01001100101110001110111111110000101000001101000001010111100110111000101111100000011011010001000000110000111000011010100011111100001010000110011000110111001110000010101011111111001110011110010001100101" + "00000011010001110001000000001010010111110010111110101000011001000111010000010101000100101110111111001111000111100101010100000010100101111001100111001000110001111101010100000000100001100001101110010000" + "00000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" + "00000100100001001110100000001010101011111101001011110000110001001011101000000000100010111000110010000111011001101000001000101010101010011011001000010000000000000000000000000000000000000000000000000000" + "00100011011110110001001111110000010100000010110100001111001110110100010111111111001101000111001101111000100110010111110011000000000101100100110111100010000000000000000000000000000000000000000000000000" + }, + /* 90*/ { BARCODE_DBAR_EXPSTK, 5, "[8110]106141410012471011076011110850921108609310123191000", 0, 5, 249, 1, "NACAG Appendix C: Example 3", + "010101111101111000101111111100001010000011000101000101111001101110001011110000000010110100010000001100001110000110101000111111000010100001100110001101001000010000111010111100000011100011100011011001011100001001101110001111000000101001100010000111010" + "000010000010000111010000000010100101111100111010111010000110010001110100001010101001001011101111110011110001111001010101000000101001011110011001110010110111101111000101000010101000011100011100100110100011110110010001010000101010010110011101111000000" + "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" + "000010000001000010101000000101000011110111011110110111101101011100001010010101010010101000011111011101111101110011001010000010101000101001111001110001000001100110001010000000101010100111111101101000000000000000000000000000000000000000000000000000000" + "101001111110111101010111111000011100001000100001001000010010100011110001100000000101010111100000100010000010001100110101111100000011010110000110001110111110011001110100111111000001011000000010010100100000000000000000000000000000000000000000000000000" + }, + /* 91*/ { BARCODE_DBAR_EXPSTK, 6, "[8110]106141411234562891101201212085010048000214025610048000310123191000", 0, 5, 298, 1, "NACAG Appendix C: Example 4", + "0100111111001110101011111111000010100000110001010001011110011011100010111100000000101101000100000011000011100001101010001111110000101010011000111000010101110001000000101111000000111001000001001110010011000011011101100011110000001010000010010110000100011001011000001011111111001110001110101100111101" + "0000000000110001010100000000101001011111001110101110100001100100011101000010101010010010111011111100111100011110010101010000001010010101100111000111101010001110111111010000101010000110111110110001101100111100100010010100001010100101111101101001111011100110100111110100000000100001110001010011000000" + "0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000" + "0000001110011100111010100101010100101001111011111101000100011101100010100000101010001110110010001000010111101100001110100000001010101000011101111010110010111110001001101000000000100011100001011000010111001010111000001000101010101010001111001001100000000000000000000000000000000000000000000000000000" + "0010110001100011000100011000000001010110000100000010111011100010011101011111000000110001001101110111101000010011110001001111110000010111100010000101001101000001110110010111111111001100011110100111101000110101000111110011000000000101110000110110011010000000000000000000000000000000000000000000000000" + }, + /* 92*/ { BARCODE_DBAR_EXPSTK, 5, "[8110]1061414154321031501101201211014092110256100126663101231", 0, 5, 249, 1, "NACAG Appendix C: Example 5", + "010100111111010011101111111100001011001000001100110101111001101110001011110000000010110100010000001100001111000010101000111111000010101100100000001001100011101011000010111100000011101001111000101111000111011001001110001111000000101011001000001110010" + "000011000000101100010000000010100100110111110011001010000110010001110100001010101001001011101111110011110000111101010101000000101001010011011111110110011100010100111101000010101000010110000111010000111000100110110001010000101010010100110111110000000" + "000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000" + "000001110000100101101000000101000011110100100011100111100001001101001010010101010010011111110101101100010010110011111010000010101000111101010000010001110001001100110010001010101010100011000111001011000010011010000010100000000010000000000000000000000" + "101110001111011010010111111000011100001011011100011000011110110010110001100000000101100000001010010011101101001100000101111100000011000010101111101110001110110011001100110000000001011100111000110100111101100101111101011111111100110100000000000000000" + }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -733,11 +790,11 @@ static void test_examples(int index, int generate, int debug) { int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length); - assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (generate) { - printf(" /*%3d*/ { %s, %d, \"%s\", %d, %d, %d, \"%s\",\n", - i, testUtilBarcodeName(symbol->symbology), data[i].option_2, data[i].data, symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); + printf(" /*%3d*/ { %s, %d, \"%s\", %d, %d, %d, %d, \"%s\",\n", + i, testUtilBarcodeName(symbol->symbology), data[i].option_2, data[i].data, data[i].ret, symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); testUtilModulesDump(symbol, " ", "\n"); printf(" },\n"); } else { @@ -1085,12 +1142,12 @@ static void test_binary_buffer_size(int index, int generate, int debug) { struct item data[] = { /* 0*/ { "[91]1", 0, 1, 102, "Minimum digit" }, /* 1*/ { "[91]+", 0, 1, 102, "Minimum ISO-646" }, - /* 2*/ { "[00]123456789012345678[00]123456789012345678[00]123456789012345678[91]12345678", 0, 1, 543, "70 == any AIs max" }, - /* 3*/ { "[00]123456789012345678[00]123456789012345678[00]123456789012345678[91]123456789", ZINT_ERROR_TOO_LONG, 0, 0, "71 > any AIs max" }, - /* 4*/ { "[01]12345678901234[00]123456789012345678[00]123456789012345678[91]1234567890123456", 0, 1, 543, "74 == 01 + other AIs max" }, - /* 5*/ { "[01]12345678901234[00]123456789012345678[00]123456789012345678[91]12345678901234567", ZINT_ERROR_TOO_LONG, 0, 0, "75 > 01 + other AIs max" }, - /* 6*/ { "[01]92345678901234[3920]123456789012345[00]123456789012345678[91]1234567890123456789", 0, 1, 543, "77 (incl. FNC1 after 3920) == 01 + 392x + other AIs max" }, - /* 7*/ { "[01]92345678901234[3920]123456789012345[00]123456789012345678[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "78 > 01 + 392x + other AIs max" }, + /* 2*/ { "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]12345678", 0, 1, 543, "70 == any AIs max" }, + /* 3*/ { "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]123456789", ZINT_ERROR_TOO_LONG, 0, 0, "71 > any AIs max" }, + /* 4*/ { "[01]12345678901231[00]123456789012345675[00]123456789012345675[91]1234567890123456", 0, 1, 543, "74 == 01 + other AIs max" }, + /* 5*/ { "[01]12345678901231[00]123456789012345675[00]123456789012345675[91]12345678901234567", ZINT_ERROR_TOO_LONG, 0, 0, "75 > 01 + other AIs max" }, + /* 6*/ { "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]1234567890123456789", 0, 1, 543, "77 (incl. FNC1 after 3920) == 01 + 392x + other AIs max" }, + /* 7*/ { "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "78 > 01 + 392x + other AIs max" }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -1141,10 +1198,10 @@ static void test_hrt(int index, int debug) { /* 2*/ { BARCODE_DBAR_OMN, "1000000000009", "(01)10000000000090" }, /* 3*/ { BARCODE_DBAR_LTD, "1341056790138", "(01)13410567901384" }, /* 4*/ { BARCODE_DBAR_LTD, "13410567901384", "(01)13410567901384" }, - /* 5*/ { BARCODE_DBAR_EXP, "[01]12345678901234", "(01)12345678901234" }, + /* 5*/ { BARCODE_DBAR_EXP, "[01]12345678901231", "(01)12345678901231" }, /* 6*/ { BARCODE_DBAR_STK, "12345678901231", "" }, /* 7*/ { BARCODE_DBAR_OMNSTK, "10000000000090", "" }, - /* 8*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901234", "" }, + /* 8*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901231", "" }, }; int data_size = ARRAY_SIZE(data); @@ -1192,20 +1249,22 @@ static void test_input(int index, int debug) { /* 7*/ { BARCODE_DBAR_LTD, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 }, /* 8*/ { BARCODE_DBAR_LTD, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 9*/ { BARCODE_DBAR_LTD, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 10*/ { BARCODE_DBAR_EXP, "[01]12345678901234", 0, 1, 134 }, - /* 11*/ { BARCODE_DBAR_EXP, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 12*/ { BARCODE_DBAR_EXP, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 13*/ { BARCODE_DBAR_STK, "1234567890123", 0, 3, 50 }, - /* 14*/ { BARCODE_DBAR_STK, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 15*/ { BARCODE_DBAR_STK, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1 }, - /* 16*/ { BARCODE_DBAR_STK, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 17*/ { BARCODE_DBAR_OMNSTK, "1234567890123", 0, 5, 50 }, - /* 18*/ { BARCODE_DBAR_OMNSTK, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 19*/ { BARCODE_DBAR_OMNSTK, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1 }, - /* 20*/ { BARCODE_DBAR_OMNSTK, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 21*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901234", 0, 5, 102 }, - /* 22*/ { BARCODE_DBAR_EXPSTK, "[01]123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 23*/ { BARCODE_DBAR_EXPSTK, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 10*/ { BARCODE_DBAR_EXP, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134 }, + /* 11*/ { BARCODE_DBAR_EXP, "[01]12345678901231", 0, 1, 134 }, + /* 12*/ { BARCODE_DBAR_EXP, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 13*/ { BARCODE_DBAR_EXP, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 14*/ { BARCODE_DBAR_STK, "1234567890123", 0, 3, 50 }, + /* 15*/ { BARCODE_DBAR_STK, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 16*/ { BARCODE_DBAR_STK, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1 }, + /* 17*/ { BARCODE_DBAR_STK, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 18*/ { BARCODE_DBAR_OMNSTK, "1234567890123", 0, 5, 50 }, + /* 19*/ { BARCODE_DBAR_OMNSTK, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 20*/ { BARCODE_DBAR_OMNSTK, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1 }, + /* 21*/ { BARCODE_DBAR_OMNSTK, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 22*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102 }, + /* 22*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901231", 0, 5, 102 }, + /* 23*/ { BARCODE_DBAR_EXPSTK, "[01]123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 24*/ { BARCODE_DBAR_EXPSTK, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1 }, }; int data_size = ARRAY_SIZE(data); diff --git a/backend/tests/test_vector.c b/backend/tests/test_vector.c index f22dc707..7f9aaacd 100644 --- a/backend/tests/test_vector.c +++ b/backend/tests/test_vector.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -162,7 +162,7 @@ static void test_buffer_vector(int index, int generate, int debug) { /* 21*/ { BARCODE_EANX_CHK, "1234", "", 50, 1, 47, 118, 116.4 }, /* 22*/ { BARCODE_EANX, "12", "", 50, 1, 20, 64, 116.4 }, /* 23*/ { BARCODE_EANX_CHK, "12", "", 50, 1, 20, 64, 116.4 }, - /* 24*/ { BARCODE_GS1_128, "[01]12345678901234", "", 50, 1, 134, 268, 118.9 }, + /* 24*/ { BARCODE_GS1_128, "[01]12345678901231", "", 50, 1, 134, 268, 118.9 }, /* 25*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118.9 }, /* 26*/ { BARCODE_CODE128, "1234567890", "", 50, 1, 90, 180, 118.9 }, /* 27*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118.9 }, @@ -173,7 +173,7 @@ static void test_buffer_vector(int index, int generate, int debug) { /* 32*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180, 100 }, /* 33*/ { BARCODE_DBAR_OMN, "1234567890123", "", 50, 1, 96, 192, 118.9 }, /* 34*/ { BARCODE_DBAR_LTD, "1234567890123", "", 50, 1, 79, 158, 118.9 }, - /* 35*/ { BARCODE_DBAR_EXP, "[01]12345678901234", "", 34, 1, 134, 268, 86.900002 }, + /* 35*/ { BARCODE_DBAR_EXP, "[01]12345678901231", "", 34, 1, 134, 268, 86.900002 }, /* 36*/ { BARCODE_TELEPEN, "1234567890", "", 50, 1, 208, 416, 118.9 }, /* 37*/ { BARCODE_UPCA, "12345678901", "", 50, 1, 95, 226, 116.4 }, /* 38*/ { BARCODE_UPCA_CHK, "123456789012", "", 50, 1, 95, 226, 116.4 }, @@ -216,7 +216,7 @@ static void test_buffer_vector(int index, int generate, int debug) { /* 75*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334, 118.9 }, /* 76*/ { BARCODE_DBAR_STK, "1234567890123", "", 13, 3, 50, 100, 26 }, /* 77*/ { BARCODE_DBAR_OMNSTK, "1234567890123", "", 69, 5, 50, 100, 138 }, - /* 78*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901234", "", 71, 5, 102, 204, 142 }, + /* 78*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901231", "", 71, 5, 102, 204, 142 }, /* 79*/ { BARCODE_PLANET, "12345678901", "", 12, 2, 123, 246, 24 }, /* 80*/ { BARCODE_MICROPDF417, "1234567890", "", 12, 6, 82, 164, 24 }, /* 81*/ { BARCODE_USPS_IMAIL, "12345678901234567890", "", 8, 3, 129, 258, 16 }, @@ -246,10 +246,10 @@ static void test_buffer_vector(int index, int generate, int debug) { /*105*/ { BARCODE_EANX_CC, "1234567", "[20]01", 50, 8, 72, 172, 116.4 }, /*106*/ { BARCODE_EANX_CC, "1234567+12", "[20]01", 50, 8, 99, 226, 116.4 }, /*107*/ { BARCODE_EANX_CC, "1234567+12345", "[20]01", 50, 8, 126, 280, 116.4 }, - /*108*/ { BARCODE_GS1_128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118.9 }, + /*108*/ { BARCODE_GS1_128_CC, "[01]12345678901231", "[20]01", 50, 5, 145, 290, 118.9 }, /*109*/ { BARCODE_DBAR_OMN_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60.900002 }, /*110*/ { BARCODE_DBAR_LTD_CC, "1234567890123", "[20]01", 19, 6, 79, 158, 56.900002 }, - /*111*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100.9 }, + /*111*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901231", "[20]01", 41, 5, 134, 268, 100.9 }, /*112*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 116.4 }, /*113*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 116.4 }, /*114*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 116.4 }, @@ -258,7 +258,7 @@ static void test_buffer_vector(int index, int generate, int debug) { /*117*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 116.4 }, /*118*/ { BARCODE_DBAR_STK_CC, "1234567890123", "[20]01", 24, 9, 56, 112, 48 }, /*119*/ { BARCODE_DBAR_OMNSTK_CC, "1234567890123", "[20]01", 80, 11, 56, 112, 160 }, - /*120*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, + /*120*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901231", "[20]01", 78, 9, 102, 204, 156 }, /*121*/ { BARCODE_CHANNEL, "01", "", 50, 1, 19, 38, 118.9 }, /*122*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, /*123*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, @@ -722,7 +722,7 @@ static void test_noncomposite_string_x(int index, int debug) { struct item data[] = { /* 0*/ { BARCODE_DBAR_OMN, "1234567890123", 96, 96 }, /* 1*/ { BARCODE_DBAR_LTD, "1234567890123", 79, 79 }, - /* 2*/ { BARCODE_DBAR_EXP, "[01]12345678901234", 134, 134 }, + /* 2*/ { BARCODE_DBAR_EXP, "[01]12345678901231", 134, 134 }, }; int data_size = sizeof(data) / sizeof(struct item); diff --git a/backend/tests/tools/bwipp_dump-barcode.ps.diff b/backend/tests/tools/bwipp_dump-barcode.ps.diff index 0a4941b3..9893408f 100644 --- a/backend/tests/tools/bwipp_dump-barcode.ps.diff +++ b/backend/tests/tools/bwipp_dump-barcode.ps.diff @@ -1,15 +1,6 @@ ---- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2020-12-19 06:21:55.358036729 +0000 -+++ ../tools/bwipp_dump.ps 2020-12-21 14:41:10.265502623 +0000 -@@ -29,6 +29,8 @@ - % CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - % IN THE SOFTWARE. - -+% vim: set ts=4 sw=4 et : -+ - % --BEGIN TEMPLATE-- - - % --BEGIN RESOURCE preamble-- -@@ -24471,34 +24473,80 @@ +--- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2021-01-16 23:24:06.598867470 +0000 ++++ ../tools/bwipp_dump.ps 2021-01-16 23:39:53.854722084 +0000 +@@ -26135,34 +26135,80 @@ pop } ifelse @@ -25,21 +16,7 @@ + linear options //ean13 exec + dontdraw not { + //renlinear exec - -- % Plot the separator -- -1 72 rmoveto << -- /ren //renmatrix -- /pixs [ -- 0 1 93 {0} repeat 1 0 -- 1 0 93 {0} repeat 0 1 -- 0 1 93 {0} repeat 1 0 -- ] -- /pixx 97 -- /pixy 3 -- /height 6 72 div -- /width 97 72 div -- /opt options -- >> //renmatrix exec ++ + % Plot the separator + -1 72 rmoveto << + /ren //renmatrix @@ -55,12 +32,25 @@ + /opt options + >> //renmatrix exec -- % Plot the 2D part -- -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec +- % Plot the separator +- -1 72 rmoveto << +- /ren //renmatrix +- /pixs [ +- 0 1 93 {0} repeat 1 0 +- 1 0 93 {0} repeat 0 1 +- 0 1 93 {0} repeat 1 0 +- ] +- /pixx 97 +- /pixy 3 +- /height 6 72 div +- /width 97 72 div +- /opt options +- >> //renmatrix exec + % Plot the 2D part + -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec -- grestore +- % Plot the 2D part +- -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec + grestore + } { + /linsym exch def @@ -83,7 +73,8 @@ + /ccrpad 0 array def + /pixx ccpixx def + } ifelse -+ + +- grestore + /pixs [ + 0 ccpixx ccpixs length 1 sub { + /i exch def @@ -109,7 +100,7 @@ end -@@ -24557,7 +24605,7 @@ +@@ -26221,7 +26267,7 @@ pop } ifelse @@ -118,7 +109,7 @@ % Get the result of encoding with ean8 and gs1-cc options (lintype) (ean8) put -@@ -24565,29 +24613,75 @@ +@@ -26229,29 +26275,75 @@ options (dontdraw) true put % Plot the linear part @@ -126,21 +117,7 @@ + linear options //ean8 exec + dontdraw not { + //renlinear exec - -- % Plot the separator -- -1 72 rmoveto << -- /ren //renmatrix -- /pixs [ -- 0 1 65 {0} repeat 1 0 -- 1 0 65 {0} repeat 0 1 -- 0 1 65 {0} repeat 1 0 -- ] -- /pixx 69 -- /pixy 3 -- /height 6 72 div -- /width 69 72 div -- /opt options -- >> //renmatrix exec ++ + % Plot the separator + -1 72 rmoveto << + /ren //renmatrix @@ -161,10 +138,20 @@ + dup (pixx) get 69 exch sub 6 rmoveto + //renmatrix exec -- % Plot the 2D part -- comp options //gs1-cc exec -- dup (pixx) get 69 exch sub 6 rmoveto -- //renmatrix exec +- % Plot the separator +- -1 72 rmoveto << +- /ren //renmatrix +- /pixs [ +- 0 1 65 {0} repeat 1 0 +- 1 0 65 {0} repeat 0 1 +- 0 1 65 {0} repeat 1 0 +- ] +- /pixx 69 +- /pixy 3 +- /height 6 72 div +- /width 69 72 div +- /opt options +- >> //renmatrix exec + grestore + } { + /linsym exch def @@ -172,8 +159,7 @@ + linsym /sbs get { cvi 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's + ] def + /linheight linsym /bhs get 0 get 72 mul cvi def - -- grestore ++ + /compsym comp options //gs1-cc exec def + /ccpixs compsym /pixs get def + /ccpixx compsym /pixx get def @@ -188,7 +174,11 @@ + /ccrpad 0 array def + /pixx ccpixx def + } ifelse -+ + +- % Plot the 2D part +- comp options //gs1-cc exec +- dup (pixx) get 69 exch sub 6 rmoveto +- //renmatrix exec + /pixs [ + 0 ccpixx ccpixs length 1 sub { + /i exch def @@ -199,7 +189,8 @@ + 2 { linpad aload pop 0 1 65 {0} repeat 1 0 ccrpad aload pop } repeat + linheight { linpad aload pop 0 linpixs aload pop 0 } repeat + ] def -+ + +- grestore + /pixy pixs length pixx idiv def + << + /ren //renmatrix @@ -214,7 +205,7 @@ end -@@ -24646,34 +24740,80 @@ +@@ -26310,34 +26402,80 @@ pop } ifelse @@ -230,21 +221,7 @@ + linear options //upca exec + dontdraw not { + //renlinear exec - -- % Plot the separator -- -1 72 rmoveto << -- /ren //renmatrix -- /pixs [ -- 0 1 93 {0} repeat 1 0 -- 1 0 93 {0} repeat 0 1 -- 0 1 93 {0} repeat 1 0 -- ] -- /pixx 97 -- /pixy 3 -- /height 6 72 div -- /width 97 72 div -- /opt options -- >> //renmatrix exec ++ + % Plot the separator + -1 72 rmoveto << + /ren //renmatrix @@ -260,12 +237,25 @@ + /opt options + >> //renmatrix exec -- % Plot the 2D part -- -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec +- % Plot the separator +- -1 72 rmoveto << +- /ren //renmatrix +- /pixs [ +- 0 1 93 {0} repeat 1 0 +- 1 0 93 {0} repeat 0 1 +- 0 1 93 {0} repeat 1 0 +- ] +- /pixx 97 +- /pixy 3 +- /height 6 72 div +- /width 97 72 div +- /opt options +- >> //renmatrix exec + % Plot the 2D part + -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec -- grestore +- % Plot the 2D part +- -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec + grestore + } { + /linsym exch def @@ -288,7 +278,8 @@ + /ccrpad 0 array def + /pixx ccpixx def + } ifelse -+ + +- grestore + /pixs [ + 0 ccpixx ccpixs length 1 sub { + /i exch def @@ -314,7 +305,7 @@ end -@@ -24747,34 +24887,80 @@ +@@ -26411,34 +26549,80 @@ /opt options >> def @@ -330,21 +321,7 @@ + linear options //upce exec + dontdraw not { + //renlinear exec - -- % Plot the separator -- -1 72 rmoveto << -- /ren //renmatrix -- /pixs [ -- 0 1 49 {0} repeat 1 0 -- 1 0 49 {0} repeat 0 1 -- 0 1 49 {0} repeat 1 0 -- ] -- /pixx 53 -- /pixy 3 -- /height 6 72 div -- /width 53 72 div -- /opt options -- >> //renmatrix exec ++ + % Plot the separator + -1 72 rmoveto << + /ren //renmatrix @@ -360,12 +337,25 @@ + /opt options + >> //renmatrix exec -- % Plot the 2D part -- -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec +- % Plot the separator +- -1 72 rmoveto << +- /ren //renmatrix +- /pixs [ +- 0 1 49 {0} repeat 1 0 +- 1 0 49 {0} repeat 0 1 +- 0 1 49 {0} repeat 1 0 +- ] +- /pixx 53 +- /pixy 3 +- /height 6 72 div +- /width 53 72 div +- /opt options +- >> //renmatrix exec + % Plot the 2D part + -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec -- grestore +- % Plot the 2D part +- -2 6 rmoveto comp options //gs1-cc exec //renmatrix exec + grestore + } { + /linsym exch def @@ -388,7 +378,8 @@ + /ccrpad 0 array def + /pixx ccpixx def + } ifelse -+ + +- grestore + /pixs [ + 0 ccpixx ccpixs length 1 sub { + /i exch def @@ -414,7 +405,7 @@ end -@@ -24833,7 +25019,7 @@ +@@ -26497,7 +26681,7 @@ pop } ifelse @@ -423,7 +414,7 @@ options (lintype) (databaromni) put options (linkage) true put -@@ -24844,7 +25030,7 @@ +@@ -26508,7 +26692,7 @@ linear options //databaromni exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -432,7 +423,7 @@ % Plot the separator /sepfinder { -@@ -24875,20 +25061,66 @@ +@@ -26539,20 +26723,66 @@ sep 0 [0 0 0] putinterval sep sep length 4 sub [0 0 0 0] putinterval 18 sepfinder 64 sepfinder @@ -511,7 +502,7 @@ end -@@ -24946,7 +25178,7 @@ +@@ -26610,7 +26840,7 @@ pop } ifelse @@ -520,7 +511,7 @@ options (lintype) (databarstacked) put options (linkage) true put -@@ -24957,7 +25189,7 @@ +@@ -26621,7 +26851,7 @@ linear options //databarstacked exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -529,7 +520,7 @@ % Plot the separator /sepfinder { -@@ -24985,20 +25217,52 @@ +@@ -26649,20 +26879,52 @@ sep 0 [ 0 0 0 0 ] putinterval sep sep length 4 sub [ 0 0 0 0 ] putinterval 18 sepfinder @@ -594,7 +585,7 @@ end -@@ -25056,7 +25320,7 @@ +@@ -26720,7 +26982,7 @@ pop } ifelse @@ -603,7 +594,7 @@ options (lintype) (databarstackedomni) put options (linkage) true put -@@ -25067,7 +25331,7 @@ +@@ -26731,7 +26993,7 @@ linear options //databarstackedomni exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -612,7 +603,7 @@ % Plot the separator /sepfinder { -@@ -25095,20 +25359,52 @@ +@@ -26759,20 +27021,52 @@ sep 0 [ 0 0 0 0 ] putinterval sep sep length 4 sub [ 0 0 0 0 ] putinterval 18 sepfinder @@ -677,7 +668,7 @@ end -@@ -25281,7 +25577,7 @@ +@@ -26945,7 +27239,7 @@ pop } ifelse @@ -686,7 +677,7 @@ options (lintype) (databarlimited) put options (linkage) true put -@@ -25292,7 +25588,7 @@ +@@ -26956,7 +27250,7 @@ linear options //databarlimited exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -695,7 +686,7 @@ % Plot the separator mark -@@ -25300,22 +25596,68 @@ +@@ -26964,22 +27258,68 @@ counttomark 1 sub array astore /sep exch def pop pop sep 0 [0 0 0] putinterval sep sep length 9 sub [0 0 0 0 0 0 0 0 0] putinterval % 4 + 5 right guard spaces @@ -733,8 +724,7 @@ + /compsym comp options //gs1-cc exec def + /ccpixs compsym /pixs get def + /ccpixx compsym /pixx get def - -- grestore ++ + /linpixs [ 0 % Begin with left guard space + linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates x 1/0's + ] def @@ -763,7 +753,8 @@ + ] def + /pixx ccpixx 1 add def + } ifelse -+ + +- grestore + /pixy pixs length pixx idiv def + << + /ren //renmatrix @@ -778,7 +769,7 @@ end -@@ -25374,7 +25716,7 @@ +@@ -27038,7 +27378,7 @@ pop } ifelse @@ -787,7 +778,7 @@ options (lintype) (databarexpanded) put options (linkage) true put -@@ -25385,7 +25727,7 @@ +@@ -27049,7 +27389,7 @@ linear options //databarexpanded exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -796,7 +787,7 @@ % Plot the separator /sepfinder { -@@ -25414,20 +25756,60 @@ +@@ -27078,20 +27418,60 @@ 18 98 bot length 13 sub {} for 69 98 bot length 13 sub {} for ] {sepfinder} forall @@ -869,7 +860,7 @@ end -@@ -25485,7 +25867,7 @@ +@@ -27149,7 +27529,7 @@ pop } ifelse @@ -878,7 +869,7 @@ options (lintype) (databarexpandedstacked) put options (linkage) true put -@@ -25496,7 +25878,7 @@ +@@ -27160,7 +27540,7 @@ linear options //databarexpandedstacked exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -887,7 +878,7 @@ % Plot the separator /sepfinder { -@@ -25522,21 +25904,49 @@ +@@ -27186,21 +27566,49 @@ 19 98 bot length 13 sub {} for 70 98 bot length 13 sub {} for ] {sepfinder} forall @@ -950,7 +941,7 @@ end -@@ -25595,7 +26005,7 @@ +@@ -27259,7 +27667,7 @@ pop } ifelse @@ -959,7 +950,7 @@ options (inkspread) (0) put options (dontdraw) true put -@@ -25622,35 +26032,87 @@ +@@ -27286,35 +27694,87 @@ linear << options {} forall >> //gs1-128 exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -1061,7 +1052,7 @@ end -@@ -26924,3 +27386,181 @@ +@@ -28745,3 +29205,183 @@ % --END ENCODER hibcazteccode-- % --END TEMPLATE-- @@ -1243,3 +1234,5 @@ + % If not -dNODISPLAY then render for debugging + currentpagedevice /Name get (nullpage) ne { s s scale 10 10 moveto ret ret /ren get exec } if +} if ++ ++% vim: set ts=4 sw=4 et : diff --git a/backend/tests/tools/bwipp_dump.ps.tar.xz b/backend/tests/tools/bwipp_dump.ps.tar.xz index 9ebe33c0..7498777f 100644 Binary files a/backend/tests/tools/bwipp_dump.ps.tar.xz and b/backend/tests/tools/bwipp_dump.ps.tar.xz differ diff --git a/backend/tools/gen_gs1_lint.php b/backend/tools/gen_gs1_lint.php new file mode 100644 index 00000000..c3c43d38 --- /dev/null +++ b/backend/tools/gen_gs1_lint.php @@ -0,0 +1,409 @@ + +*/ +/* To create "backend/gs1_lint.h" (from project directory): + * + * php backend/tools/gen_gs1_lint.php > backend/gs1_lint.h + * + * or to use local copy of "gs1-format_spec.txt": + * + * php backend/tools/gen_gs1_lint.php -f /gs1-format-spec.txt backend/gs1_lint.h + * + */ +/* vim: set ts=4 sw=4 et : */ + +$basename = basename(__FILE__); +$dirname = dirname(__FILE__); +$dirdirname = basename(dirname($dirname)) . '/' . basename($dirname); + +$opts = getopt('c:f:h:l:t:'); + +$print_copyright = isset($opts['c']) ? (bool) $opts['c'] : true; +$file = isset($opts['f']) ? $opts['f'] : + 'https://raw.githubusercontent.com/bwipp/postscriptbarcode/master/contrib/development/gs1-format-spec.txt'; +$print_h_guard = isset($opts['h']) ? (bool) $opts['h'] : true; +$use_length_only = isset($opts['l']) ? (bool) $opts['l'] : true; +$tab = isset($opts['t']) ? $opts['t'] : ' '; + +if (($get = file_get_contents($file)) === false) { + exit("$basename: ERROR: Could not read file \"$file\"" . PHP_EOL); +} + +$lines = explode("\n", $get); + +$spec_ais = $spec_parts = $spec_funcs = array(); +$batches = array_fill(0, 100, array()); + +// Parse the lines into AIs and specs +$line_no = 0; +foreach ($lines as $line) { + $line_no++; + if ($line === '' || $line[0] === '#') { + continue; + } + if (!preg_match('/^([0-9]+(?:-[0-9]+)?) +([NXC][0-9.][ NXC0-9.,a-z]*)$/', $line, $matches)) { + exit("$basename: ERROR: Could not parse line $line_no" . PHP_EOL); + } + $ai = $matches[1]; + $spec = trim($matches[2]); + + if (isset($spec_ais[$spec])) { + $ais = $spec_ais[$spec]; + } else { + $ais = array(); + } + + if (($hyphen = strpos($ai, '-')) !== false) { + $ai_s = (int) substr($ai, 0, $hyphen); + $ai_e = (int) substr($ai, $hyphen + 1); + $ais[] = array($ai_s, $ai_e); + + $batch_s_idx = (int) ($ai_s / 100); + $batch_e_idx = (int) ($ai_e / 100); + if ($batch_s_idx !== $batch_e_idx) { + if (!in_array($spec, $batches[$batch_s_idx])) { + $batches[$batch_s_idx][] = $spec; + } + if (!in_array($spec, $batches[$batch_e_idx])) { + $batches[$batch_e_idx][] = $spec; + } + } else { + if (!in_array($spec, $batches[$batch_s_idx])) { + $batches[$batch_s_idx][] = $spec; + } + } + } else { + $ai = (int) $ai; + $ais[] = $ai; + $batch_idx = (int) ($ai / 100); + if (!in_array($spec, $batches[$batch_idx])) { + $batches[$batch_idx][] = $spec; + } + } + + $spec_ais[$spec] = $ais; + + $spec_parts[$spec] = array(); + $parts = explode(' ', $spec); + foreach ($parts as $part) { + $checkers = explode(',', $part); + $validator = array_shift($checkers); + if (!preg_match('/^([NXC])([0-9]+)?(\.\.[0-9|]+)?$/', $validator, $matches)) { + exit("$basename: ERROR: Could not parse validator \"$validator\" line $line_no" . PHP_EOL); + } + if (count($matches) === 3) { + $min = $max = (int) $matches[2]; + } else { + $min = $matches[2] === '' ? 1 : (int) $matches[2]; + $max = (int) substr($matches[3], 2); + } + if ($matches[1] === 'N') { + $validator = "numeric"; + } elseif ($matches[1] === 'X') { + $validator = "cset82"; + } else { + $validator = "cset39"; + } + $spec_parts[$spec][] = array($min, $max, $validator, $checkers); + } +} + +// Calculate total min/maxs and convert the AIs into ranges + +foreach ($spec_ais as $spec => $ais) { + // Total min/maxs + $total_min = $total_max = 0; + foreach ($spec_parts[$spec] as list($min, $max)) { + $total_min += $min; + $total_max += $max; + } + + // Sort the AIs + $sort_ais = array(); + foreach ($ais as $ai) { + if (is_array($ai)) { + $sort_ais[] = $ai[0]; + } else { + $sort_ais[] = $ai; + } + } + array_multisort($sort_ais, $ais); + + // Consolidate contiguous AIs into ranges + $tmp_ais = array(); + foreach ($ais as $ai) { + $cnt = count($tmp_ais); + if ($cnt === 0) { + $tmp_ais[] = $ai; + } else { + $prev_ai = $tmp_ais[$cnt - 1]; + if (is_array($prev_ai)) { + $prev_s = $prev_ai[0]; + $prev_e = $prev_ai[1]; + } else { + $prev_e = $prev_s = $prev_ai; + } + if (is_array($ai)) { + $this_s = $ai[0]; + $this_e = $ai[0]; + } else { + $this_s = $this_e = $ai; + } + if ($this_s === $prev_e + 1) { + $tmp_ais[$cnt - 1] = array($prev_s, $this_e); + } else { + $tmp_ais[] = $ai; + } + } + } + + // Unconsolidate ranges of 1 into separate entries + $ais = array(); + foreach ($tmp_ais as $ai) { + if (is_array($ai) && $ai[1] === $ai[0] + 1) { + $ais[] = $ai[0]; + $ais[] = $ai[1]; + } else { + $ais[] = $ai; + } + } + + $spec_ais[$spec] = array($total_min, $total_max, $ais); +} + +// Print output + +print << + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ + + +EOD; +} + +if ($print_h_guard) { +print <<<'EOD' +#ifndef GS1_LINT_H +#define GS1_LINT_H + + +EOD; +} + +// Print the spec validator/checkers functions + +foreach ($spec_parts as $spec => $spec_part) { + $spec_funcs[$spec] = $spec_func = str_replace(array(' ', '.', ','), '_', strtolower($spec)); + print <<= $total_min && data_len <= $total_max"; + } + + if ($use_length_only) { + // Call checkers checking for length only first + $length_only_arg = ", 1 /*length_only*/"; + $offset = 0; + foreach ($spec_part as list($min, $max, $validator, $checkers)) { + foreach ($checkers as $checker) { + print << $batch_specs) { + if (empty($batch_specs)) { + continue; + } + $batch_s = $batch * 100; + $batch_e = $batch_s + 100; + if ($not_first_batch) { + print "\n$tab} else if (ai < $batch_e) {\n\n"; + } else { + print "\n{$tab}if (ai < $batch_e) {\n\n"; + $not_first_batch = true; + } + foreach ($batch_specs as $spec) { + $total_min = $spec_ais[$spec][0]; + $total_max = $spec_ais[$spec][1]; + $ais = $spec_ais[$spec][2]; + + $str = "$tab{$tab}if ("; + print $str; + $width = strlen($str); + + // Count the applicable AIs + $ais_cnt = 0; + foreach ($ais as $ai) { + if (is_array($ai)) { + if ($ai[1] < $batch_s || $ai[0] >= $batch_e) { + continue; + } + } else { + if ($ai < $batch_s || $ai >= $batch_e) { + continue; + } + } + $ais_cnt++; + } + + // Output + $not_first_ai = false; + foreach ($ais as $ai) { + if (is_array($ai)) { + if ($ai[1] < $batch_s || $ai[0] >= $batch_e) { + continue; + } + } else { + if ($ai < $batch_s || $ai >= $batch_e) { + continue; + } + } + + $str = ''; + if ($not_first_ai) { + $str .= " || "; + } else { + $not_first_ai = true; + } + if (is_array($ai)) { + if ($ai[0] === $last_batch_e) { // Don't need 1st element of range if excluded by previous batch + $str .= "ai <= " . $ai[1]; + } else if ($ai[1] + 1 == $batch_e) { // Don't need 2nd element of range if excluded by this batch + $str .= "ai >= " . $ai[0]; + } else { + if ($ais_cnt > 1) { + $str .= "(ai >= " . $ai[0] . " && ai <= " . $ai[1] . ")"; + } else { + $str .= "ai >= " . $ai[0] . " && ai <= " . $ai[1]; + } + } + } else { + $str .= "ai == " . $ai; + } + if ($width + strlen($str) > 118) { + print "\n"; + $str2 = "$tab$tab$tab "; + print $str2; + $width = strlen($str2); + } + print $str; + $width += strlen($str); + } + $spec_func = $spec_funcs[$spec]; + print << +*/ +/* To create "backend/iso3166.h" (from project directory): + * + * php backend/tools/gen_iso3166_h.php > backend/iso3166.h + */ +/* vim: set ts=4 sw=4 et : */ + +$basename = basename(__FILE__); +$dirname = dirname(__FILE__); +$dirdirname = basename(dirname($dirname)) . '/' . basename($dirname); + +$opts = getopt('c:h:t:'); + +$print_copyright = isset($opts['c']) ? (bool) $opts['c'] : true; +$print_h_guard = isset($opts['h']) ? (bool) $opts['h'] : true; +$tab = isset($opts['t']) ? $opts['t'] : ' '; + +$numeric = array( + /*AFG*/ 4, /*ALB*/ 8, /*ATA*/ 10, /*DZA*/ 12, /*ASM*/ 16, /*AND*/ 20, /*AGO*/ 24, /*ATG*/ 28, /*AZE*/ 31, /*ARG*/ 32, + /*AUS*/ 36, /*AUT*/ 40, /*BHS*/ 44, /*BHR*/ 48, /*BGD*/ 50, /*ARM*/ 51, /*BRB*/ 52, /*BEL*/ 56, /*BMU*/ 60, /*BTN*/ 64, + /*BOL*/ 68, /*BIH*/ 70, /*BWA*/ 72, /*BVT*/ 74, /*BRA*/ 76, /*BLZ*/ 84, /*IOT*/ 86, /*SLB*/ 90, /*VGB*/ 92, /*BRN*/ 96, + /*BGR*/ 100, /*MMR*/ 104, /*BDI*/ 108, /*BLR*/ 112, /*KHM*/ 116, /*CMR*/ 120, /*CAN*/ 124, /*CPV*/ 132, /*CYM*/ 136, /*CAF*/ 140, + /*LKA*/ 144, /*TCD*/ 148, /*CHL*/ 152, /*CHN*/ 156, /*TWN*/ 158, /*CXR*/ 162, /*CCK*/ 166, /*COL*/ 170, /*COM*/ 174, /*MYT*/ 175, + /*COG*/ 178, /*COD*/ 180, /*COK*/ 184, /*CRI*/ 188, /*HRV*/ 191, /*CUB*/ 192, /*CYP*/ 196, /*CZE*/ 203, /*BEN*/ 204, /*DNK*/ 208, + /*DMA*/ 212, /*DOM*/ 214, /*ECU*/ 218, /*SLV*/ 222, /*GNQ*/ 226, /*ETH*/ 231, /*ERI*/ 232, /*EST*/ 233, /*FRO*/ 234, /*FLK*/ 238, + /*SGS*/ 239, /*FJI*/ 242, /*FIN*/ 246, /*ALA*/ 248, /*FRA*/ 250, /*GUF*/ 254, /*PYF*/ 258, /*ATF*/ 260, /*DJI*/ 262, /*GAB*/ 266, + /*GEO*/ 268, /*GMB*/ 270, /*PSE*/ 275, /*DEU*/ 276, /*GHA*/ 288, /*GIB*/ 292, /*KIR*/ 296, /*GRC*/ 300, /*GRL*/ 304, /*GRD*/ 308, + /*GLP*/ 312, /*GUM*/ 316, /*GTM*/ 320, /*GIN*/ 324, /*GUY*/ 328, /*HTI*/ 332, /*HMD*/ 334, /*VAT*/ 336, /*HND*/ 340, /*HKG*/ 344, + /*HUN*/ 348, /*ISL*/ 352, /*IND*/ 356, /*IDN*/ 360, /*IRN*/ 364, /*IRQ*/ 368, /*IRL*/ 372, /*ISR*/ 376, /*ITA*/ 380, /*CIV*/ 384, + /*JAM*/ 388, /*JPN*/ 392, /*KAZ*/ 398, /*JOR*/ 400, /*KEN*/ 404, /*PRK*/ 408, /*KOR*/ 410, /*KWT*/ 414, /*KGZ*/ 417, /*LAO*/ 418, + /*LBN*/ 422, /*LSO*/ 426, /*LVA*/ 428, /*LBR*/ 430, /*LBY*/ 434, /*LIE*/ 438, /*LTU*/ 440, /*LUX*/ 442, /*MAC*/ 446, /*MDG*/ 450, + /*MWI*/ 454, /*MYS*/ 458, /*MDV*/ 462, /*MLI*/ 466, /*MLT*/ 470, /*MTQ*/ 474, /*MRT*/ 478, /*MUS*/ 480, /*MEX*/ 484, /*MCO*/ 492, + /*MNG*/ 496, /*MDA*/ 498, /*MNE*/ 499, /*MSR*/ 500, /*MAR*/ 504, /*MOZ*/ 508, /*OMN*/ 512, /*NAM*/ 516, /*NRU*/ 520, /*NPL*/ 524, + /*NLD*/ 528, /*CUW*/ 531, /*ABW*/ 533, /*SXM*/ 534, /*BES*/ 535, /*NCL*/ 540, /*VUT*/ 548, /*NZL*/ 554, /*NIC*/ 558, /*NER*/ 562, + /*NGA*/ 566, /*NIU*/ 570, /*NFK*/ 574, /*NOR*/ 578, /*MNP*/ 580, /*UMI*/ 581, /*FSM*/ 583, /*MHL*/ 584, /*PLW*/ 585, /*PAK*/ 586, + /*PAN*/ 591, /*PNG*/ 598, /*PRY*/ 600, /*PER*/ 604, /*PHL*/ 608, /*PCN*/ 612, /*POL*/ 616, /*PRT*/ 620, /*GNB*/ 624, /*TLS*/ 626, + /*PRI*/ 630, /*QAT*/ 634, /*REU*/ 638, /*ROU*/ 642, /*RUS*/ 643, /*RWA*/ 646, /*BLM*/ 652, /*SHN*/ 654, /*KNA*/ 659, /*AIA*/ 660, + /*LCA*/ 662, /*MAF*/ 663, /*SPM*/ 666, /*VCT*/ 670, /*SMR*/ 674, /*STP*/ 678, /*SAU*/ 682, /*SEN*/ 686, /*SRB*/ 688, /*SYC*/ 690, + /*SLE*/ 694, /*SGP*/ 702, /*SVK*/ 703, /*VNM*/ 704, /*SVN*/ 705, /*SOM*/ 706, /*ZAF*/ 710, /*ZWE*/ 716, /*ESP*/ 724, /*SSD*/ 728, + /*SDN*/ 729, /*ESH*/ 732, /*SUR*/ 740, /*SJM*/ 744, /*SWZ*/ 748, /*SWE*/ 752, /*CHE*/ 756, /*SYR*/ 760, /*TJK*/ 762, /*THA*/ 764, + /*TGO*/ 768, /*TKL*/ 772, /*TON*/ 776, /*TTO*/ 780, /*ARE*/ 784, /*TUN*/ 788, /*TUR*/ 792, /*TKM*/ 795, /*TCA*/ 796, /*TUV*/ 798, + /*UGA*/ 800, /*UKR*/ 804, /*MKD*/ 807, /*EGY*/ 818, /*GBR*/ 826, /*GGY*/ 831, /*JEY*/ 832, /*IMN*/ 833, /*TZA*/ 834, /*USA*/ 840, + /*VIR*/ 850, /*BFA*/ 854, /*URY*/ 858, /*UZB*/ 860, /*VEN*/ 862, /*WLF*/ 876, /*WSM*/ 882, /*YEM*/ 887, /*ZMB*/ 894, +); + +$numeric_tab = array(); +$val = 0; +$byte = 0; +$max = $numeric[count($numeric) - 1]; +for ($i = 0; $i <= $max; $i++) { + if ($i && $i % 8 == 0) { + $numeric_tab[$byte++] = $val; + $val = 0; + } + if (in_array($i, $numeric)) { + $val |= 1 << ($i & 0x7); + } +} +$numeric_tab[$byte++] = $val; +$numeric_cnt = count($numeric_tab); + +$alpha2 = array( + "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", + "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", + "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", + "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", + "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", + "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", + "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", + "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", + "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", + "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", + "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", + "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", + "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", + "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", + "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", + "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", + "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", + "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", + "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", + "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", + "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", + "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", + "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", + "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", + "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW", +); + +$alpha2_tab = array(); +$val = 0; +$byte = 0; +for ($i = 0; $i < 26; $i++) { + for ($j = 0; $j < 26; $j++) { + $ij = $i * 26 + $j; + if ($ij && $ij % 8 == 0) { + $alpha2_tab[$byte++] = $val; + $val = 0; + } + $cc = chr(65 + $i) . chr(65 + $j); + if (in_array($cc, $alpha2)) { + $val |= 1 << ($ij & 0x7); + } + } +} +$alpha2_tab[$byte++] = $val; +$alpha2_cnt = count($alpha2_tab); + +print << + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ + + +EOD; +} + +if ($print_h_guard) { +print <<<'EOD' +#ifndef ISO3166_H +#define ISO3166_H + +EOD; +} + +print <<> 3; + +{$tab}if (b < 0 || b >= $numeric_cnt) { +{$tab}{$tab}return 0; +{$tab}} +{$tab}return codes[b] & (1 << (cc & 0x7)) ? 1 : 0; +} + +/* Whether ISO 3166-1 alpha2 */ +static int iso3166_alpha2(const char *cc) { +{$tab}static const unsigned char codes[$alpha2_cnt] = { +EOD; + +for ($i = 0; $i < $alpha2_cnt; $i++) { + if ($i % 8 == 0) { + print "\n$tab$tab"; + } else { + print " "; + } + printf("0x%02X,", $alpha2_tab[$i]); +} +print << 'Z' || cc[1] < 'A' || cc[1] > 'Z') { +{$tab}{$tab}return 0; +{$tab}} +{$tab}cc_int = (cc[0] - 'A') * 26 + (cc[1] - 'A'); + +{$tab}return codes[cc_int >> 3] & (1 << (cc_int & 0x7)) ? 1 : 0; +} + +EOD; + +if ($print_h_guard) { +print <<<'EOD' + +#endif /* ISO3166_H */ + +EOD; +} diff --git a/backend/tools/gen_iso4217_h.php b/backend/tools/gen_iso4217_h.php new file mode 100644 index 00000000..277e01eb --- /dev/null +++ b/backend/tools/gen_iso4217_h.php @@ -0,0 +1,145 @@ + +*/ +/* To create "backend/iso4217.h" (from project directory): + * + * php backend/tools/gen_iso4217_h.php > backend/iso4217.h + */ +/* vim: set ts=4 sw=4 et : */ + +$basename = basename(__FILE__); +$dirname = dirname(__FILE__); +$dirdirname = basename(dirname($dirname)) . '/' . basename($dirname); + +$opts = getopt('c:h:t:'); + +$print_copyright = isset($opts['c']) ? (bool) $opts['c'] : true; +$print_h_guard = isset($opts['h']) ? (bool) $opts['h'] : true; +$tab = isset($opts['t']) ? $opts['t'] : ' '; + +$numeric = array( + /*ALL*/ 8, /*DZD*/ 12, /*ARS*/ 32, /*AUD*/ 36, /*BSD*/ 44, /*BHD*/ 48, /*BDT*/ 50, /*AMD*/ 51, /*BBD*/ 52, /*BMD*/ 60, + /*BTN*/ 64, /*BOB*/ 68, /*BWP*/ 72, /*BZD*/ 84, /*SBD*/ 90, /*BND*/ 96, /*MMK*/ 104, /*BIF*/ 108, /*KHR*/ 116, /*CAD*/ 124, + /*CVE*/ 132, /*KYD*/ 136, /*LKR*/ 144, /*CLP*/ 152, /*CNY*/ 156, /*COP*/ 170, /*KMF*/ 174, /*CRC*/ 188, /*HRK*/ 191, /*CUP*/ 192, + /*CZK*/ 203, /*DKK*/ 208, /*DOP*/ 214, /*SVC*/ 222, /*ETB*/ 230, /*ERN*/ 232, /*FKP*/ 238, /*FJD*/ 242, /*DJF*/ 262, /*GMD*/ 270, + /*GIP*/ 292, /*GTQ*/ 320, /*GNF*/ 324, /*GYD*/ 328, /*HTG*/ 332, /*HNL*/ 340, /*HKD*/ 344, /*HUF*/ 348, /*ISK*/ 352, /*INR*/ 356, + /*IDR*/ 360, /*IRR*/ 364, /*IQD*/ 368, /*ILS*/ 376, /*JMD*/ 388, /*JPY*/ 392, /*KZT*/ 398, /*JOD*/ 400, /*KES*/ 404, /*KPW*/ 408, + /*KRW*/ 410, /*KWD*/ 414, /*KGS*/ 417, /*LAK*/ 418, /*LBP*/ 422, /*LSL*/ 426, /*LRD*/ 430, /*LYD*/ 434, /*MOP*/ 446, /*MWK*/ 454, + /*MYR*/ 458, /*MVR*/ 462, /*MUR*/ 480, /*MXN*/ 484, /*MNT*/ 496, /*MDL*/ 498, /*MAD*/ 504, /*OMR*/ 512, /*NAD*/ 516, /*NPR*/ 524, + /*ANG*/ 532, /*AWG*/ 533, /*VUV*/ 548, /*NZD*/ 554, /*NIO*/ 558, /*NGN*/ 566, /*NOK*/ 578, /*PKR*/ 586, /*PAB*/ 590, /*PGK*/ 598, + /*PYG*/ 600, /*PEN*/ 604, /*PHP*/ 608, /*QAR*/ 634, /*RUB*/ 643, /*RWF*/ 646, /*SHP*/ 654, /*SAR*/ 682, /*SCR*/ 690, /*SLL*/ 694, + /*SGD*/ 702, /*VND*/ 704, /*SOS*/ 706, /*ZAR*/ 710, /*SSP*/ 728, /*SZL*/ 748, /*SEK*/ 752, /*CHF*/ 756, /*SYP*/ 760, /*THB*/ 764, + /*TOP*/ 776, /*TTD*/ 780, /*AED*/ 784, /*TND*/ 788, /*UGX*/ 800, /*MKD*/ 807, /*EGP*/ 818, /*GBP*/ 826, /*TZS*/ 834, /*USD*/ 840, + /*UYU*/ 858, /*UZS*/ 860, /*WST*/ 882, /*YER*/ 886, /*TWD*/ 901, /*UYW*/ 927, /*VES*/ 928, /*MRU*/ 929, /*STN*/ 930, /*CUC*/ 931, + /*ZWL*/ 932, /*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944, /*RON*/ 946, + /*CHE*/ 947, /*CHW*/ 948, /*TRY*/ 949, /*XAF*/ 950, /*XCD*/ 951, /*XOF*/ 952, /*XPF*/ 953, /*XBA*/ 955, /*XBB*/ 956, /*XBC*/ 957, + /*XBD*/ 958, /*XAU*/ 959, /*XDR*/ 960, /*XAG*/ 961, /*XPT*/ 962, /*XTS*/ 963, /*XPD*/ 964, /*XUA*/ 965, /*ZMW*/ 967, /*SRD*/ 968, + /*MGA*/ 969, /*COU*/ 970, /*AFN*/ 971, /*TJS*/ 972, /*AOA*/ 973, /*BGN*/ 975, /*CDF*/ 976, /*BAM*/ 977, /*EUR*/ 978, /*MXV*/ 979, + /*UAH*/ 980, /*GEL*/ 981, /*BOV*/ 984, /*PLN*/ 985, /*BRL*/ 986, /*CLF*/ 990, /*XSU*/ 994, /*USN*/ 997, /*XXX*/ 999, +); + +$numeric_tab = array(); +$val = 0; +$byte = 0; +$max = $numeric[count($numeric) - 1]; +for ($i = 0; $i <= $max; $i++) { + if ($i && $i % 8 == 0) { + $numeric_tab[$byte++] = $val; + $val = 0; + } + if (in_array($i, $numeric)) { + $val |= 1 << ($i & 0x7); + } +} +$numeric_tab[$byte++] = $val; +$numeric_cnt = count($numeric_tab); + +print << + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ + + +EOD; +} + +if ($print_h_guard) { +print <<<'EOD' +#ifndef ISO4217_H +#define ISO4217_H + +EOD; +} + +print <<> 3; + +{$tab}if (b < 0 || b >= $numeric_cnt) { +{$tab}{$tab}return 0; +{$tab}} +{$tab}return codes[b] & (1 << (cc & 0x7)) ? 1 : 0; +} + +EOD; + +if ($print_h_guard) { +print <<<'EOD' + +#endif /* ISO4217_H */ + +EOD; +} diff --git a/win32/libzint.vcxproj b/win32/libzint.vcxproj index 15b0677e..651519bf 100644 --- a/win32/libzint.vcxproj +++ b/win32/libzint.vcxproj @@ -192,7 +192,10 @@ + + + diff --git a/win32/vs2008/libzint.vcproj b/win32/vs2008/libzint.vcproj index fc63037a..4af9e7cb 100644 --- a/win32/vs2008/libzint.vcproj +++ b/win32/vs2008/libzint.vcproj @@ -545,10 +545,22 @@ RelativePath="..\backend\gs1.h" > + + + + + + diff --git a/win32/vs2015/libzint.vcxproj b/win32/vs2015/libzint.vcxproj index 0bbc7fec..f08100cd 100644 --- a/win32/vs2015/libzint.vcxproj +++ b/win32/vs2015/libzint.vcxproj @@ -371,7 +371,10 @@ + + + diff --git a/win32/vs2015/vsx/libzintMD.vcxproj b/win32/vs2015/vsx/libzintMD.vcxproj index 1ecc1ff0..aa6a7ab2 100644 --- a/win32/vs2015/vsx/libzintMD.vcxproj +++ b/win32/vs2015/vsx/libzintMD.vcxproj @@ -139,7 +139,10 @@ + + + diff --git a/win32/vs2019/libzint.vcxproj b/win32/vs2019/libzint.vcxproj index 8bf21072..8baece13 100644 --- a/win32/vs2019/libzint.vcxproj +++ b/win32/vs2019/libzint.vcxproj @@ -192,7 +192,10 @@ + + +