Audit of error codes

This commit is contained in:
Robin Stuart 2017-07-27 16:01:53 +01:00
parent 58e80a9ff7
commit 608b4b9134
38 changed files with 345 additions and 345 deletions

View file

@ -281,7 +281,7 @@ int batch_process(struct zint_symbol *symbol, char *filename, int mirror_mode, c
if (strlen(format_string) < 127) {
strcpy(format_string, symbol->outfile);
} else {
strcpy(symbol->errtxt, "Format string too long (A01)");
strcpy(symbol->errtxt, "101: Format string too long");
return ZINT_ERROR_INVALID_DATA;
}
}
@ -292,7 +292,7 @@ int batch_process(struct zint_symbol *symbol, char *filename, int mirror_mode, c
} else {
file = fopen(filename, "rb");
if (!file) {
strcpy(symbol->errtxt, "Unable to read input file (A02)");
strcpy(symbol->errtxt, "102: Unable to read input file");
return ZINT_ERROR_INVALID_DATA;
}
}
@ -415,7 +415,7 @@ int batch_process(struct zint_symbol *symbol, char *filename, int mirror_mode, c
posn++;
}
if (posn > 7090) {
fprintf(stderr, "On line %d: Input data too long (A03)\n", line_count);
fprintf(stderr, "103 on line %d: Input data too long\n", line_count);
fflush(stderr);
do {
character = fgetc(file);
@ -424,7 +424,7 @@ int batch_process(struct zint_symbol *symbol, char *filename, int mirror_mode, c
} while ((!feof(file)) && (line_count < 2000000000));
if (character != '\n') {
fprintf(stderr, "Warning: No newline at end of file (A04)\n");
fprintf(stderr, "warning 104: No newline at end of file\n");
fflush(stderr);
}
@ -570,7 +570,7 @@ int main(int argc, char **argv) {
my_symbol->scale = (float) (atof(optarg));
if (my_symbol->scale < 0.01) {
/* Zero and negative values are not permitted */
fprintf(stderr, "Invalid scale value (A05)\n");
fprintf(stderr, "105: Invalid scale value\n");
fflush(stderr);
my_symbol->scale = 1.0;
}
@ -579,7 +579,7 @@ int main(int argc, char **argv) {
my_symbol->dot_size = (float) (atof(optarg));
if (my_symbol->dot_size < 0.01) {
/* Zero and negative values are not permitted */
fprintf(stderr, "Invalid dot radius value (A06)\n");
fprintf(stderr, "106: Invalid dot radius value\n");
fflush(stderr);
my_symbol->dot_size = 4.0F / 5.0F;
}
@ -587,26 +587,26 @@ int main(int argc, char **argv) {
if (!strcmp(long_options[option_index].name, "border")) {
error_number = validator(NESET, optarg);
if (error_number == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid border width (A07)\n");
fprintf(stderr, "107: Invalid border width\n");
exit(1);
}
if ((atoi(optarg) >= 0) && (atoi(optarg) <= 1000)) {
my_symbol->border_width = atoi(optarg);
} else {
fprintf(stderr, "Border width out of range (A08)\n");
fprintf(stderr, "108: Border width out of range\n");
fflush(stderr);
}
}
if (!strcmp(long_options[option_index].name, "height")) {
error_number = validator(NESET, optarg);
if (error_number == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid symbol height (A09)\n");
fprintf(stderr, "109: Invalid symbol height\n");
exit(1);
}
if ((atoi(optarg) >= 1) && (atoi(optarg) <= 1000)) {
my_symbol->height = atoi(optarg);
} else {
fprintf(stderr, "Symbol height out of range (A10)\n");
fprintf(stderr, "110: Symbol height out of range\n");
fflush(stderr);
}
}
@ -615,7 +615,7 @@ int main(int argc, char **argv) {
if ((atoi(optarg) >= 1) && (atoi(optarg) <= 66)) {
my_symbol->option_2 = atoi(optarg);
} else {
fprintf(stderr, "Number of columns out of range (A11)\n");
fprintf(stderr, "111: Number of columns out of range\n");
fflush(stderr);
}
}
@ -623,7 +623,7 @@ int main(int argc, char **argv) {
if ((atoi(optarg) >= 1) && (atoi(optarg) <= 44)) {
my_symbol->option_1 = atoi(optarg);
} else {
fprintf(stderr, "Number of rows out of range (A12)\n");
fprintf(stderr, "112: Number of rows out of range\n");
fflush(stderr);
}
}
@ -631,7 +631,7 @@ int main(int argc, char **argv) {
if ((atoi(optarg) >= 1) && (atoi(optarg) <= 84)) {
my_symbol->option_2 = atoi(optarg);
} else {
fprintf(stderr, "Invalid Version (A13)\n");
fprintf(stderr, "113: Invalid Version\n");
fflush(stderr);
}
}
@ -639,7 +639,7 @@ int main(int argc, char **argv) {
if ((atoi(optarg) >= 1) && (atoi(optarg) <= 8)) {
my_symbol->option_1 = atoi(optarg);
} else {
fprintf(stderr, "ECC level out of range (A14)\n");
fprintf(stderr, "114: ECC level out of range\n");
fflush(stderr);
}
}
@ -647,7 +647,7 @@ int main(int argc, char **argv) {
if (strlen(optarg) <= 90) {
strcpy(my_symbol->primary, optarg);
} else {
fprintf(stderr, "Primary data string too long (A15)");
fprintf(stderr, "115: Primary data string too long");
fflush(stderr);
}
}
@ -655,7 +655,7 @@ int main(int argc, char **argv) {
if ((optarg[0] >= '0') && (optarg[0] <= '6')) {
my_symbol->option_1 = optarg[0] - '0';
} else {
fprintf(stderr, "Invalid mode (A16)\n");
fprintf(stderr, "116: Invalid mode\n");
fflush(stderr);
}
}
@ -663,7 +663,7 @@ int main(int argc, char **argv) {
/* Only certain inputs allowed */
error_number = validator(NESET, optarg);
if (error_number == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid rotation parameter (A17)\n");
fprintf(stderr, "117: Invalid rotation parameter\n");
exit(1);
}
switch (atoi(optarg)) {
@ -693,7 +693,7 @@ int main(int argc, char **argv) {
if ((atoi(optarg) >= 0) && (atoi(optarg) <= 999999)) {
my_symbol->eci = atoi(optarg);
} else {
fprintf(stderr, "Invalid ECI code (A18)\n");
fprintf(stderr, "118: Invalid ECI code\n");
fflush(stderr);
}
}
@ -717,7 +717,7 @@ int main(int argc, char **argv) {
case 'b':
error_number = validator(NESET, optarg);
if (error_number == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid barcode type (A19)\n");
fprintf(stderr, "119: Invalid barcode type\n");
exit(1);
}
my_symbol->symbology = atoi(optarg);
@ -726,13 +726,13 @@ int main(int argc, char **argv) {
case 'w':
error_number = validator(NESET, optarg);
if (error_number == ZINT_ERROR_INVALID_DATA) {
fprintf(stderr, "Invalid whitespace value (A20)\n");
fprintf(stderr, "120: Invalid whitespace value\n");
exit(1);
}
if ((atoi(optarg) >= 0) && (atoi(optarg) <= 1000)) {
my_symbol->whitespace_width = atoi(optarg);
} else {
fprintf(stderr, "Whitespace value out of range (A21)");
fprintf(stderr, "121: Whitespace value out of range");
fflush(stderr);
}
break;
@ -759,7 +759,7 @@ int main(int argc, char **argv) {
return 1;
}
} else {
fprintf(stderr, "Cannot define data in batch mode (A22)");
fprintf(stderr, "122: Cannot define data in batch mode");
fflush(stderr);
}
break;
@ -810,13 +810,13 @@ int main(int argc, char **argv) {
break;
default:
fprintf(stderr, "?? getopt error 0%o (A23)\n", c);
fprintf(stderr, "123: ?? getopt error 0%o\n", c);
fflush(stderr);
}
}
if (optind < argc) {
fprintf(stderr, "Invalid option ");
fprintf(stderr, "125: Invalid option\n");
while (optind < argc)
fprintf(stderr, "%s", argv[optind++]);
fprintf(stderr, "\n");
@ -824,7 +824,7 @@ int main(int argc, char **argv) {
}
if (generated == 0) {
fprintf(stderr, "error: No data received, no symbol generated (A24)\n");
fprintf(stderr, "124: No data received, no symbol generated\n");
fflush(stderr);
}