mirror of
https://git.code.sf.net/p/zint/code
synced 2025-12-17 09:57:02 +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:
@@ -93,7 +93,7 @@ static void fm_clear_mem(struct filemem *restrict const fmp) {
|
||||
}
|
||||
|
||||
/* `fopen()` if file, setup memory buffer if BARCODE_MEMORY_FILE, returning 1 on success, 0 on failure */
|
||||
INTERNAL int fm_open(struct filemem *restrict const fmp, struct zint_symbol *symbol, const char *mode) {
|
||||
INTERNAL int zint_fm_open(struct filemem *restrict const fmp, struct zint_symbol *symbol, const char *mode) {
|
||||
assert(fmp && symbol && mode);
|
||||
fmp->fp = NULL;
|
||||
fmp->mem = NULL;
|
||||
@@ -128,7 +128,7 @@ INTERNAL int fm_open(struct filemem *restrict const fmp, struct zint_symbol *sym
|
||||
fmp->fp = stdout;
|
||||
return 1;
|
||||
}
|
||||
if (!(fmp->fp = out_fopen(symbol->outfile, mode))) {
|
||||
if (!(fmp->fp = zint_out_fopen(symbol->outfile, mode))) {
|
||||
return fm_seterr(fmp, errno);
|
||||
}
|
||||
return 1;
|
||||
@@ -172,7 +172,7 @@ static int fm_mem_expand(struct filemem *restrict const fmp, const size_t size)
|
||||
}
|
||||
|
||||
/* `fwrite()` to file or memory, returning 1 on success, 0 on failure */
|
||||
INTERNAL int fm_write(const void *restrict ptr, const size_t size, const size_t nitems,
|
||||
INTERNAL int zint_fm_write(const void *restrict ptr, const size_t size, const size_t nitems,
|
||||
struct filemem *restrict const fmp) {
|
||||
assert(fmp && ptr);
|
||||
if (fmp->err) {
|
||||
@@ -200,7 +200,7 @@ INTERNAL int fm_write(const void *restrict ptr, const size_t size, const size_t
|
||||
}
|
||||
|
||||
/* `fputc()` to file or memory, returning 1 on success, 0 on failure */
|
||||
INTERNAL int fm_putc(const int ch, struct filemem *restrict const fmp) {
|
||||
INTERNAL int zint_fm_putc(const int ch, struct filemem *restrict const fmp) {
|
||||
assert(fmp);
|
||||
if (fmp->err) {
|
||||
return 0;
|
||||
@@ -220,7 +220,7 @@ INTERNAL int fm_putc(const int ch, struct filemem *restrict const fmp) {
|
||||
}
|
||||
|
||||
/* `fputs()` to file or memory, returning 1 on success, 0 on failure */
|
||||
INTERNAL int fm_puts(const char *str, struct filemem *restrict const fmp) {
|
||||
INTERNAL int zint_fm_puts(const char *str, struct filemem *restrict const fmp) {
|
||||
assert(fmp);
|
||||
if (fmp->err) {
|
||||
return 0;
|
||||
@@ -294,7 +294,7 @@ static int fm_vprintf(struct filemem *restrict const fmp, const char *fmt, va_li
|
||||
}
|
||||
|
||||
/* `fprintf()` to file or memory, returning 1 on success, 0 on failure */
|
||||
INTERNAL int fm_printf(struct filemem *restrict const fmp, const char *fmt, ...) {
|
||||
INTERNAL int zint_fm_printf(struct filemem *restrict const fmp, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
@@ -316,7 +316,7 @@ INTERNAL int fm_printf(struct filemem *restrict const fmp, const char *fmt, ...)
|
||||
|
||||
/* Output float without trailing zeroes to `fmp` with decimal pts `dp` (precision), returning 1 on success, 0 on
|
||||
failure */
|
||||
INTERNAL int fm_putsf(const char *prefix, const int dp, const float arg, struct filemem *restrict const fmp) {
|
||||
INTERNAL int zint_fm_putsf(const char *prefix, const int dp, const float arg, struct filemem *restrict const fmp) {
|
||||
int i, end;
|
||||
char buf[256]; /* Assuming `dp` reasonable */
|
||||
const int len = sprintf(buf, "%.*f", dp, arg);
|
||||
@@ -326,7 +326,7 @@ INTERNAL int fm_putsf(const char *prefix, const int dp, const float arg, struct
|
||||
return 0;
|
||||
}
|
||||
if (prefix && *prefix) {
|
||||
if (!fm_puts(prefix, fmp)) {
|
||||
if (!zint_fm_puts(prefix, fmp)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -348,12 +348,12 @@ INTERNAL int fm_putsf(const char *prefix, const int dp, const float arg, struct
|
||||
}
|
||||
}
|
||||
|
||||
return fm_puts(buf, fmp);
|
||||
return zint_fm_puts(buf, fmp);
|
||||
}
|
||||
|
||||
/* `fclose()` if file, set `symbol->memfile` & `symbol->memfile_size` if memory, returning 1 on success, 0 on
|
||||
failure */
|
||||
INTERNAL int fm_close(struct filemem *restrict const fmp, struct zint_symbol *symbol) {
|
||||
INTERNAL int zint_fm_close(struct filemem *restrict const fmp, struct zint_symbol *symbol) {
|
||||
assert(fmp && symbol);
|
||||
if (fmp->flags & BARCODE_MEMORY_FILE) {
|
||||
if (fmp->err || !fmp->mem) {
|
||||
@@ -393,7 +393,7 @@ INTERNAL int fm_close(struct filemem *restrict const fmp, struct zint_symbol *sy
|
||||
}
|
||||
|
||||
/* `fseek()` to file/memory offset, returning 1 if successful, 0 on failure */
|
||||
INTERNAL int fm_seek(struct filemem *restrict const fmp, const long offset, const int whence) {
|
||||
INTERNAL int zint_fm_seek(struct filemem *restrict const fmp, const long offset, const int whence) {
|
||||
assert(fmp);
|
||||
if (fmp->err) {
|
||||
return 0;
|
||||
@@ -417,7 +417,7 @@ INTERNAL int fm_seek(struct filemem *restrict const fmp, const long offset, cons
|
||||
}
|
||||
|
||||
/* `ftell()` returns current file/memory offset if successful, -1 on failure */
|
||||
INTERNAL long fm_tell(struct filemem *restrict const fmp) {
|
||||
INTERNAL long zint_fm_tell(struct filemem *restrict const fmp) {
|
||||
long ret;
|
||||
assert(fmp);
|
||||
if (fmp->err) {
|
||||
@@ -440,7 +440,7 @@ INTERNAL long fm_tell(struct filemem *restrict const fmp) {
|
||||
}
|
||||
|
||||
/* Return `err`, which uses `errno` values; if file and `err` not set, test `ferror()` also */
|
||||
INTERNAL int fm_error(struct filemem *restrict const fmp) {
|
||||
INTERNAL int zint_fm_error(struct filemem *restrict const fmp) {
|
||||
assert(fmp);
|
||||
if (fmp->err == 0 && !(fmp->flags & BARCODE_MEMORY_FILE) && ferror(fmp->fp)) {
|
||||
(void) fm_seterr(fmp, EIO);
|
||||
@@ -450,7 +450,7 @@ INTERNAL int fm_error(struct filemem *restrict const fmp) {
|
||||
|
||||
/* `fflush()` if file, no-op (apart from error checking) if memory, returning 1 on success, 0 on failure
|
||||
NOTE: don't use, included only for libpng compatibility */
|
||||
INTERNAL int fm_flush(struct filemem *restrict const fmp) {
|
||||
INTERNAL int zint_fm_flush(struct filemem *restrict const fmp) {
|
||||
assert(fmp);
|
||||
if (fmp->err) {
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user