2009-11-23 04:38:15 +13:00
|
|
|
/* library.c - external functions of libzint
|
|
|
|
|
|
|
|
libzint - the open source barcode library
|
2021-01-12 07:11:41 +13:00
|
|
|
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
|
2009-11-23 04:38:15 +13:00
|
|
|
|
2013-05-17 05:26:38 +12:00
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
2017-10-24 08:37:52 +13:00
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
2013-05-17 05:26:38 +12:00
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
2017-10-24 08:37:52 +13:00
|
|
|
documentation and/or other materials provided with the distribution.
|
2013-05-17 05:26:38 +12:00
|
|
|
3. Neither the name of the project nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software
|
2017-10-24 08:37:52 +13:00
|
|
|
without specific prior written permission.
|
2013-05-17 05:26:38 +12:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
2017-10-24 08:37:52 +13:00
|
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
2013-05-17 05:26:38 +12:00
|
|
|
SUCH DAMAGE.
|
2016-02-20 23:50:15 +13:00
|
|
|
*/
|
2019-10-17 22:06:21 +13:00
|
|
|
/* vim: set ts=4 sw=4 et : */
|
2009-11-23 04:38:15 +13:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2020-11-02 07:32:55 +13:00
|
|
|
#include <limits.h>
|
2009-11-23 04:38:15 +13:00
|
|
|
#ifdef _MSC_VER
|
2017-10-24 08:37:52 +13:00
|
|
|
#include <malloc.h>
|
2009-11-23 04:38:15 +13:00
|
|
|
#endif
|
|
|
|
#include "common.h"
|
2021-01-12 07:11:41 +13:00
|
|
|
#include "eci.h"
|
2009-11-23 04:38:15 +13:00
|
|
|
#include "gs1.h"
|
2021-05-15 23:23:46 +12:00
|
|
|
#include "zfiletypes.h"
|
2009-11-23 04:38:15 +13:00
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
#define TECHNETIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
|
2009-11-23 04:38:15 +13:00
|
|
|
|
2020-12-22 08:30:07 +13:00
|
|
|
/* It's assumed that int is at least 32 bits, the following will compile-time fail if not
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
* https://stackoverflow.com/a/1980056 */
|
2020-12-22 08:30:07 +13:00
|
|
|
typedef int static_assert_int_at_least_32bits[CHAR_BIT != 8 || sizeof(int) < 4 ? -1 : 1];
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Create and initialize a symbol structure */
|
2016-02-20 23:50:15 +13:00
|
|
|
struct zint_symbol *ZBarcode_Create() {
|
|
|
|
struct zint_symbol *symbol;
|
|
|
|
|
2021-05-15 23:23:46 +12:00
|
|
|
symbol = (struct zint_symbol *) malloc(sizeof(*symbol));
|
2016-02-20 23:50:15 +13:00
|
|
|
if (!symbol) return NULL;
|
|
|
|
|
2021-05-15 23:23:46 +12:00
|
|
|
memset(symbol, 0, sizeof(*symbol));
|
2020-11-02 07:32:55 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2021-09-22 11:04:15 +12:00
|
|
|
symbol->scale = 1.0f;
|
2016-02-20 23:50:15 +13:00
|
|
|
strcpy(symbol->fgcolour, "000000");
|
2020-08-03 09:26:39 +12:00
|
|
|
symbol->fgcolor = &symbol->fgcolour[0];
|
2016-02-20 23:50:15 +13:00
|
|
|
strcpy(symbol->bgcolour, "ffffff");
|
2020-08-03 09:26:39 +12:00
|
|
|
symbol->bgcolor = &symbol->bgcolour[0];
|
2020-12-22 08:30:07 +13:00
|
|
|
#ifdef NO_PNG
|
|
|
|
strcpy(symbol->outfile, "out.gif");
|
|
|
|
#else
|
2017-10-22 00:45:50 +13:00
|
|
|
strcpy(symbol->outfile, "out.png");
|
2020-12-22 08:30:07 +13:00
|
|
|
#endif
|
2016-02-20 23:50:15 +13:00
|
|
|
symbol->option_1 = -1;
|
|
|
|
symbol->show_hrt = 1; // Show human readable text
|
2018-02-11 22:55:28 +13:00
|
|
|
symbol->fontsize = 8;
|
2016-02-20 23:50:15 +13:00
|
|
|
symbol->input_mode = DATA_MODE;
|
2019-10-07 05:39:54 +13:00
|
|
|
symbol->eci = 0; // Default 0 uses ECI 3
|
2020-10-01 00:19:12 +13:00
|
|
|
symbol->dot_size = 4.0f / 5.0f;
|
2021-09-22 11:04:15 +12:00
|
|
|
symbol->guard_descent = 5.0f;
|
2020-08-22 22:09:57 +12:00
|
|
|
symbol->warn_level = WARN_DEFAULT;
|
2021-09-22 11:04:15 +12:00
|
|
|
symbol->bitmap = NULL;
|
|
|
|
symbol->alphamap = NULL;
|
|
|
|
symbol->vector = NULL;
|
2020-11-02 07:32:55 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
return symbol;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2019-12-19 13:37:55 +13:00
|
|
|
INTERNAL void vector_free(struct zint_symbol *symbol); /* Free vector structures */
|
2017-10-16 20:49:44 +13:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Free any output buffers that may have been created and initialize output fields */
|
2016-02-20 23:50:15 +13:00
|
|
|
void ZBarcode_Clear(struct zint_symbol *symbol) {
|
|
|
|
int i, j;
|
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!symbol) return;
|
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
for (i = 0; i < symbol->rows; i++) {
|
|
|
|
for (j = 0; j < symbol->width; j++) {
|
|
|
|
unset_module(symbol, i, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
symbol->rows = 0;
|
|
|
|
symbol->width = 0;
|
2021-07-07 06:53:31 +12:00
|
|
|
memset(symbol->row_height, 0, sizeof(symbol->row_height));
|
2016-10-28 08:55:26 +13:00
|
|
|
memset(symbol->text, 0, sizeof(symbol->text));
|
2016-02-20 23:50:15 +13:00
|
|
|
symbol->errtxt[0] = '\0';
|
|
|
|
if (symbol->bitmap != NULL) {
|
|
|
|
free(symbol->bitmap);
|
|
|
|
symbol->bitmap = NULL;
|
|
|
|
}
|
2020-08-03 23:13:05 +12:00
|
|
|
if (symbol->alphamap != NULL) {
|
|
|
|
free(symbol->alphamap);
|
|
|
|
symbol->alphamap = NULL;
|
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
symbol->bitmap_width = 0;
|
|
|
|
symbol->bitmap_height = 0;
|
2021-07-07 06:53:31 +12:00
|
|
|
symbol->bitmap_byte_length = 0;
|
2017-10-16 20:49:44 +13:00
|
|
|
|
|
|
|
// If there is a rendered version, ensure its memory is released
|
2018-06-10 20:16:18 +12:00
|
|
|
vector_free(symbol);
|
2009-12-02 22:09:45 +13:00
|
|
|
}
|
2009-11-23 04:38:15 +13:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Free a symbol structure, including any output buffers */
|
2016-02-20 23:50:15 +13:00
|
|
|
void ZBarcode_Delete(struct zint_symbol *symbol) {
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!symbol) return;
|
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
if (symbol->bitmap != NULL)
|
|
|
|
free(symbol->bitmap);
|
2020-08-03 23:13:05 +12:00
|
|
|
if (symbol->alphamap != NULL)
|
|
|
|
free(symbol->alphamap);
|
2016-02-20 23:50:15 +13:00
|
|
|
|
|
|
|
// If there is a rendered version, ensure its memory is released
|
2018-06-10 20:16:18 +12:00
|
|
|
vector_free(symbol);
|
2016-09-06 09:06:50 +12:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
free(symbol);
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2019-12-19 13:37:55 +13:00
|
|
|
INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN system barcodes */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 3 from 9 (or Code 39) */
|
|
|
|
INTERNAL int pzn(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmazentral Nummer (PZN) */
|
2021-06-20 00:11:23 +12:00
|
|
|
/* Extended Code 3 from 9 (or Code 39+) */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int excode39(struct zint_symbol *symbol, unsigned char source[], int length);
|
2021-06-20 00:11:23 +12:00
|
|
|
/* Codabar - a simple substitution cipher */
|
|
|
|
INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int length);
|
|
|
|
/* Code 2 of 5 Standard (& Matrix) */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int c25standard(struct zint_symbol *symbol, unsigned char source[], int length);
|
|
|
|
INTERNAL int c25ind(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Industrial */
|
|
|
|
INTERNAL int c25iata(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 IATA */
|
|
|
|
INTERNAL int c25inter(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Interleaved */
|
|
|
|
INTERNAL int c25logic(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Data Logic */
|
2019-12-19 13:37:55 +13:00
|
|
|
INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int length); /* ITF-14 */
|
|
|
|
INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int length); /* Deutsche Post Leitcode */
|
|
|
|
INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int length); /* Deutsche Post Identcode */
|
2021-06-20 00:11:23 +12:00
|
|
|
/* Code 93 - a re-working of Code 39+, generates 2 check digits */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int code93(struct zint_symbol *symbol, unsigned char source[], int length);
|
|
|
|
INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 128 and NVE-18 */
|
|
|
|
INTERNAL int gs1_128(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-128 (GS1-128) */
|
|
|
|
INTERNAL int code11(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 11 */
|
|
|
|
INTERNAL int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length); /* MSI Plessey */
|
2020-12-23 23:57:24 +13:00
|
|
|
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int length); /* Telepen ASCII */
|
|
|
|
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int length); /* Telepen Numeric */
|
|
|
|
INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int length); /* Plessey Code */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int pharma(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmacode One Track */
|
|
|
|
INTERNAL int flat(struct zint_symbol *symbol, unsigned char source[], int length); /* Flattermarken */
|
2019-12-19 13:37:55 +13:00
|
|
|
INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length); /* Facing Identification Mark */
|
|
|
|
INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmacode Two Track */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int postnet(struct zint_symbol *symbol, unsigned char source[], int length); /* Postnet */
|
|
|
|
INTERNAL int planet(struct zint_symbol *symbol, unsigned char source[], int length); /* PLANET */
|
2021-06-20 00:11:23 +12:00
|
|
|
/* Intelligent Mail (aka USPS OneCode) */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int usps_imail(struct zint_symbol *symbol, unsigned char source[], int length);
|
|
|
|
INTERNAL int rm4scc(struct zint_symbol *symbol, unsigned char source[], int length); /* RM4SCC */
|
|
|
|
INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int length); /* Australia Post 4-state */
|
2020-12-23 23:57:24 +13:00
|
|
|
INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 16k */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int pdf417(struct zint_symbol *symbol, unsigned char source[], int length); /* PDF417 */
|
|
|
|
INTERNAL int micropdf417(struct zint_symbol *symbol, unsigned char chaine[], int length); /* Micro PDF417 */
|
2019-12-19 13:37:55 +13:00
|
|
|
INTERNAL int maxicode(struct zint_symbol *symbol, unsigned char source[], int length); /* Maxicode */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int dbar_omn(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS-14 */
|
|
|
|
INTERNAL int dbar_ltd(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS Limited */
|
|
|
|
INTERNAL int dbar_exp(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS Expanded */
|
2019-12-19 13:37:55 +13:00
|
|
|
INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int length); /* Composite Symbology */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int kix(struct zint_symbol *symbol, unsigned char source[], int length); /* TNT KIX Code */
|
2020-11-28 01:54:44 +13:00
|
|
|
INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Code */
|
2019-12-19 13:37:55 +13:00
|
|
|
INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int length); /* Italian Pharmacode */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int daft(struct zint_symbol *symbol, unsigned char source[], int length); /* DAFT Code */
|
|
|
|
INTERNAL int ean14(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-14 */
|
|
|
|
INTERNAL int nve18(struct zint_symbol *symbol, unsigned char source[], int length); /* NVE-18 */
|
2020-11-28 01:54:44 +13:00
|
|
|
INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int length); /* Micro QR Code */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int azrune(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Runes */
|
|
|
|
INTERNAL int koreapost(struct zint_symbol *symbol, unsigned char source[], int length); /* Korea Post */
|
|
|
|
INTERNAL int japanpost(struct zint_symbol *symbol, unsigned char source[], int length); /* Japanese Post */
|
|
|
|
INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 49 */
|
|
|
|
INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int length); /* Channel Code */
|
|
|
|
INTERNAL int codeone(struct zint_symbol *symbol, unsigned char source[], int length); /* Code One */
|
|
|
|
INTERNAL int gridmatrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Grid Matrix */
|
|
|
|
INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int length); /* Han Xin */
|
2020-12-23 23:57:24 +13:00
|
|
|
INTERNAL int dotcode(struct zint_symbol *symbol, unsigned char source[], int length); /* DotCode */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int length); /* Codablock */
|
2020-11-28 01:54:44 +13:00
|
|
|
INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int length); /* UPNQR */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int qrcode(struct zint_symbol *symbol, unsigned char source[], int length); /* QR Code */
|
|
|
|
INTERNAL int datamatrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Data Matrix (IEC16022) */
|
2021-06-20 00:11:23 +12:00
|
|
|
/* VIN Code (Vehicle Identification Number) */
|
|
|
|
INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length);
|
|
|
|
/* Royal Mail 4-state Mailmark */
|
|
|
|
INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int length);
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int ultra(struct zint_symbol *symbol, unsigned char source[], int length); /* Ultracode */
|
2020-12-23 23:57:24 +13:00
|
|
|
INTERNAL int rmqr(struct zint_symbol *symbol, unsigned char source[], int length); /* rMQR */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length); /* DPD Code */
|
2019-12-19 13:37:55 +13:00
|
|
|
|
|
|
|
INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to PNG/BMP/PCX */
|
|
|
|
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to EPS/EMF/SVG */
|
|
|
|
|
2021-06-20 00:11:23 +12:00
|
|
|
/* Prefix error message with Error/Warning */
|
2021-07-07 06:53:31 +12:00
|
|
|
STATIC_UNLESS_ZINT_TEST int error_tag(struct zint_symbol *symbol, int error_number, const char *error_string) {
|
2013-01-01 02:41:59 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
if (error_number != 0) {
|
2021-07-07 06:53:31 +12:00
|
|
|
static const char *error_fmt = "Error %.93s"; /* Truncate if too long */
|
|
|
|
static const char *warn_fmt = "Warning %.91s"; /* Truncate if too long */
|
|
|
|
const char *fmt = error_number >= ZINT_ERROR ? error_fmt : warn_fmt;
|
2017-09-11 03:03:09 +12:00
|
|
|
char error_buffer[100];
|
2021-07-07 06:53:31 +12:00
|
|
|
|
2021-09-01 05:34:29 +12:00
|
|
|
if (error_number < ZINT_ERROR && symbol->warn_level == WARN_FAIL_ALL) {
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Convert to error equivalent */
|
|
|
|
if (error_number == ZINT_WARN_NONCOMPLIANT) {
|
|
|
|
error_number = ZINT_ERROR_NONCOMPLIANT;
|
|
|
|
} else if (error_number == ZINT_WARN_USES_ECI) {
|
|
|
|
error_number = ZINT_ERROR_USES_ECI;
|
|
|
|
} else { /* ZINT_WARN_INVALID_OPTION */
|
|
|
|
error_number = ZINT_ERROR_INVALID_OPTION;
|
|
|
|
}
|
|
|
|
fmt = error_fmt;
|
|
|
|
}
|
|
|
|
sprintf(error_buffer, fmt, error_string ? error_string : symbol->errtxt);
|
|
|
|
strcpy(symbol->errtxt, error_buffer);
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
/* Output a hexadecimal representation of the rendered symbol */
|
2019-12-19 13:37:55 +13:00
|
|
|
static int dump_plot(struct zint_symbol *symbol) {
|
2016-02-20 23:50:15 +13:00
|
|
|
FILE *f;
|
|
|
|
int i, r;
|
|
|
|
char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
|
|
|
|
'9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
|
|
|
int space = 0;
|
2016-09-06 09:06:50 +12:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
if (symbol->output_options & BARCODE_STDOUT) {
|
|
|
|
f = stdout;
|
|
|
|
} else {
|
|
|
|
f = fopen(symbol->outfile, "w");
|
|
|
|
if (!f) {
|
2017-07-28 03:01:53 +12:00
|
|
|
strcpy(symbol->errtxt, "201: Could not open output file");
|
2016-02-20 23:50:15 +13:00
|
|
|
return ZINT_ERROR_FILE_ACCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (r = 0; r < symbol->rows; r++) {
|
2017-09-11 03:03:09 +12:00
|
|
|
int byt = 0;
|
2016-02-20 23:50:15 +13:00
|
|
|
for (i = 0; i < symbol->width; i++) {
|
|
|
|
byt = byt << 1;
|
2020-11-02 07:32:55 +13:00
|
|
|
if (symbol->symbology == BARCODE_ULTRA) {
|
|
|
|
if (module_colour_is_set(symbol, r, i)) {
|
|
|
|
byt += 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (module_is_set(symbol, r, i)) {
|
|
|
|
byt += 1;
|
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
if (((i + 1) % 4) == 0) {
|
|
|
|
fputc(hex[byt], f);
|
|
|
|
space++;
|
2016-02-19 12:23:31 +13:00
|
|
|
byt = 0;
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2020-08-05 09:22:26 +12:00
|
|
|
if (space == 2 && i + 1 < symbol->width) {
|
2016-02-20 23:50:15 +13:00
|
|
|
fputc(' ', f);
|
2016-02-19 12:23:31 +13:00
|
|
|
space = 0;
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
}
|
2010-09-13 01:52:44 +12:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
if ((symbol->width % 4) != 0) {
|
|
|
|
byt = byt << (4 - (symbol->width % 4));
|
|
|
|
fputc(hex[byt], f);
|
|
|
|
}
|
|
|
|
fputs("\n", f);
|
|
|
|
space = 0;
|
|
|
|
}
|
2010-09-13 01:52:44 +12:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
if (symbol->output_options & BARCODE_STDOUT) {
|
|
|
|
fflush(f);
|
|
|
|
} else {
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-09-13 01:52:44 +12:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
/* Process health industry bar code data */
|
2020-11-28 01:54:44 +13:00
|
|
|
static int hibc(struct zint_symbol *symbol, unsigned char source[], int length) {
|
|
|
|
int i;
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
int counter, error_number = 0;
|
2020-11-02 07:32:55 +13:00
|
|
|
char to_process[113], check_digit;
|
2016-02-20 23:50:15 +13:00
|
|
|
|
2016-10-27 06:34:21 +13:00
|
|
|
/* without "+" and check: max 110 characters in HIBC 2.6 */
|
|
|
|
if (length > 110) {
|
2021-07-07 06:53:31 +12:00
|
|
|
strcpy(symbol->errtxt, "202: Data too long for HIBC LIC (110 character maximum)");
|
2016-02-20 23:50:15 +13:00
|
|
|
return ZINT_ERROR_TOO_LONG;
|
|
|
|
}
|
|
|
|
to_upper(source);
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
if (is_sane(TECHNETIUM, source, length) != 0) {
|
2021-07-07 06:53:31 +12:00
|
|
|
strcpy(symbol->errtxt, "203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)");
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
counter = 41;
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
counter += posn(TECHNETIUM, source[i]);
|
|
|
|
}
|
|
|
|
counter = counter % 43;
|
|
|
|
|
|
|
|
if (counter < 10) {
|
|
|
|
check_digit = itoc(counter);
|
|
|
|
} else {
|
|
|
|
if (counter < 36) {
|
|
|
|
check_digit = (counter - 10) + 'A';
|
|
|
|
} else {
|
|
|
|
switch (counter) {
|
|
|
|
case 36: check_digit = '-';
|
|
|
|
break;
|
|
|
|
case 37: check_digit = '.';
|
|
|
|
break;
|
|
|
|
case 38: check_digit = ' ';
|
|
|
|
break;
|
|
|
|
case 39: check_digit = '$';
|
|
|
|
break;
|
|
|
|
case 40: check_digit = '/';
|
|
|
|
break;
|
|
|
|
case 41: check_digit = '+';
|
|
|
|
break;
|
|
|
|
case 42: check_digit = '%';
|
|
|
|
break;
|
|
|
|
default: check_digit = ' ';
|
|
|
|
break; /* Keep compiler happy */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-02 07:32:55 +13:00
|
|
|
to_process[0] = '+';
|
|
|
|
memcpy(to_process + 1, source, length);
|
|
|
|
to_process[length + 1] = check_digit;
|
|
|
|
length += 2;
|
|
|
|
to_process[length] = '\0';
|
2016-02-20 23:50:15 +13:00
|
|
|
|
|
|
|
switch (symbol->symbology) {
|
|
|
|
case BARCODE_HIBC_128:
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
error_number = code128(symbol, (unsigned char *) to_process, length);
|
2020-11-02 07:32:55 +13:00
|
|
|
ustrcpy(symbol->text, "*");
|
|
|
|
ustrcat(symbol->text, to_process);
|
|
|
|
ustrcat(symbol->text, "*");
|
2016-02-20 23:50:15 +13:00
|
|
|
break;
|
|
|
|
case BARCODE_HIBC_39:
|
|
|
|
symbol->option_2 = 0;
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
error_number = code39(symbol, (unsigned char *) to_process, length);
|
2020-11-02 07:32:55 +13:00
|
|
|
ustrcpy(symbol->text, "*");
|
|
|
|
ustrcat(symbol->text, to_process);
|
|
|
|
ustrcat(symbol->text, "*");
|
2016-02-20 23:50:15 +13:00
|
|
|
break;
|
|
|
|
case BARCODE_HIBC_DM:
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
error_number = datamatrix(symbol, (unsigned char *) to_process, length);
|
2016-02-20 23:50:15 +13:00
|
|
|
break;
|
|
|
|
case BARCODE_HIBC_QR:
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
error_number = qrcode(symbol, (unsigned char *) to_process, length);
|
2016-02-20 23:50:15 +13:00
|
|
|
break;
|
|
|
|
case BARCODE_HIBC_PDF:
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
error_number = pdf417(symbol, (unsigned char *) to_process, length);
|
2016-02-20 23:50:15 +13:00
|
|
|
break;
|
|
|
|
case BARCODE_HIBC_MICPDF:
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
error_number = micropdf417(symbol, (unsigned char *) to_process, length);
|
2016-02-20 23:50:15 +13:00
|
|
|
break;
|
|
|
|
case BARCODE_HIBC_AZTEC:
|
|
|
|
error_number = aztec(symbol, (unsigned char *) to_process, length);
|
|
|
|
break;
|
2016-08-25 06:37:49 +12:00
|
|
|
case BARCODE_HIBC_BLOCKF:
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
error_number = codablockf(symbol, (unsigned char *) to_process, length);
|
2016-08-25 06:37:49 +12:00
|
|
|
break;
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2019-10-06 23:30:21 +13:00
|
|
|
static int check_force_gs1(const int symbology) {
|
|
|
|
/* Returns 1 if symbology MUST have GS1 data */
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
switch (symbology) {
|
2020-07-30 07:43:08 +12:00
|
|
|
case BARCODE_GS1_128:
|
2019-10-17 22:06:21 +13:00
|
|
|
case BARCODE_EAN14:
|
|
|
|
case BARCODE_NVE18:
|
2020-07-30 07:43:08 +12:00
|
|
|
case BARCODE_DBAR_EXP:
|
|
|
|
case BARCODE_DBAR_EXPSTK:
|
2021-07-07 06:53:31 +12:00
|
|
|
return 1;
|
2019-10-06 23:30:21 +13:00
|
|
|
break;
|
|
|
|
}
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
return is_composite(symbology);
|
2019-10-06 23:30:21 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
static int gs1_compliant(const int symbology) {
|
|
|
|
/* Returns 1 if symbology supports GS1 data */
|
|
|
|
|
|
|
|
switch (symbology) {
|
2016-02-20 23:50:15 +13:00
|
|
|
case BARCODE_CODE16K:
|
|
|
|
case BARCODE_AZTEC:
|
|
|
|
case BARCODE_DATAMATRIX:
|
|
|
|
case BARCODE_CODE49:
|
|
|
|
case BARCODE_QRCODE:
|
2016-07-26 09:52:29 +12:00
|
|
|
case BARCODE_DOTCODE:
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
case BARCODE_CODEONE:
|
2020-04-08 04:41:21 +12:00
|
|
|
case BARCODE_ULTRA:
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
case BARCODE_RMQR:
|
|
|
|
// TODO: case BARCODE_CODABLOCKF:
|
|
|
|
// TODO: case BARCODE_HANXIN:
|
|
|
|
// TODO: case BARCODE_GRIDMATRIX:
|
2021-07-07 06:53:31 +12:00
|
|
|
return 1;
|
2016-02-20 23:50:15 +13:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
return check_force_gs1(symbology);
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
static int is_dotty(const int symbology) {
|
|
|
|
/* Returns 1 if symbology is a matrix design renderable as dots */
|
2016-09-06 09:06:50 +12:00
|
|
|
|
2016-08-13 06:30:46 +12:00
|
|
|
switch (symbology) {
|
2020-10-01 00:19:12 +13:00
|
|
|
/* Note MAXICODE and ULTRA absent */
|
2016-08-13 06:30:46 +12:00
|
|
|
case BARCODE_QRCODE:
|
|
|
|
case BARCODE_DATAMATRIX:
|
|
|
|
case BARCODE_MICROQR:
|
|
|
|
case BARCODE_HIBC_DM:
|
|
|
|
case BARCODE_AZTEC:
|
|
|
|
case BARCODE_HIBC_QR:
|
|
|
|
case BARCODE_HIBC_AZTEC:
|
|
|
|
case BARCODE_AZRUNE:
|
|
|
|
case BARCODE_CODEONE:
|
|
|
|
case BARCODE_GRIDMATRIX:
|
|
|
|
case BARCODE_HANXIN:
|
|
|
|
case BARCODE_DOTCODE:
|
2017-05-21 10:37:50 +12:00
|
|
|
case BARCODE_UPNQR:
|
2019-11-26 08:08:25 +13:00
|
|
|
case BARCODE_RMQR:
|
2021-07-07 06:53:31 +12:00
|
|
|
return 1;
|
2016-08-13 06:30:46 +12:00
|
|
|
break;
|
|
|
|
}
|
2016-09-06 09:06:50 +12:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
return 0;
|
2016-08-13 06:30:46 +12:00
|
|
|
}
|
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
static int is_fixed_ratio(const int symbology) {
|
|
|
|
/* Returns 1 if symbology has fixed aspect ratio (matrix design) */
|
|
|
|
|
|
|
|
if (is_dotty(symbology)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (symbology) {
|
|
|
|
case BARCODE_MAXICODE:
|
|
|
|
case BARCODE_ULTRA:
|
2021-07-07 06:53:31 +12:00
|
|
|
return 1;
|
2020-10-01 00:19:12 +13:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
return 0;
|
2020-10-01 00:19:12 +13:00
|
|
|
}
|
|
|
|
|
2016-08-16 23:43:41 +12:00
|
|
|
static int supports_eci(const int symbology) {
|
|
|
|
/* Returns 1 if symbology can encode the ECI character */
|
2016-09-06 09:06:50 +12:00
|
|
|
|
2016-08-16 23:43:41 +12:00
|
|
|
switch (symbology) {
|
|
|
|
case BARCODE_AZTEC:
|
|
|
|
case BARCODE_DATAMATRIX:
|
|
|
|
case BARCODE_MAXICODE:
|
|
|
|
case BARCODE_MICROPDF417:
|
|
|
|
case BARCODE_PDF417:
|
2020-07-30 09:35:31 +12:00
|
|
|
case BARCODE_PDF417COMP:
|
2016-08-16 23:43:41 +12:00
|
|
|
case BARCODE_QRCODE:
|
|
|
|
case BARCODE_DOTCODE:
|
2021-02-06 12:55:24 +13:00
|
|
|
case BARCODE_CODEONE:
|
2016-08-16 23:43:41 +12:00
|
|
|
case BARCODE_GRIDMATRIX:
|
|
|
|
case BARCODE_HANXIN:
|
2019-03-21 22:14:24 +13:00
|
|
|
case BARCODE_ULTRA:
|
2021-08-21 03:50:39 +12:00
|
|
|
case BARCODE_RMQR:
|
2021-07-07 06:53:31 +12:00
|
|
|
return 1;
|
2016-08-16 23:43:41 +12:00
|
|
|
break;
|
|
|
|
}
|
2016-09-06 09:06:50 +12:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
return 0;
|
2016-08-16 23:43:41 +12:00
|
|
|
}
|
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
static int has_hrt(const int symbology) {
|
|
|
|
/* Returns 1 if symbology supports HRT */
|
|
|
|
|
|
|
|
if (is_fixed_ratio(symbology)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (symbology) { /* These don't support HRT */
|
|
|
|
case BARCODE_CODE16K:
|
|
|
|
case BARCODE_CODE49:
|
|
|
|
case BARCODE_FLAT:
|
|
|
|
case BARCODE_POSTNET:
|
|
|
|
case BARCODE_FIM:
|
|
|
|
case BARCODE_PHARMA:
|
|
|
|
case BARCODE_PHARMA_TWO:
|
|
|
|
case BARCODE_PDF417:
|
|
|
|
case BARCODE_PDF417COMP:
|
|
|
|
case BARCODE_AUSPOST:
|
|
|
|
case BARCODE_AUSREPLY:
|
|
|
|
case BARCODE_AUSROUTE:
|
|
|
|
case BARCODE_AUSREDIRECT:
|
|
|
|
case BARCODE_RM4SCC:
|
|
|
|
case BARCODE_CODABLOCKF:
|
|
|
|
case BARCODE_JAPANPOST:
|
|
|
|
case BARCODE_DBAR_STK:
|
|
|
|
case BARCODE_DBAR_OMNSTK:
|
|
|
|
case BARCODE_DBAR_EXPSTK:
|
|
|
|
case BARCODE_PLANET:
|
|
|
|
case BARCODE_MICROPDF417:
|
|
|
|
case BARCODE_USPS_IMAIL:
|
|
|
|
case BARCODE_KIX:
|
|
|
|
case BARCODE_DAFT:
|
|
|
|
case BARCODE_HIBC_PDF:
|
|
|
|
case BARCODE_HIBC_MICPDF:
|
|
|
|
case BARCODE_HIBC_BLOCKF:
|
|
|
|
case BARCODE_MAILMARK:
|
|
|
|
case BARCODE_DBAR_STK_CC:
|
|
|
|
case BARCODE_DBAR_OMNSTK_CC:
|
|
|
|
case BARCODE_DBAR_EXPSTK_CC:
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
/* Used for dispatching barcodes and for whether symbol id valid */
|
|
|
|
typedef int (*barcode_func_t)(struct zint_symbol *, unsigned char *, int);
|
|
|
|
static const barcode_func_t barcode_funcs[146] = {
|
|
|
|
NULL, code11, c25standard, c25inter, c25iata, /*0-4*/
|
|
|
|
NULL, c25logic, c25ind, code39, excode39, /*5-9*/
|
|
|
|
NULL, NULL, NULL, eanx, eanx, /*10-14*/
|
|
|
|
NULL, gs1_128, NULL, codabar, NULL, /*15-19*/
|
|
|
|
code128, dpleit, dpident, code16k, code49, /*20-24*/
|
|
|
|
code93, NULL, NULL, flat, dbar_omn, /*25-29*/
|
|
|
|
dbar_ltd, dbar_exp, telepen, NULL, eanx, /*30-34*/
|
|
|
|
eanx, NULL, eanx, eanx, NULL, /*35-39*/
|
|
|
|
postnet, NULL, NULL, NULL, NULL, /*40-44*/
|
|
|
|
NULL, NULL, msi_plessey, NULL, fim, /*45-49*/
|
|
|
|
code39, pharma, pzn, pharma_two, NULL, /*50-54*/
|
|
|
|
pdf417, pdf417, maxicode, qrcode, NULL, /*55-59*/
|
|
|
|
code128, NULL, NULL, auspost, NULL, /*60-64*/
|
|
|
|
NULL, auspost, auspost, auspost, eanx, /*65-69*/
|
|
|
|
rm4scc, datamatrix, ean14, vin, codablockf, /*70-74*/
|
|
|
|
nve18, japanpost, koreapost, NULL, dbar_omn, /*75-79*/
|
|
|
|
dbar_omn, dbar_exp, planet, NULL, micropdf417, /*80-84*/
|
|
|
|
usps_imail, plessey, telepen_num, NULL, itf14, /*85-89*/
|
|
|
|
kix, NULL, aztec, daft, NULL, /*90-94*/
|
|
|
|
NULL, dpd, microqr, hibc, hibc, /*95-99*/
|
|
|
|
NULL, NULL, hibc, NULL, hibc, /*100-104*/
|
|
|
|
NULL, hibc, NULL, hibc, NULL, /*105-109*/
|
|
|
|
hibc, NULL, hibc, NULL, NULL, /*110-114*/
|
|
|
|
dotcode, hanxin, NULL, NULL, NULL, /*115-119*/
|
|
|
|
NULL, mailmark, NULL, NULL, NULL, /*120-124*/
|
|
|
|
NULL, NULL, NULL, azrune, code32, /*125-129*/
|
|
|
|
composite, composite, composite, composite, composite, /*130-134*/
|
|
|
|
composite, composite, composite, composite, composite, /*135-139*/
|
|
|
|
channel, codeone, gridmatrix, upnqr, ultra, /*140-144*/
|
|
|
|
rmqr,
|
|
|
|
};
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length);
|
2019-11-28 05:16:14 +13:00
|
|
|
|
2020-10-27 01:21:43 +13:00
|
|
|
static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char *source, const int length) {
|
2016-02-20 23:50:15 +13:00
|
|
|
int error_number = 0;
|
2019-11-28 05:16:14 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
switch (symbol->symbology) {
|
2019-11-28 05:16:14 +13:00
|
|
|
/* These are the "elite" standards which have support for specific character sets */
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
case BARCODE_QRCODE:
|
|
|
|
case BARCODE_MICROQR:
|
|
|
|
case BARCODE_GRIDMATRIX:
|
|
|
|
case BARCODE_HANXIN:
|
|
|
|
case BARCODE_UPNQR:
|
|
|
|
case BARCODE_RMQR:
|
|
|
|
error_number = (*barcode_funcs[symbol->symbology])(symbol, source, length);
|
2019-11-26 08:08:25 +13:00
|
|
|
break;
|
2019-11-28 05:16:14 +13:00
|
|
|
default: error_number = reduced_charset(symbol, source, length);
|
|
|
|
break;
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2009-11-23 04:38:15 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
/* These are the "norm" standards which only support Latin-1 at most, though a few support ECI */
|
2021-07-07 06:53:31 +12:00
|
|
|
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length) {
|
2016-02-20 23:50:15 +13:00
|
|
|
int error_number = 0;
|
2020-10-27 01:21:43 +13:00
|
|
|
unsigned char *preprocessed = source;
|
2016-02-20 23:50:15 +13:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
int eci_length = get_eci_length(symbol->eci, source, length);
|
2009-11-23 04:38:15 +13:00
|
|
|
#ifndef _MSC_VER
|
2021-01-12 07:11:41 +13:00
|
|
|
unsigned char preprocessed_buf[eci_length + 1];
|
2009-11-23 04:38:15 +13:00
|
|
|
#else
|
2021-01-12 07:11:41 +13:00
|
|
|
unsigned char *preprocessed_buf = (unsigned char *) _alloca(eci_length + 1);
|
2009-11-23 04:38:15 +13:00
|
|
|
#endif
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2021-01-12 07:11:41 +13:00
|
|
|
if ((symbol->input_mode & 0x07) == UNICODE_MODE && is_eci_convertible(symbol->eci)) {
|
2020-10-27 01:21:43 +13:00
|
|
|
/* Prior check ensures ECI only set for those that support it */
|
|
|
|
preprocessed = preprocessed_buf;
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = utf8_to_eci(symbol->eci, source, preprocessed, &length);
|
2020-10-27 01:21:43 +13:00
|
|
|
if (error_number != 0) {
|
2021-07-07 06:53:31 +12:00
|
|
|
if (symbol->eci) {
|
|
|
|
sprintf(symbol->errtxt, "244: Invalid character in input data for ECI %d", symbol->eci);
|
|
|
|
} else {
|
|
|
|
strcpy(symbol->errtxt, "204: Invalid character in input data (ISO/IEC 8859-1 only)");
|
|
|
|
}
|
2020-10-27 01:21:43 +13:00
|
|
|
return error_number;
|
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2019-12-02 03:09:46 +13:00
|
|
|
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
error_number = (*barcode_funcs[symbol->symbology])(symbol, preprocessed, length);
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2021-06-11 03:20:14 +12:00
|
|
|
STATIC_UNLESS_ZINT_TEST void strip_bom(unsigned char *source, int *input_length) {
|
2017-10-10 07:59:02 +13:00
|
|
|
int i;
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2021-01-13 08:51:54 +13:00
|
|
|
/* Note if BOM is only data then not stripped */
|
|
|
|
if (*input_length > 3 && (source[0] == 0xef) && (source[1] == 0xbb) && (source[2] == 0xbf)) {
|
|
|
|
/* BOM at start of input data, strip in accordance with RFC 3629 */
|
|
|
|
for (i = 3; i <= *input_length; i++) { /* Include terminating NUL */
|
|
|
|
source[i - 3] = source[i];
|
2017-10-10 07:59:02 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
*input_length -= 3;
|
2017-10-10 07:59:02 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-19 13:37:55 +13:00
|
|
|
static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_string, int *length) {
|
2017-10-22 00:45:50 +13:00
|
|
|
int in_posn, out_posn;
|
|
|
|
int hex1, hex2;
|
2020-08-04 22:48:43 +12:00
|
|
|
int i, unicode;
|
2017-10-22 00:45:50 +13:00
|
|
|
|
|
|
|
#ifndef _MSC_VER
|
|
|
|
unsigned char escaped_string[*length + 1];
|
|
|
|
#else
|
2021-05-15 23:23:46 +12:00
|
|
|
unsigned char *escaped_string = (unsigned char *) _alloca(*length + 1);
|
2017-10-22 00:45:50 +13:00
|
|
|
#endif
|
|
|
|
|
|
|
|
in_posn = 0;
|
|
|
|
out_posn = 0;
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2017-10-22 00:45:50 +13:00
|
|
|
do {
|
|
|
|
if (input_string[in_posn] == '\\') {
|
2020-05-16 21:22:33 +12:00
|
|
|
if (in_posn + 1 >= *length) {
|
|
|
|
strcpy(symbol->errtxt, "236: Incomplete escape character in input data");
|
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
|
|
|
}
|
2017-10-22 00:45:50 +13:00
|
|
|
switch (input_string[in_posn + 1]) {
|
|
|
|
case '0': escaped_string[out_posn] = 0x00; /* Null */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'E': escaped_string[out_posn] = 0x04; /* End of Transmission */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'a': escaped_string[out_posn] = 0x07; /* Bell */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'b': escaped_string[out_posn] = 0x08; /* Backspace */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 't': escaped_string[out_posn] = 0x09; /* Horizontal tab */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'n': escaped_string[out_posn] = 0x0a; /* Line feed */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'v': escaped_string[out_posn] = 0x0b; /* Vertical tab */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'f': escaped_string[out_posn] = 0x0c; /* Form feed */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'r': escaped_string[out_posn] = 0x0d; /* Carriage return */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'e': escaped_string[out_posn] = 0x1b; /* Escape */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'G': escaped_string[out_posn] = 0x1d; /* Group Separator */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'R': escaped_string[out_posn] = 0x1e; /* Record Separator */
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
|
|
|
case 'x': if (in_posn + 4 > *length) {
|
|
|
|
strcpy(symbol->errtxt, "232: Incomplete escape character in input data");
|
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
|
|
|
}
|
|
|
|
hex1 = ctoi(input_string[in_posn + 2]);
|
|
|
|
hex2 = ctoi(input_string[in_posn + 3]);
|
|
|
|
if ((hex1 >= 0) && (hex2 >= 0)) {
|
2021-01-16 03:22:32 +13:00
|
|
|
escaped_string[out_posn] = (hex1 << 4) + hex2;
|
2017-10-22 00:45:50 +13:00
|
|
|
in_posn += 4;
|
|
|
|
} else {
|
|
|
|
strcpy(symbol->errtxt, "233: Corrupt escape character in input data");
|
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '\\': escaped_string[out_posn] = '\\';
|
|
|
|
in_posn += 2;
|
|
|
|
break;
|
2020-08-04 22:48:43 +12:00
|
|
|
case 'u':
|
|
|
|
if (in_posn + 6 > *length) {
|
2021-01-16 03:22:32 +13:00
|
|
|
strcpy(symbol->errtxt, "209: Incomplete Unicode escape character in input data");
|
2020-08-04 22:48:43 +12:00
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
|
|
|
}
|
|
|
|
unicode = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (ctoi(input_string[in_posn + i + 2]) == -1) {
|
2021-01-16 03:22:32 +13:00
|
|
|
strcpy(symbol->errtxt, "211: Corrupt Unicode escape character in input data");
|
2020-08-04 22:48:43 +12:00
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
|
|
|
}
|
|
|
|
unicode = unicode << 4;
|
|
|
|
unicode += ctoi(input_string[in_posn + i + 2]);
|
|
|
|
}
|
2021-01-16 03:22:32 +13:00
|
|
|
/* Exclude reversed BOM and surrogates */
|
|
|
|
if (unicode == 0xfffe || (unicode >= 0xd800 && unicode < 0xe000)) {
|
|
|
|
strcpy(symbol->errtxt, "246: Invalid Unicode BMP escape character in input data");
|
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
|
|
|
}
|
2020-08-04 22:48:43 +12:00
|
|
|
if (unicode >= 0x800) {
|
|
|
|
escaped_string[out_posn] = 0xe0 + ((unicode & 0xf000) >> 12);
|
|
|
|
out_posn++;
|
|
|
|
escaped_string[out_posn] = 0x80 + ((unicode & 0x0fc0) >> 6);
|
|
|
|
out_posn++;
|
|
|
|
escaped_string[out_posn] = 0x80 + (unicode & 0x003f);
|
|
|
|
} else if (unicode >= 0x80) {
|
|
|
|
escaped_string[out_posn] = 0xc0 + ((unicode & 0x07c0) >> 6);
|
|
|
|
out_posn++;
|
|
|
|
escaped_string[out_posn] = 0x80 + (unicode & 0x003f);
|
|
|
|
} else {
|
|
|
|
escaped_string[out_posn] = unicode & 0x7f;
|
|
|
|
}
|
|
|
|
in_posn += 6;
|
|
|
|
break;
|
2017-10-22 00:45:50 +13:00
|
|
|
default: strcpy(symbol->errtxt, "234: Unrecognised escape character in input data");
|
|
|
|
return ZINT_ERROR_INVALID_DATA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
escaped_string[out_posn] = input_string[in_posn];
|
|
|
|
in_posn++;
|
|
|
|
}
|
|
|
|
out_posn++;
|
|
|
|
} while (in_posn < *length);
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2017-10-22 00:45:50 +13:00
|
|
|
memcpy(input_string, escaped_string, out_posn);
|
2018-01-14 04:45:26 +13:00
|
|
|
input_string[out_posn] = '\0';
|
2017-10-22 00:45:50 +13:00
|
|
|
*length = out_posn;
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
return 0;
|
2017-10-22 00:45:50 +13:00
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Encode a barcode. If `length` is 0, `source` must be NUL-terminated. */
|
|
|
|
int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int length) {
|
2021-01-13 08:51:54 +13:00
|
|
|
int error_number, warn_number;
|
2015-08-18 23:50:42 +12:00
|
|
|
#ifdef _MSC_VER
|
2021-01-12 07:11:41 +13:00
|
|
|
unsigned char *local_source;
|
2015-08-18 23:50:42 +12:00
|
|
|
#endif
|
2020-10-01 00:19:12 +13:00
|
|
|
|
|
|
|
if (!symbol) return ZINT_ERROR_INVALID_DATA;
|
|
|
|
|
2020-12-22 08:30:07 +13:00
|
|
|
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
|
|
|
printf("ZBarcode_Encode: symbology: %d, input_mode: 0x%X, ECI: %d, option_1: %d, option_2: %d,"
|
2021-05-29 01:37:57 +12:00
|
|
|
" option_3: %d, scale: %g\n output_options: 0x%X, fg: %s, bg: %s,"
|
2021-07-27 02:29:05 +12:00
|
|
|
" length: %d, First 10 source: \"%.*s\", First 10 primary: \"%.10s\"\n",
|
2020-12-22 08:30:07 +13:00
|
|
|
symbol->symbology, symbol->input_mode, symbol->eci, symbol->option_1, symbol->option_2,
|
2021-05-29 01:37:57 +12:00
|
|
|
symbol->option_3, symbol->scale, symbol->output_options, symbol->fgcolour, symbol->bgcolour,
|
2021-07-27 02:29:05 +12:00
|
|
|
length, length < 10 ? length : 10, source ? (const char *) source : "<NULL>", symbol->primary);
|
2020-12-22 08:30:07 +13:00
|
|
|
}
|
|
|
|
|
2021-01-13 08:51:54 +13:00
|
|
|
warn_number = 0;
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
if (source == NULL) {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "200: Input data NULL");
|
2020-10-01 00:19:12 +13:00
|
|
|
}
|
2021-07-07 06:53:31 +12:00
|
|
|
if (length <= 0) {
|
|
|
|
length = (int) ustrlen(source);
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2021-07-07 06:53:31 +12:00
|
|
|
if (length <= 0) {
|
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "205: No input data");
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2021-07-07 06:53:31 +12:00
|
|
|
if (length > ZINT_MAX_DATA_LEN) {
|
|
|
|
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "243: Input data too long");
|
2020-12-22 08:30:07 +13:00
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
|
|
|
|
/* First check the symbology field */
|
2020-11-02 07:32:55 +13:00
|
|
|
if (!ZBarcode_ValidID(symbol->symbology)) {
|
2021-07-07 06:53:31 +12:00
|
|
|
int orig_symbology = symbol->symbology; /* For self-check */
|
2020-11-02 07:32:55 +13:00
|
|
|
if (symbol->symbology < 1) {
|
2021-07-07 06:53:31 +12:00
|
|
|
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "206: Symbology out of range");
|
|
|
|
if (warn_number >= ZINT_ERROR) {
|
|
|
|
return warn_number;
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2021-07-07 06:53:31 +12:00
|
|
|
/* symbol->symbologys 1 to 126 are defined by tbarcode */
|
2020-11-02 07:32:55 +13:00
|
|
|
} else if (symbol->symbology == 5) {
|
|
|
|
symbol->symbology = BARCODE_C25STANDARD;
|
|
|
|
} else if ((symbol->symbology >= 10) && (symbol->symbology <= 12)) {
|
|
|
|
symbol->symbology = BARCODE_EANX;
|
|
|
|
} else if (symbol->symbology == 15) {
|
|
|
|
symbol->symbology = BARCODE_EANX;
|
|
|
|
} else if (symbol->symbology == 17) {
|
|
|
|
symbol->symbology = BARCODE_UPCA;
|
|
|
|
} else if (symbol->symbology == 19) {
|
2021-07-07 06:53:31 +12:00
|
|
|
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "207: Codabar 18 not supported");
|
|
|
|
if (warn_number >= ZINT_ERROR) {
|
|
|
|
return warn_number;
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
symbol->symbology = BARCODE_CODABAR;
|
2021-07-07 06:53:31 +12:00
|
|
|
} else if (symbol->symbology == 26) { /* UPC-A up to tbarcode 9, ISSN for tbarcode 10+ */
|
2020-11-02 07:32:55 +13:00
|
|
|
symbol->symbology = BARCODE_UPCA;
|
2021-07-07 06:53:31 +12:00
|
|
|
} else if (symbol->symbology == 27) { /* UPCD1 up to tbarcode 9, ISSN + 2 digit add-on for tbarcode 10+ */
|
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "208: UPCD1 not supported");
|
2020-11-02 07:32:55 +13:00
|
|
|
} else if (symbol->symbology == 33) {
|
|
|
|
symbol->symbology = BARCODE_GS1_128;
|
|
|
|
} else if (symbol->symbology == 36) {
|
|
|
|
symbol->symbology = BARCODE_UPCA;
|
2021-07-07 06:53:31 +12:00
|
|
|
} else if (symbol->symbology == 39) {
|
|
|
|
symbol->symbology = BARCODE_UPCE;
|
2020-11-02 07:32:55 +13:00
|
|
|
} else if ((symbol->symbology >= 41) && (symbol->symbology <= 45)) {
|
|
|
|
symbol->symbology = BARCODE_POSTNET;
|
|
|
|
} else if (symbol->symbology == 46) {
|
|
|
|
symbol->symbology = BARCODE_PLESSEY;
|
|
|
|
} else if (symbol->symbology == 48) {
|
|
|
|
symbol->symbology = BARCODE_NVE18;
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
} else if (symbol->symbology == 54) { /* General Parcel up to tbarcode 9, Brazilian CEPNet for tbarcode 10+ */
|
2021-07-07 06:53:31 +12:00
|
|
|
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "210: General Parcel Code not supported");
|
|
|
|
if (warn_number >= ZINT_ERROR) {
|
|
|
|
return warn_number;
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2020-11-02 07:32:55 +13:00
|
|
|
} else if ((symbol->symbology == 59) || (symbol->symbology == 61)) {
|
2020-08-22 22:09:57 +12:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2020-11-02 07:32:55 +13:00
|
|
|
} else if (symbol->symbology == 62) {
|
|
|
|
symbol->symbology = BARCODE_CODE93;
|
|
|
|
} else if ((symbol->symbology == 64) || (symbol->symbology == 65)) {
|
|
|
|
symbol->symbology = BARCODE_AUSPOST;
|
|
|
|
} else if (symbol->symbology == 78) {
|
|
|
|
symbol->symbology = BARCODE_DBAR_OMN;
|
|
|
|
} else if (symbol->symbology == 83) {
|
|
|
|
symbol->symbology = BARCODE_PLANET;
|
|
|
|
} else if (symbol->symbology == 88) {
|
|
|
|
symbol->symbology = BARCODE_GS1_128;
|
2021-07-07 06:53:31 +12:00
|
|
|
} else if (symbol->symbology == 91) { /* BC412 up to tbarcode 9, Code 32 for tbarcode 10+ */
|
|
|
|
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "212: Symbology out of range");
|
|
|
|
if (warn_number >= ZINT_ERROR) {
|
|
|
|
return warn_number;
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2020-11-02 07:32:55 +13:00
|
|
|
} else if ((symbol->symbology >= 94) && (symbol->symbology <= 95)) {
|
2021-07-07 06:53:31 +12:00
|
|
|
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "213: Symbology out of range");
|
|
|
|
if (warn_number >= ZINT_ERROR) {
|
|
|
|
return warn_number;
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2020-11-02 07:32:55 +13:00
|
|
|
} else if (symbol->symbology == 100) {
|
|
|
|
symbol->symbology = BARCODE_HIBC_128;
|
|
|
|
} else if (symbol->symbology == 101) {
|
|
|
|
symbol->symbology = BARCODE_HIBC_39;
|
|
|
|
} else if (symbol->symbology == 103) {
|
|
|
|
symbol->symbology = BARCODE_HIBC_DM;
|
|
|
|
} else if (symbol->symbology == 105) {
|
|
|
|
symbol->symbology = BARCODE_HIBC_QR;
|
|
|
|
} else if (symbol->symbology == 107) {
|
|
|
|
symbol->symbology = BARCODE_HIBC_PDF;
|
|
|
|
} else if (symbol->symbology == 109) {
|
|
|
|
symbol->symbology = BARCODE_HIBC_MICPDF;
|
|
|
|
} else if (symbol->symbology == 111) {
|
|
|
|
symbol->symbology = BARCODE_HIBC_BLOCKF;
|
|
|
|
} else if ((symbol->symbology == 113) || (symbol->symbology == 114)) {
|
2021-07-07 06:53:31 +12:00
|
|
|
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "214: Symbology out of range");
|
|
|
|
if (warn_number >= ZINT_ERROR) {
|
|
|
|
return warn_number;
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2020-11-02 07:32:55 +13:00
|
|
|
} else if ((symbol->symbology >= 117) && (symbol->symbology <= 127)) {
|
2021-07-07 06:53:31 +12:00
|
|
|
if (symbol->symbology != 121) { /* BARCODE_MAILMARK */
|
|
|
|
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "215: Symbology out of range");
|
|
|
|
if (warn_number >= ZINT_ERROR) {
|
|
|
|
return warn_number;
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
|
|
|
/* Everything from 128 up is Zint-specific */
|
|
|
|
} else if (symbol->symbology > 145) {
|
2021-07-07 06:53:31 +12:00
|
|
|
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "216: Symbology out of range");
|
|
|
|
if (warn_number >= ZINT_ERROR) {
|
|
|
|
return warn_number;
|
2020-08-22 22:09:57 +12:00
|
|
|
}
|
2021-01-13 08:51:54 +13:00
|
|
|
symbol->symbology = BARCODE_CODE128;
|
2021-07-07 06:53:31 +12:00
|
|
|
}
|
|
|
|
if (symbol->symbology == orig_symbology) { /* Should never happen */
|
|
|
|
return error_tag(symbol, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error"); /* Not reached */
|
2020-08-22 22:09:57 +12:00
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
|
2020-11-02 07:32:55 +13:00
|
|
|
if (symbol->eci != 0) {
|
|
|
|
if (!(supports_eci(symbol->symbology))) {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "217: Symbology does not support ECI switching");
|
2021-01-13 08:51:54 +13:00
|
|
|
}
|
|
|
|
if ((symbol->eci < 0) || (symbol->eci == 1) || (symbol->eci == 2) || (symbol->eci > 999999)) {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "218: Invalid ECI mode");
|
2020-11-02 07:32:55 +13:00
|
|
|
}
|
2016-08-16 23:43:41 +12:00
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
|
2021-09-21 01:56:27 +12:00
|
|
|
if ((symbol->scale < 0.01f) || (symbol->scale > 100.0f)) {
|
2021-09-22 11:04:15 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "227: Scale out of range (0.01 to 100)");
|
2021-09-21 01:56:27 +12:00
|
|
|
}
|
2020-10-01 00:19:12 +13:00
|
|
|
if ((symbol->dot_size < 0.01f) || (symbol->dot_size > 20.0f)) {
|
2021-09-22 11:04:15 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "221: Dot size out of range (0.01 to 20)");
|
2021-09-21 01:56:27 +12:00
|
|
|
}
|
|
|
|
|
2021-10-19 02:05:51 +13:00
|
|
|
if ((symbol->height < 0.0f) || (symbol->height > 2000.0f)) { /* Allow for 44 row CODABLOCKF at 45X each */
|
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "765: Height out of range (0 to 2000)");
|
2021-09-22 11:04:15 +12:00
|
|
|
}
|
|
|
|
if ((symbol->guard_descent < 0.0f) || (symbol->guard_descent > 50.0f)) {
|
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "769: Guard bar descent out of range (0 to 50)");
|
2021-09-21 01:56:27 +12:00
|
|
|
}
|
|
|
|
if ((symbol->whitespace_width < 0) || (symbol->whitespace_width > 100)) {
|
2021-09-22 11:04:15 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "766: Whitespace width out of range (0 to 100)");
|
2021-09-21 01:56:27 +12:00
|
|
|
}
|
|
|
|
if ((symbol->whitespace_height < 0) || (symbol->whitespace_height > 100)) {
|
2021-09-22 11:04:15 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "767: Whitespace height out of range (0 to 100)");
|
2021-09-21 01:56:27 +12:00
|
|
|
}
|
|
|
|
if ((symbol->border_width < 0) || (symbol->border_width > 100)) {
|
2021-09-22 11:04:15 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "768: Border width out of range (0 to 100)");
|
2019-10-17 22:06:21 +13:00
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
if ((symbol->input_mode & 0x07) > 2) {
|
|
|
|
symbol->input_mode = DATA_MODE; /* Reset completely TODO: in future, warn/error */
|
2021-01-12 07:11:41 +13:00
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
if ((symbol->input_mode & 0x07) == UNICODE_MODE && !is_valid_utf8(source, length)) {
|
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "245: Invalid UTF-8 in input data");
|
2019-11-28 05:16:14 +13:00
|
|
|
}
|
|
|
|
|
2021-01-12 07:11:41 +13:00
|
|
|
#ifndef _MSC_VER
|
2021-07-07 06:53:31 +12:00
|
|
|
unsigned char local_source[length + 1];
|
2021-01-12 07:11:41 +13:00
|
|
|
#else
|
2021-07-07 06:53:31 +12:00
|
|
|
local_source = (unsigned char *) _alloca(length + 1);
|
2021-01-12 07:11:41 +13:00
|
|
|
#endif
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
memcpy(local_source, source, length);
|
|
|
|
local_source[length] = '\0';
|
2019-10-17 22:06:21 +13:00
|
|
|
|
|
|
|
/* Start acting on input mode */
|
2019-11-28 05:16:14 +13:00
|
|
|
if (symbol->input_mode & ESCAPE_MODE) {
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = escape_char_process(symbol, local_source, &length); /* Only returns errors, not warnings */
|
2017-10-22 00:45:50 +13:00
|
|
|
if (error_number != 0) {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, error_number, NULL);
|
2017-10-22 00:45:50 +13:00
|
|
|
}
|
|
|
|
}
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2019-11-28 05:16:14 +13:00
|
|
|
if ((symbol->input_mode & 0x07) == UNICODE_MODE) {
|
2021-07-07 06:53:31 +12:00
|
|
|
strip_bom(local_source, &length);
|
2019-11-28 05:16:14 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
if (((symbol->input_mode & 0x07) == GS1_MODE) || (check_force_gs1(symbol->symbology))) {
|
2019-10-17 22:06:21 +13:00
|
|
|
if (gs1_compliant(symbol->symbology) == 1) {
|
2020-12-23 23:57:24 +13:00
|
|
|
// Reduce input for composite and non-forced symbologies, others (EAN128 and RSS_EXP based) will
|
|
|
|
// handle it themselves
|
2019-10-17 22:06:21 +13:00
|
|
|
if (is_composite(symbol->symbology) || !check_force_gs1(symbol->symbology)) {
|
|
|
|
#ifndef _MSC_VER
|
2021-07-07 06:53:31 +12:00
|
|
|
unsigned char reduced[length + 1];
|
2019-10-17 22:06:21 +13:00
|
|
|
#else
|
2021-07-07 06:53:31 +12:00
|
|
|
unsigned char *reduced = (unsigned char *) _alloca(length + 1);
|
2019-10-17 22:06:21 +13:00
|
|
|
#endif
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = gs1_verify(symbol, local_source, length, reduced);
|
|
|
|
if (error_number) {
|
2021-07-13 09:27:16 +12:00
|
|
|
static const char in_2d_comp[] = " in 2D component";
|
|
|
|
if (is_composite(symbol->symbology)
|
|
|
|
&& strlen(symbol->errtxt) + strlen(in_2d_comp) < sizeof(symbol->errtxt)) {
|
2021-01-13 08:51:54 +13:00
|
|
|
strcat(symbol->errtxt, in_2d_comp);
|
2020-10-01 00:19:12 +13:00
|
|
|
}
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = error_tag(symbol, error_number, NULL);
|
|
|
|
if (error_number >= ZINT_ERROR) {
|
|
|
|
return error_number;
|
|
|
|
}
|
|
|
|
warn_number = error_number; /* Override any previous warning (errtxt has been overwritten) */
|
2021-01-21 10:15:03 +13:00
|
|
|
}
|
2021-07-07 06:53:31 +12:00
|
|
|
ustrcpy(local_source, reduced); // Cannot contain NUL char
|
|
|
|
length = (int) ustrlen(local_source);
|
2019-10-17 22:06:21 +13:00
|
|
|
}
|
|
|
|
} else {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "220: Selected symbology does not support GS1 mode");
|
2019-10-17 22:06:21 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = extended_or_reduced_charset(symbol, local_source, length);
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2019-11-28 05:16:14 +13:00
|
|
|
if ((error_number == ZINT_ERROR_INVALID_DATA) && symbol->eci == 0 && supports_eci(symbol->symbology)
|
|
|
|
&& (symbol->input_mode & 0x07) == UNICODE_MODE) {
|
2016-08-16 23:43:41 +12:00
|
|
|
/* Try another ECI mode */
|
2021-07-07 06:53:31 +12:00
|
|
|
symbol->eci = get_best_eci(local_source, length);
|
2021-03-22 06:35:52 +13:00
|
|
|
if (symbol->eci != 0) {
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = extended_or_reduced_charset(symbol, local_source, length);
|
|
|
|
/* Inclusion of ECI more noteworthy than other warnings, so overwrite (if any) */
|
|
|
|
if (error_number < ZINT_ERROR) {
|
2021-03-22 06:35:52 +13:00
|
|
|
error_number = ZINT_WARN_USES_ECI;
|
|
|
|
if (!(symbol->debug & ZINT_DEBUG_TEST)) {
|
2021-07-07 06:53:31 +12:00
|
|
|
sprintf(symbol->errtxt, "222: Encoded data includes ECI %d", symbol->eci);
|
2021-03-22 06:35:52 +13:00
|
|
|
}
|
|
|
|
if (symbol->debug & ZINT_DEBUG_PRINT) printf("Added ECI %d\n", symbol->eci);
|
2019-11-28 05:16:14 +13:00
|
|
|
}
|
2018-01-22 03:33:54 +13:00
|
|
|
}
|
2016-08-16 23:43:41 +12:00
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
|
2017-07-26 22:44:47 +12:00
|
|
|
if (error_number == 0) {
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = warn_number; /* Already tagged */
|
|
|
|
} else {
|
|
|
|
error_number = error_tag(symbol, error_number, NULL);
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
if (error_number < ZINT_ERROR) {
|
2021-06-20 00:11:23 +12:00
|
|
|
if (symbol->height < 0.5f) { /* Absolute minimum */
|
|
|
|
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
|
|
|
|
}
|
2016-09-15 09:34:59 +12:00
|
|
|
}
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Output a previously encoded symbol to file `symbol->outfile` */
|
2016-02-20 23:50:15 +13:00
|
|
|
int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
|
|
|
|
int error_number;
|
2021-07-07 06:53:31 +12:00
|
|
|
int len;
|
2016-02-20 23:50:15 +13:00
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!symbol) return ZINT_ERROR_INVALID_DATA;
|
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
switch (rotate_angle) {
|
|
|
|
case 0:
|
|
|
|
case 90:
|
|
|
|
case 180:
|
|
|
|
case 270:
|
|
|
|
break;
|
|
|
|
default:
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "223: Invalid rotation angle");
|
2021-01-13 08:51:54 +13:00
|
|
|
break;
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
|
2016-08-26 23:15:54 +12:00
|
|
|
if (symbol->output_options & BARCODE_DOTTY_MODE) {
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!(is_dotty(symbol->symbology))) {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "224: Selected symbology cannot be rendered as dots");
|
2016-08-13 06:30:46 +12:00
|
|
|
}
|
|
|
|
}
|
2016-09-06 09:06:50 +12:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
len = (int) strlen(symbol->outfile);
|
|
|
|
if (len > 3) {
|
2017-09-11 03:03:09 +12:00
|
|
|
char output[4];
|
2021-07-07 06:53:31 +12:00
|
|
|
output[0] = symbol->outfile[len - 3];
|
|
|
|
output[1] = symbol->outfile[len - 2];
|
|
|
|
output[2] = symbol->outfile[len - 1];
|
2016-02-20 23:50:15 +13:00
|
|
|
output[3] = '\0';
|
2021-01-13 08:51:54 +13:00
|
|
|
to_upper((unsigned char *) output);
|
2009-11-23 04:38:15 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
if (!(strcmp(output, "PNG"))) {
|
2016-07-20 10:02:39 +12:00
|
|
|
error_number = plot_raster(symbol, rotate_angle, OUT_PNG_FILE);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
} else if (!(strcmp(output, "BMP"))) {
|
2016-07-20 10:02:39 +12:00
|
|
|
error_number = plot_raster(symbol, rotate_angle, OUT_BMP_FILE);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
} else if (!(strcmp(output, "PCX"))) {
|
2016-09-06 09:06:50 +12:00
|
|
|
error_number = plot_raster(symbol, rotate_angle, OUT_PCX_FILE);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
} else if (!(strcmp(output, "GIF"))) {
|
2016-07-29 06:58:33 +12:00
|
|
|
error_number = plot_raster(symbol, rotate_angle, OUT_GIF_FILE);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
} else if (!(strcmp(output, "TIF"))) {
|
2016-12-31 09:25:58 +13:00
|
|
|
error_number = plot_raster(symbol, rotate_angle, OUT_TIF_FILE);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
} else if (!(strcmp(output, "TXT"))) {
|
2016-02-20 23:50:15 +13:00
|
|
|
error_number = dump_plot(symbol);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
} else if (!(strcmp(output, "EPS"))) {
|
2019-12-02 03:09:46 +13:00
|
|
|
error_number = plot_vector(symbol, rotate_angle, OUT_EPS_FILE);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
} else if (!(strcmp(output, "SVG"))) {
|
2018-06-18 13:36:40 +12:00
|
|
|
error_number = plot_vector(symbol, rotate_angle, OUT_SVG_FILE);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
|
|
|
} else if (!(strcmp(output, "EMF"))) {
|
2018-06-18 13:36:40 +12:00
|
|
|
error_number = plot_vector(symbol, rotate_angle, OUT_EMF_FILE);
|
2021-01-13 08:51:54 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
} else {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "225: Unknown output format");
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
} else {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "226: Unknown output format");
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, error_number, NULL);
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2021-07-13 09:27:16 +12:00
|
|
|
/* Output a previously encoded symbol to memory as raster (`symbol->bitmap`) */
|
2016-02-20 23:50:15 +13:00
|
|
|
int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
|
|
|
|
int error_number;
|
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!symbol) return ZINT_ERROR_INVALID_DATA;
|
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
switch (rotate_angle) {
|
|
|
|
case 0:
|
|
|
|
case 90:
|
|
|
|
case 180:
|
|
|
|
case 270:
|
|
|
|
break;
|
|
|
|
default:
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "228: Invalid rotation angle");
|
2021-01-13 08:51:54 +13:00
|
|
|
break;
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
if (symbol->output_options & BARCODE_DOTTY_MODE) {
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!(is_dotty(symbol->symbology))) {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "237: Selected symbology cannot be rendered as dots");
|
2020-06-05 05:45:25 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-02 22:45:47 +13:00
|
|
|
error_number = plot_raster(symbol, rotate_angle, OUT_BUFFER);
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, error_number, NULL);
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2021-07-13 09:27:16 +12:00
|
|
|
/* Output a previously encoded symbol to memory as vector (`symbol->vector`) */
|
2018-06-18 13:36:40 +12:00
|
|
|
int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
|
|
|
|
int error_number;
|
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!symbol) return ZINT_ERROR_INVALID_DATA;
|
|
|
|
|
2018-06-18 13:36:40 +12:00
|
|
|
switch (rotate_angle) {
|
|
|
|
case 0:
|
|
|
|
case 90:
|
|
|
|
case 180:
|
|
|
|
case 270:
|
|
|
|
break;
|
|
|
|
default:
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "219: Invalid rotation angle");
|
2021-01-13 08:51:54 +13:00
|
|
|
break;
|
2018-06-18 13:36:40 +12:00
|
|
|
}
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
if (symbol->output_options & BARCODE_DOTTY_MODE) {
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!(is_dotty(symbol->symbology))) {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "238: Selected symbology cannot be rendered as dots");
|
2020-06-05 05:45:25 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-18 13:36:40 +12:00
|
|
|
error_number = plot_vector(symbol, rotate_angle, OUT_BUFFER);
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, error_number, NULL);
|
2018-06-18 13:36:40 +12:00
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Encode and output a symbol to file `symbol->outfile` */
|
2021-07-13 09:27:16 +12:00
|
|
|
int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, const unsigned char *source, int length, int rotate_angle) {
|
2016-02-20 23:50:15 +13:00
|
|
|
int error_number;
|
2018-01-22 07:10:42 +13:00
|
|
|
int first_err;
|
2013-01-01 02:41:59 +13:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = ZBarcode_Encode(symbol, source, length);
|
2020-10-01 00:19:12 +13:00
|
|
|
if (error_number >= ZINT_ERROR) {
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
|
|
|
}
|
2009-11-23 04:38:15 +13:00
|
|
|
|
2018-01-22 07:10:42 +13:00
|
|
|
first_err = error_number;
|
2016-02-20 23:50:15 +13:00
|
|
|
error_number = ZBarcode_Print(symbol, rotate_angle);
|
2018-01-22 07:10:42 +13:00
|
|
|
if (error_number == 0) {
|
|
|
|
error_number = first_err;
|
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2021-07-13 09:27:16 +12:00
|
|
|
/* Encode and output a symbol to memory as raster (`symbol->bitmap`) */
|
|
|
|
int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, const unsigned char *source, int length,
|
|
|
|
int rotate_angle) {
|
2016-02-20 23:50:15 +13:00
|
|
|
int error_number;
|
2018-01-22 07:10:42 +13:00
|
|
|
int first_err;
|
2013-01-01 02:41:59 +13:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = ZBarcode_Encode(symbol, source, length);
|
2020-10-01 00:19:12 +13:00
|
|
|
if (error_number >= ZINT_ERROR) {
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
|
|
|
}
|
2009-11-23 04:38:15 +13:00
|
|
|
|
2018-01-22 07:10:42 +13:00
|
|
|
first_err = error_number;
|
2016-02-20 23:50:15 +13:00
|
|
|
error_number = ZBarcode_Buffer(symbol, rotate_angle);
|
2018-01-22 07:10:42 +13:00
|
|
|
if (error_number == 0) {
|
|
|
|
error_number = first_err;
|
|
|
|
}
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2021-07-13 09:27:16 +12:00
|
|
|
/* Encode and output a symbol to memory as vector (`symbol->vector`) */
|
|
|
|
int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, const unsigned char *source, int length,
|
2021-06-20 00:11:23 +12:00
|
|
|
int rotate_angle) {
|
2018-06-18 13:36:40 +12:00
|
|
|
int error_number;
|
|
|
|
int first_err;
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
error_number = ZBarcode_Encode(symbol, source, length);
|
2020-10-01 00:19:12 +13:00
|
|
|
if (error_number >= ZINT_ERROR) {
|
2018-06-18 13:36:40 +12:00
|
|
|
return error_number;
|
|
|
|
}
|
|
|
|
|
|
|
|
first_err = error_number;
|
|
|
|
error_number = ZBarcode_Buffer_Vector(symbol, rotate_angle);
|
|
|
|
if (error_number == 0) {
|
|
|
|
error_number = first_err;
|
|
|
|
}
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2018-06-18 13:36:40 +12:00
|
|
|
return error_number;
|
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Encode a barcode using input data from file `filename` */
|
2021-07-13 09:27:16 +12:00
|
|
|
int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) {
|
2016-02-20 23:50:15 +13:00
|
|
|
FILE *file;
|
2020-12-18 15:36:48 +13:00
|
|
|
int file_opened = 0;
|
2016-02-20 23:50:15 +13:00
|
|
|
unsigned char *buffer;
|
2020-03-27 11:17:37 +13:00
|
|
|
long fileLen;
|
|
|
|
size_t n;
|
2021-06-10 22:15:39 +12:00
|
|
|
size_t nRead = 0;
|
2016-02-20 23:50:15 +13:00
|
|
|
int ret;
|
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
if (!symbol) return ZINT_ERROR_INVALID_DATA;
|
|
|
|
|
|
|
|
if (!filename) {
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "239: Filename NULL");
|
2020-10-01 00:19:12 +13:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
if (!strcmp(filename, "-")) {
|
|
|
|
file = stdin;
|
2020-12-22 08:30:07 +13:00
|
|
|
fileLen = ZINT_MAX_DATA_LEN;
|
2016-02-20 23:50:15 +13:00
|
|
|
} else {
|
|
|
|
file = fopen(filename, "rb");
|
|
|
|
if (!file) {
|
2021-06-10 22:15:39 +12:00
|
|
|
sprintf(symbol->errtxt, "229: Unable to read input file (%d: %.30s)", errno, strerror(errno));
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2020-12-18 15:36:48 +13:00
|
|
|
file_opened = 1;
|
2016-02-20 23:50:15 +13:00
|
|
|
|
|
|
|
/* Get file length */
|
|
|
|
fseek(file, 0, SEEK_END);
|
|
|
|
fileLen = ftell(file);
|
|
|
|
fseek(file, 0, SEEK_SET);
|
|
|
|
|
2020-12-23 23:57:24 +13:00
|
|
|
/* On many Linux distros ftell() returns LONG_MAX not -1 on error */
|
|
|
|
if (fileLen <= 0 || fileLen == LONG_MAX) {
|
2016-02-20 23:50:15 +13:00
|
|
|
fclose(file);
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "235: Input file empty or unseekable");
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
2020-12-22 08:30:07 +13:00
|
|
|
if (fileLen > ZINT_MAX_DATA_LEN) {
|
2020-03-27 11:17:37 +13:00
|
|
|
fclose(file);
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "230: Input file too long");
|
2020-03-27 11:17:37 +13:00
|
|
|
}
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory */
|
2021-01-12 07:11:41 +13:00
|
|
|
buffer = (unsigned char *) malloc(fileLen);
|
2016-02-20 23:50:15 +13:00
|
|
|
if (!buffer) {
|
2020-12-18 15:36:48 +13:00
|
|
|
if (file_opened) {
|
2016-02-20 23:50:15 +13:00
|
|
|
fclose(file);
|
2020-03-27 11:17:37 +13:00
|
|
|
}
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_MEMORY, "231: Insufficient memory for file read buffer");
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read file contents into buffer */
|
|
|
|
|
|
|
|
do {
|
|
|
|
n = fread(buffer + nRead, 1, fileLen - nRead, file);
|
|
|
|
if (ferror(file)) {
|
2021-06-10 22:15:39 +12:00
|
|
|
sprintf(symbol->errtxt, "241: Input file read error (%d: %.30s)", errno, strerror(errno));
|
2020-12-18 15:36:48 +13:00
|
|
|
if (file_opened) {
|
2020-03-27 11:17:37 +13:00
|
|
|
fclose(file);
|
|
|
|
}
|
|
|
|
free(buffer);
|
2021-07-07 06:53:31 +12:00
|
|
|
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
|
2016-02-20 23:50:15 +13:00
|
|
|
}
|
|
|
|
nRead += n;
|
2021-06-10 22:15:39 +12:00
|
|
|
} while (!feof(file) && (0 < n) && ((long) nRead < fileLen));
|
2016-02-20 23:50:15 +13:00
|
|
|
|
2020-12-18 15:36:48 +13:00
|
|
|
if (file_opened) {
|
2020-03-27 11:17:37 +13:00
|
|
|
fclose(file);
|
|
|
|
}
|
2021-06-27 22:47:55 +12:00
|
|
|
ret = ZBarcode_Encode(symbol, buffer, (int) nRead);
|
2016-02-20 23:50:15 +13:00
|
|
|
free(buffer);
|
|
|
|
return ret;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Encode a symbol using input data from file `filename` and output to file `symbol->outfile` */
|
2021-07-13 09:27:16 +12:00
|
|
|
int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, const char *filename, int rotate_angle) {
|
2016-02-20 23:50:15 +13:00
|
|
|
int error_number;
|
2018-01-22 07:10:42 +13:00
|
|
|
int first_err;
|
2013-01-01 02:41:59 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
error_number = ZBarcode_Encode_File(symbol, filename);
|
2020-10-01 00:19:12 +13:00
|
|
|
if (error_number >= ZINT_ERROR) {
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
|
|
|
}
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2018-01-22 07:10:42 +13:00
|
|
|
first_err = error_number;
|
|
|
|
error_number = ZBarcode_Print(symbol, rotate_angle);
|
|
|
|
if (error_number == 0) {
|
|
|
|
error_number = first_err;
|
|
|
|
}
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2018-01-22 07:10:42 +13:00
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`) */
|
2021-07-13 09:27:16 +12:00
|
|
|
int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char const *filename, int rotate_angle) {
|
2016-02-20 23:50:15 +13:00
|
|
|
int error_number;
|
2018-01-22 07:10:42 +13:00
|
|
|
int first_err;
|
2013-01-01 02:41:59 +13:00
|
|
|
|
2016-02-20 23:50:15 +13:00
|
|
|
error_number = ZBarcode_Encode_File(symbol, filename);
|
2020-10-01 00:19:12 +13:00
|
|
|
if (error_number >= ZINT_ERROR) {
|
2016-02-20 23:50:15 +13:00
|
|
|
return error_number;
|
|
|
|
}
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2018-01-22 07:10:42 +13:00
|
|
|
first_err = error_number;
|
|
|
|
error_number = ZBarcode_Buffer(symbol, rotate_angle);
|
|
|
|
if (error_number == 0) {
|
|
|
|
error_number = first_err;
|
|
|
|
}
|
2013-01-01 02:41:59 +13:00
|
|
|
|
2018-01-22 07:10:42 +13:00
|
|
|
return error_number;
|
2009-11-23 04:38:15 +13:00
|
|
|
}
|
2010-05-31 05:25:24 +12:00
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`) */
|
2021-07-13 09:27:16 +12:00
|
|
|
int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, const char *filename, int rotate_angle) {
|
2018-06-18 13:36:40 +12:00
|
|
|
int error_number;
|
|
|
|
int first_err;
|
|
|
|
|
|
|
|
error_number = ZBarcode_Encode_File(symbol, filename);
|
2020-10-01 00:19:12 +13:00
|
|
|
if (error_number >= ZINT_ERROR) {
|
2018-06-18 13:36:40 +12:00
|
|
|
return error_number;
|
|
|
|
}
|
2019-12-02 03:09:46 +13:00
|
|
|
|
2018-06-18 13:36:40 +12:00
|
|
|
first_err = error_number;
|
|
|
|
error_number = ZBarcode_Buffer_Vector(symbol, rotate_angle);
|
|
|
|
if (error_number == 0) {
|
|
|
|
error_number = first_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error_number;
|
|
|
|
}
|
|
|
|
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
/* Checks whether a symbology is supported */
|
2021-07-13 09:27:16 +12:00
|
|
|
int ZBarcode_ValidID(int symbol_id) {
|
|
|
|
|
|
|
|
if (symbol_id <= 0 || symbol_id > 145) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
return barcode_funcs[symbol_id] != NULL;
|
2021-07-13 09:27:16 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
|
|
|
|
unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
|
|
|
|
unsigned int result = 0;
|
|
|
|
|
|
|
|
if (!ZBarcode_ValidID(symbol_id)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cap_flag & ZINT_CAP_HRT) && has_hrt(symbol_id)) {
|
|
|
|
result |= ZINT_CAP_HRT;
|
|
|
|
}
|
|
|
|
if ((cap_flag & ZINT_CAP_STACKABLE) && is_stackable(symbol_id)) {
|
|
|
|
result |= ZINT_CAP_STACKABLE;
|
|
|
|
}
|
|
|
|
if ((cap_flag & ZINT_CAP_EXTENDABLE) && is_extendable(symbol_id)) {
|
|
|
|
result |= ZINT_CAP_EXTENDABLE;
|
|
|
|
}
|
|
|
|
if ((cap_flag & ZINT_CAP_COMPOSITE) && is_composite(symbol_id)) {
|
|
|
|
result |= ZINT_CAP_COMPOSITE;
|
|
|
|
}
|
|
|
|
if ((cap_flag & ZINT_CAP_ECI) && supports_eci(symbol_id)) {
|
|
|
|
result |= ZINT_CAP_ECI;
|
|
|
|
}
|
|
|
|
if ((cap_flag & ZINT_CAP_GS1) && gs1_compliant(symbol_id)) {
|
|
|
|
result |= ZINT_CAP_GS1;
|
|
|
|
}
|
|
|
|
if ((cap_flag & ZINT_CAP_DOTTY) && is_dotty(symbol_id)) {
|
|
|
|
result |= ZINT_CAP_DOTTY;
|
|
|
|
}
|
2021-09-25 00:21:24 +12:00
|
|
|
if (cap_flag & ZINT_CAP_QUIET_ZONES) {
|
|
|
|
switch (symbol_id) { /* See `quiet_zones()` in "output.c" */
|
|
|
|
case BARCODE_CODE16K:
|
|
|
|
case BARCODE_CODE49:
|
|
|
|
case BARCODE_CODABLOCKF:
|
|
|
|
case BARCODE_HIBC_BLOCKF:
|
|
|
|
case BARCODE_ITF14:
|
|
|
|
case BARCODE_EANX:
|
|
|
|
case BARCODE_EANX_CHK:
|
|
|
|
case BARCODE_EANX_CC:
|
|
|
|
case BARCODE_ISBNX:
|
|
|
|
case BARCODE_UPCA:
|
|
|
|
case BARCODE_UPCA_CHK:
|
|
|
|
case BARCODE_UPCA_CC:
|
|
|
|
case BARCODE_UPCE:
|
|
|
|
case BARCODE_UPCE_CHK:
|
|
|
|
case BARCODE_UPCE_CC:
|
|
|
|
result |= ZINT_CAP_QUIET_ZONES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-07-13 09:27:16 +12:00
|
|
|
if ((cap_flag & ZINT_CAP_FIXED_RATIO) && is_fixed_ratio(symbol_id)) {
|
|
|
|
result |= ZINT_CAP_FIXED_RATIO;
|
|
|
|
}
|
|
|
|
if (cap_flag & ZINT_CAP_READER_INIT) {
|
|
|
|
/* Note does not include HIBC versions */
|
|
|
|
switch (symbol_id) {
|
|
|
|
case BARCODE_CODE128: /* Note does not include GS1_128 or NVE18 */
|
|
|
|
case BARCODE_CODE128B:
|
|
|
|
case BARCODE_CODE16K:
|
|
|
|
case BARCODE_CODABLOCKF:
|
|
|
|
case BARCODE_PDF417:
|
|
|
|
case BARCODE_PDF417COMP:
|
|
|
|
case BARCODE_DATAMATRIX:
|
|
|
|
case BARCODE_MICROPDF417:
|
|
|
|
case BARCODE_AZTEC:
|
|
|
|
case BARCODE_DOTCODE:
|
|
|
|
case BARCODE_GRIDMATRIX:
|
|
|
|
case BARCODE_ULTRA:
|
|
|
|
result |= ZINT_CAP_READER_INIT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cap_flag & ZINT_CAP_FULL_MULTIBYTE) {
|
|
|
|
switch (symbol_id) {
|
|
|
|
case BARCODE_QRCODE:
|
|
|
|
case BARCODE_MICROQR:
|
|
|
|
//case BARCODE_HIBC_QR: Note character set restricted to ASCII subset
|
|
|
|
//case BARCODE_UPNQR: Note does not use Kanji mode
|
|
|
|
case BARCODE_RMQR:
|
|
|
|
case BARCODE_HANXIN:
|
|
|
|
case BARCODE_GRIDMATRIX:
|
|
|
|
result |= ZINT_CAP_FULL_MULTIBYTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cap_flag & ZINT_CAP_MASK) {
|
|
|
|
switch (symbol_id) {
|
|
|
|
case BARCODE_QRCODE:
|
|
|
|
case BARCODE_MICROQR:
|
|
|
|
case BARCODE_HANXIN:
|
|
|
|
case BARCODE_DOTCODE:
|
|
|
|
result |= ZINT_CAP_MASK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
if (cap_flag & ZINT_CAP_STRUCTAPP) {
|
|
|
|
switch (symbol_id) {
|
|
|
|
case BARCODE_PDF417:
|
|
|
|
case BARCODE_PDF417COMP:
|
|
|
|
case BARCODE_MAXICODE:
|
|
|
|
case BARCODE_QRCODE: /* Note does not include MICROQR, UPNQR or rMQR */
|
|
|
|
case BARCODE_DATAMATRIX:
|
|
|
|
case BARCODE_MICROPDF417:
|
|
|
|
case BARCODE_AZTEC:
|
|
|
|
case BARCODE_HIBC_DM:
|
|
|
|
case BARCODE_HIBC_QR:
|
|
|
|
case BARCODE_HIBC_PDF:
|
|
|
|
case BARCODE_HIBC_MICPDF:
|
|
|
|
case BARCODE_HIBC_AZTEC:
|
|
|
|
case BARCODE_DOTCODE:
|
|
|
|
case BARCODE_CODEONE:
|
|
|
|
case BARCODE_GRIDMATRIX:
|
|
|
|
case BARCODE_ULTRA:
|
|
|
|
result |= ZINT_CAP_STRUCTAPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
|
|
|
if ((cap_flag & ZINT_CAP_COMPLIANT_HEIGHT) && !is_fixed_ratio(symbol_id)) {
|
|
|
|
switch (symbol_id) {
|
|
|
|
/* These don't have a compliant height defined */
|
|
|
|
case BARCODE_CODE11: /* TODO: Find doc */
|
|
|
|
case BARCODE_C25STANDARD: /* For C25 only have doc for C25INTER */
|
|
|
|
case BARCODE_C25IATA:
|
|
|
|
case BARCODE_C25LOGIC:
|
|
|
|
case BARCODE_C25IND:
|
|
|
|
case BARCODE_CODE128: /* Left to application */
|
|
|
|
case BARCODE_CODE128B:
|
|
|
|
case BARCODE_DPLEIT: /* TODO: Find doc */
|
|
|
|
case BARCODE_DPIDENT: /* TODO: Find doc */
|
|
|
|
case BARCODE_FLAT: /* TODO: Find doc */
|
|
|
|
case BARCODE_MSI_PLESSEY: /* TODO: Find doc */
|
|
|
|
case BARCODE_PDF417: /* Has compliant height but already warns & uses for default */
|
|
|
|
case BARCODE_PDF417COMP:
|
|
|
|
case BARCODE_VIN: /* Spec unlikely */
|
|
|
|
case BARCODE_KOREAPOST: /* TODO: Find doc */
|
|
|
|
case BARCODE_MICROPDF417: /* See PDF417 */
|
|
|
|
case BARCODE_PLESSEY: /* TODO: Find doc */
|
|
|
|
case BARCODE_DAFT: /* Generic */
|
|
|
|
case BARCODE_HIBC_128: /* See CODE128 */
|
|
|
|
case BARCODE_HIBC_PDF: /* See PDF417 */
|
|
|
|
case BARCODE_HIBC_MICPDF: /* See PDF417 */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result |= ZINT_CAP_COMPLIANT_HEIGHT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-07-13 09:27:16 +12:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-07-07 06:53:31 +12:00
|
|
|
/* Return the version of Zint linked to */
|
2017-07-01 20:06:47 +12:00
|
|
|
int ZBarcode_Version() {
|
2020-09-05 03:38:11 +12:00
|
|
|
if (ZINT_VERSION_BUILD) {
|
2020-12-22 08:30:07 +13:00
|
|
|
return (ZINT_VERSION_MAJOR * 10000) + (ZINT_VERSION_MINOR * 100) + ZINT_VERSION_RELEASE * 10
|
|
|
|
+ ZINT_VERSION_BUILD;
|
2020-09-05 03:38:11 +12:00
|
|
|
}
|
2017-07-01 20:06:47 +12:00
|
|
|
return (ZINT_VERSION_MAJOR * 10000) + (ZINT_VERSION_MINOR * 100) + ZINT_VERSION_RELEASE;
|
2017-06-14 07:05:35 +12:00
|
|
|
}
|