Avoid possible confusion with Windows error code

Bugfix by Oxy Genic
Ref: https://sourceforge.net/p/zint/mailman/message/34857131/
This commit is contained in:
Robin Stuart 2016-02-17 10:37:20 +00:00
parent 7ae95b2b42
commit 2e59058615
31 changed files with 3878 additions and 3878 deletions

View File

@ -63,10 +63,10 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int l
if(length > 80) { if(length > 80) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -96,10 +96,10 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], i
if(length > 45) { if(length > 45) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid character in data"); strcpy(symbol->errtxt, "Invalid character in data");
return error_number; return error_number;
} }
@ -128,10 +128,10 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int len
if(length > 45) { if(length > 45) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -161,10 +161,10 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int le
if(length > 80) { if(length > 80) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -199,10 +199,10 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[],
if(length > 89) { if(length > 89) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if (error_number == ERROR_INVALID_DATA) { if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -260,11 +260,11 @@ int itf14(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 13) { if(length > 13) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid character in data"); strcpy(symbol->errtxt, "Invalid character in data");
return error_number; return error_number;
} }
@ -303,10 +303,10 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[], int length)
count = 0; count = 0;
if(length > 13) { if(length > 13) {
strcpy(symbol->errtxt, "Input wrong length"); strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -340,10 +340,10 @@ int dpident(struct zint_symbol *symbol, unsigned char source[], int length)
count = 0; count = 0;
if(length > 11) { if(length > 11) {
strcpy(symbol->errtxt, "Input wrong length"); strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }

View File

@ -140,16 +140,16 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt
break; break;
default: default:
strcpy(symbol->errtxt, "Auspost input is wrong length"); strcpy(symbol->errtxt, "Auspost input is wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
} else { } else {
if (length > 8) { if (length > 8) {
strcpy(symbol->errtxt, "Auspost input is too long"); strcpy(symbol->errtxt, "Auspost input is too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
switch(symbol->symbology) { switch(symbol->symbology) {
case BARCODE_AUSREPLY: strcpy(fcc, "45"); break; case BARCODE_AUSREPLY: strcpy(fcc, "45"); break;
@ -166,7 +166,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt
concat(localstr, (char*)source); concat(localstr, (char*)source);
h = strlen(localstr); h = strlen(localstr);
error_number = is_sane(GDSET, (unsigned char *)localstr, h); error_number = is_sane(GDSET, (unsigned char *)localstr, h);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -175,7 +175,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt
memcpy(dpid, localstr, 8); memcpy(dpid, localstr, 8);
dpid[8] = '\0'; dpid[8] = '\0';
error_number = is_sane(NEON, (unsigned char *)dpid, strlen(dpid)); error_number = is_sane(NEON, (unsigned char *)dpid, strlen(dpid));
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in DPID"); strcpy(symbol->errtxt, "Invalid characters in DPID");
return error_number; return error_number;
} }

View File

@ -588,7 +588,7 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char
bytes--; bytes--;
if(bytes > 2079) { if(bytes > 2079) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(bytes > 31) { /* Put 00000 followed by 11-bit number of bytes less 31 */ if(bytes > 31) { /* Put 00000 followed by 11-bit number of bytes less 31 */
@ -660,7 +660,7 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char
if(debug) printf("\n"); if(debug) printf("\n");
if(strlen(binary_string) > 14970) { if(strlen(binary_string) > 14970) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
return 0; return 0;
@ -847,7 +847,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length)
if(symbol->output_options & READER_INIT) { reader = 1; comp_loop = 1; } if(symbol->output_options & READER_INIT) { reader = 1; comp_loop = 1; }
if((gs1 == 1) && (reader == 1)) { if((gs1 == 1) && (reader == 1)) {
strcpy(symbol->errtxt, "Cannot encode in GS1 and Reader Initialisation mode at the same time"); strcpy(symbol->errtxt, "Cannot encode in GS1 and Reader Initialisation mode at the same time");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
switch(symbol->input_mode) { switch(symbol->input_mode) {
@ -872,7 +872,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length)
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");
err_code = WARN_INVALID_OPTION; err_code = ZINT_WARN_INVALID_OPTION;
symbol->option_1 = -1; symbol->option_1 = -1;
} }
@ -960,7 +960,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length)
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)");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Determine codeword bitlength - Table 3 */ /* Determine codeword bitlength - Table 3 */
@ -1053,7 +1053,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length)
} }
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");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
/* Determine codeword bitlength - Table 3 */ /* Determine codeword bitlength - Table 3 */
@ -1124,7 +1124,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length)
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");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(debug) { if(debug) {
@ -1141,7 +1141,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length)
if(reader && (layers > 22)) { if(reader && (layers > 22)) {
strcpy(symbol->errtxt, "Data too long for reader initialisation symbol"); strcpy(symbol->errtxt, "Data too long for reader initialisation symbol");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
data_blocks = adjusted_length / codeword_size; data_blocks = adjusted_length / codeword_size;
@ -1437,12 +1437,12 @@ int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length)
input_value = 0; input_value = 0;
if(length > 3) { if(length > 3) {
strcpy(symbol->errtxt, "Input too large"); strcpy(symbol->errtxt, "Input too large");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number != 0) { if(error_number != 0) {
strcpy(symbol->errtxt, "Invalid characters in input"); strcpy(symbol->errtxt, "Invalid characters in input");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
switch(length) { switch(length) {
case 3: input_value = 100 * ctoi(source[0]); case 3: input_value = 100 * ctoi(source[0]);
@ -1458,7 +1458,7 @@ int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length)
if(input_value > 255) { if(input_value > 255) {
strcpy(symbol->errtxt, "Input too large"); strcpy(symbol->errtxt, "Input too large");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
strcpy(binary_string, ""); strcpy(binary_string, "");

View File

@ -109,10 +109,10 @@ int code_11(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 121) { if(length > 121) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(SODIUM, source, length); error_number = is_sane(SODIUM, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -193,14 +193,14 @@ int c39(struct zint_symbol *symbol, unsigned char source[], int length)
if((symbol->symbology == BARCODE_LOGMARS) && (length > 59)) { if((symbol->symbology == BARCODE_LOGMARS) && (length > 59)) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} else if(length > 74) { } else if(length > 74) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
to_upper(source); to_upper(source);
error_number = is_sane(SILVER , source, length); error_number = is_sane(SILVER , source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -284,10 +284,10 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length
count = 0; count = 0;
if(length > 6) { if(length > 6) {
strcpy(symbol->errtxt, "Input wrong length"); strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -308,7 +308,7 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length
localstr[8] = '\0'; localstr[8] = '\0';
if(localstr[7] == 'A') { if(localstr[7] == 'A') {
strcpy(symbol->errtxt, "Invalid PZN Data"); strcpy(symbol->errtxt, "Invalid PZN Data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
error_number = c39(symbol, (unsigned char *)localstr, strlen(localstr)); error_number = c39(symbol, (unsigned char *)localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char *)"PZN"); ustrcpy(symbol->text, (unsigned char *)"PZN");
@ -330,7 +330,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 74) { if(length > 74) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Creates a buffer string and places control characters into it */ /* Creates a buffer string and places control characters into it */
@ -338,7 +338,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[], int length)
if(source[i] > 127) { if(source[i] > 127) {
/* Cannot encode extended ASCII */ /* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "Invalid characters in input data"); strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
concat((char*)buffer, EC39Ctrl[source[i]]); concat((char*)buffer, EC39Ctrl[source[i]]);
} }
@ -373,7 +373,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 107) { if(length > 107) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Message Content */ /* Message Content */
@ -381,7 +381,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[], int length)
if (source[i] > 127) { if (source[i] > 127) {
/* Cannot encode extended ASCII */ /* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "Invalid characters in input data"); strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
concat(buffer, C93Ctrl[source[i]]); concat(buffer, C93Ctrl[source[i]]);
symbol->text[i] = source[i] ? source[i] : ' '; symbol->text[i] = source[i] ? source[i] : ' ';
@ -391,7 +391,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[], int length)
h = strlen(buffer); h = strlen(buffer);
if (h > 107) { if (h > 107) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
@ -506,10 +506,10 @@ int channel_code(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 7) { if(length > 7) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -533,7 +533,7 @@ int channel_code(struct zint_symbol *symbol, unsigned char source[], int length)
} }
if(range) { if(range) {
strcpy(symbol->errtxt, "Value out of range"); strcpy(symbol->errtxt, "Value out of range");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
for(i = 0; i < 11; i++) { B[i] = 0; S[i] = 0; } for(i = 0; i < 11; i++) { B[i] = 0; S[i] = 0; }

View File

@ -1031,7 +1031,7 @@ int code_one(struct zint_symbol *symbol, unsigned char source[], int length)
if((symbol->option_2 < 0) || (symbol->option_2 > 10)) { if((symbol->option_2 < 0) || (symbol->option_2 > 10)) {
strcpy(symbol->errtxt, "Invalid symbol size"); strcpy(symbol->errtxt, "Invalid symbol size");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if(symbol->option_2 == 9) { if(symbol->option_2 == 9) {
@ -1044,11 +1044,11 @@ int code_one(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 18) { if(length > 18) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(is_sane(NEON, source, length) == ERROR_INVALID_DATA) { if(is_sane(NEON, source, length) == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid input data (Version S encodes numeric input only)"); strcpy(symbol->errtxt, "Invalid input data (Version S encodes numeric input only)");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
sub_version = 3; codewords = 12; block_width = 6; /* Version S-30 */ sub_version = 3; codewords = 12; block_width = 6; /* Version S-30 */
@ -1120,12 +1120,12 @@ int code_one(struct zint_symbol *symbol, unsigned char source[], int length)
data_length = c1_encode(symbol, source, data, length); data_length = c1_encode(symbol, source, data, length);
if(data_length == 0) { if(data_length == 0) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(data_length > 38) { if(data_length > 38) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
size = 10; size = 10;
@ -1187,7 +1187,7 @@ int code_one(struct zint_symbol *symbol, unsigned char source[], int length)
data_length = c1_encode(symbol, source, data, length); data_length = c1_encode(symbol, source, data, length);
if(data_length == 0) { if(data_length == 0) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
for(i = 7; i >= 0; i--) { for(i = 7; i >= 0; i--) {

View File

@ -236,7 +236,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length)
/* 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, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Detect extended ASCII characters */ /* Detect extended ASCII characters */
@ -403,7 +403,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length)
} }
if(glyph_count > 80.0) { if(glyph_count > 80.0) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* So now we know what start character to use - we can get on with it! */ /* So now we know what start character to use - we can get on with it! */
@ -635,13 +635,13 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length)
/* 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, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
if(source[i] == '\0') { if(source[i] == '\0') {
/* Null characters not allowed! */ /* Null characters not allowed! */
strcpy(symbol->errtxt, "NULL character in input data"); strcpy(symbol->errtxt, "NULL character in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
@ -766,7 +766,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length)
} }
if(glyph_count > 80.0) { if(glyph_count > 80.0) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* So now we know what start character to use - we can get on with it! */ /* So now we know what start character to use - we can get on with it! */
@ -939,11 +939,11 @@ int nve_18(struct zint_symbol *symbol, unsigned char source[], int length)
if(sourcelen > 17) { if(sourcelen > 17) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -980,11 +980,11 @@ int ean_14(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 13) { if(length > 13) {
strcpy(symbol->errtxt, "Input wrong length"); strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid character in data"); strcpy(symbol->errtxt, "Invalid character in data");
return error_number; return error_number;
} }

View File

@ -200,7 +200,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length)
if(input_length > 157) { if(input_length > 157) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
bar_characters = 0; bar_characters = 0;
@ -390,7 +390,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length)
if(glyph_count > 77.0) { if(glyph_count > 77.0) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Calculate how tall the symbol will be */ /* Calculate how tall the symbol will be */
@ -415,7 +415,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length)
if(m == 2) { m = 5; } if(m == 2) { m = 5; }
if(gs1) { if(gs1) {
strcpy(symbol->errtxt, "Cannot use both GS1 mode and Reader Initialisation"); strcpy(symbol->errtxt, "Cannot use both GS1 mode and Reader Initialisation");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} else { } else {
if((set[0] == 'B') && (set[1] == 'C')) { m = 6; } if((set[0] == 'B') && (set[1] == 'C')) { m = 6; }
} }

View File

@ -52,7 +52,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 81) { if(length > 81) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; } if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
@ -60,7 +60,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
if(source[i] > 127) { if(source[i] > 127) {
strcpy(symbol->errtxt, "Invalid characters in input data"); strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(gs1 && (source[i] == '[')) if(gs1 && (source[i] == '['))
concat(intermediate, "*"); /* FNC1 */ concat(intermediate, "*"); /* FNC1 */
@ -206,7 +206,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
if(codeword_count > 49) { if(codeword_count > 49) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Place codewords in code character array (c grid) */ /* Place codewords in code character array (c grid) */

View File

@ -112,7 +112,7 @@ int is_sane(char test_string[], unsigned char source[], int length)
} }
} }
if (!(latch)) { if (!(latch)) {
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
@ -321,7 +321,7 @@ int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned
} }
if(next == -1) { if(next == -1) {
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)"); strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
i = next; i = next;
} while(i < *length); } while(i < *length);
@ -350,11 +350,11 @@ int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[],
} else { } else {
if((source[bpos] >= 0x80) && (source[bpos] <= 0xbf)) { if((source[bpos] >= 0x80) && (source[bpos] <= 0xbf)) {
strcpy(symbol->errtxt, "Corrupt Unicode data"); strcpy(symbol->errtxt, "Corrupt Unicode data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if((source[bpos] >= 0xc0) && (source[bpos] <= 0xc1)) { if((source[bpos] >= 0xc0) && (source[bpos] <= 0xc1)) {
strcpy(symbol->errtxt, "Overlong encoding not supported"); strcpy(symbol->errtxt, "Overlong encoding not supported");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if((source[bpos] >= 0xc2) && (source[bpos] <= 0xdf)) { if((source[bpos] >= 0xc2) && (source[bpos] <= 0xdf)) {
@ -371,7 +371,7 @@ int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[],
} else } else
if(source[bpos] >= 0xf0) { if(source[bpos] >= 0xf0) {
strcpy(symbol->errtxt, "Unicode sequences of more than 3 bytes not supported"); strcpy(symbol->errtxt, "Unicode sequences of more than 3 bytes not supported");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }

View File

@ -863,7 +863,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
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, "Invalid AI 90 data"); strcpy(symbol->errtxt, "Invalid AI 90 data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
} }
@ -1186,7 +1186,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
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");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
for(i = 0; i < strlen(general_field); i++) { for(i = 0; i < strlen(general_field); i++) {
@ -1382,7 +1382,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
/* CC-A 2D component - calculate remaining space */ /* CC-A 2D component - calculate remaining space */
switch(*(cc_width)) { switch(*(cc_width)) {
case 2: case 2:
if(binary_length > 167) { return ERROR_TOO_LONG; } if(binary_length > 167) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(binary_length <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(binary_length <= 118) { target_bitsize = 118; } if(binary_length <= 118) { target_bitsize = 118; }
@ -1392,7 +1392,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(binary_length <= 59) { target_bitsize = 59; } if(binary_length <= 59) { target_bitsize = 59; }
break; break;
case 3: case 3:
if(binary_length > 167) { return ERROR_TOO_LONG; } if(binary_length > 167) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(binary_length <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(binary_length <= 118) { target_bitsize = 118; } if(binary_length <= 118) { target_bitsize = 118; }
@ -1400,7 +1400,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(binary_length <= 78) { target_bitsize = 78; } if(binary_length <= 78) { target_bitsize = 78; }
break; break;
case 4: case 4:
if(binary_length > 197) { return ERROR_TOO_LONG; } if(binary_length > 197) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 197) { target_bitsize = 197; } if(binary_length <= 197) { target_bitsize = 197; }
if(binary_length <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(binary_length <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
@ -1414,7 +1414,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
/* CC-B 2D component - calculated from ISO/IEC 24728 Table 1 */ /* CC-B 2D component - calculated from ISO/IEC 24728 Table 1 */
switch(*(cc_width)) { switch(*(cc_width)) {
case 2: case 2:
if(binary_length > 336) { return ERROR_TOO_LONG; } if(binary_length > 336) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 336) { target_bitsize = 336; } if(binary_length <= 336) { target_bitsize = 336; }
if(binary_length <= 296) { target_bitsize = 296; } if(binary_length <= 296) { target_bitsize = 296; }
if(binary_length <= 256) { target_bitsize = 256; } if(binary_length <= 256) { target_bitsize = 256; }
@ -1424,7 +1424,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(binary_length <= 56) { target_bitsize = 56; } if(binary_length <= 56) { target_bitsize = 56; }
break; break;
case 3: case 3:
if(binary_length > 768) { return ERROR_TOO_LONG; } if(binary_length > 768) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 768) { target_bitsize = 768; } if(binary_length <= 768) { target_bitsize = 768; }
if(binary_length <= 648) { target_bitsize = 648; } if(binary_length <= 648) { target_bitsize = 648; }
if(binary_length <= 536) { target_bitsize = 536; } if(binary_length <= 536) { target_bitsize = 536; }
@ -1437,7 +1437,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(binary_length <= 32) { target_bitsize = 32; } if(binary_length <= 32) { target_bitsize = 32; }
break; break;
case 4: case 4:
if(binary_length > 1184) { return ERROR_TOO_LONG; } if(binary_length > 1184) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 1184) { target_bitsize = 1184; } if(binary_length <= 1184) { target_bitsize = 1184; }
if(binary_length <= 1016) { target_bitsize = 1016; } if(binary_length <= 1016) { target_bitsize = 1016; }
if(binary_length <= 840) { target_bitsize = 840; } if(binary_length <= 840) { target_bitsize = 840; }
@ -1480,7 +1480,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
codewords_used += 3; codewords_used += 3;
if(codewords_used > symbol->option_3) { if(codewords_used > symbol->option_3) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* *(cc_width) = 0.5 + sqrt((codewords_used) / 3); */ /* *(cc_width) = 0.5 + sqrt((codewords_used) / 3); */
*(cc_width) = (lin_width - 62) / 17; *(cc_width) = (lin_width - 62) / 17;
@ -1545,7 +1545,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(strlen(binary_string) > 11805) { /* (2361 * 5) */ if(strlen(binary_string) > 11805) { /* (2361 * 5) */
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* all the code below is repeated from above - it needs to be calculated again because the /* all the code below is repeated from above - it needs to be calculated again because the
@ -1556,7 +1556,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
/* CC-A 2D component - calculate padding required */ /* CC-A 2D component - calculate padding required */
switch(*(cc_width)) { switch(*(cc_width)) {
case 2: case 2:
if(binary_length > 167) { return ERROR_TOO_LONG; } if(binary_length > 167) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(binary_length <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(binary_length <= 118) { target_bitsize = 118; } if(binary_length <= 118) { target_bitsize = 118; }
@ -1566,7 +1566,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(binary_length <= 59) { target_bitsize = 59; } if(binary_length <= 59) { target_bitsize = 59; }
break; break;
case 3: case 3:
if(binary_length > 167) { return ERROR_TOO_LONG; } if(binary_length > 167) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(binary_length <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(binary_length <= 118) { target_bitsize = 118; } if(binary_length <= 118) { target_bitsize = 118; }
@ -1574,7 +1574,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(binary_length <= 78) { target_bitsize = 78; } if(binary_length <= 78) { target_bitsize = 78; }
break; break;
case 4: case 4:
if(binary_length > 197) { return ERROR_TOO_LONG; } if(binary_length > 197) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 197) { target_bitsize = 197; } if(binary_length <= 197) { target_bitsize = 197; }
if(binary_length <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(binary_length <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
@ -1588,7 +1588,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
/* CC-B 2D component */ /* CC-B 2D component */
switch(*(cc_width)) { switch(*(cc_width)) {
case 2: case 2:
if(binary_length > 336) { return ERROR_TOO_LONG; } if(binary_length > 336) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 336) { target_bitsize = 336; } if(binary_length <= 336) { target_bitsize = 336; }
if(binary_length <= 296) { target_bitsize = 296; } if(binary_length <= 296) { target_bitsize = 296; }
if(binary_length <= 256) { target_bitsize = 256; } if(binary_length <= 256) { target_bitsize = 256; }
@ -1598,7 +1598,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(binary_length <= 56) { target_bitsize = 56; } if(binary_length <= 56) { target_bitsize = 56; }
break; break;
case 3: case 3:
if(binary_length > 768) { return ERROR_TOO_LONG; } if(binary_length > 768) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 768) { target_bitsize = 768; } if(binary_length <= 768) { target_bitsize = 768; }
if(binary_length <= 648) { target_bitsize = 648; } if(binary_length <= 648) { target_bitsize = 648; }
if(binary_length <= 536) { target_bitsize = 536; } if(binary_length <= 536) { target_bitsize = 536; }
@ -1611,7 +1611,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
if(binary_length <= 32) { target_bitsize = 32; } if(binary_length <= 32) { target_bitsize = 32; }
break; break;
case 4: case 4:
if(binary_length > 1184) { return ERROR_TOO_LONG; } if(binary_length > 1184) { return ZINT_ERROR_TOO_LONG; }
if(binary_length <= 1184) { target_bitsize = 1184; } if(binary_length <= 1184) { target_bitsize = 1184; }
if(binary_length <= 1016) { target_bitsize = 1016; } if(binary_length <= 1016) { target_bitsize = 1016; }
if(binary_length <= 840) { target_bitsize = 840; } if(binary_length <= 840) { target_bitsize = 840; }
@ -1654,7 +1654,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
codewords_used += 3; codewords_used += 3;
if(codewords_used > symbol->option_3) { if(codewords_used > symbol->option_3) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* *(cc_width) = 0.5 + sqrt((codewords_used) / 3); */ /* *(cc_width) = 0.5 + sqrt((codewords_used) / 3); */
*(cc_width) = (lin_width - 62) / 17; *(cc_width) = (lin_width - 62) / 17;
@ -1766,12 +1766,12 @@ int composite(struct zint_symbol *symbol, unsigned char source[], int length)
pri_len = strlen(symbol->primary); pri_len = strlen(symbol->primary);
if(pri_len == 0) { if(pri_len == 0) {
strcpy(symbol->errtxt, "No primary (linear) message in 2D composite"); strcpy(symbol->errtxt, "No primary (linear) message in 2D composite");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if(length > 2990) { if(length > 2990) {
strcpy(symbol->errtxt, "2D component input data too long"); strcpy(symbol->errtxt, "2D component input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
linear = ZBarcode_Create(); /* Symbol contains the 2D component and Linear contains the rest */ linear = ZBarcode_Create(); /* Symbol contains the 2D component and Linear contains the rest */
@ -1784,7 +1784,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[], int length)
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)");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
linear->symbology = symbol->symbology; linear->symbology = symbol->symbology;
@ -1849,16 +1849,16 @@ int composite(struct zint_symbol *symbol, unsigned char source[], int length)
if(cc_mode == 1) { if(cc_mode == 1) {
i = cc_binary_string(symbol, reduced, binary_string, cc_mode, &cc_width, &ecc_level, linear->width); i = cc_binary_string(symbol, reduced, binary_string, cc_mode, &cc_width, &ecc_level, linear->width);
if (i == ERROR_TOO_LONG) { if (i == ZINT_ERROR_TOO_LONG) {
cc_mode = 2; cc_mode = 2;
} }
} }
if(cc_mode == 2) { /* If the data didn't fit into CC-A it is recalculated for CC-B */ if(cc_mode == 2) { /* If the data didn't fit into CC-A it is recalculated for CC-B */
i = cc_binary_string(symbol, reduced, binary_string, cc_mode, &cc_width, &ecc_level, linear->width); i = cc_binary_string(symbol, reduced, binary_string, cc_mode, &cc_width, &ecc_level, linear->width);
if (i == ERROR_TOO_LONG) { if (i == ZINT_ERROR_TOO_LONG) {
if(symbol->symbology != BARCODE_EAN128_CC) { if(symbol->symbology != BARCODE_EAN128_CC) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} else { } else {
cc_mode = 3; cc_mode = 3;
} }
@ -1868,8 +1868,8 @@ int composite(struct zint_symbol *symbol, unsigned char source[], int length)
if(cc_mode == 3) { /* If the data didn't fit in CC-B (and linear part is GS1-128) it is recalculated if(cc_mode == 3) { /* If the data didn't fit in CC-B (and linear part is GS1-128) it is recalculated
for CC-C */ for CC-C */
i = cc_binary_string(symbol, reduced, binary_string, cc_mode, &cc_width, &ecc_level, linear->width); i = cc_binary_string(symbol, reduced, binary_string, cc_mode, &cc_width, &ecc_level, linear->width);
if (i == ERROR_TOO_LONG) { if (i == ZINT_ERROR_TOO_LONG) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
} }
@ -1880,7 +1880,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[], int length)
} }
if(error_number != 0) { if(error_number != 0) {
return ERROR_ENCODING_PROBLEM; return ZINT_ERROR_ENCODING_PROBLEM;
} }
/* Merge the linear component with the 2D component */ /* Merge the linear component with the 2D component */

View File

@ -553,7 +553,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha
if(symbol->output_options & READER_INIT) { if(symbol->output_options & READER_INIT) {
if(gs1) { if(gs1) {
strcpy(symbol->errtxt, "Cannot encode in GS1 mode and Reader Initialisation at the same time"); strcpy(symbol->errtxt, "Cannot encode in GS1 mode and Reader Initialisation at the same time");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} else { } else {
target[tp] = 234; tp++; /* Reader Programming */ target[tp] = 234; tp++; /* Reader Programming */
concat(binary, " "); concat(binary, " ");
@ -1075,7 +1075,7 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng
if(binlen == 0) { if(binlen == 0) {
strcpy(symbol->errtxt, "Data too long to fit in symbol"); strcpy(symbol->errtxt, "Data too long to fit in symbol");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) { if((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) {
@ -1102,7 +1102,7 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng
symbolsize = calcsize; symbolsize = calcsize;
if(optionsize != -1) { if(optionsize != -1) {
/* flag an error */ /* flag an error */
error_number = WARN_INVALID_OPTION; error_number = ZINT_WARN_INVALID_OPTION;
strcpy(symbol->errtxt, "Data does not fit in selected symbol size"); strcpy(symbol->errtxt, "Data does not fit in selected symbol size");
} }
} }
@ -1212,7 +1212,7 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length)
} else { } else {
/* ECC 000 - 140 */ /* ECC 000 - 140 */
strcpy(symbol->errtxt, "Older Data Matrix standards are no longer supported"); strcpy(symbol->errtxt, "Older Data Matrix standards are no longer supported");
error_number = ERROR_INVALID_OPTION; error_number = ZINT_ERROR_INVALID_OPTION;
} }
return error_number; return error_number;

View File

@ -699,7 +699,7 @@ int gm_encode(int gbdata[], int length, char binary[], int reader)
break; break;
} }
if(strlen(binary) > 9191) { if(strlen(binary) > 9191) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
} while(sp < length); } while(sp < length);
@ -736,7 +736,7 @@ int gm_encode(int gbdata[], int length, char binary[], int reader)
} }
if(strlen(binary) > 9191) { if(strlen(binary) > 9191) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
return 0; return 0;
} }
@ -961,7 +961,7 @@ int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length)
} while ((j < 7445) && (glyph == 0)); } while ((j < 7445) && (glyph == 0));
if(glyph == 0) { if(glyph == 0) {
strcpy(symbol->errtxt, "Invalid character in input data"); strcpy(symbol->errtxt, "Invalid character in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
gbdata[i] = glyph; gbdata[i] = glyph;
} }
@ -1041,7 +1041,7 @@ int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length)
if(data_cw > data_max) { if(data_cw > data_max) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
gm_add_ecc(binary, data_cw, layers, ecc_level, word); gm_add_ecc(binary, data_cw, layers, ecc_level, word);

View File

@ -76,17 +76,17 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
for(i = 0; i < src_len; i++) { for(i = 0; i < src_len; i++) {
if(source[i] >=128) { if(source[i] >=128) {
strcpy(symbol->errtxt, "Extended ASCII characters are not supported by GS1"); strcpy(symbol->errtxt, "Extended ASCII characters are not supported by GS1");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(source[i] < 32) { if(source[i] < 32) {
strcpy(symbol->errtxt, "Control characters are not supported by GS1"); strcpy(symbol->errtxt, "Control characters are not supported by GS1");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
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");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
/* Check the position of the brackets */ /* Check the position of the brackets */
@ -115,31 +115,31 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
if(bracket_level != 0) { if(bracket_level != 0) {
/* Not all brackets are closed */ /* Not all brackets are closed */
strcpy(symbol->errtxt, "Malformed AI in input data (brackets don\'t match)"); strcpy(symbol->errtxt, "Malformed AI in input data (brackets don\'t match)");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(max_bracket_level > 1) { if(max_bracket_level > 1) {
/* Nested brackets */ /* Nested brackets */
strcpy(symbol->errtxt, "Found nested brackets in input data"); strcpy(symbol->errtxt, "Found nested brackets in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(max_ai_length > 4) { if(max_ai_length > 4) {
/* AI is too long */ /* AI is too long */
strcpy(symbol->errtxt, "Invalid AI in input data (AI too long)"); strcpy(symbol->errtxt, "Invalid AI in input data (AI too long)");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(min_ai_length <= 1) { if(min_ai_length <= 1) {
/* AI is too short */ /* AI is too short */
strcpy(symbol->errtxt, "Invalid AI in input data (AI too short)"); strcpy(symbol->errtxt, "Invalid AI in input data (AI too short)");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(ai_latch == 1) { if(ai_latch == 1) {
/* Non-numeric data in AI */ /* Non-numeric data in AI */
strcpy(symbol->errtxt, "Invalid AI in input data (non-numeric characters in AI)"); strcpy(symbol->errtxt, "Invalid AI in input data (non-numeric characters in AI)");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
ai_count = 0; ai_count = 0;
@ -172,7 +172,7 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
if(data_length[i] == 0) { if(data_length[i] == 0) {
/* No data for given AI */ /* No data for given AI */
strcpy(symbol->errtxt, "Empty data field in input data"); strcpy(symbol->errtxt, "Empty data field in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
@ -253,13 +253,13 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
if(error_latch == 5) { if(error_latch == 5) {
strcpy(symbol->errtxt, "Invalid data length for AI "); strcpy(symbol->errtxt, "Invalid data length for AI ");
concat(symbol->errtxt, ai_string); concat(symbol->errtxt, ai_string);
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(error_latch == 6) { if(error_latch == 6) {
strcpy(symbol->errtxt, "Invalid AI value "); strcpy(symbol->errtxt, "Invalid AI value ");
concat(symbol->errtxt, ai_string); concat(symbol->errtxt, ai_string);
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
/* Resolve AI data - put resulting string in 'reduced' */ /* Resolve AI data - put resulting string in 'reduced' */
@ -318,5 +318,5 @@ int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsign
return 0; return 0;
} }
strcpy(symbol->errtxt, "ugs1_verify overflow"); strcpy(symbol->errtxt, "ugs1_verify overflow");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }

View File

@ -334,10 +334,10 @@ int imail(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 32) { if(length > 32) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(SODIUM, source, length); error_number = is_sane(SODIUM, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -374,11 +374,11 @@ int imail(struct zint_symbol *symbol, unsigned char source[], int length)
if(strlen(tracker) != 20) { if(strlen(tracker) != 20) {
strcpy(symbol->errtxt, "Invalid length tracking code"); strcpy(symbol->errtxt, "Invalid length tracking code");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(strlen(zip) > 11) { if(strlen(zip) > 11) {
strcpy(symbol->errtxt, "Invalid ZIP code"); strcpy(symbol->errtxt, "Invalid ZIP code");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
/* *** Step 1 - Conversion of Data Fields into Binary Data *** */ /* *** Step 1 - Conversion of Data Fields into Binary Data *** */

View File

@ -224,7 +224,7 @@ int dump_plot(struct zint_symbol *symbol)
f = fopen(symbol->outfile, "w"); f = fopen(symbol->outfile, "w");
if(!f) { if(!f) {
strcpy(symbol->errtxt, "Could not open output file"); strcpy(symbol->errtxt, "Could not open output file");
return ERROR_FILE_ACCESS; return ZINT_ERROR_FILE_ACCESS;
} }
} }
@ -254,11 +254,11 @@ int hibc(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 36) { if(length > 36) {
strcpy(symbol->errtxt, "Data too long for HIBC LIC"); strcpy(symbol->errtxt, "Data too long for HIBC LIC");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
to_upper(source); to_upper(source);
error_number = is_sane(TECHNETIUM , source, length); error_number = is_sane(TECHNETIUM , source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -606,8 +606,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
} }
if(length == 0) { if(length == 0) {
strcpy(symbol->errtxt, "No input data"); strcpy(symbol->errtxt, "No input data");
error_tag(symbol->errtxt, ERROR_INVALID_DATA); error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(strcmp(symbol->outfile, "") == 0) { if(strcmp(symbol->outfile, "") == 0) {
@ -620,32 +620,32 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
#endif #endif
/* 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"); symbol->symbology = BARCODE_CODE128; error_number = ZINT_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"); symbol->symbology = BARCODE_CODABAR; error_number = ZINT_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"); error_number = ZINT_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"); symbol->symbology = BARCODE_CODE128; error_number = ZINT_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"); error_number = ZINT_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; }
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"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } if(symbol->symbology == 91) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = ZINT_WARN_INVALID_OPTION; }
if((symbol->symbology >= 94) && (symbol->symbology <= 96)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } if((symbol->symbology >= 94) && (symbol->symbology <= 96)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = ZINT_WARN_INVALID_OPTION; }
if(symbol->symbology == 100) { symbol->symbology = BARCODE_HIBC_128; } if(symbol->symbology == 100) { symbol->symbology = BARCODE_HIBC_128; }
if(symbol->symbology == 101) { symbol->symbology = BARCODE_HIBC_39; } if(symbol->symbology == 101) { symbol->symbology = BARCODE_HIBC_39; }
if(symbol->symbology == 103) { symbol->symbology = BARCODE_HIBC_DM; } if(symbol->symbology == 103) { symbol->symbology = BARCODE_HIBC_DM; }
@ -653,10 +653,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
if(symbol->symbology == 107) { symbol->symbology = BARCODE_HIBC_PDF; } if(symbol->symbology == 107) { symbol->symbology = BARCODE_HIBC_PDF; }
if(symbol->symbology == 109) { symbol->symbology = BARCODE_HIBC_MICPDF; } if(symbol->symbology == 109) { symbol->symbology = BARCODE_HIBC_MICPDF; }
if(symbol->symbology == 111) { symbol->symbology = BARCODE_HIBC_BLOCKF; } if(symbol->symbology == 111) { symbol->symbology = BARCODE_HIBC_BLOCKF; }
if((symbol->symbology >= 113) && (symbol->symbology <= 127)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } if((symbol->symbology >= 113) && (symbol->symbology <= 127)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = ZINT_WARN_INVALID_OPTION; }
/* Everything from 128 up is Zint-specific */ /* Everything from 128 up is Zint-specific */
if(symbol->symbology >= 143) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } if(symbol->symbology >= 143) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = ZINT_WARN_INVALID_OPTION; }
if((symbol->symbology == BARCODE_CODABLOCKF) || (symbol->symbology == BARCODE_HIBC_BLOCKF)) { strcpy(symbol->errtxt, "Codablock F not supported"); error_number = ERROR_INVALID_OPTION; } if((symbol->symbology == BARCODE_CODABLOCKF) || (symbol->symbology == BARCODE_HIBC_BLOCKF)) { strcpy(symbol->errtxt, "Codablock F not supported"); error_number = ZINT_ERROR_INVALID_OPTION; }
if(error_number > 4) { if(error_number > 4) {
error_tag(symbol->errtxt, error_number); error_tag(symbol->errtxt, error_number);
@ -671,7 +671,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
if(source[i] == '\0') { if(source[i] == '\0') {
strcpy(symbol->errtxt, "NULL characters not permitted in GS1 mode"); strcpy(symbol->errtxt, "NULL characters not permitted in GS1 mode");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
if(gs1_compliant(symbol->symbology) == 1) { if(gs1_compliant(symbol->symbology) == 1) {
@ -680,7 +680,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
length = ustrlen(local_source); length = ustrlen(local_source);
} else { } else {
strcpy(symbol->errtxt, "Selected symbology does not support GS1 mode"); strcpy(symbol->errtxt, "Selected symbology does not support GS1 mode");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
} else { } else {
memcpy(local_source, source, length); memcpy(local_source, source, length);
@ -729,7 +729,7 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle)
break; break;
default: default:
strcpy(symbol->errtxt, "Invalid rotation angle"); strcpy(symbol->errtxt, "Invalid rotation angle");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if(strlen(symbol->outfile) > 3) { if(strlen(symbol->outfile) > 3) {
@ -756,13 +756,13 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle)
} else } else
{ {
strcpy(symbol->errtxt, "Unknown output format"); strcpy(symbol->errtxt, "Unknown output format");
error_tag(symbol->errtxt, ERROR_INVALID_OPTION); error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
} else { } else {
strcpy(symbol->errtxt, "Unknown output format"); strcpy(symbol->errtxt, "Unknown output format");
error_tag(symbol->errtxt, ERROR_INVALID_OPTION); error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
error_tag(symbol->errtxt, error_number); error_tag(symbol->errtxt, error_number);
@ -781,7 +781,7 @@ int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle)
break; break;
default: default:
strcpy(symbol->errtxt, "Invalid rotation angle"); strcpy(symbol->errtxt, "Invalid rotation angle");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
error_number = bmp_handle(symbol, rotate_angle); error_number = bmp_handle(symbol, rotate_angle);
@ -834,7 +834,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename)
file = fopen(filename, "rb"); file = fopen(filename, "rb");
if (!file) { if (!file) {
strcpy(symbol->errtxt, "Unable to read input file"); strcpy(symbol->errtxt, "Unable to read input file");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
/* Get file length */ /* Get file length */
@ -846,7 +846,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename)
/* The largest amount of data that can be encoded is 7089 numeric digits in QR Code */ /* The largest amount of data that can be encoded is 7089 numeric digits in QR Code */
strcpy(symbol->errtxt, "Input file too long"); strcpy(symbol->errtxt, "Input file too long");
fclose(file); fclose(file);
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
@ -856,7 +856,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename)
strcpy(symbol->errtxt, "Internal memory error"); strcpy(symbol->errtxt, "Internal memory error");
if (strcmp(filename, "-")) if (strcmp(filename, "-"))
fclose(file); fclose(file);
return ERROR_MEMORY; return ZINT_ERROR_MEMORY;
} }
/* Read file contents into buffer */ /* Read file contents into buffer */
@ -868,7 +868,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename)
{ {
strcpy(symbol->errtxt, strerror(errno)); strcpy(symbol->errtxt, strerror(errno));
nRead = 0; nRead = 0;
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
nRead += n; nRead += n;
} while (!feof(file) && (0 < n) && (nRead < fileLen)); } while (!feof(file) && (0 < n) && (nRead < fileLen));

View File

@ -139,7 +139,7 @@ int maxi_text_process(int mode, unsigned char source[], int length)
int set[144], character[144], i, j, done, count, current_set; int set[144], character[144], i, j, done, count, current_set;
if(length > 138) { if(length > 138) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
for(i = 0; i < 144; i++) { for(i = 0; i < 144; i++) {
@ -459,15 +459,15 @@ int maxi_text_process(int mode, unsigned char source[], int length)
} while (i <= 143); } while (i <= 143);
if(((mode ==2) || (mode == 3)) && (length > 84)) { if(((mode ==2) || (mode == 3)) && (length > 84)) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(((mode == 4) || (mode == 6)) && (length > 93)) { if(((mode == 4) || (mode == 6)) && (length > 93)) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if((mode == 5) && (length > 77)) { if((mode == 5) && (length > 77)) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
@ -605,7 +605,7 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[], int length)
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, "Invalid Maxicode Mode"); strcpy(symbol->errtxt, "Invalid Maxicode Mode");
return ERROR_INVALID_OPTION; return ZINT_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 */
@ -614,13 +614,13 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[], int length)
} }
if(lp != 15) { if(lp != 15) {
strcpy(symbol->errtxt, "Invalid Primary String"); strcpy(symbol->errtxt, "Invalid Primary String");
return ERROR_INVALID_DATA; return ZINT_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] < '0') || (symbol->primary[i] > '9')) { if((symbol->primary[i] < '0') || (symbol->primary[i] > '9')) {
strcpy(symbol->errtxt, "Invalid Primary String"); strcpy(symbol->errtxt, "Invalid Primary String");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
@ -656,7 +656,7 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[], int length)
} }
i = maxi_text_process(mode, local_source, length); i = maxi_text_process(mode, local_source, length);
if(i == ERROR_TOO_LONG ) { if(i == ZINT_ERROR_TOO_LONG ) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return i; return i;
} }

View File

@ -67,10 +67,10 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 6) { if(length > 6) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -79,7 +79,7 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length)
if((tester < 3) || (tester > 131070)) { if((tester < 3) || (tester > 131070)) {
strcpy(symbol->errtxt, "Data out of range"); strcpy(symbol->errtxt, "Data out of range");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
do do
@ -126,7 +126,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, "Data out of range"); strcpy(symbol->errtxt, "Data out of range");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
error_number = 0; error_number = 0;
strcpy(inter, ""); strcpy(inter, "");
@ -170,10 +170,10 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 8) { if(length > 8) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -214,11 +214,11 @@ int codabar(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 60) { /* No stack smashing please */ if(length > 60) { /* No stack smashing please */
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
to_upper(source); to_upper(source);
error_number = is_sane(CALCIUM, source, length); error_number = is_sane(CALCIUM, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -226,14 +226,14 @@ int codabar(struct zint_symbol *symbol, unsigned char source[], int length)
if((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C') && (source[0] != 'D')) if((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C') && (source[0] != 'D'))
{ {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if((source[length - 1] != 'A') && (source[length - 1] != 'B') && if((source[length - 1] != 'A') && (source[length - 1] != 'B') &&
(source[length - 1] != 'C') && (source[length - 1] != 'D')) (source[length - 1] != 'C') && (source[length - 1] != 'D'))
{ {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
for(i = 0; i < length; i++) for(i = 0; i < length; i++)
@ -257,10 +257,10 @@ int code32(struct zint_symbol *symbol, unsigned char source[], int length)
/* Validate the input */ /* Validate the input */
if(length > 8) { if(length > 8) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }

View File

@ -707,12 +707,12 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length)
if((symbol->option_1 < -1) || (symbol->option_1 > 8)) { if((symbol->option_1 < -1) || (symbol->option_1 > 8)) {
strcpy(symbol->errtxt, "Security value out of range"); strcpy(symbol->errtxt, "Security value out of range");
symbol->option_1 = -1; symbol->option_1 = -1;
error_number = WARN_INVALID_OPTION; error_number = ZINT_WARN_INVALID_OPTION;
} }
if((symbol->option_2 < 0) || (symbol->option_2 > 30)) { if((symbol->option_2 < 0) || (symbol->option_2 > 30)) {
strcpy(symbol->errtxt, "Number of columns out of range"); strcpy(symbol->errtxt, "Number of columns out of range");
symbol->option_2 = 0; symbol->option_2 = 0;
error_number = WARN_INVALID_OPTION; error_number = ZINT_WARN_INVALID_OPTION;
} }
/* 349 */ /* 349 */
@ -723,23 +723,23 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length)
switch(codeerr) { switch(codeerr) {
case 1: case 1:
strcpy(symbol->errtxt, "No such file or file unreadable"); strcpy(symbol->errtxt, "No such file or file unreadable");
error_number = ERROR_INVALID_OPTION; error_number = ZINT_ERROR_INVALID_OPTION;
break; break;
case 2: case 2:
strcpy(symbol->errtxt, "Input string too long"); strcpy(symbol->errtxt, "Input string too long");
error_number = ERROR_TOO_LONG; error_number = ZINT_ERROR_TOO_LONG;
break; break;
case 3: case 3:
strcpy(symbol->errtxt, "Number of codewords per row too small"); strcpy(symbol->errtxt, "Number of codewords per row too small");
error_number = WARN_INVALID_OPTION; error_number = ZINT_WARN_INVALID_OPTION;
break; break;
case 4: case 4:
strcpy(symbol->errtxt, "Data too long for specified number of columns"); strcpy(symbol->errtxt, "Data too long for specified number of columns");
error_number = ERROR_TOO_LONG; error_number = ZINT_ERROR_TOO_LONG;
break; break;
default: default:
strcpy(symbol->errtxt, "Something strange happened"); strcpy(symbol->errtxt, "Something strange happened");
error_number = ERROR_ENCODING_PROBLEM; error_number = ZINT_ERROR_ENCODING_PROBLEM;
break; break;
} }
} }
@ -825,12 +825,12 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length)
if(mclength > 126) { if(mclength > 126) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(symbol->option_2 > 4) { if(symbol->option_2 > 4) {
strcpy(symbol->errtxt, "Specified width out of range"); strcpy(symbol->errtxt, "Specified width out of range");
symbol->option_2 = 0; symbol->option_2 = 0;
codeerr = WARN_INVALID_OPTION; codeerr = ZINT_WARN_INVALID_OPTION;
} }
if(debug) { if(debug) {
@ -849,21 +849,21 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length)
/* 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, "Specified symbol size too small for data"); strcpy(symbol->errtxt, "Specified symbol size too small for data");
codeerr = WARN_INVALID_OPTION; codeerr = ZINT_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, "Specified symbol size too small for data"); strcpy(symbol->errtxt, "Specified symbol size too small for data");
codeerr = WARN_INVALID_OPTION; codeerr = ZINT_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, "Specified symbol size too small for data"); strcpy(symbol->errtxt, "Specified symbol size too small for data");
codeerr = WARN_INVALID_OPTION; codeerr = ZINT_WARN_INVALID_OPTION;
} }
if(symbol->option_2 == 1) { if(symbol->option_2 == 1) {

View File

@ -58,10 +58,10 @@ int plessey(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 65) { if(length > 65) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(SSET, source, length); error_number = is_sane(SSET, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -116,7 +116,7 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 55) { if(length > 55) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* start character */ /* start character */
@ -148,7 +148,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int le
if(length > 18) { if(length > 18) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* start character */ /* start character */
@ -219,7 +219,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], cons
if(src_len > 18) { /* No Entry Stack Smashers! limit because of str->number conversion*/ if(src_len > 18) { /* No Entry Stack Smashers! limit because of str->number conversion*/
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* start character */ /* start character */
@ -332,7 +332,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[], const
if(src_len > 55) { if(src_len > 55) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* start character */ /* start character */
@ -397,7 +397,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[], cons
if(src_len > 18) { if(src_len > 18) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* start character */ /* start character */
@ -488,7 +488,7 @@ int msi_handle(struct zint_symbol *symbol, unsigned char source[], int length) {
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number != 0) { if(error_number != 0) {
strcpy(symbol->errtxt, "Invalid characters in input data"); strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }

View File

@ -119,21 +119,21 @@ int png_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
if(strlen(symbol->fgcolour) != 6) { if(strlen(symbol->fgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed foreground colour target"); strcpy(symbol->errtxt, "Malformed foreground colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if(strlen(symbol->bgcolour) != 6) { if(strlen(symbol->bgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed background colour target"); strcpy(symbol->errtxt, "Malformed background colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
errno = is_sane(SSET, (unsigned char*)symbol->fgcolour, strlen(symbol->fgcolour)); errno = is_sane(SSET, (unsigned char*)symbol->fgcolour, strlen(symbol->fgcolour));
if (errno == ERROR_INVALID_DATA) { if (errno == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed foreground colour target"); strcpy(symbol->errtxt, "Malformed foreground colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
errno = is_sane(SSET, (unsigned char*)symbol->bgcolour, strlen(symbol->bgcolour)); errno = is_sane(SSET, (unsigned char*)symbol->bgcolour, strlen(symbol->bgcolour));
if (errno == ERROR_INVALID_DATA) { if (errno == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed background colour target"); strcpy(symbol->errtxt, "Malformed background colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
@ -148,14 +148,14 @@ int png_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
#ifdef _MSC_VER #ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "Can't open output file"); strcpy(symbol->errtxt, "Can't open output file");
return ERROR_FILE_ACCESS; return ZINT_ERROR_FILE_ACCESS;
} }
#endif #endif
graphic->outfile = stdout; graphic->outfile = stdout;
} else { } else {
if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) { if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "Can't open output file"); strcpy(symbol->errtxt, "Can't open output file");
return ERROR_FILE_ACCESS; return ZINT_ERROR_FILE_ACCESS;
} }
} }
@ -163,21 +163,21 @@ int png_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic, writepng_error_handler, NULL); png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic, writepng_error_handler, NULL);
if (!png_ptr) { if (!png_ptr) {
strcpy(symbol->errtxt, "Out of memory"); strcpy(symbol->errtxt, "Out of memory");
return ERROR_MEMORY; return ZINT_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, "Out of memory"); strcpy(symbol->errtxt, "Out of memory");
return ERROR_MEMORY; return ZINT_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, "libpng error occurred"); strcpy(symbol->errtxt, "libpng error occurred");
return ERROR_MEMORY; return ZINT_ERROR_MEMORY;
} }
/* open output file with libpng */ /* open output file with libpng */
@ -346,21 +346,21 @@ int bmp_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
if(strlen(symbol->fgcolour) != 6) { if(strlen(symbol->fgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed foreground colour target"); strcpy(symbol->errtxt, "Malformed foreground colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if(strlen(symbol->bgcolour) != 6) { if(strlen(symbol->bgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed background colour target"); strcpy(symbol->errtxt, "Malformed background colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
errno = is_sane(SSET, (unsigned char*)symbol->fgcolour, strlen(symbol->fgcolour)); errno = is_sane(SSET, (unsigned char*)symbol->fgcolour, strlen(symbol->fgcolour));
if (errno == ERROR_INVALID_DATA) { if (errno == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed foreground colour target"); strcpy(symbol->errtxt, "Malformed foreground colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
errno = is_sane(SSET, (unsigned char*)symbol->bgcolour, strlen(symbol->fgcolour)); errno = is_sane(SSET, (unsigned char*)symbol->bgcolour, strlen(symbol->fgcolour));
if (errno == ERROR_INVALID_DATA) { if (errno == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed background colour target"); strcpy(symbol->errtxt, "Malformed background colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
@ -473,7 +473,7 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
/* Apply scale options by creating another pixel buffer */ /* Apply scale options by creating another pixel buffer */
if (!(scaled_pixelbuf = (char *) malloc(scale_width * scale_height))) { if (!(scaled_pixelbuf = (char *) malloc(scale_width * scale_height))) {
printf("Insufficient memory for pixel buffer"); printf("Insufficient memory for pixel buffer");
return ERROR_ENCODING_PROBLEM; return ZINT_ERROR_ENCODING_PROBLEM;
} else { } else {
for(i = 0; i < (scale_width * scale_height); i++) { for(i = 0; i < (scale_width * scale_height); i++) {
*(scaled_pixelbuf + i) = '0'; *(scaled_pixelbuf + i) = '0';
@ -490,7 +490,7 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
#ifndef NO_PNG #ifndef NO_PNG
error_number = png_pixel_plot(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle); error_number = png_pixel_plot(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle);
#else #else
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
#endif #endif
} else { } else {
error_number = bmp_pixel_plot(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle); error_number = bmp_pixel_plot(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle);
@ -647,7 +647,7 @@ int maxi_png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
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");
return ERROR_ENCODING_PROBLEM; return ZINT_ERROR_ENCODING_PROBLEM;
} else { } else {
for(i = 0; i < (image_width * image_height); i++) { for(i = 0; i < (image_width * image_height); i++) {
*(pixelbuf + i) = '0'; *(pixelbuf + i) = '0';
@ -848,7 +848,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
if (!(pixelbuf = (char *) malloc(image_width * image_height))) { if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
printf("Insufficient memory for pixel buffer"); printf("Insufficient memory for pixel buffer");
return ERROR_ENCODING_PROBLEM; return ZINT_ERROR_ENCODING_PROBLEM;
} else { } else {
for(i = 0; i < (image_width * image_height); i++) { for(i = 0; i < (image_width * image_height); i++) {
*(pixelbuf + i) = '0'; *(pixelbuf + i) = '0';

View File

@ -79,10 +79,10 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[], int
if(length > 38) { if(length > 38) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -150,10 +150,10 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[], int
if(length > 38) { if(length > 38) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -219,10 +219,10 @@ int korea_post(struct zint_symbol *symbol, unsigned char source[], int length)
error_number = 0; error_number = 0;
if(length > 6) { if(length > 6) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -257,7 +257,7 @@ int fim(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 1) { if(length > 1) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
switch((char)source[0]) { switch((char)source[0]) {
@ -279,7 +279,7 @@ int fim(struct zint_symbol *symbol, unsigned char source[], int length)
break; break;
default: default:
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
break; break;
} }
@ -334,11 +334,11 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 120) { if(length > 120) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
to_upper(source); to_upper(source);
error_number = is_sane(KRSET, source, length); error_number = is_sane(KRSET, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -384,11 +384,11 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 18) { if(length > 18) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
to_upper(source); to_upper(source);
error_number = is_sane(KRSET, source, length); error_number = is_sane(KRSET, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -441,12 +441,12 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[], int length)
error_number = 0; error_number = 0;
if(length > 50) { if(length > 50) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
to_upper((unsigned char*)source); to_upper((unsigned char*)source);
error_number = is_sane(DAFTSET, (unsigned char*)source, length); error_number = is_sane(DAFTSET, (unsigned char*)source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -493,10 +493,10 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length
if(length > 90) { if(length > 90) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, length); error_number = is_sane(NEON, source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -533,7 +533,7 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[], int length)
to_upper((unsigned char*)local_source); to_upper((unsigned char*)local_source);
error_number = is_sane(SHKASUTSET, (unsigned char*)local_source, length); error_number = is_sane(SHKASUTSET, (unsigned char*)local_source, length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }

View File

@ -73,7 +73,7 @@ int ps_plot(struct zint_symbol *symbol)
} }
if(feps == NULL) { if(feps == NULL) {
strcpy(symbol->errtxt, "Could not open output file"); strcpy(symbol->errtxt, "Could not open output file");
return ERROR_FILE_ACCESS; return ZINT_ERROR_FILE_ACCESS;
} }
/* sort out colour options */ /* sort out colour options */
@ -82,21 +82,21 @@ int ps_plot(struct zint_symbol *symbol)
if(strlen(symbol->fgcolour) != 6) { if(strlen(symbol->fgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed foreground colour target"); strcpy(symbol->errtxt, "Malformed foreground colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if(strlen(symbol->bgcolour) != 6) { if(strlen(symbol->bgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed background colour target"); strcpy(symbol->errtxt, "Malformed background colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour, strlen(symbol->fgcolour)); error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour, strlen(symbol->fgcolour));
if (error_number == ERROR_INVALID_DATA) { if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed foreground colour target"); strcpy(symbol->errtxt, "Malformed foreground colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour, strlen(symbol->bgcolour)); error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour, strlen(symbol->bgcolour));
if (error_number == ERROR_INVALID_DATA) { if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed background colour target"); strcpy(symbol->errtxt, "Malformed background colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
locale = setlocale(LC_ALL, "C"); locale = setlocale(LC_ALL, "C");

View File

@ -407,6 +407,8 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in
position += short_data_block_length; position += short_data_block_length;
} while (position < length) ; } while (position < length) ;
printf("Actual binary: %d\n", (int) strlen(binary));
/* Terminator */ /* Terminator */
concat(binary, "0000"); concat(binary, "0000");
@ -1253,7 +1255,7 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[], int length)
} while ((j < 6843) && (glyph == 0)); } while ((j < 6843) && (glyph == 0));
if(glyph == 0) { if(glyph == 0) {
strcpy(symbol->errtxt, "Invalid character in input data"); strcpy(symbol->errtxt, "Invalid character in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
jisdata[i] = glyph; jisdata[i] = glyph;
} }
@ -1277,7 +1279,7 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[], int length)
if(est_binlen > (8 * max_cw)) { if(est_binlen > (8 * max_cw)) {
strcpy(symbol->errtxt, "Input too long for selected error correction level"); strcpy(symbol->errtxt, "Input too long for selected error correction level");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
autosize = 40; autosize = 40;
@ -1402,7 +1404,7 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length,
do { do {
if(strlen(binary) > 128) { if(strlen(binary) > 128) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
data_block = mode[position]; data_block = mode[position];
@ -1440,7 +1442,7 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length,
if(debug) { printf("0x%4X ", prod); } if(debug) { printf("0x%4X ", prod); }
if(strlen(binary) > 128) { if(strlen(binary) > 128) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
} }
@ -1469,7 +1471,7 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length,
if(debug) { printf("0x%4X ", byte); } if(debug) { printf("0x%4X ", byte); }
if(strlen(binary) > 128) { if(strlen(binary) > 128) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
} }
@ -1510,7 +1512,7 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length,
if(debug) { printf("0x%4X ", prod); } if(debug) { printf("0x%4X ", prod); }
if(strlen(binary) > 128) { if(strlen(binary) > 128) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
i += 2; i += 2;
@ -1558,7 +1560,7 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length,
if(debug) { printf("0x%4X (%d)", prod, prod); } if(debug) { printf("0x%4X (%d)", prod, prod); }
if(strlen(binary) > 128) { if(strlen(binary) > 128) {
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
i += 3; i += 3;
@ -2227,7 +2229,7 @@ int microqr(struct zint_symbol *symbol, unsigned char source[], int length)
if(length > 35) { if(length > 35) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
@ -2259,7 +2261,7 @@ int microqr(struct zint_symbol *symbol, unsigned char source[], int length)
} while ((j < 6843) && (glyph == 0)); } while ((j < 6843) && (glyph == 0));
if(glyph == 0) { if(glyph == 0) {
strcpy(symbol->errtxt, "Invalid character in input data"); strcpy(symbol->errtxt, "Invalid character in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
jisdata[i] = glyph; jisdata[i] = glyph;
} }
@ -2319,7 +2321,7 @@ int microqr(struct zint_symbol *symbol, unsigned char source[], int length)
if(binary_count[2] > 84) { version_valid[2] = 0; } if(binary_count[2] > 84) { version_valid[2] = 0; }
if(binary_count[3] > 128) { if(binary_count[3] > 128) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Eliminate possible versions depending on error correction level specified */ /* Eliminate possible versions depending on error correction level specified */
@ -2330,7 +2332,7 @@ int microqr(struct zint_symbol *symbol, unsigned char source[], int length)
if(ecc_level == LEVEL_H) { if(ecc_level == LEVEL_H) {
strcpy(symbol->errtxt, "Error correction level H not available"); strcpy(symbol->errtxt, "Error correction level H not available");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if(ecc_level == LEVEL_Q) { if(ecc_level == LEVEL_Q) {
@ -2339,7 +2341,7 @@ int microqr(struct zint_symbol *symbol, unsigned char source[], int length)
version_valid[2] = 0; version_valid[2] = 0;
if(binary_count[3] > 80) { if(binary_count[3] > 80) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
} }
@ -2349,7 +2351,7 @@ int microqr(struct zint_symbol *symbol, unsigned char source[], int length)
if(binary_count[2] > 68) { version_valid[2] = 0; } if(binary_count[2] > 68) { version_valid[2] = 0; }
if(binary_count[3] > 112) { if(binary_count[3] > 112) {
strcpy(symbol->errtxt, "Input data too long"); strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
} }

View File

@ -168,10 +168,10 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
if(src_len > 13) { if(src_len > 13) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, src_len); error_number = is_sane(NEON, source, src_len);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -674,17 +674,17 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
if(src_len > 13) { if(src_len > 13) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
error_number = is_sane(NEON, source, src_len); error_number = is_sane(NEON, source, src_len);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
if(src_len == 13) { if(src_len == 13) {
if((source[0] != '0') && (source[0] != '1')) { if((source[0] != '0') && (source[0] != '1')) {
strcpy(symbol->errtxt, "Input out of range"); strcpy(symbol->errtxt, "Input out of range");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
@ -1254,7 +1254,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
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");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
} }
@ -1580,7 +1580,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
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");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
for(i = 0; i < strlen(general_field); i++) { for(i = 0; i < strlen(general_field); i++) {
@ -1821,7 +1821,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
if(strlen(binary_string) > 252) { if(strlen(binary_string) > 252) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Now add padding to binary string (7.2.5.5.4) */ /* Now add padding to binary string (7.2.5.5.4) */

View File

@ -67,7 +67,7 @@ int svg_plot(struct zint_symbol *symbol)
} }
if(fsvg == NULL) { if(fsvg == NULL) {
strcpy(symbol->errtxt, "Could not open output file"); strcpy(symbol->errtxt, "Could not open output file");
return ERROR_FILE_ACCESS; return ZINT_ERROR_FILE_ACCESS;
} }
/* sort out colour options */ /* sort out colour options */
@ -76,21 +76,21 @@ int svg_plot(struct zint_symbol *symbol)
if(strlen(symbol->fgcolour) != 6) { if(strlen(symbol->fgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed foreground colour target"); strcpy(symbol->errtxt, "Malformed foreground colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if(strlen(symbol->bgcolour) != 6) { if(strlen(symbol->bgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed background colour target"); strcpy(symbol->errtxt, "Malformed background colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour, strlen(symbol->fgcolour)); error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour, strlen(symbol->fgcolour));
if (error_number == ERROR_INVALID_DATA) { if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed foreground colour target"); strcpy(symbol->errtxt, "Malformed foreground colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour, strlen(symbol->bgcolour)); error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour, strlen(symbol->bgcolour));
if (error_number == ERROR_INVALID_DATA) { if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed background colour target"); strcpy(symbol->errtxt, "Malformed background colour target");
return ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
locale = setlocale(LC_ALL, "C"); locale = setlocale(LC_ALL, "C");

View File

@ -68,7 +68,7 @@ int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len)
if(src_len > 30) { if(src_len > 30) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
/* Start character */ /* Start character */
strcpy(dest, TeleTable['_']); strcpy(dest, TeleTable['_']);
@ -77,7 +77,7 @@ int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len)
if(source[i] > 126) { if(source[i] > 126) {
/* Cannot encode extended ASCII */ /* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "Invalid characters in input data"); strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
concat(dest, TeleTable[source[i]]); concat(dest, TeleTable[source[i]]);
count += source[i]; count += source[i];
@ -114,12 +114,12 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len)
if(temp_length > 60) { if(temp_length > 60) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
ustrcpy(temp, source); ustrcpy(temp, source);
to_upper(temp); to_upper(temp);
error_number = is_sane(NEON, temp, temp_length); error_number = is_sane(NEON, temp, temp_length);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
@ -140,7 +140,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len)
{ {
if(temp[i] == 'X') { if(temp[i] == 'X') {
strcpy(symbol->errtxt, "Invalid position of X in Telepen data"); strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if(temp[i + 1] == 'X') { if(temp[i + 1] == 'X') {

View File

@ -421,7 +421,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
to_upper(source); to_upper(source);
error_number = is_sane("0123456789X", source, src_len); error_number = is_sane("0123456789X", source, src_len);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in input"); strcpy(symbol->errtxt, "Invalid characters in input");
return error_number; return error_number;
} }
@ -430,7 +430,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
if(((src_len < 9) || (src_len > 13)) || ((src_len > 10) && (src_len < 13))) if(((src_len < 9) || (src_len > 13)) || ((src_len > 10) && (src_len < 13)))
{ {
strcpy(symbol->errtxt, "Input wrong length"); strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
if(src_len == 13) /* Using 13 character ISBN */ if(src_len == 13) /* Using 13 character ISBN */
@ -439,14 +439,14 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
((source[2] == '8') || (source[2] == '9')))) ((source[2] == '8') || (source[2] == '9'))))
{ {
strcpy(symbol->errtxt, "Invalid ISBN"); strcpy(symbol->errtxt, "Invalid ISBN");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
check_digit = isbn13_check(source); check_digit = isbn13_check(source);
if (source[src_len - 1] != check_digit) if (source[src_len - 1] != check_digit)
{ {
strcpy(symbol->errtxt, "Incorrect ISBN check"); strcpy(symbol->errtxt, "Incorrect ISBN check");
return ERROR_INVALID_CHECK; return ZINT_ERROR_INVALID_CHECK;
} }
source[12] = '\0'; source[12] = '\0';
@ -459,7 +459,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
if(check_digit != source[src_len - 1]) if(check_digit != source[src_len - 1])
{ {
strcpy(symbol->errtxt, "Incorrect ISBN check"); strcpy(symbol->errtxt, "Incorrect ISBN check");
return ERROR_INVALID_CHECK; return ZINT_ERROR_INVALID_CHECK;
} }
for(i = 13; i > 0; i--) for(i = 13; i > 0; i--)
{ {
@ -487,7 +487,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
if(check_digit != source[ustrlen(source) - 1]) if(check_digit != source[ustrlen(source) - 1])
{ {
strcpy(symbol->errtxt, "Incorrect SBN check"); strcpy(symbol->errtxt, "Incorrect SBN check");
return ERROR_INVALID_CHECK; return ZINT_ERROR_INVALID_CHECK;
} }
/* Convert to EAN-13 number */ /* Convert to EAN-13 number */
@ -603,18 +603,18 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
if(src_len > 19) { if(src_len > 19) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ZINT_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 */
error_number = is_sane("0123456789+", source, src_len); error_number = is_sane("0123456789+", source, src_len);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data"); strcpy(symbol->errtxt, "Invalid characters in data");
return error_number; return error_number;
} }
} else { } else {
error_number = is_sane("0123456789Xx", source, src_len); error_number = is_sane("0123456789Xx", source, src_len);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in input"); strcpy(symbol->errtxt, "Invalid characters in input");
return error_number; return error_number;
} }
@ -668,7 +668,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
case 5: add_on(first_part, (char*)dest, 0); ustrcpy(symbol->text, first_part); break; case 5: add_on(first_part, (char*)dest, 0); ustrcpy(symbol->text, 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, "Invalid length input"); return ERROR_TOO_LONG; default: strcpy(symbol->errtxt, "Invalid length input"); return ZINT_ERROR_TOO_LONG;
} }
break; break;
case BARCODE_EANX_CC: case BARCODE_EANX_CC:
@ -696,7 +696,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
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, "Invalid length EAN input"); return ERROR_TOO_LONG; default: strcpy(symbol->errtxt, "Invalid length EAN input"); return ZINT_ERROR_TOO_LONG;
} }
break; break;
case BARCODE_UPCA: case BARCODE_UPCA:
@ -704,7 +704,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
upca(symbol, first_part, (char*)dest); upca(symbol, first_part, (char*)dest);
} else { } else {
strcpy(symbol->errtxt, "Input wrong length"); strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
break; break;
case BARCODE_UPCA_CC: case BARCODE_UPCA_CC:
@ -722,7 +722,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
upca(symbol, first_part, (char*)dest); upca(symbol, first_part, (char*)dest);
} else { } else {
strcpy(symbol->errtxt, "UPCA input wrong length"); strcpy(symbol->errtxt, "UPCA input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
break; break;
case BARCODE_UPCE: case BARCODE_UPCE:
@ -730,7 +730,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
upce(symbol, first_part, (char*)dest); upce(symbol, first_part, (char*)dest);
} else { } else {
strcpy(symbol->errtxt, "Input wrong length"); strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
break; break;
case BARCODE_UPCE_CC: case BARCODE_UPCE_CC:
@ -748,7 +748,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
upce(symbol, first_part, (char*)dest); upce(symbol, first_part, (char*)dest);
} else { } else {
strcpy(symbol->errtxt, "UPCE input wrong length"); strcpy(symbol->errtxt, "UPCE input wrong length");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
break; break;
case BARCODE_ISBNX: case BARCODE_ISBNX:
@ -773,7 +773,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
break; break;
default: default:
strcpy(symbol->errtxt, "Invalid length input"); strcpy(symbol->errtxt, "Invalid length input");
return ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
expand(symbol, (char*)dest); expand(symbol, (char*)dest);

View File

@ -203,14 +203,14 @@ struct zint_symbol {
#define DM_SQUARE 100 #define DM_SQUARE 100
#define WARN_INVALID_OPTION 2 #define ZINT_WARN_INVALID_OPTION 2
#define ERROR_TOO_LONG 5 #define ZINT_ERROR_TOO_LONG 5
#define ERROR_INVALID_DATA 6 #define ZINT_ERROR_INVALID_DATA 6
#define ERROR_INVALID_CHECK 7 #define ZINT_ERROR_INVALID_CHECK 7
#define ERROR_INVALID_OPTION 8 #define ZINT_ERROR_INVALID_OPTION 8
#define ERROR_ENCODING_PROBLEM 9 #define ZINT_ERROR_ENCODING_PROBLEM 9
#define ERROR_FILE_ACCESS 10 #define ZINT_ERROR_FILE_ACCESS 10
#define ERROR_MEMORY 11 #define ZINT_ERROR_MEMORY 11
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(_MSC_VER) #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(_MSC_VER)
# if defined (DLL_EXPORT) || defined(PIC) || defined(_USRDLL) # if defined (DLL_EXPORT) || defined(PIC) || defined(_USRDLL)

View File

@ -79,7 +79,7 @@ void QZint::encode()
QByteArray pstr=m_primaryMessage.left(99).toAscii(); QByteArray pstr=m_primaryMessage.left(99).toAscii();
strcpy(m_zintSymbol->primary,pstr.data()); strcpy(m_zintSymbol->primary,pstr.data());
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length()); int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length());
if (error > WARN_INVALID_OPTION) if (error > ZINT_WARN_INVALID_OPTION)
m_lastError=m_zintSymbol->errtxt; m_lastError=m_zintSymbol->errtxt;
if (m_zintSymbol->symbology == BARCODE_MAXICODE) if (m_zintSymbol->symbology == BARCODE_MAXICODE)
@ -282,10 +282,10 @@ bool QZint::save_to_file(QString filename)
strcpy(m_zintSymbol->fgcolour,fgcol.data()); strcpy(m_zintSymbol->fgcolour,fgcol.data());
strcpy(m_zintSymbol->bgcolour,bgcol.data()); strcpy(m_zintSymbol->bgcolour,bgcol.data());
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length()); int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length());
if (error > WARN_INVALID_OPTION) if (error > ZINT_WARN_INVALID_OPTION)
m_lastError=m_zintSymbol->errtxt; m_lastError=m_zintSymbol->errtxt;
error = ZBarcode_Print(m_zintSymbol, 0); error = ZBarcode_Print(m_zintSymbol, 0);
if (error > WARN_INVALID_OPTION) if (error > ZINT_WARN_INVALID_OPTION)
m_lastError=m_zintSymbol->errtxt; m_lastError=m_zintSymbol->errtxt;
if(error == 0) { return true; } else { return false; } if(error == 0) { return true; } else { return false; }
} }

View File

@ -117,7 +117,7 @@ int validator(char test_string[], char source[])
for(j = 0; j < strlen(test_string); j++) { for(j = 0; j < strlen(test_string); j++) {
if (source[i] == test_string[j]) { latch = 1; } } if (source[i] == test_string[j]) { latch = 1; } }
if (!(latch)) { if (!(latch)) {
return ERROR_INVALID_DATA; } return ZINT_ERROR_INVALID_DATA; }
} }
return 0; return 0;
@ -207,7 +207,7 @@ int batch_process(struct zint_symbol *symbol, char *filename)
strcpy(format_string, symbol->outfile); strcpy(format_string, symbol->outfile);
} else { } else {
strcpy(symbol->errtxt, "Format string too long"); strcpy(symbol->errtxt, "Format string too long");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
memset(adjusted, 0, sizeof(char) * 2); memset(adjusted, 0, sizeof(char) * 2);
@ -218,7 +218,7 @@ int batch_process(struct zint_symbol *symbol, char *filename)
file = fopen(filename, "rb"); file = fopen(filename, "rb");
if (!file) { if (!file) {
strcpy(symbol->errtxt, "Unable to read input file"); strcpy(symbol->errtxt, "Unable to read input file");
return ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
@ -452,7 +452,7 @@ int main(int argc, char **argv)
} }
if(!strcmp(long_options[option_index].name, "border")) { if(!strcmp(long_options[option_index].name, "border")) {
error_number = validator(NESET, optarg); error_number = validator(NESET, optarg);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid border width\n"); fprintf(stderr, "Invalid border width\n");
exit(1); exit(1);
} }
@ -465,7 +465,7 @@ int main(int argc, char **argv)
} }
if(!strcmp(long_options[option_index].name, "height")) { if(!strcmp(long_options[option_index].name, "height")) {
error_number = validator(NESET, optarg); error_number = validator(NESET, optarg);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid symbol height\n"); fprintf(stderr, "Invalid symbol height\n");
exit(1); exit(1);
} }
@ -520,7 +520,7 @@ int main(int argc, char **argv)
if(!strcmp(long_options[option_index].name, "rotate")) { if(!strcmp(long_options[option_index].name, "rotate")) {
/* Only certain inputs allowed */ /* Only certain inputs allowed */
error_number = validator(NESET, optarg); error_number = validator(NESET, optarg);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid rotation parameter\n"); fprintf(stderr, "Invalid rotation parameter\n");
exit(1); exit(1);
} }
@ -547,7 +547,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 == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid barcode type\n"); fprintf(stderr, "Invalid barcode type\n");
exit(1); exit(1);
} }
@ -556,7 +556,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 == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid whitespace value\n"); fprintf(stderr, "Invalid whitespace value\n");
exit(1); exit(1);
} }

View File

@ -187,10 +187,8 @@ void SequenceWindow::import()
void SequenceWindow::generate_sequence() void SequenceWindow::generate_sequence()
{ {
int returnval;
ExportWindow dlg; ExportWindow dlg;
dlg.barcode = barcode; dlg.barcode = barcode;
dlg.output_data = txtPreview->toPlainText(); dlg.output_data = txtPreview->toPlainText();
returnval = dlg.exec(); dlg.exec();
} }