1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-01-10 13:36:02 +00:00

ERROR_* renamed to ZERROR*

Merged form master
This commit is contained in:
tgotic
2011-01-17 19:38:34 +01:00
parent 23087a32a4
commit ac9f0a9649

View File

@@ -65,17 +65,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 ZERROR_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 ZERROR_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 ZERROR_INVALID_DATA;
} }
/* Check the position of the brackets */ /* Check the position of the brackets */
@@ -104,31 +104,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 ZERROR_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 ZERROR_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 ZERROR_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 ZERROR_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 ZERROR_INVALID_DATA;
} }
ai_count = 0; ai_count = 0;
@@ -161,7 +161,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 ZERROR_INVALID_DATA;
} }
} }
@@ -170,48 +170,68 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
for(i = 0; i < ai_count; i++) { for(i = 0; i < ai_count; i++) {
switch (ai_value[i]) { switch (ai_value[i]) {
case 0: if(data_length[i] != 18) { error_latch = 1; } break; case 0: if(data_length[i] != 18) { error_latch = 1; } break;
case 1: if(data_length[i] != 14) { error_latch = 1; } break; case 1:
case 2: if(data_length[i] != 14) { error_latch = 1; } break; case 2:
case 3: if(data_length[i] != 14) { error_latch = 1; } break; case 3: if(data_length[i] != 14) { error_latch = 1; } break;
case 4: if(data_length[i] != 16) { error_latch = 1; } break; case 4: if(data_length[i] != 16) { error_latch = 1; } break;
case 11: if(data_length[i] != 6) { error_latch = 1; } break; case 11:
case 12: if(data_length[i] != 6) { error_latch = 1; } break; case 12:
case 13: if(data_length[i] != 6) { error_latch = 1; } break; case 13:
case 14: if(data_length[i] != 6) { error_latch = 1; } break; case 14:
case 15: if(data_length[i] != 6) { error_latch = 1; } break; case 15:
case 16: if(data_length[i] != 6) { error_latch = 1; } break; case 16:
case 17: if(data_length[i] != 6) { error_latch = 1; } break; case 17:
case 18: if(data_length[i] != 6) { error_latch = 1; } break; case 18:
case 19: if(data_length[i] != 6) { error_latch = 1; } break; case 19: if(data_length[i] != 6) { error_latch = 1; } break;
case 20: if(data_length[i] != 2) { error_latch = 1; } break; case 20: if(data_length[i] != 2) { error_latch = 1; } break;
case 23: error_latch = 2; break; case 23:
case 24: error_latch = 2; break; case 24:
case 25: error_latch = 2; break; case 25:
case 39: error_latch = 2; break; case 39:
case 40: error_latch = 2; break; case 40:
case 41: error_latch = 2; break; case 41:
case 42: error_latch = 2; break; case 42:
case 70: error_latch = 2; break; case 70:
case 80: error_latch = 2; break; case 80:
case 81: error_latch = 2; break; case 81: error_latch = 2; break;
} }
if((ai_value[i] >= 100) && (ai_value[i] <= 179)) { error_latch = 2; } if(
if((ai_value[i] >= 1000) && (ai_value[i] <= 1799)) { error_latch = 2; } ((ai_value[i] >= 100) && (ai_value[i] <= 179))
if((ai_value[i] >= 200) && (ai_value[i] <= 229)) { error_latch = 2; } || ((ai_value[i] >= 1000) && (ai_value[i] <= 1799))
if((ai_value[i] >= 2000) && (ai_value[i] <= 2299)) { error_latch = 2; } || ((ai_value[i] >= 200) && (ai_value[i] <= 229))
if((ai_value[i] >= 300) && (ai_value[i] <= 309)) { error_latch = 2; } || ((ai_value[i] >= 2000) && (ai_value[i] <= 2299))
if((ai_value[i] >= 3000) && (ai_value[i] <= 3099)) { error_latch = 2; } || ((ai_value[i] >= 300) && (ai_value[i] <= 309))
if((ai_value[i] >= 31) && (ai_value[i] <= 36)) { error_latch = 2; } || ((ai_value[i] >= 3000) && (ai_value[i] <= 3099))
if((ai_value[i] >= 310) && (ai_value[i] <= 369)) { error_latch = 2; } || ((ai_value[i] >= 31) && (ai_value[i] <= 36))
if((ai_value[i] >= 3100) && (ai_value[i] <= 3699)) { if(data_length[i] != 6) { error_latch = 1; } } || ((ai_value[i] >= 310) && (ai_value[i] <= 369))
if((ai_value[i] >= 370) && (ai_value[i] <= 379)) { error_latch = 2; } ) {
if((ai_value[i] >= 3700) && (ai_value[i] <= 3799)) { error_latch = 2; } error_latch = 2;
if((ai_value[i] >= 410) && (ai_value[i] <= 415)) { if(data_length[i] != 13) { error_latch = 1; } } }
if((ai_value[i] >= 4100) && (ai_value[i] <= 4199)) { error_latch = 2; } if((ai_value[i] >= 3100) && (ai_value[i] <= 3699)) {
if((ai_value[i] >= 700) && (ai_value[i] <= 703)) { error_latch = 2; } if(data_length[i] != 6) {
if((ai_value[i] >= 800) && (ai_value[i] <= 810)) { error_latch = 2; } error_latch = 1;
if((ai_value[i] >= 900) && (ai_value[i] <= 999)) { error_latch = 2; } }
if((ai_value[i] >= 9000) && (ai_value[i] <= 9999)) { error_latch = 2; } }
if(
((ai_value[i] >= 370) && (ai_value[i] <= 379))
|| ((ai_value[i] >= 3700) && (ai_value[i] <= 3799))
) {
error_latch = 2;
}
if((ai_value[i] >= 410) && (ai_value[i] <= 415)) {
if(data_length[i] != 13) {
error_latch = 1;
}
}
if(
((ai_value[i] >= 4100) && (ai_value[i] <= 4199))
|| ((ai_value[i] >= 700) && (ai_value[i] <= 703))
|| ((ai_value[i] >= 800) && (ai_value[i] <= 810))
|| ((ai_value[i] >= 900) && (ai_value[i] <= 999))
|| ((ai_value[i] >= 9000) && (ai_value[i] <= 9999))
) {
error_latch = 2;
}
if((error_latch < 4) && (error_latch > 0)) { if((error_latch < 4) && (error_latch > 0)) {
/* error has just been detected: capture AI */ /* error has just been detected: capture AI */
itostr(ai_string, ai_value[i]); itostr(ai_string, ai_value[i]);
@@ -222,13 +242,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 ZERROR_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 ZERROR_INVALID_DATA;
} }
/* Resolve AI data - put resulting string in 'reduced' */ /* Resolve AI data - put resulting string in 'reduced' */
@@ -251,11 +271,15 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
ai_latch = 0; ai_latch = 0;
/* The following values from "GS-1 General Specification version 8.0 issue 2, May 2008" /* The following values from "GS-1 General Specification version 8.0 issue 2, May 2008"
figure 5.4.8.2.1 - 1 "Element Strings with Pre-Defined Length Using Application Identifiers" */ figure 5.4.8.2.1 - 1 "Element Strings with Pre-Defined Length Using Application Identifiers" */
if((last_ai >= 0) && (last_ai <= 4)) { ai_latch = 1; } if(
if((last_ai >= 11) && (last_ai <= 20)) { ai_latch = 1; } ((last_ai >= 0) && (last_ai <= 4))
if(last_ai == 23) { ai_latch = 1; } /* legacy support - see 5.3.8.2.2 */ || ((last_ai >= 11) && (last_ai <= 20))
if((last_ai >= 31) && (last_ai <= 36)) { ai_latch = 1; } || (last_ai == 23) /* legacy support - see 5.3.8.2.2 */
if(last_ai == 41) { ai_latch = 1; } || ((last_ai >= 31) && (last_ai <= 36))
|| (last_ai == 41)
) {
ai_latch = 1;
}
} }
/* The ']' character is simply dropped from the input */ /* The ']' character is simply dropped from the input */
} }
@@ -283,5 +307,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 ZERROR_INVALID_DATA;
} }