mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
back-merged
This commit is contained in:
parent
6413351fd6
commit
d8330f5d96
@ -115,7 +115,7 @@ int GetPossibleCharacterSet(unsigned char C)
|
|||||||
* int CFollowing The number of characters encodable in CodeC if we
|
* int CFollowing The number of characters encodable in CodeC if we
|
||||||
* start here.
|
* start here.
|
||||||
*/
|
*/
|
||||||
void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data, int dataLength)
|
static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data,const size_t dataLength)
|
||||||
{
|
{
|
||||||
int charCur;
|
int charCur;
|
||||||
int runChar;
|
int runChar;
|
||||||
@ -205,7 +205,7 @@ int RemainingDigits(CharacterSetTable *T, int charCur,int emptyColumns)
|
|||||||
* Return value Resulting row count
|
* Return value Resulting row count
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int Columns2Rows(CharacterSetTable *T, unsigned char *data, int dataLength,
|
static int Columns2Rows(CharacterSetTable *T, unsigned char *data, const size_t dataLength,
|
||||||
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
|
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
|
||||||
{
|
{
|
||||||
int useColumns; /* Usable Characters per line */
|
int useColumns; /* Usable Characters per line */
|
||||||
@ -430,7 +430,7 @@ int Columns2Rows(CharacterSetTable *T, unsigned char *data, int dataLength,
|
|||||||
}
|
}
|
||||||
/* Find columns if row count is given.
|
/* Find columns if row count is given.
|
||||||
*/
|
*/
|
||||||
int Rows2Columns(CharacterSetTable *T, unsigned char *data, int dataLength,
|
static int Rows2Columns(CharacterSetTable *T, unsigned char *data, const size_t dataLength,
|
||||||
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
|
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
|
||||||
{
|
{
|
||||||
int errorCur;
|
int errorCur;
|
||||||
@ -630,8 +630,7 @@ void SumASCII(uchar **ppOutPos, int Sum, int CharacterSet)
|
|||||||
/* Main function called by zint framework
|
/* Main function called by zint framework
|
||||||
*/
|
*/
|
||||||
int codablock(struct zint_symbol *symbol,const unsigned char source[], const size_t length) {
|
int codablock(struct zint_symbol *symbol,const unsigned char source[], const size_t length) {
|
||||||
int charCur;
|
size_t charCur,dataLength;
|
||||||
int dataLength;
|
|
||||||
int Error;
|
int Error;
|
||||||
int rows, columns, useColumns;
|
int rows, columns, useColumns;
|
||||||
int fillings;
|
int fillings;
|
||||||
@ -733,7 +732,7 @@ int codablock(struct zint_symbol *symbol,const unsigned char source[], const siz
|
|||||||
Sum1=Sum2=0;
|
Sum1=Sum2=0;
|
||||||
if (rows>1)
|
if (rows>1)
|
||||||
{
|
{
|
||||||
int charCur;
|
size_t charCur;
|
||||||
for (charCur=0 ; charCur<dataLength ; charCur++) {
|
for (charCur=0 ; charCur<dataLength ; charCur++) {
|
||||||
Sum1=(Sum1 + (charCur%86+1)*data[charCur])%86;
|
Sum1=(Sum1 + (charCur%86+1)*data[charCur])%86;
|
||||||
Sum2=(Sum2 + (charCur%86)*data[charCur])%86;
|
Sum2=(Sum2 + (charCur%86)*data[charCur])%86;
|
||||||
|
@ -59,7 +59,7 @@ char itoc(const int source) {
|
|||||||
void bin_append(const int arg, const int length, char *binary) {
|
void bin_append(const int arg, const int length, char *binary) {
|
||||||
int i;
|
int i;
|
||||||
int start;
|
int start;
|
||||||
int posn = strlen(binary);
|
size_t posn = strlen(binary);
|
||||||
|
|
||||||
start = 0x01 << (length - 1);
|
start = 0x01 << (length - 1);
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ int is_extendable(const int symbology) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int istwodigits(const unsigned char source[], const int position) {
|
int istwodigits(const unsigned char source[], const size_t position) {
|
||||||
if ((source[position] >= '0') && (source[position] <= '9')) {
|
if ((source[position] >= '0') && (source[position] <= '9')) {
|
||||||
if ((source[position + 1] >= '0') && (source[position + 1] <= '9')) {
|
if ((source[position + 1] >= '0') && (source[position + 1] <= '9')) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -64,7 +64,7 @@ extern "C" {
|
|||||||
extern int posn(const char set_string[], const char data);
|
extern int posn(const char set_string[], const char data);
|
||||||
extern int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
extern int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||||
extern void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
extern void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||||
extern int istwodigits(const unsigned char source[], const int position);
|
extern int istwodigits(const unsigned char source[], const size_t position);
|
||||||
extern int parunmodd(const unsigned char llyth);
|
extern int parunmodd(const unsigned char llyth);
|
||||||
extern void expand(struct zint_symbol *symbol, const char data[]);
|
extern void expand(struct zint_symbol *symbol, const char data[]);
|
||||||
extern void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
extern void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||||
|
@ -150,7 +150,7 @@ static int cc_a(struct zint_symbol *symbol, char source[], int cc_width) {
|
|||||||
codeWords[i] = 0;
|
codeWords[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bitlen = strlen(source);
|
bitlen = (int)strlen(source);
|
||||||
|
|
||||||
for (i = 0; i < 208; i++) {
|
for (i = 0; i < 208; i++) {
|
||||||
local_source[i] = '0';
|
local_source[i] = '0';
|
||||||
|
@ -256,7 +256,7 @@ static void dminsert(char binary_string[], const int posn, const char newbit) {
|
|||||||
binary_string[posn] = newbit;
|
binary_string[posn] = newbit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void insert_value(unsigned char binary_stream[], const int posn, const size_t streamlen, const int newbit) {
|
static void insert_value(unsigned char binary_stream[], const int posn, const int streamlen, const int newbit) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = (int)streamlen; i > posn; i--) {
|
for(i = (int)streamlen; i > posn; i--) {
|
||||||
@ -265,15 +265,15 @@ static void insert_value(unsigned char binary_stream[], const int posn, const si
|
|||||||
binary_stream[posn] = (unsigned char) newbit;
|
binary_stream[posn] = (unsigned char) newbit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int p_r_6_2_1(const unsigned char inputData[], const int position, const size_t sourcelen) {
|
static int p_r_6_2_1(const unsigned char inputData[], const size_t position, const size_t sourcelen) {
|
||||||
/* Annex P section (r)(6)(ii)(I)
|
/* Annex P section (r)(6)(ii)(I)
|
||||||
"If one of the three X12 terminator/separator characters first
|
"If one of the three X12 terminator/separator characters first
|
||||||
occurs in the yet to be processed data before a non-X12 character..."
|
occurs in the yet to be processed data before a non-X12 character..."
|
||||||
*/
|
*/
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
int nonX12Position = 0;
|
size_t nonX12Position = 0;
|
||||||
int specialX12Position = 0;
|
size_t specialX12Position = 0;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
for (i = position; i < sourcelen; i++) {
|
for (i = position; i < sourcelen; i++) {
|
||||||
|
@ -1203,13 +1203,15 @@ int dotcode(struct zint_symbol *symbol, const unsigned char source[], int length
|
|||||||
int binary_finish = 0;
|
int binary_finish = 0;
|
||||||
int debug = 0;
|
int debug = 0;
|
||||||
int padding_dots, is_first;
|
int padding_dots, is_first;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
unsigned char* masked_codeword_array;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
unsigned char codeword_array[length * 3];
|
unsigned char codeword_array[length * 3];
|
||||||
#else
|
#else
|
||||||
char* dot_stream;
|
char* dot_stream;
|
||||||
char* dot_array;
|
char* dot_array;
|
||||||
unsigned char* masked_codeword_array;
|
|
||||||
unsigned char* codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char));
|
unsigned char* codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char));
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Convert Unicode to other character encodings */
|
/* Convert Unicode to other character encodings */
|
||||||
int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int *length) {
|
int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length) {
|
||||||
int glyph;
|
int glyph;
|
||||||
int bytelen;
|
int bytelen;
|
||||||
int in_posn;
|
int in_posn;
|
||||||
@ -288,7 +288,7 @@ int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find the lowest ECI mode which will encode a given set of Unicode text */
|
/* Find the lowest ECI mode which will encode a given set of Unicode text */
|
||||||
int get_best_eci(unsigned char source[], int length) {
|
int get_best_eci(unsigned char source[], size_t length) {
|
||||||
int eci = 3;
|
int eci = 3;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
@ -65,7 +65,7 @@ int getsubmode(char input) {
|
|||||||
|
|
||||||
/* Calculate the approximate length of the binary string */
|
/* Calculate the approximate length of the binary string */
|
||||||
static int calculate_binlength(char mode[], int source[], const size_t length, int eci) {
|
static int calculate_binlength(char mode[], int source[], const size_t length, int eci) {
|
||||||
int i;
|
size_t i;
|
||||||
char lastmode = 't';
|
char lastmode = 't';
|
||||||
int est_binlen = 0;
|
int est_binlen = 0;
|
||||||
int submode = 1;
|
int submode = 1;
|
||||||
@ -226,7 +226,7 @@ int isFourByte(int glyph, int glyph2) {
|
|||||||
|
|
||||||
/* Calculate mode switching */
|
/* Calculate mode switching */
|
||||||
static void hx_define_mode(char mode[], int source[], const size_t length) {
|
static void hx_define_mode(char mode[], int source[], const size_t length) {
|
||||||
int i;
|
size_t i;
|
||||||
char lastmode = 't';
|
char lastmode = 't';
|
||||||
int done;
|
int done;
|
||||||
|
|
||||||
|
@ -172,7 +172,8 @@ short int islarger(short int accum[], short int reg[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void binary_load(short int reg[], char data[], const size_t src_len) {
|
void binary_load(short int reg[], char data[], const size_t src_len) {
|
||||||
int read, i;
|
size_t read;
|
||||||
|
int i;
|
||||||
short int temp[112] = {0};
|
short int temp[112] = {0};
|
||||||
|
|
||||||
for (i = 0; i < 112; i++) {
|
for (i = 0; i < 112; i++) {
|
||||||
|
@ -145,8 +145,9 @@ void ZBarcode_Delete(struct zint_symbol *symbol) {
|
|||||||
free(symbol);
|
free(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int get_best_eci(unsigned char source[], int length); /* Calculate suitable ECI mode */
|
extern int get_best_eci(unsigned char source[], size_t length); /* Calculate suitable ECI mode */
|
||||||
extern int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int *length); /* Convert Unicode to other encodings */
|
extern int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */
|
||||||
|
|
||||||
|
|
||||||
extern int eanx(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN system barcodes */
|
extern int eanx(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN system barcodes */
|
||||||
extern int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Code 3 from 9 (or Code 39) */
|
extern int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Code 3 from 9 (or Code 39) */
|
||||||
@ -203,7 +204,7 @@ extern int grid_matrix(struct zint_symbol *symbol, const unsigned char source[],
|
|||||||
extern int han_xin(struct zint_symbol * symbol, const unsigned char source[], size_t length); /* Han Xin */
|
extern int han_xin(struct zint_symbol * symbol, const unsigned char source[], size_t length); /* Han Xin */
|
||||||
extern int dotcode(struct zint_symbol * symbol, const unsigned char source[], int length); /* DotCode */
|
extern int dotcode(struct zint_symbol * symbol, const unsigned char source[], int length); /* DotCode */
|
||||||
extern int codablock(struct zint_symbol * symbol, const unsigned char source[], const size_t length); /* Codablock */
|
extern int codablock(struct zint_symbol * symbol, const unsigned char source[], const size_t length); /* Codablock */
|
||||||
extern int upnqr(struct zint_symbol *symbol, const unsigned char source[], int length); /* UPNQR */
|
extern int upnqr(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* UPNQR */
|
||||||
extern int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* Data Matrix (IEC16022) */
|
extern int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* Data Matrix (IEC16022) */
|
||||||
extern int dmatrix(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* QR Code */
|
extern int dmatrix(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* QR Code */
|
||||||
|
|
||||||
@ -615,7 +616,7 @@ static int extended_charset(struct zint_symbol *symbol, const unsigned char *sou
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reduced_charset(struct zint_symbol *symbol, const unsigned char *source, int in_length) {
|
static int reduced_charset(struct zint_symbol *symbol, const unsigned char *source, size_t in_length) {
|
||||||
/* These are the "norm" standards which only support Latin-1 at most */
|
/* These are the "norm" standards which only support Latin-1 at most */
|
||||||
int error_number = 0;
|
int error_number = 0;
|
||||||
|
|
||||||
@ -1049,7 +1050,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source,int
|
|||||||
case BARCODE_MICROQR:
|
case BARCODE_MICROQR:
|
||||||
case BARCODE_GRIDMATRIX:
|
case BARCODE_GRIDMATRIX:
|
||||||
case BARCODE_HANXIN:
|
case BARCODE_HANXIN:
|
||||||
error_number = utf_to_eci(symbol->eci, source, local_source, &in_length);
|
error_number = utf_to_eci(symbol->eci, source, local_source, (size_t*)&in_length);
|
||||||
error_number = extended_charset(symbol, local_source, in_length);
|
error_number = extended_charset(symbol, local_source, in_length);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
10
backend/qr.c
10
backend/qr.c
@ -42,7 +42,7 @@
|
|||||||
#include <stdlib.h> /* abs */
|
#include <stdlib.h> /* abs */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
extern int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int *length); /* Convert Unicode to other encodings */
|
extern int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */
|
||||||
|
|
||||||
/* Returns true if input glyph is in the Alphanumeric set */
|
/* Returns true if input glyph is in the Alphanumeric set */
|
||||||
static int in_alpha(const int glyph) {
|
static int in_alpha(const int glyph) {
|
||||||
@ -147,7 +147,7 @@ static int tribus(const int version,const int a,const int b,const int c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert input data to a binary stream and add padding */
|
/* Convert input data to a binary stream and add padding */
|
||||||
static void qr_binary(int datastream[], const int version, const int target_binlen, const char mode[], const int jisdata[], const size_t length, const int gs1, const int eci, const int est_binlen, int debug) {
|
static void qr_binary(int datastream[], const int version, const int target_binlen, const char mode[], const int jisdata[], const size_t length, const int gs1, const int eci, const int est_binlen,const int debug) {
|
||||||
int position = 0;
|
int position = 0;
|
||||||
int short_data_block_length, i;
|
int short_data_block_length, i;
|
||||||
char data_block, padbits;
|
char data_block, padbits;
|
||||||
@ -1313,7 +1313,7 @@ static void applyOptimisation(const int version,char inputMode[], const size_t i
|
|||||||
free(blockMode);
|
free(blockMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blockLength(const int start,const char inputMode[],const size_t inputLength) {
|
static int blockLength(const size_t start,const char inputMode[],const size_t inputLength) {
|
||||||
/* Find the length of the block starting from 'start' */
|
/* Find the length of the block starting from 'start' */
|
||||||
size_t i;
|
size_t i;
|
||||||
int count;
|
int count;
|
||||||
@ -1648,7 +1648,7 @@ int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t len
|
|||||||
|
|
||||||
/* NOTE: From this point forward concerns Micro QR Code only */
|
/* NOTE: From this point forward concerns Micro QR Code only */
|
||||||
|
|
||||||
static int micro_qr_intermediate(char binary[], const int jisdata[], const char mode[], const size_t length, int *kanji_used, int *alphanum_used, int *byte_used, int debug) {
|
static int micro_qr_intermediate(char binary[], const int jisdata[], const char mode[], const size_t length, int *kanji_used, int *alphanum_used, int *byte_used,const int debug) {
|
||||||
/* Convert input data to an "intermediate stage" where data is binary encoded but
|
/* Convert input data to an "intermediate stage" where data is binary encoded but
|
||||||
control information is not */
|
control information is not */
|
||||||
int position = 0;
|
int position = 0;
|
||||||
@ -2888,7 +2888,7 @@ int microqr(struct zint_symbol *symbol, const unsigned char source[], size_t len
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* For UPNQR the symbol size and error correction capacity is fixed */
|
/* For UPNQR the symbol size and error correction capacity is fixed */
|
||||||
int upnqr(struct zint_symbol *symbol, const unsigned char source[], int length) {
|
int upnqr(struct zint_symbol *symbol, const unsigned char source[], size_t length) {
|
||||||
int i, j, est_binlen;
|
int i, j, est_binlen;
|
||||||
int ecc_level, version, target_binlen, blocks, size;
|
int ecc_level, version, target_binlen, blocks, size;
|
||||||
int bitmask, error_number;
|
int bitmask, error_number;
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>libpng16d.lib;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)zintd.dll</OutputFile>
|
<OutputFile>$(OutDir)zintd.dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>..\extern\libpng\lib\x86;..\extern\zlib\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>..\extern\libpng\lib\x86;..\extern\zlib\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<IgnoreSpecificDefaultLibraries>libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
<IgnoreSpecificDefaultLibraries>libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||||
@ -169,7 +169,7 @@
|
|||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>libpng16d.lib;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)zintd.dll</OutputFile>
|
<OutputFile>$(OutDir)zintd.dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>..\extern\libpng\lib\x64;..\extern\zlib\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>..\extern\libpng\lib\x64;..\extern\zlib\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<IgnoreSpecificDefaultLibraries>libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
<IgnoreSpecificDefaultLibraries>libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||||
|
Loading…
Reference in New Issue
Block a user