mirror of
https://git.code.sf.net/p/zint/code
synced 2026-05-14 18:13:53 +00:00
general: prefix all INTERNAL funcs/tables with zint_, except
those in "backend/common.h", which are prefixed by `z_` - makes symbol clashes more unlikely when zint is statically linked (ticket #337, props Ulrich Becker) DOTCODE: fix padding allowance (10 -> 52 - probable max 35) to cover cases with large no. of columns requested and little data, to prevent `codeword_array` buffer overflow AZTEC/CODEONE: some code fiddling general_field: prefix defines with `GF_`, shorten static funcs prefix `general_field_` -> `gf_`
This commit is contained in:
@@ -65,7 +65,7 @@ static const char BC412Table[35][8] = {
|
||||
{'1','2','1','3','1','1','1','2'}
|
||||
};
|
||||
|
||||
INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int length) { /* IBM BC412 */
|
||||
INTERNAL int zint_bc412(struct zint_symbol *symbol, unsigned char source[], int length) { /* IBM BC412 */
|
||||
unsigned char padded_source[20];
|
||||
int posns[35];
|
||||
int i, counter_odd = 0, counter_even = 0, check_sum = 0;
|
||||
@@ -75,12 +75,12 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
|
||||
|
||||
if (length > 18) {
|
||||
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 790, "Input length %d too long (maximum 18)", length);
|
||||
return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 790, "Input length %d too long (maximum 18)", length);
|
||||
}
|
||||
if (length < 7) {
|
||||
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 792, "Input length %d too short (minimum 7)", length);
|
||||
return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 792, "Input length %d too short (minimum 7)", length);
|
||||
}
|
||||
to_upper(source, length);
|
||||
z_to_upper(source, length);
|
||||
|
||||
padded_source[0] = source[0];
|
||||
padded_source[1] = '0';
|
||||
@@ -89,8 +89,8 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
padded_source[i] = source[i - 1];
|
||||
}
|
||||
|
||||
if ((i = not_sane_lookup(BROMINE, 35, padded_source, length + 1, posns))) {
|
||||
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 791,
|
||||
if ((i = z_not_sane_lookup(BROMINE, 35, padded_source, length + 1, posns))) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 791,
|
||||
"Invalid character at position %d in input (alphanumerics only, excluding \"O\")", i - 1);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
memcpy(d, "111", 3);
|
||||
d += 3;
|
||||
|
||||
expand(symbol, dest, d - dest);
|
||||
z_expand(symbol, dest, d - dest);
|
||||
|
||||
if (symbol->output_options & COMPLIANT_HEIGHT) {
|
||||
/* SEMI T1-95 Table 1 "Module" (Character) Height 2mm ± 0.025mm, using Module Spacing 0.12mm ± 0.025mm as
|
||||
@@ -138,17 +138,17 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
const float min_height = 13.6206894f; /* 1.975 / 0.145 */
|
||||
const float default_height = 16.666666f; /* 2.0 / 0.12 */
|
||||
const float max_height = 21.3157902f; /* 2.025 / 0.095 */
|
||||
error_number = set_height(symbol, min_height, default_height, max_height, 0 /*no_errtxt*/);
|
||||
error_number = z_set_height(symbol, min_height, default_height, max_height, 0 /*no_errtxt*/);
|
||||
} else {
|
||||
/* Using compliant height as default as no backwards compatibility to consider */
|
||||
const float default_height = 16.666666f; /* 2.0 / 0.12 */
|
||||
(void) set_height(symbol, 0.0f, default_height, 0.0f, 1 /*no_errtxt*/);
|
||||
(void) z_set_height(symbol, 0.0f, default_height, 0.0f, 1 /*no_errtxt*/);
|
||||
}
|
||||
|
||||
hrt_cpy_nochk(symbol, padded_source, length + 1);
|
||||
z_hrt_cpy_nochk(symbol, padded_source, length + 1);
|
||||
|
||||
if (raw_text && rt_cpy(symbol, padded_source, length + 1)) {
|
||||
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
|
||||
if (raw_text && z_rt_cpy(symbol, padded_source, length + 1)) {
|
||||
return ZINT_ERROR_MEMORY; /* `z_rt_cpy()` only fails with OOM */
|
||||
}
|
||||
|
||||
return error_number;
|
||||
|
||||
Reference in New Issue
Block a user