Resolve issues with batch processing.

A couple of minor errors prevented the --batch option from working.
The default output filename (out.png) is now set when encoding.
This commit is contained in:
Robin Stuart 2011-03-08 11:36:10 +00:00
parent 533a5d0453
commit 0871eda1c0
2 changed files with 8 additions and 6 deletions

View File

@ -48,7 +48,7 @@ struct zint_symbol *ZBarcode_Create()
symbol->width = 0; symbol->width = 0;
strcpy(symbol->fgcolour, "000000"); strcpy(symbol->fgcolour, "000000");
strcpy(symbol->bgcolour, "ffffff"); strcpy(symbol->bgcolour, "ffffff");
strcpy(symbol->outfile, "out.png"); strcpy(symbol->outfile, "");
symbol->scale = 1.0; symbol->scale = 1.0;
symbol->option_1 = -1; symbol->option_1 = -1;
symbol->option_2 = 0; symbol->option_2 = 0;
@ -590,7 +590,9 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
return ERROR_INVALID_DATA; return ERROR_INVALID_DATA;
} }
if(strcmp(symbol->outfile, "") == 0) {
strcpy(symbol->outfile, "out.png");
}
#ifndef _MSC_VER #ifndef _MSC_VER
unsigned char local_source[length + 1]; unsigned char local_source[length + 1];
#else #else

View File

@ -201,7 +201,7 @@ int batch_process(struct zint_symbol *symbol, char *filename)
memset(buffer, 0, sizeof(unsigned char) * 7100); memset(buffer, 0, sizeof(unsigned char) * 7100);
if(symbol->outfile[0] == '\0') { if(symbol->outfile[0] == '\0') {
strcpy(format_string, "$$$$$.png"); strcpy(format_string, "~~~~~.png");
} else { } else {
if(strlen(format_string) < 127) { if(strlen(format_string) < 127) {
strcpy(format_string, symbol->outfile); strcpy(format_string, symbol->outfile);
@ -241,12 +241,12 @@ int batch_process(struct zint_symbol *symbol, char *filename)
local_line_count /= 10; local_line_count /= 10;
inpos++; inpos++;
} while (local_line_count > 0); } while (local_line_count > 0);
number[inpos] = '\0';
for(i = 0; i < inpos; i++) { for(i = 0; i < inpos; i++) {
reverse_number[i] = number[inpos - i - 1]; reverse_number[i] = number[inpos - i - 1];
} }
format_len = strlen(format_string); format_len = strlen(format_string);
for(i = format_len; i > 0; i--) { for(i = format_len; i > 0; i--) {
format_char = format_string[i - 1]; format_char = format_string[i - 1];
@ -260,7 +260,7 @@ int batch_process(struct zint_symbol *symbol, char *filename)
adjusted[0] = ' '; adjusted[0] = ' ';
} }
break; break;
case '$': case '~':
if (inpos > 0) { if (inpos > 0) {
adjusted[0] = reverse_number[inpos - 1]; adjusted[0] = reverse_number[inpos - 1];
inpos--; inpos--;
@ -268,7 +268,7 @@ int batch_process(struct zint_symbol *symbol, char *filename)
adjusted[0] = '0'; adjusted[0] = '0';
} }
break; break;
case '*': case '@':
if (inpos > 0) { if (inpos > 0) {
adjusted[0] = reverse_number[inpos - 1]; adjusted[0] = reverse_number[inpos - 1];
inpos--; inpos--;