mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Improvements from Oxy patch
Original email reads... It does not contain any fundamental changes or new functions but a lot of improvements which I have done over time (added several const/static specifiers, replaced repeated if-conditions by if-else, removed some warnings).
This commit is contained in:
parent
922ee489a9
commit
5d9ce6f684
@ -109,7 +109,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt
|
|||||||
unsigned int loopey, reader, h;
|
unsigned int loopey, reader, h;
|
||||||
|
|
||||||
char data_pattern[200];
|
char data_pattern[200];
|
||||||
char fcc[3] = {0, 0}, dpid[10];
|
char fcc[3] = {0, 0, 0}, dpid[10];
|
||||||
char localstr[30];
|
char localstr[30];
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
@ -52,7 +52,7 @@ void mapshorten(int *charmap, int *typemap, int start, int length) {
|
|||||||
* Insert a character into the middle of a string at position posn
|
* Insert a character into the middle of a string at position posn
|
||||||
*/
|
*/
|
||||||
void insert(char binary_string[], int posn, char newbit) {
|
void insert(char binary_string[], int posn, char newbit) {
|
||||||
int i, end;
|
size_t i, end;
|
||||||
|
|
||||||
end = strlen(binary_string);
|
end = strlen(binary_string);
|
||||||
for (i = end; i > posn; i--) {
|
for (i = end; i > posn; i--) {
|
||||||
@ -81,7 +81,7 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char
|
|||||||
maplength = 0;
|
maplength = 0;
|
||||||
debug = 0;
|
debug = 0;
|
||||||
|
|
||||||
for (i = 0; i < src_len; i++) {
|
for (i = 0; i < (int) src_len; i++) {
|
||||||
if (gs1 && (i == 0)) {
|
if (gs1 && (i == 0)) {
|
||||||
/* Add FNC1 to beginning of GS1 messages */
|
/* Add FNC1 to beginning of GS1 messages */
|
||||||
charmap[maplength] = 0;
|
charmap[maplength] = 0;
|
||||||
@ -109,7 +109,7 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char
|
|||||||
/* Look for double character encoding possibilities */
|
/* Look for double character encoding possibilities */
|
||||||
i = 0;
|
i = 0;
|
||||||
do {
|
do {
|
||||||
if (((charmap[i] == 300) && (charmap[i + 1] == 11))
|
if (((charmap[i] == 300) && (charmap[i + 1] == 11))
|
||||||
&& ((typemap[i] == PUNC) && (typemap[i + 1] == PUNC))) {
|
&& ((typemap[i] == PUNC) && (typemap[i + 1] == PUNC))) {
|
||||||
/* CR LF combination */
|
/* CR LF combination */
|
||||||
charmap[i] = 2;
|
charmap[i] = 2;
|
||||||
@ -118,7 +118,7 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char
|
|||||||
maplength--;
|
maplength--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((charmap[i] == 302) && (charmap[i + 1] == 1))
|
if (((charmap[i] == 302) && (charmap[i + 1] == 1))
|
||||||
&& ((typemap[i] == 24) && (typemap[i + 1] == 23))) {
|
&& ((typemap[i] == 24) && (typemap[i + 1] == 23))) {
|
||||||
/* . SP combination */
|
/* . SP combination */
|
||||||
charmap[i] = 3;
|
charmap[i] = 3;
|
||||||
@ -127,7 +127,7 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char
|
|||||||
maplength--;
|
maplength--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((charmap[i] == 301) && (charmap[i + 1] == 1))
|
if (((charmap[i] == 301) && (charmap[i + 1] == 1))
|
||||||
&& ((typemap[i] == 24) && (typemap[i + 1] == 23))) {
|
&& ((typemap[i] == 24) && (typemap[i + 1] == 23))) {
|
||||||
/* , SP combination */
|
/* , SP combination */
|
||||||
charmap[i] = 4;
|
charmap[i] = 4;
|
||||||
@ -136,7 +136,7 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char
|
|||||||
maplength--;
|
maplength--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((charmap[i] == 21) && (charmap[i + 1] == 1))
|
if (((charmap[i] == 21) && (charmap[i + 1] == 1))
|
||||||
&& ((typemap[i] == PUNC) && (typemap[i + 1] == 23))) {
|
&& ((typemap[i] == PUNC) && (typemap[i + 1] == 23))) {
|
||||||
/* : SP combination */
|
/* : SP combination */
|
||||||
charmap[i] = 5;
|
charmap[i] = 5;
|
||||||
@ -629,7 +629,7 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char
|
|||||||
if (bytes > 31) {
|
if (bytes > 31) {
|
||||||
/* Put 00000 followed by 11-bit number of bytes less 31 */
|
/* Put 00000 followed by 11-bit number of bytes less 31 */
|
||||||
concat(binary_string, "00000");
|
concat(binary_string, "00000");
|
||||||
|
|
||||||
for (p = 0; p < 11; p++) {
|
for (p = 0; p < 11; p++) {
|
||||||
if ((bytes - 31) & (0x400 >> p)) {
|
if ((bytes - 31) & (0x400 >> p)) {
|
||||||
concat(binary_string, "1");
|
concat(binary_string, "1");
|
||||||
@ -1000,8 +1000,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layers == 0) {
|
if (layers == 0) { /* Couldn't find a symbol which fits the data */
|
||||||
/* Couldn't find a symbol which fits the data */
|
|
||||||
strcpy(symbol->errtxt, "Input too long (too many bits for selected ECC)");
|
strcpy(symbol->errtxt, "Input too long (too many bits for selected ECC)");
|
||||||
return ZINT_ERROR_TOO_LONG;
|
return ZINT_ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
@ -1299,7 +1298,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
for (i = 0; i < data_blocks; i++) {
|
for (i = 0; i < data_blocks; i++) {
|
||||||
for(p = 0; p < 10; p++) {
|
for (p = 0; p < 10; p++) {
|
||||||
if (adjusted_string[i * codeword_size + p] == '1') {
|
if (adjusted_string[i * codeword_size + p] == '1') {
|
||||||
data_part[i] += (0x200 >> p);
|
data_part[i] += (0x200 >> p);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[], int length) { /*
|
|||||||
strcpy(dest, "112211");
|
strcpy(dest, "112211");
|
||||||
|
|
||||||
/* Draw main body of barcode */
|
/* Draw main body of barcode */
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < (unsigned int) length; i++) {
|
||||||
lookup(SODIUM, C11Table, source[i], dest);
|
lookup(SODIUM, C11Table, source[i], dest);
|
||||||
if (source[i] == '-')
|
if (source[i] == '-')
|
||||||
weight[i] = 10;
|
weight[i] = 10;
|
||||||
@ -187,7 +187,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[], int length) { /*
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Code 39 */
|
/* Code 39 */
|
||||||
int c39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int c39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int counter;
|
unsigned int counter;
|
||||||
char check_digit;
|
char check_digit;
|
||||||
@ -219,7 +219,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
/* Start character */
|
/* Start character */
|
||||||
strcpy(dest, "1211212111");
|
strcpy(dest, "1211212111");
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < (unsigned int) length; i++) {
|
||||||
lookup(SILVER, C39Table, source[i], dest);
|
lookup(SILVER, C39Table, source[i], dest);
|
||||||
counter += posn(SILVER, source[i]);
|
counter += posn(SILVER, source[i]);
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Pharmazentral Nummer (PZN) */
|
/* Pharmazentral Nummer (PZN) */
|
||||||
int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
|
|
||||||
int i, error_number, zeroes;
|
int i, error_number, zeroes;
|
||||||
unsigned int count, check_digit;
|
unsigned int count, check_digit;
|
||||||
@ -338,7 +338,7 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
|
/* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
|
||||||
int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
|
|
||||||
unsigned char buffer[150] = {0};
|
unsigned char buffer[150] = {0};
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -352,7 +352,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Creates a buffer string and places control characters into it */
|
/* Creates a buffer string and places control characters into it */
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < (unsigned int) length; i++) {
|
||||||
if (source[i] > 127) {
|
if (source[i] > 127) {
|
||||||
/* Cannot encode extended ASCII */
|
/* Cannot encode extended ASCII */
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data");
|
||||||
@ -364,7 +364,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
/* Then sends the buffer to the C39 function */
|
/* Then sends the buffer to the C39 function */
|
||||||
error_number = c39(symbol, buffer, ustrlen(buffer));
|
error_number = c39(symbol, buffer, ustrlen(buffer));
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < (unsigned int) length; i++)
|
||||||
symbol->text[i] = source[i] ? source[i] : ' ';
|
symbol->text[i] = source[i] ? source[i] : ' ';
|
||||||
symbol->text[length] = '\0';
|
symbol->text[length] = '\0';
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Code 93 is an advancement on Code 39 and the definition is a lot tighter */
|
/* Code 93 is an advancement on Code 39 and the definition is a lot tighter */
|
||||||
int c93(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int c93(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
|
|
||||||
/* SILVER includes the extra characters a, b, c and d to represent Code 93 specific
|
/* SILVER includes the extra characters a, b, c and d to represent Code 93 specific
|
||||||
shift characters 1, 2, 3 and 4 respectively. These characters are never used by
|
shift characters 1, 2, 3 and 4 respectively. These characters are never used by
|
||||||
|
@ -289,25 +289,25 @@ int c1_look_ahead_test(unsigned char source[], int sourcelen, int position, int
|
|||||||
|
|
||||||
if (sp == sourcelen) {
|
if (sp == sourcelen) {
|
||||||
/* Step K */
|
/* Step K */
|
||||||
best_count = edi_count;
|
best_count = (int)edi_count;
|
||||||
|
|
||||||
if (text_count <= best_count) {
|
if (text_count <= best_count) {
|
||||||
best_count = text_count;
|
best_count = (int)text_count;
|
||||||
best_scheme = C1_TEXT;
|
best_scheme = C1_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c40_count <= best_count) {
|
if (c40_count <= best_count) {
|
||||||
best_count = c40_count;
|
best_count = (int)c40_count;
|
||||||
best_scheme = C1_C40;
|
best_scheme = C1_C40;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ascii_count <= best_count) {
|
if (ascii_count <= best_count) {
|
||||||
best_count = ascii_count;
|
best_count = (int)ascii_count;
|
||||||
best_scheme = C1_ASCII;
|
best_scheme = C1_ASCII;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (byte_count <= best_count) {
|
if (byte_count <= best_count) {
|
||||||
best_count = byte_count;
|
best_count = (int)byte_count;
|
||||||
best_scheme = C1_BYTE;
|
best_scheme = C1_BYTE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1052,7 +1052,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
|
|
||||||
strcpy(temp_binary, "");
|
strcpy(temp_binary, "");
|
||||||
if (strlen(decimal_binary) > 24) {
|
if (strlen(decimal_binary) > 24) {
|
||||||
for (i = 0; i <= (strlen(decimal_binary) - 24); i++) {
|
for(i = 0; i <= (int)(strlen(decimal_binary) - 24); i++) {
|
||||||
temp_binary[i] = decimal_binary[i + 24];
|
temp_binary[i] = decimal_binary[i + 24];
|
||||||
}
|
}
|
||||||
strcpy(decimal_binary, temp_binary);
|
strcpy(decimal_binary, temp_binary);
|
||||||
|
@ -75,7 +75,7 @@ static const char *C128Table[107] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Determine appropriate mode for a given character */
|
/* Determine appropriate mode for a given character */
|
||||||
int parunmodd(unsigned char llyth) {
|
int parunmodd(const unsigned char llyth) {
|
||||||
int modd;
|
int modd;
|
||||||
modd = 0;
|
modd = 0;
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ void c128_set_b(unsigned char source, char dest[], int values[], int *bar_chars)
|
|||||||
/* Translate Code 128 Set C characters into barcodes
|
/* Translate Code 128 Set C characters into barcodes
|
||||||
* This set handles numbers in a compressed form
|
* This set handles numbers in a compressed form
|
||||||
*/
|
*/
|
||||||
void c128_set_c(unsigned char source_a, unsigned char source_b, char dest[], int values[], int *bar_chars) {
|
void c128_set_c(unsigned char source_a, unsigned char source_b, char dest[], int values[], int *bar_chars) {
|
||||||
int weight;
|
int weight;
|
||||||
|
|
||||||
weight = (10 * ctoi(source_a)) + ctoi(source_b);
|
weight = (10 * ctoi(source_a)) + ctoi(source_b);
|
||||||
@ -291,7 +291,7 @@ void c128_set_c(unsigned char source_a, unsigned char source_b, char dest[], int
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Handle Code 128 and NVE-18 */
|
/* Handle Code 128 and NVE-18 */
|
||||||
int code_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int code_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
int i, j, k, values[170] = {0}, bar_characters, read, total_sum;
|
int i, j, k, values[170] = {0}, bar_characters, read, total_sum;
|
||||||
int error_number, indexchaine, indexliste, sourcelen, f_state;
|
int error_number, indexchaine, indexliste, sourcelen, f_state;
|
||||||
char set[170] = {' '}, fset[170] = {' '}, mode, last_set, current_set = ' ';
|
char set[170] = {' '}, fset[170] = {' '}, mode, last_set, current_set = ' ';
|
||||||
@ -681,7 +681,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Handle EAN-128 (Now known as GS1-128) */
|
/* Handle EAN-128 (Now known as GS1-128) */
|
||||||
int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
int i, j, values[170], bar_characters, read, total_sum;
|
int i, j, values[170], bar_characters, read, total_sum;
|
||||||
int error_number, indexchaine, indexliste;
|
int error_number, indexchaine, indexliste;
|
||||||
char set[170], mode, last_set;
|
char set[170], mode, last_set;
|
||||||
@ -748,7 +748,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
list[1][indexliste] = mode;
|
list[1][indexliste] = mode;
|
||||||
while ((list[1][indexliste] == mode) && (indexchaine < strlen(reduced))) {
|
while ((list[1][indexliste] == mode) && (indexchaine < (int) strlen(reduced))) {
|
||||||
list[0][indexliste]++;
|
list[0][indexliste]++;
|
||||||
indexchaine++;
|
indexchaine++;
|
||||||
mode = parunmodd(reduced[indexchaine]);
|
mode = parunmodd(reduced[indexchaine]);
|
||||||
@ -757,7 +757,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
indexliste++;
|
indexliste++;
|
||||||
} while (indexchaine < strlen(reduced));
|
} while (indexchaine < (int) strlen(reduced));
|
||||||
|
|
||||||
dxsmooth(&indexliste);
|
dxsmooth(&indexliste);
|
||||||
|
|
||||||
@ -825,7 +825,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
being too long */
|
being too long */
|
||||||
last_set = ' ';
|
last_set = ' ';
|
||||||
glyph_count = 0.0;
|
glyph_count = 0.0;
|
||||||
for (i = 0; i < strlen(reduced); i++) {
|
for (i = 0; i < (int) strlen(reduced); i++) {
|
||||||
if ((set[i] == 'a') || (set[i] == 'b')) {
|
if ((set[i] == 'a') || (set[i] == 'b')) {
|
||||||
glyph_count = glyph_count + 1.0;
|
glyph_count = glyph_count + 1.0;
|
||||||
}
|
}
|
||||||
@ -919,7 +919,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
bar_characters++;
|
bar_characters++;
|
||||||
read++;
|
read++;
|
||||||
}
|
}
|
||||||
} while (read < strlen(reduced));
|
} while (read < (int) strlen(reduced));
|
||||||
|
|
||||||
/* "...note that the linkage flag is an extra code set character between
|
/* "...note that the linkage flag is an extra code set character between
|
||||||
the last data character and the Symbol Check Character" (GS1 Specification) */
|
the last data character and the Symbol Check Character" (GS1 Specification) */
|
||||||
|
@ -113,7 +113,7 @@ void grwp16(int *indexliste) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Implements rules from ISO 15417 Annex E */
|
/* Implements rules from ISO 15417 Annex E */
|
||||||
void dxsmooth16(int *indexliste) {
|
void dxsmooth16(int *indexliste) {
|
||||||
int i, current, last, next, length;
|
int i, current, last, next, length;
|
||||||
|
|
||||||
for (i = 0; i < *(indexliste); i++) {
|
for (i = 0; i < *(indexliste); i++) {
|
||||||
@ -285,7 +285,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
bar_characters = 0;
|
bar_characters = 0;
|
||||||
|
|
||||||
/* Detect extended ASCII characters */
|
/* Detect extended ASCII characters */
|
||||||
for (i = 0; i < input_length; i++) {
|
for (i = 0; i < (unsigned int) input_length; i++) {
|
||||||
if (source[i] >= 128) {
|
if (source[i] >= 128) {
|
||||||
fset[i] = 'f';
|
fset[i] = 'f';
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
fset[i] = '\0';
|
fset[i] = '\0';
|
||||||
|
|
||||||
/* Decide when to latch to extended mode */
|
/* Decide when to latch to extended mode */
|
||||||
for (i = 0; i < input_length; i++) {
|
for (i = 0; i < (unsigned int) input_length; i++) {
|
||||||
j = 0;
|
j = 0;
|
||||||
if (fset[i] == 'f') {
|
if (fset[i] == 'f') {
|
||||||
do {
|
do {
|
||||||
@ -309,10 +309,10 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
|
|
||||||
/* Decide if it is worth reverting to 646 encodation for a few characters */
|
/* Decide if it is worth reverting to 646 encodation for a few characters */
|
||||||
if (input_length > 1) {
|
if (input_length > 1) {
|
||||||
for (i = 1; i < input_length; i++) {
|
for (i = 1; i < (unsigned int) input_length; i++) {
|
||||||
if ((fset[i - 1] == 'F') && (fset[i] == ' ')) {
|
if ((fset[i - 1] == 'F') && (fset[i] == ' ')) {
|
||||||
/* Detected a change from 8859-1 to 646 - count how long for */
|
/* Detected a change from 8859-1 to 646 - count how long for */
|
||||||
for (j = 0; (fset[i + j] == ' ') && ((i + j) < input_length); j++);
|
for (j = 0; (fset[i + j] == ' ') && ((i + j) < (unsigned int) input_length); j++);
|
||||||
if ((j < 5) || ((j < 3) && ((i + j) == (input_length - 1)))) {
|
if ((j < 5) || ((j < 3) && ((i + j) == (input_length - 1)))) {
|
||||||
/* Change to shifting back rather than latching back */
|
/* Change to shifting back rather than latching back */
|
||||||
for (k = 0; k < j; k++) {
|
for (k = 0; k < j; k++) {
|
||||||
@ -543,7 +543,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
current_set = set[0];
|
current_set = set[0];
|
||||||
f_state = 0;
|
f_state = 0;
|
||||||
/* f_state remembers if we are in Extended ASCII mode (value 1) or
|
/* f_state remembers if we are in Extended ASCII mode (value 1) or
|
||||||
in ISO/IEC 646 mode (value 0) */
|
in ISO/IEC 646 mode (value 0) */
|
||||||
if (fset[0] == 'F') {
|
if (fset[0] == 'F') {
|
||||||
switch (current_set) {
|
switch (current_set) {
|
||||||
case 'A':
|
case 'A':
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
int code_49(struct zint_symbol *symbol, unsigned char source[], int length) {
|
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, h;
|
int i, j, rows, M, x_count, y_count, z_count, posn_val, local_value, h;
|
||||||
char intermediate[170];
|
char intermediate[170] = "";
|
||||||
int codewords[170], codeword_count;
|
int codewords[170], codeword_count;
|
||||||
int c_grid[8][8]; /* Refers to table 3 */
|
int c_grid[8][8]; /* Refers to table 3 */
|
||||||
int w_grid[8][4]; /* Refets to table 2 */
|
int w_grid[8][4]; /* Refets to table 2 */
|
||||||
@ -195,7 +195,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
} while (i < h);
|
} while (i < h);
|
||||||
|
|
||||||
switch (codewords[0]) {
|
switch (codewords[0]) {
|
||||||
/* Set starting mode value */
|
/* Set starting mode value */
|
||||||
case 48: M = 2;
|
case 48: M = 2;
|
||||||
break;
|
break;
|
||||||
case 43: M = 4;
|
case 43: M = 4;
|
||||||
|
@ -54,8 +54,8 @@ void ustrcpy(unsigned char target[], const unsigned char source[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Concatinates dest[] with the contents of source[], copying /0 as well */
|
/* Concatinates dest[] with the contents of source[], copying /0 as well */
|
||||||
void concat(char dest[], const char source[]) {
|
void concat(char dest[], const char source[]) {
|
||||||
unsigned int i, j, n;
|
size_t i, j, n;
|
||||||
|
|
||||||
j = strlen(dest);
|
j = strlen(dest);
|
||||||
n = strlen(source);
|
n = strlen(source);
|
||||||
@ -65,7 +65,7 @@ void concat(char dest[], const char source[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Concatinates dest[] with the contents of source[], copying /0 as well */
|
/* Concatinates dest[] with the contents of source[], copying /0 as well */
|
||||||
void uconcat(unsigned char dest[], const unsigned char source[]) {
|
void uconcat(unsigned char dest[], const unsigned char source[]) {
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
j = ustrlen(dest);
|
j = ustrlen(dest);
|
||||||
@ -75,14 +75,14 @@ void uconcat(unsigned char dest[], const unsigned char source[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Converts a character 0-9 to its equivalent integer value */
|
/* Converts a character 0-9 to its equivalent integer value */
|
||||||
int ctoi(char source) {
|
int ctoi(const char source) {
|
||||||
if ((source >= '0') && (source <= '9'))
|
if ((source >= '0') && (source <= '9'))
|
||||||
return (source - '0');
|
return (source - '0');
|
||||||
return (source - 'A' + 10);
|
return (source - 'A' + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Converts an integer value to its hexadecimal character */
|
/* Converts an integer value to its hexadecimal character */
|
||||||
char itoc(int source) {
|
char itoc(const int source) {
|
||||||
if ((source >= 0) && (source <= 9)) {
|
if ((source >= 0) && (source <= 9)) {
|
||||||
return ('0' + source);
|
return ('0' + source);
|
||||||
} else {
|
} else {
|
||||||
@ -91,7 +91,7 @@ char itoc(int source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Converts lower case characters to upper case in a string source[] */
|
/* Converts lower case characters to upper case in a string source[] */
|
||||||
void to_upper(unsigned char source[]) {
|
void to_upper(unsigned char source[]) {
|
||||||
unsigned int i, src_len = ustrlen(source);
|
unsigned int i, src_len = ustrlen(source);
|
||||||
|
|
||||||
for (i = 0; i < src_len; i++) {
|
for (i = 0; i < src_len; i++) {
|
||||||
@ -102,7 +102,7 @@ void to_upper(unsigned char source[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Verifies that a string only uses valid characters */
|
/* Verifies that a string only uses valid characters */
|
||||||
int is_sane(char test_string[], unsigned char source[], int length) {
|
int is_sane(char test_string[], const unsigned char source[], const int length) {
|
||||||
unsigned int i, j, latch;
|
unsigned int i, j, latch;
|
||||||
unsigned int lt = strlen(test_string);
|
unsigned int lt = strlen(test_string);
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ int is_sane(char test_string[], unsigned char source[], int length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the position of data in set_string */
|
/* Returns the position of data in set_string */
|
||||||
int posn(char set_string[], char data) {
|
int posn(char set_string[], const char data) {
|
||||||
unsigned int i, n = strlen(set_string);
|
unsigned int i, n = strlen(set_string);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
@ -135,7 +135,7 @@ int posn(char set_string[], char data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Replaces huge switch statements for looking up in tables */
|
/* Replaces huge switch statements for looking up in tables */
|
||||||
void lookup(char set_string[], const char *table[], char data, char dest[]) {
|
void lookup(char set_string[], const char *table[], const char data, char dest[]) {
|
||||||
unsigned int i, n = strlen(set_string);
|
unsigned int i, n = strlen(set_string);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
@ -146,22 +146,22 @@ void lookup(char set_string[], const char *table[], char data, char dest[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return true (1) if a module is dark/black, orherwise false (0) */
|
/* Return true (1) if a module is dark/black, orherwise false (0) */
|
||||||
int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord) {
|
int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
|
||||||
return (symbol->encoded_data[y_coord][x_coord / 7] >> (x_coord % 7)) & 1;
|
return (symbol->encoded_data[y_coord][x_coord / 7] >> (x_coord % 7)) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a module to dark/black */
|
/* Set a module to dark/black */
|
||||||
void set_module(struct zint_symbol *symbol, int y_coord, int x_coord) {
|
void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
|
||||||
symbol->encoded_data[y_coord][x_coord / 7] |= 1 << (x_coord % 7);
|
symbol->encoded_data[y_coord][x_coord / 7] |= 1 << (x_coord % 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set (or unset) a module to white */
|
/* Set (or unset) a module to white */
|
||||||
void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord) {
|
void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
|
||||||
symbol->encoded_data[y_coord][x_coord / 7] &= ~(1 << (x_coord % 7));
|
symbol->encoded_data[y_coord][x_coord / 7] &= ~(1 << (x_coord % 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expands from a width pattern to a bit pattern */
|
/* Expands from a width pattern to a bit pattern */
|
||||||
void expand(struct zint_symbol *symbol, char data[]) {
|
void expand(struct zint_symbol *symbol, char data[]) {
|
||||||
|
|
||||||
unsigned int reader, n = strlen(data);
|
unsigned int reader, n = strlen(data);
|
||||||
int writer, i;
|
int writer, i;
|
||||||
@ -231,7 +231,7 @@ int is_stackable(int symbology) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Indicates which symbols can have addon (EAN-2 and EAN-5) */
|
/* Indicates which symbols can have addon (EAN-2 and EAN-5) */
|
||||||
int is_extendable(int symbology) {
|
int is_extendable(const int symbology) {
|
||||||
if (symbology == BARCODE_EANX) {
|
if (symbology == BARCODE_EANX) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -257,21 +257,21 @@ int is_extendable(int symbology) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int roundup(float input) {
|
int roundup(const float input) {
|
||||||
float remainder;
|
float remainder;
|
||||||
int integer_part;
|
int integer_part;
|
||||||
|
|
||||||
integer_part = (int) input;
|
integer_part = (int) input;
|
||||||
remainder = input - integer_part;
|
remainder = input - integer_part;
|
||||||
|
|
||||||
if (remainder > 0.1) {
|
if (remainder > 0.1F) {
|
||||||
integer_part++;
|
integer_part++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return integer_part;
|
return integer_part;
|
||||||
}
|
}
|
||||||
|
|
||||||
int istwodigits(unsigned char source[], int position) {
|
int istwodigits(const unsigned char source[], const int position) {
|
||||||
if ((source[position] >= '0') && (source[position] <= '9')) {
|
if ((source[position] >= '0') && (source[position] <= '9')) {
|
||||||
if ((source[position + 1] >= '0') && (source[position + 1] <= '9')) {
|
if ((source[position + 1] >= '0') && (source[position + 1] <= '9')) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -281,8 +281,8 @@ int istwodigits(unsigned char source[], int position) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float froundup(float input) {
|
double froundup(const double input) {
|
||||||
float fraction, output = 0.0;
|
double fraction, output = 0.0;
|
||||||
|
|
||||||
fraction = input - (int) input;
|
fraction = input - (int) input;
|
||||||
if (fraction > 0.01) {
|
if (fraction > 0.01) {
|
||||||
@ -295,7 +295,7 @@ float froundup(float input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert Unicode to Latin-1 for those symbologies which only support Latin-1 */
|
/* Convert Unicode to Latin-1 for those symbologies which only support Latin-1 */
|
||||||
int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length) {
|
int latin1_process(struct zint_symbol *symbol, const unsigned char source[], unsigned char preprocessed[], int *length) {
|
||||||
int j, i, next;
|
int j, i, next;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
@ -330,7 +330,7 @@ int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[], int *length) {
|
int utf8toutf16(struct zint_symbol *symbol, const unsigned char source[], int vals[], int *length) {
|
||||||
int bpos, jpos, error_number;
|
int bpos, jpos, error_number;
|
||||||
int next;
|
int next;
|
||||||
|
|
||||||
|
@ -55,24 +55,24 @@ extern "C" {
|
|||||||
extern void ustrcpy(unsigned char target[], const unsigned char source[]);
|
extern void ustrcpy(unsigned char target[], const unsigned char source[]);
|
||||||
extern void concat(char dest[], const char source[]);
|
extern void concat(char dest[], const char source[]);
|
||||||
extern void uconcat(unsigned char dest[], const unsigned char source[]);
|
extern void uconcat(unsigned char dest[], const unsigned char source[]);
|
||||||
extern int ctoi(char source);
|
extern int ctoi(const char source);
|
||||||
extern char itoc(int source);
|
extern char itoc(const int source);
|
||||||
extern void to_upper(unsigned char source[]);
|
extern void to_upper(unsigned char source[]);
|
||||||
extern int is_sane(char test_string[], unsigned char source[], int length);
|
extern int is_sane(char test_string[], const unsigned char source[], const int length);
|
||||||
extern void lookup(char set_string[], const char *table[], char data, char dest[]);
|
extern void lookup(char set_string[], const char *table[], const char data, char dest[]);
|
||||||
extern int posn(char set_string[], char data);
|
extern int posn(char set_string[], const char data);
|
||||||
extern void expand(struct zint_symbol *symbol, char data[]);
|
extern void expand(struct zint_symbol *symbol, char data[]);
|
||||||
extern int is_stackable(int symbology);
|
extern int is_stackable(const int symbology);
|
||||||
extern int is_extendable(int symbology);
|
extern int is_extendable(const int symbology);
|
||||||
extern int roundup(float input);
|
extern int roundup(const float input);
|
||||||
extern int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord);
|
extern int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||||
extern void set_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
extern void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||||
extern void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
extern void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||||
extern int istwodigits(unsigned char source[], int position);
|
extern int istwodigits(const unsigned char source[], const int position);
|
||||||
extern float froundup(float input);
|
extern double froundup(const double input);
|
||||||
extern int parunmodd(unsigned char llyth);
|
extern int parunmodd(const unsigned char llyth);
|
||||||
extern int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length);
|
extern int latin1_process(struct zint_symbol *symbol, const unsigned char source[], unsigned char preprocessed[], int *length);
|
||||||
extern int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[], int *length);
|
extern int utf8toutf16(struct zint_symbol *symbol, const unsigned char source[], int vals[], int *length);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -129,7 +129,7 @@ int encode928(UINT bitString[], UINT codeWords[], int bitLng) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* CC-A 2D component */
|
/* CC-A 2D component */
|
||||||
int cc_a(struct zint_symbol *symbol, char source[], int cc_width) {
|
int cc_a(struct zint_symbol *symbol, char source[], int cc_width) {
|
||||||
int i, strpos, segment, bitlen, cwCnt, variant, rows;
|
int i, strpos, segment, bitlen, cwCnt, variant, rows;
|
||||||
int k, offset, j, total, rsCodeWords[8];
|
int k, offset, j, total, rsCodeWords[8];
|
||||||
int LeftRAPStart, RightRAPStart, CentreRAPStart, StartCluster;
|
int LeftRAPStart, RightRAPStart, CentreRAPStart, StartCluster;
|
||||||
@ -307,7 +307,7 @@ int cc_a(struct zint_symbol *symbol, char source[], int cc_width) {
|
|||||||
writer = 0;
|
writer = 0;
|
||||||
flip = 1;
|
flip = 1;
|
||||||
strcpy(pattern, "");
|
strcpy(pattern, "");
|
||||||
for (loop = 0; loop < strlen(codebarre); loop++) {
|
for (loop = 0; loop < (int) strlen(codebarre); loop++) {
|
||||||
if ((codebarre[loop] >= '0') && (codebarre[loop] <= '9')) {
|
if ((codebarre[loop] >= '0') && (codebarre[loop] <= '9')) {
|
||||||
for (k = 0; k < ctoi(codebarre[loop]); k++) {
|
for (k = 0; k < ctoi(codebarre[loop]); k++) {
|
||||||
if (flip == 0) {
|
if (flip == 0) {
|
||||||
@ -331,7 +331,7 @@ int cc_a(struct zint_symbol *symbol, char source[], int cc_width) {
|
|||||||
symbol->width = writer;
|
symbol->width = writer;
|
||||||
|
|
||||||
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
|
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
|
||||||
for (loop = 0; loop < strlen(pattern); loop++) {
|
for (loop = 0; loop < (int) strlen(pattern); loop++) {
|
||||||
if (pattern[loop] == '1') {
|
if (pattern[loop] == '1') {
|
||||||
set_module(symbol, i, loop);
|
set_module(symbol, i, loop);
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ int cc_a(struct zint_symbol *symbol, char source[], int cc_width) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* CC-B 2D component */
|
/* CC-B 2D component */
|
||||||
int cc_b(struct zint_symbol *symbol, char source[], int cc_width) {
|
int cc_b(struct zint_symbol *symbol, char source[], int cc_width) {
|
||||||
int length, i, binloc;
|
int length, i, binloc;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
unsigned char data_string[(strlen(source) / 8) + 3];
|
unsigned char data_string[(strlen(source) / 8) + 3];
|
||||||
@ -591,7 +591,7 @@ int cc_b(struct zint_symbol *symbol, char source[], int cc_width) {
|
|||||||
writer = 0;
|
writer = 0;
|
||||||
flip = 1;
|
flip = 1;
|
||||||
strcpy(pattern, "");
|
strcpy(pattern, "");
|
||||||
for (loop = 0; loop < strlen(codebarre); loop++) {
|
for (loop = 0; loop < (int) strlen(codebarre); loop++) {
|
||||||
if ((codebarre[loop] >= '0') && (codebarre[loop] <= '9')) {
|
if ((codebarre[loop] >= '0') && (codebarre[loop] <= '9')) {
|
||||||
for (k = 0; k < ctoi(codebarre[loop]); k++) {
|
for (k = 0; k < ctoi(codebarre[loop]); k++) {
|
||||||
if (flip == 0) {
|
if (flip == 0) {
|
||||||
@ -615,7 +615,7 @@ int cc_b(struct zint_symbol *symbol, char source[], int cc_width) {
|
|||||||
symbol->width = writer;
|
symbol->width = writer;
|
||||||
|
|
||||||
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
|
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
|
||||||
for (loop = 0; loop < strlen(pattern); loop++) {
|
for (loop = 0; loop < (int) strlen(pattern); loop++) {
|
||||||
if (pattern[loop] == '1') {
|
if (pattern[loop] == '1') {
|
||||||
set_module(symbol, i, loop);
|
set_module(symbol, i, loop);
|
||||||
}
|
}
|
||||||
@ -646,7 +646,7 @@ int cc_b(struct zint_symbol *symbol, char source[], int cc_width) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* CC-C 2D component - byte compressed PDF417 */
|
/* CC-C 2D component - byte compressed PDF417 */
|
||||||
int cc_c(struct zint_symbol *symbol, char source[], int cc_width, int ecc_level) {
|
int cc_c(struct zint_symbol *symbol, char source[], int cc_width, int ecc_level) {
|
||||||
int length, i, p, binloc;
|
int length, i, p, binloc;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
unsigned char data_string[(strlen(source) / 8) + 4];
|
unsigned char data_string[(strlen(source) / 8) + 4];
|
||||||
@ -765,12 +765,12 @@ int cc_c(struct zint_symbol *symbol, char source[], int cc_width, int ecc_level)
|
|||||||
|
|
||||||
for (j = 0; j <= cc_width + 1; j++) {
|
for (j = 0; j <= cc_width + 1; j++) {
|
||||||
switch (i % 3) {
|
switch (i % 3) {
|
||||||
case 1: offset = 929; /* cluster(3) */
|
case 1: offset = 929; /* cluster(3) */
|
||||||
break;
|
break;
|
||||||
case 2: offset = 1858; /* cluster(6) */
|
case 2: offset = 1858; /* cluster(6) */
|
||||||
break;
|
break;
|
||||||
default: offset = 0; /* cluster(0) */
|
default: offset = 0; /* cluster(0) */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
concat(codebarre, codagemc[offset + dummy[j]]);
|
concat(codebarre, codagemc[offset + dummy[j]]);
|
||||||
concat(codebarre, "*");
|
concat(codebarre, "*");
|
||||||
@ -778,10 +778,10 @@ int cc_c(struct zint_symbol *symbol, char source[], int cc_width, int ecc_level)
|
|||||||
concat(codebarre, "-");
|
concat(codebarre, "-");
|
||||||
|
|
||||||
strcpy(pattern, "");
|
strcpy(pattern, "");
|
||||||
for (loop = 0; loop < strlen(codebarre); loop++) {
|
for (loop = 0; loop < (int) strlen(codebarre); loop++) {
|
||||||
lookup(BRSET, PDFttf, codebarre[loop], pattern);
|
lookup(BRSET, PDFttf, codebarre[loop], pattern);
|
||||||
}
|
}
|
||||||
for (loop = 0; loop < strlen(pattern); loop++) {
|
for (loop = 0; loop < (int) strlen(pattern); loop++) {
|
||||||
if (pattern[loop] == '1') {
|
if (pattern[loop] == '1') {
|
||||||
set_module(symbol, i, loop);
|
set_module(symbol, i, loop);
|
||||||
}
|
}
|
||||||
@ -914,7 +914,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
|
|||||||
alphanum = 0;
|
alphanum = 0;
|
||||||
numeric = 0;
|
numeric = 0;
|
||||||
|
|
||||||
for (i = 0; i < strlen(ninety); i++) {
|
for (i = 0; i < (int) strlen(ninety); i++) {
|
||||||
|
|
||||||
if ((ninety[i] >= 'A') && (ninety[i] <= 'Z')) {
|
if ((ninety[i] >= 'A') && (ninety[i] <= 'Z')) {
|
||||||
/* Character is alphabetic */
|
/* Character is alphabetic */
|
||||||
@ -1217,7 +1217,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = read_posn; i < strlen(source); i++) {
|
for (i = read_posn; i < (int) strlen(source); i++) {
|
||||||
general_field[j] = source[i];
|
general_field[j] = source[i];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@ -1228,7 +1228,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
|
|||||||
}
|
}
|
||||||
|
|
||||||
latch = 0;
|
latch = 0;
|
||||||
for (i = 0; i < strlen(general_field); i++) {
|
for (i = 0; i < (int) strlen(general_field); i++) {
|
||||||
/* Table 13 - ISO/IEC 646 encodation */
|
/* Table 13 - ISO/IEC 646 encodation */
|
||||||
if ((general_field[i] < ' ') || (general_field[i] > 'z')) {
|
if ((general_field[i] < ' ') || (general_field[i] > 'z')) {
|
||||||
general_field_type[i] = INVALID_CHAR;
|
general_field_type[i] = INVALID_CHAR;
|
||||||
@ -1301,13 +1301,13 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
|
|||||||
return ZINT_ERROR_INVALID_DATA;
|
return ZINT_ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < strlen(general_field); i++) {
|
for (i = 0; i < (int) strlen(general_field); i++) {
|
||||||
if ((general_field_type[i] == ISOIEC) && (general_field[i + 1] == '[')) {
|
if ((general_field_type[i] == ISOIEC) && (general_field[i + 1] == '[')) {
|
||||||
general_field_type[i + 1] = ISOIEC;
|
general_field_type[i + 1] = ISOIEC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < strlen(general_field); i++) {
|
for (i = 0; i < (int) strlen(general_field); i++) {
|
||||||
if ((general_field_type[i] == ALPHA_OR_ISO) && (general_field[i + 1] == '[')) {
|
if ((general_field_type[i] == ALPHA_OR_ISO) && (general_field[i + 1] == '[')) {
|
||||||
general_field_type[i + 1] = ALPHA_OR_ISO;
|
general_field_type[i + 1] = ALPHA_OR_ISO;
|
||||||
}
|
}
|
||||||
@ -1487,7 +1487,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
|
|||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (i + latch < strlen(general_field));
|
} while (i + latch < (int) strlen(general_field));
|
||||||
|
|
||||||
binary_length = strlen(binary_string);
|
binary_length = strlen(binary_string);
|
||||||
if (cc_mode == 1) {
|
if (cc_mode == 1) {
|
||||||
@ -2031,11 +2031,11 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar
|
|||||||
concat(binary_string, "0000");
|
concat(binary_string, "0000");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (strlen(binary_string) < target_bitsize) {
|
while (strlen(binary_string) < (unsigned int) target_bitsize) {
|
||||||
concat(binary_string, "00100");
|
concat(binary_string, "00100");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(binary_string) > target_bitsize) {
|
if (strlen(binary_string) > (unsigned int) target_bitsize) {
|
||||||
binary_string[target_bitsize] = '\0';
|
binary_string[target_bitsize] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2244,7 +2244,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (cc_mode) {
|
switch (cc_mode) {
|
||||||
/* Note that ecc_level is only relevant to CC-C */
|
/* Note that ecc_level is only relevant to CC-C */
|
||||||
case 1: error_number = cc_a(symbol, binary_string, cc_width);
|
case 1: error_number = cc_a(symbol, binary_string, cc_width);
|
||||||
break;
|
break;
|
||||||
case 2: error_number = cc_b(symbol, binary_string, cc_width);
|
case 2: error_number = cc_b(symbol, binary_string, cc_width);
|
||||||
|
@ -51,8 +51,8 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "dmatrix.h"
|
#include "dmatrix.h"
|
||||||
|
|
||||||
// Annex M placement alorithm low level
|
/* Annex M placement alorithm low level */
|
||||||
static void ecc200placementbit(int *array, int NR, int NC, int r, int c, int p, char b) {
|
static void ecc200placementbit(int *array, const int NR, const int NC, int r, int c, const int p, const char b) {
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
r += NR;
|
r += NR;
|
||||||
c += 4 - ((NR + 4) % 8);
|
c += 4 - ((NR + 4) % 8);
|
||||||
@ -86,7 +86,8 @@ static void ecc200placementbit(int *array, int NR, int NC, int r, int c, int p,
|
|||||||
array[r * NC + c] = (p << 3) + b;
|
array[r * NC + c] = (p << 3) + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ecc200placementblock(int *array, int NR, int NC, int r, int c, int p) {
|
static void ecc200placementblock(int *array, const int NR, const int NC, const int r,
|
||||||
|
const int c, const int p) {
|
||||||
ecc200placementbit(array, NR, NC, r - 2, c - 2, p, 7);
|
ecc200placementbit(array, NR, NC, r - 2, c - 2, p, 7);
|
||||||
ecc200placementbit(array, NR, NC, r - 2, c - 1, p, 6);
|
ecc200placementbit(array, NR, NC, r - 2, c - 1, p, 6);
|
||||||
ecc200placementbit(array, NR, NC, r - 1, c - 2, p, 5);
|
ecc200placementbit(array, NR, NC, r - 1, c - 2, p, 5);
|
||||||
@ -97,7 +98,7 @@ static void ecc200placementblock(int *array, int NR, int NC, int r, int c, int p
|
|||||||
ecc200placementbit(array, NR, NC, r - 0, c - 0, p, 0);
|
ecc200placementbit(array, NR, NC, r - 0, c - 0, p, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ecc200placementcornerA(int *array, int NR, int NC, int p) {
|
static void ecc200placementcornerA(int *array, const int NR, const int NC, const int p) {
|
||||||
ecc200placementbit(array, NR, NC, NR - 1, 0, p, 7);
|
ecc200placementbit(array, NR, NC, NR - 1, 0, p, 7);
|
||||||
ecc200placementbit(array, NR, NC, NR - 1, 1, p, 6);
|
ecc200placementbit(array, NR, NC, NR - 1, 1, p, 6);
|
||||||
ecc200placementbit(array, NR, NC, NR - 1, 2, p, 5);
|
ecc200placementbit(array, NR, NC, NR - 1, 2, p, 5);
|
||||||
@ -108,7 +109,7 @@ static void ecc200placementcornerA(int *array, int NR, int NC, int p) {
|
|||||||
ecc200placementbit(array, NR, NC, 3, NC - 1, p, 0);
|
ecc200placementbit(array, NR, NC, 3, NC - 1, p, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ecc200placementcornerB(int *array, int NR, int NC, int p) {
|
static void ecc200placementcornerB(int *array, const int NR, const int NC, const int p) {
|
||||||
ecc200placementbit(array, NR, NC, NR - 3, 0, p, 7);
|
ecc200placementbit(array, NR, NC, NR - 3, 0, p, 7);
|
||||||
ecc200placementbit(array, NR, NC, NR - 2, 0, p, 6);
|
ecc200placementbit(array, NR, NC, NR - 2, 0, p, 6);
|
||||||
ecc200placementbit(array, NR, NC, NR - 1, 0, p, 5);
|
ecc200placementbit(array, NR, NC, NR - 1, 0, p, 5);
|
||||||
@ -119,7 +120,7 @@ static void ecc200placementcornerB(int *array, int NR, int NC, int p) {
|
|||||||
ecc200placementbit(array, NR, NC, 1, NC - 1, p, 0);
|
ecc200placementbit(array, NR, NC, 1, NC - 1, p, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ecc200placementcornerC(int *array, int NR, int NC, int p) {
|
static void ecc200placementcornerC(int *array, const int NR, const int NC, const int p) {
|
||||||
ecc200placementbit(array, NR, NC, NR - 3, 0, p, 7);
|
ecc200placementbit(array, NR, NC, NR - 3, 0, p, 7);
|
||||||
ecc200placementbit(array, NR, NC, NR - 2, 0, p, 6);
|
ecc200placementbit(array, NR, NC, NR - 2, 0, p, 6);
|
||||||
ecc200placementbit(array, NR, NC, NR - 1, 0, p, 5);
|
ecc200placementbit(array, NR, NC, NR - 1, 0, p, 5);
|
||||||
@ -130,7 +131,7 @@ static void ecc200placementcornerC(int *array, int NR, int NC, int p) {
|
|||||||
ecc200placementbit(array, NR, NC, 3, NC - 1, p, 0);
|
ecc200placementbit(array, NR, NC, 3, NC - 1, p, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ecc200placementcornerD(int *array, int NR, int NC, int p) {
|
static void ecc200placementcornerD(int *array, const int NR, const int NC, const int p) {
|
||||||
ecc200placementbit(array, NR, NC, NR - 1, 0, p, 7);
|
ecc200placementbit(array, NR, NC, NR - 1, 0, p, 7);
|
||||||
ecc200placementbit(array, NR, NC, NR - 1, NC - 1, p, 6);
|
ecc200placementbit(array, NR, NC, NR - 1, NC - 1, p, 6);
|
||||||
ecc200placementbit(array, NR, NC, 0, NC - 3, p, 5);
|
ecc200placementbit(array, NR, NC, 0, NC - 3, p, 5);
|
||||||
@ -141,8 +142,8 @@ static void ecc200placementcornerD(int *array, int NR, int NC, int p) {
|
|||||||
ecc200placementbit(array, NR, NC, 1, NC - 1, p, 0);
|
ecc200placementbit(array, NR, NC, 1, NC - 1, p, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Annex M placement alorithm main function
|
/* Annex M placement alorithm main function */
|
||||||
static void ecc200placement(int *array, int NR, int NC) {
|
static void ecc200placement(int *array, const int NR, const int NC) {
|
||||||
int r, c, p;
|
int r, c, p;
|
||||||
// invalidate
|
// invalidate
|
||||||
for (r = 0; r < NR; r++)
|
for (r = 0; r < NR; r++)
|
||||||
@ -186,8 +187,8 @@ static void ecc200placement(int *array, int NR, int NC) {
|
|||||||
array[NR * NC - 1] = array[NR * NC - NC - 2] = 1;
|
array[NR * NC - 1] = array[NR * NC - NC - 2] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate and append ecc code, and if necessary interleave
|
/* calculate and append ecc code, and if necessary interleave */
|
||||||
static void ecc200(unsigned char *binary, int bytes, int datablock, int rsblock, int skew) {
|
static void ecc200(unsigned char *binary, const int bytes, const int datablock, const int rsblock, const int skew) {
|
||||||
int blocks = (bytes + 2) / datablock, b;
|
int blocks = (bytes + 2) / datablock, b;
|
||||||
int n, p;
|
int n, p;
|
||||||
rs_init_gf(0x12d);
|
rs_init_gf(0x12d);
|
||||||
@ -217,7 +218,7 @@ static void ecc200(unsigned char *binary, int bytes, int datablock, int rsblock,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return true (1) if a character is valid in X12 set */
|
/* Return true (1) if a character is valid in X12 set */
|
||||||
int isX12(unsigned char source) {
|
static int isX12(const int source) {
|
||||||
if (source == 13) {
|
if (source == 13) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -241,17 +242,17 @@ int isX12(unsigned char source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Insert a character into the middle of a string at position posn */
|
/* Insert a character into the middle of a string at position posn */
|
||||||
void dminsert(char binary_string[], int posn, char newbit) {
|
static void dminsert(char binary_string[], const int posn, const char newbit) {
|
||||||
int i, end;
|
int i, end;
|
||||||
|
|
||||||
end = strlen(binary_string);
|
end = (int) strlen(binary_string);
|
||||||
for (i = end; i > posn; i--) {
|
for (i = end; i > posn; i--) {
|
||||||
binary_string[i] = binary_string[i - 1];
|
binary_string[i] = binary_string[i - 1];
|
||||||
}
|
}
|
||||||
binary_string[posn] = newbit;
|
binary_string[posn] = newbit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert_value(unsigned char binary_stream[], int posn, int streamlen, char newbit) {
|
static void insert_value(unsigned char binary_stream[], const int posn, const int streamlen, const int newbit) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = streamlen; i > posn; i--) {
|
for (i = streamlen; i > posn; i--) {
|
||||||
@ -260,7 +261,7 @@ void insert_value(unsigned char binary_stream[], int posn, int streamlen, char n
|
|||||||
binary_stream[posn] = newbit;
|
binary_stream[posn] = newbit;
|
||||||
}
|
}
|
||||||
|
|
||||||
int p_r_6_2_1(unsigned char inputData[], int position, int sourcelen) {
|
int p_r_6_2_1(const unsigned char inputData[], int position, const int sourcelen) {
|
||||||
/* Annex P section (r)(6)(ii)(I)
|
/* Annex P section (r)(6)(ii)(I)
|
||||||
"If one of the three X12 terminator/separator characters first
|
"If one of the three X12 terminator/separator characters first
|
||||||
occurs in the yet to be processed data before a non-X12 character..."
|
occurs in the yet to be processed data before a non-X12 character..."
|
||||||
@ -297,7 +298,7 @@ int p_r_6_2_1(unsigned char inputData[], int position, int sourcelen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 'look ahead test' from Annex P */
|
/* 'look ahead test' from Annex P */
|
||||||
int look_ahead_test(unsigned char inputData[], int sourcelen, int position, int current_mode, 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;
|
float ascii_count, c40_count, text_count, x12_count, edf_count, b256_count, best_count;
|
||||||
int sp, best_scheme;
|
int sp, best_scheme;
|
||||||
|
|
||||||
@ -338,12 +339,12 @@ int look_ahead_test(unsigned char inputData[], int sourcelen, int position, int
|
|||||||
do {
|
do {
|
||||||
if (sp == (sourcelen - 1)) {
|
if (sp == (sourcelen - 1)) {
|
||||||
/* At the end of data ... step (k) */
|
/* At the end of data ... step (k) */
|
||||||
ascii_count = ceil(ascii_count);
|
ascii_count = ceilf(ascii_count);
|
||||||
b256_count = ceil(b256_count);
|
b256_count = ceilf(b256_count);
|
||||||
edf_count = ceil(edf_count);
|
edf_count = ceilf(edf_count);
|
||||||
text_count = ceil(text_count);
|
text_count = ceilf(text_count);
|
||||||
x12_count = ceil(x12_count);
|
x12_count = ceilf(x12_count);
|
||||||
c40_count = ceil(c40_count);
|
c40_count = ceilf(c40_count);
|
||||||
|
|
||||||
best_count = c40_count;
|
best_count = c40_count;
|
||||||
best_scheme = DM_C40; // (k)(7)
|
best_scheme = DM_C40; // (k)(7)
|
||||||
@ -375,12 +376,12 @@ int look_ahead_test(unsigned char inputData[], int sourcelen, int position, int
|
|||||||
|
|
||||||
/* ascii ... step (l) */
|
/* ascii ... step (l) */
|
||||||
if ((inputData[sp] >= '0') && (inputData[sp] <= '9')) {
|
if ((inputData[sp] >= '0') && (inputData[sp] <= '9')) {
|
||||||
ascii_count += 0.5; // (l)(1)
|
ascii_count += 0.5F; // (l)(1)
|
||||||
} else {
|
} else {
|
||||||
if (inputData[sp] > 127) {
|
if (inputData[sp] > 127) {
|
||||||
ascii_count = ceil(ascii_count) + 2.0; // (l)(2)
|
ascii_count = ceilf(ascii_count) + 2.0F; // (l)(2)
|
||||||
} else {
|
} else {
|
||||||
ascii_count = ceil(ascii_count) + 1.0; // (l)(3)
|
ascii_count = ceilf(ascii_count) + 1.0F; // (l)(3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,12 +389,12 @@ int look_ahead_test(unsigned char inputData[], int sourcelen, int position, int
|
|||||||
if ((inputData[sp] == ' ') ||
|
if ((inputData[sp] == ' ') ||
|
||||||
(((inputData[sp] >= '0') && (inputData[sp] <= '9')) ||
|
(((inputData[sp] >= '0') && (inputData[sp] <= '9')) ||
|
||||||
((inputData[sp] >= 'A') && (inputData[sp] <= 'Z')))) {
|
((inputData[sp] >= 'A') && (inputData[sp] <= 'Z')))) {
|
||||||
c40_count += (2.0 / 3.0); // (m)(1)
|
c40_count += (2.0F / 3.0F); // (m)(1)
|
||||||
} else {
|
} else {
|
||||||
if (inputData[sp] > 127) {
|
if (inputData[sp] > 127) {
|
||||||
c40_count += (8.0 / 3.0); // (m)(2)
|
c40_count += (8.0F / 3.0F); // (m)(2)
|
||||||
} else {
|
} else {
|
||||||
c40_count += (4.0 / 3.0); // (m)(3)
|
c40_count += (4.0F / 3.0F); // (m)(3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,45 +402,45 @@ int look_ahead_test(unsigned char inputData[], int sourcelen, int position, int
|
|||||||
if ((inputData[sp] == ' ') ||
|
if ((inputData[sp] == ' ') ||
|
||||||
(((inputData[sp] >= '0') && (inputData[sp] <= '9')) ||
|
(((inputData[sp] >= '0') && (inputData[sp] <= '9')) ||
|
||||||
((inputData[sp] >= 'a') && (inputData[sp] <= 'z')))) {
|
((inputData[sp] >= 'a') && (inputData[sp] <= 'z')))) {
|
||||||
text_count += (2.0 / 3.0); // (n)(1)
|
text_count += (2.0F / 3.0F); // (n)(1)
|
||||||
} else {
|
} else {
|
||||||
if (inputData[sp] > 127) {
|
if (inputData[sp] > 127) {
|
||||||
text_count += (8.0 / 3.0); // (n)(2)
|
text_count += (8.0F / 3.0F); // (n)(2)
|
||||||
} else {
|
} else {
|
||||||
text_count += (4.0 / 3.0); // (n)(3)
|
text_count += (4.0F / 3.0F); // (n)(3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* x12 ... step (o) */
|
/* x12 ... step (o) */
|
||||||
if (isX12(inputData[sp])) {
|
if (isX12(inputData[sp])) {
|
||||||
x12_count += (2.0 / 3.0); // (o)(1)
|
x12_count += (2.0F / 3.0F); // (o)(1)
|
||||||
} else {
|
} else {
|
||||||
if (inputData[sp] > 127) {
|
if (inputData[sp] > 127) {
|
||||||
x12_count += (13.0 / 3.0); // (o)(2)
|
x12_count += (13.0F / 3.0F); // (o)(2)
|
||||||
} else {
|
} else {
|
||||||
x12_count += (10.0 / 3.0); // (o)(3)
|
x12_count += (10.0F / 3.0F); // (o)(3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* edifact ... step (p) */
|
/* edifact ... step (p) */
|
||||||
if ((inputData[sp] >= ' ') && (inputData[sp] <= '^')) {
|
if ((inputData[sp] >= ' ') && (inputData[sp] <= '^')) {
|
||||||
edf_count += (3.0 / 4.0); // (p)(1)
|
edf_count += (3.0F / 4.0F); // (p)(1)
|
||||||
} else {
|
} else {
|
||||||
if (inputData[sp] > 127) {
|
if (inputData[sp] > 127) {
|
||||||
edf_count += (17.0 / 4.0); // (p)(2)
|
edf_count += (17.0F / 4.0F); // (p)(2)
|
||||||
} else {
|
} else {
|
||||||
edf_count += (13.0 / 4.0); // (p)(3)
|
edf_count += (13.0F / 4.0F); // (p)(3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((gs1 == 1) && (inputData[sp] == '[')) {
|
if ((gs1 == 1) && (inputData[sp] == '[')) {
|
||||||
edf_count += 6.0;
|
edf_count += 6.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* base 256 ... step (q) */
|
/* base 256 ... step (q) */
|
||||||
if ((gs1 == 1) && (inputData[sp] == '[')) {
|
if ((gs1 == 1) && (inputData[sp] == '[')) {
|
||||||
b256_count += 4.0; // (q)(1)
|
b256_count += 4.0F; // (q)(1)
|
||||||
} else {
|
} else {
|
||||||
b256_count += 1.0; // (q)(2)
|
b256_count += 1.0F; // (q)(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,10 +449,10 @@ int look_ahead_test(unsigned char inputData[], int sourcelen, int position, int
|
|||||||
/* 4 data characters processed ... step (r) */
|
/* 4 data characters processed ... step (r) */
|
||||||
|
|
||||||
/* step (r)(6) */
|
/* step (r)(6) */
|
||||||
if (((c40_count + 1.0) < ascii_count) &&
|
if (((c40_count + 1.0F) < ascii_count) &&
|
||||||
((c40_count + 1.0) < b256_count) &&
|
((c40_count + 1.0F) < b256_count) &&
|
||||||
((c40_count + 1.0) < edf_count) &&
|
((c40_count + 1.0F) < edf_count) &&
|
||||||
((c40_count + 1.0) < text_count)) {
|
((c40_count + 1.0F) < text_count)) {
|
||||||
|
|
||||||
if (c40_count < x12_count) {
|
if (c40_count < x12_count) {
|
||||||
best_scheme = DM_C40;
|
best_scheme = DM_C40;
|
||||||
@ -468,47 +469,47 @@ int look_ahead_test(unsigned char inputData[], int sourcelen, int position, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* step (r)(5) */
|
/* step (r)(5) */
|
||||||
if (((x12_count + 1.0) < ascii_count) &&
|
if (((x12_count + 1.0F) < ascii_count) &&
|
||||||
((x12_count + 1.0) < b256_count) &&
|
((x12_count + 1.0F) < b256_count) &&
|
||||||
((x12_count + 1.0) < edf_count) &&
|
((x12_count + 1.0F) < edf_count) &&
|
||||||
((x12_count + 1.0) < text_count) &&
|
((x12_count + 1.0F) < text_count) &&
|
||||||
((x12_count + 1.0) < c40_count)) {
|
((x12_count + 1.0F) < c40_count)) {
|
||||||
best_scheme = DM_X12;
|
best_scheme = DM_X12;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* step (r)(4) */
|
/* step (r)(4) */
|
||||||
if (((text_count + 1.0) < ascii_count) &&
|
if (((text_count + 1.0F) < ascii_count) &&
|
||||||
((text_count + 1.0) < b256_count) &&
|
((text_count + 1.0F) < b256_count) &&
|
||||||
((text_count + 1.0) < edf_count) &&
|
((text_count + 1.0F) < edf_count) &&
|
||||||
((text_count + 1.0) < x12_count) &&
|
((text_count + 1.0F) < x12_count) &&
|
||||||
((text_count + 1.0) < c40_count)) {
|
((text_count + 1.0F) < c40_count)) {
|
||||||
best_scheme = DM_TEXT;
|
best_scheme = DM_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* step (r)(3) */
|
/* step (r)(3) */
|
||||||
if (((edf_count + 1.0) < ascii_count) &&
|
if (((edf_count + 1.0F) < ascii_count) &&
|
||||||
((edf_count + 1.0) < b256_count) &&
|
((edf_count + 1.0F) < b256_count) &&
|
||||||
((edf_count + 1.0) < text_count) &&
|
((edf_count + 1.0F) < text_count) &&
|
||||||
((edf_count + 1.0) < x12_count) &&
|
((edf_count + 1.0F) < x12_count) &&
|
||||||
((edf_count + 1.0) < c40_count)) {
|
((edf_count + 1.0F) < c40_count)) {
|
||||||
best_scheme = DM_EDIFACT;
|
best_scheme = DM_EDIFACT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* step (r)(2) */
|
/* step (r)(2) */
|
||||||
if (((b256_count + 1.0) <= ascii_count) ||
|
if (((b256_count + 1.0F) <= ascii_count) ||
|
||||||
(((b256_count + 1.0) < edf_count) &&
|
(((b256_count + 1.0F) < edf_count) &&
|
||||||
((b256_count + 1.0) < text_count) &&
|
((b256_count + 1.0F) < text_count) &&
|
||||||
((b256_count + 1.0) < x12_count) &&
|
((b256_count + 1.0F) < x12_count) &&
|
||||||
((b256_count + 1.0) < c40_count))) {
|
((b256_count + 1.0F) < c40_count))) {
|
||||||
best_scheme = DM_BASE256;
|
best_scheme = DM_BASE256;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* step (r)(1) */
|
/* step (r)(1) */
|
||||||
if (((ascii_count + 1.0) <= b256_count) &&
|
if (((ascii_count + 1.0F) <= b256_count) &&
|
||||||
((ascii_count + 1.0) <= edf_count) &&
|
((ascii_count + 1.0F) <= edf_count) &&
|
||||||
((ascii_count + 1.0) <= text_count) &&
|
((ascii_count + 1.0F) <= text_count) &&
|
||||||
((ascii_count + 1.0) <= x12_count) &&
|
((ascii_count + 1.0F) <= x12_count) &&
|
||||||
((ascii_count + 1.0) <= c40_count)) {
|
((ascii_count + 1.0F) <= c40_count)) {
|
||||||
best_scheme = DM_ASCII;
|
best_scheme = DM_ASCII;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1001,8 +1002,7 @@ int dm200encode_remainder(unsigned char target[], int target_length, unsigned ch
|
|||||||
{
|
{
|
||||||
target[target_length] = source[inputlen - 1] + 1;
|
target[target_length] = source[inputlen - 1] + 1;
|
||||||
target_length++;
|
target_length++;
|
||||||
}
|
} else if (process_p == 2) {
|
||||||
else if (process_p == 2) {
|
|
||||||
target[target_length] = source[inputlen - 2] + 1;
|
target[target_length] = source[inputlen - 2] + 1;
|
||||||
target_length++;
|
target_length++;
|
||||||
target[target_length] = source[inputlen - 1] + 1;
|
target[target_length] = source[inputlen - 1] + 1;
|
||||||
@ -1079,8 +1079,7 @@ int dm200encode_remainder(unsigned char target[], int target_length, unsigned ch
|
|||||||
if (symbols_left < 3) {
|
if (symbols_left < 3) {
|
||||||
target[target_length] = 31;
|
target[target_length] = 31;
|
||||||
target_length++;
|
target_length++;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
target[target_length] = (31 << 2);
|
target[target_length] = (31 << 2);
|
||||||
target_length++;
|
target_length++;
|
||||||
|
|
||||||
@ -1179,17 +1178,17 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (symbol->option_3 == DM_SQUARE) {
|
if (symbol->option_3 == DM_SQUARE) {
|
||||||
/* Skip rectangular symbols in square only mode */
|
/* Skip rectangular symbols in square only mode */
|
||||||
while (matrixH[calcsize] != matrixW[calcsize]) {
|
while (matrixH[calcsize] != matrixW[calcsize]) {
|
||||||
calcsize++;
|
calcsize++;
|
||||||
}
|
}
|
||||||
} else if (symbol->option_3 != DM_DMRE) {
|
} else if (symbol->option_3 != DM_DMRE) {
|
||||||
/* Skip DMRE symbols */
|
/* Skip DMRE symbols */
|
||||||
while (isDMRE[calcsize]) {
|
while (isDMRE[calcsize]) {
|
||||||
calcsize++;
|
calcsize++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolsize = optionsize;
|
symbolsize = optionsize;
|
||||||
if (calcsize > optionsize) {
|
if (calcsize > optionsize) {
|
||||||
symbolsize = calcsize;
|
symbolsize = calcsize;
|
||||||
@ -1297,7 +1296,7 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int dmatrix(struct zint_symbol *symbol, unsigned char source[], const int length) {
|
||||||
int error_number;
|
int error_number;
|
||||||
|
|
||||||
if (symbol->option_1 <= 1) {
|
if (symbol->option_1 <= 1) {
|
||||||
|
@ -312,9 +312,9 @@ int seek_forward(int gbdata[], int length, int position, int current_mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add the length indicator for byte encoded blocks */
|
/* Add the length indicator for byte encoded blocks */
|
||||||
void add_byte_count(char binary[], int byte_count_posn, int byte_count) {
|
static void add_byte_count(char binary[], const size_t byte_count_posn, const int byte_count) {
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
for (p = 0; p < 8; p++) {
|
for (p = 0; p < 8; p++) {
|
||||||
if (byte_count & (0x100 >> p)) {
|
if (byte_count & (0x100 >> p)) {
|
||||||
binary[byte_count_posn + p] = '0';
|
binary[byte_count_posn + p] = '0';
|
||||||
@ -352,13 +352,13 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) {
|
|||||||
/* Create a binary stream representation of the input data.
|
/* Create a binary stream representation of the input data.
|
||||||
7 sets are defined - Chinese characters, Numerals, Lower case letters, Upper case letters,
|
7 sets are defined - Chinese characters, Numerals, Lower case letters, Upper case letters,
|
||||||
Mixed numerals and latters, Control characters and 8-bit binary data */
|
Mixed numerals and latters, Control characters and 8-bit binary data */
|
||||||
int sp, current_mode, next_mode, last_mode, glyph = 0;
|
int sp, current_mode, next_mode, last_mode, glyph = 0, q;
|
||||||
int c1, c2, done;
|
int c1, c2, done;
|
||||||
int p = 0, ppos;
|
int p = 0, ppos;
|
||||||
int numbuf[3], punt = 0;
|
int numbuf[3], punt = 0;
|
||||||
int number_pad_posn, debug = 0;
|
size_t number_pad_posn, byte_count_posn = 0;
|
||||||
int byte_count_posn = 0, byte_count = 0;
|
int byte_count = 0, debug = 0;
|
||||||
int shift, i, q;
|
int shift, i;
|
||||||
|
|
||||||
strcpy(binary, "");
|
strcpy(binary, "");
|
||||||
|
|
||||||
@ -830,7 +830,7 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gm_add_ecc(char binary[], int data_posn, int layers, int ecc_level, int word[]) {
|
static void gm_add_ecc(const char binary[], const size_t data_posn, const int layers, const int ecc_level, int word[]) {
|
||||||
int data_cw, i, j, wp, p;
|
int data_cw, i, j, wp, p;
|
||||||
int n1, b1, n2, b2, e1, b3, e2;
|
int n1, b1, n2, b2, e1, b3, e2;
|
||||||
int block_size, data_size, ecc_size;
|
int block_size, data_size, ecc_size;
|
||||||
@ -854,7 +854,7 @@ void gm_add_ecc(char binary[], int data_posn, int layers, int ecc_level, int wor
|
|||||||
|
|
||||||
/* Add padding codewords */
|
/* Add padding codewords */
|
||||||
data[data_posn] = 0x00;
|
data[data_posn] = 0x00;
|
||||||
for (i = (data_posn + 1); i < data_cw; i++) {
|
for (i = (int) (data_posn + 1); i < data_cw; i++) {
|
||||||
if (i & 1) {
|
if (i & 1) {
|
||||||
data[i] = 0x7e;
|
data[i] = 0x7e;
|
||||||
} else {
|
} else {
|
||||||
@ -1032,7 +1032,7 @@ void place_layer_id(char* grid, int size, int layers, int modules, int ecc_level
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], int length) {
|
||||||
int size, modules, dark, error_number;
|
int size, modules, dark, error_number;
|
||||||
int auto_layers, min_layers, layers, auto_ecc_level, min_ecc_level, ecc_level;
|
int auto_layers, min_layers, layers, auto_ecc_level, min_ecc_level, ecc_level;
|
||||||
int x, y, i, j, glyph;
|
int x, y, i, j, glyph;
|
||||||
|
@ -69,7 +69,7 @@ void itostr(char ai_string[], int ai_value) {
|
|||||||
concat(ai_string, ")");
|
concat(ai_string, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, char reduced[]) {
|
int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const unsigned int src_len, char reduced[]) {
|
||||||
int i, j, last_ai, ai_latch;
|
int i, j, last_ai, ai_latch;
|
||||||
char ai_string[6];
|
char ai_string[6];
|
||||||
int bracket_level, max_bracket_level, ai_length, max_ai_length, min_ai_length;
|
int bracket_level, max_bracket_level, ai_length, max_ai_length, min_ai_length;
|
||||||
@ -335,7 +335,7 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, unsigned char reduced[]) {
|
int ugs1_verify(struct zint_symbol *symbol, const unsigned char source[], const unsigned int src_len, unsigned char reduced[]) {
|
||||||
/* Only to keep the compiler happy */
|
/* Only to keep the compiler happy */
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
char temp[src_len + 5];
|
char temp[src_len + 5];
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
extern int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, char reduced[]);
|
extern int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const unsigned int src_len, char reduced[]);
|
||||||
extern int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, unsigned char reduced[]);
|
extern int ugs1_verify(struct zint_symbol *symbol, const unsigned char source[], const unsigned int src_len, unsigned char reduced[]);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ extern int australia_post(struct zint_symbol *symbol, unsigned char source[], in
|
|||||||
extern int code16k(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 16k */
|
extern int code16k(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 16k */
|
||||||
extern int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length); /* PDF417 */
|
extern int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length); /* PDF417 */
|
||||||
extern int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Data Matrix (IEC16022) */
|
extern int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Data Matrix (IEC16022) */
|
||||||
extern int qr_code(struct zint_symbol *symbol, unsigned char source[], int length); /* QR Code */
|
extern int qr_code(struct zint_symbol *symbol, const unsigned char source[], int length); /* QR Code */
|
||||||
extern int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length); /* Micro PDF417 */
|
extern int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length); /* Micro PDF417 */
|
||||||
extern int maxicode(struct zint_symbol *symbol, unsigned char source[], int length); /* Maxicode */
|
extern int maxicode(struct zint_symbol *symbol, unsigned char source[], int length); /* Maxicode */
|
||||||
extern int rss14(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS-14 */
|
extern int rss14(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS-14 */
|
||||||
@ -173,14 +173,14 @@ extern int code32(struct zint_symbol *symbol, unsigned char source[], int length
|
|||||||
extern int daft_code(struct zint_symbol *symbol, unsigned char source[], int length); /* DAFT Code */
|
extern int daft_code(struct zint_symbol *symbol, unsigned char source[], int length); /* DAFT Code */
|
||||||
extern int ean_14(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-14 */
|
extern int ean_14(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-14 */
|
||||||
extern int nve_18(struct zint_symbol *symbol, unsigned char source[], int length); /* NVE-18 */
|
extern int nve_18(struct zint_symbol *symbol, unsigned char source[], int length); /* NVE-18 */
|
||||||
extern int microqr(struct zint_symbol *symbol, unsigned char source[], int length); /* Micro QR Code */
|
extern int microqr(struct zint_symbol *symbol, const unsigned char source[], int length); /* Micro QR Code */
|
||||||
extern int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Runes */
|
extern int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Runes */
|
||||||
extern int korea_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Korea Post */
|
extern int korea_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Korea Post */
|
||||||
extern int japan_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Japanese Post */
|
extern int japan_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Japanese Post */
|
||||||
extern int code_49(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 49 */
|
extern int code_49(struct zint_symbol *symbol, unsigned char source[], const int length); /* Code 49 */
|
||||||
extern int channel_code(struct zint_symbol *symbol, unsigned char source[], int length); /* Channel Code */
|
extern int channel_code(struct zint_symbol *symbol, unsigned char source[], int length); /* Channel Code */
|
||||||
extern int code_one(struct zint_symbol *symbol, unsigned char source[], int length); /* Code One */
|
extern int code_one(struct zint_symbol *symbol, unsigned char source[], int length); /* Code One */
|
||||||
extern int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Grid Matrix */
|
extern int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], int length); /* Grid Matrix */
|
||||||
|
|
||||||
#ifndef NO_PNG
|
#ifndef NO_PNG
|
||||||
extern int png_handle(struct zint_symbol *symbol, int rotate_angle);
|
extern int png_handle(struct zint_symbol *symbol, int rotate_angle);
|
||||||
@ -353,7 +353,7 @@ int hibc(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gs1_compliant(int symbology) {
|
static int gs1_compliant(const int symbology) {
|
||||||
/* Returns 1 if symbology supports GS1 data */
|
/* Returns 1 if symbology supports GS1 data */
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -480,7 +480,7 @@ int ZBarcode_ValidID(int symbol_id) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int extended_charset(struct zint_symbol *symbol, unsigned char *source, int length) {
|
static int extended_charset(struct zint_symbol *symbol, const unsigned char *source, const int length) {
|
||||||
int error_number = 0;
|
int error_number = 0;
|
||||||
|
|
||||||
/* These are the "elite" standards which can support multiple character sets */
|
/* These are the "elite" standards which can support multiple character sets */
|
||||||
@ -496,7 +496,7 @@ int extended_charset(struct zint_symbol *symbol, unsigned char *source, int leng
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length) {
|
static int reduced_charset(struct zint_symbol *symbol, const unsigned char *source, int length) {
|
||||||
/* These are the "norm" standards which only support Latin-1 at most */
|
/* These are the "norm" standards which only support Latin-1 at most */
|
||||||
int error_number = 0;
|
int error_number = 0;
|
||||||
|
|
||||||
|
35
backend/qr.c
35
backend/qr.c
@ -40,6 +40,7 @@
|
|||||||
#include "qr.h"
|
#include "qr.h"
|
||||||
#include "reedsol.h"
|
#include "reedsol.h"
|
||||||
#include <stdlib.h> /* abs */
|
#include <stdlib.h> /* abs */
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
/* Returns true if input glyph is in the Alphanumeric set */
|
/* Returns true if input glyph is in the Alphanumeric set */
|
||||||
int in_alpha(int glyph) {
|
int in_alpha(int glyph) {
|
||||||
@ -1297,16 +1298,12 @@ int tribus(int version, int a, int b, int c) {
|
|||||||
void applyOptimisation(int version, char inputMode[], int inputLength) {
|
void applyOptimisation(int version, char inputMode[], int inputLength) {
|
||||||
|
|
||||||
|
|
||||||
int blockCount = 0;
|
int blockCount = 0, block;
|
||||||
int i, j;
|
int i, j;
|
||||||
char currentMode = ' '; // Null
|
char currentMode = ' '; // Null
|
||||||
int block;
|
int *blockLength;
|
||||||
|
char *blockMode;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
int* blockLength;
|
|
||||||
int* blockMode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < inputLength; i++) {
|
for (i = 0; i < inputLength; i++) {
|
||||||
if (inputMode[i] != currentMode) {
|
if (inputMode[i] != currentMode) {
|
||||||
currentMode = inputMode[i];
|
currentMode = inputMode[i];
|
||||||
@ -1314,13 +1311,16 @@ void applyOptimisation(int version, char inputMode[], int inputLength) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
blockLength=(int*)malloc(sizeof(int)*blockCount);
|
||||||
int blockLength[blockCount];
|
assert(blockLength);
|
||||||
char blockMode[blockCount];
|
if (!blockLength) return;
|
||||||
#else
|
blockMode=(char*)malloc(sizeof(char)*blockCount);
|
||||||
blockLength = (int *) _alloca(blockCount * sizeof (int));
|
assert(blockMode);
|
||||||
blockMode = (int *) _alloca(blockCount * sizeof(int));
|
if (!blockMode)
|
||||||
#endif
|
{
|
||||||
|
free(blockLength);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
j = -1;
|
j = -1;
|
||||||
currentMode = ' '; // Null
|
currentMode = ' '; // Null
|
||||||
@ -1405,6 +1405,9 @@ void applyOptimisation(int version, char inputMode[], int inputLength) {
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(blockLength);
|
||||||
|
free(blockMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int blockLength(int start, char inputMode[], int inputLength) {
|
int blockLength(int start, char inputMode[], int inputLength) {
|
||||||
@ -1490,7 +1493,7 @@ int getBinaryLength(int version, char inputMode[], int inputData[], int inputLen
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qr_code(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int qr_code(struct zint_symbol *symbol, const unsigned char source[], int length) {
|
||||||
int error_number, i, j, glyph, est_binlen;
|
int error_number, i, j, glyph, est_binlen;
|
||||||
int ecc_level, autosize, version, max_cw, target_binlen, blocks, size;
|
int ecc_level, autosize, version, max_cw, target_binlen, blocks, size;
|
||||||
int bitmask, gs1;
|
int bitmask, gs1;
|
||||||
@ -2757,7 +2760,7 @@ int micro_apply_bitmask(unsigned char *grid, int size) {
|
|||||||
return best_pattern;
|
return best_pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
int microqr(struct zint_symbol *symbol, unsigned char source[], int length) {
|
int microqr(struct zint_symbol *symbol, const unsigned char source[], int length) {
|
||||||
int i, j, glyph, size;
|
int i, j, glyph, size;
|
||||||
char binary_stream[200];
|
char binary_stream[200];
|
||||||
char full_stream[200];
|
char full_stream[200];
|
||||||
|
@ -68,7 +68,7 @@ static int *logt = NULL, *alog = NULL, *rspoly = NULL;
|
|||||||
// polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is
|
// polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is
|
||||||
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
|
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
|
||||||
|
|
||||||
void rs_init_gf(int poly) {
|
void rs_init_gf(const int poly) {
|
||||||
int m, b, p, v;
|
int m, b, p, v;
|
||||||
|
|
||||||
// Find the top bit, and hence the symbol size
|
// Find the top bit, and hence the symbol size
|
||||||
@ -100,7 +100,7 @@ void rs_init_gf(int poly) {
|
|||||||
// (x + 2**i)*(x + 2**(i+1))*... [nsym terms]
|
// (x + 2**i)*(x + 2**(i+1))*... [nsym terms]
|
||||||
// For ECC200, index is 1.
|
// For ECC200, index is 1.
|
||||||
|
|
||||||
void rs_init_code(int nsym, int index) {
|
void rs_init_code(const int nsym,int index) {
|
||||||
int i, k;
|
int i, k;
|
||||||
|
|
||||||
rspoly = (int *) malloc(sizeof (int) * (nsym + 1));
|
rspoly = (int *) malloc(sizeof (int) * (nsym + 1));
|
||||||
@ -120,7 +120,7 @@ void rs_init_code(int nsym, int index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs_encode(int len, unsigned char *data, unsigned char *res) {
|
void rs_encode(const int len,const unsigned char *data, unsigned char *res) {
|
||||||
int i, k, m;
|
int i, k, m;
|
||||||
for (i = 0; i < rlen; i++)
|
for (i = 0; i < rlen; i++)
|
||||||
res[i] = 0;
|
res[i] = 0;
|
||||||
@ -140,7 +140,7 @@ void rs_encode(int len, unsigned char *data, unsigned char *res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The same as above but for larger bitlengths - Aztec code compatible */
|
/* The same as above but for larger bitlengths - Aztec code compatible */
|
||||||
void rs_encode_long(int len, unsigned int *data, unsigned int *res) {
|
void rs_encode_long(const int len,const unsigned int *data, unsigned int *res) {
|
||||||
int i, k, m;
|
int i, k, m;
|
||||||
for (i = 0; i < rlen; i++)
|
for (i = 0; i < rlen; i++)
|
||||||
res[i] = 0;
|
res[i] = 0;
|
||||||
|
@ -37,10 +37,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
extern void rs_init_gf(int poly);
|
extern void rs_init_gf(const int poly);
|
||||||
extern void rs_init_code(int nsym, int index);
|
extern void rs_init_code(const int nsym,int index);
|
||||||
extern void rs_encode(int len, unsigned char *data, unsigned char *res);
|
extern void rs_encode(const int len,const unsigned char *data, unsigned char *res);
|
||||||
extern void rs_encode_long(int len, unsigned int *data, unsigned int *res);
|
extern void rs_encode_long(const int len,const unsigned int *data, unsigned int *res);
|
||||||
extern void rs_free(void);
|
extern void rs_free(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -56,7 +56,7 @@ int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexag
|
|||||||
|
|
||||||
int render_plot_add_string(struct zint_symbol *symbol, unsigned char *text, float x, float y, float fsize, float width, struct zint_render_string **last_string);
|
int render_plot_add_string(struct zint_symbol *symbol, unsigned char *text, float x, float y, float fsize, float width, struct zint_render_string **last_string);
|
||||||
|
|
||||||
int render_plot(struct zint_symbol *symbol, float width, float height) {
|
int render_plot(struct zint_symbol *symbol,const float width,const float height) {
|
||||||
struct zint_render *render;
|
struct zint_render *render;
|
||||||
struct zint_render_line *line, *last_line = NULL;
|
struct zint_render_line *line, *last_line = NULL;
|
||||||
struct zint_render_string *last_string = NULL;
|
struct zint_render_string *last_string = NULL;
|
||||||
@ -173,7 +173,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
|
else if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
|
||||||
upceanflag = 12;
|
upceanflag = 12;
|
||||||
if (symbol->whitespace_width < 10) {
|
if (symbol->whitespace_width < 10) {
|
||||||
symbol->whitespace_width = 10;
|
symbol->whitespace_width = 10;
|
||||||
@ -191,7 +191,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
|
else if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
|
||||||
upceanflag = 6;
|
upceanflag = 6;
|
||||||
if (symbol->whitespace_width == 0) {
|
if (symbol->whitespace_width == 0) {
|
||||||
symbol->whitespace_width = 10;
|
symbol->whitespace_width = 10;
|
||||||
@ -228,7 +228,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height) {
|
|||||||
if (large_bar_count == 0) {
|
if (large_bar_count == 0) {
|
||||||
required_aspect = width / height;
|
required_aspect = width / height;
|
||||||
symbol_aspect = (total_symbol_width_x + (2 * xoffset)) / (preset_height + (2 * yoffset) + text_offset + text_height);
|
symbol_aspect = (total_symbol_width_x + (2 * xoffset)) / (preset_height + (2 * yoffset) + text_offset + text_height);
|
||||||
symbol->height = preset_height;
|
symbol->height = (int)preset_height;
|
||||||
if (required_aspect > symbol_aspect) {
|
if (required_aspect > symbol_aspect) {
|
||||||
/* the area is too wide */
|
/* the area is too wide */
|
||||||
scaler = height / (preset_height + (2 * yoffset) + text_offset + text_height);
|
scaler = height / (preset_height + (2 * yoffset) + text_offset + text_height);
|
||||||
@ -242,7 +242,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scaler = width / (total_symbol_width_x + (2 * xoffset));
|
scaler = width / (total_symbol_width_x + (2 * xoffset));
|
||||||
symbol->height = (height / scaler) - ((2 * yoffset) + text_offset + text_height);
|
symbol->height = (int)((height / scaler) - ((2 * yoffset) + text_offset + text_height));
|
||||||
|
|
||||||
render->width = width;
|
render->width = width;
|
||||||
render->height = height;
|
render->height = height;
|
||||||
@ -277,7 +277,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (symbol->symbology == BARCODE_CODE49) {
|
else if(symbol->symbology == BARCODE_CODE49) {
|
||||||
/* The minimum X-dimension of Code 49 is 0.191mm */
|
/* The minimum X-dimension of Code 49 is 0.191mm */
|
||||||
if (x_dimension < 0.191) {
|
if (x_dimension < 0.191) {
|
||||||
render->width = 0.191 * GL_CONST * total_area_width_x;
|
render->width = 0.191 * GL_CONST * total_area_width_x;
|
||||||
@ -316,20 +316,20 @@ int render_plot(struct zint_symbol *symbol, float width, float height) {
|
|||||||
render->height = 4.064 * GL_CONST;
|
render->height = 4.064 * GL_CONST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((symbol->symbology == BARCODE_POSTNET) || (symbol->symbology == BARCODE_PLANET)) {
|
else if((symbol->symbology == BARCODE_POSTNET) || (symbol->symbology == BARCODE_PLANET)) {
|
||||||
/* The size of PostNet and PLANET are fized */
|
/* The size of PostNet and PLANET are fized */
|
||||||
render->width = 0.508 * GL_CONST * total_area_width_x;
|
render->width = 0.508 * GL_CONST * total_area_width_x;
|
||||||
render->height = 2.921 * GL_CONST;
|
render->height = 2.921 * GL_CONST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((symbol->symbology == BARCODE_AUSPOST) || (symbol->symbology == BARCODE_AUSREPLY)) ||
|
else if(((symbol->symbology == BARCODE_AUSPOST) || (symbol->symbology == BARCODE_AUSREPLY)) ||
|
||||||
((symbol->symbology == BARCODE_AUSROUTE) || (symbol->symbology == BARCODE_AUSREDIRECT))) {
|
((symbol->symbology == BARCODE_AUSROUTE) || (symbol->symbology == BARCODE_AUSREDIRECT))) {
|
||||||
/* Australia Post use the same sizes as USPS */
|
/* Australia Post use the same sizes as USPS */
|
||||||
render->width = 0.508 * GL_CONST * total_area_width_x;
|
render->width = 0.508 * GL_CONST * total_area_width_x;
|
||||||
render->height = 4.064 * GL_CONST;
|
render->height = 4.064 * GL_CONST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((symbol->symbology == BARCODE_RM4SCC) || (symbol->symbology == BARCODE_KIX)) {
|
else if((symbol->symbology == BARCODE_RM4SCC) || (symbol->symbology == BARCODE_KIX)) {
|
||||||
/* Royal Mail and KIX Code uses 22 bars per inch */
|
/* Royal Mail and KIX Code uses 22 bars per inch */
|
||||||
render->width = 0.577 * GL_CONST * total_area_width_x;
|
render->width = 0.577 * GL_CONST * total_area_width_x;
|
||||||
render->height = 5.22 * GL_CONST;
|
render->height = 5.22 * GL_CONST;
|
||||||
@ -680,6 +680,8 @@ struct zint_render_line *render_plot_create_line(float x, float y, float width,
|
|||||||
struct zint_render_line *line;
|
struct zint_render_line *line;
|
||||||
|
|
||||||
line = (struct zint_render_line*) malloc(sizeof (struct zint_render_line));
|
line = (struct zint_render_line*) malloc(sizeof (struct zint_render_line));
|
||||||
|
if (!line) return NULL;
|
||||||
|
|
||||||
line->next = NULL;
|
line->next = NULL;
|
||||||
line->x = x;
|
line->x = x;
|
||||||
line->y = y;
|
line->y = y;
|
||||||
@ -694,6 +696,7 @@ struct zint_render_line *render_plot_create_line(float x, float y, float width,
|
|||||||
* next value.
|
* next value.
|
||||||
*/
|
*/
|
||||||
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line) {
|
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line) {
|
||||||
|
if (!line) return ZINT_ERROR_MEMORY;
|
||||||
if (*last_line)
|
if (*last_line)
|
||||||
(*last_line)->next = line;
|
(*last_line)->next = line;
|
||||||
else
|
else
|
||||||
@ -707,6 +710,7 @@ struct zint_render_ring *render_plot_create_ring(float x, float y, float radius,
|
|||||||
struct zint_render_ring *ring;
|
struct zint_render_ring *ring;
|
||||||
|
|
||||||
ring = (struct zint_render_ring *) malloc(sizeof (struct zint_render_ring));
|
ring = (struct zint_render_ring *) malloc(sizeof (struct zint_render_ring));
|
||||||
|
if (!ring) return NULL;
|
||||||
ring->next = NULL;
|
ring->next = NULL;
|
||||||
ring->x = x;
|
ring->x = x;
|
||||||
ring->y = y;
|
ring->y = y;
|
||||||
@ -717,6 +721,7 @@ struct zint_render_ring *render_plot_create_ring(float x, float y, float radius,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ring, struct zint_render_ring **last_ring) {
|
int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ring, struct zint_render_ring **last_ring) {
|
||||||
|
if (!ring) return ZINT_ERROR_MEMORY;
|
||||||
if (*last_ring)
|
if (*last_ring)
|
||||||
(*last_ring)->next = ring;
|
(*last_ring)->next = ring;
|
||||||
else
|
else
|
||||||
@ -730,6 +735,7 @@ struct zint_render_hexagon *render_plot_create_hexagon(float x, float y) {
|
|||||||
struct zint_render_hexagon *hexagon;
|
struct zint_render_hexagon *hexagon;
|
||||||
|
|
||||||
hexagon = (struct zint_render_hexagon*) malloc(sizeof (struct zint_render_hexagon));
|
hexagon = (struct zint_render_hexagon*) malloc(sizeof (struct zint_render_hexagon));
|
||||||
|
if (!hexagon) return NULL;
|
||||||
hexagon->next = NULL;
|
hexagon->next = NULL;
|
||||||
hexagon->x = x;
|
hexagon->x = x;
|
||||||
hexagon->y = y;
|
hexagon->y = y;
|
||||||
@ -738,6 +744,7 @@ struct zint_render_hexagon *render_plot_create_hexagon(float x, float y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexagon *hexagon, struct zint_render_hexagon **last_hexagon) {
|
int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexagon *hexagon, struct zint_render_hexagon **last_hexagon) {
|
||||||
|
if (!hexagon) return ZINT_ERROR_MEMORY;
|
||||||
if (*last_hexagon)
|
if (*last_hexagon)
|
||||||
(*last_hexagon)->next = hexagon;
|
(*last_hexagon)->next = hexagon;
|
||||||
else
|
else
|
||||||
|
@ -235,7 +235,7 @@ extern "C" {
|
|||||||
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
|
||||||
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
|
||||||
|
|
||||||
ZINT_EXTERN int ZBarcode_Render(struct zint_symbol *symbol, float width, float height);
|
ZINT_EXTERN int ZBarcode_Render(struct zint_symbol *symbol, const float width, const float height);
|
||||||
|
|
||||||
ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
|
||||||
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
|
||||||
|
Loading…
Reference in New Issue
Block a user