mirror of
https://git.code.sf.net/p/zint/code
synced 2025-06-04 00:48:44 -04:00
code reworked
This commit is contained in:
parent
f48d7ab6a6
commit
bf2dbe7494
26 changed files with 284 additions and 499 deletions
|
@ -3,20 +3,6 @@
|
|||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk>
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
@ -27,13 +13,13 @@
|
|||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
static char *C25MatrixTable[10] = {"113311", "311131", "131131", "331111", "113131", "313111",
|
||||
static const char *C25MatrixTable[10] = {"113311", "311131", "131131", "331111", "113131", "313111",
|
||||
"133111", "111331", "311311", "131311"};
|
||||
|
||||
static char *C25IndustTable[10] = {"1111313111", "3111111131", "1131111131", "3131111111", "1111311131",
|
||||
static const char *C25IndustTable[10] = {"1111313111", "3111111131", "1131111131", "3131111111", "1111311131",
|
||||
"3111311111", "1131311111", "1111113131", "3111113111", "1131113111"};
|
||||
|
||||
static char *C25InterTable[10] = {"11331", "31113", "13113", "33111", "11313", "31311", "13311", "11133",
|
||||
static const char *C25InterTable[10] = {"11331", "31113", "13113", "33111", "11313", "31311", "13311", "11133",
|
||||
"31131", "13131"};
|
||||
|
||||
static inline char check_digit(unsigned int count)
|
||||
|
@ -48,7 +34,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int l
|
|||
char dest[512]; /* 6 + 80 * 6 + 6 + 1 ~ 512*/
|
||||
|
||||
error_number = 0;
|
||||
|
||||
|
||||
if(length > 80) {
|
||||
strcpy(symbol->errtxt, "Input too long");
|
||||
return ERROR_TOO_LONG;
|
||||
|
@ -58,7 +44,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int l
|
|||
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
|
||||
/* start character */
|
||||
strcpy(dest, "411111");
|
||||
|
||||
|
@ -68,7 +54,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int l
|
|||
|
||||
/* Stop character */
|
||||
concat (dest, "41111");
|
||||
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, source);
|
||||
return error_number;
|
||||
|
@ -81,7 +67,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], i
|
|||
char dest[512]; /* 6 + 40 * 10 + 6 + 1 */
|
||||
|
||||
error_number = 0;
|
||||
|
||||
|
||||
if(length > 45) {
|
||||
strcpy(symbol->errtxt, "Input too long");
|
||||
return ERROR_TOO_LONG;
|
||||
|
@ -91,7 +77,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], i
|
|||
strcpy(symbol->errtxt, "Invalid character in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
|
||||
/* start character */
|
||||
strcpy(dest, "313111");
|
||||
|
||||
|
@ -101,7 +87,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], i
|
|||
|
||||
/* Stop character */
|
||||
concat (dest, "31113");
|
||||
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, source);
|
||||
return error_number;
|
||||
|
@ -111,9 +97,9 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int len
|
|||
{ /* Code 2 of 5 IATA */
|
||||
int i, error_number;
|
||||
char dest[512]; /* 4 + 45 * 10 + 3 + 1 */
|
||||
|
||||
|
||||
error_number = 0;
|
||||
|
||||
|
||||
if(length > 45) {
|
||||
strcpy(symbol->errtxt, "Input too long");
|
||||
return ERROR_TOO_LONG;
|
||||
|
@ -123,17 +109,17 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int len
|
|||
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
|
||||
/* start */
|
||||
strcpy(dest, "1111");
|
||||
|
||||
for(i = 0; i < length; i++) {
|
||||
lookup(NEON, C25IndustTable, source[i], dest);
|
||||
}
|
||||
|
||||
|
||||
/* stop */
|
||||
concat (dest, "311");
|
||||
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, source);
|
||||
return error_number;
|
||||
|
@ -144,7 +130,7 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int le
|
|||
|
||||
int i, error_number;
|
||||
char dest[512]; /* 4 + 80 * 6 + 3 + 1 */
|
||||
|
||||
|
||||
error_number = 0;
|
||||
|
||||
if(length > 80) {
|
||||
|
@ -166,7 +152,7 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int le
|
|||
|
||||
/* Stop character */
|
||||
concat (dest, "311");
|
||||
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, source);
|
||||
return error_number;
|
||||
|
@ -184,7 +170,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[],
|
|||
#endif
|
||||
|
||||
error_number = 0;
|
||||
|
||||
|
||||
if(length > 89) {
|
||||
strcpy(symbol->errtxt, "Input too long");
|
||||
return ERROR_TOO_LONG;
|
||||
|
@ -194,7 +180,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[],
|
|||
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
|
||||
ustrcpy(temp, (unsigned char *) "");
|
||||
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
|
||||
if an odd number of characters has been entered then add a leading zero */
|
||||
|
@ -229,7 +215,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[],
|
|||
|
||||
/* Stop character */
|
||||
concat (dest, "311");
|
||||
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, temp);
|
||||
return error_number;
|
||||
|
@ -241,16 +227,16 @@ int itf14(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
int i, error_number, zeroes;
|
||||
unsigned int count;
|
||||
char localstr[16];
|
||||
|
||||
|
||||
error_number = 0;
|
||||
|
||||
count = 0;
|
||||
|
||||
|
||||
if(length > 13) {
|
||||
strcpy(symbol->errtxt, "Input too long");
|
||||
return ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if(error_number == ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "Invalid character in data");
|
||||
|
@ -263,7 +249,7 @@ int itf14(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
localstr[i] = '0';
|
||||
}
|
||||
strcpy(localstr + zeroes, (char *)source);
|
||||
|
||||
|
||||
/* Calculate the check digit - the same method used for EAN-13 */
|
||||
|
||||
for (i = 12; i >= 0; i--) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue