mirror of
https://git.code.sf.net/p/zint/code
synced 2025-12-23 04:47:03 +00:00
ERROR_* renamed to ZERROR_*
updated form master
This commit is contained in:
@@ -49,12 +49,10 @@ char upc_check(char source[])
|
|||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
for (i = 0; i < strlen(source); i++)
|
for (i = 0; i < strlen(source); i++) {
|
||||||
{
|
|
||||||
count += ctoi(source[i]);
|
count += ctoi(source[i]);
|
||||||
|
|
||||||
if ((i%2) == 0)
|
if (!(i & 1)) {
|
||||||
{
|
|
||||||
count += 2 * (ctoi(source[i]));
|
count += 2 * (ctoi(source[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,12 +288,10 @@ char ean_check(char source[])
|
|||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
h = strlen(source);
|
h = strlen(source);
|
||||||
for (i = h - 1; i >= 0; i--)
|
for (i = h - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
count += ctoi(source[i]);
|
count += ctoi(source[i]);
|
||||||
|
|
||||||
if (!((i%2) == 0))
|
if (i & 1) {
|
||||||
{
|
|
||||||
count += 2 * ctoi(source[i]);
|
count += 2 * ctoi(source[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,7 +409,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 == ZERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input");
|
strcpy(symbol->errtxt, "Invalid characters in input");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
@@ -422,7 +418,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 ZERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(src_len == 13) /* Using 13 character ISBN */
|
if(src_len == 13) /* Using 13 character ISBN */
|
||||||
@@ -431,14 +427,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 ZERROR_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 ZERROR_INVALID_CHECK;
|
||||||
}
|
}
|
||||||
source[12] = '\0';
|
source[12] = '\0';
|
||||||
|
|
||||||
@@ -451,7 +447,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 ZERROR_INVALID_CHECK;
|
||||||
}
|
}
|
||||||
for(i = 13; i > 0; i--)
|
for(i = 13; i > 0; i--)
|
||||||
{
|
{
|
||||||
@@ -479,7 +475,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 ZERROR_INVALID_CHECK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert to EAN-13 number */
|
/* Convert to EAN-13 number */
|
||||||
@@ -595,18 +591,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 ZERROR_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 == ZERROR_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 == ZERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input");
|
strcpy(symbol->errtxt, "Invalid characters in input");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
@@ -660,7 +656,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; break;
|
default: strcpy(symbol->errtxt, "Invalid length input"); return ZERROR_TOO_LONG; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_EANX_CC:
|
case BARCODE_EANX_CC:
|
||||||
@@ -688,7 +684,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; break;
|
default: strcpy(symbol->errtxt, "Invalid length EAN input"); return ZERROR_TOO_LONG; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCA:
|
case BARCODE_UPCA:
|
||||||
@@ -696,7 +692,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 ZERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCA_CC:
|
case BARCODE_UPCA_CC:
|
||||||
@@ -714,7 +710,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 ZERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCE:
|
case BARCODE_UPCE:
|
||||||
@@ -722,7 +718,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 ZERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCE_CC:
|
case BARCODE_UPCE_CC:
|
||||||
@@ -740,7 +736,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 ZERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_ISBNX:
|
case BARCODE_ISBNX:
|
||||||
@@ -765,7 +761,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 ZERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user