Code format and audit, part 4

Update copyright info, remove unused code, etc.
This commit is contained in:
Robin Stuart 2016-02-20 12:37:50 +00:00
parent 660d8148bd
commit 858c6264b1
10 changed files with 631 additions and 597 deletions

View File

@ -9,8 +9,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
#comment or remove the above line before release #comment or remove the above line before release
set (ZINT_VERSION_MAJOR 2) set (ZINT_VERSION_MAJOR 2)
set (ZINT_VERSION_MINOR 4) set (ZINT_VERSION_MINOR 5)
set (ZINT_VERSION_RELEASE 4) set (ZINT_VERSION_RELEASE 0)
set (ZINT_VERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}.${ZINT_VERSION_RELEASE}" ) set (ZINT_VERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}.${ZINT_VERSION_RELEASE}" )
add_definitions (-DZINT_VERSION=\"${ZINT_VERSION}\" -Wall) add_definitions (-DZINT_VERSION=\"${ZINT_VERSION}\" -Wall)

View File

@ -2,7 +2,7 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk> Copyright (C) 2008-2016 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -35,7 +35,7 @@
#include <malloc.h> #include <malloc.h>
#endif #endif
/* Print list of supported symbologies */
void types(void) { void types(void) {
printf( " 1: Code 11 51: Pharma One-Track 90: KIX Code\n" printf( " 1: Code 11 51: Pharma One-Track 90: KIX Code\n"
" 2: Standard 2of5 52: PZN 92: Aztec Code\n" " 2: Standard 2of5 52: PZN 92: Aztec Code\n"
@ -52,14 +52,14 @@ void types(void) {
"21: Leitcode 69: ISBN 129: Code 23\n" "21: Leitcode 69: ISBN 129: Code 23\n"
"22: Identcode 70: RM4SCC 130: Comp EAN\n" "22: Identcode 70: RM4SCC 130: Comp EAN\n"
"23: Code 16k 71: Data Matrix 131: Comp GS1-128\n" "23: Code 16k 71: Data Matrix 131: Comp GS1-128\n"
"24: Code 49 72: EAN-14 132: Comp Databar-14\n" "24: Code 49 72: EAN-14 132: Comp DataBar Omni\n"
"25: Code 93 75: NVE-18 133: Comp Databar Ltd\n" "25: Code 93 75: NVE-18 133: Comp DataBar Ltd\n"
"28: Flattermarken 76: Japanese Post 134: Comp Databar Ext\n" "28: Flattermarken 76: Japanese Post 134: Comp DataBar ExpOm\n"
"29: Databar-14 77: Korea Post 135: Comp UPC-A\n" "29: GS1 DataBar Omni 77: Korea Post 135: Comp UPC-A\n"
"30: Databar Limited 79: Databar-14 Stack 136: Comp UPC-E\n" "30: GS1 DataBar Ltd 79: GS1 DataBar Stack 136: Comp UPC-E\n"
"31: Databar Extended 80: Databar-14 Stack Omni 137: Comp Databar-14 Stack\n" "31: GS1 DataBar ExpOm 80: GS1 DataBar Stack Omni 137: Comp DataBar Stack\n"
"32: Telepen Alpha 81: Databar Extended Stack 138: Comp Databar Stack Omni\n" "32: Telepen Alpha 81: GS1 DataBar ESO 138: Comp DataBar Stack Omni\n"
"34: UPC-A 82: Planet 139: Comp Databar Ext Stack\n" "34: UPC-A 82: Planet 139: Comp DataBar ESO\n"
"37: UPC-E 84: MicroPDF 140: Channel Code\n" "37: UPC-E 84: MicroPDF 140: Channel Code\n"
"40: Postnet 85: USPS OneCode 141: Code One\n" "40: Postnet 85: USPS OneCode 141: Code One\n"
"47: MSI Plessey 86: UK Plessey 142: Grid Matrix\n" "47: MSI Plessey 86: UK Plessey 142: Grid Matrix\n"
@ -68,10 +68,9 @@ void types(void) {
); );
} }
void usage(void) /* Output usage information */
{ void usage(void) {
printf( printf( "Zint version %s\n"
"Zint version %s\n"
"Encode input data in a barcode and save as a PNG, EPS or SVG file.\n\n" "Encode input data in a barcode and save as a PNG, EPS or SVG file.\n\n"
" -h, --help Display this message.\n" " -h, --help Display this message.\n"
" -t, --types Display table of barcode types\n" " -t, --types Display table of barcode types\n"
@ -108,52 +107,83 @@ void usage(void)
, ZINT_VERSION); , ZINT_VERSION);
} }
int validator(char test_string[], char source[]) /* Verifies that a string only uses valid characters */
{ /* Verifies that a string only uses valid characters */ int validator(char test_string[], char source[]) {
unsigned int i, j, latch; unsigned int i, j, latch;
for(i = 0; i < strlen(source); i++) { for (i = 0; i < strlen(source); i++) {
latch = 0; latch = 0;
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 ZINT_ERROR_INVALID_DATA; } return ZINT_ERROR_INVALID_DATA;
}
} }
return 0; return 0;
} }
int escape_char_process(struct zint_symbol *my_symbol, unsigned char input_string[], int length) int escape_char_process(struct zint_symbol *my_symbol, unsigned char input_string[], int length) {
{
int error_number; int error_number;
int i, j; int i, j;
#ifndef _MSC_VER #ifndef _MSC_VER
unsigned char escaped_string[length + 1]; unsigned char escaped_string[length + 1];
#else #else
unsigned char* escaped_string = (unsigned char*)_alloca(length + 1); unsigned char* escaped_string = (unsigned char*) _alloca(length + 1);
#endif #endif
i = 0; i = 0;
j = 0; j = 0;
do { do {
if(input_string[i] == '\\') { if (input_string[i] == '\\') {
switch(input_string[i + 1]) { switch (input_string[i + 1]) {
case '0': escaped_string[j] = 0x00; i += 2; break; /* Null */ case '0': escaped_string[j] = 0x00; /* Null */
case 'E': escaped_string[j] = 0x04; i += 2; break; /* End of Transmission */ i += 2;
case 'a': escaped_string[j] = 0x07; i += 2; break; /* Bell */ break;
case 'b': escaped_string[j] = 0x08; i += 2; break; /* Backspace */ case 'E': escaped_string[j] = 0x04; /* End of Transmission */
case 't': escaped_string[j] = 0x09; i += 2; break; /* Horizontal tab */ i += 2;
case 'n': escaped_string[j] = 0x0a; i += 2; break; /* Line feed */ break;
case 'v': escaped_string[j] = 0x0b; i += 2; break; /* Vertical tab */ case 'a': escaped_string[j] = 0x07; /* Bell */
case 'f': escaped_string[j] = 0x0c; i += 2; break; /* Form feed */ i += 2;
case 'r': escaped_string[j] = 0x0d; i += 2; break; /* Carriage return */ break;
case 'e': escaped_string[j] = 0x1b; i += 2; break; /* Escape */ case 'b': escaped_string[j] = 0x08; /* Backspace */
case 'G': escaped_string[j] = 0x1d; i += 2; break; /* Group Separator */ i += 2;
case 'R': escaped_string[j] = 0x1e; i += 2; break; /* Record Separator */ break;
case '\\': escaped_string[j] = '\\'; i += 2; break; case 't': escaped_string[j] = 0x09; /* Horizontal tab */
default: escaped_string[j] = input_string[i]; i++; break; i += 2;
break;
case 'n': escaped_string[j] = 0x0a; /* Line feed */
i += 2;
break;
case 'v': escaped_string[j] = 0x0b; /* Vertical tab */
i += 2;
break;
case 'f': escaped_string[j] = 0x0c; /* Form feed */
i += 2;
break;
case 'r': escaped_string[j] = 0x0d; /* Carriage return */
i += 2;
break;
case 'e': escaped_string[j] = 0x1b; /* Escape */
i += 2;
break;
case 'G': escaped_string[j] = 0x1d; /* Group Separator */
i += 2;
break;
case 'R': escaped_string[j] = 0x1e; /* Record Separator */
i += 2;
break;
case '\\': escaped_string[j] = '\\';
i += 2;
break;
default: escaped_string[j] = input_string[i];
i++;
break;
} }
} else { } else {
escaped_string[j] = input_string[i]; escaped_string[j] = input_string[i];
@ -168,26 +198,27 @@ int escape_char_process(struct zint_symbol *my_symbol, unsigned char input_strin
return error_number; return error_number;
} }
static char itoc(int source) /* Converts an integer value to its hexadecimal character */
{ /* Converts an integer value to its hexadecimal character */ static char itoc(int source) {
if ((source >= 0) && (source <= 9)) { if ((source >= 0) && (source <= 9)) {
return ('0' + source); } return ('0' + source);
else { } else {
return ('A' + (source - 10)); } return ('A' + (source - 10));
}
} }
static void concat(char dest[], char source[]) /* Concatinates dest[] with the contents of source[], copying /0 as well */
{ /* Concatinates dest[] with the contents of source[], copying /0 as well */ static void concat(char dest[], char source[]) {
unsigned int i, j, n; unsigned int i, j, n;
j = strlen(dest); j = strlen(dest);
n = strlen(source); n = strlen(source);
for(i = 0; i <= n; i++) { for (i = 0; i <= n; i++) {
dest[i + j] = source[i]; } dest[i + j] = source[i];
}
} }
int batch_process(struct zint_symbol *symbol, char *filename) int batch_process(struct zint_symbol *symbol, char *filename) {
{
FILE *file; FILE *file;
unsigned char buffer[7100]; unsigned char buffer[7100];
unsigned char character = 0; unsigned char character = 0;
@ -199,20 +230,20 @@ int batch_process(struct zint_symbol *symbol, char *filename)
int format_len, i; int format_len, i;
char adjusted[2]; char adjusted[2];
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);
} else { } else {
strcpy(symbol->errtxt, "Format string too long"); strcpy(symbol->errtxt, "Format string too long");
return ZINT_ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
} }
memset(adjusted, 0, sizeof(char) * 2); memset(adjusted, 0, sizeof (char) * 2);
if(!strcmp(filename, "-")) { if (!strcmp(filename, "-")) {
file = stdin; file = stdin;
} else { } else {
file = fopen(filename, "rb"); file = fopen(filename, "rb");
@ -229,18 +260,18 @@ int batch_process(struct zint_symbol *symbol, char *filename)
break; break;
} }
character = (unsigned char) intChar; character = (unsigned char) intChar;
if(character == '\n') { if (character == '\n') {
if(buffer[posn - 1] == '\r') { if (buffer[posn - 1] == '\r') {
/* CR+LF - assume Windows formatting and remove CR */ /* CR+LF - assume Windows formatting and remove CR */
posn--; posn--;
buffer[posn] = '\0'; buffer[posn] = '\0';
} }
inpos = 0; inpos = 0;
local_line_count = line_count; local_line_count = line_count;
memset(number, 0, sizeof(char) * 12); memset(number, 0, sizeof (char) * 12);
memset(reverse_number, 0, sizeof(char) * 12); memset(reverse_number, 0, sizeof (char) * 12);
memset(reversed_string, 0, sizeof(char) * 127); memset(reversed_string, 0, sizeof (char) * 127);
memset(output_file, 0, sizeof(char) * 127); memset(output_file, 0, sizeof (char) * 127);
do { do {
number[inpos] = itoc(local_line_count % 10); number[inpos] = itoc(local_line_count % 10);
local_line_count /= 10; local_line_count /= 10;
@ -248,15 +279,15 @@ int batch_process(struct zint_symbol *symbol, char *filename)
} while (local_line_count > 0); } while (local_line_count > 0);
number[inpos] = '\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];
switch(format_char) { switch (format_char) {
case '#': case '#':
if (inpos > 0) { if (inpos > 0) {
adjusted[0] = reverse_number[inpos - 1]; adjusted[0] = reverse_number[inpos - 1];
@ -288,34 +319,34 @@ int batch_process(struct zint_symbol *symbol, char *filename)
concat(reversed_string, adjusted); concat(reversed_string, adjusted);
} }
for(i = 0; i < format_len; i++) { for (i = 0; i < format_len; i++) {
output_file[i] = reversed_string[format_len - i - 1]; output_file[i] = reversed_string[format_len - i - 1];
} }
strcpy(symbol->outfile, output_file); strcpy(symbol->outfile, output_file);
error_number = ZBarcode_Encode_and_Print(symbol, buffer, posn, 0); error_number = ZBarcode_Encode_and_Print(symbol, buffer, posn, 0);
if(error_number != 0) { if (error_number != 0) {
fprintf(stderr, "On line %d: %s\n", line_count, symbol->errtxt); fprintf(stderr, "On line %d: %s\n", line_count, symbol->errtxt);
fflush(stderr); fflush(stderr);
} }
ZBarcode_Clear(symbol); ZBarcode_Clear(symbol);
memset(buffer, 0, sizeof(unsigned char) * 7100); memset(buffer, 0, sizeof (unsigned char) * 7100);
posn = 0; posn = 0;
line_count++; line_count++;
} else { } else {
buffer[posn] = character; buffer[posn] = character;
posn++; posn++;
} }
if(posn > 7090) { if (posn > 7090) {
fprintf(stderr, "On line %d: Input data too long\n", line_count); fprintf(stderr, "On line %d: Input data too long\n", line_count);
fflush(stderr); fflush(stderr);
do { do {
character = fgetc(file); character = fgetc(file);
} while((!feof(file)) && (character != '\n')); } while ((!feof(file)) && (character != '\n'));
} }
} while ((!feof(file)) && (line_count < 2000000000)); } while ((!feof(file)) && (line_count < 2000000000));
if(character != '\n') { if (character != '\n') {
fprintf(stderr, "Warning: No newline at end of file\n"); fprintf(stderr, "Warning: No newline at end of file\n");
fflush(stderr); fflush(stderr);
} }
@ -324,8 +355,7 @@ int batch_process(struct zint_symbol *symbol, char *filename)
return error_number; return error_number;
} }
int main(int argc, char **argv) int main(int argc, char **argv) {
{
struct zint_symbol *my_symbol; struct zint_symbol *my_symbol;
int c; int c;
int error_number; int error_number;
@ -340,12 +370,12 @@ int main(int argc, char **argv)
my_symbol->input_mode = UNICODE_MODE; my_symbol->input_mode = UNICODE_MODE;
batch_mode = 0; batch_mode = 0;
if(argc == 1) { if (argc == 1) {
usage(); usage();
exit(1); exit(1);
} }
while(1) { while (1) {
int option_index = 0; int option_index = 0;
static struct option long_options[] = { static struct option long_options[] = {
{"help", 0, 0, 'h'}, {"help", 0, 0, 'h'},
@ -385,91 +415,91 @@ int main(int argc, char **argv)
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
c = getopt_long(argc, argv, "htb:w:d:o:i:rcmp", long_options, &option_index); c = getopt_long(argc, argv, "htb:w:d:o:i:rcmp", long_options, &option_index);
if(c == -1) break; if (c == -1) break;
switch(c) { switch (c) {
case 0: case 0:
if(!strcmp(long_options[option_index].name, "bind")) { if (!strcmp(long_options[option_index].name, "bind")) {
my_symbol->output_options += BARCODE_BIND; my_symbol->output_options += BARCODE_BIND;
} }
if(!strcmp(long_options[option_index].name, "box")) { if (!strcmp(long_options[option_index].name, "box")) {
my_symbol->output_options += BARCODE_BOX; my_symbol->output_options += BARCODE_BOX;
} }
if(!strcmp(long_options[option_index].name, "init")) { if (!strcmp(long_options[option_index].name, "init")) {
my_symbol->output_options += READER_INIT; my_symbol->output_options += READER_INIT;
} }
if(!strcmp(long_options[option_index].name, "smalltext")) { if (!strcmp(long_options[option_index].name, "smalltext")) {
my_symbol->output_options += SMALL_TEXT; my_symbol->output_options += SMALL_TEXT;
} }
if(!strcmp(long_options[option_index].name, "directeps")) { if (!strcmp(long_options[option_index].name, "directeps")) {
my_symbol->output_options += BARCODE_STDOUT; my_symbol->output_options += BARCODE_STDOUT;
strncpy(my_symbol->outfile, "dummy.eps", 10); strncpy(my_symbol->outfile, "dummy.eps", 10);
} }
if(!strcmp(long_options[option_index].name, "directpng")) { if (!strcmp(long_options[option_index].name, "directpng")) {
my_symbol->output_options += BARCODE_STDOUT; my_symbol->output_options += BARCODE_STDOUT;
strncpy(my_symbol->outfile, "dummy.png", 10); strncpy(my_symbol->outfile, "dummy.png", 10);
} }
if(!strcmp(long_options[option_index].name, "directsvg")) { if (!strcmp(long_options[option_index].name, "directsvg")) {
my_symbol->output_options += BARCODE_STDOUT; my_symbol->output_options += BARCODE_STDOUT;
strncpy(my_symbol->outfile, "dummy.svg", 10); strncpy(my_symbol->outfile, "dummy.svg", 10);
} }
if(!strcmp(long_options[option_index].name, "dump")) { if (!strcmp(long_options[option_index].name, "dump")) {
my_symbol->output_options += BARCODE_STDOUT; my_symbol->output_options += BARCODE_STDOUT;
strncpy(my_symbol->outfile, "dummy.txt", 10); strncpy(my_symbol->outfile, "dummy.txt", 10);
} }
if(!strcmp(long_options[option_index].name, "gs1")) { if (!strcmp(long_options[option_index].name, "gs1")) {
my_symbol->input_mode = GS1_MODE; my_symbol->input_mode = GS1_MODE;
} }
if(!strcmp(long_options[option_index].name, "kanji")) { if (!strcmp(long_options[option_index].name, "kanji")) {
my_symbol->input_mode = KANJI_MODE; my_symbol->input_mode = KANJI_MODE;
} }
if(!strcmp(long_options[option_index].name, "sjis")) { if (!strcmp(long_options[option_index].name, "sjis")) {
my_symbol->input_mode = SJIS_MODE; my_symbol->input_mode = SJIS_MODE;
} }
if(!strcmp(long_options[option_index].name, "binary")) { if (!strcmp(long_options[option_index].name, "binary")) {
my_symbol->input_mode = DATA_MODE; my_symbol->input_mode = DATA_MODE;
} }
if(!strcmp(long_options[option_index].name, "fg")) { if (!strcmp(long_options[option_index].name, "fg")) {
strncpy(my_symbol->fgcolour, optarg, 7); strncpy(my_symbol->fgcolour, optarg, 7);
} }
if(!strcmp(long_options[option_index].name, "bg")) { if (!strcmp(long_options[option_index].name, "bg")) {
strncpy(my_symbol->bgcolour, optarg, 7); strncpy(my_symbol->bgcolour, optarg, 7);
} }
if(!strcmp(long_options[option_index].name, "notext")) { if (!strcmp(long_options[option_index].name, "notext")) {
my_symbol->show_hrt = 0; my_symbol->show_hrt = 0;
} }
if(!strcmp(long_options[option_index].name, "square")) { if (!strcmp(long_options[option_index].name, "square")) {
my_symbol->option_3 = DM_SQUARE; my_symbol->option_3 = DM_SQUARE;
} }
if(!strcmp(long_options[option_index].name, "scale")) { if (!strcmp(long_options[option_index].name, "scale")) {
my_symbol->scale = (float)(atof(optarg)); my_symbol->scale = (float) (atof(optarg));
if(my_symbol->scale < 0.01) { if (my_symbol->scale < 0.01) {
/* Zero and negative values are not permitted */ /* Zero and negative values are not permitted */
fprintf(stderr, "Invalid scale value\n"); fprintf(stderr, "Invalid scale value\n");
fflush(stderr); fflush(stderr);
my_symbol->scale = 1.0; my_symbol->scale = 1.0;
} }
} }
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 == ZINT_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);
} }
if((atoi(optarg) >= 0) && (atoi(optarg) <= 1000)) { if ((atoi(optarg) >= 0) && (atoi(optarg) <= 1000)) {
my_symbol->border_width = atoi(optarg); my_symbol->border_width = atoi(optarg);
} else { } else {
fprintf(stderr, "Border width out of range\n"); fprintf(stderr, "Border width out of range\n");
fflush(stderr); fflush(stderr);
} }
} }
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 == ZINT_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);
} }
if((atoi(optarg) >= 1) && (atoi(optarg) <= 1000)) { if ((atoi(optarg) >= 1) && (atoi(optarg) <= 1000)) {
my_symbol->height = atoi(optarg); my_symbol->height = atoi(optarg);
} else { } else {
fprintf(stderr, "Symbol height out of range\n"); fprintf(stderr, "Symbol height out of range\n");
@ -477,61 +507,65 @@ int main(int argc, char **argv)
} }
} }
if(!strcmp(long_options[option_index].name, "cols")) { if (!strcmp(long_options[option_index].name, "cols")) {
if((atoi(optarg) >= 1) && (atoi(optarg) <= 30)) { if ((atoi(optarg) >= 1) && (atoi(optarg) <= 30)) {
my_symbol->option_2 = atoi(optarg); my_symbol->option_2 = atoi(optarg);
} else { } else {
fprintf(stderr, "Number of columns out of range\n"); fprintf(stderr, "Number of columns out of range\n");
fflush(stderr); fflush(stderr);
} }
} }
if(!strcmp(long_options[option_index].name, "vers")) { if (!strcmp(long_options[option_index].name, "vers")) {
if((atoi(optarg) >= 1) && (atoi(optarg) <= 47)) { if ((atoi(optarg) >= 1) && (atoi(optarg) <= 47)) {
my_symbol->option_2 = atoi(optarg); my_symbol->option_2 = atoi(optarg);
} else { } else {
fprintf(stderr, "Invalid QR Code version\n"); fprintf(stderr, "Invalid QR Code version\n");
fflush(stderr); fflush(stderr);
} }
} }
if(!strcmp(long_options[option_index].name, "secure")) { if (!strcmp(long_options[option_index].name, "secure")) {
if((atoi(optarg) >= 1) && (atoi(optarg) <= 8)) { if ((atoi(optarg) >= 1) && (atoi(optarg) <= 8)) {
my_symbol->option_1 = atoi(optarg); my_symbol->option_1 = atoi(optarg);
} else { } else {
fprintf(stderr, "ECC level out of range\n"); fprintf(stderr, "ECC level out of range\n");
fflush(stderr); fflush(stderr);
} }
} }
if(!strcmp(long_options[option_index].name, "primary")) { if (!strcmp(long_options[option_index].name, "primary")) {
if(strlen(optarg) <= 90) { if (strlen(optarg) <= 90) {
strcpy(my_symbol->primary, optarg); strcpy(my_symbol->primary, optarg);
} else { } else {
fprintf(stderr, "Primary data string too long"); fprintf(stderr, "Primary data string too long");
fflush(stderr); fflush(stderr);
} }
} }
if(!strcmp(long_options[option_index].name, "mode")) { if (!strcmp(long_options[option_index].name, "mode")) {
if((optarg[0] >= '0') && (optarg[0] <= '6')) { if ((optarg[0] >= '0') && (optarg[0] <= '6')) {
my_symbol->option_1 = optarg[0] - '0'; my_symbol->option_1 = optarg[0] - '0';
} else { } else {
fprintf(stderr, "Invalid mode\n"); fprintf(stderr, "Invalid mode\n");
fflush(stderr); fflush(stderr);
} }
} }
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 == ZINT_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);
} }
switch(atoi(optarg)) { switch (atoi(optarg)) {
case 90: rotate_angle = 90; break; case 90: rotate_angle = 90;
case 180: rotate_angle = 180; break; break;
case 270: rotate_angle = 270; break; case 180: rotate_angle = 180;
default: rotate_angle = 0; break; break;
case 270: rotate_angle = 270;
break;
default: rotate_angle = 0;
break;
} }
} }
if(!strcmp(long_options[option_index].name, "batch")) { if (!strcmp(long_options[option_index].name, "batch")) {
/* Switch to batch processing mode */ /* Switch to batch processing mode */
batch_mode = 1; batch_mode = 1;
} }
@ -547,7 +581,7 @@ int main(int argc, char **argv)
case 'b': case 'b':
error_number = validator(NESET, optarg); error_number = validator(NESET, optarg);
if(error_number == ZINT_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,11 +590,11 @@ int main(int argc, char **argv)
case 'w': case 'w':
error_number = validator(NESET, optarg); error_number = validator(NESET, optarg);
if(error_number == ZINT_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);
} }
if((atoi(optarg) >= 0) && (atoi(optarg) <= 1000)) { if ((atoi(optarg) >= 0) && (atoi(optarg) <= 1000)) {
my_symbol->whitespace_width = atoi(optarg); my_symbol->whitespace_width = atoi(optarg);
} else { } else {
fprintf(stderr, "Whitespace value out of range"); fprintf(stderr, "Whitespace value out of range");
@ -569,13 +603,13 @@ int main(int argc, char **argv)
break; break;
case 'd': /* we have some data! */ case 'd': /* we have some data! */
if(batch_mode == 0) { if (batch_mode == 0) {
error_number = escape_char_process(my_symbol, (unsigned char*)optarg, strlen(optarg)); error_number = escape_char_process(my_symbol, (unsigned char*) optarg, strlen(optarg));
if(error_number == 0) { if (error_number == 0) {
error_number = ZBarcode_Print(my_symbol, rotate_angle); error_number = ZBarcode_Print(my_symbol, rotate_angle);
} }
generated = 1; generated = 1;
if(error_number != 0) { if (error_number != 0) {
fprintf(stderr, "%s\n", my_symbol->errtxt); fprintf(stderr, "%s\n", my_symbol->errtxt);
fflush(stderr); fflush(stderr);
ZBarcode_Delete(my_symbol); ZBarcode_Delete(my_symbol);
@ -588,13 +622,13 @@ int main(int argc, char **argv)
break; break;
case 'i': /* Take data from file */ case 'i': /* Take data from file */
if(batch_mode == 0) { if (batch_mode == 0) {
error_number = ZBarcode_Encode_File(my_symbol, optarg); error_number = ZBarcode_Encode_File(my_symbol, optarg);
if(error_number == 0) { if (error_number == 0) {
error_number = ZBarcode_Print(my_symbol, rotate_angle); error_number = ZBarcode_Print(my_symbol, rotate_angle);
} }
generated = 1; generated = 1;
if(error_number != 0) { if (error_number != 0) {
fprintf(stderr, "%s\n", my_symbol->errtxt); fprintf(stderr, "%s\n", my_symbol->errtxt);
fflush(stderr); fflush(stderr);
ZBarcode_Delete(my_symbol); ZBarcode_Delete(my_symbol);
@ -604,7 +638,7 @@ int main(int argc, char **argv)
/* Take each line of text as a separate data set */ /* Take each line of text as a separate data set */
error_number = batch_process(my_symbol, optarg); error_number = batch_process(my_symbol, optarg);
generated = 1; generated = 1;
if(error_number != 0) { if (error_number != 0) {
fprintf(stderr, "%s\n", my_symbol->errtxt); fprintf(stderr, "%s\n", my_symbol->errtxt);
fflush(stderr); fflush(stderr);
ZBarcode_Delete(my_symbol); ZBarcode_Delete(my_symbol);
@ -639,7 +673,7 @@ int main(int argc, char **argv)
fflush(stderr); fflush(stderr);
} }
if(generated == 0) { if (generated == 0) {
fprintf(stderr, "error: No data received, no symbol generated\n"); fprintf(stderr, "error: No data received, no symbol generated\n");
fflush(stderr); fflush(stderr);
} }

View File

@ -1,6 +1,6 @@
/* /*
Zint Barcode Generator - the open source barcode generator Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/* /*
Zint Barcode Generator - the open source barcode generator Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/* /*
Zint Barcode Generator - the open source barcode generator Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/* /*
Zint Barcode Generator - the open source barcode generator Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> * * Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
* Copyright (C) 2009 by Robin Stuart <robin@zint.org.uk> * * Copyright (C) 2009-2016 by Robin Stuart <rstuart114@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -169,7 +169,7 @@ bool MainWindow::save()
void MainWindow::about() void MainWindow::about()
{ {
QMessageBox::about(this, tr("About Zint"), QMessageBox::about(this, tr("About Zint"),
tr("<h2>Zint Barcode Studio 2.4.2</h2>" tr("<h2>Zint Barcode Studio 2.5</h2>"
"<p>A free barcode generator" "<p>A free barcode generator"
"<p>Instruction manual is available from Sourceforge:" "<p>Instruction manual is available from Sourceforge:"
"<p>http://www.sourceforge.net/projects/zint" "<p>http://www.sourceforge.net/projects/zint"

View File

@ -1,6 +1,6 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> * * Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
* Copyright (C) 2009 by Robin Stuart <robin@zint.org.uk> * * Copyright (C) 2009-2016 by Robin Stuart <rstuart114@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *

View File

@ -1,6 +1,6 @@
/* /*
Zint Barcode Generator - the open source barcode generator Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/* /*
Zint Barcode Generator - the open source barcode generator Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by