First attempt at i18n using gettext

This commit is contained in:
Robin Stuart 2020-11-07 19:26:10 +00:00
parent 44923349f3
commit 06058d7518
45 changed files with 1236 additions and 356 deletions

View file

@ -64,12 +64,14 @@ INTERNAL int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source
char dest[512]; /* 6 + 80 * 6 + 6 + 1 ~ 512*/
if (length > 80) {
strcpy(symbol->errtxt, "301: Input too long");
symbol->err_origin = 301;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "302: Invalid characters in data");
symbol->err_origin = 302;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -95,12 +97,14 @@ INTERNAL int industrial_two_of_five(struct zint_symbol *symbol, unsigned char so
char dest[512]; /* 6 + 40 * 10 + 6 + 1 */
if (length > 45) {
strcpy(symbol->errtxt, "303: Input too long");
symbol->err_origin = 303;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "304: Invalid character in data");
symbol->err_origin = 304;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -125,12 +129,14 @@ INTERNAL int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[]
char dest[512]; /* 4 + 45 * 10 + 3 + 1 */
if (length > 45) {
strcpy(symbol->errtxt, "305: Input too long");
symbol->err_origin = 305;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "306: Invalid characters in data");
symbol->err_origin = 306;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -156,12 +162,14 @@ INTERNAL int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[
char dest[512]; /* 4 + 80 * 6 + 3 + 1 */
if (length > 80) {
strcpy(symbol->errtxt, "307: Input too long");
symbol->err_origin = 307;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "308: Invalid characters in data");
symbol->err_origin = 308;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -192,12 +200,14 @@ INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, const unsigned
#endif
if (length > 89) {
strcpy(symbol->errtxt, "309: Input too long");
symbol->err_origin = 309;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "310: Invalid characters in data");
symbol->err_origin = 310;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -250,13 +260,15 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
count = 0;
if (length > 13) {
strcpy(symbol->errtxt, "311: Input too long");
symbol->err_origin = 311;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "312: Invalid character in data");
symbol->err_origin = 312;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -301,12 +313,14 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
count = 0;
if (length > 13) {
strcpy(symbol->errtxt, "313: Input wrong length");
symbol->err_origin = 313;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "314: Invalid characters in data");
symbol->err_origin = 314;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -337,12 +351,14 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
count = 0;
if (length > 11) {
strcpy(symbol->errtxt, "315: Input wrong length");
symbol->err_origin = 315;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "316: Invalid characters in data");
symbol->err_origin = 316;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}

View file

@ -113,7 +113,8 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
/* Check input immediately to catch nuls */
error_number = is_sane(GDSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "404: Invalid characters in data");
symbol->err_origin = 404;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
strcpy(localstr, "");
@ -140,17 +141,20 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
error_number = is_sane(NEON, source, length);
break;
default:
strcpy(symbol->errtxt, "401: Auspost input is wrong length");
symbol->err_origin = 401;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "402: Invalid characters in data");
symbol->err_origin = 402;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
} else {
int zeroes;
if (length > 8) {
strcpy(symbol->errtxt, "403: Auspost input is too long");
symbol->err_origin = 403;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
switch (symbol->symbology) {
@ -175,7 +179,8 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
dpid[8] = '\0';
error_number = is_sane(NEON, (unsigned char *) dpid, strlen(dpid));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "405: Invalid characters in DPID");
symbol->err_origin = 405;
strcpy(symbol->errtxt, _("Invalid character in DPID"));
return error_number;
}

View file

@ -1003,7 +1003,8 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const siz
comp_loop = 1;
}
if (gs1 && reader) {
strcpy(symbol->errtxt, "501: Cannot encode in GS1 and Reader Initialisation mode at the same time");
symbol->err_origin = 501;
strcpy(symbol->errtxt, _("Can't encode in GS1 and Reader Initialisation mode at the same time"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -1012,12 +1013,14 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const siz
error_number = aztec_text_process(source, length, binary_string, gs1, symbol->eci, debug);
if (error_number != 0) {
strcpy(symbol->errtxt, "502: Input too long or too many extended ASCII characters");
symbol->err_origin = 502;
strcpy(symbol->errtxt, _("Input too long or too many extended ASCII characters"));
return error_number;
}
if (!((symbol->option_1 >= -1) && (symbol->option_1 <= 4))) {
strcpy(symbol->errtxt, "503: Invalid error correction level - using default instead");
symbol->err_origin = 503;
strcpy(symbol->errtxt, _("Invalid error correction level - using default instead"));
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
} else {
@ -1109,7 +1112,8 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const siz
}
if (layers == 0) { /* Couldn't find a symbol which fits the data */
strcpy(symbol->errtxt, "504: Input too long (too many bits for selected ECC)");
symbol->err_origin = 504;
strcpy(symbol->errtxt, _("Input too long for selected error correction level"));
return ZINT_ERROR_TOO_LONG;
}
@ -1205,7 +1209,8 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const siz
layers = symbol->option_2 - 4;
}
if ((symbol->option_2 < 0) || (symbol->option_2 > 36)) {
strcpy(symbol->errtxt, "510: Invalid Aztec Code size");
symbol->err_origin = 510;
strcpy(symbol->errtxt, _("Invalid Aztec Code size"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -1279,7 +1284,8 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const siz
}
if (adjusted_length > data_maxsize) {
strcpy(symbol->errtxt, "505: Data too long for specified Aztec Code symbol size");
symbol->err_origin = 505;
strcpy(symbol->errtxt, _("Data too long for specified Aztec Code symbol size"));
return ZINT_ERROR_TOO_LONG;
}
@ -1297,7 +1303,8 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const siz
}
if (reader && (layers > 22)) {
strcpy(symbol->errtxt, "506: Data too long for reader initialisation symbol");
symbol->err_origin = 506;
strcpy(symbol->errtxt, _("Data too long for reader initialisation symbol"));
return ZINT_ERROR_TOO_LONG;
}
@ -1576,12 +1583,14 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
input_value = 0;
if (length > 3) {
strcpy(symbol->errtxt, "507: Input too large");
symbol->err_origin = 507;
strcpy(symbol->errtxt, _("Input too large"));
return ZINT_ERROR_INVALID_DATA;
}
error_number = is_sane(NEON, source, length);
if (error_number != 0) {
strcpy(symbol->errtxt, "508: Invalid characters in input");
symbol->err_origin = 508;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
switch (length) {
@ -1597,7 +1606,8 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
}
if (input_value > 255) {
strcpy(symbol->errtxt, "509: Input too large");
symbol->err_origin = 509;
strcpy(symbol->errtxt, _("Input too large"));
return ZINT_ERROR_INVALID_DATA;
}

View file

@ -69,7 +69,8 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
bitmap_file_start = (unsigned char *) malloc(file_size);
if (bitmap_file_start == NULL) {
strcpy(symbol->errtxt, "602: Out of memory");
symbol->err_origin = 602;
strcpy(symbol->errtxt, _("Out of memory"));
return ZINT_ERROR_MEMORY;
}
memset(bitmap_file_start, 0, file_size); /* Not required but keeps padding bytes consistent */
@ -176,7 +177,8 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "600: Can't open output file");
symbol->err_origin = 600;
strcpy(symbol->errtxt, _("Can't open output file"));
free(bitmap_file_start);
return ZINT_ERROR_FILE_ACCESS;
}
@ -185,7 +187,8 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
} else {
if (!(bmp_file = fopen(symbol->outfile, "wb"))) {
free(bitmap_file_start);
strcpy(symbol->errtxt, "601: Can't open output file");
symbol->err_origin = 601;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
}

View file

@ -663,13 +663,15 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
return error_number;
}
if (rows > 44) {
strcpy(symbol->errtxt, "410: Rows parameter not in 0..44");
symbol->err_origin = 410;
strcpy(symbol->errtxt, _("Rows parameter not in range 0 to 44"));
return ZINT_ERROR_INVALID_OPTION;
}
/* option_2: (usable data) columns: <= 0: automatic, 9..67 (min 9 == 4 data, max 67 == 62 data) */
columns = symbol->option_2;
if ( ! (columns <= 0 || (columns >= 9 && columns <= 67)) ) {
strcpy(symbol->errtxt, "411: Columns parameter not in 0, 9..67");
symbol->err_origin = 411;
strcpy(symbol->errtxt, _("Columns parameter not 0 or in range 9 to 67"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -730,7 +732,8 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
error_number = Columns2Rows(symbol, T, dataLength, &rows, &useColumns, pSet, &fillings);
}
if (error_number != 0) {
strcpy(symbol->errtxt, "413: Data string too long");
symbol->err_origin = 413;
strcpy(symbol->errtxt, _("Input too long"));
return error_number;
}
/* Suppresses clang-analyzer-core.VLASize warning */

View file

@ -111,17 +111,20 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
assert(length > 0);
if (length > 121) {
strcpy(symbol->errtxt, "320: Input too long");
symbol->err_origin = 320;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SODIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "321: Invalid characters in data");
symbol->err_origin = 321;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
if (symbol->option_2 < 0 || symbol->option_2 > 2) {
strcpy(symbol->errtxt, "339: Invalid check digit version");
symbol->err_origin = 339;
strcpy(symbol->errtxt, _("Invalid check digit version"));
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->option_2 == 2) {
@ -227,19 +230,23 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_
}
if ((symbol->symbology == BARCODE_LOGMARS) && (length > 30)) { /* MIL-STD-1189 Rev. B Section 5.2.6.2 */
strcpy(symbol->errtxt, "322: Input too long");
symbol->err_origin = 322;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
} else if ((symbol->symbology == BARCODE_HIBC_39) && (length > 68)) { /* Prevent encoded_data out-of-bounds >= 143 due to wider 'wide' bars */
strcpy(symbol->errtxt, "319: Input too long"); /* Note use 319 (2of5 range) as 340 taken by CODE128 */
symbol->err_origin = 319;
strcpy(symbol->errtxt, _("Input too long")); /* Note use 319 (2of5 range) as 340 taken by CODE128 */
return ZINT_ERROR_TOO_LONG;
} else if (length > 85) {
strcpy(symbol->errtxt, "323: Input too long");
symbol->err_origin = 323;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(SILVER, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "324: Invalid characters in data");
symbol->err_origin = 324;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -327,12 +334,14 @@ INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], i
char localstr[11];
if (length > 7) {
strcpy(symbol->errtxt, "325: Input wrong length");
symbol->err_origin = 325;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "326: Invalid characters in data");
symbol->err_origin = 326;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -354,7 +363,8 @@ INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], i
}
if (check_digit == 10) {
strcpy(symbol->errtxt, "327: Invalid PZN Data");
symbol->err_origin = 327;
strcpy(symbol->errtxt, _("Invalid PZN Data"));
return ZINT_ERROR_INVALID_DATA;
}
localstr[8] = itoc(check_digit);
@ -373,7 +383,8 @@ INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length
int error_number;
if (length > 85) {
strcpy(symbol->errtxt, "328: Input too long");
symbol->err_origin = 328;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -381,7 +392,8 @@ INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "329: Invalid characters in input data");
symbol->err_origin = 329;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
ustrcat(buffer, EC39Ctrl[source[i]]);
@ -414,7 +426,8 @@ INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length)
strcpy(buffer, "");
if (length > 107) {
strcpy(symbol->errtxt, "330: Input too long");
symbol->err_origin = 330;
strcpy(symbol->errtxt, "Input too long");
return ZINT_ERROR_TOO_LONG;
}
@ -422,7 +435,8 @@ INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length)
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "331: Invalid characters in input data");
symbol->err_origin = 331;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
strcat(buffer, C93Ctrl[source[i]]);
@ -432,7 +446,8 @@ INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length)
/* Now we can check the true length of the barcode */
h = (int) strlen(buffer);
if (h > 107) {
strcpy(symbol->errtxt, "332: Input too long");
symbol->err_origin = 332;
strcpy(symbol->errtxt, "Input too long");
return ZINT_ERROR_TOO_LONG;
}
@ -617,12 +632,14 @@ INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], in
char hrt[9];
if (length > 7) {
strcpy(symbol->errtxt, "333: Input too long");
symbol->err_origin = 333;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "334: Invalid characters in data");
symbol->err_origin = 334;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -682,7 +699,8 @@ INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], in
break;
}
if (range) {
strcpy(symbol->errtxt, "335: Value out of range");
symbol->err_origin = 335;
strcpy(symbol->errtxt, _("Value out of range"));
return ZINT_ERROR_INVALID_DATA;
}
@ -727,13 +745,15 @@ INTERNAL int vin(struct zint_symbol *symbol, const unsigned char source[], const
// Check length
if (length != 17) {
strcpy(symbol->errtxt, "336: Input wrong length, 17 characters required");
symbol->err_origin = 336;
strcpy(symbol->errtxt, _("Input wrong length, 17 characters required"));
return ZINT_ERROR_TOO_LONG;
}
// Check input characters, I, O and Q are not allowed
if (is_sane(ARSENIC, source, length) == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "337: Invalid characters in input data");
symbol->err_origin = 337;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
@ -776,7 +796,8 @@ INTERNAL int vin(struct zint_symbol *symbol, const unsigned char source[], const
}
if (input_check != output_check) {
strcpy(symbol->errtxt, "338: Invalid check digit in input data");
symbol->err_origin = 338;
strcpy(symbol->errtxt, _("Invalid check digit"));
return ZINT_ERROR_INVALID_DATA;
}
}

View file

