code cleanup and minor fixes

This commit is contained in:
oxygenic 2012-12-31 14:41:59 +01:00
parent 8c78216dc1
commit 1d241cca05
26 changed files with 1048 additions and 1092 deletions

View File

@ -3,55 +3,41 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009 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.
*/ */
static int c40_shift[] = { static const int c40_shift[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
static int c40_value[] = { static const int c40_value[] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13, 3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13,
15,16,17,18,19,20,21,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39, 15,16,17,18,19,20,21,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,
22,23,24,25,26,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 }; 22,23,24,25,26,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 };
static int text_shift[] = { static const int text_shift[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3 }; 2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3 };
static int text_value[] = { static const int text_value[] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13, 3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13,
15,16,17,18,19,20,21,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26, 15,16,17,18,19,20,21,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
22,23,24,25,26,0,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,27,28,29,30,31 }; 22,23,24,25,26,0,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,27,28,29,30,31 };
static int c1_height[] = { 16, 22, 28, 40, 52, 70, 104, 148 }; static const int c1_height[] = { 16, 22, 28, 40, 52, 70, 104, 148 };
static int c1_width[] = { 18, 22, 32, 42, 54, 76, 98, 134 }; static const int c1_width[] = { 18, 22, 32, 42, 54, 76, 98, 134 };
static int c1_data_length[] = { 10, 19, 44, 91, 182, 370, 732, 1480 }; static const int c1_data_length[] = { 10, 19, 44, 91, 182, 370, 732, 1480 };
static int c1_ecc_length[] = { 10, 16, 26, 44, 70, 140, 280, 560 }; static const int c1_ecc_length[] = { 10, 16, 26, 44, 70, 140, 280, 560 };
static int c1_blocks[] = { 1, 1, 1, 1, 1, 2, 4, 8 }; static const int c1_blocks[] = { 1, 1, 1, 1, 1, 2, 4, 8 };
static int c1_data_blocks[] = { 10, 19, 44, 91, 182, 185, 183, 185 }; static const int c1_data_blocks[] = { 10, 19, 44, 91, 182, 185, 183, 185 };
static int c1_ecc_blocks[] = { 10, 16, 26, 44, 70, 70, 70, 70 }; static const int c1_ecc_blocks[] = { 10, 16, 26, 44, 70, 70, 70, 70 };
static int c1_grid_width[] = { 4, 5, 7, 9, 12, 17, 22, 30 }; static const int c1_grid_width[] = { 4, 5, 7, 9, 12, 17, 22, 30 };
static int c1_grid_height[] = { 5, 7, 10, 15, 21, 30, 46, 68 }; static const int c1_grid_height[] = { 5, 7, 10, 15, 21, 30, 46, 68 };
#define C1_ASCII 1 #define C1_ASCII 1
#define C1_C40 2 #define C1_C40 2

View File

