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
set (ZINT_VERSION_MAJOR 2)
set (ZINT_VERSION_MINOR 4)
set (ZINT_VERSION_RELEASE 4)
set (ZINT_VERSION_MINOR 5)
set (ZINT_VERSION_RELEASE 0)
set (ZINT_VERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}.${ZINT_VERSION_RELEASE}" )
add_definitions (-DZINT_VERSION=\"${ZINT_VERSION}\" -Wall)

View File

@ -2,7 +2,7 @@
/*
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
it under the terms of the GNU General Public License as published by
@ -35,7 +35,7 @@
#include <malloc.h>
#endif
/* Print list of supported symbologies */
void types(void) {
printf( " 1: Code 11 51: Pharma One-Track 90: KIX 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"
"22: Identcode 70: RM4SCC 130: Comp EAN\n"
"23: Code 16k 71: Data Matrix 131: Comp GS1-128\n"
"24: Code 49 72: EAN-14 132: Comp Databar-14\n"
"25: Code 93 75: NVE-18 133: Comp Databar Ltd\n"
"28: Flattermarken 76: Japanese Post 134: Comp Databar Ext\n"
"29: Databar-14 77: Korea Post 135: Comp UPC-A\n"
"30: Databar Limited 79: Databar-14 Stack 136: Comp UPC-E\n"
"31: Databar Extended 80: Databar-14 Stack Omni 137: Comp Databar-14 Stack\n"
"32: Telepen Alpha 81: Databar Extended Stack 138: Comp Databar Stack Omni\n"
"34: UPC-A 82: Planet 139: Comp Databar Ext Stack\n"
"24: Code 49 72: EAN-14 132: Comp DataBar Omni\n"
"25: Code 93 75: NVE-18 133: Comp DataBar Ltd\n"
"28: Flattermarken 76: Japanese Post 134: Comp DataBar ExpOm\n"
"29: GS1 DataBar Omni 77: Korea Post 135: Comp UPC-A\n"
"30: GS1 DataBar Ltd 79: GS1 DataBar Stack 136: Comp UPC-E\n"
"31: GS1 DataBar ExpOm 80: GS1 DataBar Stack Omni 137: Comp DataBar Stack\n"
"32: Telepen Alpha 81: GS1 DataBar ESO 138: Comp DataBar Stack Omni\n"
"34: UPC-A 82: Planet 139: Comp DataBar ESO\n"
"37: UPC-E 84: MicroPDF 140: Channel Code\n"
"40: Postnet 85: USPS OneCode 141: Code One\n"
"47: MSI Plessey 86: UK Plessey 142: Grid Matrix\n"
@ -68,10 +68,9 @@ void types(void) {
);
}
void usage(void)
{
printf(
"Zint version %s\n"
/* Output usage information */
void usage(void) {
printf( "Zint version %s\n"
"Encode input data in a barcode and save as a PNG, EPS or SVG file.\n\n"
" -h, --help Display this message.\n"
" -t, --types Display table of barcode types\n"
@ -108,23 +107,26 @@ void usage(void)
, 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;
for (i = 0; i < strlen(source); i++) {
latch = 0;
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)) {
return ZINT_ERROR_INVALID_DATA; }
return ZINT_ERROR_INVALID_DATA;
}
}
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 i, j;
@ -140,20 +142,48 @@ int escape_char_process(struct zint_symbol *my_symbol, unsigned char input_strin
do {
if (input_string[i] == '\\') {
switch (input_string[i + 1]) {
case '0': escaped_string[j] = 0x00; i += 2; break; /* Null */
case 'E': escaped_string[j] = 0x04; i += 2; break; /* End of Transmission */
case 'a': escaped_string[j] = 0x07; i += 2; break; /* Bell */
case 'b': escaped_string[j] = 0x08; i += 2; break; /* Backspace */
case 't': escaped_string[j] = 0x09; i += 2; break; /* Horizontal tab */
case 'n': escaped_string[j] = 0x0a; i += 2; break; /* Line feed */
case 'v': escaped_string[j] = 0x0b; i += 2; break; /* Vertical tab */
case 'f': escaped_string[j] = 0x0c; i += 2; break; /* Form feed */
case 'r': escaped_string[j] = 0x0d; i += 2; break; /* Carriage return */
case 'e': escaped_string[j] = 0x1b; i += 2; break; /* Escape */
case 'G': escaped_string[j] = 0x1d; i += 2; break; /* Group Separator */
case 'R': escaped_string[j] = 0x1e; i += 2; break; /* Record Separator */
case '\\': escaped_string[j] = '\\'; i += 2; break;
default: escaped_string[j] = input_string[i]; i++; break;
case '0': escaped_string[j] = 0x00; /* Null */
i += 2;
break;
case 'E': escaped_string[j] = 0x04; /* End of Transmission */
i += 2;
break;
case 'a': escaped_string[j] = 0x07; /* Bell */
i += 2;
break;
case 'b': escaped_string[j] = 0x08; /* Backspace */
i += 2;
break;
case 't': escaped_string[j] = 0x09; /* Horizontal tab */
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 {
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;
}
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)) {
return ('0' + source); }
else {
return ('A' + (source - 10)); }
return ('0' + source);
} else {
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;
j = strlen(dest);
n = strlen(source);
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;
unsigned char buffer[7100];
unsigned char character = 0;
@ -324,8 +355,7 @@ int batch_process(struct zint_symbol *symbol, char *filename)
return error_number;
}
int main(int argc, char **argv)
{
int main(int argc, char **argv) {
struct zint_symbol *my_symbol;
int c;
int error_number;
@ -525,10 +555,14 @@ int main(int argc, char **argv)
exit(1);
}
switch (atoi(optarg)) {
case 90: rotate_angle = 90; break;
case 180: rotate_angle = 180; break;
case 270: rotate_angle = 270; break;
default: rotate_angle = 0; break;
case 90: rotate_angle = 90;
break;
case 180: rotate_angle = 180;
break;
case 270: rotate_angle = 270;
break;
default: rotate_angle = 0;
break;
}
}
if (!strcmp(long_options[option_index].name, "batch")) {

View File

@ -1,6 +1,6 @@
/*
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
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
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
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
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
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
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
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) 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 *
* it under the terms of the GNU General Public License as published by *
@ -169,7 +169,7 @@ bool MainWindow::save()
void MainWindow::about()
{
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>Instruction manual is available from Sourceforge:"
"<p>http://www.sourceforge.net/projects/zint"

View File

@ -1,6 +1,6 @@
/***************************************************************************
* 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 *
* 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
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
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
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
it under the terms of the GNU General Public License as published by