@ -1015,7 +1015,8 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
if (tp > 1480) {
/* Data is too large for symbol */
strcpy(symbol->errtxt, "511: Input data too long");
symbol->err_origin = 511;
strcpy(symbol->errtxt, _("Input too long"));
return 0;
}
} while (sp < length);
@ -1160,7 +1161,8 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
/* Re-check length of data */
if (tp > 1480) {
/* Data is too large for symbol */
strcpy(symbol->errtxt, "512: Input data too long");
symbol->err_origin = 512;
strcpy(symbol->errtxt, _("Input too long"));
return 0;
}
/*
@ -1193,7 +1195,8 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
int sub_version = 0;
if ((symbol->option_2 < 0) || (symbol->option_2 > 10)) {
strcpy(symbol->errtxt, "513: Invalid symbol size");
symbol->err_origin = 513;
strcpy(symbol->errtxt, _("Invalid symbol size"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -1206,11 +1209,13 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
int block_width;
if (length > 18) {
strcpy(symbol->errtxt, "514: Input data too long");
symbol->err_origin = 514;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
if (is_sane(NEON, source, length) == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "515: Invalid input data (Version S encodes numeric input only)");
symbol->err_origin = 515;
strcpy(symbol->errtxt, _("Invalid input data (Version S encodes numeric input only)"));
return ZINT_ERROR_INVALID_DATA;
}
@ -1306,7 +1311,8 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
int data_cw, ecc_cw, block_width;
if (length > 80) {
strcpy(symbol->errtxt, "519: Input data too long");
symbol->err_origin = 519;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -1317,7 +1323,8 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
}
if (data_length > 38) {
strcpy(symbol->errtxt, "516: Input data too long");
symbol->err_origin = 516;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -1412,7 +1419,8 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
data_length = c1_encode(symbol, source, data, length);
if (data_length == 0) {
strcpy(symbol->errtxt, "517: Input data is too long");
symbol->err_origin = 517;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -1427,7 +1435,8 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
}
if ((symbol-> option_2 != 0) && (symbol->option_2 < size)) {
strcpy(symbol->errtxt, "518: Input too long for selected symbol size");
symbol->err_origin = 518;
strcpy(symbol->errtxt, _("Input too long for selected symbol size"));
return ZINT_ERROR_TOO_LONG;
}

View file

@ -316,7 +316,8 @@ INTERNAL int code_128(struct zint_symbol *symbol, const unsigned char source[],
if (sourcelen > C128_MAX) {
/* This only blocks ridiculously long input - the actual length of the
resulting barcode depends on the type of data, so this is trapped later */
strcpy(symbol->errtxt, "340: Input too long");
symbol->err_origin = 340;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -479,7 +480,8 @@ INTERNAL int code_128(struct zint_symbol *symbol, const unsigned char source[],
}
}
if (glyph_count > 60.0) {
strcpy(symbol->errtxt, "341: Input too long");
symbol->err_origin = 341;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -720,7 +722,8 @@ INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], const s
if (length > C128_MAX) {
/* This only blocks ridiculously long input - the actual length of the
resulting barcode depends on the type of data, so this is trapped later */
strcpy(symbol->errtxt, "342: Input too long");
symbol->err_origin = 342;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -851,7 +854,8 @@ INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], const s
}
}
if (glyph_count > 60.0) {
strcpy(symbol->errtxt, "344: Input too long");
symbol->err_origin = 344;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -1030,13 +1034,15 @@ INTERNAL int nve_18(struct zint_symbol *symbol, unsigned char source[], int leng
sourcelen = length;
if (sourcelen > 17) {
strcpy(symbol->errtxt, "345: Input too long");
symbol->err_origin = 345;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "346: Invalid characters in data");
symbol->err_origin = 346;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
zeroes = 17 - sourcelen;
@ -1071,13 +1077,15 @@ INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int leng
unsigned char ean128_equiv[20];
if (length > 13) {
strcpy(symbol->errtxt, "347: Input wrong length");
symbol->err_origin = 347;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "348: Invalid character in data");
symbol->err_origin = 348;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -1117,7 +1125,8 @@ INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int
int cd; // Check digit
if (length != 28) {
strcpy(symbol->errtxt, "349: DPD input wrong length");
symbol->err_origin = 349;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
@ -1127,12 +1136,14 @@ INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "350: Invalid character in DPD data");
symbol->err_origin = 350;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
if ((identifier < 32) || (identifier > 127)) {
strcpy(symbol->errtxt, "351: Invalid DPD identifier");
symbol->err_origin = 351;
strcpy(symbol->errtxt, _("Invalid DPD identifier"));
return ZINT_ERROR_INVALID_DATA;
}

View file

@ -135,7 +135,8 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], const s
}
if (input_length > C128_MAX) {
strcpy(symbol->errtxt, "420: Input too long");
symbol->err_origin = 420;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -280,7 +281,8 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], const s
}
if (glyph_count > 77.0) {
strcpy(symbol->errtxt, "421: Input too long");
symbol->err_origin = 421;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -312,7 +314,8 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], const s
m = 5;
}
if (gs1) {
strcpy(symbol->errtxt, "422: Cannot use both GS1 mode and Reader Initialisation");
symbol->err_origin = 422;
strcpy(symbol->errtxt, _("Can't encode in GS1 and Reader Initialisation mode at the same time"));
return ZINT_ERROR_INVALID_OPTION;
} else {
if ((set[0] == 'B') && (set[1] == 'C')) {

View file

@ -52,7 +52,8 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], const i
int h, len;
if (length > 81) {
strcpy(symbol->errtxt, "430: Input too long");
symbol->err_origin = 430;
strcpy(symbol->errtxt, "Input too long");
return ZINT_ERROR_TOO_LONG;
}
if ((symbol->input_mode & 0x07) == GS1_MODE) {
@ -64,7 +65,8 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], const i
for (i = 0; i < length; i++) {
if (source[i] > 127) {
strcpy(symbol->errtxt, "431: Invalid characters in input data");
symbol->err_origin = 431;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
if (gs1 && (source[i] == '['))
@ -215,7 +217,8 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], const i
}
if (codeword_count > 49) {
strcpy(symbol->errtxt, "432: Input too long");
symbol->err_origin = 432;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}

View file

@ -319,11 +319,13 @@ INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char sou
} while (bpos < *length && state != 0 && state != 12);
if (state != 0) {
strcpy(symbol->errtxt, "240: Corrupt Unicode data");
symbol->err_origin = 240;
strcpy(symbol->errtxt, _("Corrupt Unicode data"));
return ZINT_ERROR_INVALID_DATA;
}
if (disallow_4byte && codepoint > 0xffff) {
strcpy(symbol->errtxt, "242: Unicode sequences of more than 3 bytes not supported");
symbol->err_origin = 242;
strcpy(symbol->errtxt, _("Unicode sequences of more than 3 bytes not supported"));
return ZINT_ERROR_INVALID_DATA;
}

View file

@ -50,6 +50,11 @@
#include <stdlib.h>
#include <string.h>
/* i18n */
#include <libintl.h>
#include <locale.h>
#define _(STRING) gettext(STRING)
/* Helpers to cast away char pointer signedness */
#define ustrlen(source) strlen((const char *) (source))
#define ustrcpy(target, source) strcpy((char *) (target), (const char *) (source))

View file

