mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-27 05:24:13 -04:00
PDF417: fix cols/rows calculation to require multiple <= 928 codewords;
add specify rows option (option_3) (#204); warn if cols increased from specified (back-incompatible); move table definitions from "pdf417.h" to new "pdf417_tabs.h" and make INTERNAL_DATA and share with composite.c (saves ~10K); prefix routines and tables with "pdf_"; some small performance improvements through if/elses, pdf_textprocess() & pdf_numbprocess() loop simplifications MICROQR: fix debug access crash on printing non-NUL-terminating binary DATAMATRIX: fix missing ++ from "[tp]" at C40/TEXT EOD processing of GS1 (though probably never reached); use "[tp++]" throughout Add const to static tables missing it and also to some variables Change "debug" -> "debug_print" throughout
This commit is contained in:
parent
706f021637
commit
4e72a541f7
47 changed files with 1949 additions and 1231 deletions
|
@ -99,9 +99,9 @@ static void types(void) {
|
|||
|
||||
/* Output usage information */
|
||||
static void usage(void) {
|
||||
int zint_version = ZBarcode_Version();
|
||||
int version_major = zint_version / 10000;
|
||||
int version_minor = (zint_version % 10000) / 100;
|
||||
const int zint_version = ZBarcode_Version();
|
||||
const int version_major = zint_version / 10000;
|
||||
const int version_minor = (zint_version % 10000) / 100;
|
||||
int version_release = zint_version % 100;
|
||||
int version_build;
|
||||
|
||||
|
@ -109,10 +109,10 @@ static void usage(void) {
|
|||
/* This is a test release */
|
||||
version_release = version_release / 10;
|
||||
version_build = zint_version % 10;
|
||||
printf( "Zint version %d.%d.%d.%d (dev)\n", version_major, version_minor, version_release, version_build);
|
||||
printf("Zint version %d.%d.%d.%d (dev)\n", version_major, version_minor, version_release, version_build);
|
||||
} else {
|
||||
/* This is a stable release */
|
||||
printf( "Zint version %d.%d.%d\n", version_major, version_minor, version_release);
|
||||
printf("Zint version %d.%d.%d\n", version_major, version_minor, version_release);
|
||||
}
|
||||
|
||||
printf( "Encode input data in a barcode and save as BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF/TXT\n\n"
|
||||
|
@ -156,11 +156,11 @@ static void usage(void) {
|
|||
" --noquietzones Disable default quiet zones\n"
|
||||
" --notext Remove human readable text\n"
|
||||
" -o, --output=FILE Send output to FILE. Default is out.png\n"
|
||||
" --primary=STRING Set structured primary message (MaxiCode/Composite)\n"
|
||||
" --primary=STRING Set primary message (MaxiCode/Composite)\n"
|
||||
" --quietzones Add compliant quiet zones\n"
|
||||
" -r, --reverse Reverse colours (white on black)\n"
|
||||
" --rotate=NUMBER Rotate symbol by NUMBER degrees\n"
|
||||
" --rows=NUMBER Set number of rows (Codablock-F)\n"
|
||||
" --rows=NUMBER Set number of rows (Codablock-F/PDF417)\n"
|
||||
" --scale=NUMBER Adjust size of X-dimension\n"
|
||||
" --scmvv=NUMBER Prefix SCM with \"[)>\\R01\\Gvv\" (vv is NUMBER) (MaxiCode)\n"
|
||||
" --secure=NUMBER Set error correction level (ECC)\n"
|
||||
|
@ -213,7 +213,7 @@ static void show_eci(void) {
|
|||
static int validate_int(const char source[], int *p_val) {
|
||||
int val = 0;
|
||||
int i;
|
||||
int length = (int) strlen(source);
|
||||
const int length = (int) strlen(source);
|
||||
|
||||
if (length > 9) { /* Prevent overflow */
|
||||
return 0;
|
||||
|
@ -241,7 +241,8 @@ static char itoc(const int source) {
|
|||
|
||||
/* Converts upper case characters to lower case in a string source[] */
|
||||
static void to_lower(char source[]) {
|
||||
int i, src_len = (int) strlen(source);
|
||||
int i;
|
||||
const int src_len = (int) strlen(source);
|
||||
|
||||
for (i = 0; i < src_len; i++) {
|
||||
if ((source[i] >= 'A') && (source[i] <= 'Z')) {
|
||||
|
@ -393,8 +394,8 @@ static int get_barcode_name(const char *barcode_name) {
|
|||
n[j] = '\0';
|
||||
|
||||
while (s <= e) {
|
||||
int m = (s + e) / 2;
|
||||
int cmp = strcmp(names[m].n, n);
|
||||
const int m = (s + e) / 2;
|
||||
const int cmp = strcmp(names[m].n, n);
|
||||
if (cmp < 0) {
|
||||
s = m + 1;
|
||||
} else if (cmp > 0) {
|
||||
|
@ -750,7 +751,7 @@ static int win_argc = 0;
|
|||
static char **win_argv = NULL;
|
||||
|
||||
/* Free Windows args */
|
||||
static void win_free_args() {
|
||||
static void win_free_args(void) {
|
||||
int i;
|
||||
if (!win_argv) {
|
||||
return;
|
||||
|
@ -775,14 +776,15 @@ static void win_args(int *p_argc, char ***p_argv) {
|
|||
LocalFree(szArgList);
|
||||
} else {
|
||||
for (i = 0; i < win_argc; i++) {
|
||||
int len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, szArgList[i], -1, NULL, 0, NULL, NULL);
|
||||
const int len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, szArgList[i], -1, NULL, 0,
|
||||
NULL /*lpDefaultChar*/, NULL /*lpUsedDefaultChar*/);
|
||||
if (len == 0 || !(win_argv[i] = malloc(len + 1))) {
|
||||
win_free_args();
|
||||
LocalFree(szArgList);
|
||||
return;
|
||||
}
|
||||
if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, szArgList[i], -1, win_argv[i], len, NULL, NULL)
|
||||
== 0) {
|
||||
if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, szArgList[i], -1, win_argv[i], len,
|
||||
NULL /*lpDefaultChar*/, NULL /*lpUsedDefaultChar*/) == 0) {
|
||||
win_free_args();
|
||||
LocalFree(szArgList);
|
||||
return;
|
||||
|
@ -822,6 +824,7 @@ int main(int argc, char **argv) {
|
|||
int mask = 0;
|
||||
int separator = 0;
|
||||
int addon_gap = 0;
|
||||
int rows = 0;
|
||||
char filetype[4] = {0};
|
||||
int no_png;
|
||||
int png_refused;
|
||||
|
@ -868,7 +871,7 @@ int main(int argc, char **argv) {
|
|||
OPT_VERBOSE, OPT_VERS, OPT_VWHITESP, OPT_WERROR,
|
||||
};
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
static const struct option long_options[] = {
|
||||
{"addongap", 1, NULL, OPT_ADDONGAP},
|
||||
{"barcode", 1, NULL, 'b'},
|
||||
{"batch", 0, NULL, OPT_BATCH},
|
||||
|
@ -930,7 +933,7 @@ int main(int argc, char **argv) {
|
|||
{"whitesp", 1, NULL, 'w'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
int c = getopt_long_only(argc, argv, "b:d:ehi:o:rtw:", long_options, &option_index);
|
||||
const int c = getopt_long_only(argc, argv, "b:d:ehi:o:rtw:", long_options, &option_index);
|
||||
if (c == -1) break;
|
||||
|
||||
switch (c) {
|
||||
|
@ -1182,10 +1185,10 @@ int main(int argc, char **argv) {
|
|||
fprintf(stderr, "Error 132: Invalid rows value (digits only)\n");
|
||||
return do_exit(1);
|
||||
}
|
||||
if ((val >= 1) && (val <= 44)) {
|
||||
my_symbol->option_1 = val;
|
||||
if ((val >= 1) && (val <= 90)) {
|
||||
rows = val;
|
||||
} else {
|
||||
fprintf(stderr, "Warning 112: Number of rows out of range (1 to 44), ignoring\n");
|
||||
fprintf(stderr, "Warning 112: Number of rows out of range (1 to 90), ignoring\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
break;
|
||||
|
@ -1371,8 +1374,8 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (data_arg_num) {
|
||||
unsigned int cap = ZBarcode_Cap(my_symbol->symbology, ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE |
|
||||
ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK);
|
||||
const unsigned int cap = ZBarcode_Cap(my_symbol->symbology, ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE |
|
||||
ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK);
|
||||
if (fullmultibyte && (cap & ZINT_CAP_FULL_MULTIBYTE)) {
|
||||
my_symbol->option_3 = ZINT_FULL_MULTIBYTE;
|
||||
}
|
||||
|
@ -1385,6 +1388,14 @@ int main(int argc, char **argv) {
|
|||
if (addon_gap && (cap & ZINT_CAP_EXTENDABLE)) {
|
||||
my_symbol->option_2 = addon_gap;
|
||||
}
|
||||
if (rows) {
|
||||
if (my_symbol->symbology == BARCODE_PDF417 || my_symbol->symbology == BARCODE_PDF417COMP
|
||||
|| my_symbol->symbology == BARCODE_HIBC_PDF) {
|
||||
my_symbol->option_3 = rows;
|
||||
} else if (my_symbol->symbology == BARCODE_CODABLOCKF || my_symbol->symbology == BARCODE_HIBC_BLOCKF) {
|
||||
my_symbol->option_1 = rows;
|
||||
}
|
||||
}
|
||||
|
||||
if (batch_mode) {
|
||||
/* Take each line of text as a separate data set */
|
||||
|
|
|
@ -277,7 +277,7 @@ static void test_dump_args(int index, int debug) {
|
|||
/* 14*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 1, "B2 D6 96 CA B5 64" },
|
||||
/* 15*/ { BARCODE_CODE11, "123", NULL, "456", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2" },
|
||||
/* 16*/ { BARCODE_CODE11, "123", "456", "789", "012", -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2\nB2 A6 D2 D5 64\nB2 AD AD 2D 64" },
|
||||
/* 17*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, 1, 0, 0, -1, "FF 54 7A BC 3D 4F 1D 5C 0F E8 A4\nFF 54 7A 90 2F D3 1F AB 8F E8 A4\nFF 54 6A F8 3A BF 15 3C 0F E8 A4\nFF 54 57 9E 24 E7 1A F7 CF E8 A4\nFF 54 7A E7 3D 0D 9D 73 0F E8 A4\nFF 54 7D 70 B9 CB DF 5E CF E8 A4" },
|
||||
/* 17*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 0, 0, -1, "FF 54 7A BC 3D 4F 1D 5C 0F E8 A4\nFF 54 7A 90 2F D3 1F AB 8F E8 A4\nFF 54 6A F8 3A BF 15 3C 0F E8 A4\nFF 54 57 9E 24 E7 1A F7 CF E8 A4\nFF 54 7A E7 3D 0D 9D 73 0F E8 A4\nFF 54 7D 70 B9 CB DF 5E CF E8 A4" },
|
||||
/* 18*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA 8\nB3 4\n8F 0\nB2 C\nA6 0\nBA C\nD6 0\nEB 4\nE2 8\nFF C" },
|
||||
/* 19*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, READER_INIT, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\nAC 7\n8A 4\nA0 3\nC2 2\nB5 1\n82 2\nBA 7\n8C C\nA0 5\n86 A\nFF F" },
|
||||
/* 20*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\nA6 ED A9 D1\nB2 FE 92 7E\n98 E7 C3 FF\nE8 D0 90 CC\nC7 EB 8D 63\nC5 48 D3 C4\nFF FF FF FF" },
|
||||
|
@ -663,7 +663,7 @@ static void test_checks(int index, int debug) {
|
|||
/* 19*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value (digits only)" },
|
||||
/* 20*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 137: Invalid rotation parameter (0, 90, 180 or 270 only), ignoring" },
|
||||
/* 21*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, "Error 132: Invalid rows value (digits only)" },
|
||||
/* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, "Warning 112: Number of rows out of range (1 to 44), ignoring" },
|
||||
/* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, -1, -1, "Warning 112: Number of rows out of range (1 to 90), ignoring" },
|
||||
/* 23*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Warning 105: Invalid scale value (less than 0.01), ignoring" },
|
||||
/* 24*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 0.49, -1, -1, -1, -1, -1, -1, "Warning 146: Scaling less than 0.5 will be set to 0.5 for 'gif' output" },
|
||||
/* 25*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Error 149: Invalid Structured Carrier Message version value (digits only)" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue