mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Updated error handling
This commit is contained in:
parent
79efc11936
commit
844dfdebef
@ -89,7 +89,7 @@ void rs_error(char data_pattern[])
|
|||||||
|
|
||||||
for(reader = 4; reader > 0; reader--)
|
for(reader = 4; reader > 0; reader--)
|
||||||
{
|
{
|
||||||
concat(data_pattern, AusBarTable[result[reader - 1]]);
|
concat(data_pattern, AusBarTable[(int)result[reader - 1]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,17 +125,17 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
case 16: strcpy(fcc, "59"); errno = is_sane(NESET, source); break;
|
case 16: strcpy(fcc, "59"); errno = is_sane(NESET, source); break;
|
||||||
case 18: strcpy(fcc, "62"); break;
|
case 18: strcpy(fcc, "62"); break;
|
||||||
case 23: strcpy(fcc, "62"); errno = is_sane(NESET, source); break;
|
case 23: strcpy(fcc, "62"); errno = is_sane(NESET, source); break;
|
||||||
default: strcpy(symbol->errtxt, "error: auspost input is wrong length");
|
default: strcpy(symbol->errtxt, "Auspost input is wrong length [631]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(errno == ERROR_INVALID_DATA) {
|
if(errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [632]");
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(ustrlen(source) != 8) {
|
if(ustrlen(source) != 8) {
|
||||||
strcpy(symbol->errtxt, "error: auspost input is wrong length");
|
strcpy(symbol->errtxt, "Auspost input is wrong length [633]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
switch(symbol->symbology) {
|
switch(symbol->symbology) {
|
||||||
@ -148,7 +148,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
errno = is_sane(GDSET, source);
|
errno = is_sane(GDSET, source);
|
||||||
if(errno == ERROR_INVALID_DATA) {
|
if(errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [634]");
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
dpid[8] = '\0';
|
dpid[8] = '\0';
|
||||||
errno = is_sane(NESET, (unsigned char*)dpid);
|
errno = is_sane(NESET, (unsigned char*)dpid);
|
||||||
if(errno == ERROR_INVALID_DATA) {
|
if(errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in DPID");
|
strcpy(symbol->errtxt, "Invalid characters in DPID [635]");
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,12 +556,12 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
err_code = aztec_text_process(source, binary_string);
|
err_code = aztec_text_process(source, binary_string);
|
||||||
|
|
||||||
if(err_code != 0) {
|
if(err_code != 0) {
|
||||||
strcpy(symbol->errtxt, "Input too long or too many extended ASCII characters");
|
strcpy(symbol->errtxt, "Input too long or too many extended ASCII characters [921]");
|
||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!((symbol->option_1 >= -1) && (symbol->option_1 <= 4))) {
|
if(!((symbol->option_1 >= -1) && (symbol->option_1 <= 4))) {
|
||||||
strcpy(symbol->errtxt, "Invalid error correction level - using default instead");
|
strcpy(symbol->errtxt, "Invalid error correction level - using default instead [922]");
|
||||||
err_code = WARN_INVALID_OPTION;
|
err_code = WARN_INVALID_OPTION;
|
||||||
symbol->option_1 = -1;
|
symbol->option_1 = -1;
|
||||||
}
|
}
|
||||||
@ -644,7 +644,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(layers == 0) { /* Couldn't find a symbol which fits the data */
|
if(layers == 0) { /* Couldn't find a symbol which fits the data */
|
||||||
strcpy(symbol->errtxt, "Input too long (too many bits for selected ECC)");
|
strcpy(symbol->errtxt, "Input too long (too many bits for selected ECC) [923]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,7 +694,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
layers = symbol->option_2 - 4;
|
layers = symbol->option_2 - 4;
|
||||||
}
|
}
|
||||||
if((symbol->option_2 < 0) || (symbol->option_2 > 36)) {
|
if((symbol->option_2 < 0) || (symbol->option_2 > 36)) {
|
||||||
strcpy(symbol->errtxt, "Invalid Aztec Code size");
|
strcpy(symbol->errtxt, "Invalid Aztec Code size [924]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,7 +736,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(adjusted_length > data_maxsize) {
|
if(adjusted_length > data_maxsize) {
|
||||||
strcpy(symbol->errtxt, "Data too long for specified Aztec Code symbol size");
|
strcpy(symbol->errtxt, "Data too long for specified Aztec Code symbol size [925]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
final_mode = MODEA;
|
final_mode = MODEA;
|
||||||
|
|
||||||
if(input_length > 5450) {
|
if(input_length > 5450) {
|
||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long [741]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
columns_needed = (estimate_codelength + 2) / rows_needed;
|
columns_needed = (estimate_codelength + 2) / rows_needed;
|
||||||
if(columns_needed < 4) { columns_needed = 4; }
|
if(columns_needed < 4) { columns_needed = 4; }
|
||||||
if(columns_needed > 62) {
|
if(columns_needed > 62) {
|
||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long [742]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = data_encode_blockf(source, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode);
|
error_number = data_encode_blockf(source, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode);
|
||||||
if(error_number > 0) {
|
if(error_number > 0) {
|
||||||
if(error_number == ERROR_TOO_LONG) {
|
if(error_number == ERROR_TOO_LONG) {
|
||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long [743]");
|
||||||
}
|
}
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,12 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 80) {
|
if(ustrlen(source) > 80) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [011]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NASET, source);
|
error_number = is_sane(NASET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [012]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
c_weight = 1;
|
c_weight = 1;
|
||||||
@ -168,12 +168,12 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
to_upper(source);
|
to_upper(source);
|
||||||
if(ustrlen(source) > 45) {
|
if(ustrlen(source) > 45) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [081]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(TCSET , source);
|
error_number = is_sane(TCSET , source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [082]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,12 +252,12 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
count = 0;
|
count = 0;
|
||||||
h = ustrlen(source);
|
h = ustrlen(source);
|
||||||
if(h != 6) {
|
if(h != 6) {
|
||||||
strcpy(symbol->errtxt, "error: input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length [521]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [522]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* only stops strings which are far too long - actual length of the barcode
|
/* only stops strings which are far too long - actual length of the barcode
|
||||||
depends on the type of data being encoded - if it's too long it's picked up
|
depends on the type of data being encoded - if it's too long it's picked up
|
||||||
by c39() */
|
by c39() */
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [091]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < ustrlen(source); i++) {
|
||||||
if(source[i] > 127) {
|
if(source[i] > 127) {
|
||||||
/* Cannot encode extended ASCII */
|
/* Cannot encode extended ASCII */
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data [092]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -348,14 +348,14 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(ustrlen(source) > 45) {
|
if(ustrlen(source) > 45) {
|
||||||
/* This stops rediculously long input - the actual length of the barcode
|
/* This stops rediculously long input - the actual length of the barcode
|
||||||
depends on the type of data */
|
depends on the type of data */
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [251]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < ustrlen(source); i++) {
|
||||||
if(source[i] > 127) {
|
if(source[i] > 127) {
|
||||||
/* Cannot encode extended ASCII */
|
/* Cannot encode extended ASCII */
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data [252]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
/* Now we can check the true length of the barcode */
|
/* Now we can check the true length of the barcode */
|
||||||
if(strlen(buffer) > 45) {
|
if(strlen(buffer) > 45) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [253]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(sourcelen > 160) {
|
if(sourcelen > 160) {
|
||||||
/* This only blocks rediculously long input - the actual length of the
|
/* This only blocks rediculously long input - the actual length of the
|
||||||
resulting barcode depends on the type of data, so this is trapped later */
|
resulting barcode depends on the type of data, so this is trapped later */
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [201]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,11 +218,11 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(symbol->symbology == BARCODE_NVE18) {
|
if(symbol->symbology == BARCODE_NVE18) {
|
||||||
errornum = is_sane(NESET, source);
|
errornum = is_sane(NESET, source);
|
||||||
if(errornum == ERROR_INVALID_DATA) {
|
if(errornum == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [202]");
|
||||||
return errornum;
|
return errornum;
|
||||||
}
|
}
|
||||||
if(sourcelen != 17) {
|
if(sourcelen != 17) {
|
||||||
strcpy(symbol->errtxt, "error: input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length [203]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
for(i = sourcelen + 2; i > 1; i--) {
|
for(i = sourcelen + 2; i > 1; i--) {
|
||||||
@ -400,7 +400,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(glyph_count > 80.0) {
|
if(glyph_count > 80.0) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [204]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,20 +597,20 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(sourcelen > 160) {
|
if(sourcelen > 160) {
|
||||||
/* This only blocks rediculously long input - the actual length of the
|
/* This only blocks rediculously long input - the actual length of the
|
||||||
resulting barcode depends on the type of data, so this is trapped later */
|
resulting barcode depends on the type of data, so this is trapped later */
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [161]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Detect extended ASCII characters */
|
/* Detect extended ASCII characters */
|
||||||
for(i = 0; i < sourcelen; i++) {
|
for(i = 0; i < sourcelen; i++) {
|
||||||
if(source[i] >=128) {
|
if(source[i] >=128) {
|
||||||
strcpy(symbol->errtxt, "error: extended ASCII characters not supported by GS1-128");
|
strcpy(symbol->errtxt, "Extended ASCII characters not supported by GS1-128 [162]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(source[0] != '[') {
|
if(source[0] != '[') {
|
||||||
strcpy(symbol->errtxt, "error: input string doesn't start with AI");
|
strcpy(symbol->errtxt, "Input string doesn't start with AI [163]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +750,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(glyph_count > 80.0) {
|
if(glyph_count > 80.0) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [164]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -910,13 +910,13 @@ int ean_14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
input_length = ustrlen(source);
|
input_length = ustrlen(source);
|
||||||
|
|
||||||
if(input_length != 13) {
|
if(input_length != 13) {
|
||||||
strcpy(symbol->errtxt, "error: input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length [721]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid character in data");
|
strcpy(symbol->errtxt, "Invalid character in data [722]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
concat((char*)ean128_equiv, "[01]");
|
concat((char*)ean128_equiv, "[01]");
|
||||||
|
@ -124,7 +124,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
input_length = ustrlen(source);
|
input_length = ustrlen(source);
|
||||||
|
|
||||||
if(input_length > 157) {
|
if(input_length > 157) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [231]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(glyph_count > 77.0) {
|
if(glyph_count > 77.0) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [232]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,7 +826,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
|
|||||||
if (!(((ninety[i] >= '0') && (ninety[i] <= '9')) || ((ninety[i] >= 'A') && (ninety[i] <= 'Z')))) {
|
if (!(((ninety[i] >= '0') && (ninety[i] <= '9')) || ((ninety[i] >= 'A') && (ninety[i] <= 'Z')))) {
|
||||||
if((ninety[i] != '*') && (ninety[i] != ',') && (ninety[i] != '-') && (ninety[i] != '.') && (ninety[i] != '/')) {
|
if((ninety[i] != '*') && (ninety[i] != ',') && (ninety[i] != '-') && (ninety[i] != '.') && (ninety[i] != '/')) {
|
||||||
/* An Invalid AI 90 character */
|
/* An Invalid AI 90 character */
|
||||||
strcpy(symbol->errtxt, "error: invalid AI 90 data");
|
strcpy(symbol->errtxt, "Invalid AI 90 data [A1]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1151,7 +1151,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
|
|||||||
|
|
||||||
if(latch == 1) {
|
if(latch == 1) {
|
||||||
/* Invalid characters in input data */
|
/* Invalid characters in input data */
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data [A2]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1510,7 +1510,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(strlen(binary_string) > 11805) { /* (2361 * 5) */
|
if(strlen(binary_string) > 11805) { /* (2361 * 5) */
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [A3]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1682,24 +1682,24 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
separator_row = 0;
|
separator_row = 0;
|
||||||
|
|
||||||
if(strlen(symbol->primary) == 0) {
|
if(strlen(symbol->primary) == 0) {
|
||||||
strcpy(symbol->errtxt, "error: No primary (linear) message in 2D composite");
|
strcpy(symbol->errtxt, "No primary (linear) message in 2D composite [A4]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ustrlen(source) > 2990) {
|
if(ustrlen(source) > 2990) {
|
||||||
strcpy(symbol->errtxt, "error: 2D component input data too long");
|
strcpy(symbol->errtxt, "2D component input data too long [A5]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(source[0] != '[') {
|
if(source[0] != '[') {
|
||||||
strcpy(symbol->errtxt, "Data does not start with an AI");
|
strcpy(symbol->errtxt, "Data does not start with an AI [A6]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source) - 1; i++) {
|
for(i = 0; i < ustrlen(source) - 1; i++) {
|
||||||
if((source[i] == '[') && (source[i + 1] == '[')) {
|
if((source[i] == '[') && (source[i + 1] == '[')) {
|
||||||
/* Can't have nested brackets - Quit */
|
/* Can't have nested brackets - Quit */
|
||||||
strcpy(symbol->errtxt, "Nested AI detected (two or more open brackets)");
|
strcpy(symbol->errtxt, "Nested AI detected (two or more open brackets) [A7]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1707,7 +1707,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
for(i = 0; i < ustrlen(source) - 1; i++) {
|
for(i = 0; i < ustrlen(source) - 1; i++) {
|
||||||
if((source[i] == ']') && (source[i + 1] == ']')) {
|
if((source[i] == ']') && (source[i + 1] == ']')) {
|
||||||
/* Can't have nested brackets - Quit */
|
/* Can't have nested brackets - Quit */
|
||||||
strcpy(symbol->errtxt, "Nested AI detected (two or more close brackets)");
|
strcpy(symbol->errtxt, "Nested AI detected (two or more close brackets) [A8]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1754,7 +1754,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
if((cc_mode == 3) && (symbol->symbology != BARCODE_EAN128_CC)) {
|
if((cc_mode == 3) && (symbol->symbology != BARCODE_EAN128_CC)) {
|
||||||
/* CC-C can only be used with a GS1-128 linear part */
|
/* CC-C can only be used with a GS1-128 linear part */
|
||||||
strcpy(symbol->errtxt, "Invalid mode (CC-C only valid with GS1-128 linear component)");
|
strcpy(symbol->errtxt, "Invalid mode (CC-C only valid with GS1-128 linear component) [A9]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
215
backend/dm200.c
215
backend/dm200.c
@ -81,8 +81,7 @@ static void *safemalloc(int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Annex M placement alorithm low level
|
// Annex M placement alorithm low level
|
||||||
static void ecc200placementbit(int *array, int NR, int NC, int r, int c,
|
static void ecc200placementbit(int *array, int NR, int NC, int r, int c, int p, char b)
|
||||||
int p, char b)
|
|
||||||
{
|
{
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
r += NR;
|
r += NR;
|
||||||
@ -229,8 +228,7 @@ static void ecc200(unsigned char *binary, int bytes, int datablock, int rsblock)
|
|||||||
* necessary padding to tl
|
* necessary padding to tl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl,
|
char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl, char *encoding, int *lenp)
|
||||||
char *encoding, int *lenp)
|
|
||||||
{
|
{
|
||||||
char enc = 'a'; // start in ASCII encoding mode
|
char enc = 'a'; // start in ASCII encoding mode
|
||||||
int tp = 0, sp = 0;
|
int tp = 0, sp = 0;
|
||||||
@ -272,65 +270,49 @@ char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl,
|
|||||||
char *w;
|
char *w;
|
||||||
if (c & 0x80) {
|
if (c & 0x80) {
|
||||||
if (newenc == 'x') {
|
if (newenc == 'x') {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "Cannot encode char 0x%02X in X12\n", c);
|
||||||
"Cannot encode char 0x%02X in X12\n",
|
|
||||||
c);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
c &= 0x7f;
|
c &= 0x7f;
|
||||||
out[p++] = 1;
|
out[(int)p++] = 1;
|
||||||
out[p++] = 30;
|
out[(int)p++] = 30;
|
||||||
}
|
}
|
||||||
w = strchr(e, c);
|
w = strchr(e, c);
|
||||||
if (w)
|
if (w)
|
||||||
out[p++] = ((w - e) + 3) % 40;
|
out[(int)p++] = ((w - e) + 3) % 40;
|
||||||
else {
|
else {
|
||||||
if (newenc == 'x') {
|
if (newenc == 'x') {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "Cannot encode char 0x%02X in X12\n", c);
|
||||||
"Cannot encode char 0x%02X in X12\n",
|
|
||||||
c);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (c < 32) { // shift 1
|
if (c < 32) { // shift 1
|
||||||
out[p++] = 0;
|
out[(int)p++] = 0;
|
||||||
out[p++] = c;
|
out[(int)p++] = c;
|
||||||
} else {
|
} else {
|
||||||
w = strchr(s2, c);
|
w = strchr(s2, c);
|
||||||
if (w) { // shift 2
|
if (w) { // shift 2
|
||||||
out[p++] = 1;
|
out[(int)p++] = 1;
|
||||||
out[p++] =
|
out[(int)p++] = (w - s2);
|
||||||
(w - s2);
|
|
||||||
} else {
|
} else {
|
||||||
w = strchr(s3,
|
w = strchr(s3, c);
|
||||||
c);
|
|
||||||
if (w) {
|
if (w) {
|
||||||
out[p++]
|
out[(int)p++] = 2;
|
||||||
= 2;
|
out[(int)p++] = (w - s3);
|
||||||
out[p++]
|
|
||||||
=
|
|
||||||
(w -
|
|
||||||
s3);
|
|
||||||
} else {
|
} else {
|
||||||
fprintf
|
fprintf (stderr, "Could not encode 0x%02X, should not happen\n", c);
|
||||||
(stderr,
|
return 0;
|
||||||
"Could not encode 0x%02X, should \
|
|
||||||
not happen\n", c);
|
|
||||||
return
|
|
||||||
0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p == 2 && tp + 2 <= tl && sp == sl)
|
if (p == 2 && tp + 2 <= tl && sp == sl)
|
||||||
out[p++] = 0; // shift 1 pad at end
|
out[(int)p++] = 0; // shift 1 pad at end
|
||||||
while (p >= 3) {
|
while (p >= 3) {
|
||||||
int v =
|
int v =
|
||||||
out[0] * 1600 +
|
out[0] * 1600 +
|
||||||
out[1] * 40 + out[2] + 1;
|
out[1] * 40 + out[2] + 1;
|
||||||
if (enc != newenc) {
|
if (enc != newenc) {
|
||||||
if (enc == 'c'
|
if (enc == 'c' || enc == 't' || enc == 'x')
|
||||||
|| enc == 't'
|
|
||||||
|| enc == 'x')
|
|
||||||
t[tp++] = 254; // escape C40/text/X12
|
t[tp++] = 254; // escape C40/text/X12
|
||||||
else if (enc == 'x')
|
else if (enc == 'x')
|
||||||
t[tp++] = 0x7C; // escape EDIFACT
|
t[tp++] = 0x7C; // escape EDIFACT
|
||||||
@ -360,8 +342,7 @@ char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl,
|
|||||||
t[tp++] = 254;
|
t[tp++] = 254;
|
||||||
enc = 'a';
|
enc = 'a';
|
||||||
}
|
}
|
||||||
while (sp < sl && tolower(encoding[sp]) == 'e'
|
while (sp < sl && tolower(encoding[sp]) == 'e' && p < 4)
|
||||||
&& p < 4)
|
|
||||||
out[p++] = s[sp++];
|
out[p++] = s[sp++];
|
||||||
if (p < 4) {
|
if (p < 4) {
|
||||||
out[p++] = 0x1F;
|
out[p++] = 0x1F;
|
||||||
@ -387,10 +368,8 @@ char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl,
|
|||||||
t[tp++] = 0x7C; // escape EDIFACT
|
t[tp++] = 0x7C; // escape EDIFACT
|
||||||
}
|
}
|
||||||
enc = 'a';
|
enc = 'a';
|
||||||
if (sl - sp >= 2 && isdigit(s[sp])
|
if (sl - sp >= 2 && isdigit(s[sp]) && isdigit(s[sp + 1])) {
|
||||||
&& isdigit(s[sp + 1])) {
|
t[tp++] = (s[sp] - '0') * 10 + s[sp + 1] - '0' + 130;
|
||||||
t[tp++] =
|
|
||||||
(s[sp] - '0') * 10 + s[sp + 1] - '0' + 130;
|
|
||||||
sp += 2;
|
sp += 2;
|
||||||
} else if (s[sp] > 127) {
|
} else if (s[sp] > 127) {
|
||||||
t[tp++] = 235;
|
t[tp++] = 235;
|
||||||
@ -403,10 +382,7 @@ char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl,
|
|||||||
int l = 0; // how much to encode
|
int l = 0; // how much to encode
|
||||||
if (encoding) {
|
if (encoding) {
|
||||||
int p;
|
int p;
|
||||||
for (p = sp;
|
for (p = sp; p < sl && tolower(encoding[p]) == 'b'; p++)
|
||||||
p < sl
|
|
||||||
&& tolower(encoding[p]) == 'b';
|
|
||||||
p++)
|
|
||||||
l++;
|
l++;
|
||||||
}
|
}
|
||||||
t[tp++] = 231; // base256
|
t[tp++] = 231; // base256
|
||||||
@ -523,16 +499,14 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
bl = 0;
|
bl = 0;
|
||||||
if (p + sl < l)
|
if (p + sl < l)
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (enc[p + sl][e].t && ((t = enc[p + sl][e].t +
|
if (enc[p + sl][(int)e].t && ((t = enc[p + sl][(int)e].t + switchcost[E_ASCII][(int)e]) < bl || !bl)) {
|
||||||
switchcost[E_ASCII]
|
|
||||||
[e]) < bl || !bl)) {
|
|
||||||
bl = t;
|
bl = t;
|
||||||
b = e;
|
b = e;
|
||||||
}
|
}
|
||||||
enc[p][E_ASCII].t = tl + bl;
|
enc[p][E_ASCII].t = tl + bl;
|
||||||
enc[p][E_ASCII].s = sl;
|
enc[p][E_ASCII].s = sl;
|
||||||
if (bl && b == E_ASCII)
|
if (bl && b == E_ASCII)
|
||||||
enc[p][b].s += enc[p + sl][b].s;
|
enc[p][(int)b].s += enc[p + sl][(int)b].s;
|
||||||
// C40
|
// C40
|
||||||
sub = tl = sl = 0;
|
sub = tl = sl = 0;
|
||||||
do {
|
do {
|
||||||
@ -559,12 +533,7 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
bl = 0;
|
bl = 0;
|
||||||
if (p + sl < l)
|
if (p + sl < l)
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (enc[p + sl][e].t
|
if (enc[p + sl][(int)e].t && ((t = enc[p + sl][(int)e].t + switchcost[E_C40][(int)e]) < bl || !bl)) {
|
||||||
&&
|
|
||||||
((t =
|
|
||||||
enc[p + sl][e].t +
|
|
||||||
switchcost[E_C40][e]) < bl
|
|
||||||
|| !bl)) {
|
|
||||||
bl = t;
|
bl = t;
|
||||||
b = e;
|
b = e;
|
||||||
}
|
}
|
||||||
@ -576,7 +545,7 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
enc[p][E_C40].t = tl + bl;
|
enc[p][E_C40].t = tl + bl;
|
||||||
enc[p][E_C40].s = sl;
|
enc[p][E_C40].s = sl;
|
||||||
if (bl && b == E_C40)
|
if (bl && b == E_C40)
|
||||||
enc[p][b].s += enc[p + sl][b].s;
|
enc[p][(int)b].s += enc[p + sl][(int)b].s;
|
||||||
}
|
}
|
||||||
// Text
|
// Text
|
||||||
sub = tl = sl = 0;
|
sub = tl = sl = 0;
|
||||||
@ -604,12 +573,7 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
bl = 0;
|
bl = 0;
|
||||||
if (p + sl < l)
|
if (p + sl < l)
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (enc[p + sl][e].t
|
if (enc[p + sl][(int)e].t && ((t = enc[p + sl][(int)e].t + switchcost[E_TEXT][(int)e]) < bl || !bl)) {
|
||||||
&&
|
|
||||||
((t =
|
|
||||||
enc[p + sl][e].t +
|
|
||||||
switchcost[E_TEXT][e]) < bl
|
|
||||||
|| !bl)) {
|
|
||||||
bl = t;
|
bl = t;
|
||||||
b = e;
|
b = e;
|
||||||
}
|
}
|
||||||
@ -620,14 +584,13 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
enc[p][E_TEXT].t = tl + bl;
|
enc[p][E_TEXT].t = tl + bl;
|
||||||
enc[p][E_TEXT].s = sl;
|
enc[p][E_TEXT].s = sl;
|
||||||
if (bl && b == E_TEXT)
|
if (bl && b == E_TEXT)
|
||||||
enc[p][b].s += enc[p + sl][b].s;
|
enc[p][(int)b].s += enc[p + sl][(int)b].s;
|
||||||
}
|
}
|
||||||
// X12
|
// X12
|
||||||
sub = tl = sl = 0;
|
sub = tl = sl = 0;
|
||||||
do {
|
do {
|
||||||
unsigned char c = s[p + sl++];
|
unsigned char c = s[p + sl++];
|
||||||
if (c != 13 && c != '*' && c != '>' && c != ' '
|
if (c != 13 && c != '*' && c != '>' && c != ' ' && !isdigit(c) && !isupper(c)) {
|
||||||
&& !isdigit(c) && !isupper(c)) {
|
|
||||||
sl = 0;
|
sl = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -641,12 +604,7 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
bl = 0;
|
bl = 0;
|
||||||
if (p + sl < l)
|
if (p + sl < l)
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (enc[p + sl][e].t
|
if (enc[p + sl][(int)e].t && ((t = enc[p + sl][(int)e].t + switchcost[E_X12][(int)e]) < bl || !bl)) {
|
||||||
&&
|
|
||||||
((t =
|
|
||||||
enc[p + sl][e].t +
|
|
||||||
switchcost[E_X12][e]) < bl
|
|
||||||
|| !bl)) {
|
|
||||||
bl = t;
|
bl = t;
|
||||||
b = e;
|
b = e;
|
||||||
}
|
}
|
||||||
@ -658,7 +616,7 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
enc[p][E_X12].t = tl + bl;
|
enc[p][E_X12].t = tl + bl;
|
||||||
enc[p][E_X12].s = sl;
|
enc[p][E_X12].s = sl;
|
||||||
if (bl && b == E_X12)
|
if (bl && b == E_X12)
|
||||||
enc[p][b].s += enc[p + sl][b].s;
|
enc[p][(int)b].s += enc[p + sl][(int)b].s;
|
||||||
}
|
}
|
||||||
// EDIFACT
|
// EDIFACT
|
||||||
sl = bl = 0;
|
sl = bl = 0;
|
||||||
@ -669,12 +627,8 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
bs = 1;
|
bs = 1;
|
||||||
} else
|
} else
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (e != E_EDIFACT && enc[p + 1][e].t
|
if (e != E_EDIFACT && enc[p + 1][(int)e].t && ((t = 2 + enc[p + 1][(int)e].t + switchcost[E_ASCII][(int)e]) < bl || !bl))
|
||||||
&&
|
// E_ASCII as allowed for unlatch
|
||||||
((t =
|
|
||||||
2 + enc[p + 1][e].t +
|
|
||||||
switchcost[E_ASCII][e])
|
|
||||||
< bl || !bl)) // E_ASCII as allowed for unlatch
|
|
||||||
{
|
{
|
||||||
bs = 1;
|
bs = 1;
|
||||||
bl = t;
|
bl = t;
|
||||||
@ -686,13 +640,8 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
bs = 2;
|
bs = 2;
|
||||||
} else
|
} else
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (e != E_EDIFACT
|
if (e != E_EDIFACT && enc[p + 2][(int)e].t && ((t = 3 + enc[p + 2][(int)e].t + switchcost[E_ASCII][(int)e]) < bl || !bl))
|
||||||
&& enc[p + 2][e].t
|
// E_ASCII as allowed for unlatch
|
||||||
&&
|
|
||||||
((t =
|
|
||||||
3 + enc[p + 2][e].t +
|
|
||||||
switchcost[E_ASCII][e])
|
|
||||||
< bl || !bl)) // E_ASCII as allowed for unlatch
|
|
||||||
{
|
{
|
||||||
bs = 2;
|
bs = 2;
|
||||||
bl = t;
|
bl = t;
|
||||||
@ -704,55 +653,25 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
bs = 3;
|
bs = 3;
|
||||||
} else
|
} else
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (e != E_EDIFACT
|
if (e != E_EDIFACT && enc[p + 3][(int)e].t && ((t = 3 + enc[p + 3][(int)e].t + switchcost [E_ASCII][(int)e]) < bl || !bl))
|
||||||
&& enc[p + 3][e].t
|
// E_ASCII as allowed for unlatch
|
||||||
&&
|
|
||||||
((t =
|
|
||||||
3 + enc[p +
|
|
||||||
3][e].t +
|
|
||||||
switchcost
|
|
||||||
[E_ASCII][e])
|
|
||||||
< bl || !bl)) // E_ASCII as allowed for unlatch
|
|
||||||
{
|
{
|
||||||
bs = 3;
|
bs = 3;
|
||||||
bl = t;
|
bl = t;
|
||||||
b = e;
|
b = e;
|
||||||
}
|
}
|
||||||
if (p + 4 < l && s[p + 3] >= 32 && s[p + 3] <= 94) { // can encode 4
|
if (p + 4 < l && s[p + 3] >= 32 && s[p + 3] <= 94) { // can encode 4
|
||||||
if (p + 4 == l
|
if (p + 4 == l && (!bl || bl < 3)) {
|
||||||
&& (!bl || bl < 3)) {
|
|
||||||
bl = 3;
|
bl = 3;
|
||||||
bs = 4;
|
bs = 4;
|
||||||
} else {
|
} else {
|
||||||
for (e = 0; e < E_MAX;
|
for (e = 0; e < E_MAX; e++)
|
||||||
e++)
|
if (enc[p + 4][(int)e].t && ((t = 3 + enc[p + 4][(int)e].t + switchcost [E_EDIFACT][(int)e]) < bl || !bl)) {
|
||||||
if (enc[p + 4]
|
|
||||||
[e].t
|
|
||||||
&&
|
|
||||||
((t =
|
|
||||||
3 +
|
|
||||||
enc[p +
|
|
||||||
4][e].
|
|
||||||
t +
|
|
||||||
switchcost
|
|
||||||
[E_EDIFACT]
|
|
||||||
[e]) < bl
|
|
||||||
|| !bl)) {
|
|
||||||
bs = 4;
|
bs = 4;
|
||||||
bl = t;
|
bl = t;
|
||||||
b = e;
|
b = e;
|
||||||
}
|
}
|
||||||
if (exact
|
if (exact && enc[p + 4][E_ASCII].t && enc[p + 4][E_ASCII].t <= 2 && (t = 3 + enc[p + 4][E_ASCII].t) < bl) {
|
||||||
&& enc[p +
|
|
||||||
4][E_ASCII].t
|
|
||||||
&& enc[p +
|
|
||||||
4][E_ASCII].
|
|
||||||
t <= 2
|
|
||||||
&& (t =
|
|
||||||
3 + enc[p +
|
|
||||||
4]
|
|
||||||
[E_ASCII].t) <
|
|
||||||
bl) {
|
|
||||||
// special case, switch to ASCII for last 1 ot two bytes
|
// special case, switch to ASCII for last 1 ot two bytes
|
||||||
bs = 4;
|
bs = 4;
|
||||||
bl = t;
|
bl = t;
|
||||||
@ -765,25 +684,19 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
enc[p][E_EDIFACT].t = bl;
|
enc[p][E_EDIFACT].t = bl;
|
||||||
enc[p][E_EDIFACT].s = bs;
|
enc[p][E_EDIFACT].s = bs;
|
||||||
if (bl && b == E_EDIFACT)
|
if (bl && b == E_EDIFACT)
|
||||||
enc[p][b].s += enc[p + bs][b].s;
|
enc[p][(int)b].s += enc[p + bs][(int)b].s;
|
||||||
}
|
}
|
||||||
// Binary
|
// Binary
|
||||||
bl = 0;
|
bl = 0;
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (enc[p + 1][e].t
|
if (enc[p + 1][(int)e].t && ((t = enc[p + 1][(int)e].t + switchcost[E_BINARY][(int)e] + ((e == E_BINARY && enc[p + 1][(int)e].t == 249) ? 1 : 0)) < bl || !bl)) {
|
||||||
&&
|
|
||||||
((t =
|
|
||||||
enc[p + 1][e].t + switchcost[E_BINARY][e] +
|
|
||||||
((e == E_BINARY
|
|
||||||
&& enc[p + 1][e].t == 249) ? 1 : 0))
|
|
||||||
< bl || !bl)) {
|
|
||||||
bl = t;
|
bl = t;
|
||||||
b = e;
|
b = e;
|
||||||
}
|
}
|
||||||
enc[p][E_BINARY].t = 1 + bl;
|
enc[p][E_BINARY].t = 1 + bl;
|
||||||
enc[p][E_BINARY].s = 1;
|
enc[p][E_BINARY].s = 1;
|
||||||
if (bl && b == E_BINARY)
|
if (bl && b == E_BINARY)
|
||||||
enc[p][b].s += enc[p + 1][b].s;
|
enc[p][(int)b].s += enc[p + 1][(int)b].s;
|
||||||
/*
|
/*
|
||||||
* fprintf (stderr, "%d:", p); for (e = 0; e < E_MAX; e++) fprintf \
|
* fprintf (stderr, "%d:", p); for (e = 0; e < E_MAX; e++) fprintf \
|
||||||
* (stderr, " %c*%d/%d", encchr[e], enc[p][e].s, enc[p][e].t); \
|
* (stderr, " %c*%d/%d", encchr[e], enc[p][e].s, enc[p][e].t); \
|
||||||
@ -797,18 +710,16 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
while (p < l) {
|
while (p < l) {
|
||||||
int t, m = 0, b = 0;
|
int t, m = 0, b = 0;
|
||||||
for (e = 0; e < E_MAX; e++)
|
for (e = 0; e < E_MAX; e++)
|
||||||
if (enc[p][e].t
|
if (enc[p][(int)e].t && ((t = enc[p][(int)e].t + switchcost[(int)cur][(int)e]) < m || t == m && e == cur || !m)) {
|
||||||
&& ((t = enc[p][e].t + switchcost[cur][e]) <
|
|
||||||
m || t == m && e == cur || !m)) {
|
|
||||||
b = e;
|
b = e;
|
||||||
m = t;
|
m = t;
|
||||||
}
|
}
|
||||||
cur = b;
|
cur = b;
|
||||||
m = enc[p][b].s;
|
m = enc[p][(int)b].s;
|
||||||
if (!p && lenp)
|
if (!p && lenp)
|
||||||
*lenp = enc[p][b].t;
|
*lenp = enc[p][(int)b].t;
|
||||||
while (p < l && m--)
|
while (p < l && m--)
|
||||||
encoding[p++] = encchr[b];
|
encoding[p++] = encchr[(int)b];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
encoding[p] = 0;
|
encoding[p] = 0;
|
||||||
@ -830,9 +741,7 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact)
|
|||||||
* Returns 0 on error (writes to stderr with details).
|
* Returns 0 on error (writes to stderr with details).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned char *iec16022ecc200(int *Wptr, int *Hptr, char **encodingptr,
|
unsigned char *iec16022ecc200(int *Wptr, int *Hptr, char **encodingptr, int barcodelen, unsigned char *barcode, int *lenp, int *maxp, int *eccp)
|
||||||
int barcodelen, unsigned char *barcode,
|
|
||||||
int *lenp, int *maxp, int *eccp)
|
|
||||||
{
|
{
|
||||||
unsigned char binary[3000]; // encoded raw data and ecc to place in barcode
|
unsigned char binary[3000]; // encoded raw data and ecc to place in barcode
|
||||||
int W = 0, H = 0;
|
int W = 0, H = 0;
|
||||||
@ -849,9 +758,7 @@ unsigned char *iec16022ecc200(int *Wptr, int *Hptr, char **encodingptr,
|
|||||||
|
|
||||||
// encoding
|
// encoding
|
||||||
if (W) { // known size
|
if (W) { // known size
|
||||||
for (matrix = ecc200matrix; matrix->W && (matrix->W != W ||
|
for (matrix = ecc200matrix; matrix->W && (matrix->W != W || matrix->H != H); matrix++) ;
|
||||||
matrix->H != H);
|
|
||||||
matrix++) ;
|
|
||||||
if (!matrix->W) {
|
if (!matrix->W) {
|
||||||
fprintf(stderr, "Invalid size %dx%d\n", W, H);
|
fprintf(stderr, "Invalid size %dx%d\n", W, H);
|
||||||
return 0;
|
return 0;
|
||||||
@ -878,9 +785,7 @@ unsigned char *iec16022ecc200(int *Wptr, int *Hptr, char **encodingptr,
|
|||||||
|
|
||||||
if (encoding) { // find one that fits chosen encoding
|
if (encoding) { // find one that fits chosen encoding
|
||||||
for (matrix = ecc200matrix; matrix->W; matrix++)
|
for (matrix = ecc200matrix; matrix->W; matrix++)
|
||||||
if (ecc200encode
|
if (ecc200encode(binary, matrix->bytes, barcode, barcodelen, encoding, 0))
|
||||||
(binary, matrix->bytes, barcode, barcodelen,
|
|
||||||
encoding, 0))
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
int len;
|
int len;
|
||||||
@ -891,22 +796,18 @@ unsigned char *iec16022ecc200(int *Wptr, int *Hptr, char **encodingptr,
|
|||||||
if (e && !matrix->W) { // try for non exact fit
|
if (e && !matrix->W) { // try for non exact fit
|
||||||
free(e);
|
free(e);
|
||||||
e = encmake(barcodelen, barcode, &len, 0);
|
e = encmake(barcodelen, barcode, &len, 0);
|
||||||
for (matrix = ecc200matrix;
|
for (matrix = ecc200matrix; matrix->W && matrix->bytes < len; matrix++) ;
|
||||||
matrix->W && matrix->bytes < len;
|
|
||||||
matrix++) ;
|
|
||||||
}
|
}
|
||||||
encoding = e;
|
encoding = e;
|
||||||
}
|
}
|
||||||
if (!matrix->W) {
|
if (!matrix->W) {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "Cannot find suitable size, barcode too long\n");
|
||||||
"Cannot find suitable size, barcode too long\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
W = matrix->W;
|
W = matrix->W;
|
||||||
H = matrix->H;
|
H = matrix->H;
|
||||||
}
|
}
|
||||||
if (!ecc200encode(binary, matrix->bytes, barcode, barcodelen,
|
if (!ecc200encode(binary, matrix->bytes, barcode, barcodelen, encoding, lenp)) {
|
||||||
encoding, lenp)) {
|
|
||||||
fprintf(stderr, "Barcode too long for %dx%d\n", W, H);
|
fprintf(stderr, "Barcode too long for %dx%d\n", W, H);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -936,12 +837,8 @@ unsigned char *iec16022ecc200(int *Wptr, int *Hptr, char **encodingptr,
|
|||||||
for (x = 0; x < NC; x++) {
|
for (x = 0; x < NC; x++) {
|
||||||
int v = places[(NR - y - 1) * NC + x];
|
int v = places[(NR - y - 1) * NC + x];
|
||||||
//fprintf (stderr, "%4d", v);
|
//fprintf (stderr, "%4d", v);
|
||||||
if (v == 1 || v > 7
|
if (v == 1 || v > 7 && (binary[(v >> 3) - 1] & (1 << (v & 7))))
|
||||||
&& (binary[(v >> 3) - 1] & (1 << (v & 7))))
|
grid[(1 + y + 2 * (y / (matrix->FH - 2))) * W + 1 + x + 2 * (x / (matrix->FW - 2))] = 1;
|
||||||
grid[(1 + y +
|
|
||||||
2 * (y / (matrix->FH - 2))) * W +
|
|
||||||
1 + x +
|
|
||||||
2 * (x / (matrix->FW - 2))] = 1;
|
|
||||||
}
|
}
|
||||||
//fprintf (stderr, "\n");
|
//fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
} else */
|
} else */
|
||||||
barcodelen = ustrlen(source);
|
barcodelen = ustrlen(source);
|
||||||
if(barcodelen > 780) {
|
if(barcodelen > 780) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [711]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
// check parameters
|
// check parameters
|
||||||
@ -93,9 +93,13 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if (!H)
|
if (!H)
|
||||||
W = H;
|
W = H;
|
||||||
}
|
}
|
||||||
if (eccstr)
|
/* if (eccstr) */
|
||||||
ecc = atoi(eccstr);
|
ecc = atoi(eccstr);
|
||||||
if (W & 1) { // odd size
|
|
||||||
|
/* Yes I _have_ commented out large blocks of code! - odd size Data Matrix support
|
||||||
|
may be included in a later release but the code for it isn't needed here */
|
||||||
|
|
||||||
|
/* if (W & 1) { // odd size
|
||||||
if (W != H || W < 9 || W > 49) {
|
if (W != H || W < 9 || W > 49) {
|
||||||
strcpy(symbol->errtxt, "error: invalid Data Matrix size");
|
strcpy(symbol->errtxt, "error: invalid Data Matrix size");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
@ -136,21 +140,19 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
// default is even sizes only unless explicit ecc set to force odd
|
// default is even sizes only unless explicit ecc set to force odd
|
||||||
// sizes
|
// sizes
|
||||||
ecc = 200;
|
ecc = 200;
|
||||||
}
|
} */
|
||||||
|
|
||||||
// processing stamps
|
// processing stamps
|
||||||
if ((W & 1) || ecc < 200) { // odd sizes
|
/*if ((W & 1) || ecc < 200) { // odd sizes
|
||||||
strcpy(symbol->errtxt, "error: odd sizes not supported");
|
strcpy(symbol->errtxt, "error: odd sizes not supported");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
} else { // even sizes
|
} else { */ // even sizes
|
||||||
grid =
|
grid = iec16022ecc200(&W, &H, &encoding, barcodelen, source, &len, &maxlen, &ecclen);
|
||||||
iec16022ecc200(&W, &H, &encoding, barcodelen, source, &len,
|
/*} */
|
||||||
&maxlen, &ecclen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// output
|
// output
|
||||||
if (!grid || !W) {
|
if (!grid || !W) {
|
||||||
strcpy(symbol->errtxt, "error: Data Matrix encoding error");
|
strcpy(symbol->errtxt, "Data Matrix encoding error [722]");
|
||||||
return ERROR_ENCODING_PROBLEM;
|
return ERROR_ENCODING_PROBLEM;
|
||||||
}
|
}
|
||||||
int y;
|
int y;
|
||||||
|
@ -313,12 +313,12 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 32) {
|
if(ustrlen(source) > 32) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [851]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
errno = is_sane(NASET, source);
|
errno = is_sane(NASET, source);
|
||||||
if(errno == ERROR_INVALID_DATA) {
|
if(errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [852]");
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,11 +361,11 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(strlen(tracker) != 20) {
|
if(strlen(tracker) != 20) {
|
||||||
strcpy(symbol->errtxt, "error: invalid length tracking code");
|
strcpy(symbol->errtxt, "Invalid length tracking code [853]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
if(strlen(zip) > 11) {
|
if(strlen(zip) > 11) {
|
||||||
strcpy(symbol->errtxt, "error: invalid ZIP code");
|
strcpy(symbol->errtxt, "Invalid ZIP code [854]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,49 +115,69 @@ int png_handle(struct zint_symbol *symbol, int rotate_angle);
|
|||||||
|
|
||||||
extern int ps_plot(struct zint_symbol *symbol);
|
extern int ps_plot(struct zint_symbol *symbol);
|
||||||
|
|
||||||
|
void error_tag(char error_string[], int error_number)
|
||||||
|
{
|
||||||
|
char error_buffer[100];
|
||||||
|
|
||||||
|
if(error_number != 0) {
|
||||||
|
strcpy(error_buffer, error_string);
|
||||||
|
|
||||||
|
if(error_number > 4) {
|
||||||
|
strcpy(error_string, "error: ");
|
||||||
|
} else {
|
||||||
|
strcpy(error_string, "warning: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
concat(error_string, error_buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input)
|
int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input)
|
||||||
{
|
{
|
||||||
int error_number;
|
int error_number, error_buffer;
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
/* First check the symbology field */
|
/* First check the symbology field */
|
||||||
|
|
||||||
if(symbol->symbology < 1) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
if(symbol->symbology < 1) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z01]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
||||||
|
|
||||||
/* symbol->symbologys 1 to 86 are defined by tbarcode */
|
/* symbol->symbologys 1 to 86 are defined by tbarcode */
|
||||||
if(symbol->symbology == 5) { symbol->symbology = BARCODE_C25MATRIX; }
|
if(symbol->symbology == 5) { symbol->symbology = BARCODE_C25MATRIX; }
|
||||||
if((symbol->symbology >= 10) && (symbol->symbology <= 12)) { symbol->symbology = BARCODE_EANX; }
|
if((symbol->symbology >= 10) && (symbol->symbology <= 12)) { symbol->symbology = BARCODE_EANX; }
|
||||||
if((symbol->symbology == 14) || (symbol->symbology == 15)) { symbol->symbology = BARCODE_EANX; }
|
if((symbol->symbology == 14) || (symbol->symbology == 15)) { symbol->symbology = BARCODE_EANX; }
|
||||||
if(symbol->symbology == 17) { symbol->symbology = BARCODE_UPCA; }
|
if(symbol->symbology == 17) { symbol->symbology = BARCODE_UPCA; }
|
||||||
if(symbol->symbology == 19) { strcpy(symbol->errtxt, "Codabar 18 not supported, using Codabar"); symbol->symbology = BARCODE_CODABAR; error_number = WARN_INVALID_OPTION; }
|
if(symbol->symbology == 19) { strcpy(symbol->errtxt, "Codabar 18 not supported, using Codabar [Z02]"); symbol->symbology = BARCODE_CODABAR; error_number = WARN_INVALID_OPTION; }
|
||||||
if(symbol->symbology == 24) { strcpy(symbol->errtxt, "Code 49 not supported, using Code 93"); symbol->symbology = BARCODE_CODE93; error_number = WARN_INVALID_OPTION; }
|
if(symbol->symbology == 24) { strcpy(symbol->errtxt, "Code 49 not supported, using Code 93 [Z03]"); symbol->symbology = BARCODE_CODE93; error_number = WARN_INVALID_OPTION; }
|
||||||
if(symbol->symbology == 26) { symbol->symbology = BARCODE_UPCA; }
|
if(symbol->symbology == 26) { symbol->symbology = BARCODE_UPCA; }
|
||||||
if(symbol->symbology == 27) { strcpy(symbol->errtxt, "UPCD1 not supported"); error_number = ERROR_INVALID_OPTION; }
|
if(symbol->symbology == 27) { strcpy(symbol->errtxt, "UPCD1 not supported [Z04]"); error_number = ERROR_INVALID_OPTION; }
|
||||||
if(symbol->symbology == 33) { symbol->symbology = BARCODE_EAN128; }
|
if(symbol->symbology == 33) { symbol->symbology = BARCODE_EAN128; }
|
||||||
if((symbol->symbology == 35) || (symbol->symbology == 36)) { symbol->symbology = BARCODE_UPCA; }
|
if((symbol->symbology == 35) || (symbol->symbology == 36)) { symbol->symbology = BARCODE_UPCA; }
|
||||||
if((symbol->symbology == 38) || (symbol->symbology == 39)) { symbol->symbology = BARCODE_UPCE; }
|
if((symbol->symbology == 38) || (symbol->symbology == 39)) { symbol->symbology = BARCODE_UPCE; }
|
||||||
if((symbol->symbology >= 41) && (symbol->symbology <= 45)) { symbol->symbology = BARCODE_POSTNET; }
|
if((symbol->symbology >= 41) && (symbol->symbology <= 45)) { symbol->symbology = BARCODE_POSTNET; }
|
||||||
if(symbol->symbology == 46) { symbol->symbology = BARCODE_PLESSEY; }
|
if(symbol->symbology == 46) { symbol->symbology = BARCODE_PLESSEY; }
|
||||||
if(symbol->symbology == 48) { symbol->symbology = BARCODE_NVE18; }
|
if(symbol->symbology == 48) { symbol->symbology = BARCODE_NVE18; }
|
||||||
if(symbol->symbology == 54) { strcpy(symbol->errtxt, "General Parcel Code not supported, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
if(symbol->symbology == 54) { strcpy(symbol->errtxt, "General Parcel Code not supported, using Code 128 [Z05]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
||||||
if((symbol->symbology == 59) || (symbol->symbology == 61)) { symbol->symbology = BARCODE_CODE128; }
|
if((symbol->symbology == 59) || (symbol->symbology == 61)) { symbol->symbology = BARCODE_CODE128; }
|
||||||
if(symbol->symbology == 62) { symbol->symbology = BARCODE_CODE93; }
|
if(symbol->symbology == 62) { symbol->symbology = BARCODE_CODE93; }
|
||||||
if((symbol->symbology == 64) || (symbol->symbology == 65)) { symbol->symbology = BARCODE_AUSPOST; }
|
if((symbol->symbology == 64) || (symbol->symbology == 65)) { symbol->symbology = BARCODE_AUSPOST; }
|
||||||
if(symbol->symbology == 73) { strcpy(symbol->errtxt, "Codablock E not supported"); error_number = ERROR_INVALID_OPTION; }
|
if(symbol->symbology == 73) { strcpy(symbol->errtxt, "Codablock E not supported [Z06]"); error_number = ERROR_INVALID_OPTION; }
|
||||||
if(symbol->symbology == 76) { strcpy(symbol->errtxt, "Japanese Postal Code not supported"); error_number = ERROR_INVALID_OPTION; }
|
if(symbol->symbology == 76) { strcpy(symbol->errtxt, "Japanese Postal Code not supported [Z07]"); error_number = ERROR_INVALID_OPTION; }
|
||||||
if(symbol->symbology == 77) { strcpy(symbol->errtxt, "Korean Postal Code not supported"); error_number = ERROR_INVALID_OPTION; }
|
if(symbol->symbology == 77) { strcpy(symbol->errtxt, "Korean Postal Code not supported [Z08]"); error_number = ERROR_INVALID_OPTION; }
|
||||||
if(symbol->symbology == 78) { symbol->symbology = BARCODE_RSS14; }
|
if(symbol->symbology == 78) { symbol->symbology = BARCODE_RSS14; }
|
||||||
if(symbol->symbology == 83) { symbol->symbology = BARCODE_PLANET; }
|
if(symbol->symbology == 83) { symbol->symbology = BARCODE_PLANET; }
|
||||||
/* NOTE: Tbarcode v8 needs sorting out */
|
/* NOTE: Tbarcode v8 needs sorting out */
|
||||||
if(symbol->symbology == 88) { symbol->symbology = BARCODE_EAN128; }
|
if(symbol->symbology == 88) { symbol->symbology = BARCODE_EAN128; }
|
||||||
if(symbol->symbology == 91) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128\n"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
if(symbol->symbology == 91) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z09]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
||||||
/* leave a gap for future expansion of tbarcode */
|
/* leave a gap for future expansion of tbarcode */
|
||||||
if((symbol->symbology >= 94) && (symbol->symbology <= 128)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128\n"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
if((symbol->symbology >= 94) && (symbol->symbology <= 128)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z10]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
||||||
/* Everything from 100 up is Zint-specific */
|
/* Everything from 100 up is Zint-specific */
|
||||||
if(symbol->symbology >= 140) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
if(symbol->symbology >= 140) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z11]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
||||||
|
|
||||||
if(error_number > 4) {
|
if(error_number > 4) {
|
||||||
|
error_tag(symbol->errtxt, error_number);
|
||||||
return error_number;
|
return error_number;
|
||||||
|
} else {
|
||||||
|
error_buffer = error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(symbol->symbology == BARCODE_CODE16K) {
|
if(symbol->symbology == BARCODE_CODE16K) {
|
||||||
@ -243,6 +263,11 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input)
|
|||||||
case BARCODE_EAN14: error_number = ean_14(symbol, input); break;
|
case BARCODE_EAN14: error_number = ean_14(symbol, input); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(error_number == 0) {
|
||||||
|
error_number = error_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_tag(symbol->errtxt, error_number);
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,17 +290,20 @@ int ZBarcode_Print(struct zint_symbol *symbol)
|
|||||||
if(!(strcmp(output, "EPS"))) {
|
if(!(strcmp(output, "EPS"))) {
|
||||||
error_number = ps_plot(symbol);
|
error_number = ps_plot(symbol);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: unknown output format");
|
strcpy(symbol->errtxt, "Unknown output format [Z20]");
|
||||||
|
error_tag(symbol->errtxt, ERROR_INVALID_OPTION);
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
#ifndef NO_PNG
|
#ifndef NO_PNG
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: unknown output format");
|
strcpy(symbol->errtxt, "Unknown output format [Z21]");
|
||||||
|
error_tag(symbol->errtxt, ERROR_INVALID_OPTION);
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_tag(symbol->errtxt, error_number);
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,17 +326,20 @@ int ZBarcode_Print_Rotated(struct zint_symbol *symbol, int rotate_angle)
|
|||||||
if(!(strcmp(output, "EPS"))) {
|
if(!(strcmp(output, "EPS"))) {
|
||||||
error_number = ps_plot(symbol);
|
error_number = ps_plot(symbol);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: unknown output format");
|
strcpy(symbol->errtxt, "Unknown output format [Z23]");
|
||||||
|
error_tag(symbol->errtxt, ERROR_INVALID_OPTION);
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
#ifndef NO_PNG
|
#ifndef NO_PNG
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: unknown output format");
|
strcpy(symbol->errtxt, "Unknown output format [Z24]");
|
||||||
|
error_tag(symbol->errtxt, ERROR_INVALID_OPTION);
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_tag(symbol->errtxt, error_number);
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,19 +571,19 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((mode < 2) || (mode > 6)) { /* Only codes 2 to 6 supported */
|
if((mode < 2) || (mode > 6)) { /* Only codes 2 to 6 supported */
|
||||||
strcpy(symbol->errtxt, "Error: Invalid Maxicode Mode");
|
strcpy(symbol->errtxt, "Invalid Maxicode Mode [571]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mode == 2) || (mode == 3)) { /* Modes 2 and 3 need data in symbol->primary */
|
if((mode == 2) || (mode == 3)) { /* Modes 2 and 3 need data in symbol->primary */
|
||||||
if(strlen(symbol->primary) != 15) {
|
if(strlen(symbol->primary) != 15) {
|
||||||
strcpy(symbol->errtxt, "Error: Invalid Primary String");
|
strcpy(symbol->errtxt, "Invalid Primary String [572]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 9; i < 15; i++) { /* check that country code and service are numeric */
|
for(i = 9; i < 15; i++) { /* check that country code and service are numeric */
|
||||||
if((symbol->primary[i] < 48) || (symbol->primary[i] > 57)) {
|
if((symbol->primary[i] < 48) || (symbol->primary[i] > 57)) {
|
||||||
strcpy(symbol->errtxt, "Error: Invalid Primary String");
|
strcpy(symbol->errtxt, "Invalid Primary String [573]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -622,7 +622,7 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
i = maxi_text_process(mode, source);
|
i = maxi_text_process(mode, source);
|
||||||
if(i == ERROR_TOO_LONG ) {
|
if(i == ERROR_TOO_LONG ) {
|
||||||
strcpy(symbol->errtxt, "Error: Input data too long");
|
strcpy(symbol->errtxt, "Input data too long [574]");
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 6) {
|
if(ustrlen(source) > 6) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [511]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [512]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
tester = atoi((char*)source);
|
tester = atoi((char*)source);
|
||||||
|
|
||||||
if((tester < 3) || (tester > 131070)) {
|
if((tester < 3) || (tester > 131070)) {
|
||||||
strcpy(symbol->errtxt, "error: data out of range");
|
strcpy(symbol->errtxt, "Data out of range [513]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ int pharma_two_calc(struct zint_symbol *symbol, unsigned char source[], char des
|
|||||||
|
|
||||||
if((tester < 4) || (tester > 64570080))
|
if((tester < 4) || (tester > 64570080))
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: data out of range");
|
strcpy(symbol->errtxt, "Data out of range [533]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
do
|
do
|
||||||
@ -161,12 +161,12 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(height_pattern, "");
|
strcpy(height_pattern, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 8) {
|
if(ustrlen(source) > 8) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [531]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [532]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
error_number = pharma_two_calc(symbol, source, height_pattern);
|
error_number = pharma_two_calc(symbol, source, height_pattern);
|
||||||
@ -204,13 +204,13 @@ int codabar(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 60) { /* No stack smashing please */
|
if(ustrlen(source) > 60) { /* No stack smashing please */
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [181]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
to_upper(source);
|
to_upper(source);
|
||||||
error_number = is_sane(CASET, source);
|
error_number = is_sane(CASET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [182]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,14 +218,14 @@ int codabar(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(((source[0] != 'A') && (source[0] != 'B')) &&
|
if(((source[0] != 'A') && (source[0] != 'B')) &&
|
||||||
((source[0] != 'C') && (source[0] != 'D')))
|
((source[0] != 'C') && (source[0] != 'D')))
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [183]");
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((source[ustrlen(source) - 1] != 'A') && (source[ustrlen(source) - 1] != 'B')) &&
|
if(((source[ustrlen(source) - 1] != 'A') && (source[ustrlen(source) - 1] != 'B')) &&
|
||||||
((source[ustrlen(source) - 1] != 'C') && (source[ustrlen(source) - 1] != 'D')))
|
((source[ustrlen(source) - 1] != 'C') && (source[ustrlen(source) - 1] != 'D')))
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [184]");
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,12 +249,12 @@ int code32(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
/* Validate the input */
|
/* Validate the input */
|
||||||
if(ustrlen(source) > 8) {
|
if(ustrlen(source) > 8) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [C91]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [C92]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,12 +706,12 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if((symbol->option_1 < -1) || (symbol->option_1 > 8)) {
|
if((symbol->option_1 < -1) || (symbol->option_1 > 8)) {
|
||||||
strcpy(symbol->errtxt, "warning: security value out of range");
|
strcpy(symbol->errtxt, "Security value out of range [551]");
|
||||||
symbol->option_1 = -1;
|
symbol->option_1 = -1;
|
||||||
errno = WARN_INVALID_OPTION;
|
errno = WARN_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
if((symbol->option_2 < 0) || (symbol->option_2 > 30)) {
|
if((symbol->option_2 < 0) || (symbol->option_2 > 30)) {
|
||||||
strcpy(symbol->errtxt, "warning: number of columns out of range");
|
strcpy(symbol->errtxt, "Number of columns out of range [552]");
|
||||||
symbol->option_2 = 0;
|
symbol->option_2 = 0;
|
||||||
errno = WARN_INVALID_OPTION;
|
errno = WARN_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
@ -723,23 +723,23 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(codeerr != 0) {
|
if(codeerr != 0) {
|
||||||
switch(codeerr) {
|
switch(codeerr) {
|
||||||
case 1:
|
case 1:
|
||||||
strcpy(symbol->errtxt, "error: no such file or file unreadable (PDF error 1)");
|
strcpy(symbol->errtxt, "No such file or file unreadable [553]");
|
||||||
errno = ERROR_INVALID_OPTION;
|
errno = ERROR_INVALID_OPTION;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
strcpy(symbol->errtxt, "error: input string too long (PDF error 2)");
|
strcpy(symbol->errtxt, "Input string too long [554]");
|
||||||
errno = ERROR_TOO_LONG;
|
errno = ERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
strcpy(symbol->errtxt, "error: number of codewords per row too small (PDF error 3)");
|
strcpy(symbol->errtxt, "Number of codewords per row too small [555]");
|
||||||
errno = WARN_INVALID_OPTION;
|
errno = WARN_INVALID_OPTION;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
strcpy(symbol->errtxt, "error: data too long for specified number of columns (PDF error 4)");
|
strcpy(symbol->errtxt, "Data too long for specified number of columns [556]");
|
||||||
errno = ERROR_TOO_LONG;
|
errno = ERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(symbol->errtxt, "error: something strange happened");
|
strcpy(symbol->errtxt, "Something strange happened [557]");
|
||||||
errno = ERROR_ENCODING_PROBLEM;
|
errno = ERROR_ENCODING_PROBLEM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -807,11 +807,11 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
/* This is where it all changes! */
|
/* This is where it all changes! */
|
||||||
|
|
||||||
if(mclength > 126) {
|
if(mclength > 126) {
|
||||||
strcpy(symbol->errtxt, "error: input data too long");
|
strcpy(symbol->errtxt, "Input data too long [841]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
if(symbol->option_2 > 4) {
|
if(symbol->option_2 > 4) {
|
||||||
strcpy(symbol->errtxt, "warning: specified width out of range");
|
strcpy(symbol->errtxt, "Specified width out of range [842]");
|
||||||
symbol->option_2 = 0;
|
symbol->option_2 = 0;
|
||||||
codeerr = WARN_INVALID_OPTION;
|
codeerr = WARN_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
@ -823,21 +823,21 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
if((symbol->option_2 == 1) && (mclength > 20)) {
|
if((symbol->option_2 == 1) && (mclength > 20)) {
|
||||||
/* the user specified 1 column but the data doesn't fit - go to automatic */
|
/* the user specified 1 column but the data doesn't fit - go to automatic */
|
||||||
symbol->option_2 = 0;
|
symbol->option_2 = 0;
|
||||||
strcpy(symbol->errtxt, "warning: specified symbol size too small for data");
|
strcpy(symbol->errtxt, "Specified symbol size too small for data [843]");
|
||||||
codeerr = WARN_INVALID_OPTION;
|
codeerr = WARN_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((symbol->option_2 == 2) && (mclength > 37)) {
|
if((symbol->option_2 == 2) && (mclength > 37)) {
|
||||||
/* the user specified 2 columns but the data doesn't fit - go to automatic */
|
/* the user specified 2 columns but the data doesn't fit - go to automatic */
|
||||||
symbol->option_2 = 0;
|
symbol->option_2 = 0;
|
||||||
strcpy(symbol->errtxt, "warning: specified symbol size too small for data");
|
strcpy(symbol->errtxt, "Specified symbol size too small for data [844]");
|
||||||
codeerr = WARN_INVALID_OPTION;
|
codeerr = WARN_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((symbol->option_2 == 3) && (mclength > 82)) {
|
if((symbol->option_2 == 3) && (mclength > 82)) {
|
||||||
/* the user specified 3 columns but the data doesn't fit - go to automatic */
|
/* the user specified 3 columns but the data doesn't fit - go to automatic */
|
||||||
symbol->option_2 = 0;
|
symbol->option_2 = 0;
|
||||||
strcpy(symbol->errtxt, "warning: specified symbol size too small for data");
|
strcpy(symbol->errtxt, "Specified symbol size too small for data [845]");
|
||||||
codeerr = WARN_INVALID_OPTION;
|
codeerr = WARN_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,12 +47,12 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 65) {
|
if(ustrlen(source) > 65) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [861]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, source);
|
error_number = is_sane(SSET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [862]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
checkptr = calloc (1, ustrlen(source) * 4 + 8);
|
checkptr = calloc (1, ustrlen(source) * 4 + 8);
|
||||||
@ -108,12 +108,12 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 55) {
|
if(ustrlen(source) > 55) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [471]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [472]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,12 +146,12 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 55) {
|
if(ustrlen(source) > 55) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [473]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [474]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,12 +244,12 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 55) { /* No Entry Stack Smashers! */
|
if(ustrlen(source) > 55) { /* No Entry Stack Smashers! */
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [475]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [476]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,12 +401,12 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 55) {
|
if(ustrlen(source) > 55) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [477]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [478]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,12 +471,12 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 55) {
|
if(ustrlen(source) > 55) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [479]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [47A]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,21 +84,21 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
|
|||||||
to_upper((unsigned char*)symbol->bgcolour);
|
to_upper((unsigned char*)symbol->bgcolour);
|
||||||
|
|
||||||
if(strlen(symbol->fgcolour) != 6) {
|
if(strlen(symbol->fgcolour) != 6) {
|
||||||
strcpy(symbol->errtxt, "error: malformed foreground colour target");
|
strcpy(symbol->errtxt, "Malformed foreground colour target [B1]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
if(strlen(symbol->bgcolour) != 6) {
|
if(strlen(symbol->bgcolour) != 6) {
|
||||||
strcpy(symbol->errtxt, "error: malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target [B2]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
errno = is_sane(SSET, (unsigned char*)symbol->fgcolour);
|
errno = is_sane(SSET, (unsigned char*)symbol->fgcolour);
|
||||||
if (errno == ERROR_INVALID_DATA) {
|
if (errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: malformed foreground colour target");
|
strcpy(symbol->errtxt, "Malformed foreground colour target [B3]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
errno = is_sane(SSET, (unsigned char*)symbol->bgcolour);
|
errno = is_sane(SSET, (unsigned char*)symbol->bgcolour);
|
||||||
if (errno == ERROR_INVALID_DATA) {
|
if (errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target [B4]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
|
|||||||
|
|
||||||
/* Open output file in binary mode */
|
/* Open output file in binary mode */
|
||||||
if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) {
|
if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) {
|
||||||
strcpy(symbol->errtxt, "error: can't open output file");
|
strcpy(symbol->errtxt, "Can't open output file [B5]");
|
||||||
return ERROR_FILE_ACCESS;
|
return ERROR_FILE_ACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,21 +119,21 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
|
|||||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic,
|
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic,
|
||||||
writepng_error_handler, NULL);
|
writepng_error_handler, NULL);
|
||||||
if (!png_ptr) {
|
if (!png_ptr) {
|
||||||
strcpy(symbol->errtxt, "error: out of memory");
|
strcpy(symbol->errtxt, "Out of memory [B6]");
|
||||||
return ERROR_MEMORY;
|
return ERROR_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (!info_ptr) {
|
if (!info_ptr) {
|
||||||
png_destroy_write_struct(&png_ptr, NULL);
|
png_destroy_write_struct(&png_ptr, NULL);
|
||||||
strcpy(symbol->errtxt, "error: out of memory");
|
strcpy(symbol->errtxt, "Out of memory [B7]");
|
||||||
return ERROR_MEMORY;
|
return ERROR_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* catch jumping here */
|
/* catch jumping here */
|
||||||
if (setjmp(graphic->jmpbuf)) {
|
if (setjmp(graphic->jmpbuf)) {
|
||||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||||
strcpy(symbol->errtxt, "error: libpng error occurred");
|
strcpy(symbol->errtxt, "libpng error occurred [B8]");
|
||||||
return ERROR_MEMORY;
|
return ERROR_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ int maxi_png_plot(struct zint_symbol *symbol, int rotate_angle)
|
|||||||
image_height = 300;
|
image_height = 300;
|
||||||
|
|
||||||
if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
|
if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
|
||||||
printf("Insifficient memory for pixel buffer");
|
printf("Insifficient memory for pixel buffer [B9]");
|
||||||
return ERROR_ENCODING_PROBLEM;
|
return ERROR_ENCODING_PROBLEM;
|
||||||
} else {
|
} else {
|
||||||
for(i = 0; i < (image_width * image_height); i++) {
|
for(i = 0; i < (image_width * image_height); i++) {
|
||||||
@ -503,7 +503,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
|
|||||||
image_height = 2 * (symbol->height + textoffset + yoffset + yoffset);
|
image_height = 2 * (symbol->height + textoffset + yoffset + yoffset);
|
||||||
|
|
||||||
if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
|
if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
|
||||||
printf("Insifficient memory for pixel buffer");
|
printf("Insifficient memory for pixel buffer [BA]");
|
||||||
return ERROR_ENCODING_PROBLEM;
|
return ERROR_ENCODING_PROBLEM;
|
||||||
} else {
|
} else {
|
||||||
for(i = 0; i < (image_width * image_height); i++) {
|
for(i = 0; i < (image_width * image_height); i++) {
|
||||||
|
@ -57,12 +57,12 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 90) {
|
if(ustrlen(source) > 90) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [401]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [402]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
sum = 0;
|
sum = 0;
|
||||||
@ -133,12 +133,12 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 90) {
|
if(ustrlen(source) > 90) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [821]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [822]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
sum = 0;
|
sum = 0;
|
||||||
@ -212,12 +212,12 @@ int fim(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
to_upper(source);
|
to_upper(source);
|
||||||
if(ustrlen(source) > 1) {
|
if(ustrlen(source) > 1) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [491]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(BESET, source);
|
error_number = is_sane(BESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [492]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
lookup(BESET, FIMTable, source[0], dest);
|
lookup(BESET, FIMTable, source[0], dest);
|
||||||
@ -275,12 +275,12 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
to_upper(source);
|
to_upper(source);
|
||||||
if(ustrlen(source) > 120) {
|
if(ustrlen(source) > 120) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [701]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(KRSET, source);
|
error_number = is_sane(KRSET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [702]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
check = rm4scc((char*)source, (unsigned char*)height_pattern);
|
check = rm4scc((char*)source, (unsigned char*)height_pattern);
|
||||||
@ -329,12 +329,12 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
to_upper(source);
|
to_upper(source);
|
||||||
if(ustrlen(source) != 11) {
|
if(ustrlen(source) != 11) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [901]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(KRSET, source);
|
error_number = is_sane(KRSET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [902]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ustrlen(source); i++) {
|
for (i = 0; i < ustrlen(source); i++) {
|
||||||
@ -380,7 +380,7 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
input_length = ustrlen(source);
|
input_length = ustrlen(source);
|
||||||
strcpy(local_source, (char*)source);
|
strcpy(local_source, (char*)source);
|
||||||
if(input_length > 50) {
|
if(input_length > 50) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long [931]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
to_upper((unsigned char*)local_source);
|
to_upper((unsigned char*)local_source);
|
||||||
@ -428,12 +428,12 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 90) {
|
if(ustrlen(source) > 90) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [281]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [282]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
backend/ps.c
10
backend/ps.c
@ -52,7 +52,7 @@ int ps_plot(struct zint_symbol *symbol)
|
|||||||
|
|
||||||
feps = fopen(symbol->outfile, "w");
|
feps = fopen(symbol->outfile, "w");
|
||||||
if(feps == NULL) {
|
if(feps == NULL) {
|
||||||
strcpy(symbol->errtxt, "error: could not open output file");
|
strcpy(symbol->errtxt, "Could not open output file [C1]");
|
||||||
return ERROR_FILE_ACCESS;
|
return ERROR_FILE_ACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,21 +61,21 @@ int ps_plot(struct zint_symbol *symbol)
|
|||||||
to_upper((unsigned char*)symbol->bgcolour);
|
to_upper((unsigned char*)symbol->bgcolour);
|
||||||
|
|
||||||
if(strlen(symbol->fgcolour) != 6) {
|
if(strlen(symbol->fgcolour) != 6) {
|
||||||
strcpy(symbol->errtxt, "error: malformed foreground colour target");
|
strcpy(symbol->errtxt, "Malformed foreground colour target [C2]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
if(strlen(symbol->bgcolour) != 6) {
|
if(strlen(symbol->bgcolour) != 6) {
|
||||||
strcpy(symbol->errtxt, "error: malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target [C3]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour);
|
error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: malformed foreground colour target");
|
strcpy(symbol->errtxt, "Malformed foreground colour target [C4]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour);
|
error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target [C5]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
code = encode(symbol->option_1, symbol->option_2, source);
|
code = encode(symbol->option_1, symbol->option_2, source);
|
||||||
if(code == NULL) {
|
if(code == NULL) {
|
||||||
strcpy(symbol->errtxt, "error: libqrencode failed to encode the input data");
|
strcpy(symbol->errtxt, "libqrencode failed to encode the input data [581]");
|
||||||
return ERROR_ENCODING_PROBLEM;
|
return ERROR_ENCODING_PROBLEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* Handler if no QR Encode library is available */
|
/* Handler if no QR Encode library is available */
|
||||||
int qr_code(struct zint_symbol *symbol, unsigned char source[])
|
int qr_code(struct zint_symbol *symbol, unsigned char source[])
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: QR Code library <qrencode> not available");
|
strcpy(symbol->errtxt, "QR Code library <qrencode> not available [580]");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -150,12 +150,12 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
separator_row = 0;
|
separator_row = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 13) {
|
if(ustrlen(source) > 13) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [291]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [292]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,12 +647,12 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
separator_row = 0;
|
separator_row = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 13) {
|
if(ustrlen(source) > 13) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [301]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [302]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1189,7 +1189,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
|
|||||||
if((source[i] < '0') || (source[i] > '9')) {
|
if((source[i] < '0') || (source[i] > '9')) {
|
||||||
if((source[i] != '[') && (source[i] != ']')) {
|
if((source[i] != '[') && (source[i] != ']')) {
|
||||||
/* Something is wrong */
|
/* Something is wrong */
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data [314]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1560,7 +1560,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
|
|||||||
|
|
||||||
if(latch == 1) {
|
if(latch == 1) {
|
||||||
/* Invalid characters in input data */
|
/* Invalid characters in input data */
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data [315]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1793,7 +1793,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(strlen(binary_string) > 252) {
|
if(strlen(binary_string) > 252) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [316]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1841,14 +1841,14 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
reader=0;
|
reader=0;
|
||||||
|
|
||||||
if(source[0] != '[') {
|
if(source[0] != '[') {
|
||||||
strcpy(symbol->errtxt, "Data does not start with an AI");
|
strcpy(symbol->errtxt, "Data does not start with an AI [311]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source) - 1; i++) {
|
for(i = 0; i < ustrlen(source) - 1; i++) {
|
||||||
if((source[i] == '[') && (source[i + 1] == '[')) {
|
if((source[i] == '[') && (source[i + 1] == '[')) {
|
||||||
/* Can't have nested brackets - Quit */
|
/* Can't have nested brackets - Quit */
|
||||||
strcpy(symbol->errtxt, "Nested AI detected (two or more open brackets)");
|
strcpy(symbol->errtxt, "Nested AI detected (two or more open brackets) [312]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1856,7 +1856,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
for(i = 0; i < ustrlen(source) - 1; i++) {
|
for(i = 0; i < ustrlen(source) - 1; i++) {
|
||||||
if((source[i] == ']') && (source[i + 1] == ']')) {
|
if((source[i] == ']') && (source[i + 1] == ']')) {
|
||||||
/* Can't have nested brackets - Quit */
|
/* Can't have nested brackets - Quit */
|
||||||
strcpy(symbol->errtxt, "Nested AI detected (two or more close brackets)");
|
strcpy(symbol->errtxt, "Nested AI detected (two or more close brackets) [313]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,14 +62,14 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 30) {
|
if(ustrlen(source) > 30) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [321]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < ustrlen(source); i++) {
|
||||||
if(source[i] > 127) {
|
if(source[i] > 127) {
|
||||||
/* Cannot encode extended ASCII */
|
/* Cannot encode extended ASCII */
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data [322]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,13 +111,13 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
if(input_length > 60) {
|
if(input_length > 60) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [871]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
to_upper(local_source);
|
to_upper(local_source);
|
||||||
error_number = is_sane(NASET, local_source);
|
error_number = is_sane(NASET, local_source);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [872]");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
for (i=0; i < input_length; i+=2)
|
for (i=0; i < input_length; i+=2)
|
||||||
{
|
{
|
||||||
if(local_source[i] == 'X') {
|
if(local_source[i] == 'X') {
|
||||||
strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
|
strcpy(symbol->errtxt, "Invalid position of X in Telepen data [873]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
equivalent[10] = source[4];
|
equivalent[10] = source[4];
|
||||||
if(((source[2] == '0') || (source[2] == '1')) || (source[2] == '2')) {
|
if(((source[2] == '0') || (source[2] == '1')) || (source[2] == '2')) {
|
||||||
/* Note 1 - "X3 shall not be equal to 0, 1 or 2" */
|
/* Note 1 - "X3 shall not be equal to 0, 1 or 2" */
|
||||||
strcpy(symbol->errtxt, "warning: invalid UPC-E data");
|
strcpy(symbol->errtxt, "Invalid UPC-E data [371]");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
@ -160,7 +160,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
equivalent[10] = source[4];
|
equivalent[10] = source[4];
|
||||||
if(source[3] == '0') {
|
if(source[3] == '0') {
|
||||||
/* Note 2 - "X4 shall not be equal to 0" */
|
/* Note 2 - "X4 shall not be equal to 0" */
|
||||||
strcpy(symbol->errtxt, "warning: invalid UPC-E data");
|
strcpy(symbol->errtxt, "Invalid UPC-E data [372]");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '5':
|
case '5':
|
||||||
@ -174,7 +174,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
equivalent[10] = emode;
|
equivalent[10] = emode;
|
||||||
if(source[4] == '0') {
|
if(source[4] == '0') {
|
||||||
/* Note 3 - "X5 shall not be equal to 0" */
|
/* Note 3 - "X5 shall not be equal to 0" */
|
||||||
strcpy(symbol->errtxt, "warning: invalid UPC-E data");
|
strcpy(symbol->errtxt, "Invalid UPC-E data [373]");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -403,14 +403,14 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
|
|||||||
to_upper(source);
|
to_upper(source);
|
||||||
errno = is_sane("0123456789X", source);
|
errno = is_sane("0123456789X", source);
|
||||||
if(errno == ERROR_INVALID_DATA) {
|
if(errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in input");
|
strcpy(symbol->errtxt, "Invalid characters in input [691]");
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Input must be 9, 10 or 13 characters */
|
/* Input must be 9, 10 or 13 characters */
|
||||||
if(((ustrlen(source) < 9) || (ustrlen(source) > 13)) || ((ustrlen(source) > 10) && (ustrlen(source) < 13)))
|
if(((ustrlen(source) < 9) || (ustrlen(source) > 13)) || ((ustrlen(source) > 10) && (ustrlen(source) < 13)))
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length [692]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,14 +419,14 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
|
|||||||
if(!(((source[0] == '9') && (source[1] == '7')) &&
|
if(!(((source[0] == '9') && (source[1] == '7')) &&
|
||||||
((source[2] == '8') || (source[2] == '9'))))
|
((source[2] == '8') || (source[2] == '9'))))
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: invalid ISBN");
|
strcpy(symbol->errtxt, "Invalid ISBN [693]");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_digit = isbn13_check(source);
|
check_digit = isbn13_check(source);
|
||||||
if (source[ustrlen(source) - 1] != check_digit)
|
if (source[ustrlen(source) - 1] != check_digit)
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: incorrect ISBN check");
|
strcpy(symbol->errtxt, "Incorrect ISBN check [694]");
|
||||||
return ERROR_INVALID_CHECK;
|
return ERROR_INVALID_CHECK;
|
||||||
}
|
}
|
||||||
source[12] = '\0';
|
source[12] = '\0';
|
||||||
@ -439,7 +439,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
|
|||||||
check_digit = isbn_check(source);
|
check_digit = isbn_check(source);
|
||||||
if(check_digit != source[ustrlen(source) - 1])
|
if(check_digit != source[ustrlen(source) - 1])
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: incorrect ISBN check");
|
strcpy(symbol->errtxt, "Incorrect ISBN check [695]");
|
||||||
return ERROR_INVALID_CHECK;
|
return ERROR_INVALID_CHECK;
|
||||||
}
|
}
|
||||||
for(i = 13; i > 0; i--)
|
for(i = 13; i > 0; i--)
|
||||||
@ -467,7 +467,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
|
|||||||
check_digit = isbn_check(source);
|
check_digit = isbn_check(source);
|
||||||
if(check_digit != source[ustrlen(source) - 1])
|
if(check_digit != source[ustrlen(source) - 1])
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "error: incorrect SBN check");
|
strcpy(symbol->errtxt, "Incorrect SBN check [696]");
|
||||||
return ERROR_INVALID_CHECK;
|
return ERROR_INVALID_CHECK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,14 +504,14 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
writer = 0;
|
writer = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 19) {
|
if(ustrlen(source) > 19) {
|
||||||
strcpy(symbol->errtxt, "error: input too long");
|
strcpy(symbol->errtxt, "Input too long [131]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
if(symbol->symbology != BARCODE_ISBNX) {
|
if(symbol->symbology != BARCODE_ISBNX) {
|
||||||
/* ISBN has it's own checking routine */
|
/* ISBN has it's own checking routine */
|
||||||
errno = is_sane(NASET, source);
|
errno = is_sane(NASET, source);
|
||||||
if(errno == ERROR_INVALID_DATA) {
|
if(errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "error: invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data [132]");
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
case 5: add_on(first_part, (char*)dest, 0); strcpy(symbol->text, (char*)first_part); break;
|
case 5: add_on(first_part, (char*)dest, 0); strcpy(symbol->text, (char*)first_part); break;
|
||||||
case 7: ean8(symbol, first_part, (char*)dest); break;
|
case 7: ean8(symbol, first_part, (char*)dest); break;
|
||||||
case 12: ean13(symbol, first_part, (char*)dest); break;
|
case 12: ean13(symbol, first_part, (char*)dest); break;
|
||||||
default: strcpy(symbol->errtxt, "error: invalid length input"); return ERROR_TOO_LONG; break;
|
default: strcpy(symbol->errtxt, "Invalid length input [133]"); return ERROR_TOO_LONG; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_EANX_CC:
|
case BARCODE_EANX_CC:
|
||||||
@ -583,14 +583,14 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
symbol->row_height[symbol->rows + 2] = 2;
|
symbol->row_height[symbol->rows + 2] = 2;
|
||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
ean13(symbol, first_part, (char*)dest); break;
|
ean13(symbol, first_part, (char*)dest); break;
|
||||||
default: strcpy(symbol->errtxt, "error: invalid length EAN input"); return ERROR_TOO_LONG; break;
|
default: strcpy(symbol->errtxt, "Invalid length EAN input [134]"); return ERROR_TOO_LONG; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCA:
|
case BARCODE_UPCA:
|
||||||
if(ustrlen(first_part) == 11) {
|
if(ustrlen(first_part) == 11) {
|
||||||
upca(symbol, first_part, (char*)dest);
|
upca(symbol, first_part, (char*)dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length [135]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -608,7 +608,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
upca(symbol, first_part, (char*)dest);
|
upca(symbol, first_part, (char*)dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: UPCA input wrong length");
|
strcpy(symbol->errtxt, "UPCA input wrong length [136]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -616,7 +616,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 7)) {
|
if((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 7)) {
|
||||||
upce(symbol, first_part, (char*)dest);
|
upce(symbol, first_part, (char*)dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length [137]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -634,7 +634,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
upce(symbol, first_part, (char*)dest);
|
upce(symbol, first_part, (char*)dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: UPCE input wrong length");
|
strcpy(symbol->errtxt, "UPCE input wrong length [138]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -659,7 +659,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
concat(symbol->text, (char*)second_part);
|
concat(symbol->text, (char*)second_part);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(symbol->errtxt, "error: invalid length input");
|
strcpy(symbol->errtxt, "Invalid length input [139]");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ int data_process(struct zint_symbol *symbol, unsigned char source[], int rotate_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(next == -1) {
|
if(next == -1) {
|
||||||
strcpy(symbol->errtxt, "Invalid character in input string (only Latin-1 characters supported)");
|
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
|
||||||
error_number = WARN_INVALID_OPTION;
|
error_number = ERROR_INVALID_DATA;
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
i = next;
|
i = next;
|
||||||
@ -160,9 +160,11 @@ int main(int argc, char **argv)
|
|||||||
int c;
|
int c;
|
||||||
int error_number;
|
int error_number;
|
||||||
int rotate_angle;
|
int rotate_angle;
|
||||||
|
int generated;
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
rotate_angle = 0;
|
rotate_angle = 0;
|
||||||
|
generated = 0;
|
||||||
my_symbol = ZBarcode_Create();
|
my_symbol = ZBarcode_Create();
|
||||||
|
|
||||||
if(argc == 1) {
|
if(argc == 1) {
|
||||||
@ -301,7 +303,7 @@ int main(int argc, char **argv)
|
|||||||
case 'b':
|
case 'b':
|
||||||
error_number = validator(NESET, optarg);
|
error_number = validator(NESET, optarg);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
printf("Invalid barcode type\n");
|
fprintf(stderr, "Invalid barcode type\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
my_symbol->symbology = atoi(optarg);
|
my_symbol->symbology = atoi(optarg);
|
||||||
@ -310,7 +312,7 @@ int main(int argc, char **argv)
|
|||||||
case 'w':
|
case 'w':
|
||||||
error_number = validator(NESET, optarg);
|
error_number = validator(NESET, optarg);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
printf("Invalid whitespace value\n");
|
fprintf(stderr, "Invalid whitespace value\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if((atoi(optarg) >= 0) && (atoi(optarg) <= 1000)) {
|
if((atoi(optarg) >= 0) && (atoi(optarg) <= 1000)) {
|
||||||
@ -322,8 +324,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
case 'd': /* we have some data! */
|
case 'd': /* we have some data! */
|
||||||
error_number = data_process(my_symbol, (unsigned char*)optarg, rotate_angle);
|
error_number = data_process(my_symbol, (unsigned char*)optarg, rotate_angle);
|
||||||
|
generated = 1;
|
||||||
if(error_number != 0) {
|
if(error_number != 0) {
|
||||||
printf("%s\n", my_symbol->errtxt);
|
fprintf(stderr, "%s\n", my_symbol->errtxt);
|
||||||
ZBarcode_Delete(my_symbol);
|
ZBarcode_Delete(my_symbol);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -342,21 +345,21 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("?? getopt error 0%o\n", c);
|
fprintf(stderr, "?? getopt error 0%o\n", c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
printf("Invalid option ");
|
fprintf(stderr, "Invalid option ");
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
printf("%s", argv[optind++]);
|
fprintf(stderr, "%s", argv[optind++]);
|
||||||
printf("\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strcmp(my_symbol->errtxt, "")) {
|
if(generated == 0) {
|
||||||
printf(my_symbol->errtxt);
|
fprintf(stderr, "error: No data received, no symbol generated\n");
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZBarcode_Delete(my_symbol);
|
ZBarcode_Delete(my_symbol);
|
||||||
|
|
||||||
return error_number;
|
return error_number;
|
||||||
|
Loading…
Reference in New Issue
Block a user