@ -1258,7 +1258,8 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
if (!general_field_encode(general_field, &mode, &last_digit, binary_string)) {
/* Invalid characters in input data */
strcpy(symbol->errtxt, "441: Invalid characters in input data");
symbol->err_origin = 441;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
@ -1276,7 +1277,8 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
}
if (target_bitsize == 0) {
strcpy(symbol->errtxt, "442: Input too long for selected 2D component");
symbol->err_origin = 442;
strcpy(symbol->errtxt, _("Input too long for selected 2D component"));
return ZINT_ERROR_TOO_LONG;
}
@ -1299,7 +1301,8 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
}
if (strlen(binary_string) > 11805) { /* (2361 * 5) */
strcpy(symbol->errtxt, "443: Input too long");
symbol->err_origin = 443;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -1317,7 +1320,8 @@ static int cc_binary_string(struct zint_symbol *symbol, const char source[], cha
}
if (target_bitsize == 0) {
strcpy(symbol->errtxt, "444: Input too long for selected 2D component");
symbol->err_origin = 444;
strcpy(symbol->errtxt, _("Input too long for selected 2D component"));
return ZINT_ERROR_TOO_LONG;
}
@ -1389,19 +1393,22 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
error_number = 0;
pri_len = (int)strlen(symbol->primary);
if (pri_len == 0) {
strcpy(symbol->errtxt, "445: No primary (linear) message in 2D composite");
symbol->err_origin = 445;
strcpy(symbol->errtxt, _("No primary (linear) message in 2D composite"));
return ZINT_ERROR_INVALID_OPTION;
}
if (length > 2990) {
strcpy(symbol->errtxt, "446: 2D component input data too long");
symbol->err_origin = 446;
strcpy(symbol->errtxt, _("2D component input data too long"));
return ZINT_ERROR_TOO_LONG;
}
cc_mode = symbol->option_1;
if ((cc_mode == 3) && (symbol->symbology != BARCODE_GS1_128_CC)) {
/* CC-C can only be used with a GS1-128 linear part */
strcpy(symbol->errtxt, "447: Invalid mode (CC-C only valid with GS1-128 linear component)");
symbol->err_origin = 447;
strcpy(symbol->errtxt, _("Invalid mode (CC-C only valid with GS1-128 linear component)"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -1409,7 +1416,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
/* Do a test run of encoding the linear component to establish its width */
linear_width = linear_dummy_run((unsigned char *) symbol->primary, pri_len, symbol->errtxt);
if (linear_width == 0) {
strcat(symbol->errtxt, " in linear component");
strcat(symbol->errtxt, _(" in linear component"));
return ZINT_ERROR_INVALID_DATA;
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
@ -1449,7 +1456,8 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
}
}
if (cc_width == 0) {
strcpy(symbol->errtxt, "449: Input wrong length in linear component");
symbol->err_origin = 449;
strcpy(symbol->errtxt, _("Input wrong length in linear component"));
return ZINT_ERROR_TOO_LONG;
}
break;
@ -1565,7 +1573,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
if (error_number != 0) {
strcpy(symbol->errtxt, linear->errtxt);
strcat(symbol->errtxt, " in linear component");
strcat(symbol->errtxt, _(" in linear component"));
ZBarcode_Delete(linear);
return error_number;
}

View file

@ -570,7 +570,8 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
if (symbol->output_options & READER_INIT) {
if (gs1) {
strcpy(symbol->errtxt, "521: Cannot encode in GS1 mode and Reader Initialisation at the same time");
symbol->err_origin = 521;
strcpy(symbol->errtxt, _("Can't encode in GS1 and Reader Initialisation mode at the same time"));
return ZINT_ERROR_INVALID_OPTION;
} else {
target[tp] = 234;
@ -971,7 +972,8 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
}
if (tp > 1558) {
strcpy(symbol->errtxt, "520: Data too long to fit in symbol");
symbol->err_origin = 520;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -1236,7 +1238,8 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
// The symbol size was given by --ver (option_2)
// Thus check if the data fits into this symbol size and use this size
if (calcsize > optionsize) {
strcpy(symbol->errtxt, "522: Input too long for selected symbol size");
symbol->err_origin = 522;
strcpy(symbol->errtxt, _("Input too long for selected symbol size"));
return ZINT_ERROR_TOO_LONG;
}
symbolsize = optionsize;
@ -1247,7 +1250,8 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
binlen = dm200encode_remainder(binary, binlen, source, inputlen, last_mode, last_shift, process_buffer, process_p, symbols_left, debug);
if (binlen > matrixbytes[symbolsize]) {
strcpy(symbol->errtxt, "523: Data too long to fit in symbol");
symbol->err_origin = 523;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -1354,7 +1358,8 @@ INTERNAL int dmatrix(struct zint_symbol *symbol, const unsigned char source[], c
error_number = data_matrix_200(symbol, source, in_length);
} else {
/* ECC 000 - 140 */
strcpy(symbol->errtxt, "524: Older Data Matrix standards are no longer supported");
symbol->err_origin = 524;
strcpy(symbol->errtxt, _("Older Data Matrix standards are no longer supported"));
error_number = ZINT_ERROR_INVALID_OPTION;
}

View file

@ -1325,7 +1325,8 @@ INTERNAL int dotcode(struct zint_symbol *symbol, const unsigned char source[], i
#endif /* _MSC_VER */
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "525: Invalid ECI");
symbol->err_origin = 525;
strcpy(symbol->errtxt, _("Invalid ECI"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -1408,12 +1409,14 @@ INTERNAL int dotcode(struct zint_symbol *symbol, const unsigned char source[], i
}
if ((height > 200) || (width > 200)) {
strcpy(symbol->errtxt, "526: Specified symbol size is too large");
symbol->err_origin = 526;
strcpy(symbol->errtxt, _("Specified symbol size is too large"));
return ZINT_ERROR_INVALID_OPTION;
}
if ((height < 5) || (width < 5)) {
strcpy(symbol->errtxt, "527: Specified symbol size has a dimension which is too small");
symbol->err_origin = 527;
strcpy(symbol->errtxt, _("Specified symbol size has a dimension which is too small"));
return ZINT_ERROR_INVALID_OPTION;
}

View file

@ -673,7 +673,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
emf_file = fopen(symbol->outfile, "wb");
}
if (emf_file == NULL) {
strcpy(symbol->errtxt, "640: Could not open output file");
symbol->err_origin = 640;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}

View file

@ -2890,7 +2890,8 @@ INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char so
} else {
ret = gb18030_wctomb_zint(gbdata + j, gbdata + j + 1, utfdata[i]);
if (ret == 0) {
strcpy(symbol->errtxt, "820: Invalid character in input data");
symbol->err_origin = 820;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
if (ret == 4) {

View file

@ -1563,7 +1563,8 @@ INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char sou
gbdata[i] = utfdata[i];
} else {
if (!gb2312_wctomb_zint(gbdata + i, utfdata[i])) {
strcpy(symbol->errtxt, "810: Invalid character in input data");
symbol->err_origin = 810;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
}

View file

@ -314,14 +314,16 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "610: Can't open output file");
symbol->err_origin = 610;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
#endif
gif_file = stdout;
} else {
if (!(gif_file = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "611: Can't open output file");
symbol->err_origin = 611;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
}
@ -414,7 +416,8 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
RGBCur[0] = 0; RGBCur[1] = 0; RGBCur[2] = 0;
break;
default: /* error case - return */
strcpy(symbol->errtxt, "611: unknown pixel colour");
symbol->err_origin = 611;
strcpy(symbol->errtxt, _("Unknown pixel colour"));
return ZINT_ERROR_INVALID_DATA;
}
/* Search, if RGB value is already present */

View file

@ -955,7 +955,8 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
if (error_number == 0) {
done = 1;
} else if (symbol->eci && symbol->eci <= 899) {
strcpy(symbol->errtxt, "575: Invalid characters in input data");
symbol->err_origin = 575;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
}
@ -971,13 +972,15 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
if (symbol->output_options & READER_INIT) reader = 1;
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "533: Invalid ECI");
symbol->err_origin = 533;
strcpy(symbol->errtxt, _("Invalid ECI"));
return ZINT_ERROR_INVALID_OPTION;
}
error_number = gm_encode(gbdata, length, binary, reader, symbol->eci, symbol->debug);
if (error_number != 0) {
strcpy(symbol->errtxt, "531: Input data too long");
symbol->err_origin = 531;
strcpy(symbol->errtxt, _("Input too long"));
return error_number;
}
@ -1003,7 +1006,8 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
if (symbol->option_2 >= min_layers) {
layers = symbol->option_2;
} else {
strcpy(symbol->errtxt, "534: Input data too long for selected symbol size");
symbol->err_origin = 534;
strcpy(symbol->errtxt, _("Input too long for selected symbol size"));
return ZINT_ERROR_TOO_LONG;
}
}
@ -1059,7 +1063,8 @@ INTERNAL int grid_matrix(struct zint_symbol *symbol, const unsigned char source[
}
if (data_cw > data_max) {
strcpy(symbol->errtxt, "532: Input data too long");
symbol->err_origin = 532;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}

View file

@ -106,25 +106,30 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
/* Detect extended ASCII characters */
for (i = 0; i < (int) src_len; i++) {
if (source[i] >= 128) {
strcpy(symbol->errtxt, "250: Extended ASCII characters are not supported by GS1");
symbol->err_origin = 250;
strcpy(symbol->errtxt, _("Extended ASCII characters are not supported by GS1"));
return ZINT_ERROR_INVALID_DATA;
}
if (source[i] == '\0') {
strcpy(symbol->errtxt, "262: NUL characters not permitted in GS1 mode");
symbol->err_origin = 262;
strcpy(symbol->errtxt, _("NUL characters not permitted in GS1 mode"));
return ZINT_ERROR_INVALID_DATA;
}
if (source[i] < 32) {
strcpy(symbol->errtxt, "251: Control characters are not supported by GS1");
symbol->err_origin = 251;
strcpy(symbol->errtxt, _("Control characters are not supported by GS1"));
return ZINT_ERROR_INVALID_DATA;
}
if (source[i] == 127) {
strcpy(symbol->errtxt, "263: DEL characters are not supported by GS1");
symbol->err_origin = 263;
strcpy(symbol->errtxt, _("DEL characters are not supported by GS1"));
return ZINT_ERROR_INVALID_DATA;
}
}
if (source[0] != '[') {
strcpy(symbol->errtxt, "252: Data does not start with an AI");
symbol->err_origin = 252;
strcpy(symbol->errtxt, _("Data does not start with an AI"));
if (symbol->warn_level != WARN_ZPL_COMPAT) {
return ZINT_ERROR_INVALID_DATA;
} else {
@ -169,31 +174,36 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
if (bracket_level != 0) {
/* Not all brackets are closed */
strcpy(symbol->errtxt, "253: Malformed AI in input data (brackets don\'t match)");
symbol->err_origin = 253;
strcpy(symbol->errtxt, _("Malformed AI in input data (brackets don\'t match)"));
return ZINT_ERROR_INVALID_DATA;
}
if (max_bracket_level > 1) {
/* Nested brackets */
strcpy(symbol->errtxt, "254: Found nested brackets in input data");
symbol->err_origin = 254;
strcpy(symbol->errtxt, _("Found nested brackets in input data"));
return ZINT_ERROR_INVALID_DATA;
}
if (max_ai_length > 4) {
/* AI is too long */
strcpy(symbol->errtxt, "255: Invalid AI in input data (AI too long)");
symbol->err_origin = 255;
strcpy(symbol->errtxt, _("Invalid AI in input data (AI too long)"));
return ZINT_ERROR_INVALID_DATA;
}
if (min_ai_length <= 1) {
/* AI is too short */
strcpy(symbol->errtxt, "256: Invalid AI in input data (AI too short)");
symbol->err_origin = 256;
strcpy(symbol->errtxt, _("Invalid AI in input data (AI too short)"));
return ZINT_ERROR_INVALID_DATA;
}
if (ai_latch == 1) {
/* Non-numeric data in AI */
strcpy(symbol->errtxt, "257: Invalid AI in input data (non-numeric characters in AI)");
symbol->err_origin = 257;
strcpy(symbol->errtxt, _("Invalid AI in input data (non-numeric characters in AI)"));
return ZINT_ERROR_INVALID_DATA;
}
@ -230,7 +240,8 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
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");
symbol->err_origin = 258;
strcpy(symbol->errtxt, _("Empty data field in input data"));
return ZINT_ERROR_INVALID_DATA;
}
}
@ -665,7 +676,8 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
if (error_latch == 1) {
itostr(ai_string, ai_value[i]);
strcpy(symbol->errtxt, "259: Invalid data length for AI ");
symbol->err_origin = 259;
strcpy(symbol->errtxt, _("Invalid data length for AI "));
strcat(symbol->errtxt, ai_string);
if (symbol->warn_level != WARN_ZPL_COMPAT) {
return ZINT_ERROR_INVALID_DATA;
@ -676,7 +688,8 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
if (error_latch == 2) {
itostr(ai_string, ai_value[i]);
strcpy(symbol->errtxt, "260: Invalid AI value ");
symbol->err_origin = 260;
strcpy(symbol->errtxt, _("Invalid AI value "));
strcat(symbol->errtxt, ai_string);
if (symbol->warn_level != WARN_ZPL_COMPAT) {
return ZINT_ERROR_INVALID_DATA;

View file

@ -1410,7 +1410,8 @@ INTERNAL int han_xin(struct zint_symbol *symbol, const unsigned char source[], s
if (error_number == 0) {
done = 1;
} else if (symbol->eci && symbol->eci <= 899) {
strcpy(symbol->errtxt, "575: Invalid characters in input data");
symbol->err_origin = 575;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
}
@ -1479,7 +1480,8 @@ INTERNAL int han_xin(struct zint_symbol *symbol, const unsigned char source[], s
}
if (version == 85) {
strcpy(symbol->errtxt, "541: Input too long for selected error correction level");
symbol->err_origin = 541;
strcpy(symbol->errtxt, _("Input too long for selected error correction level"));
return ZINT_ERROR_TOO_LONG;
}
@ -1492,7 +1494,8 @@ INTERNAL int han_xin(struct zint_symbol *symbol, const unsigned char source[], s
}
if ((symbol->option_2 != 0) && (symbol->option_2 < version)) {
strcpy(symbol->errtxt, "542: Input too long for selected symbol size");
symbol->err_origin = 542;
strcpy(symbol->errtxt, _("Input too long for selected symbol size"));
return ZINT_ERROR_TOO_LONG;
}

View file

@ -257,12 +257,14 @@ INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int lengt
int zip_len, len;
if (length > 32) {
strcpy(symbol->errtxt, "450: Input too long");
symbol->err_origin = 450;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SODIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "451: Invalid characters in data");
symbol->err_origin = 451;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -297,17 +299,20 @@ INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int lengt
}
if (strlen(tracker) != 20) {
strcpy(symbol->errtxt, "452: Invalid length tracking code");
symbol->err_origin = 452;
strcpy(symbol->errtxt, _("Invalid length tracking code"));
return ZINT_ERROR_INVALID_DATA;
}
if (tracker[1] > '4') {
strcpy(symbol->errtxt, "454: Invalid Barcode Identifier");
symbol->err_origin = 454;
strcpy(symbol->errtxt, _("Invalid Barcode Identifier"));
return ZINT_ERROR_INVALID_DATA;
}
zip_len = strlen(zip);
if (zip_len != 0 && zip_len != 5 && zip_len != 9 && zip_len != 11) {
strcpy(symbol->errtxt, "453: Invalid ZIP code");
symbol->err_origin = 453;
strcpy(symbol->errtxt, _("Invalid ZIP code"));
return ZINT_ERROR_INVALID_DATA;
}

View file

@ -185,16 +185,16 @@ INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int
INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to PNG/BMP/PCX */
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to EPS/EMF/SVG */
static void error_tag(char error_string[], int error_number) {
static void error_tag(char error_string[], int error_number, int err_origin) {
if (error_number != 0) {
char error_buffer[100];
strcpy(error_buffer, error_string);
if (error_number >= ZINT_ERROR) {
strcpy(error_string, "Error ");
sprintf(error_string, "Error %d: ", err_origin);
} else {
strcpy(error_string, "Warning ");
sprintf(error_string, "Warning %d: ", err_origin);
}
strcat(error_string, error_buffer);
@ -214,7 +214,8 @@ static int dump_plot(struct zint_symbol *symbol) {
} else {
f = fopen(symbol->outfile, "w");
if (!f) {
strcpy(symbol->errtxt, "201: Could not open output file");
symbol->err_origin = 201;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
}
@ -268,13 +269,15 @@ static int hibc(struct zint_symbol *symbol, unsigned char source[], size_t lengt
/* without "+" and check: max 110 characters in HIBC 2.6 */
if (length > 110) {
strcpy(symbol->errtxt, "202: Data too long for HIBC LIC");
symbol->err_origin = 202;
strcpy(symbol->errtxt, _("Data too long for HIBC LIC"));
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(TECHNETIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "203: Invalid characters in data");
symbol->err_origin = 203;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -742,7 +745,8 @@ static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, si
preprocessed = preprocessed_buf;
error_number = utf_to_eci(symbol->eci && symbol->eci <= 899 ? symbol->eci : 3, source, preprocessed, &in_length);
if (error_number != 0) {
strcpy(symbol->errtxt, "204: Invalid characters in input data");
symbol->err_origin = 204;
strcpy(symbol->errtxt,_("Invalid character in data"));
return error_number;
}
}
@ -947,7 +951,8 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_
do {
if (input_string[in_posn] == '\\') {
if (in_posn + 1 >= *length) {
strcpy(symbol->errtxt, "236: Incomplete escape character in input data");
symbol->err_origin = 236;
strcpy(symbol->errtxt, _("Incomplete escape character in input data"));
return ZINT_ERROR_INVALID_DATA;
}
switch (input_string[in_posn + 1]) {
@ -988,7 +993,8 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_
in_posn += 2;
break;
case 'x': if (in_posn + 4 > *length) {
strcpy(symbol->errtxt, "232: Incomplete escape character in input data");
symbol->err_origin = 232;
strcpy(symbol->errtxt, _("Incomplete escape character in input data"));
return ZINT_ERROR_INVALID_DATA;
}
hex1 = ctoi(input_string[in_posn + 2]);
@ -1004,7 +1010,8 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_
}
in_posn += 4;
} else {
strcpy(symbol->errtxt, "233: Corrupt escape character in input data");
symbol->err_origin = 233;
strcpy(symbol->errtxt, _("Corrupt escape character in input data"));
return ZINT_ERROR_INVALID_DATA;
}
break;
@ -1013,13 +1020,15 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_
break;
case 'u':
if (in_posn + 6 > *length) {
strcpy(symbol->errtxt, "209: Incomplete unicode escape character in input data");
symbol->err_origin = 209;
strcpy(symbol->errtxt, _("Incomplete Unicode escape character in input data"));
return ZINT_ERROR_INVALID_DATA;
}
unicode = 0;
for (i = 0; i < 4; i++) {
if (ctoi(input_string[in_posn + i + 2]) == -1) {
strcpy(symbol->errtxt, "211: Corrupt unicode escape character in input data");
symbol->err_origin = 211;
strcpy(symbol->errtxt, _("Corrupt Unicode escape character in input data"));
return ZINT_ERROR_INVALID_DATA;
}
unicode = unicode << 4;
@ -1040,7 +1049,9 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_
}
in_posn += 6;
break;
default: strcpy(symbol->errtxt, "234: Unrecognised escape character in input data");
default:
symbol->err_origin = 234;
strcpy(symbol->errtxt, _("Unrecognised escape character in input data"));
return ZINT_ERROR_INVALID_DATA;
break;
}
@ -1071,16 +1082,18 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
error_number = 0;
if (source == NULL) {
strcpy(symbol->errtxt, "200: Input data NULL");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
symbol->err_origin = 200;
strcpy(symbol->errtxt, _("Input data NULL"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA, symbol->err_origin);
return ZINT_ERROR_INVALID_DATA;
}
if (in_length <= 0) {
in_length = (int)ustrlen(source);
}
if (in_length <= 0) {
strcpy(symbol->errtxt, "205: No input data");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
symbol->err_origin = 205;
strcpy(symbol->errtxt, _("No input data"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA, symbol->err_origin);
return ZINT_ERROR_INVALID_DATA;
}
@ -1100,7 +1113,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
/* First check the symbology field */
if (!ZBarcode_ValidID(symbol->symbology)) {
if (symbol->symbology < 1) {
strcpy(symbol->errtxt, "206: Symbology out of range");
symbol->err_origin = 206;
strcpy(symbol->errtxt, _("Symbology out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
error_number = ZINT_ERROR_INVALID_OPTION;
} else {
@ -1117,7 +1131,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
} else if (symbol->symbology == 17) {
symbol->symbology = BARCODE_UPCA;
} else if (symbol->symbology == 19) {
strcpy(symbol->errtxt, "207: Codabar 18 not supported");
symbol->err_origin = 207;
strcpy(symbol->errtxt, _("Codabar 18 not supported"));
if (symbol->warn_level == WARN_FAIL_ALL) {
error_number = ZINT_ERROR_INVALID_OPTION;
} else {
@ -1127,7 +1142,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
} else if (symbol->symbology == 26) {
symbol->symbology = BARCODE_UPCA;
} else if (symbol->symbology == 27) {
strcpy(symbol->errtxt, "208: UPCD1 not supported");
symbol->err_origin = 208;
strcpy(symbol->errtxt, _("UPCD1 not supported"));
error_number = ZINT_ERROR_INVALID_OPTION;
} else if (symbol->symbology == 33) {
symbol->symbology = BARCODE_GS1_128;
@ -1140,7 +1156,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
} else if (symbol->symbology == 48) {
symbol->symbology = BARCODE_NVE18;
} else if (symbol->symbology == 54) {
strcpy(symbol->errtxt, "210: General Parcel Code not supported");
symbol->err_origin = 210;
strcpy(symbol->errtxt, _("General Parcel Code not supported"));
if (symbol->warn_level == WARN_FAIL_ALL) {
error_number = ZINT_ERROR_INVALID_OPTION;
} else {
@ -1160,7 +1177,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
} else if (symbol->symbology == 88) {
symbol->symbology = BARCODE_GS1_128;
} else if (symbol->symbology == 91) {
strcpy(symbol->errtxt, "212: Symbology out of range");
symbol->err_origin = 212;
strcpy(symbol->errtxt, _("Symbology out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
error_number = ZINT_ERROR_INVALID_OPTION;
} else {
@ -1168,7 +1186,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
error_number = ZINT_WARN_INVALID_OPTION;
}
} else if ((symbol->symbology >= 94) && (symbol->symbology <= 95)) {
strcpy(symbol->errtxt, "213: Symbology out of range");
symbol->err_origin = 213;
strcpy(symbol->errtxt, _("Symbology out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
error_number = ZINT_ERROR_INVALID_OPTION;
} else {
@ -1190,7 +1209,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
} else if (symbol->symbology == 111) {
symbol->symbology = BARCODE_HIBC_BLOCKF;
} else if ((symbol->symbology == 113) || (symbol->symbology == 114)) {
strcpy(symbol->errtxt, "214: Symbology out of range");
symbol->err_origin = 214;
strcpy(symbol->errtxt, _("Symbology out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
error_number = ZINT_ERROR_INVALID_OPTION;
} else {
@ -1201,7 +1221,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
symbol->symbology = BARCODE_DOTCODE;
} else if ((symbol->symbology >= 117) && (symbol->symbology <= 127)) {
if (symbol->symbology != 121) {
strcpy(symbol->errtxt, "215: Symbology out of range");
symbol->err_origin = 215;
strcpy(symbol->errtxt, _("Symbology out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
error_number = ZINT_ERROR_INVALID_OPTION;
} else {
@ -1211,7 +1232,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
}
/* Everything from 128 up is Zint-specific */
} else if (symbol->symbology > 145) {
strcpy(symbol->errtxt, "216: Symbology out of range");
symbol->err_origin = 216;
strcpy(symbol->errtxt, _("Symbology out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
error_number = ZINT_ERROR_INVALID_OPTION;
} else {
@ -1220,23 +1242,26 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
}
}
if (error_number >= ZINT_ERROR) {
error_tag(symbol->errtxt, error_number);
error_tag(symbol->errtxt, error_number, symbol->err_origin);
return error_number;
}
}
if (symbol->eci != 0) {
if (!(supports_eci(symbol->symbology))) {
strcpy(symbol->errtxt, "217: Symbology does not support ECI switching");
symbol->err_origin = 217;
strcpy(symbol->errtxt, _("Symbology does not support ECI switching"));
error_number = ZINT_ERROR_INVALID_OPTION;
} else if ((symbol->eci < 0) || (symbol->eci == 1) || (symbol->eci == 2) || (symbol->eci > 999999)) {
strcpy(symbol->errtxt, "218: Invalid ECI mode");
symbol->err_origin = 218;
strcpy(symbol->errtxt, _("Invalid ECI"));
error_number = ZINT_ERROR_INVALID_OPTION;
}
}
if ((symbol->dot_size < 0.01f) || (symbol->dot_size > 20.0f)) {
strcpy(symbol->errtxt, "221: Invalid dot size");
symbol->err_origin = 221;
strcpy(symbol->errtxt, _("Invalid dot size"));
error_number = ZINT_ERROR_INVALID_OPTION;
}
@ -1245,7 +1270,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
}
if (error_number >= ZINT_ERROR) {
error_tag(symbol->errtxt, error_number);
error_tag(symbol->errtxt, error_number, symbol->err_origin);
return error_number;
}
error_buffer = error_number;
@ -1257,7 +1282,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
if (symbol->input_mode & ESCAPE_MODE) {
error_number = escape_char_process(symbol, local_source, &in_length);
if (error_number != 0) {
error_tag(symbol->errtxt, error_number);
error_tag(symbol->errtxt, error_number, symbol->err_origin);
return error_number;
}
}
@ -1278,17 +1303,18 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
error_number = gs1_verify(symbol, local_source, in_length, reduced);
if (error_number != 0) {
if (is_composite(symbol->symbology)) {
strcat(symbol->errtxt, " in 2D component");
strcat(symbol->errtxt, _(" in 2D component"));
}
error_tag(symbol->errtxt, error_number);
error_tag(symbol->errtxt, error_number, symbol->err_origin);
return error_number;
}
ustrcpy(local_source, reduced); // Cannot contain nul char
in_length = (int) ustrlen(local_source);
}
} else {
strcpy(symbol->errtxt, "220: Selected symbology does not support GS1 mode");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 220;
strcpy(symbol->errtxt, _("Selected symbology does not support GS1 mode"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
}
@ -1305,7 +1331,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
if (error_number == 0) {
error_number = ZINT_WARN_USES_ECI;
if (!(symbol->debug & ZINT_DEBUG_TEST)) {
strcpy(symbol->errtxt, "222: Encoded data includes ECI");
symbol->err_origin = 222;
strcpy(symbol->errtxt, _("Encoded data includes ECI"));
}
if (symbol->debug & ZINT_DEBUG_PRINT) printf("Data ECI %d\n", symbol->eci);
}
@ -1314,7 +1341,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
if (error_number == 0) {
error_number = error_buffer;
}
error_tag(symbol->errtxt, error_number);
error_tag(symbol->errtxt, error_number, symbol->err_origin);
if (error_number < ZINT_ERROR) {
check_row_heights(symbol);
@ -1335,15 +1362,17 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
case 270:
break;
default:
strcpy(symbol->errtxt, "223: Invalid rotation angle");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 223;
strcpy(symbol->errtxt, _("Invalid rotation angle"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->output_options & BARCODE_DOTTY_MODE) {
if (!(is_dotty(symbol->symbology))) {
strcpy(symbol->errtxt, "224: Selected symbology cannot be rendered as dots");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 224;
strcpy(symbol->errtxt, _("Selected symbology cannot be rendered as dots"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
}
@ -1398,17 +1427,19 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
if (!(strcmp(output, "EMF"))) {
error_number = plot_vector(symbol, rotate_angle, OUT_EMF_FILE);
} else {
strcpy(symbol->errtxt, "225: Unknown output format");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 225;
strcpy(symbol->errtxt, _("Unknown output format"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
} else {
strcpy(symbol->errtxt, "226: Unknown output format");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 226;
strcpy(symbol->errtxt, _("Unknown output format"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
error_tag(symbol->errtxt, error_number);
error_tag(symbol->errtxt, error_number, symbol->err_origin);
return error_number;
}
@ -1424,21 +1455,23 @@ int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
case 270:
break;
default:
strcpy(symbol->errtxt, "228: Invalid rotation angle");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 228;
strcpy(symbol->errtxt, _("Invalid rotation angle"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->output_options & BARCODE_DOTTY_MODE) {
if (!(is_dotty(symbol->symbology))) {
strcpy(symbol->errtxt, "237: Selected symbology cannot be rendered as dots");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 237;
strcpy(symbol->errtxt, _("Selected symbology cannot be rendered as dots"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
}
error_number = plot_raster(symbol, rotate_angle, OUT_BUFFER);
error_tag(symbol->errtxt, error_number);
error_tag(symbol->errtxt, error_number, symbol->err_origin);
return error_number;
}
@ -1454,21 +1487,23 @@ int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
case 270:
break;
default:
strcpy(symbol->errtxt, "219: Invalid rotation angle");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 219;
strcpy(symbol->errtxt, _("Invalid rotation angle"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->output_options & BARCODE_DOTTY_MODE) {
if (!(is_dotty(symbol->symbology))) {
strcpy(symbol->errtxt, "238: Selected symbology cannot be rendered as dots");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
symbol->err_origin = 238;
strcpy(symbol->errtxt, _("Selected symbology cannot be rendered as dots"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION, symbol->err_origin);
return ZINT_ERROR_INVALID_OPTION;
}
}
error_number = plot_vector(symbol, rotate_angle, OUT_BUFFER);
error_tag(symbol->errtxt, error_number);
error_tag(symbol->errtxt, error_number, symbol->err_origin);
return error_number;
}
@ -1536,8 +1571,9 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
if (!symbol) return ZINT_ERROR_INVALID_DATA;
if (!filename) {
strcpy(symbol->errtxt, "239: Filename NULL");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
symbol->err_origin = 239;
strcpy(symbol->errtxt, _("Filename NULL"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA, symbol->err_origin);
return ZINT_ERROR_INVALID_DATA;
}
@ -1547,8 +1583,9 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
} else {
file = fopen(filename, "rb");
if (!file) {
sprintf(symbol->errtxt, "229: Unable to read input file (%.30s)", strerror(errno));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
symbol->err_origin = 229;
sprintf(symbol->errtxt, _("Unable to read input file (%.30s)"), strerror(errno));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA, symbol->err_origin);
return ZINT_ERROR_INVALID_DATA;
}
@ -1559,14 +1596,16 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
if (fileLen > 7900 && fileLen != LONG_MAX) { /* On many Linux distros ftell() returns LONG_MAX not -1 on error */
/* The largest amount of data that can be encoded is 7827 numeric digits in Han Xin Code */
strcpy(symbol->errtxt, "230: Input file too long");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
symbol->err_origin = 230;
strcpy(symbol->errtxt, _("Input file too long"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA, symbol->err_origin);
fclose(file);
return ZINT_ERROR_INVALID_DATA;
}
if (fileLen <= 0 || fileLen == LONG_MAX) {
strcpy(symbol->errtxt, "235: Input file empty or unseekable");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
symbol->err_origin = 235;
strcpy(symbol->errtxt, _("Input file empty or unseekable"));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA, symbol->err_origin);
fclose(file);
return ZINT_ERROR_INVALID_DATA;
}
@ -1575,8 +1614,9 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
/* Allocate memory */
buffer = (unsigned char *) malloc(fileLen * sizeof (unsigned char));
if (!buffer) {
strcpy(symbol->errtxt, "231: Internal memory error");
error_tag(symbol->errtxt, ZINT_ERROR_MEMORY);
symbol->err_origin = 231;
strcpy(symbol->errtxt, _("Internal memory error"));
error_tag(symbol->errtxt, ZINT_ERROR_MEMORY, symbol->err_origin);
if (strcmp(filename, "-")) {
fclose(file);
}
@ -1588,8 +1628,9 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
do {
n = fread(buffer + nRead, 1, fileLen - nRead, file);
if (ferror(file)) {
sprintf(symbol->errtxt, "241: Input file read error (%.30s)", strerror(errno));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
symbol->err_origin = 234;
sprintf(symbol->errtxt, _("Input file read error (%.30s)"), strerror(errno));
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA, symbol->err_origin);
if (strcmp(filename, "-")) {
fclose(file);
}

View file

@ -146,7 +146,8 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
int length = (int) in_length;
if (length > 26) {
strcpy(symbol->errtxt, "580: Input too long");
symbol->err_origin = 580;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -173,28 +174,32 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
}
if (is_sane(RUBIDIUM, (unsigned char *) local_source, length) != 0) {
strcpy(symbol->errtxt, "581: Invalid characters in input data");
symbol->err_origin = 581;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
// Format is in the range 0-4
format = ctoi(local_source[0]);
if ((format < 0) || (format > 4)) {
strcpy(symbol->errtxt, "582: Invalid format");
symbol->err_origin = 582;
strcpy(symbol->errtxt, _("Invalid format"));
return ZINT_ERROR_INVALID_DATA;
}
// Version ID is in the range 1-4
version_id = ctoi(local_source[1]) - 1;
if ((version_id < 0) || (version_id > 3)) {
strcpy(symbol->errtxt, "583: Invalid Version ID");
symbol->err_origin = 583;
strcpy(symbol->errtxt, _("Invalid Version ID"));
return ZINT_ERROR_INVALID_DATA;
}
// Class is in the range 0-9,A-E
mail_class = ctoi(local_source[2]);
if ((mail_class < 0) || (mail_class > 14)) {
strcpy(symbol->errtxt, "584: Invalid Class");
symbol->err_origin = 584;
strcpy(symbol->errtxt, _("Invalid Class"));
return ZINT_ERROR_INVALID_DATA;
}
@ -205,7 +210,8 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
supply_chain_id *= 10;
supply_chain_id += ctoi(local_source[i]);
} else {
strcpy(symbol->errtxt, "585: Invalid Supply Chain ID");
symbol->err_origin = 585;
strcpy(symbol->errtxt, _("Invalid Supply Chain ID"));
return ZINT_ERROR_INVALID_DATA;
}
}
@ -217,7 +223,8 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
item_id *= 10;
item_id += (long) ctoi(local_source[i]);
} else {
strcpy(symbol->errtxt, "586: Invalid Item ID");
symbol->err_origin = 586;
strcpy(symbol->errtxt, _("Invalid Item ID"));
return ZINT_ERROR_INVALID_DATA;
}
}
@ -271,7 +278,8 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
// Verify postcode type
if (postcode_type != 7) {
if (verify_postcode(postcode, postcode_type) != 0) {
strcpy(symbol->errtxt, "587: Invalid postcode");
symbol->err_origin = 587;
strcpy(symbol->errtxt, _("Invalid postcode"));
return ZINT_ERROR_INVALID_DATA;
}
}

View file

@ -613,7 +613,8 @@ INTERNAL int maxicode(struct zint_symbol *symbol, unsigned char local_source[],
}
if ((mode < 2) || (mode > 6)) { /* Only codes 2 to 6 supported */
strcpy(symbol->errtxt, "550: Invalid Maxicode Mode");
symbol->err_origin = 550;
strcpy(symbol->errtxt, _("Invalid Maxicode Mode"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -624,13 +625,15 @@ INTERNAL int maxicode(struct zint_symbol *symbol, unsigned char local_source[],
lp = strlen(symbol->primary);
}
if (lp != 15) {
strcpy(symbol->errtxt, "551: Invalid Primary Message");
symbol->err_origin = 551;
strcpy(symbol->errtxt, _("Invalid Primary Message"));
return ZINT_ERROR_INVALID_DATA;
}
for (i = 9; i < 15; i++) { /* check that country code and service are numeric */
if ((symbol->primary[i] < '0') || (symbol->primary[i] > '9')) {
strcpy(symbol->errtxt, "552: Invalid Primary Message");
symbol->err_origin = 552;
strcpy(symbol->errtxt, _("Invalid Primary Message"));
return ZINT_ERROR_INVALID_DATA;
}
}
@ -673,7 +676,8 @@ INTERNAL int maxicode(struct zint_symbol *symbol, unsigned char local_source[],
i = maxi_text_process(maxi_codeword, mode, local_source, length, symbol->eci);
if (i == ZINT_ERROR_TOO_LONG) {
strcpy(symbol->errtxt, "553: Input data too long");
symbol->err_origin = 553;
strcpy(symbol->errtxt, _("Input too long"));
return i;
}

View file

@ -67,19 +67,22 @@ INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int
char dest[64]; /* 17 * 2 + 1 */
if (length > 6) {
strcpy(symbol->errtxt, "350: Input too long");
symbol->err_origin = 350;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "351: Invalid characters in data");
symbol->err_origin = 351;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
tester = atoi((char*) source);
if ((tester < 3) || (tester > 131070)) {
strcpy(symbol->errtxt, "352: Data out of range");
symbol->err_origin = 352;
strcpy(symbol->errtxt, _("Data out of range"));
return ZINT_ERROR_INVALID_DATA;
}
@ -122,7 +125,8 @@ static int pharma_two_calc(struct zint_symbol *symbol, unsigned char source[], c
tester = atoi((char*) source);
if ((tester < 4) || (tester > 64570080)) {
strcpy(symbol->errtxt, "353: Data out of range");
symbol->err_origin = 353;
strcpy(symbol->errtxt, _("Data out of range"));
return ZINT_ERROR_INVALID_DATA;
}
error_number = 0;
@ -162,12 +166,14 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
strcpy(height_pattern, "");
if (length > 8) {
strcpy(symbol->errtxt, "354: Input too long");
symbol->err_origin = 354;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "355: Invalid characters in data");
symbol->err_origin = 355;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
error_number = pharma_two_calc(symbol, source, height_pattern);
@ -203,13 +209,15 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
strcpy(dest, "");
if (length > 60) { /* No stack smashing please */
strcpy(symbol->errtxt, "356: Input too long");
symbol->err_origin = 356;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
/* BS EN 798:1995 4.2 "'Codabar' symbols shall consist of ... b) start character;
* c) one or more symbol characters representing data ... d) stop character ..." */
if (length < 3) {
strcpy(symbol->errtxt, "362: Input too short");
symbol->err_origin = 362;
strcpy(symbol->errtxt, _("Input too short"));
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
@ -217,19 +225,22 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
/* Codabar must begin and end with the characters A, B, C or D */
if ((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C')
&& (source[0] != 'D')) {
strcpy(symbol->errtxt, "358: Does not begin with \"A\", \"B\", \"C\" or \"D\"");
symbol->err_origin = 358;
strcpy(symbol->errtxt, _("Does not begin with \"A\", \"B\", \"C\" or \"D\""));
return ZINT_ERROR_INVALID_DATA;
}
if ((source[length - 1] != 'A') && (source[length - 1] != 'B') &&
(source[length - 1] != 'C') && (source[length - 1] != 'D')) {
strcpy(symbol->errtxt, "359: Does not end with \"A\", \"B\", \"C\" or \"D\"");
symbol->err_origin = 359;
strcpy(symbol->errtxt, _("Does not end with \"A\", \"B\", \"C\" or \"D\""));
return ZINT_ERROR_INVALID_DATA;
}
/* And must not use A, B, C or D otherwise (BS EN 798:1995 4.3.2) */
error_number = is_sane(CALCIUM_INNER, source + 1, length - 2);
if (error_number) {
strcpy(symbol->errtxt, "363: Cannot contain \"A\", \"B\", \"C\" or \"D\"");
symbol->err_origin = 363;
strcpy(symbol->errtxt, _("Can't contain \"A\", \"B\", \"C\" or \"D\""));
return error_number;
}
@ -270,12 +281,14 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
/* Validate the input */
if (length > 8) {
strcpy(symbol->errtxt, "360: Input too long");
symbol->err_origin = 360;
strcpy(symbol->errtxt, "Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "361: Invalid characters in data");
symbol->err_origin = 361;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}

View file

@ -40,11 +40,13 @@ INTERNAL int output_check_colour_options(struct zint_symbol *symbol) {
int error_number;
if ((strlen(symbol->fgcolour) != 6) && (strlen(symbol->fgcolour) != 8)) {
strcpy(symbol->errtxt, "651: Malformed foreground colour target");
symbol->err_origin = 651;
strcpy(symbol->errtxt, _("Malformed foreground colour target"));
return ZINT_ERROR_INVALID_OPTION;
}
if ((strlen(symbol->bgcolour) != 6) && (strlen(symbol->bgcolour) != 8)) {
strcpy(symbol->errtxt, "652: Malformed background colour target");
symbol->err_origin = 652;
strcpy(symbol->errtxt, _("Malformed background colour target"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -53,13 +55,15 @@ INTERNAL int output_check_colour_options(struct zint_symbol *symbol) {
error_number = is_sane(SSET, (unsigned char *) symbol->fgcolour, strlen(symbol->fgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "653: Malformed foreground colour target");
symbol->err_origin = 653;
strcpy(symbol->errtxt, _("Malformed foreground colour target"));
return ZINT_ERROR_INVALID_OPTION;
}
error_number = is_sane(SSET, (unsigned char *) symbol->bgcolour, strlen(symbol->bgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "654: Malformed background colour target");
symbol->err_origin = 654;
strcpy(symbol->errtxt, _("Malformed background colour target"));
return ZINT_ERROR_INVALID_OPTION;
}

View file

@ -103,14 +103,16 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
if (symbol->output_options & BARCODE_STDOUT) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "620: Can't open output file");
symbol->err_origin = 620;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
#endif
pcx_file = stdout;
} else {
if (!(pcx_file = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "621: Can't open output file");
symbol->err_origin = 621;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
}

View file

@ -511,7 +511,8 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
int debug = symbol->debug & ZINT_DEBUG_PRINT;
if (length > PDF417_MAX_LEN) {
strcpy(symbol->errtxt, "463: Input string too long");
symbol->err_origin = 463;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -563,7 +564,8 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
if (symbol->eci != 0) {
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "472: Invalid ECI");
symbol->err_origin = 472;
strcpy(symbol->errtxt, _("Invalid ECI"));
return ZINT_ERROR_INVALID_OPTION;
}
/* Encoding ECI assignment number, according to Table 8 */
@ -632,7 +634,8 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
longueur = mclength;
if (longueur + k > 928) {
/* Enforce maximum codeword limit */
strcpy(symbol->errtxt, "464: Input string too long");
symbol->err_origin = 464;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -646,7 +649,8 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
symbol->option_2 = symbol->option_2 + 1;
if (((longueur + k) / symbol->option_2) > 90) {
strcpy(symbol->errtxt, "465: Data too long for specified number of columns");
symbol->err_origin = 465;
strcpy(symbol->errtxt, _("Data too long for specified number of columns"));
return ZINT_ERROR_TOO_LONG;
}
}
@ -801,7 +805,8 @@ INTERNAL int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int l
error_number = 0;
if ((symbol->option_1 < -1) || (symbol->option_1 > 8)) {
strcpy(symbol->errtxt, "460: Security value out of range");
symbol->err_origin = 460;
strcpy(symbol->errtxt, _("Security value out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
} else {
@ -810,7 +815,8 @@ INTERNAL int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int l
}
}
if ((symbol->option_2 < 0) || (symbol->option_2 > 30)) {
strcpy(symbol->errtxt, "461: Number of columns out of range");
symbol->err_origin = 461;
strcpy(symbol->errtxt, _("Number of columns out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
} else {
@ -842,7 +848,8 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
int debug = symbol->debug & ZINT_DEBUG_PRINT;
if (length > MICRO_PDF417_MAX_LEN) {
strcpy(symbol->errtxt, "474: Input data too long");
symbol->err_origin = 474;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -896,7 +903,8 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
}
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "473: Invalid ECI");
symbol->err_origin = 473;
strcpy(symbol->errtxt, _("Invalid ECI"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -942,11 +950,13 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
/* This is where it all changes! */
if (mclength > 126) {
strcpy(symbol->errtxt, "467: Input data too long");
symbol->err_origin = 467;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
if (symbol->option_2 > 4) {
strcpy(symbol->errtxt, "468: Specified width out of range");
symbol->err_origin = 468;
strcpy(symbol->errtxt, _("Specified width out of range"));
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
} else {
@ -969,7 +979,8 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
if ((symbol->option_2 == 1) && (mclength > 20)) {
/* the user specified 1 column but the data doesn't fit - go to automatic */
strcpy(symbol->errtxt, "469: Specified symbol size too small for data");
symbol->err_origin = 469;
strcpy(symbol->errtxt, _("Specified symbol size too small for data"));
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
} else {
@ -980,7 +991,8 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
if ((symbol->option_2 == 2) && (mclength > 37)) {
/* the user specified 2 columns but the data doesn't fit - go to automatic */
strcpy(symbol->errtxt, "470: Specified symbol size too small for data");
symbol->err_origin = 470;
strcpy(symbol->errtxt, _("Specified symbol size too small for data"));
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
} else {
@ -991,7 +1003,8 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
if ((symbol->option_2 == 3) && (mclength > 82)) {
/* the user specified 3 columns but the data doesn't fit - go to automatic */
strcpy(symbol->errtxt, "471: Specified symbol size too small for data");
symbol->err_origin = 471;
strcpy(symbol->errtxt, _("Specified symbol size too small for data"));
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
} else {

View file

@ -57,12 +57,14 @@ INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], const s
int error_number;
if (length > 65) {
strcpy(symbol->errtxt, "370: Input too long");
symbol->err_origin = 370;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "371: Invalid characters in data");
symbol->err_origin = 371;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
checkptr = (unsigned char *) calloc(1, length * 4 + 8);
@ -116,7 +118,8 @@ static int msi_plessey(struct zint_symbol *symbol, unsigned char source[], const
char dest[512]; /* 2 + 55 * 8 + 3 + 1 ~ 512 */
if (length > 55) {
strcpy(symbol->errtxt, "372: Input too long");
symbol->err_origin = 372;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -148,7 +151,8 @@ static int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[],
error_number = 0;
if (length > 18) {
strcpy(symbol->errtxt, "373: Input too long");
symbol->err_origin = 373;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -216,7 +220,8 @@ static int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[
if (src_len > 18) {
/* No Entry Stack Smashers! limit because of str->number conversion*/
strcpy(symbol->errtxt, "374: Input too long");
symbol->err_origin = 374;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -318,7 +323,8 @@ static int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[],
error_number = 0;
if (src_len > 55) {
strcpy(symbol->errtxt, "375: Input too long");
symbol->err_origin = 375;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -382,7 +388,8 @@ static int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[
error_number = 0;
if (src_len > 18) {
strcpy(symbol->errtxt, "376: Input too long");
symbol->err_origin = 376;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -468,7 +475,8 @@ INTERNAL int msi_handle(struct zint_symbol *symbol, unsigned char source[], int
error_number = is_sane(NEON, source, length);
if (error_number != 0) {
strcpy(symbol->errtxt, "377: Invalid characters in input data");
symbol->err_origin = 377;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}

View file

@ -58,14 +58,14 @@ struct mainprog_info_type {
static void writepng_error_handler(png_structp png_ptr, png_const_charp msg) {
struct mainprog_info_type *graphic;
fprintf(stderr, "writepng libpng error: %s (F30)\n", msg);
fprintf(stderr, _("writepng libpng error: %s (F30)\n"), msg);
fflush(stderr);
graphic = (struct mainprog_info_type*) png_get_error_ptr(png_ptr);
if (graphic == NULL) {
/* we are completely hosed now */
fprintf(stderr,
"writepng severe error: jmpbuf not recoverable; terminating. (F31)\n");
_("writepng severe error: jmpbuf not recoverable; terminating. (F31)\n"));
fflush(stderr);
return;
}
@ -138,14 +138,16 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
if (symbol->output_options & BARCODE_STDOUT) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "631: Can't open output file");
symbol->err_origin = 631;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
#endif
graphic->outfile = stdout;
} else {
if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "632: Can't open output file");
symbol->err_origin = 632;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
}
@ -153,21 +155,24 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
/* Set up error handling routine as proc() above */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic, writepng_error_handler, NULL);
if (!png_ptr) {
strcpy(symbol->errtxt, "633: Out of memory");
symbol->err_origin = 633;
strcpy(symbol->errtxt, _("Out of memory"));
return ZINT_ERROR_MEMORY;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_write_struct(&png_ptr, NULL);
strcpy(symbol->errtxt, "634: Out of memory");
symbol->err_origin = 634;
strcpy(symbol->errtxt, _("Out of memory"));
return ZINT_ERROR_MEMORY;
}
/* catch jumping here */
if (setjmp(graphic->jmpbuf)) {
png_destroy_write_struct(&png_ptr, &info_ptr);
strcpy(symbol->errtxt, "635: libpng error occurred");
symbol->err_origin = 635;
strcpy(symbol->errtxt, _("libpng error occurred"));
return ZINT_ERROR_MEMORY;
}

548
backend/po/libzint.pot Normal file
View file

@ -0,0 +1,548 @@
# Zint barcode encoding library
# Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
# This file is distributed under the same license as the libzint package.
# Robin Stuart <rstuart114@gmail.com>, 2020.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: LIBZINT 2.9.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-07 19:17+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: library.c:1306
msgid " in 2D component"
msgstr ""
#: composite.c:1419 composite.c:1576
msgid " in linear component"
msgstr ""
#: composite.c:1403
msgid "2D component input data too long"
msgstr ""
#: upcean.c:964
msgid "Add-on input wrong length"
msgstr ""
#: medical.c:243
msgid "Can't contain \"A\", \"B\", \"C\" or \"D\""
msgstr ""
#: aztec.c:1007 code16k.c:318 dmatrix.c:574
msgid "Can't encode in GS1 and Reader Initialisation mode at the same time"
msgstr ""
#: emf.c:677 gif.c:318 gif.c:326 library.c:218 png.c:142 png.c:150 ps.c:173
#: svg.c:197 tif.c:132 tif.c:140 bmp.c:181 bmp.c:191 pcx.c:107 pcx.c:115
msgid "Can't open output file"
msgstr ""
#: library.c:1135
msgid "Codabar 18 not supported"
msgstr ""
#: codablock.c:674
msgid "Columns parameter not 0 or in range 9 to 67"
msgstr ""
#: gs1.c:120
msgid "Control characters are not supported by GS1"
msgstr ""
#: common.c:323
msgid "Corrupt Unicode data"
msgstr ""
#: library.c:1031
msgid "Corrupt Unicode escape character in input data"
msgstr ""
#: library.c:1014
msgid "Corrupt escape character in input data"
msgstr ""
#: gs1.c:125
msgid "DEL characters are not supported by GS1"
msgstr ""
#: gs1.c:132
msgid "Data does not start with an AI"
msgstr ""
#: medical.c:85 medical.c:129
msgid "Data out of range"
msgstr ""
#: library.c:273
msgid "Data too long for HIBC LIC"
msgstr ""
#: aztec.c:1307
msgid "Data too long for reader initialisation symbol"
msgstr ""
#: ultra.c:940
msgid "Data too long for selected error correction capacity"
msgstr ""
#: aztec.c:1288
msgid "Data too long for specified Aztec Code symbol size"
msgstr ""
#: pdf417.c:653
msgid "Data too long for specified number of columns"
msgstr ""
#: medical.c:229
msgid "Does not begin with \"A\", \"B\", \"C\" or \"D\""
msgstr ""
#: medical.c:235
msgid "Does not end with \"A\", \"B\", \"C\" or \"D\""
msgstr ""
#: ultra.c:889
msgid "ECI value not supported by Ultracode"
msgstr ""
#: gs1.c:244
msgid "Empty data field in input data"
msgstr ""
#: library.c:1335
msgid "Encoded data includes ECI"
msgstr ""
#: qr.c:2380
msgid "Error correction level H not available"
msgstr ""
#: qr.c:2932
msgid "Error correction level L not available in rMQR"
msgstr ""
#: qr.c:2938
msgid "Error correction level Q not available in rMQR"
msgstr ""
#: qr.c:2391
msgid "Error correction level Q requires Version M4"
msgstr ""
#: gs1.c:110
msgid "Extended ASCII characters are not supported by GS1"
msgstr ""
#: library.c:1575
msgid "Filename NULL"
msgstr ""
#: gs1.c:185
msgid "Found nested brackets in input data"
msgstr ""
#: library.c:1160
msgid "General Parcel Code not supported"
msgstr ""
#: library.c:1024
msgid "Incomplete Unicode escape character in input data"
msgstr ""
#: library.c:955 library.c:997
msgid "Incomplete escape character in input data"
msgstr ""
#: upcean.c:581 upcean.c:599
msgid "Incorrect ISBN check"
msgstr ""
#: upcean.c:599
msgid "Incorrect SBN check"
msgstr ""
#: library.c:1086
msgid "Input data NULL"
msgstr ""
#: library.c:1607
msgid "Input file empty or unseekable"
msgstr ""
#: library.c:1632
#, c-format
msgid "Input file read error (%.30s)"
msgstr ""
#: library.c:1600
msgid "Input file too long"
msgstr ""
#: rss.c:635
msgid "Input out of range"
msgstr ""
#: aztec.c:1587 aztec.c:1610
msgid "Input too large"
msgstr ""
#: 2of5.c:68 2of5.c:101 2of5.c:133 2of5.c:166 2of5.c:204 2of5.c:264 2of5.c:317
#: codablock.c:736 code16k.c:139 code16k.c:285 code49.c:221 imail.c:261
#: maxicode.c:680 pdf417.c:515 pdf417.c:638 pdf417.c:852 pdf417.c:954 rss.c:287
#: rss.c:613 rss.c:1183 upcean.c:762 auspost.c:157 code128.c:320 code128.c:484
#: code128.c:726 code128.c:858 code128.c:1038 code1.c:1019 code1.c:1165
#: code1.c:1213 code1.c:1315 code1.c:1327 code1.c:1423 code.c:115 code.c:234
#: code.c:238 code.c:242 code.c:387 code.c:636 composite.c:1305 dmatrix.c:976
#: dmatrix.c:1254 gridmtx.c:983 gridmtx.c:1067 mailmark.c:150 medical.c:71
#: medical.c:170 medical.c:213 plessey.c:61 plessey.c:122 plessey.c:155
#: plessey.c:224 plessey.c:327 plessey.c:392 postal.c:221 postal.c:262
#: postal.c:342 postal.c:388 postal.c:437 postal.c:493 postal.c:528 qr.c:2371
#: qr.c:2467 qr.c:2475 qr.c:2487 telepen.c:71 telepen.c:120
msgid "Input too long"
msgstr ""
#: composite.c:1281 composite.c:1324
msgid "Input too long for selected 2D component"
msgstr ""
#: aztec.c:1116 hanxin.c:1484 qr.c:1596 qr.c:2949
msgid "Input too long for selected error correction level"
msgstr ""
#: code1.c:1439 dmatrix.c:1242 gridmtx.c:1010 hanxin.c:1498 qr.c:1685 qr.c:2510
#: qr.c:2716 qr.c:3030
msgid "Input too long for selected symbol size"
msgstr ""
#: aztec.c:1017
msgid "Input too long or too many extended ASCII characters"
msgstr ""
#: medical.c:220
msgid "Input too short"
msgstr ""
#: 2of5.c:355 upcean.c:566 upcean.c:846 upcean.c:879 upcean.c:889 upcean.c:908
#: upcean.c:918 upcean.c:937 auspost.c:145 code128.c:1081 code128.c:1129
#: code.c:338 postal.c:93 postal.c:157
msgid "Input wrong length"
msgstr ""
#: composite.c:1460
msgid "Input wrong length in linear component"
msgstr ""
#: code.c:749
msgid "Input wrong length, 17 characters required"
msgstr ""
#: raster.c:131
msgid "Insufficient memory for alphamap buffer"
msgstr ""
#: raster.c:123
msgid "Insufficient memory for bitmap buffer"
msgstr ""
#: raster.c:178 raster.c:675 raster.c:834 raster.c:1139
msgid "Insufficient memory for pixel buffer"
msgstr ""
#: library.c:1618
msgid "Internal memory error"
msgstr ""
#: gs1.c:192
msgid "Invalid AI in input data (AI too long)"
msgstr ""
#: gs1.c:199
msgid "Invalid AI in input data (AI too short)"
msgstr ""
#: gs1.c:206
msgid "Invalid AI in input data (non-numeric characters in AI)"
msgstr ""
#: gs1.c:692
msgid "Invalid AI value "
msgstr ""
#: aztec.c:1213
msgid "Invalid Aztec Code size"
msgstr ""
#: imail.c:308
msgid "Invalid Barcode Identifier"
msgstr ""
#: mailmark.c:202
msgid "Invalid Class"
msgstr ""
#: code128.c:1146
msgid "Invalid DPD identifier"
msgstr ""
#: dotcode.c:1329 library.c:1257 pdf417.c:568 pdf417.c:907 gridmtx.c:976
msgid "Invalid ECI"
msgstr ""
#: upcean.c:574
msgid "Invalid ISBN"
msgstr ""
#: mailmark.c:227
msgid "Invalid Item ID"
msgstr ""
#: maxicode.c:617
msgid "Invalid Maxicode Mode"
msgstr ""
#: code.c:367
msgid "Invalid PZN Data"
msgstr ""
#: maxicode.c:629 maxicode.c:636
msgid "Invalid Primary Message"
msgstr ""
#: mailmark.c:214
msgid "Invalid Supply Chain ID"
msgstr ""
#: upcean.c:243 upcean.c:254 upcean.c:270
msgid "Invalid UPC-E data"
msgstr ""
#: mailmark.c:194
msgid "Invalid Version ID"
msgstr ""
#: imail.c:315
msgid "Invalid ZIP code"
msgstr ""
#: upcean.c:791
msgid "Invalid add-on data"
msgstr ""
#: auspost.c:183
msgid "Invalid character in DPID"
msgstr ""
#: 2of5.c:74 2of5.c:107 2of5.c:139 2of5.c:172 2of5.c:210 2of5.c:271 2of5.c:323
#: 2of5.c:361 aztec.c:1593 code49.c:69 gb2312.c:1567 imail.c:267 library.c:280
#: library.c:749 rss.c:293 rss.c:619 rss.c:962 upcean.c:559 upcean.c:770
#: upcean.c:777 auspost.c:117 auspost.c:150 code128.c:1045 code128.c:1088
#: code128.c:1140 code.c:121 code.c:249 code.c:344 code.c:396 code.c:439
#: code.c:642 code.c:756 composite.c:1262 gb18030.c:2894 gridmtx.c:959
#: hanxin.c:1414 mailmark.c:178 medical.c:77 medical.c:176 medical.c:291
#: plessey.c:67 plessey.c:479 postal.c:99 postal.c:163 postal.c:227
#: postal.c:285 postal.c:349 postal.c:395 postal.c:445 postal.c:499
#: postal.c:539 qr.c:1561 qr.c:2700 sjis.c:1535 telepen.c:81 telepen.c:128
msgid "Invalid character in data"
msgstr ""
#: rss.c:300 rss.c:626 upcean.c:144 upcean.c:314 upcean.c:434 upcean.c:493
#: code.c:800
msgid "Invalid check digit"
msgstr ""
#: code.c:127
msgid "Invalid check digit version"
msgstr ""
#: gs1.c:680
msgid "Invalid data length for AI "
msgstr ""
#: library.c:1264
msgid "Invalid dot size"
msgstr ""
#: aztec.c:1023
msgid "Invalid error correction level - using default instead"
msgstr ""
#: mailmark.c:186
msgid "Invalid format"
msgstr ""
#: code1.c:1218
msgid "Invalid input data (Version S encodes numeric input only)"
msgstr ""
#: imail.c:303
msgid "Invalid length tracking code"
msgstr ""
#: composite.c:1411
msgid "Invalid mode (CC-C only valid with GS1-128 linear component)"
msgstr ""
#: telepen.c:146
msgid "Invalid position of X in Telepen data"
msgstr ""
#: mailmark.c:282
msgid "Invalid postcode"
msgstr ""
#: qr.c:2955
msgid "Invalid rMQR symbol size"
msgstr ""
#: library.c:1366 library.c:1459 library.c:1491
msgid "Invalid rotation angle"
msgstr ""
#: code1.c:1199
msgid "Invalid symbol size"
msgstr ""
#: gs1.c:178
msgid "Malformed AI in input data (brackets don't match)"
msgstr ""
#: output.c:49 output.c:66
msgid "Malformed background colour target"
msgstr ""
#: output.c:44 output.c:59
msgid "Malformed foreground colour target"
msgstr ""
#: gs1.c:115
msgid "NUL characters not permitted in GS1 mode"
msgstr ""
#: library.c:1095
msgid "No input data"
msgstr ""
#: composite.c:1397
msgid "No primary (linear) message in 2D composite"
msgstr ""
#: pdf417.c:819
msgid "Number of columns out of range"
msgstr ""
#: dmatrix.c:1362
msgid "Older Data Matrix standards are no longer supported"
msgstr ""
#: png.c:159 png.c:167 bmp.c:73
msgid "Out of memory"
msgstr ""
#: tif.c:123
msgid "Output file size too big"
msgstr ""
#: raster.c:1172
msgid "PNG format disabled at compile time"
msgstr ""
#: codablock.c:667
msgid "Rows parameter not in range 0 to 44"
msgstr ""
#: pdf417.c:809
msgid "Security value out of range"
msgstr ""
#: library.c:1374 library.c:1467 library.c:1499
msgid "Selected symbology cannot be rendered as dots"
msgstr ""
#: library.c:1316
msgid "Selected symbology does not support GS1 mode"
msgstr ""
#: dotcode.c:1419
msgid "Specified symbol size has a dimension which is too small"
msgstr ""
#: dotcode.c:1413
msgid "Specified symbol size is too large"
msgstr ""
#: pdf417.c:983 pdf417.c:995 pdf417.c:1007
msgid "Specified symbol size too small for data"
msgstr ""
#: pdf417.c:959
msgid "Specified width out of range"
msgstr ""
#: library.c:1253
msgid "Symbology does not support ECI switching"
msgstr ""
#: library.c:1117 library.c:1181 library.c:1190 library.c:1213 library.c:1225
#: library.c:1236
msgid "Symbology out of range"
msgstr ""
#: library.c:1146
msgid "UPCD1 not supported"
msgstr ""
#: qr.c:2693
msgid "UPNQR does not support GS-1 encoding"
msgstr ""
#: library.c:1587
#, c-format
msgid "Unable to read input file (%.30s)"
msgstr ""
#: common.c:328
msgid "Unicode sequences of more than 3 bytes not supported"
msgstr ""
#: library.c:1431 library.c:1437
msgid "Unknown output format"
msgstr ""
#: gif.c:420
msgid "Unknown pixel colour"
msgstr ""
#: library.c:1054
msgid "Unrecognised escape character in input data"
msgstr ""
#: code.c:703
msgid "Value out of range"
msgstr ""
#: qr.c:2386
msgid "Version M1 supports error correction level L only"
msgstr ""
#: png.c:175
msgid "libpng error occurred"
msgstr ""
#: png.c:61
#, c-format
msgid "writepng libpng error: %s (F30)\n"
msgstr ""
#: png.c:68
#, c-format
msgid "writepng severe error: jmpbuf not recoverable; terminating. (F31)\n"
msgstr ""

View file

@ -89,12 +89,14 @@ static int postnet(struct zint_symbol *symbol, unsigned char source[], char dest
int error_number;
if (length != 5 && length != 9 && length != 11) {
strcpy(symbol->errtxt, "480: Input wrong length");
symbol->err_origin = 480;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "481: Invalid characters in data");
symbol->err_origin = 481;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
sum = 0;
@ -151,12 +153,14 @@ static int planet(struct zint_symbol *symbol, unsigned char source[], char dest[
int error_number;
if (length != 11 && length != 13) {
strcpy(symbol->errtxt, "482: Input wrong length");
symbol->err_origin = 482;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "483: Invalid characters in data");
symbol->err_origin = 483;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
sum = 0;
@ -213,12 +217,14 @@ INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int
char localstr[8], dest[80];
if (length > 6) {
strcpy(symbol->errtxt, "484: Input too long");
symbol->err_origin = 484;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "485: Invalid characters in data");
symbol->err_origin = 485;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
zeroes = 6 - length;
@ -252,7 +258,8 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
char dest[16] = {0};
if (length > 1) {
strcpy(symbol->errtxt, "486: Input too long");
symbol->err_origin = 486;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -274,7 +281,8 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
strcpy(dest, "1111131311111");
break;
default:
strcpy(symbol->errtxt, "487: Invalid characters in data");
symbol->err_origin = 487;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
break;
}
@ -330,13 +338,15 @@ INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int
strcpy(height_pattern, "");
if (length > 50) {
strcpy(symbol->errtxt, "488: Input too long");
symbol->err_origin = 488;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "489: Invalid characters in data");
symbol->err_origin = 489;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
/*check = */rm4scc(source, height_pattern, length);
@ -374,13 +384,15 @@ INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int le
strcpy(height_pattern, "");
if (length > 18) {
strcpy(symbol->errtxt, "490: Input too long");
symbol->err_origin = 490;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "491: Invalid characters in data");
symbol->err_origin = 491;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -421,14 +433,16 @@ INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int l
strcpy(height_pattern, "");
if (length > 50) {
strcpy(symbol->errtxt, "492: Input too long");
symbol->err_origin = 492;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
to_upper((unsigned char*) source);
error_number = is_sane(DAFTSET, (unsigned char*) source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "493: Invalid characters in data");
symbol->err_origin = 493;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -475,12 +489,14 @@ INTERNAL int flattermarken(struct zint_symbol *symbol, unsigned char source[], i
char dest[512]; /* 90 * 4 + 1 ~ */
if (length > 90) {
strcpy(symbol->errtxt, "494: Input too long");
symbol->err_origin = 494;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "495: Invalid characters in data");
symbol->err_origin = 495;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
*dest = '\0';
@ -508,7 +524,8 @@ INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int
#endif
if (length > 20) {
strcpy(symbol->errtxt, "496: Input too long");
symbol->err_origin = 496;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -518,7 +535,8 @@ INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int
to_upper((unsigned char*) local_source);
if (is_sane(SHKASUTSET, (unsigned char*) local_source, length) == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "497: Invalid characters in data");
symbol->err_origin = 497;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
memset(inter, 'd', 20); /* Pad character CC4 */

View file

@ -169,7 +169,8 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
feps = fopen(symbol->outfile, "w");
}
if (feps == NULL) {
strcpy(symbol->errtxt, "645: Could not open output file");
symbol->err_origin = 645;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}

View file

@ -1557,7 +1557,8 @@ INTERNAL int qr_code(struct zint_symbol *symbol, const unsigned char source[], s
if (error_number == 0) {
done = 1;
} else if (symbol->eci && symbol->eci <= 899) {
strcpy(symbol->errtxt, "575: Invalid characters in input data");
symbol->err_origin = 575;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
}
@ -1591,7 +1592,8 @@ INTERNAL int qr_code(struct zint_symbol *symbol, const unsigned char source[], s
}
if (est_binlen > (8 * max_cw)) {
strcpy(symbol->errtxt, "561: Input too long for selected error correction level");
symbol->err_origin = 561;
strcpy(symbol->errtxt, _("Input too long for selected error correction level"));
return ZINT_ERROR_TOO_LONG;
}
@ -1679,7 +1681,8 @@ INTERNAL int qr_code(struct zint_symbol *symbol, const unsigned char source[], s
}
if (symbol->option_2 < version) {
strcpy(symbol->errtxt, "569: Input too long for selected symbol size");
symbol->err_origin = 569;
strcpy(symbol->errtxt, _("Input too long for selected symbol size"));
return ZINT_ERROR_TOO_LONG;
}
}
@ -2364,7 +2367,8 @@ INTERNAL int microqr(struct zint_symbol *symbol, const unsigned char source[], s
#endif
if (length > 35) {
strcpy(symbol->errtxt, "562: Input data too long");
symbol->err_origin = 562;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
@ -2372,16 +2376,19 @@ INTERNAL int microqr(struct zint_symbol *symbol, const unsigned char source[], s
ecc_level = LEVEL_L;
if (symbol->option_1 >= 1 && symbol->option_1 <= 4) {
if (symbol->option_1 == 4) {
strcpy(symbol->errtxt, "566: Error correction level H not available");
symbol->err_origin = 566;
strcpy(symbol->errtxt, _("Error correction level H not available"));
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->option_2 >= 1 && symbol->option_2 <= 4) {
if (symbol->option_2 == 1 && symbol->option_1 != 1) {
strcpy(symbol->errtxt, "574: Version M1 supports error correction level L only");
symbol->err_origin = 574;
strcpy(symbol->errtxt, _("Version M1 supports error correction level L only"));
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->option_2 != 4 && symbol->option_1 == 3) {
strcpy(symbol->errtxt, "575: Error correction level Q requires Version M4");
symbol->err_origin = 575;
strcpy(symbol->errtxt, _("Error correction level Q requires Version M4"));
return ZINT_ERROR_INVALID_OPTION;
}
}
@ -2456,14 +2463,16 @@ INTERNAL int microqr(struct zint_symbol *symbol, const unsigned char source[], s
version_valid[2] = 0;
}
if (binary_count[3] > 128) {
strcpy(symbol->errtxt, "565: Input data too long");
symbol->err_origin = 565;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
/* Eliminate possible versions depending on binary length and error correction level specified */
if (ecc_level == LEVEL_Q) {
if (binary_count[3] > 80) {
strcpy(symbol->errtxt, "567: Input data too long");
symbol->err_origin = 567;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
} else if (ecc_level == LEVEL_M) {
@ -2474,7 +2483,8 @@ INTERNAL int microqr(struct zint_symbol *symbol, const unsigned char source[], s
version_valid[2] = 0;
}
if (binary_count[3] > 112) {
strcpy(symbol->errtxt, "568: Input data too long");
symbol->err_origin = 568;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
}
@ -2496,7 +2506,8 @@ INTERNAL int microqr(struct zint_symbol *symbol, const unsigned char source[], s
if (symbol->option_2 - 1 >= autoversion) {
version = symbol->option_2 - 1;
} else {
strcpy(symbol->errtxt, "570: Input too long for selected symbol size");
symbol->err_origin = 570;
strcpy(symbol->errtxt, _("Input too long for selected symbol size"));
return ZINT_ERROR_TOO_LONG;
}
}
@ -2678,13 +2689,15 @@ INTERNAL int upnqr(struct zint_symbol *symbol, const unsigned char source[], siz
}
break;
case GS1_MODE:
strcpy(symbol->errtxt, "571: UPNQR does not support GS-1 encoding");
symbol->err_origin = 571;
strcpy(symbol->errtxt, _("UPNQR does not support GS-1 encoding"));
return ZINT_ERROR_INVALID_OPTION;
break;
case UNICODE_MODE:
error_number = utf_to_eci(4, source, preprocessed, &length);
if (error_number != 0) {
strcpy(symbol->errtxt, "572: Invalid characters in input data");
symbol->err_origin = 572;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
for (i = 0; i < (int) length; i++) {
@ -2699,7 +2712,8 @@ INTERNAL int upnqr(struct zint_symbol *symbol, const unsigned char source[], siz
ecc_level = LEVEL_M;
if (est_binlen > 3320) {
strcpy(symbol->errtxt, "573: Input too long for selected symbol");
symbol->err_origin = 573;
strcpy(symbol->errtxt, _("Input too long for selected symbol size"));
return ZINT_ERROR_TOO_LONG;
}
@ -2914,12 +2928,14 @@ INTERNAL int rmqr(struct zint_symbol *symbol, const unsigned char source[], size
ecc_level = LEVEL_M;
max_cw = 152;
if (symbol->option_1 == 1) {
strcpy(symbol->errtxt, "576: Error correction level L not available in rMQR");
symbol->err_origin = 576;
strcpy(symbol->errtxt, _("Error correction level L not available in rMQR"));
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->option_1 == 3) {
strcpy(symbol->errtxt, "577: Error correction level Q not available in rMQR");
symbol->err_origin = 577;
strcpy(symbol->errtxt, _("Error correction level Q not available in rMQR"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -2929,12 +2945,14 @@ INTERNAL int rmqr(struct zint_symbol *symbol, const unsigned char source[], size
}
if (est_binlen > (8 * max_cw)) {
strcpy(symbol->errtxt, "578: Input too long for selected error correction level");
symbol->err_origin = 578;
strcpy(symbol->errtxt, _("Input too long for selected error correction level"));
return ZINT_ERROR_TOO_LONG;
}
if ((symbol->option_2 < 0) || (symbol->option_2 > 38)) {
strcpy(symbol->errtxt, "579: Invalid rMQR symbol size");
symbol->err_origin = 579;
strcpy(symbol->errtxt, _("Invalid rMQR symbol size"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -3008,7 +3026,8 @@ INTERNAL int rmqr(struct zint_symbol *symbol, const unsigned char source[], size
if (est_binlen > (target_codewords * 8)) {
// User has selected a symbol too small for the data
strcpy(symbol->errtxt, "580: Input too long for selected symbol size");
symbol->err_origin = 580;
strcpy(symbol->errtxt, _("Input too long for selected symbol size"));
return ZINT_ERROR_TOO_LONG;
}

View file

@ -119,14 +119,16 @@ static int buffer_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
symbol->bitmap = (unsigned char *) malloc((size_t) symbol->bitmap_width * symbol->bitmap_height * 3);
if (symbol->bitmap == NULL) {
strcpy(symbol->errtxt, "661: Insufficient memory for bitmap buffer");
symbol->err_origin = 661;
strcpy(symbol->errtxt, _("Insufficient memory for bitmap buffer"));
return ZINT_ERROR_MEMORY;
}
if (plot_alpha) {
symbol->alphamap = (unsigned char *) malloc((size_t) symbol->bitmap_width * symbol->bitmap_height);
if (symbol->alphamap == NULL) {
strcpy(symbol->errtxt, "662: Insufficient memory for alphamap buffer");
symbol->err_origin = 662;
strcpy(symbol->errtxt, _("Insufficient memory for alphamap buffer"));
return ZINT_ERROR_MEMORY;
}
for (row = 0; row < symbol->bitmap_height; row++) {
@ -172,7 +174,8 @@ static int save_raster_image_to_file(struct zint_symbol *symbol, int image_heigh
if (rotate_angle) {
if (!(rotated_pixbuf = (unsigned char *) malloc((size_t) image_width * image_height))) {
strcpy(symbol->errtxt, "650: Insufficient memory for pixel buffer");
symbol->err_origin = 650;
strcpy(symbol->errtxt, _("Insufficient memory for pixel buffer"));
return ZINT_ERROR_ENCODING_PROBLEM;
}
}
@ -569,7 +572,8 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in
image_height = ceil((double) (300 + 2 * (yoffset + boffset)) * scaler);
if (!(pixelbuf = (unsigned char *) malloc((size_t) image_width * image_height))) {
strcpy(symbol->errtxt, "655: Insufficient memory for pixel buffer");
symbol->err_origin = 655;
strcpy(symbol->errtxt, "Insufficient memory for pixel buffer");
return ZINT_ERROR_ENCODING_PROBLEM;
}
memset(pixelbuf, DEFAULT_PAPER, (size_t) image_width * image_height);
@ -577,7 +581,8 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in
hexagon_size = ceil(scaler * 10);
if (!(scaled_hexagon = (unsigned char *) malloc((size_t) hexagon_size * hexagon_size))) {
strcpy(symbol->errtxt, "656: Insufficient memory for pixel buffer");
symbol->err_origin = 656;
strcpy(symbol->errtxt, "Insufficient memory for pixel buffer");
free(pixelbuf);
return ZINT_ERROR_ENCODING_PROBLEM;
}
@ -666,7 +671,8 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int f
/* Apply scale options by creating another pixel buffer */
if (!(scaled_pixelbuf = (unsigned char *) malloc((size_t) scale_width * scale_height))) {
strcpy(symbol->errtxt, "657: Insufficient memory for pixel buffer");
symbol->err_origin = 657;
strcpy(symbol->errtxt, _("Insufficient memory for pixel buffer"));
return ZINT_ERROR_ENCODING_PROBLEM;
}
memset(scaled_pixelbuf, DEFAULT_PAPER, (size_t) scale_width * scale_height);
@ -824,7 +830,8 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
image_height = (symbol->height + textoffset + yoffset + boffset) * si;
if (!(pixelbuf = (unsigned char *) malloc((size_t) image_width * image_height))) {
strcpy(symbol->errtxt, "658: Insufficient memory for pixel buffer");
symbol->err_origin = 658;
strcpy(symbol->errtxt, _("Insufficient memory for pixel buffer"));
return ZINT_ERROR_ENCODING_PROBLEM;
}
memset(pixelbuf, DEFAULT_PAPER, (size_t) image_width * image_height);
@ -1128,7 +1135,8 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
/* Apply scale options by creating another pixel buffer */
if (!(scaled_pixelbuf = (unsigned char *) malloc((size_t) scale_width * scale_height))) {
free(pixelbuf);
strcpy(symbol->errtxt, "659: Insufficient memory for pixel buffer");
symbol->err_origin = 659;
strcpy(symbol->errtxt, _("Insufficient memory for pixel buffer"));
return ZINT_ERROR_ENCODING_PROBLEM;
}
memset(scaled_pixelbuf, DEFAULT_PAPER, (size_t) scale_width * scale_height);
@ -1160,7 +1168,8 @@ INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_
#ifdef NO_PNG
if (file_type == OUT_PNG_FILE) {
strcpy(symbol->errtxt, "660: PNG format disabled at compile time");
symbol->err_origin = 660;
strcpy(symbol->errtxt, _("PNG format disabled at compile time"));
return ZINT_ERROR_INVALID_OPTION;
}
#endif /* NO_PNG */

View file

@ -283,18 +283,21 @@ INTERNAL int rss14(struct zint_symbol *symbol, unsigned char source[], int src_l
separator_row = 0;
if (src_len > 14) { /* Allow check digit to be specified (will be verified and ignored) */
strcpy(symbol->errtxt, "380: Input too long");
symbol->err_origin = 380;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "381: Invalid characters in data");
symbol->err_origin = 381;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
if (src_len == 14) { /* Verify check digit */
if (calc_check_digit(source) != ctoi(source[13])) {
strcpy(symbol->errtxt, "388: Invalid check digit");
symbol->err_origin = 388;
strcpy(symbol->errtxt, _("Invalid check digit"));
return ZINT_ERROR_INVALID_CHECK;
}
src_len--; /* Ignore */
@ -606,18 +609,21 @@ INTERNAL int rsslimited(struct zint_symbol *symbol, unsigned char source[], int
separator_row = 0;
if (src_len > 14) { /* Allow check digit to be specified (will be verified and ignored) */
strcpy(symbol->errtxt, "382: Input too long");
symbol->err_origin = 382;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "383: Invalid characters in data");
symbol->err_origin = 383;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
if (src_len == 14) { /* Verify check digit */
if (calc_check_digit(source) != ctoi(source[13])) {
strcpy(symbol->errtxt, "389: Invalid check digit");
symbol->err_origin = 389;
strcpy(symbol->errtxt, _("Invalid check digit"));
return ZINT_ERROR_INVALID_CHECK;
}
src_len--; /* Ignore */
@ -625,7 +631,8 @@ INTERNAL int rsslimited(struct zint_symbol *symbol, unsigned char source[], int
if (src_len == 13) {
if ((source[0] != '0') && (source[0] != '1')) {
strcpy(symbol->errtxt, "384: Input out of range");
symbol->err_origin = 384;
strcpy(symbol->errtxt, _("Input out of range"));
return ZINT_ERROR_INVALID_DATA;
}
}
@ -951,7 +958,8 @@ static int rss_binary_string(struct zint_symbol *symbol, char source[], char bin
if ((source[i] < '0') || (source[i] > '9')) {
if ((source[i] != '[') && (source[i] != ']')) {
/* Something is wrong */
strcpy(symbol->errtxt, "385: Invalid characters in input data");
symbol->err_origin = 385;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
}
@ -1098,7 +1106,8 @@ static int rss_binary_string(struct zint_symbol *symbol, char source[], char bin
if (!general_field_encode(general_field, &mode, &last_digit, binary_string)) {
/* Invalid characters in input data */
strcpy(symbol->errtxt, "386: Invalid characters in input data");
symbol->err_origin = 386;
strcpy(symbol->errtxt, "Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
if (debug) printf("Resultant binary = %s\n", binary_string);
@ -1170,7 +1179,8 @@ static int rss_binary_string(struct zint_symbol *symbol, char source[], char bin
}
if (strlen(binary_string) > 252) { /* 252 = (21 * 12) */
strcpy(symbol->errtxt, "387: Input too long");
symbol->err_origin = 387;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}

View file

@ -1531,7 +1531,8 @@ INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char sourc
for (i = 0, length = *p_length; i < length; i++) {
if (!sjis_wctomb_zint(jisdata + i, utfdata[i])) {
strcpy(symbol->errtxt, "800: Invalid character in input data");
symbol->err_origin = 800;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
}

View file

@ -193,7 +193,8 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
fsvg = fopen(symbol->outfile, "w");
}
if (fsvg == NULL) {
strcpy(symbol->errtxt, "680: Could not open output file");
symbol->err_origin = 680;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}

View file

@ -67,7 +67,8 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], const s
count = 0;
if (src_len > 30) {
strcpy(symbol->errtxt, "390: Input too long");
symbol->err_origin = 390;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
/* Start character */
@ -76,7 +77,8 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], const s
for (i = 0; i < src_len; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "391: Invalid characters in input data");
symbol->err_origin = 391;
strcpy(symbol->errtxt, _("Invalid character in data"));
return ZINT_ERROR_INVALID_DATA;
}
strcat(dest, TeleTable[source[i]]);
@ -114,14 +116,16 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], con
count = 0;
if (temp_length > 60) {
strcpy(symbol->errtxt, "392: Input too long");
symbol->err_origin = 392;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
ustrcpy(temp, source);
to_upper(temp);
error_number = is_sane(SODIUM, temp, temp_length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "393: Invalid characters in data");
symbol->err_origin = 393;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
@ -138,7 +142,8 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], con
for (i = 0; i < temp_length; i += 2) {
if (temp[i] == 'X') {
strcpy(symbol->errtxt, "394: Invalid position of X in Telepen data");
symbol->err_origin = 394;
strcpy(symbol->errtxt, _("Invalid position of X in Telepen data"));
return ZINT_ERROR_INVALID_DATA;
}

View file

@ -119,7 +119,8 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
}
if (free_memory > 0xffff0000) {
strcpy(symbol->errtxt, "670: Output file size too big");
symbol->err_origin = 670;
strcpy(symbol->errtxt, _("Output file size too big"));
return ZINT_ERROR_MEMORY;
}
@ -127,14 +128,16 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
if (symbol->output_options & BARCODE_STDOUT) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "671: Can't open output file");
symbol->err_origin = 671;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
#endif
tif_file = stdout;
} else {
if (!(tif_file = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "672: Can't open output file");
symbol->err_origin = 672;
strcpy(symbol->errtxt, _("Can't open output file"));
return ZINT_ERROR_FILE_ACCESS;
}
}

View file

@ -885,7 +885,8 @@ INTERNAL int ultracode(struct zint_symbol *symbol, const unsigned char source[],
}
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "590: ECI value not supported by Ultracode");
symbol->err_origin = 590;
strcpy(symbol->errtxt, _("ECI value not supported by Ultracode"));
return ZINT_ERROR_INVALID_OPTION;
}
@ -935,7 +936,8 @@ INTERNAL int ultracode(struct zint_symbol *symbol, const unsigned char source[],
/* Maximum capacity is 282 codewords */
total_cws = data_cw_count + qcc + 3; // 3 == TCC pattern + RSEC pattern + QCC pattern
if (total_cws > 282) {
strcpy(symbol->errtxt, "591: Data too long for selected error correction capacity");
symbol->err_origin = 591;
strcpy(symbol->errtxt, _("Data too long for selected error correction capacity"));
return ZINT_ERROR_TOO_LONG;
}

View file

@ -140,7 +140,8 @@ static int upca(struct zint_symbol *symbol, unsigned char source[], char dest[])
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("UPC-A: Invalid check digit %s, gtin: %s, Check digit: %c\n", source, gtin, upc_check(gtin));
}
strcpy(symbol->errtxt, "270: Invalid check digit");
symbol->err_origin = 270;
strcpy(symbol->errtxt, _("Invalid check digit"));
return ZINT_ERROR_INVALID_CHECK;
}
gtin[length - 1] = upc_check(gtin);
@ -238,7 +239,8 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
equivalent[10] = source[4];
if (((source[2] == '0') || (source[2] == '1')) || (source[2] == '2')) {
/* Note 1 - "X3 shall not be equal to 0, 1 or 2" */
strcpy(symbol->errtxt, "271: Invalid UPC-E data");
symbol->err_origin = 271;
strcpy(symbol->errtxt, _("Invalid UPC-E data"));
return ZINT_ERROR_INVALID_DATA;
}
break;
@ -248,7 +250,8 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
equivalent[10] = source[4];
if (source[3] == '0') {
/* Note 2 - "X4 shall not be equal to 0" */
strcpy(symbol->errtxt, "272: Invalid UPC-E data");
symbol->err_origin = 272;
strcpy(symbol->errtxt, _("Invalid UPC-E data"));
return ZINT_ERROR_INVALID_DATA;
}
break;
@ -263,7 +266,8 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
equivalent[10] = emode;
if (source[4] == '0') {
/* Note 3 - "X5 shall not be equal to 0" */
strcpy(symbol->errtxt, "273: Invalid UPC-E data");
symbol->err_origin = 273;
strcpy(symbol->errtxt, _("Invalid UPC-E data"));
return ZINT_ERROR_INVALID_DATA;
}
break;
@ -306,7 +310,8 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("UPC-E: Invalid check digit %s, equivalent: %s, hrt: %s, Check digit: %c\n", source, equivalent, hrt, check_digit);
}
strcpy(symbol->errtxt, "274: Invalid check digit");
symbol->err_origin = 274;
strcpy(symbol->errtxt, _("Invalid check digit"));
return ZINT_ERROR_INVALID_CHECK;
}
}
@ -425,7 +430,8 @@ static int ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("EAN-13 Invalid check digit: %s, gtin: %s, Check digit: %c\n", source, gtin, ean_check(gtin));
}
strcpy(symbol->errtxt, "275: Invalid check digit");
symbol->err_origin = 275;
strcpy(symbol->errtxt, _("Invalid check digit"));
return ZINT_ERROR_INVALID_CHECK;
}
gtin[length - 1] = ean_check(gtin);
@ -483,7 +489,8 @@ static int ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("EAN-8: Invalid check digit %s, gtin: %s, Check digit: %c\n", source, gtin, upc_check(gtin));
}
strcpy(symbol->errtxt, "276: Invalid check digit");
symbol->err_origin = 276;
strcpy(symbol->errtxt, _("Invalid check digit"));
return ZINT_ERROR_INVALID_CHECK;
}
gtin[length - 1] = upc_check(gtin);
@ -548,26 +555,30 @@ static int isbn(struct zint_symbol *symbol, unsigned char source[], const size_t
to_upper(source);
error_number = is_sane("0123456789X", source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "277: Invalid characters in input");
symbol->err_origin = 277;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
/* Input must be 9, 10 or 13 characters */
if (src_len != 9 && src_len != 10 && src_len != 13) {
strcpy(symbol->errtxt, "278: Input wrong length");
symbol->err_origin = 278;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
if (src_len == 13) /* Using 13 character ISBN */ {
if (!(((source[0] == '9') && (source[1] == '7')) &&
((source[2] == '8') || (source[2] == '9')))) {
strcpy(symbol->errtxt, "279: Invalid ISBN");
symbol->err_origin = 279;
strcpy(symbol->errtxt, _("Invalid ISBN"));
return ZINT_ERROR_INVALID_DATA;
}
check_digit = isbn13_check(source);
if (source[src_len - 1] != check_digit) {
strcpy(symbol->errtxt, "280: Incorrect ISBN check");
symbol->err_origin = 280;
strcpy(symbol->errtxt, _("Incorrect ISBN check"));
return ZINT_ERROR_INVALID_CHECK;
}
source[12] = '\0';
@ -584,7 +595,8 @@ static int isbn(struct zint_symbol *symbol, unsigned char source[], const size_t
if (src_len == 9 || src_len == 10) /* Using 10 digit ISBN or 9 digit SBN padded with leading zero */ {
check_digit = isbn_check(source);
if (check_digit != source[ustrlen(source) - 1]) {
strcpy(symbol->errtxt, src_len == 9 ? "281: Incorrect SBN check" : "281: Incorrect ISBN check");
symbol->err_origin = 281;
strcpy(symbol->errtxt, src_len == 9 ? _("Incorrect SBN check") : _("Incorrect ISBN check"));
return ZINT_ERROR_INVALID_CHECK;
}
for (i = 11; i > 2; i--) {
@ -746,20 +758,23 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
writer = 0;
if (src_len > 19) {
strcpy(symbol->errtxt, "283: Input too long");
symbol->err_origin = 283;
strcpy(symbol->errtxt, _("Input too long"));
return ZINT_ERROR_TOO_LONG;
}
if (symbol->symbology != BARCODE_ISBNX) {
/* ISBN has its own checking routine */
error_number = is_sane("0123456789+", source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "284: Invalid characters in data");
symbol->err_origin = 284;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
} else {
error_number = is_sane("0123456789Xx+", source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "285: Invalid characters in input");
symbol->err_origin = 285;
strcpy(symbol->errtxt, _("Invalid character in data"));
return error_number;
}
}
@ -772,7 +787,8 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
}
}
if (plus_count > 1) {
strcpy(symbol->errtxt, "293: Invalid add-on data");
symbol->err_origin = 293;
strcpy(symbol->errtxt, _("Invalid add-on data"));
return ZINT_ERROR_INVALID_DATA;
}
@ -825,7 +841,9 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
case 12:
case 13: error_number = ean13(symbol, first_part, (char*) dest);
break;
default: strcpy(symbol->errtxt, "286: Input wrong length");
default:
symbol->err_origin = 286;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
break;
@ -856,7 +874,9 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
symbol->rows += 3;
error_number = ean13(symbol, first_part, (char*) dest);
break;
default: strcpy(symbol->errtxt, "287: Input wrong length");
default:
symbol->err_origin = 287;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
break;
@ -865,7 +885,8 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
if ((ustrlen(first_part) == 11) || (ustrlen(first_part) == 12)) {
error_number = upca(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "288: Input wrong length");
symbol->err_origin = 288;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
break;
@ -883,7 +904,8 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
symbol->rows += 3;
error_number = upca(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "289: Input wrong length");
symbol->err_origin = 289;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
break;
@ -892,7 +914,8 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
if ((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= (symbol->symbology == BARCODE_UPCE ? 7 : 8))) {
error_number = upce(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "290: Input wrong length");
symbol->err_origin = 290;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
break;
@ -910,7 +933,8 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
symbol->rows += 3;
error_number = upce(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "291: Input wrong length");
symbol->err_origin = 291;
strcpy(symbol->errtxt, _("Input wrong length"));
return ZINT_ERROR_TOO_LONG;
}
break;
@ -936,7 +960,8 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
strcat((char*) symbol->text, (char*) second_part);
break;
default:
strcpy(symbol->errtxt, "292: Add-on input wrong length");
symbol->err_origin = 292;
strcpy(symbol->errtxt, _("Add-on input wrong length"));
return ZINT_ERROR_TOO_LONG;
}

View file

@ -99,6 +99,7 @@ extern "C" {
unsigned char encoded_data[200][143];
int row_height[200]; /* Largest symbol is 189 x 189 Han Xin */
char errtxt[100];
int err_origin;
unsigned char *bitmap;
int bitmap_width;
int bitmap_height;