mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
#209 suppress CodeQL warnings except CODEONE; simplifications AZTEC_RUNE, MICROPDF417
This commit is contained in:
parent
bee5f08f50
commit
f62a678d0f
@ -61,7 +61,7 @@ static inline char check_digit(unsigned int count) {
|
||||
INTERNAL int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, error_number;
|
||||
char dest[512]; /* 6 + 80 * 6 + 6 + 1 ~ 512*/
|
||||
char dest[512]; /* 6 + 80 * 6 + 5 + 1 = 492 */
|
||||
|
||||
if (length > 80) {
|
||||
strcpy(symbol->errtxt, "301: Input too long");
|
||||
@ -92,7 +92,7 @@ INTERNAL int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source
|
||||
INTERNAL int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, error_number;
|
||||
char dest[512]; /* 6 + 40 * 10 + 6 + 1 */
|
||||
char dest[512]; /* 6 + 45 * 10 + 5 + 1 = 462 */
|
||||
|
||||
if (length > 45) {
|
||||
strcpy(symbol->errtxt, "303: Input too long");
|
||||
@ -122,7 +122,7 @@ INTERNAL int industrial_two_of_five(struct zint_symbol *symbol, unsigned char so
|
||||
/* Code 2 of 5 IATA */
|
||||
INTERNAL int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number;
|
||||
char dest[512]; /* 4 + 45 * 10 + 3 + 1 */
|
||||
char dest[512]; /* 4 + 45 * 10 + 3 + 1 = 458 */
|
||||
|
||||
if (length > 45) {
|
||||
strcpy(symbol->errtxt, "305: Input too long");
|
||||
@ -153,7 +153,7 @@ INTERNAL int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[]
|
||||
INTERNAL int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, error_number;
|
||||
char dest[512]; /* 4 + 80 * 6 + 3 + 1 */
|
||||
char dest[512]; /* 4 + 80 * 6 + 3 + 1 = 488 */
|
||||
|
||||
if (length > 80) {
|
||||
strcpy(symbol->errtxt, "307: Input too long");
|
||||
@ -181,17 +181,17 @@ INTERNAL int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[
|
||||
}
|
||||
|
||||
/* Code 2 of 5 Interleaved */
|
||||
INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, const unsigned char source[], size_t length) {
|
||||
INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, j, error_number;
|
||||
char bars[7], spaces[7], mixed[14], dest[1000];
|
||||
char bars[7], spaces[7], mixed[14], dest[512]; /* 4 + 90 * 5 + 3 + 1 = 458 */
|
||||
#ifndef _MSC_VER
|
||||
unsigned char temp[length + 2];
|
||||
#else
|
||||
unsigned char* temp = (unsigned char *) _alloca((length + 2) * sizeof (unsigned char));
|
||||
#endif
|
||||
|
||||
if (length > 89) {
|
||||
if (length > 90) {
|
||||
strcpy(symbol->errtxt, "309: Input too long");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
@ -201,24 +201,24 @@ INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, const unsigned
|
||||
return error_number;
|
||||
}
|
||||
|
||||
ustrcpy(temp, "");
|
||||
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 then add a leading zero */
|
||||
if (length & 1) {
|
||||
ustrcpy(temp, "0");
|
||||
length++;
|
||||
}
|
||||
ustrcat(temp, source);
|
||||
ustrncat(temp, source, length);
|
||||
|
||||
/* start character */
|
||||
strcpy(dest, "1111");
|
||||
|
||||
for (i = 0; i < (int) length; i += 2) {
|
||||
for (i = 0; i < length; i += 2) {
|
||||
int k = 0;
|
||||
/* look up the bars and the spaces and put them in two strings */
|
||||
strcpy(bars, "");
|
||||
bars[0] = '\0';
|
||||
lookup(NEON, C25InterTable, temp[i], bars);
|
||||
strcpy(spaces, "");
|
||||
spaces[0] = '\0';
|
||||
lookup(NEON, C25InterTable, temp[i + 1], spaces);
|
||||
|
||||
/* then merge (interlace) the strings together */
|
||||
@ -238,7 +238,6 @@ INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, const unsigned
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, temp);
|
||||
return error_number;
|
||||
|
||||
}
|
||||
|
||||
/* Interleaved 2-of-5 (ITF) */
|
||||
@ -277,7 +276,7 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
}
|
||||
localstr[13] = check_digit(count);
|
||||
localstr[14] = '\0';
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, 14);
|
||||
ustrcpy(symbol->text, localstr);
|
||||
|
||||
if (!((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND))) {
|
||||
@ -324,7 +323,7 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
}
|
||||
localstr[13] = check_digit(count);
|
||||
localstr[14] = '\0';
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, 14);
|
||||
ustrcpy(symbol->text, localstr);
|
||||
return error_number;
|
||||
}
|
||||
@ -360,7 +359,7 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
}
|
||||
localstr[11] = check_digit(count);
|
||||
localstr[12] = '\0';
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, 12);
|
||||
ustrcpy(symbol->text, localstr);
|
||||
return error_number;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
|
||||
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
|
||||
@ -55,9 +55,7 @@ static const char *AusBarTable[64] = {
|
||||
"332", "333"
|
||||
};
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "common.h"
|
||||
#include "reedsol.h"
|
||||
#ifdef _MSC_VER
|
||||
@ -103,8 +101,8 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
3 = Tracker only */
|
||||
int error_number;
|
||||
int writer;
|
||||
unsigned int loopey, reader;
|
||||
size_t h;
|
||||
int loopey, reader;
|
||||
int h;
|
||||
|
||||
char data_pattern[200];
|
||||
char fcc[3] = {0, 0, 0}, dpid[10];
|
||||
@ -168,12 +166,16 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
localstr[zeroes] = '\0';
|
||||
}
|
||||
|
||||
strncat(localstr, (char *) source, length);
|
||||
h = strlen(localstr);
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("AUSPOST FCC: %s\n", fcc);
|
||||
}
|
||||
|
||||
ustrncat(localstr, source, length);
|
||||
h = (int) strlen(localstr);
|
||||
/* Verifiy that the first 8 characters are numbers */
|
||||
memcpy(dpid, localstr, 8);
|
||||
dpid[8] = '\0';
|
||||
error_number = is_sane(NEON, (unsigned char *) dpid, strlen(dpid));
|
||||
error_number = is_sane(NEON, (unsigned char *) dpid, 8);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "405: Invalid characters in DPID");
|
||||
return error_number;
|
||||
@ -187,8 +189,6 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
lookup(NEON, AusNTable, fcc[reader], data_pattern);
|
||||
}
|
||||
|
||||
/* printf("AUSPOST FCC: %s ", fcc); */
|
||||
|
||||
/* Delivery Point Identifier (DPID) */
|
||||
for (reader = 0; reader < 8; reader++) {
|
||||
lookup(NEON, AusNTable, dpid[reader], data_pattern);
|
||||
@ -208,7 +208,7 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
}
|
||||
|
||||
/* Filler bar */
|
||||
h = strlen(data_pattern);
|
||||
h = (int) strlen(data_pattern);
|
||||
switch (h) {
|
||||
case 22:
|
||||
case 37:
|
||||
@ -227,7 +227,7 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
|
||||
|
||||
/* Turn the symbol into a bar pattern ready for plotting */
|
||||
writer = 0;
|
||||
h = strlen(data_pattern);
|
||||
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);
|
||||
|
@ -100,12 +100,12 @@ static char get_next_mode(char encode_mode[], const int src_len, int i) {
|
||||
}
|
||||
}
|
||||
|
||||
static int az_bin_append_posn(const int arg, const int length, char *binary, int posn) {
|
||||
static int az_bin_append_posn(const int arg, const int length, char *binary, int bin_posn) {
|
||||
|
||||
if (posn + length > AZTEC_BIN_CAPACITY) {
|
||||
if (bin_posn + length > AZTEC_BIN_CAPACITY) {
|
||||
return 0; /* Fail */
|
||||
}
|
||||
return bin_append_posn(arg, length, binary, posn);
|
||||
return bin_append_posn(arg, length, binary, bin_posn);
|
||||
}
|
||||
|
||||
static int aztec_text_process(const unsigned char source[], int src_len, char binary_string[], const int gs1,
|
||||
@ -1470,9 +1470,11 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
|
||||
/* Encodes Aztec runes as specified in ISO/IEC 24778:2008 Annex A */
|
||||
INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int input_value, error_number, i, y, x;
|
||||
unsigned int input_value;
|
||||
int error_number, i, y, x, r;
|
||||
char binary_string[28];
|
||||
unsigned char data_codewords[3], ecc_codewords[6];
|
||||
int bp = 0;
|
||||
int debug = symbol->debug & ZINT_DEBUG_PRINT;
|
||||
rs_t rs;
|
||||
|
||||
@ -1503,52 +1505,17 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
*binary_string = '\0';
|
||||
bin_append(input_value, 8, binary_string);
|
||||
bp = bin_append_posn(input_value, 8, binary_string, bp);
|
||||
|
||||
data_codewords[0] = 0;
|
||||
data_codewords[1] = 0;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (binary_string[i * 4] == '1') {
|
||||
data_codewords[i] += 8;
|
||||
}
|
||||
if (binary_string[(i * 4) + 1] == '1') {
|
||||
data_codewords[i] += 4;
|
||||
}
|
||||
if (binary_string[(i * 4) + 2] == '1') {
|
||||
data_codewords[i] += 2;
|
||||
}
|
||||
if (binary_string[(i * 4) + 3] == '1') {
|
||||
data_codewords[i] += 1;
|
||||
}
|
||||
}
|
||||
data_codewords[0] = input_value >> 4;
|
||||
data_codewords[1] = input_value & 0xF;
|
||||
|
||||
rs_init_gf(&rs, 0x13);
|
||||
rs_init_code(&rs, 5, 1);
|
||||
rs_encode(&rs, 2, data_codewords, ecc_codewords);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (ecc_codewords[4 - i] & 0x08) {
|
||||
binary_string[(i * 4) + 8] = '1';
|
||||
} else {
|
||||
binary_string[(i * 4) + 8] = '0';
|
||||
}
|
||||
if (ecc_codewords[4 - i] & 0x04) {
|
||||
binary_string[(i * 4) + 9] = '1';
|
||||
} else {
|
||||
binary_string[(i * 4) + 9] = '0';
|
||||
}
|
||||
if (ecc_codewords[4 - i] & 0x02) {
|
||||
binary_string[(i * 4) + 10] = '1';
|
||||
} else {
|
||||
binary_string[(i * 4) + 10] = '0';
|
||||
}
|
||||
if (ecc_codewords[4 - i] & 0x01) {
|
||||
binary_string[(i * 4) + 11] = '1';
|
||||
} else {
|
||||
binary_string[(i * 4) + 11] = '0';
|
||||
}
|
||||
bp = bin_append_posn(ecc_codewords[4 - i], 4, binary_string, bp);
|
||||
}
|
||||
|
||||
for (i = 0; i < 28; i += 2) {
|
||||
@ -1564,12 +1531,13 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
|
||||
for (y = 8; y < 19; y++) {
|
||||
r = y * 27;
|
||||
for (x = 8; x < 19; x++) {
|
||||
if (CompactAztecMap[(y * 27) + x] == 1) {
|
||||
if (CompactAztecMap[r + x] == 1) {
|
||||
set_module(symbol, y - 8, x - 8);
|
||||
}
|
||||
if (CompactAztecMap[(y * 27) + x] >= 2) {
|
||||
if (binary_string[CompactAztecMap[(y * 27) + x] - 2000] == '1') {
|
||||
if (CompactAztecMap[r + x] >= 2) {
|
||||
if (binary_string[CompactAztecMap[r + x] - 2000] == '1') {
|
||||
set_module(symbol, y - 8, x - 8);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
@ -213,7 +213,7 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
}
|
||||
|
||||
/* Code 39 */
|
||||
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
|
||||
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i;
|
||||
int counter;
|
||||
int error_number;
|
||||
@ -246,7 +246,7 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_
|
||||
/* Start character */
|
||||
strcpy(dest, "1211212111");
|
||||
|
||||
for (i = 0; i < (int) length; i++) {
|
||||
for (i = 0; i < length; i++) {
|
||||
lookup(SILVER, C39Table, source[i], dest);
|
||||
counter += posn(SILVER, source[i]);
|
||||
}
|
||||
@ -297,7 +297,7 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_
|
||||
|
||||
if ((symbol->symbology == BARCODE_LOGMARS) || (symbol->symbology == BARCODE_HIBC_39)) {
|
||||
/* LOGMARS uses wider 'wide' bars than normal Code 39 */
|
||||
counter = strlen(dest);
|
||||
counter = (int) strlen(dest);
|
||||
for (i = 0; i < counter; i++) {
|
||||
if (dest[i] == '2') {
|
||||
dest[i] = '3';
|
||||
@ -309,7 +309,7 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_
|
||||
|
||||
if (symbol->symbology == BARCODE_CODE39) {
|
||||
ustrcpy(symbol->text, "*");
|
||||
ustrcat(symbol->text, source);
|
||||
ustrncat(symbol->text, source, length);
|
||||
ustrcat(symbol->text, localstr);
|
||||
ustrcat(symbol->text, "*");
|
||||
} else {
|
||||
@ -359,7 +359,7 @@ INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], i
|
||||
}
|
||||
localstr[8] = itoc(check_digit);
|
||||
localstr[9] = '\0';
|
||||
error_number = c39(symbol, (unsigned char *) localstr, strlen(localstr));
|
||||
error_number = c39(symbol, (unsigned char *) localstr, 9);
|
||||
ustrcpy(symbol->text, "PZN ");
|
||||
ustrcat(symbol->text, localstr);
|
||||
return error_number;
|
||||
@ -388,7 +388,7 @@ INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length
|
||||
}
|
||||
|
||||
/* Then sends the buffer to the C39 function */
|
||||
error_number = c39(symbol, buffer, ustrlen(buffer));
|
||||
error_number = c39(symbol, buffer, (int) ustrlen(buffer));
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
symbol->text[i] = source[i] >= ' ' && source[i] != 0x7F ? source[i] : ' ';
|
||||
@ -711,19 +711,18 @@ INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], in
|
||||
}
|
||||
|
||||
/* Vehicle Identification Number (VIN) */
|
||||
INTERNAL int vin(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length) {
|
||||
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];
|
||||
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;
|
||||
int length = (int) in_length;
|
||||
|
||||
// Check length
|
||||
if (length != 17) {
|
||||
@ -741,7 +740,6 @@ INTERNAL int vin(struct zint_symbol *symbol, const unsigned char source[], const
|
||||
|
||||
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];
|
||||
|
104
backend/code1.c
104
backend/code1.c
@ -151,27 +151,27 @@ static int c1_look_ahead_test(unsigned char source[], int sourcelen, int positio
|
||||
|
||||
/* Step J */
|
||||
if (current_mode == C1_ASCII) {
|
||||
ascii_count = 0.0;
|
||||
c40_count = 1.0;
|
||||
text_count = 1.0;
|
||||
edi_count = 1.0;
|
||||
byte_count = 2.0;
|
||||
ascii_count = 0.0f;
|
||||
c40_count = 1.0f;
|
||||
text_count = 1.0f;
|
||||
edi_count = 1.0f;
|
||||
byte_count = 2.0f;
|
||||
} else {
|
||||
ascii_count = 1.0;
|
||||
c40_count = 2.0;
|
||||
text_count = 2.0;
|
||||
edi_count = 2.0;
|
||||
byte_count = 3.0;
|
||||
ascii_count = 1.0f;
|
||||
c40_count = 2.0f;
|
||||
text_count = 2.0f;
|
||||
edi_count = 2.0f;
|
||||
byte_count = 3.0f;
|
||||
}
|
||||
|
||||
switch (current_mode) {
|
||||
case C1_C40: c40_count = 0.0;
|
||||
case C1_C40: c40_count = 0.0f;
|
||||
break;
|
||||
case C1_TEXT: text_count = 0.0;
|
||||
case C1_TEXT: text_count = 0.0f;
|
||||
break;
|
||||
case C1_BYTE: byte_count = 0.0;
|
||||
case C1_BYTE: byte_count = 0.0f;
|
||||
break;
|
||||
case C1_EDI: edi_count = 0.0;
|
||||
case C1_EDI: edi_count = 0.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -185,106 +185,106 @@ static int c1_look_ahead_test(unsigned char source[], int sourcelen, int positio
|
||||
|
||||
/* Step L */
|
||||
if ((source[sp] >= '0') && (source[sp] <= '9')) {
|
||||
ascii_count += 0.5;
|
||||
ascii_count += 0.5f;
|
||||
} else {
|
||||
ascii_count = ceil(ascii_count);
|
||||
ascii_count = (float) ceil(ascii_count);
|
||||
if (source[sp] > 127) {
|
||||
ascii_count += 2.0;
|
||||
ascii_count += 2.0f;
|
||||
} else {
|
||||
ascii_count += 1.0;
|
||||
ascii_count += 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/* Step M */
|
||||
done = 0;
|
||||
if (reduced_char == ' ') {
|
||||
c40_count += (2.0 / 3.0);
|
||||
c40_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if ((reduced_char >= '0') && (reduced_char <= '9')) {
|
||||
c40_count += (2.0 / 3.0);
|
||||
c40_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if ((reduced_char >= 'A') && (reduced_char <= 'Z')) {
|
||||
c40_count += (2.0 / 3.0);
|
||||
c40_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if (source[sp] > 127) {
|
||||
c40_count += (4.0 / 3.0);
|
||||
c40_count += (4.0f / 3.0f);
|
||||
}
|
||||
if (done == 0) {
|
||||
c40_count += (4.0 / 3.0);
|
||||
c40_count += (4.0f / 3.0f);
|
||||
}
|
||||
|
||||
/* Step N */
|
||||
done = 0;
|
||||
if (reduced_char == ' ') {
|
||||
text_count += (2.0 / 3.0);
|
||||
text_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if ((reduced_char >= '0') && (reduced_char <= '9')) {
|
||||
text_count += (2.0 / 3.0);
|
||||
text_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if ((reduced_char >= 'a') && (reduced_char <= 'z')) {
|
||||
text_count += (2.0 / 3.0);
|
||||
text_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if (source[sp] > 127) {
|
||||
text_count += (4.0 / 3.0);
|
||||
text_count += (4.0f / 3.0f);
|
||||
}
|
||||
if (done == 0) {
|
||||
text_count += (4.0 / 3.0);
|
||||
text_count += (4.0f / 3.0f);
|
||||
}
|
||||
|
||||
/* Step O */
|
||||
done = 0;
|
||||
if (source[sp] == 13) {
|
||||
edi_count += (2.0 / 3.0);
|
||||
edi_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if (source[sp] == '*') {
|
||||
edi_count += (2.0 / 3.0);
|
||||
edi_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if (source[sp] == '>') {
|
||||
edi_count += (2.0 / 3.0);
|
||||
edi_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if (source[sp] == ' ') {
|
||||
edi_count += (2.0 / 3.0);
|
||||
edi_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if ((source[sp] >= '0') && (source[sp] <= '9')) {
|
||||
edi_count += (2.0 / 3.0);
|
||||
edi_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if ((source[sp] >= 'A') && (source[sp] <= 'Z')) {
|
||||
edi_count += (2.0 / 3.0);
|
||||
edi_count += (2.0f / 3.0f);
|
||||
done = 1;
|
||||
}
|
||||
if (source[sp] > 127) {
|
||||
edi_count += (13.0 / 3.0);
|
||||
edi_count += (13.0f / 3.0f);
|
||||
} else {
|
||||
if (done == 0) {
|
||||
edi_count += (10.0 / 3.0);
|
||||
edi_count += (10.0f / 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
/* Step P */
|
||||
if (gs1 && (source[sp] == '[')) {
|
||||
byte_count += 3.0;
|
||||
byte_count += 3.0f;
|
||||
} else {
|
||||
byte_count += 1.0;
|
||||
byte_count += 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ascii_count = ceil(ascii_count);
|
||||
c40_count = ceil(c40_count);
|
||||
text_count = ceil(text_count);
|
||||
edi_count = ceil(edi_count);
|
||||
byte_count = ceil(byte_count);
|
||||
ascii_count = (float) ceil(ascii_count);
|
||||
c40_count = (float) ceil(c40_count);
|
||||
text_count = (float) ceil(text_count);
|
||||
edi_count = (float) ceil(edi_count);
|
||||
byte_count = (float) ceil(byte_count);
|
||||
best_scheme = C1_ASCII;
|
||||
|
||||
if (sp == sourcelen) {
|
||||
@ -313,12 +313,12 @@ static int c1_look_ahead_test(unsigned char source[], int sourcelen, int positio
|
||||
} else {
|
||||
/* Step Q */
|
||||
|
||||
if (((edi_count + 1.0 <= ascii_count) && (edi_count + 1.0 <= c40_count)) &&
|
||||
((edi_count + 1.0 <= byte_count) && (edi_count + 1.0 <= text_count))) {
|
||||
if (((edi_count + 1.0f <= ascii_count) && (edi_count + 1.0f <= c40_count)) &&
|
||||
((edi_count + 1.0f <= byte_count) && (edi_count + 1.0f <= text_count))) {
|
||||
best_scheme = C1_EDI;
|
||||
}
|
||||
|
||||
if ((c40_count + 1.0 <= ascii_count) && (c40_count + 1.0 <= text_count)) {
|
||||
if ((c40_count + 1.0f <= ascii_count) && (c40_count + 1.0f <= text_count)) {
|
||||
|
||||
if (c40_count < edi_count) {
|
||||
best_scheme = C1_C40;
|
||||
@ -333,18 +333,18 @@ static int c1_look_ahead_test(unsigned char source[], int sourcelen, int positio
|
||||
}
|
||||
}
|
||||
|
||||
if (((text_count + 1.0 <= ascii_count) && (text_count + 1.0 <= c40_count)) &&
|
||||
((text_count + 1.0 <= byte_count) && (text_count + 1.0 <= edi_count))) {
|
||||
if (((text_count + 1.0f <= ascii_count) && (text_count + 1.0f <= c40_count)) &&
|
||||
((text_count + 1.0f <= byte_count) && (text_count + 1.0f <= edi_count))) {
|
||||
best_scheme = C1_TEXT;
|
||||
}
|
||||
|
||||
if (((ascii_count + 1.0 <= byte_count) && (ascii_count + 1.0 <= c40_count)) &&
|
||||
((ascii_count + 1.0 <= text_count) && (ascii_count + 1.0 <= edi_count))) {
|
||||
if (((ascii_count + 1.0f <= byte_count) && (ascii_count + 1.0f <= c40_count)) &&
|
||||
((ascii_count + 1.0f <= text_count) && (ascii_count + 1.0f <= edi_count))) {
|
||||
best_scheme = C1_ASCII;
|
||||
}
|
||||
|
||||
if (((byte_count + 1.0 <= ascii_count) && (byte_count + 1.0 <= c40_count)) &&
|
||||
((byte_count + 1.0 <= text_count) && (byte_count + 1.0 <= edi_count))) {
|
||||
if (((byte_count + 1.0f <= ascii_count) && (byte_count + 1.0f <= c40_count)) &&
|
||||
((byte_count + 1.0f <= text_count) && (byte_count + 1.0f <= edi_count))) {
|
||||
best_scheme = C1_BYTE;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@
|
||||
|
||||
/* Code 16k can hold up to 77 characters or 154 numbers */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "common.h"
|
||||
@ -107,7 +106,7 @@ static void c16k_set_c(const unsigned char source_a, unsigned char source_b, int
|
||||
(*bar_chars)++;
|
||||
}
|
||||
|
||||
INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
|
||||
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;
|
||||
@ -242,35 +241,35 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], const s
|
||||
|
||||
/* Make sure the data will fit in the symbol */
|
||||
last_set = set[0];
|
||||
glyph_count = 0.0;
|
||||
glyph_count = 0.0f;
|
||||
for (i = 0; i < input_length; i++) {
|
||||
if ((set[i] == 'a') || (set[i] == 'b')) {
|
||||
glyph_count = glyph_count + 1.0;
|
||||
glyph_count = glyph_count + 1.0f;
|
||||
}
|
||||
if (fset[i] == 'f') {
|
||||
glyph_count = glyph_count + 1.0;
|
||||
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.0;
|
||||
glyph_count = glyph_count + 1.0f;
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
if ((set[i] == 'B') && (set[1] == 'C')) {
|
||||
glyph_count = glyph_count - 1.0;
|
||||
glyph_count = glyph_count - 1.0f;
|
||||
}
|
||||
if ((set[i] == 'B') && (set[1] == 'B')) {
|
||||
if (set[2] == 'C') {
|
||||
glyph_count = glyph_count - 1.0;
|
||||
glyph_count = glyph_count - 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((set[i] == 'C') && (!((gs1) && (source[i] == '[')))) {
|
||||
glyph_count = glyph_count + 0.5;
|
||||
glyph_count = glyph_count + 0.5f;
|
||||
} else {
|
||||
glyph_count = glyph_count + 1.0;
|
||||
glyph_count = glyph_count + 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,13 +278,13 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], const s
|
||||
glyph_count--;
|
||||
}
|
||||
|
||||
if (glyph_count > 77.0) {
|
||||
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.0;
|
||||
glyph_count = glyph_count + 2.0f;
|
||||
i = (int)glyph_count;
|
||||
rows = (i / 5);
|
||||
if (i % 5 > 0) {
|
||||
@ -473,7 +472,7 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], const s
|
||||
/* Write the information into the symbol */
|
||||
writer = 0;
|
||||
flip_flop = 1;
|
||||
for (mx_reader = 0, len = strlen(width_pattern); mx_reader < len; mx_reader++) {
|
||||
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);
|
||||
|
@ -31,7 +31,6 @@
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#include "code49.h"
|
||||
@ -40,7 +39,7 @@
|
||||
|
||||
/* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */
|
||||
|
||||
INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], const int length) {
|
||||
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;
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include <malloc.h>
|
||||
/* ceilf (C99) not before MSVC++2013 (C++ 12.0) */
|
||||
#if _MSC_VER < 1800
|
||||
#define ceilf ceil
|
||||
#define ceilf (float) ceil
|
||||
#endif
|
||||
#endif
|
||||
#include "common.h"
|
||||
@ -241,35 +241,35 @@ static int isX12(const int source) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Insert a character into the middle of a string at position posn */
|
||||
static void dminsert(char binary_string[], const int posn, const char newbit) {
|
||||
/* Insert a character into the middle of a string at position bin_posn */
|
||||
static void dminsert(char binary_string[], const int bin_posn, const char newbit) {
|
||||
int i, end;
|
||||
|
||||
end = (int) strlen(binary_string);
|
||||
for (i = end + 1; i > posn; i--) {
|
||||
for (i = end + 1; i > bin_posn; i--) {
|
||||
binary_string[i] = binary_string[i - 1];
|
||||
}
|
||||
binary_string[posn] = newbit;
|
||||
binary_string[bin_posn] = newbit;
|
||||
}
|
||||
|
||||
static void insert_value(unsigned char binary_stream[], const int posn, const int streamlen, const int newbit) {
|
||||
static void insert_value(unsigned char binary_stream[], const int bin_posn, const int streamlen, const int newbit) {
|
||||
int i;
|
||||
|
||||
for(i = (int)streamlen; i > posn; i--) {
|
||||
for (i = streamlen; i > bin_posn; i--) {
|
||||
binary_stream[i] = binary_stream[i - 1];
|
||||
}
|
||||
binary_stream[posn] = (unsigned char) newbit;
|
||||
binary_stream[bin_posn] = (unsigned char) newbit;
|
||||
}
|
||||
|
||||
static int p_r_6_2_1(const unsigned char inputData[], const size_t position, const size_t sourcelen) {
|
||||
static int p_r_6_2_1(const unsigned char inputData[], const int position, const int sourcelen) {
|
||||
/* Annex P section (r)(6)(ii)(I)
|
||||
"If one of the three X12 terminator/separator characters first
|
||||
occurs in the yet to be processed data before a non-X12 character..."
|
||||
*/
|
||||
|
||||
size_t i;
|
||||
size_t nonX12Position = 0;
|
||||
size_t specialX12Position = 0;
|
||||
int i;
|
||||
int nonX12Position = 0;
|
||||
int specialX12Position = 0;
|
||||
int retval = 0;
|
||||
|
||||
for (i = position; i < sourcelen; i++) {
|
||||
@ -298,11 +298,12 @@ static int p_r_6_2_1(const unsigned char inputData[], const size_t position, con
|
||||
}
|
||||
|
||||
/* 'look ahead test' from Annex P */
|
||||
static int look_ahead_test(const unsigned char inputData[], const size_t sourcelen, const size_t position, const int current_mode, const int gs1) {
|
||||
static int look_ahead_test(const unsigned char inputData[], const int sourcelen, const int position,
|
||||
const int current_mode, const int gs1) {
|
||||
float ascii_count, c40_count, text_count, x12_count, edf_count, b256_count, best_count;
|
||||
const float stiction = (1.0F / 24.0F); // smallest change to act on, to get around floating point inaccuracies
|
||||
int best_scheme;
|
||||
size_t sp;
|
||||
int sp;
|
||||
|
||||
best_scheme = DM_NULL;
|
||||
|
||||
@ -528,12 +529,12 @@ static int look_ahead_test(const unsigned char inputData[], const size_t sourcel
|
||||
/* Encodes data using ASCII, C40, Text, X12, EDIFACT or Base 256 modes as appropriate
|
||||
Supports encoding FNC1 in supporting systems */
|
||||
static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], unsigned char target[],
|
||||
int *last_mode, int *last_shift, size_t *length_p, int process_buffer[], int *process_p, int *binlen_p) {
|
||||
int *last_mode, int *last_shift, int *length_p, int process_buffer[], int *process_p, int *binlen_p) {
|
||||
|
||||
size_t sp;
|
||||
int sp;
|
||||
int tp, i, gs1;
|
||||
int current_mode, next_mode;
|
||||
size_t inputlen = *length_p;
|
||||
int inputlen = *length_p;
|
||||
int debug = symbol->debug & ZINT_DEBUG_PRINT;
|
||||
#ifndef _MSC_VER
|
||||
char binary[2 * inputlen + 1 + 4 + 1]; /* Allow for GS1/READER_INIT, ECI and nul chars overhead */
|
||||
@ -589,15 +590,13 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
target[tp] = (unsigned char) symbol->eci + 1;
|
||||
tp++;
|
||||
strcat(binary, " ");
|
||||
}
|
||||
if ((symbol->eci >= 127) && (symbol->eci <= 16382)) {
|
||||
} else if (symbol->eci <= 16382) {
|
||||
target[tp] = (unsigned char) ((symbol->eci - 127) / 254) + 128;
|
||||
tp++;
|
||||
target[tp] = (unsigned char) ((symbol->eci - 127) % 254) + 1;
|
||||
tp++;
|
||||
strcat(binary, " ");
|
||||
}
|
||||
if (symbol->eci >= 16383) {
|
||||
} else {
|
||||
target[tp] = (unsigned char) ((symbol->eci - 16383) / 64516) + 192;
|
||||
tp++;
|
||||
target[tp] = (unsigned char) (((symbol->eci - 16383) / 254) % 254) + 1;
|
||||
@ -760,12 +759,12 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
(*process_p)++;
|
||||
|
||||
while (*process_p >= 3) {
|
||||
int iv;
|
||||
unsigned int iv;
|
||||
|
||||
iv = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + (process_buffer[2]) + 1;
|
||||
target[tp] = (unsigned char) (iv / 256);
|
||||
target[tp] = (unsigned char) (iv >> 8);
|
||||
tp++;
|
||||
target[tp] = iv % 256;
|
||||
target[tp] = (unsigned char) (iv & 0xFF);
|
||||
tp++;
|
||||
strcat(binary, " ");
|
||||
if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]);
|
||||
@ -831,12 +830,12 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
(*process_p)++;
|
||||
|
||||
while (*process_p >= 3) {
|
||||
int iv;
|
||||
unsigned int iv;
|
||||
|
||||
iv = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + (process_buffer[2]) + 1;
|
||||
target[tp] = (unsigned char) (iv / 256);
|
||||
target[tp] = (unsigned char) (iv >> 8);
|
||||
tp++;
|
||||
target[tp] = iv % 256;
|
||||
target[tp] = (unsigned char) (iv & 0xFF);
|
||||
tp++;
|
||||
strcat(binary, " ");
|
||||
if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]);
|
||||
@ -887,12 +886,12 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
(*process_p)++;
|
||||
|
||||
while (*process_p >= 3) {
|
||||
int iv;
|
||||
unsigned int iv;
|
||||
|
||||
iv = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + (process_buffer[2]) + 1;
|
||||
target[tp] = (unsigned char) (iv / 256);
|
||||
target[tp] = (unsigned char) (iv >> 8);
|
||||
tp++;
|
||||
target[tp] = iv % 256;
|
||||
target[tp] = (unsigned char) (iv & 0xFF);
|
||||
tp++;
|
||||
strcat(binary, " ");
|
||||
if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]);
|
||||
@ -941,7 +940,10 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
target[tp] = (unsigned char) (((process_buffer[2] & 0x03) << 6) + process_buffer[3]);
|
||||
tp++;
|
||||
strcat(binary, " ");
|
||||
if (debug) printf("[%d %d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2], process_buffer[3]);
|
||||
if (debug) {
|
||||
printf("[%d %d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2],
|
||||
process_buffer[3]);
|
||||
}
|
||||
|
||||
process_buffer[0] = process_buffer[4];
|
||||
process_buffer[1] = process_buffer[5];
|
||||
@ -1026,21 +1028,27 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dm200encode_remainder(unsigned char target[], int target_length, const unsigned char source[], const size_t inputlen,
|
||||
const int last_mode, const int last_shift, const int process_buffer[], const int process_p, const int symbols_left, int debug) {
|
||||
static int dm200encode_remainder(unsigned char target[], int target_length, const unsigned char source[],
|
||||
const int inputlen, const int last_mode, const int last_shift, const int process_buffer[],
|
||||
const int process_p, const int symbols_left, int debug) {
|
||||
|
||||
switch (last_mode) {
|
||||
case DM_C40:
|
||||
case DM_TEXT:
|
||||
/* NOTE: the use of a 0-padded doublet is only mentioned in ISO/IEC 16022:2006 for case 5.2.5.2 (b) when 2 symbols and
|
||||
* 2 C40/Text characters are left, but using it here also for other cases. This matches the behaviour of tec-it (but
|
||||
* not BWIPP) and is used for figures 4.15-1-1 and 4.15-1-1 in GS1 General Specifications. */
|
||||
|
||||
if (debug) printf("%s last_shift %d, symbols_left %d, process_p %d ", last_mode == DM_C40 ? "C40" : "TEX", last_shift, symbols_left, process_p);
|
||||
/* NOTE: the use of a 0-padded doublet is only mentioned in ISO/IEC 16022:2006 for case 5.2.5.2 (b)
|
||||
* when 2 symbols and 2 C40/Text characters are left, but using it here also for other cases. This
|
||||
* matches the behaviour of tec-it (but not BWIPP) and is used for figures 4.15-1-1 and 4.15-1-1 in
|
||||
* GS1 General Specifications.
|
||||
*/
|
||||
if (debug) {
|
||||
printf("%s last_shift %d, symbols_left %d, process_p %d ", last_mode == DM_C40 ? "C40" : "TEX",
|
||||
last_shift, symbols_left, process_p);
|
||||
}
|
||||
if (process_p == 1) // 1 data character left to encode.
|
||||
{
|
||||
if (last_shift) {
|
||||
target[target_length - 1] -= last_shift - 1; // Remove shift from second half of previous doublet leaving pad value (0)
|
||||
// Remove shift from second half of previous doublet leaving pad value (0)
|
||||
target[target_length - 1] -= last_shift - 1;
|
||||
}
|
||||
if (symbols_left > 1) {
|
||||
target[target_length] = 254;
|
||||
@ -1053,10 +1061,10 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
|
||||
} else if (process_p == 2) // 2 data characters left to encode.
|
||||
{
|
||||
// Pad with shift 1 value (0) and encode as double.
|
||||
int intValue = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + 1; // ie (0 + 1).
|
||||
target[target_length] = (unsigned char) (intValue / 256);
|
||||
unsigned int intValue = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + 1; // ie (0 + 1).
|
||||
target[target_length] = (unsigned char) (intValue >> 8);
|
||||
target_length++;
|
||||
target[target_length] = (unsigned char) (intValue % 256);
|
||||
target[target_length] = (unsigned char) (intValue & 0xFF);
|
||||
target_length++;
|
||||
if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], 0);
|
||||
if (symbols_left > 2) {
|
||||
@ -1129,7 +1137,8 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
|
||||
target_length++;
|
||||
if (debug) printf("[%d 31 0 0] ", process_buffer[0]);
|
||||
} else if (process_p == 2) {
|
||||
target[target_length] = (unsigned char) ((process_buffer[0] << 2) + ((process_buffer[1] & 0x30) >> 4));
|
||||
target[target_length] = (unsigned char) ((process_buffer[0] << 2)
|
||||
+ ((process_buffer[1] & 0x30) >> 4));
|
||||
target_length++;
|
||||
target[target_length] = (unsigned char) (((process_buffer[1] & 0x0f) << 4) + ((31 & 0x3c) >> 2));
|
||||
target_length++;
|
||||
@ -1137,9 +1146,11 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
|
||||
target_length++;
|
||||
if (debug) printf("[%d %d 31 0] ", process_buffer[0], process_buffer[1]);
|
||||
} else if (process_p == 3) {
|
||||
target[target_length] = (unsigned char) ((process_buffer[0] << 2) + ((process_buffer[1] & 0x30) >> 4));
|
||||
target[target_length] = (unsigned char) ((process_buffer[0] << 2)
|
||||
+ ((process_buffer[1] & 0x30) >> 4));
|
||||
target_length++;
|
||||
target[target_length] = (unsigned char) (((process_buffer[1] & 0x0f) << 4) + ((process_buffer[2] & 0x3c) >> 2));
|
||||
target[target_length] = (unsigned char) (((process_buffer[1] & 0x0f) << 4)
|
||||
+ ((process_buffer[2] & 0x3c) >> 2));
|
||||
target_length++;
|
||||
target[target_length] = (unsigned char) (((process_buffer[2] & 0x03) << 6) + 31);
|
||||
target_length++;
|
||||
@ -1183,9 +1194,8 @@ static void add_tail(unsigned char target[], int tp, const int tail_length) {
|
||||
}
|
||||
}
|
||||
|
||||
static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source[], const size_t in_length) {
|
||||
static int data_matrix_200(struct zint_symbol *symbol, const unsigned char source[], int inputlen) {
|
||||
int i, skew = 0;
|
||||
size_t inputlen = in_length;
|
||||
unsigned char binary[2200];
|
||||
int binlen;
|
||||
int process_buffer[8]; /* holds remaining data to finalised */
|
||||
@ -1199,7 +1209,8 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
|
||||
int debug = symbol->debug & ZINT_DEBUG_PRINT;
|
||||
|
||||
/* inputlen may be decremented by 2 if macro character is used */
|
||||
error_number = dm200encode(symbol, source, binary, &last_mode, &last_shift, &inputlen, process_buffer, &process_p, &binlen);
|
||||
error_number = dm200encode(symbol, source, binary, &last_mode, &last_shift, &inputlen, process_buffer,
|
||||
&process_p, &binlen);
|
||||
if (error_number != 0) {
|
||||
return error_number;
|
||||
}
|
||||
@ -1245,7 +1256,8 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
|
||||
|
||||
// Now we know the symbol size we can handle the remaining data in the process buffer.
|
||||
symbols_left = matrixbytes[symbolsize] - binlen;
|
||||
binlen = dm200encode_remainder(binary, binlen, source, inputlen, last_mode, last_shift, process_buffer, process_p, symbols_left, debug);
|
||||
binlen = dm200encode_remainder(binary, binlen, source, inputlen, last_mode, last_shift, process_buffer,
|
||||
process_p, symbols_left, debug);
|
||||
|
||||
if (binlen > matrixbytes[symbolsize]) {
|
||||
strcpy(symbol->errtxt, "523: Data too long to fit in symbol");
|
||||
@ -1283,7 +1295,9 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
|
||||
}
|
||||
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, binary, skew ? 1558 + 620 : bytes + rsblock * (bytes / datablock));
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) {
|
||||
debug_test_codeword_dump(symbol, binary, skew ? 1558 + 620 : bytes + rsblock * (bytes / datablock));
|
||||
}
|
||||
#endif
|
||||
{ // placement
|
||||
int x, y, NC, NR, *places;
|
||||
@ -1322,11 +1336,9 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
|
||||
for (y = 0; y < NR; y++) {
|
||||
for (x = 0; x < NC; x++) {
|
||||
int v = places[(NR - y - 1) * NC + x];
|
||||
//fprintf (stderr, "%4d", v);
|
||||
if (v == 1 || (v > 7 && (binary[(v >> 3) - 1] & (1 << (v & 7)))))
|
||||
grid[(1 + y + 2 * (y / (FH - 2))) * W + 1 + x + 2 * (x / (FW - 2))] = 1;
|
||||
}
|
||||
//fprintf (stderr, "\n");
|
||||
}
|
||||
for (y = H - 1; y >= 0; y--) {
|
||||
for (x = 0; x < W; x++) {
|
||||
@ -1346,12 +1358,12 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
|
||||
return error_number;
|
||||
}
|
||||
|
||||
INTERNAL int dmatrix(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length) {
|
||||
INTERNAL int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int error_number;
|
||||
|
||||
if (symbol->option_1 <= 1) {
|
||||
/* ECC 200 */
|
||||
error_number = data_matrix_200(symbol, source, in_length);
|
||||
error_number = data_matrix_200(symbol, source, length);
|
||||
} else {
|
||||
/* ECC 000 - 140 */
|
||||
strcpy(symbol->errtxt, "524: Older Data Matrix standards are no longer supported");
|
||||
|
@ -996,7 +996,7 @@ static int dotcode_encode_message(struct zint_symbol *symbol, const unsigned cha
|
||||
if (n >= 2) {
|
||||
/* Empty binary buffer */
|
||||
for (i = 0; i < (binary_buffer_size + 1); i++) {
|
||||
lawrencium[i] = binary_buffer % 103;
|
||||
lawrencium[i] = (int) (binary_buffer % 103);
|
||||
binary_buffer /= 103;
|
||||
}
|
||||
|
||||
@ -1043,7 +1043,7 @@ static int dotcode_encode_message(struct zint_symbol *symbol, const unsigned cha
|
||||
|
||||
if (binary_buffer_size == 5) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
lawrencium[i] = binary_buffer % 103;
|
||||
lawrencium[i] = (int) (binary_buffer % 103);
|
||||
binary_buffer /= 103;
|
||||
}
|
||||
|
||||
@ -1066,7 +1066,7 @@ static int dotcode_encode_message(struct zint_symbol *symbol, const unsigned cha
|
||||
if ((!done) && (encoding_mode == 'X')) {
|
||||
/* Empty binary buffer */
|
||||
for (i = 0; i < (binary_buffer_size + 1); i++) {
|
||||
lawrencium[i] = binary_buffer % 103;
|
||||
lawrencium[i] = (int) (binary_buffer % 103);
|
||||
binary_buffer /= 103;
|
||||
}
|
||||
|
||||
@ -1096,7 +1096,7 @@ static int dotcode_encode_message(struct zint_symbol *symbol, const unsigned cha
|
||||
if (binary_buffer_size != 0) {
|
||||
/* Empty binary buffer */
|
||||
for (i = 0; i < (binary_buffer_size + 1); i++) {
|
||||
lawrencium[i] = binary_buffer % 103;
|
||||
lawrencium[i] = (int) (binary_buffer % 103);
|
||||
binary_buffer /= 103;
|
||||
}
|
||||
|
||||
@ -1116,20 +1116,21 @@ static int dotcode_encode_message(struct zint_symbol *symbol, const unsigned cha
|
||||
}
|
||||
|
||||
/* Convert codewords to binary data stream */
|
||||
static size_t make_dotstream(unsigned char masked_array[], int array_length, char dot_stream[]) {
|
||||
static int make_dotstream(const unsigned char masked_array[], const int array_length, char dot_stream[]) {
|
||||
int i;
|
||||
|
||||
dot_stream[0] = '\0';
|
||||
int bp = 0;
|
||||
|
||||
/* Mask value is encoded as two dots */
|
||||
bin_append(masked_array[0], 2, dot_stream);
|
||||
bp = bin_append_posn(masked_array[0], 2, dot_stream, bp);
|
||||
|
||||
/* The rest of the data uses 9-bit dot patterns from Annex C */
|
||||
for (i = 1; i < array_length; i++) {
|
||||
bin_append(dot_patterns[masked_array[i]], 9, dot_stream);
|
||||
bp = bin_append_posn(dot_patterns[masked_array[i]], 9, dot_stream, bp);
|
||||
}
|
||||
|
||||
return strlen(dot_stream);
|
||||
dot_stream[bp] = '\0';
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
/* Determines if a given dot is a reserved corner dot
|
||||
@ -1299,14 +1300,14 @@ static void force_corners(int width, int height, char *dot_array) {
|
||||
}
|
||||
}
|
||||
|
||||
INTERNAL int dotcode(struct zint_symbol *symbol, const unsigned char source[], int length) {
|
||||
INTERNAL int dotcode(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, j, k;
|
||||
size_t jc, n_dots;
|
||||
int jc, n_dots;
|
||||
int data_length, ecc_length;
|
||||
int min_dots, min_area;
|
||||
int height, width;
|
||||
int mask_score[8];
|
||||
size_t dot_stream_length;
|
||||
int dot_stream_length;
|
||||
int high_score, best_mask;
|
||||
int binary_finish = 0;
|
||||
int debug = symbol->debug;
|
||||
@ -1364,7 +1365,7 @@ INTERNAL int dotcode(struct zint_symbol *symbol, const unsigned char source[], i
|
||||
height = (int) h;
|
||||
width = (int) w;
|
||||
|
||||
if ((width + height) % 2 == 1) {
|
||||
if (((width + height) & 1) == 1) {
|
||||
if ((width * height) < min_area) {
|
||||
width++;
|
||||
height++;
|
||||
|
@ -81,19 +81,21 @@ static int count_hexagons(struct zint_symbol *symbol) {
|
||||
return hexagons;
|
||||
}
|
||||
|
||||
static int count_strings(struct zint_symbol *symbol, int *fsize, int *fsize2, int *halign, int *halign1, int *halign2) {
|
||||
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 = *halign = *halign1 = *halign2 = 0;
|
||||
*fsize = *fsize2 = 0.0f;
|
||||
*halign = *halign1 = *halign2 = 0;
|
||||
|
||||
str = symbol->vector->strings;
|
||||
while (str) {
|
||||
/* Allow 2 font sizes */
|
||||
if (*fsize == 0) {
|
||||
*fsize = (int) str->fsize;
|
||||
} else if (str->fsize != *fsize && *fsize2 == 0) {
|
||||
*fsize2 = (int) str->fsize;
|
||||
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) {
|
||||
@ -136,7 +138,7 @@ static void utfle_copy(unsigned char *output, unsigned char *input, int length)
|
||||
|
||||
static int bump_up(int input) {
|
||||
/* Strings length must be a multiple of 4 bytes */
|
||||
if ((input % 2) == 1) {
|
||||
if ((input & 1) == 1) {
|
||||
input++;
|
||||
}
|
||||
return input;
|
||||
@ -199,10 +201,10 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
emr_rectangle_t background;
|
||||
emr_settextcolor_t emr_settextcolor;
|
||||
|
||||
int fsize;
|
||||
float fsize;
|
||||
emr_extcreatefontindirectw_t emr_extcreatefontindirectw;
|
||||
emr_selectobject_t emr_selectobject_font;
|
||||
int fsize2;
|
||||
float fsize2;
|
||||
emr_extcreatefontindirectw_t emr_extcreatefontindirectw2;
|
||||
emr_selectobject_t emr_selectobject_font2;
|
||||
int halign;
|
||||
@ -212,7 +214,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
int halign2;
|
||||
emr_settextalign_t emr_settextalign2;
|
||||
|
||||
int current_fsize;
|
||||
float current_fsize;
|
||||
int current_halign;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@ -220,7 +222,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
emr_ellipse_t *circle;
|
||||
emr_polygon_t *hexagon;
|
||||
emr_exttextoutw_t *text;
|
||||
int *text_fsizes;
|
||||
float *text_fsizes;
|
||||
int *text_haligns;
|
||||
#endif
|
||||
|
||||
@ -243,18 +245,19 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
string_count = count_strings(symbol, &fsize, &fsize2, &halign, &halign1, &halign2);
|
||||
|
||||
#ifndef _MSC_VER
|
||||
emr_rectangle_t rectangle[rectangle_count ? rectangle_count : 1]; // Avoid sanitize runtime error by making always non-zero
|
||||
// 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];
|
||||
emr_exttextoutw_t text[string_count ? string_count: 1];
|
||||
int text_fsizes[string_count ? string_count: 1];
|
||||
float text_fsizes[string_count ? string_count: 1];
|
||||
int text_haligns[string_count ? string_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));
|
||||
text = (emr_exttextoutw_t*) _alloca(string_count * sizeof (emr_exttextoutw_t));
|
||||
text_fsizes = (int *) _alloca(string_count * sizeof (int));
|
||||
text_fsizes = (float *) _alloca(string_count * sizeof (float));
|
||||
text_haligns = (int *) _alloca(string_count * sizeof (int));
|
||||
#endif
|
||||
|
||||
@ -274,8 +277,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
}
|
||||
}
|
||||
|
||||
width = ceil(symbol->vector->width);
|
||||
height = ceil(symbol->vector->height);
|
||||
width = (int) ceil(symbol->vector->width);
|
||||
height = (int) ceil(symbol->vector->height);
|
||||
|
||||
/* Header */
|
||||
emr_header.type = 0x00000001; // EMR_HEADER
|
||||
@ -293,7 +296,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
if (symbol->symbology == BARCODE_ULTRA) {
|
||||
emr_header.emf_header.handles = 11; // Number of graphics objects
|
||||
} else {
|
||||
emr_header.emf_header.handles = fsize2 ? 5 : 4;
|
||||
emr_header.emf_header.handles = fsize2 != 0.0f ? 5 : 4;
|
||||
}
|
||||
emr_header.emf_header.reserved = 0x0000;
|
||||
emr_header.emf_header.n_description = 0;
|
||||
@ -417,7 +420,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
|
||||
if (draw_background) {
|
||||
/* Make background from a rectangle */
|
||||
background.type = 0x0000002b; // EMR_RECTANGLE;
|
||||
background.type = 0x0000002b; // EMR_RECTANGLE
|
||||
background.size = 24;
|
||||
background.box.top = 0;
|
||||
background.box.left = 0;
|
||||
@ -431,12 +434,12 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
rect = symbol->vector->rectangles;
|
||||
this_rectangle = 0;
|
||||
while (rect) {
|
||||
rectangle[this_rectangle].type = 0x0000002b; // EMR_RECTANGLE;
|
||||
rectangle[this_rectangle].type = 0x0000002b; // EMR_RECTANGLE
|
||||
rectangle[this_rectangle].size = 24;
|
||||
rectangle[this_rectangle].box.top = rect->y;
|
||||
rectangle[this_rectangle].box.bottom = rect->y + rect->height;
|
||||
rectangle[this_rectangle].box.left = rect->x;
|
||||
rectangle[this_rectangle].box.right = rect->x + rect->width;
|
||||
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++;
|
||||
@ -454,10 +457,10 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
}
|
||||
circle[this_circle].type = 0x0000002a; // EMR_ELLIPSE
|
||||
circle[this_circle].size = 24;
|
||||
circle[this_circle].box.top = circ->y - radius;
|
||||
circle[this_circle].box.bottom = circ->y + radius;
|
||||
circle[this_circle].box.left = circ->x - radius;
|
||||
circle[this_circle].box.right = circ->x + radius;
|
||||
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++;
|
||||
@ -507,18 +510,18 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
fx = hex->x - half_radius;
|
||||
}
|
||||
|
||||
hexagon[this_hexagon].a_points_a.x = ax;
|
||||
hexagon[this_hexagon].a_points_a.y = ay;
|
||||
hexagon[this_hexagon].a_points_b.x = bx;
|
||||
hexagon[this_hexagon].a_points_b.y = by;
|
||||
hexagon[this_hexagon].a_points_c.x = cx;
|
||||
hexagon[this_hexagon].a_points_c.y = cy;
|
||||
hexagon[this_hexagon].a_points_d.x = dx;
|
||||
hexagon[this_hexagon].a_points_d.y = dy;
|
||||
hexagon[this_hexagon].a_points_e.x = ex;
|
||||
hexagon[this_hexagon].a_points_e.y = ey;
|
||||
hexagon[this_hexagon].a_points_f.x = fx;
|
||||
hexagon[this_hexagon].a_points_f.y = fy;
|
||||
hexagon[this_hexagon].a_points_a.x = (int32_t) ax;
|
||||
hexagon[this_hexagon].a_points_a.y = (int32_t) ay;
|
||||
hexagon[this_hexagon].a_points_b.x = (int32_t) bx;
|
||||
hexagon[this_hexagon].a_points_b.y = (int32_t) by;
|
||||
hexagon[this_hexagon].a_points_c.x = (int32_t) cx;
|
||||
hexagon[this_hexagon].a_points_c.y = (int32_t) cy;
|
||||
hexagon[this_hexagon].a_points_d.x = (int32_t) dx;
|
||||
hexagon[this_hexagon].a_points_d.y = (int32_t) dy;
|
||||
hexagon[this_hexagon].a_points_e.x = (int32_t) ex;
|
||||
hexagon[this_hexagon].a_points_e.y = (int32_t) ey;
|
||||
hexagon[this_hexagon].a_points_f.x = (int32_t) fx;
|
||||
hexagon[this_hexagon].a_points_f.y = (int32_t) fy;
|
||||
|
||||
hexagon[this_hexagon].bounds.top = hexagon[this_hexagon].a_points_d.y;
|
||||
hexagon[this_hexagon].bounds.bottom = hexagon[this_hexagon].a_points_a.y;
|
||||
@ -532,12 +535,13 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
|
||||
/* 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));
|
||||
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 = 11;
|
||||
emr_extcreatefontindirectw.elw.height = fsize;
|
||||
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
|
||||
@ -557,7 +561,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
if (fsize2) {
|
||||
memcpy(&emr_extcreatefontindirectw2, &emr_extcreatefontindirectw, sizeof(emr_extcreatefontindirectw));
|
||||
emr_extcreatefontindirectw2.ih_fonts = 12;
|
||||
emr_extcreatefontindirectw2.elw.height = fsize2;
|
||||
emr_extcreatefontindirectw2.elw.height = (int32_t) fsize2;
|
||||
bytecount += 104;
|
||||
recordcount++;
|
||||
|
||||
@ -626,8 +630,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
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 = str->x;
|
||||
text[this_text].w_emr_text.reference.y = str->y;
|
||||
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;
|
||||
@ -770,7 +774,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
current_fsize = fsize;
|
||||
current_halign = -1;
|
||||
for (i = 0; i < string_count; i++) {
|
||||
if (text_fsizes[i] != current_fsize) { // NOLINT(clang-analyzer-core.UndefinedBinaryOperatorResult) suppress clang-tidy warning: text_fsizes fully set
|
||||
if (text_fsizes[i] != current_fsize) {
|
||||
current_fsize = text_fsizes[i];
|
||||
fwrite(&emr_selectobject_font2, sizeof (emr_selectobject_t), 1, emf_file);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ static const unsigned short cp936ext_pagefe[24] = {
|
||||
0xa6e5, 0xa6e8, 0xa6e9, 0xa6ea, 0xa6eb, 0x0000, 0x0000, 0x0000, /*0x40-0x47*/
|
||||
};
|
||||
|
||||
static int cp936ext_wctomb(unsigned int *r, unsigned int wc) {
|
||||
static int cp936ext_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
unsigned short c = 0;
|
||||
if (wc >= 0x0140 && wc < 0x0150) {
|
||||
c = cp936ext_page01[wc-0x0140];
|
||||
@ -2383,7 +2383,7 @@ static const Summary16 gbkext_inv_uni2indx_pagefe[31] = {
|
||||
{ 14311, 0x0000 }, { 14311, 0x0000 }, { 14311, 0x0014 },
|
||||
};
|
||||
|
||||
static int gbkext_inv_wctomb(unsigned int *r, unsigned int wc) {
|
||||
static int gbkext_inv_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
const Summary16 *summary = NULL;
|
||||
if (wc >= 0x0200 && wc < 0x02e0) {
|
||||
summary = &gbkext_inv_uni2indx_page02[(wc>>4)-0x020];
|
||||
@ -2424,7 +2424,7 @@ static int gbkext_inv_wctomb(unsigned int *r, unsigned int wc) {
|
||||
* GBK (libiconv-1.16/lib/gbk.h)
|
||||
*/
|
||||
|
||||
static int gbk_wctomb(unsigned int *r, unsigned int wc) {
|
||||
static int gbk_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
int ret;
|
||||
|
||||
/* ZINT: Note these mappings U+30FB and U+2015 different from GB 2312 */
|
||||
@ -2553,7 +2553,7 @@ static const unsigned short gb18030ext_pagefe[16] = {
|
||||
0xa6ed, 0xa6f3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/
|
||||
};
|
||||
|
||||
static int gb18030ext_wctomb(unsigned int *r, unsigned int wc) {
|
||||
static int gb18030ext_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
unsigned short c = 0;
|
||||
if (wc == 0x01f9) {
|
||||
c = 0xa8bf;
|
||||
@ -2727,7 +2727,7 @@ static const unsigned short gb18030uni_ranges[206] = {
|
||||
25994, 25998, 26012, 26016, 26110, 26116
|
||||
};
|
||||
|
||||
static int gb18030uni_wctomb(unsigned int *r1, unsigned int *r2, unsigned int wc) {
|
||||
static int gb18030uni_wctomb(unsigned int *r1, unsigned int *r2, const unsigned int wc) {
|
||||
unsigned int i = wc;
|
||||
if (i >= 0x0080 && i <= 0xffff) {
|
||||
if (i == 0xe7c7) {
|
||||
@ -2798,7 +2798,7 @@ static const unsigned short gb18030_pua2charset[31*3] = {
|
||||
0xe864, 0xe864, 0xfea0,
|
||||
};
|
||||
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, unsigned int wc) {
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, const unsigned int wc) {
|
||||
int ret;
|
||||
|
||||
/* Code set 0 (ASCII) */
|
||||
@ -2871,7 +2871,7 @@ INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, unsigned in
|
||||
|
||||
/* Convert UTF-8 string to GB 18030 and place in array of ints */
|
||||
INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata) {
|
||||
unsigned int *gbdata) {
|
||||
int error_number, ret;
|
||||
unsigned int i, j, length;
|
||||
#ifndef _MSC_VER
|
||||
@ -2906,8 +2906,8 @@ INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char so
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to single byte ECI and place in array of ints */
|
||||
INTERNAL int gb18030_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte) {
|
||||
INTERNAL int gb18030_utf8tosb(const int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
const int full_multibyte) {
|
||||
int error_number;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char single_byte[*p_length + 1];
|
||||
@ -2926,9 +2926,10 @@ INTERNAL int gb18030_utf8tosb(int eci, const unsigned char source[], int *p_leng
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match HANXIN Chinese
|
||||
* mode in single entry, and quad-bytes in 2 entries. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb18030_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte) {
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match HANXIN
|
||||
* Chinese mode in single entry, and quad-bytes in 2 entries. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb18030_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
const int full_multibyte) {
|
||||
unsigned int i, j, length;
|
||||
int done;
|
||||
unsigned char c1, c2, c3, c4;
|
||||
|
@ -37,12 +37,13 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, unsigned int wc);
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, const unsigned int wc);
|
||||
INTERNAL int gb18030_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata);
|
||||
INTERNAL int gb18030_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte);
|
||||
INTERNAL void gb18030_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte);
|
||||
unsigned int *gbdata);
|
||||
INTERNAL int gb18030_utf8tosb(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
|
||||
}
|
||||
|
@ -1502,7 +1502,7 @@ static const Summary16 gb2312_uni2indx_pageff[15] = {
|
||||
{ 7441, 0x0000 }, { 7441, 0x0000 }, { 7441, 0x002b },
|
||||
};
|
||||
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int *r, const unsigned int wc) {
|
||||
const Summary16 *summary = NULL;
|
||||
if (wc < 0x0460) {
|
||||
if (wc == 0x00b7) { /* ZINT: Patched to duplicate map to 0xA1A4 */
|
||||
@ -1545,7 +1545,7 @@ INTERNAL int gb2312_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
|
||||
/* Convert UTF-8 string to GB 2312 (EUC-CN) and place in array of ints */
|
||||
INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata) {
|
||||
unsigned int *gbdata) {
|
||||
int error_number;
|
||||
unsigned int i, length;
|
||||
#ifndef _MSC_VER
|
||||
@ -1574,8 +1574,8 @@ INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char sou
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to single byte ECI and place in array of ints */
|
||||
INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte) {
|
||||
INTERNAL int gb2312_utf8tosb(const int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
const int full_multibyte) {
|
||||
int error_number;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char single_byte[*p_length + 1];
|
||||
@ -1594,9 +1594,10 @@ INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], int *p_lengt
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match GRIDMATRIX Chinese
|
||||
* mode in a single entry. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte) {
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match GRIDMATRIX
|
||||
* Chinese mode in a single entry. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
const int full_multibyte) {
|
||||
unsigned int i, j, length;
|
||||
unsigned char c1, c2;
|
||||
|
||||
|
@ -37,12 +37,13 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int *r, unsigned int wc);
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int *r, const unsigned int wc);
|
||||
INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata);
|
||||
INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte);
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte);
|
||||
unsigned int *gbdata);
|
||||
INTERNAL int gb2312_utf8tosb(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
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
large_int byte_array_reg;
|
||||
unsigned char byte_array[13];
|
||||
unsigned short usps_crc;
|
||||
int codeword[10];
|
||||
unsigned int codeword[10];
|
||||
unsigned short characters[10];
|
||||
short int bar_map[130];
|
||||
int zip_len, len;
|
||||
@ -362,15 +362,15 @@ INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
/* *** Step 3 - Conversion from Binary Data to Codewords *** */
|
||||
|
||||
/* start with codeword J which is base 636 */
|
||||
codeword[9] = large_div_u64(&accum, 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] = large_div_u64(&accum, 1365);
|
||||
codeword[j] = (unsigned int) large_div_u64(&accum, 1365);
|
||||
}
|
||||
|
||||
codeword[0] = large_lo(&accum);
|
||||
codeword[0] = (unsigned int) large_lo(&accum);
|
||||
|
||||
/* *** Step 4 - Inserting Additional Information into Codewords *** */
|
||||
|
||||
|
@ -211,7 +211,8 @@ INTERNAL uint64_t large_div_u64(large_int *t, uint64_t v) {
|
||||
/* 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) */
|
||||
|
||||
rnhilo1 = (tnhi << 32) + tnlo1 - (qhat1 * v); /* Note high digit (if any) of both tnhi and (qhat1 * v) shifted out */
|
||||
/* Note high digit (if any) of both tnhi and (qhat1 * v) shifted out */
|
||||
rnhilo1 = (tnhi << 32) + tnlo1 - (qhat1 * v);
|
||||
|
||||
/* Compute qhat0 estimate */
|
||||
|
||||
@ -255,21 +256,22 @@ INTERNAL void large_uint_array(const large_int *t, unsigned int *uint_array, int
|
||||
}
|
||||
mask = ~(((uint64_t) -1) << bits);
|
||||
for (i = 0, j = 0; i < size && j < 64; i++, j += bits) {
|
||||
uint_array[size - 1 - i] = (t->lo >> j) & mask; /* Little-endian order */
|
||||
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] = ((t->hi & ~((((uint64_t) -1) << j))) << (bits - j)) | (t->lo >> (64 - (bits - j)) & mask);
|
||||
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] = (t->hi >> j) & mask;
|
||||
uint_array[size - 1 - i] = (unsigned int) ((t->hi >> j) & mask);
|
||||
}
|
||||
if (i < size && j != 128) {
|
||||
uint_array[size - 1 - i] = t->hi >> (j - bits) & mask;
|
||||
uint_array[size - 1 - i] = (unsigned int) (t->hi >> (j - bits) & mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -299,10 +301,10 @@ INTERNAL void large_print(large_int *t) {
|
||||
|
||||
/* Format large_int into buffer, which should be at least 35 chars in size */
|
||||
INTERNAL char *large_dump(large_int *t, char *buf) {
|
||||
unsigned int tlo1 = large_lo(t) >> 32;
|
||||
unsigned int tlo0 = large_lo(t) & MASK32;
|
||||
unsigned int thi1 = large_hi(t) >> 32;
|
||||
unsigned int thi0 = large_hi(t) & MASK32;
|
||||
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);
|
||||
|
@ -127,14 +127,14 @@ INTERNAL int get_best_eci(unsigned char source[], int length); /* Calculate suit
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *length); /* Convert Unicode to other encodings */
|
||||
|
||||
INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN system barcodes */
|
||||
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Code 3 from 9 (or Code 39) */
|
||||
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 3 from 9 (or Code 39) */
|
||||
INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmazentral Nummer (PZN) */
|
||||
INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length); /* Extended Code 3 from 9 (or Code 39+) */
|
||||
INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int length); /* Codabar - a simple substitution cipher */
|
||||
INTERNAL int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Standard (& Matrix) */
|
||||
INTERNAL int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Industrial */
|
||||
INTERNAL int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 IATA */
|
||||
INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* Code 2 of 5 Interleaved */
|
||||
INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Interleaved */
|
||||
INTERNAL int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Data Logic */
|
||||
INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int length); /* ITF-14 */
|
||||
INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int length); /* Deutsche Post Leitcode */
|
||||
@ -144,9 +144,9 @@ INTERNAL int code_128(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-128 (GS1-128) */
|
||||
INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 11 */
|
||||
INTERNAL int msi_handle(struct zint_symbol *symbol, unsigned char source[], int length); /* MSI Plessey */
|
||||
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Telepen ASCII */
|
||||
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Telepen Numeric */
|
||||
INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Plessey Code */
|
||||
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int length); /* Telepen ASCII */
|
||||
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int length); /* Telepen Numeric */
|
||||
INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int length); /* Plessey Code */
|
||||
INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmacode One Track */
|
||||
INTERNAL int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length); /* Flattermarken */
|
||||
INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length); /* Facing Identification Mark */
|
||||
@ -156,7 +156,7 @@ INTERNAL int planet_plot(struct zint_symbol *symbol, unsigned char source[], int
|
||||
INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int length); /* Intelligent Mail (aka USPS OneCode) */
|
||||
INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length); /* RM4SCC */
|
||||
INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Australia Post 4-state */
|
||||
INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[],const size_t length); /* Code 16k */
|
||||
INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 16k */
|
||||
INTERNAL int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length); /* PDF417 */
|
||||
INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length); /* Micro PDF417 */
|
||||
INTERNAL int maxicode(struct zint_symbol *symbol, unsigned char source[], int length); /* Maxicode */
|
||||
@ -174,20 +174,20 @@ INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Runes */
|
||||
INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Korea Post */
|
||||
INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Japanese Post */
|
||||
INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], const int length); /* Code 49 */
|
||||
INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 49 */
|
||||
INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], int length); /* Channel Code */
|
||||
INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int length); /* Code One */
|
||||
INTERNAL int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Grid Matrix */
|
||||
INTERNAL int han_xin(struct zint_symbol * symbol, unsigned char source[], int length); /* Han Xin */
|
||||
INTERNAL int dotcode(struct zint_symbol * symbol, const unsigned char source[], int length); /* DotCode */
|
||||
INTERNAL int han_xin(struct zint_symbol *symbol, unsigned char source[], int length); /* Han Xin */
|
||||
INTERNAL int dotcode(struct zint_symbol *symbol, unsigned char source[], int length); /* DotCode */
|
||||
INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int length); /* Codablock */
|
||||
INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int length); /* UPNQR */
|
||||
INTERNAL int qr_code(struct zint_symbol *symbol, unsigned char source[], int length); /* QR Code */
|
||||
INTERNAL int dmatrix(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* Data Matrix (IEC16022) */
|
||||
INTERNAL int vin(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* VIN Code (Vehicle Identification Number) */
|
||||
INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* Royal Mail 4-state Mailmark */
|
||||
INTERNAL int ultracode(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* Ultracode */
|
||||
INTERNAL int rmqr(struct zint_symbol *symbol, unsigned char source[], int in_length); /* rMQR */
|
||||
INTERNAL int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Data Matrix (IEC16022) */
|
||||
INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length); /* VIN Code (Vehicle Identification Number) */
|
||||
INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int length); /* Royal Mail 4-state Mailmark */
|
||||
INTERNAL int ultracode(struct zint_symbol *symbol, unsigned char source[], int length); /* Ultracode */
|
||||
INTERNAL int rmqr(struct zint_symbol *symbol, unsigned char source[], int length); /* rMQR */
|
||||
INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int length); /* DPD Code */
|
||||
|
||||
INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to PNG/BMP/PCX */
|
||||
@ -1300,7 +1300,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
|
||||
if (((symbol->input_mode & 0x07) == GS1_MODE) || (check_force_gs1(symbol->symbology))) {
|
||||
if (gs1_compliant(symbol->symbology) == 1) {
|
||||
// Reduce input for composite and non-forced symbologies, others (EAN128 and RSS_EXP based) will handle it themselves
|
||||
// Reduce input for composite and non-forced symbologies, others (EAN128 and RSS_EXP based) will
|
||||
// handle it themselves
|
||||
if (is_composite(symbol->symbology) || !check_force_gs1(symbol->symbology)) {
|
||||
#ifndef _MSC_VER
|
||||
unsigned char reduced[in_length + 1];
|
||||
@ -1591,7 +1592,8 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
||||
fileLen = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
if (fileLen <= 0 || fileLen == LONG_MAX) { /* On many Linux distros ftell() returns LONG_MAX not -1 on error */
|
||||
/* On many Linux distros ftell() returns LONG_MAX not -1 on error */
|
||||
if (fileLen <= 0 || fileLen == LONG_MAX) {
|
||||
strcpy(symbol->errtxt, "235: Input file empty or unseekable");
|
||||
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_DATA);
|
||||
fclose(file);
|
||||
|
@ -39,7 +39,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
@ -61,13 +60,13 @@ static const char *postcode_format[6] = {
|
||||
};
|
||||
|
||||
// Data/Check Symbols from Table 5
|
||||
static const unsigned short data_symbol_odd[32] = {
|
||||
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 short data_symbol_even[30] = {
|
||||
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
|
||||
@ -122,7 +121,7 @@ static int verify_postcode(char* postcode, int type) {
|
||||
}
|
||||
|
||||
/* Royal Mail Mailmark */
|
||||
INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length) {
|
||||
INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
char local_source[28];
|
||||
int format;
|
||||
@ -143,7 +142,6 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
|
||||
char bar[80];
|
||||
int check_count;
|
||||
int i, j, len;
|
||||
int length = (int) in_length;
|
||||
rs_t rs;
|
||||
|
||||
if (length > 26) {
|
||||
@ -395,11 +393,11 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
|
||||
// Conversion from Consolidated Data Value to Data Numbers
|
||||
|
||||
for (j = data_top; j >= (data_step + 1); j--) {
|
||||
data[j] = large_div_u64(&cdv, 32);
|
||||
data[j] = (unsigned char) large_div_u64(&cdv, 32);
|
||||
}
|
||||
|
||||
for (j = data_step; j >= 0; j--) {
|
||||
data[j] = large_div_u64(&cdv, 30);
|
||||
data[j] = (unsigned char) large_div_u64(&cdv, 30);
|
||||
}
|
||||
|
||||
// Generation of Reed-Solomon Check Numbers
|
||||
@ -476,7 +474,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, const unsigned char source[],
|
||||
|
||||
/* Translate 4-state data pattern to symbol */
|
||||
j = 0;
|
||||
for (i = 0, len = strlen(bar); i < len; i++) {
|
||||
for (i = 0, len = (int) strlen(bar); i < len; i++) {
|
||||
if ((bar[i] == 'F') || (bar[i] == 'A')) {
|
||||
set_module(symbol, 0, j);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
|
||||
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length);
|
||||
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||
|
||||
/* Codabar table checked against EN 798:1995 */
|
||||
|
||||
@ -93,7 +93,7 @@ INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
} while (tester != 0);
|
||||
|
||||
h = strlen(inter) - 1;
|
||||
h = (int) strlen(inter) - 1;
|
||||
*dest = '\0';
|
||||
for (counter = h; counter >= 0; counter--) {
|
||||
if (inter[counter] == 'W') {
|
||||
@ -144,7 +144,7 @@ static int pharma_two_calc(struct zint_symbol *symbol, unsigned char source[], c
|
||||
}
|
||||
} while (tester != 0);
|
||||
|
||||
h = strlen(inter) - 1;
|
||||
h = (int) strlen(inter) - 1;
|
||||
for (counter = h; counter >= 0; counter--) {
|
||||
dest[h - counter] = inter[counter];
|
||||
}
|
||||
@ -176,7 +176,7 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
|
||||
writer = 0;
|
||||
h = strlen(height_pattern);
|
||||
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);
|
||||
@ -198,7 +198,7 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
|
||||
int i, error_number;
|
||||
char dest[512];
|
||||
int add_checksum, count, checksum;
|
||||
int add_checksum, count = 0, checksum;
|
||||
|
||||
strcpy(dest, "");
|
||||
|
||||
@ -234,9 +234,6 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
}
|
||||
|
||||
add_checksum = symbol->option_2 == 1;
|
||||
if (add_checksum) {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (add_checksum) {
|
||||
@ -322,7 +319,7 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
}
|
||||
risultante[6] = '\0';
|
||||
/* Plot the barcode using Code 39 */
|
||||
error_number = c39(symbol, (unsigned char*) risultante, strlen(risultante));
|
||||
error_number = c39(symbol, (unsigned char*) risultante, (int) strlen(risultante));
|
||||
if (error_number != 0) {
|
||||
return error_number;
|
||||
}
|
||||
|
277
backend/pdf417.c
277
backend/pdf417.c
@ -88,8 +88,12 @@ static const char MicroAutosize[56] = {
|
||||
1, 14, 2, 7, 3, 25, 8, 16, 5, 17, 9, 6, 10, 11, 28, 12, 19, 13, 29, 20, 30, 21, 22, 31, 23, 32, 33, 34
|
||||
};
|
||||
|
||||
#define PDF417_MAX_LEN 2710 /* ISO/IEC 15438:2015 5.1.1 c) 3) Max possible number of characters at error correction level 0 (Numeric Compaction mode) */
|
||||
#define MICRO_PDF417_MAX_LEN 366 /* ISO/IEC 24728:2006 5.1.1 c) 3) Max possible number of characters (Numeric Compaction mode) */
|
||||
/* ISO/IEC 15438:2015 5.1.1 c) 3) Max possible number of characters at error correction level 0
|
||||
(Numeric Compaction mode) */
|
||||
#define PDF417_MAX_LEN 2710
|
||||
|
||||
/* ISO/IEC 24728:2006 5.1.1 c) 3) Max possible number of characters (Numeric Compaction mode) */
|
||||
#define MICRO_PDF417_MAX_LEN 366
|
||||
|
||||
/* 866 */
|
||||
|
||||
@ -377,8 +381,8 @@ static void textprocess(int *chainemc, int *mclength, char chaine[], int start,
|
||||
}
|
||||
/* Now translate the string chainet into codewords */
|
||||
|
||||
/* Default mode for PDF417 is Text Compaction Alpha (ISO/IEC 1543:2015 5.4.2.1), and for MICROPDF417 is Byte Compaction
|
||||
* (ISO/IEC 24728:2006 5.4.3), so only add flag if not first codeword or is MICROPDF417 */
|
||||
/* Default mode for PDF417 is Text Compaction Alpha (ISO/IEC 1543:2015 5.4.2.1), and for MICROPDF417 is Byte
|
||||
* Compaction (ISO/IEC 24728:2006 5.4.3), so only add flag if not first codeword or is MICROPDF417 */
|
||||
if (*mclength || is_micro) {
|
||||
chainemc[(*mclength)++] = 900;
|
||||
}
|
||||
@ -409,8 +413,9 @@ INTERNAL void byteprocess(int *chainemc, int *mclength, unsigned char chaine[],
|
||||
chainemc[(*mclength)++] = 924;
|
||||
if (debug) printf("924 ");
|
||||
} else {
|
||||
/* Default mode for MICROPDF417 is Byte Compaction (ISO/IEC 24728:2006 5.4.3), but not emitting it depends on whether
|
||||
* an ECI has been emitted previously (or not) it appears, so simpler and safer to always emit it. */
|
||||
/* Default mode for MICROPDF417 is Byte Compaction (ISO/IEC 24728:2006 5.4.3), but not emitting it
|
||||
* depends on whether an ECI has been emitted previously (or not) it appears, so simpler and safer
|
||||
* to always emit it. */
|
||||
chainemc[(*mclength)++] = 901;
|
||||
if (debug) printf("901 ");
|
||||
}
|
||||
@ -507,6 +512,7 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
|
||||
int total, chainemc[PDF417_MAX_LEN], mclength, c1, c2, c3, dummy[35], calcheight;
|
||||
int liste[2][PDF417_MAX_LEN] = {{0}};
|
||||
char pattern[580];
|
||||
int bp = 0;
|
||||
int error_number = 0;
|
||||
int debug = symbol->debug & ZINT_DEBUG_PRINT;
|
||||
|
||||
@ -733,7 +739,7 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
|
||||
|
||||
/* we now encode each row */
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
int p;
|
||||
bp = 0;
|
||||
for (j = 0; j < symbol->option_2; j++) {
|
||||
dummy[j + 1] = chainemc[i * symbol->option_2 + j];
|
||||
}
|
||||
@ -755,28 +761,28 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
|
||||
offset = 1858; /* cluster(6) */
|
||||
break;
|
||||
}
|
||||
p = bin_append_posn(0x1FEA8, 17, pattern, 0); /* Row start */
|
||||
bp = bin_append_posn(0x1FEA8, 17, pattern, bp); /* Row start */
|
||||
|
||||
for (j = 0; j <= symbol->option_2; j++) {
|
||||
p = bin_append_posn(pdf_bitpattern[offset + dummy[j]], 16, pattern, p);
|
||||
pattern[p++] = '0';
|
||||
bp = bin_append_posn(pdf_bitpattern[offset + dummy[j]], 16, pattern, bp);
|
||||
pattern[bp++] = '0';
|
||||
}
|
||||
|
||||
if (symbol->symbology != BARCODE_PDF417COMP) {
|
||||
p = bin_append_posn(pdf_bitpattern[offset + dummy[j]], 16, pattern, p);
|
||||
pattern[p++] = '0';
|
||||
p = bin_append_posn(0x3FA29, 18, pattern, p); /* Row Stop */
|
||||
bp = bin_append_posn(pdf_bitpattern[offset + dummy[j]], 16, pattern, bp);
|
||||
pattern[bp++] = '0';
|
||||
bp = bin_append_posn(0x3FA29, 18, pattern, bp); /* Row Stop */
|
||||
} else {
|
||||
pattern[p++] = '1'; /* Compact PDF417 Stop pattern */
|
||||
pattern[bp++] = '1'; /* Compact PDF417 Stop pattern */
|
||||
}
|
||||
pattern[p] = '\0';
|
||||
|
||||
for (loop = 0; loop < p; loop++) {
|
||||
for (loop = 0; loop < bp; loop++) {
|
||||
if (pattern[loop] == '1') {
|
||||
set_module(symbol, i, loop);
|
||||
}
|
||||
}
|
||||
}
|
||||
symbol->width = bp;
|
||||
|
||||
/* Allow user to adjust height of symbol, but enforce minimum row height of 3X */
|
||||
calcheight = (int)(symbol->height / i);
|
||||
@ -787,8 +793,6 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
|
||||
for (j = 0; j < i; j++) {
|
||||
symbol->row_height[j] = calcheight;
|
||||
}
|
||||
|
||||
symbol->width = (int) strlen(pattern);
|
||||
|
||||
/* 843 */
|
||||
return error_number;
|
||||
@ -834,9 +838,10 @@ INTERNAL int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int l
|
||||
/* like PDF417 only much smaller! */
|
||||
INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length) {
|
||||
int i, k, j, indexchaine, indexliste, mode, longueur, mccorrection[50] = {0}, offset;
|
||||
int total, chainemc[PDF417_MAX_LEN], mclength, dummy[5], codeerr;
|
||||
int total, chainemc[PDF417_MAX_LEN], mclength, codeerr;
|
||||
int liste[2][PDF417_MAX_LEN] = {{0}};
|
||||
char pattern[580];
|
||||
int bp = 0;
|
||||
int variant, LeftRAPStart, CentreRAPStart, RightRAPStart, StartCluster;
|
||||
int LeftRAP, CentreRAP, RightRAP, Cluster, loop, calcheight;
|
||||
int debug = symbol->debug & ZINT_DEBUG_PRINT;
|
||||
@ -895,28 +900,26 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
|
||||
mclength++;
|
||||
}
|
||||
|
||||
if (symbol->eci > 811799) {
|
||||
strcpy(symbol->errtxt, "473: Invalid ECI");
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
||||
if (symbol->eci != 0) {
|
||||
|
||||
/* Encoding ECI assignment number, according to Table 8 */
|
||||
if (symbol->eci <= 899) {
|
||||
chainemc[mclength] = 927; /* ECI */
|
||||
mclength++;
|
||||
chainemc[mclength] = symbol->eci;
|
||||
mclength++;
|
||||
}
|
||||
if ((symbol->eci >= 900) && (symbol->eci <= 810899)) {
|
||||
} else if (symbol->eci <= 810899) {
|
||||
chainemc[mclength] = 926; /* ECI */
|
||||
mclength++;
|
||||
chainemc[mclength] = (symbol->eci / 900) - 1;
|
||||
mclength++;
|
||||
chainemc[mclength] = symbol->eci % 900;
|
||||
mclength++;
|
||||
}
|
||||
if (symbol->eci >= 810900) {
|
||||
} else {
|
||||
if (symbol->eci > 811799) {
|
||||
strcpy(symbol->errtxt, "473: Invalid ECI");
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
chainemc[mclength] = 925; /* ECI */
|
||||
mclength++;
|
||||
chainemc[mclength] = symbol->eci - 810900;
|
||||
@ -1002,120 +1005,92 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
|
||||
|
||||
if (symbol->option_2 == 1) {
|
||||
/* the user specified 1 column and the data does fit */
|
||||
variant = 6;
|
||||
if (mclength <= 16) {
|
||||
variant = 5;
|
||||
}
|
||||
if (mclength <= 12) {
|
||||
variant = 4;
|
||||
}
|
||||
if (mclength <= 10) {
|
||||
variant = 3;
|
||||
}
|
||||
if (mclength <= 7) {
|
||||
variant = 2;
|
||||
}
|
||||
if (mclength <= 4) {
|
||||
variant = 1;
|
||||
} else if (mclength <= 7) {
|
||||
variant = 2;
|
||||
} else if (mclength <= 10) {
|
||||
variant = 3;
|
||||
} else if (mclength <= 12) {
|
||||
variant = 4;
|
||||
} else if (mclength <= 16) {
|
||||
variant = 5;
|
||||
} else {
|
||||
variant = 6;
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol->option_2 == 2) {
|
||||
} else if (symbol->option_2 == 2) {
|
||||
/* the user specified 2 columns and the data does fit */
|
||||
variant = 13;
|
||||
if (mclength <= 33) {
|
||||
variant = 12;
|
||||
}
|
||||
if (mclength <= 29) {
|
||||
variant = 11;
|
||||
}
|
||||
if (mclength <= 24) {
|
||||
variant = 10;
|
||||
}
|
||||
if (mclength <= 19) {
|
||||
variant = 9;
|
||||
}
|
||||
if (mclength <= 13) {
|
||||
variant = 8;
|
||||
}
|
||||
if (mclength <= 8) {
|
||||
variant = 7;
|
||||
} else if (mclength <= 13) {
|
||||
variant = 8;
|
||||
} else if (mclength <= 19) {
|
||||
variant = 9;
|
||||
} else if (mclength <= 24) {
|
||||
variant = 10;
|
||||
} else if (mclength <= 29) {
|
||||
variant = 11;
|
||||
} else if (mclength <= 33) {
|
||||
variant = 12;
|
||||
} else {
|
||||
variant = 13;
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol->option_2 == 3) {
|
||||
} else if (symbol->option_2 == 3) {
|
||||
/* the user specified 3 columns and the data does fit */
|
||||
variant = 23;
|
||||
if (mclength <= 70) {
|
||||
variant = 22;
|
||||
}
|
||||
if (mclength <= 58) {
|
||||
variant = 21;
|
||||
}
|
||||
if (mclength <= 46) {
|
||||
variant = 20;
|
||||
}
|
||||
if (mclength <= 34) {
|
||||
variant = 19;
|
||||
}
|
||||
if (mclength <= 24) {
|
||||
variant = 18;
|
||||
}
|
||||
if (mclength <= 18) {
|
||||
variant = 17;
|
||||
}
|
||||
if (mclength <= 14) {
|
||||
variant = 16;
|
||||
}
|
||||
if (mclength <= 10) {
|
||||
variant = 15;
|
||||
}
|
||||
if (mclength <= 6) {
|
||||
variant = 14;
|
||||
} else if (mclength <= 10) {
|
||||
variant = 15;
|
||||
} else if (mclength <= 14) {
|
||||
variant = 16;
|
||||
} else if (mclength <= 18) {
|
||||
variant = 17;
|
||||
} else if (mclength <= 24) {
|
||||
variant = 18;
|
||||
} else if (mclength <= 34) {
|
||||
variant = 19;
|
||||
} else if (mclength <= 46) {
|
||||
variant = 20;
|
||||
} else if (mclength <= 58) {
|
||||
variant = 21;
|
||||
} else if (mclength <= 70) {
|
||||
variant = 22;
|
||||
} else {
|
||||
variant = 23;
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol->option_2 == 4) {
|
||||
} else if (symbol->option_2 == 4) {
|
||||
/* the user specified 4 columns and the data does fit */
|
||||
variant = 34;
|
||||
if (mclength <= 108) {
|
||||
variant = 33;
|
||||
}
|
||||
if (mclength <= 90) {
|
||||
variant = 32;
|
||||
}
|
||||
if (mclength <= 72) {
|
||||
variant = 31;
|
||||
}
|
||||
if (mclength <= 54) {
|
||||
variant = 30;
|
||||
}
|
||||
if (mclength <= 39) {
|
||||
variant = 29;
|
||||
}
|
||||
if (mclength <= 30) {
|
||||
variant = 28;
|
||||
}
|
||||
if (mclength <= 24) {
|
||||
variant = 27;
|
||||
}
|
||||
if (mclength <= 18) {
|
||||
variant = 26;
|
||||
}
|
||||
if (mclength <= 12) {
|
||||
variant = 25;
|
||||
}
|
||||
if (mclength <= 8) {
|
||||
variant = 24;
|
||||
} else if (mclength <= 12) {
|
||||
variant = 25;
|
||||
} else if (mclength <= 18) {
|
||||
variant = 26;
|
||||
} else if (mclength <= 24) {
|
||||
variant = 27;
|
||||
} else if (mclength <= 30) {
|
||||
variant = 28;
|
||||
} else if (mclength <= 39) {
|
||||
variant = 29;
|
||||
} else if (mclength <= 54) {
|
||||
variant = 30;
|
||||
} else if (mclength <= 72) {
|
||||
variant = 31;
|
||||
} else if (mclength <= 90) {
|
||||
variant = 32;
|
||||
} else if (mclength <= 108) {
|
||||
variant = 33;
|
||||
} else {
|
||||
variant = 34;
|
||||
}
|
||||
}
|
||||
|
||||
if (variant == 0) {
|
||||
} else {
|
||||
/* Zint can choose automatically from all available variations */
|
||||
for (i = 27; i >= 0; i--) {
|
||||
|
||||
if (MicroAutosize[i] >= mclength) {
|
||||
variant = MicroAutosize[i + 28];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1197,50 +1172,43 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
|
||||
if (debug) printf("\nInternal row representation:\n");
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
if (debug) printf("row %d: ", i);
|
||||
strcpy(pattern, "");
|
||||
bp = 0;
|
||||
offset = 929 * Cluster;
|
||||
for (j = 0; j < 5; j++) {
|
||||
dummy[j] = 0;
|
||||
}
|
||||
for (j = 0; j < symbol->option_2; j++) {
|
||||
dummy[j + 1] = chainemc[i * symbol->option_2 + j];
|
||||
if (debug) printf("[%d] ", dummy[j + 1]);
|
||||
}
|
||||
k = i * symbol->option_2;
|
||||
|
||||
/* Copy the data into codebarre */
|
||||
bin_append(rap_side[LeftRAP - 1], 10, pattern);
|
||||
bin_append(pdf_bitpattern[offset + dummy[1]], 16, pattern);
|
||||
strcat(pattern, "0");
|
||||
if (symbol->option_2 == 3) {
|
||||
bin_append(rap_centre[CentreRAP - 1], 10, pattern);
|
||||
}
|
||||
bp = bin_append_posn(rap_side[LeftRAP - 1], 10, pattern, bp);
|
||||
bp = bin_append_posn(pdf_bitpattern[offset + chainemc[k]], 16, pattern, bp);
|
||||
pattern[bp++] = '0';
|
||||
if (symbol->option_2 >= 2) {
|
||||
bin_append(pdf_bitpattern[offset + dummy[2]], 16, pattern);
|
||||
strcat(pattern, "0");
|
||||
if (symbol->option_2 == 3) {
|
||||
bp = bin_append_posn(rap_centre[CentreRAP - 1], 10, pattern, bp);
|
||||
}
|
||||
bp = bin_append_posn(pdf_bitpattern[offset + chainemc[k + 1]], 16, pattern, bp);
|
||||
pattern[bp++] = '0';
|
||||
if (symbol->option_2 >= 3) {
|
||||
if (symbol->option_2 == 4) {
|
||||
bp = bin_append_posn(rap_centre[CentreRAP - 1], 10, pattern, bp);
|
||||
}
|
||||
bp = bin_append_posn(pdf_bitpattern[offset + chainemc[k + 2]], 16, pattern, bp);
|
||||
pattern[bp++] = '0';
|
||||
if (symbol->option_2 == 4) {
|
||||
bp = bin_append_posn(pdf_bitpattern[offset + chainemc[k + 3]], 16, pattern, bp);
|
||||
pattern[bp++] = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (symbol->option_2 == 4) {
|
||||
bin_append(rap_centre[CentreRAP - 1], 10, pattern);
|
||||
}
|
||||
if (symbol->option_2 >= 3) {
|
||||
bin_append(pdf_bitpattern[offset + dummy[3]], 16, pattern);
|
||||
strcat(pattern, "0");
|
||||
}
|
||||
if (symbol->option_2 == 4) {
|
||||
bin_append(pdf_bitpattern[offset + dummy[4]], 16, pattern);
|
||||
strcat(pattern, "0");
|
||||
}
|
||||
bin_append(rap_side[RightRAP - 1], 10, pattern);
|
||||
strcat(pattern, "1"); /* stop */
|
||||
if (debug) printf("%s\n", pattern);
|
||||
bp = bin_append_posn(rap_side[RightRAP - 1], 10, pattern, bp);
|
||||
pattern[bp++] = '1'; /* stop */
|
||||
if (debug) printf("%.*s\n", bp, pattern);
|
||||
|
||||
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
|
||||
for (loop = 0; loop < (int)strlen(pattern); loop++) {
|
||||
for (loop = 0; loop < bp; loop++) {
|
||||
if (pattern[loop] == '1') {
|
||||
set_module(symbol, i, loop);
|
||||
}
|
||||
}
|
||||
symbol->row_height[i] = 2;
|
||||
symbol->width = strlen(pattern);
|
||||
|
||||
/* Set up RAPs and Cluster for next row */
|
||||
LeftRAP++;
|
||||
@ -1261,6 +1229,7 @@ INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], in
|
||||
Cluster = 0;
|
||||
}
|
||||
}
|
||||
symbol->width = bp;
|
||||
|
||||
/* Allow user to adjust height of symbol, but enforce minimum row height of 2X */
|
||||
calcheight = (int)(symbol->height / i);
|
||||
|
@ -37,9 +37,10 @@
|
||||
#define SSET "0123456789ABCDEF"
|
||||
|
||||
static const char *PlessTable[16] = {
|
||||
"13131313", "31131313", "13311313", "31311313", "13133113", "31133113",
|
||||
"13313113", "31313113", "13131331", "31131331", "13311331", "31311331", "13133131",
|
||||
"31133131", "13313131", "31313131"
|
||||
"13131313", "31131313", "13311313", "31311313",
|
||||
"13133113", "31133113", "13313113", "31313113",
|
||||
"13131331", "31131331", "13311331", "31311331",
|
||||
"13133131", "31133131", "13313131", "31313131"
|
||||
};
|
||||
|
||||
static const char *MSITable[10] = {
|
||||
@ -48,9 +49,9 @@ static const char *MSITable[10] = {
|
||||
};
|
||||
|
||||
/* Not MSI/Plessey but the older Plessey standard */
|
||||
INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
|
||||
INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
unsigned int i;
|
||||
int i;
|
||||
unsigned char *checkptr;
|
||||
static const char grid[9] = {1, 1, 1, 1, 0, 1, 0, 0, 1};
|
||||
char dest[1024]; /* 8 + 65 * 8 + 8 * 2 + 9 + 1 ~ 1024 */
|
||||
@ -141,7 +142,7 @@ static int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[],
|
||||
|
||||
int i, wright, pump, n;
|
||||
unsigned long dau, pedwar;
|
||||
char un[200], tri[32];
|
||||
char un[32], tri[32];
|
||||
int error_number, h;
|
||||
char dest[1000];
|
||||
|
||||
@ -174,7 +175,7 @@ static int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[],
|
||||
sprintf(tri, "%lu", dau);
|
||||
|
||||
pedwar = 0;
|
||||
h = strlen(tri);
|
||||
h = (int) strlen(tri);
|
||||
for (i = 0; i < h; i++) {
|
||||
pedwar += ctoi(tri[i]);
|
||||
}
|
||||
@ -208,7 +209,7 @@ static int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[
|
||||
|
||||
int i, n, wright, pump;
|
||||
unsigned long dau, pedwar, chwech;
|
||||
char un[16], tri[32];
|
||||
char un[32], tri[32];
|
||||
int error_number, h;
|
||||
char dest[1000];
|
||||
|
||||
@ -243,7 +244,7 @@ static int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[
|
||||
sprintf(tri, "%lu", dau);
|
||||
|
||||
pedwar = 0;
|
||||
h = strlen(tri);
|
||||
h = (int) strlen(tri);
|
||||
for (i = 0; i < h; i++) {
|
||||
pedwar += ctoi(tri[i]);
|
||||
}
|
||||
@ -273,7 +274,7 @@ static int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[
|
||||
sprintf(tri, "%lu", dau);
|
||||
|
||||
pedwar = 0;
|
||||
h = strlen(tri);
|
||||
h = (int) strlen(tri);
|
||||
for (i = 0; i < h; i++) {
|
||||
pedwar += ctoi(tri[i]);
|
||||
}
|
||||
@ -334,7 +335,7 @@ static int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[],
|
||||
x = 0;
|
||||
weight = 2;
|
||||
for (i = src_len - 1; i >= 0; i--) {
|
||||
x += weight * ctoi(source[i]);
|
||||
x += (long) (weight * ctoi(source[i]));
|
||||
weight++;
|
||||
if (weight > 7) {
|
||||
weight = 2;
|
||||
@ -373,7 +374,7 @@ static int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[
|
||||
unsigned long x, dau, pedwar;
|
||||
int h;
|
||||
int si;
|
||||
char un[16], tri[16];
|
||||
char un[32], tri[32];
|
||||
int error_number;
|
||||
char dest[1000];
|
||||
unsigned char temp[32];
|
||||
@ -398,7 +399,7 @@ static int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[
|
||||
x = 0;
|
||||
weight = 2;
|
||||
for (si = src_len - 1; si >= 0; si--) {
|
||||
x += weight * ctoi(source[si]);
|
||||
x += (long) (weight * ctoi(source[si]));
|
||||
weight++;
|
||||
if (weight > 7) {
|
||||
weight = 2;
|
||||
@ -433,7 +434,7 @@ static int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[
|
||||
sprintf(tri, "%lu", dau);
|
||||
|
||||
pedwar = 0;
|
||||
h = strlen(tri);
|
||||
h = (int) strlen(tri);
|
||||
for (i = 0; i < h; i++) {
|
||||
pedwar += ctoi(tri[i]);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch
|
||||
* JISX0201.1976-0 (libiconv-1.16/lib/jisx0201.h)
|
||||
*/
|
||||
|
||||
static int jisx0201_wctomb(unsigned int *r, unsigned int wc) {
|
||||
static int jisx0201_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) {
|
||||
*r = wc;
|
||||
return 1;
|
||||
@ -1444,7 +1444,7 @@ static const Summary16 jisx0208_uni2indx_pageff[15] = {
|
||||
{ 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0028 },
|
||||
};
|
||||
|
||||
static int jisx0208_wctomb(unsigned int *r, unsigned int wc) {
|
||||
static int jisx0208_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
const Summary16 *summary = NULL;
|
||||
if (wc < 0x0100) {
|
||||
summary = &jisx0208_uni2indx_page00[(wc>>4)];
|
||||
@ -1484,7 +1484,7 @@ static int jisx0208_wctomb(unsigned int *r, unsigned int wc) {
|
||||
*/
|
||||
|
||||
/* Returns 1 or 2 on success, 0 if no mapping */
|
||||
INTERNAL int sjis_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
INTERNAL int sjis_wctomb_zint(unsigned int *r, const unsigned int wc) {
|
||||
int ret;
|
||||
|
||||
/* Try JIS X 0201-1976. */
|
||||
@ -1494,8 +1494,8 @@ INTERNAL int sjis_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
}
|
||||
|
||||
/* Try JIS X 0208-1990. */
|
||||
/* ZINT: Note leaving mapping of full-width reverse solidus U+FF3C to 0x815F (duplicate of patched U+005C) to avoid
|
||||
* having to regen tables */
|
||||
/* ZINT: Note leaving mapping of full-width reverse solidus U+FF3C to 0x815F (duplicate of patched U+005C) to
|
||||
* avoid having to regen tables */
|
||||
ret = jisx0208_wctomb(r, wc);
|
||||
if (ret) {
|
||||
return ret;
|
||||
@ -1503,7 +1503,7 @@ INTERNAL int sjis_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
|
||||
/* User-defined range. See
|
||||
* Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */
|
||||
/* ZINT: https://file.allitebooks.com/20160708/CJKV%20Information%20Processing.pdf (table 4-86, p. 286, 2nd ed.) */
|
||||
/* ZINT: https://file.allitebooks.com/20160708/CJKV%20Information%20Processing.pdf (table 4-86, p.286, 2nd ed.) */
|
||||
if (wc >= 0xe000 && wc < 0xe758) {
|
||||
unsigned char c1, c2;
|
||||
c1 = (unsigned int) (wc - 0xe000) / 188;
|
||||
@ -1517,7 +1517,7 @@ INTERNAL int sjis_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
|
||||
/* Convert UTF-8 string to Shift JIS and place in array of ints */
|
||||
INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *jisdata) {
|
||||
unsigned int *jisdata) {
|
||||
int error_number;
|
||||
unsigned int i, length;
|
||||
#ifndef _MSC_VER
|
||||
@ -1542,8 +1542,8 @@ INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char sourc
|
||||
}
|
||||
|
||||
/* Convert UTF-8 string to single byte ECI and place in array of ints */
|
||||
INTERNAL int sjis_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *jisdata,
|
||||
int full_multibyte) {
|
||||
INTERNAL int sjis_utf8tosb(const int eci, const unsigned char source[], int *p_length, unsigned int *jisdata,
|
||||
const int full_multibyte) {
|
||||
int error_number;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char single_byte[*p_length + 1];
|
||||
@ -1562,9 +1562,9 @@ INTERNAL int sjis_utf8tosb(int eci, const unsigned char source[], int *p_length,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match QR Kanji mode in a
|
||||
* single entry. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int *jisdata, int full_multibyte) {
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match QR Kanji mode in
|
||||
* a single entry. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int *jisdata, const int full_multibyte) {
|
||||
unsigned int i, j, jis, length;
|
||||
unsigned char c;
|
||||
|
||||
|
@ -37,12 +37,12 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INTERNAL int sjis_wctomb_zint(unsigned int *r, unsigned int wc);
|
||||
INTERNAL int sjis_wctomb_zint(unsigned int *r, const unsigned int wc);
|
||||
INTERNAL int sjis_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *jisdata);
|
||||
INTERNAL int sjis_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *jisdata,
|
||||
int full_multibyte);
|
||||
INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int *jisdata, int full_multibyte);
|
||||
unsigned int *jisdata);
|
||||
INTERNAL int sjis_utf8tosb(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
|
||||
}
|
||||
|
@ -31,7 +31,8 @@
|
||||
*/
|
||||
/* 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 */
|
||||
/* 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"
|
||||
|
||||
@ -57,8 +58,8 @@ static char *TeleTable[] = {
|
||||
"3113111113", "11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113", "131111111113", "1111111111111111",
|
||||
};
|
||||
|
||||
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], const size_t src_len) {
|
||||
unsigned int i, count, check_digit;
|
||||
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 */
|
||||
|
||||
@ -104,39 +105,39 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], const s
|
||||
return error_number;
|
||||
}
|
||||
|
||||
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], const size_t src_len) {
|
||||
unsigned int count, check_digit, glyph;
|
||||
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len) {
|
||||
int count, check_digit, glyph;
|
||||
int error_number;
|
||||
size_t i, temp_length = src_len;
|
||||
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 (temp_length > 60) {
|
||||
if (src_len > 60) {
|
||||
strcpy(symbol->errtxt, "392: Input too long");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
ustrcpy(temp, source);
|
||||
to_upper(temp);
|
||||
error_number = is_sane(SODIUM, temp, temp_length);
|
||||
error_number = is_sane(SODIUM, temp, src_len);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "393: Invalid characters in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Add a leading zero if required */
|
||||
if (temp_length & 1) {
|
||||
memmove(temp + 1, temp, temp_length);
|
||||
if (src_len & 1) {
|
||||
memmove(temp + 1, temp, src_len);
|
||||
temp[0] = '0';
|
||||
|
||||
temp[++temp_length] = '\0';
|
||||
temp[++src_len] = '\0';
|
||||
}
|
||||
|
||||
/* Start character */
|
||||
strcpy(dest, TeleTable['_']);
|
||||
|
||||
for (i = 0; i < temp_length; i += 2) {
|
||||
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;
|
||||
|
@ -48,8 +48,8 @@ static void test_large(int index, int debug) {
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_C25STANDARD, "1", 80, 0, 1, 817 },
|
||||
/* 1*/ { BARCODE_C25STANDARD, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { BARCODE_C25INTER, "1", 89, 0, 1, 819 },
|
||||
/* 3*/ { BARCODE_C25INTER, "1", 90, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { BARCODE_C25INTER, "1", 90, 0, 1, 819 },
|
||||
/* 3*/ { BARCODE_C25INTER, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 4*/ { BARCODE_C25IATA, "1", 45, 0, 1, 639 },
|
||||
/* 5*/ { BARCODE_C25IATA, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 6*/ { BARCODE_C25LOGIC, "1", 80, 0, 1, 809 },
|
||||
|
@ -2022,6 +2022,9 @@ static void test_perf(int index, int debug) {
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ~~~~~~~~~~~~~~~~~~~~~~~~~ ?????????????????????????? 12345678901234567890123456 \377\377\377\377\377\377",
|
||||
0, 113, 113, "1540 chars, 12-bit words, mixed" },
|
||||
/* 4*/ { BARCODE_AZRUNE, -1, -1, -1,
|
||||
"255",
|
||||
0, 11, 11, "3 chars, AZRUNE" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "testcommon.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
extern int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
|
||||
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
|
||||
|
||||
static void test_pixel_plot(int index, int debug) {
|
||||
|
||||
|
@ -68,8 +68,9 @@ static void test_large(int index, int debug) {
|
||||
/* 18*/ { BARCODE_VIN, -1, "1", 17, 0, 1, 246 },
|
||||
/* 19*/ { BARCODE_VIN, -1, "1", 18, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 20*/ { BARCODE_VIN, -1, "1", 16, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 21*/ { BARCODE_HIBC_39, -1, "1", 66, 0, 1, 1119 }, // 68 - 2 ('+' and check digit)
|
||||
/* 22*/ { BARCODE_HIBC_39, -1, "1", 67, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 21*/ { BARCODE_VIN, 1, "1", 17, 0, 1, 259 },
|
||||
/* 22*/ { BARCODE_HIBC_39, -1, "1", 66, 0, 1, 1119 }, // 68 - 2 ('+' and check digit)
|
||||
/* 23*/ { BARCODE_HIBC_39, -1, "1", 67, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
extern int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
|
||||
INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
|
||||
|
||||
static void test_pixel_plot(int index, int debug) {
|
||||
|
||||
|
@ -189,6 +189,8 @@ static void test_encode(int index, int generate, int debug) {
|
||||
|
||||
testStart("");
|
||||
|
||||
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
@ -202,34 +204,39 @@ static void test_encode(int index, int generate, int debug) {
|
||||
char *expected;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1234567890", 0, 1, 127, "Verified manually against bwipp and tec-it",
|
||||
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1234567890", 0, 1, 127, "Verified manually against tec-it",
|
||||
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001"
|
||||
},
|
||||
/* 1*/ { BARCODE_MSI_PLESSEY, 1, "1234567890", 0, 1, 139, "Verified manually against bwipp and tec-it",
|
||||
/* 1*/ { BARCODE_MSI_PLESSEY, 1, "1234567890", 0, 1, 139, "Verified manually against tec-it",
|
||||
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001001101101001"
|
||||
},
|
||||
/* 2*/ { BARCODE_MSI_PLESSEY, 2, "1234567890", 0, 1, 151, "Verified manually against bwipp and tec-it",
|
||||
/* 2*/ { BARCODE_MSI_PLESSEY, 2, "1234567890", 0, 1, 151, "Verified manually against tec-it",
|
||||
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001001101101001001001101001"
|
||||
},
|
||||
/* 3*/ { BARCODE_MSI_PLESSEY, 3, "1234567890", 0, 1, 139, "Verified manually against bwipp",
|
||||
/* 3*/ { BARCODE_MSI_PLESSEY, 3, "1234567890", 0, 1, 139, "",
|
||||
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001001101101001"
|
||||
},
|
||||
/* 4*/ { BARCODE_MSI_PLESSEY, 4, "1234567890", 0, 1, 151, "Verified manually against bwipp",
|
||||
/* 4*/ { BARCODE_MSI_PLESSEY, 4, "1234567890", 0, 1, 151, "",
|
||||
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001001101101001001001101001"
|
||||
},
|
||||
/* 5*/ { BARCODE_MSI_PLESSEY, 3, "2211", 0, 1, 79, "Produces mod-11 '10' check digit; verified manually against bwipp (badmod11)",
|
||||
/* 5*/ { BARCODE_MSI_PLESSEY, 3, "2211", 0, 1, 79, "Produces mod-11 '10' check digit; BWIPP (badmod11)",
|
||||
"1101001001101001001001101001001001001101001001001101001001001101001001001001001"
|
||||
},
|
||||
/* 6*/ { BARCODE_MSI_PLESSEY, 4, "2211", 0, 1, 91, "Verified manually against bwipp (badmod11)",
|
||||
/* 6*/ { BARCODE_MSI_PLESSEY, 4, "2211", 0, 1, 91, "BWIPP (badmod11)",
|
||||
"1101001001101001001001101001001001001101001001001101001001001101001001001001001001001001001"
|
||||
},
|
||||
/* 7*/ { BARCODE_PLESSEY, -1, "0123456789ABCDEF", 0, 1, 323, "Verified manually against bwipp",
|
||||
/* 7*/ { BARCODE_PLESSEY, -1, "0123456789ABCDEF", 0, 1, 323, "",
|
||||
"11101110100011101000100010001000111010001000100010001110100010001110111010001000100010001110100011101000111010001000111011101000111011101110100010001000100011101110100010001110100011101000111011101110100011101000100011101110111010001110111010001110111011101110111011101110111010001000111010001000100010001110001000101110111"
|
||||
},
|
||||
/* 8*/ { BARCODE_MSI_PLESSEY, 4, "999999999999999999", 0, 1, 247, "Max value; #209 check buffer not overrun",
|
||||
"1101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001001001001001101001"
|
||||
},
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
char escaped[1024];
|
||||
char bwipp_buf[4096];
|
||||
char bwipp_msg[1024];
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
@ -254,10 +261,17 @@ static void test_encode(int index, int generate, int debug) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
|
||||
if (ret == 0) {
|
||||
int width, row;
|
||||
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
|
||||
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
|
||||
int width, row;
|
||||
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
|
||||
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
|
||||
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "testcommon.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
extern int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
|
||||
INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
|
||||
|
||||
static void test_pixel_plot(int index, int debug) {
|
||||
|
||||
|
@ -2025,6 +2025,74 @@ static void test_microqr_encode(int index, int generate, int debug) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
// Not a real test, just performance indicator
|
||||
static void test_microqr_perf(int index, int debug) {
|
||||
|
||||
if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
|
||||
return;
|
||||
}
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
int option_1;
|
||||
int option_2;
|
||||
char *data;
|
||||
int ret;
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_MICROQR, UNICODE_MODE, 1, 1, "12345", 0, 11, 11, "Max 5 numbers, M1" },
|
||||
/* 1*/ { BARCODE_MICROQR, UNICODE_MODE, 1, 2, "1234567890", 0, 13, 13, "Max 10 numbers, M2-L" },
|
||||
/* 2*/ { BARCODE_MICROQR, UNICODE_MODE, 1, 3, "123456789012345", 0, 15, 15, "Max 15 numbers, M3-L" },
|
||||
/* 3*/ { BARCODE_MICROQR, UNICODE_MODE, 1, 4, "12345678901234567890123456789012345", 0, 17, 17, "Max 35 numbers, M4-L" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer;
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
diff_encode = diff_buffer = 0;
|
||||
|
||||
for (int j = 0; j < TEST_PERF_ITERATIONS; j++) {
|
||||
struct zint_symbol *symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
diff_encode += clock() - start;
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/);
|
||||
diff_buffer += clock() - start;
|
||||
assert_zero(ret, "i:%d ZBarcode_Buffer ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
printf("%s: diff_encode %gms, diff_buffer %gms\n", data[i].comment, diff_encode * 1000.0 / CLOCKS_PER_SEC, diff_buffer * 1000.0 / CLOCKS_PER_SEC);
|
||||
|
||||
total_encode += diff_encode;
|
||||
total_buffer += diff_buffer;
|
||||
}
|
||||
if (index != -1) {
|
||||
printf("totals: encode %gms, buffer %gms\n", total_encode * 1000.0 / CLOCKS_PER_SEC, total_buffer * 1000.0 / CLOCKS_PER_SEC);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_upnqr_input(int index, int generate, int debug) {
|
||||
|
||||
testStart("");
|
||||
@ -2674,6 +2742,7 @@ int main(int argc, char *argv[]) {
|
||||
{ "test_microqr_padding", test_microqr_padding, 1, 1, 1 },
|
||||
{ "test_microqr_optimize", test_microqr_optimize, 1, 1, 1 },
|
||||
{ "test_microqr_encode", test_microqr_encode, 1, 1, 1 },
|
||||
{ "test_microqr_perf", test_microqr_perf, 1, 0, 1 },
|
||||
|
||||
{ "test_upnqr_input", test_upnqr_input, 1, 1, 1 },
|
||||
{ "test_upnqr_encode", test_upnqr_encode, 1, 1, 1 },
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
extern int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
|
||||
INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
|
||||
|
||||
// For overview when debugging: ./test_tiff -f pixel_plot -d 5
|
||||
static void test_pixel_plot(int index, int debug) {
|
||||
|
@ -29,6 +29,7 @@ run_bwipp_test "test_gs1" "gs1_reduce"
|
||||
run_bwipp_test "test_imail" "encode"
|
||||
run_bwipp_test "test_medical" "encode"
|
||||
run_bwipp_test "test_pdf417" "encode"
|
||||
run_bwipp_test "test_plessey" "encode"
|
||||
run_bwipp_test "test_postal" "encode"
|
||||
run_bwipp_test "test_rss"
|
||||
run_bwipp_test "test_telepen" "encode"
|
||||
|
@ -351,8 +351,9 @@ static float look_ahead_ascii(unsigned char source[], int in_length, int in_locn
|
||||
}
|
||||
|
||||
/* Returns true if should latch to subset other than given `subset` */
|
||||
static int c43_should_latch_other(const unsigned char data[], const size_t length, const unsigned int locn, int subset, int gs1) {
|
||||
unsigned int i, fraglen, predict_window;
|
||||
static int c43_should_latch_other(const unsigned char data[], const int length, const int locn, const int subset,
|
||||
const int gs1) {
|
||||
int i, fraglen, predict_window;
|
||||
int cnt, alt_cnt, fragno;
|
||||
const char* set = subset == 1 ? ultra_c43_set1 : ultra_c43_set2;
|
||||
const char* alt_set = subset == 2 ? ultra_c43_set1 : ultra_c43_set2;
|
||||
@ -612,7 +613,8 @@ static float look_ahead_c43(unsigned char source[], int in_length, int in_locn,
|
||||
}
|
||||
|
||||
/* Produces a set of codewords which are "somewhat" optimised - this could be improved on */
|
||||
static int ultra_generate_codewords(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length, int codewords[]) {
|
||||
static int ultra_generate_codewords(struct zint_symbol *symbol, const unsigned char source[], const int in_length,
|
||||
int codewords[]) {
|
||||
int i;
|
||||
int crop_length;
|
||||
int codeword_count = 0;
|
||||
@ -646,7 +648,7 @@ static int ultra_generate_codewords(struct zint_symbol *symbol, const unsigned c
|
||||
|
||||
// Decide start character codeword (from Table 5)
|
||||
symbol_mode = ASCII_MODE;
|
||||
for (i = 0; i < (int) in_length; i++) {
|
||||
for (i = 0; i < in_length; i++) {
|
||||
if (source[i] >= 0x80) {
|
||||
symbol_mode = EIGHTBIT_MODE;
|
||||
break;
|
||||
@ -747,14 +749,14 @@ static int ultra_generate_codewords(struct zint_symbol *symbol, const unsigned c
|
||||
}
|
||||
codeword_count++;
|
||||
|
||||
for (i = 7; i < ((int) in_length - 2); i++) {
|
||||
for (i = 7; i < (in_length - 2); i++) {
|
||||
crop_source[i - 7] = source[i];
|
||||
}
|
||||
crop_length = in_length - 9;
|
||||
crop_source[crop_length] = '\0';
|
||||
} else {
|
||||
/* Make a cropped version of input data - removes http:// and https:// if needed */
|
||||
for (i = input_locn; i < (int) in_length; i++) {
|
||||
for (i = input_locn; i < in_length; i++) {
|
||||
crop_source[i - input_locn] = source[i];
|
||||
}
|
||||
crop_length = in_length - input_locn;
|
||||
@ -860,7 +862,7 @@ static int ultra_generate_codewords(struct zint_symbol *symbol, const unsigned c
|
||||
return codeword_count;
|
||||
}
|
||||
|
||||
INTERNAL int ultracode(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length) {
|
||||
INTERNAL int ultracode(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int data_cw_count = 0;
|
||||
int acc, qcc;
|
||||
int ecc_level;
|
||||
@ -879,7 +881,7 @@ INTERNAL int ultracode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
char* pattern;
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
cw_memalloc = in_length * 2;
|
||||
cw_memalloc = length * 2;
|
||||
if (cw_memalloc < 283) {
|
||||
cw_memalloc = 283;
|
||||
}
|
||||
@ -895,7 +897,7 @@ INTERNAL int ultracode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
data_codewords = (int *) _alloca(cw_memalloc * sizeof (int));
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
data_cw_count = ultra_generate_codewords(symbol, source, in_length, data_codewords);
|
||||
data_cw_count = ultra_generate_codewords(symbol, source, length, data_codewords);
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("Codewords returned = %d\n", data_cw_count);
|
||||
|
@ -299,7 +299,7 @@ static int batch_process(struct zint_symbol *symbol, char *filename, int mirror_
|
||||
FILE *file;
|
||||
unsigned char buffer[ZINT_MAX_DATA_LEN] = {0}; // Maximum HanXin input
|
||||
unsigned char character = 0;
|
||||
int posn = 0, error_number = 0, line_count = 1;
|
||||
int buf_posn = 0, error_number = 0, line_count = 1;
|
||||
char output_file[256];
|
||||
char number[12], reverse_number[12];
|
||||
int inpos, local_line_count;
|
||||
@ -333,10 +333,10 @@ static int batch_process(struct zint_symbol *symbol, char *filename, int mirror_
|
||||
}
|
||||
character = (unsigned char) intChar;
|
||||
if (character == '\n') {
|
||||
if (posn > 0 && buffer[posn - 1] == '\r') {
|
||||
if (buf_posn > 0 && buffer[buf_posn - 1] == '\r') {
|
||||
/* CR+LF - assume Windows formatting and remove CR */
|
||||
posn--;
|
||||
buffer[posn] = '\0';
|
||||
buf_posn--;
|
||||
buffer[buf_posn] = '\0';
|
||||
}
|
||||
|
||||
if (mirror_mode == 0) {
|
||||
@ -433,7 +433,7 @@ static int batch_process(struct zint_symbol *symbol, char *filename, int mirror_
|
||||
}
|
||||
i++;
|
||||
o++;
|
||||
} while (i < posn && o < 251);
|
||||
} while (i < buf_posn && o < 251);
|
||||
|
||||
/* Add file extension */
|
||||
output_file[o] = '.';
|
||||
@ -443,20 +443,20 @@ static int batch_process(struct zint_symbol *symbol, char *filename, int mirror_
|
||||
}
|
||||
|
||||
strcpy(symbol->outfile, output_file);
|
||||
error_number = ZBarcode_Encode_and_Print(symbol, buffer, posn, rotate_angle);
|
||||
error_number = ZBarcode_Encode_and_Print(symbol, buffer, buf_posn, rotate_angle);
|
||||
if (error_number != 0) {
|
||||
fprintf(stderr, "On line %d: %s\n", line_count, symbol->errtxt);
|
||||
fflush(stderr);
|
||||
}
|
||||
ZBarcode_Clear(symbol);
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
posn = 0;
|
||||
buf_posn = 0;
|
||||
line_count++;
|
||||
} else {
|
||||
buffer[posn] = character;
|
||||
posn++;
|
||||
buffer[buf_posn] = character;
|
||||
buf_posn++;
|
||||
}
|
||||
if (posn >= (int) sizeof(buffer)) {
|
||||
if (buf_posn >= (int) sizeof(buffer)) {
|
||||
fprintf(stderr, "On line %d: Error 103: Input data too long\n", line_count);
|
||||
fflush(stderr);
|
||||
do {
|
||||
|
Loading…
Reference in New Issue
Block a user