Update Zint

This commit is contained in:
Rodrigo Torres
2022-01-26 09:16:57 -03:00
parent fdf7807cfb
commit 6822ade01b
621 changed files with 303830 additions and 67843 deletions

352
3rdparty/zint-2.10.0/backend/2of5.c vendored Normal file
View File

@@ -0,0 +1,352 @@
/* 2of5.c - Handles Code 2 of 5 barcodes */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include "common.h"
#include "gs1.h"
static const char *C25MatrixTable[10] = {
"113311", "311131", "131131", "331111", "113131",
"313111", "133111", "111331", "311311", "131311"
};
static const char *C25MatrixStartStop[2] = { "411111", "41111" };
static const char *C25IndustTable[10] = {
"1111313111", "3111111131", "1131111131", "3131111111", "1111311131",
"3111311111", "1131311111", "1111113131", "3111113111", "1131113111"
};
static const char *C25IndustStartStop[2] = { "313111", "31113" };
static const char *C25IataLogicStartStop[2] = { "1111", "311" };
static const char *C25InterTable[10] = {
"11331", "31113", "13113", "33111", "11313",
"31311", "13311", "11133", "31131", "13131"
};
static char check_digit(const unsigned int count) {
return itoc((10 - (count % 10)) % 10);
}
/* Common to Standard (Matrix), Industrial, IATA, and Data Logic */
static int c25_common(struct zint_symbol *symbol, const unsigned char source[], int length, const int max,
const char *table[10], const char *start_stop[2], const int error_base) {
int i, error_number;
char dest[512]; /* Largest destination 6 + (80 + 1) * 6 + 5 + 1 = 498 */
unsigned char temp[80 + 1 + 1]; /* Largest maximum 80 */
int have_checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2;
if (length > max) {
sprintf(symbol->errtxt, "%d: Input too long (%d character maximum)", error_base, max);
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
sprintf(symbol->errtxt, "%d: Invalid character in data (digits only)", error_base + 1);
return error_number;
}
ustrcpy(temp, source);
if (have_checkdigit) {
/* Add standard GS1 check digit */
temp[length] = gs1_check_digit(source, length);
temp[++length] = '\0';
}
/* start character */
strcpy(dest, start_stop[0]);
for (i = 0; i < length; i++) {
lookup(NEON, table, temp[i], dest);
}
/* Stop character */
strcat(dest, start_stop[1]);
expand(symbol, dest);
ustrcpy(symbol->text, temp);
if (symbol->option_2 == 2) {
/* Remove check digit from HRT */
symbol->text[length - 1] = '\0';
}
return error_number;
}
/* Code 2 of 5 Standard (Code 2 of 5 Matrix) */
INTERNAL int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25_common(symbol, source, length, 80, C25MatrixTable, C25MatrixStartStop, 301);
}
/* Code 2 of 5 Industrial */
INTERNAL int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25_common(symbol, source, length, 45, C25IndustTable, C25IndustStartStop, 303);
}
/* Code 2 of 5 IATA */
INTERNAL int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25_common(symbol, source, length, 45, C25IndustTable, C25IataLogicStartStop, 305);
}
/* Code 2 of 5 Data Logic */
INTERNAL int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25_common(symbol, source, length, 80, C25MatrixTable, C25IataLogicStartStop, 307);
}
/* Common to Interleaved, ITF-14, DP Leitcode, DP Identcode */
static int c25inter_common(struct zint_symbol *symbol, unsigned char source[], int length,
const int dont_set_height) {
int i, j, error_number;
char bars[7], spaces[7], mixed[14], dest[512]; /* 4 + (90 + 2) * 5 + 3 + 1 = 468 */
unsigned char temp[90 + 2 + 1];
int have_checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2;
float height;
if (length > 90) {
strcpy(symbol->errtxt, "309: Input too long (90 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "310: Invalid character in data (digits only)");
return error_number;
}
temp[0] = '\0';
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
if an odd number of characters has been entered and no check digit or an even number and have check digit
then add a leading zero */
if (((length & 1) && !have_checkdigit) || (!(length & 1) && have_checkdigit)) {
ustrcpy(temp, "0");
length++;
}
ustrncat(temp, source, length);
if (have_checkdigit) {
/* Add standard GS1 check digit */
temp[length] = gs1_check_digit(temp, length);
temp[++length] = '\0';
}
/* start character */
strcpy(dest, "1111");
for (i = 0; i < length; i += 2) {
int k = 0;
/* look up the bars and the spaces and put them in two strings */
bars[0] = '\0';
lookup(NEON, C25InterTable, temp[i], bars);
spaces[0] = '\0';
lookup(NEON, C25InterTable, temp[i + 1], spaces);
/* then merge (interlace) the strings together */
for (j = 0; j <= 4; j++) {
mixed[k] = bars[j];
k++;
mixed[k] = spaces[j];
k++;
}
mixed[k] = '\0';
strcat(dest, mixed);
}
/* Stop character */
strcat(dest, "311");
expand(symbol, dest);
ustrcpy(symbol->text, temp);
if (symbol->option_2 == 2) {
/* Remove check digit from HRT */
symbol->text[length - 1] = '\0';
}
if (!dont_set_height) {
#ifdef COMPLIANT_HEIGHTS
/* ISO/IEC 16390:2007 Section 4.4 min height 5mm or 15% of symbol width whichever greater where
(P = character pairs, N = wide/narrow ratio = 3) width = (P(4N + 6) + N + 6)X = (length / 2) * 18 + 9 */
height = (float) ((18.0 * (length / 2) + 9.0) * 0.15);
if (height < (float) (5.0 / 0.33)) { /* Taking X = 0.330mm from Annex D.3.1 (application specification) */
height = (float) (5.0 / 0.33);
}
/* Using 50 as default as none recommended */
error_number = set_height(symbol, height, height > 50.0f ? height : 50.0f, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
}
return error_number;
}
/* Code 2 of 5 Interleaved ISO/IEC 16390:2007 */
INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25inter_common(symbol, source, length, 0 /*dont_set_height*/);
}
/* Interleaved 2-of-5 (ITF-14) */
INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number, warn_number = 0, zeroes;
unsigned char localstr[16] = {0};
if (length > 13) {
strcpy(symbol->errtxt, "311: Input too long (13 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "312: Invalid character in data (digits only)");
return error_number;
}
/* Add leading zeros as required */
zeroes = 13 - length;
for (i = 0; i < zeroes; i++) {
localstr[i] = '0';
}
ustrcpy(localstr + zeroes, source);
/* Calculate the check digit - the same method used for EAN-13 */
localstr[13] = gs1_check_digit(localstr, 13);
localstr[14] = '\0';
error_number = c25inter_common(symbol, localstr, 14, 1 /*dont_set_height*/);
ustrcpy(symbol->text, localstr);
if (!((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND))) {
// If no option has been selected then uses default box option
symbol->output_options |= BARCODE_BOX;
if (symbol->border_width == 0) { /* Allow override if non-zero */
/* GS1 General Specifications 21.0.1 Sections 5.3.2.4 & 5.3.6 (4.83 / 1.016 ~ 4.75) */
symbol->border_width = 5; /* Note change from previous value 8 */
}
}
if (error_number < ZINT_ERROR) {
#ifdef COMPLIANT_HEIGHTS
/* GS1 General Specifications 21.0.1 5.12.3.2 table 2, including footnote (**): (note bind/box additional to
symbol->height), same as GS1-128: "in case of further space constraints"
height 5.8mm / 1.016mm (X max) ~ 5.7; default 31.75mm / 0.495mm ~ 64.14 */
warn_number = set_height(symbol, (float) (5.8 / 1.016), (float) (31.75 / 0.495), 0.0f, 0 /*no_errtxt*/);
#else
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
return error_number ? error_number : warn_number;
}
/* Deutshe Post Leitcode */
INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
unsigned int count;
unsigned char localstr[16] = {0};
int zeroes;
count = 0;
if (length > 13) {
strcpy(symbol->errtxt, "313: Input wrong length (13 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "314: Invalid character in data (digits only)");
return error_number;
}
zeroes = 13 - length;
for (i = 0; i < zeroes; i++)
localstr[i] = '0';
ustrcpy(localstr + zeroes, source);
for (i = 12; i >= 0; i--) {
count += 4 * ctoi(localstr[i]);
if (i & 1) {
count += 5 * ctoi(localstr[i]);
}
}
localstr[13] = check_digit(count);
localstr[14] = '\0';
error_number = c25inter_common(symbol, localstr, 14, 1 /*dont_set_height*/);
ustrcpy(symbol->text, localstr);
// TODO: Find documentation on BARCODE_DPLEIT dimensions/height
return error_number;
}
/* Deutsche Post Identcode */
INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number, zeroes;
unsigned int count;
unsigned char localstr[16] = {0};
count = 0;
if (length > 11) {
strcpy(symbol->errtxt, "315: Input wrong length (11 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "316: Invalid character in data (digits only)");
return error_number;
}
zeroes = 11 - length;
for (i = 0; i < zeroes; i++)
localstr[i] = '0';
ustrcpy(localstr + zeroes, source);
for (i = 10; i >= 0; i--) {
count += 4 * ctoi(localstr[i]);
if (i & 1) {
count += 5 * ctoi(localstr[i]);
}
}
localstr[11] = check_digit(count);
localstr[12] = '\0';
error_number = c25inter_common(symbol, localstr, 12, 1 /*dont_set_height*/);
ustrcpy(symbol->text, localstr);
// TODO: Find documentation on BARCODE_DPIDENT dimensions/height
return error_number;
}

View File

@@ -0,0 +1,70 @@
# Copyright (C) 2008 by BogDan Vatra < bogdan@licentia.eu >
# Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
# vim: set ts=4 sw=4 et :
project(zint)
configure_file(zintconfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/zintconfig.h)
set(zint_COMMON_SRCS common.c library.c large.c reedsol.c gs1.c eci.c general_field.c sjis.c gb2312.c gb18030.c)
set(zint_ONEDIM_SRCS code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c)
set(zint_POSTAL_SRCS postal.c auspost.c imail.c mailmark.c)
set(zint_TWODIM_SRCS code16k.c codablock.c dmatrix.c pdf417.c qr.c maxicode.c composite.c aztec.c code49.c code1.c gridmtx.c hanxin.c dotcode.c ultra.c)
set(zint_OUTPUT_SRCS vector.c ps.c svg.c emf.c bmp.c pcx.c gif.c png.c tif.c raster.c output.c)
set(zint_SRCS ${zint_OUTPUT_SRCS} ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS})
add_library(zint SHARED ${zint_SRCS})
if(ZINT_STATIC)
add_library(zint-static STATIC ${zint_SRCS})
endif()
function(zint_target_link_libraries library)
target_link_libraries(zint ${library})
if(ZINT_STATIC)
target_link_libraries(zint-static ${library})
endif()
endfunction()
function(zint_target_compile_definitions scope definition)
target_compile_definitions(zint ${scope} ${definition})
if(ZINT_STATIC)
target_compile_definitions(zint-static ${scope} ${definition})
endif()
endfunction()
set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
VERSION ${ZINT_VERSION})
if(ZINT_USE_PNG)
find_package(PNG)
endif()
if(ZINT_USE_PNG AND PNG_FOUND)
zint_target_link_libraries(PNG::PNG)
else()
zint_target_compile_definitions(PUBLIC NO_PNG)
endif()
if(ZINT_TEST)
zint_target_compile_definitions(PUBLIC ZINT_TEST)
endif()
if(NOT MSVC)
# Link with standard C math library.
zint_target_link_libraries(m)
endif()
if(MSVC)
target_compile_definitions(zint PRIVATE DLL_EXPORT)
endif()
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS})
if(ZINT_STATIC)
install(TARGETS zint-static ${INSTALL_TARGETS_DEFAULT_ARGS})
endif()
install(FILES zint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
if(ZINT_TEST)
add_subdirectory(tests)
endif()

133
3rdparty/zint-2.10.0/backend/DEVELOPER vendored Normal file
View File

@@ -0,0 +1,133 @@
Contents
--------
Here is a guide to which bit of source code does what.
2of5.c:
Matrix 2 of 5
Industrial 2 of 5
IATA 2 of 5
Data Logic
Interleaved 2 of 5
ITF-14
Deutche Post Leitcode
Deutche Post Identcode
auspost.c:
Australia Post Standard Customer Barcode
Australia Post Customer Barcode 2
Australia Post Customer Barcode 3
Australia Post Reply Paid Barcode
Australia Post Routing Barcode
Australia Post Redirect Barcode
aztec.c:
Aztec Code
Compact Aztec Code
Aztec Runes
blockf.c:
Codablock-F
code128.c:
Code 128
Code 128 Subset B
NVE-18
GS1-128 (UCC/EAN-128)
EAN-14
code16k.c:
Code 16k
code.c:
Code 11
Code 39
Pharmazentral Nummer (PZN)
Extended Code 39 (Code 39+)
Code 93
LOGMARS
Channel Code
code1.c:
Code One
code49.c:
Code 49
composite.c:
CC-A Composite Symbology
CC-B Composite Symbology
CC-C Composite Symbology
dotcode.c:
Dot Code
dm200.c:
Data Matrix ECC 200
gridmtx.c:
Grid Matrix
hanxin.c:
Han Xin Code
imail.c:
USPS OneCode (Intelligent Mail)
maxicode.c:
UPS Maxicode
medical.c:
Pharma Code
Two Track Pharma Code
Codabar
Code 32
pdf417.c:
PDF417
Truncated PDF417
MicroPDF417
plessey.c:
UK Plessey Code (bidirectional)
MSI Plessey
postal.c:
PostNet
PLANET
Facing Identification Mark (FIM)
Royal Mail 4-State Country Code (RM4SCC)
KIX Code
DAFT Code
Flattermarken
Korean Postal Code
Japanese Postal Code
qr.c:
QR Code
Micro QR Code
UPNQR
rss.c:
GS1 DataBar (DataBar-14) (RSS-14)
GS1 DataBar Stacked (RSS-14 Stacked)
GS1 DataBar Stacked Omnidirectional (DataBar-14 Stacked Omnidirectional)
(RSS-14 Stacked Omnidirectional)
GS1 DataBar Limited (RSS Limited)
GS1 DataBar Expanded (RSS Expanded)
GS1 DataBar Expanded Stacked (RSS Expanded Stacked)
telepen.c:
Telepen ASCII
Telepen Numeric
upcean.c:
UPC-A
UPC-E
EAN-2 add-on
EAN-5 add-on
EAN-8
EAN-13
SBN (verification)
ISBN (verification)
ISBN-13 (verification)

13
3rdparty/zint-2.10.0/backend/LICENSE vendored Normal file
View File

@@ -0,0 +1,13 @@
ZINT was originally developed by Robin Stuart and licensed under the terms of the GPL (Gnu
Public License). In 2013 Robin Stuart and all developers that contributed to the code agreed
to change the license to a less restrictive one (see ZINT mailing list of May 2013 for
related mails) under the following conditions:
- the names of original copyright holder Robin Stuart and contributors are not removed,
neither from sources nor from the manual
- the documentation is done in British English (as Robin said: "Oh, and please don't
replace the word "colour" with "color" in the documentation - that really annoys me!")
Change to BSD-license is done for backend and therefore for ZINT shared library only, for
the frontends and Qt4-backend the GPL is still valid. Since BSD-license is GPL-compatible
this gives the possibility to include ZINT library in own products or link against it from
own software.

260
3rdparty/zint-2.10.0/backend/auspost.c vendored Normal file
View File

@@ -0,0 +1,260 @@
/* auspost.c - Handles Australia Post 4-State Barcode */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#define GDSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #"
static const char *AusNTable[10] = {
"00", "01", "02", "10", "11", "12", "20", "21", "22", "30"
};
static const char *AusCTable[64] = {
"222", "300", "301", "302", "310", "311", "312", "320", "321", "322",
"000", "001", "002", "010", "011", "012", "020", "021", "022", "100", "101", "102", "110",
"111", "112", "120", "121", "122", "200", "201", "202", "210", "211", "212", "220", "221",
"023", "030", "031", "032", "033", "103", "113", "123", "130", "131", "132", "133", "203",
"213", "223", "230", "231", "232", "233", "303", "313", "323", "330", "331", "332", "333",
"003", "013"
};
static const char *AusBarTable[64] = {
"000", "001", "002", "003", "010", "011", "012", "013", "020", "021",
"022", "023", "030", "031", "032", "033", "100", "101", "102", "103", "110", "111", "112",
"113", "120", "121", "122", "123", "130", "131", "132", "133", "200", "201", "202", "203",
"210", "211", "212", "213", "220", "221", "222", "223", "230", "231", "232", "233", "300",
"301", "302", "303", "310", "311", "312", "313", "320", "321", "322", "323", "330", "331",
"332", "333"
};
#include <stdio.h>
#include "common.h"
#include "reedsol.h"
static char convert_pattern(char data, int shift) {
return (data - '0') << shift;
}
/* Adds Reed-Solomon error correction to auspost */
static void rs_error(char data_pattern[]) {
int reader, len, triple_writer = 0;
unsigned char triple[31];
unsigned char result[5];
rs_t rs;
for (reader = 2, len = (int) strlen(data_pattern); reader < len; reader += 3, triple_writer++) {
triple[triple_writer] = convert_pattern(data_pattern[reader], 4)
+ convert_pattern(data_pattern[reader + 1], 2)
+ convert_pattern(data_pattern[reader + 2], 0);
}
rs_init_gf(&rs, 0x43);
rs_init_code(&rs, 4, 1);
rs_encode(&rs, triple_writer, triple, result);
for (reader = 4; reader > 0; reader--) {
strcat(data_pattern, AusBarTable[(int) result[reader - 1]]);
}
}
INTERNAL int daft_set_height(struct zint_symbol *symbol, float min_height, float max_height);
/* Handles Australia Posts's 4 State Codes */
INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[], int length) {
/* Customer Standard Barcode, Barcode 2 or Barcode 3 system determined automatically
(i.e. the FCC doesn't need to be specified by the user) dependent
on the length of the input string */
/* The contents of data_pattern conform to the following standard:
0 = Tracker, Ascender and Descender
1 = Tracker and Ascender
2 = Tracker and Descender
3 = Tracker only */
int error_number;
int writer;
int loopey, reader;
int h;
char data_pattern[200];
char fcc[3] = {0, 0, 0}, dpid[10];
char localstr[30];
/* Check input immediately to catch nuls */
error_number = is_sane(GDSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "404: Invalid character in data (alphanumerics, space and \"#\" only)");
return error_number;
}
strcpy(localstr, "");
/* Do all of the length checking first to avoid stack smashing */
if (symbol->symbology == BARCODE_AUSPOST) {
/* Format control code (FCC) */
switch (length) {
case 8:
strcpy(fcc, "11");
break;
case 13:
strcpy(fcc, "59");
break;
case 16:
strcpy(fcc, "59");
error_number = is_sane(NEON, source, length);
break;
case 18:
strcpy(fcc, "62");
break;
case 23:
strcpy(fcc, "62");
error_number = is_sane(NEON, source, length);
break;
default:
strcpy(symbol->errtxt, "401: Auspost input is wrong length (8, 13, 16, 18 or 23 characters only)");
return ZINT_ERROR_TOO_LONG;
}
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "402: Invalid character in data (digits only for lengths 16 and 23)");
return error_number;
}
} else {
int zeroes;
if (length > 8) {
strcpy(symbol->errtxt, "403: Auspost input is too long (8 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
switch (symbol->symbology) {
case BARCODE_AUSREPLY: strcpy(fcc, "45");
break;
case BARCODE_AUSROUTE: strcpy(fcc, "87");
break;
case BARCODE_AUSREDIRECT: strcpy(fcc, "92");
break;
}
/* Add leading zeros as required */
zeroes = 8 - length;
memset(localstr, '0', zeroes);
localstr[zeroes] = '\0';
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("AUSPOST FCC: %s\n", fcc);
}
ustrncat(localstr, source, length);
h = (int) strlen(localstr);
/* Verify that the first 8 characters are numbers */
memcpy(dpid, localstr, 8);
dpid[8] = '\0';
error_number = is_sane(NEON, (unsigned char *) dpid, 8);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "405: Invalid character in DPID (first 8 characters) (digits only)");
return error_number;
}
/* Start character */
strcpy(data_pattern, "13");
/* Encode the FCC */
for (reader = 0; reader < 2; reader++) {
lookup(NEON, AusNTable, fcc[reader], data_pattern);
}
/* Delivery Point Identifier (DPID) */
for (reader = 0; reader < 8; reader++) {
lookup(NEON, AusNTable, dpid[reader], data_pattern);
}
/* Customer Information */
if (h > 8) {
if ((h == 13) || (h == 18)) {
for (reader = 8; reader < h; reader++) {
lookup(GDSET, AusCTable, localstr[reader], data_pattern);
}
} else if ((h == 16) || (h == 23)) {
for (reader = 8; reader < h; reader++) {
lookup(NEON, AusNTable, localstr[reader], data_pattern);
}
}
}
/* Filler bar */
h = (int) strlen(data_pattern);
switch (h) {
case 22:
case 37:
case 52:
strcat(data_pattern, "3");
break;
default:
break;
}
/* Reed Solomon error correction */
rs_error(data_pattern);
/* Stop character */
strcat(data_pattern, "13");
/* Turn the symbol into a bar pattern ready for plotting */
writer = 0;
h = (int) strlen(data_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((data_pattern[loopey] == '1') || (data_pattern[loopey] == '0')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((data_pattern[loopey] == '2') || (data_pattern[loopey] == '0')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
#ifdef COMPLIANT_HEIGHTS
/* Australia Post Customer Barcoding Technical Specifications (Revised Aug 2012) Dimensions, placement and
printing p.12
https://auspost.com.au/content/dam/auspost_corp/media/documents/customer-barcode-technical-specifications-aug2012.pdf
X 0.5mm (average of 0.4mm - 0.6mm), min height 4.2mm / 0.6mm (X max) = 7, max 5.6mm / 0.4mm (X min) = 14
Tracker 1.3mm (average of 1mm - 1.6mm), Ascender/Descender 3.15mm (average of 2.6mm - 3.7mm) less T = 1.85mm
*/
symbol->row_height[0] = 1.85f / 0.5f; /* 3.7 */
symbol->row_height[1] = 1.3f / 0.5f; /* 2.6 */
error_number = daft_set_height(symbol, 7.0f, 14.0f); /* Note using max X for minimum and min X for maximum */
#else
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, 0.0f, 0.0f);
#endif
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}

1483
3rdparty/zint-2.10.0/backend/aztec.c vendored Normal file

File diff suppressed because it is too large Load Diff

167
3rdparty/zint-2.10.0/backend/aztec.h vendored Normal file
View File

@@ -0,0 +1,167 @@
/* aztec.h - Handles Aztec 2D Symbols */
/*
libzint - the open source barcode library
Copyright (C) 2008-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef __AZTEC_H
#define __AZTEC_H
static const short CompactAztecMap[] = {
/* 27 x 27 data grid */
609, 608, 411, 413, 415, 417, 419, 421, 423, 425, 427, 429, 431, 433, 435, 437, 439, 441, 443, 445, 447, 449, 451, 453, 455, 457, 459, // 0
607, 606, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, // 1
605, 604, 409, 408, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 460, 461, // 2
603, 602, 407, 406, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 462, 463, // 3
601, 600, 405, 404, 241, 240, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 284, 285, 464, 465, // 4
599, 598, 403, 402, 239, 238, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 286, 287, 466, 467, // 5
597, 596, 401, 400, 237, 236, 105, 104, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 140, 141, 288, 289, 468, 469, // 6
595, 594, 399, 398, 235, 234, 103, 102, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 142, 143, 290, 291, 470, 471, // 7
593, 592, 397, 396, 233, 232, 101, 100, 1, 1, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 0, 1, 28, 29, 144, 145, 292, 293, 472, 473, // 8
591, 590, 395, 394, 231, 230, 99, 98, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 30, 31, 146, 147, 294, 295, 474, 475, // 9
589, 588, 393, 392, 229, 228, 97, 96, 2027, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2007, 32, 33, 148, 149, 296, 297, 476, 477, // 10
587, 586, 391, 390, 227, 226, 95, 94, 2026, 1, 0, 1, 1, 1, 1, 1, 0, 1, 2008, 34, 35, 150, 151, 298, 299, 478, 479, // 11
585, 584, 389, 388, 225, 224, 93, 92, 2025, 1, 0, 1, 0, 0, 0, 1, 0, 1, 2009, 36, 37, 152, 153, 300, 301, 480, 481, // 12
583, 582, 387, 386, 223, 222, 91, 90, 2024, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2010, 38, 39, 154, 155, 302, 303, 482, 483, // 13
581, 580, 385, 384, 221, 220, 89, 88, 2023, 1, 0, 1, 0, 0, 0, 1, 0, 1, 2011, 40, 41, 156, 157, 304, 305, 484, 485, // 14
579, 578, 383, 382, 219, 218, 87, 86, 2022, 1, 0, 1, 1, 1, 1, 1, 0, 1, 2012, 42, 43, 158, 159, 306, 307, 486, 487, // 15
577, 576, 381, 380, 217, 216, 85, 84, 2021, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2013, 44, 45, 160, 161, 308, 309, 488, 489, // 16
575, 574, 379, 378, 215, 214, 83, 82, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 47, 162, 163, 310, 311, 490, 491, // 17
573, 572, 377, 376, 213, 212, 81, 80, 0, 0, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 0, 0, 48, 49, 164, 165, 312, 313, 492, 493, // 18
571, 570, 375, 374, 211, 210, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 50, 51, 166, 167, 314, 315, 494, 495, // 19
569, 568, 373, 372, 209, 208, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 52, 53, 168, 169, 316, 317, 496, 497, // 20
567, 566, 371, 370, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 170, 171, 318, 319, 498, 499, // 21
565, 564, 369, 368, 207, 205, 203, 201, 199, 197, 195, 193, 191, 189, 187, 185, 183, 181, 179, 177, 175, 172, 173, 320, 321, 500, 501, // 22
563, 562, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 322, 323, 502, 503, // 23
561, 560, 367, 365, 363, 361, 359, 357, 355, 353, 351, 349, 347, 345, 343, 341, 339, 337, 335, 333, 331, 329, 327, 324, 325, 504, 505, // 24
558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 506, 507, // 25
559, 557, 555, 553, 551, 549, 547, 545, 543, 541, 539, 537, 535, 533, 531, 529, 527, 525, 523, 521, 519, 517, 515, 513, 511, 508, 509, // 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
};
/* Pre-calculated finder, descriptor, orientation mappings for full-range symbol */
static const short AztecMapCore[15][15] = {
{ 1, 1, 20000, 20001, 20002, 20003, 20004, 0, 20005, 20006, 20007, 20008, 20009, 0, 1, },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
{ 20039, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 20010, },
{ 20038, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 20011, },
{ 20037, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 20012, },
{ 20036, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 20013, },
{ 20035, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 20014, },
{ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, },
{ 20034, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 20015, },
{ 20033, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 20016, },
{ 20032, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 20017, },
{ 20031, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 20018, },
{ 20030, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 20019, },
{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
{ 0, 0, 20029, 20028, 20027, 20026, 20025, 0, 20024, 20023, 20022, 20021, 20020, 0, 0, },
};
static const char AztecSymbolChar[128] = {
/* From Table 2 */
0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 15, 16, 17, 18, 19, 1, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 0, 18, 0, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 21, 22,
23, 24, 25, 26, 20, 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, 27, 21, 28, 22, 23, 24, 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, 29, 25, 30, 26, 27
};
static const char AztecModes[129] = "BMMMMMMMMMMMMXBBBBBBBBBBBBBMMMMMXPPPPPPPPPPPXPXPDDDDDDDDDDPPPPPPMUUUUUUUUUUUUUUUUUUUUUUUUUUPMPMMMLLLLLLLLLLLLLLLLLLLLLLLLLLPMPMM";
static const short AztecSizes[32] = {
/* Codewords per symbol */
21, 48, 60, 88, 120, 156, 196, 240, 230, 272, 316, 364, 416, 470, 528, 588, 652, 720, 790,
864, 940, 1020, 920, 992, 1066, 1144, 1224, 1306, 1392, 1480, 1570, 1664
};
static const short AztecCompactSizes[4] = {
17, 40, 51, 76
};
static const short Aztec10DataSizes[32] = {
/* Data bits per symbol maximum with 10% error correction */
96, 246, 408, 616, 840, 1104, 1392, 1704, 2040, 2420, 2820, 3250, 3720, 4200, 4730,
5270, 5840, 6450, 7080, 7750, 8430, 9150, 9900, 10680, 11484, 12324, 13188, 14076,
15000, 15948, 16920, 17940
};
static const short Aztec23DataSizes[32] = {
/* Data bits per symbol maximum with 23% error correction */
84, 204, 352, 520, 720, 944, 1184, 1456, 1750, 2070, 2410, 2780, 3180, 3590, 4040,
4500, 5000, 5520, 6060, 6630, 7210, 7830, 8472, 9132, 9816, 10536, 11280, 12036,
12828, 13644, 14472, 15348
};
static const short Aztec36DataSizes[32] = {
/* Data bits per symbol maximum with 36% error correction */
66, 168, 288, 432, 592, 776, 984, 1208, 1450, 1720, 2000, 2300, 2640, 2980, 3350,
3740, 4150, 4580, 5030, 5500, 5990, 6500, 7032, 7584, 8160, 8760, 9372, 9996, 10656,
11340, 12024, 12744
};
static const short Aztec50DataSizes[32] = {
/* Data bits per symbol maximum with 50% error correction */
48, 126, 216, 328, 456, 600, 760, 936, 1120, 1330, 1550, 1790, 2050, 2320, 2610,
2910, 3230, 3570, 3920, 4290, 4670, 5070, 5484, 5916, 6360, 6828, 7308, 7800, 8316,
8844, 9384, 9948
};
static const short AztecCompact10DataSizes[4] = {
78, 198, 336, 520
};
static const short AztecCompact23DataSizes[4] = {
66, 168, 288, 440
};
static const short AztecCompact36DataSizes[4] = {
48, 138, 232, 360
};
static const short AztecCompact50DataSizes[4] = {
36, 102, 176, 280
};
static const char AztecOffset[32] = {
66, 64, 62, 60, 57, 55, 53, 51, 49, 47, 45, 42, 40, 38, 36, 34, 32, 30, 28, 25, 23, 21,
19, 17, 15, 13, 10, 8, 6, 4, 2, 0
};
static const char AztecCompactOffset[4] = {
6, 4, 2, 0
};
static const short AztecMapGridYOffsets[] = {
27, 43, 59, 75, 91, 107, 123, 139
};
#endif /* __AZTEC_H */

2320
3rdparty/zint-2.10.0/backend/big5.h vendored Normal file

File diff suppressed because it is too large Load Diff

215
3rdparty/zint-2.10.0/backend/bmp.c vendored Normal file
View File

@@ -0,0 +1,215 @@
/* bmp.c - Handles output to Windows Bitmap file */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <errno.h>
#include <stdio.h>
#include "common.h"
#include "bmp.h" /* Bitmap header structure */
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#endif
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
int i, row, column;
int row_size;
int bits_per_pixel;
int colour_count;
unsigned int data_offset, data_size, file_size;
unsigned char *bitmap_file_start, *bmp_posn;
unsigned char *bitmap;
FILE *bmp_file;
bitmap_file_header_t file_header;
bitmap_info_header_t info_header;
color_ref_t bg_color_ref;
color_ref_t fg_color_ref;
color_ref_t ultra_color_ref[8];
int ultra_fg_index = 9;
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; /* Suppress gcc -fanalyzer warning */
fg_color_ref.red = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fg_color_ref.green = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fg_color_ref.blue = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
fg_color_ref.reserved = 0x00;
bg_color_ref.red = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bg_color_ref.green = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bg_color_ref.blue = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
bg_color_ref.reserved = 0x00;
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 8; i++) {
ultra_color_ref[i].red = colour_to_red(i + 1);
ultra_color_ref[i].green = colour_to_green(i + 1);
ultra_color_ref[i].blue = colour_to_blue(i + 1);
ultra_color_ref[i].reserved = 0x00;
if (memcmp(&ultra_color_ref[i], &fg_color_ref, sizeof(fg_color_ref)) == 0) {
ultra_fg_index = i + 1;
}
}
bits_per_pixel = 4;
colour_count = ultra_fg_index == 9 ? 10 : 9;
} else {
bits_per_pixel = 1;
colour_count = 2;
}
row_size = 4 * ((bits_per_pixel * symbol->bitmap_width + 31) / 32);
data_size = symbol->bitmap_height * row_size;
data_offset = sizeof(bitmap_file_header_t) + sizeof(bitmap_info_header_t);
data_offset += colour_count * sizeof(color_ref_t);
file_size = data_offset + data_size;
bitmap_file_start = (unsigned char *) malloc(file_size);
if (bitmap_file_start == NULL) {
strcpy(symbol->errtxt, "602: Insufficient memory for BMP file buffer");
return ZINT_ERROR_MEMORY;
}
memset(bitmap_file_start, 0, file_size); /* Not required but keeps padding bytes consistent */
bitmap = bitmap_file_start + data_offset;
/* Pixel Plotting */
if (symbol->symbology == BARCODE_ULTRA) {
for (row = 0; row < symbol->bitmap_height; row++) {
for (column = 0; column < symbol->bitmap_width; column++) {
i = (column / 2) + (row * row_size);
switch (*(pixelbuf + (symbol->bitmap_width * (symbol->bitmap_height - row - 1)) + column)) {
case 'C': // Cyan
bitmap[i] += 1 << (4 * (1 - (column % 2)));
break;
case 'B': // Blue
bitmap[i] += 2 << (4 * (1 - (column % 2)));
break;
case 'M': // Magenta
bitmap[i] += 3 << (4 * (1 - (column % 2)));
break;
case 'R': // Red
bitmap[i] += 4 << (4 * (1 - (column % 2)));
break;
case 'Y': // Yellow
bitmap[i] += 5 << (4 * (1 - (column % 2)));
break;
case 'G': // Green
bitmap[i] += 6 << (4 * (1 - (column % 2)));
break;
case 'K': // Black
bitmap[i] += 7 << (4 * (1 - (column % 2)));
break;
case 'W': // White
bitmap[i] += 8 << (4 * (1 - (column % 2)));
break;
case '1': // Foreground
bitmap[i] += ultra_fg_index << (4 * (1 - (column % 2)));
break;
}
}
}
} else {
for (row = 0; row < symbol->bitmap_height; row++) {
for (column = 0; column < symbol->bitmap_width; column++) {
i = (column / 8) + (row * row_size);
if ((*(pixelbuf + (symbol->bitmap_width * (symbol->bitmap_height - row - 1)) + column)) == '1') {
bitmap[i] += (0x01 << (7 - (column % 8)));
}
}
}
}
symbol->bitmap_byte_length = data_size;
file_header.header_field = 0x4d42; // "BM"
file_header.file_size = file_size;
file_header.reserved = 0;
file_header.data_offset = data_offset;
info_header.header_size = sizeof(bitmap_info_header_t);
info_header.width = symbol->bitmap_width;
info_header.height = symbol->bitmap_height;
info_header.colour_planes = 1;
info_header.bits_per_pixel = bits_per_pixel;
info_header.compression_method = 0; // BI_RGB
info_header.image_size = 0;
info_header.horiz_res = 0;
info_header.vert_res = 0;
info_header.colours = colour_count;
info_header.important_colours = colour_count;
bmp_posn = bitmap_file_start;
memcpy(bitmap_file_start, &file_header, sizeof(bitmap_file_header_t));
bmp_posn += sizeof(bitmap_file_header_t);
memcpy(bmp_posn, &info_header, sizeof(bitmap_info_header_t));
bmp_posn += sizeof(bitmap_info_header_t);
memcpy(bmp_posn, &bg_color_ref, sizeof(color_ref_t));
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 8; i++) {
bmp_posn += sizeof(color_ref_t);
memcpy(bmp_posn, &ultra_color_ref[i], sizeof(color_ref_t));
}
if (ultra_fg_index == 9) {
bmp_posn += sizeof(color_ref_t);
memcpy(bmp_posn, &fg_color_ref, sizeof(color_ref_t));
}
} else {
bmp_posn += sizeof(color_ref_t);
memcpy(bmp_posn, &fg_color_ref, sizeof(color_ref_t));
}
/* Open output file in binary mode */
if (output_to_stdout) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
sprintf(symbol->errtxt, "600: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno));
free(bitmap_file_start);
return ZINT_ERROR_FILE_ACCESS;
}
#endif
bmp_file = stdout;
} else {
if (!(bmp_file = fopen(symbol->outfile, "wb"))) {
free(bitmap_file_start);
sprintf(symbol->errtxt, "601: Could not open output file (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
}
fwrite(bitmap_file_start, file_header.file_size, 1, bmp_file);
if (output_to_stdout) {
fflush(bmp_file);
} else {
fclose(bmp_file);
}
free(bitmap_file_start);
return 0;
}

84
3rdparty/zint-2.10.0/backend/bmp.h vendored Normal file
View File

@@ -0,0 +1,84 @@
/* bmp.h - header structure for Windows bitmap files
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef BMP_H
#define BMP_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
#pragma pack (1)
typedef struct bitmap_file_header {
uint16_t header_field;
uint32_t file_size;
uint32_t reserved;
uint32_t data_offset;
} bitmap_file_header_t;
typedef struct bitmap_info_header {
uint32_t header_size;
int32_t width;
int32_t height;
uint16_t colour_planes;
uint16_t bits_per_pixel;
uint32_t compression_method;
uint32_t image_size;
int32_t horiz_res;
int32_t vert_res;
uint32_t colours;
uint32_t important_colours;
} bitmap_info_header_t;
typedef struct color_ref {
uint8_t blue;
uint8_t green;
uint8_t red;
uint8_t reserved;
} color_ref_t;
#pragma pack ()
#ifdef __cplusplus
}
#endif
#endif /* BMP_H */

View File

@@ -0,0 +1,106 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* Channel code precalculated values to avoid excessive looping */
/* To generate uncomment CHANNEL_GENERATE_PRECALCS define and run "./test_channel -f generate -g" */
/* Paste result below here */
static channel_precalc channel_precalcs7[] = {
{ 115338, { 1, 3, 1, 1, 1, 1, 5, 1, }, { 1, 1, 1, 2, 1, 2, 3, 3, }, { 1, 7, 5, 5, 5, 5, 5, }, { 1, 7, 7, 7, 6, 6, 5, }, },
{ 230676, { 1, 1, 2, 2, 4, 1, 1, 2, }, { 1, 2, 1, 3, 2, 1, 3, 1, }, { 1, 7, 7, 6, 5, 2, 2, }, { 1, 7, 6, 6, 4, 3, 3, }, },
{ 346014, { 1, 2, 3, 1, 1, 1, 3, 2, }, { 1, 2, 2, 1, 1, 3, 1, 3, }, { 1, 7, 6, 4, 4, 4, 4, }, { 1, 7, 6, 5, 5, 5, 3, }, },
{ 461352, { 1, 2, 1, 1, 1, 2, 2, 4, }, { 1, 3, 1, 1, 3, 2, 2, 1, }, { 1, 7, 6, 6, 6, 6, 5, }, { 1, 7, 5, 5, 5, 3, 2, }, },
};
static channel_precalc channel_precalcs8[] = {
{ 119121, { 2, 1, 3, 2, 1, 3, 2, 1, }, { 1, 1, 1, 4, 3, 2, 1, 2, }, { 8, 7, 7, 5, 4, 4, 2, }, { 8, 8, 8, 8, 5, 3, 2, }, },
{ 238242, { 2, 1, 1, 2, 2, 2, 1, 4, }, { 1, 1, 3, 1, 1, 2, 4, 2, }, { 8, 7, 7, 7, 6, 5, 4, }, { 8, 8, 8, 6, 6, 6, 5, }, },
{ 357363, { 2, 2, 1, 4, 1, 1, 1, 3, }, { 1, 1, 1, 1, 3, 2, 5, 1, }, { 8, 7, 6, 6, 3, 3, 3, }, { 8, 8, 8, 8, 8, 6, 5, }, },
{ 476484, { 2, 2, 1, 1, 3, 2, 3, 1, }, { 1, 1, 3, 1, 2, 2, 3, 2, }, { 8, 7, 6, 6, 6, 4, 3, }, { 8, 8, 8, 6, 6, 5, 4, }, },
{ 595605, { 2, 3, 3, 2, 1, 1, 1, 2, }, { 1, 1, 2, 1, 1, 1, 5, 3, }, { 8, 7, 5, 3, 2, 2, 2, }, { 8, 8, 8, 7, 7, 7, 7, }, },
{ 714726, { 2, 1, 1, 6, 1, 1, 2, 1, }, { 1, 2, 1, 3, 1, 4, 1, 2, }, { 8, 7, 7, 7, 2, 2, 2, }, { 8, 8, 7, 7, 5, 5, 2, }, },
{ 833847, { 2, 1, 1, 3, 1, 3, 3, 1, }, { 1, 2, 3, 1, 1, 3, 2, 2, }, { 8, 7, 7, 7, 5, 5, 3, }, { 8, 8, 7, 5, 5, 5, 3, }, },
{ 952968, { 2, 2, 2, 3, 2, 1, 2, 1, }, { 1, 2, 2, 1, 2, 2, 2, 3, }, { 8, 7, 6, 5, 3, 2, 2, }, { 8, 8, 7, 6, 6, 5, 4, }, },
{ 1072089, { 2, 5, 1, 1, 2, 2, 1, 1, }, { 1, 2, 1, 3, 1, 3, 3, 1, }, { 8, 7, 3, 3, 3, 2, 1, }, { 8, 8, 7, 7, 5, 5, 3, }, },
{ 1191210, { 2, 2, 1, 2, 1, 1, 3, 3, }, { 1, 3, 1, 1, 5, 1, 1, 2, }, { 8, 7, 6, 6, 5, 5, 5, }, { 8, 8, 6, 6, 6, 2, 2, }, },
{ 1310331, { 2, 1, 2, 1, 2, 3, 2, 2, }, { 1, 4, 1, 3, 1, 1, 2, 2, }, { 8, 7, 7, 6, 6, 5, 3, }, { 8, 8, 5, 5, 3, 3, 3, }, },
{ 1429452, { 2, 2, 1, 2, 2, 3, 2, 1, }, { 1, 5, 3, 1, 2, 1, 1, 1, }, { 8, 7, 6, 6, 5, 4, 2, }, { 8, 8, 4, 2, 2, 1, 1, }, },
{ 1548573, { 3, 1, 1, 2, 5, 1, 1, 1, }, { 1, 1, 2, 2, 1, 2, 5, 1, }, { 8, 6, 6, 6, 5, 1, 1, }, { 8, 8, 8, 7, 6, 6, 5, }, },
{ 1667694, { 3, 2, 2, 1, 1, 3, 2, 1, }, { 1, 1, 1, 1, 2, 4, 3, 2, }, { 8, 6, 5, 4, 4, 4, 2, }, { 8, 8, 8, 8, 8, 7, 4, }, },
{ 1786815, { 3, 4, 2, 1, 2, 1, 1, 1, }, { 1, 1, 2, 1, 1, 2, 1, 6, }, { 8, 6, 3, 2, 2, 1, 1, }, { 8, 8, 8, 7, 7, 7, 6, }, },
{ 1905936, { 3, 2, 1, 3, 1, 3, 1, 1, }, { 1, 2, 1, 1, 1, 4, 2, 3, }, { 8, 6, 5, 5, 3, 3, 1, }, { 8, 8, 7, 7, 7, 7, 4, }, },
{ 2025057, { 3, 1, 2, 2, 1, 1, 4, 1, }, { 1, 3, 2, 1, 1, 1, 5, 1, }, { 8, 6, 6, 5, 4, 4, 4, }, { 8, 8, 6, 5, 5, 5, 5, }, },
{ 2144178, { 3, 1, 2, 1, 2, 2, 2, 2, }, { 1, 5, 1, 1, 4, 1, 1, 1, }, { 8, 6, 6, 5, 5, 4, 3, }, { 8, 8, 4, 4, 4, 1, 1, }, },
{ 2263299, { 4, 2, 1, 2, 1, 1, 1, 3, }, { 1, 1, 1, 1, 3, 3, 3, 2, }, { 8, 5, 4, 4, 3, 3, 3, }, { 8, 8, 8, 8, 8, 6, 4, }, },
{ 2382420, { 4, 2, 1, 1, 1, 1, 4, 1, }, { 1, 2, 2, 2, 2, 2, 2, 2, }, { 8, 5, 4, 4, 4, 4, 4, }, { 8, 8, 7, 6, 5, 4, 3, }, },
{ 2501541, { 5, 1, 1, 2, 2, 1, 1, 2, }, { 1, 1, 2, 3, 3, 1, 1, 3, }, { 8, 4, 4, 4, 3, 2, 2, }, { 8, 8, 8, 7, 5, 3, 3, }, },
{ 2620662, { 6, 1, 1, 1, 2, 1, 1, 2, }, { 1, 2, 4, 1, 2, 3, 1, 1, }, { 8, 3, 3, 3, 3, 2, 2, }, { 8, 8, 7, 4, 4, 3, 1, }, },
{ 2739783, { 1, 1, 1, 1, 3, 3, 4, 1, }, { 2, 1, 2, 1, 6, 1, 1, 1, }, { 8, 8, 8, 8, 8, 6, 4, }, { 8, 7, 7, 6, 6, 1, 1, }, },
{ 2858904, { 1, 1, 2, 3, 3, 1, 3, 1, }, { 2, 1, 3, 1, 3, 1, 2, 2, }, { 8, 8, 8, 7, 5, 3, 3, }, { 8, 7, 7, 5, 5, 3, 3, }, },
{ 2978025, { 1, 2, 2, 4, 1, 2, 1, 2, }, { 2, 1, 1, 1, 1, 3, 4, 2, }, { 8, 8, 7, 6, 3, 3, 2, }, { 8, 7, 7, 7, 7, 7, 5, }, },
{ 3097146, { 1, 2, 2, 1, 3, 3, 2, 1, }, { 2, 1, 3, 3, 2, 2, 1, 1, }, { 8, 8, 7, 6, 6, 4, 2, }, { 8, 7, 7, 5, 3, 2, 1, }, },
{ 3216267, { 1, 3, 1, 1, 1, 3, 1, 4, }, { 2, 1, 3, 2, 3, 2, 1, 1, }, { 8, 8, 6, 6, 6, 6, 4, }, { 8, 7, 7, 5, 4, 2, 1, }, },
{ 3335388, { 1, 1, 1, 4, 4, 1, 2, 1, }, { 2, 2, 1, 1, 1, 1, 3, 4, }, { 8, 8, 8, 8, 5, 2, 2, }, { 8, 7, 6, 6, 6, 6, 6, }, },
{ 3454509, { 1, 1, 2, 4, 3, 1, 2, 1, }, { 2, 2, 2, 5, 1, 1, 1, 1, }, { 8, 8, 8, 7, 4, 2, 2, }, { 8, 7, 6, 5, 1, 1, 1, }, },
{ 3573630, { 1, 2, 1, 3, 1, 2, 3, 2, }, { 2, 2, 2, 1, 1, 4, 2, 1, }, { 8, 8, 7, 7, 5, 5, 4, }, { 8, 7, 6, 5, 5, 5, 2, }, },
{ 3692751, { 1, 4, 2, 3, 2, 1, 1, 1, }, { 2, 2, 1, 1, 2, 1, 2, 4, }, { 8, 8, 5, 4, 2, 1, 1, }, { 8, 7, 6, 6, 6, 5, 5, }, },
{ 3811872, { 1, 1, 2, 1, 3, 5, 1, 1, }, { 2, 3, 3, 2, 2, 1, 1, 1, }, { 8, 8, 8, 7, 7, 5, 1, }, { 8, 7, 5, 3, 2, 1, 1, }, },
{ 3930993, { 1, 1, 1, 1, 6, 2, 2, 1, }, { 2, 4, 1, 2, 1, 3, 1, 1, }, { 8, 8, 8, 8, 8, 3, 2, }, { 8, 7, 4, 4, 3, 3, 1, }, },
{ 4050114, { 1, 3, 3, 2, 2, 1, 2, 1, }, { 2, 6, 2, 1, 1, 1, 1, 1, }, { 8, 8, 6, 4, 3, 2, 2, }, { 8, 7, 2, 1, 1, 1, 1, }, },
{ 4169235, { 2, 1, 2, 2, 4, 2, 1, 1, }, { 2, 1, 2, 1, 1, 1, 4, 3, }, { 8, 7, 7, 6, 5, 2, 1, }, { 8, 7, 7, 6, 6, 6, 6, }, },
{ 4288356, { 2, 2, 2, 1, 1, 3, 3, 1, }, { 2, 1, 1, 4, 2, 1, 1, 3, }, { 8, 7, 6, 5, 5, 5, 3, }, { 8, 7, 7, 7, 4, 3, 3, }, },
{ 4407477, { 2, 3, 3, 1, 2, 1, 1, 2, }, { 2, 1, 3, 2, 4, 1, 1, 1, }, { 8, 7, 5, 3, 3, 2, 2, }, { 8, 7, 7, 5, 4, 1, 1, }, },
{ 4526598, { 2, 1, 4, 1, 4, 1, 1, 1, }, { 2, 2, 2, 1, 2, 3, 1, 2, }, { 8, 7, 7, 4, 4, 1, 1, }, { 8, 7, 6, 5, 5, 4, 2, }, },
{ 4645719, { 2, 4, 2, 1, 1, 2, 1, 2, }, { 2, 2, 1, 1, 3, 2, 3, 1, }, { 8, 7, 4, 3, 3, 3, 2, }, { 8, 7, 6, 6, 6, 4, 3, }, },
{ 4764840, { 2, 1, 1, 1, 2, 4, 1, 3, }, { 2, 4, 1, 2, 1, 3, 1, 1, }, { 8, 7, 7, 7, 7, 6, 3, }, { 8, 7, 4, 4, 3, 3, 1, }, },
{ 4883961, { 3, 1, 1, 3, 2, 2, 1, 2, }, { 2, 1, 2, 2, 2, 1, 2, 3, }, { 8, 6, 6, 6, 4, 3, 2, }, { 8, 7, 7, 6, 5, 4, 4, }, },
{ 5003082, { 3, 3, 3, 1, 1, 1, 2, 1, }, { 2, 1, 2, 1, 1, 3, 1, 4, }, { 8, 6, 4, 2, 2, 2, 2, }, { 8, 7, 7, 6, 6, 6, 4, }, },
{ 5122203, { 3, 1, 1, 2, 1, 2, 1, 4, }, { 2, 3, 1, 1, 1, 2, 4, 1, }, { 8, 6, 6, 6, 5, 5, 4, }, { 8, 7, 5, 5, 5, 5, 4, }, },
{ 5241324, { 4, 1, 1, 3, 1, 2, 2, 1, }, { 2, 1, 3, 1, 1, 3, 3, 1, }, { 8, 5, 5, 5, 3, 3, 2, }, { 8, 7, 7, 5, 5, 5, 3, }, },
{ 5360445, { 4, 3, 1, 1, 2, 1, 1, 2, }, { 2, 4, 1, 3, 2, 1, 1, 1, }, { 8, 5, 3, 3, 3, 2, 2, }, { 8, 7, 4, 4, 2, 1, 1, }, },
{ 5479566, { 1, 1, 3, 1, 3, 2, 1, 3, }, { 3, 1, 1, 2, 1, 2, 1, 4, }, { 8, 8, 8, 6, 6, 4, 3, }, { 8, 6, 6, 6, 5, 5, 4, }, },
{ 5598687, { 1, 2, 1, 1, 5, 1, 3, 1, }, { 3, 1, 1, 1, 1, 3, 1, 4, }, { 8, 8, 7, 7, 7, 3, 3, }, { 8, 6, 6, 6, 6, 6, 4, }, },
{ 5717808, { 1, 3, 1, 2, 1, 3, 1, 3, }, { 3, 1, 1, 2, 4, 1, 1, 2, }, { 8, 8, 6, 6, 5, 5, 3, }, { 8, 6, 6, 6, 5, 2, 2, }, },
{ 5836929, { 1, 1, 2, 3, 1, 2, 3, 2, }, { 3, 2, 1, 1, 1, 1, 2, 4, }, { 8, 8, 8, 7, 5, 5, 4, }, { 8, 6, 5, 5, 5, 5, 5, }, },
{ 5956050, { 1, 2, 3, 3, 2, 2, 1, 1, }, { 3, 2, 3, 1, 1, 1, 1, 3, }, { 8, 8, 7, 5, 3, 2, 1, }, { 8, 6, 5, 3, 3, 3, 3, }, },
{ 6075171, { 1, 3, 1, 1, 3, 3, 2, 1, }, { 3, 3, 1, 1, 3, 1, 2, 1, }, { 8, 8, 6, 6, 6, 4, 2, }, { 8, 6, 4, 4, 4, 2, 2, }, },
{ 6194292, { 2, 1, 1, 3, 4, 1, 2, 1, }, { 3, 1, 2, 1, 3, 1, 3, 1, }, { 8, 7, 7, 7, 5, 2, 2, }, { 8, 6, 6, 5, 5, 3, 3, }, },
{ 6313413, { 2, 3, 2, 2, 1, 2, 2, 1, }, { 3, 1, 1, 2, 1, 3, 2, 2, }, { 8, 7, 5, 4, 3, 3, 2, }, { 8, 6, 6, 6, 5, 5, 3, }, },
{ 6432534, { 2, 3, 1, 1, 2, 2, 3, 1, }, { 3, 2, 1, 2, 3, 1, 2, 1, }, { 8, 7, 5, 5, 5, 4, 3, }, { 8, 6, 5, 5, 4, 2, 2, }, },
{ 6551655, { 3, 1, 1, 2, 1, 4, 1, 2, }, { 3, 1, 2, 3, 1, 1, 3, 1, }, { 8, 6, 6, 6, 5, 5, 2, }, { 8, 6, 6, 5, 3, 3, 3, }, },
{ 6670776, { 3, 1, 1, 1, 1, 3, 4, 1, }, { 3, 3, 1, 2, 1, 1, 3, 1, }, { 8, 6, 6, 6, 6, 6, 4, }, { 8, 6, 4, 4, 3, 3, 3, }, },
{ 6789897, { 5, 2, 1, 1, 2, 1, 2, 1, }, { 3, 1, 1, 1, 2, 2, 3, 2, }, { 8, 4, 3, 3, 3, 2, 2, }, { 8, 6, 6, 6, 6, 5, 4, }, },
{ 6909018, { 1, 2, 2, 2, 2, 1, 4, 1, }, { 4, 1, 1, 2, 1, 2, 1, 3, }, { 8, 8, 7, 6, 5, 4, 4, }, { 8, 5, 5, 5, 4, 4, 3, }, },
{ 7028139, { 1, 1, 3, 2, 2, 2, 1, 3, }, { 4, 2, 2, 1, 2, 2, 1, 1, }, { 8, 8, 8, 6, 5, 4, 3, }, { 8, 5, 4, 3, 3, 2, 1, }, },
{ 7147260, { 2, 1, 4, 3, 2, 1, 1, 1, }, { 4, 1, 1, 1, 4, 1, 1, 2, }, { 8, 7, 7, 4, 2, 1, 1, }, { 8, 5, 5, 5, 5, 2, 2, }, },
{ 7266381, { 2, 4, 1, 3, 2, 1, 1, 1, }, { 4, 2, 1, 1, 1, 2, 1, 3, }, { 8, 7, 4, 4, 2, 1, 1, }, { 8, 5, 4, 4, 4, 4, 3, }, },
{ 7385502, { 4, 2, 1, 3, 1, 2, 1, 1, }, { 4, 1, 1, 4, 2, 1, 1, 1, }, { 8, 5, 4, 4, 2, 2, 1, }, { 8, 5, 5, 5, 2, 1, 1, }, },
{ 7504623, { 1, 1, 3, 4, 3, 1, 1, 1, }, { 5, 2, 1, 1, 1, 1, 1, 3, }, { 8, 8, 8, 6, 3, 1, 1, }, { 8, 4, 3, 3, 3, 3, 3, }, },
{ 7623744, { 3, 1, 1, 2, 2, 1, 2, 3, }, { 5, 2, 1, 1, 1, 2, 1, 2, }, { 8, 6, 6, 6, 5, 4, 4, }, { 8, 4, 3, 3, 3, 3, 2, }, },
};

983
3rdparty/zint-2.10.0/backend/codablock.c vendored Normal file
View File

@@ -0,0 +1,983 @@
/* codablock.c - Handles Codablock-F and Codablock-E */
/*
libzint - the open source barcode library
Copyright (C) 2016 - 2021 Harald Oehlmann
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <math.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include <assert.h>
#include "common.h"
INTERNAL int code_128(struct zint_symbol *symbol, unsigned char source[], int length);
#define uchar unsigned char
/* FTab C128 flags - may be added */
#define CodeA 1
#define CodeB 2
#define CodeC 4
#define CEnd 8
#define CShift 16
#define CFill 32
#define CodeFNC1 64
#define CodeFNC4 128
#define ZTNum (CodeA+CodeB+CodeC)
#define ZTFNC1 (CodeA+CodeB+CodeC+CodeFNC1)
/* ASCII-Extension for Codablock-F */
#define aFNC1 (uchar)(128)
#define aFNC2 (uchar)(129)
#define aFNC3 (uchar)(130)
#define aFNC4 (uchar)(131)
#define aCodeA (uchar)(132)
#define aCodeB (uchar)(133)
#define aCodeC (uchar)(134)
#define aShift (uchar)(135)
static const char *C128Table[107] = {
/* Code 128 character encodation - Table 1 */
"212222", "222122", "222221", "121223", "121322", "131222", "122213",
"122312", "132212", "221213", "221312", "231212", "112232", "122132", "122231", "113222",
"123122", "123221", "223211", "221132", "221231", "213212", "223112", "312131", "311222",
"321122", "321221", "312212", "322112", "322211", "212123", "212321", "232121", "111323",
"131123", "131321", "112313", "132113", "132311", "211313", "231113", "231311", "112133",
"112331", "132131", "113123", "113321", "133121", "313121", "211331", "231131", "213113",
"213311", "213131", "311123", "311321", "331121", "312113", "312311", "332111", "314111",
"221411", "431111", "111224", "111422", "121124", "121421", "141122", "141221", "112214",
"112412", "122114", "122411", "142112", "142211", "241211", "221114", "413111", "241112",
"134111", "111242", "121142", "121241", "114212", "124112", "124211", "411212", "421112",
"421211", "212141", "214121", "412121", "111143", "111341", "131141", "114113", "114311",
"411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232",
"2331112"
};
/* Code F Analysing-Chart */
typedef struct sCharacterSetTable
{
int CharacterSet; /* Still possible character sets for actual*/
int AFollowing; /* Still following Characters in Charset A */
int BFollowing; /* Still following Characters in Charset B */
int CFollowing; /* Still following Characters in Charset C */
} CharacterSetTable;
/* Find the possible Code-128 Character sets for a character
* The result is an or of CodeA, CodeB, CodeC, CodeFNC1, CodeFNC4 depending on the
* possible Code 128 character sets.
*/
static int GetPossibleCharacterSet(unsigned char C)
{
if (C<='\x1f') /* Control chars */
return CodeA;
if (C>='0' && C<='9')
return ZTNum; /* ZTNum=CodeA+CodeB+CodeC */
if (C==aFNC1) /* FNC1s (GS1) not used */
return ZTFNC1; /* ZTFNC1=CodeA+CodeB+CodeC+CodeFNC1 */ /* Not reached */
if (C==aFNC4)
return (CodeA | CodeB | CodeFNC4);
if (C>='\x60' && C<='\x7f') /* 60 to 127 */
return CodeB;
return CodeA+CodeB;
}
/* Create a Table with the following information for each Data character:
* int CharacterSet is an or of CodeA, CodeB, CodeC, CodeFNC1, CodeFNC4,
* depending on which character set is applicable.
* (Result of GetPossibleCharacterSet)
* int AFollowing,BFollowing The number of source characters you still may encode
* in this character set.
* int CFollowing The number of characters encodable in CodeC if we
* start here.
*/
static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data, const int dataLength)
{
int charCur;
int runChar;
/* Treat the Data backwards */
charCur=dataLength-1;
T[charCur].CharacterSet=GetPossibleCharacterSet(data[charCur]);
T[charCur].AFollowing=((T[charCur].CharacterSet & CodeA)==0)?0:1;
T[charCur].BFollowing=((T[charCur].CharacterSet & CodeB)==0)?0:1;
T[charCur].CFollowing=0;
for (charCur--;charCur>=0;charCur--)
{
T[charCur].CharacterSet=GetPossibleCharacterSet(data[charCur]);
T[charCur].AFollowing=
((T[charCur].CharacterSet & CodeA)==0)?0:T[charCur+1].AFollowing+1;
T[charCur].BFollowing=
((T[charCur].CharacterSet & CodeB)==0)?0:T[charCur+1].BFollowing+1;
T[charCur].CFollowing=0;
}
/* Find the CodeC-chains */
for (charCur=0;charCur<dataLength;charCur++)
{
T[charCur].CFollowing=0;
if ((T[charCur].CharacterSet & CodeC)!=0)
{
/* CodeC possible */
runChar=charCur;
do{
/* Whether this is FNC1, whether next is */
/* numeric */
if (T[runChar].CharacterSet==ZTFNC1) /* FNC1s (GS1) not used */
/* FNC1 */
++(T[charCur].CFollowing); /* Not reached */
else
{
++runChar;
if (runChar>=dataLength)
break;
/* Only a Number may follow */
if (T[runChar].CharacterSet==ZTNum)
T[charCur].CFollowing+=2;
else
break;
}
++runChar;
} while (runChar<dataLength);
}
}
}
/* Find the amount of numerical characters in pairs which will fit in
* one bundle into the line (up to here). This is calculated online because
* it depends on the space in the line.
*/
static int RemainingDigits(CharacterSetTable *T, int charCur,int emptyColumns)
{
int digitCount; /* Numerical digits fitting in the line */
int runChar;
runChar=charCur;
digitCount=0;
while(emptyColumns>0 && runChar<charCur+T[charCur].CFollowing)
{
if (T[runChar].CharacterSet!=ZTFNC1)
{
/* NOT FNC1 */
digitCount+=2;
runChar++;
}
runChar++;
emptyColumns--;
}
return digitCount;
}
/* Find the Character distribution at a given column count.
* If too many rows (>44) are requested the columns are extended.
* Parameters :
* T Pointer on the Characters which fit in the row
* If a different count is calculated it is corrected
* in the callers workspace.
* pFillings Output of filling characters
* pSet Output of the character sets used, allocated by me.
* Return value Resulting row count
*/
static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const int dataLength,
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
{
int useColumns; /* Usable Characters per line */
int fillings = 0; /* Number of filling characters */
int rowsCur;
int runChar;
int emptyColumns; /* Number of codes still empty in line. */
int emptyColumns2; /* Alternative emptyColumns to compare */
int CPaires; /* Number of digit pairs which may fit in the line */
int characterSetCur; /* Current Character Set */
int isFNC4; /* Set if current character FNC4 */
useColumns=*pUseColumns;
/* >>> Loop until rowsCur <= 44 */
do {
int charCur=0;
memset(pSet,0,dataLength*sizeof(int));
rowsCur=0;
/* >>> Line Loop */
do{
/* >> Start Character */
emptyColumns=useColumns; /* Remained place in Line */
/* >>Choose in Set A or B */
/* (C is changed as an option later on) */
pSet[charCur]=characterSetCur=
(T[charCur].AFollowing > T[charCur].BFollowing)
? CodeA : CodeB;
/* >> Test on Numeric Mode C */
CPaires=RemainingDigits(T,charCur, emptyColumns);
if (CPaires>=4)
{
/* 4 Digits in Numeric compression ->OK */
/* > May an odd start find more ? */
/* Skip leading <FNC1>'s */
/* Typical structure : <FNC1><FNC1>12... */
/* Test if numeric after one isn't better.*/
runChar=charCur;
emptyColumns2=emptyColumns;
while (T[runChar].CharacterSet==ZTFNC1) /* FNC1s (GS1) not used */
{
++runChar; /* Not reached */
--emptyColumns2;
}
if (CPaires>=RemainingDigits(T,runChar+1,emptyColumns2-1))
{
/* Start odd is not better */
/* We start in C */
pSet[charCur]=characterSetCur=CodeC;
/* Increment charCur */
if (T[charCur].CharacterSet!=ZTFNC1)
++charCur; /* 2 Num.Digits */
}
}
++charCur;
--emptyColumns;
/* >> Following characters */
while(emptyColumns>0 && charCur<dataLength)
{
isFNC4 = (T[charCur].CharacterSet & CodeFNC4);
switch(characterSetCur){
case CodeA:
case CodeB:
/* >> Check switching to CodeC */
/* Switch if :
* - Character not FNC1
* - 4 real Digits will fit in line
* - an odd Start will not be better
*/
if (T[charCur].CharacterSet==ZTNum
&& (CPaires=RemainingDigits(T,charCur, emptyColumns-1))>=4
&& CPaires > RemainingDigits(T,charCur+1,emptyColumns-2))
{
/* > Change to C */
pSet[charCur]=characterSetCur=CodeC;
charCur+=2; /* 2 Digit */
emptyColumns-=2; /* <SwitchC>12 */
} else if (characterSetCur==CodeA)
{
if (T[charCur].AFollowing == 0 || (isFNC4 && T[charCur].AFollowing == 1))
{
/* Must change to B */
if (emptyColumns == 1 || (isFNC4 && emptyColumns == 2))
{
/* Can't switch: */
pSet[charCur-1]|=CEnd+CFill;
emptyColumns=0;
}else{
/* <Shift> or <switchB>? */
if (T[charCur].BFollowing == 1 || (isFNC4 && T[charCur].BFollowing == 2))
{
/* Note using order "FNC4 shift char" (same as CODE128) not "shift FNC4 char" as
given in Table B.1 and Table B.2 */
if (isFNC4) { /* So skip FNC4 and shift value instead */
--emptyColumns;
++charCur;
}
pSet[charCur]|=CShift;
} else {
pSet[charCur]|=CodeB;
characterSetCur = CodeB;
}
emptyColumns-=2;
++charCur;
}
} else if (isFNC4 && emptyColumns == 1) {
/* Can't fit extended ASCII on same line */
pSet[charCur-1]|=CEnd+CFill;
emptyColumns=0;
}else{
--emptyColumns;
++charCur;
}
} else { /* Last possibility : CodeB */
if (T[charCur].BFollowing == 0 || (isFNC4 && T[charCur].BFollowing == 1))
{
/* Must change to A */
if (emptyColumns == 1 || (isFNC4 && emptyColumns == 2))
{
/* Can't switch: */
pSet[charCur-1]|=CEnd+CFill;
emptyColumns=0;
} else {
/* <Shift> or <switchA>? */
if (T[charCur].AFollowing == 1 || (isFNC4 && T[charCur].AFollowing == 2))
{
/* Note using order "FNC4 shift char" (same as CODE128) not "shift FNC4 char" as
given in Table B.1 and Table B.2 */
if (isFNC4) { /* So skip FNC4 and shift value instead */
--emptyColumns;
++charCur;
}
pSet[charCur]|=CShift;
} else {
pSet[charCur]|=CodeA;
characterSetCur = CodeA;
}
emptyColumns-=2;
++charCur;
}
} else if (isFNC4 && emptyColumns == 1) {
/* Can't fit extended ASCII on same line */
pSet[charCur-1]|=CEnd+CFill;
emptyColumns=0;
}else{
--emptyColumns;
++charCur;
}
}
break;
case CodeC:
if(T[charCur].CFollowing>0)
{
charCur+=(T[charCur].CharacterSet==ZTFNC1)?1:2;
emptyColumns--;
}else{
/* Must change to A or B */
if (emptyColumns==1)
{
/* Can't switch: */
pSet[charCur-1]|=CEnd+CFill;
emptyColumns=0;
}else{
/*<SwitchA> or <switchA>?*/
characterSetCur=pSet[charCur]=
(T[charCur].AFollowing > T[charCur].BFollowing)
?CodeA:CodeB;
emptyColumns-=2;
++charCur;
}
}
break;
} /* switch */
} /* while */
/* > End of Codeline */
pSet[charCur-1]|=CEnd;
++rowsCur;
} while (charCur<dataLength); /* <= Data.Len-1 */
/* Allow for check characters K1, K2 */
switch (emptyColumns) {
case 1:
pSet[charCur-1]|=CFill;
/* fall through */
case 0:
++rowsCur;
fillings=useColumns-2+emptyColumns;
break;
case 2:
fillings=0;
break;
default:
pSet[charCur-1]|=CFill;
fillings=emptyColumns-2;
}
if (rowsCur>44) {
++useColumns;
if (useColumns > 62) {
return ZINT_ERROR_TOO_LONG;
}
} else if (rowsCur == 1) {
rowsCur = 2;
fillings += useColumns;
}
} while(rowsCur>44);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf(" -> out: rowsCur <%i>, useColumns <%i>, fillings <%i>\n",rowsCur,useColumns,fillings);
}
*pUseColumns=useColumns;
*pRows=rowsCur;
*pFillings=fillings;
return 0;
}
/* Find columns if row count is given.
*/
static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, const int dataLength,
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
{
int rowsCur;
int rowsRequested; /* Number of requested rows */
int columnsRequested; /* Number of requested columns (if any) */
int fillings;
int useColumns;
int testColumns; /* To enter into Width2Rows */
int testListSize = 0;
int pTestList[62 + 1];
#ifndef _MSC_VER
int *pBackupSet[dataLength];
#else
int *pBackupSet = (int *)_alloca(dataLength*sizeof(int));
#endif
rowsRequested=*pRows;
columnsRequested = *pUseColumns >= 4 ? *pUseColumns : 0;
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Optimizer : Searching <%i> rows\n", rowsRequested);
}
if (columnsRequested) {
testColumns = columnsRequested;
} else {
/* First guess */
testColumns=dataLength/rowsRequested;
if (testColumns > 62)
testColumns = 62;
else if (testColumns < 4)
testColumns = 4;
}
for (;;) {
int errorCur;
pTestList[testListSize] = testColumns;
testListSize++;
useColumns=testColumns; /* Make a copy because it may be modified */
errorCur = Columns2Rows(symbol, T, dataLength, &rowsCur, &useColumns, pSet, &fillings);
if (errorCur != 0)
return errorCur;
if (rowsCur<=rowsRequested) {
/* Less or exactly line number found */
/* check if column count below already tested or at smallest/requested */
int fInTestList = (rowsCur == 2 || testColumns == 4 || testColumns == columnsRequested);
int posCur;
for (posCur = 0; posCur < testListSize && ! fInTestList; posCur++) {
if ( pTestList[posCur] == testColumns-1 )
fInTestList = 1;
}
if (fInTestList) {
/* >> Smaller Width already tested
*/
if (rowsCur < rowsRequested) {
fillings += useColumns * (rowsRequested - rowsCur);
rowsCur = rowsRequested;
}
/* Exit with actual */
*pFillings=fillings;
*pRows=rowsCur;
*pUseColumns = useColumns;
return 0;
}
/* > Test more rows (shorter CDB) */
memcpy(pBackupSet,pSet,dataLength*sizeof(int));
--testColumns;
} else {
/* > Too many rows */
/* > Test less rows (longer code) */
memcpy(pBackupSet,pSet,dataLength*sizeof(int));
if (++testColumns > 62) {
return ZINT_ERROR_TOO_LONG;
}
}
}
}
/* Print a character in character set A
*/
static void A2C128_A(uchar **ppOutPos,uchar c)
{
uchar * pOutPos = *ppOutPos;
switch(c){
case aCodeB: *pOutPos=100; break;
case aFNC4: *pOutPos=101; break;
case aFNC1: *pOutPos=102; break; /* FNC1s (GS1) not used */ /* Not reached */
case aFNC2: *pOutPos=97; break; /* FNC2s (Message Append) not used */ /* Not reached */
case aFNC3: *pOutPos=96; break;
case aCodeC: *pOutPos=99; break;
case aShift: *pOutPos=98; break;
default:
/* +++ HaO 13.11.98 c>' ' && c < '\x1F' corrected */
if(c>=' ' && c<='_')
*pOutPos=(uchar)(c-' ');
else
*pOutPos=(uchar)(c+64);
break;
}
(*ppOutPos)++;
}
/* Output c in Set B
*/
static void A2C128_B(uchar **ppOutPos,uchar c)
{
uchar * pOutPos = *ppOutPos;
switch(c){
case aFNC1: *pOutPos=102; break; /* FNC1s (GS1) not used */ /* Not reached */
case aFNC2: *pOutPos=97; break; /* FNC2s (Message Append) not used */ /* Not reached */
case aFNC3: *pOutPos=96; break;
case aFNC4: *pOutPos=100; break;
case aCodeA: *pOutPos=101; break;
case aCodeC: *pOutPos=99; break;
case aShift: *pOutPos=98; break;
default: *pOutPos=(uchar)(c-' '); break;
}
++(*ppOutPos);
}
/* Output c1, c2 in Set C
*/
static void A2C128_C(uchar **ppOutPos,uchar c1,uchar c2)
{
uchar * pOutPos = *ppOutPos;
switch(c1){
case aFNC1: *pOutPos=102; break; /* FNC1s (GS1) not used */ /* Not reached */
case aCodeB: *pOutPos=100; break;
case aCodeA: *pOutPos=101; break;
default: *pOutPos=(char)(10 * (c1- '0') + (c2 - '0'));break;
}
(*ppOutPos)++;
}
/* Output a character in Characterset
*/
static void ASCIIZ128(uchar **ppOutPos, int CharacterSet,uchar c1, uchar c2)
{
if (CharacterSet==CodeA)
A2C128_A(ppOutPos,c1);
else if(CharacterSet==CodeB)
A2C128_B(ppOutPos,c1);
else
A2C128_C(ppOutPos,c1,c2);
}
/* XLate Tables D.2, D.3 and F.1 of Codablock-F Specification and call output
*/
static void SumASCII(uchar **ppOutPos, int Sum, int CharacterSet)
{
switch (CharacterSet){
case CodeA: /* Row # Indicators and Data Check Characters K1/K2 for CodeA and CodeB are the same */
case CodeB:
if (Sum<=31)
A2C128_B(ppOutPos, (uchar)(Sum+96));
else if(Sum<=47)
A2C128_B(ppOutPos, (uchar)Sum);
else
A2C128_B(ppOutPos, (uchar)(Sum+10));
break;
case CodeC:
A2C128_C(ppOutPos
,(char)(Sum/10+'0') ,(uchar)(Sum%10+'0'));
break;
}
}
/* Main function called by zint framework
*/
INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int length) {
int charCur, dataLength;
int error_number;
int rows, columns, useColumns;
int fillings;
int Sum1,Sum2;
uchar * pOutPos;
int rowCur;
int characterSetCur;
int emptyColumns;
char dest[1000];
int r, c;
float min_row_height = 0.0f;
#ifdef _MSC_VER
CharacterSetTable *T;
unsigned char *data;
int *pSet;
uchar * pOutput;
#endif
/* Suppresses clang-analyzer-core.VLASize warning */
assert(length > 0);
/* Parameter check */
/* option1: rows <= 0: automatic, 1..44 */
rows = symbol->option_1;
if (rows == 1) {
error_number = code_128(symbol, source, length); /* Only returns errors, not warnings */
if (error_number < ZINT_ERROR) {
symbol->output_options |= BARCODE_BIND;
if (symbol->border_width == 0) { /* Allow override if non-zero */
symbol->border_width = 1; /* AIM ISS-X-24 Section 4.6.1 b) (note change from previous default 2) */
}
symbol->text[0] = '\0'; /* Disable HRT for compatibility with CODABLOCKF */
#ifdef COMPLIANT_HEIGHTS
/* AIM ISS-X-24 Section 4.5.1 minimum row height 8 (for compatibility with CODABLOCKF, not specced for
CODE128) */
error_number = set_height(symbol, 8.0f, 10.0f, 0.0f, 0 /*no_errtxt*/);
#else
(void) set_height(symbol, 0.0f, 5.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
return error_number;
}
if (rows > 44) {
strcpy(symbol->errtxt, "410: Rows parameter not in 0..44");
return ZINT_ERROR_INVALID_OPTION;
}
/* option_2: (usable data) columns: <= 0: automatic, 9..67 (min 9 == 4 data, max 67 == 62 data) */
columns = symbol->option_2;
if ( ! (columns <= 0 || (columns >= 9 && columns <= 67)) ) {
strcpy(symbol->errtxt, "411: Columns parameter not in 0, 9..67");
return ZINT_ERROR_INVALID_OPTION;
}
#ifndef _MSC_VER
unsigned char data[length*2+1];
#else
data = (unsigned char *) _alloca(length * 2+1);
#endif
dataLength = 0;
if (symbol->output_options & READER_INIT) {
data[dataLength] = aFNC3;
dataLength++;
}
/* Replace all Codes>127 with <fnc4>Code-128 */
for (charCur = 0; charCur < length; charCur++) {
if (source[charCur]>127)
{
data[dataLength] = aFNC4;
dataLength++;
data[dataLength] = (unsigned char)(source[charCur]&127);
} else
data[dataLength] = source[charCur];
dataLength++;
}
/* Build character set table */
#ifndef _MSC_VER
CharacterSetTable T[dataLength];
int pSet[dataLength];
#else
T=(CharacterSetTable *)_alloca(dataLength*sizeof(CharacterSetTable));
pSet = (int *)_alloca(dataLength*sizeof(int));
#endif
CreateCharacterSetTable(T,data,dataLength);
/* Find final row and column count */
/* nor row nor column count given */
if (rows <= 0 && columns <= 0) {
/* use 1/1 aspect/ratio Codablock */
columns = (int) floor(sqrt(dataLength)) + 5;
if (columns > 67) {
columns = 67;
} else if (columns < 9) {
columns = 9;
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Auto column count for %d characters:%d\n", dataLength, columns);
}
}
/* There are 5 Codewords for Organisation Start(2),row(1),CheckSum,Stop */
useColumns = columns - 5;
if ( rows > 0 ) {
/* row count given */
error_number = Rows2Columns(symbol, T, dataLength, &rows, &useColumns, pSet, &fillings);
} else {
/* column count given */
error_number = Columns2Rows(symbol, T, dataLength, &rows, &useColumns, pSet, &fillings);
}
if (error_number != 0) {
strcpy(symbol->errtxt, "413: Data string too long");
return error_number;
}
/* Suppresses clang-analyzer-core.VLASize warning */
assert(rows >= 2 && useColumns >= 4);
/* Data Check Characters K1 and K2, Annex F */
Sum1 = Sum2 = 0;
for (charCur = 0; charCur < length; charCur++) {
Sum1 = (Sum1 + (charCur + 1) * source[charCur]) % 86; /* Mod as we go along to avoid overflow */
Sum2 = (Sum2 + charCur * source[charCur]) % 86;
}
if (symbol->debug & ZINT_DEBUG_PRINT) { /* start a new level of local variables */
int DPos;
printf("\nData:");
for (DPos=0 ; DPos< dataLength ; DPos++)
fputc(data[DPos],stdout);
printf("\n Set:");
for (DPos=0 ; DPos< dataLength ; DPos++) {
switch (pSet[DPos]&(CodeA+CodeB+CodeC)) {
case CodeA: fputc('A',stdout); break;
case CodeB: fputc('B',stdout); break;
case CodeC: fputc('C',stdout); break;
default: fputc('.',stdout); break;
}
}
printf("\nFNC1:");
for (DPos=0 ; DPos< dataLength ; DPos++)
fputc((pSet[DPos]&CodeFNC1)==0?'.':'X',stdout);
printf("\n END:");
for (DPos=0 ; DPos< dataLength ; DPos++)
fputc((pSet[DPos]&CEnd)==0?'.':'X',stdout);
printf("\nShif:");
for (DPos=0 ; DPos< dataLength ; DPos++)
fputc((pSet[DPos]&CShift)==0?'.':'X',stdout);
printf("\nFILL:");
for (DPos=0 ; DPos< dataLength ; DPos++)
fputc((pSet[DPos]&CFill)==0?'.':'X',stdout);
fputc('\n',stdout);
printf("K1 %d, K2 %d\n", Sum1, Sum2);
}
columns = useColumns + 5;
/* >>> Build C128 code numbers */
/* The C128 column count contains Start (2CW), Row ID, Checksum, Stop */
#ifndef _MSC_VER
uchar pOutput[columns * rows];
#else
pOutput = (unsigned char *) _alloca(columns * rows);
#endif
pOutPos = pOutput;
charCur=0;
/* >> Loop over rows */
for (rowCur=0 ; rowCur<rows ; rowCur++) {
if (charCur>=dataLength)
{
/* >> Empty line with StartA, aCodeB, row #, and then filler aCodeC aCodeB etc */
*pOutPos='\x67';
pOutPos++;
*pOutPos = 100; /* aCodeB */
pOutPos++;
characterSetCur = CodeB;
SumASCII(&pOutPos, rowCur + 42, characterSetCur); /* Row # */
emptyColumns = useColumns;
if (rowCur == rows - 1) {
emptyColumns -= 2;
}
while (emptyColumns>0)
{
if(characterSetCur==CodeC)
{
A2C128_C(&pOutPos,aCodeB,'\0');
characterSetCur=CodeB;
}else{
A2C128_B(&pOutPos,aCodeC);
characterSetCur=CodeC;
}
--emptyColumns;
}
}else{
/* >> Normal Line */
/* > Startcode */
switch (pSet[charCur] & (CodeA+CodeB+CodeC)){
case CodeA:
*pOutPos = '\x67';
pOutPos++;
*pOutPos = '\x62';
pOutPos++;
characterSetCur=CodeA;
break;
case CodeB:
*pOutPos = '\x67';
pOutPos++;
*pOutPos = '\x64';
pOutPos++;
characterSetCur=CodeB;
break;
case CodeC:
default:
*pOutPos = '\x67';
pOutPos++;
*pOutPos = '\x63';
pOutPos++;
characterSetCur=CodeC;
break;
}
/* > Set F1 */
/* In first line : # of rows */
SumASCII(&pOutPos, rowCur == 0 ? rows - 2 : rowCur + 42, characterSetCur);
/* >>> Data */
emptyColumns=useColumns;
/* >> Character loop */
while (emptyColumns > 0 && charCur < dataLength)
{
/* ? Change character set */
if (emptyColumns < useColumns)
{
if ((pSet[charCur]&CodeA)!=0)
{
/* Change to A */
ASCIIZ128(&pOutPos,characterSetCur,aCodeA,'\0');
--emptyColumns;
characterSetCur=CodeA;
} else if ((pSet[charCur]&CodeB)!=0)
{
/* Change to B */
ASCIIZ128(&pOutPos,characterSetCur,aCodeB,'\0');
--emptyColumns;
characterSetCur=CodeB;
} else if ((pSet[charCur]&CodeC)!=0)
{
/* Change to C */
ASCIIZ128(&pOutPos,characterSetCur,aCodeC,'\0');
--emptyColumns;
characterSetCur=CodeC;
}
}
if ((pSet[charCur]&CShift)!=0)
{
/* >> Shift it and put out the shifted character */
ASCIIZ128(&pOutPos,characterSetCur,aShift,'\0');
emptyColumns-=2;
characterSetCur=(characterSetCur==CodeB)?CodeA:CodeB;
ASCIIZ128(&pOutPos,characterSetCur,data[charCur],'\0');
characterSetCur=(characterSetCur==CodeB)?CodeA:CodeB;
}else{
/* Normal Character */
if (characterSetCur==CodeC)
{
if (data[charCur]==aFNC1) /* FNC1s (GS1) not used */
A2C128_C(&pOutPos,aFNC1,'\0'); /* Not reached */
else
{
A2C128_C(&pOutPos, data[charCur],
(uchar) (charCur + 1 < dataLength ? data[charCur + 1] : 0));
++charCur;
/* We need this here to get the good index */
/* for the termination flags in Set. */
}
}else
ASCIIZ128(&pOutPos,characterSetCur,data[charCur],'\0');
--emptyColumns;
}
/* >> End Criteria */
if ((pSet[charCur] & CFill) || (pSet[charCur] & CEnd))
{
/* Fill Line but leave space for checks in last line */
if (rowCur == rows - 1) {
emptyColumns -= 2;
}
while(emptyColumns>0)
{
switch(characterSetCur){
case CodeC:
A2C128_C(&pOutPos,aCodeB,'\0');
characterSetCur=CodeB;
break;
case CodeB:
A2C128_B(&pOutPos,aCodeC);
characterSetCur=CodeC;
break;
case CodeA:
A2C128_A(&pOutPos,aCodeC);
characterSetCur=CodeC;
break;
}
--emptyColumns;
}
}
++charCur;
} /* Loop over characters */
} /* if filling-Line / normal */
/* Add checksum in last line */
if (rowCur == rows - 1)
{
SumASCII(&pOutPos,Sum1,characterSetCur);
SumASCII(&pOutPos,Sum2,characterSetCur);
}
/* Add Code 128 checksum */
{
int Sum = pOutput[columns * rowCur] % 103;
int Pos = 1;
for ( ; Pos < useColumns+3 ; Pos++)
{
Sum = (Sum + pOutput[columns * rowCur + Pos] * Pos) % 103;
}
*pOutPos=(uchar)Sum;
pOutPos++;
}
/* Add end character */
*pOutPos=106;
pOutPos++;
} /* End Lineloop */
if (symbol->debug & ZINT_DEBUG_PRINT) {
/* Dump the output to the screen
*/
printf("\nCode 128 Code Numbers:\n");
{ /* start a new level of local variables */
int DPos, DPos2;
for (DPos=0 ; DPos< rows ; DPos++)
{
for (DPos2=0 ; DPos2 < columns ; DPos2++)
{
printf("%3d ",(int)(pOutput[DPos*columns+DPos2]));
}
printf("\n");
}
}
printf("rows=%i columns=%i fillings=%i\n", rows, columns, fillings);
}
#ifdef ZINT_TEST
if (symbol->debug & ZINT_DEBUG_TEST) {
debug_test_codeword_dump(symbol, pOutput, rows * columns);
}
#endif
/* Paint the C128 patterns */
for (r = 0; r < rows; r++) {
strcpy(dest, "");
for(c = 0; c < columns; c++) {
strcat(dest, C128Table[pOutput[r * columns + c]]);
}
expand(symbol, dest);
}
#ifdef COMPLIANT_HEIGHTS
/* AIM ISS-X-24 Section 4.6.1 minimum row height; use 10 * rows as default for back-compatibility */
min_row_height = (float) (0.55 * useColumns + 3.0);
if (min_row_height < 8.0f) {
min_row_height = 8.0f;
}
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
symbol->output_options |= BARCODE_BIND;
if (symbol->border_width == 0) { /* Allow override if non-zero */
symbol->border_width = 1; /* AIM ISS-X-24 Section 4.6.1 b) (note change from previous default 2) */
}
return error_number;
}

837
3rdparty/zint-2.10.0/backend/code.c vendored Normal file
View File

@@ -0,0 +1,837 @@
/* code.c - Handles Code 11, 39, 39+, 93, PZN, Channel and VIN */
/* LOGMARS MIL-STD-1189 Rev. B https://apps.dtic.mil/dtic/tr/fulltext/u2/a473534.pdf */
/* PZN https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/IFA_Info_Code_39_EN.pdf */
/* PZN https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/IFA-Info_Check_Digit_Calculations_PZN_PPN_UDI_EN.pdf */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* In version 0.5 this file was 1,553 lines long! */
#include <stdio.h>
#include <assert.h>
#include "common.h"
#define SODIUM "0123456789-"
#define SILVER "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd"
#define ARSENIC "0123456789ABCDEFGHJKLMNPRSTUVWXYZ"
static const char *C11Table[11] = {
"111121", "211121", "121121", "221111", "112121", "212111", "122111",
"111221", "211211", "211111", "112111"
};
/* Code 39 tables checked against ISO/IEC 16388:2007 */
/* Incorporates Table A1 */
static const char *C39Table[43] = {
/* Code 39 character assignments (Table 1) */
"1112212111", "2112111121", "1122111121", "2122111111", "1112211121",
"2112211111", "1122211111", "1112112121", "2112112111", "1122112111", "2111121121",
"1121121121", "2121121111", "1111221121", "2111221111", "1121221111", "1111122121",
"2111122111", "1121122111", "1111222111", "2111111221", "1121111221", "2121111211",
"1111211221", "2111211211", "1121211211", "1111112221", "2111112211", "1121112211",
"1111212211", "2211111121", "1221111121", "2221111111", "1211211121", "2211211111",
"1221211111", "1211112121", "2211112111", "1221112111", "1212121111", "1212111211",
"1211121211", "1112121211"
};
static const char *EC39Ctrl[128] = {
/* Encoding the full ASCII character set in Code 39 (Table A2) */
"%U", "$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", "$Z",
"%A", "%B", "%C", "%D", "%E", " ", "/A", "/B", "/C", "/D", "/E", "/F", "/G", "/H", "/I", "/J",
"/K", "/L", "-", ".", "/O", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "/Z", "%F",
"%G", "%H", "%I", "%J", "%V", "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", "Z", "%K", "%L", "%M", "%N", "%O",
"%W", "+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", "+Z", "%P", "%Q", "%R", "%S", "%T"
};
static const char *C93Ctrl[128] = {
"bU", "aA", "aB", "aC", "aD", "aE", "aF", "aG", "aH", "aI", "aJ", "aK",
"aL", "aM", "aN", "aO", "aP", "aQ", "aR", "aS", "aT", "aU", "aV", "aW", "aX", "aY", "aZ",
"bA", "bB", "bC", "bD", "bE", " ", "cA", "cB", "cC", "$", "%", "cF", "cG", "cH", "cI", "cJ",
"+", "cL", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "cZ", "bF",
"bG", "bH", "bI", "bJ", "bV", "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", "Z", "bK", "bL", "bM", "bN", "bO",
"bW", "dA", "dB", "dC", "dD", "dE", "dF", "dG", "dH", "dI", "dJ", "dK", "dL", "dM", "dN", "dO",
"dP", "dQ", "dR", "dS", "dT", "dU", "dV", "dW", "dX", "dY", "dZ", "bP", "bQ", "bR", "bS", "bT"
};
static const char *C93Table[47] = {
"131112", "111213", "111312", "111411", "121113", "121212", "121311",
"111114", "131211", "141111", "211113", "211212", "211311", "221112", "221211", "231111",
"112113", "112212", "112311", "122112", "132111", "111123", "111222", "111321", "121122",
"131121", "212112", "212211", "211122", "211221", "221121", "222111", "112122", "112221",
"122121", "123111", "121131", "311112", "311211", "321111", "112131", "113121", "211131",
"121221", "312111", "311121", "122211"
};
/* *********************** CODE 11 ******************** */
INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int length) { /* Code 11 */
int i;
int h, c_digit, c_weight, c_count, k_digit, k_weight, k_count;
int weight[122], error_number;
char dest[750]; /* 6 + 121 * 6 + 2 * 6 + 5 + 1 == 750 */
char checkstr[3];
int num_check_digits;
/* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning */
assert(length > 0);
if (length > 121) {
strcpy(symbol->errtxt, "320: Input too long (121 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SODIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "321: Invalid character in data (digits and \"-\" only)");
return error_number;
}
if (symbol->option_2 < 0 || symbol->option_2 > 2) {
strcpy(symbol->errtxt, "339: Invalid check digit version (1, 2 only)");
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->option_2 == 2) {
num_check_digits = 0;
} else if (symbol->option_2 == 1) {
num_check_digits = 1;
} else {
num_check_digits = 2;
}
c_weight = 1;
c_count = 0;
k_weight = 1;
k_count = 0;
/* start character */
strcpy(dest, "112211");
/* Draw main body of barcode */
for (i = 0; i < length; i++) {
lookup(SODIUM, C11Table, source[i], dest);
if (source[i] == '-')
weight[i] = 10;
else
weight[i] = ctoi(source[i]);
}
if (num_check_digits) {
/* Calculate C checksum */
for (h = length - 1; h >= 0; h--) {
c_count += (c_weight * weight[h]);
c_weight++;
if (c_weight > 10) {
c_weight = 1;
}
}
c_digit = c_count % 11;
if (num_check_digits == 1) {
checkstr[0] = itoc(c_digit);
if (checkstr[0] == 'A') {
checkstr[0] = '-';
}
checkstr[1] = '\0';
lookup(SODIUM, C11Table, checkstr[0], dest);
} else {
weight[length] = c_digit;
/* Calculate K checksum */
for (h = length; h >= 0; h--) {
k_count += (k_weight * weight[h]);
k_weight++;
if (k_weight > 9) {
k_weight = 1;
}
}
k_digit = k_count % 11;
checkstr[0] = itoc(c_digit);
checkstr[1] = itoc(k_digit);
if (checkstr[0] == 'A') {
checkstr[0] = '-';
}
if (checkstr[1] == 'A') {
checkstr[1] = '-';
}
checkstr[2] = '\0';
lookup(SODIUM, C11Table, checkstr[0], dest);
lookup(SODIUM, C11Table, checkstr[1], dest);
}
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Check digit (%d): %s\n", num_check_digits, num_check_digits ? checkstr : "<none>");
}
/* Stop character */
strcat(dest, "11221");
expand(symbol, dest);
// TODO: Find documentation on BARCODE_CODE11 dimensions/height
ustrcpy(symbol->text, source);
if (num_check_digits) {
ustrcat(symbol->text, checkstr);
}
return error_number;
}
/* Code 39 */
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
int counter;
int error_number;
char dest[880]; /* 10 (Start) + 85 * 10 + 10 (Check) + 9 (Stop) + 1 = 880 */
char localstr[2] = {0};
float height;
counter = 0;
if ((symbol->option_2 < 0) || (symbol->option_2 > 1)) {
symbol->option_2 = 0;
}
if ((symbol->symbology == BARCODE_LOGMARS) && (length > 30)) { /* MIL-STD-1189 Rev. B Section 5.2.6.2 */
strcpy(symbol->errtxt, "322: Input too long (30 character maximum)");
return ZINT_ERROR_TOO_LONG;
/* Prevent encoded_data out-of-bounds >= 143 for BARCODE_HIBC_39 due to wider 'wide' bars */
} else if ((symbol->symbology == BARCODE_HIBC_39) && (length > 69)) {
/* Note use 319 (2of5 range) as 340 taken by CODE128 */
strcpy(symbol->errtxt, "319: Input too long (67 character maximum)"); /* 69 less '+' and check */
return ZINT_ERROR_TOO_LONG;
} else if (length > 85) {
strcpy(symbol->errtxt, "323: Input too long (85 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(SILVER, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "324: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)");
return error_number;
}
/* Start character */
strcpy(dest, "1211212111");
for (i = 0; i < length; i++) {
lookup(SILVER, C39Table, source[i], dest);
counter += posn(SILVER, source[i]);
}
if (symbol->option_2 == 1) {
char check_digit;
counter %= 43;
check_digit = SILVER[counter];
lookup(SILVER, C39Table, check_digit, dest);
/* Display a space check digit as _, otherwise it looks like an error */
if (check_digit == ' ') {
check_digit = '_';
}
localstr[0] = check_digit;
localstr[1] = '\0';
}
/* Stop character */
strcat(dest, "121121211");
if ((symbol->symbology == BARCODE_LOGMARS) || (symbol->symbology == BARCODE_HIBC_39)) {
/* LOGMARS uses wider 'wide' bars than normal Code 39 */
counter = (int) strlen(dest);
for (i = 0; i < counter; i++) {
if (dest[i] == '2') {
dest[i] = '3';
}
}
}
if (symbol->debug) {
printf("Barspaces: %s\n", dest);
}
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
if (symbol->symbology == BARCODE_LOGMARS) {
/* MIL-STD-1189 Rev. B Section 5.2
Min height 0.25" / 0.04" (X max) = 6.25
Default height 0.625" (average of 0.375" - 0.875") / 0.01375" (average of 0.0075" - 0.02") ~ 45.45 */
height = (float) (0.625 / 0.01375);
error_number = set_height(symbol, 6.25f, height, (float) (0.875 / 0.0075), 0 /*no_errtxt*/);
} else if (symbol->symbology == BARCODE_CODE39 || symbol->symbology == BARCODE_EXCODE39
|| symbol->symbology == BARCODE_HIBC_39) {
/* ISO/IEC 16388:2007 4.4 (e) recommended min height 5.0mm or 15% of width excluding quiet zones;
as X left to application specification use
width = (C + 2) * (3 * N + 6) * X + (C + 1) * I = (C + 2) * 9 + C + 1) * X = (10 * C + 19) */
height = (float) ((10.0 * (symbol->option_2 == 1 ? length + 1 : length) + 19.0) * 0.15);
/* Using 50 as default as none recommended */
error_number = set_height(symbol, height, height > 50.0f ? height : 50.0f, 0.0f, 0 /*no_errtxt*/);
}
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
if (symbol->symbology == BARCODE_CODE39) {
ustrcpy(symbol->text, "*");
ustrncat(symbol->text, source, length);
ustrcat(symbol->text, localstr);
ustrcat(symbol->text, "*");
} else {
ustrcpy(symbol->text, source);
ustrcat(symbol->text, localstr);
}
return error_number;
}
/* Pharmazentral Nummer (PZN) */
INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number, zeroes;
unsigned int count, check_digit;
char localstr[11];
if (length > 7) {
strcpy(symbol->errtxt, "325: Input wrong length (7 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "326: Invalid character in data (digits only)");
return error_number;
}
localstr[0] = '-';
zeroes = 7 - length + 1;
for (i = 1; i < zeroes; i++)
localstr[i] = '0';
ustrcpy(localstr + zeroes, source);
count = 0;
for (i = 1; i < 8; i++) {
count += i * ctoi(localstr[i]);
}
check_digit = count % 11;
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("PZN: %s, check digit %d\n", localstr, (int) check_digit);
}
if (check_digit == 10) {
strcpy(symbol->errtxt, "327: Invalid PZN, check digit is '10'");
return ZINT_ERROR_INVALID_DATA;
}
localstr[8] = itoc(check_digit);
localstr[9] = '\0';
error_number = c39(symbol, (unsigned char *) localstr, 9);
ustrcpy(symbol->text, "PZN ");
ustrcat(symbol->text, localstr);
#ifdef COMPLIANT_HEIGHTS
/* Technical Information regarding PZN Coding V 2.1 (25 Feb 2019) Code size
https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/IFA_Info_Code_39_EN.pdf
"normal" X 0.25mm (0.187mm - 0.45mm), height 8mm - 20mm for 0.25mm X, 10mm mentioned so use that as default,
10mm / 0.25mm = 40 */
if (error_number < ZINT_ERROR) {
error_number = set_height(symbol, (float) (8.0 / 0.45), 40.0f, (float) (20.0 / 0.187), 0 /*no_errtxt*/);
}
#else
if (error_number < ZINT_ERROR) {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
#endif
return error_number;
}
/* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
unsigned char buffer[85 * 2 + 1] = {0};
int i;
int error_number;
if (length > 85) {
strcpy(symbol->errtxt, "328: Input too long (85 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
/* Creates a buffer string and places control characters into it */
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "329: Invalid character in data, extended ASCII not allowed");
return ZINT_ERROR_INVALID_DATA;
}
ustrcat(buffer, EC39Ctrl[source[i]]);
}
/* Then sends the buffer to the C39 function */
error_number = c39(symbol, buffer, (int) ustrlen(buffer));
for (i = 0; i < length; i++)
symbol->text[i] = source[i] >= ' ' && source[i] != 0x7F ? source[i] : ' ';
symbol->text[length] = '\0';
return error_number;
}
/* Code 93 is an advancement on Code 39 and the definition is a lot tighter */
INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length) {
/* SILVER includes the extra characters a, b, c and d to represent Code 93 specific
shift characters 1, 2, 3 and 4 respectively. These characters are never used by
c39() and ec39() */
int i;
int h, weight, c, k, values[128], error_number = 0;
char buffer[220];
char dest[670];
char set_copy[] = SILVER;
float height;
strcpy(buffer, "");
if (length > 107) {
strcpy(symbol->errtxt, "330: Input too long (107 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
/* Message Content */
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "331: Invalid character in data, extended ASCII not allowed");
return ZINT_ERROR_INVALID_DATA;
}
strcat(buffer, C93Ctrl[source[i]]);
symbol->text[i] = source[i] >= ' ' && source[i] != 0x7F ? source[i] : ' ';
}
/* Now we can check the true length of the barcode */
h = (int) strlen(buffer);
if (h > 107) {
strcpy(symbol->errtxt, "332: Input too long"); // TODO: Better error message
return ZINT_ERROR_TOO_LONG;
}
for (i = 0; i < h; i++) {
values[i] = posn(SILVER, buffer[i]);
}
/* Putting the data into dest[] is not done until after check digits are calculated */
/* Check digit C */
c = 0;
weight = 1;
for (i = h - 1; i >= 0; i--) {
c += values[i] * weight;
weight++;
if (weight == 21)
weight = 1;
}
c = c % 47;
values[h] = c;
buffer[h] = set_copy[c];
/* Check digit K */
k = 0;
weight = 1;
for (i = h; i >= 0; i--) {
k += values[i] * weight;
weight++;
if (weight == 16)
weight = 1;
}
k = k % 47;
buffer[++h] = set_copy[k];
buffer[++h] = '\0';
/* Start character */
strcpy(dest, "111141");
for (i = 0; i < h; i++) {
lookup(SILVER, C93Table, buffer[i], dest);
}
/* Stop character */
strcat(dest, "1111411");
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
/* ANSI/AIM BC5-1995 Section 2.6 minimum height 0.2" or 15% of symbol length, whichever is greater
0.2" / 0.0075" (min X) = ~26.66; symbol length = (9 * (C + 4) + 1) * X + 2 * Q = symbol->width + 20 */
height = (float) ((symbol->width + 20) * 0.15);
if (height < 0.2f / 0.0075f) {
height = 0.2f / 0.0075f;
}
/* Using 50 as default for back-compatibility */
error_number = set_height(symbol, height, height > 50.0f ? height : 50.0f, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
symbol->text[length] = set_copy[c];
symbol->text[length + 1] = set_copy[k];
symbol->text[length + 2] = '\0';
return error_number;
}
typedef const struct s_channel_precalc {
long value; unsigned char B[8]; unsigned char S[8]; unsigned char bmax[7]; unsigned char smax[7];
} channel_precalc;
//#define CHANNEL_GENERATE_PRECALCS
#ifdef CHANNEL_GENERATE_PRECALCS
/* To generate precalc tables uncomment CHANNEL_GENERATE_PRECALCS define and run "./test_channel -f generate -g" and
place result in "channel_precalcs.h" */
static void channel_generate_precalc(int channels, long value, int mod, int last, int B[8], int S[8], int bmax[7],
int smax[7]) {
int i;
if (value == mod) printf("static channel_precalc channel_precalcs%d[] = {\n", channels);
printf(" { %7ld, {", value); for (i = 0; i < 8; i++) printf(" %d,", B[i]); printf(" },");
printf(" {"); for (i = 0; i < 8; i++) printf(" %d,", S[i]); printf(" },");
printf(" {"); for (i = 0; i < 7; i++) printf(" %d,", bmax[i]); printf(" },");
printf(" {"); for (i = 0; i < 7; i++) printf(" %d,", smax[i]); printf(" }, },\n");
if (value == last) printf("};\n");
}
#else
#include "channel_precalcs.h"
#endif
static long channel_copy_precalc(channel_precalc precalc, int B[8], int S[8], int bmax[7], int smax[7]) {
int i;
for (i = 0; i < 7; i++) {
B[i] = precalc.B[i];
S[i] = precalc.S[i];
bmax[i] = precalc.bmax[i];
smax[i] = precalc.smax[i];
}
B[7] = precalc.B[7];
S[7] = precalc.S[7];
return precalc.value;
}
/* CHNCHR is adapted from ANSI/AIM BC12-1998 Annex D Figure D5 and is Copyright (c) AIM 1997 */
/* It is used here on the understanding that it forms part of the specification
for Channel Code and therefore its use is permitted under the following terms
set out in that document:
"It is the intent and understanding of AIM [t]hat the symbology presented in this
specification is entirely in the public domain and free of all use restrictions,
licenses and fees. AIM USA, its member companies, or individual officers
assume no liability for the use of this document." */
static void CHNCHR(int channels, long target_value, int B[8], int S[8]) {
/* Use of initial pre-calculations taken from Barcode Writer in Pure PostScript (BWIPP)
* Copyright (c) 2004-2020 Terry Burton (MIT/X-Consortium license) */
static channel_precalc initial_precalcs[6] = {
{ 0, { 1, 1, 1, 1, 1, 2, 1, 2, }, { 1, 1, 1, 1, 1, 1, 1, 3, }, { 1, 1, 1, 1, 1, 3, 2, }, { 1, 1, 1, 1, 1, 3, 3, }, },
{ 0, { 1, 1, 1, 1, 2, 1, 1, 3, }, { 1, 1, 1, 1, 1, 1, 1, 4, }, { 1, 1, 1, 1, 4, 3, 3, }, { 1, 1, 1, 1, 4, 4, 4, }, },
{ 0, { 1, 1, 1, 2, 1, 1, 2, 3, }, { 1, 1, 1, 1, 1, 1, 1, 5, }, { 1, 1, 1, 5, 4, 4, 4, }, { 1, 1, 1, 5, 5, 5, 5, }, },
{ 0, { 1, 1, 2, 1, 1, 2, 1, 4, }, { 1, 1, 1, 1, 1, 1, 1, 6, }, { 1, 1, 6, 5, 5, 5, 4, }, { 1, 1, 6, 6, 6, 6, 6, }, },
{ 0, { 1, 2, 1, 1, 2, 1, 1, 5, }, { 1, 1, 1, 1, 1, 1, 1, 7, }, { 1, 7, 6, 6, 6, 5, 5, }, { 1, 7, 7, 7, 7, 7, 7, }, },
{ 0, { 2, 1, 1, 2, 1, 1, 2, 5, }, { 1, 1, 1, 1, 1, 1, 1, 8, }, { 8, 7, 7, 7, 6, 6, 6, }, { 8, 8, 8, 8, 8, 8, 8, }, },
};
int bmax[7], smax[7];
long value = 0;
channel_copy_precalc(initial_precalcs[channels - 3], B, S, bmax, smax);
#ifndef CHANNEL_GENERATE_PRECALCS
if (channels == 7 && target_value >= channel_precalcs7[0].value) {
value = channel_copy_precalc(channel_precalcs7[(target_value / channel_precalcs7[0].value) - 1], B, S, bmax,
smax);
} else if (channels == 8 && target_value >= channel_precalcs8[0].value) {
value = channel_copy_precalc(channel_precalcs8[(target_value / channel_precalcs8[0].value) - 1], B, S, bmax,
smax);
}
#endif
goto chkchr;
ls0:smax[1] = smax[0] + 1 - S[0]; B[0] = 1;
if (S[0] == 1) goto nb0;
lb0: bmax[1] = bmax[0] + 1 - B[0]; S[1] = 1;
ls1: smax[2] = smax[1] + 1 - S[1]; B[1] = 1;
if (S[0] + B[0] + S[1] == 3) goto nb1;
lb1: bmax[2] = bmax[1] + 1 - B[1]; S[2] = 1;
ls2: smax[3] = smax[2] + 1 - S[2]; B[2] = 1;
if (B[0] + S[1] + B[1] + S[2] == 4) goto nb2;
lb2: bmax[3] = bmax[2] + 1 - B[2]; S[3] = 1;
ls3: smax[4] = smax[3] + 1 - S[3]; B[3] = 1;
if (B[1] + S[2] + B[2] + S[3] == 4) goto nb3;
lb3: bmax[4] = bmax[3] + 1 - B[3]; S[4] = 1;
ls4: smax[5] = smax[4] + 1 - S[4]; B[4] = 1;
if (B[2] + S[3] + B[3] + S[4] == 4) goto nb4;
lb4: bmax[5] = bmax[4] + 1 - B[4]; S[5] = 1;
ls5: smax[6] = smax[5] + 1 - S[5]; B[5] = 1;
if (B[3] + S[4] + B[4] + S[5] == 4) goto nb5;
lb5: bmax[6] = bmax[5] + 1 - B[5]; S[6] = 1;
ls6: S[7] = smax[6] + 1 - S[6]; B[6] = 1;
if (B[4] + S[5] + B[5] + S[6] == 4) goto nb6;
lb6: B[7] = bmax[6] + 1 - B[6];
if (B[5] + S[6] + B[6] + S[7] + B[7] == 5) goto nb6;
chkchr:
#ifdef CHANNEL_GENERATE_PRECALCS
/* 115338 == (576688 + 2) / 5 */
if (channels == 7 && value && value % 115338 == 0) {
channel_generate_precalc(channels, value, 115338,
115338 * (5 - 1), B, S, bmax, smax);
/* 119121 == (7742862 + 3) / 65 */
} else if (channels == 8 && value && value % 119121 == 0) {
channel_generate_precalc(channels, value, 119121,
119121 * (65 - 1), B, S, bmax, smax);
}
#endif
if (value == target_value) return;
value++;
nb6: if (++B[6] <= bmax[6]) goto lb6;
if (++S[6] <= smax[6]) goto ls6;
nb5: if (++B[5] <= bmax[5]) goto lb5;
if (++S[5] <= smax[5]) goto ls5;
nb4: if (++B[4] <= bmax[4]) goto lb4;
if (++S[4] <= smax[4]) goto ls4;
nb3: if (++B[3] <= bmax[3]) goto lb3;
if (++S[3] <= smax[3]) goto ls3;
nb2: if (++B[2] <= bmax[2]) goto lb2;
if (++S[2] <= smax[2]) goto ls2;
nb1: if (++B[1] <= bmax[1]) goto lb1;
if (++S[1] <= smax[1]) goto ls1;
nb0: if (++B[0] <= bmax[0]) goto lb0;
if (++S[0] <= smax[0]) goto ls0;
}
/* Channel Code - According to ANSI/AIM BC12-1998 */
INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], int length) {
static int max_ranges[] = { -1, -1, -1, 26, 292, 3493, 44072, 576688, 7742862 };
int S[8] = {0}, B[8] = {0};
long target_value = 0;
char pattern[30];
int channels, i;
int error_number, zeroes;
char hrt[9];
float height;
if (length > 7) {
strcpy(symbol->errtxt, "333: Input too long (7 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "334: Invalid character in data (digits only)");
return error_number;
}
if ((symbol->option_2 < 3) || (symbol->option_2 > 8)) {
channels = 0;
} else {
channels = symbol->option_2;
}
for (i = 0; i < length; i++) {
target_value *= 10;
target_value += ctoi((char) source[i]);
}
if (channels == 0) {
channels = length + 1;
if (target_value > 576688 && channels < 8) {
channels = 8;
} else if (target_value > 44072 && channels < 7) {
channels = 7;
} else if (target_value > 3493 && channels < 6) {
channels = 6;
} else if (target_value > 292 && channels < 5) {
channels = 5;
} else if (target_value > 26 && channels < 4) {
channels = 4;
}
}
if (channels == 2) {
channels = 3;
}
if (target_value > max_ranges[channels]) {
if (channels == 8) {
sprintf(symbol->errtxt, "305: Value out of range (0 to %d)", max_ranges[channels]);
} else {
sprintf(symbol->errtxt, "335: Value out of range (0 to %d) for %d channels",
max_ranges[channels], channels);
}
return ZINT_ERROR_INVALID_DATA;
}
CHNCHR(channels, target_value, B, S);
strcpy(pattern, "111111111"); /* Finder pattern */
for (i = 8 - channels; i < 8; i++) {
char part[3];
part[0] = itoc(S[i]);
part[1] = itoc(B[i]);
part[2] = '\0';
strcat(pattern, part);
}
zeroes = channels - 1 - length;
if (zeroes < 0) {
zeroes = 0;
}
memset(hrt, '0', zeroes);
ustrcpy(hrt + zeroes, source);
ustrcpy(symbol->text, hrt);
expand(symbol, pattern);
#ifdef COMPLIANT_HEIGHTS
/* ANSI/AIM BC12-1998 gives min height as 5mm or 15% of length but X left as application specification so use
15% of length where
length = (3 (quiet zones) + 9 (finder) + 4 * channels - 2) * X */
height = (float) ((10 + 4 * channels) * 0.15);
/* Using 50 as default for back-compatibility */
error_number = set_height(symbol, height > 50.0f ? height : 50.0f, height, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
return error_number;
}
/* Vehicle Identification Number (VIN) */
INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length) {
/* This code verifies the check digit present in North American VIN codes */
char local_source[18];
char dest[200]; /* 10 + 10 + 17 * 10 + 9 + 1 = 200 */
char input_check;
char output_check;
int value[17];
int weight[17] = {8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2};
int sum;
int i;
// Check length
if (length != 17) {
strcpy(symbol->errtxt, "336: Input wrong length (17 characters required)");
return ZINT_ERROR_TOO_LONG;
}
// Check input characters, I, O and Q are not allowed
if (is_sane(ARSENIC, source, length) == ZINT_ERROR_INVALID_DATA) {
sprintf(symbol->errtxt, "337: Invalid character in data (\"%s\" only)", ARSENIC);
return ZINT_ERROR_INVALID_DATA;
}
ustrcpy(local_source, source);
to_upper((unsigned char *) local_source);
// Check digit only valid for North America
if (local_source[0] >= '1' && local_source[0] <= '5') {
input_check = local_source[8];
for (i = 0; i < 17; i++) {
if ((local_source[i] >= '0') && (local_source[i] <= '9')) {
value[i] = local_source[i] - '0';
} else if ((local_source[i] >= 'A') && (local_source[i] <= 'I')) {
value[i] = (local_source[i] - 'A') + 1;
} else if ((local_source[i] >= 'J') && (local_source[i] <= 'R')) {
value[i] = (local_source[i] - 'J') + 1;
} else if ((local_source[i] >= 'S') && (local_source[i] <= 'Z')) {
value[i] = (local_source[i] - 'S') + 2;
}
}
sum = 0;
for (i = 0; i < 17; i++) {
sum += value[i] * weight[i];
}
output_check = '0' + (sum % 11);
if (output_check == ':') {
// Check digit was 10
output_check = 'X';
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Producing VIN code: %s\n", local_source);
printf("Input check was %c, calculated check is %c\n", input_check, output_check);
}
if (input_check != output_check) {
sprintf(symbol->errtxt, "338: Invalid check digit '%c', expecting '%c'", input_check, output_check);
return ZINT_ERROR_INVALID_CHECK;
}
}
/* Start character */
strcpy(dest, "1211212111");
/* Import character 'I' prefix? */
if (symbol->option_2 & 1) {
strcat(dest, "1121122111");
}
// Copy glyphs to symbol
for (i = 0; i < 17; i++) {
lookup(SILVER, C39Table, local_source[i], dest);
}
strcat(dest, "121121211");
ustrcpy(symbol->text, local_source);
expand(symbol, dest);
/* Specification of dimensions/height for BARCODE_VIN unlikely */
return 0;
}

1472
3rdparty/zint-2.10.0/backend/code1.c vendored Normal file

File diff suppressed because it is too large Load Diff

102
3rdparty/zint-2.10.0/backend/code1.h vendored Normal file
View File

@@ -0,0 +1,102 @@
/* code1.h - Lookup info for USS Code One */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
static const char 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,
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, 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 const char 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,
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,
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 const char 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,
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, 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 const char 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,
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,
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 const unsigned short int c1_height[] = {
16, 22, 28, 40, 52, 70, 104, 148
};
static const unsigned short int c1_width[] = {
18, 22, 32, 42, 54, 76, 98, 134
};
static const unsigned short int c1_data_length[] = {
10, 19, 44, 91, 182, 370, 732, 1480
};
static const unsigned short int c1_ecc_length[] = {
10, 16, 26, 44, 70, 140, 280, 560
};
static const unsigned short int c1_blocks[] = {
1, 1, 1, 1, 1, 2, 4, 8
};
static const unsigned short int c1_data_blocks[] = {
10, 19, 44, 91, 182, 185, 183, 185
};
static const unsigned short int c1_ecc_blocks[] = {
10, 16, 26, 44, 70, 70, 70, 70
};
static const unsigned short int c1_grid_width[] = {
4, 5, 7, 9, 12, 17, 22, 30
};
static const unsigned short int c1_grid_height[] = {
5, 7, 10, 15, 21, 30, 46, 68
};
#define C1_ASCII 1
#define C1_C40 2
#define C1_DECIMAL 3
#define C1_TEXT 4
#define C1_EDI 5
#define C1_BYTE 6

1210
3rdparty/zint-2.10.0/backend/code128.c vendored Normal file

File diff suppressed because it is too large Load Diff

59
3rdparty/zint-2.10.0/backend/code128.h vendored Normal file
View File

@@ -0,0 +1,59 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef CODE128_H
#define CODE128_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define C128_MAX 160
#define SHIFTA 90
#define LATCHA 91
#define SHIFTB 92
#define LATCHB 93
#define SHIFTC 94
#define LATCHC 95
#define AORB 96
#define ABORC 97
#define KRSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
INTERNAL int parunmodd(const unsigned char llyth);
INTERNAL void dxsmooth(int list[2][C128_MAX], int *indexliste);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CODE128_H */

511
3rdparty/zint-2.10.0/backend/code16k.c vendored Normal file
View File

@@ -0,0 +1,511 @@
/* code16k.c - Handles Code 16k stacked symbology */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* Updated to comply with BS EN 12323:2005 */
/* Code 16k can hold up to 77 characters or 154 numbers */
#include <stdio.h>
#include <assert.h>
#include "common.h"
#include "code128.h"
static const char *C16KTable[107] = {
/* EN 12323 Table 1 - "Code 16K" character encodations */
"212222", "222122", "222221", "121223", "121322", "131222", "122213",
"122312", "132212", "221213", "221312", "231212", "112232", "122132", "122231", "113222",
"123122", "123221", "223211", "221132", "221231", "213212", "223112", "312131", "311222",
"321122", "321221", "312212", "322112", "322211", "212123", "212321", "232121", "111323",
"131123", "131321", "112313", "132113", "132311", "211313", "231113", "231311", "112133",
"112331", "132131", "113123", "113321", "133121", "313121", "211331", "231131", "213113",
"213311", "213131", "311123", "311321", "331121", "312113", "312311", "332111", "314111",
"221411", "431111", "111224", "111422", "121124", "121421", "141122", "141221", "112214",
"112412", "122114", "122411", "142112", "142211", "241211", "221114", "413111", "241112",
"134111", "111242", "121142", "121241", "114212", "124112", "124211", "411212", "421112",
"421211", "212141", "214121", "412121", "111143", "111341", "131141", "114113", "114311",
"411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232",
"211133"
};
static const char *C16KStartStop[8] = {
/* EN 12323 Table 3 and Table 4 - Start patterns and stop patterns */
"3211", "2221", "2122", "1411", "1132", "1231", "1114", "3112"
};
/* EN 12323 Table 5 - Start and stop values defining row numbers */
static const int C16KStartValues[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7
};
static const int C16KStopValues[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3
};
static void c16k_set_a(const unsigned char source, int values[], int *bar_chars) {
if (source > 127) {
if (source < 160) {
values[(*bar_chars)] = source + 64 - 128;
} else {
values[(*bar_chars)] = source - 32 - 128;
}
} else {
if (source < 32) {
values[(*bar_chars)] = source + 64;
} else {
values[(*bar_chars)] = source - 32;
}
}
(*bar_chars)++;
}
static void c16k_set_b(const unsigned char source, int values[], int *bar_chars) {
if (source > 127) {
values[(*bar_chars)] = source - 32 - 128;
} else {
values[(*bar_chars)] = source - 32;
}
(*bar_chars)++;
}
static void c16k_set_c(const unsigned char source_a, unsigned char source_b, int values[], int *bar_chars) {
int weight;
weight = (10 * ctoi(source_a)) + ctoi(source_b);
values[(*bar_chars)] = weight;
(*bar_chars)++;
}
INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int length) {
char width_pattern[100];
int current_row, rows, looper, first_check, second_check;
int indexchaine;
int list[2][C128_MAX] = {{0}};
char set[C128_MAX] = {0}, fset[C128_MAX], mode, last_set, current_set;
int pads_needed, indexliste, i, j, m, read, mx_reader;
int values[C128_MAX] = {0};
int bar_characters;
float glyph_count;
int error_number = 0, first_sum, second_sum;
int input_length;
int gs1, c_count;
int separator;
float min_row_height = 0.0f;
/* Suppresses clang-analyzer-core.UndefinedBinaryOperatorResult warning on fset which is fully set */
assert(length > 0);
strcpy(width_pattern, "");
input_length = length;
if ((symbol->input_mode & 0x07) == GS1_MODE) {
gs1 = 1;
} else {
gs1 = 0;
}
if (input_length > C128_MAX) {
strcpy(symbol->errtxt, "420: Input too long");
return ZINT_ERROR_TOO_LONG;
}
bar_characters = 0;
/* Detect extended ASCII characters */
for (i = 0; i < input_length; i++) {
fset[i] = source[i] >= 128 ? 'f' : ' ';
}
/* Note to be safe not using extended ASCII latch as not mentioned in BS EN 12323:2005 */
/* Detect mode A, B and C characters */
indexliste = 0;
indexchaine = 0;
mode = parunmodd(source[indexchaine]);
do {
list[1][indexliste] = mode;
while ((list[1][indexliste] == mode) && (indexchaine < input_length)) {
list[0][indexliste]++;
indexchaine++;
if (indexchaine == input_length) {
break;
}
mode = parunmodd(source[indexchaine]);
if ((gs1) && (source[indexchaine] == '[')) {
mode = ABORC;
} /* FNC1 */
}
indexliste++;
} while (indexchaine < input_length);
dxsmooth(list, &indexliste);
/* Put set data into set[] */
read = 0;
for (i = 0; i < indexliste; i++) {
for (j = 0; j < list[0][i]; j++) {
switch (list[1][i]) {
case SHIFTA: set[read] = 'a';
break;
case LATCHA: set[read] = 'A';
break;
case SHIFTB: set[read] = 'b';
break;
case LATCHB: set[read] = 'B';
break;
case LATCHC: set[read] = 'C';
break;
}
read++;
}
}
/* Watch out for odd-length Mode C blocks */
c_count = 0;
for (i = 0; i < read; i++) {
if (set[i] == 'C') {
if (source[i] == '[') {
if (c_count & 1) {
if ((i - c_count) != 0) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
}
}
c_count = 0;
} else {
c_count++;
}
} else {
if (c_count & 1) {
if ((i - c_count) != 0) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
}
}
c_count = 0;
}
}
if (c_count & 1) {
if ((i - c_count) != 0) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
}
}
for (i = 1; i < read - 1; i++) {
if ((set[i] == 'C') && ((set[i - 1] == 'B') && (set[i + 1] == 'B'))) {
set[i] = 'B';
}
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Data: %.*s\n", input_length, source);
printf(" Set: %.*s\n", input_length, set);
printf("FSet: %.*s\n", input_length, fset);
}
/* Make sure the data will fit in the symbol */
last_set = set[0];
glyph_count = 0.0f;
for (i = 0; i < input_length; i++) {
if ((set[i] == 'a') || (set[i] == 'b')) {
glyph_count = glyph_count + 1.0f;
}
if (fset[i] == 'f') {
glyph_count = glyph_count + 1.0f;
}
if (((set[i] == 'A') || (set[i] == 'B')) || (set[i] == 'C')) {
if (set[i] != last_set) {
last_set = set[i];
glyph_count = glyph_count + 1.0f;
}
}
if (i == 0) {
if ((set[i] == 'B') && (set[1] == 'C')) {
glyph_count = glyph_count - 1.0f;
}
if ((set[i] == 'B') && (set[1] == 'B')) {
if (set[2] == 'C') {
glyph_count = glyph_count - 1.0f;
}
}
}
if ((set[i] == 'C') && (!((gs1) && (source[i] == '[')))) {
glyph_count = glyph_count + 0.5f;
} else {
glyph_count = glyph_count + 1.0f;
}
}
if ((gs1) && (set[0] != 'A')) {
/* FNC1 can be integrated with mode character */
glyph_count--;
}
if (glyph_count > 77.0f) {
strcpy(symbol->errtxt, "421: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Calculate how tall the symbol will be */
glyph_count = glyph_count + 2.0f;
i = (int)glyph_count;
rows = (i / 5);
if (i % 5 > 0) {
rows++;
}
if (rows == 1) {
rows = 2;
}
/* start with the mode character - Table 2 */
m = 0;
switch (set[0]) {
case 'A': m = 0;
break;
case 'B': m = 1;
break;
case 'C': m = 2;
break;
}
if (symbol->output_options & READER_INIT) {
if (m == 2) {
m = 5;
}
if (gs1) {
strcpy(symbol->errtxt, "422: Cannot use both GS1 mode and Reader Initialisation");
return ZINT_ERROR_INVALID_OPTION;
} else {
if ((set[0] == 'B') && (set[1] == 'C')) {
m = 6;
}
}
values[bar_characters] = (7 * (rows - 2)) + m; /* see 4.3.4.2 */
values[bar_characters + 1] = 96; /* FNC3 */
bar_characters += 2;
} else {
if (gs1) {
/* Integrate FNC1 */
switch (set[0]) {
case 'B': m = 3;
break;
case 'C': m = 4;
break;
}
} else {
if ((set[0] == 'B') && (set[1] == 'C')) {
m = 5;
}
if (((set[0] == 'B') && (set[1] == 'B')) && (set[2] == 'C')) {
m = 6;
}
}
values[bar_characters] = (7 * (rows - 2)) + m; /* see 4.3.4.2 */
bar_characters++;
}
current_set = set[0];
read = 0;
/* Encode the data */
do {
if ((read != 0) && (set[read] != set[read - 1])) {
/* Latch different code set */
switch (set[read]) {
case 'A':
values[bar_characters] = 101;
bar_characters++;
current_set = 'A';
break;
case 'B':
values[bar_characters] = 100;
bar_characters++;
current_set = 'B';
break;
case 'C':
if (!((read == 1) && (set[0] == 'B'))) {
/* Not Mode C/Shift B */
if (!((read == 2) && ((set[0] == 'B') && (set[1] == 'B')))) {
/* Not Mode C/Double Shift B */
values[bar_characters] = 99;
bar_characters++;
}
}
current_set = 'C';
break;
}
}
if (fset[read] == 'f') {
/* Shift extended mode */
switch (current_set) {
case 'A':
values[bar_characters] = 101; /* FNC 4 */
break;
case 'B':
values[bar_characters] = 100; /* FNC 4 */
break;
}
bar_characters++;
}
if ((set[read] == 'a') || (set[read] == 'b')) {
/* Insert shift character */
values[bar_characters] = 98;
bar_characters++;
}
if (!((gs1) && (source[read] == '['))) {
switch (set[read]) { /* Encode data characters */
case 'A':
case 'a':
c16k_set_a(source[read], values, &bar_characters);
read++;
break;
case 'B':
case 'b':
c16k_set_b(source[read], values, &bar_characters);
read++;
break;
case 'C': c16k_set_c(source[read], source[read + 1], values, &bar_characters);
read += 2;
break;
}
} else {
values[bar_characters] = 102;
bar_characters++;
read++;
}
} while (read < input_length);
pads_needed = 5 - ((bar_characters + 2) % 5);
if (pads_needed == 5) {
pads_needed = 0;
}
if ((bar_characters + pads_needed) < 8) {
pads_needed += 8 - (bar_characters + pads_needed);
}
for (i = 0; i < pads_needed; i++) {
values[bar_characters] = 103;
bar_characters++;
}
/* Calculate check digits */
first_sum = 0;
second_sum = 0;
for (i = 0; i < bar_characters; i++) {
first_sum += (i + 2) * values[i];
second_sum += (i + 1) * values[i];
}
first_check = first_sum % 107;
second_sum += first_check * (bar_characters + 1);
second_check = second_sum % 107;
values[bar_characters] = first_check;
values[bar_characters + 1] = second_check;
bar_characters += 2;
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Codewords:");
for (i = 0; i < bar_characters; i++) {
printf(" %d", values[i]);
}
printf("\n");
}
#ifdef ZINT_TEST
if (symbol->debug & ZINT_DEBUG_TEST) {
debug_test_codeword_dump_int(symbol, values, bar_characters); /* Missing row start/stop */
}
#endif
for (current_row = 0; current_row < rows; current_row++) {
int writer;
int flip_flop;
int len;
strcpy(width_pattern, "");
strcat(width_pattern, C16KStartStop[C16KStartValues[current_row]]);
strcat(width_pattern, "1");
for (i = 0; i < 5; i++) {
strcat(width_pattern, C16KTable[values[(current_row * 5) + i]]);
}
strcat(width_pattern, C16KStartStop[C16KStopValues[current_row]]);
/* Write the information into the symbol */
writer = 0;
flip_flop = 1;
for (mx_reader = 0, len = (int) strlen(width_pattern); mx_reader < len; mx_reader++) {
for (looper = 0; looper < ctoi(width_pattern[mx_reader]); looper++) {
if (flip_flop == 1) {
set_module(symbol, current_row, writer);
writer++;
} else {
writer++;
}
}
if (flip_flop == 0) {
flip_flop = 1;
} else {
flip_flop = 0;
}
}
}
symbol->rows = rows;
symbol->width = 70;
#ifdef COMPLIANT_HEIGHTS
separator = symbol->option_3 >= 1 && symbol->option_3 <= 4 ? symbol->option_3 : 1;
/* BS EN 12323:2005 Section 4.5 (d) minimum 8X; use 10 * rows as default for back-compatibility */
min_row_height = 8.0f + separator;
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void)&separator;
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
symbol->output_options |= BARCODE_BIND;
if (symbol->border_width == 0) { /* Allow override if non-zero */
symbol->border_width = 1; /* BS EN 12323:2005 Section 4.3.7 minimum (note change from previous default 2) */
}
return error_number;
}

372
3rdparty/zint-2.10.0/backend/code49.c vendored Normal file
View File

@@ -0,0 +1,372 @@
/* code49.c - Handles Code 49 */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include "common.h"
#include "code49.h"
#define INSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%!&*"
/* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */
INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, j, rows, M, x_count, y_count, z_count, posn_val, local_value;
char intermediate[170] = "";
int codewords[170], codeword_count;
int c_grid[8][8]; /* Refers to table 3 */
int w_grid[8][4]; /* Refets to table 2 */
int pad_count = 0;
char pattern[80];
int gs1;
int h, len;
int separator;
float min_row_height = 0.0f;
int error_number = 0;
if (length > 81) {
strcpy(symbol->errtxt, "430: Input too long (81 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
if ((symbol->input_mode & 0x07) == GS1_MODE) {
gs1 = 1;
strcpy(intermediate, "*"); /* FNC1 */
} else {
gs1 = 0;
}
for (i = 0; i < length; i++) {
if (source[i] > 127) {
strcpy(symbol->errtxt, "431: Invalid character in input data, extended ASCII not allowed");
return ZINT_ERROR_INVALID_DATA;
}
if (gs1 && (source[i] == '['))
strcat(intermediate, "*"); /* FNC1 */
else
strcat(intermediate, c49_table7[source[i]]);
}
codeword_count = 0;
i = 0;
h = (int) strlen(intermediate);
do {
if ((intermediate[i] >= '0') && (intermediate[i] <= '9')) {
/* Numeric data */
for (j = 0; (intermediate[i + j] >= '0') && (intermediate[i + j] <= '9'); j++);
if (j >= 5) {
/* Use Numeric Encodation Method */
int block_count, c;
int block_remain;
int block_value;
codewords[codeword_count] = 48; /* Numeric Shift */
codeword_count++;
block_count = j / 5;
block_remain = j % 5;
for (c = 0; c < block_count; c++) {
if ((c == block_count - 1) && (block_remain == 2)) {
/* Rule (d) */
block_value = 100000;
block_value += ctoi(intermediate[i]) * 1000;
block_value += ctoi(intermediate[i + 1]) * 100;
block_value += ctoi(intermediate[i + 2]) * 10;
block_value += ctoi(intermediate[i + 3]);
codewords[codeword_count] = block_value / (48 * 48);
block_value = block_value - (48 * 48) * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 4;
block_value = ctoi(intermediate[i]) * 100;
block_value += ctoi(intermediate[i + 1]) * 10;
block_value += ctoi(intermediate[i + 2]);
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 3;
} else {
block_value = ctoi(intermediate[i]) * 10000;
block_value += ctoi(intermediate[i + 1]) * 1000;
block_value += ctoi(intermediate[i + 2]) * 100;
block_value += ctoi(intermediate[i + 3]) * 10;
block_value += ctoi(intermediate[i + 4]);
codewords[codeword_count] = block_value / (48 * 48);
block_value = block_value - (48 * 48) * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 5;
}
}
switch (block_remain) {
case 1:
/* Rule (a) */
codewords[codeword_count] = posn(INSET, intermediate[i]);
codeword_count++;
i++;
break;
case 3:
/* Rule (b) */
block_value = ctoi(intermediate[i]) * 100;
block_value += ctoi(intermediate[i + 1]) * 10;
block_value += ctoi(intermediate[i + 2]);
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 3;
break;
case 4:
/* Rule (c) */
block_value = 100000;
block_value += ctoi(intermediate[i]) * 1000;
block_value += ctoi(intermediate[i + 1]) * 100;
block_value += ctoi(intermediate[i + 2]) * 10;
block_value += ctoi(intermediate[i + 3]);
codewords[codeword_count] = block_value / (48 * 48);
block_value = block_value - (48 * 48) * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 4;
break;
}
if (i < h) {
/* There is more to add */
codewords[codeword_count] = 48; /* Numeric Shift */
codeword_count++;
}
} else {
codewords[codeword_count] = posn(INSET, intermediate[i]);
codeword_count++;
i++;
}
} else {
codewords[codeword_count] = posn(INSET, intermediate[i]);
codeword_count++;
i++;
}
} while (i < h);
switch (codewords[0]) {
/* Set starting mode value */
case 48: M = 2;
break;
case 43: M = 4;
break;
case 44: M = 5;
break;
default: M = 0;
break;
}
if (M != 0) {
codeword_count--;
for (i = 0; i < codeword_count; i++) {
codewords[i] = codewords[i + 1];
}
}
if (codeword_count > 49) {
strcpy(symbol->errtxt, "432: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Place codewords in code character array (c grid) */
rows = 0;
do {
for (i = 0; i < 7; i++) {
if (((rows * 7) + i) < codeword_count) {
c_grid[rows][i] = codewords[(rows * 7) + i];
} else {
c_grid[rows][i] = 48; /* Pad */
pad_count++;
}
}
rows++;
} while ((rows * 7) < codeword_count);
if ((((rows <= 6) && (pad_count < 5))) || (rows > 6) || (rows == 1)) {
/* Add a row */
for (i = 0; i < 7; i++) {
c_grid[rows][i] = 48; /* Pad */
}
rows++;
}
/* Add row count and mode character */
c_grid[rows - 1][6] = (7 * (rows - 2)) + M;
/* Add row check character */
for (i = 0; i < rows - 1; i++) {
int row_sum = 0;
for (j = 0; j < 7; j++) {
row_sum += c_grid[i][j];
}
c_grid[i][7] = row_sum % 49;
}
/* Calculate Symbol Check Characters */
posn_val = 0;
x_count = c_grid[rows - 1][6] * 20;
y_count = c_grid[rows - 1][6] * 16;
z_count = c_grid[rows - 1][6] * 38;
for (i = 0; i < rows - 1; i++) {
for (j = 0; j < 4; j++) {
local_value = (c_grid[i][2 * j] * 49) + c_grid[i][(2 * j) + 1];
x_count += c49_x_weight[posn_val] * local_value;
y_count += c49_y_weight[posn_val] * local_value;
z_count += c49_z_weight[posn_val] * local_value;
posn_val++;
}
}
if (rows > 6) {
/* Add Z Symbol Check */
c_grid[rows - 1][0] = (z_count % 2401) / 49;
c_grid[rows - 1][1] = (z_count % 2401) % 49;
}
local_value = (c_grid[rows - 1][0] * 49) + c_grid[rows - 1][1];
x_count += c49_x_weight[posn_val] * local_value;
y_count += c49_y_weight[posn_val] * local_value;
posn_val++;
/* Add Y Symbol Check */
c_grid[rows - 1][2] = (y_count % 2401) / 49;
c_grid[rows - 1][3] = (y_count % 2401) % 49;
local_value = (c_grid[rows - 1][2] * 49) + c_grid[rows - 1][3];
x_count += c49_x_weight[posn_val] * local_value;
/* Add X Symbol Check */
c_grid[rows - 1][4] = (x_count % 2401) / 49;
c_grid[rows - 1][5] = (x_count % 2401) % 49;
/* Add last row check character */
j = 0;
for (i = 0; i < 7; i++) {
j += c_grid[rows - 1][i];
}
c_grid[rows - 1][7] = j % 49;
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Codewords:\n");
for (i = 0; i < rows; i++) {
for (j = 0; j < 8; j++) {
printf(" %2d", c_grid[i][j]);
}
printf("\n");
}
}
#ifdef ZINT_TEST
if (symbol->debug & ZINT_DEBUG_TEST) {
debug_test_codeword_dump_int(symbol, (int *)c_grid, rows * 8);
}
#endif
/* Transfer data to symbol character array (w grid) */
for (i = 0; i < rows; i++) {
for (j = 0; j < 4; j++) {
w_grid[i][j] = (c_grid[i][2 * j] * 49) + c_grid[i][(2 * j) + 1];
}
}
for (i = 0; i < rows; i++) {
strcpy(pattern, "10"); /* Start character */
for (j = 0; j < 4; j++) {
if (i != (rows - 1)) {
if (c49_table4[i][j] == 'E') {
/* Even Parity */
bin_append(c49_even_bitpattern[w_grid[i][j]], 16, pattern);
} else {
/* Odd Parity */
bin_append(c49_odd_bitpattern[w_grid[i][j]], 16, pattern);
}
} else {
/* Last row uses all even parity */
bin_append(c49_even_bitpattern[w_grid[i][j]], 16, pattern);
}
}
strcat(pattern, "1111"); /* Stop character */
/* Expand into symbol */
for (j = 0, len = (int) strlen(pattern); j < len; j++) {
if (pattern[j] == '1') {
set_module(symbol, i, j);
}
}
}
symbol->rows = rows;
symbol->width = (int) strlen(pattern);
#ifdef COMPLIANT_HEIGHTS
separator = symbol->option_3 >= 1 && symbol->option_3 <= 4 ? symbol->option_3 : 1;
/* ANSI/AIM BC6-2000 Section 2.6 minimum 8X; use 10 * rows as default for back-compatibility */
min_row_height = 8.0f + separator;
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void)&separator;
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
symbol->output_options |= BARCODE_BIND;
if (symbol->border_width == 0) { /* Allow override if non-zero */
symbol->border_width = 1; /* ANSI/AIM BC6-2000 Section 2.1 (note change from previous default 2) */
}
return error_number;
}

558
3rdparty/zint-2.10.0/backend/code49.h vendored Normal file
View File

@@ -0,0 +1,558 @@
/* code49.h - Code 49 Tables */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* This data set taken from ANSI/AIM-BC6-2000, 4th April 2000 */
static const char *c49_table7[128] = {
/* Table 7: Code 49 ASCII Chart */
"! ", "!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",
"!Z", "!1", "!2", "!3", "!4", "!5", " ", "!6", "!7", "!8", "$", "%", "!9", "!0",
"!-", "!.", "!$", "+", "!/", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "!+", "&1", "&2", "&3", "&4", "&5", "&6", "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", "Z", "&7", "&8", "&9", "&0", "&-", "&.", "&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", "&Z", "&$", "&/", "&+",
"&%", "& "
};
/* Table 5: Check Character Weighting Values */
static const char c49_x_weight[] = {
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
};
static const char c49_y_weight[] = {
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
};
static const char c49_z_weight[] = {
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
};
static const char *c49_table4[8] = {
/* Table 4: Row Parity Pattern for Code 49 Symbols */
"OEEO", "EOEO", "OOEE", "EEOO", "OEOE", "EOOE", "OOOO", "EEEE"
};
static const unsigned short int c49_even_bitpattern[] = {
/* Appendix E - Code 49 Encodation Patterns (Even Symbol Character Parity) */
0xBE5C, 0xC16E, 0x86DC, 0xC126, 0x864C, 0x9EDC, 0xC726, 0x9E4C, 0xDF26, 0x82CC,
0x8244, 0x8ECC, 0xC322, 0x8E44, 0xBECC, 0xCF22, 0xBE44, 0xC162, 0x86C4, 0xC762,
0x9EC4, 0xDF62, 0x812E, 0x872E, 0x9F2E, 0x836E, 0x8326, 0x8F6E, 0x8F26, 0xBF6E,
0x8166, 0x8122, 0x8766, 0x8722, 0x9F66, 0x9F22, 0x8362, 0x8F62, 0xBF62, 0xA2E0,
0xE8B8, 0xFA2E, 0xD370, 0xF4DC, 0xD130, 0xF44C, 0xAEE0, 0xEBB8, 0xFAEE, 0xA660,
0xE998, 0xFA66, 0xA220, 0xE888, 0xFA22, 0xD730, 0xF5CC, 0xD310, 0xF4C4, 0xAE20,
0xEB88, 0xFAE2, 0x9170, 0xE45C, 0xD8B8, 0xF62E, 0xC9B8, 0xF26E, 0xB370, 0xC898,
0xF226, 0xB130, 0xEC4C, 0x9770, 0xE5DC, 0x9330, 0xE4CC, 0x9110, 0xE444, 0xD888,
0xF622, 0xCB98, 0xF2E6, 0xB730, 0xC988, 0xF262, 0xB310, 0xECC4, 0x9710, 0xE5C4,
0xDB88, 0xF6E2, 0x88B8, 0xE22E, 0xCC5C, 0xB8B8, 0xEE2E, 0xC4DC, 0x99B8, 0xC44C,
0x9898, 0xE626, 0xDC4C, 0x8BB8, 0xE2EE, 0x8998, 0xE266, 0xBBB8, 0x8888, 0xE222,
0xB998, 0xCC44, 0xB888, 0xEE22, 0xC5CC, 0x9B98, 0xC4C4, 0x9988, 0xE662, 0xDCC4,
0x8B88, 0xE2E2, 0xCDC4, 0xBB88, 0xEEE2, 0x845C, 0xC62E, 0x9C5C, 0xDE2E, 0xC26E,
0x8CDC, 0xC226, 0x8C4C, 0xBCDC, 0xCE26, 0xBC4C, 0x85DC, 0x84CC, 0x9DDC, 0x8444,
0x9CCC, 0xC622, 0x9C44, 0xDE22, 0xC2E6, 0x8DCC, 0xC262, 0x8CC4, 0xBDCC, 0xCE62,
0xBCC4, 0x85C4, 0xC6E2, 0x9DC4, 0xDEE2, 0x822E, 0x8E2E, 0x866E, 0x8626, 0x9E6E,
0x9E26, 0x82EE, 0x8266, 0x8EEE, 0x8222, 0x8E66, 0xBEEE, 0x8E22, 0xBE66, 0x86E6,
0x8662, 0x9EE6, 0x9E62, 0x82E2, 0x8EE2, 0xBEE2, 0xA170, 0xE85C, 0xD1B8, 0xF46E,
0xD098, 0xF426, 0xA770, 0xE9DC, 0xA330, 0xE8CC, 0xA110, 0xE844, 0xD7B8, 0xF5EE,
0xD398, 0xF4E6, 0xD188, 0xF462, 0xAF30, 0xEBCC, 0xA710, 0xE9C4, 0xD788, 0xF5E2,
0x90B8, 0xE42E, 0xD85C, 0xC8DC, 0xB1B8, 0xC84C, 0xB098, 0xEC26, 0x93B8, 0xE4EE,
0x9198, 0xE466, 0x9088, 0xE422, 0xD844, 0xCBDC, 0xB7B8, 0xC9CC, 0xB398, 0xC8C4,
0xB188, 0xEC62, 0x9798, 0xE5E6, 0x9388, 0xE4E2, 0xD9C4, 0xCBC4, 0xB788, 0xEDE2,
0x885C, 0xCC2E, 0xB85C, 0xC46E, 0x98DC, 0xC426, 0x984C, 0xDC26, 0x89DC, 0x88CC,
0xB9DC, 0x8844, 0xB8CC, 0xCC22, 0xB844, 0xC5EE, 0x9BDC, 0xC4E6, 0x99CC, 0xC462,
0x98C4, 0xDC62, 0x8BCC, 0x89C4, 0xBBCC, 0xCCE2, 0xB9C4, 0xC5E2, 0x9BC4, 0xDDE2,
0x842E, 0x9C2E, 0x8C6E, 0x8C26, 0xBC6E, 0x84EE, 0x8466, 0x9CEE, 0x8422, 0x9C66,
0x9C22, 0x8DEE, 0x8CE6, 0xBDEE, 0x8C62, 0xBCE6, 0xBC62, 0x85E6, 0x84E2, 0x9DE6,
0x9CE2, 0x8DE2, 0xBDE2, 0xA0B8, 0xE82E, 0xD0DC, 0xD04C, 0xA3B8, 0xE8EE, 0xA198,
0xE866, 0xA088, 0xE822, 0xD3DC, 0xD1CC, 0xD0C4, 0xAFB8, 0xEBEE, 0xA798, 0xE9E6,
0xA388, 0xE8E2, 0xD7CC, 0xD3C4, 0x905C, 0xD82E, 0xC86E, 0xB0DC, 0xC826, 0xB04C,
0x91DC, 0x90CC, 0x9044, 0xD822, 0xC9EE, 0xB3DC, 0xC8E6, 0xB1CC, 0xC862, 0xB0C4,
0x97DC, 0x93CC, 0x91C4, 0xD8E2, 0xCBE6, 0xB7CC, 0xC9E2, 0xB3C4, 0x882E, 0x986E,
0x9826, 0x88EE, 0x8866, 0xB8EE, 0x8822, 0xB866, 0x99EE, 0x98E6, 0x9862, 0x8BEE,
0x89E6, 0xBBEE, 0x88E2, 0xB9E6, 0xB8E2, 0x9BE6, 0x99E2, 0xA05C, 0xD06E, 0xD026,
0xA1DC, 0xA0CC, 0xA044, 0xD1EE, 0xD0E6, 0xD062, 0xA7DC, 0xA3CC, 0xA1C4, 0xD7EE,
0xD3E6, 0xD1E2, 0x902E, 0xB06E, 0x90EE, 0x9066, 0x9022, 0xB1EE, 0xB0E6, 0xB062,
0x93EE, 0x91E6, 0x90E2, 0xB7EE, 0xB3E6, 0xB1E2, 0xA9C0, 0xEA70, 0xFA9C, 0xD460,
0xF518, 0xFD46, 0xA840, 0xEA10, 0xFA84, 0xED78, 0xFB5E, 0x94E0, 0xE538, 0xF94E,
0xDA70, 0xF69C, 0xCA30, 0xF28C, 0xB460, 0xED18, 0xFB46, 0x9420, 0xE508, 0xF942,
0xDA10, 0xF684, 0x9AF0, 0xE6BC, 0xDD78, 0xF75E, 0x8A70, 0xE29C, 0xCD38, 0xF34E,
0xBA70, 0xEE9C, 0xC518, 0xF146, 0x9A30, 0xE68C, 0xDD18, 0xF746, 0x8A10, 0xE284,
0xCD08, 0xF342, 0xBA10, 0xEE84, 0x8D78, 0xE35E, 0xCEBC, 0xBD78, 0xEF5E, 0x8538,
0xE14E, 0xC69C, 0x9D38, 0xE74E, 0xDE9C, 0xC28C, 0x8D18, 0xE346, 0xCE8C, 0xBD18,
0xEF46, 0x8508, 0xE142, 0xC684, 0x9D08, 0xE742, 0xDE84, 0x86BC, 0xC75E, 0x9EBC,
0xDF5E, 0x829C, 0xC34E, 0x8E9C, 0xCF4E, 0xBE9C, 0xC146, 0x868C, 0xC746, 0x9E8C,
0xDF46, 0x8284, 0xC342, 0x8E84, 0xCF42, 0xBE84, 0x835E, 0x8F5E, 0xBF5E, 0x814E,
0x874E, 0x9F4E, 0x8346, 0x8F46, 0xBF46, 0x8142, 0x8742, 0x9F42, 0xD2F0, 0xF4BC,
0xADE0, 0xEB78, 0xFADE, 0xA4E0, 0xE938, 0xFA4E, 0xD670, 0xF59C, 0xD230, 0xF48C,
0xAC60, 0xEB18, 0xFAC6, 0xA420, 0xE908, 0xFA42, 0xD610, 0xF584, 0xC978, 0xF25E,
0xB2F0, 0xECBC, 0x96F0, 0xE5BC, 0x9270, 0xE49C, 0xD938, 0xF64E, 0xCB38, 0xF2CE,
0xB670, 0xC918, 0xF246, 0xB230, 0xEC8C, 0x9630, 0xE58C, 0x9210, 0xE484, 0xD908,
0xF642, 0xCB08, 0xF2C2, 0xB610, 0xED84, 0xC4BC, 0x9978, 0xE65E, 0xDCBC, 0x8B78,
0xE2DE, 0x8938, 0xE24E, 0xBB78, 0xCC9C, 0xB938, 0xEE4E, 0xC59C, 0x9B38, 0xC48C,
0x9918, 0xE646, 0xDC8C, 0x8B18, 0xE2C6, 0x8908, 0xE242, 0xBB18, 0xCC84, 0xB908,
0xEE42, 0xC584, 0x9B08, 0xE6C2, 0xDD84, 0xC25E, 0x8CBC, 0xCE5E, 0xBCBC, 0x85BC,
0x849C, 0x9DBC, 0xC64E, 0x9C9C, 0xDE4E, 0xC2CE, 0x8D9C, 0xC246, 0x8C8C, 0xBD9C,
0xCE46, 0xBC8C, 0x858C, 0x8484, 0x9D8C, 0xC642, 0x9C84, 0xDE42, 0xC2C2, 0x8D84,
0xCEC2, 0xBD84, 0x865E, 0x9E5E, 0x82DE, 0x824E, 0x8EDE, 0x8E4E, 0xBEDE, 0xBE4E,
0x86CE, 0x8646, 0x9ECE, 0x9E46, 0x82C6, 0x8242, 0x8EC6, 0x8E42, 0xBEC6, 0xBE42,
0x86C2, 0x9EC2, 0xD178, 0xF45E, 0xA6F0, 0xE9BC, 0xA270, 0xE89C, 0xD778, 0xF5DE,
0xD338, 0xF4CE, 0xD118, 0xF446, 0xAE70, 0xEB9C, 0xA630, 0xE98C, 0xA210, 0xE884,
0xD718, 0xF5C6, 0xD308, 0xF4C2, 0xAE10, 0xEB84, 0xC8BC, 0xB178, 0xEC5E, 0x9378,
0xE4DE, 0x9138, 0xE44E, 0xD89C, 0xCBBC, 0xB778, 0xC99C, 0xB338, 0xC88C, 0xB118,
0xEC46, 0x9738, 0xE5CE, 0x9318, 0xE4C6, 0x9108, 0xE442, 0xD884, 0xCB8C, 0xB718,
0xC984, 0xB308, 0xECC2, 0x9708, 0xE5C2, 0xDB84, 0xC45E, 0x98BC, 0xDC5E, 0x89BC,
0x889C, 0xB9BC, 0xCC4E, 0xB89C, 0xC5DE, 0x9BBC, 0xC4CE, 0x999C, 0xC446, 0x988C,
0xDC46, 0x8B9C, 0x898C, 0xBB9C, 0x8884, 0xB98C, 0xCC42, 0xB884, 0xC5C6, 0x9B8C,
0xC4C2, 0x9984, 0xDCC2, 0x8B84, 0xCDC2, 0xBB84, 0x8C5E, 0xBC5E, 0x84DE, 0x844E,
0x9CDE, 0x9C4E, 0x8DDE, 0x8CCE, 0xBDDE, 0x8C46, 0xBCCE, 0xBC46, 0x85CE, 0x84C6,
0x9DCE, 0x8442, 0x9CC6, 0x9C42, 0x8DC6, 0x8CC2, 0xBDC6, 0xBCC2, 0x85C2, 0x9DC2,
0xD0BC, 0xA378, 0xE8DE, 0xA138, 0xE84E, 0xD3BC, 0xD19C, 0xD08C, 0xAF78, 0xEBDE,
0xA738, 0xE9CE, 0xA318, 0xE8C6, 0xA108, 0xE842, 0xD79C, 0xD38C, 0xD184, 0xAF18,
0xEBC6, 0xA708, 0xE9C2, 0xC85E, 0xB0BC, 0x91BC, 0x909C, 0xD84E, 0xC9DE, 0xB3BC,
0xC8CE, 0xB19C, 0xC846, 0xB08C, 0x97BC, 0x939C, 0x918C, 0x9084, 0xD842, 0xCBCE,
0xB79C, 0xC9C6, 0xB38C, 0xC8C2, 0xB184, 0x978C, 0x9384, 0xD9C2, 0x985E, 0x88DE,
0x884E, 0xB8DE, 0xB84E, 0x99DE, 0x98CE, 0x9846, 0x8BDE, 0x89CE, 0xBBDE, 0x88C6,
0xB9CE, 0x8842, 0xB8C6, 0xB842, 0x9BCE, 0x99C6, 0x98C2, 0x8BC6, 0x89C2, 0xBBC6,
0xB9C2, 0xD05E, 0xA1BC, 0xA09C, 0xD1DE, 0xD0CE, 0xD046, 0xA7BC, 0xA39C, 0xA18C,
0xA084, 0xD7DE, 0xD3CE, 0xD1C6, 0xD0C2, 0xAF9C, 0xA78C, 0xA384, 0xB05E, 0x90DE,
0x904E, 0xB1DE, 0xB0CE, 0xB046, 0x93DE, 0x91CE, 0x90C6, 0x9042, 0xB7DE, 0xB3CE,
0xB1C6, 0xB0C2, 0x97CE, 0x93C6, 0x91C2, 0xA0DE, 0xA04E, 0xA3DE, 0xA1CE, 0xA0C6,
0xA042, 0xAFDE, 0xA7CE, 0xA3C6, 0xA1C2, 0xD4F0, 0xF53C, 0xA8E0, 0xEA38, 0xFA8E,
0xD430, 0xF50C, 0xA820, 0xEA08, 0xFA82, 0xDAF8, 0xF6BE, 0xCA78, 0xF29E, 0xB4F0,
0xED3C, 0x9470, 0xE51C, 0xDA38, 0xF68E, 0xCA18, 0xF286, 0xB430, 0xED0C, 0x9410,
0xE504, 0xDA08, 0xF682, 0xCD7C, 0xBAF8, 0xEEBE, 0xC53C, 0x9A78, 0xE69E, 0xDD3C,
0x8A38, 0xE28E, 0xCD1C, 0xBA38, 0xEE8E, 0xC50C, 0x9A18, 0xE686, 0xDD0C, 0x8A08,
0xE282, 0xCD04, 0xBA08, 0xEE82, 0xC6BE, 0x9D7C, 0xDEBE, 0xC29E, 0x8D3C, 0xCE9E,
0xBD3C, 0x851C, 0xC68E, 0x9D1C, 0xDE8E, 0xC286, 0x8D0C, 0xCE86, 0xBD0C, 0x8504,
0xC682, 0x9D04, 0xDE82, 0x8EBE, 0xBEBE, 0x869E, 0x9E9E, 0x828E, 0x8E8E, 0xBE8E,
0x8686, 0x9E86, 0x8282, 0x8E82, 0xBE82, 0xE97C, 0xD6F8, 0xF5BE, 0xD278, 0xF49E,
0xACF0, 0xEB3C, 0xA470, 0xE91C, 0xD638, 0xF58E, 0xD218, 0xF486, 0xAC30, 0xEB0C,
0xA410, 0xE904, 0xD608, 0xF582, 0x92F8, 0xE4BE, 0xD97C, 0xCB7C, 0xB6F8, 0xC93C,
0xB278, 0xEC9E, 0x9678, 0xE59E, 0x9238, 0xE48E, 0xD91C, 0xCB1C, 0xB638, 0xC90C,
0xB218, 0xEC86, 0x9618, 0xE586, 0x9208, 0xE482, 0xD904, 0xCB04, 0xB608, 0xED82,
0x897C, 0xCCBE, 0xB97C, 0xC5BE, 0x9B7C, 0xC49E, 0x993C, 0xDC9E, 0x8B3C, 0x891C,
0xBB3C, 0xCC8E, 0xB91C, 0xC58E, 0x9B1C, 0xC486, 0x990C, 0xDC86, 0x8B0C, 0x8904,
0xBB0C, 0xCC82, 0xB904, 0xC582, 0x9B04, 0xDD82, 0x84BE, 0x9CBE, 0x8DBE, 0x8C9E,
0xBDBE, 0xBC9E, 0x859E, 0x848E, 0x9D9E, 0x9C8E, 0x8D8E, 0x8C86, 0xBD8E, 0xBC86,
0x8586, 0x8482, 0x9D86, 0x9C82, 0x8D82, 0xBD82, 0xA2F8, 0xE8BE, 0xD37C, 0xD13C,
0xAEF8, 0xEBBE, 0xA678, 0xE99E, 0xA238, 0xE88E, 0xD73C, 0xD31C, 0xD10C, 0xAE38,
0xEB8E, 0xA618, 0xE986, 0xA208, 0xE882, 0xD70C, 0xD304, 0x917C, 0xD8BE, 0xC9BE,
0xB37C, 0xC89E, 0xB13C, 0x977C, 0x933C, 0x911C, 0xD88E, 0xCB9E, 0xB73C, 0xC98E,
0xB31C, 0xC886, 0xB10C, 0x971C, 0x930C, 0x9104, 0xD882, 0xCB86, 0xB70C, 0xC982,
0xB304, 0x88BE, 0xB8BE, 0x99BE, 0x989E, 0x8BBE, 0x899E, 0xBBBE, 0x888E, 0xB99E,
0xB88E, 0x9B9E, 0x998E, 0x9886, 0x8B8E, 0x8986, 0xBB8E, 0x8882, 0xB986, 0xB882,
0x9B86, 0x9982, 0xA17C, 0xD1BE, 0xD09E, 0xA77C, 0xA33C, 0xA11C, 0xD7BE, 0xD39E,
0xD18E, 0xD086, 0xAF3C, 0xA71C, 0xA30C, 0xA104, 0xD78E, 0xD386, 0xD182, 0x90BE,
0xB1BE, 0xB09E, 0x93BE, 0x919E, 0x908E, 0xB7BE, 0xB39E, 0xB18E, 0xB086, 0x979E,
0x938E, 0x9186, 0x9082, 0xB78E, 0xB386, 0xB182, 0xA0BE, 0xA3BE, 0xA19E, 0xA08E,
0xAFBE, 0xA79E, 0xA38E, 0xA186, 0xA082, 0xA9F0, 0xEA7C, 0xD478, 0xF51E, 0xA870,
0xEA1C, 0xD418, 0xF506, 0xA810, 0xEA04, 0xED7E, 0x94F8, 0xE53E, 0xDA7C, 0xCA3C,
0xB478, 0xED1E, 0x9438, 0xE50E, 0xDA1C, 0xCA0C, 0xB418, 0xED06, 0x9408, 0xE502,
0xDA04, 0x9AFC, 0xDD7E, 0x8A7C, 0xCD3E, 0xBA7C, 0xC51E, 0x9A3C, 0xDD1E, 0x8A1C,
0xCD0E, 0xBA1C, 0xC506, 0x9A0C, 0xDD06, 0x8A04, 0xCD02, 0xBA04, 0x8D7E, 0xBD7E,
0x853E, 0x9D3E, 0x8D1E, 0xBD1E, 0x850E, 0x9D0E, 0x8D06, 0xBD06, 0x8502, 0x9D02,
0xD2FC, 0xADF8, 0xEB7E, 0xA4F8, 0xE93E, 0xD67C, 0xD23C, 0xAC78, 0xEB1E, 0xA438,
0xE90E, 0xD61C, 0xD20C, 0xAC18, 0xEB06, 0xA408, 0xE902, 0xC97E, 0xB2FC, 0x96FC,
0x927C, 0xD93E, 0xCB3E, 0xB67C, 0xC91E, 0xB23C, 0x963C, 0x921C, 0xD90E, 0xCB0E,
0xB61C, 0xC906, 0xB20C, 0x960C, 0x9204, 0xD902, 0x997E, 0x8B7E, 0x893E, 0xBB7E,
0xB93E, 0xE4A0, 0xF928, 0xD940, 0xF650, 0xFD94, 0xCB40, 0xF2D0, 0xEDA0, 0xFB68,
0x8940, 0xE250, 0xCCA0, 0xF328, 0xB940, 0xEE50, 0xFB94, 0xC5A0, 0xF168, 0x9B40,
0xE6D0, 0xF9B4, 0xDDA0, 0xF768, 0xFDDA, 0x84A0, 0xE128, 0xC650, 0xF194, 0x9CA0,
0xE728, 0xF9CA, 0xDE50, 0xF794, 0xC2D0, 0x8DA0, 0xE368, 0xCED0, 0xF3B4, 0xBDA0,
0xEF68, 0xFBDA, 0x8250, 0xC328, 0x8E50, 0xE394, 0xCF28, 0xF3CA, 0xBE50, 0xEF94,
0xC168, 0x86D0, 0xE1B4, 0xC768, 0xF1DA, 0x9ED0, 0xE7B4, 0xDF68, 0xF7DA, 0x8128,
0xC194, 0x8728, 0xE1CA, 0xC794, 0x9F28, 0xE7CA, 0x8368, 0xC3B4, 0x8F68, 0xE3DA,
0xCFB4, 0xBF68, 0xEFDA, 0xE8A0, 0xFA28, 0xD340, 0xF4D0, 0xFD34, 0xEBA0, 0xFAE8,
0x9140, 0xE450, 0xF914, 0xD8A0, 0xF628, 0xFD8A, 0xC9A0, 0xF268, 0xB340, 0xECD0,
0xFB34, 0x9740, 0xE5D0, 0xF974, 0xDBA0, 0xF6E8, 0xFDBA, 0x88A0, 0xE228, 0xCC50,
0xF314, 0xB8A0, 0xEE28, 0xFB8A, 0xC4D0, 0xF134, 0x99A0, 0xE668, 0xF99A, 0xDCD0,
0xF734, 0x8BA0, 0xE2E8, 0xCDD0, 0xF374, 0xBBA0, 0xEEE8, 0xFBBA, 0x8450, 0xE114,
0xC628, 0xF18A, 0x9C50, 0xE714, 0xDE28, 0xF78A, 0xC268, 0x8CD0, 0xE334, 0xCE68,
0xF39A, 0xBCD0, 0xEF34, 0x85D0, 0xE174, 0xC6E8, 0xF1BA, 0x9DD0, 0xE774, 0xDEE8,
0xF7BA, 0x8228, 0xC314, 0x8E28, 0xE38A, 0xCF14, 0xC134, 0x8668, 0xE19A, 0xC734,
0x9E68, 0xE79A, 0xDF34, 0x82E8, 0xC374, 0x8EE8, 0xE3BA, 0xCF74, 0xBEE8, 0xEFBA,
0x8114, 0xC18A, 0x8714, 0xC78A, 0x8334, 0xC39A, 0x8F34, 0xCF9A, 0x8174, 0xC1BA,
0x8774, 0xC7BA, 0x9F74, 0xDFBA, 0xA140, 0xE850, 0xFA14, 0xD1A0, 0xF468, 0xFD1A,
0xA740, 0xE9D0, 0xFA74, 0xD7A0, 0xF5E8, 0xFD7A, 0x90A0, 0xE428, 0xF90A, 0xD850,
0xF614, 0xC8D0, 0xF234, 0xB1A0, 0xEC68, 0xFB1A, 0x93A0, 0xE4E8, 0xF93A, 0xD9D0,
0xF674, 0xCBD0, 0xF2F4, 0xB7A0, 0xEDE8, 0xFB7A, 0x8850, 0xE214, 0xCC28, 0xF30A,
0xB850, 0xEE14, 0xC468, 0xF11A, 0x98D0, 0xE634, 0xDC68, 0xF71A, 0x89D0, 0xE274,
0xCCE8, 0xF33A, 0xB9D0, 0xEE74, 0xC5E8, 0xF17A, 0x9BD0, 0xE6F4, 0xDDE8, 0xF77A,
0x8428, 0xE10A, 0xC614, 0x9C28, 0xE70A, 0xC234, 0x8C68, 0xE31A, 0xCE34, 0xBC68,
0xEF1A, 0x84E8, 0xE13A, 0xC674, 0x9CE8, 0xE73A, 0xDE74, 0xC2F4, 0x8DE8, 0xE37A,
0xCEF4, 0xBDE8, 0xEF7A, 0x8214, 0xC30A, 0x8E14, 0xC11A, 0x8634, 0xC71A, 0x9E34,
0x8274, 0xC33A, 0x8E74, 0xCF3A, 0xBE74, 0xC17A, 0x86F4, 0xC77A, 0x9EF4, 0xDF7A,
0x810A, 0x870A, 0x831A, 0x8F1A, 0x813A, 0x873A, 0x9F3A, 0x837A, 0x8F7A, 0xBF7A,
0xA0A0, 0xE828, 0xFA0A, 0xD0D0, 0xF434, 0xA3A0, 0xE8E8, 0xFA3A, 0xD3D0, 0xF4F4,
0xAFA0, 0xEBE8, 0xFAFA, 0x9050, 0xE414, 0xD828, 0xF60A, 0xC868, 0xF21A, 0xB0D0,
0xEC34, 0x91D0, 0xE474, 0xD8E8, 0xF63A, 0xC9E8, 0xF27A, 0xB3D0, 0xECF4, 0x97D0,
0xE5F4, 0xDBE8, 0xF6FA, 0x8828, 0xE20A, 0xCC14, 0xC434, 0x9868, 0xE61A, 0xDC34,
0x88E8, 0xE23A, 0xCC74, 0xB8E8, 0xEE3A, 0xC4F4, 0x99E8, 0xE67A, 0xDCF4, 0x8BE8,
0xE2FA, 0xCDF4, 0xBBE8, 0xEEFA, 0x8414, 0xC60A, 0xC21A, 0x8C34, 0xCE1A, 0x8474,
0xC63A, 0x9C74, 0xDE3A, 0xC27A, 0x8CF4, 0xCE7A, 0xBCF4, 0x85F4, 0xC6FA, 0x9DF4,
0xDEFA, 0x820A, 0x861A, 0x823A, 0x8E3A, 0x867A, 0x9E7A, 0x82FA, 0x8EFA, 0xBEFA,
0xA050, 0xE814, 0xD068, 0xF41A, 0xA1D0, 0xE874, 0xD1E8, 0xF47A, 0xA7D0, 0xE9F4,
0xD7E8, 0xF5FA, 0x9028, 0xE40A, 0xC834, 0xB068, 0xEC1A, 0x90E8, 0xE43A, 0xD874,
0xC8F4, 0xB1E8, 0xEC7A, 0x93E8, 0xE4FA, 0xD9F4, 0xCBF4, 0xB7E8, 0xEDFA, 0x8814,
0xC41A, 0x9834, 0x8874, 0xCC3A, 0xB874, 0xC47A, 0x98F4, 0xDC7A, 0x89F4, 0xCCFA,
0xB9F4, 0xC5FA, 0x9BF4, 0xDDFA, 0x840A, 0x8C1A, 0x843A, 0x9C3A, 0x8C7A, 0xBC7A,
0x84FA, 0x9CFA, 0x8DFA, 0xBDFA, 0xEA40, 0xFA90, 0xED60, 0xFB58, 0xE520, 0xF948,
0xDA40, 0xF690, 0xFDA4, 0x9AC0, 0xE6B0, 0xF9AC, 0xDD60, 0xF758, 0xFDD6, 0x8A40,
0xE290, 0xCD20, 0xF348, 0xBA40, 0xEE90, 0xFBA4, 0x8D60, 0xE358, 0xCEB0, 0xF3AC,
0xBD60, 0xEF58, 0xFBD6, 0x8520, 0xE148, 0xC690, 0xF1A4, 0x9D20, 0xE748, 0xF9D2,
0xDE90, 0xF7A4, 0x86B0, 0xE1AC, 0xC758, 0xF1D6, 0x9EB0, 0xE7AC, 0xDF58, 0xF7D6,
0x8290, 0xC348, 0x8E90, 0xE3A4, 0xCF48, 0xF3D2, 0xBE90, 0xEFA4, 0x8358, 0xC3AC,
0x8F58, 0xE3D6, 0xCFAC, 0xBF58, 0xEFD6, 0x8148, 0xC1A4, 0x8748, 0xE1D2, 0xC7A4,
0x9F48, 0xE7D2, 0xDFA4, 0xD2C0, 0xF4B0, 0xFD2C, 0xEB60, 0xFAD8, 0xE920, 0xFA48,
0xD640, 0xF590, 0xFD64, 0xC960, 0xF258, 0xB2C0, 0xECB0, 0xFB2C, 0x96C0, 0xE5B0,
0xF96C, 0x9240, 0xE490, 0xF924, 0xD920, 0xF648, 0xFD92, 0xCB20, 0xF2C8, 0xB640,
0xED90, 0xFB64, 0xC4B0, 0xF12C, 0x9960, 0xE658, 0xF996, 0xDCB0, 0xF72C, 0x8B60,
0xE2D8, 0x8920, 0xE248, 0xBB60, 0xCC90, 0xF324, 0xB920, 0xEE48, 0xFB92, 0xC590,
0xF164, 0x9B20, 0xE6C8, 0xF9B2, 0xDD90, 0xF764, 0xC258, 0x8CB0, 0xE32C, 0xCE58,
0xF396, 0xBCB0, 0xEF2C, 0x85B0, 0xE16C, 0x8490, 0xE124, 0x9DB0, 0xC648, 0xF192,
0x9C90, 0xE724, 0xDE48, 0xF792, 0xC2C8, 0x8D90, 0xE364, 0xCEC8, 0xF3B2, 0xBD90,
0xEF64, 0xC12C, 0x8658, 0xE196, 0xC72C, 0x9E58, 0xE796, 0xDF2C, 0x82D8, 0x8248,
0x8ED8, 0xC324, 0x8E48, 0xE392, 0xBED8, 0xCF24, 0xBE48, 0xEF92, 0xC164, 0x86C8,
0xE1B2, 0xC764, 0x9EC8, 0xE7B2, 0xDF64, 0x832C, 0xC396, 0x8F2C, 0xCF96, 0x816C,
0x8124, 0x876C, 0xC192, 0x8724, 0x9F6C, 0xC792, 0x9F24, 0x8364, 0xC3B2, 0x8F64,
0xCFB2, 0xBF64, 0xD160, 0xF458, 0xFD16, 0xA6C0, 0xE9B0, 0xFA6C, 0xA240, 0xE890,
0xFA24, 0xD760, 0xF5D8, 0xFD76, 0xD320, 0xF4C8, 0xFD32, 0xAE40, 0xEB90, 0xFAE4,
0xC8B0, 0xF22C, 0xB160, 0xEC58, 0xFB16, 0x9360, 0xE4D8, 0xF936, 0x9120, 0xE448,
0xF912, 0xD890, 0xF624, 0xCBB0, 0xF2EC, 0xB760, 0xC990, 0xF264, 0xB320, 0xECC8,
0xFB32, 0x9720, 0xE5C8, 0xF972, 0xDB90, 0xF6E4, 0xC458, 0xF116, 0x98B0, 0xE62C,
0xDC58, 0xF716, 0x89B0, 0xE26C, 0x8890, 0xE224, 0xB9B0, 0xCC48, 0xF312, 0xB890,
0xEE24, 0xC5D8, 0xF176, 0x9BB0, 0xC4C8, 0xF132, 0x9990, 0xE664, 0xDCC8, 0xF732,
0x8B90, 0xE2E4, 0xCDC8, 0xF372, 0xBB90, 0xEEE4, 0xC22C, 0x8C58, 0xE316, 0xCE2C,
0xBC58, 0xEF16, 0x84D8, 0xE136, 0x8448, 0xE112, 0x9CD8, 0xC624, 0x9C48, 0xE712,
0xDE24, 0xC2EC, 0x8DD8, 0xC264, 0x8CC8, 0xE332, 0xBDD8, 0xCE64, 0xBCC8, 0xEF32,
0x85C8, 0xE172, 0xC6E4, 0x9DC8, 0xE772, 0xDEE4, 0xC116, 0x862C, 0xC716, 0x9E2C,
0x826C, 0x8224, 0x8E6C, 0xC312, 0x8E24, 0xBE6C, 0xCF12, 0xC176, 0x86EC, 0xC132,
0x8664, 0x9EEC, 0xC732, 0x9E64, 0xDF32, 0x82E4, 0xC372, 0x8EE4, 0xCF72, 0xBEE4,
0x8316, 0x8F16, 0x8136, 0x8112, 0x8736, 0x8712, 0x9F36, 0x8376, 0x8332, 0x8F76,
0x8F32, 0xBF76, 0x8172, 0x8772, 0x9F72, 0xD0B0, 0xF42C, 0xA360, 0xE8D8, 0xFA36,
0xA120, 0xE848, 0xFA12, 0xD3B0, 0xF4EC, 0xD190, 0xF464, 0xAF60, 0xEBD8, 0xFAF6,
0xA720, 0xE9C8, 0xFA72, 0xD790, 0xF5E4, 0xC858, 0xF216, 0xB0B0, 0xEC2C, 0x91B0,
0xE46C, 0x9090, 0xE424, 0xD848, 0xF612, 0xC9D8, 0xF276, 0xB3B0, 0xC8C8, 0xF232,
0xB190, 0xEC64, 0x97B0, 0xE5EC, 0x9390, 0xE4E4, 0xD9C8, 0xF672, 0xCBC8, 0xF2F2,
0xB790, 0xEDE4, 0xC42C, 0x9858, 0xE616, 0xDC2C, 0x88D8, 0xE236, 0x8848, 0xE212,
0xB8D8, 0xCC24, 0xB848, 0xEE12, 0xC4EC, 0x99D8, 0xC464, 0x98C8, 0xE632, 0xDC64,
0x8BD8, 0xE2F6, 0x89C8, 0xE272, 0xBBD8, 0xCCE4, 0xB9C8, 0xEE72, 0xC5E4, 0x9BC8,
0xE6F2, 0xDDE4, 0xC216, 0x8C2C, 0xCE16, 0x846C, 0x8424, 0x9C6C, 0xC612, 0x9C24,
0xC276, 0x8CEC, 0xC232, 0x8C64, 0xBCEC, 0xCE32, 0xBC64, 0x85EC, 0x84E4, 0x9DEC,
0xC672, 0x9CE4, 0xDE72, 0xC2F2, 0x8DE4, 0xCEF2, 0xBDE4, 0x8616, 0x8236, 0x8212,
0x8E36, 0x8E12, 0x8676, 0x8632, 0x9E76, 0x9E32, 0x82F6, 0x8272, 0x8EF6, 0x8E72,
0xBEF6, 0xBE72, 0x86F2, 0x9EF2, 0xD058, 0xF416, 0xA1B0, 0xE86C, 0xA090, 0xE824,
0xD1D8, 0xF476, 0xD0C8, 0xF432, 0xA7B0, 0xE9EC, 0xA390, 0xE8E4, 0xD7D8, 0xF5F6,
0xD3C8, 0xF4F2, 0xAF90, 0xEBE4, 0xC82C, 0xB058, 0xEC16, 0x90D8, 0xE436, 0x9048,
0xE412, 0xD824, 0xC8EC, 0xB1D8, 0xC864, 0xB0C8, 0xEC32, 0x93D8, 0xE4F6, 0x91C8,
0xE472, 0xD8E4, 0xCBEC, 0xB7D8, 0xC9E4, 0xB3C8, 0xECF2, 0x97C8, 0xE5F2, 0xDBE4,
0xC416, 0x982C, 0x886C, 0x8824, 0xB86C, 0xCC12, 0xC476, 0x98EC, 0xC432, 0x9864,
0xDC32, 0x89EC, 0x88E4, 0xB9EC, 0xCC72, 0xB8E4, 0xC5F6, 0x9BEC, 0xC4F2, 0x99E4,
0xDCF2, 0x8BE4, 0xCDF2, 0xBBE4, 0x8C16, 0x8436, 0x8412, 0x9C36, 0x8C76, 0x8C32,
0xBC76, 0x84F6, 0x8472, 0x9CF6, 0x9C72, 0x8DF6, 0x8CF2, 0xBDF6, 0xBCF2, 0x85F2,
0x9DF2, 0xD02C, 0xA0D8, 0xE836, 0xA048, 0xE812, 0xD0EC, 0xD064, 0xA3D8, 0xE8F6,
0xA1C8, 0xE872, 0xD3EC, 0xD1E4, 0xAFD8, 0xEBF6, 0xA7C8, 0xE9F2, 0xC816, 0x906C,
0x9024, 0xC876, 0xB0EC, 0xC832, 0xB064, 0x91EC, 0x90E4, 0xD872, 0xC9F6, 0xB3EC,
0xC8F2, 0xB1E4, 0x97EC, 0x93E4, 0xD9F2, 0x8836, 0x8812, 0x9876, 0x9832, 0x88F6,
0x8872, 0xB8F6, 0xB872, 0x99F6, 0x98F2, 0x8BF6, 0x89F2, 0xBBF6, 0xB9F2, 0xD4C0,
0xF530, 0xFD4C, 0xEA20, 0xFA88, 0xDAE0, 0xF6B8, 0xFDAE, 0xCA60, 0xF298, 0xB4C0,
0xED30, 0xFB4C, 0x9440, 0xE510, 0xF944, 0xDA20, 0xF688, 0xFDA2, 0xCD70, 0xF35C,
0xBAE0, 0xEEB8, 0xFBAE, 0xC530, 0xF14C, 0x9A60, 0xE698, 0xF9A6, 0xDD30, 0xF74C,
0x8A20, 0xE288, 0xCD10, 0xF344, 0xBA20, 0xEE88, 0xFBA2, 0xC6B8, 0xF1AE, 0x9D70,
0xE75C, 0xDEB8, 0xF7AE, 0xC298, 0x8D30, 0xE34C, 0xCE98, 0xF3A6, 0xBD30, 0xEF4C,
0x8510, 0xE144, 0xC688, 0xF1A2, 0x9D10, 0xE744, 0xDE88, 0xF7A2, 0xC35C, 0x8EB8,
0xE3AE, 0xCF5C, 0xBEB8, 0xEFAE, 0xC14C, 0x8698, 0xE1A6, 0xC74C, 0x9E98, 0xE7A6,
0xDF4C, 0x8288, 0xC344, 0x8E88, 0xE3A2, 0xCF44, 0xBE88, 0xEFA2, 0xC1AE, 0x875C,
0xC7AE, 0x9F5C, 0xDFAE, 0x834C, 0xC3A6, 0x8F4C, 0xCFA6, 0xBF4C, 0x8144, 0xC1A2,
0x8744, 0xC7A2, 0x9F44, 0xDFA2, 0xE970, 0xFA5C, 0xD6E0, 0xF5B8, 0xFD6E, 0xD260,
0xF498, 0xFD26, 0xACC0, 0xEB30, 0xFACC, 0xA440, 0xE910, 0xFA44, 0xD620, 0xF588,
0xFD62, 0x92E0, 0xE4B8, 0xF92E, 0xD970, 0xF65C, 0xCB70, 0xF2DC, 0xB6E0, 0xC930,
0xF24C, 0xB260, 0xEC98, 0xFB26, 0x9660, 0xE598, 0xF966, 0x9220, 0xE488, 0xF922,
0xD910, 0xF644, 0xCB10, 0xF2C4, 0xB620, 0xED88, 0xFB62, 0x8970, 0xE25C, 0xCCB8,
0xF32E, 0xB970, 0xEE5C, 0xC5B8, 0xF16E, 0x9B70, 0xC498, 0xF126, 0x9930, 0xE64C,
0xDC98, 0xF726, 0x8B30, 0xE2CC, 0x8910, 0xE244, 0xBB30, 0xCC88, 0xF322, 0xB910,
0xEE44, 0xC588, 0xF162, 0x9B10, 0xE6C4, 0xDD88, 0xF762, 0x84B8, 0xE12E, 0xC65C,
0x9CB8, 0xE72E, 0xDE5C, 0xC2DC, 0x8DB8, 0xC24C, 0x8C98, 0xE326, 0xBDB8, 0xCE4C,
0xBC98, 0xEF26, 0x8598, 0xE166, 0x8488, 0xE122, 0x9D98, 0xC644, 0x9C88, 0xE722,
0xDE44, 0xC2C4, 0x8D88, 0xE362, 0xCEC4, 0xBD88, 0xEF62, 0x825C, 0xC32E, 0x8E5C,
0xCF2E
};
static const unsigned short int c49_odd_bitpattern[] = {
/* Appendix E - Code 49 Encodation Patterns (Odd Symbol Character Parity) */
0xC940, 0xF250, 0xECA0, 0xFB28, 0xE5A0, 0xF968, 0xDB40, 0xF6D0, 0xFDB4, 0xC4A0,
0xF128, 0x9940, 0xE650, 0xF994, 0xDCA0, 0xF728, 0xFDCA, 0x8B40, 0xE2D0, 0xCDA0,
0xF368, 0xBB40, 0xEED0, 0xFBB4, 0xC250, 0x8CA0, 0xE328, 0xCE50, 0xF394, 0xBCA0,
0xEF28, 0xFBCA, 0x85A0, 0xE168, 0xC6D0, 0xF1B4, 0x9DA0, 0xE768, 0xF9DA, 0xDED0,
0xF7B4, 0xC128, 0x8650, 0xE194, 0xC728, 0xF1CA, 0x9E50, 0xE794, 0xDF28, 0xF7CA,
0x82D0, 0xC368, 0x8ED0, 0xE3B4, 0xCF68, 0xF3DA, 0xBED0, 0xEFB4, 0x8328, 0xC394,
0x8F28, 0xE3CA, 0xCF94, 0x8168, 0xC1B4, 0x8768, 0xE1DA, 0xC7B4, 0x9F68, 0xE7DA,
0xDFB4, 0xD140, 0xF450, 0xFD14, 0xE9A0, 0xFA68, 0xD740, 0xF5D0, 0xFD74, 0xC8A0,
0xF228, 0xB140, 0xEC50, 0xFB14, 0x9340, 0xE4D0, 0xF934, 0xD9A0, 0xF668, 0xFD9A,
0xCBA0, 0xF2E8, 0xB740, 0xEDD0, 0xFB74, 0xC450, 0xF114, 0x98A0, 0xE628, 0xF98A,
0xDC50, 0xF714, 0x89A0, 0xE268, 0xCCD0, 0xF334, 0xB9A0, 0xEE68, 0xFB9A, 0xC5D0,
0xF174, 0x9BA0, 0xE6E8, 0xF9BA, 0xDDD0, 0xF774, 0xC228, 0x8C50, 0xE314, 0xCE28,
0xF38A, 0xBC50, 0xEF14, 0x84D0, 0xE134, 0xC668, 0xF19A, 0x9CD0, 0xE734, 0xDE68,
0xF79A, 0xC2E8, 0x8DD0, 0xE374, 0xCEE8, 0xF3BA, 0xBDD0, 0xEF74, 0xC114, 0x8628,
0xE18A, 0xC714, 0x9E28, 0xE78A, 0x8268, 0xC334, 0x8E68, 0xE39A, 0xCF34, 0xBE68,
0xEF9A, 0xC174, 0x86E8, 0xE1BA, 0xC774, 0x9EE8, 0xE7BA, 0xDF74, 0x8314, 0xC38A,
0x8F14, 0x8134, 0xC19A, 0x8734, 0xC79A, 0x9F34, 0x8374, 0xC3BA, 0x8F74, 0xCFBA,
0xBF74, 0xD0A0, 0xF428, 0xFD0A, 0xA340, 0xE8D0, 0xFA34, 0xD3A0, 0xF4E8, 0xFD3A,
0xAF40, 0xEBD0, 0xFAF4, 0xC850, 0xF214, 0xB0A0, 0xEC28, 0xFB0A, 0x91A0, 0xE468,
0xF91A, 0xD8D0, 0xF634, 0xC9D0, 0xF274, 0xB3A0, 0xECE8, 0xFB3A, 0x97A0, 0xE5E8,
0xF97A, 0xDBD0, 0xF6F4, 0xC428, 0xF10A, 0x9850, 0xE614, 0xDC28, 0xF70A, 0x88D0,
0xE234, 0xCC68, 0xF31A, 0xB8D0, 0xEE34, 0xC4E8, 0xF13A, 0x99D0, 0xE674, 0xDCE8,
0xF73A, 0x8BD0, 0xE2F4, 0xCDE8, 0xF37A, 0xBBD0, 0xEEF4, 0xC214, 0x8C28, 0xE30A,
0xCE14, 0x8468, 0xE11A, 0xC634, 0x9C68, 0xE71A, 0xDE34, 0xC274, 0x8CE8, 0xE33A,
0xCE74, 0xBCE8, 0xEF3A, 0x85E8, 0xE17A, 0xC6F4, 0x9DE8, 0xE77A, 0xDEF4, 0xC10A,
0x8614, 0xC70A, 0x8234, 0xC31A, 0x8E34, 0xCF1A, 0xC13A, 0x8674, 0xC73A, 0x9E74,
0xDF3A, 0x82F4, 0xC37A, 0x8EF4, 0xCF7A, 0xBEF4, 0x830A, 0x811A, 0x871A, 0x833A,
0x8F3A, 0x817A, 0x877A, 0x9F7A, 0xD050, 0xF414, 0xA1A0, 0xE868, 0xFA1A, 0xD1D0,
0xF474, 0xA7A0, 0xE9E8, 0xFA7A, 0xD7D0, 0xF5F4, 0xC828, 0xF20A, 0xB050, 0xEC14,
0x90D0, 0xE434, 0xD868, 0xF61A, 0xC8E8, 0xF23A, 0xB1D0, 0xEC74, 0x93D0, 0xE4F4,
0xD9E8, 0xF67A, 0xCBE8, 0xF2FA, 0xB7D0, 0xEDF4, 0xC414, 0x9828, 0xE60A, 0x8868,
0xE21A, 0xCC34, 0xB868, 0xEE1A, 0xC474, 0x98E8, 0xE63A, 0xDC74, 0x89E8, 0xE27A,
0xCCF4, 0xB9E8, 0xEE7A, 0xC5F4, 0x9BE8, 0xE6FA, 0xDDF4, 0xC20A, 0x8C14, 0x8434,
0xC61A, 0x9C34, 0xC23A, 0x8C74, 0xCE3A, 0xBC74, 0x84F4, 0xC67A, 0x9CF4, 0xDE7A,
0xC2FA, 0x8DF4, 0xCEFA, 0xBDF4, 0x860A, 0x821A, 0x8E1A, 0x863A, 0x9E3A, 0x827A,
0x8E7A, 0xBE7A, 0x86FA, 0x9EFA, 0xD028, 0xF40A, 0xA0D0, 0xE834, 0xD0E8, 0xF43A,
0xA3D0, 0xE8F4, 0xD3E8, 0xF4FA, 0xAFD0, 0xEBF4, 0xC814, 0x9068, 0xE41A, 0xD834,
0xC874, 0xB0E8, 0xEC3A, 0x91E8, 0xE47A, 0xD8F4, 0xC9F4, 0xB3E8, 0xECFA, 0x97E8,
0xE5FA, 0xDBF4, 0xC40A, 0x8834, 0xCC1A, 0xC43A, 0x9874, 0xDC3A, 0x88F4, 0xCC7A,
0xB8F4, 0xC4FA, 0x99F4, 0xDCFA, 0x8BF4, 0xCDFA, 0xBBF4, 0x841A, 0x8C3A, 0x847A,
0x9C7A, 0x8CFA, 0xBCFA, 0x85FA, 0x9DFA, 0xF520, 0xFD48, 0xDAC0, 0xF6B0, 0xFDAC,
0xCA40, 0xF290, 0xED20, 0xFB48, 0xCD60, 0xF358, 0xBAC0, 0xEEB0, 0xFBAC, 0xC520,
0xF148, 0x9A40, 0xE690, 0xF9A4, 0xDD20, 0xF748, 0xFDD2, 0xC6B0, 0xF1AC, 0x9D60,
0xE758, 0xF9D6, 0xDEB0, 0xF7AC, 0xC290, 0x8D20, 0xE348, 0xCE90, 0xF3A4, 0xBD20,
0xEF48, 0xFBD2, 0xC358, 0x8EB0, 0xE3AC, 0xCF58, 0xF3D6, 0xBEB0, 0xEFAC, 0xC148,
0x8690, 0xE1A4, 0xC748, 0xF1D2, 0x9E90, 0xE7A4, 0xDF48, 0xF7D2, 0xC1AC, 0x8758,
0xE1D6, 0xC7AC, 0x9F58, 0xE7D6, 0xDFAC, 0x8348, 0xC3A4, 0x8F48, 0xE3D2, 0xCFA4,
0xBF48, 0xEFD2, 0xE960, 0xFA58, 0xD6C0, 0xF5B0, 0xFD6C, 0xD240, 0xF490, 0xFD24,
0xEB20, 0xFAC8, 0x92C0, 0xE4B0, 0xF92C, 0xD960, 0xF658, 0xFD96, 0xCB60, 0xF2D8,
0xB6C0, 0xC920, 0xF248, 0xB240, 0xEC90, 0xFB24, 0x9640, 0xE590, 0xF964, 0xDB20,
0xF6C8, 0xFDB2, 0x8960, 0xE258, 0xCCB0, 0xF32C, 0xB960, 0xEE58, 0xFB96, 0xC5B0,
0xF16C, 0x9B60, 0xC490, 0xF124, 0x9920, 0xE648, 0xF992, 0xDC90, 0xF724, 0x8B20,
0xE2C8, 0xCD90, 0xF364, 0xBB20, 0xEEC8, 0xFBB2, 0x84B0, 0xE12C, 0xC658, 0xF196,
0x9CB0, 0xE72C, 0xDE58, 0xF796, 0xC2D8, 0x8DB0, 0xC248, 0x8C90, 0xE324, 0xBDB0,
0xCE48, 0xF392, 0xBC90, 0xEF24, 0x8590, 0xE164, 0xC6C8, 0xF1B2, 0x9D90, 0xE764,
0xDEC8, 0xF7B2, 0x8258, 0xC32C, 0x8E58, 0xE396, 0xCF2C, 0xBE58, 0xEF96, 0xC16C,
0x86D8, 0xC124, 0x8648, 0xE192, 0x9ED8, 0xC724, 0x9E48, 0xE792, 0xDF24, 0x82C8,
0xC364, 0x8EC8, 0xE3B2, 0xCF64, 0xBEC8, 0xEFB2, 0x812C, 0xC196, 0x872C, 0xC796,
0x9F2C, 0x836C, 0x8324, 0x8F6C, 0xC392, 0x8F24, 0xBF6C, 0xCF92, 0x8164, 0xC1B2,
0x8764, 0xC7B2, 0x9F64, 0xDFB2, 0xA2C0, 0xE8B0, 0xFA2C, 0xD360, 0xF4D8, 0xFD36,
0xD120, 0xF448, 0xFD12, 0xAEC0, 0xEBB0, 0xFAEC, 0xA640, 0xE990, 0xFA64, 0xD720,
0xF5C8, 0xFD72, 0x9160, 0xE458, 0xF916, 0xD8B0, 0xF62C, 0xC9B0, 0xF26C, 0xB360,
0xC890, 0xF224, 0xB120, 0xEC48, 0xFB12, 0x9760, 0xE5D8, 0xF976, 0x9320, 0xE4C8,
0xF932, 0xD990, 0xF664, 0xCB90, 0xF2E4, 0xB720, 0xEDC8, 0xFB72, 0x88B0, 0xE22C,
0xCC58, 0xF316, 0xB8B0, 0xEE2C, 0xC4D8, 0xF136, 0x99B0, 0xC448, 0xF112, 0x9890,
0xE624, 0xDC48, 0xF712, 0x8BB0, 0xE2EC, 0x8990, 0xE264, 0xBBB0, 0xCCC8, 0xF332,
0xB990, 0xEE64, 0xC5C8, 0xF172, 0x9B90, 0xE6E4, 0xDDC8, 0xF772, 0x8458, 0xE116,
0xC62C, 0x9C58, 0xE716, 0xDE2C, 0xC26C, 0x8CD8, 0xC224, 0x8C48, 0xE312, 0xBCD8,
0xCE24, 0xBC48, 0xEF12, 0x85D8, 0xE176, 0x84C8, 0xE132, 0x9DD8, 0xC664, 0x9CC8,
0xE732, 0xDE64, 0xC2E4, 0x8DC8, 0xE372, 0xCEE4, 0xBDC8, 0xEF72, 0x822C, 0xC316,
0x8E2C, 0xCF16, 0xC136, 0x866C, 0xC112, 0x8624, 0x9E6C, 0xC712, 0x9E24, 0x82EC,
0x8264, 0x8EEC, 0xC332, 0x8E64, 0xBEEC, 0xCF32, 0xBE64, 0xC172, 0x86E4, 0xC772,
0x9EE4, 0xDF72, 0x8116, 0x8716, 0x8336, 0x8312, 0x8F36, 0x8F12, 0x8176, 0x8132,
0x8776, 0x8732, 0x9F76, 0x9F32, 0x8372, 0x8F72, 0xBF72, 0xA160, 0xE858, 0xFA16,
0xD1B0, 0xF46C, 0xD090, 0xF424, 0xA760, 0xE9D8, 0xFA76, 0xA320, 0xE8C8, 0xFA32,
0xD7B0, 0xF5EC, 0xD390, 0xF4E4, 0xAF20, 0xEBC8, 0xFAF2, 0x90B0, 0xE42C, 0xD858,
0xF616, 0xC8D8, 0xF236, 0xB1B0, 0xC848, 0xF212, 0xB090, 0xEC24, 0x93B0, 0xE4EC,
0x9190, 0xE464, 0xD8C8, 0xF632, 0xCBD8, 0xF2F6, 0xB7B0, 0xC9C8, 0xF272, 0xB390,
0xECE4, 0x9790, 0xE5E4, 0xDBC8, 0xF6F2, 0x8858, 0xE216, 0xCC2C, 0xB858, 0xEE16,
0xC46C, 0x98D8, 0xC424, 0x9848, 0xE612, 0xDC24, 0x89D8, 0xE276, 0x88C8, 0xE232,
0xB9D8, 0xCC64, 0xB8C8, 0xEE32, 0xC5EC, 0x9BD8, 0xC4E4, 0x99C8, 0xE672, 0xDCE4,
0x8BC8, 0xE2F2, 0xCDE4, 0xBBC8, 0xEEF2, 0x842C, 0xC616, 0x9C2C, 0xC236, 0x8C6C,
0xC212, 0x8C24, 0xBC6C, 0xCE12, 0x84EC, 0x8464, 0x9CEC, 0xC632, 0x9C64, 0xDE32,
0xC2F6, 0x8DEC, 0xC272, 0x8CE4, 0xBDEC, 0xCE72, 0xBCE4, 0x85E4, 0xC6F2, 0x9DE4,
0xDEF2, 0x8216, 0x8E16, 0x8636, 0x8612, 0x9E36, 0x8276, 0x8232, 0x8E76, 0x8E32,
0xBE76, 0x86F6, 0x8672, 0x9EF6, 0x9E72, 0x82F2, 0x8EF2, 0xBEF2, 0xA0B0, 0xE82C,
0xD0D8, 0xF436, 0xD048, 0xF412, 0xA3B0, 0xE8EC, 0xA190, 0xE864, 0xD3D8, 0xF4F6,
0xD1C8, 0xF472, 0xAFB0, 0xEBEC, 0xA790, 0xE9E4, 0xD7C8, 0xF5F2, 0x9058, 0xE416,
0xD82C, 0xC86C, 0xB0D8, 0xC824, 0xB048, 0xEC12, 0x91D8, 0xE476, 0x90C8, 0xE432,
0xD864, 0xC9EC, 0xB3D8, 0xC8E4, 0xB1C8, 0xEC72, 0x97D8, 0xE5F6, 0x93C8, 0xE4F2,
0xD9E4, 0xCBE4, 0xB7C8, 0xEDF2, 0x882C, 0xCC16, 0xC436, 0x986C, 0xC412, 0x9824,
0x88EC, 0x8864, 0xB8EC, 0xCC32, 0xB864, 0xC4F6, 0x99EC, 0xC472, 0x98E4, 0xDC72,
0x8BEC, 0x89E4, 0xBBEC, 0xCCF2, 0xB9E4, 0xC5F2, 0x9BE4, 0xDDF2, 0x8416, 0x8C36,
0x8C12, 0x8476, 0x8432, 0x9C76, 0x9C32, 0x8CF6, 0x8C72, 0xBCF6, 0xBC72, 0x85F6,
0x84F2, 0x9DF6, 0x9CF2, 0x8DF2, 0xBDF2, 0xA058, 0xE816, 0xD06C, 0xD024, 0xA1D8,
0xE876, 0xA0C8, 0xE832, 0xD1EC, 0xD0E4, 0xA7D8, 0xE9F6, 0xA3C8, 0xE8F2, 0xD7EC,
0xD3E4, 0x902C, 0xC836, 0xB06C, 0xC812, 0x90EC, 0x9064, 0xD832, 0xC8F6, 0xB1EC,
0xC872, 0xB0E4, 0x93EC, 0x91E4, 0xD8F2, 0xCBF6, 0xB7EC, 0xC9F2, 0xB3E4, 0x8816,
0x9836, 0x8876, 0x8832, 0xB876, 0x98F6, 0x9872, 0x89F6, 0x88F2, 0xB9F6, 0xB8F2,
0x9BF6, 0x99F2, 0xEA60, 0xFA98, 0xD440, 0xF510, 0xFD44, 0xED70, 0xFB5C, 0x94C0,
0xE530, 0xF94C, 0xDA60, 0xF698, 0xFDA6, 0xCA20, 0xF288, 0xB440, 0xED10, 0xFB44,
0x9AE0, 0xE6B8, 0xF9AE, 0xDD70, 0xF75C, 0x8A60, 0xE298, 0xCD30, 0xF34C, 0xBA60,
0xEE98, 0xFBA6, 0xC510, 0xF144, 0x9A20, 0xE688, 0xF9A2, 0xDD10, 0xF744, 0x8D70,
0xE35C, 0xCEB8, 0xF3AE, 0xBD70, 0xEF5C, 0x8530, 0xE14C, 0xC698, 0xF1A6, 0x9D30,
0xE74C, 0xDE98, 0xF7A6, 0xC288, 0x8D10, 0xE344, 0xCE88, 0xF3A2, 0xBD10, 0xEF44,
0x86B8, 0xE1AE, 0xC75C, 0x9EB8, 0xE7AE, 0xDF5C, 0x8298, 0xC34C, 0x8E98, 0xE3A6,
0xCF4C, 0xBE98, 0xEFA6, 0xC144, 0x8688, 0xE1A2, 0xC744, 0x9E88, 0xE7A2, 0xDF44,
0x835C, 0xC3AE, 0x8F5C, 0xCFAE, 0xBF5C, 0x814C, 0xC1A6, 0x874C, 0xC7A6, 0x9F4C,
0xDFA6, 0x8344, 0xC3A2, 0x8F44, 0xCFA2, 0xBF44, 0xD2E0, 0xF4B8, 0xFD2E, 0xADC0,
0xEB70, 0xFADC, 0xA4C0, 0xE930, 0xFA4C, 0xD660, 0xF598, 0xFD66, 0xD220, 0xF488,
0xFD22, 0xAC40, 0xEB10, 0xFAC4, 0xC970, 0xF25C, 0xB2E0, 0xECB8, 0xFB2E, 0x96E0,
0xE5B8, 0xF96E, 0x9260, 0xE498, 0xF926, 0xD930, 0xF64C, 0xCB30, 0xF2CC, 0xB660,
0xC910, 0xF244, 0xB220, 0xEC88, 0xFB22, 0x9620, 0xE588, 0xF962, 0xDB10, 0xF6C4,
0xC4B8, 0xF12E, 0x9970, 0xE65C, 0xDCB8, 0xF72E, 0x8B70, 0xE2DC, 0x8930, 0xE24C,
0xBB70, 0xCC98, 0xF326, 0xB930, 0xEE4C, 0xC598, 0xF166, 0x9B30, 0xC488, 0xF122,
0x9910, 0xE644, 0xDC88, 0xF722, 0x8B10, 0xE2C4, 0xCD88, 0xF362, 0xBB10, 0xEEC4,
0xC25C, 0x8CB8, 0xE32E, 0xCE5C, 0xBCB8, 0xEF2E, 0x85B8, 0xE16E, 0x8498, 0xE126,
0x9DB8, 0xC64C, 0x9C98, 0xE726, 0xDE4C, 0xC2CC, 0x8D98, 0xC244, 0x8C88, 0xE322,
0xBD98, 0xCE44, 0xBC88, 0xEF22, 0x8588, 0xE162, 0xC6C4, 0x9D88, 0xE762, 0xDEC4,
0xC12E, 0x865C, 0xC72E, 0x9E5C, 0xDF2E, 0x82DC, 0x824C, 0x8EDC, 0xC326, 0x8E4C,
0xBEDC, 0xCF26, 0xBE4C, 0xC166, 0x86CC, 0xC122, 0x8644, 0x9ECC, 0xC722, 0x9E44,
0xDF22, 0x82C4, 0xC362, 0x8EC4, 0xCF62, 0xBEC4, 0x832E, 0x8F2E, 0x816E, 0x8126,
0x876E, 0x8726, 0x9F6E, 0x9F26, 0x8366, 0x8322, 0x8F66, 0x8F22, 0xBF66, 0x8162,
0x8762, 0x9F62, 0xD170, 0xF45C, 0xA6E0, 0xE9B8, 0xFA6E, 0xA260, 0xE898, 0xFA26,
0xD770, 0xF5DC, 0xD330, 0xF4CC, 0xD110, 0xF444, 0xAE60, 0xEB98, 0xFAE6, 0xA620,
0xE988, 0xFA62, 0xD710, 0xF5C4, 0xC8B8, 0xF22E, 0xB170, 0xEC5C, 0x9370, 0xE4DC,
0x9130, 0xE44C, 0xD898, 0xF626, 0xCBB8, 0xF2EE, 0xB770, 0xC998, 0xF266, 0xB330,
0xC888, 0xF222, 0xB110, 0xEC44, 0x9730, 0xE5CC, 0x9310, 0xE4C4, 0xD988, 0xF662,
0xCB88, 0xF2E2, 0xB710, 0xEDC4, 0xC45C, 0x98B8, 0xE62E, 0xDC5C, 0x89B8, 0xE26E,
0x8898, 0xE226, 0xB9B8, 0xCC4C, 0xB898, 0xEE26, 0xC5DC, 0x9BB8, 0xC4CC, 0x9998,
0xC444, 0x9888, 0xE622, 0xDC44, 0x8B98, 0xE2E6, 0x8988, 0xE262, 0xBB98, 0xCCC4,
0xB988, 0xEE62, 0xC5C4, 0x9B88, 0xE6E2, 0xDDC4, 0xC22E, 0x8C5C, 0xCE2E, 0xBC5C,
0x84DC, 0x844C, 0x9CDC, 0xC626, 0x9C4C, 0xDE26, 0xC2EE, 0x8DDC, 0xC266, 0x8CCC,
0xC222, 0xBDDC, 0x8C44, 0xBCCC, 0xCE22, 0xBC44, 0x85CC, 0x84C4, 0x9DCC, 0xC662,
0x9CC4, 0xDE62, 0xC2E2, 0x8DC4, 0xCEE2, 0xBDC4, 0x862E, 0x9E2E, 0x826E, 0x8226,
0x8E6E, 0x8E26, 0xBE6E, 0x86EE, 0x8666, 0x9EEE, 0x8622, 0x9E66, 0x9E22, 0x82E6,
0x8262, 0x8EE6, 0x8E62, 0xBEE6, 0xBE62, 0x86E2, 0x9EE2, 0xD0B8, 0xF42E, 0xA370,
0xE8DC, 0xA130, 0xE84C, 0xD3B8, 0xF4EE, 0xD198, 0xF466, 0xD088, 0xF422, 0xAF70,
0xEBDC, 0xA730, 0xE9CC, 0xA310, 0xE8C4, 0xD798, 0xF5E6, 0xD388, 0xF4E2, 0xAF10,
0xEBC4, 0xC85C, 0xB0B8, 0xEC2E, 0x91B8, 0xE46E, 0x9098, 0xE426, 0xD84C, 0xC9DC,
0xB3B8, 0xC8CC, 0xB198, 0xC844, 0xB088, 0xEC22, 0x97B8, 0xE5EE, 0x9398, 0xE4E6,
0x9188, 0xE462, 0xD8C4, 0xCBCC, 0xB798, 0xC9C4, 0xB388, 0xECE2, 0x9788, 0xE5E2,
0xDBC4, 0xC42E, 0x985C, 0xDC2E, 0x88DC, 0x884C, 0xB8DC, 0xCC26, 0xB84C, 0xC4EE,
0x99DC, 0xC466, 0x98CC, 0xC422, 0x9844, 0xDC22, 0x8BDC, 0x89CC, 0xBBDC, 0x88C4,
0xB9CC, 0xCC62, 0xB8C4, 0xC5E6, 0x9BCC, 0xC4E2, 0x99C4, 0xDCE2, 0x8BC4, 0xCDE2,
0xBBC4, 0x8C2E, 0x846E, 0x8426, 0x9C6E, 0x9C26, 0x8CEE, 0x8C66, 0xBCEE, 0x8C22,
0xBC66, 0x85EE, 0x84E6, 0x9DEE, 0x8462, 0x9CE6, 0x9C62, 0x8DE6, 0x8CE2, 0xBDE6,
0xBCE2, 0x85E2, 0x9DE2, 0xD05C, 0xA1B8, 0xE86E, 0xA098, 0xE826, 0xD1DC, 0xD0CC,
0xD044, 0xA7B8, 0xE9EE, 0xA398, 0xE8E6, 0xA188, 0xE862, 0xD7DC, 0xD3CC, 0xD1C4,
0xAF98, 0xEBE6, 0xA788, 0xE9E2, 0xC82E, 0xB05C, 0x90DC, 0x904C, 0xD826, 0xC8EE,
0xB1DC, 0xC866, 0xB0CC, 0xC822, 0xB044, 0x93DC, 0x91CC, 0x90C4, 0xD862, 0xCBEE,
0xB7DC, 0xC9E6, 0xB3CC, 0xC8E2, 0xB1C4, 0x97CC, 0x93C4, 0xD9E2, 0x982E, 0x886E,
0x8826, 0xB86E, 0x98EE, 0x9866, 0x9822, 0x89EE, 0x88E6, 0xB9EE, 0x8862, 0xB8E6,
0xB862, 0x9BEE, 0x99E6, 0x98E2, 0x8BE6, 0x89E2, 0xBBE6, 0xB9E2, 0xD02E, 0xA0DC,
0xA04C, 0xD0EE, 0xD066, 0xD022, 0xA3DC, 0xA1CC, 0xA0C4, 0xD3EE, 0xD1E6, 0xD0E2,
0xAFDC, 0xA7CC, 0xA3C4, 0x906E, 0x9026, 0xB0EE, 0xB066, 0x91EE, 0x90E6, 0x9062,
0xB3EE, 0xB1E6, 0xB0E2, 0x97EE, 0x93E6, 0x91E2, 0xD4E0, 0xF538, 0xFD4E, 0xA8C0,
0xEA30, 0xFA8C, 0xD420, 0xF508, 0xFD42, 0xDAF0, 0xF6BC, 0xCA70, 0xF29C, 0xB4E0,
0xED38, 0xFB4E, 0x9460, 0xE518, 0xF946, 0xDA30, 0xF68C, 0xCA10, 0xF284, 0xB420,
0xED08, 0xFB42, 0xCD78, 0xF35E, 0xBAF0, 0xEEBC, 0xC538, 0xF14E, 0x9A70, 0xE69C,
0xDD38, 0xF74E, 0x8A30, 0xE28C, 0xCD18, 0xF346, 0xBA30, 0xEE8C, 0xC508, 0xF142,
0x9A10, 0xE684, 0xDD08, 0xF742, 0xC6BC, 0x9D78, 0xE75E, 0xDEBC, 0xC29C, 0x8D38,
0xE34E, 0xCE9C, 0xBD38, 0xEF4E, 0x8518, 0xE146, 0xC68C, 0x9D18, 0xE746, 0xDE8C,
0xC284, 0x8D08, 0xE342, 0xCE84, 0xBD08, 0xEF42, 0xC35E, 0x8EBC, 0xCF5E, 0xBEBC,
0xC14E, 0x869C, 0xC74E, 0x9E9C, 0xDF4E, 0x828C, 0xC346, 0x8E8C, 0xCF46, 0xBE8C,
0xC142, 0x8684, 0xC742, 0x9E84, 0xDF42, 0x875E, 0x9F5E, 0x834E, 0x8F4E, 0xBF4E,
0x8146, 0x8746, 0x9F46, 0x8342, 0x8F42, 0xBF42, 0xE978, 0xFA5E, 0xD6F0, 0xF5BC,
0xD270, 0xF49C, 0xACE0, 0xEB38, 0xFACE, 0xA460, 0xE918, 0xFA46, 0xD630, 0xF58C,
0xD210, 0xF484, 0xAC20, 0xEB08, 0xFAC2, 0x92F0, 0xE4BC, 0xD978, 0xF65E, 0xCB78,
0xF2DE, 0xB6F0, 0xC938, 0xF24E, 0xB270, 0xEC9C, 0x9670, 0xE59C, 0x9230, 0xE48C,
0xD918, 0xF646, 0xCB18, 0xF2C6, 0xB630, 0xC908, 0xF242, 0xB210, 0xEC84, 0x9610,
0xE584, 0xDB08, 0xF6C2, 0x8978, 0xE25E, 0xCCBC, 0xB978, 0xEE5E, 0xC5BC, 0x9B78,
0xC49C, 0x9938, 0xE64E, 0xDC9C, 0x8B38, 0xE2CE, 0x8918, 0xE246, 0xBB38, 0xCC8C,
0xB918, 0xEE46, 0xC58C, 0x9B18, 0xC484, 0x9908, 0xE642, 0xDC84, 0x8B08, 0xE2C2,
0xCD84, 0xBB08, 0xEEC2, 0x84BC, 0xC65E, 0x9CBC, 0xDE5E, 0xC2DE, 0x8DBC, 0xC24E,
0x8C9C, 0xBDBC, 0xCE4E, 0xBC9C, 0x859C, 0x848C, 0x9D9C, 0xC646, 0x9C8C, 0xDE46,
0xC2C6, 0x8D8C, 0xC242, 0x8C84, 0xBD8C, 0xCE42, 0xBC84, 0x8584, 0xC6C2, 0x9D84,
0xDEC2, 0x825E, 0x8E5E, 0xBE5E, 0x86DE, 0x864E, 0x9EDE, 0x9E4E, 0x82CE, 0x8246,
0x8ECE, 0x8E46, 0xBECE, 0xBE46, 0x86C6, 0x8642, 0x9EC6, 0x9E42, 0x82C2, 0x8EC2,
0xBEC2, 0xA2F0, 0xE8BC, 0xD378, 0xF4DE, 0xD138, 0xF44E, 0xAEF0, 0xEBBC, 0xA670,
0xE99C, 0xA230, 0xE88C, 0xD738, 0xF5CE, 0xD318, 0xF4C6, 0xD108, 0xF442, 0xAE30,
0xEB8C, 0xA610, 0xE984, 0xD708, 0xF5C2, 0x9178, 0xE45E, 0xD8BC, 0xC9BC, 0xB378,
0xC89C, 0xB138, 0xEC4E, 0x9778, 0xE5DE, 0x9338, 0xE4CE, 0x9118, 0xE446, 0xD88C,
0xCB9C, 0xB738, 0xC98C, 0xB318, 0xC884, 0xB108, 0xEC42, 0x9718, 0xE5C6, 0x9308,
0xE4C2, 0xD984, 0xCB84, 0xB708, 0xEDC2, 0x88BC, 0xCC5E, 0xB8BC, 0xC4DE, 0x99BC,
0xC44E, 0x989C, 0xDC4E, 0x8BBC, 0x899C, 0xBBBC, 0x888C, 0xB99C, 0xCC46, 0xB88C,
0xC5CE, 0x9B9C, 0xC4C6, 0x998C, 0xC442, 0x9884, 0xDC42, 0x8B8C, 0x8984, 0xBB8C,
0xCCC2, 0xB984, 0xC5C2, 0x9B84, 0xDDC2, 0x845E, 0x9C5E, 0x8CDE, 0x8C4E, 0xBCDE,
0xBC4E, 0x85DE, 0x84CE, 0x9DDE, 0x8446, 0x9CCE, 0x9C46, 0x8DCE, 0x8CC6, 0xBDCE,
0x8C42, 0xBCC6, 0xBC42, 0x85C6, 0x84C2, 0x9DC6, 0x9CC2, 0x8DC2, 0xBDC2, 0xA178,
0xE85E, 0xD1BC, 0xD09C, 0xA778, 0xE9DE, 0xA338, 0xE8CE, 0xA118, 0xE846, 0xD7BC,
0xD39C, 0xD18C, 0xD084, 0xAF38, 0xEBCE, 0xA718, 0xE9C6, 0xA308, 0xE8C2, 0xD78C,
0xD384, 0x90BC, 0xD85E, 0xC8DE, 0xB1BC, 0xC84E, 0xB09C, 0x93BC, 0x919C, 0x908C,
0xD846, 0xCBDE, 0xB7BC, 0xC9CE, 0xB39C, 0xC8C6, 0xB18C, 0xC842, 0xB084, 0x979C,
0x938C, 0x9184, 0xD8C2, 0xCBC6, 0xB78C, 0xC9C2, 0xB384, 0x885E, 0xB85E, 0x98DE,
0x984E, 0x89DE, 0x88CE, 0xB9DE, 0x8846, 0xB8CE, 0xB846, 0x9BDE, 0x99CE, 0x98C6,
0x9842, 0x8BCE, 0x89C6, 0xBBCE, 0x88C2, 0xB9C6, 0xB8C2, 0x9BC6, 0x99C2, 0xA0BC,
0xD0DE, 0xD04E, 0xA3BC, 0xA19C, 0xA08C, 0xD3DE, 0xD1CE, 0xD0C6, 0xD042, 0xAFBC,
0xA79C, 0xA38C, 0xA184, 0xD7CE, 0xD3C6, 0xD1C2, 0x905E, 0xB0DE, 0xB04E, 0x91DE,
0x90CE, 0x9046, 0xB3DE, 0xB1CE, 0xB0C6, 0xB042, 0x97DE, 0x93CE, 0x91C6, 0x90C2,
0xB7CE, 0xB3C6, 0xB1C2, 0xA05E, 0xA1DE, 0xA0CE, 0xA046, 0xA7DE, 0xA3CE, 0xA1C6,
0xA0C2, 0xA9E0, 0xEA78, 0xFA9E, 0xD470, 0xF51C, 0xA860, 0xEA18, 0xFA86, 0xD410,
0xF504, 0xED7C, 0x94F0, 0xE53C, 0xDA78, 0xF69E, 0xCA38, 0xF28E, 0xB470, 0xED1C,
0x9430, 0xE50C, 0xDA18, 0xF686, 0xCA08, 0xF282, 0xB410, 0xED04, 0x9AF8, 0xE6BE,
0xDD7C, 0x8A78, 0xE29E, 0xCD3C, 0xBA78, 0xEE9E, 0xC51C, 0x9A38, 0xE68E, 0xDD1C,
0x8A18, 0xE286, 0xCD0C, 0xBA18, 0xEE86, 0xC504, 0x9A08, 0xE682, 0xDD04, 0x8D7C,
0xCEBE, 0xBD7C, 0x853C, 0xC69E, 0x9D3C, 0xDE9E, 0xC28E, 0x8D1C, 0xCE8E, 0xBD1C,
0x850C, 0xC686, 0x9D0C, 0xDE86, 0xC282, 0x8D04, 0xCE82, 0xBD04, 0x86BE, 0x9EBE,
0x829E, 0x8E9E, 0xBE9E, 0x868E, 0x9E8E, 0x8286, 0x8E86, 0xBE86, 0x8682, 0x9E82,
0xD2F8, 0xF4BE, 0xADF0, 0xEB7C, 0xA4F0, 0xE93C, 0xD678, 0xF59E, 0xD238, 0xF48E,
0xAC70, 0xEB1C, 0xA430, 0xE90C, 0xD618, 0xF586, 0xD208, 0xF482, 0xAC10, 0xEB04,
0xC97C, 0xB2F8, 0xECBE, 0x96F8, 0xE5BE, 0x9278, 0xE49E, 0xD93C, 0xCB3C, 0xB678,
0xC91C, 0xB238, 0xEC8E, 0x9638, 0xE58E, 0x9218, 0xE486, 0xD90C, 0xCB0C, 0xB618,
0xC904, 0xB208, 0xEC82, 0x9608, 0xE582, 0xDB04, 0xC4BE, 0x997C, 0xDCBE, 0x8B7C,
0x893C, 0xBB7C, 0xCC9E, 0xB93C, 0xC59E, 0x9B3C, 0xC48E, 0x991C, 0xDC8E, 0x8B1C,
0x890C, 0xBB1C, 0xCC86, 0xB90C, 0xC586, 0x9B0C, 0xC482, 0x9904, 0xDC82, 0x8B04,
0xCD82, 0xBB04, 0x8CBE, 0xBCBE, 0x85BE, 0x849E, 0x9DBE, 0x9C9E, 0x8D9E, 0x8C8E,
0xBD9E, 0xBC8E, 0x858E, 0x8486, 0x9D8E, 0x9C86, 0x8D86, 0x8C82, 0xBD86, 0xBC82,
0x8582, 0x9D82, 0xD17C, 0xA6F8, 0xE9BE, 0xA278, 0xE89E, 0xD77C, 0xD33C, 0xD11C,
0xAE78, 0xEB9E, 0xA638, 0xE98E, 0xA218, 0xE886, 0xD71C, 0xD30C, 0xD104, 0xAE18,
0xEB86, 0xA608, 0xE982, 0xC8BE, 0xB17C, 0x937C, 0x913C, 0xD89E, 0xCBBE, 0xB77C,
0xC99E, 0xB33C, 0xC88E, 0xB11C, 0x973C, 0x931C, 0x910C, 0xD886, 0xCB8E, 0xB71C,
0xC986, 0xB30C, 0xC882, 0xB104, 0x970C, 0x9304, 0xD982, 0x98BE, 0x89BE, 0x889E,
0xB9BE, 0xB89E, 0x9BBE, 0x999E, 0x988E, 0x8B9E, 0x898E, 0xBB9E, 0x8886, 0xB98E,
0xB886, 0x9B8E, 0x9986, 0x9882, 0x8B86, 0x8982, 0xBB86, 0xB982, 0xD0BE, 0xA37C,
0xA13C, 0xD3BE, 0xD19E, 0xD08E, 0xAF7C, 0xA73C, 0xA31C, 0xA10C, 0xD79E, 0xD38E,
0xD186, 0xD082, 0xAF1C, 0xA70C, 0xA304, 0xB0BE, 0x91BE, 0x909E, 0xB3BE, 0xB19E,
0xB08E, 0x97BE, 0x939E, 0x918E, 0x9086, 0xB79E, 0xB38E, 0xB186, 0xB082, 0x978E,
0x9386, 0x9182, 0xA1BE, 0xA09E, 0xA7BE, 0xA39E, 0xA18E, 0xA086, 0xAF9E, 0xA78E,
0xA386, 0xA182, 0xD4F8, 0xF53E, 0xA8F0, 0xEA3C, 0xD438, 0xF50E, 0xA830, 0xEA0C,
0xD408, 0xF502, 0xDAFC, 0xCA7C, 0xB4F8, 0xED3E, 0x9478, 0xE51E, 0xDA3C, 0xCA1C,
0xB438, 0xED0E, 0x9418, 0xE506, 0xDA0C, 0xCA04, 0xB408, 0xED02, 0xCD7E, 0xBAFC,
0xC53E, 0x9A7C, 0xDD3E, 0x8A3C, 0xCD1E, 0xBA3C, 0xC50E, 0x9A1C, 0xDD0E, 0x8A0C,
0xCD06, 0xBA0C, 0xC502, 0x9A04, 0xDD02, 0x9D7E, 0x8D3E, 0xBD3E, 0x851E, 0x9D1E,
0x8D0E, 0xBD0E, 0x8506, 0x9D06, 0x8D02, 0xBD02, 0xE97E, 0xD6FC, 0xD27C, 0xACF8,
0xEB3E, 0xA478, 0xE91E, 0xD63C, 0xD21C, 0xAC38, 0xEB0E, 0xA418, 0xE906, 0xD60C,
0xD204, 0x92FC, 0xD97E, 0xCB7E, 0xB6FC, 0xC93E, 0xB27C, 0x967C, 0x923C, 0xD91E,
0xCB1E, 0xB63C, 0xC90E, 0xB21C, 0x961C, 0x920C, 0xD906, 0xCB06, 0xB60C, 0xC902,
0xB204, 0x897E, 0xB97E, 0x9B7E, 0x993E, 0x8B3E, 0x891E, 0xBB3E, 0xB91E, 0x9B1E,
0x990E, 0x8B0E, 0x8906, 0xBB0E, 0xB906, 0x9B06, 0x9902, 0xA2FC, 0xD37E, 0xD13E,
0xAEFC
};

518
3rdparty/zint-2.10.0/backend/common.c vendored Normal file
View File

@@ -0,0 +1,518 @@
/* common.c - Contains functions needed for a number of barcodes */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifdef ZINT_TEST
#include <stdio.h>
#endif
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
/* Converts a character 0-9, A-F to its equivalent integer value */
INTERNAL int ctoi(const char source) {
if ((source >= '0') && (source <= '9'))
return (source - '0');
if ((source >= 'A') && (source <= 'F'))
return (source - 'A' + 10);
if ((source >= 'a') && (source <= 'f'))
return (source - 'a' + 10);
return -1;
}
/* Converts an integer value to its hexadecimal character */
INTERNAL char itoc(const int source) {
if ((source >= 0) && (source <= 9)) {
return ('0' + source);
} else {
return ('A' + (source - 10));
}
}
/* Converts decimal string of length <= 9 to integer value. Returns -1 if not numeric */
INTERNAL int to_int(const unsigned char source[], const int length) {
int val = 0;
int i;
for (i = 0; i < length; i++) {
if (source[i] < '0' || source[i] > '9') {
return -1;
}
val *= 10;
val += source[i] - '0';
}
return val;
}
/* Converts lower case characters to upper case in a string source[] */
INTERNAL void to_upper(unsigned char source[]) {
int i, src_len = (int) ustrlen(source);
for (i = 0; i < src_len; i++) {
if ((source[i] >= 'a') && (source[i] <= 'z')) {
source[i] = (source[i] - 'a') + 'A';
}
}
}
/* Returns the number of times a character occurs in a string */
INTERNAL int chr_cnt(const unsigned char string[], const int length, const unsigned char c) {
int count = 0;
int i;
for (i = 0; i < length; i++) {
if (string[i] == c) {
count++;
}
}
return count;
}
/* Verifies that a string only uses valid characters */
INTERNAL int is_sane(const char test_string[], const unsigned char source[], const int length) {
int i, j, lt = (int) strlen(test_string);
for (i = 0; i < length; i++) {
unsigned int latch = FALSE;
for (j = 0; j < lt; j++) {
if (source[i] == test_string[j]) {
latch = TRUE;
break;
}
}
if (!(latch)) {
return ZINT_ERROR_INVALID_DATA;
}
}
return 0;
}
/* Replaces huge switch statements for looking up in tables */
INTERNAL void lookup(const char set_string[], const char *table[], const char data, char dest[]) {
int i, n = (int) strlen(set_string);
for (i = 0; i < n; i++) {
if (data == set_string[i]) {
strcat(dest, table[i]);
break;
}
}
}
/* Convert an integer value to a string representing its binary equivalent */
INTERNAL void bin_append(const int arg, const int length, char *binary) {
int bin_posn = (int) strlen(binary);
bin_append_posn(arg, length, binary, bin_posn);
binary[bin_posn + length] = '\0';
}
/* Convert an integer value to a string representing its binary equivalent at a set position */
INTERNAL int bin_append_posn(const int arg, const int length, char *binary, const int bin_posn) {
int i;
int start;
start = 0x01 << (length - 1);
for (i = 0; i < length; i++) {
if (arg & (start >> i)) {
binary[bin_posn + i] = '1';
} else {
binary[bin_posn + i] = '0';
}
}
return bin_posn + length;
}
/* Returns the position of data in set_string */
INTERNAL int posn(const char set_string[], const char data) {
int i, n = (int) strlen(set_string);
for (i = 0; i < n; i++) {
if (data == set_string[i]) {
return i;
}
}
return -1;
}
#ifndef COMMON_INLINE
/* Return true (1) if a module is dark/black, otherwise false (0) */
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
return (symbol->encoded_data[y_coord][x_coord >> 3] >> (x_coord & 0x07)) & 1;
}
/* Set a module to dark/black */
INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
symbol->encoded_data[y_coord][x_coord >> 3] |= 1 << (x_coord & 0x07);
}
/* Return true (1-8) if a module is colour, otherwise false (0) */
INTERNAL int module_colour_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
return symbol->encoded_data[y_coord][x_coord];
}
/* Set a module to a colour */
INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, const int x_coord, const int colour) {
symbol->encoded_data[y_coord][x_coord] = colour;
}
#endif
/* Set a dark/black module to white (i.e. unset) */
INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
symbol->encoded_data[y_coord][x_coord >> 3] &= ~(1 << (x_coord & 0x07));
}
/* Expands from a width pattern to a bit pattern */
INTERNAL void expand(struct zint_symbol *symbol, const char data[]) {
int reader, n = (int) strlen(data);
int writer, i;
int latch, num;
writer = 0;
latch = 1;
for (reader = 0; reader < n; reader++) {
num = ctoi(data[reader]);
for (i = 0; i < num; i++) {
if (latch) {
set_module(symbol, symbol->rows, writer);
}
writer++;
}
latch = !latch;
}
if (symbol->symbology != BARCODE_PHARMA) {
if (writer > symbol->width) {
symbol->width = writer;
}
} else {
/* Pharmacode One ends with a space - adjust for this */
if (writer > symbol->width + 2) {
symbol->width = writer - 2;
}
}
symbol->rows = symbol->rows + 1;
}
/* Indicates which symbologies can have row binding */
INTERNAL int is_stackable(const int symbology) {
if (symbology < BARCODE_PHARMA_TWO && symbology != BARCODE_POSTNET) {
return 1;
}
switch (symbology) {
case BARCODE_CODE128B:
case BARCODE_ISBNX:
case BARCODE_EAN14:
case BARCODE_NVE18:
case BARCODE_KOREAPOST:
case BARCODE_PLESSEY:
case BARCODE_TELEPEN_NUM:
case BARCODE_ITF14:
case BARCODE_CODE32:
case BARCODE_CODABLOCKF:
case BARCODE_HIBC_BLOCKF:
return 1;
break;
}
return 0;
}
/* Indicates which symbols can have addon (EAN-2 and EAN-5) */
INTERNAL int is_extendable(const int symbology) {
switch (symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CHK:
case BARCODE_UPCA:
case BARCODE_UPCA_CHK:
case BARCODE_UPCE:
case BARCODE_UPCE_CHK:
case BARCODE_ISBNX:
case BARCODE_EANX_CC:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
return 1;
break;
}
return 0;
}
/* Indicates which symbols can have composite 2D component data */
INTERNAL int is_composite(const int symbology) {
return symbology >= BARCODE_EANX_CC && symbology <= BARCODE_DBAR_EXPSTK_CC;
}
/* Whether next two characters are digits */
INTERNAL int istwodigits(const unsigned char source[], const int length, const int position) {
if ((position + 1 < length) && (source[position] >= '0') && (source[position] <= '9')
&& (source[position + 1] >= '0') && (source[position + 1] <= '9')) {
return 1;
}
return 0;
}
/* State machine to decode UTF-8 to Unicode codepoints (state 0 means done, state 12 means error) */
INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte) {
/*
Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
See https://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
*/
static const unsigned char utf8d[] = {
/* The first part of the table maps bytes to character classes that
* reduce the size of the transition table and create bitmasks. */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,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,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
/* The second part is a transition table that maps a combination
* of a state of the automaton and a character class to a state. */
0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
12,36,12,12,12,12,12,12,12,12,12,12,
};
unsigned int type = utf8d[byte];
*codep = *state != 0 ? (byte & 0x3fu) | (*codep << 6) : (0xff >> type) & byte;
*state = utf8d[256 + *state + type];
return *state;
}
/* Is string valid UTF-8? */
INTERNAL int is_valid_utf8(const unsigned char source[], const int length) {
int i;
unsigned int codepoint, state = 0;
for (i = 0; i < length; i++) {
if (decode_utf8(&state, &codepoint, source[i]) == 12) {
return 0;
}
}
return state == 0;
}
/* Convert UTF-8 to Unicode. If `disallow_4byte` unset, allow all values (UTF-32). If `disallow_4byte` set,
* only allow codepoints <= U+FFFF (ie four-byte sequences not allowed) (UTF-16, no surrogates) */
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[],
int *length, const int disallow_4byte) {
int bpos;
int jpos;
unsigned int codepoint, state = 0;
bpos = 0;
jpos = 0;
while (bpos < *length) {
do {
decode_utf8(&state, &codepoint, source[bpos++]);
} while (bpos < *length && state != 0 && state != 12);
if (state != 0) {
strcpy(symbol->errtxt, "240: Corrupt Unicode data");
return ZINT_ERROR_INVALID_DATA;
}
if (disallow_4byte && codepoint > 0xffff) {
strcpy(symbol->errtxt, "242: Unicode sequences of more than 3 bytes not supported");
return ZINT_ERROR_INVALID_DATA;
}
vals[jpos] = codepoint;
jpos++;
}
*length = jpos;
return 0;
}
/* Set symbol height, returning a warning if not within minimum and/or maximum if given.
`default_height` does not include height of fixed-height rows (i.e. separators/composite data) */
INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, const float default_height,
const float max_height, const int no_errtxt) {
int error_number = 0;
float fixed_height = 0.0f;
int zero_count = 0;
float row_height;
int i;
int rows = symbol->rows ? symbol->rows : 1; /* Sometimes called before expand() */
for (i = 0; i < rows; i++) {
if (symbol->row_height[i]) {
fixed_height += symbol->row_height[i];
} else {
zero_count++;
}
}
if (zero_count) {
if (symbol->height) {
row_height = (symbol->height - fixed_height) / zero_count;
} else if (default_height) {
row_height = default_height / zero_count;
} else {
row_height = min_row_height;
}
if (row_height < 0.5f) { /* Absolute minimum */
row_height = 0.5f;
}
if (min_row_height && row_height < min_row_height) {
error_number = ZINT_WARN_NONCOMPLIANT;
if (!no_errtxt) {
strcpy(symbol->errtxt, "247: Height not compliant with standards");
}
}
symbol->height = row_height * zero_count + fixed_height;
} else {
symbol->height = fixed_height; /* Ignore any given height */
}
if (max_height && symbol->height > max_height) {
error_number = ZINT_WARN_NONCOMPLIANT;
if (!no_errtxt) {
strcpy(symbol->errtxt, "248: Height not compliant with standards");
}
}
return error_number;
}
/* Returns red component if any of ultra colour indexing "0CBMRYGKW" */
INTERNAL int colour_to_red(const int colour) {
int return_val = 0;
switch (colour) {
case 8: // White
case 3: // Magenta
case 4: // Red
case 5: // Yellow
return_val = 255;
break;
}
return return_val;
}
/* Returns green component if any of ultra colour indexing "0CBMRYGKW" */
INTERNAL int colour_to_green(const int colour) {
int return_val = 0;
switch (colour) {
case 8: // White
case 1: // Cyan
case 5: // Yellow
case 6: // Green
return_val = 255;
break;
}
return return_val;
}
/* Returns blue component if any of ultra colour indexing "0CBMRYGKW" */
INTERNAL int colour_to_blue(const int colour) {
int return_val = 0;
switch (colour) {
case 8: // White
case 1: // Cyan
case 2: // Blue
case 3: // Magenta
return_val = 255;
break;
}
return return_val;
}
#ifdef ZINT_TEST
/* Dumps hex-formatted codewords in symbol->errtxt (for use in testing) */
void debug_test_codeword_dump(struct zint_symbol *symbol, const unsigned char *codewords, const int length) {
int i, max = length, cnt_len = 0;
if (length > 30) { /* 30*3 < errtxt 92 (100 - "Warning ") chars */
sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */
cnt_len = (int) strlen(symbol->errtxt);
max = 30 - (cnt_len + 2) / 3;
}
for (i = 0; i < max; i++) {
sprintf(symbol->errtxt + cnt_len + i * 3, "%02X ", codewords[i]);
}
symbol->errtxt[strlen(symbol->errtxt) - 1] = '\0'; /* Zap last space */
}
/* Dumps decimal-formatted codewords in symbol->errtxt (for use in testing) */
void debug_test_codeword_dump_int(struct zint_symbol *symbol, const int *codewords, const int length) {
int i, max = 0, cnt_len, errtxt_len;
char temp[20];
errtxt_len = sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */
for (i = 0, cnt_len = errtxt_len; i < length; i++) {
cnt_len += sprintf(temp, "%d ", codewords[i]);
if (cnt_len > 92) {
break;
}
max++;
}
for (i = 0; i < max; i++) {
errtxt_len += sprintf(symbol->errtxt + errtxt_len, "%d ", codewords[i]);
}
symbol->errtxt[strlen(symbol->errtxt) - 1] = '\0'; /* Zap last space */
}
#endif

156
3rdparty/zint-2.10.0/backend/common.h vendored Normal file
View File

@@ -0,0 +1,156 @@
/* common.h - Header for all common functions in common.c */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef __COMMON_H
#define __COMMON_H
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
/* The most commonly used set */
#define NEON "0123456789"
#include "zint.h"
#include "zintconfig.h"
#include <stdlib.h>
#include <string.h>
/* Helpers to cast away char pointer signedness */
#define ustrlen(source) strlen((const char *) (source))
#define ustrcpy(target, source) strcpy((char *) (target), (const char *) (source))
#define ustrcat(target, source) strcat((char *) (target), (const char *) (source))
#define ustrncat(target, source, count) strncat((char *) (target), (const char *) (source), (count))
#ifdef _MSC_VER
# if _MSC_VER == 1200 /* VC6 */
# define ceilf (float) ceil
# define floorf (float) floor
# define fmodf (float) fmod
# endif
# if _MSC_VER < 1800 /* round (C99) not before MSVC 2013 (C++ 12.0) */
# define round(arg) floor((arg) + 0.5)
# define roundf(arg) floorf((arg) + 0.5f)
# endif
# pragma warning(disable: 4244) /* conversion from int to float */
# if _MSC_VER != 1200 /* VC6 */
# pragma warning(disable: 4996) /* function or variable may be unsafe */
# endif
#endif
/* Is float integral value? (https://stackoverflow.com/a/40404149/664741) */
#define isfintf(arg) (fmodf(arg, 1.0f) == 0.0f)
#if (defined(__GNUC__) || defined(__clang__)) && !defined(ZINT_TEST) && !defined(__MINGW32__)
# define INTERNAL __attribute__ ((visibility ("hidden")))
#elif defined(ZINT_TEST)
# define INTERNAL ZINT_EXTERN /* The test suite references INTERNAL functions, so they need to be exported */
#else
# define INTERNAL
#endif
#ifdef ZINT_TEST
#define STATIC_UNLESS_ZINT_TEST INTERNAL
#else
#define STATIC_UNLESS_ZINT_TEST static
#endif
#define COMMON_INLINE 1
#ifdef COMMON_INLINE
/* Return true (1) if a module is dark/black, otherwise false (0) */
# define module_is_set(s, y, x) (((s)->encoded_data[(y)][(x) >> 3] >> ((x) & 0x07)) & 1)
/* Set a module to dark/black */
# define set_module(s, y, x) do { (s)->encoded_data[(y)][(x) >> 3] |= 1 << ((x) & 0x07); } while (0)
/* Return true (1-8) if a module is colour, otherwise false (0) */
# define module_colour_is_set(s, y, x) ((s)->encoded_data[(y)][(x)])
/* Set a module to a colour */
# define set_module_colour(s, y, x, c) do { (s)->encoded_data[(y)][(x)] = (c); } while (0)
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
INTERNAL int ctoi(const char source);
INTERNAL char itoc(const int source);
INTERNAL int to_int(const unsigned char source[], const int length);
INTERNAL void to_upper(unsigned char source[]);
INTERNAL int chr_cnt(const unsigned char string[], const int length, const unsigned char c);
INTERNAL int is_sane(const char test_string[], const unsigned char source[], const int length);
INTERNAL void lookup(const char set_string[], const char *table[], const char data, char dest[]);
INTERNAL void bin_append(const int arg, const int length, char *binary);
INTERNAL int bin_append_posn(const int arg, const int length, char *binary, const int bin_posn);
INTERNAL int posn(const char set_string[], const char data);
#ifndef COMMON_INLINE
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL int module_colour_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, const int x_coord,
const int colour);
#endif
INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL void expand(struct zint_symbol *symbol, const char data[]);
INTERNAL int is_stackable(const int symbology);
INTERNAL int is_extendable(const int symbology);
INTERNAL int is_composite(const int symbology);
INTERNAL int istwodigits(const unsigned char source[], const int length, const int position);
INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte);
INTERNAL int is_valid_utf8(const unsigned char source[], const int length);
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[],
int *length, const int disallow_4byte);
INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, const float default_height,
const float max_height, const int set_errtxt);
INTERNAL int colour_to_red(const int colour);
INTERNAL int colour_to_green(const int colour);
INTERNAL int colour_to_blue(const int colour);
#ifdef ZINT_TEST
INTERNAL void debug_test_codeword_dump(struct zint_symbol *symbol, const unsigned char *codewords,
const int length);
INTERNAL void debug_test_codeword_dump_int(struct zint_symbol *symbol, const int *codewords, const int length);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __COMMON_H */

1631
3rdparty/zint-2.10.0/backend/composite.c vendored Normal file

File diff suppressed because it is too large Load Diff

140
3rdparty/zint-2.10.0/backend/composite.h vendored Normal file
View File

@@ -0,0 +1,140 @@
/* composite.c - Tables for UCC.EAN Composite Symbols */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* CC-A component coefficients from ISO/IEC 24728:2006 Annex F */
static const unsigned short int ccaCoeffs[30] = {
/* k = 4 */
522, 568, 723, 809,
/* k = 5 */
427, 919, 460, 155, 566,
/* k = 6 */
861, 285, 19, 803, 17, 766,
/* k = 7 */
76, 925, 537, 597, 784, 691, 437,
/* k = 8 */
237, 308, 436, 284, 646, 653, 428, 379
};
/* rows, error codewords, k-offset of valid CC-A sizes from ISO/IEC 24723:2006 Table 9 */
static const char ccaVariants[51] = {
5, 6, 7, 8, 9, 10, 12, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7,
4, 4, 5, 5, 6, 6, 7, 4, 5, 6, 7, 7, 4, 5, 6, 7, 8,
0, 0, 4, 4, 9, 9, 15, 0, 4, 9, 15, 15, 0, 4, 9, 15, 22
};
/* following is Left RAP, Centre RAP, Right RAP and Start Cluster from ISO/IEC 24723:2006 tables 10 and 11 */
static const char aRAPTable[68] = {
39, 1, 32, 8, 14, 43, 20, 11, 1, 5, 15, 21, 40, 43, 46, 34, 29,
0, 0, 0, 0, 0, 0, 0, 43, 33, 37, 47, 1, 20, 23, 26, 14, 9,
19, 33, 12, 40, 46, 23, 52, 23, 13, 17, 27, 33, 52, 3, 6, 46, 41,
6, 0, 3, 3, 3, 0, 3, 3, 0, 3, 6, 6, 0, 0, 0, 0, 3
};
/* Row Address Patterns are as defined in pdf417.h */
/* Generated by tools/gen_pwr928_table.php */
static const UINT pwr928[69][7] = {
{ 0, 0, 0, 0, 0, 0, 1, },
{ 0, 0, 0, 0, 0, 0, 2, },
{ 0, 0, 0, 0, 0, 0, 4, },
{ 0, 0, 0, 0, 0, 0, 8, },
{ 0, 0, 0, 0, 0, 0, 16, },
{ 0, 0, 0, 0, 0, 0, 32, },
{ 0, 0, 0, 0, 0, 0, 64, },
{ 0, 0, 0, 0, 0, 0, 128, },
{ 0, 0, 0, 0, 0, 0, 256, },
{ 0, 0, 0, 0, 0, 0, 512, },
{ 0, 0, 0, 0, 0, 1, 96, },
{ 0, 0, 0, 0, 0, 2, 192, },
{ 0, 0, 0, 0, 0, 4, 384, },
{ 0, 0, 0, 0, 0, 8, 768, },
{ 0, 0, 0, 0, 0, 17, 608, },
{ 0, 0, 0, 0, 0, 35, 288, },
{ 0, 0, 0, 0, 0, 70, 576, },
{ 0, 0, 0, 0, 0, 141, 224, },
{ 0, 0, 0, 0, 0, 282, 448, },
{ 0, 0, 0, 0, 0, 564, 896, },
{ 0, 0, 0, 0, 1, 201, 864, },
{ 0, 0, 0, 0, 2, 403, 800, },
{ 0, 0, 0, 0, 4, 807, 672, },
{ 0, 0, 0, 0, 9, 687, 416, },
{ 0, 0, 0, 0, 19, 446, 832, },
{ 0, 0, 0, 0, 38, 893, 736, },
{ 0, 0, 0, 0, 77, 859, 544, },
{ 0, 0, 0, 0, 155, 791, 160, },
{ 0, 0, 0, 0, 311, 654, 320, },
{ 0, 0, 0, 0, 623, 380, 640, },
{ 0, 0, 0, 1, 318, 761, 352, },
{ 0, 0, 0, 2, 637, 594, 704, },
{ 0, 0, 0, 5, 347, 261, 480, },
{ 0, 0, 0, 10, 694, 523, 32, },
{ 0, 0, 0, 21, 461, 118, 64, },
{ 0, 0, 0, 42, 922, 236, 128, },
{ 0, 0, 0, 85, 916, 472, 256, },
{ 0, 0, 0, 171, 905, 16, 512, },
{ 0, 0, 0, 343, 882, 33, 96, },
{ 0, 0, 0, 687, 836, 66, 192, },
{ 0, 0, 1, 447, 744, 132, 384, },
{ 0, 0, 2, 895, 560, 264, 768, },
{ 0, 0, 5, 863, 192, 529, 608, },
{ 0, 0, 11, 798, 385, 131, 288, },
{ 0, 0, 23, 668, 770, 262, 576, },
{ 0, 0, 47, 409, 612, 525, 224, },
{ 0, 0, 94, 819, 297, 122, 448, },
{ 0, 0, 189, 710, 594, 244, 896, },
{ 0, 0, 379, 493, 260, 489, 864, },
{ 0, 0, 759, 58, 521, 51, 800, },
{ 0, 1, 590, 117, 114, 103, 672, },
{ 0, 3, 252, 234, 228, 207, 416, },
{ 0, 6, 504, 468, 456, 414, 832, },
{ 0, 13, 81, 8, 912, 829, 736, },
{ 0, 26, 162, 17, 897, 731, 544, },
{ 0, 52, 324, 35, 867, 535, 160, },
{ 0, 104, 648, 71, 807, 142, 320, },
{ 0, 209, 368, 143, 686, 284, 640, },
{ 0, 418, 736, 287, 444, 569, 352, },
{ 0, 837, 544, 574, 889, 210, 704, },
{ 1, 747, 161, 221, 850, 421, 480, },
{ 3, 566, 322, 443, 772, 843, 32, },
{ 7, 204, 644, 887, 617, 758, 64, },
{ 14, 409, 361, 847, 307, 588, 128, },
{ 28, 818, 723, 766, 615, 248, 256, },
{ 57, 709, 519, 605, 302, 496, 512, },
{ 115, 491, 111, 282, 605, 65, 96, },
{ 231, 54, 222, 565, 282, 130, 192, },
{ 462, 108, 445, 202, 564, 260, 384, },
};

View File

@@ -0,0 +1,32 @@
/* Sed: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/versions.asp */
#if defined (_WIN32) && (defined(_USRDLL) || defined(DLL_EXPORT) || defined(PIC))
#include <windows.h>
#include <shlwapi.h>
#include "zintconfig.h"
#ifdef __cplusplus
extern "C"
{
#endif
__declspec(dllexport) HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi);
#ifdef __cplusplus
}
#endif
HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi)
{
if (!pdvi || (sizeof(*pdvi) != pdvi->info1.cbSize))
return (E_INVALIDARG);
pdvi->info1.dwMajorVersion = ZINT_VERSION_MAJOR;
pdvi->info1.dwMinorVersion = ZINT_VERSION_MINOR;
pdvi->info1.dwBuildNumber = ZINT_VERSION_RELEASE;
pdvi->info1.dwPlatformID = DLLVER_PLATFORM_WINDOWS;
if (sizeof(DLLVERSIONINFO2) == pdvi->info1.cbSize)
pdvi->ullVersion = MAKEDLLVERULL(ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE, ZINT_VERSION_BUILD);
return S_OK;
}
#endif /* _WIN32 */

1222
3rdparty/zint-2.10.0/backend/dmatrix.c vendored Normal file

File diff suppressed because it is too large Load Diff

245
3rdparty/zint-2.10.0/backend/dmatrix.h vendored Normal file
View File

@@ -0,0 +1,245 @@
/* dmatrix.h - Handles Data Matrix ECC 200 */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/*
Containes Extended Rectangular Data Matrix (DMRE)
See http://www.dmre.info for information
Contact: harald.oehlmann@eurodatacouncil.org
*/
#ifndef __DMATRIX_H
#define __DMATRIX_H
#define DM_NULL 0
#define DM_ASCII 1
#define DM_C40 2
#define DM_TEXT 3
#define DM_X12 4
#define DM_EDIFACT 5
#define DM_BASE256 6
static const char 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,
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, 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 const char 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,
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,
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 const char 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,
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, 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 const char 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,
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,
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
};
// Position in option array [symbol option value - 1]
// The position in the option array is by increasing total data codewords with square first
// The last comment value is the total data codewords value.
// The index of this array is the --vers parameter value -1 and is given as first comment value
static const unsigned short int intsymbol[] = {
/* Standard DM */
0, /* 1: 10x10 , 3*/ 1, /* 2: 12x12 , 5*/ 3, /* 3: 14x14 , 8*/ 5, /* 4: 16x16 , 12*/
7, /* 5: 18x18 , 18*/ 9, /* 6: 20x20 , 22*/ 12, /* 7: 22x22 , 30*/ 15, /* 8: 24x24 , 36*/
18, /* 9: 26x26 , 44*/ 23, /* 10: 32x32 , 62*/ 31, /* 11: 36x36 , 86*/ 34, /* 12: 40x40 ,114*/
36, /* 13: 44x44 ,144*/ 37, /* 14: 48x48 ,174*/ 38, /* 15: 52x52 ,204*/ 39, /* 16: 64x64 ,280*/
40, /* 17: 72x72 ,368*/ 41, /* 18: 80x80 ,456*/ 42, /* 19: 88x88 ,576*/ 43, /* 20: 96x96 ,696*/
44, /* 21:104x104,816*/ 45, /* 22:120x120,1050*/46, /* 23:132x132,1304*/47, /* 24:144x144,1558*/
2, /* 25: 8x18 , 5*/ 4, /* 26: 8x32 , 10*/ 6, /* 27: 12x26 , 16*/ 10, /* 28: 12x36 , 22*/
13, /* 29: 16x36 , 32*/ 20, /* 30: 16x48 , 49*/
/* DMRE */
8, /* 31: 8x48 , 18*/ 11, /* 32: 8x64 , 24*/ 14, /* 33: 8x80 , 32*/ 16, /* 34: 8x96 , 38*/
21, /* 35: 8x120, 49*/ 25, /* 36: 8x144, 63*/ 17, /* 37: 12x64 , 43*/ 26, /* 38: 12x88 , 64*/
24, /* 39: 16x64 , 62*/ 19, /* 40: 20x36 , 44*/ 22, /* 41: 20x44 , 56*/ 30, /* 42: 20x64 , 84*/
28, /* 43: 22x48 , 72*/ 29, /* 44: 24x48 , 80*/ 33, /* 45: 24x64 ,108*/ 27, /* 46: 26x40 , 70*/
32, /* 47: 26x48 , 90*/ 35, /* 48: 26x64 ,118*/
};
// Number of DM Sizes
#define DMSIZESCOUNT 48
// Number of 144x144 for special interlace
#define INTSYMBOL144 47
// Is the current code a DMRE code ?
// This is the case, if intsymbol index >= 30
static const char isDMRE[] = {
/* 0*/ 0, /* 10x10, 3*/ 0, /* 12x12 , 5*/ 0, /* 8x18 , 5*/ 0, /* 14x14 , 8*/
/* 4*/ 0, /* 8x32 , 10*/ 0, /* 16x16 , 12*/ 0, /* 12x26 , 16*/ 0, /* 18x18 , 18*/
/* 8*/ 1, /* 8x48 , 18*/ 0, /* 20x20 , 22*/ 0, /* 12x36 , 22*/ 1, /* 8x64 , 24*/
/*12*/ 0, /* 22x22 , 30*/ 0, /* 16x36 , 32*/ 1, /* 8x80 , 32*/ 0, /* 24x24 , 36*/
/*16*/ 1, /* 8x96 , 38*/ 1, /* 12x64 , 43*/ 0, /* 26x26 , 44*/ 1, /* 20x36 , 44*/
/*20*/ 0, /* 16x48 , 49*/ 1, /* 8x120, 49*/ 1, /* 20x44 , 56*/ 0, /* 32x32 , 62*/
/*24*/ 1, /* 16x64 , 62*/ 1, /* 8x144, 63*/ 1, /* 12x88 , 64*/ 1, /* 26x40 , 70*/
/*28*/ 1, /* 22x48 , 72*/ 1, /* 24x48 , 80*/ 1, /* 20x64 , 84*/ 0, /* 36x36 , 86*/
/*32*/ 1, /* 26x48 , 90*/ 1, /* 24x64 ,108*/ 0, /* 40x40 ,114*/ 1, /* 26x64 ,118*/
/*36*/ 0, /* 44x44 ,144*/ 0, /* 48x48 ,174*/ 0, /* 52x52 ,204*/ 0, /* 64x64 ,280*/
/*40*/ 0, /* 72x72 ,368*/ 0, /* 80x80 ,456*/ 0, /* 88x88 ,576*/ 0, /* 96x96 ,696*/
/*44*/ 0, /*104x104,816*/ 0, /*120x120,1050*/0, /*132x132,1304*/0 /*144x144,1558*/
};
// Horizontal matrix size
static const unsigned short int matrixH[] = {
/* 0*/ 10, /* 10x10 , 3*/ 12, /* 12x12 , 5 */ 8, /* 8x18 , 5*/ 14, /* 14x14 , 8*/
/* 4*/ 8, /* 8x32 , 10*/ 16, /* 16x16 , 12*/ 12, /* 12x26 , 16*/ 18, /* 18x18 , 18*/
/* 8*/ 8, /* 8x48 , 18*/ 20, /* 20x20 , 22*/ 12, /* 12x36 , 22*/ 8, /* 8x64 , 24*/
/*12*/ 22, /* 22x22 , 30*/ 16, /* 16x36 , 32*/ 8, /* 8x80 , 32*/ 24, /* 24x24 , 36*/
/*16*/ 8, /* 8x96 , 38*/ 12, /* 12x64 , 43*/ 26, /* 26x26 , 44*/ 20, /* 20x36 , 44*/
/*20*/ 16, /* 16x48 , 49*/ 8, /* 8x120, 49*/ 20, /* 20x44 , 56*/ 32, /* 32x32 , 62*/
/*24*/ 16, /* 16x64 , 62*/ 8, /* 8x144, 63*/ 12, /* 12x88 , 64*/ 26, /* 26x40 , 70*/
/*28*/ 22, /* 22x48 , 72*/ 24, /* 24x48 , 80*/ 20, /* 20x64 , 84*/ 36, /* 36x36 , 86*/
/*32*/ 26, /* 26x48 , 90*/ 24, /* 24x64 ,108*/ 40, /* 40x40 ,114*/ 26, /* 26x64 ,118*/
/*36*/ 44, /* 44x44 ,144*/ 48, /* 48x48 ,174*/ 52, /* 52x52 ,204*/ 64, /* 64x64 ,280*/
/*40*/ 72, /* 72x72 ,368*/ 80, /* 80x80 ,456*/ 88, /* 88x88 ,576*/ 96, /* 96x96 ,696*/
/*44*/104, /*104x104,816*/ 120,/*120x120,1050*/132,/*132x132,1304*/144 /*144x144,1558*/
};
// Vertical matrix sizes
static const unsigned short int matrixW[] = {
/* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 18, /* 8x18 */ 14, /* 14x14 */
/* 4*/ 32, /* 8x32 */ 16, /* 16x16 */ 26, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 48, /* 8x48 */ 20, /* 20x20 */ 36, /* 12x36 */ 64, /* 8x64 */
/*12*/ 22, /* 22x22 */ 36, /* 16x36 */ 80, /* 8x80 */ 24, /* 24x24 */
/*16*/ 96, /* 8x96 */ 64, /* 12x64 */ 26, /* 26x26 */ 36, /* 20x36 */
/*20*/ 48, /* 16x48 */120, /* 8x120*/ 44, /* 20x44 */ 32, /* 32x32 */
/*24*/ 64, /* 16x64 */144, /* 8x144*/ 88, /* 12x88 */ 40, /* 26x40 */
/*28*/ 48, /* 22x48 */ 48, /* 24x48 */ 64, /* 20x64 */ 36, /* 36x36 */
/*32*/ 48, /* 26x48 */ 64, /* 24x64 */ 40, /* 40x40 */ 64, /* 26x64 */
/*36*/ 44, /* 44x44 */ 48, /* 48x48 */ 52, /* 52x52 */ 64, /* 64x64 */
/*40*/ 72, /* 72x72 */ 80, /* 80x80 */ 88, /* 88x88 */ 96, /* 96x96 */
/*44*/104, /*104x104*/120, /*120x120*/ 132, /*132x132*/144 /*144x144*/
};
// Horizontal submodule size (including subfinder)
static const unsigned short int matrixFH[] = {
/* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 8, /* 8x18 */ 14, /* 14x14 */
/* 4*/ 8, /* 8x32 */ 16, /* 16x16 */ 12, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 8, /* 8x48 */ 20, /* 20x20 */ 12, /* 12x36 */ 8, /* 8x64 */
/*12*/ 22, /* 22x22 */ 16, /* 16x36 */ 8, /* 8x80 */ 24, /* 24x24 */
/*16*/ 8, /* 8x96 */ 12, /* 12x64 */ 26, /* 26x26 */ 20, /* 20x36 */
/*20*/ 16, /* 16x48 */ 8, /* 8x120*/ 20, /* 20x44 */ 16, /* 32x32 */
/*24*/ 16, /* 16x64 */ 8, /* 8x144*/ 12, /* 12x88 */ 26, /* 26x40 */
/*28*/ 22, /* 22x48 */ 24, /* 24x48 */ 20, /* 20x64 */ 18, /* 36x36 */
/*32*/ 26, /* 26x48 */ 24, /* 24x64 */ 20, /* 40x40 */ 26, /* 26x64 */
/*36*/ 22, /* 44x44 */ 24, /* 48x48 */ 26, /* 52x52 */ 16, /* 64x64 */
/*40*/ 18, /* 72x72 */ 20, /* 80x80 */ 22, /* 88x88 */ 24, /* 96x96 */
/*44*/ 26, /*104x104*/ 20, /*120x120*/ 22, /*132x132*/ 24 /*144x144*/
};
// Vertical submodule size (including subfinder)
static const unsigned short int matrixFW[] = {
/* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 18, /* 8x18 */ 14, /* 14x14 */
/* 4*/ 16, /* 8x32 */ 16, /* 16x16 */ 26, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 24, /* 8x48 */ 20, /* 20x20 */ 18, /* 12x36 */ 16, /* 8x64 */
/*12*/ 22, /* 22x22 */ 18, /* 16x36 */ 20, /* 8x80 */ 24, /* 24x24 */
/*16*/ 24, /* 8x96 */ 16, /* 12x64 */ 26, /* 26x26 */ 18, /* 20x36 */
/*20*/ 24, /* 16x48 */ 20, /* 8x120*/ 22, /* 20x44 */ 16, /* 32x32 */
/*24*/ 16, /* 16x64 */ 24, /* 8x144*/ 22, /* 12x88 */ 20, /* 26x40 */
/*28*/ 24, /* 22x48 */ 24, /* 24x48 */ 16, /* 20x64 */ 18, /* 36x36 */
/*32*/ 24, /* 26x48 */ 16, /* 24x64 */ 20, /* 40x40 */ 16, /* 26x64 */
/*36*/ 22, /* 44x44 */ 24, /* 48x48 */ 26, /* 52x52 */ 16, /* 64x64 */
/*40*/ 18, /* 72x72 */ 20, /* 80x80 */ 22, /* 88x88 */ 24, /* 96x96 */
/*44*/ 26, /*104x104*/ 20, /*120x120*/ 22, /*132x132*/ 24 /*144x144*/
};
// Total Data Codewords
static const unsigned short int matrixbytes[] = {
/* 0*/ 3, /* 10x10 */ 5, /* 12x12 */ 5, /* 8x18 */ 8, /* 14x14 */
/* 4*/ 10, /* 8x32 */ 12, /* 16x16 */ 16, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 18, /* 8x48 */ 22, /* 20x20 */ 22, /* 12x36 */ 24, /* 8x64 */
/*12*/ 30, /* 22x22 */ 32, /* 16x36 */ 32, /* 8x80 */ 36, /* 24x24 */
/*16*/ 38, /* 8x96 */ 43, /* 12x64 */ 44, /* 26x26 */ 44, /* 20x36 */
/*20*/ 49, /* 16x48 */ 49, /* 8x120*/ 56, /* 20x44 */ 62, /* 32x32 */
/*24*/ 62, /* 16x64 */ 63, /* 8x144*/ 64, /* 12x88 */ 70, /* 26x40 */
/*28*/ 72, /* 22x48 */ 80, /* 24x48 */ 84, /* 20x64 */ 86, /* 36x36 */
/*32*/ 90, /* 26x48 */ 108, /* 24x64 */ 114, /* 40x40 */ 118, /* 26x64 */
/*36*/ 144, /* 44x44 */ 174, /* 48x48 */ 204, /* 52x52 */ 280, /* 64x64 */
/*40*/ 368, /* 72x72 */ 456, /* 80x80 */ 576, /* 88x88 */ 696, /* 96x96 */
/*44*/ 816, /*104x104*/1050, /*120x120*/1304, /*132x132*/1558 /*144x144*/
};
// Data Codewords per RS-Block
static const unsigned short int matrixdatablock[] = {
/* 0*/ 3, /* 10x10 */ 5, /* 12x12 */ 5, /* 8x18 */ 8, /* 14x14 */
/* 4*/ 10, /* 8x32 */ 12, /* 16x16 */ 16, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 18, /* 8x48 */ 22, /* 20x20 */ 22, /* 12x36 */ 24, /* 8x64 */
/*12*/ 30, /* 22x22 */ 32, /* 16x36 */ 32, /* 8x80 */ 36, /* 24x24 */
/*16*/ 38, /* 8x96 */ 43, /* 12x64 */ 44, /* 26x26 */ 44, /* 20x36 */
/*20*/ 49, /* 16x48 */ 49, /* 8x120*/ 56, /* 20x44 */ 62, /* 32x32 */
/*24*/ 62, /* 16x64 */ 63, /* 8x144*/ 64, /* 12x88 */ 70, /* 26x40 */
/*28*/ 72, /* 22x48 */ 80, /* 24x48 */ 84, /* 20x64 */ 86, /* 36x36 */
/*32*/ 90, /* 26x48 */ 108, /* 24x64 */ 114, /* 40x40 */ 118, /* 26x64 */
/*36*/ 144, /* 44x44 */ 174, /* 48x48 */ 102, /* 52x52 */ 140, /* 64x64 */
/*40*/ 92, /* 72x72 */ 114, /* 80x80 */ 144, /* 88x88 */ 174, /* 96x96 */
/*44*/ 136, /*104x104*/ 175, /*120x120*/ 163, /*132x132*/ 156 /* 144x144*/
};
// ECC Codewords per RS-Block
static const unsigned short int matrixrsblock[] = {
/* 0*/ 5, /* 10x10 */ 7, /* 12x12 */ 7, /* 8x18 */ 10, /* 14x14 */
/* 4*/ 11, /* 8x32 */ 12, /* 16x16 */ 14, /* 12x26 */ 14, /* 18x18 */
/* 8*/ 15, /* 8x48 */ 18, /* 20x20 */ 18, /* 12x36 */ 18, /* 8x64 */
/*12*/ 20, /* 22x22 */ 24, /* 16x36 */ 22, /* 8x80 */ 24, /* 24x24 */
/*16*/ 28, /* 8x96 */ 27, /* 12x64 */ 28, /* 26x26 */ 28, /* 20x36 */
/*20*/ 28, /* 16x48 */ 32, /* 8x120*/ 34, /* 20x44 */ 36, /* 32x32 */
/*24*/ 36, /* 16x64 */ 36, /* 8x144*/ 36, /* 12x88 */ 38, /* 26x40 */
/*28*/ 38, /* 22x48 */ 41, /* 24x48 */ 42, /* 20x64 */ 42, /* 36x36 */
/*32*/ 42, /* 26x48 */ 46, /* 24x64 */ 48, /* 40x40 */ 50, /* 26x64 */
/*36*/ 56, /* 44x44 */ 68, /* 48x48 */ 42, /* 52x52 */ 56, /* 64x64 */
/*40*/ 36, /* 72x72 */ 48, /* 80x80 */ 56, /* 88x88 */ 68, /* 96x96 */
/*44*/ 56, /*104x104*/ 68, /*120x120*/ 62, /*132x132*/ 62 /*144x144*/
};
#endif /* __DMATRIX_H */

1602
3rdparty/zint-2.10.0/backend/dotcode.c vendored Normal file

File diff suppressed because it is too large Load Diff

279
3rdparty/zint-2.10.0/backend/eci.c vendored Normal file
View File

@@ -0,0 +1,279 @@
/* eci.c - Extended Channel Interpretations
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#include "eci.h"
#include "eci_sb.h"
#include "sjis.h"
#include "big5.h"
#include "gb2312.h"
#include "ksx1001.h"
/* ECI 20 Shift JIS */
static int sjis_wctomb(unsigned char *r, const unsigned int wc) {
int ret;
unsigned int c;
ret = sjis_wctomb_zint(&c, wc);
if (ret == 0) {
return 0;
}
if (ret == 2) {
r[0] = (unsigned char) (c >> 8);
r[1] = (unsigned char) (c & 0xff);
} else {
*r = (unsigned char) c;
}
return ret;
}
/* ECI 27 ASCII (ISO/IEC 646:1991 IRV (US)) */
static int ascii_wctosb(unsigned char *r, const unsigned int wc) {
if (wc < 0x80) {
*r = (unsigned char) wc;
return 1;
}
return 0;
}
/* ECI 170 ASCII subset (ISO/IEC 646:1991 Invariant, excludes chars that historically had national variants) */
static int ascii_invariant_wctosb(unsigned char *r, const unsigned int wc) {
if (wc == 0x7f || (wc <= 'z' && wc != '#' && wc != '$' && wc != '@' && (wc <= 'Z' || wc == '_' || wc >= 'a'))) {
*r = (unsigned char) wc;
return 1;
}
return 0;
}
/* ECI 28 Big5 Chinese (Taiwan) */
static int big5_wctomb(unsigned char *r, const unsigned int wc) {
unsigned int c;
if (wc < 0x80) {
*r = (unsigned char) wc;
return 1;
}
if (big5_wctomb_zint(&c, wc)) {
r[0] = (unsigned char) (c >> 8);
r[1] = (unsigned char) (c & 0xff);
return 2;
}
return 0;
}
/* ECI 29 GB 2312 Chinese (PRC) */
static int gb2312_wctomb(unsigned char *r, const unsigned int wc) {
unsigned int c;
if (wc < 0x80) {
*r = (unsigned char) wc;
return 1;
}
if (gb2312_wctomb_zint(&c, wc)) {
r[0] = (unsigned char) (c >> 8);
r[1] = (unsigned char) (c & 0xff);
return 2;
}
return 0;
}
/* ECI 30 EUC-KR (KS X 1001, formerly KS C 5601) Korean
* See euc_kr_wctomb() in libiconv-1.16/lib/euc_kr.h */
static int euc_kr_wctomb(unsigned char *r, const unsigned int wc) {
unsigned int c;
if (wc < 0x80) {
*r = (unsigned char) wc;
return 1;
}
if (ksx1001_wctomb_zint(&c, wc)) {
r[0] = (unsigned char) ((c >> 8) + 0x80);
r[1] = (unsigned char) ((c & 0xff) + 0x80);
return 2;
}
return 0;
}
/* Helper to count the number of chars in a string within a range */
static int chr_range_cnt(const unsigned char string[], const int length, const unsigned char c1,
const unsigned char c2) {
int count = 0;
int i;
if (c1) {
for (i = 0; i < length; i++) {
if (string[i] >= c1 && string[i] <= c2) {
count++;
}
}
} else {
for (i = 0; i < length; i++) {
if (string[i] <= c2) {
count++;
}
}
}
return count;
}
/* Is ECI convertible from UTF-8? */
INTERNAL int is_eci_convertible(const int eci) {
if (eci == 26 || (eci > 30 && eci != 170)) { /* Exclude ECI 170 - ASCII Invariant */
/* UTF-8 (26) or 8-bit binary data (899) or undefined (> 30 and < 899) or not character set (> 899) */
return 0;
}
return 1;
}
/* Calculate length required to convert UTF-8 to (double-byte) encoding */
INTERNAL int get_eci_length(const int eci, const unsigned char source[], int length) {
if (eci == 20) { /* Shift JIS */
/* Only ASCII backslash (reverse solidus) exceeds UTF-8 length */
length += chr_cnt(source, length, '\\');
} else if (eci == 25) { /* UCS-2BE */
/* All ASCII chars take 2 bytes */
length += chr_range_cnt(source, length, 0, 0x7F);
} else if (eci == 29) { /* GB 2312 (and GB 18030 if Han Xin) */
/* Not needed for GB 2312 but allow for GB 18030 4 byters */
length *= 2;
}
/* Big5 and EUC-KR fit in UTF-8 length */
return length;
}
/* Convert UTF-8 Unicode to other character encodings */
INTERNAL int utf8_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *p_length) {
typedef int (*eci_func_t)(unsigned char *r, const unsigned int wc);
static const eci_func_t eci_funcs[31] = {
NULL, NULL, NULL, NULL, iso8859_2_wctosb,
iso8859_3_wctosb, iso8859_4_wctosb, iso8859_5_wctosb, iso8859_6_wctosb, iso8859_7_wctosb,
iso8859_8_wctosb, iso8859_9_wctosb, iso8859_10_wctosb, iso8859_11_wctosb, NULL,
iso8859_13_wctosb, iso8859_14_wctosb, iso8859_15_wctosb, iso8859_16_wctosb, NULL,
sjis_wctomb, cp1250_wctosb, cp1251_wctosb, cp1252_wctosb, cp1256_wctosb,
ucs2be_wctomb, NULL, ascii_wctosb, big5_wctomb, gb2312_wctomb,
euc_kr_wctomb,
};
eci_func_t eci_func;
unsigned int codepoint, state;
int in_posn;
int out_posn;
int length = *p_length;
in_posn = 0;
out_posn = 0;
/* Special case ISO/IEC 8859-1 */
if (eci == 0 || eci == 3) { /* Default ECI 0 to ISO/IEC 8859-1 */
state = 0;
while (in_posn < length) {
do {
decode_utf8(&state, &codepoint, source[in_posn++]);
} while (in_posn < length && state != 0 && state != 12);
if (state != 0) {
return ZINT_ERROR_INVALID_DATA;
}
if (codepoint >= 0x80 && (codepoint < 0x00a0 || codepoint >= 0x0100)) {
return ZINT_ERROR_INVALID_DATA;
}
dest[out_posn++] = (unsigned char) codepoint;
}
dest[out_posn] = '\0';
*p_length = out_posn;
return 0;
}
if (eci == 170) { /* ASCII Invariant (archaic subset) */
eci_func = ascii_invariant_wctosb;
} else {
eci_func = eci_funcs[eci];
if (eci_func == NULL) {
return ZINT_ERROR_INVALID_DATA;
}
}
state = 0;
while (in_posn < length) {
int incr;
do {
decode_utf8(&state, &codepoint, source[in_posn++]);
} while (in_posn < length && state != 0 && state != 12);
if (state != 0) {
return ZINT_ERROR_INVALID_DATA;
}
incr = (*eci_func)(dest + out_posn, codepoint);
if (incr == 0) {
return ZINT_ERROR_INVALID_DATA;
}
out_posn += incr;
}
dest[out_posn] = '\0';
*p_length = out_posn;
return 0;
}
/* Find the lowest single-byte ECI mode which will encode a given set of Unicode text */
INTERNAL int get_best_eci(const unsigned char source[], int length) {
int eci = 3;
/* Note: attempting single-byte conversions only, so get_eci_length() unnecessary */
#ifndef _MSC_VER
unsigned char local_source[length + 1];
#else
unsigned char *local_source = (unsigned char *) _alloca(length + 1);
#endif
do {
if (eci == 14) { /* Reserved */
eci = 15;
} else if (eci == 19) { /* Reserved */
eci = 21; /* Skip 20 Shift JIS */
}
if (utf8_to_eci(eci, source, local_source, &length) == 0) {
return eci;
}
eci++;
} while (eci < 25);
if (!is_valid_utf8(source, length)) {
return 0;
}
return 26; // If all of these fail, use Unicode!
}

49
3rdparty/zint-2.10.0/backend/eci.h vendored Normal file
View File

@@ -0,0 +1,49 @@
/* eci.c - Extended Channel Interpretations to Unicode tables
libzint - the open source barcode library
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef ECI_H
#define ECI_H
#ifdef __cplusplus
extern "C" {
#endif
INTERNAL int is_eci_convertible(const int eci);
INTERNAL int get_eci_length(const int eci, const unsigned char source[], int length);
INTERNAL int utf8_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *p_length);
INTERNAL int get_best_eci(const unsigned char source[], int length);
#ifdef __cplusplus
}
#endif
#endif /* ECI_H */

1132
3rdparty/zint-2.10.0/backend/eci_sb.h vendored Normal file

File diff suppressed because it is too large Load Diff

802
3rdparty/zint-2.10.0/backend/emf.c vendored Normal file
View File

@@ -0,0 +1,802 @@
/* emf.c - Support for Microsoft Enhanced Metafile Format
libzint - the open source barcode library
Copyright (C) 2016 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* Developed according to [MS-EMF] - v20160714, Released July 14, 2016
* and [MS-WMF] - v20160714, Released July 14, 2016 */
#include <errno.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#include <malloc.h>
#endif
#include "common.h"
#include "emf.h"
static int count_rectangles(struct zint_symbol *symbol) {
int rectangles = 0;
struct zint_vector_rect *rect;
rect = symbol->vector->rectangles;
while (rect) {
rectangles++;
rect = rect->next;
}
return rectangles;
}
static int count_circles(struct zint_symbol *symbol) {
int circles = 0;
struct zint_vector_circle *circ;
circ = symbol->vector->circles;
while (circ) {
circles++;
circ = circ->next;
}
return circles;
}
static int count_hexagons(struct zint_symbol *symbol) {
int hexagons = 0;
struct zint_vector_hexagon *hex;
hex = symbol->vector->hexagons;
while (hex) {
hexagons++;
hex = hex->next;
}
return hexagons;
}
static int count_strings(struct zint_symbol *symbol, float *fsize, float *fsize2, int *halign, int *halign1,
int *halign2) {
int strings = 0;
struct zint_vector_string *str;
*fsize = *fsize2 = 0.0f;
*halign = *halign1 = *halign2 = 0;
str = symbol->vector->strings;
while (str) {
/* Allow 2 font sizes */
if (*fsize == 0.0f) {
*fsize = str->fsize;
} else if (str->fsize != *fsize && *fsize2 == 0.0f) {
*fsize2 = str->fsize;
}
/* Only 3 haligns possible */
if (str->halign) {
if (str->halign == 1) {
*halign1 = str->halign;
} else {
*halign2 = str->halign;
}
}
strings++;
str = str->next;
}
return strings;
}
static void utfle_copy(unsigned char *output, unsigned char *input, int length) {
int i;
int o;
/* Convert UTF-8 to UTF-16LE - only needs to handle characters <= U+00FF */
i = 0;
o = 0;
do {
if (input[i] <= 0x7f) {
/* 1 byte mode (7-bit ASCII) */
output[o] = input[i];
output[o + 1] = 0x00;
o += 2;
i++;
} else {
/* 2 byte mode */
output[o] = ((input[i] & 0x1f) << 6) + (input[i + 1] & 0x3f);
output[o + 1] = 0x00;
o += 2;
i += 2;
}
} while (i < length);
}
static int bump_up(int input) {
/* Strings length must be a multiple of 4 bytes */
if ((input & 1) == 1) {
input++;
}
return input;
}
static int utfle_length(unsigned char *input, int length) {
int result = 0;
int i;
for (i = 0; i < length; i++) {
result++;
if (input[i] >= 0x80) { /* 2 byte UTF-8 counts as one UTF-16LE character */
i++;
}
}
return result;
}
INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
int i;
FILE *emf_file;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
int error_number = 0;
int rectangle_count, this_rectangle;
int circle_count, this_circle;
int hexagon_count, this_hexagon;
int string_count, this_text;
int bytecount, recordcount;
float previous_diameter;
float radius, half_radius, half_sqrt3_radius;
int colours_used = 0;
int rectangle_bycolour[9] = {0};
int width, height;
int draw_background = 1;
int bold;
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT;
struct zint_vector_rect *rect;
struct zint_vector_circle *circ;
struct zint_vector_hexagon *hex;
struct zint_vector_string *str;
/* Allow for up to 6 strings (current max 3 for UPC/EAN) */
unsigned char *this_string[6];
emr_exttextoutw_t text[6];
float text_fsizes[6];
int text_haligns[6];
emr_header_t emr_header;
emr_eof_t emr_eof;
emr_mapmode_t emr_mapmode;
emr_setworldtransform_t emr_setworldtransform;
emr_createbrushindirect_t emr_createbrushindirect_fg;
emr_createbrushindirect_t emr_createbrushindirect_bg;
emr_createbrushindirect_t emr_createbrushindirect_colour[9]; // Used for colour symbols only
emr_selectobject_t emr_selectobject_fgbrush;
emr_selectobject_t emr_selectobject_bgbrush;
emr_selectobject_t emr_selectobject_colour[9]; // Used for colour symbols only
emr_createpen_t emr_createpen;
emr_selectobject_t emr_selectobject_pen;
emr_rectangle_t background;
emr_settextcolor_t emr_settextcolor;
float fsize;
emr_extcreatefontindirectw_t emr_extcreatefontindirectw;
emr_selectobject_t emr_selectobject_font;
float fsize2;
emr_extcreatefontindirectw_t emr_extcreatefontindirectw2;
emr_selectobject_t emr_selectobject_font2;
int halign;
emr_settextalign_t emr_settextalign;
int halign1;
emr_settextalign_t emr_settextalign1;
int halign2;
emr_settextalign_t emr_settextalign2;
float current_fsize;
int current_halign;
#ifdef _MSC_VER
emr_rectangle_t *rectangle;
emr_ellipse_t *circle;
emr_polygon_t *hexagon;
#endif
if (symbol->vector == NULL) {
strcpy(symbol->errtxt, "643: Vector header NULL");
return ZINT_ERROR_INVALID_DATA;
}
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
if (strlen(symbol->bgcolour) > 6) {
if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) {
draw_background = 0;
}
}
rectangle_count = count_rectangles(symbol);
circle_count = count_circles(symbol);
hexagon_count = count_hexagons(symbol);
string_count = count_strings(symbol, &fsize, &fsize2, &halign, &halign1, &halign2);
#ifndef _MSC_VER
// Avoid sanitize runtime error by making always non-zero
emr_rectangle_t rectangle[rectangle_count ? rectangle_count : 1];
emr_ellipse_t circle[circle_count ? circle_count : 1];
emr_polygon_t hexagon[hexagon_count ? hexagon_count : 1];
#else
rectangle = (emr_rectangle_t*) _alloca(rectangle_count * sizeof(emr_rectangle_t));
circle = (emr_ellipse_t*) _alloca(circle_count * sizeof(emr_ellipse_t));
hexagon = (emr_polygon_t*) _alloca(hexagon_count * sizeof(emr_polygon_t));
#endif
// Calculate how many coloured rectangles
if (symbol->symbology == BARCODE_ULTRA) {
rect = symbol->vector->rectangles;
while (rect) {
if (rect->colour == -1) { /* Foreground colour */
if (rectangle_bycolour[0] == 0) {
colours_used++;
rectangle_bycolour[0] = 1;
}
} else {
if (rectangle_bycolour[rect->colour] == 0) {
colours_used++;
rectangle_bycolour[rect->colour] = 1;
}
}
rect = rect->next;
}
}
width = (int) ceilf(symbol->vector->width);
height = (int) ceilf(symbol->vector->height);
/* Header */
emr_header.type = 0x00000001; // EMR_HEADER
emr_header.size = 108; // Including extensions
emr_header.emf_header.bounds.left = 0;
emr_header.emf_header.bounds.right = rotate_angle == 90 || rotate_angle == 270 ? height : width;
emr_header.emf_header.bounds.bottom = rotate_angle == 90 || rotate_angle == 270 ? width : height;
emr_header.emf_header.bounds.top = 0;
emr_header.emf_header.frame.left = 0;
emr_header.emf_header.frame.right = emr_header.emf_header.bounds.right * 30;
emr_header.emf_header.frame.top = 0;
emr_header.emf_header.frame.bottom = emr_header.emf_header.bounds.bottom * 30;
emr_header.emf_header.record_signature = 0x464d4520; // ENHMETA_SIGNATURE
emr_header.emf_header.version = 0x00010000;
if (symbol->symbology == BARCODE_ULTRA) {
emr_header.emf_header.handles = 12; // Number of graphics objects
} else {
emr_header.emf_header.handles = fsize2 != 0.0f ? 5 : 4;
}
emr_header.emf_header.reserved = 0x0000;
emr_header.emf_header.n_description = 0;
emr_header.emf_header.off_description = 0;
emr_header.emf_header.n_pal_entries = 0;
emr_header.emf_header.device.cx = 1000;
emr_header.emf_header.device.cy = 1000;
emr_header.emf_header.millimeters.cx = 300;
emr_header.emf_header.millimeters.cy = 300;
/* HeaderExtension1 */
emr_header.emf_header.cb_pixel_format = 0x0000; // None set
emr_header.emf_header.off_pixel_format = 0x0000; // None set
emr_header.emf_header.b_open_gl = 0x0000; // OpenGL not present
/* HeaderExtension2 */
emr_header.emf_header.micrometers.cx = 0;
emr_header.emf_header.micrometers.cy = 0;
bytecount = 108;
recordcount = 1;
emr_mapmode.type = 0x00000011; // EMR_SETMAPMODE
emr_mapmode.size = 12;
emr_mapmode.mapmode = 0x01; // MM_TEXT
bytecount += 12;
recordcount++;
if (rotate_angle) {
emr_setworldtransform.type = 0x00000023; // EMR_SETWORLDTRANSFORM
emr_setworldtransform.size = 32;
emr_setworldtransform.m11 = rotate_angle == 90 ? 0.0f : rotate_angle == 180 ? -1.0f : 0.0f;
emr_setworldtransform.m12 = rotate_angle == 90 ? 1.0f : rotate_angle == 180 ? 0.0f : -1.0f;
emr_setworldtransform.m21 = rotate_angle == 90 ? -1.0f : rotate_angle == 180 ? 0.0f : 1.0f;
emr_setworldtransform.m22 = rotate_angle == 90 ? 0.0f : rotate_angle == 180 ? -1.0f : 0.0f;
emr_setworldtransform.dx = rotate_angle == 90 ? height : rotate_angle == 180 ? width : 0.0f;
emr_setworldtransform.dy = rotate_angle == 90 ? 0.0f : rotate_angle == 180 ? height : width;
bytecount += 32;
recordcount++;
}
/* Create Brushes */
emr_createbrushindirect_bg.type = 0x00000027; // EMR_CREATEBRUSHINDIRECT
emr_createbrushindirect_bg.size = 24;
emr_createbrushindirect_bg.ih_brush = 1;
emr_createbrushindirect_bg.log_brush.brush_style = 0x0000; // BS_SOLID
emr_createbrushindirect_bg.log_brush.color.red = bgred;
emr_createbrushindirect_bg.log_brush.color.green = bggrn;
emr_createbrushindirect_bg.log_brush.color.blue = bgblu;
emr_createbrushindirect_bg.log_brush.color.reserved = 0;
emr_createbrushindirect_bg.log_brush.brush_hatch = 0x0006; // HS_SOLIDCLR
bytecount += 24;
recordcount++;
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 9; i++) {
emr_createbrushindirect_colour[i].type = 0x00000027; // EMR_CREATEBRUSHINDIRECT
emr_createbrushindirect_colour[i].size = 24;
emr_createbrushindirect_colour[i].ih_brush = 2 + i;
emr_createbrushindirect_colour[i].log_brush.brush_style = 0x0000; // BS_SOLID
if (i == 0) {
emr_createbrushindirect_colour[i].log_brush.color.red = fgred;
emr_createbrushindirect_colour[i].log_brush.color.green = fggrn;
emr_createbrushindirect_colour[i].log_brush.color.blue = fgblu;
} else {
emr_createbrushindirect_colour[i].log_brush.color.red = colour_to_red(i);
emr_createbrushindirect_colour[i].log_brush.color.green = colour_to_green(i);
emr_createbrushindirect_colour[i].log_brush.color.blue = colour_to_blue(i);
}
emr_createbrushindirect_colour[i].log_brush.color.reserved = 0;
emr_createbrushindirect_colour[i].log_brush.brush_hatch = 0x0006; // HS_SOLIDCLR
}
bytecount += colours_used * 24;
recordcount += colours_used;
} else {
emr_createbrushindirect_fg.type = 0x00000027; // EMR_CREATEBRUSHINDIRECT
emr_createbrushindirect_fg.size = 24;
emr_createbrushindirect_fg.ih_brush = 2;
emr_createbrushindirect_fg.log_brush.brush_style = 0x0000; // BS_SOLID
emr_createbrushindirect_fg.log_brush.color.red = fgred;
emr_createbrushindirect_fg.log_brush.color.green = fggrn;
emr_createbrushindirect_fg.log_brush.color.blue = fgblu;
emr_createbrushindirect_fg.log_brush.color.reserved = 0;
emr_createbrushindirect_fg.log_brush.brush_hatch = 0x0006; // HS_SOLIDCLR
bytecount += 24;
recordcount++;
}
emr_selectobject_bgbrush.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_bgbrush.size = 12;
emr_selectobject_bgbrush.ih_object = 1;
bytecount += 12;
recordcount++;
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 9; i++) {
emr_selectobject_colour[i].type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_colour[i].size = 12;
emr_selectobject_colour[i].ih_object = 2 + i;
}
bytecount += colours_used * 12;
recordcount += colours_used;
} else {
emr_selectobject_fgbrush.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_fgbrush.size = 12;
emr_selectobject_fgbrush.ih_object = 2;
bytecount += 12;
recordcount++;
}
/* Create Pens */
emr_createpen.type = 0x00000026; // EMR_CREATEPEN
emr_createpen.size = 28;
emr_createpen.ih_pen = 11;
emr_createpen.log_pen.pen_style = 0x00000005; // PS_NULL
emr_createpen.log_pen.width.x = 1;
emr_createpen.log_pen.width.y = 0; // ignored
emr_createpen.log_pen.color_ref.red = 0;
emr_createpen.log_pen.color_ref.green = 0;
emr_createpen.log_pen.color_ref.blue = 0;
emr_createpen.log_pen.color_ref.reserved = 0;
bytecount += 28;
recordcount++;
emr_selectobject_pen.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_pen.size = 12;
emr_selectobject_pen.ih_object = 11;
bytecount += 12;
recordcount++;
if (draw_background) {
/* Make background from a rectangle */
background.type = 0x0000002b; // EMR_RECTANGLE
background.size = 24;
background.box.top = 0;
background.box.left = 0;
background.box.right = emr_header.emf_header.bounds.right;
background.box.bottom = emr_header.emf_header.bounds.bottom;
bytecount += 24;
recordcount++;
}
// Rectangles
rect = symbol->vector->rectangles;
this_rectangle = 0;
while (rect) {
rectangle[this_rectangle].type = 0x0000002b; // EMR_RECTANGLE
rectangle[this_rectangle].size = 24;
rectangle[this_rectangle].box.top = (int32_t) rect->y;
rectangle[this_rectangle].box.bottom = (int32_t) (rect->y + rect->height);
rectangle[this_rectangle].box.left = (int32_t) rect->x;
rectangle[this_rectangle].box.right = (int32_t) (rect->x + rect->width);
this_rectangle++;
bytecount += 24;
recordcount++;
rect = rect->next;
}
// Circles
previous_diameter = radius = 0.0f;
circ = symbol->vector->circles;
this_circle = 0;
while (circ) {
if (previous_diameter != circ->diameter) {
previous_diameter = circ->diameter;
radius = (float) (0.5 * previous_diameter);
}
circle[this_circle].type = 0x0000002a; // EMR_ELLIPSE
circle[this_circle].size = 24;
circle[this_circle].box.top = (int32_t) (circ->y - radius);
circle[this_circle].box.bottom = (int32_t) (circ->y + radius);
circle[this_circle].box.left = (int32_t) (circ->x - radius);
circle[this_circle].box.right = (int32_t) (circ->x + radius);
this_circle++;
bytecount += 24;
recordcount++;
circ = circ->next;
}
// Hexagons
previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f;
hex = symbol->vector->hexagons;
this_hexagon = 0;
while (hex) {
hexagon[this_hexagon].type = 0x00000003; // EMR_POLYGON
hexagon[this_hexagon].size = 76;
hexagon[this_hexagon].count = 6;
if (previous_diameter != hex->diameter) {
previous_diameter = hex->diameter;
radius = (float) (0.5 * previous_diameter);
half_radius = (float) (0.25 * previous_diameter);
half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter);
}
/* Note rotation done via world transform */
hexagon[this_hexagon].a_points_a.x = (int32_t) (hex->x);
hexagon[this_hexagon].a_points_a.y = (int32_t) (hex->y + radius);
hexagon[this_hexagon].a_points_b.x = (int32_t) (hex->x + half_sqrt3_radius);
hexagon[this_hexagon].a_points_b.y = (int32_t) (hex->y + half_radius);
hexagon[this_hexagon].a_points_c.x = (int32_t) (hex->x + half_sqrt3_radius);
hexagon[this_hexagon].a_points_c.y = (int32_t) (hex->y - half_radius);
hexagon[this_hexagon].a_points_d.x = (int32_t) (hex->x);
hexagon[this_hexagon].a_points_d.y = (int32_t) (hex->y - radius);
hexagon[this_hexagon].a_points_e.x = (int32_t) (hex->x - half_sqrt3_radius);
hexagon[this_hexagon].a_points_e.y = (int32_t) (hex->y - half_radius);
hexagon[this_hexagon].a_points_f.x = (int32_t) (hex->x - half_sqrt3_radius);
hexagon[this_hexagon].a_points_f.y = (int32_t) (hex->y + half_radius);
hexagon[this_hexagon].bounds.top = hexagon[this_hexagon].a_points_d.y;
hexagon[this_hexagon].bounds.bottom = hexagon[this_hexagon].a_points_a.y;
hexagon[this_hexagon].bounds.left = hexagon[this_hexagon].a_points_e.x;
hexagon[this_hexagon].bounds.right = hexagon[this_hexagon].a_points_c.x;
this_hexagon++;
bytecount += 76;
recordcount++;
hex = hex->next;
}
/* Create font records, alignment records and text color */
if (symbol->vector->strings) {
bold = (symbol->output_options & BOLD_TEXT) &&
(!is_extendable(symbol->symbology) || (symbol->output_options & SMALL_TEXT));
memset(&emr_extcreatefontindirectw, 0, sizeof(emr_extcreatefontindirectw));
emr_extcreatefontindirectw.type = 0x00000052; // EMR_EXTCREATEFONTINDIRECTW
emr_extcreatefontindirectw.size = 104;
emr_extcreatefontindirectw.ih_fonts = 12;
emr_extcreatefontindirectw.elw.height = (int32_t) fsize;
emr_extcreatefontindirectw.elw.width = 0; // automatic
emr_extcreatefontindirectw.elw.weight = bold ? 700 : 400;
emr_extcreatefontindirectw.elw.char_set = 0x00; // ANSI_CHARSET
emr_extcreatefontindirectw.elw.out_precision = 0x00; // OUT_DEFAULT_PRECIS
emr_extcreatefontindirectw.elw.clip_precision = 0x00; // CLIP_DEFAULT_PRECIS
emr_extcreatefontindirectw.elw.pitch_and_family = 0x02 | (0x02 << 6); // FF_SWISS | VARIABLE_PITCH
utfle_copy(emr_extcreatefontindirectw.elw.facename, (unsigned char *) "sans-serif", 10);
bytecount += 104;
recordcount++;
emr_selectobject_font.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_font.size = 12;
emr_selectobject_font.ih_object = 12;
bytecount += 12;
recordcount++;
if (fsize2) {
memcpy(&emr_extcreatefontindirectw2, &emr_extcreatefontindirectw, sizeof(emr_extcreatefontindirectw));
emr_extcreatefontindirectw2.ih_fonts = 13;
emr_extcreatefontindirectw2.elw.height = (int32_t) fsize2;
bytecount += 104;
recordcount++;
emr_selectobject_font2.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_font2.size = 12;
emr_selectobject_font2.ih_object = 13;
bytecount += 12;
recordcount++;
}
/* Note select aligns counted below in strings loop */
emr_settextalign.type = 0x00000016; // EMR_SETTEXTALIGN
emr_settextalign.size = 12;
emr_settextalign.text_alignment_mode = 0x0006 | 0x0018; // TA_CENTER | TA_BASELINE
if (halign1) {
emr_settextalign1.type = 0x00000016; // EMR_SETTEXTALIGN
emr_settextalign1.size = 12;
emr_settextalign1.text_alignment_mode = 0x0000 | 0x0018; // TA_LEFT | TA_BASELINE
}
if (halign2) {
emr_settextalign2.type = 0x00000016; // EMR_SETTEXTALIGN
emr_settextalign2.size = 12;
emr_settextalign2.text_alignment_mode = 0x0002 | 0x0018; // TA_RIGHT | TA_BASELINE
}
emr_settextcolor.type = 0x0000018; // EMR_SETTEXTCOLOR
emr_settextcolor.size = 12;
emr_settextcolor.color.red = fgred;
emr_settextcolor.color.green = fggrn;
emr_settextcolor.color.blue = fgblu;
emr_settextcolor.color.reserved = 0;
bytecount += 12;
recordcount++;
}
// Text
this_text = 0;
// Loop over font sizes so that they're grouped together, so only have to select font twice at most
for (i = 0, current_fsize = fsize; i < 2 && current_fsize; i++, current_fsize = fsize2) {
str = symbol->vector->strings;
current_halign = -1;
while (str) {
int utfle_len;
int bumped_len;
if (str->fsize != current_fsize) {
str = str->next;
continue;
}
text_fsizes[this_text] = str->fsize;
text_haligns[this_text] = str->halign;
if (text_haligns[this_text] != current_halign) {
current_halign = text_haligns[this_text];
bytecount += 12;
recordcount++;
}
assert(str->length > 0);
utfle_len = utfle_length(str->text, str->length);
bumped_len = bump_up(utfle_len) * 2;
if (!(this_string[this_text] = (unsigned char *) malloc(bumped_len))) {
for (i = 0; i < this_text; i++) {
free(this_string[i]);
}
strcpy(symbol->errtxt, "641: Insufficient memory for EMF string buffer");
return ZINT_ERROR_MEMORY;
}
memset(this_string[this_text], 0, bumped_len);
text[this_text].type = 0x00000054; // EMR_EXTTEXTOUTW
text[this_text].size = 76 + bumped_len;
text[this_text].bounds.top = 0; // ignored
text[this_text].bounds.left = 0; // ignored
text[this_text].bounds.right = 0xffffffff; // ignored
text[this_text].bounds.bottom = 0xffffffff; // ignored
text[this_text].i_graphics_mode = 0x00000002; // GM_ADVANCED
text[this_text].ex_scale = 1.0f;
text[this_text].ey_scale = 1.0f;
text[this_text].w_emr_text.reference.x = (int32_t) str->x;
text[this_text].w_emr_text.reference.y = (int32_t) str->y;
text[this_text].w_emr_text.chars = utfle_len;
text[this_text].w_emr_text.off_string = 76;
text[this_text].w_emr_text.options = 0;
text[this_text].w_emr_text.rectangle.top = 0;
text[this_text].w_emr_text.rectangle.left = 0;
text[this_text].w_emr_text.rectangle.right = 0xffffffff;
text[this_text].w_emr_text.rectangle.bottom = 0xffffffff;
text[this_text].w_emr_text.off_dx = 0;
utfle_copy(this_string[this_text], str->text, str->length);
bytecount += 76 + bumped_len;
recordcount++;
this_text++;
str = str->next;
}
}
/* Suppress clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning */
assert(this_text == string_count);
/* Create EOF record */
emr_eof.type = 0x0000000e; // EMR_EOF
emr_eof.size = 20; // Assuming no palette entries
emr_eof.n_pal_entries = 0;
emr_eof.off_pal_entries = 0;
emr_eof.size_last = emr_eof.size;
bytecount += 20;
recordcount++;
if (symbol->symbology == BARCODE_MAXICODE) {
bytecount += 5 * sizeof(emr_selectobject_t);
recordcount += 5;
}
/* Put final counts in header */
emr_header.emf_header.bytes = bytecount;
emr_header.emf_header.records = recordcount;
/* Send EMF data to file */
if (output_to_stdout) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
sprintf(symbol->errtxt, "642: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
#endif
emf_file = stdout;
} else {
if (!(emf_file = fopen(symbol->outfile, "wb"))) {
sprintf(symbol->errtxt, "640: Could not open output file (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
}
fwrite(&emr_header, sizeof(emr_header_t), 1, emf_file);
fwrite(&emr_mapmode, sizeof(emr_mapmode_t), 1, emf_file);
if (rotate_angle) {
fwrite(&emr_setworldtransform, sizeof(emr_setworldtransform_t), 1, emf_file);
}
fwrite(&emr_createbrushindirect_bg, sizeof(emr_createbrushindirect_t), 1, emf_file);
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 9; i++) {
if (rectangle_bycolour[i]) {
fwrite(&emr_createbrushindirect_colour[i], sizeof(emr_createbrushindirect_t), 1, emf_file);
}
}
} else {
fwrite(&emr_createbrushindirect_fg, sizeof(emr_createbrushindirect_t), 1, emf_file);
}
fwrite(&emr_createpen, sizeof(emr_createpen_t), 1, emf_file);
if (symbol->vector->strings) {
fwrite(&emr_extcreatefontindirectw, sizeof(emr_extcreatefontindirectw_t), 1, emf_file);
if (fsize2) {
fwrite(&emr_extcreatefontindirectw2, sizeof(emr_extcreatefontindirectw_t), 1, emf_file);
}
}
fwrite(&emr_selectobject_bgbrush, sizeof(emr_selectobject_t), 1, emf_file);
fwrite(&emr_selectobject_pen, sizeof(emr_selectobject_t), 1, emf_file);
if (draw_background) {
fwrite(&background, sizeof(emr_rectangle_t), 1, emf_file);
}
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 9; i++) {
if (rectangle_bycolour[i]) {
fwrite(&emr_selectobject_colour[i], sizeof(emr_selectobject_t), 1, emf_file);
rect = symbol->vector->rectangles;
this_rectangle = 0;
while (rect) {
if ((i == 0 && rect->colour == -1) || rect->colour == i) {
fwrite(&rectangle[this_rectangle], sizeof(emr_rectangle_t), 1, emf_file);
}
this_rectangle++;
rect = rect->next;
}
}
}
} else {
fwrite(&emr_selectobject_fgbrush, sizeof(emr_selectobject_t), 1, emf_file);
// Rectangles
for (i = 0; i < rectangle_count; i++) {
fwrite(&rectangle[i], sizeof(emr_rectangle_t), 1, emf_file);
}
}
// Hexagons
for (i = 0; i < hexagon_count; i++) {
fwrite(&hexagon[i], sizeof(emr_polygon_t), 1, emf_file);
}
// Circles
if (symbol->symbology == BARCODE_MAXICODE) {
// Bullseye needed
for (i = 0; i < circle_count; i++) {
fwrite(&circle[i], sizeof(emr_ellipse_t), 1, emf_file);
if (i < circle_count - 1) {
if (i % 2) {
fwrite(&emr_selectobject_fgbrush, sizeof(emr_selectobject_t), 1, emf_file);
} else {
fwrite(&emr_selectobject_bgbrush, sizeof(emr_selectobject_t), 1, emf_file);
}
}
}
} else {
for (i = 0; i < circle_count; i++) {
fwrite(&circle[i], sizeof(emr_ellipse_t), 1, emf_file);
}
}
// Text
if (string_count > 0) {
fwrite(&emr_selectobject_font, sizeof(emr_selectobject_t), 1, emf_file);
fwrite(&emr_settextcolor, sizeof(emr_settextcolor_t), 1, emf_file);
}
current_fsize = fsize;
current_halign = -1;
for (i = 0; i < string_count; i++) {
if (text_fsizes[i] != current_fsize) {
current_fsize = text_fsizes[i];
fwrite(&emr_selectobject_font2, sizeof(emr_selectobject_t), 1, emf_file);
}
if (text_haligns[i] != current_halign) {
current_halign = text_haligns[i];
if (current_halign == 0) {
fwrite(&emr_settextalign, sizeof(emr_settextalign_t), 1, emf_file);
} else if (current_halign == 1) {
fwrite(&emr_settextalign1, sizeof(emr_settextalign_t), 1, emf_file);
} else {
fwrite(&emr_settextalign2, sizeof(emr_settextalign_t), 1, emf_file);
}
}
fwrite(&text[i], sizeof(emr_exttextoutw_t), 1, emf_file);
fwrite(this_string[i], bump_up(text[i].w_emr_text.chars) * 2, 1, emf_file);
free(this_string[i]);
}
fwrite(&emr_eof, sizeof(emr_eof_t), 1, emf_file);
if (output_to_stdout) {
fflush(emf_file);
} else {
fclose(emf_file);
}
return error_number;
}

252
3rdparty/zint-2.10.0/backend/emf.h vendored Normal file
View File

@@ -0,0 +1,252 @@
/* emf.h - header structure for Microsoft EMF
libzint - the open source barcode library
Copyright (C) 2016-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef EMF_H
#define EMF_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
#pragma pack(1)
typedef struct rect_l {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
} rect_l_t;
typedef struct size_l {
uint32_t cx;
uint32_t cy;
} size_l_t;
typedef struct point_l {
int32_t x;
int32_t y;
} point_l_t;
typedef struct color_ref {
uint8_t red;
uint8_t green;
uint8_t blue;
uint8_t reserved;
} color_ref_t;
typedef struct log_brush_ex {
uint32_t brush_style;
color_ref_t color;
uint32_t brush_hatch;
} log_brush_ex_t;
typedef struct log_pen {
uint32_t pen_style;
point_l_t width;
color_ref_t color_ref;
} log_pen_t;
typedef struct log_font {
int32_t height;
int32_t width;
int32_t escapement;
int32_t orientation;
int32_t weight;
uint8_t italic;
uint8_t underline;
uint8_t strike_out;
uint8_t char_set;
uint8_t out_precision;
uint8_t clip_precision;
uint8_t quality;
uint8_t pitch_and_family;
unsigned char facename[64];
} log_font_t;
typedef struct emr_text {
point_l_t reference;
uint32_t chars;
uint32_t off_string;
uint32_t options;
rect_l_t rectangle;
uint32_t off_dx;
} emr_text_t;
typedef struct emf_header {
rect_l_t bounds;
rect_l_t frame;
uint32_t record_signature;
uint32_t version;
uint32_t bytes;
uint32_t records;
uint16_t handles;
uint16_t reserved;
uint32_t n_description;
uint32_t off_description;
uint32_t n_pal_entries;
size_l_t device;
size_l_t millimeters;
// HeaderExtension1 Object
uint32_t cb_pixel_format;
uint32_t off_pixel_format;
uint32_t b_open_gl;
// HeaderExtension2 Object
size_l_t micrometers;
} emf_header_t;
typedef struct emr_header {
uint32_t type;
uint32_t size;
emf_header_t emf_header;
} emr_header_t;
typedef struct emr_mapmode {
uint32_t type;
uint32_t size;
uint32_t mapmode;
} emr_mapmode_t;
typedef struct emr_setworldtransform {
uint32_t type;
uint32_t size;
float m11;
float m12;
float m21;
float m22;
float dx;
float dy;
} emr_setworldtransform_t;
typedef struct emr_createbrushindirect {
uint32_t type;
uint32_t size;
uint32_t ih_brush;
log_brush_ex_t log_brush;
} emr_createbrushindirect_t;
typedef struct emr_createpen {
uint32_t type;
uint32_t size;
uint32_t ih_pen;
log_pen_t log_pen;
} emr_createpen_t;
typedef struct emr_selectobject {
uint32_t type;
uint32_t size;
uint32_t ih_object;
} emr_selectobject_t;
typedef struct emr_rectangle {
uint32_t type;
uint32_t size;
rect_l_t box;
} emr_rectangle_t;
typedef struct emr_ellipse {
uint32_t type;
uint32_t size;
rect_l_t box;
} emr_ellipse_t;
typedef struct emr_polygon {
uint32_t type;
uint32_t size;
rect_l_t bounds;
uint32_t count;
point_l_t a_points_a;
point_l_t a_points_b;
point_l_t a_points_c;
point_l_t a_points_d;
point_l_t a_points_e;
point_l_t a_points_f;
} emr_polygon_t;
typedef struct emr_extcreatefontindirectw {
uint32_t type;
uint32_t size;
uint32_t ih_fonts;
log_font_t elw;
} emr_extcreatefontindirectw_t;
typedef struct emr_settextalign {
uint32_t type;
uint32_t size;
uint32_t text_alignment_mode;
} emr_settextalign_t;
typedef struct emr_settextcolor {
uint32_t type;
uint32_t size;
color_ref_t color;
} emr_settextcolor_t;
typedef struct emr_exttextoutw {
uint32_t type;
uint32_t size;
rect_l_t bounds;
uint32_t i_graphics_mode;
float ex_scale;
float ey_scale;
emr_text_t w_emr_text;
} emr_exttextoutw_t;
typedef struct emr_eof {
uint32_t type;
uint32_t size;
uint32_t n_pal_entries;
uint32_t off_pal_entries;
uint32_t size_last;
} emr_eof_t;
typedef struct box {
emr_rectangle_t top;
emr_rectangle_t bottom;
emr_rectangle_t left;
emr_rectangle_t right;
} box_t;
#pragma pack()
#ifdef __cplusplus
}
#endif
#endif /* EMF_H */

489
3rdparty/zint-2.10.0/backend/font.h vendored Normal file
View File

@@ -0,0 +1,489 @@
/* font.h - Font for PNG images */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef FONT_H
#define FONT_H
typedef const unsigned short font_item;
#define NORMAL_FONT_WIDTH 7
#define NORMAL_FONT_HEIGHT 14
static font_item ascii_font[] = {
/* Each character is 7 x 14 pixels */
0, 0, 8, 8, 8, 8, 8, 8, 8, 0, 8, 8, 0, 0, /* ! */
0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* " */
0, 0, 20, 20, 20, 62, 20, 20, 62, 20, 20, 20, 0, 0, /* # */
0, 0, 8, 60, 74, 74, 40, 28, 10, 74, 74, 60, 8, 0, /* $ */
0, 0, 50, 74, 76, 56, 8, 16, 28, 50, 82, 76, 0, 0, /* % */
0, 0, 24, 36, 36, 36, 24, 50, 74, 68, 76, 50, 0, 0, /* & */
0, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ' */
0, 2, 4, 8, 8, 16, 16, 16, 16, 16, 8, 8, 4, 2, /* ( */
0, 32, 16, 8, 8, 4, 4, 4, 4, 4, 8, 8, 16, 32, /* ) */
0, 0, 0, 0, 8, 42, 28, 8, 28, 42, 8, 0, 0, 0, /* * */
0, 0, 0, 0, 8, 8, 8, 62, 8, 8, 8, 0, 0, 0, /* + */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 8, 8, 16, /* , */
0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, /* - */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 28, 8, 0, /* . */
0, 2, 2, 4, 4, 8, 8, 8, 16, 16, 32, 32, 64, 64, /* / */
0, 0, 24, 36, 66, 66, 66, 66, 66, 66, 36, 24, 0, 0, /* 0 */
0, 0, 8, 24, 40, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* 1 */
0, 0, 60, 66, 66, 2, 4, 4, 8, 16, 32, 126, 0, 0, /* 2 */
0, 0, 126, 2, 4, 8, 28, 2, 2, 66, 66, 60, 0, 0, /* 3 */
0, 0, 4, 12, 20, 20, 36, 36, 68, 126, 4, 4, 0, 0, /* 4 */
0, 0, 126, 64, 64, 124, 66, 2, 2, 66, 66, 60, 0, 0, /* 5 */
0, 0, 28, 32, 64, 64, 92, 98, 66, 66, 66, 60, 0, 0, /* 6 */
0, 0, 126, 2, 4, 4, 8, 8, 16, 16, 32, 32, 0, 0, /* 7 */
0, 0, 60, 66, 66, 36, 24, 36, 66, 66, 66, 60, 0, 0, /* 8 */
0, 0, 60, 66, 66, 66, 70, 58, 2, 66, 68, 56, 0, 0, /* 9 */
0, 0, 0, 0, 8, 28, 8, 0, 0, 8, 28, 8, 0, 0, /* : */
0, 0, 0, 0, 0, 24, 24, 0, 0, 24, 8, 8, 16, 0, /* ; */
0, 0, 0, 2, 4, 8, 16, 32, 16, 8, 4, 2, 0, 0, /* < */
0, 0, 0, 0, 0, 126, 0, 0, 126, 0, 0, 0, 0, 0, /* = */
0, 0, 0, 32, 16, 8, 4, 2, 4, 8, 16, 32, 0, 0, /* > */
0, 0, 60, 66, 66, 4, 8, 8, 8, 0, 8, 8, 0, 0, /* ? */
0, 0, 28, 34, 78, 82, 82, 82, 82, 78, 32, 30, 0, 0, /* @ */
0, 0, 24, 36, 66, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* A */
0, 0, 120, 68, 66, 68, 120, 68, 66, 66, 68, 120, 0, 0, /* B */
0, 0, 60, 66, 66, 64, 64, 64, 64, 66, 66, 60, 0, 0, /* C */
0, 0, 120, 68, 66, 66, 66, 66, 66, 66, 68, 120, 0, 0, /* D */
0, 0, 126, 64, 64, 64, 120, 64, 64, 64, 64, 126, 0, 0, /* E */
0, 0, 126, 64, 64, 64, 120, 64, 64, 64, 64, 64, 0, 0, /* F */
0, 0, 60, 66, 66, 64, 64, 78, 66, 66, 70, 58, 0, 0, /* G */
0, 0, 66, 66, 66, 66, 126, 66, 66, 66, 66, 66, 0, 0, /* H */
0, 0, 62, 8, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* I */
0, 0, 14, 4, 4, 4, 4, 4, 4, 68, 68, 56, 0, 0, /* J */
0, 0, 66, 68, 72, 80, 96, 80, 72, 68, 66, 66, 0, 0, /* K */
0, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 126, 0, 0, /* L */
0, 0, 66, 102, 102, 90, 90, 66, 66, 66, 66, 66, 0, 0, /* M */
0, 0, 66, 66, 98, 98, 82, 74, 70, 70, 66, 66, 0, 0, /* N */
0, 0, 60, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* O */
0, 0, 124, 66, 66, 66, 66, 124, 64, 64, 64, 64, 0, 0, /* P */
0, 0, 60, 66, 66, 66, 66, 66, 114, 74, 70, 60, 4, 2, /* Q */
0, 0, 124, 66, 66, 66, 66, 124, 72, 68, 66, 66, 0, 0, /* R */
0, 0, 60, 66, 66, 64, 48, 12, 2, 66, 66, 60, 0, 0, /* S */
0, 0, 127, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, /* T */
0, 0, 66, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* U */
0, 0, 66, 66, 66, 66, 36, 36, 36, 24, 24, 24, 0, 0, /* V */
0, 0, 34, 34, 34, 34, 34, 34, 42, 42, 42, 20, 0, 0, /* W */
0, 0, 66, 66, 36, 36, 24, 24, 36, 36, 66, 66, 0, 0, /* X */
0, 0, 34, 34, 34, 20, 20, 8, 8, 8, 8, 8, 0, 0, /* Y */
0, 0, 126, 2, 4, 8, 8, 16, 32, 32, 64, 126, 0, 0, /* Z */
0, 30, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 30, /* [ */
0, 64, 64, 32, 32, 16, 16, 16, 8, 8, 4, 4, 2, 2, /* \ */
0, 60, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 60, /* ] */
0, 24, 36, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ^ */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 126, /* _ */
0, 16, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` */
0, 0, 0, 0, 0, 60, 66, 2, 62, 66, 66, 62, 0, 0, /* a */
0, 0, 64, 64, 64, 92, 98, 66, 66, 66, 98, 92, 0, 0, /* b */
0, 0, 0, 0, 0, 60, 66, 64, 64, 64, 66, 60, 0, 0, /* c */
0, 0, 2, 2, 2, 58, 70, 66, 66, 66, 70, 58, 0, 0, /* d */
0, 0, 0, 0, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* e */
0, 0, 12, 18, 16, 16, 124, 16, 16, 16, 16, 16, 0, 0, /* f */
0, 0, 0, 0, 0, 58, 68, 68, 68, 56, 32, 92, 66, 60, /* g */
0, 0, 64, 64, 64, 92, 98, 66, 66, 66, 66, 66, 0, 0, /* h */
0, 0, 8, 8, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* i */
0, 0, 2, 2, 0, 6, 2, 2, 2, 2, 2, 34, 34, 28, /* j */
0, 0, 64, 64, 64, 68, 72, 80, 112, 72, 68, 66, 0, 0, /* k */
0, 0, 24, 8, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* l */
0, 0, 0, 0, 0, 52, 42, 42, 42, 42, 42, 34, 0, 0, /* m */
0, 0, 0, 0, 0, 92, 98, 66, 66, 66, 66, 66, 0, 0, /* n */
0, 0, 0, 0, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* o */
0, 0, 0, 0, 0, 92, 98, 66, 66, 66, 98, 92, 64, 64, /* p */
0, 0, 0, 0, 0, 58, 70, 66, 66, 66, 70, 58, 2, 2, /* q */
0, 0, 0, 0, 0, 92, 98, 66, 64, 64, 64, 64, 0, 0, /* r */
0, 0, 0, 0, 0, 60, 66, 32, 24, 4, 66, 60, 0, 0, /* s */
0, 0, 16, 16, 16, 124, 16, 16, 16, 16, 18, 12, 0, 0, /* t */
0, 0, 0, 0, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* u */
0, 0, 0, 0, 0, 34, 34, 34, 20, 20, 8, 8, 0, 0, /* v */
0, 0, 0, 0, 0, 34, 34, 42, 42, 42, 42, 20, 0, 0, /* w */
0, 0, 0, 0, 0, 66, 66, 36, 24, 36, 66, 66, 0, 0, /* x */
0, 0, 0, 0, 0, 66, 66, 66, 66, 70, 58, 2, 66, 60, /* y */
0, 0, 0, 0, 0, 126, 4, 8, 16, 16, 32, 126, 0, 0, /* z */
0, 6, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 6, /* { */
0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* | */
0, 48, 8, 8, 8, 8, 8, 4, 8, 8, 8, 8, 8, 48, /* } */
0, 32, 82, 74, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ~ */
0, 0, 8, 8, 0, 8, 8, 8, 8, 8, 8, 8, 0, 0, /* ¡ */
0, 0, 0, 0, 16, 60, 82, 80, 80, 80, 82, 60, 16, 0, /* ¢ */
0, 0, 0, 12, 18, 16, 16, 60, 16, 16, 60, 18, 0, 0, /* £ */
0, 0, 0, 0, 66, 60, 36, 36, 60, 66, 0, 0, 0, 0, /* ¤ */
0, 0, 34, 20, 20, 8, 62, 8, 62, 8, 8, 8, 0, 0, /* ¥ */
0, 0, 8, 8, 8, 8, 0, 0, 8, 8, 8, 8, 0, 0, /* ¦ */
0, 60, 66, 32, 24, 36, 66, 36, 24, 4, 66, 60, 0, 0, /* § */
0, 36, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ¨ */
0, 60, 66, 90, 102, 98, 98, 98, 102, 90, 66, 60, 0, 0, /* © */
0, 28, 34, 30, 34, 38, 26, 0, 62, 0, 0, 0, 0, 0, /* ª */
0, 0, 0, 0, 0, 10, 20, 40, 80, 40, 20, 10, 0, 0, /* « */
0, 0, 0, 0, 0, 0, 0, 0, 62, 2, 2, 2, 0, 0, /* ¬ */
0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, /* ­ */
0, 60, 66, 122, 102, 102, 122, 102, 102, 102, 66, 60, 0, 0, /* ® */
0, 0, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ¯ */
0, 24, 36, 36, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ° */
0, 0, 0, 0, 0, 0, 8, 8, 62, 8, 8, 62, 0, 0, /* ± */
0, 24, 36, 4, 8, 16, 32, 60, 0, 0, 0, 0, 0, 0, /* ² */
0, 24, 36, 4, 24, 4, 36, 24, 0, 0, 0, 0, 0, 0, /* ³ */
0, 4, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ´ */
0, 0, 0, 0, 0, 0, 34, 34, 34, 34, 54, 42, 32, 32, /* µ */
0, 0, 30, 42, 42, 42, 42, 26, 10, 10, 10, 10, 10, 14, /* ¶ */
0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, /* · */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 16, /* ¸ */
0, 8, 24, 8, 8, 8, 8, 28, 0, 0, 0, 0, 0, 0, /* ¹ */
0, 0, 24, 36, 36, 24, 0, 60, 0, 0, 0, 0, 0, 0, /* º */
0, 0, 0, 0, 0, 80, 40, 20, 10, 20, 40, 80, 0, 0, /* » */
0, 0, 32, 98, 36, 36, 40, 18, 22, 42, 78, 66, 0, 0, /* ¼ */
0, 0, 32, 98, 36, 36, 40, 20, 26, 34, 68, 78, 0, 0, /* ½ */
0, 0, 98, 18, 36, 24, 104, 18, 38, 42, 78, 2, 0, 0, /* ¾ */
0, 0, 0, 16, 16, 0, 16, 16, 16, 16, 32, 66, 66, 60, /* ¿ */
16, 8, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* À */
8, 16, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Á */
24, 36, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Â */
50, 76, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Ã */
0, 36, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Ä */
0, 24, 36, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Å */
0, 0, 30, 40, 72, 72, 126, 72, 72, 72, 72, 78, 0, 0, /* Æ */
0, 0, 60, 66, 66, 64, 64, 64, 64, 66, 66, 60, 8, 16, /* Ç */
16, 8, 0, 126, 64, 64, 64, 124, 64, 64, 64, 126, 0, 0, /* È */
8, 16, 0, 126, 64, 64, 64, 124, 64, 64, 64, 126, 0, 0, /* É */
24, 36, 0, 126, 64, 64, 64, 124, 64, 64, 64, 126, 0, 0, /* Ê */
0, 36, 0, 126, 64, 64, 64, 124, 64, 64, 64, 126, 0, 0, /* Ë */
16, 8, 0, 62, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* Ì */
4, 8, 0, 62, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* Í */
8, 20, 0, 62, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* Î */
0, 20, 0, 62, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* Ï */
0, 0, 60, 34, 33, 33, 121, 33, 33, 33, 34, 60, 0, 0, /* Ð */
50, 76, 0, 98, 98, 82, 82, 74, 74, 74, 70, 70, 0, 0, /* Ñ */
16, 8, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ò */
8, 16, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ó */
24, 36, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ô */
50, 76, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Õ */
0, 36, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ö */
0, 0, 0, 0, 0, 65, 34, 20, 8, 20, 34, 65, 0, 0, /* × */
2, 2, 60, 70, 74, 74, 74, 82, 82, 82, 98, 60, 64, 64, /* Ø */
16, 8, 0, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ù */
8, 16, 0, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ú */
24, 36, 0, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Û */
0, 36, 0, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ü */
4, 8, 0, 34, 34, 20, 20, 8, 8, 8, 8, 8, 0, 0, /* Ý */
0, 0, 64, 64, 124, 66, 66, 66, 66, 124, 64, 64, 0, 0, /* Þ */
0, 0, 24, 36, 36, 36, 56, 36, 34, 34, 34, 124, 0, 0, /* ß */
0, 0, 16, 8, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* à */
0, 0, 4, 8, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* á */
0, 0, 24, 36, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* â */
0, 0, 50, 76, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* ã */
0, 0, 0, 36, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* ä */
0, 24, 36, 24, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* å */
0, 0, 0, 0, 0, 62, 73, 25, 47, 72, 73, 62, 0, 0, /* æ */
0, 0, 0, 0, 0, 60, 66, 64, 64, 64, 66, 60, 8, 16, /* ç */
0, 0, 16, 8, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* è */
0, 0, 8, 16, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* é */
0, 0, 24, 36, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* ê */
0, 0, 0, 36, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* ë */
0, 0, 16, 8, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* ì */
0, 0, 4, 8, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* í */
0, 0, 24, 36, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* î */
0, 0, 0, 20, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* ï */
0, 20, 8, 20, 2, 30, 34, 34, 34, 34, 34, 28, 0, 0, /* ð */
0, 0, 50, 76, 0, 92, 98, 66, 66, 66, 66, 66, 0, 0, /* ñ */
0, 0, 16, 8, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* ò */
0, 0, 8, 16, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* ó */
0, 0, 24, 36, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* ô */
0, 0, 50, 76, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* õ */
0, 0, 0, 36, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* ö */
0, 0, 0, 0, 0, 0, 0, 24, 0, 126, 0, 24, 0, 0, /* ÷ */
0, 0, 0, 2, 4, 60, 74, 74, 82, 82, 98, 60, 64, 64, /* ø */
0, 0, 16, 8, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* ù */
0, 0, 8, 16, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* ú */
0, 0, 24, 36, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* û */
0, 0, 0, 36, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* ü */
0, 0, 8, 16, 0, 66, 66, 34, 36, 20, 28, 8, 72, 48, /* ý */
0, 0, 64, 64, 64, 92, 98, 66, 66, 66, 98, 92, 64, 64, /* þ */
0, 0, 0, 36, 0, 66, 66, 34, 36, 20, 28, 8, 72, 48, /* ÿ */
};
#define SMALL_FONT_WIDTH 5
#define SMALL_FONT_HEIGHT 9
static font_item small_font[] = {
/* Each character is 5 x 9 pixels */
0, 2, 2, 2, 2, 0, 2, 0, 0, /* ! */
0, 5, 5, 5, 0, 0, 0, 0, 0, /* " */
0, 0, 5, 15, 5, 15, 5, 0, 0, /* # */
0, 0, 7, 26, 7, 18, 7, 0, 0, /* $ */
0, 8, 9, 2, 4, 25, 1, 0, 0, /* % */
0, 0, 4, 10, 4, 10, 5, 0, 0, /* & */
0, 2, 2, 2, 0, 0, 0, 0, 0, /* ' */
0, 2, 4, 4, 4, 4, 2, 0, 0, /* ( */
0, 4, 2, 2, 2, 2, 4, 0, 0, /* ) */
0, 0, 5, 2, 7, 2, 5, 0, 0, /* * */
0, 0, 2, 2, 15, 2, 2, 0, 0, /* + */
0, 0, 0, 0, 16, 3, 2, 4, 0, /* , */
0, 0, 0, 0, 15, 0, 0, 0, 0, /* - */
0, 0, 0, 0, 0, 6, 6, 0, 0, /* . */
0, 0, 1, 2, 4, 8, 0, 0, 0, /* / */
0, 2, 5, 5, 5, 5, 2, 0, 0, /* 0 */
0, 2, 6, 2, 2, 2, 7, 0, 0, /* 1 */
0, 6, 9, 1, 2, 4, 15, 0, 0, /* 2 */
0, 15, 1, 6, 1, 9, 6, 0, 0, /* 3 */
0, 2, 6, 10, 15, 2, 2, 0, 0, /* 4 */
0, 15, 8, 14, 1, 9, 6, 0, 0, /* 5 */
0, 6, 8, 14, 9, 9, 6, 0, 0, /* 6 */
0, 15, 1, 2, 2, 4, 4, 0, 0, /* 7 */
0, 6, 9, 6, 9, 9, 6, 0, 0, /* 8 */
0, 6, 9, 9, 7, 1, 6, 0, 0, /* 9 */
0, 0, 6, 6, 0, 6, 6, 0, 0, /* : */
0, 0, 6, 6, 0, 6, 4, 8, 0, /* ; */
0, 0, 1, 2, 4, 2, 1, 0, 0, /* < */
0, 0, 0, 15, 0, 15, 0, 0, 0, /* = */
0, 0, 4, 2, 1, 2, 4, 0, 0, /* > */
0, 2, 5, 1, 2, 0, 2, 0, 0, /* ? */
0, 6, 9, 11, 11, 8, 6, 0, 0, /* @ */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* A */
0, 14, 9, 14, 9, 9, 14, 0, 0, /* B */
0, 6, 9, 8, 8, 9, 6, 0, 0, /* C */
0, 14, 9, 9, 9, 9, 14, 0, 0, /* D */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* E */
0, 15, 8, 14, 8, 8, 8, 0, 0, /* F */
0, 6, 9, 8, 11, 9, 7, 0, 0, /* G */
0, 9, 9, 15, 9, 9, 9, 0, 0, /* H */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* I */
0, 1, 1, 1, 1, 9, 6, 0, 0, /* J */
0, 9, 10, 12, 12, 10, 9, 0, 0, /* K */
0, 8, 8, 8, 8, 8, 15, 0, 0, /* L */
0, 9, 15, 15, 9, 9, 9, 0, 0, /* M */
0, 9, 13, 13, 11, 11, 9, 0, 0, /* N */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* O */
0, 14, 9, 9, 14, 8, 8, 0, 0, /* P */
0, 6, 9, 9, 9, 13, 6, 1, 0, /* Q */
0, 14, 9, 9, 14, 10, 9, 0, 0, /* R */
0, 6, 9, 4, 2, 9, 6, 0, 0, /* S */
0, 7, 2, 2, 2, 2, 2, 0, 0, /* T */
0, 9, 9, 9, 9, 9, 6, 0, 0, /* U */
0, 9, 9, 9, 9, 6, 6, 0, 0, /* V */
0, 9, 9, 9, 15, 15, 9, 0, 0, /* W */
0, 9, 9, 6, 6, 9, 9, 0, 0, /* X */
0, 5, 5, 5, 2, 2, 2, 0, 0, /* Y */
0, 15, 1, 2, 4, 8, 15, 0, 0, /* Z */
0, 7, 4, 4, 4, 4, 7, 0, 0, /* [ */
0, 0, 8, 4, 2, 1, 0, 0, 0, /* \ */
0, 7, 1, 1, 1, 1, 7, 0, 0, /* ] */
0, 2, 5, 0, 0, 0, 0, 0, 0, /* ^ */
0, 0, 0, 0, 0, 0, 15, 0, 0, /* _ */
0, 4, 2, 0, 0, 0, 0, 0, 0, /* ` */
0, 0, 0, 7, 9, 11, 5, 0, 0, /* a */
0, 8, 8, 14, 9, 9, 14, 0, 0, /* b */
0, 0, 0, 6, 8, 8, 6, 0, 0, /* c */
0, 1, 1, 7, 9, 9, 7, 0, 0, /* d */
0, 0, 0, 6, 11, 12, 6, 0, 0, /* e */
0, 2, 5, 4, 14, 4, 4, 0, 0, /* f */
0, 0, 0, 7, 9, 6, 8, 7, 0, /* g */
0, 8, 8, 14, 9, 9, 9, 0, 0, /* h */
0, 2, 0, 6, 2, 2, 7, 0, 0, /* i */
0, 1, 0, 1, 1, 1, 5, 2, 0, /* j */
0, 8, 8, 10, 12, 10, 9, 0, 0, /* k */
0, 6, 2, 2, 2, 2, 7, 0, 0, /* l */
0, 0, 0, 10, 15, 9, 9, 0, 0, /* m */
0, 0, 0, 14, 9, 9, 9, 0, 0, /* n */
0, 0, 0, 6, 9, 9, 6, 0, 0, /* o */
0, 0, 0, 14, 9, 9, 14, 8, 0, /* p */
0, 0, 0, 7, 9, 9, 7, 1, 0, /* q */
0, 0, 0, 14, 9, 8, 8, 0, 0, /* r */
0, 0, 0, 7, 12, 3, 14, 0, 0, /* s */
0, 4, 4, 14, 4, 4, 3, 0, 0, /* t */
0, 0, 0, 9, 9, 9, 7, 0, 0, /* u */
0, 0, 0, 5, 5, 5, 2, 0, 0, /* v */
0, 0, 0, 9, 9, 15, 15, 0, 0, /* w */
0, 0, 0, 9, 6, 6, 9, 0, 0, /* x */
0, 0, 0, 9, 9, 5, 2, 4, 0, /* y */
0, 0, 0, 15, 2, 4, 15, 0, 0, /* z */
0, 1, 2, 6, 2, 2, 1, 0, 0, /* { */
0, 2, 2, 2, 2, 2, 2, 0, 0, /* | */
0, 4, 2, 3, 2, 2, 4, 0, 0, /* } */
0, 5, 10, 0, 0, 0, 0, 0, 0, /* ~ */
0, 2, 0, 2, 2, 2, 2, 0, 0, /* ¡ */
0, 0, 2, 7, 10, 10, 7, 2, 0, /* ¢ */
0, 0, 3, 4, 14, 4, 11, 0, 0, /* £ */
0, 0, 8, 7, 5, 7, 8, 0, 0, /* ¤ */
0, 5, 21, 2, 7, 2, 18, 0, 0, /* ¥ */
0, 0, 2, 2, 0, 2, 2, 0, 0, /* ¦ */
0, 3, 4, 6, 5, 3, 1, 6, 0, /* § */
0, 5, 0, 0, 0, 0, 0, 0, 0, /* ¨ */
0, 7, 8, 10, 12, 10, 8, 7, 0, /* © */
0, 6, 26, 22, 16, 16, 16, 0, 0, /* ª */
0, 0, 0, 4, 9, 4, 0, 0, 0, /* « */
0, 0, 0, 16, 15, 17, 0, 0, 0, /* ¬ */
0, 0, 0, 0, 0, 0, 0, 0, 0, /* ­ */
0, 7, 8, 14, 12, 12, 8, 7, 0, /* ® */
0, 15, 16, 16, 16, 16, 16, 0, 0, /* ¯ */
0, 2, 5, 2, 0, 0, 0, 0, 0, /* ° */
0, 2, 2, 15, 2, 2, 15, 0, 0, /* ± */
0, 6, 2, 20, 6, 0, 16, 0, 0, /* ² */
0, 6, 6, 2, 6, 0, 0, 0, 0, /* ³ */
0, 2, 4, 0, 0, 0, 0, 0, 0, /* ´ */
0, 0, 0, 9, 9, 9, 14, 8, 0, /* µ */
0, 7, 13, 13, 5, 5, 5, 0, 0, /* ¶ */
0, 0, 0, 6, 6, 0, 0, 0, 0, /* · */
0, 0, 0, 0, 0, 0, 2, 4, 0, /* ¸ */
0, 2, 6, 2, 7, 0, 0, 0, 0, /* ¹ */
0, 4, 10, 4, 0, 0, 0, 0, 0, /* º */
0, 0, 0, 9, 4, 9, 0, 0, 0, /* » */
0, 8, 8, 8, 25, 3, 7, 1, 0, /* ¼ */
0, 8, 8, 8, 11, 1, 2, 3, 0, /* ½ */
0, 12, 12, 4, 13, 3, 7, 1, 0, /* ¾ */
0, 2, 0, 2, 4, 5, 2, 0, 0, /* ¿ */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* À */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* Á */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* Â */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* Ã */
0, 9, 6, 9, 15, 9, 9, 0, 0, /* Ä */
0, 6, 6, 9, 15, 9, 9, 0, 0, /* Å */
0, 7, 10, 11, 14, 10, 11, 0, 0, /* Æ */
0, 6, 9, 8, 8, 9, 6, 4, 0, /* Ç */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* È */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* É */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* Ê */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* Ë */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* Ì */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* Í */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* Î */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* Ï */
0, 14, 5, 13, 5, 5, 14, 0, 0, /* Ð */
0, 11, 9, 13, 11, 11, 9, 0, 0, /* Ñ */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* Ò */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* Ó */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* Ô */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* Õ */
0, 9, 6, 9, 9, 9, 6, 0, 0, /* Ö */
0, 0, 0, 9, 6, 6, 9, 0, 0, /* × */
0, 7, 11, 11, 13, 13, 14, 0, 0, /* Ø */
0, 9, 9, 9, 9, 9, 6, 0, 0, /* Ù */
0, 9, 9, 9, 9, 9, 6, 0, 0, /* Ú */
0, 9, 9, 9, 9, 9, 6, 0, 0, /* Û */
0, 9, 0, 9, 9, 9, 6, 0, 0, /* Ü */
0, 5, 5, 5, 2, 2, 2, 0, 0, /* Ý */
0, 8, 14, 9, 14, 8, 8, 0, 0, /* Þ */
0, 6, 9, 10, 9, 9, 10, 0, 0, /* ß */
0, 4, 2, 7, 9, 11, 5, 0, 0, /* à */
0, 2, 4, 7, 9, 11, 5, 0, 0, /* á */
0, 2, 5, 7, 9, 11, 5, 0, 0, /* â */
0, 5, 10, 7, 9, 11, 5, 0, 0, /* ã */
0, 5, 0, 7, 9, 11, 5, 0, 0, /* ä */
0, 6, 6, 7, 9, 11, 5, 0, 0, /* å */
0, 0, 0, 7, 11, 10, 7, 0, 0, /* æ */
0, 0, 0, 3, 4, 4, 3, 2, 0, /* ç */
0, 4, 2, 6, 11, 12, 6, 0, 0, /* è */
0, 2, 4, 6, 11, 12, 6, 0, 0, /* é */
0, 4, 10, 6, 11, 12, 6, 0, 0, /* ê */
0, 10, 0, 6, 11, 12, 6, 0, 0, /* ë */
0, 4, 2, 6, 2, 2, 7, 0, 0, /* ì */
0, 2, 4, 6, 2, 2, 7, 0, 0, /* í */
0, 2, 5, 6, 2, 2, 7, 0, 0, /* î */
0, 5, 0, 6, 2, 2, 7, 0, 0, /* ï */
0, 4, 3, 6, 9, 9, 6, 0, 0, /* ð */
0, 5, 10, 14, 9, 9, 9, 0, 0, /* ñ */
0, 4, 2, 6, 9, 9, 6, 0, 0, /* ò */
0, 2, 4, 6, 9, 9, 6, 0, 0, /* ó */
0, 6, 0, 6, 9, 9, 6, 0, 0, /* ô */
0, 5, 10, 6, 9, 9, 6, 0, 0, /* õ */
0, 5, 0, 6, 9, 9, 6, 0, 0, /* ö */
0, 0, 6, 0, 15, 0, 6, 0, 0, /* ÷ */
0, 0, 0, 7, 11, 13, 14, 0, 0, /* ø */
0, 4, 2, 9, 9, 9, 7, 0, 0, /* ù */
0, 2, 4, 9, 9, 9, 7, 0, 0, /* ú */
0, 6, 0, 9, 9, 9, 7, 0, 0, /* û */
0, 5, 0, 9, 9, 9, 7, 0, 0, /* ü */
0, 2, 4, 9, 9, 5, 2, 4, 0, /* ý */
0, 0, 8, 14, 9, 9, 14, 8, 0, /* þ */
0, 5, 0, 9, 9, 5, 2, 4, 0, /* ÿ */
};
/* Adapted from OCR-B font version 0.2 Matthew Skala
* https://tsukurimashou.osdn.jp/ocr.php.en
*
* Copyright Matthew Skala (2011); based on code by Norbert Schwarz (1986, 2011)
*
* "The version in this package descends from a set of Metafont
* definitions by Norbert Schwarz of Ruhr-Universitaet Bochum,
* bearing dates ranging from 1986 to 2010. He originally
* distributed it under a "non-commercial use only"
* restriction but has since released it for unrestricted use
* and distribution. See the README file for more details."
*
* The README states (http://mirrors.ctan.org/fonts/ocr-b.zip)
*
* "As far as the digitization in METAFONT input which I have
* developed, you may freely use, modify, and/or distribute any of
* these files or the resulting fonts, without limitation. A previous
* release of ocr-b only granted rights for non-commercial use; that
* restriction is now lifted."
*
* Used OCRB.otf with FontForge to create OCRB-18.bdf (normal) and OCRB-16.bdf (small) and then touched up using gbdfed
* Note there's no bold version of OCR-B.
*/
#define UPCEAN_FONT_WIDTH 9
#define UPCEAN_FONT_HEIGHT 14
/* Each character is 9 x 14 pixels */
static font_item upcean_font[] = {
/*30*/ 0x007C, 0x00FE, 0x00C6, 0x0183, 0x0183, 0x0183, 0x0183, 0x0183, 0x0183, 0x0183, 0x0183, 0x00C6, 0x00FE, 0x007C, /* 0 */
/*31*/ 0x000C, 0x001C, 0x003C, 0x006C, 0x004C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, /* 1 */
/*32*/ 0x007C, 0x00FE, 0x0183, 0x0003, 0x0007, 0x000E, 0x001C, 0x0038, 0x0070, 0x00E0, 0x01C0, 0x0180, 0x01FE, 0x00FF, /* 2 */
/*33*/ 0x01FE, 0x01FE, 0x0006, 0x000C, 0x0018, 0x0038, 0x003C, 0x0006, 0x0003, 0x0003, 0x0003, 0x0006, 0x01FE, 0x00F8, /* 3 */
/*34*/ 0x0018, 0x0018, 0x0030, 0x0030, 0x0060, 0x0060, 0x00C4, 0x00CC, 0x018C, 0x01FF, 0x01FF, 0x000C, 0x000C, 0x000C, /* 4 */
/*35*/ 0x00FE, 0x00FE, 0x00C0, 0x00C0, 0x00C0, 0x00F8, 0x00FC, 0x0006, 0x0006, 0x0006, 0x0006, 0x000C, 0x01FC, 0x00F8, /* 5 */
/*36*/ 0x000C, 0x001C, 0x0038, 0x0030, 0x0060, 0x00F8, 0x00FE, 0x01C7, 0x0183, 0x0183, 0x0183, 0x01C3, 0x00FE, 0x007C, /* 6 */
/*37*/ 0x01FF, 0x01FF, 0x0003, 0x0006, 0x000E, 0x000C, 0x0018, 0x0030, 0x0030, 0x0030, 0x0060, 0x0060, 0x0060, 0x0060, /* 7 */
/*38*/ 0x007C, 0x00FE, 0x00C6, 0x0082, 0x00C6, 0x007C, 0x007C, 0x00EE, 0x01C7, 0x0183, 0x0183, 0x0183, 0x00FE, 0x007C, /* 8 */
/*39*/ 0x007C, 0x00FE, 0x00C7, 0x0183, 0x0183, 0x0183, 0x01C3, 0x00FE, 0x007E, 0x000C, 0x000C, 0x0018, 0x0030, 0x0060, /* 9 */
};
#define UPCEAN_SMALL_FONT_WIDTH 8
#define UPCEAN_SMALL_FONT_HEIGHT 13
/* Each character is 8 x 13 pixels */
static font_item upcean_small_font[] = {
/*30*/ 0x3C, 0x7E, 0x66, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0x66, 0x7E, 0x3C, /* 0 */
/*31*/ 0x00, 0x0E, 0x1E, 0x36, 0x26, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, /* 1 */
/*32*/ 0x38, 0x7C, 0xC6, 0x02, 0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xFC, 0x7E, /* 2 */
/*33*/ 0x00, 0xFE, 0xFE, 0x06, 0x1C, 0x38, 0x3E, 0x07, 0x03, 0x03, 0x06, 0xFC, 0x78, /* 3 */
/*34*/ 0x00, 0x18, 0x18, 0x30, 0x30, 0x60, 0x64, 0xCC, 0xCC, 0xFF, 0xFF, 0x0C, 0x0C, /* 4 */
/*35*/ 0x00, 0x7E, 0x7E, 0x40, 0x40, 0x78, 0x7C, 0x06, 0x02, 0x02, 0x06, 0xFC, 0x78, /* 5 */
/*36*/ 0x00, 0x0C, 0x1C, 0x30, 0x30, 0x7C, 0xFE, 0xC7, 0xC3, 0xC3, 0xC3, 0x7E, 0x3C, /* 6 */
/*37*/ 0x00, 0xFF, 0xFF, 0x03, 0x06, 0x0C, 0x18, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, /* 7 */
/*38*/ 0x3C, 0x7E, 0x66, 0x42, 0x66, 0x3C, 0x3C, 0x66, 0xC3, 0xC3, 0xC3, 0x7E, 0x3C, /* 8 */
/*39*/ 0x3C, 0x7E, 0xE7, 0xC3, 0xC3, 0xC3, 0xE3, 0x7E, 0x1E, 0x0C, 0x18, 0x30, 0x60, /* 9 */
};
#endif /* FONT_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2975
3rdparty/zint-2.10.0/backend/gb18030.c vendored Normal file

File diff suppressed because it is too large Load Diff

52
3rdparty/zint-2.10.0/backend/gb18030.h vendored Normal file
View File

@@ -0,0 +1,52 @@
/* gb18030.h - Unicode to GB 18030
libzint - the open source barcode library
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef GB18030_H
#define GB18030_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, const unsigned int wc);
INTERNAL int gb18030_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
unsigned int *gbdata);
INTERNAL int gb18030_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
const int full_multibyte);
INTERNAL void gb18030_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata,
const int full_multibyte);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* GB18030_H */

1632
3rdparty/zint-2.10.0/backend/gb2312.c vendored Normal file

File diff suppressed because it is too large Load Diff

52
3rdparty/zint-2.10.0/backend/gb2312.h vendored Normal file
View File

@@ -0,0 +1,52 @@
/* gb2312.h - Unicode to GB 2312-1980 (EUC-CN)
libzint - the open source barcode library
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef GB2312_H
#define GB2312_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
INTERNAL int gb2312_wctomb_zint(unsigned int *r, const unsigned int wc);
INTERNAL int gb2312_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
unsigned int *gbdata);
INTERNAL int gb2312_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
const int full_multibyte);
INTERNAL void gb2312_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata,
const int full_multibyte);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* GB2312_H */

View File

@@ -0,0 +1,206 @@
/* general_field.c - Handles general field compaction (GS1 DataBar and composites) */
/*
libzint - the open source barcode library
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include "common.h"
#include "general_field.h"
static const char alphanum_puncs[] = "*,-./";
static const char isoiec_puncs[] = "!\"%&'()*+,-./:;<=>?_ "; /* Note contains space, not in cset82 */
/* Returns type of char at `i`. FNC1 counted as NUMERIC. Returns 0 if invalid char */
static int general_field_type(const char *general_field, const int i) {
if (general_field[i] == '[' || (general_field[i] >= '0' && general_field[i] <= '9')) {
return NUMERIC;
}
if ((general_field[i] >= 'A' && general_field[i] <= 'Z') || strchr(alphanum_puncs, general_field[i])) {
return ALPHANUMERIC;
}
if ((general_field[i] >= 'a' && general_field[i] <= 'z') || strchr(isoiec_puncs, general_field[i])) {
return ISOIEC;
}
return 0;
}
/* Returns true if next (including `i`) `num` chars of type `type`, or if given (non-zero), `type2` */
static int general_field_next(const char *general_field, int i, const int general_field_len, int num, const int type,
const int type2) {
if (i + num > general_field_len) {
return 0;
}
for (; i < general_field_len && num; i++, num--) {
int type_i = general_field_type(general_field, i);
if ((type_i != type && !type2) || (type_i != type && type_i != type2)) {
return 0;
}
}
return num == 0;
}
/* Returns true if next (including `i`) `num` up to `max_num` chars of type `type` and occur at end */
static int general_field_next_terminate(const char *general_field, int i, const int general_field_len, int num,
const int max_num, const int type) {
if (i + max_num < general_field_len) {
return 0;
}
for (; i < general_field_len; i++, num--) {
if (general_field_type(general_field, i) != type) {
return 0;
}
}
return i == general_field_len && num <= 0;
}
/* Returns true if none of the next (including `i`) `num` chars (or end occurs) of type `type` */
static int general_field_next_none(const char *general_field, int i, const int general_field_len, int num,
const int type) {
for (; i < general_field_len && num; i++, num--) {
if (general_field_type(general_field, i) == type) {
return 0;
}
}
return num == 0 || i == general_field_len;
}
/* Attempts to apply encoding rules from sections 7.2.5.5.1 to 7.2.5.5.3
* of ISO/IEC 24724:2011 (same as sections 5.4.1 to 5.4.3 of ISO/IEC 24723:2010) */
INTERNAL int general_field_encode(const char *general_field, const int general_field_len, int *p_mode,
char *p_last_digit, char binary_string[], int *p_bp) {
int i, d1, d2;
int mode = *p_mode;
char last_digit = '\0'; /* Set to odd remaining digit at end if any */
int bp = *p_bp;
for (i = 0; i < general_field_len; ) {
int type = general_field_type(general_field, i);
if (!type) {
return 0;
}
switch (mode) {
case NUMERIC:
if (i < general_field_len - 1) { /* If at least 2 characters remain */
if (type != NUMERIC || general_field_type(general_field, i + 1) != NUMERIC) {
/* 7.2.5.5.1/5.4.1 a) */
bp = bin_append_posn(0, 4, binary_string, bp); /* Alphanumeric latch "0000" */
mode = ALPHANUMERIC;
} else {
d1 = general_field[i] == '[' ? 10 : ctoi(general_field[i]);
d2 = general_field[i + 1] == '[' ? 10 : ctoi(general_field[i + 1]);
bp = bin_append_posn((11 * d1) + d2 + 8, 7, binary_string, bp);
i += 2;
}
} else { /* If 1 character remains */
if (type != NUMERIC) {
/* 7.2.5.5.1/5.4.1 b) */
bp = bin_append_posn(0, 4, binary_string, bp); /* Alphanumeric latch "0000" */
mode = ALPHANUMERIC;
} else {
/* Ending with single digit.
* 7.2.5.5.1 c) and 5.4.1 c) dealt with separately outside this procedure */
last_digit = general_field[i];
i++;
}
}
break;
case ALPHANUMERIC:
if (general_field[i] == '[') {
/* 7.2.5.5.2/5.4.2 a) */
bp = bin_append_posn(15, 5, binary_string, bp); /* "01111" */
mode = NUMERIC;
i++;
} else if (type == ISOIEC) {
/* 7.2.5.5.2/5.4.2 b) */
bp = bin_append_posn(4, 5, binary_string, bp); /* ISO/IEC 646 latch "00100" */
mode = ISOIEC;
} else if (general_field_next(general_field, i, general_field_len, 6, NUMERIC, 0)) {
/* 7.2.5.5.2/5.4.2 c) */
bp = bin_append_posn(0, 3, binary_string, bp); /* Numeric latch "000" */
mode = NUMERIC;
} else if (general_field_next_terminate(general_field, i, general_field_len, 4,
5 /*Can limit to 5 max due to above*/, NUMERIC)) {
/* 7.2.5.5.2/5.4.2 d) */
bp = bin_append_posn(0, 3, binary_string, bp); /* Numeric latch "000" */
mode = NUMERIC;
} else if ((general_field[i] >= '0') && (general_field[i] <= '9')) {
bp = bin_append_posn(general_field[i] - 43, 5, binary_string, bp);
i++;
} else if ((general_field[i] >= 'A') && (general_field[i] <= 'Z')) {
bp = bin_append_posn(general_field[i] - 33, 6, binary_string, bp);
i++;
} else {
bp = bin_append_posn(posn(alphanum_puncs, general_field[i]) + 58, 6, binary_string, bp);
i++;
}
break;
case ISOIEC:
if (general_field[i] == '[') {
/* 7.2.5.5.3/5.4.3 a) */
bp = bin_append_posn(15, 5, binary_string, bp); /* "01111" */
mode = NUMERIC;
i++;
} else {
int next_10_not_isoiec = general_field_next_none(general_field, i, general_field_len, 10, ISOIEC);
if (next_10_not_isoiec && general_field_next(general_field, i, general_field_len, 4,
NUMERIC, 0)) {
/* 7.2.5.5.3/5.4.3 b) */
bp = bin_append_posn(0, 3, binary_string, bp); /* Numeric latch "000" */
mode = NUMERIC;
} else if (next_10_not_isoiec && general_field_next(general_field, i, general_field_len, 5,
ALPHANUMERIC, NUMERIC)) {
/* 7.2.5.5.3/5.4.3 c) */
/* Note this rule can produce longer bitstreams if most of the alphanumerics are numeric */
bp = bin_append_posn(4, 5, binary_string, bp); /* Alphanumeric latch "00100" */
mode = ALPHANUMERIC;
} else if ((general_field[i] >= '0') && (general_field[i] <= '9')) {
bp = bin_append_posn(general_field[i] - 43, 5, binary_string, bp);
i++;
} else if ((general_field[i] >= 'A') && (general_field[i] <= 'Z')) {
bp = bin_append_posn(general_field[i] - 1, 7, binary_string, bp);
i++;
} else if ((general_field[i] >= 'a') && (general_field[i] <= 'z')) {
bp = bin_append_posn(general_field[i] - 7, 7, binary_string, bp);
i++;
} else {
bp = bin_append_posn(posn(isoiec_puncs, general_field[i]) + 232, 8, binary_string, bp);
i++;
}
}
break;
}
}
*p_mode = mode;
*p_last_digit = last_digit;
*p_bp = bp;
return 1;
}

View File

@@ -0,0 +1,50 @@
/*
libzint - the open source barcode library
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef __GENERAL_FIELD_H
#define __GENERAL_FIELD_H
#define NUMERIC 110
#define ALPHANUMERIC 97
#define ISOIEC 105
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
INTERNAL int general_field_encode(const char *general_field, const int general_field_len, int *p_mode,
char *p_last_digit, char binary_string[], int *p_bp);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GENERAL_FIELD_H */

608
3rdparty/zint-2.10.0/backend/gif.c vendored Normal file
View File

@@ -0,0 +1,608 @@
/* gif.c - Handles output to gif file */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <errno.h>
#include <stdio.h>
#include "common.h"
#include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#include <malloc.h>
#endif
#define SSET "0123456789ABCDEF"
typedef struct s_statestruct {
unsigned char *pOut;
unsigned char *pIn;
unsigned int InLen;
unsigned int OutLength;
unsigned int OutPosCur;
unsigned int OutByteCountPos;
unsigned short ClearCode;
unsigned short FreeCode;
char fByteCountByteSet;
unsigned char OutBitsFree;
unsigned short NodeAxon[4096];
unsigned short NodeNext[4096];
unsigned char NodePix[4096];
unsigned char colourCode[10];
unsigned char colourPaletteIndex[10];
int colourCount;
} statestruct;
/* Transform a Pixel to a lzw colourmap index and move to next pixel.
* All colour values are listed in colourCode with corresponding palette index
*/
static unsigned char NextPaletteIndex(statestruct *pState)
{
unsigned char pixelColour;
int colourIndex;
pixelColour = *(pState->pIn);
(pState->pIn)++;
(pState->InLen)--;
for (colourIndex = 0; colourIndex < pState->colourCount; colourIndex++) {
if (pixelColour == pState->colourCode[colourIndex])
return pState->colourPaletteIndex[colourIndex];
}
return 0; /* Not reached */
}
static int BufferNextByte(statestruct *pState) {
(pState->OutPosCur)++;
/* Check if this position is a byte count position
* fg_f_bytecountbyte_set indicates, if byte count position bytes should be
* inserted in general.
* If this is true, and the distance to the last byte count position is 256
* (e.g. 255 bytes in between), a byte count byte is inserted, and the value
* of the last one is set to 255.
* */
if (pState->fByteCountByteSet && (pState->OutByteCountPos + 256 == pState->OutPosCur)) {
(pState->pOut)[pState->OutByteCountPos] = 255;
pState->OutByteCountPos = pState->OutPosCur;
(pState->OutPosCur)++;
}
if (pState->OutPosCur >= pState->OutLength)
return 1;
(pState->pOut)[pState->OutPosCur] = 0x00;
return 0;
}
static int AddCodeToBuffer(statestruct *pState, unsigned short CodeIn, unsigned char CodeBits) {
/* Check, if we may fill up the current byte completely */
if (CodeBits >= pState->OutBitsFree) {
(pState->pOut)[pState->OutPosCur] |= (unsigned char) (CodeIn << (8 - pState->OutBitsFree));
if (BufferNextByte(pState))
return -1;
CodeIn = (unsigned short) (CodeIn >> pState->OutBitsFree);
CodeBits -= pState->OutBitsFree;
pState->OutBitsFree = 8;
/* Write a full byte if there are at least 8 code bits left */
if (CodeBits >= pState->OutBitsFree) {
(pState->pOut)[pState->OutPosCur] = (unsigned char) CodeIn;
if (BufferNextByte(pState))
return -1;
CodeIn = (unsigned short) (CodeIn >> 8);
CodeBits -= 8;
}
}
/* The remaining bits of CodeIn fit in the current byte. */
if (CodeBits > 0) {
(pState->pOut)[pState->OutPosCur] |= (unsigned char) (CodeIn << (8 - pState->OutBitsFree));
pState->OutBitsFree -= CodeBits;
}
return 0;
}
static void FlushStringTable(statestruct *pState) {
unsigned short Pos;
for (Pos = 0; Pos < pState->ClearCode; Pos++) {
(pState->NodeAxon)[Pos] = 0;
}
}
static unsigned short FindPixelOutlet(statestruct *pState, unsigned short HeadNode, unsigned char Byte) {
unsigned short Outlet;
Outlet = (pState->NodeAxon)[HeadNode];
while (Outlet) {
if ((pState->NodePix)[Outlet] == Byte)
return Outlet;
Outlet = (pState->NodeNext)[Outlet];
}
return 0;
}
static int NextCode(statestruct *pState, unsigned char *pPixelValueCur, unsigned char CodeBits) {
unsigned short UpNode;
unsigned short DownNode;
/* start with the root node for last pixel chain */
UpNode = *pPixelValueCur;
if ((pState->InLen) == 0)
return AddCodeToBuffer(pState, UpNode, CodeBits);
*pPixelValueCur = NextPaletteIndex(pState);
/* Follow the string table and the data stream to the end of the longest string that has a code */
while (0 != (DownNode = FindPixelOutlet(pState, UpNode, *pPixelValueCur))) {
UpNode = DownNode;
if ((pState->InLen) == 0)
return AddCodeToBuffer(pState, UpNode, CodeBits);
*pPixelValueCur = NextPaletteIndex(pState);
}
/* Submit 'UpNode' which is the code of the longest string */
if (AddCodeToBuffer(pState, UpNode, CodeBits))
return -1;
/* ... and extend the string by appending 'PixelValueCur' */
/* Create a successor node for 'PixelValueCur' whose code is 'freecode' */
(pState->NodePix)[pState->FreeCode] = *pPixelValueCur;
(pState->NodeAxon)[pState->FreeCode] = (pState->NodeNext)[pState->FreeCode] = 0;
/* ...and link it to the end of the chain emanating from fg_axon[UpNode]. */
DownNode = (pState->NodeAxon)[UpNode];
if (!DownNode) {
(pState->NodeAxon)[UpNode] = pState->FreeCode;
} else {
while ((pState->NodeNext)[DownNode]) {
DownNode = (pState->NodeNext)[DownNode];
}
(pState->NodeNext)[DownNode] = pState->FreeCode;
}
return 1;
}
static int gif_lzw(statestruct *pState, int paletteBitSize) {
unsigned char PixelValueCur;
unsigned char CodeBits;
unsigned short Pos;
// > Get first data byte
if (pState->InLen == 0)
return 0;
PixelValueCur = NextPaletteIndex(pState);
/* Number of bits per data item (=pixel)
* We need at least a value of 2, otherwise the cc and eoi code consumes
* the whole string table
*/
if (paletteBitSize == 1)
paletteBitSize = 2;
/* initial size of compression codes */
CodeBits = paletteBitSize + 1;
pState->ClearCode = (1 << paletteBitSize);
pState->FreeCode = pState->ClearCode + 2;
pState->OutBitsFree = 8;
pState->OutPosCur = -1;
pState->fByteCountByteSet = 0;
if (BufferNextByte(pState))
return 0;
for (Pos = 0; Pos < pState->ClearCode; Pos++)
(pState->NodePix)[Pos] = (unsigned char) Pos;
FlushStringTable(pState);
/* Write what the GIF specification calls the "code size". */
(pState->pOut)[pState->OutPosCur] = paletteBitSize;
/* Reserve first bytecount byte */
if (BufferNextByte(pState))
return 0;
pState->OutByteCountPos = pState->OutPosCur;
if (BufferNextByte(pState))
return 0;
pState->fByteCountByteSet = 1;
/* Submit one 'ClearCode' as the first code */
if (AddCodeToBuffer(pState, pState->ClearCode, CodeBits))
return 0;
for (;;) {
int Res;
/* generate and save the next code, which may consist of multiple input pixels. */
Res = NextCode(pState, &PixelValueCur, CodeBits);
if (Res < 0)
return 0;
//* Check for end of data stream */
if (!Res) {
/* submit 'eoi' as the last item of the code stream */
if (AddCodeToBuffer(pState, (unsigned short) (pState->ClearCode + 1), CodeBits))
return 0;
pState->fByteCountByteSet = 0;
if (pState->OutBitsFree < 8) {
if (BufferNextByte(pState))
return 0;
}
// > Update last bytecount byte;
if (pState->OutByteCountPos < pState->OutPosCur) {
(pState->pOut)[pState->OutByteCountPos]
= (unsigned char) (pState->OutPosCur - pState->OutByteCountPos - 1);
}
pState->OutPosCur++;
return pState->OutPosCur;
}
/* Check for currently last code */
if (pState->FreeCode == (1U << CodeBits))
CodeBits++;
pState->FreeCode++;
/* Check for full stringtable */
if (pState->FreeCode == 0xfff) {
FlushStringTable(pState);
if (AddCodeToBuffer(pState, pState->ClearCode, CodeBits))
return 0;
CodeBits = (unsigned char) (1 + paletteBitSize);
pState->FreeCode = (unsigned short) (pState->ClearCode + 2);
}
}
}
/*
* Called function to save in gif format
*/
INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
unsigned char outbuf[10];
FILE *gif_file;
unsigned short usTemp;
int byte_out;
int colourCount;
unsigned char paletteRGB[10][3];
int paletteCount, paletteCountCur, paletteIndex;
unsigned int pixelIndex;
int paletteBitSize;
int paletteSize;
statestruct State;
int transparent_index;
int bgindex = -1, fgindex = -1;
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT;
unsigned char backgroundColourIndex;
unsigned char RGBCur[3];
unsigned char RGBUnused[3] = {0,0,0};
int colourIndex;
int fFound;
unsigned char pixelColour;
unsigned int bitmapSize = symbol->bitmap_height * symbol->bitmap_width;
/* Allow for overhead of 4 == code size + byte count + overflow byte + zero terminator */
unsigned int lzoutbufSize = bitmapSize + 4;
#ifdef _MSC_VER
char *lzwoutbuf;
#endif
#ifndef _MSC_VER
char lzwoutbuf[lzoutbufSize];
#else
lzwoutbuf = (char *) _alloca(lzoutbufSize);
#endif /* _MSC_VER */
/*
* Build a table of the used palette items.
* Currently, there are the following 10 colour codes:
* '0': standard background
* '1': standard foreground
* 'W': white
* 'C': cyan
* 'B': blue
* 'M': magenta
* 'R': red
* 'Y': yellow
* 'G': green
* 'K': black
* '0' and '1' may be identical to one of the other values
*
* A data structure is set up as follows:
* state.colourCode: list of colour codes
* paletteIndex: palette index of the corresponding colour code
* There are colourCount entries in the upper lists.
* paletteRGB: RGB value at the palette position
* There are paletteCount entries.
* This value is smaller to colourCount, if multiple colour codes have the
* same RGB value and point to the same palette value.
* Example:
* 0 1 W K are present. 0 is equal to white, while 1 is blue
* The resulting tables are:
* paletteItem: ['0']=0 (white), ['1']=1 (blue), ['W']=0 (white),
* ['K']=2 (black)
* Thus, there are 4 colour codes and 3 palette entries.
*/
colourCount = 0;
paletteCount = 0;
/* loop over all pixels */
for (pixelIndex = 0; pixelIndex < bitmapSize; pixelIndex++) {
fFound = 0;
/* get pixel colour code */
pixelColour = pixelbuf[pixelIndex];
/* look, if colour code is already in colour list */
for (colourIndex = 0; colourIndex < colourCount; colourIndex++) {
if ((State.colourCode)[colourIndex] == pixelColour) {
fFound = 1;
break;
}
}
/* If colour is already present, go to next colour code */
if (fFound)
continue;
/* Colour code not present - add colour code */
/* Get RGB value */
switch (pixelColour) {
case '0': /* standard background */
RGBCur[0] = (unsigned char) (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
RGBCur[1] = (unsigned char) (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
RGBCur[2] = (unsigned char) (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
break;
case '1': /* standard foreground */
RGBCur[0] = (unsigned char) (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
RGBCur[1] = (unsigned char) (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
RGBCur[2] = (unsigned char) (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
break;
case 'W': /* white */
RGBCur[0] = 255; RGBCur[1] = 255; RGBCur[2] = 255;
break;
case 'C': /* cyan */
RGBCur[0] = 0; RGBCur[1] = 255; RGBCur[2] = 255;
break;
case 'B': /* blue */
RGBCur[0] = 0; RGBCur[1] = 0; RGBCur[2] = 255;
break;
case 'M': /* magenta */
RGBCur[0] = 255; RGBCur[1] = 0; RGBCur[2] = 255;
break;
case 'R': /* red */
RGBCur[0] = 255; RGBCur[1] = 0; RGBCur[2] = 0;
break;
case 'Y': /* yellow */
RGBCur[0] = 255; RGBCur[1] = 255; RGBCur[2] = 0;
break;
case 'G': /* green */
RGBCur[0] = 0; RGBCur[1] = 255; RGBCur[2] = 0;
break;
case 'K': /* black */
RGBCur[0] = 0; RGBCur[1] = 0; RGBCur[2] = 0;
break;
default: /* error case - return */
strcpy(symbol->errtxt, "612: unknown pixel colour");
return ZINT_ERROR_INVALID_DATA;
}
/* Search, if RGB value is already present */
fFound = 0;
for (paletteIndex = 0; paletteIndex < paletteCount; paletteIndex++) {
if (RGBCur[0] == paletteRGB[paletteIndex][0]
&& RGBCur[1] == paletteRGB[paletteIndex][1]
&& RGBCur[2] == paletteRGB[paletteIndex][2])
{
fFound = 1;
break;
}
}
/* RGB not present, add it */
if (!fFound) {
paletteIndex = paletteCount;
paletteRGB[paletteIndex][0] = RGBCur[0];
paletteRGB[paletteIndex][1] = RGBCur[1];
paletteRGB[paletteIndex][2] = RGBCur[2];
paletteCount++;
if (pixelColour == '0') bgindex = paletteIndex;
if (pixelColour == '1') fgindex = paletteIndex;
}
/* Add palette index to current colour code */
(State.colourCode)[colourCount] = pixelColour;
(State.colourPaletteIndex)[colourCount] = paletteIndex;
colourCount++;
}
State.colourCount = colourCount;
/* Set transparency */
/* Note: does not allow both transparent foreground and background -
* background takes priority */
transparent_index = -1;
if (strlen(symbol->fgcolour) > 6) {
if ((symbol->fgcolour[6] == '0') && (symbol->fgcolour[7] == '0')) {
// Transparent foreground
transparent_index = fgindex;
}
}
if (strlen(symbol->bgcolour) > 6) {
if ((symbol->bgcolour[6] == '0') && (symbol->bgcolour[7] == '0')) {
// Transparent background
transparent_index = bgindex;
}
}
/* find palette bit size from palette size*/
/* 1,2 -> 1, 3,4 ->2, 5,6,7,8->3 */
paletteBitSize = 0;
paletteCountCur = paletteCount - 1;
while (paletteCountCur != 0) {
paletteBitSize++;
paletteCountCur >>= 1;
}
/* Minimum is 1 */
if (paletteBitSize == 0)
paletteBitSize = 1;
/* palette size 2 ^ bit size */
paletteSize = 1 << paletteBitSize;
/* Open output file in binary mode */
if (output_to_stdout) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
sprintf(symbol->errtxt, "610: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
#endif
gif_file = stdout;
} else {
if (!(gif_file = fopen(symbol->outfile, "wb"))) {
sprintf(symbol->errtxt, "611: Could not open output file (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
}
/* GIF signature (6) */
memcpy(outbuf, "GIF87a", 6);
if (transparent_index != -1)
outbuf[4] = '9';
fwrite(outbuf, 6, 1, gif_file);
/* Screen Descriptor (7) */
/* Screen Width */
usTemp = (unsigned short) symbol->bitmap_width;
outbuf[0] = (unsigned char) (0xff & usTemp);
outbuf[1] = (unsigned char) ((0xff00 & usTemp) / 0x100);
/* Screen Height */
usTemp = (unsigned short) symbol->bitmap_height;
outbuf[2] = (unsigned char) (0xff & usTemp);
outbuf[3] = (unsigned char) ((0xff00 & usTemp) / 0x100);
/* write ImageBits-1 to the three least significant bits of byte 5 of
* the Screen Descriptor
* Bits 76543210
* 1 : Global colour map
* 111 : 8 bit colour depth of the palette
* 0 : Not ordered in decreasing importance
* xxx : palette bit zize - 1
*/
outbuf[4] = (unsigned char) (0xf0 | (0x7 & (paletteBitSize - 1)));
/*
* Background colour index
* Default to 0. If colour code 0 or K is present, it is used as index
*/
backgroundColourIndex = 0;
for (colourIndex = 0; colourIndex < colourCount; colourIndex++) {
if ((State.colourCode)[colourIndex] == '0' || (State.colourCode)[colourIndex] == 'W') {
backgroundColourIndex = (State.colourPaletteIndex)[colourIndex];
break;
}
}
outbuf[5] = backgroundColourIndex;
/* Byte 7 must be 0x00 */
outbuf[6] = 0x00;
fwrite(outbuf, 7, 1, gif_file);
/* Global Color Table (paletteSize*3) */
fwrite(paletteRGB, 3*paletteCount, 1, gif_file);
/* add unused palette items to fill palette size */
for (paletteIndex = paletteCount; paletteIndex < paletteSize; paletteIndex++) {
fwrite(RGBUnused, 3, 1, gif_file);
}
/* Graphic control extension (8) */
/* A graphic control extension block is used for overlay gifs.
* This is necessary to define a transparent color.
*/
if (transparent_index != -1) {
/* Extension Introducer = '!' */
outbuf[0] = '\x21';
/* Graphic Control Label */
outbuf[1] = '\xf9';
/* Block Size */
outbuf[2] = 4;
/* Packet fields:
* 3 Reserved
* 3 Disposal Method: 0 No Action, 1 No Dispose, 2: Background, 3: Prev.
* 1 User Input Flag: 0: no user input, 1: user input
* 1 Transparent Color Flag: 0: No Transparency, 1: Transparency index
*/
outbuf[3] = 1;
/* Delay Time */
outbuf[4] = 0;
outbuf[5] = 0;
/* Transparent Color Index */
outbuf[6] = (unsigned char) transparent_index;
/* Block Terminator */
outbuf[7] = 0;
fwrite(outbuf, 8, 1, gif_file);
}
/* Image Descriptor */
/* Image separator character = ',' */
outbuf[0] = 0x2c;
/* "Image Left" */
outbuf[1] = 0x00;
outbuf[2] = 0x00;
/* "Image Top" */
outbuf[3] = 0x00;
outbuf[4] = 0x00;
/* Image Width (low byte first) */
outbuf[5] = (unsigned char) (0xff & symbol->bitmap_width);
outbuf[6] = (unsigned char) ((0xff00 & symbol->bitmap_width) / 0x100);
/* Image Height */
outbuf[7] = (unsigned char) (0xff & symbol->bitmap_height);
outbuf[8] = (unsigned char) ((0xff00 & symbol->bitmap_height) / 0x100);
/* Byte 10 contains the interlaced flag and
* information on the local color table.
* There is no local color table if its most significant bit is reset.
*/
outbuf[9] = 0x00;
fwrite(outbuf, 10, 1, gif_file);
/* prepare state array */
State.pIn = pixelbuf;
State.InLen = bitmapSize;
State.pOut = (unsigned char *) lzwoutbuf;
State.OutLength = lzoutbufSize;
/* call lzw encoding */
byte_out = gif_lzw(&State, paletteBitSize);
if (byte_out <= 0) {
if (!output_to_stdout) {
fclose(gif_file);
}
strcpy(symbol->errtxt, "613: Insufficient memory for LZW buffer");
return ZINT_ERROR_MEMORY;
}
fwrite(lzwoutbuf, byte_out, 1, gif_file);
/* GIF terminator */
fputc('\x3b', gif_file);
if (output_to_stdout) {
fflush(gif_file);
} else {
fclose(gif_file);
}
return 0;
}

1196
3rdparty/zint-2.10.0/backend/gridmtx.c vendored Normal file

File diff suppressed because it is too large Load Diff

178
3rdparty/zint-2.10.0/backend/gridmtx.h vendored Normal file
View File

@@ -0,0 +1,178 @@
/* gridmtx.h - definitions for Grid Matrix
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#define EUROPIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
static const char shift_set[] = {
/* From Table 7 - Encoding of control characters */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* NULL -> SI */
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* DLE -> US */
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':',
';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~'
};
static const unsigned short int gm_recommend_cw[] = {
9, 30, 59, 114, 170, 237, 315, 405, 506, 618, 741, 875, 1021
};
static const unsigned short int gm_max_cw[] = {
11, 40, 79, 146, 218, 305, 405, 521, 650, 794, 953, 1125, 1313
};
static const unsigned short int gm_data_codewords[] = {
0, 15, 13, 11, 9,
45, 40, 35, 30, 25,
89, 79, 69, 59, 49,
146, 130, 114, 98, 81,
218, 194, 170, 146, 121,
305, 271, 237, 203, 169,
405, 360, 315, 270, 225,
521, 463, 405, 347, 289,
650, 578, 506, 434, 361,
794, 706, 618, 530, 441,
953, 847, 741, 635, 529,
1125, 1000, 875, 750, 625,
1313, 1167, 1021, 875, 729
};
static const char gm_n1[] = {
18, 50, 98, 81, 121, 113, 113, 116, 121, 126, 118, 125, 122
};
static const char gm_b1[] = {
1, 1, 1, 2, 2, 2, 2, 3, 2, 7, 5, 10, 6
};
static const char gm_b2[] = {
0, 0, 0, 0, 0, 1, 2, 2, 4, 0, 4, 0, 6
};
/* Values from table A.1 */
static const char gm_ebeb[] = {
/* E1 B3 E2 B4 */
0, 0, 0, 0, // version 1
3, 1, 0, 0,
5, 1, 0, 0,
7, 1, 0, 0,
9, 1, 0, 0,
5, 1, 0, 0, // version 2
10, 1, 0, 0,
15, 1, 0, 0,
20, 1, 0, 0,
25, 1, 0, 0,
9, 1, 0, 0, // version 3
19, 1, 0, 0,
29, 1, 0, 0,
39, 1, 0, 0,
49, 1, 0, 0,
8, 2, 0, 0, // version 4
16, 2, 0, 0,
24, 2, 0, 0,
32, 2, 0, 0,
41, 1, 40, 1,
12, 2, 0, 0, // version 5
24, 2, 0, 0,
36, 2, 0, 0,
48, 2, 0, 0,
61, 1, 60, 1,
11, 3, 0, 0, // version 6
23, 1, 22, 2,
34, 2, 33, 1,
45, 3, 0, 0,
57, 1, 56, 2,
12, 1, 11, 3, // version 7
23, 2, 22, 2,
34, 3, 33, 1,
45, 4, 0, 0,
57, 1, 56, 3,
12, 2, 11, 3, // version 8
23, 5, 0, 0,
35, 3, 34, 2,
47, 1, 46, 4,
58, 4, 57, 1,
12, 6, 0, 0, // version 9
24, 6, 0, 0,
36, 6, 0, 0,
48, 6, 0, 0,
61, 1, 60, 5,
13, 4, 12, 3, // version 10
26, 1, 25, 6,
38, 5, 37, 2,
51, 2, 50, 5,
63, 7, 0, 0,
12, 6, 11, 3, // version 11
24, 4, 23, 5,
36, 2, 35, 7,
47, 9, 0, 0,
59, 7, 58, 2,
13, 5, 12, 5, // version 12
25, 10, 0, 0,
38, 5, 37, 5,
50, 10, 0, 0,
63, 5, 62, 5,
13, 1, 12, 11, //version 13
25, 3, 24, 9,
37, 5, 36, 7,
49, 7, 48, 5,
61, 9, 60, 3
};
static const unsigned short int gm_macro_matrix[] = {
728, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650,
727, 624, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 651,
726, 623, 528, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 553, 652,
725, 622, 527, 440, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 463, 554, 653,
724, 621, 526, 439, 360, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 381, 464, 555, 654,
723, 620, 525, 438, 359, 288, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 307, 382, 465, 556, 655,
722, 619, 524, 437, 358, 287, 224, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 241, 308, 383, 466, 557, 656,
721, 618, 523, 436, 357, 286, 223, 168, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 183, 242, 309, 384, 467, 558, 657,
720, 617, 522, 435, 356, 285, 222, 167, 120, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 133, 184, 243, 310, 385, 468, 559, 658,
719, 616, 521, 434, 355, 284, 221, 166, 119, 80, 49, 50, 51, 52, 53, 54, 55, 56, 91, 134, 185, 244, 311, 386, 469, 560, 659,
718, 615, 520, 433, 354, 283, 220, 165, 118, 79, 48, 25, 26, 27, 28, 29, 30, 57, 92, 135, 186, 245, 312, 387, 470, 561, 660,
717, 614, 519, 432, 353, 282, 219, 164, 117, 78, 47, 24, 9, 10, 11, 12, 31, 58, 93, 136, 187, 246, 313, 388, 471, 562, 661,
716, 613, 518, 431, 352, 281, 218, 163, 116, 77, 46, 23, 8, 1, 2, 13, 32, 59, 94, 137, 188, 247, 314, 389, 472, 563, 662,
715, 612, 517, 430, 351, 280, 217, 162, 115, 76, 45, 22, 7, 0, 3, 14, 33, 60, 95, 138, 189, 248, 315, 390, 473, 564, 663,
714, 611, 516, 429, 350, 279, 216, 161, 114, 75, 44, 21, 6, 5, 4, 15, 34, 61, 96, 139, 190, 249, 316, 391, 474, 565, 664,
713, 610, 515, 428, 349, 278, 215, 160, 113, 74, 43, 20, 19, 18, 17, 16, 35, 62, 97, 140, 191, 250, 317, 392, 475, 566, 665,
712, 609, 514, 427, 348, 277, 214, 159, 112, 73, 42, 41, 40, 39, 38, 37, 36, 63, 98, 141, 192, 251, 318, 393, 476, 567, 666,
711, 608, 513, 426, 347, 276, 213, 158, 111, 72, 71, 70, 69, 68, 67, 66, 65, 64, 99, 142, 193, 252, 319, 394, 477, 568, 667,
710, 607, 512, 425, 346, 275, 212, 157, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 143, 194, 253, 320, 395, 478, 569, 668,
709, 606, 511, 424, 345, 274, 211, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 195, 254, 321, 396, 479, 570, 669,
708, 605, 510, 423, 344, 273, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 255, 322, 397, 480, 571, 670,
707, 604, 509, 422, 343, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 323, 398, 481, 572, 671,
706, 603, 508, 421, 342, 341, 340, 339, 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, 324, 399, 482, 573, 672,
705, 602, 507, 420, 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 483, 574, 673,
704, 601, 506, 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 575, 674,
703, 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, 578, 577, 576, 675,
702, 701, 700, 699, 698, 697, 696, 695, 694, 693, 692, 691, 690, 689, 688, 687, 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, 676,
};

1400
3rdparty/zint-2.10.0/backend/gs1.c vendored Normal file

File diff suppressed because it is too large Load Diff

48
3rdparty/zint-2.10.0/backend/gs1.h vendored Normal file
View File

@@ -0,0 +1,48 @@
/* gs1.h - Verifies GS1 data */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef __GS1_H
#define __GS1_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int src_len,
unsigned char reduced[]);
INTERNAL char gs1_check_digit(const unsigned char source[], const int src_len);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GS1_H */

843
3rdparty/zint-2.10.0/backend/gs1_lint.h vendored Normal file
View File

@@ -0,0 +1,843 @@
/*
* GS1 AI checker generated by "backend/tools/gen_gs1_lint.php" from
* https://raw.githubusercontent.com/bwipp/postscriptbarcode/master/contrib/development/gs1-format-spec.txt
*/
/*
libzint - the open source barcode library
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef GS1_LINT_H
#define GS1_LINT_H
/* N18,csum,key (Used by SSCC) */
static int n18_csum_key(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 18
&& csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& key(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 0)
&& key(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 0);
}
/* N14,csum,key (Used by GTIN, CONTENT) */
static int n14_csum_key(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 14
&& csum(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& key(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 0)
&& key(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..20 (Used by BATCH/LOT, SERIAL, CPV, PCN...) */
static int x1__20(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 20
&& cset82(data, data_len, 0, 1, 20, p_err_no, p_err_posn, err_msg);
}
/* N6,yymmd0 (Used by PROD DATE, DUE DATE, PACK DATE, BEST BEFORE or BEST BY...) */
static int n6_yymmd0(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 6
&& yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0);
}
/* N2 (Used by VARIANT) */
static int n2(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 2
&& numeric(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg);
}
/* X1..28 (Used by TPX) */
static int x1__28(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 28
&& cset82(data, data_len, 0, 1, 28, p_err_no, p_err_posn, err_msg);
}
/* X1..30 (Used by ADDITIONAL ID, CUST. PART NO., SECONDARY SERIAL, REF. TO SOURCE...) */
static int x1__30(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 30
&& cset82(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg);
}
/* N1..6 (Used by MTO VARIANT) */
static int n1__6(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 6
&& numeric(data, data_len, 0, 1, 6, p_err_no, p_err_posn, err_msg);
}
/* N13,csum,key X0..17 (Used by GDTI) */
static int n13_csum_key_x0__17(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 13 && data_len <= 30
&& csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0)
&& key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0)
&& cset82(data, data_len, 13, 0, 17, p_err_no, p_err_posn, err_msg);
}
/* N13,csum,key N0..12 (Used by GCN) */
static int n13_csum_key_n0__12(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 13 && data_len <= 25
&& csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0)
&& key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 13, 0, 12, p_err_no, p_err_posn, err_msg);
}
/* N1..8 (Used by VAR. COUNT, COUNT) */
static int n1__8(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 8
&& numeric(data, data_len, 0, 1, 8, p_err_no, p_err_posn, err_msg);
}
/* N6 (Used by NET WEIGHT (kg), LENGTH (m), WIDTH (m), HEIGHT (m)...) */
static int n6(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 6
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg);
}
/* N1..15 (Used by AMOUNT, PRICE) */
static int n1__15(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 15
&& numeric(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg);
}
/* N3,iso4217 N1..15 (Used by AMOUNT, PRICE) */
static int n3_iso4217_n1__15(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 4 && data_len <= 18
&& iso4217(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg)
&& iso4217(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 3, 1, 15, p_err_no, p_err_posn, err_msg);
}
/* N4 (Used by PRCNT OFF, POINTS) */
static int n4(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 4
&& numeric(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg);
}
/* X1..30,key (Used by GINC, GIAI - ASSEMBLY, GIAI) */
static int x1__30_key(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 30
&& key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset82(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg)
&& key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 0);
}
/* N17,csum,key (Used by GSIN) */
static int n17_csum_key(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 17
&& csum(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& key(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg, 0)
&& key(data, data_len, 0, 17, 17, p_err_no, p_err_posn, err_msg, 0);
}
/* N13,csum,key (Used by SHIP TO LOC, BILL TO, PURCHASE FROM, SHIP FOR LOC...) */
static int n13_csum_key(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 13
&& csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0)
&& key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0);
}
/* N3,iso3166 X1..9 (Used by SHIP TO POST) */
static int n3_iso3166_x1__9(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 4 && data_len <= 12
&& iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg)
&& iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0)
&& cset82(data, data_len, 3, 1, 9, p_err_no, p_err_posn, err_msg);
}
/* N3,iso3166 (Used by ORIGIN, COUNTRY - PROCESS, COUNTRY - FULL PROCESS) */
static int n3_iso3166(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 3
&& iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg)
&& iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0);
}
/* N3..15,iso3166list (Used by COUNTRY - INITIAL PROCESS, COUNTRY - DISASSEMBLY) */
static int n3__15_iso3166list(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 3 && data_len <= 15
&& iso3166list(data, data_len, 0, 3, 15, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 3, 15, p_err_no, p_err_posn, err_msg)
&& iso3166list(data, data_len, 0, 3, 15, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..3 (Used by ORIGIN SUBDIVISION, AQUATIC SPECIES) */
static int x1__3(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 3
&& cset82(data, data_len, 0, 1, 3, p_err_no, p_err_posn, err_msg);
}
/* X1..35,pcenc (Used by SHIP TO COMP, SHIP TO NAME, RTN TO COMP, RTN TO NAME...) */
static int x1__35_pcenc(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 35
&& pcenc(data, data_len, 0, 1, 35, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset82(data, data_len, 0, 1, 35, p_err_no, p_err_posn, err_msg)
&& pcenc(data, data_len, 0, 1, 35, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..70,pcenc (Used by SHIP TO ADD1, SHIP TO ADD2, SHIP TO SUB, SHIP TO LOC...) */
static int x1__70_pcenc(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 70
&& pcenc(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg)
&& pcenc(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 0);
}
/* X2,iso3166alpha2 (Used by SHIP TO COUNTRY, RTN TO COUNTRY) */
static int x2_iso3166alpha2(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 2
&& iso3166alpha2(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset82(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg)
&& iso3166alpha2(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg, 0);
}
/* N1,yesno (Used by DANGEROUS GOODS, AUTH LEAVE, SIG REQUIRED) */
static int n1_yesno(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 1
&& yesno(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg)
&& yesno(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 0);
}
/* N6,yymmd0 N4,hhmm (Used by NBEF DEL DT., NAFT DEL DT.) */
static int n6_yymmd0_n4_hhmm(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 10
&& yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg)
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0);
}
/* N6,yymmdd (Used by REL DATE, FIRST FREEZE DATE) */
static int n6_yymmdd(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 6
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0);
}
/* N13 (Used by NSN) */
static int n13(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 13
&& numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg);
}
/* N6,yymmdd N4,hhmm (Used by EXPIRY TIME) */
static int n6_yymmdd_n4_hhmm(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 10
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg)
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0);
}
/* N1..4 (Used by ACTIVE POTENCY) */
static int n1__4(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 4
&& numeric(data, data_len, 0, 1, 4, p_err_no, p_err_posn, err_msg);
}
/* X1..12 (Used by CATCH AREA) */
static int x1__12(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 12
&& cset82(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg);
}
/* N6,yymmdd N0..6,yymmdd (Used by HARVEST DATE) */
static int n6_yymmdd_n0__6_yymmdd(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 6 && data_len <= 12
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& yymmdd(data, data_len, 6, 0, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 6, 0, 6, p_err_no, p_err_posn, err_msg)
&& yymmdd(data, data_len, 6, 0, 6, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..10 (Used by FISHING GEAR TYPE) */
static int x1__10(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 10
&& cset82(data, data_len, 0, 1, 10, p_err_no, p_err_posn, err_msg);
}
/* X1..2 (Used by PROD METHOD) */
static int x1__2(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 2
&& cset82(data, data_len, 0, 1, 2, p_err_no, p_err_posn, err_msg);
}
/* N3,iso3166999 X1..27 (Used by PROCESSOR # s) */
static int n3_iso3166999_x1__27(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 4 && data_len <= 30
&& iso3166999(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg)
&& iso3166999(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0)
&& cset82(data, data_len, 3, 1, 27, p_err_no, p_err_posn, err_msg);
}
/* N1 X1 X1 X1,importeridx (Used by UIC+EXT) */
static int n1_x1_x1_x1_importeridx(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 4
&& importeridx(data, data_len, 3, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg)
&& cset82(data, data_len, 1, 1, 1, p_err_no, p_err_posn, err_msg)
&& cset82(data, data_len, 2, 1, 1, p_err_no, p_err_posn, err_msg)
&& cset82(data, data_len, 3, 1, 1, p_err_no, p_err_posn, err_msg)
&& importeridx(data, data_len, 3, 1, 1, p_err_no, p_err_posn, err_msg, 0);
}
/* X2 X1..28 (Used by CERT # s) */
static int x2_x1__28(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 3 && data_len <= 30
&& cset82(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg)
&& cset82(data, data_len, 2, 1, 28, p_err_no, p_err_posn, err_msg);
}
/* N4,nonzero N5,nonzero N3,nonzero N1,winding N1 (Used by DIMENSIONS) */
static int n4_nonzero_n5_nonzero_n3_nonzero_n1_winding_n1(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 14
&& nonzero(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& nonzero(data, data_len, 4, 5, 5, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& nonzero(data, data_len, 9, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& winding(data, data_len, 12, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg)
&& nonzero(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 4, 5, 5, p_err_no, p_err_posn, err_msg)
&& nonzero(data, data_len, 4, 5, 5, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 9, 3, 3, p_err_no, p_err_posn, err_msg)
&& nonzero(data, data_len, 9, 3, 3, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 12, 1, 1, p_err_no, p_err_posn, err_msg)
&& winding(data, data_len, 12, 1, 1, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 13, 1, 1, p_err_no, p_err_posn, err_msg);
}
/* N1,zero N13,csum,key X0..16 (Used by GRAI) */
static int n1_zero_n13_csum_key_x0__16(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 14 && data_len <= 30
&& zero(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& csum(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& key(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg)
&& zero(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg, 0)
&& key(data, data_len, 1, 13, 13, p_err_no, p_err_posn, err_msg, 0)
&& cset82(data, data_len, 14, 0, 16, p_err_no, p_err_posn, err_msg);
}
/* N14,csum N4,pieceoftotal (Used by ITIP, ITIP CONTENT) */
static int n14_csum_n4_pieceoftotal(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 18
&& csum(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& pieceoftotal(data, data_len, 14, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 14, 4, 4, p_err_no, p_err_posn, err_msg)
&& pieceoftotal(data, data_len, 14, 4, 4, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..34,iban (Used by IBAN) */
static int x1__34_iban(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 34
&& iban(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset82(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg)
&& iban(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg, 0);
}
/* N8,yymmddhh N0..4,mmoptss (Used by PROD TIME) */
static int n8_yymmddhh_n0__4_mmoptss(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 8 && data_len <= 12
&& yymmddhh(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& mmoptss(data, data_len, 8, 0, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg)
&& yymmddhh(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 8, 0, 4, p_err_no, p_err_posn, err_msg)
&& mmoptss(data, data_len, 8, 0, 4, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..50 (Used by OPTSEN) */
static int x1__50(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 50
&& cset82(data, data_len, 0, 1, 50, p_err_no, p_err_posn, err_msg);
}
/* C1..30,key (Used by CPID) */
static int c1__30_key(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 30
&& key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset39(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg)
&& key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 0);
}
/* N1..12,nozeroprefix (Used by CPID SERIAL) */
static int n1__12_nozeroprefix(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 12
&& nozeroprefix(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg)
&& nozeroprefix(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..25,csumalpha,key (Used by GMN) */
static int x1__25_csumalpha_key(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 25
&& csumalpha(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& key(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset82(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg)
&& csumalpha(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg, 0)
&& key(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg, 0);
}
/* N18,csum (Used by GSRN - PROVIDER, GSRN - RECIPIENT) */
static int n18_csum(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 18
&& csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg)
&& csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 0);
}
/* N1..10 (Used by SRIN) */
static int n1__10(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 10
&& numeric(data, data_len, 0, 1, 10, p_err_no, p_err_posn, err_msg);
}
/* X1..25 (Used by REF NO.) */
static int x1__25(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 25
&& cset82(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg);
}
/* X1..70,couponcode */
static int x1__70_couponcode(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 70
&& couponcode(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg)
&& couponcode(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..70,couponposoffer */
static int x1__70_couponposoffer(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 70
&& couponposoffer(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg)
&& couponposoffer(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 0);
}
/* X1..70 (Used by PRODUCT URL) */
static int x1__70(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 70
&& cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg);
}
/* X1..90 (Used by INTERNAL) */
static int x1__90(const unsigned char *data, const int data_len,
int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 1 && data_len <= 90
&& cset82(data, data_len, 0, 1, 90, p_err_no, p_err_posn, err_msg);
}
/* Entry point. Returns 1 on success, 0 on failure: `*p_err_no` set to 1 if unknown AI, 2 if bad data length */
static int gs1_lint(const int ai, const unsigned char *data, const int data_len, int *p_err_no, int *p_err_posn,
char err_msg[50]) {
/* Assume data length failure */
*p_err_no = 2;
if (ai < 100) {
if (ai == 0) {
return n18_csum_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 1 || ai == 2) {
return n14_csum_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 10 || ai == 21 || ai == 22) {
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
}
if ((ai >= 11 && ai <= 13) || (ai >= 15 && ai <= 17)) {
return n6_yymmd0(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 20) {
return n2(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 30 || ai == 37) {
return n1__8(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 90) {
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai >= 91) {
return x1__90(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 300) {
if (ai == 235) {
return x1__28(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 240 || ai == 241 || ai == 250 || ai == 251) {
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 242) {
return n1__6(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 243 || ai == 254) {
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 253) {
return n13_csum_key_x0__17(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 255) {
return n13_csum_key_n0__12(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 500) {
if (ai == 400 || ai == 403) {
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 401) {
return x1__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 402) {
return n17_csum_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai >= 410 && ai <= 417) {
return n13_csum_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 420) {
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 421) {
return n3_iso3166_x1__9(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 422 || ai == 424 || ai == 426) {
return n3_iso3166(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 423 || ai == 425) {
return n3__15_iso3166list(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 427) {
return x1__3(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 800) {
if (ai >= 710 && ai <= 714) {
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 3200) {
if ((ai >= 3100 && ai <= 3105) || (ai >= 3110 && ai <= 3115) || (ai >= 3120 && ai <= 3125)
|| (ai >= 3130 && ai <= 3135) || (ai >= 3140 && ai <= 3145) || (ai >= 3150 && ai <= 3155)
|| (ai >= 3160 && ai <= 3165)) {
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 3300) {
if (ai <= 3205 || (ai >= 3210 && ai <= 3215) || (ai >= 3220 && ai <= 3225) || (ai >= 3230 && ai <= 3235)
|| (ai >= 3240 && ai <= 3245) || (ai >= 3250 && ai <= 3255) || (ai >= 3260 && ai <= 3265)
|| (ai >= 3270 && ai <= 3275) || (ai >= 3280 && ai <= 3285) || (ai >= 3290 && ai <= 3295)) {
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 3400) {
if (ai <= 3305 || (ai >= 3310 && ai <= 3315) || (ai >= 3320 && ai <= 3325) || (ai >= 3330 && ai <= 3335)
|| (ai >= 3340 && ai <= 3345) || (ai >= 3350 && ai <= 3355) || (ai >= 3360 && ai <= 3365)
|| (ai >= 3370 && ai <= 3375)) {
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 3500) {
if (ai <= 3405 || (ai >= 3410 && ai <= 3415) || (ai >= 3420 && ai <= 3425) || (ai >= 3430 && ai <= 3435)
|| (ai >= 3440 && ai <= 3445) || (ai >= 3450 && ai <= 3455) || (ai >= 3460 && ai <= 3465)
|| (ai >= 3470 && ai <= 3475) || (ai >= 3480 && ai <= 3485) || (ai >= 3490 && ai <= 3495)) {
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 3600) {
if (ai <= 3505 || (ai >= 3510 && ai <= 3515) || (ai >= 3520 && ai <= 3525) || (ai >= 3530 && ai <= 3535)
|| (ai >= 3540 && ai <= 3545) || (ai >= 3550 && ai <= 3555) || (ai >= 3560 && ai <= 3565)
|| (ai >= 3570 && ai <= 3575)) {
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 3700) {
if (ai <= 3605 || (ai >= 3610 && ai <= 3615) || (ai >= 3620 && ai <= 3625) || (ai >= 3630 && ai <= 3635)
|| (ai >= 3640 && ai <= 3645) || (ai >= 3650 && ai <= 3655) || (ai >= 3660 && ai <= 3665)
|| (ai >= 3670 && ai <= 3675) || (ai >= 3680 && ai <= 3685) || (ai >= 3690 && ai <= 3695)) {
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 4000) {
if ((ai >= 3900 && ai <= 3909) || (ai >= 3920 && ai <= 3929)) {
return n1__15(data, data_len, p_err_no, p_err_posn, err_msg);
}
if ((ai >= 3910 && ai <= 3919) || (ai >= 3930 && ai <= 3939)) {
return n3_iso4217_n1__15(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai >= 3940 && ai <= 3943) {
return n4(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai >= 3950 && ai <= 3955) {
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 4400) {
if (ai == 4300 || ai == 4301 || ai == 4310 || ai == 4311 || ai == 4320) {
return x1__35_pcenc(data, data_len, p_err_no, p_err_posn, err_msg);
}
if ((ai >= 4302 && ai <= 4306) || (ai >= 4312 && ai <= 4316)) {
return x1__70_pcenc(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 4307 || ai == 4317) {
return x2_iso3166alpha2(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 4308 || ai == 4319) {
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 4318) {
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai >= 4321 && ai <= 4323) {
return n1_yesno(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 4324 || ai == 4325) {
return n6_yymmd0_n4_hhmm(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 4326) {
return n6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 7100) {
if (ai == 7001) {
return n13(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7002) {
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7003) {
return n6_yymmdd_n4_hhmm(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7004) {
return n1__4(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7005) {
return x1__12(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7006) {
return n6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7007) {
return n6_yymmdd_n0__6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7008) {
return x1__3(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7009) {
return x1__10(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7010) {
return x1__2(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai >= 7020 && ai <= 7022) {
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7023) {
return x1__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai >= 7030 && ai <= 7039) {
return n3_iso3166999_x1__27(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7040) {
return n1_x1_x1_x1_importeridx(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 7300) {
if (ai >= 7230 && ai <= 7239) {
return x2_x1__28(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7240) {
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 8100) {
if (ai == 8001) {
return n4_nonzero_n5_nonzero_n3_nonzero_n1_winding_n1(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8002 || ai == 8012) {
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8003) {
return n1_zero_n13_csum_key_x0__16(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8004) {
return x1__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8005) {
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8006 || ai == 8026) {
return n14_csum_n4_pieceoftotal(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8007) {
return x1__34_iban(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8008) {
return n8_yymmddhh_n0__4_mmoptss(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8009) {
return x1__50(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8010) {
return c1__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8011) {
return n1__12_nozeroprefix(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8013) {
return x1__25_csumalpha_key(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8017 || ai == 8018) {
return n18_csum(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8019) {
return n1__10(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8020) {
return x1__25(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 8200) {
if (ai == 8110) {
return x1__70_couponcode(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8111) {
return n4(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8112) {
return x1__70_couponposoffer(data, data_len, p_err_no, p_err_posn, err_msg);
}
} else if (ai < 8300) {
if (ai == 8200) {
return x1__70(data, data_len, p_err_no, p_err_posn, err_msg);
}
}
/* Unknown AI */
*p_err_no = 1;
return 0;
}
#endif /* GS1_LINT_H */

1671
3rdparty/zint-2.10.0/backend/hanxin.c vendored Normal file

File diff suppressed because it is too large Load Diff

460
3rdparty/zint-2.10.0/backend/hanxin.h vendored Normal file
View File

@@ -0,0 +1,460 @@
/* hanxin.h - definitions for Han Xin code
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2016 Zoe Stuart
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* Data from table B1: Data capacity of Han Xin Code */
static const unsigned short int hx_total_codewords[] = {
25, 37, 50, 54, 69, 84, 100, 117, 136, 155, 161, 181, 203, 225, 249,
273, 299, 325, 353, 381, 411, 422, 453, 485, 518, 552, 587, 623, 660,
698, 737, 754, 794, 836, 878, 922, 966, 1011, 1058, 1105, 1126, 1175,
1224, 1275, 1327, 1380, 1434, 1489, 1513, 1569, 1628, 1686, 1745, 1805,
1867, 1929, 1992, 2021, 2086, 2151, 2218, 2286, 2355, 2425, 2496, 2528,
2600, 2673, 2749, 2824, 2900, 2977, 3056, 3135, 3171, 3252, 3334, 3416,
3500, 3585, 3671, 3758, 3798, 3886
};
static const unsigned short int hx_data_codewords_L1[] = {
21, 31, 42, 46, 57, 70, 84, 99, 114, 131, 135, 153, 171, 189, 209, 229,
251, 273, 297, 321, 345, 354, 381, 407, 436, 464, 493, 523, 554, 586, 619,
634, 666, 702, 738, 774, 812, 849, 888, 929, 946, 987, 1028, 1071, 1115,
1160, 1204, 1251, 1271, 1317, 1368, 1416, 1465, 1517, 1569, 1621, 1674,
1697, 1752, 1807, 1864, 1920, 1979, 2037, 2096, 2124, 2184, 2245, 2309,
2372, 2436, 2501, 2568, 2633, 2663, 2732, 2800, 2870, 2940, 3011,
3083, 3156, 3190, 3264
};
static const unsigned short int hx_data_codewords_L2[] = {
17, 25, 34, 38, 49, 58, 70, 81, 96, 109, 113, 127, 143, 157, 175, 191, 209,
227, 247, 267, 287, 296, 317, 339, 362, 386, 411, 437, 462, 488, 515, 528,
556, 586, 614, 646, 676, 707, 740, 773, 788, 823, 856, 893, 929, 966, 1004,
1043, 1059, 1099, 1140, 1180, 1221, 1263, 1307, 1351, 1394, 1415, 1460,
1505, 1552, 1600, 1649, 1697, 1748, 1770, 1820, 1871, 1925, 1976, 2030,
2083, 2140, 2195, 2219, 2276, 2334, 2392, 2450, 2509, 2569, 2630, 2658,
2720
};
static const unsigned short int hx_data_codewords_L3[] = {
13, 19, 26, 30, 37, 46, 54, 63, 74, 83, 87, 97, 109, 121, 135, 147, 161,
175, 191, 205, 221, 228, 245, 261, 280, 298, 317, 337, 358, 376, 397, 408,
428, 452, 474, 498, 522, 545, 572, 597, 608, 635, 660, 689, 717, 746, 774,
805, 817, 847, 880, 910, 943, 975, 1009, 1041, 1076, 1091, 1126, 1161, 1198,
1234, 1271, 1309, 1348, 1366, 1404, 1443, 1485, 1524, 1566, 1607, 1650, 1693,
1713, 1756, 1800, 1844, 1890, 1935, 1983, 2030, 2050, 2098
};
static const unsigned short int hx_data_codewords_L4[] = {
9, 15, 20, 22, 27, 34, 40, 47, 54, 61, 65, 73, 81, 89, 99, 109, 119, 129,
141, 153, 165, 168, 181, 195, 208, 220, 235, 251, 264, 280, 295, 302, 318,
334, 352, 368, 386, 405, 424, 441, 450, 469, 490, 509, 531, 552, 574, 595, 605,
627, 652, 674, 697, 721, 747, 771, 796, 809, 834, 861, 892, 914, 941, 969, 998,
1012, 1040, 1069, 1099, 1130, 1160, 1191, 1222, 1253, 1269, 1300, 1334,
1366, 1400, 1433, 1469, 1504, 1520, 1554
};
/* Value 'k' from Annex A */
static const char hx_module_k[] = {
0, 0, 0, 14, 16, 16, 17, 18, 19, 20,
14, 15, 16, 16, 17, 17, 18, 19, 20, 20,
21, 16, 17, 17, 18, 18, 19, 19, 20, 20,
21, 17, 17, 18, 18, 19, 19, 19, 20, 20,
17, 17, 18, 18, 18, 19, 19, 19, 17, 17,
18, 18, 18, 18, 19, 19, 19, 17, 17, 18,
18, 18, 18, 19, 19, 17, 17, 17, 18, 18,
18, 18, 19, 19, 17, 17, 17, 18, 18, 18,
18, 18, 17, 17
};
/* Value 'r' from Annex A */
static const char hx_module_r[] = {
0, 0, 0, 15, 15, 17, 18, 19, 20, 21,
15, 15, 15, 17, 17, 19, 19, 19, 19, 21,
21, 17, 16, 18, 17, 19, 18, 20, 19, 21,
20, 17, 19, 17, 19, 17, 19, 21, 19, 21,
18, 20, 17, 19, 21, 18, 20, 22, 17, 19,
15, 17, 19, 21, 17, 19, 21, 18, 20, 15,
17, 19, 21, 16, 18, 17, 19, 21, 15, 17,
19, 21, 15, 17, 18, 20, 22, 15, 17, 19,
21, 23, 17, 19
};
/* Value of 'm' from Annex A */
static const char hx_module_m[] = {
0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
6, 6, 6, 6, 6, 6, 6, 7, 7, 7,
7, 7, 7, 7, 7, 8, 8, 8, 8, 8,
8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
9, 9, 10, 10
};
/* Error correction block sizes from Table D1 */
static const unsigned short int hx_table_d1[] = {
/* #blocks, k, 2t, #blocks, k, 2t, #blocks, k, 2t */
1, 21, 4, 0, 0, 0, 0, 0, 0, // version 1
1, 17, 8, 0, 0, 0, 0, 0, 0,
1, 13, 12, 0, 0, 0, 0, 0, 0,
1, 9, 16, 0, 0, 0, 0, 0, 0,
1, 31, 6, 0, 0, 0, 0, 0, 0, // version 2
1, 25, 12, 0, 0, 0, 0, 0, 0,
1, 19, 18, 0, 0, 0, 0, 0, 0,
1, 15, 22, 0, 0, 0, 0, 0, 0,
1, 42, 8, 0, 0, 0, 0, 0, 0, // version 3
1, 34, 16, 0, 0, 0, 0, 0, 0,
1, 26, 24, 0, 0, 0, 0, 0, 0,
1, 20, 30, 0, 0, 0, 0, 0, 0,
1, 46, 8, 0, 0, 0, 0, 0, 0, // version 4
1, 38, 16, 0, 0, 0, 0, 0, 0,
1, 30, 24, 0, 0, 0, 0, 0, 0,
1, 22, 32, 0, 0, 0, 0, 0, 0,
1, 57, 12, 0, 0, 0, 0, 0, 0, // version 5
1, 49, 20, 0, 0, 0, 0, 0, 0,
1, 37, 32, 0, 0, 0, 0, 0, 0,
1, 14, 20, 1, 13, 22, 0, 0, 0,
1, 70, 14, 0, 0, 0, 0, 0, 0, // version 6
1, 58, 26, 0, 0, 0, 0, 0, 0,
1, 24, 20, 1, 22, 18, 0, 0, 0,
1, 16, 24, 1, 18, 26, 0, 0, 0,
1, 84, 16, 0, 0, 0, 0, 0, 0, // version 7
1, 70, 30, 0, 0, 0, 0, 0, 0,
1, 26, 22, 1, 28, 24, 0, 0, 0,
2, 14, 20, 1, 12, 20, 0, 0, 0,
1, 99, 18, 0, 0, 0, 0, 0, 0, // version 8
1, 40, 18, 1, 41, 18, 0, 0, 0,
1, 31, 26, 1, 32, 28, 0, 0, 0,
2, 16, 24, 1, 15, 22, 0, 0, 0,
1, 114, 22, 0, 0, 0, 0, 0, 0, // version 9
2, 48, 20, 0, 0, 0, 0, 0, 0,
2, 24, 20, 1, 26, 22, 0, 0, 0,
2, 18, 28, 1, 18, 26, 0, 0, 0,
1, 131, 24, 0, 0, 0, 0, 0, 0, // version 10
1, 52, 22, 1, 57, 24, 0, 0, 0,
2, 27, 24, 1, 29, 24, 0, 0, 0,
2, 21, 32, 1, 19, 30, 0, 0, 0,
1, 135, 26, 0, 0, 0, 0, 0, 0, // version 11
1, 56, 24, 1, 57, 24, 0, 0, 0,
2, 28, 24, 1, 31, 26, 0, 0, 0,
2, 22, 32, 1, 21, 32, 0, 0, 0,
1, 153, 28, 0, 0, 0, 0, 0, 0, // version 12
1, 62, 26, 1, 65, 28, 0, 0, 0,
2, 32, 28, 1, 33, 28, 0, 0, 0,
3, 17, 26, 1, 22, 30, 0, 0, 0,
1, 86, 16, 1, 85, 16, 0, 0, 0, // version 13
1, 71, 30, 1, 72, 30, 0, 0, 0,
2, 37, 32, 1, 35, 30, 0, 0, 0,
3, 20, 30, 1, 21, 32, 0, 0, 0,
1, 94, 18, 1, 95, 18, 0, 0, 0, // version 14
2, 51, 22, 1, 55, 24, 0, 0, 0,
3, 30, 26, 1, 31, 26, 0, 0, 0,
4, 18, 28, 1, 17, 24, 0, 0, 0,
1, 104, 20, 1, 105, 20, 0, 0, 0, // version 15
2, 57, 24, 1, 61, 26, 0, 0, 0,
3, 33, 28, 1, 36, 30, 0, 0, 0,
4, 20, 30, 1, 19, 30, 0, 0, 0,
1, 115, 22, 1, 114, 22, 0, 0, 0, // version 16
2, 65, 28, 1, 61, 26, 0, 0, 0,
3, 38, 32, 1, 33, 30, 0, 0, 0,
5, 19, 28, 1, 14, 24, 0, 0, 0,
1, 126, 24, 1, 125, 24, 0, 0, 0, // version 17
2, 70, 30, 1, 69, 30, 0, 0, 0,
4, 33, 28, 1, 29, 26, 0, 0, 0,
5, 20, 30, 1, 19, 30, 0, 0, 0,
1, 136, 26, 1, 137, 26, 0, 0, 0, //version 18
3, 56, 24, 1, 59, 26, 0, 0, 0,
5, 35, 30, 0, 0, 0, 0, 0, 0,
6, 18, 28, 1, 21, 28, 0, 0, 0,
1, 148, 28, 1, 149, 28, 0, 0, 0, // version 19
3, 61, 26, 1, 64, 28, 0, 0, 0,
7, 24, 20, 1, 23, 22, 0, 0, 0,
6, 20, 30, 1, 21, 32, 0, 0, 0,
3, 107, 20, 0, 0, 0, 0, 0, 0, // version 20
3, 65, 28, 1, 72, 30, 0, 0, 0,
7, 26, 22, 1, 23, 22, 0, 0, 0,
7, 19, 28, 1, 20, 32, 0, 0, 0,
3, 115, 22, 0, 0, 0, 0, 0, 0, // version 21
4, 56, 24, 1, 63, 28, 0, 0, 0,
7, 28, 24, 1, 25, 22, 0, 0, 0,
8, 18, 28, 1, 21, 22, 0, 0, 0,
2, 116, 22, 1, 122, 24, 0, 0, 0, // version 22
4, 56, 24, 1, 72, 30, 0, 0, 0,
7, 28, 24, 1, 32, 26, 0, 0, 0,
8, 18, 28, 1, 24, 30, 0, 0, 0,
3, 127, 24, 0, 0, 0, 0, 0, 0, // version 23
5, 51, 22, 1, 62, 26, 0, 0, 0,
7, 30, 26, 1, 35, 26, 0, 0, 0,
8, 20, 30, 1, 21, 32, 0, 0, 0,
2, 135, 26, 1, 137, 26, 0, 0, 0, // version 24
5, 56, 24, 1, 59, 26, 0, 0, 0,
7, 33, 28, 1, 30, 28, 0, 0, 0,
11, 16, 24, 1, 19, 26, 0, 0, 0,
3, 105, 20, 1, 121, 22, 0, 0, 0, // version 25
5, 61, 26, 1, 57, 26, 0, 0, 0,
9, 28, 24, 1, 28, 22, 0, 0, 0,
10, 19, 28, 1, 18, 30, 0, 0, 0,
2, 157, 30, 1, 150, 28, 0, 0, 0, // version 26
5, 65, 28, 1, 61, 26, 0, 0, 0,
8, 33, 28, 1, 34, 30, 0, 0, 0,
10, 19, 28, 2, 15, 26, 0, 0, 0,
3, 126, 24, 1, 115, 22, 0, 0, 0, // version 27
7, 51, 22, 1, 54, 22, 0, 0, 0,
8, 35, 30, 1, 37, 30, 0, 0, 0,
15, 15, 22, 1, 10, 22, 0, 0, 0,
4, 105, 20, 1, 103, 20, 0, 0, 0, // version 28
7, 56, 24, 1, 45, 18, 0, 0, 0,
10, 31, 26, 1, 27, 26, 0, 0, 0,
10, 17, 26, 3, 20, 28, 1, 21, 28,
3, 139, 26, 1, 137, 28, 0, 0, 0, // version 29
6, 66, 28, 1, 66, 30, 0, 0, 0,
9, 36, 30, 1, 34, 32, 0, 0, 0,
13, 19, 28, 1, 17, 32, 0, 0, 0,
6, 84, 16, 1, 82, 16, 0, 0, 0, // version 30
6, 70, 30, 1, 68, 30, 0, 0, 0,
7, 35, 30, 3, 33, 28, 1, 32, 28,
13, 20, 30, 1, 20, 28, 0, 0, 0,
5, 105, 20, 1, 94, 18, 0, 0, 0, // version 31
6, 74, 32, 1, 71, 30, 0, 0, 0,
11, 33, 28, 1, 34, 32, 0, 0, 0,
13, 19, 28, 3, 16, 26, 0, 0, 0,
4, 127, 24, 1, 126, 24, 0, 0, 0, // version 32
7, 66, 28, 1, 66, 30, 0, 0, 0,
12, 30, 24, 1, 24, 28, 1, 24, 30,
15, 19, 28, 1, 17, 32, 0, 0, 0,
7, 84, 16, 1, 78, 16, 0, 0, 0, // version 33
7, 70, 30, 1, 66, 28, 0, 0, 0,
12, 33, 28, 1, 32, 30, 0, 0, 0,
14, 21, 32, 1, 24, 28, 0, 0, 0,
5, 117, 22, 1, 117, 24, 0, 0, 0, // version 34
8, 66, 28, 1, 58, 26, 0, 0, 0,
11, 38, 32, 1, 34, 32, 0, 0, 0,
15, 20, 30, 2, 17, 26, 0, 0, 0,
4, 148, 28, 1, 146, 28, 0, 0, 0, // version 35
8, 68, 30, 1, 70, 24, 0, 0, 0,
10, 36, 32, 3, 38, 28, 0, 0, 0,
16, 19, 28, 3, 16, 26, 0, 0, 0,
4, 126, 24, 2, 135, 26, 0, 0, 0, // version 36
8, 70, 28, 2, 43, 26, 0, 0, 0,
13, 32, 28, 2, 41, 30, 0, 0, 0,
17, 19, 28, 3, 15, 26, 0, 0, 0,
5, 136, 26, 1, 132, 24, 0, 0, 0, // version 37
5, 67, 30, 4, 68, 28, 1, 69, 28,
14, 35, 30, 1, 32, 24, 0, 0, 0,
18, 18, 26, 3, 16, 28, 1, 14, 28,
3, 142, 26, 3, 141, 28, 0, 0, 0, // version 38
8, 70, 30, 1, 73, 32, 1, 74, 32,
12, 34, 30, 3, 34, 26, 1, 35, 28,
18, 21, 32, 1, 27, 30, 0, 0, 0,
5, 116, 22, 2, 103, 20, 1, 102, 20, // version 39
9, 74, 32, 1, 74, 30, 0, 0, 0,
14, 34, 28, 2, 32, 32, 1, 32, 30,
19, 21, 32, 1, 25, 26, 0, 0, 0,
7, 116, 22, 1, 117, 22, 0, 0, 0, // version 40
11, 65, 28, 1, 58, 24, 0, 0, 0,
15, 38, 32, 1, 27, 28, 0, 0, 0,
20, 20, 30, 1, 20, 32, 1, 21, 32,
6, 136, 26, 1, 130, 24, 0, 0, 0, // version 41
11, 66, 28, 1, 62, 30, 0, 0, 0,
14, 34, 28, 3, 34, 32, 1, 30, 30,
18, 20, 30, 3, 20, 28, 2, 15, 26,
5, 105, 20, 2, 115, 22, 2, 116, 22, // version 42
10, 75, 32, 1, 73, 32, 0, 0, 0,
16, 38, 32, 1, 27, 28, 0, 0, 0,
22, 19, 28, 2, 16, 30, 1, 19, 30,
6, 147, 28, 1, 146, 28, 0, 0, 0, // version 43
11, 66, 28, 2, 65, 30, 0, 0, 0,
18, 33, 28, 2, 33, 30, 0, 0, 0,
22, 21, 32, 1, 28, 30, 0, 0, 0,
6, 116, 22, 3, 125, 24, 0, 0, 0, // version 44
11, 75, 32, 1, 68, 30, 0, 0, 0,
13, 35, 28, 6, 34, 32, 1, 30, 30,
23, 21, 32, 1, 26, 30, 0, 0, 0,
7, 105, 20, 4, 95, 18, 0, 0, 0, // version 45
12, 67, 28, 1, 63, 30, 1, 62, 32,
21, 31, 26, 2, 33, 32, 0, 0, 0,
23, 21, 32, 2, 24, 30, 0, 0, 0,
10, 116, 22, 0, 0, 0, 0, 0, 0, // version 46
12, 74, 32, 1, 78, 30, 0, 0, 0,
18, 37, 32, 1, 39, 30, 1, 41, 28,
25, 21, 32, 1, 27, 28, 0, 0, 0,
5, 126, 24, 4, 115, 22, 1, 114, 22, // version 47
12, 67, 28, 2, 66, 32, 1, 68, 30,
21, 35, 30, 1, 39, 30, 0, 0, 0,
26, 21, 32, 1, 28, 28, 0, 0, 0,
9, 126, 24, 1, 117, 22, 0, 0, 0, // version 48
13, 75, 32, 1, 68, 30, 0, 0, 0,
20, 35, 30, 3, 35, 28, 0, 0, 0,
27, 21, 32, 1, 28, 30, 0, 0, 0,
9, 126, 24, 1, 137, 26, 0, 0, 0, // version 49
13, 71, 30, 2, 68, 32, 0, 0, 0,
20, 37, 32, 1, 39, 28, 1, 38, 28,
24, 20, 32, 5, 25, 28, 0, 0, 0,
8, 147, 28, 1, 141, 28, 0, 0, 0, // version 50
10, 73, 32, 4, 74, 30, 1, 73, 30,
16, 36, 32, 6, 39, 30, 1, 37, 30,
27, 21, 32, 3, 20, 26, 0, 0, 0,
9, 137, 26, 1, 135, 26, 0, 0, 0, // version 51
12, 70, 30, 4, 75, 32, 0, 0, 0,
24, 35, 30, 1, 40, 28, 0, 0, 0,
23, 20, 32, 8, 24, 30, 0, 0, 0,
14, 95, 18, 1, 86, 18, 0, 0, 0, // version 52
13, 73, 32, 3, 77, 30, 0, 0, 0,
24, 35, 30, 2, 35, 28, 0, 0, 0,
26, 21, 32, 5, 21, 30, 1, 23, 30,
9, 147, 28, 1, 142, 28, 0, 0, 0, // version 53
10, 73, 30, 6, 70, 32, 1, 71, 32,
25, 35, 30, 2, 34, 26, 0, 0, 0,
29, 21, 32, 4, 22, 30, 0, 0, 0,
11, 126, 24, 1, 131, 24, 0, 0, 0, // version 54
16, 74, 32, 1, 79, 30, 0, 0, 0,
25, 38, 32, 1, 25, 30, 0, 0, 0,
33, 21, 32, 1, 28, 28, 0, 0, 0,
14, 105, 20, 1, 99, 18, 0, 0, 0, // version 55
19, 65, 28, 1, 72, 28, 0, 0, 0,
24, 37, 32, 2, 40, 30, 1, 41, 30,
31, 21, 32, 4, 24, 32, 0, 0, 0,
10, 147, 28, 1, 151, 28, 0, 0, 0, // version 56
15, 71, 30, 3, 71, 32, 1, 73, 32,
24, 37, 32, 3, 38, 30, 1, 39, 30,
36, 19, 30, 3, 29, 26, 0, 0, 0,
15, 105, 20, 1, 99, 18, 0, 0, 0, // version 57
19, 70, 30, 1, 64, 28, 0, 0, 0,
27, 38, 32, 2, 25, 26, 0, 0, 0,
38, 20, 30, 2, 18, 28, 0, 0, 0,
14, 105, 20, 1, 113, 22, 1, 114, 22, // version 58
17, 67, 30, 3, 92, 32, 0, 0, 0,
30, 35, 30, 1, 41, 30, 0, 0, 0,
36, 21, 32, 1, 26, 30, 1, 27, 30,
11, 146, 28, 1, 146, 26, 0, 0, 0, // version 59
20, 70, 30, 1, 60, 26, 0, 0, 0,
29, 38, 32, 1, 24, 32, 0, 0, 0,
40, 20, 30, 2, 17, 26, 0, 0, 0,
3, 137, 26, 1, 136, 26, 10, 126, 24, // version 60
22, 65, 28, 1, 75, 30, 0, 0, 0,
30, 37, 32, 1, 51, 30, 0, 0, 0,
42, 20, 30, 1, 21, 30, 0, 0, 0,
12, 126, 24, 2, 118, 22, 1, 116, 22, // version 61
19, 74, 32, 1, 74, 30, 1, 72, 28,
30, 38, 32, 2, 29, 30, 0, 0, 0,
39, 20, 32, 2, 37, 26, 1, 38, 26,
12, 126, 24, 3, 136, 26, 0, 0, 0, // version 62
21, 70, 30, 2, 65, 28, 0, 0, 0,
34, 35, 30, 1, 44, 32, 0, 0, 0,
42, 20, 30, 2, 19, 28, 2, 18, 28,
12, 126, 24, 3, 117, 22, 1, 116, 22, // version 63
25, 61, 26, 2, 62, 28, 0, 0, 0,
34, 35, 30, 1, 40, 32, 1, 41, 32,
45, 20, 30, 1, 20, 32, 1, 21, 32,
15, 105, 20, 2, 115, 22, 2, 116, 22, // version 64
25, 65, 28, 1, 72, 28, 0, 0, 0,
18, 35, 30, 17, 37, 32, 1, 50, 32,
42, 20, 30, 6, 19, 28, 1, 15, 28,
19, 105, 20, 1, 101, 20, 0, 0, 0, // version 65
33, 51, 22, 1, 65, 22, 0, 0, 0,
40, 33, 28, 1, 28, 28, 0, 0, 0,
49, 20, 30, 1, 18, 28, 0, 0, 0,
18, 105, 20, 2, 117, 22, 0, 0, 0, // version 66
26, 65, 28, 1, 80, 30, 0, 0, 0,
35, 35, 30, 3, 35, 28, 1, 36, 28,
52, 18, 28, 2, 38, 30, 0, 0, 0,
26, 84, 16, 0, 0, 0, 0, 0, 0, // version 67
26, 70, 30, 0, 0, 0, 0, 0, 0,
45, 31, 26, 1, 9, 26, 0, 0, 0,
52, 20, 30, 0, 0, 0, 0, 0, 0,
16, 126, 24, 1, 114, 22, 1, 115, 22, // version 68
23, 70, 30, 3, 65, 28, 1, 66, 28,
40, 35, 30, 1, 43, 30, 0, 0, 0,
46, 20, 30, 7, 19, 28, 1, 16, 28,
19, 116, 22, 1, 105, 22, 0, 0, 0, // version 69
20, 70, 30, 7, 66, 28, 1, 63, 28,
40, 35, 30, 1, 42, 32, 1, 43, 32,
54, 20, 30, 1, 19, 30, 0, 0, 0,
17, 126, 24, 2, 115, 22, 0, 0, 0, // version 70
24, 70, 30, 4, 74, 32, 0, 0, 0,
48, 31, 26, 2, 18, 26, 0, 0, 0,
54, 19, 28, 6, 15, 26, 1, 14, 26,
29, 84, 16, 0, 0, 0, 0, 0, 0, // version 71
29, 70, 30, 0, 0, 0, 0, 0, 0,
6, 34, 30, 3, 36, 30, 38, 33, 28,
58, 20, 30, 0, 0, 0, 0, 0, 0,
16, 147, 28, 1, 149, 28, 0, 0, 0, // version 72
31, 66, 28, 1, 37, 26, 0, 0, 0,
48, 33, 28, 1, 23, 26, 0, 0, 0,
53, 20, 30, 6, 19, 28, 1, 17, 28,
20, 115, 22, 2, 134, 24, 0, 0, 0, // verdion 73
29, 66, 28, 2, 56, 26, 2, 57, 26,
45, 36, 30, 2, 15, 28, 0, 0, 0,
59, 20, 30, 2, 21, 32, 0, 0, 0,
17, 147, 28, 1, 134, 26, 0, 0, 0, // version 74
26, 70, 30, 5, 75, 32, 0, 0, 0,
47, 35, 30, 1, 48, 32, 0, 0, 0,
64, 18, 28, 2, 33, 30, 1, 35, 30,
22, 115, 22, 1, 133, 24, 0, 0, 0, // version 75
33, 65, 28, 1, 74, 28, 0, 0, 0,
43, 36, 30, 5, 27, 28, 1, 30, 28,
57, 20, 30, 5, 21, 32, 1, 24, 32,
18, 136, 26, 2, 142, 26, 0, 0, 0, // version 76
33, 66, 28, 2, 49, 26, 0, 0, 0,
48, 35, 30, 2, 38, 28, 0, 0, 0,
64, 20, 30, 1, 20, 32, 0, 0, 0,
19, 126, 24, 2, 135, 26, 1, 136, 26, // version 77
32, 66, 28, 2, 55, 26, 2, 56, 26,
49, 36, 30, 2, 18, 32, 0, 0, 0,
65, 18, 28, 5, 27, 30, 1, 29, 30,
20, 137, 26, 1, 130, 26, 0, 0, 0, // version 78
30, 75, 32, 2, 71, 32, 0, 0, 0,
46, 35, 30, 6, 39, 32, 0, 0, 0,
3, 12, 30, 70, 19, 28, 0, 0, 0,
20, 147, 28, 0, 0, 0, 0, 0, 0, // version 79
35, 70, 30, 0, 0, 0, 0, 0, 0,
49, 35, 30, 5, 35, 28, 0, 0, 0,
70, 20, 30, 0, 0, 0, 0, 0, 0,
21, 136, 26, 1, 155, 28, 0, 0, 0, // version 80
34, 70, 30, 1, 64, 28, 1, 65, 28,
54, 35, 30, 1, 45, 30, 0, 0, 0,
68, 20, 30, 3, 18, 28, 1, 19, 28,
19, 126, 24, 5, 115, 22, 1, 114, 22, // version 81
33, 70, 30, 3, 65, 28, 1, 64, 28,
52, 35, 30, 3, 41, 32, 1, 40, 32,
67, 20, 30, 5, 21, 32, 1, 24, 32,
2, 150, 28, 21, 136, 26, 0, 0, 0, // version 82
32, 70, 30, 6, 65, 28, 0, 0, 0,
52, 38, 32, 2, 27, 32, 0, 0, 0,
73, 20, 30, 2, 22, 32, 0, 0, 0,
21, 126, 24, 4, 136, 26, 0, 0, 0, // version 83
30, 74, 32, 6, 73, 30, 0, 0, 0,
54, 35, 30, 4, 40, 32, 0, 0, 0,
75, 20, 30, 1, 20, 28, 0, 0, 0,
30, 105, 20, 1, 114, 22, 0, 0, 0, // version 84
3, 45, 22, 55, 47, 20, 0, 0, 0,
2, 26, 26, 62, 33, 28, 0, 0, 0,
79, 18, 28, 4, 33, 30, 0, 0, 0
};

456
3rdparty/zint-2.10.0/backend/imail.c vendored Normal file
View File

@@ -0,0 +1,456 @@
/* imail.c - Handles Intelligent Mail (aka OneCode) for USPS */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* The function "USPS_MSB_Math_CRC11GenerateFrameCheckSequence"
is Copyright (C) 2006 United States Postal Service */
#include <stdio.h>
#include "common.h"
#include "large.h"
#define SODIUM "0123456789-"
/* The following lookup tables were generated using the code in Appendix C */
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,
0x003E, 0x0F80, 0x004F, 0x1E40, 0x0057, 0x1D40, 0x005B, 0x1B40, 0x005D, 0x1740,
0x005E, 0x0F40, 0x0067, 0x1CC0, 0x006B, 0x1AC0, 0x006D, 0x16C0, 0x006E, 0x0EC0,
0x0073, 0x19C0, 0x0075, 0x15C0, 0x0076, 0x0DC0, 0x0079, 0x13C0, 0x007A, 0x0BC0,
0x007C, 0x07C0, 0x008F, 0x1E20, 0x0097, 0x1D20, 0x009B, 0x1B20, 0x009D, 0x1720,
0x009E, 0x0F20, 0x00A7, 0x1CA0, 0x00AB, 0x1AA0, 0x00AD, 0x16A0, 0x00AE, 0x0EA0,
0x00B3, 0x19A0, 0x00B5, 0x15A0, 0x00B6, 0x0DA0, 0x00B9, 0x13A0, 0x00BA, 0x0BA0,
0x00BC, 0x07A0, 0x00C7, 0x1C60, 0x00CB, 0x1A60, 0x00CD, 0x1660, 0x00CE, 0x0E60,
0x00D3, 0x1960, 0x00D5, 0x1560, 0x00D6, 0x0D60, 0x00D9, 0x1360, 0x00DA, 0x0B60,
0x00DC, 0x0760, 0x00E3, 0x18E0, 0x00E5, 0x14E0, 0x00E6, 0x0CE0, 0x00E9, 0x12E0,
0x00EA, 0x0AE0, 0x00EC, 0x06E0, 0x00F1, 0x11E0, 0x00F2, 0x09E0, 0x00F4, 0x05E0,
0x00F8, 0x03E0, 0x010F, 0x1E10, 0x0117, 0x1D10, 0x011B, 0x1B10, 0x011D, 0x1710,
0x011E, 0x0F10, 0x0127, 0x1C90, 0x012B, 0x1A90, 0x012D, 0x1690, 0x012E, 0x0E90,
0x0133, 0x1990, 0x0135, 0x1590, 0x0136, 0x0D90, 0x0139, 0x1390, 0x013A, 0x0B90,
0x013C, 0x0790, 0x0147, 0x1C50, 0x014B, 0x1A50, 0x014D, 0x1650, 0x014E, 0x0E50,
0x0153, 0x1950, 0x0155, 0x1550, 0x0156, 0x0D50, 0x0159, 0x1350, 0x015A, 0x0B50,
0x015C, 0x0750, 0x0163, 0x18D0, 0x0165, 0x14D0, 0x0166, 0x0CD0, 0x0169, 0x12D0,
0x016A, 0x0AD0, 0x016C, 0x06D0, 0x0171, 0x11D0, 0x0172, 0x09D0, 0x0174, 0x05D0,
0x0178, 0x03D0, 0x0187, 0x1C30, 0x018B, 0x1A30, 0x018D, 0x1630, 0x018E, 0x0E30,
0x0193, 0x1930, 0x0195, 0x1530, 0x0196, 0x0D30, 0x0199, 0x1330, 0x019A, 0x0B30,
0x019C, 0x0730, 0x01A3, 0x18B0, 0x01A5, 0x14B0, 0x01A6, 0x0CB0, 0x01A9, 0x12B0,
0x01AA, 0x0AB0, 0x01AC, 0x06B0, 0x01B1, 0x11B0, 0x01B2, 0x09B0, 0x01B4, 0x05B0,
0x01B8, 0x03B0, 0x01C3, 0x1870, 0x01C5, 0x1470, 0x01C6, 0x0C70, 0x01C9, 0x1270,
0x01CA, 0x0A70, 0x01CC, 0x0670, 0x01D1, 0x1170, 0x01D2, 0x0970, 0x01D4, 0x0570,
0x01D8, 0x0370, 0x01E1, 0x10F0, 0x01E2, 0x08F0, 0x01E4, 0x04F0, 0x01E8, 0x02F0,
0x020F, 0x1E08, 0x0217, 0x1D08, 0x021B, 0x1B08, 0x021D, 0x1708, 0x021E, 0x0F08,
0x0227, 0x1C88, 0x022B, 0x1A88, 0x022D, 0x1688, 0x022E, 0x0E88, 0x0233, 0x1988,
0x0235, 0x1588, 0x0236, 0x0D88, 0x0239, 0x1388, 0x023A, 0x0B88, 0x023C, 0x0788,
0x0247, 0x1C48, 0x024B, 0x1A48, 0x024D, 0x1648, 0x024E, 0x0E48, 0x0253, 0x1948,
0x0255, 0x1548, 0x0256, 0x0D48, 0x0259, 0x1348, 0x025A, 0x0B48, 0x025C, 0x0748,
0x0263, 0x18C8, 0x0265, 0x14C8, 0x0266, 0x0CC8, 0x0269, 0x12C8, 0x026A, 0x0AC8,
0x026C, 0x06C8, 0x0271, 0x11C8, 0x0272, 0x09C8, 0x0274, 0x05C8, 0x0278, 0x03C8,
0x0287, 0x1C28, 0x028B, 0x1A28, 0x028D, 0x1628, 0x028E, 0x0E28, 0x0293, 0x1928,
0x0295, 0x1528, 0x0296, 0x0D28, 0x0299, 0x1328, 0x029A, 0x0B28, 0x029C, 0x0728,
0x02A3, 0x18A8, 0x02A5, 0x14A8, 0x02A6, 0x0CA8, 0x02A9, 0x12A8, 0x02AA, 0x0AA8,
0x02AC, 0x06A8, 0x02B1, 0x11A8, 0x02B2, 0x09A8, 0x02B4, 0x05A8, 0x02B8, 0x03A8,
0x02C3, 0x1868, 0x02C5, 0x1468, 0x02C6, 0x0C68, 0x02C9, 0x1268, 0x02CA, 0x0A68,
0x02CC, 0x0668, 0x02D1, 0x1168, 0x02D2, 0x0968, 0x02D4, 0x0568, 0x02D8, 0x0368,
0x02E1, 0x10E8, 0x02E2, 0x08E8, 0x02E4, 0x04E8, 0x0307, 0x1C18, 0x030B, 0x1A18,
0x030D, 0x1618, 0x030E, 0x0E18, 0x0313, 0x1918, 0x0315, 0x1518, 0x0316, 0x0D18,
0x0319, 0x1318, 0x031A, 0x0B18, 0x031C, 0x0718, 0x0323, 0x1898, 0x0325, 0x1498,
0x0326, 0x0C98, 0x0329, 0x1298, 0x032A, 0x0A98, 0x032C, 0x0698, 0x0331, 0x1198,
0x0332, 0x0998, 0x0334, 0x0598, 0x0338, 0x0398, 0x0343, 0x1858, 0x0345, 0x1458,
0x0346, 0x0C58, 0x0349, 0x1258, 0x034A, 0x0A58, 0x034C, 0x0658, 0x0351, 0x1158,
0x0352, 0x0958, 0x0354, 0x0558, 0x0361, 0x10D8, 0x0362, 0x08D8, 0x0364, 0x04D8,
0x0383, 0x1838, 0x0385, 0x1438, 0x0386, 0x0C38, 0x0389, 0x1238, 0x038A, 0x0A38,
0x038C, 0x0638, 0x0391, 0x1138, 0x0392, 0x0938, 0x0394, 0x0538, 0x03A1, 0x10B8,
0x03A2, 0x08B8, 0x03A4, 0x04B8, 0x03C1, 0x1078, 0x03C2, 0x0878, 0x03C4, 0x0478,
0x040F, 0x1E04, 0x0417, 0x1D04, 0x041B, 0x1B04, 0x041D, 0x1704, 0x041E, 0x0F04,
0x0427, 0x1C84, 0x042B, 0x1A84, 0x042D, 0x1684, 0x042E, 0x0E84, 0x0433, 0x1984,
0x0435, 0x1584, 0x0436, 0x0D84, 0x0439, 0x1384, 0x043A, 0x0B84, 0x043C, 0x0784,
0x0447, 0x1C44, 0x044B, 0x1A44, 0x044D, 0x1644, 0x044E, 0x0E44, 0x0453, 0x1944,
0x0455, 0x1544, 0x0456, 0x0D44, 0x0459, 0x1344, 0x045A, 0x0B44, 0x045C, 0x0744,
0x0463, 0x18C4, 0x0465, 0x14C4, 0x0466, 0x0CC4, 0x0469, 0x12C4, 0x046A, 0x0AC4,
0x046C, 0x06C4, 0x0471, 0x11C4, 0x0472, 0x09C4, 0x0474, 0x05C4, 0x0487, 0x1C24,
0x048B, 0x1A24, 0x048D, 0x1624, 0x048E, 0x0E24, 0x0493, 0x1924, 0x0495, 0x1524,
0x0496, 0x0D24, 0x0499, 0x1324, 0x049A, 0x0B24, 0x049C, 0x0724, 0x04A3, 0x18A4,
0x04A5, 0x14A4, 0x04A6, 0x0CA4, 0x04A9, 0x12A4, 0x04AA, 0x0AA4, 0x04AC, 0x06A4,
0x04B1, 0x11A4, 0x04B2, 0x09A4, 0x04B4, 0x05A4, 0x04C3, 0x1864, 0x04C5, 0x1464,
0x04C6, 0x0C64, 0x04C9, 0x1264, 0x04CA, 0x0A64, 0x04CC, 0x0664, 0x04D1, 0x1164,
0x04D2, 0x0964, 0x04D4, 0x0564, 0x04E1, 0x10E4, 0x04E2, 0x08E4, 0x0507, 0x1C14,
0x050B, 0x1A14, 0x050D, 0x1614, 0x050E, 0x0E14, 0x0513, 0x1914, 0x0515, 0x1514,
0x0516, 0x0D14, 0x0519, 0x1314, 0x051A, 0x0B14, 0x051C, 0x0714, 0x0523, 0x1894,
0x0525, 0x1494, 0x0526, 0x0C94, 0x0529, 0x1294, 0x052A, 0x0A94, 0x052C, 0x0694,
0x0531, 0x1194, 0x0532, 0x0994, 0x0534, 0x0594, 0x0543, 0x1854, 0x0545, 0x1454,
0x0546, 0x0C54, 0x0549, 0x1254, 0x054A, 0x0A54, 0x054C, 0x0654, 0x0551, 0x1154,
0x0552, 0x0954, 0x0561, 0x10D4, 0x0562, 0x08D4, 0x0583, 0x1834, 0x0585, 0x1434,
0x0586, 0x0C34, 0x0589, 0x1234, 0x058A, 0x0A34, 0x058C, 0x0634, 0x0591, 0x1134,
0x0592, 0x0934, 0x05A1, 0x10B4, 0x05A2, 0x08B4, 0x05C1, 0x1074, 0x05C2, 0x0874,
0x0607, 0x1C0C, 0x060B, 0x1A0C, 0x060D, 0x160C, 0x060E, 0x0E0C, 0x0613, 0x190C,
0x0615, 0x150C, 0x0616, 0x0D0C, 0x0619, 0x130C, 0x061A, 0x0B0C, 0x061C, 0x070C,
0x0623, 0x188C, 0x0625, 0x148C, 0x0626, 0x0C8C, 0x0629, 0x128C, 0x062A, 0x0A8C,
0x062C, 0x068C, 0x0631, 0x118C, 0x0632, 0x098C, 0x0643, 0x184C, 0x0645, 0x144C,
0x0646, 0x0C4C, 0x0649, 0x124C, 0x064A, 0x0A4C, 0x0651, 0x114C, 0x0652, 0x094C,
0x0661, 0x10CC, 0x0662, 0x08CC, 0x0683, 0x182C, 0x0685, 0x142C, 0x0686, 0x0C2C,
0x0689, 0x122C, 0x068A, 0x0A2C, 0x0691, 0x112C, 0x0692, 0x092C, 0x06A1, 0x10AC,
0x06A2, 0x08AC, 0x06C1, 0x106C, 0x06C2, 0x086C, 0x0703, 0x181C, 0x0705, 0x141C,
0x0706, 0x0C1C, 0x0709, 0x121C, 0x070A, 0x0A1C, 0x0711, 0x111C, 0x0712, 0x091C,
0x0721, 0x109C, 0x0722, 0x089C, 0x0741, 0x105C, 0x0742, 0x085C, 0x0781, 0x103C,
0x0782, 0x083C, 0x080F, 0x1E02, 0x0817, 0x1D02, 0x081B, 0x1B02, 0x081D, 0x1702,
0x081E, 0x0F02, 0x0827, 0x1C82, 0x082B, 0x1A82, 0x082D, 0x1682, 0x082E, 0x0E82,
0x0833, 0x1982, 0x0835, 0x1582, 0x0836, 0x0D82, 0x0839, 0x1382, 0x083A, 0x0B82,
0x0847, 0x1C42, 0x084B, 0x1A42, 0x084D, 0x1642, 0x084E, 0x0E42, 0x0853, 0x1942,
0x0855, 0x1542, 0x0856, 0x0D42, 0x0859, 0x1342, 0x085A, 0x0B42, 0x0863, 0x18C2,
0x0865, 0x14C2, 0x0866, 0x0CC2, 0x0869, 0x12C2, 0x086A, 0x0AC2, 0x0871, 0x11C2,
0x0872, 0x09C2, 0x0887, 0x1C22, 0x088B, 0x1A22, 0x088D, 0x1622, 0x088E, 0x0E22,
0x0893, 0x1922, 0x0895, 0x1522, 0x0896, 0x0D22, 0x0899, 0x1322, 0x089A, 0x0B22,
0x08A3, 0x18A2, 0x08A5, 0x14A2, 0x08A6, 0x0CA2, 0x08A9, 0x12A2, 0x08AA, 0x0AA2,
0x08B1, 0x11A2, 0x08B2, 0x09A2, 0x08C3, 0x1862, 0x08C5, 0x1462, 0x08C6, 0x0C62,
0x08C9, 0x1262, 0x08CA, 0x0A62, 0x08D1, 0x1162, 0x08D2, 0x0962, 0x08E1, 0x10E2,
0x0907, 0x1C12, 0x090B, 0x1A12, 0x090D, 0x1612, 0x090E, 0x0E12, 0x0913, 0x1912,
0x0915, 0x1512, 0x0916, 0x0D12, 0x0919, 0x1312, 0x091A, 0x0B12, 0x0923, 0x1892,
0x0925, 0x1492, 0x0926, 0x0C92, 0x0929, 0x1292, 0x092A, 0x0A92, 0x0931, 0x1192,
0x0932, 0x0992, 0x0943, 0x1852, 0x0945, 0x1452, 0x0946, 0x0C52, 0x0949, 0x1252,
0x094A, 0x0A52, 0x0951, 0x1152, 0x0961, 0x10D2, 0x0983, 0x1832, 0x0985, 0x1432,
0x0986, 0x0C32, 0x0989, 0x1232, 0x098A, 0x0A32, 0x0991, 0x1132, 0x09A1, 0x10B2,
0x09C1, 0x1072, 0x0A07, 0x1C0A, 0x0A0B, 0x1A0A, 0x0A0D, 0x160A, 0x0A0E, 0x0E0A,
0x0A13, 0x190A, 0x0A15, 0x150A, 0x0A16, 0x0D0A, 0x0A19, 0x130A, 0x0A1A, 0x0B0A,
0x0A23, 0x188A, 0x0A25, 0x148A, 0x0A26, 0x0C8A, 0x0A29, 0x128A, 0x0A2A, 0x0A8A,
0x0A31, 0x118A, 0x0A43, 0x184A, 0x0A45, 0x144A, 0x0A46, 0x0C4A, 0x0A49, 0x124A,
0x0A51, 0x114A, 0x0A61, 0x10CA, 0x0A83, 0x182A, 0x0A85, 0x142A, 0x0A86, 0x0C2A,
0x0A89, 0x122A, 0x0A91, 0x112A, 0x0AA1, 0x10AA, 0x0AC1, 0x106A, 0x0B03, 0x181A,
0x0B05, 0x141A, 0x0B06, 0x0C1A, 0x0B09, 0x121A, 0x0B11, 0x111A, 0x0B21, 0x109A,
0x0B41, 0x105A, 0x0B81, 0x103A, 0x0C07, 0x1C06, 0x0C0B, 0x1A06, 0x0C0D, 0x1606,
0x0C0E, 0x0E06, 0x0C13, 0x1906, 0x0C15, 0x1506, 0x0C16, 0x0D06, 0x0C19, 0x1306,
0x0C23, 0x1886, 0x0C25, 0x1486, 0x0C26, 0x0C86, 0x0C29, 0x1286, 0x0C31, 0x1186,
0x0C43, 0x1846, 0x0C45, 0x1446, 0x0C49, 0x1246, 0x0C51, 0x1146, 0x0C61, 0x10C6,
0x0C83, 0x1826, 0x0C85, 0x1426, 0x0C89, 0x1226, 0x0C91, 0x1126, 0x0CA1, 0x10A6,
0x0CC1, 0x1066, 0x0D03, 0x1816, 0x0D05, 0x1416, 0x0D09, 0x1216, 0x0D11, 0x1116,
0x0D21, 0x1096, 0x0D41, 0x1056, 0x0D81, 0x1036, 0x0E03, 0x180E, 0x0E05, 0x140E,
0x0E09, 0x120E, 0x0E11, 0x110E, 0x0E21, 0x108E, 0x0E41, 0x104E, 0x0E81, 0x102E,
0x0F01, 0x101E, 0x100F, 0x1E01, 0x1017, 0x1D01, 0x101B, 0x1B01, 0x101D, 0x1701,
0x1027, 0x1C81, 0x102B, 0x1A81, 0x102D, 0x1681, 0x1033, 0x1981, 0x1035, 0x1581,
0x1039, 0x1381, 0x1047, 0x1C41, 0x104B, 0x1A41, 0x104D, 0x1641, 0x1053, 0x1941,
0x1055, 0x1541, 0x1059, 0x1341, 0x1063, 0x18C1, 0x1065, 0x14C1, 0x1069, 0x12C1,
0x1071, 0x11C1, 0x1087, 0x1C21, 0x108B, 0x1A21, 0x108D, 0x1621, 0x1093, 0x1921,
0x1095, 0x1521, 0x1099, 0x1321, 0x10A3, 0x18A1, 0x10A5, 0x14A1, 0x10A9, 0x12A1,
0x10B1, 0x11A1, 0x10C3, 0x1861, 0x10C5, 0x1461, 0x10C9, 0x1261, 0x10D1, 0x1161,
0x1107, 0x1C11, 0x110B, 0x1A11, 0x110D, 0x1611, 0x1113, 0x1911, 0x1115, 0x1511,
0x1119, 0x1311, 0x1123, 0x1891, 0x1125, 0x1491, 0x1129, 0x1291, 0x1131, 0x1191,
0x1143, 0x1851, 0x1145, 0x1451, 0x1149, 0x1251, 0x1183, 0x1831, 0x1185, 0x1431,
0x1189, 0x1231, 0x1207, 0x1C09, 0x120B, 0x1A09, 0x120D, 0x1609, 0x1213, 0x1909,
0x1215, 0x1509, 0x1219, 0x1309, 0x1223, 0x1889, 0x1225, 0x1489, 0x1229, 0x1289,
0x1243, 0x1849, 0x1245, 0x1449, 0x1283, 0x1829, 0x1285, 0x1429, 0x1303, 0x1819,
0x1305, 0x1419, 0x1407, 0x1C05, 0x140B, 0x1A05, 0x140D, 0x1605, 0x1413, 0x1905,
0x1415, 0x1505, 0x1423, 0x1885, 0x1425, 0x1485, 0x1443, 0x1845, 0x1483, 0x1825,
0x1503, 0x1815, 0x1603, 0x180D, 0x1807, 0x1C03, 0x180B, 0x1A03, 0x1813, 0x1903,
0x1823, 0x1883, 0x1843, 0x1445, 0x1249, 0x1151, 0x10E1, 0x0C46, 0x0A4A, 0x0952,
0x08E2, 0x064C, 0x0554, 0x04E4, 0x0358, 0x02E8, 0x01F0
};
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,
0x000C, 0x0600, 0x0011, 0x1100, 0x0012, 0x0900, 0x0014, 0x0500, 0x0018, 0x0300,
0x0021, 0x1080, 0x0022, 0x0880, 0x0024, 0x0480, 0x0028, 0x0280, 0x0030, 0x0180,
0x0041, 0x1040, 0x0042, 0x0840, 0x0044, 0x0440, 0x0048, 0x0240, 0x0050, 0x0140,
0x0060, 0x00C0, 0x0081, 0x1020, 0x0082, 0x0820, 0x0084, 0x0420, 0x0088, 0x0220,
0x0090, 0x0120, 0x0101, 0x1010, 0x0102, 0x0810, 0x0104, 0x0410, 0x0108, 0x0210,
0x0201, 0x1008, 0x0202, 0x0808, 0x0204, 0x0408, 0x0401, 0x1004, 0x0402, 0x0804,
0x0801, 0x1002, 0x1001, 0x0802, 0x0404, 0x0208, 0x0110, 0x00A0
};
static const unsigned short 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,
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,
129, 56, 4, 109, 96, 28, 36, 47, 11, 71, 33, 102, 21, 9, 17, 49, 124, 79, 64, 91, 42, 69, 53,
60, 14, 1, 27, 103, 126, 75, 89, 50, 120, 19, 32, 110, 92, 111, 130, 59, 31, 12, 81, 43, 55,
5, 74, 22, 101, 128, 58, 118, 48, 108, 38, 98, 93, 23, 83, 13, 73, 3
};
/***************************************************************************
** USPS_MSB_Math_CRC11GenerateFrameCheckSequence
**
** Inputs:
** ByteAttayPtr is the address of a 13 byte array holding 102 bits which
** are right justified - ie: the leftmost 2 bits of the first byte do not
** hold data and must be set to zero.
**
** Outputs:
** return unsigned short - 11 bit Frame Check Sequence (right justified)
***************************************************************************/
static unsigned short USPS_MSB_Math_CRC11GenerateFrameCheckSequence(unsigned char *ByteArrayPtr) {
unsigned short GeneratorPolynomial = 0x0F35;
unsigned short FrameCheckSequence = 0x07FF;
unsigned short Data;
int ByteIndex, Bit;
/* Do most significant byte skipping the 2 most significant bits */
Data = *ByteArrayPtr << 5;
ByteArrayPtr++;
for (Bit = 2; Bit < 8; Bit++) {
if ((FrameCheckSequence ^ Data) & 0x400)
FrameCheckSequence = (FrameCheckSequence << 1) ^ GeneratorPolynomial;
else
FrameCheckSequence = (FrameCheckSequence << 1);
FrameCheckSequence &= 0x7FF;
Data <<= 1;
}
/* Do rest of the bytes */
for (ByteIndex = 1; ByteIndex < 13; ByteIndex++) {
Data = *ByteArrayPtr << 3;
ByteArrayPtr++;
for (Bit = 0; Bit < 8; Bit++) {
if ((FrameCheckSequence ^ Data) & 0x0400) {
FrameCheckSequence = (FrameCheckSequence << 1) ^ GeneratorPolynomial;
} else {
FrameCheckSequence = (FrameCheckSequence << 1);
}
FrameCheckSequence &= 0x7FF;
Data <<= 1;
}
}
return FrameCheckSequence;
}
INTERNAL int daft_set_height(struct zint_symbol *symbol, float min_height, float max_height);
INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int length) {
char data_pattern[200];
int error_number;
int i, j, read;
char zip[35], tracker[35], temp[2];
large_int accum;
large_int byte_array_reg;
unsigned char byte_array[13];
unsigned short usps_crc;
unsigned int codeword[10];
unsigned short characters[10];
short int bar_map[130];
int zip_len, len;
if (length > 32) {
strcpy(symbol->errtxt, "450: Input too long (32 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SODIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "451: Invalid character in data (digits and \"-\" only)");
return error_number;
}
strcpy(zip, "");
strcpy(tracker, "");
/* separate the tracking code from the routing code */
read = 0;
j = 0;
for (i = 0; i < length; i++) {
if (source[i] == '-') {
tracker[read] = '\0';
j = 1;
read = 0;
} else {
if (j == 0) {
/* reading tracker */
tracker[read] = source[i];
read++;
} else {
/* reading zip code */
zip[read] = source[i];
read++;
}
}
}
if (j == 0) {
tracker[read] = '\0';
} else {
zip[read] = '\0';
}
if (strlen(tracker) != 20) {
strcpy(symbol->errtxt, "452: Invalid length for tracking code (20 characters required)");
return ZINT_ERROR_INVALID_DATA;
}
if (tracker[1] > '4') {
strcpy(symbol->errtxt, "454: Barcode Identifier (second character) out of range (0 to 4)");
return ZINT_ERROR_INVALID_DATA;
}
zip_len = (int) strlen(zip);
if (zip_len != 0 && zip_len != 5 && zip_len != 9 && zip_len != 11) {
strcpy(symbol->errtxt, "453: Invalid length for ZIP code (5, 9 or 11 characters required)");
return ZINT_ERROR_INVALID_DATA;
}
/* *** Step 1 - Conversion of Data Fields into Binary Data *** */
/* Routing code first */
large_load_str_u64(&accum, (unsigned char *) zip, zip_len);
/* add weight to routing code */
if (zip_len > 9) {
large_add_u64(&accum, 1000100001);
} else if (zip_len > 5) {
large_add_u64(&accum, 100001);
} else if (zip_len > 0) {
large_add_u64(&accum, 1);
}
/* tracking code */
/* multiply by 10 */
large_mul_u64(&accum, 10);
/* add first digit of tracker */
large_add_u64(&accum, ctoi(tracker[0]));
/* multiply by 5 */
large_mul_u64(&accum, 5);
/* add second digit */
large_add_u64(&accum, ctoi(tracker[1]));
/* and then the rest */
for (read = 2, len = (int) strlen(tracker); read < len; read++) {
large_mul_u64(&accum, 10);
large_add_u64(&accum, ctoi(tracker[read]));
}
/* *** Step 2 - Generation of 11-bit CRC on Binary Data *** */
large_load(&byte_array_reg, &accum);
large_unset_bit(&byte_array_reg, 102);
large_unset_bit(&byte_array_reg, 103);
large_uchar_array(&byte_array_reg, byte_array, 13, 8 /*bits*/);
usps_crc = USPS_MSB_Math_CRC11GenerateFrameCheckSequence(byte_array);
/* *** Step 3 - Conversion from Binary Data to Codewords *** */
/* start with codeword J which is base 636 */
codeword[9] = (unsigned int) large_div_u64(&accum, 636);
/* then codewords I to B with base 1365 */
for (j = 8; j > 0; j--) {
codeword[j] = (unsigned int) large_div_u64(&accum, 1365);
}
codeword[0] = (unsigned int) large_lo(&accum);
/* *** Step 4 - Inserting Additional Information into Codewords *** */
codeword[9] = codeword[9] * 2;
if (usps_crc >= 1024) {
codeword[0] += 659;
}
/* *** Step 5 - Conversion from Codewords to Characters *** */
for (i = 0; i < 10; i++) {
if (codeword[i] < 1287) {
characters[i] = AppxD_I[codeword[i]];
} else {
characters[i] = AppxD_II[codeword[i] - 1287];
}
}
for (i = 0; i < 10; i++) {
if (usps_crc & (1 << i)) {
characters[i] = 0x1FFF - characters[i];
}
}
/* *** Step 6 - Conversion from Characters to the Intelligent Mail Barcode *** */
for (i = 0; i < 10; i++) {
for (j = 0; j < 13; j++) {
if (characters[i] & (1 << j)) {
bar_map[AppxD_IV[(13 * i) + j] - 1] = 1;
} else {
bar_map[AppxD_IV[(13 * i) + j] - 1] = 0;
}
}
}
strcpy(data_pattern, "");
temp[1] = '\0';
for (i = 0; i < 65; i++) {
j = 0;
if (bar_map[i] == 0)
j += 1;
if (bar_map[i + 65] == 0)
j += 2;
temp[0] = itoc(j);
strcat(data_pattern, temp);
}
/* Translate 4-state data pattern to symbol */
read = 0;
for (i = 0, len = (int) strlen(data_pattern); i < len; i++) {
if ((data_pattern[i] == '1') || (data_pattern[i] == '0')) {
set_module(symbol, 0, read);
}
set_module(symbol, 1, read);
if ((data_pattern[i] == '2') || (data_pattern[i] == '0')) {
set_module(symbol, 2, read);
}
read += 2;
}
#ifdef COMPLIANT_HEIGHTS
/* USPS-B-3200 Section 2.3.1
Using bar pitch as X (1" / 43) ~ 0.023" based on 22 bars + 21 spaces per inch (bar width 0.015" - 0.025"),
height 0.125" - 0.165"
Tracker 0.048" (average of 0.039" - 0.057")
Ascender/descender 0.0965" (average of 0.082" - 0.111") less T = 0.0485"
*/
symbol->row_height[0] = 0.0485f * 43; /* 2.0855 */
symbol->row_height[1] = 0.048f * 43; /* 2.064 */
/* Note using max X for minimum and min X for maximum */
error_number = daft_set_height(symbol, 0.125f * 39 /*4.875*/, 0.165f * 47 /*7.755*/);
#else
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
daft_set_height(symbol, 0.0f, 0.0f);
#endif
symbol->rows = 3;
symbol->width = read - 1;
return error_number;
}

88
3rdparty/zint-2.10.0/backend/iso3166.h vendored Normal file
View File

@@ -0,0 +1,88 @@
/*
* ISO 3166 country codes generated by "backend/tools/gen_iso3166_h.php"
*/
/*
libzint - the open source barcode library
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef ISO3166_H
#define ISO3166_H
/* Whether ISO 3166-1 numeric */
static int iso3166_numeric(int cc) {
static const unsigned char codes[112] = {
0x10, 0x15, 0x11, 0x91, 0x11, 0x11, 0x1D, 0x11,
0x51, 0x15, 0x50, 0x14, 0x11, 0x11, 0x11, 0x11,
0x10, 0x11, 0x11, 0x51, 0x44, 0xC4, 0x14, 0x91,
0x11, 0x18, 0x51, 0x44, 0x84, 0xC7, 0x44, 0x45,
0x54, 0x54, 0x18, 0x00, 0x11, 0x11, 0x11, 0x11,
0x11, 0x51, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
0x11, 0x41, 0x11, 0x45, 0x46, 0x54, 0x44, 0x45,
0x44, 0x44, 0x44, 0x44, 0x11, 0x10, 0x1D, 0x11,
0x11, 0x11, 0xE9, 0x10, 0x10, 0x44, 0x44, 0x44,
0xB4, 0x87, 0x40, 0x11, 0x11, 0x11, 0x45, 0x44,
0x4C, 0x50, 0xD8, 0x44, 0x44, 0x44, 0x45, 0xC0,
0x47, 0x10, 0x10, 0x13, 0x10, 0x11, 0x11, 0x15,
0x11, 0x11, 0x11, 0x59, 0x91, 0x00, 0x04, 0x84,
0x07, 0x01, 0x44, 0x54, 0x00, 0x10, 0x84, 0x40,
};
int b = cc >> 3;
if (b < 0 || b >= 112) {
return 0;
}
return codes[b] & (1 << (cc & 0x7)) ? 1 : 0;
}
/* Whether ISO 3166-1 alpha2 */
static int iso3166_alpha2(const char *cc) {
static const unsigned char codes[85] = {
0x78, 0x59, 0xDF, 0xEE, 0xEF, 0xBD, 0xDD, 0xDE,
0x27, 0x3F, 0x84, 0x15, 0x80, 0xD4, 0x00, 0x0E,
0x00, 0x5C, 0x09, 0xB0, 0x9F, 0xFB, 0x15, 0x00,
0x8D, 0x06, 0x18, 0x78, 0x0F, 0x40, 0x40, 0x03,
0x00, 0x1D, 0x2B, 0xF4, 0x41, 0x81, 0x4F, 0xFD,
0xFC, 0xFF, 0xD7, 0x25, 0x4B, 0x08, 0x00, 0x01,
0x40, 0x3C, 0x8F, 0x53, 0x01, 0x00, 0x00, 0x40,
0x00, 0x51, 0xF1, 0xFD, 0xE7, 0x3A, 0xBB, 0x9F,
0x9A, 0x41, 0x10, 0x04, 0x57, 0x85, 0x40, 0x00,
0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x08, 0x04, 0x40, 0x00, 0x01,
};
int cc_int;
if (cc[0] < 'A' || cc[0] > 'Z' || cc[1] < 'A' || cc[1] > 'Z') {
return 0;
}
cc_int = (cc[0] - 'A') * 26 + (cc[1] - 'A');
return codes[cc_int >> 3] & (1 << (cc_int & 0x7)) ? 1 : 0;
}
#endif /* ISO3166_H */

65
3rdparty/zint-2.10.0/backend/iso4217.h vendored Normal file
View File

@@ -0,0 +1,65 @@
/*
* ISO 4217 currency codes generated by "backend/tools/gen_iso4217_h.php"
*/
/*
libzint - the open source barcode library
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef ISO4217_H
#define ISO4217_H
/* Whether ISO 4217-1 numeric */
static int iso4217_numeric(int cc) {
static const unsigned char codes[125] = {
0x00, 0x11, 0x00, 0x00, 0x11, 0x10, 0x1D, 0x10,
0x11, 0x01, 0x10, 0x04, 0x01, 0x11, 0x10, 0x10,
0x10, 0x01, 0x01, 0x11, 0x00, 0x44, 0x00, 0x90,
0x01, 0x08, 0x41, 0x40, 0x40, 0x41, 0x04, 0x00,
0x40, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x11, 0x11, 0x10, 0x11, 0x11, 0x11, 0x01, 0x01,
0x10, 0x41, 0x11, 0x45, 0x46, 0x44, 0x04, 0x40,
0x40, 0x44, 0x00, 0x00, 0x11, 0x00, 0x05, 0x01,
0x11, 0x10, 0x30, 0x00, 0x10, 0x44, 0x40, 0x00,
0x04, 0x44, 0x40, 0x11, 0x01, 0x00, 0x00, 0x04,
0x48, 0x40, 0x00, 0x00, 0x00, 0x04, 0x44, 0x40,
0x45, 0x00, 0x00, 0x01, 0x00, 0x10, 0x11, 0x11,
0x00, 0x11, 0x11, 0x00, 0x81, 0x00, 0x04, 0x04,
0x04, 0x01, 0x00, 0x14, 0x00, 0x00, 0x44, 0x00,
0x20, 0x00, 0x00, 0x80, 0x7F, 0xB5, 0xFD, 0xFB,
0xBF, 0xBF, 0x3F, 0x47, 0xA4,
};
int b = cc >> 3;
if (b < 0 || b >= 125) {
return 0;
}
return codes[b] & (1 << (cc & 0x7)) ? 1 : 0;
}
#endif /* ISO4217_H */

1863
3rdparty/zint-2.10.0/backend/ksx1001.h vendored Normal file

File diff suppressed because it is too large Load Diff

319
3rdparty/zint-2.10.0/backend/large.c vendored Normal file
View File

@@ -0,0 +1,319 @@
/* large.c - Handles binary manipulation of large numbers */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* `large_mul_u64()` and `large_div_u64()` are adapted from articles by F. W. Jacob
* https://www.codeproject.com/Tips/618570/UInt-Multiplication-Squaring
* "This article, along with any associated source code and files, is licensed under The BSD License"
* http://www.codeproject.com/Tips/785014/UInt-Division-Modulus
* "This article, along with any associated source code and files, is licensed under The BSD License"
*
* These in turn are based on Hacker's Delight (2nd Edition, 2012) by Henry S. Warren, Jr.
* "You are free to use, copy, and distribute any of the code on this web site, whether modified by you or not."
* https://web.archive.org/web/20190716204559/http://www.hackersdelight.org/permissions.htm
*
* `clz_u64()` and other bits and pieces are adapted from r128.h by Alan Hickman (fahickman)
* https://github.com/fahickman/r128/blob/master/r128.h
* "R128 is released into the public domain. See LICENSE for details." LICENSE is The Unlicense.
*/
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#include "large.h"
#define MASK32 0xFFFFFFFF
/* Convert decimal string `s` of (at most) length `length` to 64-bit and place in 128-bit `t` */
INTERNAL void large_load_str_u64(large_int *t, const unsigned char *s, const int length) {
uint64_t val = 0;
const unsigned char *se = s + length;
for (; s < se && *s >= '0' && *s <= '9'; s++) {
val *= 10;
val += *s - '0';
}
t->lo = val;
t->hi = 0;
}
/* Add 128-bit `s` to 128-bit `t` */
INTERNAL void large_add(large_int *t, const large_int *s) {
t->lo += s->lo;
t->hi += s->hi + (t->lo < s->lo);
}
/* Add 64-bit `s` to 128-bit `t` */
INTERNAL void large_add_u64(large_int *t, const uint64_t s) {
t->lo += s;
if (t->lo < s) {
t->hi++;
}
}
/* Subtract 64-bit `s` from 128-bit `t` */
INTERNAL void large_sub_u64(large_int *t, const uint64_t s) {
uint64_t r = t->lo - s;
if (r > t->lo) {
t->hi--;
}
t->lo = r;
}
/* Multiply 128-bit `t` by 64-bit `s`
* See Jacob `mult64to128()` and Warren Section 8-2
* Note '0' denotes low 32-bits, '1' high 32-bits
* if p00 == s0 * tlo0
* k00 == carry of p00
* p01 == s0 * tlo1
* k01 == carry of (p01 + k00)
* p10 == s1 * tlo0
* k10 == carry of p10
* p11 == s1 * tlo1 (unmasked, i.e. including unshifted carry if any)
* then t->lo == (p01 + p10 + k00) << 32 + p00
* and t->hi == p11 + k10 + k01 + thi * s
*
* (thi) tlo1 tlo0
* x s1 s0
* -------------------------
* p00
* k01 p01 + k00
* p10
* p11 + k10
*/
INTERNAL void large_mul_u64(large_int *t, const uint64_t s) {
uint64_t thi = t->hi;
uint64_t tlo0 = t->lo & MASK32;
uint64_t tlo1 = t->lo >> 32;
uint64_t s0 = s & MASK32;
uint64_t s1 = s >> 32;
uint64_t tmp = s0 * tlo0; /* p00 (unmasked) */
uint64_t p00 = tmp & MASK32;
uint64_t k10;
tmp = (s1 * tlo0) + (tmp >> 32); /* (p10 + k00) (p10 unmasked) */
k10 = tmp >> 32;
tmp = (s0 * tlo1) + (tmp & MASK32); /* (p01 + p10 + k00) (p01 unmasked) */
t->lo = (tmp << 32) + p00; /* (p01 + p10 + k00) << 32 + p00 (note any carry from unmasked p01 shifted out) */
t->hi = (s1 * tlo1) + k10 + (tmp >> 32) + thi * s; /* p11 + k10 + k01 + thi * s */
}
/* Count leading zeroes. See Hickman `r128__clz64()` */
STATIC_UNLESS_ZINT_TEST int clz_u64(uint64_t x) {
uint64_t n = 64, y;
y = x >> 32; if (y) { n -= 32; x = y; }
y = x >> 16; if (y) { n -= 16; x = y; }
y = x >> 8; if (y) { n -= 8; x = y; }
y = x >> 4; if (y) { n -= 4; x = y; }
y = x >> 2; if (y) { n -= 2; x = y; }
y = x >> 1; if (y) { n -= 1; x = y; }
return (int) (n - x);
}
/* Divide 128-bit dividend `t` by 64-bit divisor `v`
* See Jacob `divmod128by128/64()` and Warren Section 92 (divmu64.c.txt)
* Note digits are 32-bit parts */
INTERNAL uint64_t large_div_u64(large_int *t, uint64_t v) {
const uint64_t b = 0x100000000; /* Number base (2**32) */
uint64_t qhi = 0; /* High digit of returned quotient */
uint64_t tnhi, tnlo, tnlo1, tnlo0, vn1, vn0; /* Normalized forms of (parts of) t and v */
uint64_t rnhilo1; /* Remainder after dividing 1st 3 digits of t by v */
uint64_t qhat1, qhat0; /* Estimated quotient digits */
uint64_t rhat; /* Remainder of estimated quotient digit */
uint64_t tmp;
int norm_shift;
/* Deal with single-digit (i.e. 32-bit) divisor here */
if (v < b) {
qhi = t->hi / v;
tmp = ((t->hi - qhi * v) << 32) + (t->lo >> 32); /* k * b + tlo1 */
qhat1 = tmp / v;
tmp = ((tmp - qhat1 * v) << 32) + (t->lo & MASK32); /* k * b + tlo0 */
qhat0 = tmp / v;
t->lo = (qhat1 << 32) | qhat0;
t->hi = qhi;
return tmp - qhat0 * v;
}
/* Main algorithm requires t->hi < v */
if (t->hi >= v) {
qhi = t->hi / v;
t->hi %= v;
}
/* Normalize by shifting v left just enough so that its high-order
* bit is on, and shift t left the same amount. Note don't need extra
* high-end digit for dividend as t->hi < v */
norm_shift = clz_u64(v);
v <<= norm_shift;
vn1 = v >> 32;
vn0 = v & MASK32;
if (norm_shift > 0) {
tnhi = (t->hi << norm_shift) | (t->lo >> (64 - norm_shift));
tnlo = t->lo << norm_shift;
} else {
tnhi = t->hi;
tnlo = t->lo;
}
tnlo1 = tnlo >> 32;
tnlo0 = tnlo & MASK32;
/* Compute qhat1 estimate */
qhat1 = tnhi / vn1; /* Divide first digit of v into first 2 digits of t */
rhat = tnhi % vn1;
/* Loop until qhat1 one digit and <= (rhat * b + 3rd digit of t) / vn0 */
for (tmp = qhat1 * vn0; qhat1 >= b || tmp > (rhat << 32) + tnlo1; tmp -= vn0) {
--qhat1;
rhat += vn1;
if (rhat >= b) { /* Must check here as (rhat << 32) would overflow */
break; /* qhat1 * vn0 < b * b (since vn0 < b) */
}
}
/* Note qhat1 will be exact as have fully divided by 2-digit divisor
* (can only be too high by 1 (and require "add back" step) if divisor at least 3 digits) */
/* Note high digit (if any) of both tnhi and (qhat1 * v) shifted out */
rnhilo1 = (tnhi << 32) + tnlo1 - (qhat1 * v);
/* Compute qhat0 estimate */
qhat0 = rnhilo1 / vn1; /* Divide first digit of v into 2-digit remains of first 3 digits of t */
rhat = rnhilo1 % vn1;
/* Loop until qhat0 one digit and <= (rhat * b + 4th digit of t) / vn0 */
for (tmp = qhat0 * vn0; qhat0 >= b || tmp > (rhat << 32) + tnlo0; tmp -= vn0) {
--qhat0;
rhat += vn1;
if (rhat >= b) {
break;
}
}
/* Similarly qhat0 will be exact */
t->lo = (qhat1 << 32) | qhat0;
t->hi = qhi;
/* Unnormalize remainder */
return ((rnhilo1 << 32) + tnlo0 - (qhat0 * v)) >> norm_shift;
}
/* Unset a bit (zero-based) */
INTERNAL void large_unset_bit(large_int *t, const int bit) {
if (bit < 64) {
t->lo &= ~(((uint64_t) 1) << bit);
} else if (bit < 128) {
t->hi &= ~(((uint64_t) 1) << (bit - 64));
}
}
/* Output large_int into an unsigned int array of size `size`, each element containing `bits` bits */
INTERNAL void large_uint_array(const large_int *t, unsigned int *uint_array, const int size, int bits) {
int i, j;
uint64_t mask;
if (bits <= 0) {
bits = 8;
} else if (bits > 32) {
bits = 32;
}
mask = ~(((uint64_t) -1) << bits);
for (i = 0, j = 0; i < size && j < 64; i++, j += bits) {
uint_array[size - 1 - i] = (unsigned int) ((t->lo >> j) & mask); /* Little-endian order */
}
if (i < size) {
if (j != 64) {
j -= 64;
/* (first j bits of t->hi) << (bits - j) | (last (bits - j) bits of t->lo) */
uint_array[size - i] = (unsigned int) (((t->hi & ~((((uint64_t) -1) << j))) << (bits - j))
| (t->lo >> (64 - (bits - j)) & mask));
} else {
j = 0;
}
for (; i < size && j < 64; i++, j += bits) {
uint_array[size - 1 - i] = (unsigned int) ((t->hi >> j) & mask);
}
if (i < size) {
memset(uint_array, 0, sizeof(unsigned int) * (size - i));
}
}
}
/* As `large_uint_array()` above, except output to unsigned char array */
INTERNAL void large_uchar_array(const large_int *t, unsigned char *uchar_array, const int size, int bits) {
int i;
#ifndef _MSC_VER
unsigned int uint_array[size ? size : 1]; /* Avoid run-time warning if size is 0 */
#else
unsigned int *uint_array = (unsigned int *) _alloca(sizeof(unsigned int) * (size ? size : 1));
#endif
large_uint_array(t, uint_array, size, bits);
for (i = 0; i < size; i++) {
uchar_array[i] = (unsigned char) uint_array[i];
}
}
/* Output formatted large_int to stdout */
INTERNAL void large_print(const large_int *t) {
char buf[35]; /* 2 (0x) + 32 (hex) + 1 */
puts(large_dump(t, buf));
}
/* Format large_int into buffer, which should be at least 35 chars in size */
INTERNAL char *large_dump(const large_int *t, char *buf) {
unsigned int tlo1 = (unsigned int) (large_lo(t) >> 32);
unsigned int tlo0 = (unsigned int) (large_lo(t) & MASK32);
unsigned int thi1 = (unsigned int) (large_hi(t) >> 32);
unsigned int thi0 = (unsigned int) (large_hi(t) & MASK32);
if (thi1) {
sprintf(buf, "0x%X%08X%08X%08X", thi1, thi0, tlo1, tlo0);
} else if (thi0) {
sprintf(buf, "0x%X%08X%08X", thi0, tlo1, tlo0);
} else if (tlo1) {
sprintf(buf, "0x%X%08X", tlo1, tlo0);
} else {
sprintf(buf, "0x%X", tlo0);
}
return buf;
}

80
3rdparty/zint-2.10.0/backend/large.h vendored Normal file
View File

@@ -0,0 +1,80 @@
/* large.h - Handles binary manipulation of large numbers */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef __LARGE_H
#define __LARGE_H
#ifndef _MSC_VER
#include <stdint.h>
#else
#include "ms_stdint.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct { uint64_t lo; uint64_t hi; } large_int;
#define large_lo(s) ((s)->lo)
#define large_hi(s) ((s)->hi)
/* Set 128-bit `t` from 128-bit `s` */
#define large_load(t, s) do { (t)->lo = (s)->lo; (t)->hi = (s)->hi; } while (0)
/* Set 128-bit `t` from 64-bit `s` */
#define large_load_u64(t, s) do { (t)->lo = (s); (t)->hi = 0; } while (0)
INTERNAL void large_load_str_u64(large_int *t, const unsigned char *s, const int length);
INTERNAL void large_add(large_int *t, const large_int *s);
INTERNAL void large_add_u64(large_int *t, const uint64_t s);
INTERNAL void large_sub_u64(large_int *t, const uint64_t s);
INTERNAL void large_mul_u64(large_int *t, const uint64_t s);
INTERNAL uint64_t large_div_u64(large_int *t, uint64_t v);
INTERNAL void large_unset_bit(large_int *t, const int bit);
INTERNAL void large_uint_array(const large_int *t, unsigned int *uint_array, const int size, int bits);
INTERNAL void large_uchar_array(const large_int *t, unsigned char *uchar_array, const int size, int bits);
INTERNAL void large_print(const large_int *t);
INTERNAL char *large_dump(const large_int *t, char *buf);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LARGE_H */

1575
3rdparty/zint-2.10.0/backend/library.c vendored Normal file

File diff suppressed because it is too large Load Diff

45
3rdparty/zint-2.10.0/backend/libzint.rc vendored Normal file
View File

@@ -0,0 +1,45 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winver.h>
#define VER_FILEVERSION 2,10,0,0
#define VER_FILEVERSION_STR "2,10,0,0\0"
#ifdef GCC_WINDRES
VS_VERSION_INFO VERSIONINFO
#else
VS_VERSION_INFO VERSIONINFO
#endif
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_FILEVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
//language ID = U.S. English, char set = Windows, Multilingual
BEGIN
VALUE "FileDescription", "libzint barcode library\0"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "zint.dll\0"
VALUE "LegalCopyright", "Copyright <20> 2021 Robin Stuart & BogDan Vatra\0"
VALUE "OriginalFilename", "zint.dll\0"
VALUE "ProductName", "libzint\0"
VALUE "ProductVersion", VER_FILEVERSION_STR
VALUE "License", "BSD License version 3\0"
VALUE "WWW", "http://www.sourceforge.net/projects/zint\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1250
END
END

510
3rdparty/zint-2.10.0/backend/mailmark.c vendored Normal file
View File

@@ -0,0 +1,510 @@
/* mailmark.c - Royal Mail 4-state Mailmark barcodes */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/*
* Developed in accordance with "Royal Mail Mailmark barcode C encoding and deconding instructions"
* (https://www.royalmail.com/sites/default/files/Mailmark-4-state-barcode-C-encoding-and-decoding-instructions-Sept-2015.pdf)
* and "Royal Mail Mailmark barcode L encoding and decoding"
* (https://www.royalmail.com/sites/default/files/Mailmark-4-state-barcode-L-encoding-and-decoding-instructions-Sept-2015.pdf)
*
*/
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#include "large.h"
#include "reedsol.h"
#define RUBIDIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "
// Allowed character values from Table 3
#define SET_F "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define SET_L "ABDEFGHJLNPQRSTUWXYZ"
#define SET_N "0123456789"
#define SET_S " "
static const char *postcode_format[6] = {
"FNFNLLNLS", "FFNNLLNLS", "FFNNNLLNL", "FFNFNLLNL", "FNNLLNLSS", "FNNNLLNLS"
};
// Data/Check Symbols from Table 5
static const unsigned char data_symbol_odd[32] = {
0x01, 0x02, 0x04, 0x07, 0x08, 0x0B, 0x0D, 0x0E, 0x10, 0x13, 0x15, 0x16,
0x19, 0x1A, 0x1C, 0x1F, 0x20, 0x23, 0x25, 0x26, 0x29, 0x2A, 0x2C, 0x2F,
0x31, 0x32, 0x34, 0x37, 0x38, 0x3B, 0x3D, 0x3E
};
static const unsigned char data_symbol_even[30] = {
0x03, 0x05, 0x06, 0x09, 0x0A, 0x0C, 0x0F, 0x11, 0x12, 0x14, 0x17, 0x18,
0x1B, 0x1D, 0x1E, 0x21, 0x22, 0x24, 0x27, 0x28, 0x2B, 0x2D, 0x2E, 0x30,
0x33, 0x35, 0x36, 0x39, 0x3A, 0x3C
};
static const unsigned short extender_group_c[22] = {
3, 5, 7, 11, 13, 14, 16, 17, 19, 0, 1, 2, 4, 6, 8, 9, 10, 12, 15, 18, 20, 21
};
static const unsigned short extender_group_l[26] = {
2, 5, 7, 8, 13, 14, 15, 16, 21, 22, 23, 0, 1, 3, 4, 6, 9, 10, 11, 12, 17, 18, 19, 20, 24, 25
};
static int verify_character(char input, char type) {
int val = 0;
switch (type) {
case 'F':
val = posn(SET_F, input);
break;
case 'L':
val = posn(SET_L, input);
break;
case 'N':
val = posn(SET_N, input);
break;
case 'S':
val = posn(SET_S, input);
break;
}
if (val == -1) {
return 0;
} else {
return 1;
}
}
static int verify_postcode(char *postcode, int type) {
int i;
char pattern[11];
strcpy(pattern, postcode_format[type - 1]);
for (i = 0; i < 9; i++) {
if (!(verify_character(postcode[i], pattern[i]))) {
return 1;
}
}
return 0;
}
INTERNAL int daft_set_height(struct zint_symbol *symbol, float min_height, float max_height);
/* Royal Mail Mailmark */
INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int length) {
char local_source[28];
int format;
int version_id;
int mail_class;
int supply_chain_id;
unsigned int item_id;
char postcode[10];
int postcode_type;
char pattern[10];
large_int destination_postcode;
large_int b;
large_int cdv;
unsigned char data[26];
int data_top, data_step;
unsigned char check[7];
unsigned int extender[27];
char bar[80];
int check_count;
int i, j, len;
rs_t rs;
int error_number = 0;
if (length > 26) {
strcpy(symbol->errtxt, "580: Input too long (26 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
ustrcpy(local_source, source);
if (length < 22) {
for (i = length; i <= 22; i++) {
strcat(local_source, " ");
}
length = 22;
}
if ((length > 22) && (length < 26)) {
for (i = length; i <= 26; i++) {
strcat(local_source, " ");
}
length = 26;
}
to_upper((unsigned char *) local_source);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Producing Mailmark %s\n", local_source);
}
if (is_sane(RUBIDIUM, (unsigned char *) local_source, length) != 0) {
strcpy(symbol->errtxt, "581: Invalid character in data (alphanumerics and space only)");
return ZINT_ERROR_INVALID_DATA;
}
// Format is in the range 0-4
format = ctoi(local_source[0]);
if ((format < 0) || (format > 4)) {
strcpy(symbol->errtxt, "582: Format out of range (0 to 4)");
return ZINT_ERROR_INVALID_DATA;
}
// Version ID is in the range 1-4
version_id = ctoi(local_source[1]) - 1;
if ((version_id < 0) || (version_id > 3)) {
strcpy(symbol->errtxt, "583: Version ID out of range (1 to 4)");
return ZINT_ERROR_INVALID_DATA;
}
// Class is in the range 0-9,A-E
mail_class = ctoi(local_source[2]);
if ((mail_class < 0) || (mail_class > 14)) {
strcpy(symbol->errtxt, "584: Class out of range (0 to 9 and A to E)");
return ZINT_ERROR_INVALID_DATA;
}
// Supply Chain ID is 2 digits for barcode C and 6 digits for barcode L
supply_chain_id = 0;
for (i = 3; i < (length - 17); i++) {
if ((local_source[i] >= '0') && (local_source[i] <= '9')) {
supply_chain_id *= 10;
supply_chain_id += ctoi(local_source[i]);
} else {
strcpy(symbol->errtxt, "585: Invalid Supply Chain ID (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
}
// Item ID is 8 digits
item_id = 0;
for (i = length - 17; i < (length - 9); i++) {
if ((local_source[i] >= '0') && (local_source[i] <= '9')) {
item_id *= 10;
item_id += ctoi(local_source[i]);
} else {
strcpy(symbol->errtxt, "586: Invalid Item ID (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
}
// Separate Destination Post Code plus DPS field
for (i = 0; i < 9; i++) {
postcode[i] = local_source[(length - 9) + i];
}
postcode[9] = '\0';
// Detect postcode type
/* postcode_type is used to select which format of postcode
*
* 1 = FNFNLLNLS
* 2 = FFNNLLNLS
* 3 = FFNNNLLNL
* 4 = FFNFNLLNL
* 5 = FNNLLNLSS
* 6 = FNNNLLNLS
* 7 = International designation
*/
if (strcmp(postcode, "XY11 ") == 0) {
postcode_type = 7;
} else {
if (postcode[7] == ' ') {
postcode_type = 5;
} else {
if (postcode[8] == ' ') {
// Types 1, 2 and 6
if ((postcode[1] >= '0') && (postcode[1] <= '9')) {
if ((postcode[2] >= '0') && (postcode[2] <= '9')) {
postcode_type = 6;
} else {
postcode_type = 1;
}
} else {
postcode_type = 2;
}
} else {
// Types 3 and 4
if ((postcode[3] >= '0') && (postcode[3] <= '9')) {
postcode_type = 3;
} else {
postcode_type = 4;
}
}
}
}
// Verify postcode type
if (postcode_type != 7) {
if (verify_postcode(postcode, postcode_type) != 0) {
strcpy(symbol->errtxt, "587: Invalid postcode");
return ZINT_ERROR_INVALID_DATA;
}
}
// Convert postcode to internal user field
large_load_u64(&destination_postcode, 0);
if (postcode_type != 7) {
strcpy(pattern, postcode_format[postcode_type - 1]);
large_load_u64(&b, 0);
for (i = 0; i < 9; i++) {
switch (pattern[i]) {
case 'F':
large_mul_u64(&b, 26);
large_add_u64(&b, posn(SET_F, postcode[i]));
break;
case 'L':
large_mul_u64(&b, 20);
large_add_u64(&b, posn(SET_L, postcode[i]));
break;
case 'N':
large_mul_u64(&b, 10);
large_add_u64(&b, posn(SET_N, postcode[i]));
break;
// case 'S' ignored as value is 0
}
}
large_load(&destination_postcode, &b);
// destination_postcode = a + b
large_load_u64(&b, 1);
if (postcode_type == 1) {
large_add(&destination_postcode, &b);
}
large_add_u64(&b, 5408000000);
if (postcode_type == 2) {
large_add(&destination_postcode, &b);
}
large_add_u64(&b, 5408000000);
if (postcode_type == 3) {
large_add(&destination_postcode, &b);
}
large_add_u64(&b, 54080000000);
if (postcode_type == 4) {
large_add(&destination_postcode, &b);
}
large_add_u64(&b, 140608000000);
if (postcode_type == 5) {
large_add(&destination_postcode, &b);
}
large_add_u64(&b, 208000000);
if (postcode_type == 6) {
large_add(&destination_postcode, &b);
}
}
// Conversion from Internal User Fields to Consolidated Data Value
// Set CDV to 0
large_load_u64(&cdv, 0);
// Add Destination Post Code plus DPS
large_add(&cdv, &destination_postcode);
// Multiply by 100,000,000
large_mul_u64(&cdv, 100000000);
// Add Item ID
large_add_u64(&cdv, item_id);
if (length == 22) {
// Barcode C - Multiply by 100
large_mul_u64(&cdv, 100);
} else {
// Barcode L - Multiply by 1,000,000
large_mul_u64(&cdv, 1000000);
}
// Add Supply Chain ID
large_add_u64(&cdv, supply_chain_id);
// Multiply by 15
large_mul_u64(&cdv, 15);
// Add Class
large_add_u64(&cdv, mail_class);
// Multiply by 5
large_mul_u64(&cdv, 5);
// Add Format
large_add_u64(&cdv, format);
// Multiply by 4
large_mul_u64(&cdv, 4);
// Add Version ID
large_add_u64(&cdv, version_id);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("DPC type %d\n", postcode_type);
printf("CDV: ");
large_print(&cdv);
}
if (length == 22) {
data_top = 15;
data_step = 8;
check_count = 6;
} else {
data_top = 18;
data_step = 10;
check_count = 7;
}
// Conversion from Consolidated Data Value to Data Numbers
for (j = data_top; j >= (data_step + 1); j--) {
data[j] = (unsigned char) large_div_u64(&cdv, 32);
}
for (j = data_step; j >= 0; j--) {
data[j] = (unsigned char) large_div_u64(&cdv, 30);
}
// Generation of Reed-Solomon Check Numbers
rs_init_gf(&rs, 0x25);
rs_init_code(&rs, check_count, 1);
rs_encode(&rs, (data_top + 1), data, check);
// Append check digits to data
for (i = 1; i <= check_count; i++) {
data[data_top + i] = check[check_count - i];
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Codewords: ");
for (i = 0; i <= data_top + check_count; i++) {
printf("%d ", (int) data[i]);
}
printf("\n");
}
// Conversion from Data Numbers and Check Numbers to Data Symbols and Check Symbols
for (i = 0; i <= data_step; i++) {
data[i] = data_symbol_even[data[i]];
}
for (i = data_step + 1; i <= (data_top + check_count); i++) {
data[i] = data_symbol_odd[data[i]];
}
// Conversion from Data Symbols and Check Symbols to Extender Groups
for (i = 0; i < length; i++) {
if (length == 22) {
extender[extender_group_c[i]] = data[i];
} else {
extender[extender_group_l[i]] = data[i];
}
}
// Conversion from Extender Groups to Bar Identifiers
strcpy(bar, "");
for (i = 0; i < length; i++) {
for (j = 0; j < 3; j++) {
switch (extender[i] & 0x24) {
case 0x24:
strcat(bar, "F");
break;
case 0x20:
if (i % 2) {
strcat(bar, "D");
} else {
strcat(bar, "A");
}
break;
case 0x04:
if (i % 2) {
strcat(bar, "A");
} else {
strcat(bar, "D");
}
break;
default:
strcat(bar, "T");
break;
}
extender[i] = extender[i] << 1;
}
}
bar[(length * 3)] = '\0';
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Bar pattern: %s\n", bar);
}
/* Translate 4-state data pattern to symbol */
j = 0;
for (i = 0, len = (int) strlen(bar); i < len; i++) {
if ((bar[i] == 'F') || (bar[i] == 'A')) {
set_module(symbol, 0, j);
}
set_module(symbol, 1, j);
if ((bar[i] == 'F') || (bar[i] == 'D')) {
set_module(symbol, 2, j);
}
j += 2;
}
#ifdef COMPLIANT_HEIGHTS
/* Royal Mail Mailmark Barcode Definition Document (15 Sept 2015) Section 3.5.1
https://www.royalmail.com/sites/default/files/Royal-Mail-Mailmark-barcode-definition-document-September-2015.pdf
Using bar pitch as X (25.4mm / 42.3) ~ 0.6mm based on 21.2 bars + 21.1 spaces per 25.4mm (bar width 0.38-63mm)
Using recommended 1.9mm and 1.3mm heights for Ascender/Descenders and Trackers resp. as defaults
Min height 4.22mm * 39 (max pitch) / 25.4mm ~ 6.47, max height 5.84mm * 47 (min pitch) / 25.4mm ~ 10.8
*/
symbol->row_height[0] = (float) ((1.9 * 42.3) / 25.4); /* ~3.16 */
symbol->row_height[1] = (float) ((1.3 * 42.3) / 25.4); /* ~2.16 */
/* Note using max X for minimum and min X for maximum */
error_number = daft_set_height(symbol, (float) ((4.22 * 39) / 25.4), (float) ((5.84 * 47) / 25.4));
#else
symbol->row_height[0] = 4.0f;
symbol->row_height[1] = 2.0f;
daft_set_height(symbol, 0.0f, 0.0f);
#endif
symbol->rows = 3;
symbol->width = j - 1;
return error_number;
}

700
3rdparty/zint-2.10.0/backend/maxicode.c vendored Normal file
View File

@@ -0,0 +1,700 @@
/* maxicode.c - Handles Maxicode */
/*
libzint - the open source barcode library
Copyright (C) 2010-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* Includes corrections thanks to Monica Swanson @ Source Technologies */
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#include "maxicode.h"
#include "reedsol.h"
/* Handles error correction of primary message */
static void maxi_do_primary_check(unsigned char maxi_codeword[144]) {
unsigned char results[15];
int j;
int datalen = 10;
int ecclen = 10;
rs_t rs;
rs_init_gf(&rs, 0x43);
rs_init_code(&rs, ecclen, 1);
rs_encode(&rs, datalen, maxi_codeword, results);
for (j = 0; j < ecclen; j += 1)
maxi_codeword[ datalen + j] = results[ecclen - 1 - j];
}
/* Handles error correction of odd characters in secondary */
static void maxi_do_secondary_chk_odd(unsigned char maxi_codeword[144], const int ecclen) {
unsigned char data[100];
unsigned char results[30];
int j;
int datalen = 68;
rs_t rs;
rs_init_gf(&rs, 0x43);
rs_init_code(&rs, ecclen, 1);
if (ecclen == 20)
datalen = 84;
for (j = 1; j < datalen; j += 2)
data[(j - 1) / 2] = maxi_codeword[j + 20];
rs_encode(&rs, datalen / 2, data, results);
for (j = 0; j < (ecclen); j += 1)
maxi_codeword[ datalen + (2 * j) + 1 + 20 ] = results[ecclen - 1 - j];
}
/* Handles error correction of even characters in secondary */
static void maxi_do_secondary_chk_even(unsigned char maxi_codeword[144], const int ecclen) {
unsigned char data[100];
unsigned char results[30];
int j;
int datalen = 68;
rs_t rs;
if (ecclen == 20)
datalen = 84;
rs_init_gf(&rs, 0x43);
rs_init_code(&rs, ecclen, 1);
for (j = 0; j < datalen + 1; j += 2)
data[j / 2] = maxi_codeword[j + 20];
rs_encode(&rs, datalen / 2, data, results);
for (j = 0; j < (ecclen); j += 1)
maxi_codeword[ datalen + (2 * j) + 20] = results[ecclen - 1 - j];
}
/* Moves everything up so that a shift or latch can be inserted */
static void maxi_bump(unsigned char set[], unsigned char character[], const int bump_posn, int *p_length) {
if (bump_posn < 143) {
memmove(set + bump_posn + 1, set + bump_posn, 143 - bump_posn);
memmove(character + bump_posn + 1, character + bump_posn, 143 - bump_posn);
}
(*p_length)++; /* Increment length regardless to make sure too long always triggered */
}
/* If the value is present in array, return the value, else return badvalue */
static int value_in_array(const unsigned char val, const unsigned char arr[], const int badvalue,
const int arrLength) {
int i;
for (i = 0; i < arrLength; i++) {
if (arr[i] == val) return val;
}
return badvalue;
}
/* Choose the best set from previous and next set in the range of the setval array, if no value can be found we
* return setval[0] */
static int bestSurroundingSet(const int index, const int length, const unsigned char set[],
const unsigned char setval[], const int setLength) {
int badValue = -1;
int option1 = value_in_array(set[index - 1], setval, badValue, setLength);
if (index + 1 < length) {
// we have two options to check (previous & next)
int option2 = value_in_array(set[index + 1], setval, badValue, setLength);
if (option2 != badValue && option1 > option2) {
return option2;
}
}
if (option1 != badValue) {
return option1;
}
return setval[0];
}
/* Format text according to Appendix A */
static int maxi_text_process(unsigned char maxi_codeword[144], const int mode, const unsigned char in_source[],
int length, const int eci, const int scm_vv, const int debug_print) {
unsigned char set[144], character[144] = {0};
int i, count, current_set, padding_set;
static const unsigned char set15[2] = { 1, 5 };
static const unsigned char set12[2] = { 1, 2 };
static const unsigned char set12345[5] = { 1, 2, 3, 4, 5 };
const unsigned char *source = in_source;
#ifndef _MSC_VER
unsigned char source_buf[length + 9]; /* For prefixing 9-character SCM sequence */
#else
unsigned char *source_buf = (unsigned char *) _alloca(length + 9);
#endif
if (length > 144) {
return ZINT_ERROR_TOO_LONG;
}
if (scm_vv != -1) { /* Add SCM prefix */
if (length > 135) {
return ZINT_ERROR_TOO_LONG;
}
sprintf((char *) source_buf, "[)>\03601\035%02d", scm_vv); /* [)>\R01\Gvv */
memcpy(source_buf + 9, in_source, length);
source = source_buf;
length += 9;
}
memset(set, 255, 144);
for (i = 0; i < length; i++) {
/* Look up characters in table from Appendix A - this gives
value and code set for most characters */
set[i] = maxiCodeSet[source[i]];
character[i] = maxiSymbolChar[source[i]];
}
/* If a character can be represented in more than one code set,
pick which version to use */
if (set[0] == 0) {
if (character[0] == 13) {
character[0] = 0;
}
set[0] = 1;
}
for (i = 1; i < length; i++) {
if (set[i] == 0) {
/* Special character */
if (character[i] == 13) {
/* Carriage Return */
set[i] = bestSurroundingSet(i, length, set, set15, 2);
if (set[i] == 5) {
character[i] = 13;
} else {
character[i] = 0;
}
} else if (character[i] == 28) {
/* FS */
set[i] = bestSurroundingSet(i, length, set, set12345, 5);
if (set[i] == 5) {
character[i] = 32;
}
} else if (character[i] == 29) {
/* GS */
set[i] = bestSurroundingSet(i, length, set, set12345, 5);
if (set[i] == 5) {
character[i] = 33;
}
} else if (character[i] == 30) {
/* RS */
set[i] = bestSurroundingSet(i, length, set, set12345, 5);
if (set[i] == 5) {
character[i] = 34;
}
} else if (character[i] == 32) {
/* Space */
set[i] = bestSurroundingSet(i, length, set, set12345, 5);
if (set[i] == 1) {
character[i] = 32;
} else if (set[i] == 2) {
character[i] = 47;
} else {
character[i] = 59;
}
} else if (character[i] == 44) {
/* Comma */
set[i] = bestSurroundingSet(i, length, set, set12, 2);
if (set[i] == 2) {
character[i] = 48;
}
} else if (character[i] == 46) {
/* Full Stop */
set[i] = bestSurroundingSet(i, length, set, set12, 2);
if (set[i] == 2) {
character[i] = 49;
}
} else if (character[i] == 47) {
/* Slash */
set[i] = bestSurroundingSet(i, length, set, set12, 2);
if (set[i] == 2) {
character[i] = 50;
}
} else if (character[i] == 58) {
/* Colon */
set[i] = bestSurroundingSet(i, length, set, set12, 2);
if (set[i] == 2) {
character[i] = 51;
}
}
}
}
padding_set = set[length - 1] == 2 ? 2 : 1;
for (i = length; i < 144; i++) {
/* Add the padding */
set[i] = padding_set;
character[i] = 33;
}
/* Find candidates for number compression */
/* Note the prohibition on number compression in the primary message in ISO/IEC 16023:2000 B.1 (1)
applies to modes 2 & 3 only */
count = 0;
for (i = 0; i < 144; i++) {
if ((set[i] == 1) && ((character[i] >= 48) && (character[i] <= 57))) {
/* Character is a number */
count++;
if (count == 9) {
/* Nine digits in a row can be compressed */
memset(set + i - 8, 6, 9); /* Set set of nine digits to 6 */
count = 0;
}
} else {
count = 0;
}
}
/* Add shift and latch characters */
current_set = 1;
i = 0;
do {
if ((set[i] != current_set) && (set[i] != 6)) {
switch (set[i]) {
case 1:
if (current_set == 2) { /* Set B */
if (i + 1 < 144 && set[i + 1] == 1) {
if (i + 2 < 144 && set[i + 2] == 1) {
if (i + 3 < 144 && set[i + 3] == 1) {
/* Latch A */
maxi_bump(set, character, i, &length);
character[i] = 63; /* Set B Latch A */
current_set = 1;
i += 3; /* Next 3 Set A so skip over */
if (debug_print) printf("LCHA ");
} else {
/* 3 Shift A */
maxi_bump(set, character, i, &length);
character[i] = 57; /* Set B triple shift A */
i += 2; /* Next 2 Set A so skip over */
if (debug_print) printf("3SHA ");
}
} else {
/* 2 Shift A */
maxi_bump(set, character, i, &length);
character[i] = 56; /* Set B double shift A */
i++; /* Next Set A so skip over */
if (debug_print) printf("2SHA ");
}
} else {
/* Shift A */
maxi_bump(set, character, i, &length);
character[i] = 59; /* Set A Shift B */
if (debug_print) printf("SHA ");
}
} else { /* All sets other than B only have latch */
/* Latch A */
maxi_bump(set, character, i, &length);
character[i] = 58; /* Sets C,D,E Latch A */
current_set = 1;
if (debug_print) printf("LCHA ");
}
break;
case 2: /* Set B */
if (current_set != 1 || (i + 1 < 144 && set[i + 1] == 2)) { /* If not Set A or next Set B */
/* Latch B */
maxi_bump(set, character, i, &length);
character[i] = 63; /* Sets A,C,D,E Latch B */
current_set = 2;
if (debug_print) printf("LCHB ");
} else { /* Only available from Set A */
/* Shift B */
maxi_bump(set, character, i, &length);
character[i] = 59; /* Set B Shift A */
if (debug_print) printf("SHB ");
}
break;
case 3: /* Set C */
case 4: /* Set D */
case 5: /* Set E */
/* If first and next 3 same set, or not first and previous and next 2 same set */
if ((i == 0 && i + 3 < 144 && set[i + 1] == set[i] && set[i + 2] == set[i]
&& set[i + 3] == set[i])
|| (i > 0 && set[i - 1] == set[i] && i + 2 < 144 && set[i + 1] == set[i]
&& set[i + 2] == set[i])) {
/* Lock in C/D/E */
if (i == 0) {
maxi_bump(set, character, i, &length);
character[i] = 60 + set[i] - 3;
i++; /* Extra bump */
maxi_bump(set, character, i, &length);
character[i] = 60 + set[i] - 3;
i += 3; /* Next 3 same set so skip over */
} else {
/* Add single Shift to previous Shift */
maxi_bump(set, character, i - 1, &length);
character[i - 1] = 60 + set[i] - 3;
i += 2; /* Next 2 same set so skip over */
}
current_set = set[i];
if (debug_print) printf("LCK%c ", 'C' + set[i] - 3);
} else {
/* Shift C/D/E */
maxi_bump(set, character, i, &length);
character[i] = 60 + set[i] - 3;
if (debug_print) printf("SH%c ", 'C' + set[i] - 3);
}
break;
}
i++; /* Allow for bump */
}
i++;
} while (i < 144);
if (debug_print) printf("\n");
/* Number compression has not been forgotten! - It's handled below */
i = 0;
do {
if (set[i] == 6) {
/* Number compression */
int value = to_int(character + i, 9);
character[i] = 31; /* NS */
character[i + 1] = (value & 0x3f000000) >> 24;
character[i + 2] = (value & 0xfc0000) >> 18;
character[i + 3] = (value & 0x3f000) >> 12;
character[i + 4] = (value & 0xfc0) >> 6;
character[i + 5] = (value & 0x3f);
i += 6;
memmove(set + i, set + i + 3, 141 - i);
memmove(character + i, character + i + 3, 141 - i);
length -= 3;
} else {
i++;
}
} while (i <= 135); /* 144 - 9 */
/* Insert ECI at the beginning of message if needed */
/* Encode ECI assignment numbers according to table 3 */
if (eci != 0) {
maxi_bump(set, character, 0, &length);
character[0] = 27; // ECI
if (eci <= 31) {
maxi_bump(set, character, 1, &length);
character[1] = eci;
} else if (eci <= 1023) {
maxi_bump(set, character, 1, &length);
maxi_bump(set, character, 1, &length);
character[1] = 0x20 | ((eci >> 6) & 0x0F);
character[2] = eci & 0x3F;
} else if (eci <= 32767) {
maxi_bump(set, character, 1, &length);
maxi_bump(set, character, 1, &length);
maxi_bump(set, character, 1, &length);
character[1] = 0x30 | ((eci >> 12) & 0x07);
character[2] = (eci >> 6) & 0x3F;
character[3] = eci & 0x3F;
} else {
maxi_bump(set, character, 1, &length);
maxi_bump(set, character, 1, &length);
maxi_bump(set, character, 1, &length);
maxi_bump(set, character, 1, &length);
character[1] = 0x38 | ((eci >> 18) & 0x03);
character[2] = (eci >> 12) & 0x3F;
character[3] = (eci >> 6) & 0x3F;
character[4] = eci & 0x3F;
}
}
if (debug_print) printf("Length: %d\n", length);
if (((mode == 2) || (mode == 3)) && (length > 84)) {
return ZINT_ERROR_TOO_LONG;
} else if (((mode == 4) || (mode == 6)) && (length > 93)) {
return ZINT_ERROR_TOO_LONG;
} else if ((mode == 5) && (length > 77)) {
return ZINT_ERROR_TOO_LONG;
}
/* Copy the encoded text into the codeword array */
if ((mode == 2) || (mode == 3)) {
for (i = 0; i < 84; i++) { /* secondary only */
maxi_codeword[i + 20] = character[i];
}
} else if ((mode == 4) || (mode == 6)) {
for (i = 0; i < 9; i++) { /* primary */
maxi_codeword[i + 1] = character[i];
}
for (i = 0; i < 84; i++) { /* secondary */
maxi_codeword[i + 20] = character[i + 9];
}
} else { /* Mode 5 */
for (i = 0; i < 9; i++) { /* primary */
maxi_codeword[i + 1] = character[i];
}
for (i = 0; i < 68; i++) { /* secondary */
maxi_codeword[i + 20] = character[i + 9];
}
}
return 0;
}
/* Format structured primary for Mode 2 */
static void maxi_do_primary_2(unsigned char maxi_codeword[144], const unsigned char postcode[],
const int postcode_length, const int country, const int service) {
int postcode_num;
postcode_num = atoi((const char *) postcode);
maxi_codeword[0] = ((postcode_num & 0x03) << 4) | 2;
maxi_codeword[1] = ((postcode_num & 0xfc) >> 2);
maxi_codeword[2] = ((postcode_num & 0x3f00) >> 8);
maxi_codeword[3] = ((postcode_num & 0xfc000) >> 14);
maxi_codeword[4] = ((postcode_num & 0x3f00000) >> 20);
maxi_codeword[5] = ((postcode_num & 0x3c000000) >> 26) | ((postcode_length & 0x3) << 4);
maxi_codeword[6] = ((postcode_length & 0x3c) >> 2) | ((country & 0x3) << 4);
maxi_codeword[7] = (country & 0xfc) >> 2;
maxi_codeword[8] = ((country & 0x300) >> 8) | ((service & 0xf) << 2);
maxi_codeword[9] = ((service & 0x3f0) >> 4);
}
/* Format structured primary for Mode 3 */
static void maxi_do_primary_3(unsigned char maxi_codeword[144], unsigned char postcode[], const int country,
const int service) {
int i;
/* Convert to Code Set A */
for (i = 0; i < 6; i++) {
postcode[i] = maxiSymbolChar[postcode[i]];
}
maxi_codeword[0] = ((postcode[5] & 0x03) << 4) | 3;
maxi_codeword[1] = ((postcode[4] & 0x03) << 4) | ((postcode[5] & 0x3c) >> 2);
maxi_codeword[2] = ((postcode[3] & 0x03) << 4) | ((postcode[4] & 0x3c) >> 2);
maxi_codeword[3] = ((postcode[2] & 0x03) << 4) | ((postcode[3] & 0x3c) >> 2);
maxi_codeword[4] = ((postcode[1] & 0x03) << 4) | ((postcode[2] & 0x3c) >> 2);
maxi_codeword[5] = ((postcode[0] & 0x03) << 4) | ((postcode[1] & 0x3c) >> 2);
maxi_codeword[6] = ((postcode[0] & 0x3c) >> 2) | ((country & 0x3) << 4);
maxi_codeword[7] = (country & 0xfc) >> 2;
maxi_codeword[8] = ((country & 0x300) >> 8) | ((service & 0xf) << 2);
maxi_codeword[9] = ((service & 0x3f0) >> 4);
}
INTERNAL int maxicode(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, j, block, shift, mode, lp = 0;
int error_number = 0, eclen;
unsigned char maxi_codeword[144] = {0};
int scm_vv = -1;
mode = symbol->option_1;
if (mode <= 0) { /* If mode is unspecified (-1) or to be auto-determined (0) between 2 and 3 */
lp = (int) strlen(symbol->primary);
if (lp == 0) {
if (mode == 0) { /* Require primary message to auto-determine between 2 and 3 */
strcpy(symbol->errtxt, "554: Primary Message empty");
return ZINT_ERROR_INVALID_DATA;
}
mode = 4;
} else {
mode = 2;
for (i = 0; i < lp - 6; i++) {
if (((symbol->primary[i] < '0') || (symbol->primary[i] > '9')) && (symbol->primary[i] != ' ')) {
mode = 3;
break;
}
}
}
}
if ((mode < 2) || (mode > 6)) { /* Only codes 2 to 6 supported */
strcpy(symbol->errtxt, "550: Invalid MaxiCode Mode");
return ZINT_ERROR_INVALID_OPTION;
}
if ((mode == 2) || (mode == 3)) { /* Modes 2 and 3 need data in symbol->primary */
unsigned char postcode[10];
int countrycode;
int service;
int postcode_len;
if (lp == 0) { /* Mode set manually means lp doesn't get set */
lp = (int) strlen(symbol->primary);
}
if (lp < 7 || lp > 15) { /* 1 to 9 character postcode + 3 digit country code + 3 digit service class */
strcpy(symbol->errtxt, "551: Invalid length for Primary Message");
return ZINT_ERROR_INVALID_DATA;
}
postcode_len = lp - 6;
countrycode = to_int((const unsigned char *) (symbol->primary + postcode_len), 3);
service = to_int((const unsigned char *) (symbol->primary + postcode_len + 3), 3);
if (countrycode == -1 || service == -1) { /* check that country code and service are numeric */
strcpy(symbol->errtxt, "552: Non-numeric country code or service class in Primary Message");
return ZINT_ERROR_INVALID_DATA;
}
memcpy(postcode, symbol->primary, postcode_len);
postcode[postcode_len] = '\0';
if (mode == 2) {
for (i = 0; i < postcode_len; i++) {
if (postcode[i] == ' ') {
postcode[i] = '\0';
postcode_len = i;
break;
} else if (postcode[i] < '0' || postcode[i] > '9') {
strcpy(symbol->errtxt, "555: Non-numeric postcode in Primary Message");
return ZINT_ERROR_INVALID_DATA;
}
}
maxi_do_primary_2(maxi_codeword, postcode, postcode_len, countrycode, service);
} else {
/* Just truncate and space-pad */
postcode[6] = '\0';
for (i = postcode_len; i < 6; i++) {
postcode[i] = ' ';
}
/* Upper-case and check for Code Set A characters only */
to_upper(postcode);
for (i = 0; i < 6; i++) {
/* Don't allow Code Set A control characters CR, RS, GS and RS */
if (postcode[i] < ' ' || maxiCodeSet[postcode[i]] > 1) {
strcpy(symbol->errtxt, "556: Invalid character in postcode in Primary Message");
return ZINT_ERROR_INVALID_DATA;
}
}
maxi_do_primary_3(maxi_codeword, postcode, countrycode, service);
}
if (symbol->option_2) { /* Check for option_2 = vv + 1, where vv is version of SCM prefix "[)>\R01\Gvv" */
if (symbol->option_2 < 0 || symbol->option_2 > 100) {
strcpy(symbol->errtxt, "557: Invalid SCM prefix version");
return ZINT_ERROR_INVALID_OPTION;
}
scm_vv = symbol->option_2 - 1;
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Postcode: %s, Country Code: %d, Service Class: %d\n", postcode, countrycode, service);
}
} else {
maxi_codeword[0] = mode;
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Mode: %d\n", mode);
}
i = maxi_text_process(maxi_codeword, mode, source, length, symbol->eci, scm_vv, symbol->debug & ZINT_DEBUG_PRINT);
if (i == ZINT_ERROR_TOO_LONG) {
strcpy(symbol->errtxt, "553: Input data too long");
return i;
}
/* All the data is sorted - now do error correction */
maxi_do_primary_check(maxi_codeword); /* always EEC */
if (mode == 5)
eclen = 56; // 68 data codewords , 56 error corrections
else
eclen = 40; // 84 data codewords, 40 error corrections
maxi_do_secondary_chk_even(maxi_codeword, eclen / 2); // do error correction of even
maxi_do_secondary_chk_odd(maxi_codeword, eclen / 2); // do error correction of odd
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Codewords:");
for (i = 0; i < 144; i++) printf(" %d", maxi_codeword[i]);
printf("\n");
}
#ifdef ZINT_TEST
if (symbol->debug & ZINT_DEBUG_TEST) {
debug_test_codeword_dump(symbol, maxi_codeword, 144);
}
#endif
/* Copy data into symbol grid */
for (i = 0; i < 33; i++) {
for (j = 0; j < 30; j++) {
block = (MaxiGrid[(i * 30) + j] + 5) / 6;
if (block != 0) {
shift = 5 - ((MaxiGrid[(i * 30) + j] + 5) % 6);
if ((maxi_codeword[block - 1] >> shift) & 0x1) {
set_module(symbol, i, j);
}
}
}
}
/* Add orientation markings */
set_module(symbol, 0, 28); // Top right filler
set_module(symbol, 0, 29);
set_module(symbol, 9, 10); // Top left marker
set_module(symbol, 9, 11);
set_module(symbol, 10, 11);
set_module(symbol, 15, 7); // Left hand marker
set_module(symbol, 16, 8);
set_module(symbol, 16, 20); // Right hand marker
set_module(symbol, 17, 20);
set_module(symbol, 22, 10); // Bottom left marker
set_module(symbol, 23, 10);
set_module(symbol, 22, 17); // Bottom right marker
set_module(symbol, 23, 17);
symbol->width = 30;
symbol->rows = 33;
/* Note MaxiCode fixed size so symbol height ignored but set anyway */
(void) set_height(symbol, 5.0f, 0.0f, 0.0f, 1 /*no_errtxt*/);
return error_number;
}

104
3rdparty/zint-2.10.0/backend/maxicode.h vendored Normal file
View File

@@ -0,0 +1,104 @@
/* maxicode.h - Handles Maxicode */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
static const unsigned short 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,
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,
284, 283, 278, 277, 272, 271, 266, 265, 260, 259, 254, 253, 248, 247, 242, 241, 236, 235, 230, 229, 224, 223, 218, 217, 212, 211, 206, 205, 820, 0,
286, 285, 280, 279, 274, 273, 268, 267, 262, 261, 256, 255, 250, 249, 244, 243, 238, 237, 232, 231, 226, 225, 220, 219, 214, 213, 208, 207, 822, 821,
288, 287, 282, 281, 276, 275, 270, 269, 264, 263, 258, 257, 252, 251, 246, 245, 240, 239, 234, 233, 228, 227, 222, 221, 216, 215, 210, 209, 823, 0,
290, 289, 296, 295, 302, 301, 308, 307, 314, 313, 320, 319, 326, 325, 332, 331, 338, 337, 344, 343, 350, 349, 356, 355, 362, 361, 368, 367, 825, 824,
292, 291, 298, 297, 304, 303, 310, 309, 316, 315, 322, 321, 328, 327, 334, 333, 340, 339, 346, 345, 352, 351, 358, 357, 364, 363, 370, 369, 826, 0,
294, 293, 300, 299, 306, 305, 312, 311, 318, 317, 324, 323, 330, 329, 336, 335, 342, 341, 348, 347, 354, 353, 360, 359, 366, 365, 372, 371, 828, 827,
410, 409, 404, 403, 398, 397, 392, 391, 80, 79, 0, 0, 14, 13, 38, 37, 3, 0, 45, 44, 110, 109, 386, 385, 380, 379, 374, 373, 829, 0,
412, 411, 406, 405, 400, 399, 394, 393, 82, 81, 41, 0, 16, 15, 40, 39, 4, 0, 0, 46, 112, 111, 388, 387, 382, 381, 376, 375, 831, 830,
414, 413, 408, 407, 402, 401, 396, 395, 84, 83, 42, 0, 0, 0, 0, 0, 6, 5, 48, 47, 114, 113, 390, 389, 384, 383, 378, 377, 832, 0,
416, 415, 422, 421, 428, 427, 104, 103, 56, 55, 17, 0, 0, 0, 0, 0, 0, 0, 21, 20, 86, 85, 434, 433, 440, 439, 446, 445, 834, 833,
418, 417, 424, 423, 430, 429, 106, 105, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 23, 22, 88, 87, 436, 435, 442, 441, 448, 447, 835, 0,
420, 419, 426, 425, 432, 431, 108, 107, 60, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 90, 89, 438, 437, 444, 443, 450, 449, 837, 836,
482, 481, 476, 475, 470, 469, 49, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 54, 53, 464, 463, 458, 457, 452, 451, 838, 0,
484, 483, 478, 477, 472, 471, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 466, 465, 460, 459, 454, 453, 840, 839,
486, 485, 480, 479, 474, 473, 52, 51, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 43, 468, 467, 462, 461, 456, 455, 841, 0,
488, 487, 494, 493, 500, 499, 98, 97, 62, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 92, 91, 506, 505, 512, 511, 518, 517, 843, 842,
490, 489, 496, 495, 502, 501, 100, 99, 64, 63, 0, 0, 0, 0, 0, 0, 0, 0, 29, 28, 94, 93, 508, 507, 514, 513, 520, 519, 844, 0,
492, 491, 498, 497, 504, 503, 102, 101, 66, 65, 18, 0, 0, 0, 0, 0, 0, 0, 19, 30, 96, 95, 510, 509, 516, 515, 522, 521, 846, 845,
560, 559, 554, 553, 548, 547, 542, 541, 74, 73, 33, 0, 0, 0, 0, 0, 0, 11, 68, 67, 116, 115, 536, 535, 530, 529, 524, 523, 847, 0,
562, 561, 556, 555, 550, 549, 544, 543, 76, 75, 0, 0, 8, 7, 36, 35, 12, 0, 70, 69, 118, 117, 538, 537, 532, 531, 526, 525, 849, 848,
564, 563, 558, 557, 552, 551, 546, 545, 78, 77, 0, 34, 10, 9, 26, 25, 0, 0, 72, 71, 120, 119, 540, 539, 534, 533, 528, 527, 850, 0,
566, 565, 572, 571, 578, 577, 584, 583, 590, 589, 596, 595, 602, 601, 608, 607, 614, 613, 620, 619, 626, 625, 632, 631, 638, 637, 644, 643, 852, 851,
568, 567, 574, 573, 580, 579, 586, 585, 592, 591, 598, 597, 604, 603, 610, 609, 616, 615, 622, 621, 628, 627, 634, 633, 640, 639, 646, 645, 853, 0,
570, 569, 576, 575, 582, 581, 588, 587, 594, 593, 600, 599, 606, 605, 612, 611, 618, 617, 624, 623, 630, 629, 636, 635, 642, 641, 648, 647, 855, 854,
728, 727, 722, 721, 716, 715, 710, 709, 704, 703, 698, 697, 692, 691, 686, 685, 680, 679, 674, 673, 668, 667, 662, 661, 656, 655, 650, 649, 856, 0,
730, 729, 724, 723, 718, 717, 712, 711, 706, 705, 700, 699, 694, 693, 688, 687, 682, 681, 676, 675, 670, 669, 664, 663, 658, 657, 652, 651, 858, 857,
732, 731, 726, 725, 720, 719, 714, 713, 708, 707, 702, 701, 696, 695, 690, 689, 684, 683, 678, 677, 672, 671, 666, 665, 660, 659, 654, 653, 859, 0,
734, 733, 740, 739, 746, 745, 752, 751, 758, 757, 764, 763, 770, 769, 776, 775, 782, 781, 788, 787, 794, 793, 800, 799, 806, 805, 812, 811, 861, 860,
736, 735, 742, 741, 748, 747, 754, 753, 760, 759, 766, 765, 772, 771, 778, 777, 784, 783, 790, 789, 796, 795, 802, 801, 808, 807, 814, 813, 862, 0,
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
};
static const char 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) */
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,
1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2,
2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 4, 5, 5, 5, 5, 5, 5, 4, 5, 3, 4, 3, 5, 5, 4, 4, 3, 3, 3,
4, 3, 5, 4, 4, 3, 3, 4, 3, 3, 3, 4, 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, 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
};
static const char 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,
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,
38, 39, 40, 41, 52, 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, 42, 43, 44, 45, 46, 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, 32, 54, 34, 35, 36, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 36,
37, 37, 38, 39, 40, 41, 42, 43, 38, 44, 37, 39, 38, 45, 46, 40, 41, 39, 40, 41,
42, 42, 47, 43, 44, 43, 44, 45, 45, 46, 47, 46, 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, 32,
33, 34, 35, 36, 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, 32, 33, 34, 35, 36
};

384
3rdparty/zint-2.10.0/backend/medical.c vendored Normal file
View File

@@ -0,0 +1,384 @@
/* medical.c - Handles 1 track and 2 track pharmacode and Codabar */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include "common.h"
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length);
/* Codabar table checked against EN 798:1995 */
#define CALCIUM "0123456789-$:/.+ABCD"
#define CALCIUM_INNER "0123456789-$:/.+"
static const char *CodaTable[20] = {
"11111221", "11112211", "11121121", "22111111", "11211211", "21111211",
"12111121", "12112111", "12211111", "21121111", "11122111", "11221111", "21112121", "21211121",
"21212111", "11212121", "11221211", "12121121", "11121221", "11122211"
};
INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length) {
/* "Pharmacode can represent only a single integer from 3 to 131070. Unlike other
commonly used one-dimensional barcode schemes, pharmacode does not store the data in a
form corresponding to the human-readable digits; the number is encoded in binary, rather
than decimal. Pharmacode is read from right to left: with n as the bar position starting
at 0 on the right, each narrow bar adds 2n to the value and each wide bar adds 2(2^n).
The minimum barcode is 2 bars and the maximum 16, so the smallest number that could
be encoded is 3 (2 narrow bars) and the biggest is 131070 (16 wide bars)."
- http://en.wikipedia.org/wiki/Pharmacode */
/* This code uses the One Track Pharamacode calculating algorithm as recommended by
the specification at http://www.laetus.com/laetus.php?request=file&id=69
(http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf) */
unsigned long int tester;
int counter, error_number, h;
char inter[18] = {0}; /* 131070 -> 17 bits */
char dest[64]; /* 17 * 2 + 1 */
if (length > 6) {
strcpy(symbol->errtxt, "350: Input too long (6 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "351: Invalid character in data (digits only)");
return error_number;
}
tester = atoi((char *) source);
if ((tester < 3) || (tester > 131070)) {
strcpy(symbol->errtxt, "352: Data out of range (3 to 131070)");
return ZINT_ERROR_INVALID_DATA;
}
do {
if (!(tester & 1)) {
strcat(inter, "W");
tester = (tester - 2) / 2;
} else {
strcat(inter, "N");
tester = (tester - 1) / 2;
}
} while (tester != 0);
h = (int) strlen(inter) - 1;
*dest = '\0';
for (counter = h; counter >= 0; counter--) {
if (inter[counter] == 'W') {
strcat(dest, "32");
} else {
strcat(dest, "12");
}
}
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
/* Laetus Pharmacode Guide 1.2 Standard one-track height 8mm / 0.5mm (X) */
error_number = set_height(symbol, 16.0f, 0.0f, 0.0f, 0 /*no_errtxt*/);
#else
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
return error_number;
}
static int pharma_two_calc(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
/* This code uses the Two Track Pharamacode defined in the document at
http://www.laetus.com/laetus.php?request=file&id=69 and using a modified
algorithm from the One Track system. This standard accepts integet values
from 4 to 64570080. */
unsigned long int tester;
int counter, h;
char inter[17];
int error_number;
tester = atoi((char *) source);
if ((tester < 4) || (tester > 64570080)) {
strcpy(symbol->errtxt, "353: Data out of range (4 to 64570080)");
return ZINT_ERROR_INVALID_DATA;
}
error_number = 0;
strcpy(inter, "");
do {
switch (tester % 3) {
case 0:
strcat(inter, "3");
tester = (tester - 3) / 3;
break;
case 1:
strcat(inter, "1");
tester = (tester - 1) / 3;
break;
case 2:
strcat(inter, "2");
tester = (tester - 2) / 3;
break;
}
} while (tester != 0);
h = (int) strlen(inter) - 1;
for (counter = h; counter >= 0; counter--) {
dest[h - counter] = inter[counter];
}
dest[h + 1] = '\0';
return error_number;
}
INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int length) {
/* Draws the patterns for two track pharmacode */
char height_pattern[200];
unsigned int loopey, h;
int writer;
int error_number;
strcpy(height_pattern, "");
if (length > 8) {
strcpy(symbol->errtxt, "354: Input too long (8 character maximum");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "355: Invalid character in data (digits only)");
return error_number;
}
error_number = pharma_two_calc(symbol, source, height_pattern);
if (error_number != 0) {
return error_number;
}
writer = 0;
h = (int) strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((height_pattern[loopey] == '2') || (height_pattern[loopey] == '3')) {
set_module(symbol, 0, writer);
}
if ((height_pattern[loopey] == '1') || (height_pattern[loopey] == '3')) {
set_module(symbol, 1, writer);
}
writer += 2;
}
symbol->rows = 2;
symbol->width = writer - 1;
#ifdef COMPLIANT_HEIGHTS
/* Laetus Pharmacode Guide 1.4
Two-track height min 8mm / 2mm (X max) = 4, standard 8mm / 1mm = 8, max 12mm / 0.8mm (X min) = 15 */
error_number = set_height(symbol, 2.0f, 8.0f, 15.0f, 0 /*no_errtxt*/);
#else
(void) set_height(symbol, 0.0f, 10.0f, 0.0f, 1 /*no_errtxt*/);
#endif
return error_number;
}
/* The Codabar system consisting of simple substitution */
INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
char dest[512];
int add_checksum, count = 0, checksum;
int d_chars = 0;
float height;
strcpy(dest, "");
if (length > 60) { /* No stack smashing please */
strcpy(symbol->errtxt, "356: Input too long (60 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
/* BS EN 798:1995 4.2 "'Codabar' symbols shall consist of ... b) start character;
c) one or more symbol characters representing data ... d) stop character ..." */
if (length < 3) {
strcpy(symbol->errtxt, "362: Input too short (3 character minimum)");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
/* Codabar must begin and end with the characters A, B, C or D */
if ((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C')
&& (source[0] != 'D')) {
strcpy(symbol->errtxt, "358: Does not begin with \"A\", \"B\", \"C\" or \"D\"");
return ZINT_ERROR_INVALID_DATA;
}
if ((source[length - 1] != 'A') && (source[length - 1] != 'B') &&
(source[length - 1] != 'C') && (source[length - 1] != 'D')) {
strcpy(symbol->errtxt, "359: Does not end with \"A\", \"B\", \"C\" or \"D\"");
return ZINT_ERROR_INVALID_DATA;
}
/* And must not use A, B, C or D otherwise (BS EN 798:1995 4.3.2) */
error_number = is_sane(CALCIUM_INNER, source + 1, length - 2);
if (error_number) {
if (is_sane(CALCIUM, source + 1, length - 2) == 0) {
strcpy(symbol->errtxt, "363: Cannot contain \"A\", \"B\", \"C\" or \"D\"");
} else {
sprintf(symbol->errtxt, "357: Invalid character in data (\"%s\" only)", CALCIUM);
}
return error_number;
}
add_checksum = symbol->option_2 == 1;
for (i = 0; i < length; i++) {
static const char calcium[] = CALCIUM;
if (add_checksum) {
count += strchr(calcium, source[i]) - calcium;
if (i + 1 == length) {
checksum = count % 16;
if (checksum) {
checksum = 16 - checksum;
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Codabar: %s, count %d, checksum %d\n", source, count, checksum);
}
strcat(dest, CodaTable[checksum]);
}
}
lookup(calcium, CodaTable, source[i], dest);
if (source[i] == '/' || source[i] == ':' || source[i] == '.' || source[i] == '+') { /* Wide data characters */
d_chars++;
}
}
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
/* BS EN 798:1995 4.4.1 (d) max of 5mm / 0.191mm (X) ~ 26.178 or 15% of width where (taking N = narrow/wide ratio
as 2 and I = X) width = ((2 * N + 5) * C + (N 1) * (D + 2)) * X + I * (C 1) + 2Q
= ((4 + 5) * C + (D + 2) + C - 1 + 2 * 10) * X = (10 * C + D + 21) * X
Length (C) includes start/stop chars */
height = (float) ((10.0 * ((add_checksum ? length + 1 : length) + 2.0) + d_chars + 21.0) * 0.15);
if (height < (float) (5.0 / 0.191)) {
height = (float) (5.0 / 0.191);
}
/* Using 50 as default as none recommended */
error_number = set_height(symbol, height, height > 50.0f ? height : 50.0f, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
ustrcpy(symbol->text, source);
return error_number;
}
/* Italian Pharmacode */
INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, zeroes, error_number = 0, checksum, checkpart, checkdigit;
char localstr[10], risultante[7];
long int pharmacode, devisor;
int codeword[6];
char tabella[34];
/* Validate the input */
if (length > 8) {
strcpy(symbol->errtxt, "360: Input too long (8 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "361: Invalid character in data (digits only)");
return error_number;
}
/* Add leading zeros as required */
zeroes = 8 - length;
memset(localstr, '0', zeroes);
ustrcpy(localstr + zeroes, source);
/* Calculate the check digit */
checksum = 0;
for (i = 0; i < 4; i++) {
checkpart = ctoi(localstr[i * 2]);
checksum += checkpart;
checkpart = 2 * (ctoi(localstr[(i * 2) + 1]));
if (checkpart >= 10) {
checksum += (checkpart - 10) + 1;
} else {
checksum += checkpart;
}
}
/* Add check digit to data string */
checkdigit = checksum % 10;
localstr[8] = itoc(checkdigit);
localstr[9] = '\0';
/* Convert string into an integer value */
pharmacode = atoi(localstr);
/* Convert from decimal to base-32 */
devisor = 33554432;
for (i = 5; i >= 0; i--) {
long int remainder;
codeword[i] = pharmacode / devisor;
remainder = pharmacode % devisor;
pharmacode = remainder;
devisor /= 32;
}
/* Look up values in 'Tabella di conversione' */
strcpy(tabella, "0123456789BCDFGHJKLMNPQRSTUVWXYZ");
for (i = 5; i >= 0; i--) {
risultante[5 - i] = tabella[codeword[i]];
}
risultante[6] = '\0';
/* Plot the barcode using Code 39 */
error_number = c39(symbol, (unsigned char *) risultante, (int) strlen(risultante));
if (error_number != 0) { /* Should never happen */
return error_number; /* Not reached */
}
#ifdef COMPLIANT_HEIGHTS
/* Allegato A Caratteristiche tecniche del bollino farmaceutico
https://www.gazzettaufficiale.it/do/atto/serie_generale/caricaPdf?cdimg=14A0566800100010110001&dgu=2014-07-18&art.dataPubblicazioneGazzetta=2014-07-18&art.codiceRedazionale=14A05668&art.num=1&art.tiposerie=SG
X given as 0.250mm; height (and quiet zones) left to ISO/IEC 16388:2007 (Code 39)
So min height 5mm = 5mm / 0.25mm = 20 > 15% of width, i.e. (10 * 8 + 19) * 0.15 = 14.85 */
error_number = set_height(symbol, 20.0f, 20.0f, 0.0f, 0 /*no_errtxt*/); /* Use as default also */
#else
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
/* Override the normal text output with the Pharmacode number */
ustrcpy(symbol->text, "A");
ustrcat(symbol->text, localstr);
return error_number;
}

235
3rdparty/zint-2.10.0/backend/ms_stdint.h vendored Normal file
View File

@@ -0,0 +1,235 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
/* @(#) $Id: ms_stdint.h,v 1.1 2009/09/19 08:16:21 hooper114 Exp $ */
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#if (_MSC_VER < 1300) && defined(__cplusplus)
extern "C++" {
#endif
# include <wchar.h>
#if (_MSC_VER < 1300) && defined(__cplusplus)
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef _W64 int intptr_t;
typedef _W64 unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]

639
3rdparty/zint-2.10.0/backend/output.c vendored Normal file
View File

@@ -0,0 +1,639 @@
/* output.c - Common routines for raster/vector
libzint - the open source barcode library
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <math.h>
#include "common.h"
#include "output.h"
#include "font.h"
#define SSET "0123456789ABCDEF"
/* Check colour options are good. Note: using raster.c error nos 651-654 */
INTERNAL int output_check_colour_options(struct zint_symbol *symbol) {
int error_number;
if ((strlen(symbol->fgcolour) != 6) && (strlen(symbol->fgcolour) != 8)) {
strcpy(symbol->errtxt, "651: Malformed foreground colour target");
return ZINT_ERROR_INVALID_OPTION;
}
if ((strlen(symbol->bgcolour) != 6) && (strlen(symbol->bgcolour) != 8)) {
strcpy(symbol->errtxt, "652: Malformed background colour target");
return ZINT_ERROR_INVALID_OPTION;
}
to_upper((unsigned char *) symbol->fgcolour);
to_upper((unsigned char *) symbol->bgcolour);
error_number = is_sane(SSET, (unsigned char *) symbol->fgcolour, (int) strlen(symbol->fgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "653: Malformed foreground colour target");
return ZINT_ERROR_INVALID_OPTION;
}
error_number = is_sane(SSET, (unsigned char *) symbol->bgcolour, (int) strlen(symbol->bgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "654: Malformed background colour target");
return ZINT_ERROR_INVALID_OPTION;
}
return 0;
}
/* Return minimum quiet zones for each symbology */
static int quiet_zones(struct zint_symbol *symbol, float *left, float *right, float *top, float *bottom) {
int done = 0;
*left = *right = *top = *bottom = 0.0f;
/* These always have quiet zones set (previously used whitespace_width) */
switch (symbol->symbology) {
case BARCODE_CODE16K:
/* BS EN 12323:2005 Section 4.5 (c) */
*left = 10.0f;
*right = 1.0f;
done = 1;
break;
case BARCODE_CODE49:
/* ANSI/AIM BC6-2000 Section 2.4 */
*left = 10.0f;
*right = 1.0f;
done = 1;
break;
case BARCODE_CODABLOCKF:
case BARCODE_HIBC_BLOCKF:
/* AIM ISS-X-24 Section 4.6.1 */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_ITF14:
/* GS1 General Specifications 21.0.1 Section 5.3.2.2 */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_EANX:
case BARCODE_EANX_CHK:
case BARCODE_EANX_CC:
case BARCODE_ISBNX:
/* GS1 General Specifications 21.0.1 Section 5.2.3.4 */
switch (ustrlen(symbol->text)) {
case 13: /* EAN-13 */
*left = 11.0f;
*right = 7.0f;
break;
case 16: /* EAN-13/ISBN + 2 digit addon */
case 19: /* EAN-13/ISBN + 5 digit addon */
*left = 11.0f;
*right = 5.0f;
break;
case 5: /* EAN-5 addon */
case 2: /* EAN-2 addon */
*left = 7.0f;
*right = 5.0f;
break;
default: /* EAN-8 (+/- 2/5 digit addon) */
*left = *right = 7.0f;
break;
}
done = 1;
break;
case BARCODE_UPCA:
case BARCODE_UPCA_CHK:
case BARCODE_UPCA_CC:
/* GS1 General Specifications 21.0.1 Section 5.2.3.4 */
*left = 9.0f;
if (ustrlen(symbol->text) > 12) { /* UPC-A + addon */
*right = 5.0f;
} else {
*right = 9.0f;
}
done = 1;
break;
case BARCODE_UPCE:
case BARCODE_UPCE_CHK:
case BARCODE_UPCE_CC:
/* GS1 General Specifications 21.0.1 Section 5.2.3.4 */
*left = 9.0f;
if (ustrlen(symbol->text) > 8) { /* UPC-E + addon */
*right = 5.0f;
} else {
*right = 7.0f;
}
done = 1;
break;
}
if (done) {
return done;
}
/* Only do others if flag set TODO: finish */
#if 0
if (!(symbol->output_options & BARCODE_QUIET_ZONES)) {
return done;
}
#else
return done;
#endif
switch (symbol->symbology) {
case BARCODE_CODE11:
/* No known standard. Following ITF-14, set to 10X */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_C25INTER:
/* ISO/IEC 16390:2007 Section 4.4 10X */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_C25STANDARD:
case BARCODE_C25IATA:
case BARCODE_C25LOGIC:
case BARCODE_C25IND:
/* No known standards. Following C25INTER, set to 10X */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_CODE39:
case BARCODE_EXCODE39:
case BARCODE_LOGMARS:
case BARCODE_PZN:
case BARCODE_VIN:
case BARCODE_HIBC_39:
case BARCODE_CODE32:
/* ISO/IEC 16388:2007 Section 4.4 (d) */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_GS1_128: /* GS1-128 */
case BARCODE_GS1_128_CC:
case BARCODE_EAN14:
/* GS1 General Specifications 21.0.1 Section 5.4.4.2 */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_CODABAR:
/* BS EN 798:1995 Section 4.4.1 (d) */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_CODE128:
case BARCODE_CODE128B:
case BARCODE_HIBC_128:
case BARCODE_NVE18:
/* ISO/IEC 15417:2007 4.4.2 */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_DPLEIT:
case BARCODE_DPIDENT:
/* Using CODE39 values TODO: Find doc */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_CODE93:
/* ANSI/AIM BC5-1995 Section 2.4 */
*left = *right = 10.0f;
done = 1;
break;
case BARCODE_FLAT:
/* TODO */
break;
case BARCODE_DBAR_OMN: /* GS1 Databar Omnidirectional */
case BARCODE_DBAR_LTD: /* GS1 Databar Limited */
case BARCODE_DBAR_EXP: /* GS1 Databar Expanded */
case BARCODE_DBAR_STK: /* GS1 DataBar Stacked */
case BARCODE_DBAR_OMNSTK: /* GS1 DataBar Stacked Omnidirectional */
case BARCODE_DBAR_EXPSTK: /* GS1 Databar Expanded Stacked */
/* GS1 General Specifications 21.0.1 Section 5.5.1.1 - Quiet Zones: None required */
done = 1;
break;
case BARCODE_DBAR_OMN_CC:
case BARCODE_DBAR_LTD_CC:
case BARCODE_DBAR_EXP_CC:
case BARCODE_DBAR_STK_CC:
case BARCODE_DBAR_OMNSTK_CC:
case BARCODE_DBAR_EXPSTK_CC:
/* GS1 General Specifications 21.0.1 Sections 5.11.2.1 (CC-A) & 5.11.2.2 (CC-B) */
*left = *right = 1.0f;
done = 1;
break;
case BARCODE_TELEPEN:
case BARCODE_TELEPEN_NUM:
/* TODO */
break;
case BARCODE_POSTNET:
case BARCODE_PLANET:
/* USPS DMM 300 2006 (2011) 5.7 Barcode in Address Block
left/right 0.125" / 0.025" (X max) = 5, top/bottom 0.04" / 0.025" (X max) = 1.6 */
*left = *right = 5.0f;
*top = *bottom = 1.6f;
done = 1;
break;
case BARCODE_MSI_PLESSEY:
/* TODO */
break;
case BARCODE_FIM:
/* USPS DMM 300 2006 (2011) 708.9.3 (top/bottom zero)
right 0.125" (min) / 0.03925" (X max) ~ 3.18, left 1.25" - 0.66725" (max width of barcode)
- 0.375 (max right) = 0.20775" / 0.03925" (X max) ~ 5.29 */
*right = (float) (0.125 / 0.03925);
*left = (float) (0.20775 / 0.03925);
done = 1;
break;
case BARCODE_PHARMA:
case BARCODE_PHARMA_TWO:
/* Laetus Pharmacode Guide 2.2 from 6mm depending on context, 6mm / 1mm (Pharma Two X) = 6 */
*left = *right = 6.0f;
done = 1;
break;
case BARCODE_PDF417:
case BARCODE_PDF417COMP:
case BARCODE_HIBC_PDF:
/* ISO/IEC 15438:2015 Section 5.8.3 */
*left = *right = *top = *bottom = 2.0f;
done = 1;
break;
case BARCODE_MICROPDF417:
case BARCODE_HIBC_MICPDF:
/* ISO/IEC 24728:2006 Section 5.8.3 */
*left = *right = *top = *bottom = 1.0f;
done = 1;
break;
case BARCODE_MAXICODE:
/* ISO/IEC 16023:2000 Section 4.11.5 */
*left = *right = *top = *bottom = 1.0f;
done = 1;
break;
case BARCODE_QRCODE:
case BARCODE_UPNQR:
case BARCODE_HIBC_QR:
/* ISO/IEC 18004:2015 Section 9.1 */
*left = *right = *top = *bottom = 4.0f;
done = 1;
break;
case BARCODE_DPD:
/* Specification DPD and primetime Parcel Despatch 4.0.2 Section 5.5.1 5mm / 0.4mm (X max) = 12.5 */
*left = *right = 12.5f;
done = 1;
break;
case BARCODE_MICROQR:
/* ISO/IEC 18004:2015 Section 9.1 */
*left = *right = *top = *bottom = 2.0f;
done = 1;
break;
case BARCODE_RMQR:
/* ISO/IEC JTC1/SC31N000 Section 6.3.10 */
*left = *right = *top = *bottom = 2.0f;
done = 1;
break;
case BARCODE_AUSPOST:
case BARCODE_AUSREPLY:
case BARCODE_AUSROUTE:
case BARCODE_AUSREDIRECT:
/* Customer Barcode Technical Specifications (2012) left/right 6mm / 0.6mm = 10,
top/bottom 2mm / 0.6mm ~ 3.33 (X max) */
*left = *right = 10.0f;
*top = *bottom = (float) (2.0 / 0.6);
done = 1;
break;
case BARCODE_RM4SCC:
/* Royal Mail Know How User's Manual Appendix C: using CBC, same as MAILMARK, 2mm all round,
use X max (25.4mm / 39) i.e. 20 bars per 25.4mm */
*left = *right = *top = *bottom = (float) ((2.0 * 39.0) / 25.4); /* ~ 3.07 */
done = 1;
break;
case BARCODE_DATAMATRIX:
case BARCODE_HIBC_DM:
/* ISO/IEC 16022:2006 Section 7.1 */
*left = *right = *top = *bottom = 1.0f;
done = 1;
break;
case BARCODE_JAPANPOST:
/* Japan Post Zip/Barcode Manual p.13 2mm all round, X 0.6mm, 2mm / 0.6mm ~ 3.33 */
*left = *right = *top = *bottom = (float) (2.0 / 0.6);
done = 1;
break;
case BARCODE_KOREAPOST:
/* TODO */
break;
case BARCODE_USPS_IMAIL:
/* USPS-B-3200 (2015) Section 2.3.2 left/right 0.125", top/bottom 0.026", use X max (1 / 39)
i.e. 20 bars per inch */
*left = *right = 0.125f * 39.0f; /* 4.875 */
*top = *bottom = 0.026f * 39.0f; /* 1.014 */
done = 1;
break;
case BARCODE_PLESSEY:
/* TODO */
break;
case BARCODE_KIX:
/* Handleiding KIX code brochure - same as RM4SCC/MAILMARK */
*left = *right = *top = *bottom = (float) ((2.0 * 39.0) / 25.4); /* ~ 3.07 */
done = 1;
break;
case BARCODE_AZTEC:
case BARCODE_HIBC_AZTEC:
case BARCODE_AZRUNE:
/* ISO/IEC 24778:2008 Section 4.1 (c) & Annex A.1 (Rune) - no quiet zone required */
done = 1;
break;
case BARCODE_DAFT:
/* Generic so unlikely to be defined */
done = 1;
break;
case BARCODE_DOTCODE:
/* ISS DotCode Rev. 4.0 Section 4.1 (3) (c) */
*left = *right = *top = *bottom = 3.0f;
done = 1;
break;
case BARCODE_HANXIN:
/* ISO/IEC DIS 20830:2019 Section 4.2.8 (also Section 6.2) */
*left = *right = *top = *bottom = 3.0f;
done = 1;
break;
case BARCODE_MAILMARK:
/* Royal Mail Mailmark Barcode Definition Document Section 3.5.2, 2mm all round, use X max (25.4mm / 39)
i.e. 20 bars per 25.4mm */
*left = *right = *top = *bottom = (float) ((2.0 * 39.0) / 25.4); /* ~ 3.07 */
done = 1;
break;
case BARCODE_CHANNEL:
/* ANSI/AIM BC12-1998 Section 4.4 (c) */
*left = 1.0f;
*right = 2.0f;
done = 1;
break;
case BARCODE_CODEONE:
/* TODO */
break;
case BARCODE_GRIDMATRIX:
/* AIMD014 (v 1.63) Section 7.1 */
*left = *right = *top = *bottom = 6.0f;
done = 1;
break;
case BARCODE_ULTRA:
/* AIMD/TSC15032-43 (v 0.99c) Section 9.2 */
*left = *right = *top = *bottom = 1.0f;
done = 1;
break;
}
return done; /* For self-checking */
}
/* Set left (x), top (y), right and bottom offsets for whitespace */
INTERNAL void output_set_whitespace_offsets(struct zint_symbol *symbol, float *xoffset, float *yoffset,
float *roffset, float *boffset) {
float qz_left, qz_right, qz_top, qz_bottom;
quiet_zones(symbol, &qz_left, &qz_right, &qz_top, &qz_bottom);
*xoffset = symbol->whitespace_width + qz_left;
*roffset = symbol->whitespace_width + qz_right;
if (symbol->output_options & BARCODE_BOX) {
*xoffset += symbol->border_width;
*roffset += symbol->border_width;
}
*yoffset = symbol->whitespace_height + qz_top;
*boffset = symbol->whitespace_height + qz_bottom;
if (symbol->output_options & (BARCODE_BOX | BARCODE_BIND)) {
*yoffset += symbol->border_width;
*boffset += symbol->border_width;
}
}
/* Set composite offset and main width excluding addon (for start of addon calc) and addon text, returning
UPC/EAN type */
INTERNAL int output_process_upcean(struct zint_symbol *symbol, int *p_main_width, int *p_comp_offset,
unsigned char addon[6], int *p_addon_gap) {
int main_width; /* Width of main linear symbol, excluding addon */
int comp_offset; /* Whitespace offset (if any) of main linear symbol due to having composite */
int upceanflag; /* UPC/EAN type flag */
int i, j, latch;
int text_length = (int) ustrlen(symbol->text);
latch = 0;
j = 0;
/* Isolate add-on text */
for (i = 6; i < text_length && j < 5; i++) {
if (latch == 1) {
addon[j] = symbol->show_hrt ? symbol->text[i] : ' '; /* Use dummy space-filled addon if no hrt */
j++;
} else if (symbol->text[i] == '+') {
latch = 1;
}
}
addon[j] = '\0';
if (latch) {
if (symbol->symbology == BARCODE_UPCA || symbol->symbology == BARCODE_UPCA_CHK
|| symbol->symbology == BARCODE_UPCA_CC) {
*p_addon_gap = symbol->option_2 >= 9 && symbol->option_2 <= 12 ? symbol->option_2 : 9;
} else {
*p_addon_gap = symbol->option_2 >= 7 && symbol->option_2 <= 12 ? symbol->option_2 : 7;
}
}
/* Calculate composite offset */
comp_offset = 0;
if (is_composite(symbol->symbology)) {
while (!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
comp_offset++;
}
}
upceanflag = 0;
main_width = symbol->width;
if ((symbol->symbology == BARCODE_EANX) || (symbol->symbology == BARCODE_EANX_CHK)
|| (symbol->symbology == BARCODE_EANX_CC) || (symbol->symbology == BARCODE_ISBNX)) {
switch (text_length) {
case 13: /* EAN-13 */
case 16: /* EAN-13 + EAN-2 */
case 19: /* EAN-13 + EAN-5 */
main_width = 95 + comp_offset; /* EAN-13 main symbol 95 modules wide */
upceanflag = 13;
break;
case 2:
/* EAN-2 can't have addon or be composite */
upceanflag = 2;
break;
case 5:
/* EAN-5 can't have addon or be composite */
upceanflag = 5;
break;
default:
main_width = 68 + comp_offset; /* EAN-8 main symbol 68 modules wide */
upceanflag = 8;
break;
}
} else if ((symbol->symbology == BARCODE_UPCA) || (symbol->symbology == BARCODE_UPCA_CHK)
|| (symbol->symbology == BARCODE_UPCA_CC)) {
main_width = 95 + comp_offset; /* UPC-A main symbol 95 modules wide */
upceanflag = 12;
} else if ((symbol->symbology == BARCODE_UPCE) || (symbol->symbology == BARCODE_UPCE_CHK)
|| (symbol->symbology == BARCODE_UPCE_CC)) {
main_width = 51 + comp_offset; /* UPC-E main symbol 51 modules wide */
upceanflag = 6;
}
*p_comp_offset = comp_offset;
*p_main_width = main_width;
return upceanflag;
}
/* Calculate large bar height i.e. linear bars with zero row height that respond to the symbol height.
If scaler `si` non-zero (raster), then large_bar_height if non-zero or else row heights will be rounded to nearest
pixel and symbol height adjusted */
INTERNAL float output_large_bar_height(struct zint_symbol *symbol, int si) {
float fixed_height = 0.0f;
int zero_count = 0;
int round_rows = 0;
int i;
float large_bar_height;
for (i = 0; i < symbol->rows; i++) {
if (symbol->row_height[i]) {
fixed_height += symbol->row_height[i];
if (!round_rows && si && !isfintf(symbol->row_height[i] * si)) {
round_rows = 1;
}
} else {
zero_count++;
}
}
if (zero_count) {
large_bar_height = (symbol->height - fixed_height) / zero_count;
if (large_bar_height <= 0.0f) { /* Shouldn't happen but protect against memory access violations */
large_bar_height = 0.01f; /* Token positive value */
symbol->height = large_bar_height * zero_count + fixed_height;
}
if (si && !isfintf(large_bar_height * si)) {
large_bar_height = roundf(large_bar_height * si) / si;
symbol->height = large_bar_height * zero_count + fixed_height;
}
/* Note should never happen that have both zero_count and round_rows */
} else {
large_bar_height = 0.0f; /* Not used if zero_count zero */
if (round_rows) {
fixed_height = 0.0f;
for (i = 0; i < symbol->rows; i++) {
if (!isfintf(symbol->row_height[i] * si)) {
symbol->row_height[i] = roundf(symbol->row_height[i] * si) / si;
}
fixed_height += symbol->row_height[i];
}
symbol->height = fixed_height;
}
}
return large_bar_height;
}
/* Split UPC/EAN add-on text into various constituents */
INTERNAL void output_upcean_split_text(int upceanflag, unsigned char text[],
unsigned char textpart1[5], unsigned char textpart2[7], unsigned char textpart3[7],
unsigned char textpart4[2]) {
int i;
if (upceanflag == 6) { /* UPC-E */
textpart1[0] = text[0];
textpart1[1] = '\0';
for (i = 0; i < 6; i++) {
textpart2[i] = text[i + 1];
}
textpart2[6] = '\0';
textpart3[0] = text[7];
textpart3[1] = '\0';
} else if (upceanflag == 8) { /* EAN-8 */
for (i = 0; i < 4; i++) {
textpart1[i] = text[i];
}
textpart1[4] = '\0';
for (i = 0; i < 4; i++) {
textpart2[i] = text[i + 4];
}
textpart2[4] = '\0';
} else if (upceanflag == 12) { /* UPC-A */
textpart1[0] = text[0];
textpart1[1] = '\0';
for (i = 0; i < 5; i++) {
textpart2[i] = text[i + 1];
}
textpart2[5] = '\0';
for (i = 0; i < 5; i++) {
textpart3[i] = text[i + 6];
}
textpart3[5] = '\0';
textpart4[0] = text[11];
textpart4[1] = '\0';
} else if (upceanflag == 13) { /* EAN-13 */
textpart1[0] = text[0];
textpart1[1] = '\0';
for (i = 0; i < 6; i++) {
textpart2[i] = text[i + 1];
}
textpart2[6] = '\0';
for (i = 0; i < 6; i++) {
textpart3[i] = text[i + 7];
}
textpart3[6] = '\0';
}
}

54
3rdparty/zint-2.10.0/backend/output.h vendored Normal file
View File

@@ -0,0 +1,54 @@
/* output.h - Common routines for raster/vector
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef OUTPUT_H
#define OUTPUT_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
INTERNAL int output_check_colour_options(struct zint_symbol *symbol);
INTERNAL void output_set_whitespace_offsets(struct zint_symbol *symbol, float *xoffset, float *yoffset,
float *roffset, float *boffset);
INTERNAL int output_process_upcean(struct zint_symbol *symbol, int *p_main_width, int *p_comp_offset,
unsigned char addon[6], int *p_addon_gap);
INTERNAL float output_large_bar_height(struct zint_symbol *symbol, int si);
INTERNAL void output_upcean_split_text(int upceanflag, unsigned char text[],
unsigned char textpart1[5], unsigned char textpart2[7], unsigned char textpart3[7],
unsigned char textpart4[2]);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* OUTPUT_H */

226
3rdparty/zint-2.10.0/backend/pcx.c vendored Normal file
View File

@@ -0,0 +1,226 @@
/* pcx.c - Handles output to ZSoft PCX file */
/* ZSoft PCX File Format Technical Reference Manual http://bespin.org/~qz/pc-gpe/pcx.txt */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <errno.h>
#include <stdio.h>
#include "common.h"
#include "pcx.h" /* PCX header structure */
#include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#include <malloc.h>
#endif
INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
int row, column, i, colour;
int run_count;
FILE *pcx_file;
pcx_header_t header;
int bytes_per_line = symbol->bitmap_width + (symbol->bitmap_width & 1); // Must be even
unsigned char previous;
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; /* Suppress gcc -fanalyzer warning */
#ifdef _MSC_VER
unsigned char *rle_row;
#endif
#ifndef _MSC_VER
unsigned char rle_row[bytes_per_line];
#else
rle_row = (unsigned char *) _alloca(bytes_per_line);
#endif /* _MSC_VER */
rle_row[bytes_per_line - 1] = 0; // Will remain zero if bitmap_width odd
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
header.manufacturer = 10; // ZSoft
header.version = 5; // Version 3.0
header.encoding = 1; // Run length encoding
header.bits_per_pixel = 8;
header.window_xmin = 0;
header.window_ymin = 0;
header.window_xmax = symbol->bitmap_width - 1;
header.window_ymax = symbol->bitmap_height - 1;
header.horiz_dpi = 300;
header.vert_dpi = 300;
for (i = 0; i < 48; i++) {
header.colourmap[i] = 0x00;
}
header.reserved = 0;
header.number_of_planes = 3;
header.bytes_per_line = bytes_per_line;
header.palette_info = 1; // Colour
header.horiz_screen_size = 0;
header.vert_screen_size = 0;
for (i = 0; i < 54; i++) {
header.filler[i] = 0x00;
}
/* Open output file in binary mode */
if (output_to_stdout) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
sprintf(symbol->errtxt, "620: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
#endif
pcx_file = stdout;
} else {
if (!(pcx_file = fopen(symbol->outfile, "wb"))) {
sprintf(symbol->errtxt, "621: Could not open output file (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
}
fwrite(&header, sizeof(pcx_header_t), 1, pcx_file);
for (row = 0; row < symbol->bitmap_height; row++) {
for (colour = 0; colour < 3; colour++) {
for (column = 0; column < symbol->bitmap_width; column++) {
switch (colour) {
case 0:
switch (pixelbuf[(row * symbol->bitmap_width) + column]) {
case 'W': // White
case 'M': // Magenta
case 'R': // Red
case 'Y': // Yellow
rle_row[column] = 255;
break;
case 'C': // Cyan
case 'B': // Blue
case 'G': // Green
case 'K': // Black
rle_row[column] = 0;
break;
case '1':
rle_row[column] = fgred;
break;
default:
rle_row[column] = bgred;
break;
}
break;
case 1:
switch (pixelbuf[(row * symbol->bitmap_width) + column]) {
case 'W': // White
case 'C': // Cyan
case 'Y': // Yellow
case 'G': // Green
rle_row[column] = 255;
break;
case 'B': // Blue
case 'M': // Magenta
case 'R': // Red
case 'K': // Black
rle_row[column] = 0;
break;
case '1':
rle_row[column] = fggrn;
break;
default:
rle_row[column] = bggrn;
break;
}
break;
case 2:
switch (pixelbuf[(row * symbol->bitmap_width) + column]) {
case 'W': // White
case 'C': // Cyan
case 'B': // Blue
case 'M': // Magenta
rle_row[column] = 255;
break;
case 'R': // Red
case 'Y': // Yellow
case 'G': // Green
case 'K': // Black
rle_row[column] = 0;
break;
case '1':
rle_row[column] = fgblu;
break;
default:
rle_row[column] = bgblu;
break;
}
break;
}
}
/* Based on ImageMagick/coders/pcx.c PCXWritePixels()
* Copyright 1999-2020 ImageMagick Studio LLC */
previous = rle_row[0];
run_count = 1;
for (column = 1; column < bytes_per_line; column++) { // Note going up to bytes_per_line
if ((previous == rle_row[column]) && (run_count < 63)) {
run_count++;
} else {
if (run_count > 1 || (previous & 0xc0) == 0xc0) {
run_count += 0xc0;
fputc(run_count, pcx_file);
}
fputc(previous, pcx_file);
previous = rle_row[column];
run_count = 1;
}
}
if (run_count > 1 || (previous & 0xc0) == 0xc0) {
run_count += 0xc0;
fputc(run_count, pcx_file);
}
fputc(previous, pcx_file);
}
}
if (output_to_stdout) {
fflush(pcx_file);
} else {
fclose(pcx_file);
}
return 0;
}

77
3rdparty/zint-2.10.0/backend/pcx.h vendored Normal file
View File

@@ -0,0 +1,77 @@
/* pcx.h - header structure for ZSoft PCX files
libzint - the open source barcode library
Copyright (C) 2016-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef PCX_H
#define PCX_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
#pragma pack (1)
typedef struct pcx_header {
uint8_t manufacturer;
uint8_t version;
uint8_t encoding;
uint8_t bits_per_pixel;
uint16_t window_xmin;
uint16_t window_ymin;
uint16_t window_xmax;
uint16_t window_ymax;
uint16_t horiz_dpi;
uint16_t vert_dpi;
uint8_t colourmap[48];
uint8_t reserved;
uint8_t number_of_planes;
uint16_t bytes_per_line;
uint16_t palette_info;
uint16_t horiz_screen_size;
uint16_t vert_screen_size;
uint8_t filler[54];
} pcx_header_t;
#pragma pack ()
#ifdef __cplusplus
}
#endif
#endif /* PCX_H */

1229
3rdparty/zint-2.10.0/backend/pdf417.c vendored Normal file

File diff suppressed because it is too large Load Diff

514
3rdparty/zint-2.10.0/backend/pdf417.h vendored Normal file
View File

@@ -0,0 +1,514 @@
/* pdf417.h - PDF417 tables and coefficients */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Portions Copyright (C) 2004 Grandzebu
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* this file contains the character table, the pre-calculated coefficients and the
codeword patterns taken from lines 416 to 454 of pdf417.frm */
#ifndef __PDF417_H
#define __PDF417_H
/* PDF417 error correction coefficients from Grand Zebu */
static const unsigned short int coefrs[1022] = {
/* k = 2 */
27, 917,
/* k = 4 */
522, 568, 723, 809,
/* k = 8 */
237, 308, 436, 284, 646, 653, 428, 379,
/* k = 16 */
274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176, 65,
/* k = 32 */
361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, 517,
273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330, 63, 410,
/* k = 64 */
539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733, 877, 381, 612,
723, 476, 462, 172, 430, 609, 858, 822, 543, 376, 511, 400, 672, 762, 283, 184,
440, 35, 519, 31, 460, 594, 225, 535, 517, 352, 605, 158, 651, 201, 488, 502,
648, 733, 717, 83, 404, 97, 280, 771, 840, 629, 4, 381, 843, 623, 264, 543,
/* k = 128 */
521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, 925, 749, 415,
822, 93, 217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908, 490, 704,
516, 258, 457, 907, 594, 723, 674, 292, 272, 96, 684, 432, 686, 606, 860, 569,
193, 219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379, 712, 463, 646, 776,
171, 491, 297, 763, 156, 732, 95, 270, 447, 90, 507, 48, 228, 821, 808, 898,
784, 663, 627, 378, 382, 262, 380, 602, 754, 336, 89, 614, 87, 432, 670, 616,
157, 374, 242, 726, 600, 269, 375, 898, 845, 454, 354, 130, 814, 587, 804, 34,
211, 330, 539, 297, 827, 865, 37, 517, 834, 315, 550, 86, 801, 4, 108, 539,
/* k = 256 */
524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, 786, 138, 720,
858, 194, 311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280, 828, 757,
710, 814, 919, 89, 68, 569, 11, 204, 796, 605, 540, 913, 801, 700, 799, 137,
439, 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257, 284, 549, 209, 884,
315, 70, 329, 793, 490, 274, 877, 162, 749, 812, 684, 461, 334, 376, 849, 521,
307, 291, 803, 712, 19, 358, 399, 908, 103, 511, 51, 8, 517, 225, 289, 470,
637, 731, 66, 255, 917, 269, 463, 830, 730, 433, 848, 585, 136, 538, 906, 90,
2, 290, 743, 199, 655, 903, 329, 49, 802, 580, 355, 588, 188, 462, 10, 134,
628, 320, 479, 130, 739, 71, 263, 318, 374, 601, 192, 605, 142, 673, 687, 234,
722, 384, 177, 752, 607, 640, 455, 193, 689, 707, 805, 641, 48, 60, 732, 621,
895, 544, 261, 852, 655, 309, 697, 755, 756, 60, 231, 773, 434, 421, 726, 528,
503, 118, 49, 795, 32, 144, 500, 238, 836, 394, 280, 566, 319, 9, 647, 550,
73, 914, 342, 126, 32, 681, 331, 792, 620, 60, 609, 441, 180, 791, 893, 754,
605, 383, 228, 749, 760, 213, 54, 297, 134, 54, 834, 299, 922, 191, 910, 532,
609, 829, 189, 20, 167, 29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173,
404, 251, 688, 95, 497, 555, 642, 543, 307, 159, 924, 558, 648, 55, 497, 10,
/* k = 512 */
352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350, 492,
197, 265, 920, 155, 914, 299, 229, 643, 294, 871, 306, 88, 87, 193, 352, 781,
846, 75, 327, 520, 435, 543, 203, 666, 249, 346, 781, 621, 640, 268, 794, 534,
539, 781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37, 858, 916, 552, 41,
542, 289, 122, 272, 383, 800, 485, 98, 752, 472, 761, 107, 784, 860, 658, 741,
290, 204, 681, 407, 855, 85, 99, 62, 482, 180, 20, 297, 451, 593, 913, 142,
808, 684, 287, 536, 561, 76, 653, 899, 729, 567, 744, 390, 513, 192, 516, 258,
240, 518, 794, 395, 768, 848, 51, 610, 384, 168, 190, 826, 328, 596, 786, 303,
570, 381, 415, 641, 156, 237, 151, 429, 531, 207, 676, 710, 89, 168, 304, 402,
40, 708, 575, 162, 864, 229, 65, 861, 841, 512, 164, 477, 221, 92, 358, 785,
288, 357, 850, 836, 827, 736, 707, 94, 8, 494, 114, 521, 2, 499, 851, 543,
152, 729, 771, 95, 248, 361, 578, 323, 856, 797, 289, 51, 684, 466, 533, 820,
669, 45, 902, 452, 167, 342, 244, 173, 35, 463, 651, 51, 699, 591, 452, 578,
37, 124, 298, 332, 552, 43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911,
283, 711, 472, 420, 245, 288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408,
842, 383, 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713, 159, 672, 729,
624, 59, 193, 417, 158, 209, 563, 564, 343, 693, 109, 608, 563, 365, 181, 772,
677, 310, 248, 353, 708, 410, 579, 870, 617, 841, 632, 860, 289, 536, 35, 777,
618, 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751, 331, 247, 184, 45,
787, 680, 18, 66, 407, 369, 54, 492, 228, 613, 830, 922, 437, 519, 644, 905,
789, 420, 305, 441, 207, 300, 892, 827, 141, 537, 381, 662, 513, 56, 252, 341,
242, 797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310, 756, 665, 397, 808,
851, 309, 473, 795, 378, 31, 647, 915, 459, 806, 590, 731, 425, 216, 548, 249,
321, 881, 699, 535, 673, 782, 210, 815, 905, 303, 843, 922, 281, 73, 469, 791,
660, 162, 498, 308, 155, 422, 907, 817, 187, 62, 16, 425, 535, 336, 286, 437,
375, 273, 610, 296, 183, 923, 116, 667, 751, 353, 62, 366, 691, 379, 687, 842,
37, 357, 720, 742, 330, 5, 39, 923, 311, 424, 242, 749, 321, 54, 669, 316,
342, 299, 534, 105, 667, 488, 640, 672, 576, 540, 316, 486, 721, 610, 46, 656,
447, 171, 616, 464, 190, 531, 297, 321, 762, 752, 533, 175, 134, 14, 381, 433,
717, 45, 111, 20, 596, 284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780,
407, 164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768, 223, 849, 647,
63, 310, 863, 251, 366, 304, 282, 738, 675, 410, 389, 244, 31, 121, 303, 263
};
static const unsigned short int pdf_bitpattern[2787] = {
0xEAE0, 0xF578, 0xFABE, 0xEA70, 0xF53C, 0xFA9F, 0xD460, 0xEA38, 0xD430, 0xA820,
0xD418, 0xA810, 0xD6E0, 0xEB78, 0xF5BE, 0xD670, 0xEB3C, 0xF59F, 0xAC60, 0xD638,
0xAC30, 0xAEE0, 0xD778, 0xEBBE, 0xAE70, 0xD73C, 0xEB9F, 0xAE38, 0xD71E, 0xAF78,
0xD7BE, 0xAF3C, 0xD79F, 0xAFBE, 0xFAFD, 0xE970, 0xF4BC, 0xFA5F, 0xD260, 0xE938,
0xF49E, 0xD230, 0xE91C, 0xA420, 0xD218, 0xE90E, 0xA410, 0xD20C, 0xA408, 0xD370,
0xE9BC, 0xF4DF, 0xA660, 0xD338, 0xE99E, 0xA630, 0xD31C, 0xE98F, 0xA618, 0xD30E,
0xA770, 0xD3BC, 0xE9DF, 0xA738, 0xD39E, 0xA71C, 0xD38F, 0xA7BC, 0xD3DF, 0xA79E,
0xA78F, 0xD160, 0xE8B8, 0xF45E, 0xD130, 0xE89C, 0xF44F, 0xA220, 0xD118, 0xE88E,
0xA210, 0xD10C, 0xA208, 0xA204, 0xA360, 0xD1B8, 0xE8DE, 0xA330, 0xD19C, 0xE8CF,
0xA318, 0xD18E, 0xA30C, 0xA306, 0xA3B8, 0xD1DE, 0xA39C, 0xD1CF, 0xA38E, 0xA3DE,
0xD0B0, 0xE85C, 0xF42F, 0xA120, 0xD098, 0xE84E, 0xA110, 0xD08C, 0xE847, 0xA108,
0xD086, 0xA104, 0xD083, 0xA1B0, 0xD0DC, 0xE86F, 0xA198, 0xD0CE, 0xA18C, 0xD0C7,
0xA186, 0xA183, 0xD0EF, 0xA1C7, 0xA0A0, 0xD058, 0xE82E, 0xA090, 0xD04C, 0xE827,
0xA088, 0xD046, 0xA084, 0xD043, 0xA082, 0xA0D8, 0xA0CC, 0xA0C6, 0xA050, 0xE817,
0xD026, 0xD023, 0xA041, 0xE570, 0xF2BC, 0xF95F, 0xCA60, 0xE538, 0xF29E, 0xCA30,
0xE51C, 0xF28F, 0x9420, 0xCA18, 0x9410, 0xCB70, 0xE5BC, 0xF2DF, 0x9660, 0xCB38,
0xE59E, 0x9630, 0xCB1C, 0x9618, 0x960C, 0x9770, 0xCBBC, 0xE5DF, 0x9738, 0xCB9E,
0x971C, 0x970E, 0x97BC, 0xCBDF, 0x979E, 0x97DF, 0xED60, 0xF6B8, 0xFB5E, 0xED30,
0xF69C, 0xFB4F, 0xDA20, 0xED18, 0xF68E, 0xDA10, 0xED0C, 0xF687, 0xDA08, 0xED06,
0xC960, 0xE4B8, 0xF25E, 0xDB60, 0xC930, 0xE49C, 0xF24F, 0xDB30, 0xED9C, 0xF6CF,
0xB620, 0x9210, 0xC90C, 0xE487, 0xB610, 0xDB0C, 0xB608, 0x9360, 0xC9B8, 0xE4DE,
0xB760, 0x9330, 0xC99C, 0xE4CF, 0xB730, 0xDB9C, 0xEDCF, 0xB718, 0x930C, 0xB70C,
0x93B8, 0xC9DE, 0xB7B8, 0x939C, 0xC9CF, 0xB79C, 0xDBCF, 0xB78E, 0x93DE, 0xB7DE,
0x93CF, 0xB7CF, 0xECB0, 0xF65C, 0xFB2F, 0xD920, 0xEC98, 0xF64E, 0xD910, 0xEC8C,
0xF647, 0xD908, 0xEC86, 0xD904, 0xD902, 0xC8B0, 0xE45C, 0xF22F, 0xD9B0, 0xC898,
0xE44E, 0xB320, 0x9110, 0xECCE, 0xE447, 0xB310, 0x9108, 0xC886, 0xB308, 0xD986,
0xC883, 0x9102, 0x91B0, 0xC8DC, 0xE46F, 0xB3B0, 0x9198, 0xC8CE, 0xB398, 0xD9CE,
0xC8C7, 0xB38C, 0x9186, 0x9183, 0x91DC, 0xC8EF, 0xB3DC, 0x91CE, 0xB3CE, 0x91C7,
0xB3C7, 0xB3EF, 0xD8A0, 0xEC58, 0xF62E, 0xD890, 0xEC4C, 0xF627, 0xD888, 0xEC46,
0xD884, 0xEC43, 0xD882, 0xD881, 0x90A0, 0xC858, 0xE42E, 0xB1A0, 0x9090, 0xC84C,
0xE427, 0xB190, 0xD8CC, 0xEC67, 0xB188, 0x9084, 0xC843, 0xB184, 0xD8C3, 0xB182,
0x90D8, 0xC86E, 0xB1D8, 0x90CC, 0xC867, 0xB1CC, 0xD8E7, 0xB1C6, 0x90C3, 0xB1C3,
0xB1EE, 0xB1E7, 0xD850, 0xEC2C, 0xF617, 0xD848, 0xEC26, 0xD844, 0xEC23, 0xD842,
0xD841, 0x9050, 0xC82C, 0xE417, 0xB0D0, 0x9048, 0xC826, 0xB0C8, 0xD866, 0xC823,
0xB0C4, 0x9042, 0xB0C2, 0x9041, 0x906C, 0xB0EC, 0xB0E6, 0xB0E3, 0xEC16, 0xEC13,
0xD821, 0xC816, 0x9024, 0xB064, 0xB062, 0xB061, 0xC560, 0xE2B8, 0xF15E, 0xC530,
0xE29C, 0x8A20, 0xC518, 0xE28E, 0x8A10, 0xC50C, 0x8A08, 0x8A04, 0x8B60, 0xC5B8,
0xE2DE, 0x8B30, 0xC59C, 0xE2CF, 0x8B18, 0xC58E, 0x8B0C, 0x8B06, 0x8BB8, 0xC5DE,
0x8B9C, 0xC5CF, 0x8B8E, 0x8BDE, 0x8BCF, 0xE6B0, 0xF35C, 0xF9AF, 0xCD20, 0xE698,
0xF34E, 0xCD10, 0xE68C, 0xF347, 0xCD08, 0xE686, 0xCD04, 0xE683, 0xC4B0, 0xE25C,
0xF12F, 0xCDB0, 0xC498, 0xE24E, 0x9B20, 0x8910, 0xE6CE, 0xE247, 0x9B10, 0xCD8C,
0xC486, 0x9B08, 0x8904, 0x9B04, 0x89B0, 0xC4DC, 0xE26F, 0x9BB0, 0x8998, 0xE6EF,
0x9B98, 0xCDCE, 0xC4C7, 0x9B8C, 0x8986, 0x9B86, 0x89DC, 0xC4EF, 0x9BDC, 0x89CE,
0x9BCE, 0x89C7, 0x89EF, 0x9BEF, 0xEEA0, 0xF758, 0xFBAE, 0xEE90, 0xF74C, 0xFBA7,
0xEE88, 0xF746, 0xEE84, 0xF743, 0xEE82, 0xCCA0, 0xE658, 0xF32E, 0xDDA0, 0xCC90,
0xF76E, 0xF327, 0xDD90, 0xEECC, 0xF767, 0xDD88, 0xCC84, 0xE643, 0xDD84, 0xEEC3,
0xCC81, 0x88A0, 0xC458, 0xE22E, 0x99A0, 0x8890, 0xC44C, 0xE227, 0xBBA0, 0x9990,
0xCCCC, 0xE667, 0xBB90, 0xDDCC, 0xEEE7, 0xC443, 0xBB88, 0x9984, 0xCCC3, 0xBB84,
0x8881, 0x88D8, 0xC46E, 0x99D8, 0x88CC, 0xC467, 0xBBD8, 0x99CC, 0xCCE7, 0xBBCC,
0xDDE7, 0x88C3, 0x99C3, 0x88EE, 0x99EE, 0x88E7, 0xBBEE, 0x99E7, 0xEE50, 0xF72C,
0xFB97, 0xEE48, 0xF726, 0xEE44, 0xF723, 0xEE42, 0xEE41, 0xCC50, 0xE62C, 0xF317,
0xDCD0, 0xCC48, 0xF737, 0xDCC8, 0xEE66, 0xE623, 0xDCC4, 0xCC42, 0xDCC2, 0xCC41,
0xDCC1, 0x8850, 0xC42C, 0xE217, 0x98D0, 0x8848, 0xC426, 0xB9D0, 0x98C8, 0xCC66,
0xC423, 0xB9C8, 0xDCE6, 0x8842, 0xB9C4, 0x98C2, 0x8841, 0x98C1, 0x886C, 0xC437,
0x98EC, 0x8866, 0xB9EC, 0x98E6, 0x8863, 0xB9E6, 0x98E3, 0x8877, 0xB9F7, 0xEE28,
0xF716, 0xEE24, 0xF713, 0xEE22, 0xEE21, 0xCC28, 0xE616, 0xDC68, 0xCC24, 0xE613,
0xDC64, 0xEE33, 0xDC62, 0xCC21, 0xDC61, 0x8828, 0xC416, 0x9868, 0x8824, 0xC413,
0xB8E8, 0x9864, 0xCC33, 0xB8E4, 0xDC73, 0x8821, 0xB8E2, 0x9861, 0xB8E1, 0x9876,
0xB8F6, 0xB8F3, 0xF70B, 0xEE11, 0xE60B, 0xCC12, 0xCC11, 0x8814, 0x9834, 0xB874,
0x8811, 0x9831, 0xC2B0, 0x8520, 0xC298, 0x8510, 0xC28C, 0xE147, 0x8508, 0xC286,
0x8504, 0xC283, 0x85B0, 0xC2DC, 0xE16F, 0x8598, 0xC2CE, 0x858C, 0xC2C7, 0x8586,
0x8583, 0x85DC, 0xC2EF, 0x85CE, 0x85C7, 0x85EF, 0xC6A0, 0xE358, 0xF1AE, 0xC690,
0xE34C, 0xC688, 0xE346, 0xC684, 0xE343, 0xC682, 0x84A0, 0xC258, 0xE12E, 0x8DA0,
0x8490, 0xE36E, 0xE127, 0x8D90, 0xC6CC, 0xE367, 0x8D88, 0x8484, 0xC243, 0x8D84,
0xC6C3, 0x8481, 0x84D8, 0xC26E, 0x8DD8, 0x84CC, 0xC267, 0x8DCC, 0xC6E7, 0x8DC6,
0x84C3, 0x84EE, 0x8DEE, 0x84E7, 0x8DE7, 0xE750, 0xF3AC, 0xF9D7, 0xE748, 0xF3A6,
0xE744, 0xF3A3, 0xE742, 0xE741, 0xC650, 0xE32C, 0xCED0, 0xC648, 0xE326, 0xCEC8,
0xE766, 0xE323, 0xCEC4, 0xC642, 0xCEC2, 0xC641, 0xCEC1, 0x8450, 0xC22C, 0x8CD0,
0x8448, 0xE337, 0x9DD0, 0x8CC8, 0xC666, 0xC223, 0x9DC8, 0xCEE6, 0x8442, 0x9DC4,
0x8CC2, 0x8441, 0x8CC1, 0x846C, 0xC237, 0x8CEC, 0x8466, 0x9DEC, 0x8CE6, 0x8463,
0x9DE6, 0x8CE3, 0x8477, 0x8CF7, 0x9DF7, 0xF7A8, 0xFBD6, 0xF7A4, 0xFBD3, 0xF7A2,
0xF7A1, 0xE728, 0xF396, 0xEF68, 0xF7B6, 0xF393, 0xEF64, 0xF7B3, 0xEF62, 0xE721,
0xEF61, 0xC628, 0xE316, 0xCE68, 0xC624, 0xE313, 0xDEE8, 0xCE64, 0xE733, 0xDEE4,
0xEF73, 0xC621, 0xDEE2, 0xCE61, 0xDEE1, 0x8428, 0xC216, 0x8C68, 0x8424, 0xC213,
0x9CE8, 0x8C64, 0xC633, 0xBDE8, 0x9CE4, 0xCE73, 0x8421, 0xBDE4, 0xDEF3, 0x8C61,
0xBDE2, 0x8436, 0x8C76, 0x8433, 0x9CF6, 0x8C73, 0xBDF6, 0x9CF3, 0xBDF3, 0xF794,
0xFBCB, 0xF792, 0xF791, 0xE714, 0xF38B, 0xEF34, 0xF79B, 0xEF32, 0xE711, 0xEF31,
0xC614, 0xE30B, 0xCE34, 0xC612, 0xDE74, 0xCE32, 0xC611, 0xDE72, 0xCE31, 0xDE71,
0x8414, 0xC20B, 0x8C34, 0xC61B, 0x9C74, 0x8C32, 0x8411, 0xBCF4, 0x9C72, 0x8C31,
0xBCF2, 0x9C71, 0xBCF1, 0x8C3B, 0xBCFB, 0xF789, 0xEF1A, 0xEF19, 0xCE1A, 0xDE3A,
0xDE39, 0x8C1A, 0x9C3A, 0xBC7A, 0xBC79, 0x82A0, 0x8290, 0xC14C, 0x8288, 0x8284,
0x8282, 0x82D8, 0x82CC, 0x82C6, 0x82C3, 0x82EE, 0x82E7, 0xC350, 0xC348, 0xE1A6,
0xC344, 0xE1A3, 0xC342, 0xC341, 0x8250, 0xC12C, 0x86D0, 0xC36C, 0xC126, 0x86C8,
0xC366, 0x86C4, 0xC363, 0x86C2, 0x8241, 0x86C1, 0x826C, 0xC137, 0x86EC, 0xC377,
0x86E6, 0x8263, 0x86E3, 0x8277, 0x86F7, 0xE3A8, 0xE3A4, 0xE3A2, 0xE3A1, 0xC328,
0xC768, 0xE3B6, 0xE193, 0xC764, 0xE3B3, 0xC762, 0xC321, 0xC761, 0x8228, 0x8668,
0x8224, 0xC113, 0x8EE8, 0x8664, 0x8222, 0x8EE4, 0x8662, 0x8221, 0x8EE2, 0x8661,
0x8236, 0x8676, 0x8233, 0x8EF6, 0x8673, 0x8EF3, 0xF3D4, 0xF3D2, 0xF3D1, 0xE394,
0xE7B4, 0xF3DB, 0xE7B2, 0xE391, 0xE7B1, 0xC314, 0xE18B, 0xC734, 0xE39B, 0xCF74,
0xC732, 0xC311, 0xCF72, 0xC731, 0xCF71, 0x8214, 0xC10B, 0x8634, 0xC31B, 0x8E74,
0x8632, 0x8211, 0x9EF4, 0x8E72, 0x8631, 0x9EF2, 0x8E71, 0x821B, 0x863B, 0x8E7B,
0x9EFB, 0xFBEA, 0xFBE9, 0xF3CA, 0xF7DA, 0xF3C9, 0xF7D9, 0xE38A, 0xE79A, 0xE389,
0xEFBA, 0xE799, 0xEFB9, 0xC30A, 0xC71A, 0xC309, 0xCF3A, 0xC719, 0xDF7A, 0xFAB0,
0xFD5C, 0xF520, 0xFA98, 0xFD4E, 0xF510, 0xFA8C, 0xFD47, 0xF508, 0xFA86, 0xF504,
0xFA83, 0xF502, 0xF5B0, 0xFADC, 0xFD6F, 0xEB20, 0xF598, 0xFACE, 0xEB10, 0xF58C,
0xFAC7, 0xEB08, 0xF586, 0xEB04, 0xF583, 0xEB02, 0xEBB0, 0xF5DC, 0xFAEF, 0xD720,
0xEB98, 0xF5CE, 0xD710, 0xEB8C, 0xF5C7, 0xD708, 0xEB86, 0xD704, 0xEB83, 0xD702,
0xD7B0, 0xEBDC, 0xF5EF, 0xAF20, 0xD798, 0xEBCE, 0xAF10, 0xD78C, 0xEBC7, 0xAF08,
0xD786, 0xAF04, 0xD783, 0xAFB0, 0xD7DC, 0xEBEF, 0xAF98, 0xD7CE, 0xAF8C, 0xD7C7,
0xAF86, 0xAFDC, 0xD7EF, 0xAFCE, 0xAFC7, 0xF4A0, 0xFA58, 0xFD2E, 0xF490, 0xFA4C,
0xFD27, 0xF488, 0xFA46, 0xF484, 0xFA43, 0xF482, 0xF481, 0xE9A0, 0xF4D8, 0xFA6E,
0xE990, 0xF4CC, 0xFA67, 0xE988, 0xF4C6, 0xE984, 0xF4C3, 0xE982, 0xE981, 0xD3A0,
0xE9D8, 0xF4EE, 0xD390, 0xE9CC, 0xF4E7, 0xD388, 0xE9C6, 0xD384, 0xE9C3, 0xD382,
0xD381, 0xA7A0, 0xD3D8, 0xE9EE, 0xA790, 0xD3CC, 0xE9E7, 0xA788, 0xD3C6, 0xA784,
0xD3C3, 0xA782, 0xA7D8, 0xD3EE, 0xA7CC, 0xD3E7, 0xA7C6, 0xA7C3, 0xA7EE, 0xA7E7,
0xF450, 0xFA2C, 0xFD17, 0xF448, 0xFA26, 0xF444, 0xFA23, 0xF442, 0xF441, 0xE8D0,
0xF46C, 0xFA37, 0xE8C8, 0xF466, 0xE8C4, 0xF463, 0xE8C2, 0xE8C1, 0xD1D0, 0xE8EC,
0xF477, 0xD1C8, 0xE8E6, 0xD1C4, 0xE8E3, 0xD1C2, 0xD1C1, 0xA3D0, 0xD1EC, 0xE8F7,
0xA3C8, 0xD1E6, 0xA3C4, 0xD1E3, 0xA3C2, 0xA3C1, 0xA3EC, 0xD1F7, 0xA3E6, 0xA3E3,
0xA3F7, 0xF428, 0xFA16, 0xF424, 0xFA13, 0xF422, 0xF421, 0xE868, 0xF436, 0xE864,
0xF433, 0xE862, 0xE861, 0xD0E8, 0xE876, 0xD0E4, 0xE873, 0xD0E2, 0xD0E1, 0xA1E8,
0xD0F6, 0xA1E4, 0xD0F3, 0xA1E2, 0xA1E1, 0xA1F6, 0xA1F3, 0xF414, 0xFA0B, 0xF412,
0xF411, 0xE834, 0xF41B, 0xE832, 0xE831, 0xD074, 0xE83B, 0xD072, 0xD071, 0xA0F4,
0xD07B, 0xA0F2, 0xA0F1, 0xF40A, 0xF409, 0xE81A, 0xE819, 0xD03A, 0xD039, 0xF2A0,
0xF958, 0xFCAE, 0xF290, 0xF94C, 0xFCA7, 0xF288, 0xF946, 0xF284, 0xF943, 0xF282,
0xF281, 0xE5A0, 0xF2D8, 0xF96E, 0xE590, 0xF2CC, 0xF967, 0xE588, 0xF2C6, 0xE584,
0xF2C3, 0xE582, 0xE581, 0xCBA0, 0xE5D8, 0xF2EE, 0xCB90, 0xE5CC, 0xF2E7, 0xCB88,
0xE5C6, 0xCB84, 0xE5C3, 0xCB82, 0xCB81, 0x97A0, 0xCBD8, 0xE5EE, 0x9790, 0xCBCC,
0xE5E7, 0x9788, 0xCBC6, 0x9784, 0xCBC3, 0x9782, 0x97D8, 0xCBEE, 0x97CC, 0xCBE7,
0x97C6, 0x97C3, 0x97EE, 0x97E7, 0xFB50, 0xFDAC, 0xB5F8, 0xFB48, 0xFDA6, 0xB4FC,
0xFB44, 0xFDA3, 0xB47E, 0xFB42, 0xFB41, 0xF250, 0xF92C, 0xFC97, 0xF6D0, 0xF248,
0xFDB7, 0xF6C8, 0xFB66, 0xF923, 0xF6C4, 0xF242, 0xF6C2, 0xF241, 0xF6C1, 0xE4D0,
0xF26C, 0xF937, 0xEDD0, 0xE4C8, 0xF266, 0xEDC8, 0xF6E6, 0xF263, 0xEDC4, 0xE4C2,
0xEDC2, 0xE4C1, 0xEDC1, 0xC9D0, 0xE4EC, 0xF277, 0xDBD0, 0xC9C8, 0xE4E6, 0xDBC8,
0xEDE6, 0xE4E3, 0xDBC4, 0xC9C2, 0xDBC2, 0xC9C1, 0xDBC1, 0x93D0, 0xC9EC, 0xE4F7,
0xB7D0, 0x93C8, 0xC9E6, 0xB7C8, 0xDBE6, 0xC9E3, 0xB7C4, 0x93C2, 0xB7C2, 0x93C1,
0x93EC, 0xC9F7, 0xB7EC, 0x93E6, 0xB7E6, 0x93E3, 0xB7E3, 0x93F7, 0xFB28, 0xFD96,
0xB2FC, 0xFB24, 0xFD93, 0xB27E, 0xFB22, 0xB23F, 0xFB21, 0xF228, 0xF916, 0xF668,
0xF224, 0xF913, 0xF664, 0xFB33, 0xF662, 0xF221, 0xF661, 0xE468, 0xF236, 0xECE8,
0xE464, 0xF233, 0xECE4, 0xF673, 0xECE2, 0xE461, 0xECE1, 0xC8E8, 0xE476, 0xD9E8,
0xC8E4, 0xE473, 0xD9E4, 0xECF3, 0xD9E2, 0xC8E1, 0xD9E1, 0x91E8, 0xC8F6, 0xB3E8,
0x91E4, 0xC8F3, 0xB3E4, 0xD9F3, 0xB3E2, 0x91E1, 0xB3E1, 0x91F6, 0xB3F6, 0x91F3,
0xB3F3, 0xFB14, 0xFD8B, 0xB17E, 0xFB12, 0xB13F, 0xFB11, 0xF214, 0xF90B, 0xF634,
0xFB1B, 0xF632, 0xF211, 0xF631, 0xE434, 0xF21B, 0xEC74, 0xE432, 0xEC72, 0xE431,
0xEC71, 0xC874, 0xE43B, 0xD8F4, 0xEC7B, 0xD8F2, 0xC871, 0xD8F1, 0x90F4, 0xC87B,
0xB1F4, 0x90F2, 0xB1F2, 0x90F1, 0xB1F1, 0x90FB, 0xB1FB, 0xFB0A, 0xB0BF, 0xFB09,
0xF20A, 0xF61A, 0xF209, 0xF619, 0xE41A, 0xEC3A, 0xE419, 0xEC39, 0xC83A, 0xD87A,
0xC839, 0xD879, 0x907A, 0xB0FA, 0x9079, 0xB0F9, 0xFB05, 0xF205, 0xF60D, 0xE40D,
0xEC1D, 0xC81D, 0xD83D, 0xF150, 0xF8AC, 0xFC57, 0xF148, 0xF8A6, 0xF144, 0xF8A3,
0xF142, 0xF141, 0xE2D0, 0xF16C, 0xF8B7, 0xE2C8, 0xF166, 0xE2C4, 0xF163, 0xE2C2,
0xE2C1, 0xC5D0, 0xE2EC, 0xF177, 0xC5C8, 0xE2E6, 0xC5C4, 0xE2E3, 0xC5C2, 0xC5C1,
0x8BD0, 0xC5EC, 0xE2F7, 0x8BC8, 0xC5E6, 0x8BC4, 0xC5E3, 0x8BC2, 0x8BC1, 0x8BEC,
0xC5F7, 0x8BE6, 0x8BE3, 0x8BF7, 0xF9A8, 0xFCD6, 0x9AFC, 0xF9A4, 0xFCD3, 0x9A7E,
0xF9A2, 0x9A3F, 0xF9A1, 0xF128, 0xF896, 0xF368, 0xF124, 0xF893, 0xF364, 0xF9B3,
0xF362, 0xF121, 0xF361, 0xE268, 0xF136, 0xE6E8, 0xE264, 0xF133, 0xE6E4, 0xF373,
0xE6E2, 0xE261, 0xE6E1, 0xC4E8, 0xE276, 0xCDE8, 0xC4E4, 0xE273, 0xCDE4, 0xE6F3,
0xCDE2, 0xC4E1, 0xCDE1, 0x89E8, 0xC4F6, 0x9BE8, 0x89E4, 0xC4F3, 0x9BE4, 0xCDF3,
0x9BE2, 0x89E1, 0x9BE1, 0x89F6, 0x9BF6, 0x89F3, 0x9BF3, 0xFDD4, 0xBAF8, 0xDD7E,
0xFDD2, 0xBA7C, 0xDD3F, 0xFDD1, 0xBA3E, 0xBA1F, 0xF994, 0xFCCB, 0x997E, 0xFBB4,
0xFDDB, 0xBB7E, 0x993F, 0xFBB2, 0xF991, 0xBB3F, 0xFBB1, 0xF114, 0xF88B, 0xF334,
0xF112, 0xF774, 0xFBBB, 0xF111, 0xF772, 0xF331, 0xF771, 0xE234, 0xF11B, 0xE674,
0xE232, 0xEEF4, 0xE672, 0xE231, 0xEEF2, 0xE671, 0xEEF1, 0xC474, 0xE23B, 0xCCF4,
0xC472, 0xDDF4, 0xCCF2, 0xC471, 0xDDF2, 0xCCF1, 0xDDF1, 0x88F4, 0xC47B, 0x99F4,
0x88F2, 0xBBF4, 0x99F2, 0x88F1, 0xBBF2, 0x99F1, 0xBBF1, 0x88FB, 0x99FB, 0xFDCA,
0xB97C, 0xDCBF, 0xFDC9, 0xB93E, 0xB91F, 0xF98A, 0x98BF, 0xFB9A, 0xF989, 0xB9BF,
0xFB99, 0xF10A, 0xF31A, 0xF109, 0xF73A, 0xF319, 0xF739, 0xE21A, 0xE63A, 0xE219,
0xEE7A, 0xE639, 0xEE79, 0xC43A, 0xCC7A, 0xC439, 0xDCFA, 0xCC79, 0xDCF9, 0x887A,
0x98FA, 0x8879, 0xB9FA, 0x98F9, 0xB9F9, 0xFDC5, 0xB8BE, 0xB89F, 0xF985, 0xFB8D,
0xF105, 0xF30D, 0xF71D, 0xE20D, 0xE61D, 0xEE3D, 0xC41D, 0xCC3D, 0xDC7D, 0x883D,
0x987D, 0xB8FD, 0xB85F, 0xF0A8, 0xF856, 0xF0A4, 0xF853, 0xF0A2, 0xF0A1, 0xE168,
0xF0B6, 0xE164, 0xF0B3, 0xE162, 0xE161, 0xC2E8, 0xE176, 0xC2E4, 0xE173, 0xC2E2,
0xC2E1, 0x85E8, 0xC2F6, 0x85E4, 0xC2F3, 0x85E2, 0x85E1, 0x85F6, 0x85F3, 0xF8D4,
0xFC6B, 0x8D7E, 0xF8D2, 0x8D3F, 0xF8D1, 0xF094, 0xF84B, 0xF1B4, 0xF092, 0xF1B2,
0xF091, 0xF1B1, 0xE134, 0xF09B, 0xE374, 0xE132, 0xE372, 0xE131, 0xE371, 0xC274,
0xE13B, 0xC6F4, 0xC272, 0xC6F2, 0xC271, 0xC6F1, 0x84F4, 0xC27B, 0x8DF4, 0x84F2,
0x8DF2, 0x84F1, 0x8DF1, 0x84FB, 0x8DFB, 0xFCEA, 0x9D7C, 0xCEBF, 0xFCE9, 0x9D3E,
0x9D1F, 0xF8CA, 0x8CBF, 0xF9DA, 0xF8C9, 0x9DBF, 0xF9D9, 0xF08A, 0xF19A, 0xF089,
0xF3BA, 0xF199, 0xF3B9, 0xE11A, 0xE33A, 0xE119, 0xE77A, 0xE339, 0xE779, 0xC23A,
0xC67A, 0xC239, 0xCEFA, 0xC679, 0xCEF9, 0x847A, 0x8CFA, 0x8479, 0x9DFA, 0x8CF9,
0x9DF9, 0xBD78, 0xDEBE, 0xBD3C, 0xDE9F, 0xBD1E, 0xBD0F, 0xFCE5, 0x9CBE, 0xFDED,
0xBDBE, 0x9C9F, 0xBD9F, 0xF8C5, 0xF9CD, 0xFBDD, 0xF085, 0xF18D, 0xF39D, 0xF7BD,
0xE10D, 0xE31D, 0xE73D, 0xEF7D, 0xC21D, 0xC63D, 0xCE7D, 0xDEFD, 0x843D, 0x8C7D,
0x9CFD, 0xBCBC, 0xDE5F, 0xBC9E, 0xBC8F, 0x9C5F, 0xBCDF, 0xBC5E, 0xBC4F, 0xBC2F,
0xF054, 0xF052, 0xF051, 0xE0B4, 0xF05B, 0xE0B2, 0xE0B1, 0xC174, 0xE0BB, 0xC172,
0xC171, 0x82F4, 0xC17B, 0x82F2, 0x82F1, 0x82FB, 0xF86A, 0x86BF, 0xF869, 0xF04A,
0xF0DA, 0xF049, 0xF0D9, 0xE09A, 0xE1BA, 0xE099, 0xE1B9, 0xC13A, 0xC37A, 0xC139,
0xC379, 0x827A, 0x86FA, 0x8279, 0x86F9, 0xFC75, 0x8EBE, 0x8E9F, 0xF865, 0xF8ED,
0xF045, 0xF0CD, 0xF1DD, 0xE08D, 0xE19D, 0xE3BD, 0xC11D, 0xC33D, 0xC77D, 0x823D,
0x867D, 0x8EFD, 0x9EBC, 0xCF5F, 0x9E9E, 0x9E8F, 0x8E5F, 0x9EDF, 0xBEB8, 0xDF5E,
0xBE9C, 0xDF4F, 0xBE8E, 0xBE87, 0x9E5E, 0xBEDE, 0x9E4F, 0xBECF, 0xBE5C, 0xDF2F,
0xBE4E, 0xBE47, 0x9E2F, 0xBE6F, 0xBE2E, 0xBE27, 0xBE17, 0xE05A, 0xE059, 0xC0BA,
0xC0B9, 0x817A, 0x8179, 0xF06D, 0xE04D, 0xE0DD, 0xC09D, 0xC1BD, 0x813D, 0x837D,
0x875F, 0x8F5E, 0x8F4F, 0x9F5C, 0xCFAF, 0x9F4E, 0x9F47, 0x8F2F, 0x9F6F, 0xBF58,
0xDFAE, 0xBF4C, 0xDFA7, 0xBF46, 0xBF43, 0x9F2E, 0xBF6E, 0x9F27, 0xBF67, 0xBF2C,
0xDF97, 0xBF26, 0xBF23, 0x9F17, 0xBF37, 0xBF16, 0xBF13, 0x87AF, 0x8FAE, 0x8FA7,
0x9FAC, 0xCFD7, 0x9FA6, 0x9FA3, 0x8F97, 0x9FB7, 0x9F96, 0x9F93, 0xD5F0, 0xEAFC,
0xA9E0, 0xD4F8, 0xEA7E, 0xA8F0, 0xD47C, 0xEA3F, 0xA878, 0xD43E, 0xA83C, 0xFD68,
0xADF0, 0xD6FC, 0xFD64, 0xACF8, 0xD67E, 0xFD62, 0xAC7C, 0xD63F, 0xFD61, 0xAC3E,
0xFAE8, 0xFD76, 0xAEFC, 0xFAE4, 0xFD73, 0xAE7E, 0xFAE2, 0xAE3F, 0xFAE1, 0xF5E8,
0xFAF6, 0xF5E4, 0xFAF3, 0xF5E2, 0xF5E1, 0xEBE8, 0xF5F6, 0xEBE4, 0xF5F3, 0xEBE2,
0xEBE1, 0xD7E8, 0xEBF6, 0xD7E4, 0xEBF3, 0xD7E2, 0xA5E0, 0xD2F8, 0xE97E, 0xA4F0,
0xD27C, 0xE93F, 0xA478, 0xD23E, 0xA43C, 0xD21F, 0xA41E, 0xFD34, 0xA6F8, 0xD37E,
0xFD32, 0xA67C, 0xD33F, 0xFD31, 0xA63E, 0xA61F, 0xFA74, 0xFD3B, 0xA77E, 0xFA72,
0xA73F, 0xFA71, 0xF4F4, 0xFA7B, 0xF4F2, 0xF4F1, 0xE9F4, 0xF4FB, 0xE9F2, 0xE9F1,
0xD3F4, 0xE9FB, 0xD3F2, 0xD3F1, 0xA2F0, 0xD17C, 0xE8BF, 0xA278, 0xD13E, 0xA23C,
0xD11F, 0xA21E, 0xA20F, 0xFD1A, 0xA37C, 0xD1BF, 0xFD19, 0xA33E, 0xA31F, 0xFA3A,
0xA3BF, 0xFA39, 0xF47A, 0xF479, 0xE8FA, 0xE8F9, 0xD1FA, 0xD1F9, 0xA178, 0xD0BE,
0xA13C, 0xD09F, 0xA11E, 0xA10F, 0xFD0D, 0xA1BE, 0xA19F, 0xFA1D, 0xF43D, 0xE87D,
0xA0BC, 0xD05F, 0xA09E, 0xA08F, 0xA0DF, 0xA05E, 0xA04F, 0x95E0, 0xCAF8, 0xE57E,
0x94F0, 0xCA7C, 0xE53F, 0x9478, 0xCA3E, 0x943C, 0xCA1F, 0x941E, 0xFCB4, 0x96F8,
0xCB7E, 0xFCB2, 0x967C, 0xCB3F, 0xFCB1, 0x963E, 0x961F, 0xF974, 0xFCBB, 0x977E,
0xF972, 0x973F, 0xF971, 0xF2F4, 0xF97B, 0xF2F2, 0xF2F1, 0xE5F4, 0xF2FB, 0xE5F2,
0xE5F1, 0xCBF4, 0xE5FB, 0xCBF2, 0xCBF1, 0xDAF0, 0xED7C, 0xF6BF, 0xB4E0, 0xDA78,
0xED3E, 0xB470, 0xDA3C, 0xED1F, 0xB438, 0xDA1E, 0xB41C, 0xDA0F, 0xB40E, 0x92F0,
0xC97C, 0xE4BF, 0xB6F0, 0x9278, 0xC93E, 0xB678, 0xDB3E, 0xC91F, 0xB63C, 0x921E,
0xB61E, 0x920F, 0xB60F, 0xFC9A, 0x937C, 0xC9BF, 0xFDBA, 0xFC99, 0xB77C, 0x933E,
0xFDB9, 0xB73E, 0x931F, 0xB71F, 0xF93A, 0x93BF, 0xFB7A, 0xF939, 0xB7BF, 0xFB79,
0xF27A, 0xF6FA, 0xF279, 0xF6F9, 0xE4FA, 0xEDFA, 0xE4F9, 0xEDF9, 0xC9FA, 0xC9F9,
0xB2E0, 0xD978, 0xECBE, 0xB270, 0xD93C, 0xEC9F, 0xB238, 0xD91E, 0xB21C, 0xD90F,
0xB20E, 0xB207, 0x9178, 0xC8BE, 0xB378, 0x913C, 0xC89F, 0xB33C, 0xD99F, 0xB31E,
0x910F, 0xB30F, 0xFC8D, 0x91BE, 0xFD9D, 0xB3BE, 0x919F, 0xB39F, 0xF91D, 0xFB3D,
0xF23D, 0xF67D, 0xE47D, 0xECFD, 0xC8FD, 0xB170, 0xD8BC, 0xEC5F, 0xB138, 0xD89E,
0xB11C, 0xD88F, 0xB10E, 0xB107, 0x90BC, 0xC85F, 0xB1BC, 0x909E, 0xB19E, 0x908F,
0xB18F, 0x90DF, 0xB1DF, 0xB0B8, 0xD85E, 0xB09C, 0xD84F, 0xB08E, 0xB087, 0x905E,
0xB0DE, 0x904F, 0xB0CF, 0xB05C, 0xD82F, 0xB04E, 0xB047, 0x902F, 0xB06F, 0xB02E,
0xB027, 0x8AF0, 0xC57C, 0xE2BF, 0x8A78, 0xC53E, 0x8A3C, 0xC51F, 0x8A1E, 0x8A0F,
0xFC5A, 0x8B7C, 0xC5BF, 0xFC59, 0x8B3E, 0x8B1F, 0xF8BA, 0x8BBF, 0xF8B9, 0xF17A,
0xF179, 0xE2FA, 0xE2F9, 0xC5FA, 0xC5F9, 0x9AE0, 0xCD78, 0xE6BE, 0x9A70, 0xCD3C,
0xE69F, 0x9A38, 0xCD1E, 0x9A1C, 0xCD0F, 0x9A0E, 0x9A07, 0x8978, 0xC4BE, 0x9B78,
0x893C, 0xC49F, 0x9B3C, 0xCD9F, 0x9B1E, 0x890F, 0x9B0F, 0xFC4D, 0x89BE, 0xFCDD,
0x9BBE, 0x899F, 0x9B9F, 0xF89D, 0xF9BD, 0xF13D, 0xF37D, 0xE27D, 0xE6FD, 0xC4FD,
0xDD70, 0xEEBC, 0xF75F, 0xBA60, 0xDD38, 0xEE9E, 0xBA30, 0xDD1C, 0xEE8F, 0xBA18,
0xDD0E, 0xBA0C, 0xDD07, 0xBA06, 0x9970, 0xCCBC, 0xE65F, 0xBB70, 0x9938, 0xCC9E,
0xBB38, 0xDD9E, 0xCC8F, 0xBB1C, 0x990E, 0xBB0E, 0x9907, 0xBB07, 0x88BC, 0xC45F,
0x99BC, 0x889E, 0xBBBC, 0x999E, 0x888F, 0xBB9E, 0x998F, 0xBB8F, 0x88DF, 0x99DF,
0xBBDF, 0xB960, 0xDCB8, 0xEE5E, 0xB930, 0xDC9C, 0xEE4F, 0xB918, 0xDC8E, 0xB90C,
0xDC87, 0xB906, 0xB903, 0x98B8, 0xCC5E, 0xB9B8, 0x989C, 0xCC4F, 0xB99C, 0xDCCF,
0xB98E, 0x9887, 0xB987, 0x885E, 0x98DE, 0x884F, 0xB9DE, 0x98CF, 0xB9CF, 0xB8B0,
0xDC5C, 0xEE2F, 0xB898, 0xDC4E, 0xB88C, 0xDC47, 0xB886, 0xB883, 0x985C, 0xCC2F,
0xB8DC, 0x984E, 0xB8CE, 0x9847, 0xB8C7, 0x882F, 0x986F, 0xB8EF, 0xB858, 0xDC2E,
0xB84C, 0xDC27, 0xB846, 0xB843, 0x982E, 0xB86E, 0x9827, 0xB867, 0xB82C, 0xDC17,
0xB826, 0xB823, 0x9817, 0xB837, 0xB816, 0xB813, 0x8578, 0xC2BE, 0x853C, 0xC29F,
0x851E, 0x850F, 0x85BE, 0x859F, 0xF85D, 0xF0BD, 0xE17D, 0xC2FD, 0x8D70, 0xC6BC,
0xE35F, 0x8D38, 0xC69E, 0x8D1C, 0xC68F, 0x8D0E, 0x8D07, 0x84BC, 0xC25F, 0x8DBC,
0x849E, 0x8D9E, 0x848F, 0x8D8F, 0x84DF, 0x8DDF, 0x9D60, 0xCEB8, 0xE75E, 0x9D30,
0xCE9C, 0xE74F, 0x9D18, 0xCE8E, 0x9D0C, 0xCE87, 0x9D06, 0x9D03, 0x8CB8, 0xC65E,
0x9DB8, 0x8C9C, 0xC64F, 0x9D9C, 0x8C8E, 0x9D8E, 0x8C87, 0x9D87, 0x845E, 0x8CDE,
0x844F, 0x9DDE, 0x8CCF, 0x9DCF, 0xDEB0, 0xEF5C, 0xF7AF, 0xBD20, 0xDE98, 0xEF4E,
0xBD10, 0xDE8C, 0xEF47, 0xBD08, 0xDE86, 0xBD04, 0xDE83, 0xBD02, 0x9CB0, 0xCE5C,
0xE72F, 0xBDB0, 0x9C98, 0xCE4E, 0xBD98, 0xDECE, 0xCE47, 0xBD8C, 0x9C86, 0xBD86,
0x9C83, 0xBD83, 0x8C5C, 0xC62F, 0x9CDC, 0x8C4E, 0xBDDC, 0x9CCE, 0x8C47, 0xBDCE,
0x9CC7, 0xBDC7, 0x842F, 0x8C6F, 0x9CEF, 0xBDEF, 0xBCA0, 0xDE58, 0xEF2E, 0xBC90,
0xDE4C, 0xEF27, 0xBC88, 0xDE46, 0xBC84, 0xDE43, 0xBC82, 0xBC81, 0x9C58, 0xCE2E,
0xBCD8, 0x9C4C, 0xCE27, 0xBCCC, 0xDE67, 0xBCC6, 0x9C43, 0xBCC3, 0x8C2E, 0x9C6E,
0x8C27, 0xBCEE, 0x9C67, 0xBCE7, 0xBC50, 0xDE2C, 0xEF17, 0xBC48, 0xDE26, 0xBC44,
0xDE23, 0xBC42, 0xBC41, 0x9C2C, 0xCE17, 0xBC6C, 0x9C26, 0xBC66, 0x9C23, 0xBC63,
0x8C17, 0x9C37, 0xBC77, 0xBC28, 0xDE16, 0xBC24, 0xDE13, 0xBC22, 0xBC21, 0x9C16,
0xBC36, 0x9C13, 0xBC33, 0xBC14, 0xDE0B, 0xBC12, 0xBC11, 0x9C0B, 0xBC1B, 0x82BC,
0xC15F, 0x829E, 0x828F, 0x82DF, 0x86B8, 0xC35E, 0x869C, 0xC34F, 0x868E, 0x8687,
0x825E, 0x86DE, 0x824F, 0x86CF, 0x8EB0, 0xC75C, 0xE3AF, 0x8E98, 0xC74E, 0x8E8C,
0xC747, 0x8E86, 0x8E83, 0x865C, 0xC32F, 0x8EDC, 0x864E, 0x8ECE, 0x8647, 0x8EC7,
0x822F, 0x866F, 0x8EEF, 0x9EA0, 0xCF58, 0xE7AE, 0x9E90, 0xCF4C, 0xE7A7, 0x9E88,
0xCF46, 0x9E84, 0xCF43, 0x9E82, 0x9E81, 0x8E58, 0xC72E, 0x9ED8, 0x8E4C, 0xC727,
0x9ECC, 0xCF67, 0x9EC6, 0x8E43, 0x9EC3, 0x862E, 0x8E6E, 0x8627, 0x9EEE, 0x8E67,
0x9EE7, 0xDF50, 0xEFAC, 0xF7D7, 0xDF48, 0xEFA6, 0xDF44, 0xEFA3, 0xDF42, 0xDF41,
0x9E50, 0xCF2C, 0xE797, 0xBED0, 0x9E48, 0xCF26, 0xBEC8, 0xDF66, 0xCF23, 0xBEC4,
0x9E42, 0xBEC2, 0x9E41, 0xBEC1, 0x8E2C, 0xC717, 0x9E6C, 0x8E26, 0xBEEC, 0x9E66,
0x8E23, 0xBEE6, 0x9E63, 0xBEE3, 0x8617, 0x8E37, 0x9E77, 0xBEF7, 0xDF28, 0xEF96,
0xDF24, 0xEF93, 0xDF22, 0xDF21, 0x9E28, 0xCF16, 0xBE68, 0x9E24, 0xCF13, 0xBE64,
0xDF33, 0xBE62, 0x9E21, 0xBE61, 0x8E16, 0x9E36, 0x8E13, 0xBE76, 0x9E33, 0xBE73,
0xDF14, 0xEF8B, 0xDF12, 0xDF11, 0x9E14, 0xCF0B, 0xBE34, 0x9E12, 0xBE32, 0x9E11,
0xBE31, 0x8E0B, 0x9E1B, 0xBE3B, 0xDF0A, 0xDF09, 0x9E0A, 0xBE1A, 0x9E09, 0xBE19,
0x815E, 0x814F, 0x835C, 0xC1AF, 0x834E, 0x8347, 0x812F, 0x836F, 0x8758, 0xC3AE,
0x874C, 0xC3A7, 0x8746, 0x8743, 0x832E, 0x876E, 0x8327, 0x8767, 0x8F50, 0xC7AC,
0xE3D7, 0x8F48, 0xC7A6, 0x8F44, 0xC7A3, 0x8F42, 0x8F41, 0x872C, 0xC397, 0x8F6C,
0xC7B7, 0x8F66, 0x8723, 0x8F63, 0x8317, 0x8737, 0x8F77, 0xCFA8, 0xE7D6, 0xCFA4,
0xE7D3, 0xCFA2, 0xCFA1, 0x8F28, 0xC796, 0x9F68, 0xCFB6, 0xC793, 0x9F64, 0x8F22,
0x9F62, 0x8F21, 0x9F61, 0x8716, 0x8F36, 0x8713, 0x9F76, 0x8F33, 0x9F73, 0xEFD4,
0xF7EB, 0xEFD2, 0xEFD1, 0xCF94, 0xE7CB, 0xDFB4, 0xCF92, 0xDFB2, 0xCF91, 0xDFB1,
0x8F14, 0xC78B, 0x9F34, 0x8F12, 0xBF74, 0x9F32, 0x8F11, 0xBF72, 0x9F31, 0xBF71,
0x870B, 0x8F1B, 0x9F3B, 0xBF7B, 0xEFCA, 0xEFC9, 0xCF8A, 0xDF9A, 0xCF89, 0xDF99,
0x8F0A, 0x9F1A, 0x8F09, 0xBF3A, 0x9F19, 0xBF39, 0xEFC5, 0xCF85, 0xDF8D, 0x8F05,
0x9F0D, 0xBF1D, 0x81AE, 0x81A7, 0x83AC, 0xC1D7, 0x83A6, 0x83A3, 0x8197, 0x83B7,
0x87A8, 0xC3D6, 0x87A4, 0xC3D3, 0x87A2, 0x87A1, 0x8396, 0x87B6, 0x8393, 0x87B3,
0xC7D4, 0xE3EB, 0xC7D2, 0xC7D1, 0x8794, 0xC3CB, 0x8FB4, 0xC7DB, 0x8FB2, 0x8791,
0x8FB1, 0x838B, 0x879B, 0x8FBB, 0xE7EA, 0xE7E9, 0xC7CA, 0xCFDA, 0xC7C9, 0xCFD9,
0x878A, 0x8F9A, 0x8789, 0x9FBA, 0x8F99, 0x9FB9, 0xE7E5, 0xC7C5, 0xCFCD, 0x8785,
0x8F8D, 0x9F9D, 0x81D6, 0x81D3, 0x83D4, 0xC1EB, 0x83D2, 0x83D1, 0x81CB, 0x83DB,
0xC3EA, 0xC3E9, 0x83CA, 0x87DA, 0x83C9, 0x87D9, 0xE3F5
};
/* MicroPDF417 coefficients from ISO/IEC 24728:2006 Annex F */
static const unsigned short int Microcoeffs[344] = {
/* k = 7 */
76, 925, 537, 597, 784, 691, 437,
/* k = 8 */
237, 308, 436, 284, 646, 653, 428, 379,
/* k = 9 */
567, 527, 622, 257, 289, 362, 501, 441, 205,
/* k = 10 */
377, 457, 64, 244, 826, 841, 818, 691, 266, 612,
/* k = 11 */
462, 45, 565, 708, 825, 213, 15, 68, 327, 602, 904,
/* k = 12 */
597, 864, 757, 201, 646, 684, 347, 127, 388, 7, 69, 851,
/* k = 13 */
764, 713, 342, 384, 606, 583, 322, 592, 678, 204, 184, 394, 692,
/* k = 14 */
669, 677, 154, 187, 241, 286, 274, 354, 478, 915, 691, 833, 105, 215,
/* k = 15 */
460, 829, 476, 109, 904, 664, 230, 5, 80, 74, 550, 575, 147, 868, 642,
/* k = 16 */
274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176, 65,
/* k = 18 */
279, 577, 315, 624, 37, 855, 275, 739, 120, 297, 312, 202, 560, 321, 233, 756,
760, 573,
/* k = 21 */
108, 519, 781, 534, 129, 425, 681, 553, 422, 716, 763, 693, 624, 610, 310, 691,
347, 165, 193, 259, 568,
/* k = 26 */
443, 284, 887, 544, 788, 93, 477, 760, 331, 608, 269, 121, 159, 830, 446, 893,
699, 245, 441, 454, 325, 858, 131, 847, 764, 169,
/* k = 32 */
361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, 517,
273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330, 63, 410,
/* k = 38 */
234, 228, 438, 848, 133, 703, 529, 721, 788, 322, 280, 159, 738, 586, 388, 684,
445, 680, 245, 595, 614, 233, 812, 32, 284, 658, 745, 229, 95, 689, 920, 771,
554, 289, 231, 125, 117, 518,
/* k = 44 */
476, 36, 659, 848, 678, 64, 764, 840, 157, 915, 470, 876, 109, 25, 632, 405,
417, 436, 714, 60, 376, 97, 413, 706, 446, 21, 3, 773, 569, 267, 272, 213,
31, 560, 231, 758, 103, 271, 572, 436, 339, 730, 82, 285,
/* k = 50 */
923, 797, 576, 875, 156, 706, 63, 81, 257, 874, 411, 416, 778, 50, 205, 303,
188, 535, 909, 155, 637, 230, 534, 96, 575, 102, 264, 233, 919, 593, 865, 26,
579, 623, 766, 146, 10, 739, 246, 127, 71, 244, 211, 477, 920, 876, 427, 820,
718, 435
};
/* rows, columns, error codewords, k-offset of valid MicroPDF417 sizes from ISO/IEC 24728:2006 */
static const unsigned short int MicroVariants[170] ={
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
11, 14, 17, 20, 24, 28, 8, 11, 14, 17, 20, 23, 26, 6, 8, 10, 12, 15, 20, 26, 32, 38, 44, 4, 6, 8, 10, 12, 15, 20, 26, 32, 38, 44,
7, 7, 7, 8, 8, 8, 8, 9, 9, 10, 11, 13, 15, 12, 14, 16, 18, 21, 26, 32, 38, 44, 50, 8, 12, 14, 16, 18, 21, 26, 32, 38, 44, 50,
0, 0, 0, 7, 7, 7, 7, 15, 15, 24, 34, 57, 84, 45, 70, 99, 115, 133, 154, 180, 212, 250, 294, 7, 45, 70, 99, 115, 133, 154, 180, 212, 250, 294
};
/* rows, columns, error codewords, k-offset */
/* following is Left RAP, Centre RAP, Right RAP and Start Cluster from ISO/IEC 24728:2006 tables 10, 11 and 12 */
static const char RAPTable[136] ={
1, 8, 36, 19, 9, 25, 1, 1, 8, 36, 19, 9, 27, 1, 7, 15, 25, 37, 1, 1, 21, 15, 1, 47, 1, 7, 15, 25, 37, 1, 1, 21, 15, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 25, 37, 17, 9, 29, 31, 25, 19, 1, 7, 15, 25, 37, 17, 9, 29, 31, 25,
9, 8, 36, 19, 17, 33, 1, 9, 8, 36, 19, 17, 35, 1, 7, 15, 25, 37, 33, 17, 37, 47, 49, 43, 1, 7, 15, 25, 37, 33, 17, 37, 47, 49,
0, 3, 6, 0, 6, 0, 0, 0, 3, 6, 0, 6, 6, 0, 0, 6, 0, 0, 0, 0, 6, 6, 0, 3, 0, 0, 6, 0, 0, 0, 0, 6, 6, 0
};
/* Left and Right Row Address Pattern from Table 2 */
static const unsigned short int rap_side[52] = {
0x322, 0x3A2, 0x3B2, 0x332, 0x372, 0x37A, 0x33A, 0x3BA, 0x39A, 0x3DA,
0x3CA, 0x38A, 0x30A, 0x31A, 0x312, 0x392, 0x3D2, 0x3D6, 0x3D4, 0x394,
0x3B4, 0x3A4, 0x3A6, 0x3AE, 0x3AC, 0x3A8, 0x328, 0x32C, 0x32E, 0x326,
0x336, 0x3B6, 0x396, 0x316, 0x314, 0x334, 0x374, 0x364, 0x366, 0x36E,
0x36C, 0x368, 0x348, 0x358, 0x35C, 0x35E, 0x34E, 0x34C, 0x344, 0x346,
0x342, 0x362
};
/* Centre Row Address Pattern from Table 2 */
static const unsigned short int rap_centre[52] = {
0x2CE, 0x24E, 0x26E, 0x22E, 0x226, 0x236, 0x216, 0x212, 0x21A, 0x23A,
0x232, 0x222, 0x262, 0x272, 0x27A, 0x2FA, 0x2F2, 0x2F6, 0x276, 0x274,
0x264, 0x266, 0x246, 0x242, 0x2C2, 0x2E2, 0x2E6, 0x2E4, 0x2EC, 0x26C,
0x22C, 0x228, 0x268, 0x2E8, 0x2C8, 0x2CC, 0x2C4, 0x2C6, 0x286, 0x28E,
0x28C, 0x29C, 0x298, 0x2B8, 0x2B0, 0x290, 0x2D0, 0x250, 0x258, 0x25C,
0x2DC, 0x2DE
};
INTERNAL void byteprocess(int *chainemc, int *mclength, const unsigned char chaine[], int start, const int length,
const int debug);
#endif /* __PDF417_H */

345
3rdparty/zint-2.10.0/backend/plessey.c vendored Normal file
View File

@@ -0,0 +1,345 @@
/* plessey.c - Handles Plessey and MSI Plessey */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include "common.h"
#define SSET "0123456789ABCDEF"
static const char *PlessTable[16] = {
"13131313", "31131313", "13311313", "31311313",
"13133113", "31133113", "13313113", "31313113",
"13131331", "31131331", "13311331", "31311331",
"13133131", "31133131", "13313131", "31313131"
};
static const char *MSITable[10] = {
"12121212", "12121221", "12122112", "12122121", "12211212",
"12211221", "12212112", "12212121", "21121212", "21121221"
};
/* Not MSI/Plessey but the older Plessey standard */
INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
unsigned char *checkptr;
static const char grid[9] = {1, 1, 1, 1, 0, 1, 0, 0, 1};
char dest[554]; /* 8 + 65 * 8 + 8 * 2 + 9 + 1 = 554 */
int error_number;
if (length > 65) {
strcpy(symbol->errtxt, "370: Input too long (65 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "371: Invalid character in data (digits and \"ABCDEF\" only)");
return error_number;
}
if (!(checkptr = (unsigned char *) calloc(1, length * 4 + 8))) {
strcpy(symbol->errtxt, "373: Insufficient memory for check digit CRC buffer");
return ZINT_ERROR_MEMORY;
}
/* Start character */
strcpy(dest, "31311331");
/* Data area */
for (i = 0; i < length; i++) {
unsigned int check = posn(SSET, source[i]);
lookup(SSET, PlessTable, source[i], dest);
checkptr[4 * i] = check & 1;
checkptr[4 * i + 1] = (check >> 1) & 1;
checkptr[4 * i + 2] = (check >> 2) & 1;
checkptr[4 * i + 3] = (check >> 3) & 1;
}
/* CRC check digit code adapted from code by Leonid A. Broukhis
used in GNU Barcode */
for (i = 0; i < (4 * length); i++) {
if (checkptr[i]) {
int j;
for (j = 0; j < 9; j++)
checkptr[i + j] ^= grid[j];
}
}
for (i = 0; i < 8; i++) {
switch (checkptr[length * 4 + i]) {
case 0: strcat(dest, "13");
break;
case 1: strcat(dest, "31");
break;
}
}
/* Stop character */
strcat(dest, "331311313");
expand(symbol, dest);
// TODO: Find documentation on BARCODE_PLESSEY dimensions/height
symbol->text[0] = '\0';
ustrncat(symbol->text, source, length);
free(checkptr);
return error_number;
}
/* Modulo 10 check digit - Luhn algorithm
See https://en.wikipedia.org/wiki/Luhn_algorithm */
static char msi_check_digit_mod10(const unsigned char source[], const int length) {
static const int vals[2][10] = {
{ 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 }, /* Doubled and digits summed */
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, /* Single */
};
int i, x = 0, undoubled = 0;
for (i = length - 1; i >= 0; i--) {
/* Note overflow impossible for max length 65 * max weight 9 * max val 15 == 8775 */
x += vals[undoubled][ctoi(source[i])];
undoubled = !undoubled;
}
return itoc((10 - x % 10) % 10);
}
/* Modulo 11 check digit - IBM weight system wrap = 7, NCR system wrap = 9
See https://en.wikipedia.org/wiki/MSI_Barcode */
static char msi_check_digit_mod11(const unsigned char source[], const int length, const int wrap) {
int i, x = 0, weight = 2;
for (i = length - 1; i >= 0; i--) {
/* Note overflow impossible for max length 65 * max weight 9 * max val 15 == 8775 */
x += weight * ctoi(source[i]);
weight++;
if (weight > wrap) {
weight = 2;
}
}
return itoc((11 - x % 11) % 11); /* Will return 'A' for 10 */
}
/* Plain MSI Plessey - does not calculate any check character */
static void msi_plessey(struct zint_symbol *symbol, const unsigned char source[], const int length, char dest[]) {
int i;
for (i = 0; i < length; i++) {
lookup(NEON, MSITable, source[i], dest);
}
symbol->text[0] = '\0';
ustrncat(symbol->text, source, length);
}
/* MSI Plessey with Modulo 10 check digit */
static void msi_plessey_mod10(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int no_checktext, char dest[]) {
int i;
char check_digit;
/* draw data section */
for (i = 0; i < length; i++) {
lookup(NEON, MSITable, source[i], dest);
}
/* calculate check digit */
check_digit = msi_check_digit_mod10(source, length);
/* draw check digit */
lookup(NEON, MSITable, check_digit, dest);
symbol->text[0] = '\0';
ustrncat(symbol->text, source, length);
if (!no_checktext) {
symbol->text[length] = check_digit;
symbol->text[length + 1] = '\0';
}
}
/* MSI Plessey with two Modulo 10 check digits */
static void msi_plessey_mod1010(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int no_checktext, char dest[]) {
int i;
unsigned char temp[65 + 2 + 1];
/* Append check digits */
temp[0] = '\0';
ustrncat(temp, source, length);
temp[length] = msi_check_digit_mod10(source, length);
temp[length + 1] = msi_check_digit_mod10(temp, length + 1);
temp[length + 2] = '\0';
/* draw data section */
for (i = 0; i < length + 2; i++) {
lookup(NEON, MSITable, temp[i], dest);
}
if (no_checktext) {
symbol->text[0] = '\0';
ustrncat(symbol->text, source, length);
} else {
ustrcpy(symbol->text, temp);
}
}
/* MSI Plessey with Modulo 11 check digit */
static void msi_plessey_mod11(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int no_checktext, const int wrap, char dest[]) {
/* Uses the IBM weight system if wrap = 7, and the NCR system if wrap = 9 */
int i;
char check_digit;
/* draw data section */
for (i = 0; i < length; i++) {
lookup(NEON, MSITable, source[i], dest);
}
/* Append check digit */
check_digit = msi_check_digit_mod11(source, length, wrap);
if (check_digit == 'A') {
lookup(NEON, MSITable, '1', dest);
lookup(NEON, MSITable, '0', dest);
} else {
lookup(NEON, MSITable, check_digit, dest);
}
symbol->text[0] = '\0';
ustrncat(symbol->text, source, length);
if (!no_checktext) {
if (check_digit == 'A') {
ustrcat(symbol->text, "10");
} else {
symbol->text[length] = check_digit;
symbol->text[length + 1] = '\0';
}
}
}
/* MSI Plessey with Modulo 11 check digit and Modulo 10 check digit */
static void msi_plessey_mod1110(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int no_checktext, const int wrap, char dest[]) {
/* Uses the IBM weight system if wrap = 7, and the NCR system if wrap = 9 */
int i;
char check_digit;
unsigned char temp[65 + 3 + 1];
int temp_len = length;
temp[0] = '\0';
ustrncat(temp, source, length);
/* Append first (mod 11) digit */
check_digit = msi_check_digit_mod11(source, length, wrap);
if (check_digit == 'A') {
temp[temp_len++] = '1';
temp[temp_len++] = '0';
} else {
temp[temp_len++] = check_digit;
}
/* Append second (mod 10) check digit */
temp[temp_len] = msi_check_digit_mod10(temp, temp_len);
temp[++temp_len] = '\0';
/* draw data section */
for (i = 0; i < temp_len; i++) {
lookup(NEON, MSITable, temp[i], dest);
}
if (no_checktext) {
symbol->text[0] = '\0';
ustrncat(symbol->text, source, length);
} else {
ustrcpy(symbol->text, temp);
}
}
INTERNAL int msi_handle(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number;
char dest[550]; /* 2 + 65 * 8 + 3 * 8 + 3 + 1 = 550 */
int check_option = symbol->option_2;
int no_checktext = 0;
if (length > 65) {
strcpy(symbol->errtxt, "372: Input too long (65 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number != 0) {
strcpy(symbol->errtxt, "377: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
if (check_option >= 11 && check_option <= 16) { /* +10 means don't print check digits in HRT */
check_option -= 10;
no_checktext = 1;
}
if ((check_option < 0) || (check_option > 6)) {
check_option = 0;
}
/* Start character */
strcpy(dest, "21");
switch (check_option) {
case 0: msi_plessey(symbol, source, length, dest);
break;
case 1: msi_plessey_mod10(symbol, source, length, no_checktext, dest);
break;
case 2: msi_plessey_mod1010(symbol, source, length, no_checktext, dest);
break;
case 3: msi_plessey_mod11(symbol, source, length, no_checktext, 7 /*IBM wrap*/, dest);
break;
case 4: msi_plessey_mod1110(symbol, source, length, no_checktext, 7 /*IBM wrap*/, dest);
break;
case 5: msi_plessey_mod11(symbol, source, length, no_checktext, 9 /*NCR wrap*/, dest);
break;
case 6: msi_plessey_mod1110(symbol, source, length, no_checktext, 9 /*NCR wrap*/, dest);
break;
}
/* Stop character */
strcat(dest, "121");
expand(symbol, dest);
// TODO: Find documentation on BARCODE_MSI_PLESSEY dimensions/height
return error_number;
}

344
3rdparty/zint-2.10.0/backend/png.c vendored Normal file
View File

@@ -0,0 +1,344 @@
/* png.c - Handles output to PNG file */
/*
libzint - the open source barcode library
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef NO_PNG
#include <errno.h>
#include <stdio.h>
#ifdef _MSC_VER
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
#endif
#include "common.h"
#include <png.h>
#include <zlib.h>
#include <setjmp.h>
#define SSET "0123456789ABCDEF"
/* Note if change this need to change "backend/tests/test_png.c" definition also */
struct wpng_error_type {
struct zint_symbol *symbol;
jmp_buf jmpbuf;
};
STATIC_UNLESS_ZINT_TEST void wpng_error_handler(png_structp png_ptr, png_const_charp msg) {
struct wpng_error_type *wpng_error_ptr;
wpng_error_ptr = (struct wpng_error_type *) png_get_error_ptr(png_ptr);
if (wpng_error_ptr == NULL) {
/* we are completely hosed now */
fprintf(stderr, "Error 636: libpng error: %s\n", msg ? msg : "<NULL>");
fprintf(stderr, "Error 637: jmpbuf not recoverable, terminating\n");
fflush(stderr);
return; /* libpng will call abort() */
}
sprintf(wpng_error_ptr->symbol->errtxt, "635: libpng error: %.60s", msg ? msg : "<NULL>");
longjmp(wpng_error_ptr->jmpbuf, 1);
}
/* Guestimate best compression strategy */
static int guess_compression_strategy(struct zint_symbol *symbol, unsigned char *pixelbuf) {
(void)pixelbuf;
/* TODO: Do properly */
/* It seems the best choice for typical barcode pngs is one of Z_DEFAULT_STRATEGY and Z_FILTERED */
/* Some guesses */
if (symbol->symbology == BARCODE_MAXICODE) {
return Z_DEFAULT_STRATEGY;
}
if (symbol->symbology == BARCODE_AZTEC && symbol->bitmap_width <= 30) {
return Z_DEFAULT_STRATEGY;
}
/* Z_FILTERED seems to work better for slightly more barcodes+data so default to that */
return Z_FILTERED;
}
INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
struct wpng_error_type wpng_error;
FILE *outfile;
png_structp png_ptr;
png_infop info_ptr;
int i;
int row, column;
png_color bg, fg;
unsigned char bg_alpha, fg_alpha;
unsigned char map[128];
png_color palette[32];
int num_palette;
unsigned char trans_alpha[32];
int num_trans;
int bit_depth;
int compression_strategy;
unsigned char *pb;
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT;
#ifndef _MSC_VER
unsigned char outdata[symbol->bitmap_width];
#else
unsigned char *outdata = (unsigned char *) _alloca(symbol->bitmap_width);
#endif
wpng_error.symbol = symbol;
fg.red = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fg.green = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fg.blue = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bg.red = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bg.green = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bg.blue = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
if (strlen(symbol->fgcolour) > 6) {
fg_alpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
} else {
fg_alpha = 0xff;
}
if (strlen(symbol->bgcolour) > 6) {
bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
} else {
bg_alpha = 0xff;
}
num_trans = 0;
if (symbol->symbology == BARCODE_ULTRA) {
static const int ultra_chars[8] = { 'W', 'C', 'B', 'M', 'R', 'Y', 'G', 'K' };
static const png_color ultra_colours[8] = {
{ 0xff, 0xff, 0xff, }, /* White */
{ 0, 0xff, 0xff, }, /* Cyan */
{ 0, 0, 0xff, }, /* Blue */
{ 0xff, 0, 0xff, }, /* Magenta */
{ 0xff, 0, 0, }, /* Red */
{ 0xff, 0xff, 0, }, /* Yellow */
{ 0, 0xff, 0, }, /* Green */
{ 0, 0, 0, }, /* Black */
};
for (i = 0; i < 8; i++) {
map[ultra_chars[i]] = i;
palette[i] = ultra_colours[i];
if (fg_alpha != 0xff) {
trans_alpha[i] = fg_alpha;
}
}
num_palette = 8;
if (fg_alpha != 0xff) {
num_trans = 8;
}
/* For Ultracode, have foreground only if have bind/box */
if (symbol->border_width > 0 && (symbol->output_options & (BARCODE_BIND | BARCODE_BOX))) {
/* Check whether can re-use black */
if (fg.red == 0 && fg.green == 0 && fg.blue == 0) {
map['1'] = 7; /* Re-use black */
} else {
map['1'] = num_palette;
palette[num_palette++] = fg;
if (fg_alpha != 0xff) {
trans_alpha[num_trans++] = fg_alpha;
}
}
}
/* For Ultracode, have background only if have whitespace/quiet zones */
if (symbol->whitespace_width > 0 || symbol->whitespace_height > 0) { /* TODO: BARCODE_QUIET_ZONES also */
/* Check whether can re-use white */
if (bg.red == 0xff && bg.green == 0xff && bg.blue == 0xff && bg_alpha == fg_alpha) {
map['0'] = 0; /* Re-use white */
} else {
if (bg_alpha == 0xff || fg_alpha != 0xff) {
/* No alpha or have foreground alpha - add to end */
map['0'] = num_palette;
palette[num_palette++] = bg;
} else {
/* Alpha and no foreground alpha - add to front & move white to end */
map['0'] = 0;
palette[0] = bg;
map['W'] = num_palette;
palette[num_palette++] = ultra_colours[0];
}
if (bg_alpha != 0xff) {
trans_alpha[num_trans++] = bg_alpha;
}
}
}
} else {
int bg_idx = 0, fg_idx = 1;
/* Do alphas first so can swop indexes if background not alpha */
if (bg_alpha != 0xff) {
trans_alpha[num_trans++] = bg_alpha;
}
if (fg_alpha != 0xff) {
trans_alpha[num_trans++] = fg_alpha;
if (num_trans == 1) {
/* Only foreground has alpha so swop indexes - saves a byte! */
bg_idx = 1;
fg_idx = 0;
}
}
map['0'] = bg_idx;
palette[bg_idx] = bg;
map['1'] = fg_idx;
palette[fg_idx] = fg;
num_palette = 2;
}
if (num_palette <= 2) {
bit_depth = 1;
} else {
bit_depth = 4;
}
/* Open output file in binary mode */
if (output_to_stdout) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
sprintf(symbol->errtxt, "631: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
#endif
outfile = stdout;
} else {
if (!(outfile = fopen(symbol->outfile, "wb"))) {
sprintf(symbol->errtxt, "632: Could not open output file (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
}
/* Set up error handling routine as proc() above */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &wpng_error, wpng_error_handler, NULL);
if (!png_ptr) {
strcpy(symbol->errtxt, "633: Insufficient memory for PNG write structure buffer");
if (!output_to_stdout) {
fclose(outfile);
}
return ZINT_ERROR_MEMORY;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_write_struct(&png_ptr, NULL);
strcpy(symbol->errtxt, "634: Insufficient memory for PNG info structure buffer");
if (!output_to_stdout) {
fclose(outfile);
}
return ZINT_ERROR_MEMORY;
}
/* catch jumping here */
if (setjmp(wpng_error.jmpbuf)) {
png_destroy_write_struct(&png_ptr, &info_ptr);
if (!output_to_stdout) {
fclose(outfile);
}
return ZINT_ERROR_MEMORY;
}
/* open output file with libpng */
png_init_io(png_ptr, outfile);
/* set compression */
png_set_compression_level(png_ptr, 9);
/* Compression strategy can make a difference */
compression_strategy = guess_compression_strategy(symbol, pixelbuf);
if (compression_strategy != Z_DEFAULT_STRATEGY) {
png_set_compression_strategy(png_ptr, compression_strategy);
}
/* set Header block */
png_set_IHDR(png_ptr, info_ptr, symbol->bitmap_width, symbol->bitmap_height,
bit_depth, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
if (num_trans) {
png_set_tRNS(png_ptr, info_ptr, trans_alpha, num_trans, NULL);
}
/* write all chunks up to (but not including) first IDAT */
png_write_info(png_ptr, info_ptr);
/* Pixel Plotting */
pb = pixelbuf;
if (bit_depth == 1) {
for (row = 0; row < symbol->bitmap_height; row++) {
unsigned char *image_data = outdata;
for (column = 0; column < symbol->bitmap_width; column += 8, image_data++) {
unsigned char byte = 0;
for (i = 0; i < 8 && column + i < symbol->bitmap_width; i++, pb++) {
byte |= map[*pb] << (7 - i);
}
*image_data = byte;
}
/* write row contents to file */
png_write_row(png_ptr, outdata);
}
} else { /* Bit depth 4 */
for (row = 0; row < symbol->bitmap_height; row++) {
unsigned char *image_data = outdata;
for (column = 0; column < symbol->bitmap_width; column += 2, image_data++) {
unsigned char byte = map[*pb++] << 4;
if (column + 1 < symbol->bitmap_width) {
byte |= map[*pb++];
}
*image_data = byte;
}
/* write row contents to file */
png_write_row(png_ptr, outdata);
}
}
/* End the file */
png_write_end(png_ptr, NULL);
/* make sure we have disengaged */
png_destroy_write_struct(&png_ptr, &info_ptr);
if (output_to_stdout) {
fflush(outfile);
} else {
fclose(outfile);
}
return 0;
}
#else
/* https://stackoverflow.com/a/26541331/664741 Suppresses gcc warning ISO C forbids an empty translation unit */
typedef int make_iso_compilers_happy;
#endif /* NO_PNG */

740
3rdparty/zint-2.10.0/backend/postal.c vendored Normal file
View File

@@ -0,0 +1,740 @@
/* postal.c - Handles PostNet, PLANET, FIM. RM4SCC and Flattermarken */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Including bug fixes by Bryan Hatton
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#define DAFTSET "DAFT"
#define KRSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define KASUTSET "1234567890-abcdefgh"
#define CHKASUTSET "0123456789-abcdefgh"
#define SHKASUTSET "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ"
/* PostNet number encoding table - In this table L is long as S is short */
static const char *PNTable[10] = {
"LLSSS", "SSSLL", "SSLSL", "SSLLS", "SLSSL", "SLSLS", "SLLSS", "LSSSL",
"LSSLS", "LSLSS"
};
static const char *PLTable[10] = {
"SSLLL", "LLLSS", "LLSLS", "LLSSL", "LSLLS", "LSLSL", "LSSLL", "SLLLS",
"SLLSL", "SLSLL"
};
static const char *RoyalValues[36] = {
"11", "12", "13", "14", "15", "10", "21", "22", "23", "24", "25",
"20", "31", "32", "33", "34", "35", "30", "41", "42", "43", "44", "45", "40", "51", "52",
"53", "54", "55", "50", "01", "02", "03", "04", "05", "00"
};
/* 0 = Full, 1 = Ascender, 2 = Descender, 3 = Tracker */
static const char *RoyalTable[36] = {
"3300", "3210", "3201", "2310", "2301", "2211", "3120", "3030", "3021",
"2130", "2121", "2031", "3102", "3012", "3003", "2112", "2103", "2013", "1320", "1230",
"1221", "0330", "0321", "0231", "1302", "1212", "1203", "0312", "0303", "0213", "1122",
"1032", "1023", "0132", "0123", "0033"
};
static const char *FlatTable[10] = {
"0504", "18", "0117", "0216", "0315", "0414", "0513", "0612", "0711", "0810"
};
static const char *KoreaTable[10] = {
"1313150613", "0713131313", "0417131313", "1506131313",
"0413171313", "17171313", "1315061313", "0413131713", "17131713", "13171713"
};
static const char *JapanTable[19] = {
"114", "132", "312", "123", "141", "321", "213", "231", "411", "144",
"414", "324", "342", "234", "432", "243", "423", "441", "111"
};
/* Set height for POSTNET/PLANET codes, maintaining ratio */
static int usps_set_height(struct zint_symbol *symbol, const int no_errtxt) {
/* USPS Domestic Mail Manual (USPS DMM 300) Jan 8, 2006 (updated 2011) 708.4.2.5 POSTNET Barcode Dimensions and
Spacing
http://web.archive.org/web/20061113174253/http://pe.usps.com/cpim/ftp/manuals/dmm300/full/mailingStandards.pdf
Using bar pitch as X (1" / 43) ~ 0.023" based on 22 bars + 21 spaces per inch (bar width 0.015" - 0.025")
Half bar height 0.05" +- 0.01; 0.040" (min) / 0.025" (X max) = 1.6 min, 0.060" (max) / 0.015" (X min) = 4 max
Full bar height 0.125" +- 0.01; 0.115" (min) / 0.025" (X max) = 4.6 min, 0.135" (max) / 0.015" (X min) = 9 max
*/
int error_number = 0;
float h_ratio; /* Half ratio */
#ifdef COMPLIANT_HEIGHTS
symbol->row_height[0] = 0.075f * 43; /* 3.225 */
symbol->row_height[1] = 0.05f * 43; /* 2.15 */
#else
symbol->row_height[0] = 6.0f;
symbol->row_height[1] = 6.0f;
#endif
if (symbol->height) {
h_ratio = symbol->row_height[1] / (symbol->row_height[0] + symbol->row_height[1]); /* 0.4 */
symbol->row_height[1] = symbol->height * h_ratio;
if (symbol->row_height[1] < 0.5f) { /* Absolute minimum */
symbol->row_height[1] = 0.5f;
symbol->row_height[0] = 0.5f / h_ratio - 0.5f; /* 0.75 */
} else {
symbol->row_height[0] = symbol->height - symbol->row_height[1];
}
}
symbol->height = symbol->row_height[0] + symbol->row_height[1];
#ifdef COMPLIANT_HEIGHTS
if (symbol->height < 4.6f || symbol->height > 9.0f) {
error_number = ZINT_WARN_NONCOMPLIANT;
if (!no_errtxt) {
strcpy(symbol->errtxt, "498: Height not compliant with standards");
}
}
#else
(void)&no_errtxt;
#endif
return error_number;
}
/* Handles the PostNet system used for Zip codes in the US */
static int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
int i, sum, check_digit;
int error_number = 0;
if (length > 38) {
strcpy(symbol->errtxt, "480: Input too long (38 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
if (length != 5 && length != 9 && length != 11) {
strcpy(symbol->errtxt, "479: Input length is not standard (5, 9 or 11 characters)");
error_number = ZINT_WARN_NONCOMPLIANT;
}
if (is_sane(NEON, source, length) == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "481: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
sum = 0;
/* start character */
strcpy(dest, "L");
for (i = 0; i < length; i++) {
lookup(NEON, PNTable, source[i], dest);
sum += ctoi(source[i]);
}
check_digit = (10 - (sum % 10)) % 10;
strcat(dest, PNTable[check_digit]);
/* stop character */
strcat(dest, "L");
return error_number;
}
/* Puts PostNet barcodes into the pattern matrix */
INTERNAL int post_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 + 1 = 206 */
unsigned int loopey, h;
int writer;
int error_number, warn_number;
error_number = postnet(symbol, source, height_pattern, length);
if (error_number >= ZINT_ERROR) {
return error_number;
}
writer = 0;
h = (int) strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if (height_pattern[loopey] == 'L') {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
writer += 2;
}
warn_number = usps_set_height(symbol, error_number /*no_errtxt*/);
symbol->rows = 2;
symbol->width = writer - 1;
return error_number ? error_number : warn_number;
}
/* Handles the PLANET system used for item tracking in the US */
static int planet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
int i, sum, check_digit;
int error_number = 0;
if (length > 38) {
strcpy(symbol->errtxt, "482: Input too long (38 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
if (length != 11 && length != 13) {
strcpy(symbol->errtxt, "478: Input length is not standard (11 or 13 characters)");
error_number = ZINT_WARN_NONCOMPLIANT;
}
if (is_sane(NEON, source, length) == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "483: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
sum = 0;
/* start character */
strcpy(dest, "L");
for (i = 0; i < length; i++) {
lookup(NEON, PLTable, source[i], dest);
sum += ctoi(source[i]);
}
check_digit = (10 - (sum % 10)) % 10;
strcat(dest, PLTable[check_digit]);
/* stop character */
strcat(dest, "L");
return error_number;
}
/* Puts PLANET barcodes into the pattern matrix */
INTERNAL int planet_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 + 1 = 206 */
unsigned int loopey, h;
int writer;
int error_number, warn_number;
error_number = planet(symbol, source, height_pattern, length);
if (error_number >= ZINT_ERROR) {
return error_number;
}
writer = 0;
h = (int) strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if (height_pattern[loopey] == 'L') {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
writer += 2;
}
warn_number = usps_set_height(symbol, error_number /*no_errtxt*/);
symbol->rows = 2;
symbol->width = writer - 1;
return error_number ? error_number : warn_number;
}
/* Korean Postal Authority */
INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int length) {
int total, loop, check, zeroes, error_number;
char localstr[8], dest[80];
if (length > 6) {
strcpy(symbol->errtxt, "484: Input too long (6 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "485: Invalid character in data (digits only)");
return error_number;
}
zeroes = 6 - length;
memset(localstr, '0', zeroes);
ustrcpy(localstr + zeroes, source);
total = 0;
for (loop = 0; loop < 6; loop++) {
total += ctoi(localstr[loop]);
}
check = 10 - (total % 10);
if (check == 10) {
check = 0;
}
localstr[6] = itoc(check);
localstr[7] = '\0';
*dest = '\0';
for (loop = 5; loop >= 0; loop--) {
lookup(NEON, KoreaTable, localstr[loop], dest);
}
lookup(NEON, KoreaTable, localstr[6], dest);
expand(symbol, dest);
ustrcpy(symbol->text, localstr);
// TODO: Find documentation on BARCODE_KOREAPOST dimensions/height
return error_number;
}
/* The simplest barcode symbology ever! Supported by MS Word, so here it is!
glyphs from http://en.wikipedia.org/wiki/Facing_Identification_Mark */
INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number = 0;
char dest[16] = {0};
if (length > 1) {
strcpy(symbol->errtxt, "486: Input too long (1 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
switch ((char) source[0]) {
case 'a':
case 'A':
strcpy(dest, "111515111");
break;
case 'b':
case 'B':
strcpy(dest, "13111311131");
break;
case 'c':
case 'C':
strcpy(dest, "11131313111");
break;
case 'd':
case 'D':
strcpy(dest, "1111131311111");
break;
default:
strcpy(symbol->errtxt, "487: Invalid character in data (\"A\", \"B\", \"C\" or \"D\" only)");
return ZINT_ERROR_INVALID_DATA;
break;
}
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
/* USPS Domestic Mail Manual (USPS DMM 300) Jan 8, 2006 (updated 2011) 708.9.3
X 0.03125" (1/32) +- 0.008" so X max 0.03925", height 0.625" (5/8) +- 0.125" (1/8) */
error_number = set_height(symbol, (float) (0.5 / 0.03925), 20.0f /*0.625 / 0.03125*/, (float) (0.75 / 0.02415),
0 /*no_errtxt*/);
#else
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
return error_number;
}
/* Set height for DAFT-type codes, maintaining ratio. Expects row_height[0] & row_height[1] to be set */
/* Used by auspost.c also */
INTERNAL int daft_set_height(struct zint_symbol *symbol, float min_height, float max_height) {
int error_number = 0;
float t_ratio; /* Tracker ratio */
if (symbol->height) {
t_ratio = symbol->row_height[1] / (symbol->row_height[0] * 2 + symbol->row_height[1]);
symbol->row_height[1] = symbol->height * t_ratio;
if (symbol->row_height[1] < 0.5f) { /* Absolute minimum */
symbol->row_height[1] = 0.5f;
symbol->row_height[0] = 0.25f / t_ratio - 0.25f;
} else {
symbol->row_height[0] = (symbol->height - symbol->row_height[1]) / 2.0f;
}
if (symbol->row_height[0] < 0.5f) {
symbol->row_height[0] = 0.5f;
symbol->row_height[1] = t_ratio / (1.0f - t_ratio);
}
}
symbol->row_height[2] = symbol->row_height[0];
symbol->height = symbol->row_height[0] + symbol->row_height[1] + symbol->row_height[2];
#ifdef COMPLIANT_HEIGHTS
if ((min_height && symbol->height < min_height) || (max_height && symbol->height > max_height)) {
error_number = ZINT_WARN_NONCOMPLIANT;
strcpy(symbol->errtxt, "499: Height not compliant with standards");
}
#else
(void)min_height; (void)max_height;
#endif
return error_number;
}
/* Handles the 4 State barcodes used in the UK by Royal Mail */
static char rm4scc(unsigned char source[], char dest[], int length) {
int i;
int top, bottom, row, column, check_digit;
char values[3], set_copy[] = KRSET;
top = 0;
bottom = 0;
/* start character */
strcpy(dest, "1");
for (i = 0; i < length; i++) {
lookup(KRSET, RoyalTable, source[i], dest);
strcpy(values, RoyalValues[posn(KRSET, source[i])]);
top += ctoi(values[0]);
bottom += ctoi(values[1]);
}
/* Calculate the check digit */
row = (top % 6) - 1;
column = (bottom % 6) - 1;
if (row == -1) {
row = 5;
}
if (column == -1) {
column = 5;
}
check_digit = (6 * row) + column;
strcat(dest, RoyalTable[check_digit]);
/* stop character */
strcat(dest, "0");
return set_copy[check_digit];
}
/* Puts RM4SCC into the data matrix */
INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[210];
int loopey, h;
int writer;
int error_number;
strcpy(height_pattern, "");
if (length > 50) {
strcpy(symbol->errtxt, "488: Input too long (50 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "489: Invalid character in data (alphanumerics only)");
return error_number;
}
/*check = */rm4scc(source, height_pattern, length);
writer = 0;
h = (int) strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
#ifdef COMPLIANT_HEIGHTS
/* Royal Mail Know How User's Manual Appendix C: using CBC
https://web.archive.org/web/20120120060743/http://www.royalmail.com/sites/default/files/docs/pdf/Know How 2006 PIP vs 1.6a Accepted Changes.pdf
Bar pitch and min/maxes same as Mailmark, so using recommendations from Royal Mail Mailmark Barcode Definition
Document (15 Sept 2015) Section 3.5.1
*/
symbol->row_height[0] = (float) ((1.9 * 42.3) / 25.4); /* ~3.16 */
symbol->row_height[1] = (float) ((1.3 * 42.3) / 25.4); /* ~2.16 */
/* Note using max X for minimum and min X for maximum */
error_number = daft_set_height(symbol, (float) ((4.22 * 39) / 25.4), (float) ((5.84 * 47) / 25.4));
#else
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, 0.0f, 0.0f);
#endif
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}
/* Handles Dutch Post TNT KIX symbols
The same as RM4SCC but without check digit
Specification at http://www.tntpost.nl/zakelijk/klantenservice/downloads/kIX_code/download.aspx */
INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[75], localstr[20];
int loopey;
int writer, i, h;
int error_number;
strcpy(height_pattern, "");
if (length > 18) {
strcpy(symbol->errtxt, "490: Input too long (18 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "491: Invalid character in data (alphanumerics only)");
return error_number;
}
ustrcpy(localstr, source);
/* Encode data */
for (i = 0; i < length; i++) {
lookup(KRSET, RoyalTable, localstr[i], height_pattern);
}
writer = 0;
h = (int) strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
#ifdef COMPLIANT_HEIGHTS
/* Dimensions same as RM4SCC */
symbol->row_height[0] = (float) ((1.9 * 42.3) / 25.4); /* ~3.16 */
symbol->row_height[1] = (float) ((1.3 * 42.3) / 25.4); /* ~2.16 */
/* Note using max X for minimum and min X for maximum */
error_number = daft_set_height(symbol, (float) ((4.22 * 39) / 25.4), (float) ((5.84 * 47) / 25.4));
#else
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, 0.0f, 0.0f);
#endif
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}
/* Handles DAFT Code symbols */
INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[100];
unsigned int loopey, h;
int writer, i, error_number;
strcpy(height_pattern, "");
if (length > 50) {
strcpy(symbol->errtxt, "492: Input too long (50 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(DAFTSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "493: Invalid character in data (\"D\", \"A\", \"F\" and \"T\" only)");
return error_number;
}
for (i = 0; i < length; i++) {
if (source[i] == 'D') {
strcat(height_pattern, "2");
}
if (source[i] == 'A') {
strcat(height_pattern, "1");
}
if (source[i] == 'F') {
strcat(height_pattern, "0");
}
if (source[i] == 'T') {
strcat(height_pattern, "3");
}
}
writer = 0;
h = (int) strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
/* Allow ratio of tracker to be specified in thousandths */
if (symbol->option_2 >= 50 && symbol->option_2 <= 900) {
float t_ratio = symbol->option_2 / 1000.0f;
if (symbol->height < 0.5f) {
symbol->height = 8.0f;
}
symbol->row_height[1] = symbol->height * t_ratio;
symbol->row_height[0] = (float) ((symbol->height - symbol->row_height[1]) / 2.0);
} else {
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
}
/* DAFT generic barcode so no dimensions/height specification */
(void) daft_set_height(symbol, 0.0f, 0.0f);
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}
/* Flattermarken - Not really a barcode symbology! */
INTERNAL int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length) {
int loop, error_number;
char dest[512]; /* 90 * 4 + 1 ~ */
if (length > 90) {
strcpy(symbol->errtxt, "494: Input too long (90 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "495: Invalid character in data (digits only)");
return error_number;
}
*dest = '\0';
for (loop = 0; loop < length; loop++) {
lookup(NEON, FlatTable, source[loop], dest);
}
expand(symbol, dest);
// TODO: Find documentation on BARCODE_FLAT dimensions/height
return error_number;
}
/* Japanese Postal Code (Kasutama Barcode) */
INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number, h;
char pattern[69];
int writer, loopey, inter_posn, i, sum, check;
char check_char;
char inter[23];
#ifndef _MSC_VER
unsigned char local_source[length + 1];
#else
unsigned char *local_source = (unsigned char *) _alloca(length + 1);
#endif
if (length > 20) {
strcpy(symbol->errtxt, "496: Input too long (20 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
ustrcpy(local_source, source);
to_upper(local_source);
if (is_sane(SHKASUTSET, local_source, length) == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "497: Invalid character in data (alphanumerics and \"-\" only)");
return ZINT_ERROR_INVALID_DATA;
}
memset(inter, 'd', 20); /* Pad character CC4 */
inter[20] = '\0';
i = 0;
inter_posn = 0;
do {
if (((local_source[i] >= '0') && (local_source[i] <= '9')) || (local_source[i] == '-')) {
inter[inter_posn] = local_source[i];
inter_posn++;
} else {
if ((local_source[i] >= 'A') && (local_source[i] <= 'J')) {
inter[inter_posn] = 'a';
inter[inter_posn + 1] = local_source[i] - 'A' + '0';
inter_posn += 2;
}
if ((local_source[i] >= 'K') && (local_source[i] <= 'T')) {
inter[inter_posn] = 'b';
inter[inter_posn + 1] = local_source[i] - 'K' + '0';
inter_posn += 2;
}
if ((local_source[i] >= 'U') && (local_source[i] <= 'Z')) {
inter[inter_posn] = 'c';
inter[inter_posn + 1] = local_source[i] - 'U' + '0';
inter_posn += 2;
}
}
i++;
} while ((i < length) && (inter_posn < 20));
inter[20] = '\0';
strcpy(pattern, "13"); /* Start */
sum = 0;
for (i = 0; i < 20; i++) {
strcat(pattern, JapanTable[posn(KASUTSET, inter[i])]);
sum += posn(CHKASUTSET, inter[i]);
}
/* Calculate check digit */
check = 19 - (sum % 19);
if (check == 19) {
check = 0;
}
if (check <= 9) {
check_char = check + '0';
} else if (check == 10) {
check_char = '-';
} else {
check_char = (check - 11) + 'a';
}
strcat(pattern, JapanTable[posn(KASUTSET, check_char)]);
if (symbol->debug & ZINT_DEBUG_PRINT) printf("Check: %d, char: %c\n", check, check_char);
strcat(pattern, "31"); /* Stop */
/* Resolve pattern to 4-state symbols */
writer = 0;
h = (int) strlen(pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((pattern[loopey] == '2') || (pattern[loopey] == '1')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((pattern[loopey] == '3') || (pattern[loopey] == '1')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
symbol->rows = 3;
symbol->width = writer - 1;
#ifdef COMPLIANT_HEIGHTS
/* Japan Post Zip/Barcode Manual pp.11-12 https://www.post.japanpost.jp/zipcode/zipmanual/p11.html
X 0.6mm (0.5mm - 0.7mm)
Tracker height 1.2mm (1.05mm - 1.35mm) / 0.6mm = 2,
Ascender/descender = 1.2mm (Full 3.6mm (3.4mm - 3.6mm, max preferred) less T divided by 2) / 0.6mm = 2 */
symbol->row_height[0] = 2.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, (float) (3.4 / 0.7) /*~4.857*/, 3.6f / 0.5f /*7.2*/);
#else
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, 0.0f, 0.0f);
#endif
return error_number;
}

494
3rdparty/zint-2.10.0/backend/ps.c vendored Normal file
View File

@@ -0,0 +1,494 @@
/* ps.c - Post Script output */
/*
libzint - the open source barcode library
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <math.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
static void colour_to_pscolor(int option, int colour, char *output) {
*output = '\0';
if ((option & CMYK_COLOUR) == 0) {
// Use RGB colour space
switch (colour) {
case 1: // Cyan
strcat(output, "0.00 1.00 1.00");
break;
case 2: // Blue
strcat(output, "0.00 0.00 1.00");
break;
case 3: // Magenta
strcat(output, "1.00 0.00 1.00");
break;
case 4: // Red
strcat(output, "1.00 0.00 0.00");
break;
case 5: // Yellow
strcat(output, "1.00 1.00 0.00");
break;
case 6: // Green
strcat(output, "0.00 1.00 0.00");
break;
case 8: // White
strcat(output, "1.00 1.00 1.00");
break;
default: // Black
strcat(output, "0.00 0.00 0.00");
break;
}
strcat(output, " setrgbcolor");
} else {
// Use CMYK colour space
switch (colour) {
case 1: // Cyan
strcat(output, "1.00 0.00 0.00 0.00");
break;
case 2: // Blue
strcat(output, "1.00 1.00 0.00 0.00");
break;
case 3: // Magenta
strcat(output, "0.00 1.00 0.00 0.00");
break;
case 4: // Red
strcat(output, "0.00 1.00 1.00 0.00");
break;
case 5: // Yellow
strcat(output, "0.00 0.00 1.00 0.00");
break;
case 6: // Green
strcat(output, "1.00 0.00 1.00 0.00");
break;
case 8: // White
strcat(output, "0.00 0.00 0.00 0.00");
break;
default: // Black
strcat(output, "0.00 0.00 0.00 1.00");
break;
}
strcat(output, " setcmykcolor");
}
}
STATIC_UNLESS_ZINT_TEST void ps_convert(const unsigned char *string, unsigned char *ps_string) {
const unsigned char *s;
unsigned char *p = ps_string;
for (s = string; *s; s++) {
switch (*s) {
case '(':
case ')':
case '\\':
*p++ = '\\';
*p++ = *s;
break;
case 0xC2: /* See `to_iso8859_1()` in raster.c */
*p++ = *++s;
break;
case 0xC3:
*p++ = *++s + 64;
break;
default:
if (*s < 0x80) {
*p++ = *s;
}
break;
}
}
*p = '\0';
}
INTERNAL int ps_plot(struct zint_symbol *symbol) {
FILE *feps;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
float red_ink, green_ink, blue_ink, red_paper, green_paper, blue_paper;
float cyan_ink, magenta_ink, yellow_ink, black_ink;
float cyan_paper, magenta_paper, yellow_paper, black_paper;
int error_number = 0;
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
float previous_diameter;
float radius, half_radius, half_sqrt3_radius;
int colour_index, colour_rect_flag;
char ps_color[33]; /* max "1.00 0.00 0.00 0.00 setcmykcolor" = 32 + 1 */
int draw_background = 1;
struct zint_vector_rect *rect;
struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle;
struct zint_vector_string *string;
const char *locale = NULL;
const char *font;
int i, len;
int ps_len = 0;
int iso_latin1 = 0;
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT;
#ifdef _MSC_VER
unsigned char *ps_string;
#endif
if (symbol->vector == NULL) {
strcpy(symbol->errtxt, "646: Vector header NULL");
return ZINT_ERROR_INVALID_DATA;
}
if (strlen(symbol->bgcolour) > 6) {
if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) {
draw_background = 0;
}
}
if (output_to_stdout) {
feps = stdout;
} else {
if (!(feps = fopen(symbol->outfile, "w"))) {
sprintf(symbol->errtxt, "645: Could not open output file (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
}
locale = setlocale(LC_ALL, "C");
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
red_ink = (float) (fgred / 256.0);
green_ink = (float) (fggrn / 256.0);
blue_ink = (float) (fgblu / 256.0);
red_paper = (float) (bgred / 256.0);
green_paper = (float) (bggrn / 256.0);
blue_paper = (float) (bgblu / 256.0);
/* Convert RGB to CMYK */
if (red_ink > green_ink) {
if (blue_ink > red_ink) {
black_ink = 1.0f - blue_ink;
} else {
black_ink = 1.0f - red_ink;
}
} else {
if (blue_ink > red_ink) {
black_ink = 1.0f - blue_ink;
} else {
black_ink = 1.0f - green_ink;
}
}
if (black_ink < 1.0f) {
cyan_ink = (1.0f - red_ink - black_ink) / (1.0f - black_ink);
magenta_ink = (1.0f - green_ink - black_ink) / (1.0f - black_ink);
yellow_ink = (1.0f - blue_ink - black_ink) / (1.0f - black_ink);
} else {
cyan_ink = 0.0f;
magenta_ink = 0.0f;
yellow_ink = 0.0f;
}
if (red_paper > green_paper) {
if (blue_paper > red_paper) {
black_paper = 1.0f - blue_paper;
} else {
black_paper = 1.0f - red_paper;
}
} else {
if (blue_paper > red_paper) {
black_paper = 1.0f - blue_paper;
} else {
black_paper = 1.0f - green_paper;
}
}
if (black_paper < 1.0f) {
cyan_paper = (1.0f - red_paper - black_paper) / (1.0f - black_paper);
magenta_paper = (1.0f - green_paper - black_paper) / (1.0f - black_paper);
yellow_paper = (1.0f - blue_paper - black_paper) / (1.0f - black_paper);
} else {
cyan_paper = 0.0f;
magenta_paper = 0.0f;
yellow_paper = 0.0f;
}
for (i = 0, len = (int) ustrlen(symbol->text); i < len; i++) {
switch (symbol->text[i]) {
case '(':
case ')':
case '\\':
ps_len += 2;
break;
default:
if (!iso_latin1 && symbol->text[i] >= 0x80) {
iso_latin1 = 1;
}
ps_len++; /* Will overcount 2 byte UTF-8 chars */
break;
}
}
#ifndef _MSC_VER
unsigned char ps_string[ps_len + 1];
#else
ps_string = (unsigned char *) _alloca(ps_len + 1);
#endif
/* Start writing the header */
fprintf(feps, "%%!PS-Adobe-3.0 EPSF-3.0\n");
if (ZINT_VERSION_BUILD) {
fprintf(feps, "%%%%Creator: Zint %d.%d.%d.%d\n",
ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE, ZINT_VERSION_BUILD);
} else {
fprintf(feps, "%%%%Creator: Zint %d.%d.%d\n", ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE);
}
fprintf(feps, "%%%%Title: Zint Generated Symbol\n");
fprintf(feps, "%%%%Pages: 0\n");
fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n",
(int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height));
fprintf(feps, "%%%%EndComments\n");
/* Definitions */
fprintf(feps, "/TL { setlinewidth moveto lineto stroke } bind def\n");
fprintf(feps, "/TD { newpath 0 360 arc fill } bind def\n");
fprintf(feps, "/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def\n");
fprintf(feps, "/TB { 2 copy } bind def\n");
fprintf(feps, "/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def\n");
fprintf(feps, "/TE { pop pop } bind def\n");
fprintf(feps, "newpath\n");
/* Now the actual representation */
// Background
if (draw_background) {
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_paper, magenta_paper, yellow_paper, black_paper);
}
fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", symbol->vector->height, symbol->vector->width);
fprintf(feps, "TE\n");
}
if (symbol->symbology != BARCODE_ULTRA) {
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
}
// Rectangles
if (symbol->symbology == BARCODE_ULTRA) {
colour_rect_flag = 0;
rect = symbol->vector->rectangles;
while (rect) {
if (rect->colour == -1) { // Foreground
if (colour_rect_flag == 0) {
// Set foreground colour
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n",
cyan_ink, magenta_ink, yellow_ink, black_ink);
}
colour_rect_flag = 1;
}
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n",
rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width);
fprintf(feps, "TE\n");
}
rect = rect->next;
}
for (colour_index = 1; colour_index <= 8; colour_index++) {
colour_rect_flag = 0;
rect = symbol->vector->rectangles;
while (rect) {
if (rect->colour == colour_index) {
if (colour_rect_flag == 0) {
// Set new colour
colour_to_pscolor(symbol->output_options, colour_index, ps_color);
fprintf(feps, "%s\n", ps_color);
colour_rect_flag = 1;
}
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n",
rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width);
fprintf(feps, "TE\n");
}
rect = rect->next;
}
}
} else {
rect = symbol->vector->rectangles;
while (rect) {
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n",
rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width);
fprintf(feps, "TE\n");
rect = rect->next;
}
}
// Hexagons
previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f;
hex = symbol->vector->hexagons;
while (hex) {
if (previous_diameter != hex->diameter) {
previous_diameter = hex->diameter;
radius = (float) (0.5 * previous_diameter);
half_radius = (float) (0.25 * previous_diameter);
half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter);
}
if ((hex->rotation == 0) || (hex->rotation == 180)) {
ay = (symbol->vector->height - hex->y) + radius;
by = (symbol->vector->height - hex->y) + half_radius;
cy = (symbol->vector->height - hex->y) - half_radius;
dy = (symbol->vector->height - hex->y) - radius;
ey = (symbol->vector->height - hex->y) - half_radius;
fy = (symbol->vector->height - hex->y) + half_radius;
ax = hex->x;
bx = hex->x + half_sqrt3_radius;
cx = hex->x + half_sqrt3_radius;
dx = hex->x;
ex = hex->x - half_sqrt3_radius;
fx = hex->x - half_sqrt3_radius;
} else {
ay = (symbol->vector->height - hex->y);
by = (symbol->vector->height - hex->y) + half_sqrt3_radius;
cy = (symbol->vector->height - hex->y) + half_sqrt3_radius;
dy = (symbol->vector->height - hex->y);
ey = (symbol->vector->height - hex->y) - half_sqrt3_radius;
fy = (symbol->vector->height - hex->y) - half_sqrt3_radius;
ax = hex->x - radius;
bx = hex->x - half_radius;
cx = hex->x + half_radius;
dx = hex->x + radius;
ex = hex->x + half_radius;
fx = hex->x - half_radius;
}
fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TH\n",
ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy);
hex = hex->next;
}
// Circles
previous_diameter = radius = 0.0f;
circle = symbol->vector->circles;
while (circle) {
if (previous_diameter != circle->diameter) {
previous_diameter = circle->diameter;
radius = (float) (0.5 * previous_diameter);
}
if (circle->colour) {
// A 'white' circle
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n",
cyan_paper, magenta_paper, yellow_paper, black_paper);
}
fprintf(feps, "%.2f %.2f %.2f TD\n", circle->x, (symbol->vector->height - circle->y), radius);
if (circle->next) {
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
}
} else {
// A 'black' circle
fprintf(feps, "%.2f %.2f %.2f TD\n", circle->x, (symbol->vector->height - circle->y), radius);
}
circle = circle->next;
}
// Text
string = symbol->vector->strings;
if (string) {
if ((symbol->output_options & BOLD_TEXT)
&& (!is_extendable(symbol->symbology) || (symbol->output_options & SMALL_TEXT))) {
font = "Helvetica-Bold";
} else {
font = "Helvetica";
}
if (iso_latin1) {
/* Change encoding to ISO 8859-1, see Postscript Language Reference Manual 2nd Edition Example 5.6 */
fprintf(feps, "/%s findfont\n", font);
fprintf(feps, "dup length dict begin\n");
fprintf(feps, "{1 index /FID ne {def} {pop pop} ifelse} forall\n");
fprintf(feps, "/Encoding ISOLatin1Encoding def\n");
fprintf(feps, "currentdict\n");
fprintf(feps, "end\n");
fprintf(feps, "/Helvetica-ISOLatin1 exch definefont pop\n");
font = "Helvetica-ISOLatin1";
}
do {
ps_convert(string->text, ps_string);
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/%s findfont\n", font);
fprintf(feps, "%.2f scalefont setfont\n", string->fsize);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n",
string->x, (symbol->vector->height - string->y));
if (string->halign == 0 || string->halign == 2) { /* Need width for middle or right align */
fprintf(feps, " (%s) stringwidth\n", ps_string);
}
if (string->rotation != 0) {
fprintf(feps, "gsave\n");
fprintf(feps, "%d rotate\n", 360 - string->rotation);
}
if (string->halign == 0 || string->halign == 2) {
fprintf(feps, "pop\n");
fprintf(feps, "%s 0 rmoveto\n", string->halign == 2 ? "neg" : "-2 div");
}
fprintf(feps, " (%s) show\n", ps_string);
if (string->rotation != 0) {
fprintf(feps, "grestore\n");
}
fprintf(feps, "setmatrix\n");
string = string->next;
} while (string);
}
if (output_to_stdout) {
fflush(feps);
} else {
fclose(feps);
}
if (locale)
setlocale(LC_ALL, locale);
return error_number;
}

3141
3rdparty/zint-2.10.0/backend/qr.c vendored Normal file

File diff suppressed because it is too large Load Diff

304
3rdparty/zint-2.10.0/backend/qr.h vendored Normal file
View File

@@ -0,0 +1,304 @@
/* qr.h Data for QR Code, Micro QR Code and rMQR
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2006 Kentaro Fukuchi <fukuchi@megaui.net>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* From ISO/IEC 18004:2015 Table 5 Encoding/decoding table for Alphanumeric mode */
static const char qr_alphanumeric[59] = {
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, /* SP-/ */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, /* 0-? */
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, /* @-O */
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 /* P-Z */
};
/* From ISO/IEC 18004:2015 Table 7 */
static const unsigned short int qr_data_codewords_L[] = {
19, 34, 55, 80, 108, 136, 156, 194, 232, 274, 324, 370, 428, 461, 523, 589, 647,
721, 795, 861, 932, 1006, 1094, 1174, 1276, 1370, 1468, 1531, 1631,
1735, 1843, 1955, 2071, 2191, 2306, 2434, 2566, 2702, 2812, 2956
};
static const unsigned short int qr_data_codewords_M[] = {
16, 28, 44, 64, 86, 108, 124, 154, 182, 216, 254, 290, 334, 365, 415, 453, 507,
563, 627, 669, 714, 782, 860, 914, 1000, 1062, 1128, 1193, 1267,
1373, 1455, 1541, 1631, 1725, 1812, 1914, 1992, 2102, 2216, 2334
};
static const unsigned short int qr_data_codewords_Q[] = {
13, 22, 34, 48, 62, 76, 88, 110, 132, 154, 180, 206, 244, 261, 295, 325, 367,
397, 445, 485, 512, 568, 614, 664, 718, 754, 808, 871, 911,
985, 1033, 1115, 1171, 1231, 1286, 1354, 1426, 1502, 1582, 1666
};
static const unsigned short int qr_data_codewords_H[] = {
9, 16, 26, 36, 46, 60, 66, 86, 100, 122, 140, 158, 180, 197, 223, 253, 283,
313, 341, 385, 406, 442, 464, 514, 538, 596, 628, 661, 701,
745, 793, 845, 901, 961, 986, 1054, 1096, 1142, 1222, 1276
};
static const unsigned short int qr_total_codewords[] = {
26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815,
901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051,
2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
};
static const unsigned short int rmqr_height[] = {
7, 7, 7, 7, 7,
9, 9, 9, 9, 9,
11, 11, 11, 11, 11, 11,
13, 13, 13, 13, 13, 13,
15, 15, 15, 15, 15,
17, 17, 17, 17, 17
};
static const unsigned short int rmqr_width[] = {
43, 59, 77, 99, 139,
43, 59, 77, 99, 139,
27, 43, 59, 77, 99, 139,
27, 43, 59, 77, 99, 139,
43, 59, 77, 99, 139,
43, 59, 77, 99, 139
};
static const unsigned short int rmqr_data_codewords_M[] = {
6, 12, 20, 28, 44, // R7x
12, 21, 31, 42, 63, // R9x
7, 19, 31, 43, 57, 84, // R11x
12, 27, 38, 53, 73, 106, // R13x
33, 48, 67, 88, 127, // R15x
39, 56, 78, 100, 152 // R17x
};
static const unsigned short int rmqr_data_codewords_H[] = {
3, 7, 10, 14, 24, // R7x
7, 11, 17, 22, 33, // R9x
5, 11, 15, 23, 29, 42, // R11x
7, 13, 20, 29, 35, 54, // R13x
15, 26, 31, 48, 69, // R15x
21, 28, 38, 56, 76 // R17x
};
static const short int rmqr_fixed_height_upper_bound[] = {
-1, 4, 9, 15, 21, 26, 31
};
static const unsigned short int rmqr_total_codewords[] = {
13, 21, 32, 44, 68, // R7x
21, 33, 49, 66, 99, // R9x
15, 31, 47, 67, 89, 132, // R11x
21, 41, 60, 85, 113, 166, // R13x
51, 74, 103, 136, 199, // R15x
61, 88, 122, 160, 232 // R17x
};
static const unsigned short int rmqr_numeric_cci[] = {
4, 5, 6, 7, 7,
5, 6, 7, 7, 8,
4, 6, 7, 7, 8, 8,
5, 6, 7, 8, 8, 8, // Note R13x77 (4th) 8 bits but max numerics 124 (7 bits)
7, 7, 8, 8, 9,
7, 8, 8, 8, 9
};
static const unsigned short int rmqr_alphanum_cci[] = {
3, 5, 5, 6, 6,
5, 5, 6, 6, 7,
4, 5, 6, 6, 7, 7,
5, 6, 6, 7, 7, 8,
6, 7, 7, 7, 8,
6, 7, 7, 8, 8
};
static const unsigned short int rmqr_byte_cci[] = {
3, 4, 5, 5, 6,
4, 5, 5, 6, 6,
3, 5, 5, 6, 6, 7,
4, 5, 6, 6, 7, 7,
6, 6, 7, 7, 7,
6, 6, 7, 7, 8
};
static const unsigned short int rmqr_kanji_cci[] = {
2, 3, 4, 5, 5,
3, 4, 5, 5, 6,
2, 4, 5, 5, 6, 6,
3, 5, 5, 6, 6, 7,
5, 5, 6, 6, 7,
5, 6, 6, 6, 7
};
static const char qr_blocks_L[] = {
1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12,
12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25
};
static const char qr_blocks_M[] = {
1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20,
21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49
};
static const char qr_blocks_Q[] = {
1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25,
27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68
};
static const char qr_blocks_H[] = {
1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30,
32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81
};
static const char rmqr_blocks_M[] = {
1, 1, 1, 1, 1, // R7x
1, 1, 1, 1, 2, // R9x
1, 1, 1, 1, 2, 2, // R11x
1, 1, 1, 2, 2, 3, // R13x
1, 1, 2, 2, 3, // R15x
1, 2, 2, 3, 4 // R17x
};
static const char rmqr_blocks_H[] = {
1, 1, 1, 1, 2, // R7x
1, 1, 2, 2, 3, // R9x
1, 1, 2, 2, 2, 3, // R11x
1, 1, 2, 2, 3, 4, // R13x
2, 2, 3, 4, 5, // R15x
2, 2, 3, 4, 6 // R17x
};
static const unsigned short int qr_sizes[] = {
21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97,
101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177
};
static const char micro_qr_sizes[] = {
11, 13, 15, 17
};
static const char qr_align_loopsize[] = {
0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7
};
// Table E1 - Row/column coordinates of center module of alignment patterns
static const unsigned short int qr_table_e1[] = {
6, 18, 0, 0, 0, 0, 0,
6, 22, 0, 0, 0, 0, 0,
6, 26, 0, 0, 0, 0, 0,
6, 30, 0, 0, 0, 0, 0,
6, 34, 0, 0, 0, 0, 0,
6, 22, 38, 0, 0, 0, 0,
6, 24, 42, 0, 0, 0, 0,
6, 26, 46, 0, 0, 0, 0,
6, 28, 50, 0, 0, 0, 0,
6, 30, 54, 0, 0, 0, 0,
6, 32, 58, 0, 0, 0, 0,
6, 34, 62, 0, 0, 0, 0,
6, 26, 46, 66, 0, 0, 0,
6, 26, 48, 70, 0, 0, 0,
6, 26, 50, 74, 0, 0, 0,
6, 30, 54, 78, 0, 0, 0,
6, 30, 56, 82, 0, 0, 0,
6, 30, 58, 86, 0, 0, 0,
6, 34, 62, 90, 0, 0, 0,
6, 28, 50, 72, 94, 0, 0,
6, 26, 50, 74, 98, 0, 0,
6, 30, 54, 78, 102, 0, 0,
6, 28, 54, 80, 106, 0, 0,
6, 32, 58, 84, 110, 0, 0,
6, 30, 58, 86, 114, 0, 0,
6, 34, 62, 90, 118, 0, 0,
6, 26, 50, 74, 98, 122, 0,
6, 30, 54, 78, 102, 126, 0,
6, 26, 52, 78, 104, 130, 0,
6, 30, 56, 82, 108, 134, 0,
6, 34, 60, 86, 112, 138, 0,
6, 30, 58, 86, 114, 142, 0,
6, 34, 62, 90, 118, 146, 0,
6, 30, 54, 78, 102, 126, 150,
6, 24, 50, 76, 102, 128, 154,
6, 28, 54, 80, 106, 132, 158,
6, 32, 58, 84, 110, 136, 162,
6, 26, 54, 82, 110, 138, 166,
6, 30, 58, 86, 114, 142, 170
};
// Table D1 - Column coordinates of centre module of alignment patterns
static const unsigned short int rmqr_table_d1[] = {
21, 0, 0, 0,
19, 39, 0, 0,
25, 51, 0, 0,
23, 49, 75, 0,
27, 55, 83, 111
};
static const unsigned int qr_annex_c[] = {
/* Format information bit sequences */
0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, 0x77c4, 0x72f3, 0x7daa, 0x789d,
0x662f, 0x6318, 0x6c41, 0x6976, 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b,
0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed
};
static const unsigned int qr_annex_d[] = {
/* Version information bit sequences */
0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, 0x0f928, 0x10b78,
0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, 0x177ec, 0x18ec4, 0x191e1, 0x1afab,
0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b,
0x2542e, 0x26a64, 0x27541, 0x28c69
};
static const unsigned int qr_annex_c1[] = {
/* Micro QR Code format information */
0x4445, 0x4172, 0x4e2b, 0x4b1c, 0x55ae, 0x5099, 0x5fc0, 0x5af7, 0x6793, 0x62a4, 0x6dfd, 0x68ca, 0x7678, 0x734f,
0x7c16, 0x7921, 0x06de, 0x03e9, 0x0cb0, 0x0987, 0x1735, 0x1202, 0x1d5b, 0x186c, 0x2508, 0x203f, 0x2f66, 0x2a51, 0x34e3,
0x31d4, 0x3e8d, 0x3bba
};
static const unsigned int rmqr_format_info_left[] = {
/* rMQR format information for finder pattern side */
0x1FAB2, 0x1E597, 0x1DBDD, 0x1C4F8, 0x1B86C, 0x1A749, 0x19903, 0x18626, 0x17F0E, 0x1602B,
0x15E61, 0x14144, 0x13DD0, 0x122F5, 0x11CBF, 0x1039A, 0x0F1CA, 0x0EEEF, 0x0D0A5, 0x0CF80,
0x0B314, 0x0AC31, 0x0927B, 0x08D5E, 0x07476, 0x06B53, 0x05519, 0x04A3C, 0x036A8, 0x0298D,
0x017C7, 0x008E2, 0x3F367, 0x3EC42, 0x3D208, 0x3CD2D, 0x3B1B9, 0x3AE9C, 0x390D6, 0x38FF3,
0x376DB, 0x369FE, 0x357B4, 0x34891, 0x33405, 0x32B20, 0x3156A, 0x30A4F, 0x2F81F, 0x2E73A,
0x2D970, 0x2C655, 0x2BAC1, 0x2A5E4, 0x29BAE, 0x2848B, 0x27DA3, 0x26286, 0x25CCC, 0x243E9,
0x23F7D, 0x22058, 0x21E12, 0x20137
};
static const unsigned int rmqr_format_info_right[] = {
/* rMQR format information for subfinder pattern side */
0x20A7B, 0x2155E, 0x22B14, 0x23431, 0x248A5, 0x25780, 0x269CA, 0x276EF, 0x28FC7, 0x290E2,
0x2AEA8, 0x2B18D, 0x2CD19, 0x2D23C, 0x2EC76, 0x2F353, 0x30103, 0x31E26, 0x3206C, 0x33F49,
0x343DD, 0x35CF8, 0x362B2, 0x37D97, 0x384BF, 0x39B9A, 0x3A5D0, 0x3BAF5, 0x3C661, 0x3D944,
0x3E70E, 0x3F82B, 0x003AE, 0x01C8B, 0x022C1, 0x03DE4, 0x04170, 0x05E55, 0x0601F, 0x07F3A,
0x08612, 0x09937, 0x0A77D, 0x0B858, 0x0C4CC, 0x0DBE9, 0x0E5A3, 0x0FA86, 0x108D6, 0x117F3,
0x129B9, 0x1369C, 0x14A08, 0x1552D, 0x16B67, 0x17442, 0x18D6A, 0x1924F, 0x1AC05, 0x1B320,
0x1CFB4, 0x1D091, 0x1EEDB, 0x1F1FE
};

1382
3rdparty/zint-2.10.0/backend/raster.c vendored Normal file

File diff suppressed because it is too large Load Diff

287
3rdparty/zint-2.10.0/backend/reedsol.c vendored Normal file
View File

@@ -0,0 +1,287 @@
/**
This is a simple Reed-Solomon encoder
(C) Cliff Hones 2004
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
// It is not written with high efficiency in mind, so is probably
// not suitable for real-time encoding. The aim was to keep it
// simple, general and clear.
//
// <Some notes on the theory and implementation need to be added here>
// Usage:
// First call rs_init_gf(&rs, prime_poly) to set up the Galois Field parameters.
// Then call rs_init_code(&rs, nsym, index) to set the encoding size
// Then call rs_encode(&rs, datalen, data, out) to encode the data.
//
// These can be called repeatedly as required - but note that
// rs_init_code must be called following any rs_init_gf call.
//
// If the parameters are fixed, some of the statics below can be
// replaced with constants in the obvious way, and additionally
// malloc/free can be avoided by using static arrays of a suitable
// size.
// Note: use of statics has been done for (up to) 8-bit tables.
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#include "reedsol.h"
#include "reedsol_logs.h"
// rs_init_gf(&rs, prime_poly) initialises the parameters for the Galois Field.
// The symbol size is determined from the highest bit set in poly
// This implementation will support sizes up to 8 bits (see rs_uint_init_gf()
// for sizes > 8 bits and <= 30 bits) - bit sizes of 8 or 4 are typical
//
// The poly is the bit pattern representing the GF characteristic
// polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
INTERNAL void rs_init_gf(rs_t *rs, const unsigned int prime_poly) {
struct item {
const unsigned char *logt;
const unsigned char *alog;
};
/* To add a new prime poly of degree <= 8 add its details to this table and to the table in `test_generate()`
* in "backend/tests/test_reedsol.c" and regenerate the log tables by running "./test_reedsol -f generate -g".
* Paste the result in "reedsol_logs.h" */
static const struct item data[] = {
{ logt_0x13, alog_0x13 }, /* 0 000- */
{ logt_0x25, alog_0x25 }, /* 0 001- */
{ logt_0x43, alog_0x43 }, /* 0 010- */
{ NULL, NULL },
{ logt_0x89, alog_0x89 }, /* 0 100- */
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
{ logt_0x11d, alog_0x11d }, /* 1 000- */
{ logt_0x12d, alog_0x12d }, /* 1 001- */
{ NULL, NULL },
{ logt_0x163, alog_0x163 }, /* 1 011- */
};
/* Using bits 9-6 as hash to save a few cycles */
/* Alter this hash or just iterate if new prime poly added that doesn't fit */
unsigned int hash = prime_poly >> 5;
rs->logt = data[hash].logt;
rs->alog = data[hash].alog;
}
// rs_init_code(&rs, nsym, index) initialises the Reed-Solomon encoder
// nsym is the number of symbols to be generated (to be appended
// to the input data). index is usually 1 - it is the index of
// the constant in the first term (i) of the RS generator polynomial:
// (x + 2**i)*(x + 2**(i+1))*... [nsym terms]
// For ECC200, index is 1.
INTERNAL void rs_init_code(rs_t *rs, const int nsym, int index) {
int i, k;
const unsigned char *logt = rs->logt;
const unsigned char *alog = rs->alog;
unsigned char *rspoly = rs->rspoly;
rs->nsym = nsym;
rspoly[0] = 1;
for (i = 1; i <= nsym; i++) {
rspoly[i] = 1;
for (k = i - 1; k > 0; k--) {
if (rspoly[k])
rspoly[k] = alog[logt[rspoly[k]] + index]; /* Multiply coeff by 2**index */
rspoly[k] ^= rspoly[k - 1]; /* Add coeff of x**(k-1) * x */
}
rspoly[0] = alog[logt[rspoly[0]] + index]; /* 2**(i + (i+1) + ... + index) */
index++;
}
}
/* rs_encode(&rs, datalen, data, res) generates nsym Reed-Solomon codes (nsym as given in rs_init_code())
* and places them in reverse order in res */
INTERNAL void rs_encode(const rs_t *rs, const int datalen, const unsigned char *data, unsigned char *res) {
int i, k;
const unsigned char *logt = rs->logt;
const unsigned char *alog = rs->alog;
const unsigned char *rspoly = rs->rspoly;
const int nsym = rs->nsym;
memset(res, 0, nsym);
for (i = 0; i < datalen; i++) {
unsigned int m = res[nsym - 1] ^ data[i];
if (m) {
unsigned int log_m = logt[m];
for (k = nsym - 1; k > 0; k--) {
if (rspoly[k])
res[k] = (unsigned char) (res[k - 1] ^ alog[log_m + logt[rspoly[k]]]);
else
res[k] = res[k - 1];
}
res[0] = alog[log_m + logt[rspoly[0]]]; /* rspoly[0] can't be zero */
} else {
memmove(res + 1, res, nsym - 1);
res[0] = 0;
}
}
}
/* The same as above but for unsigned int data and result - Aztec code compatible */
INTERNAL void rs_encode_uint(const rs_t *rs, const int datalen, const unsigned int *data, unsigned int *res) {
int i, k;
const unsigned char *logt = rs->logt;
const unsigned char *alog = rs->alog;
const unsigned char *rspoly = rs->rspoly;
const int nsym = rs->nsym;
memset(res, 0, sizeof(unsigned int) * nsym);
for (i = 0; i < datalen; i++) {
unsigned int m = res[nsym - 1] ^ data[i];
if (m) {
unsigned int log_m = logt[m];
for (k = nsym - 1; k > 0; k--) {
if (rspoly[k])
res[k] = res[k - 1] ^ alog[log_m + logt[rspoly[k]]];
else
res[k] = res[k - 1];
}
res[0] = alog[log_m + logt[rspoly[0]]];
} else {
memmove(res + 1, res, sizeof(unsigned int) * (nsym - 1));
res[0] = 0;
}
}
}
/* Versions of the above for bitlengths > 8 and <= 30 and unsigned int data and results - Aztec code compatible */
// Usage:
// First call rs_uint_init_gf(&rs_uint, prime_poly, logmod) to set up the Galois Field parameters.
// Then call rs_uint_init_code(&rs_uint, nsym, index) to set the encoding size
// Then call rs_uint_encode(&rs_uint, datalen, data, out) to encode the data.
// Then call rs_uint_free(&rs_uint) to free the log tables.
/* `logmod` (field characteristic) will be 2**bitlength - 1, eg 1023 for bitlength 10, 4095 for bitlength 12 */
INTERNAL int rs_uint_init_gf(rs_uint_t *rs_uint, const unsigned int prime_poly, const int logmod) {
int b, p, v;
unsigned int *logt, *alog;
b = logmod + 1;
rs_uint->logt = NULL;
rs_uint->alog = NULL;
if (!(logt = (unsigned int *) calloc(b, sizeof(unsigned int)))) {
return 0;
}
if (!(alog = (unsigned int *) calloc(b * 2, sizeof(unsigned int)))) {
free(logt);
return 0;
}
// Calculate the log/alog tables
for (p = 1, v = 0; v < logmod; v++) {
alog[v] = p;
alog[logmod + v] = p; /* Double up, avoids mod */
logt[p] = v;
p <<= 1;
if (p & b) /* If overflow */
p ^= prime_poly; /* Subtract prime poly */
}
rs_uint->logt = logt;
rs_uint->alog = alog;
return 1;
}
INTERNAL void rs_uint_init_code(rs_uint_t *rs_uint, const int nsym, int index) {
int i, k;
const unsigned int *logt = rs_uint->logt;
const unsigned int *alog = rs_uint->alog;
unsigned short *rspoly = rs_uint->rspoly;
if (logt == NULL || alog == NULL) {
return;
}
rs_uint->nsym = nsym;
rspoly[0] = 1;
for (i = 1; i <= nsym; i++) {
rspoly[i] = 1;
for (k = i - 1; k > 0; k--) {
if (rspoly[k])
rspoly[k] = alog[(logt[rspoly[k]] + index)];
rspoly[k] ^= rspoly[k - 1];
}
rspoly[0] = alog[(logt[rspoly[0]] + index)];
index++;
}
}
INTERNAL void rs_uint_encode(const rs_uint_t *rs_uint, const int datalen, const unsigned int *data,
unsigned int *res) {
int i, k;
const unsigned int *logt = rs_uint->logt;
const unsigned int *alog = rs_uint->alog;
const unsigned short *rspoly = rs_uint->rspoly;
const int nsym = rs_uint->nsym;
memset(res, 0, sizeof(unsigned int) * nsym);
if (logt == NULL || alog == NULL) {
return;
}
for (i = 0; i < datalen; i++) {
unsigned int m = res[nsym - 1] ^ data[i];
if (m) {
unsigned int log_m = logt[m];
for (k = nsym - 1; k > 0; k--) {
if (rspoly[k])
res[k] = res[k - 1] ^ alog[log_m + logt[rspoly[k]]];
else
res[k] = res[k - 1];
}
res[0] = alog[log_m + logt[rspoly[0]]];
} else {
memmove(res + 1, res, sizeof(unsigned int) * (nsym - 1));
res[0] = 0;
}
}
}
INTERNAL void rs_uint_free(rs_uint_t *rs_uint) {
if (rs_uint->logt) {
free(rs_uint->logt);
rs_uint->logt = NULL;
}
if (rs_uint->alog) {
free(rs_uint->alog);
rs_uint->alog = NULL;
}
}

71
3rdparty/zint-2.10.0/backend/reedsol.h vendored Normal file
View File

@@ -0,0 +1,71 @@
/*
This is a simple Reed-Solomon encoder
(C) Cliff Hones 2004
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef __REEDSOL_H
#define __REEDSOL_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct {
const unsigned char *logt; /* These are static */
const unsigned char *alog;
unsigned char rspoly[256];
int nsym;
} rs_t;
typedef struct {
unsigned int *logt; /* These are malloced */
unsigned int *alog;
unsigned short rspoly[4096]; /* 12-bit max - needs to be enlarged if > 12-bit used */
int nsym;
} rs_uint_t;
INTERNAL void rs_init_gf(rs_t *rs, const unsigned int prime_poly);
INTERNAL void rs_init_code(rs_t *rs, const int nsym, int index);
INTERNAL void rs_encode(const rs_t *rs, const int datalen, const unsigned char *data, unsigned char *res);
INTERNAL void rs_encode_uint(const rs_t *rs, const int datalen, const unsigned int *data, unsigned int *res);
/* No free needed as log tables static */
INTERNAL int rs_uint_init_gf(rs_uint_t *rs_uint, const unsigned int prime_poly, const int logmod);
INTERNAL void rs_uint_init_code(rs_uint_t *rs_uint, const int nsym, int index);
INTERNAL void rs_uint_encode(const rs_uint_t *rs_uint, const int datalen, const unsigned int *data,
unsigned int *res);
INTERNAL void rs_uint_free(rs_uint_t *rs_uint);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __REEDSOL_H */

View File

@@ -0,0 +1,264 @@
/* reedsol_logs.h - Log and antilog tables for Reed-Solomon
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef REEDSOL_LOGS_H
#define REEDSOL_LOGS_H
/* Static log/antilog tables for prime polys of up to degree 8 (> 8 too large so generated at runtime instead).
* Antilog tables doubled to avoid mod. */
/* Paste output of "./test_reedsol -f generate -g" here */
static const unsigned char logt_0x13[16] = {
0x00, 0x00, 0x01, 0x04, 0x02, 0x08, 0x05, 0x0A, 0x03, 0x0E, 0x09, 0x07, 0x06, 0x0D, 0x0B, 0x0C,
};
static const unsigned char alog_0x13[30] = {
0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0C, 0x0B, 0x05, 0x0A, 0x07, 0x0E, 0x0F, 0x0D, 0x09,
0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0C, 0x0B, 0x05, 0x0A, 0x07, 0x0E, 0x0F, 0x0D, 0x09,
};
static const unsigned char logt_0x25[32] = {
0x00, 0x00, 0x01, 0x12, 0x02, 0x05, 0x13, 0x0B, 0x03, 0x1D, 0x06, 0x1B, 0x14, 0x08, 0x0C, 0x17,
0x04, 0x0A, 0x1E, 0x11, 0x07, 0x16, 0x1C, 0x1A, 0x15, 0x19, 0x09, 0x10, 0x0D, 0x0E, 0x18, 0x0F,
};
static const unsigned char alog_0x25[62] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x05, 0x0A, 0x14, 0x0D, 0x1A, 0x11, 0x07, 0x0E, 0x1C, 0x1D, 0x1F,
0x1B, 0x13, 0x03, 0x06, 0x0C, 0x18, 0x15, 0x0F, 0x1E, 0x19, 0x17, 0x0B, 0x16, 0x09, 0x12,
0x01, 0x02, 0x04, 0x08, 0x10, 0x05, 0x0A, 0x14, 0x0D, 0x1A, 0x11, 0x07, 0x0E, 0x1C, 0x1D, 0x1F,
0x1B, 0x13, 0x03, 0x06, 0x0C, 0x18, 0x15, 0x0F, 0x1E, 0x19, 0x17, 0x0B, 0x16, 0x09, 0x12,
};
static const unsigned char logt_0x43[64] = {
0x00, 0x00, 0x01, 0x06, 0x02, 0x0C, 0x07, 0x1A, 0x03, 0x20, 0x0D, 0x23, 0x08, 0x30, 0x1B, 0x12,
0x04, 0x18, 0x21, 0x10, 0x0E, 0x34, 0x24, 0x36, 0x09, 0x2D, 0x31, 0x26, 0x1C, 0x29, 0x13, 0x38,
0x05, 0x3E, 0x19, 0x0B, 0x22, 0x1F, 0x11, 0x2F, 0x0F, 0x17, 0x35, 0x33, 0x25, 0x2C, 0x37, 0x28,
0x0A, 0x3D, 0x2E, 0x1E, 0x32, 0x16, 0x27, 0x2B, 0x1D, 0x3C, 0x2A, 0x15, 0x14, 0x3B, 0x39, 0x3A,
};
static const unsigned char alog_0x43[126] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x23, 0x05, 0x0A, 0x14, 0x28,
0x13, 0x26, 0x0F, 0x1E, 0x3C, 0x3B, 0x35, 0x29, 0x11, 0x22, 0x07, 0x0E, 0x1C, 0x38, 0x33, 0x25,
0x09, 0x12, 0x24, 0x0B, 0x16, 0x2C, 0x1B, 0x36, 0x2F, 0x1D, 0x3A, 0x37, 0x2D, 0x19, 0x32, 0x27,
0x0D, 0x1A, 0x34, 0x2B, 0x15, 0x2A, 0x17, 0x2E, 0x1F, 0x3E, 0x3F, 0x3D, 0x39, 0x31, 0x21,
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x23, 0x05, 0x0A, 0x14, 0x28,
0x13, 0x26, 0x0F, 0x1E, 0x3C, 0x3B, 0x35, 0x29, 0x11, 0x22, 0x07, 0x0E, 0x1C, 0x38, 0x33, 0x25,
0x09, 0x12, 0x24, 0x0B, 0x16, 0x2C, 0x1B, 0x36, 0x2F, 0x1D, 0x3A, 0x37, 0x2D, 0x19, 0x32, 0x27,
0x0D, 0x1A, 0x34, 0x2B, 0x15, 0x2A, 0x17, 0x2E, 0x1F, 0x3E, 0x3F, 0x3D, 0x39, 0x31, 0x21,
};
static const unsigned char logt_0x89[128] = {
0x00, 0x00, 0x01, 0x1F, 0x02, 0x3E, 0x20, 0x67, 0x03, 0x07, 0x3F, 0x0F, 0x21, 0x54, 0x68, 0x5D,
0x04, 0x7C, 0x08, 0x79, 0x40, 0x4F, 0x10, 0x73, 0x22, 0x0B, 0x55, 0x26, 0x69, 0x2E, 0x5E, 0x33,
0x05, 0x52, 0x7D, 0x3C, 0x09, 0x2C, 0x7A, 0x4D, 0x41, 0x43, 0x50, 0x2A, 0x11, 0x45, 0x74, 0x17,
0x23, 0x76, 0x0C, 0x1C, 0x56, 0x19, 0x27, 0x39, 0x6A, 0x13, 0x2F, 0x59, 0x5F, 0x47, 0x34, 0x6E,
0x06, 0x0E, 0x53, 0x5C, 0x7E, 0x1E, 0x3D, 0x66, 0x0A, 0x25, 0x2D, 0x32, 0x7B, 0x78, 0x4E, 0x72,
0x42, 0x29, 0x44, 0x16, 0x51, 0x3B, 0x2B, 0x4C, 0x12, 0x58, 0x46, 0x6D, 0x75, 0x1B, 0x18, 0x38,
0x24, 0x31, 0x77, 0x71, 0x0D, 0x5B, 0x1D, 0x65, 0x57, 0x6C, 0x1A, 0x37, 0x28, 0x15, 0x3A, 0x4B,
0x6B, 0x36, 0x14, 0x4A, 0x30, 0x70, 0x5A, 0x64, 0x60, 0x61, 0x48, 0x62, 0x35, 0x49, 0x6F, 0x63,
};
static const unsigned char alog_0x89[254] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x09, 0x12, 0x24, 0x48, 0x19, 0x32, 0x64, 0x41, 0x0B,
0x16, 0x2C, 0x58, 0x39, 0x72, 0x6D, 0x53, 0x2F, 0x5E, 0x35, 0x6A, 0x5D, 0x33, 0x66, 0x45, 0x03,
0x06, 0x0C, 0x18, 0x30, 0x60, 0x49, 0x1B, 0x36, 0x6C, 0x51, 0x2B, 0x56, 0x25, 0x4A, 0x1D, 0x3A,
0x74, 0x61, 0x4B, 0x1F, 0x3E, 0x7C, 0x71, 0x6B, 0x5F, 0x37, 0x6E, 0x55, 0x23, 0x46, 0x05, 0x0A,
0x14, 0x28, 0x50, 0x29, 0x52, 0x2D, 0x5A, 0x3D, 0x7A, 0x7D, 0x73, 0x6F, 0x57, 0x27, 0x4E, 0x15,
0x2A, 0x54, 0x21, 0x42, 0x0D, 0x1A, 0x34, 0x68, 0x59, 0x3B, 0x76, 0x65, 0x43, 0x0F, 0x1E, 0x3C,
0x78, 0x79, 0x7B, 0x7F, 0x77, 0x67, 0x47, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0x69, 0x5B, 0x3F, 0x7E,
0x75, 0x63, 0x4F, 0x17, 0x2E, 0x5C, 0x31, 0x62, 0x4D, 0x13, 0x26, 0x4C, 0x11, 0x22, 0x44,
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x09, 0x12, 0x24, 0x48, 0x19, 0x32, 0x64, 0x41, 0x0B,
0x16, 0x2C, 0x58, 0x39, 0x72, 0x6D, 0x53, 0x2F, 0x5E, 0x35, 0x6A, 0x5D, 0x33, 0x66, 0x45, 0x03,
0x06, 0x0C, 0x18, 0x30, 0x60, 0x49, 0x1B, 0x36, 0x6C, 0x51, 0x2B, 0x56, 0x25, 0x4A, 0x1D, 0x3A,
0x74, 0x61, 0x4B, 0x1F, 0x3E, 0x7C, 0x71, 0x6B, 0x5F, 0x37, 0x6E, 0x55, 0x23, 0x46, 0x05, 0x0A,
0x14, 0x28, 0x50, 0x29, 0x52, 0x2D, 0x5A, 0x3D, 0x7A, 0x7D, 0x73, 0x6F, 0x57, 0x27, 0x4E, 0x15,
0x2A, 0x54, 0x21, 0x42, 0x0D, 0x1A, 0x34, 0x68, 0x59, 0x3B, 0x76, 0x65, 0x43, 0x0F, 0x1E, 0x3C,
0x78, 0x79, 0x7B, 0x7F, 0x77, 0x67, 0x47, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0x69, 0x5B, 0x3F, 0x7E,
0x75, 0x63, 0x4F, 0x17, 0x2E, 0x5C, 0x31, 0x62, 0x4D, 0x13, 0x26, 0x4C, 0x11, 0x22, 0x44,
};
static const unsigned char logt_0x11d[256] = {
0x00, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1A, 0xC6, 0x03, 0xDF, 0x33, 0xEE, 0x1B, 0x68, 0xC7, 0x4B,
0x04, 0x64, 0xE0, 0x0E, 0x34, 0x8D, 0xEF, 0x81, 0x1C, 0xC1, 0x69, 0xF8, 0xC8, 0x08, 0x4C, 0x71,
0x05, 0x8A, 0x65, 0x2F, 0xE1, 0x24, 0x0F, 0x21, 0x35, 0x93, 0x8E, 0xDA, 0xF0, 0x12, 0x82, 0x45,
0x1D, 0xB5, 0xC2, 0x7D, 0x6A, 0x27, 0xF9, 0xB9, 0xC9, 0x9A, 0x09, 0x78, 0x4D, 0xE4, 0x72, 0xA6,
0x06, 0xBF, 0x8B, 0x62, 0x66, 0xDD, 0x30, 0xFD, 0xE2, 0x98, 0x25, 0xB3, 0x10, 0x91, 0x22, 0x88,
0x36, 0xD0, 0x94, 0xCE, 0x8F, 0x96, 0xDB, 0xBD, 0xF1, 0xD2, 0x13, 0x5C, 0x83, 0x38, 0x46, 0x40,
0x1E, 0x42, 0xB6, 0xA3, 0xC3, 0x48, 0x7E, 0x6E, 0x6B, 0x3A, 0x28, 0x54, 0xFA, 0x85, 0xBA, 0x3D,
0xCA, 0x5E, 0x9B, 0x9F, 0x0A, 0x15, 0x79, 0x2B, 0x4E, 0xD4, 0xE5, 0xAC, 0x73, 0xF3, 0xA7, 0x57,
0x07, 0x70, 0xC0, 0xF7, 0x8C, 0x80, 0x63, 0x0D, 0x67, 0x4A, 0xDE, 0xED, 0x31, 0xC5, 0xFE, 0x18,
0xE3, 0xA5, 0x99, 0x77, 0x26, 0xB8, 0xB4, 0x7C, 0x11, 0x44, 0x92, 0xD9, 0x23, 0x20, 0x89, 0x2E,
0x37, 0x3F, 0xD1, 0x5B, 0x95, 0xBC, 0xCF, 0xCD, 0x90, 0x87, 0x97, 0xB2, 0xDC, 0xFC, 0xBE, 0x61,
0xF2, 0x56, 0xD3, 0xAB, 0x14, 0x2A, 0x5D, 0x9E, 0x84, 0x3C, 0x39, 0x53, 0x47, 0x6D, 0x41, 0xA2,
0x1F, 0x2D, 0x43, 0xD8, 0xB7, 0x7B, 0xA4, 0x76, 0xC4, 0x17, 0x49, 0xEC, 0x7F, 0x0C, 0x6F, 0xF6,
0x6C, 0xA1, 0x3B, 0x52, 0x29, 0x9D, 0x55, 0xAA, 0xFB, 0x60, 0x86, 0xB1, 0xBB, 0xCC, 0x3E, 0x5A,
0xCB, 0x59, 0x5F, 0xB0, 0x9C, 0xA9, 0xA0, 0x51, 0x0B, 0xF5, 0x16, 0xEB, 0x7A, 0x75, 0x2C, 0xD7,
0x4F, 0xAE, 0xD5, 0xE9, 0xE6, 0xE7, 0xAD, 0xE8, 0x74, 0xD6, 0xF4, 0xEA, 0xA8, 0x50, 0x58, 0xAF,
};
static const unsigned char alog_0x11d[510] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1D, 0x3A, 0x74, 0xE8, 0xCD, 0x87, 0x13, 0x26,
0x4C, 0x98, 0x2D, 0x5A, 0xB4, 0x75, 0xEA, 0xC9, 0x8F, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0,
0x9D, 0x27, 0x4E, 0x9C, 0x25, 0x4A, 0x94, 0x35, 0x6A, 0xD4, 0xB5, 0x77, 0xEE, 0xC1, 0x9F, 0x23,
0x46, 0x8C, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x5D, 0xBA, 0x69, 0xD2, 0xB9, 0x6F, 0xDE, 0xA1,
0x5F, 0xBE, 0x61, 0xC2, 0x99, 0x2F, 0x5E, 0xBC, 0x65, 0xCA, 0x89, 0x0F, 0x1E, 0x3C, 0x78, 0xF0,
0xFD, 0xE7, 0xD3, 0xBB, 0x6B, 0xD6, 0xB1, 0x7F, 0xFE, 0xE1, 0xDF, 0xA3, 0x5B, 0xB6, 0x71, 0xE2,
0xD9, 0xAF, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xBD, 0x67, 0xCE,
0x81, 0x1F, 0x3E, 0x7C, 0xF8, 0xED, 0xC7, 0x93, 0x3B, 0x76, 0xEC, 0xC5, 0x97, 0x33, 0x66, 0xCC,
0x85, 0x17, 0x2E, 0x5C, 0xB8, 0x6D, 0xDA, 0xA9, 0x4F, 0x9E, 0x21, 0x42, 0x84, 0x15, 0x2A, 0x54,
0xA8, 0x4D, 0x9A, 0x29, 0x52, 0xA4, 0x55, 0xAA, 0x49, 0x92, 0x39, 0x72, 0xE4, 0xD5, 0xB7, 0x73,
0xE6, 0xD1, 0xBF, 0x63, 0xC6, 0x91, 0x3F, 0x7E, 0xFC, 0xE5, 0xD7, 0xB3, 0x7B, 0xF6, 0xF1, 0xFF,
0xE3, 0xDB, 0xAB, 0x4B, 0x96, 0x31, 0x62, 0xC4, 0x95, 0x37, 0x6E, 0xDC, 0xA5, 0x57, 0xAE, 0x41,
0x82, 0x19, 0x32, 0x64, 0xC8, 0x8D, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xDD, 0xA7, 0x53, 0xA6,
0x51, 0xA2, 0x59, 0xB2, 0x79, 0xF2, 0xF9, 0xEF, 0xC3, 0x9B, 0x2B, 0x56, 0xAC, 0x45, 0x8A, 0x09,
0x12, 0x24, 0x48, 0x90, 0x3D, 0x7A, 0xF4, 0xF5, 0xF7, 0xF3, 0xFB, 0xEB, 0xCB, 0x8B, 0x0B, 0x16,
0x2C, 0x58, 0xB0, 0x7D, 0xFA, 0xE9, 0xCF, 0x83, 0x1B, 0x36, 0x6C, 0xD8, 0xAD, 0x47, 0x8E,
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1D, 0x3A, 0x74, 0xE8, 0xCD, 0x87, 0x13, 0x26,
0x4C, 0x98, 0x2D, 0x5A, 0xB4, 0x75, 0xEA, 0xC9, 0x8F, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0,
0x9D, 0x27, 0x4E, 0x9C, 0x25, 0x4A, 0x94, 0x35, 0x6A, 0xD4, 0xB5, 0x77, 0xEE, 0xC1, 0x9F, 0x23,
0x46, 0x8C, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x5D, 0xBA, 0x69, 0xD2, 0xB9, 0x6F, 0xDE, 0xA1,
0x5F, 0xBE, 0x61, 0xC2, 0x99, 0x2F, 0x5E, 0xBC, 0x65, 0xCA, 0x89, 0x0F, 0x1E, 0x3C, 0x78, 0xF0,
0xFD, 0xE7, 0xD3, 0xBB, 0x6B, 0xD6, 0xB1, 0x7F, 0xFE, 0xE1, 0xDF, 0xA3, 0x5B, 0xB6, 0x71, 0xE2,
0xD9, 0xAF, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xBD, 0x67, 0xCE,
0x81, 0x1F, 0x3E, 0x7C, 0xF8, 0xED, 0xC7, 0x93, 0x3B, 0x76, 0xEC, 0xC5, 0x97, 0x33, 0x66, 0xCC,
0x85, 0x17, 0x2E, 0x5C, 0xB8, 0x6D, 0xDA, 0xA9, 0x4F, 0x9E, 0x21, 0x42, 0x84, 0x15, 0x2A, 0x54,
0xA8, 0x4D, 0x9A, 0x29, 0x52, 0xA4, 0x55, 0xAA, 0x49, 0x92, 0x39, 0x72, 0xE4, 0xD5, 0xB7, 0x73,
0xE6, 0xD1, 0xBF, 0x63, 0xC6, 0x91, 0x3F, 0x7E, 0xFC, 0xE5, 0xD7, 0xB3, 0x7B, 0xF6, 0xF1, 0xFF,
0xE3, 0xDB, 0xAB, 0x4B, 0x96, 0x31, 0x62, 0xC4, 0x95, 0x37, 0x6E, 0xDC, 0xA5, 0x57, 0xAE, 0x41,
0x82, 0x19, 0x32, 0x64, 0xC8, 0x8D, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xDD, 0xA7, 0x53, 0xA6,
0x51, 0xA2, 0x59, 0xB2, 0x79, 0xF2, 0xF9, 0xEF, 0xC3, 0x9B, 0x2B, 0x56, 0xAC, 0x45, 0x8A, 0x09,
0x12, 0x24, 0x48, 0x90, 0x3D, 0x7A, 0xF4, 0xF5, 0xF7, 0xF3, 0xFB, 0xEB, 0xCB, 0x8B, 0x0B, 0x16,
0x2C, 0x58, 0xB0, 0x7D, 0xFA, 0xE9, 0xCF, 0x83, 0x1B, 0x36, 0x6C, 0xD8, 0xAD, 0x47, 0x8E,
};
static const unsigned char logt_0x12d[256] = {
0x00, 0x00, 0x01, 0xF0, 0x02, 0xE1, 0xF1, 0x35, 0x03, 0x26, 0xE2, 0x85, 0xF2, 0x2B, 0x36, 0xD2,
0x04, 0xC3, 0x27, 0x72, 0xE3, 0x6A, 0x86, 0x1C, 0xF3, 0x8C, 0x2C, 0x17, 0x37, 0x76, 0xD3, 0xEA,
0x05, 0xDB, 0xC4, 0x60, 0x28, 0xDE, 0x73, 0x67, 0xE4, 0x4E, 0x6B, 0x7D, 0x87, 0x08, 0x1D, 0xA2,
0xF4, 0xBA, 0x8D, 0xB4, 0x2D, 0x63, 0x18, 0x31, 0x38, 0x0D, 0x77, 0x99, 0xD4, 0xC7, 0xEB, 0x5B,
0x06, 0x4C, 0xDC, 0xD9, 0xC5, 0x0B, 0x61, 0xB8, 0x29, 0x24, 0xDF, 0xFD, 0x74, 0x8A, 0x68, 0xC1,
0xE5, 0x56, 0x4F, 0xAB, 0x6C, 0xA5, 0x7E, 0x91, 0x88, 0x22, 0x09, 0x4A, 0x1E, 0x20, 0xA3, 0x54,
0xF5, 0xAD, 0xBB, 0xCC, 0x8E, 0x51, 0xB5, 0xBE, 0x2E, 0x58, 0x64, 0x9F, 0x19, 0xE7, 0x32, 0xCF,
0x39, 0x93, 0x0E, 0x43, 0x78, 0x80, 0x9A, 0xF8, 0xD5, 0xA7, 0xC8, 0x3F, 0xEC, 0x6E, 0x5C, 0xB0,
0x07, 0xA1, 0x4D, 0x7C, 0xDD, 0x66, 0xDA, 0x5F, 0xC6, 0x5A, 0x0C, 0x98, 0x62, 0x30, 0xB9, 0xB3,
0x2A, 0xD1, 0x25, 0x84, 0xE0, 0x34, 0xFE, 0xEF, 0x75, 0xE9, 0x8B, 0x16, 0x69, 0x1B, 0xC2, 0x71,
0xE6, 0xCE, 0x57, 0x9E, 0x50, 0xBD, 0xAC, 0xCB, 0x6D, 0xAF, 0xA6, 0x3E, 0x7F, 0xF7, 0x92, 0x42,
0x89, 0xC0, 0x23, 0xFC, 0x0A, 0xB7, 0x4B, 0xD8, 0x1F, 0x53, 0x21, 0x49, 0xA4, 0x90, 0x55, 0xAA,
0xF6, 0x41, 0xAE, 0x3D, 0xBC, 0xCA, 0xCD, 0x9D, 0x8F, 0xA9, 0x52, 0x48, 0xB6, 0xD7, 0xBF, 0xFB,
0x2F, 0xB2, 0x59, 0x97, 0x65, 0x5E, 0xA0, 0x7B, 0x1A, 0x70, 0xE8, 0x15, 0x33, 0xEE, 0xD0, 0x83,
0x3A, 0x45, 0x94, 0x12, 0x0F, 0x10, 0x44, 0x11, 0x79, 0x95, 0x81, 0x13, 0x9B, 0x3B, 0xF9, 0x46,
0xD6, 0xFA, 0xA8, 0x47, 0xC9, 0x9C, 0x40, 0x3C, 0xED, 0x82, 0x6F, 0x14, 0x5D, 0x7A, 0xB1, 0x96,
};
static const unsigned char alog_0x12d[510] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x2D, 0x5A, 0xB4, 0x45, 0x8A, 0x39, 0x72, 0xE4,
0xE5, 0xE7, 0xE3, 0xEB, 0xFB, 0xDB, 0x9B, 0x1B, 0x36, 0x6C, 0xD8, 0x9D, 0x17, 0x2E, 0x5C, 0xB8,
0x5D, 0xBA, 0x59, 0xB2, 0x49, 0x92, 0x09, 0x12, 0x24, 0x48, 0x90, 0x0D, 0x1A, 0x34, 0x68, 0xD0,
0x8D, 0x37, 0x6E, 0xDC, 0x95, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xED, 0xF7, 0xC3, 0xAB, 0x7B,
0xF6, 0xC1, 0xAF, 0x73, 0xE6, 0xE1, 0xEF, 0xF3, 0xCB, 0xBB, 0x5B, 0xB6, 0x41, 0x82, 0x29, 0x52,
0xA4, 0x65, 0xCA, 0xB9, 0x5F, 0xBE, 0x51, 0xA2, 0x69, 0xD2, 0x89, 0x3F, 0x7E, 0xFC, 0xD5, 0x87,
0x23, 0x46, 0x8C, 0x35, 0x6A, 0xD4, 0x85, 0x27, 0x4E, 0x9C, 0x15, 0x2A, 0x54, 0xA8, 0x7D, 0xFA,
0xD9, 0x9F, 0x13, 0x26, 0x4C, 0x98, 0x1D, 0x3A, 0x74, 0xE8, 0xFD, 0xD7, 0x83, 0x2B, 0x56, 0xAC,
0x75, 0xEA, 0xF9, 0xDF, 0x93, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x4D, 0x9A, 0x19, 0x32, 0x64, 0xC8,
0xBD, 0x57, 0xAE, 0x71, 0xE2, 0xE9, 0xFF, 0xD3, 0x8B, 0x3B, 0x76, 0xEC, 0xF5, 0xC7, 0xA3, 0x6B,
0xD6, 0x81, 0x2F, 0x5E, 0xBC, 0x55, 0xAA, 0x79, 0xF2, 0xC9, 0xBF, 0x53, 0xA6, 0x61, 0xC2, 0xA9,
0x7F, 0xFE, 0xD1, 0x8F, 0x33, 0x66, 0xCC, 0xB5, 0x47, 0x8E, 0x31, 0x62, 0xC4, 0xA5, 0x67, 0xCE,
0xB1, 0x4F, 0x9E, 0x11, 0x22, 0x44, 0x88, 0x3D, 0x7A, 0xF4, 0xC5, 0xA7, 0x63, 0xC6, 0xA1, 0x6F,
0xDE, 0x91, 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0xCD, 0xB7, 0x43, 0x86, 0x21, 0x42, 0x84, 0x25, 0x4A,
0x94, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x6D, 0xDA, 0x99, 0x1F, 0x3E, 0x7C, 0xF8, 0xDD, 0x97,
0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xAD, 0x77, 0xEE, 0xF1, 0xCF, 0xB3, 0x4B, 0x96,
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x2D, 0x5A, 0xB4, 0x45, 0x8A, 0x39, 0x72, 0xE4,
0xE5, 0xE7, 0xE3, 0xEB, 0xFB, 0xDB, 0x9B, 0x1B, 0x36, 0x6C, 0xD8, 0x9D, 0x17, 0x2E, 0x5C, 0xB8,
0x5D, 0xBA, 0x59, 0xB2, 0x49, 0x92, 0x09, 0x12, 0x24, 0x48, 0x90, 0x0D, 0x1A, 0x34, 0x68, 0xD0,
0x8D, 0x37, 0x6E, 0xDC, 0x95, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xED, 0xF7, 0xC3, 0xAB, 0x7B,
0xF6, 0xC1, 0xAF, 0x73, 0xE6, 0xE1, 0xEF, 0xF3, 0xCB, 0xBB, 0x5B, 0xB6, 0x41, 0x82, 0x29, 0x52,
0xA4, 0x65, 0xCA, 0xB9, 0x5F, 0xBE, 0x51, 0xA2, 0x69, 0xD2, 0x89, 0x3F, 0x7E, 0xFC, 0xD5, 0x87,
0x23, 0x46, 0x8C, 0x35, 0x6A, 0xD4, 0x85, 0x27, 0x4E, 0x9C, 0x15, 0x2A, 0x54, 0xA8, 0x7D, 0xFA,
0xD9, 0x9F, 0x13, 0x26, 0x4C, 0x98, 0x1D, 0x3A, 0x74, 0xE8, 0xFD, 0xD7, 0x83, 0x2B, 0x56, 0xAC,
0x75, 0xEA, 0xF9, 0xDF, 0x93, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x4D, 0x9A, 0x19, 0x32, 0x64, 0xC8,
0xBD, 0x57, 0xAE, 0x71, 0xE2, 0xE9, 0xFF, 0xD3, 0x8B, 0x3B, 0x76, 0xEC, 0xF5, 0xC7, 0xA3, 0x6B,
0xD6, 0x81, 0x2F, 0x5E, 0xBC, 0x55, 0xAA, 0x79, 0xF2, 0xC9, 0xBF, 0x53, 0xA6, 0x61, 0xC2, 0xA9,
0x7F, 0xFE, 0xD1, 0x8F, 0x33, 0x66, 0xCC, 0xB5, 0x47, 0x8E, 0x31, 0x62, 0xC4, 0xA5, 0x67, 0xCE,
0xB1, 0x4F, 0x9E, 0x11, 0x22, 0x44, 0x88, 0x3D, 0x7A, 0xF4, 0xC5, 0xA7, 0x63, 0xC6, 0xA1, 0x6F,
0xDE, 0x91, 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0xCD, 0xB7, 0x43, 0x86, 0x21, 0x42, 0x84, 0x25, 0x4A,
0x94, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x6D, 0xDA, 0x99, 0x1F, 0x3E, 0x7C, 0xF8, 0xDD, 0x97,
0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xAD, 0x77, 0xEE, 0xF1, 0xCF, 0xB3, 0x4B, 0x96,
};
static const unsigned char logt_0x163[256] = {
0x00, 0x00, 0x01, 0xC5, 0x02, 0x8B, 0xC6, 0x6C, 0x03, 0x32, 0x8C, 0xC0, 0xC7, 0x25, 0x6D, 0x51,
0x04, 0x17, 0x33, 0xEE, 0x8D, 0xD8, 0xC1, 0xEA, 0xC8, 0x0C, 0x26, 0xF7, 0x6E, 0x86, 0x52, 0x7C,
0x05, 0x42, 0x18, 0x91, 0x34, 0x73, 0xEF, 0x4C, 0x8E, 0xCE, 0xD9, 0xD1, 0xC2, 0xBD, 0xEB, 0xF4,
0xC9, 0x2D, 0x0D, 0xDC, 0x27, 0xB4, 0xF8, 0xA4, 0x6F, 0xB0, 0x87, 0xD4, 0x53, 0x1E, 0x7D, 0x9E,
0x06, 0x64, 0x43, 0x37, 0x19, 0x81, 0x92, 0xE3, 0x35, 0xE1, 0x74, 0x76, 0xF0, 0x9A, 0x4D, 0x78,
0x8F, 0x4A, 0xCF, 0xF2, 0xDA, 0xA2, 0xD2, 0x9C, 0xC3, 0x6A, 0xBE, 0x4F, 0xEC, 0xE8, 0xF5, 0x7A,
0xCA, 0xAC, 0x2E, 0x08, 0x0E, 0x57, 0xDD, 0x66, 0x28, 0x12, 0xB5, 0x45, 0xF9, 0x5E, 0xA5, 0x39,
0x70, 0xBA, 0xB1, 0x1B, 0x88, 0x22, 0xD5, 0x83, 0x54, 0x5B, 0x1F, 0x94, 0x7E, 0x97, 0x9F, 0xE5,
0x07, 0xAB, 0x65, 0x56, 0x44, 0x11, 0x38, 0x5D, 0x1A, 0xB9, 0x82, 0x21, 0x93, 0x5A, 0xE4, 0x96,
0x36, 0x63, 0xE2, 0x80, 0x75, 0xE0, 0x77, 0x99, 0xF1, 0x49, 0x9B, 0xA1, 0x4E, 0x69, 0x79, 0xE7,
0x90, 0x41, 0x4B, 0x72, 0xD0, 0xCD, 0xF3, 0xBC, 0xDB, 0x2C, 0xA3, 0xB3, 0xD3, 0xAF, 0x9D, 0x1D,
0xC4, 0xFE, 0x6B, 0x8A, 0xBF, 0x31, 0x50, 0x24, 0xED, 0x16, 0xE9, 0xD7, 0xF6, 0x0B, 0x7B, 0x85,
0xCB, 0x3F, 0xAD, 0x2A, 0x2F, 0xFC, 0x09, 0x14, 0x0F, 0xA9, 0x58, 0xB7, 0xDE, 0x61, 0x67, 0x47,
0x29, 0x3E, 0x13, 0xFB, 0xB6, 0xA8, 0x46, 0x60, 0xFA, 0x3D, 0x5F, 0xA7, 0xA6, 0x3C, 0x3A, 0x3B,
0x71, 0x40, 0xBB, 0xCC, 0xB2, 0x2B, 0x1C, 0xAE, 0x89, 0xFD, 0x23, 0x30, 0xD6, 0x15, 0x84, 0x0A,
0x55, 0xAA, 0x5C, 0x10, 0x20, 0xB8, 0x95, 0x59, 0x7F, 0x62, 0x98, 0xDF, 0xA0, 0x48, 0xE6, 0x68,
};
static const unsigned char alog_0x163[510] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x63, 0xC6, 0xEF, 0xBD, 0x19, 0x32, 0x64, 0xC8,
0xF3, 0x85, 0x69, 0xD2, 0xC7, 0xED, 0xB9, 0x11, 0x22, 0x44, 0x88, 0x73, 0xE6, 0xAF, 0x3D, 0x7A,
0xF4, 0x8B, 0x75, 0xEA, 0xB7, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xC3, 0xE5, 0xA9, 0x31, 0x62, 0xC4,
0xEB, 0xB5, 0x09, 0x12, 0x24, 0x48, 0x90, 0x43, 0x86, 0x6F, 0xDE, 0xDF, 0xDD, 0xD9, 0xD1, 0xC1,
0xE1, 0xA1, 0x21, 0x42, 0x84, 0x6B, 0xD6, 0xCF, 0xFD, 0x99, 0x51, 0xA2, 0x27, 0x4E, 0x9C, 0x5B,
0xB6, 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0x83, 0x65, 0xCA, 0xF7, 0x8D, 0x79, 0xF2, 0x87, 0x6D, 0xDA,
0xD7, 0xCD, 0xF9, 0x91, 0x41, 0x82, 0x67, 0xCE, 0xFF, 0x9D, 0x59, 0xB2, 0x07, 0x0E, 0x1C, 0x38,
0x70, 0xE0, 0xA3, 0x25, 0x4A, 0x94, 0x4B, 0x96, 0x4F, 0x9E, 0x5F, 0xBE, 0x1F, 0x3E, 0x7C, 0xF8,
0x93, 0x45, 0x8A, 0x77, 0xEE, 0xBF, 0x1D, 0x3A, 0x74, 0xE8, 0xB3, 0x05, 0x0A, 0x14, 0x28, 0x50,
0xA0, 0x23, 0x46, 0x8C, 0x7B, 0xF6, 0x8F, 0x7D, 0xFA, 0x97, 0x4D, 0x9A, 0x57, 0xAE, 0x3F, 0x7E,
0xFC, 0x9B, 0x55, 0xAA, 0x37, 0x6E, 0xDC, 0xDB, 0xD5, 0xC9, 0xF1, 0x81, 0x61, 0xC2, 0xE7, 0xAD,
0x39, 0x72, 0xE4, 0xAB, 0x35, 0x6A, 0xD4, 0xCB, 0xF5, 0x89, 0x71, 0xE2, 0xA7, 0x2D, 0x5A, 0xB4,
0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xE3, 0xA5, 0x29, 0x52,
0xA4, 0x2B, 0x56, 0xAC, 0x3B, 0x76, 0xEC, 0xBB, 0x15, 0x2A, 0x54, 0xA8, 0x33, 0x66, 0xCC, 0xFB,
0x95, 0x49, 0x92, 0x47, 0x8E, 0x7F, 0xFE, 0x9F, 0x5D, 0xBA, 0x17, 0x2E, 0x5C, 0xB8, 0x13, 0x26,
0x4C, 0x98, 0x53, 0xA6, 0x2F, 0x5E, 0xBC, 0x1B, 0x36, 0x6C, 0xD8, 0xD3, 0xC5, 0xE9, 0xB1,
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x63, 0xC6, 0xEF, 0xBD, 0x19, 0x32, 0x64, 0xC8,
0xF3, 0x85, 0x69, 0xD2, 0xC7, 0xED, 0xB9, 0x11, 0x22, 0x44, 0x88, 0x73, 0xE6, 0xAF, 0x3D, 0x7A,
0xF4, 0x8B, 0x75, 0xEA, 0xB7, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xC3, 0xE5, 0xA9, 0x31, 0x62, 0xC4,
0xEB, 0xB5, 0x09, 0x12, 0x24, 0x48, 0x90, 0x43, 0x86, 0x6F, 0xDE, 0xDF, 0xDD, 0xD9, 0xD1, 0xC1,
0xE1, 0xA1, 0x21, 0x42, 0x84, 0x6B, 0xD6, 0xCF, 0xFD, 0x99, 0x51, 0xA2, 0x27, 0x4E, 0x9C, 0x5B,
0xB6, 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0x83, 0x65, 0xCA, 0xF7, 0x8D, 0x79, 0xF2, 0x87, 0x6D, 0xDA,
0xD7, 0xCD, 0xF9, 0x91, 0x41, 0x82, 0x67, 0xCE, 0xFF, 0x9D, 0x59, 0xB2, 0x07, 0x0E, 0x1C, 0x38,
0x70, 0xE0, 0xA3, 0x25, 0x4A, 0x94, 0x4B, 0x96, 0x4F, 0x9E, 0x5F, 0xBE, 0x1F, 0x3E, 0x7C, 0xF8,
0x93, 0x45, 0x8A, 0x77, 0xEE, 0xBF, 0x1D, 0x3A, 0x74, 0xE8, 0xB3, 0x05, 0x0A, 0x14, 0x28, 0x50,
0xA0, 0x23, 0x46, 0x8C, 0x7B, 0xF6, 0x8F, 0x7D, 0xFA, 0x97, 0x4D, 0x9A, 0x57, 0xAE, 0x3F, 0x7E,
0xFC, 0x9B, 0x55, 0xAA, 0x37, 0x6E, 0xDC, 0xDB, 0xD5, 0xC9, 0xF1, 0x81, 0x61, 0xC2, 0xE7, 0xAD,
0x39, 0x72, 0xE4, 0xAB, 0x35, 0x6A, 0xD4, 0xCB, 0xF5, 0x89, 0x71, 0xE2, 0xA7, 0x2D, 0x5A, 0xB4,
0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xE3, 0xA5, 0x29, 0x52,
0xA4, 0x2B, 0x56, 0xAC, 0x3B, 0x76, 0xEC, 0xBB, 0x15, 0x2A, 0x54, 0xA8, 0x33, 0x66, 0xCC, 0xFB,
0x95, 0x49, 0x92, 0x47, 0x8E, 0x7F, 0xFE, 0x9F, 0x5D, 0xBA, 0x17, 0x2E, 0x5C, 0xB8, 0x13, 0x26,
0x4C, 0x98, 0x53, 0xA6, 0x2F, 0x5E, 0xBC, 0x1B, 0x36, 0x6C, 0xD8, 0xD3, 0xC5, 0xE9, 0xB1,
};
#endif /* REEDSOL_LOGS_H */

1598
3rdparty/zint-2.10.0/backend/rss.c vendored Normal file

File diff suppressed because it is too large Load Diff

292
3rdparty/zint-2.10.0/backend/rss.h vendored Normal file
View File

@@ -0,0 +1,292 @@
/* rss.h - Data tables for Reduced Space Symbology */
/*
libzint - the open source barcode library
Copyright (C) 2007 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* RSS-14 Tables */
static const unsigned short int g_sum_table[9] = {
0, 161, 961, 2015, 2715, 0, 336, 1036, 1516
};
static const char t_table[9] = {
1, 10, 34, 70, 126, 4, 20, 48, 81
};
static const char modules_odd[9] = {
12, 10, 8, 6, 4, 5, 7, 9, 11
};
static const char modules_even[9] = {
4, 6, 8, 10, 12, 10, 8, 6, 4
};
static const char widest_odd[9] = {
8, 6, 4, 3, 1, 2, 4, 6, 8
};
static const char widest_even[9] = {
1, 3, 5, 6, 8, 7, 5, 3, 1
};
static const char finder_pattern[45] = {
3, 8, 2, 1, 1,
3, 5, 5, 1, 1,
3, 3, 7, 1, 1,
3, 1, 9, 1, 1,
2, 7, 4, 1, 1,
2, 5, 6, 1, 1,
2, 3, 8, 1, 1,
1, 5, 7, 1, 1,
1, 3, 9, 1, 1
};
static const char checksum_weight[32] = {
/* Table 5 */
1, 3, 9, 27, 2, 6, 18, 54,
4, 12, 36, 29, 8, 24, 72, 58,
16, 48, 65, 37, 32, 17, 51, 74,
64, 34, 23, 69, 49, 68, 46, 59
};
/* RSS Limited Tables */
static const unsigned short int t_even_ltd[7] = {
28, 728, 6454, 203, 2408, 1, 16632
};
static const char modules_odd_ltd[7] = {
17, 13, 9, 15, 11, 19, 7
};
static const char modules_even_ltd[7] = {
9, 13, 17, 11, 15, 7, 19
};
static const char widest_odd_ltd[7] = {
6, 5, 3, 5, 4, 8, 1
};
static const char widest_even_ltd[7] = {
3, 4, 6, 4, 5, 1, 8
};
static const char checksum_weight_ltd[28] = {
/* Table 7 */
1, 3, 9, 27, 81, 65, 17, 51, 64, 14, 42, 37, 22, 66,
20, 60, 2, 6, 18, 54, 73, 41, 34, 13, 39, 28, 84, 74
};
static const char finder_pattern_ltd[1246] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 2, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1,
1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1,
1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1,
1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 2, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 2, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1,
1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 1,
1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1,
1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 1,
1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
1, 3, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1,
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1,
1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1,
1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1,
1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1,
1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1,
1, 1, 1, 2, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1,
1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1,
1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1,
1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1,
1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1,
1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 3, 1, 1,
1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1,
1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 2, 1, 1, 1,
1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 1,
1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 1,
1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1,
1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1,
1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1,
1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1,
1, 2, 1, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1,
1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1,
1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1,
1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1,
1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1,
1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1,
1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1,
1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 1,
1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1,
1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1,
2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1,
2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1,
2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1,
2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1,
2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1,
2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1,
2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1,
2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1,
2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1
};
/* RSS Expanded Tables */
static const unsigned short int g_sum_exp[5] = {
0, 348, 1388, 2948, 3988
};
static const unsigned short int t_even_exp[5] = {
4, 20, 52, 104, 204
};
static const char modules_odd_exp[5] = {
12, 10, 8, 6, 4
};
static const char modules_even_exp[5] = {
5, 7, 9, 11, 13
};
static const char widest_odd_exp[5] = {
7, 5, 4, 3, 1
};
static const char widest_even_exp[5] = {
2, 4, 5, 6, 8
};
static const unsigned short int checksum_weight_exp[184] = {
/* Table 14 */
1, 3, 9, 27, 81, 32, 96, 77,
20, 60, 180, 118, 143, 7, 21, 63,
189, 145, 13, 39, 117, 140, 209, 205,
193, 157, 49, 147, 19, 57, 171, 91,
62, 186, 136, 197, 169, 85, 44, 132,
185, 133, 188, 142, 4, 12, 36, 108,
113, 128, 173, 97, 80, 29, 87, 50,
150, 28, 84, 41, 123, 158, 52, 156,
46, 138, 203, 187, 139, 206, 196, 166,
76, 17, 51, 153, 37, 111, 122, 155,
43, 129, 176, 106, 107, 110, 119, 146,
16, 48, 144, 10, 30, 90, 59, 177,
109, 116, 137, 200, 178, 112, 125, 164,
70, 210, 208, 202, 184, 130, 179, 115,
134, 191, 151, 31, 93, 68, 204, 190,
148, 22, 66, 198, 172, 94, 71, 2,
6, 18, 54, 162, 64, 192, 154, 40,
120, 149, 25, 75, 14, 42, 126, 167,
79, 26, 78, 23, 69, 207, 199, 175,
103, 98, 83, 38, 114, 131, 182, 124,
161, 61, 183, 127, 170, 88, 53, 159,
55, 165, 73, 8, 24, 72, 5, 15,
45, 135, 194, 160, 58, 174, 100, 89
};
static const char finder_pattern_exp[60] = {
/* Table 15 */
1, 8, 4, 1, 1,
1, 1, 4, 8, 1,
3, 6, 4, 1, 1,
1, 1, 4, 6, 3,
3, 4, 6, 1, 1,
1, 1, 6, 4, 3,
3, 2, 8, 1, 1,
1, 1, 8, 2, 3,
2, 6, 5, 1, 1,
1, 1, 5, 6, 2,
2, 2, 9, 1, 1,
1, 1, 9, 2, 2
};
static const char finder_sequence[198] = {
/* Table 16 */
1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0,
1, 6, 3, 8, 0, 0, 0, 0, 0, 0, 0,
1, 10, 3, 8, 5, 0, 0, 0, 0, 0, 0,
1, 10, 3, 8, 7, 12, 0, 0, 0, 0, 0,
1, 10, 3, 8, 9, 12, 11, 0, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 10, 9, 0, 0,
1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 0,
1, 2, 3, 4, 5, 8, 7, 10, 9, 12, 11
};
static const char weight_rows[210] = {
0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 5, 6, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 9, 10, 3, 4, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 11, 12, 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 15, 16, 21, 22, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 15, 16, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 19, 20, 21, 22, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 11, 12, 17, 18, 15, 16, 21, 22, 19, 20
};

1599
3rdparty/zint-2.10.0/backend/sjis.c vendored Normal file

File diff suppressed because it is too large Load Diff

51
3rdparty/zint-2.10.0/backend/sjis.h vendored Normal file
View File

@@ -0,0 +1,51 @@
/* sjis.h - Unicode to Shift JIS
libzint - the open source barcode library
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef SJIS_H
#define SJIS_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
INTERNAL int sjis_wctomb_zint(unsigned int *r, const unsigned int wc);
INTERNAL int sjis_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
unsigned int *jisdata);
INTERNAL int sjis_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *jisdata,
const int full_multibyte);
INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int *jisdata, const int full_multibyte);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* SJIS_H */

View File

@@ -0,0 +1,54 @@
/* stdint_msvc.h - definitions for libzint
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef STDINT_MSVC_H
#define STDINT_MSVC_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef _MSC_VER
typedef BYTE uint8_t;
typedef WORD uint16_t;
typedef DWORD uint32_t;
typedef INT32 int32_t;
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* STDINT_MSVC_H */

344
3rdparty/zint-2.10.0/backend/svg.c vendored Normal file
View File

@@ -0,0 +1,344 @@
/* svg.c - Scalable Vector Graphics */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <math.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
static void pick_colour(int colour, char colour_code[]) {
switch (colour) {
case 1: // Cyan
strcpy(colour_code, "00ffff");
break;
case 2: // Blue
strcpy(colour_code, "0000ff");
break;
case 3: // Magenta
strcpy(colour_code, "ff00ff");
break;
case 4: // Red
strcpy(colour_code, "ff0000");
break;
case 5: // Yellow
strcpy(colour_code, "ffff00");
break;
case 6: // Green
strcpy(colour_code, "00ff00");
break;
case 8: // White
strcpy(colour_code, "ffffff");
break;
default: // Black
strcpy(colour_code, "000000");
break;
}
}
static void make_html_friendly(unsigned char *string, char *html_version) {
/* Converts text to use HTML entity codes */
int i, len, html_pos;
html_pos = 0;
html_version[html_pos] = '\0';
len = (int) ustrlen(string);
for (i = 0; i < len; i++) {
switch (string[i]) {
case '>':
strcat(html_version, "&gt;");
html_pos += 4;
break;
case '<':
strcat(html_version, "&lt;");
html_pos += 4;
break;
case '&':
strcat(html_version, "&amp;");
html_pos += 5;
break;
case '"':
strcat(html_version, "&quot;");
html_pos += 6;
break;
case '\'':
strcat(html_version, "&apos;");
html_pos += 6;
break;
default:
html_version[html_pos] = string[i];
html_pos++;
html_version[html_pos] = '\0';
break;
}
}
}
INTERNAL int svg_plot(struct zint_symbol *symbol) {
FILE *fsvg;
int error_number = 0;
const char *locale = NULL;
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
float previous_diameter;
float radius, half_radius, half_sqrt3_radius;
int i;
char fgcolour_string[7];
char bgcolour_string[7];
int bg_alpha = 0xff;
int fg_alpha = 0xff;
float fg_alpha_opacity = 0.0f, bg_alpha_opacity = 0.0f;
const char *font_family = "Helvetica, sans-serif";
int bold;
struct zint_vector_rect *rect;
struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle;
struct zint_vector_string *string;
char colour_code[7];
int len, html_len;
#ifdef _MSC_VER
char *html_string;
#endif
for (i = 0; i < 6; i++) {
fgcolour_string[i] = symbol->fgcolour[i];
bgcolour_string[i] = symbol->bgcolour[i];
}
fgcolour_string[6] = '\0';
bgcolour_string[6] = '\0';
if (strlen(symbol->fgcolour) > 6) {
fg_alpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
if (fg_alpha != 0xff) {
fg_alpha_opacity = (float) (fg_alpha / 255.0);
}
}
if (strlen(symbol->bgcolour) > 6) {
bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
if (bg_alpha != 0xff) {
bg_alpha_opacity = (float) (bg_alpha / 255.0);
}
}
len = (int) ustrlen(symbol->text);
html_len = len + 1;
for (i = 0; i < len; i++) {
switch (symbol->text[i]) {
case '>':
case '<':
case '"':
case '&':
case '\'':
html_len += 6;
break;
}
}
#ifndef _MSC_VER
char html_string[html_len];
#else
html_string = (char *) _alloca(html_len);
#endif
/* Check for no created vector set */
/* E-Mail Christian Schmitz 2019-09-10: reason unknown Ticket #164*/
if (symbol->vector == NULL) {
strcpy(symbol->errtxt, "681: Vector header NULL");
return ZINT_ERROR_INVALID_DATA;
}
if (symbol->output_options & BARCODE_STDOUT) {
fsvg = stdout;
} else {
if (!(fsvg = fopen(symbol->outfile, "w"))) {
sprintf(symbol->errtxt, "680: Could not open output file (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_ACCESS;
}
}
locale = setlocale(LC_ALL, "C");
/* Start writing the header */
fprintf(fsvg, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
fprintf(fsvg, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n");
fprintf(fsvg, " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
fprintf(fsvg, "<svg width=\"%d\" height=\"%d\" version=\"1.1\"\n",
(int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height));
fprintf(fsvg, " xmlns=\"http://www.w3.org/2000/svg\">\n");
fprintf(fsvg, " <desc>Zint Generated Symbol\n");
fprintf(fsvg, " </desc>\n");
fprintf(fsvg, "\n <g id=\"barcode\" fill=\"#%s\">\n", fgcolour_string);
if (bg_alpha != 0) {
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\"",
(int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height), bgcolour_string);
if (bg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", bg_alpha_opacity);
}
fprintf(fsvg, " />\n");
}
rect = symbol->vector->rectangles;
while (rect) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\"",
rect->x, rect->y, rect->width, rect->height);
if (rect->colour != -1) {
pick_colour(rect->colour, colour_code);
fprintf(fsvg, " fill=\"#%s\"", colour_code);
}
if (fg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
}
fprintf(fsvg, " />\n");
rect = rect->next;
}
previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f;
hex = symbol->vector->hexagons;
while (hex) {
if (previous_diameter != hex->diameter) {
previous_diameter = hex->diameter;
radius = (float) (0.5 * previous_diameter);
half_radius = (float) (0.25 * previous_diameter);
half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter);
}
if ((hex->rotation == 0) || (hex->rotation == 180)) {
ay = hex->y + radius;
by = hex->y + half_radius;
cy = hex->y - half_radius;
dy = hex->y - radius;
ey = hex->y - half_radius;
fy = hex->y + half_radius;
ax = hex->x;
bx = hex->x + half_sqrt3_radius;
cx = hex->x + half_sqrt3_radius;
dx = hex->x;
ex = hex->x - half_sqrt3_radius;
fx = hex->x - half_sqrt3_radius;
} else {
ay = hex->y;
by = hex->y + half_sqrt3_radius;
cy = hex->y + half_sqrt3_radius;
dy = hex->y;
ey = hex->y - half_sqrt3_radius;
fy = hex->y - half_sqrt3_radius;
ax = hex->x - radius;
bx = hex->x - half_radius;
cx = hex->x + half_radius;
dx = hex->x + radius;
ex = hex->x + half_radius;
fx = hex->x - half_radius;
}
fprintf(fsvg, " <path d=\"M %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f Z\"",
ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy);
if (fg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
}
fprintf(fsvg, " />\n");
hex = hex->next;
}
previous_diameter = radius = 0.0f;
circle = symbol->vector->circles;
while (circle) {
if (previous_diameter != circle->diameter) {
previous_diameter = circle->diameter;
radius = (float) (0.5 * previous_diameter);
}
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\"", circle->x, circle->y, radius);
if (circle->colour) {
fprintf(fsvg, " fill=\"#%s\"", bgcolour_string);
if (bg_alpha != 0xff) {
// This doesn't work how the user is likely to expect - more work needed!
fprintf(fsvg, " opacity=\"%.3f\"", bg_alpha_opacity);
}
} else {
if (fg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
}
}
fprintf(fsvg, " />\n");
circle = circle->next;
}
bold = (symbol->output_options & BOLD_TEXT)
&& (!is_extendable(symbol->symbology) || (symbol->output_options & SMALL_TEXT));
string = symbol->vector->strings;
while (string) {
const char *halign = string->halign == 2 ? "end" : string->halign == 1 ? "start" : "middle";
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"%s\"\n", string->x, string->y, halign);
fprintf(fsvg, " font-family=\"%s\" font-size=\"%.1f\"", font_family, string->fsize);
if (bold) {
fprintf(fsvg, " font-weight=\"bold\"");
}
if (fg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
}
if (string->rotation != 0) {
fprintf(fsvg, " transform=\"rotate(%d,%.2f,%.2f)\"", string->rotation, string->x, string->y);
}
fprintf(fsvg, " >\n");
make_html_friendly(string->text, html_string);
fprintf(fsvg, " %s\n", html_string);
fprintf(fsvg, " </text>\n");
string = string->next;
}
fprintf(fsvg, " </g>\n");
fprintf(fsvg, "</svg>\n");
if (symbol->output_options & BARCODE_STDOUT) {
fflush(fsvg);
} else {
fclose(fsvg);
}
if (locale)
setlocale(LC_ALL, locale);
return error_number;
}

189
3rdparty/zint-2.10.0/backend/telepen.c vendored Normal file
View File

@@ -0,0 +1,189 @@
/* telepen.c - Handles Telepen and Telepen numeric */
/*
libzint - the open source barcode library
Copyright (C) 2008-2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* Telepen Barcode Symbology information and History (BSiH)
https://telepen.co.uk/wp-content/uploads/2018/10/Barcode-Symbology-information-and-History.pdf */
#define SODIUM "0123456789X"
#include <stdio.h>
#include "common.h"
static char *TeleTable[] = {
"31313131", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111",
"31333111", "1131113131", "33113131", "1111333111", "3111113131", "1113133111", "1311133111", "111111113131",
"3131113111", "11313331", "333331", "111131113111", "31113331", "1133113111", "1313113111", "1111113331",
"31131331", "113111113111", "3311113111", "1111131331", "311111113111", "1113111331", "1311111331", "11111111113111",
"31313311", "1131311131", "33311131", "1111313311", "3111311131", "11333311", "13133311", "111111311131",
"31331131", "1131113311", "33113311", "1111331131", "3111113311", "1113131131", "1311131131", "111111113311",
"3131111131", "1131131311", "33131311", "111131111131", "3111131311", "1133111131", "1313111131", "111111131311",
"3113111311", "113111111131", "3311111131", "111113111311", "311111111131", "111311111311", "131111111311", "11111111111131",
"3131311111", "11313133", "333133", "111131311111", "31113133", "1133311111", "1313311111", "1111113133",
"313333", "113111311111", "3311311111", "11113333", "311111311111", "11131333", "13111333", "11111111311111",
"31311133", "1131331111", "33331111", "1111311133", "3111331111", "11331133", "13131133", "111111331111",
"3113131111", "1131111133", "33111133", "111113131111", "3111111133", "111311131111", "131111131111", "111111111133",
"31311313", "113131111111", "3331111111", "1111311313", "311131111111", "11331313", "13131313", "11111131111111",
"3133111111", "1131111313", "33111313", "111133111111", "3111111313", "111313111111", "131113111111", "111111111313",
"313111111111", "1131131113", "33131113", "11113111111111", "3111131113", "113311111111", "131311111111", "111111131113",
"3113111113", "11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113", "131111111113", "1111111111111111",
};
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len) {
int i, count, check_digit;
int error_number;
char dest[521]; /* 12 (start) + 30 * 16 (max for DELs) + 16 (check digit) + 12 (stop) + 1 = 521 */
error_number = 0;
count = 0;
if (src_len > 30) {
strcpy(symbol->errtxt, "390: Input too long (30 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
/* Start character */
strcpy(dest, TeleTable['_']);
for (i = 0; i < src_len; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "391: Invalid character in input data, extended ASCII not allowed");
return ZINT_ERROR_INVALID_DATA;
}
strcat(dest, TeleTable[source[i]]);
count += source[i];
}
check_digit = 127 - (count % 127);
if (check_digit == 127) {
check_digit = 0;
}
strcat(dest, TeleTable[check_digit]);
if (symbol->debug & ZINT_DEBUG_PRINT) printf("Check digit: %d\n", check_digit);
/* Stop character */
strcat(dest, TeleTable['z']);
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
/* Default height from various Telepen docs is based on default 26pt at X 0.01125" (average of 0.01" - 0.0125")
= (26 / 72) / 0.01125 ~ 32; no min height specified */
(void) set_height(symbol, 0.0f, 32.0f, 0, 1 /*no_errtxt*/);
#else
(void) set_height(symbol, 0.0f, 50.0f, 0, 1 /*no_errtxt*/);
#endif
for (i = 0; i < src_len; i++) {
if (source[i] == '\0') {
symbol->text[i] = ' ';
} else {
symbol->text[i] = source[i];
}
}
symbol->text[src_len] = '\0';
return error_number;
}
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len) {
int count, check_digit, glyph;
int error_number;
int i;
char dest[521]; /* 12 (start) + 30 * 16 (max for DELs) + 16 (check digit) + 12 (stop) + 1 = 521 */
unsigned char temp[64];
count = 0;
if (src_len > 60) {
strcpy(symbol->errtxt, "392: Input too long (60 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
ustrcpy(temp, source);
to_upper(temp);
error_number = is_sane(SODIUM, temp, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "393: Invalid character in data (digits and \"X\" only)");
return error_number;
}
/* Add a leading zero if required */
if (src_len & 1) {
memmove(temp + 1, temp, src_len);
temp[0] = '0';
temp[++src_len] = '\0';
}
/* Start character */
strcpy(dest, TeleTable['_']);
for (i = 0; i < src_len; i += 2) {
if (temp[i] == 'X') {
strcpy(symbol->errtxt, "394: Invalid position of X in Telepen data");
return ZINT_ERROR_INVALID_DATA;
}
if (temp[i + 1] == 'X') {
glyph = ctoi(temp[i]) + 17;
count += glyph;
} else {
glyph = (10 * ctoi(temp[i])) + ctoi(temp[i + 1]);
glyph += 27;
count += glyph;
}
strcat(dest, TeleTable[glyph]);
}
check_digit = 127 - (count % 127);
if (check_digit == 127) {
check_digit = 0;
}
strcat(dest, TeleTable[check_digit]);
if (symbol->debug & ZINT_DEBUG_PRINT) printf("Check digit: %d\n", check_digit);
/* Stop character */
strcat(dest, TeleTable['z']);
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
(void) set_height(symbol, 0.0f, 32.0f, 0, 1 /*no_errtxt*/); /* Same as alphanumeric Telepen */
#else
(void) set_height(symbol, 0.0f, 50.0f, 0, 1 /*no_errtxt*/);
#endif
ustrcpy(symbol->text, temp);
return error_number;
}

View File

@@ -0,0 +1,92 @@
# Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
# Adapted from qrencode/tests/CMakeLists.txt
# Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
# vim: set ts=4 sw=4 et :
cmake_minimum_required(VERSION 3.5)
project(zint_backend_tests)
enable_testing()
include(${zint-package_SOURCE_DIR}/cmake/zint_add_test.cmake)
set(BWIPP_TAR ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps.tar.xz)
set(BWIPP_PS ${CMAKE_CURRENT_BINARY_DIR}/tools/bwipp_dump.ps)
if(NOT EXISTS ${BWIPP_PS})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tools)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${BWIPP_TAR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tools)
endif()
set(testcommon_SRCS testcommon.c testcommon.h)
add_library(testcommon ${testcommon_SRCS})
target_link_libraries(testcommon zint)
target_include_directories(testcommon PUBLIC ${zint_backend_tests_SOURCE_DIR})
if(NOT HAVE_GETOPT)
target_link_libraries(testcommon zint_bundled_getopt)
endif()
if(ZINT_STATIC)
add_library(testcommon-static ${testcommon_SRCS})
target_link_libraries(testcommon-static zint-static)
target_include_directories(testcommon-static PUBLIC ${zint_backend_tests_SOURCE_DIR})
if(NOT HAVE_GETOPT)
target_link_libraries(testcommon-static zint_bundled_getopt)
endif()
endif()
zint_add_test(2of5 test_2of5)
zint_add_test(auspost test_auspost)
zint_add_test(aztec test_aztec)
zint_add_test(big5 test_big5)
zint_add_test(bmp test_bmp)
zint_add_test(channel test_channel)
zint_add_test(codablock test_codablock)
zint_add_test(code test_code)
zint_add_test(code1 test_code1)
zint_add_test(code128 test_code128)
zint_add_test(code16k test_code16k)
zint_add_test(code49 test_code49)
zint_add_test(common test_common)
zint_add_test(composite test_composite)
zint_add_test(dmatrix test_dmatrix)
zint_add_test(dotcode test_dotcode)
zint_add_test(eci test_eci)
zint_add_test(emf test_emf)
zint_add_test(gb18030 test_gb18030)
zint_add_test(gb2312 test_gb2312)
zint_add_test(gif test_gif)
zint_add_test(gridmtx test_gridmtx)
zint_add_test(gs1 test_gs1)
zint_add_test(hanxin test_hanxin)
zint_add_test(imail test_imail)
zint_add_test(iso3166 test_iso3166)
zint_add_test(iso4217 test_iso4217)
zint_add_test(ksx1001 test_ksx1001)
zint_add_test(large test_large)
zint_add_test(library test_library)
zint_add_test(mailmark test_mailmark)
zint_add_test(maxicode test_maxicode)
zint_add_test(medical test_medical)
zint_add_test(pcx test_pcx)
zint_add_test(pdf417 test_pdf417)
zint_add_test(plessey test_plessey)
if(ZINT_USE_PNG AND PNG_FOUND)
zint_add_test(png test_png)
endif()
zint_add_test(postal test_postal)
zint_add_test(print test_print)
zint_add_test(ps test_ps)
zint_add_test(qr test_qr)
zint_add_test(raster test_raster)
zint_add_test(reedsol test_reedsol)
zint_add_test(rss test_rss)
zint_add_test(sjis test_sjis)
zint_add_test(svg test_svg)
zint_add_test(telepen test_telepen)
zint_add_test(tif test_tif)
zint_add_test(ultra test_ultra)
zint_add_test(upcean test_upcean)
zint_add_test(vector test_vector)

View File

@@ -0,0 +1,106 @@
Zint backend test suite
-----------------------
In order to build the zint test suite, zint has to be compiled with the
ZINT_TEST option enabled:
cd <project-dir>
mkdir build
cd build
cmake -DZINT_TEST=ON ..
make
------------------------------------------------------------------------------
In order to run the test suite, the path of the zint library may need to be
communicated to the runtime linker. On UNIX-like systems, this is done by
exporting LD_LIBRARY_PATH to the path containing the zint library, which is
<build-dir>/backend:
cd <project-dir>
cd build
export LD_LIBRARY_PATH=$(pwd)/backend
Setting LD_LIBRARY_PATH is not required if the zint library to be tested is
installed into a system library path ( /usr/lib for example ) prior to running
the tests.
To run all tests (within <build-dir>):
ctest
For various useful options, e.g. matching (-R) and excluding (-E) tests, see
https://cmake.org/cmake/help/latest/manual/ctest.1.html#options
Tests can also be run individually, eg:
backend/tests/test_common
backend/tests/test_vector
To run a single test function within an individual test, use '-f <func-name>':
backend/tests/test_common -f utf8_to_unicode
backend/tests/test_dotcode -f input
To run a single dataset item in a single test function, use '-i <index>':
backend/tests/test_dotcode -f input -i 2
To show debug info (if any), use '-d <flag>':
backend/tests/test_dotcode -f input -i 2 -d 1
(for other flags see <project-dir>/backend/tests/testcommon.h)
To generate test data, use '-g':
backend/tests/test_dotcode -f encode -g
To run a test against BWIPP (if any), use '-d 128':
backend/tests/test_composite -d 128
(see also <project-dir>/backend/tests/tools/run_bwipp_tests.sh)
------------------------------------------------------------------------------
If the zint library was built with static linkage support, i.e. ZINT_STATIC
is ON, an additional test executable, which uses the zint-static library, will
be built. The static variant of each test shares the test name, but has a
"-static" suffix. For example,
backend/tests/test_dotcode
would run the dotcode test that uses the shared zint library, while
backend/tests/test_dotcode-static
runs the same test built against the zint-static library.
------------------------------------------------------------------------------
To make with gcc sanitize, first set for libzint and make:
cd <project-dir>
cd build
cmake -DZINT_SANITIZE=ON ..
make && sudo make install
Similarly to make with gcc debug:
cd <project-dir>
cd build
cmake -DZINT_DEBUG=ON ..
make && sudo make install
To undo sanitize/debug, remake each after setting:
cmake -DZINT_SANITIZE=OFF ..
cmake -DZINT_DEBUG=OFF ..
To get a clean libzint, set the above and also:
cmake -DZINT_TEST=OFF ..
(The tests will now fail to link.)

View File

@@ -0,0 +1,53 @@
# - Try to find the Zint barcode library
# Once done this will define
#
# LIBZINT_FOUND - System has Zint barcode
# LIBZINT_INCLUDE_DIRS - The Zint barcode include directory
# LIBZINT_LIBRARIES - The libraries needed to use Zint barcode
# LIBZINT_DEFINITIONS - Definitions needed to use Zint barcode
# LIBZINT_VERSION_STRING - the version of Zint barcode found
set (LIBZINT_DEFINITIONS "")
find_path (LIBZINT_INCLUDE_DIR NAMES zint.h)
find_library (LIBZINT_LIBRARY NAMES zint )
if (LIBZINT_LIBRARY AND LIBZINT_INCLUDE_DIR)
set (LIBZINT_INCLUDE_DIRS ${LIBZINT_INCLUDE_DIR})
set (LIBZINT_LIBRARIES ${LIBZINT_LIBRARY})
set (LIBZINT_DEFINITIONS "")
if (NOT TARGET ZINT::ZINT)
add_library (ZINT::ZINT UNKNOWN IMPORTED)
set_target_properties (ZINT::ZINT PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${LIBZINT_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBZINT_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${LIBZINT_LIBRARY}"
)
endif ()
endif ()
if (LIBZINT_INCLUDE_DIR AND EXISTS "${LIBZINT_INCLUDE_DIR}/zintconfig.h")
file (STRINGS "${LIBZINT_INCLUDE_DIR}/zintconfig.h" ZINT_MAJOR_H REGEX "^#define ZINT_VERSION_MAJOR *[0-9]*")
file (STRINGS "${LIBZINT_INCLUDE_DIR}/zintconfig.h" ZINT_MINOR_H REGEX "^#define ZINT_VERSION_MINOR *[0-9]*")
file (STRINGS "${LIBZINT_INCLUDE_DIR}/zintconfig.h" ZINT_MICRO_H REGEX "^#define ZINT_VERSION_RELEASE *[0-9]*")
string (REGEX REPLACE "^.*VERSION_MAJOR *([0-9]*)" "\\1" ZINT_MAJOR ${ZINT_MAJOR_H})
string (REGEX REPLACE "^.*VERSION_MINOR *([0-9]*)" "\\1" ZINT_MINOR ${ZINT_MINOR_H})
string (REGEX REPLACE "^.*VERSION_RELEASE *([0-9]*)" "\\1" ZINT_MICRO ${ZINT_MICRO_H})
set (LIBZINT_VERSION_STRING ${ZINT_MAJOR}.${ZINT_MINOR}.${ZINT_MICRO})
endif()
# handle the QUIETLY and REQUIRED arguments and set LIBZINT_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibZint
REQUIRED_VARS LIBZINT_LIBRARY LIBZINT_INCLUDE_DIR
VERSION_VAR LIBZINT_VERSION_STRING)
mark_as_advanced(LIBZINT_INCLUDE_DIR LIBZINT_LIBRARY)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More