@ -32,7 +32,7 @@ static int list[2][170];
/* Code 128 tables checked against ISO/IEC 15417:2007 */ /* Code 128 tables checked against ISO/IEC 15417:2007 */
static char *C128Table[107] = {"212222", "222122", "222221", "121223", "121322", "131222", "122213", static const char *C128Table[107] = {"212222", "222122", "222221", "121223", "121322", "131222", "122213",
"122312", "132212", "221213", "221312", "231212", "112232", "122132", "122231", "113222", "122312", "132212", "221213", "221312", "231212", "112232", "122132", "122231", "113222",
"123122", "123221", "223211", "221132", "221231", "213212", "223112", "312131", "311222", "123122", "123221", "223211", "221132", "221231", "213212", "223112", "312131", "311222",
"321122", "321221", "312212", "322112", "322211", "212123", "212321", "232121", "111323", "321122", "321221", "312212", "322112", "322211", "212123", "212321", "232121", "111323",
@ -63,6 +63,9 @@ int parunmodd(unsigned char llyth)
return modd; return modd;
} }
/**
* bring together same type blocks
*/
void grwp(int *indexliste) void grwp(int *indexliste)
{ {
int i, j; int i, j;
@ -90,6 +93,9 @@ void grwp(int *indexliste)
} }
} }
/**
* Implements rules from ISO 15417 Annex E
*/
void dxsmooth(int *indexliste) void dxsmooth(int *indexliste)
{ /* Implements rules from ISO 15417 Annex E */ { /* Implements rules from ISO 15417 Annex E */
int i, current, last, next, length; int i, current, last, next, length;
@ -128,6 +134,10 @@ void dxsmooth(int *indexliste)
} }
/**
* Translate Code 128 Set A characters into barcodes.
* This set handles all control characters NULL to US.
*/
void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars) void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars)
{ /* Translate Code 128 Set A characters into barcodes */ { /* Translate Code 128 Set A characters into barcodes */
/* This set handles all control characters NULL to US */ /* This set handles all control characters NULL to US */
@ -152,10 +162,13 @@ void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars)
(*bar_chars)++; (*bar_chars)++;
} }
/**
* Translate Code 128 Set B characters into barcodes.
* This set handles all characters which are not part of long numbers and not
* control characters.
*/
void c128_set_b(unsigned char source, char dest[], int values[], int *bar_chars) void c128_set_b(unsigned char source, char dest[], int values[], int *bar_chars)
{ /* Translate Code 128 Set B characters into barcodes */ {
/* This set handles all characters which are not part of long numbers and not control characters */
if(source > 127) { if(source > 127) {
concat(dest, C128Table[source - 32 - 128]); concat(dest, C128Table[source - 32 - 128]);
values[(*bar_chars)] = source - 32 - 128; values[(*bar_chars)] = source - 32 - 128;
@ -368,7 +381,6 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length)
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
/* So now we know what start character to use - we can get on with it! */ /* So now we know what start character to use - we can get on with it! */
if(symbol->output_options & READER_INIT) { if(symbol->output_options & READER_INIT) {
/* Reader Initialisation mode */ /* Reader Initialisation mode */

View File

@ -21,7 +21,7 @@
/* This data set taken from ANSI/AIM-BC6-2000, 4th April 2000 */ /* This data set taken from ANSI/AIM-BC6-2000, 4th April 2000 */
static char *c49_table7[128] = { static const char *c49_table7[128] = {
/* Table 7: Code 49 ASCII Chart */ /* Table 7: Code 49 ASCII Chart */
"! ", "!A", "!B", "!C", "!D", "!E", "!F", "!G", "!H", "!I", "!J", "!K", "!L", "! ", "!A", "!B", "!C", "!D", "!E", "!F", "!G", "!H", "!I", "!J", "!K", "!L",
"!M", "!N", "!O", "!P", "!Q", "!R", "!S", "!T", "!U", "!V", "!W", "!X", "!Y", "!M", "!N", "!O", "!P", "!Q", "!R", "!S", "!T", "!U", "!V", "!W", "!X", "!Y",
@ -36,27 +36,27 @@ static char *c49_table7[128] = {
}; };
/* Table 5: Check Character Weighting Values */ /* Table 5: Check Character Weighting Values */
int c49_x_weight[] = { static const int c49_x_weight[] = {
1, 9, 31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43, 1, 9, 31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43,
39, 11, 13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10 39, 11, 13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10
}; };
int c49_y_weight[] = { static const int c49_y_weight[] = {
9, 31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43, 39, 9, 31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43, 39,
11, 13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10, 24 11, 13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10, 24
}; };
int c49_z_weight[] = { static const int c49_z_weight[] = {
31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43, 39, 11, 31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43, 39, 11,
13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10, 24, 30 13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10, 24, 30
}; };
static char *c49_table4[8] = { static const char *c49_table4[8] = {
/* Table 4: Row Parity Pattern for Code 49 Symbols */ /* Table 4: Row Parity Pattern for Code 49 Symbols */
"OEEO", "EOEO", "OOEE", "EEOO", "OEOE", "EOOE", "OOOO", "EEEE" "OEEO", "EOEO", "OOEE", "EEOO", "OEOE", "EOOE", "OOOO", "EEEE"
}; };
static char *c49_appxe_even[2401] = { static const char *c49_appxe_even[2401] = {
/* Appendix E - Code 49 Encodation Patterns (Even Symbol Character Parity) */ /* Appendix E - Code 49 Encodation Patterns (Even Symbol Character Parity) */
/* Column 1 */ /* Column 1 */
"11521132", "11521132",
@ -615,7 +615,7 @@ static char *c49_appxe_even[2401] = {
"31412311", "15121132", "24221131", "13321132", "22421131" "31412311", "15121132", "24221131", "13321132", "22421131"
}; };
static char *c49_appxe_odd[2401] = { static const char *c49_appxe_odd[2401] = {
/* Appendix E - Code 49 Encodation Patterns (Odd Symbol Character Parity) */ /* Appendix E - Code 49 Encodation Patterns (Odd Symbol Character Parity) */
/* Column 1 */ /* Column 1 */
"22121116", "22121116",

View File

@ -23,7 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "common.h" #include "common.h"
int ustrlen(unsigned char data[]) { int ustrlen(const unsigned char data[]) {
/* Local replacement for strlen() with unsigned char strings */ /* Local replacement for strlen() with unsigned char strings */
int i; int i;
for (i=0;data[i];i++); for (i=0;data[i];i++);
@ -31,7 +31,7 @@ int ustrlen(unsigned char data[]) {
return i; return i;
} }
void ustrcpy(unsigned char target[], unsigned char source[]) { void ustrcpy(unsigned char target[],const unsigned char source[]) {
/* Local replacement for strcpy() with unsigned char strings */ /* Local replacement for strcpy() with unsigned char strings */
int i, len; int i, len;
@ -52,7 +52,7 @@ void concat(char dest[],const char source[])
dest[i + j] = source[i]; } dest[i + j] = source[i]; }
} }
void uconcat(unsigned char dest[], unsigned char source[]) void uconcat(unsigned char dest[], const unsigned char source[])
{ /* Concatinates dest[] with the contents of source[], copying /0 as well */ { /* Concatinates dest[] with the contents of source[], copying /0 as well */
unsigned int i, j; unsigned int i, j;

View File

@ -27,10 +27,10 @@ extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
extern int ustrlen(unsigned char source[]); extern int ustrlen(const unsigned char source[]);
extern void ustrcpy(unsigned char target[], unsigned char source[]); extern void ustrcpy(unsigned char target[], const unsigned char source[]);
extern void concat(char dest[],const char source[]); extern void concat(char dest[], const char source[]);
extern void uconcat(unsigned char dest[], unsigned char source[]); extern void uconcat(unsigned char dest[], const unsigned char source[]);
extern int ctoi(char source); extern int ctoi(char source);
extern char itoc(int source); extern char itoc(int source);
extern void to_upper(unsigned char source[]); extern void to_upper(unsigned char source[]);

View File

@ -3,20 +3,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk> Copyright (C) 2009 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 "common.h" #include "common.h"
@ -43,58 +29,58 @@ extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], i
#define DM_EDIFACT 5 #define DM_EDIFACT 5
#define DM_BASE256 6 #define DM_BASE256 6
static int c40_shift[] = { static const int c40_shift[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
static int c40_value[] = { static const int c40_value[] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13, 3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13,
15,16,17,18,19,20,21,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39, 15,16,17,18,19,20,21,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,
22,23,24,25,26,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 }; 22,23,24,25,26,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 };
static int text_shift[] = { static const int text_shift[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3 }; 2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3 };
static int text_value[] = { static const int text_value[] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13, 3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13,
15,16,17,18,19,20,21,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26, 15,16,17,18,19,20,21,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
22,23,24,25,26,0,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,27,28,29,30,31 }; 22,23,24,25,26,0,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,27,28,29,30,31 };
static int intsymbol[] = { static const int intsymbol[] = {
0,1,3,5,7,8,10,12,13,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,2,4,6,9,11,14 }; 0,1,3,5,7,8,10,12,13,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,2,4,6,9,11,14 };
static int matrixH[] = { static const int matrixH[] = {
10, 12, 8, 14, 8, 16, 12, 18, 20, 12, 22, 16, 24, 26, 16, 32, 36, 40, 44, 48, 10, 12, 8, 14, 8, 16, 12, 18, 20, 12, 22, 16, 24, 26, 16, 32, 36, 40, 44, 48,
52, 64, 72, 80, 88, 96, 104, 120, 132, 144 }; 52, 64, 72, 80, 88, 96, 104, 120, 132, 144 };
static int matrixW[] = { static const int matrixW[] = {
10, 12, 18, 14, 32, 16, 26, 18, 20, 36, 22, 36, 24, 26, 48, 32, 36, 40, 44, 10, 12, 18, 14, 32, 16, 26, 18, 20, 36, 22, 36, 24, 26, 48, 32, 36, 40, 44,
48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144 }; 48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144 };
static int matrixFH[] = { static const int matrixFH[] = {
10, 12, 8, 14, 8, 16, 12, 18, 20, 12, 22, 16, 24, 26, 16, 16, 18, 20, 22, 24, 10, 12, 8, 14, 8, 16, 12, 18, 20, 12, 22, 16, 24, 26, 16, 16, 18, 20, 22, 24,
26, 16, 18, 20, 22, 24, 26, 20, 22, 24 }; 26, 16, 18, 20, 22, 24, 26, 20, 22, 24 };
static int matrixFW[] = { static const int matrixFW[] = {
10, 12, 18, 14, 16, 16, 26, 18, 20, 18, 22, 18, 24, 26, 24, 16, 18, 20, 22, 10, 12, 18, 14, 16, 16, 26, 18, 20, 18, 22, 18, 24, 26, 24, 16, 18, 20, 22,
24, 26, 16, 18, 20, 22, 24, 26, 20, 22, 24 }; 24, 26, 16, 18, 20, 22, 24, 26, 20, 22, 24 };
static int matrixbytes[] = { static const int matrixbytes[] = {
3, 5, 5, 8, 10, 12, 16, 18, 22, 22, 30, 32, 36, 44, 49, 62, 86, 114, 144, 3, 5, 5, 8, 10, 12, 16, 18, 22, 22, 30, 32, 36, 44, 49, 62, 86, 114, 144,
174, 204, 280, 368, 456, 576, 696, 816, 1050, 1304, 1558 }; 174, 204, 280, 368, 456, 576, 696, 816, 1050, 1304, 1558 };
static int matrixdatablock[] = { static const int matrixdatablock[] = {
3, 5, 5, 8, 10, 12, 16, 18, 22, 22, 30, 32, 36, 44, 49, 62, 86, 114, 144, 3, 5, 5, 8, 10, 12, 16, 18, 22, 22, 30, 32, 36, 44, 49, 62, 86, 114, 144,
174, 102, 140, 92, 114, 144, 174, 136, 175, 163, 156 }; 174, 102, 140, 92, 114, 144, 174, 136, 175, 163, 156 };
static int matrixrsblock[] = { static const int matrixrsblock[] = {
5, 7, 7, 10, 11, 12, 14, 14, 18, 18, 20, 24, 24, 28, 28, 36, 42, 48, 56, 68, 5, 7, 7, 10, 11, 12, 14, 14, 18, 18, 20, 24, 24, 28, 28, 36, 42, 48, 56, 68,
42, 56, 36, 48, 56, 68, 56, 68, 62, 62 }; 42, 56, 36, 48, 56, 68, 56, 68, 62, 62 };

View File

@ -3,26 +3,12 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk> 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.
*/ */
/* This file contains the pixel-by-pixel representation of the "Misc Fixed" font /* This file contains the pixel-by-pixel representation of the "Misc Fixed" font
at 10 point size processed by the Gimp */ at 10 point size processed by the Gimp */
static int ascii_font[9310] = { static const int ascii_font[9310] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -613,7 +599,7 @@ static int ascii_font[9310] = {
0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0
}; };
static int ascii_ext_font[9310] = { static const int ascii_ext_font[9310] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -1204,7 +1190,7 @@ static int ascii_ext_font[9310] = {
0,0,1,1,0,0,0,0,0 0,0,1,1,0,0,0,0,0
}; };
static int small_font[] = { static const int small_font[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -1447,7 +1433,7 @@ static int small_font[] = {
0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0
}; };
static int small_font_extended[] = { static const int small_font_extended[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

View File

@ -18,7 +18,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
unsigned long int gb2312_lookup[] = { static const unsigned long int gb2312_lookup[] = {
0x00A4, 0xA1E8, 0x00A4, 0xA1E8,
0x00A7, 0xA1EC, 0x00A7, 0xA1EC,
0x00A8, 0xA1A7, 0x00A8, 0xA1A7,

View File

@ -3,26 +3,12 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk> 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.
*/ */
/* The function "USPS_MSB_Math_CRC11GenerateFrameCheckSequence" /* The function "USPS_MSB_Math_CRC11GenerateFrameCheckSequence"
is Copyright (C) 2006 United States Postal Service */ is Copyright (C) 2006 United States Postal Service */
static short int BCD[40] = { static const short int BCD[40] = {
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0,
@ -45,7 +31,7 @@ static short int BCD[40] = {
/* The following lookup tables were generated using the code in Appendix C */ /* The following lookup tables were generated using the code in Appendix C */
static unsigned short AppxD_I[1287] = { /* Appendix D Table 1 - 5 of 13 characters */ static const unsigned short AppxD_I[1287] = { /* Appendix D Table 1 - 5 of 13 characters */
0x001F, 0x1F00, 0x002F, 0x1E80, 0x0037, 0x1D80, 0x003B, 0x1B80, 0x003D, 0x1780, 0x001F, 0x1F00, 0x002F, 0x1E80, 0x0037, 0x1D80, 0x003B, 0x1B80, 0x003D, 0x1780,
0x003E, 0x0F80, 0x004F, 0x1E40, 0x0057, 0x1D40, 0x005B, 0x1B40, 0x005D, 0x1740, 0x003E, 0x0F80, 0x004F, 0x1E40, 0x0057, 0x1D40, 0x005B, 0x1B40, 0x005D, 0x1740,
0x005E, 0x0F40, 0x0067, 0x1CC0, 0x006B, 0x1AC0, 0x006D, 0x16C0, 0x006E, 0x0EC0, 0x005E, 0x0F40, 0x0067, 0x1CC0, 0x006B, 0x1AC0, 0x006D, 0x16C0, 0x006E, 0x0EC0,
@ -176,7 +162,7 @@ static unsigned short AppxD_I[1287] = { /* Appendix D Table 1 - 5 of 13 characte
0x1823, 0x1883, 0x1843, 0x1445, 0x1249, 0x1151, 0x10E1, 0x0C46, 0x0A4A, 0x0952, 0x1823, 0x1883, 0x1843, 0x1445, 0x1249, 0x1151, 0x10E1, 0x0C46, 0x0A4A, 0x0952,
0x08E2, 0x064C, 0x0554, 0x04E4, 0x0358, 0x02E8, 0x01F0 }; 0x08E2, 0x064C, 0x0554, 0x04E4, 0x0358, 0x02E8, 0x01F0 };
static unsigned short AppxD_II[78] = { /* Appendix D Table II - 2 of 13 characters */ static const unsigned short AppxD_II[78] = { /* Appendix D Table II - 2 of 13 characters */
0x0003, 0x1800, 0x0005, 0x1400, 0x0006, 0x0C00, 0x0009, 0x1200, 0x000A, 0x0A00, 0x0003, 0x1800, 0x0005, 0x1400, 0x0006, 0x0C00, 0x0009, 0x1200, 0x000A, 0x0A00,
0x000C, 0x0600, 0x0011, 0x1100, 0x0012, 0x0900, 0x0014, 0x0500, 0x0018, 0x0300, 0x000C, 0x0600, 0x0011, 0x1100, 0x0012, 0x0900, 0x0014, 0x0500, 0x0018, 0x0300,
0x0021, 0x1080, 0x0022, 0x0880, 0x0024, 0x0480, 0x0028, 0x0280, 0x0030, 0x0180, 0x0021, 0x1080, 0x0022, 0x0880, 0x0024, 0x0480, 0x0028, 0x0280, 0x0030, 0x0180,
@ -186,7 +172,7 @@ static unsigned short AppxD_II[78] = { /* Appendix D Table II - 2 of 13 characte
0x0201, 0x1008, 0x0202, 0x0808, 0x0204, 0x0408, 0x0401, 0x1004, 0x0402, 0x0804, 0x0201, 0x1008, 0x0202, 0x0808, 0x0204, 0x0408, 0x0401, 0x1004, 0x0402, 0x0804,
0x0801, 0x1002, 0x1001, 0x0802, 0x0404, 0x0208, 0x0110, 0x00A0 }; 0x0801, 0x1002, 0x1001, 0x0802, 0x0404, 0x0208, 0x0110, 0x00A0 };
static int AppxD_IV[130] = { /* Appendix D Table IV - Bar-to-Character Mapping (reverse lookup) */ static const int AppxD_IV[130] = { /* Appendix D Table IV - Bar-to-Character Mapping (reverse lookup) */
67, 6, 78, 16, 86, 95, 34, 40, 45, 113, 117, 121, 62, 87, 18, 104, 41, 76, 57, 119, 115, 72, 97, 67, 6, 78, 16, 86, 95, 34, 40, 45, 113, 117, 121, 62, 87, 18, 104, 41, 76, 57, 119, 115, 72, 97,
2, 127, 26, 105, 35, 122, 52, 114, 7, 24, 82, 68, 63, 94, 44, 77, 112, 70, 100, 39, 30, 107, 2, 127, 26, 105, 35, 122, 52, 114, 7, 24, 82, 68, 63, 94, 44, 77, 112, 70, 100, 39, 30, 107,
15, 125, 85, 10, 65, 54, 88, 20, 106, 46, 66, 8, 116, 29, 61, 99, 80, 90, 37, 123, 51, 25, 84, 15, 125, 85, 10, 65, 54, 88, 20, 106, 46, 66, 8, 116, 29, 61, 99, 80, 90, 37, 123, 51, 25, 84,

View File

@ -24,7 +24,7 @@
#include "common.h" #include "common.h"
#include "large.h" #include "large.h"
static short int BCD[40] = { static const short int BCD[40] = {
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0,

View File

@ -19,7 +19,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
static int MaxiGrid[] = { /* ISO/IEC 16023 Figure 5 - MaxiCode Module Sequence */ /* 30 x 33 data grid */ static const int MaxiGrid[] = { /* ISO/IEC 16023 Figure 5 - MaxiCode Module Sequence */ /* 30 x 33 data grid */
122, 121, 128, 127, 134, 133, 140, 139, 146, 145, 152, 151, 158, 157, 164, 163, 170, 169, 176, 175, 182, 181, 188, 187, 194, 193, 200, 199, 0, 0, 122, 121, 128, 127, 134, 133, 140, 139, 146, 145, 152, 151, 158, 157, 164, 163, 170, 169, 176, 175, 182, 181, 188, 187, 194, 193, 200, 199, 0, 0,
124, 123, 130, 129, 136, 135, 142, 141, 148, 147, 154, 153, 160, 159, 166, 165, 172, 171, 178, 177, 184, 183, 190, 189, 196, 195, 202, 201, 817, 0, 124, 123, 130, 129, 136, 135, 142, 141, 148, 147, 154, 153, 160, 159, 166, 165, 172, 171, 178, 177, 184, 183, 190, 189, 196, 195, 202, 201, 817, 0,
126, 125, 132, 131, 138, 137, 144, 143, 150, 149, 156, 155, 162, 161, 168, 167, 174, 173, 180, 179, 186, 185, 192, 191, 198, 197, 204, 203, 819, 818, 126, 125, 132, 131, 138, 137, 144, 143, 150, 149, 156, 155, 162, 161, 168, 167, 174, 173, 180, 179, 186, 185, 192, 191, 198, 197, 204, 203, 819, 818,
@ -55,7 +55,7 @@ static int MaxiGrid[] = { /* ISO/IEC 16023 Figure 5 - MaxiCode Module Sequence *
738, 737, 744, 743, 750, 749, 756, 755, 762, 761, 768, 767, 774, 773, 780, 779, 786, 785, 792, 791, 798, 797, 804, 803, 810, 809, 816, 815, 864, 863 738, 737, 744, 743, 750, 749, 756, 755, 762, 761, 768, 767, 774, 773, 780, 779, 786, 785, 792, 791, 798, 797, 804, 803, 810, 809, 816, 815, 864, 863
}; };
int maxiCodeSet[256] = { /* from Appendix A - ASCII character to Code Set (e.g. 2 = Set B) */ static const int maxiCodeSet[256] = { /* from Appendix A - ASCII character to Code Set (e.g. 2 = Set B) */
/* set 0 refers to special characters that fit into more than one set (e.g. GS) */ /* set 0 refers to special characters that fit into more than one set (e.g. GS) */
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 0, 2, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 0, 2, 1, 1, 1, 1, 1, 1,
@ -72,7 +72,7 @@ int maxiCodeSet[256] = { /* from Appendix A - ASCII character to Code Set (e.g.
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
}; };
int maxiSymbolChar[256] = { /* from Appendix A - ASCII character to symbol value */ static const int maxiSymbolChar[256] = { /* from Appendix A - ASCII character to symbol value */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 30, 28, 29, 30, 35, 32, 53, 34, 35, 36, 37, 38, 39, 20, 21, 22, 23, 24, 25, 26, 30, 28, 29, 30, 35, 32, 53, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 37, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 37,

View File

@ -25,7 +25,7 @@
#define SSET "0123456789ABCDEF" #define SSET "0123456789ABCDEF"
static int hexagon[120] = { static const int hexagon[120] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
@ -40,7 +40,7 @@ static int hexagon[120] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}; };
static unsigned int bullseye_compressed[] = { static const unsigned int bullseye_compressed[] = {
0,0,0,0,0,255,248,0,0,0,0,0, 0,0,0,0,0,255,248,0,0,0,0,0,
0,0,0,0,31,255,255,192,0,0,0,0, 0,0,0,0,31,255,255,192,0,0,0,0,
0,0,0,1,255,255,255,252,0,0,0,0, 0,0,0,1,255,255,255,252,0,0,0,0,

View File

@ -39,7 +39,7 @@ int plessey(struct zint_symbol *symbol, unsigned char source[], int length)
unsigned int i, check; unsigned int i, check;
unsigned char *checkptr; unsigned char *checkptr;
static char grid[9] = {1,1,1,1,0,1,0,0,1}; static const char grid[9] = {1,1,1,1,0,1,0,0,1};
char dest[1024]; /* 8 + 65 * 8 + 8 * 2 + 9 + 1 ~ 1024 */ char dest[1024]; /* 8 + 65 * 8 + 8 * 2 + 9 + 1 ~ 1024 */
int error_number; int error_number;

View File

@ -157,7 +157,7 @@ int estimate_binary_length(char mode[], int length, int gs1)
return count; return count;
} }
static inline void qr_bscan(char *binary, int data, int h) static void qr_bscan(char *binary, int data, int h)
{ {
for (; h; h>>=1) { for (; h; h>>=1) {
concat(binary, data & h ? "1" : "0"); concat(binary, data & h ? "1" : "0");