wxMaxima
Loading...
Searching...
No Matches
zint.h
1/* zint.h - definitions for libzint */
2/*
3 libzint - the open source barcode library
4 Copyright (C) 2009-2026 Robin Stuart <rstuart114@gmail.com>
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 3. Neither the name of the project nor the names of its contributors
16 may be used to endorse or promote products derived from this software
17 without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 SUCH DAMAGE.
30 */
31/* SPDX-License-Identifier: BSD-3-Clause */
32
33/*
34 * Version: 2.16.0.9 (dev) (see "zintconfig.h")
35 *
36 * For documentation, see "../docs/manual.txt" or "../docs/manual.html" or the
37 * PDF manual for 2.16.0 at
38 * https://sourceforge.net/projects/zint/files/zint/2.16.0/manual.pdf/download
39 * or online at
40 * https://zint.org.uk/manual/
41 */
42
43#ifndef ZINT_H
44#define ZINT_H
45
46#ifdef __cplusplus
47extern "C" {
48#endif /* __cplusplus */
49
50 /* Vector elements - see vector header `zint_vector` below */
52 float x, y; /* Top left */
53 float height, width;
54 int colour; /* -1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White */
55 struct zint_vector_rect *next; /* Pointer to next rectangle */
56 };
57
59 float x, y; /* Centre */
60 float diameter; /* Short (minimal) diameter (i.e. diameter of inscribed circle) */
61 int rotation; /* 0, 90, 180, 270 degrees, where 0 has apex at top, i.e. short diameter is horizontal */
62 struct zint_vector_hexagon *next; /* Pointer to next hexagon */
63 };
64
66 float x, y; /* x is relative to halign (i.e. centre, left, right), y is relative to baseline */
67 float fsize; /* Font size */
68 float width; /* Rendered width estimate */
69 int length; /* Number of characters (bytes) */
70 int rotation; /* 0, 90, 180, 270 degrees */
71 int halign; /* Horizontal alignment: 0 for centre, 1 for left, 2 for right (end) */
72 unsigned char *text; /* UTF-8, NUL-terminated */
73 struct zint_vector_string *next; /* Pointer to next string */
74 };
75
77 float x, y; /* Centre */
78 float diameter; /* Circle diameter. Does not include width (if any) */
79 float width; /* Width of circle perimeter (circumference). 0 for fill (disc) */
80 int colour; /* Zero for draw with foreground colour (else draw with background colour (legacy)) */
81 struct zint_vector_circle *next; /* Pointer to next circle */
82 };
83
84 /* Vector header */
85 struct zint_vector {
86 float width, height; /* Width, height of barcode image (including text, whitespace) */
87 struct zint_vector_rect *rectangles; /* Pointer to first rectangle */
88 struct zint_vector_hexagon *hexagons; /* Pointer to first hexagon */
89 struct zint_vector_string *strings; /* Pointer to first string */
90 struct zint_vector_circle *circles; /* Pointer to first circle */
91 };
92
93 /* Structured Append info (see `symbol->structapp` below) - ignored unless `zint_structapp.count` is non-zero */
95 int index; /* Position in Structured Append sequence, 1-based. Must be <= `count` */
96 int count; /* Number of symbols in Structured Append sequence. Set >= 2 to add SA Info */
97 char id[32]; /* Optional ID to distinguish sequence, ASCII, NUL-terminated unless max 32 long */
98 };
99
100 /* Segment for use with API `ZBarcode_Encode_Segs()` and `content_segs` */
101 struct zint_seg {
102 unsigned char *source; /* Data to encode */
103 int length; /* Length of `source`. If 0 or negative, `source` must be NUL-terminated */
104 int eci; /* Extended Channel Interpretation */
105 };
106
107 /* Main symbol structure */
108 struct zint_symbol {
109 int symbology; /* Symbol to use (see BARCODE_XXX below) */
110 float height; /* Barcode height in X-dimensions (ignored for fixed-width barcodes) */
111 float scale; /* Scale factor when printing barcode, i.e. adjusts X-dimension. Default 1 */
112 int whitespace_width; /* Width in X-dimensions of whitespace to left & right of barcode */
113 int whitespace_height; /* Height in X-dimensions of whitespace above & below the barcode */
114 int border_width; /* Size of border in X-dimensions */
115 int output_options; /* Various output parameters (bind, box etc, see below) */
116 char fgcolour[16]; /* Foreground as hexadecimal RGB/RGBA or decimal "C,M,Y,K" string, NUL-terminated */
117 char bgcolour[16]; /* Background as hexadecimal RGB/RGBA or decimal "C,M,Y,K" string, NUL-terminated */
118 char *fgcolor; /* Pointer to fgcolour (alternate spelling) */
119 char *bgcolor; /* Pointer to bgcolour (alternate spelling) */
120 char outfile[256]; /* Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if no PNG) */
121 char primary[128]; /* Primary message data (MaxiCode, Composite), NUL-terminated */
122 int option_1; /* Symbol-specific options (see "../docs/manual.txt") */
123 int option_2; /* Symbol-specific options */
124 int option_3; /* Symbol-specific options */
125 int show_hrt; /* Show (1) or hide (0) Human Readable Text (HRT). Default 1 */
126 int input_mode; /* Encoding of input data (see DATA_MODE etc below). Default DATA_MODE */
127 int eci; /* Extended Channel Interpretation. Default 0 (none) */
128 float dpmm; /* Resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none) */
129 float dot_size; /* Size of dots used in BARCODE_DOTTY_MODE. Default 0.8 */
130 float text_gap; /* Gap between barcode and text (HRT) in X-dimensions. Default 1 */
131 float guard_descent; /* Height in X-dimensions that EAN/UPC guard bars descend. Default 5 */
132 struct zint_structapp structapp; /* Structured Append info. Default structapp.count 0 (none) */
133 int warn_level; /* Affects error/warning value returned by Zint API (see WARN_XXX below) */
134 int debug; /* Debugging flags */
135 unsigned char text[256]; /* Human Readable Text (HRT) (if any), UTF-8, NUL-terminated (output only) */
136 int text_length; /* Length of text in bytes (output only) */
137 int rows; /* Number of rows used by the symbol (output only) */
138 int width; /* Width of the generated symbol (output only) */
139 char errtxt[160]; /* Error message if an error or warning occurs, NUL-terminated (output only) */
140 unsigned char *bitmap; /* Stored bitmap image (raster output only) */
141 int bitmap_width; /* Width of bitmap image (raster output only) */
142 int bitmap_height; /* Height of bitmap image (raster output only) */
143 unsigned char *alphamap; /* Array of alpha values used (raster output only) */
144 struct zint_vector *vector; /* Pointer to vector header (vector output only) */
145 unsigned char *memfile; /* Pointer to in-memory file buffer if BARCODE_MEMORY_FILE (output only) */
146 int memfile_size; /* Length of in-memory file buffer (output only) */
147 struct zint_seg *content_segs; /* Pointer to array of content segs if BARCODE_CONTENT_SEGS (output only) */
148 int content_seg_count; /* Number of `content_segs` (output only) */
149 unsigned char encoded_data[200][144]; /* Encoded data (output only). Allows for rows of 1152 modules */
150 float row_height[200]; /* Heights of rows (output only). Allows for 200 row DotCode */
151 };
152
153/* Symbologies (`symbol->symbology`) */
154 /* Tbarcode 7 codes */
155#define BARCODE_CODE11 1 /* Code 11 */
156#define BARCODE_C25STANDARD 2 /* 2 of 5 Standard (Matrix) */
157#define BARCODE_C25MATRIX 2 /* Legacy */
158#define BARCODE_C25INTER 3 /* 2 of 5 Interleaved */
159#define BARCODE_C25IATA 4 /* 2 of 5 IATA */
160#define BARCODE_C25LOGIC 6 /* 2 of 5 Data Logic */
161#define BARCODE_C25IND 7 /* 2 of 5 Industrial */
162#define BARCODE_CODE39 8 /* Code 39 */
163#define BARCODE_EXCODE39 9 /* Extended Code 39 */
164#define BARCODE_EAN8 10 /* EAN-8 (European Article Number) GTIN-8 */
165#define BARCODE_EAN_2ADDON 11 /* EAN/UPC 2-digit add-on (standalone) */
166#define BARCODE_EAN_5ADDON 12 /* EAN/UPC 5-digit add-on (standalone) */
167#define BARCODE_EANX 13 /* Legacy */
168#define BARCODE_EANX_CHK 14 /* Legacy */
169#define BARCODE_EAN13 15 /* EAN-13 (European Article Number) GTIN-13 */
170#define BARCODE_GS1_128 16 /* GS1-128 */
171#define BARCODE_EAN128 16 /* Legacy */
172#define BARCODE_CODABAR 18 /* Codabar */
173#define BARCODE_CODE128 20 /* Code 128 */
174#define BARCODE_DPLEIT 21 /* Deutsche Post Leitcode */
175#define BARCODE_DPIDENT 22 /* Deutsche Post Identcode */
176#define BARCODE_CODE16K 23 /* Code 16k */
177#define BARCODE_CODE49 24 /* Code 49 */
178#define BARCODE_CODE93 25 /* Code 93 */
179#define BARCODE_FLAT 28 /* Flattermarken */
180#define BARCODE_DBAR_OMN 29 /* GS1 DataBar Omnidirectional */
181#define BARCODE_RSS14 29 /* Legacy */
182#define BARCODE_DBAR_LTD 30 /* GS1 DataBar Limited */
183#define BARCODE_RSS_LTD 30 /* Legacy */
184#define BARCODE_DBAR_EXP 31 /* GS1 DataBar Expanded */
185#define BARCODE_RSS_EXP 31 /* Legacy */
186#define BARCODE_TELEPEN 32 /* Telepen Alpha */
187#define BARCODE_UPCA 34 /* UPC-A */
188#define BARCODE_UPCA_CHK 35 /* UPC-A including check digit */
189#define BARCODE_UPCE 37 /* UPC-E */
190#define BARCODE_UPCE_CHK 38 /* UPC-E including check digit */
191#define BARCODE_POSTNET 40 /* USPS (U.S. Postal Service) POSTNET */
192#define BARCODE_MSI_PLESSEY 47 /* MSI Plessey */
193#define BARCODE_FIM 49 /* Facing Identification Mark */
194#define BARCODE_LOGMARS 50 /* LOGMARS */
195#define BARCODE_PHARMA 51 /* Pharmacode One-Track */
196#define BARCODE_PZN 52 /* Pharmazentralnummer */
197#define BARCODE_PHARMA_TWO 53 /* Pharmacode Two-Track */
198#define BARCODE_CEPNET 54 /* Brazilian CEPNet Postal Code */
199#define BARCODE_PDF417 55 /* PDF417 */
200#define BARCODE_PDF417COMP 56 /* Compact PDF417 (Truncated PDF417) */
201#define BARCODE_PDF417TRUNC 56 /* Legacy */
202#define BARCODE_MAXICODE 57 /* MaxiCode */
203#define BARCODE_QRCODE 58 /* QR Code */
204#define BARCODE_CODE128AB 60 /* Code 128 (Suppress Code Set C) */
205#define BARCODE_CODE128B 60 /* Legacy */
206#define BARCODE_AUSPOST 63 /* Australia Post Standard Customer */
207#define BARCODE_AUSREPLY 66 /* Australia Post Reply Paid */
208#define BARCODE_AUSROUTE 67 /* Australia Post Routing */
209#define BARCODE_AUSREDIRECT 68 /* Australia Post Redirection */
210#define BARCODE_ISBNX 69 /* ISBN */
211#define BARCODE_RM4SCC 70 /* Royal Mail 4-State Customer Code */
212#define BARCODE_DATAMATRIX 71 /* Data Matrix (ECC200) */
213#define BARCODE_EAN14 72 /* EAN-14 */
214#define BARCODE_VIN 73 /* Vehicle Identification Number */
215#define BARCODE_CODABLOCKF 74 /* Codablock F */
216#define BARCODE_NVE18 75 /* NVE-18 (SSCC-18) */
217#define BARCODE_JAPANPOST 76 /* Japanese Postal Code */
218#define BARCODE_KOREAPOST 77 /* Korea Post */
219#define BARCODE_DBAR_STK 79 /* GS1 DataBar Stacked */
220#define BARCODE_RSS14STACK 79 /* Legacy */
221#define BARCODE_DBAR_OMNSTK 80 /* GS1 DataBar Stacked Omnidirectional */
222#define BARCODE_RSS14STACK_OMNI 80 /* Legacy */
223#define BARCODE_DBAR_EXPSTK 81 /* GS1 DataBar Expanded Stacked */
224#define BARCODE_RSS_EXPSTACK 81 /* Legacy */
225#define BARCODE_PLANET 82 /* USPS PLANET */
226#define BARCODE_MICROPDF417 84 /* MicroPDF417 */
227#define BARCODE_USPS_IMAIL 85 /* USPS Intelligent Mail (OneCode) */
228#define BARCODE_ONECODE 85 /* Legacy */
229#define BARCODE_PLESSEY 86 /* UK Plessey */
230
231 /* Tbarcode 8 codes */
232#define BARCODE_TELEPEN_NUM 87 /* Telepen Numeric */
233#define BARCODE_ITF14 89 /* ITF-14 */
234#define BARCODE_KIX 90 /* Dutch Post KIX Code */
235#define BARCODE_AZTEC 92 /* Aztec Code */
236#define BARCODE_DAFT 93 /* DAFT Code */
237#define BARCODE_DPD 96 /* DPD Code */
238#define BARCODE_MICROQR 97 /* Micro QR Code */
239
240 /* Tbarcode 9 codes */
241#define BARCODE_HIBC_128 98 /* HIBC (Health Industry Barcode) Code 128 */
242#define BARCODE_HIBC_39 99 /* HIBC Code 39 */
243#define BARCODE_HIBC_DM 102 /* HIBC Data Matrix */
244#define BARCODE_HIBC_QR 104 /* HIBC QR Code */
245#define BARCODE_HIBC_PDF 106 /* HIBC PDF417 */
246#define BARCODE_HIBC_MICPDF 108 /* HIBC MicroPDF417 */
247#define BARCODE_HIBC_BLOCKF 110 /* HIBC Codablock F */
248#define BARCODE_HIBC_AZTEC 112 /* HIBC Aztec Code */
249
250 /* Tbarcode 10 codes */
251#define BARCODE_DOTCODE 115 /* DotCode */
252#define BARCODE_HANXIN 116 /* Han Xin (Chinese Sensible) Code */
253
254 /* Tbarcode 11 codes */
255#define BARCODE_MAILMARK_2D 119 /* Royal Mail 2D Mailmark (CMDM) (Data Matrix) */
256#define BARCODE_UPU_S10 120 /* Universal Postal Union S10 */
257#define BARCODE_MAILMARK_4S 121 /* Royal Mail 4-State Mailmark */
258#define BARCODE_MAILMARK 121 /* Legacy */
259
260 /* Zint specific */
261#define BARCODE_AZRUNE 128 /* Aztec Runes */
262#define BARCODE_CODE32 129 /* Code 32 */
263#define BARCODE_EANX_CC 130 /* Legacy */
264#define BARCODE_GS1_128_CC 131 /* GS1-128 Composite */
265#define BARCODE_EAN128_CC 131 /* Legacy */
266#define BARCODE_DBAR_OMN_CC 132 /* GS1 DataBar Omnidirectional Composite */
267#define BARCODE_RSS14_CC 132 /* Legacy */
268#define BARCODE_DBAR_LTD_CC 133 /* GS1 DataBar Limited Composite */
269#define BARCODE_RSS_LTD_CC 133 /* Legacy */
270#define BARCODE_DBAR_EXP_CC 134 /* GS1 DataBar Expanded Composite */
271#define BARCODE_RSS_EXP_CC 134 /* Legacy */
272#define BARCODE_UPCA_CC 135 /* UPC-A Composite */
273#define BARCODE_UPCE_CC 136 /* UPC-E Composite */
274#define BARCODE_DBAR_STK_CC 137 /* GS1 DataBar Stacked Composite */
275#define BARCODE_RSS14STACK_CC 137 /* Legacy */
276#define BARCODE_DBAR_OMNSTK_CC 138 /* GS1 DataBar Stacked Omnidirectional Composite */
277#define BARCODE_RSS14_OMNI_CC 138 /* Legacy */
278#define BARCODE_DBAR_EXPSTK_CC 139 /* GS1 DataBar Expanded Stacked Composite */
279#define BARCODE_RSS_EXPSTACK_CC 139 /* Legacy */
280#define BARCODE_CHANNEL 140 /* Channel Code */
281#define BARCODE_CODEONE 141 /* Code One */
282#define BARCODE_GRIDMATRIX 142 /* Grid Matrix */
283#define BARCODE_UPNQR 143 /* UPNQR (Univerzalnega Plačilnega Naloga QR) */
284#define BARCODE_ULTRA 144 /* Ultracode */
285#define BARCODE_RMQR 145 /* Rectangular Micro QR Code (rMQR) */
286#define BARCODE_BC412 146 /* IBM BC412 (SEMI T1-95) */
287#define BARCODE_DXFILMEDGE 147 /* DX Film Edge Barcode on 35mm and APS films */
288#define BARCODE_EAN8_CC 148 /* EAN-8 Composite */
289#define BARCODE_EAN13_CC 149 /* EAN-13 Composite */
290#define BARCODE_LAST 149 /* Max barcode number marker, not barcode */
291
292/* Output options (`symbol->output_options`) */
293#define BARCODE_BIND_TOP 0x00001 /* Boundary bar above the symbol only (not below), does not affect stacking */
294 /* Note: value was once used by the legacy (never-used) BARCODE_NO_ASCII */
295#define BARCODE_BIND 0x00002 /* Boundary bars above & below the symbol and between stacked symbols */
296#define BARCODE_BOX 0x00004 /* Box around symbol */
297#define BARCODE_STDOUT 0x00008 /* Output to stdout */
298#define READER_INIT 0x00010 /* Reader Initialisation (Programming) */
299#define SMALL_TEXT 0x00020 /* Use smaller font */
300#define BOLD_TEXT 0x00040 /* Use bold font */
301#define CMYK_COLOUR 0x00080 /* CMYK colour space (Encapsulated PostScript and TIF) */
302#define BARCODE_DOTTY_MODE 0x00100 /* Plot a matrix symbol using dots rather than squares */
303#define GS1_GS_SEPARATOR 0x00200 /* Use GS instead of FNC1 as GS1 separator (Data Matrix) */
304#define OUT_BUFFER_INTERMEDIATE 0x00400 /* Return ASCII values in bitmap buffer (OUT_BUFFER only) */
305#define BARCODE_QUIET_ZONES 0x00800 /* Add compliant quiet zones (additional to any specified whitespace) */
306 /* Note: CODE16K, CODE49, CODABLOCKF, ITF14, EAN/UPC have default quiet zones
307 */
308#define BARCODE_NO_QUIET_ZONES 0x01000 /* Disable quiet zones, notably those with defaults as listed above */
309#define COMPLIANT_HEIGHT 0x02000 /* Warn if height not compliant, or use standard height (if any) as default */
310#define EANUPC_GUARD_WHITESPACE 0x04000 /* Add quiet zone indicators ("<"/">") to HRT whitespace (EAN/UPC) */
311#define EMBED_VECTOR_FONT 0x08000 /* Embed font in vector output - currently only for SVG output */
312#define BARCODE_MEMORY_FILE 0x10000 /* Write output to in-memory buffer `memfile` instead of to `outfile` */
313#define BARCODE_CONTENT_SEGS 0x20000 /* Write data encoded to content segment buffers `content_segs` */
314
315/* Input data types (`symbol->input_mode`) */
316#define DATA_MODE 0 /* Binary */
317#define UNICODE_MODE 1 /* UTF-8 */
318#define GS1_MODE 2 /* GS1 */
319/* The following may be OR-ed with above */
320#define ESCAPE_MODE 0x0008 /* Process escape sequences */
321#define GS1PARENS_MODE 0x0010 /* Process parentheses as GS1 AI delimiters (instead of square brackets) */
322#define GS1NOCHECK_MODE 0x0020 /* Do not check validity of GS1 data (except that printable ASCII only) */
323#define HEIGHTPERROW_MODE 0x0040 /* Interpret `height` as per-row rather than as overall height */
324#define FAST_MODE 0x0080 /* Use faster if less optimal encodation or other shortcuts if available */
325 /* (affects AZTEC, DATAMATRIX, MICROPDF417, PDF417, QRCODE & UPNQR only) */
326#define EXTRA_ESCAPE_MODE 0x0100 /* Process special symbology-specific escape sequences as well as others */
327 /* Note: currently Aztec Code, Code 128 and Data Matrix only */
328#define GS1SYNTAXENGINE_MODE 0x0200 /* Use the GS1 Syntax Engine (if available) to strictly validate GS1 input */
329#define GS1RAW_MODE 0x0400 /* Process GS1 data literally (no AI delimiters), parsing GSs as FNC1s */
330
331/* Aztec Code specific options (`symbol->option_3`) */
332#define ZINT_AZTEC_FULL 128 /* Only consider Full versions on automatic symbol size selection */
333
334/* Data Matrix specific options (`symbol->option_3`) */
335/* OR-able, but only one of DM_BASE_256_START/DM_C40_START, and only one of DM_SQUARE/DM_DMRE */
336#define DM_B256_START 0x02 /* Use Base 256 encodation initially, length given in `option_1` (0 = all) */
337#define DM_C40_START 0x08 /* Use C40 encodation initially, length given in `option_1` (0 = all) */
338#define DM_SQUARE 0x64 /* Only consider square versions on automatic symbol size selection */
339#define DM_DMRE 0x65 /* Consider DMRE versions on automatic symbol size selection */
340#define DM_ISO_144 0x80 /* Use ISO instead of "de facto" format for 144x144 (i.e. don't skew ECC) */
341/* Masks for testing the exclusive pairs above */
342#define DM_B256_C40_START_MASK 0x0A /* DM_B256_START or DM_C40_START */
343#define DM_SQUARE_DMRE_MASK 0x65 /* DM_SQUARE or DM_DMRE */
344
345/* QR, Han Xin, Grid Matrix specific options (`symbol->option_3`) */
346#define ZINT_FULL_MULTIBYTE 200 /* Enable Kanji/Hanzi compression for Latin-1 & binary data */
347
348/* Ultracode specific option (`symbol->option_3`) */
349#define ULTRA_COMPRESSION 128 /* Enable Ultracode compression (experimental) */
350
351/* Warning and error conditions (API return values) */
352#define ZINT_WARN_HRT_TRUNCATED 1 /* Human Readable Text was truncated (max 199 bytes) */
353#define ZINT_WARN_INVALID_OPTION 2 /* Invalid option given but overridden by Zint */
354#define ZINT_WARN_USES_ECI 3 /* Automatic ECI inserted by Zint */
355#define ZINT_WARN_NONCOMPLIANT 4 /* Symbol created not compliant with standards */
356#define ZINT_ERROR 5 /* Warn/error marker, not returned */
357#define ZINT_ERROR_TOO_LONG 5 /* Input data wrong length */
358#define ZINT_ERROR_INVALID_DATA 6 /* Input data incorrect */
359#define ZINT_ERROR_INVALID_CHECK 7 /* Input check digit incorrect */
360#define ZINT_ERROR_INVALID_OPTION 8 /* Incorrect option given */
361#define ZINT_ERROR_ENCODING_PROBLEM 9 /* Internal error (should not happen) */
362#define ZINT_ERROR_FILE_ACCESS 10 /* Error opening output file */
363#define ZINT_ERROR_MEMORY 11 /* Memory allocation (malloc) failure */
364#define ZINT_ERROR_FILE_WRITE 12 /* Error writing to output file */
365#define ZINT_ERROR_USES_ECI 13 /* Error counterpart of warning if WARN_FAIL_ALL set (see below) */
366#define ZINT_ERROR_NONCOMPLIANT 14 /* Error counterpart of warning if WARN_FAIL_ALL set */
367#define ZINT_ERROR_HRT_TRUNCATED 15 /* Error counterpart of warning if WARN_FAIL_ALL set */
368
369/* Warning level (`symbol->warn_level`) */
370#define WARN_DEFAULT 0 /* Default behaviour */
371#define WARN_FAIL_ALL 2 /* Treat warning as error */
372
373/* Capability flags (ZBarcode_Cap() `cap_flag`) */
374#define ZINT_CAP_HRT 0x0001 /* Prints Human Readable Text? */
375#define ZINT_CAP_STACKABLE 0x0002 /* Is stackable? */
376#define ZINT_CAP_EANUPC 0x0004 /* Is EAN/UPC? */
377#define ZINT_CAP_EXTENDABLE 0x0004 /* Legacy */
378#define ZINT_CAP_COMPOSITE 0x0008 /* Can have composite data? */
379#define ZINT_CAP_ECI 0x0010 /* Supports Extended Channel Interpretations? */
380#define ZINT_CAP_GS1 0x0020 /* Supports GS1 data? */
381#define ZINT_CAP_DOTTY 0x0040 /* Can be output as dots? */
382#define ZINT_CAP_QUIET_ZONES 0x0080 /* Has default quiet zones? */
383#define ZINT_CAP_FIXED_RATIO 0x0100 /* Has fixed width-to-height (aspect) ratio? */
384#define ZINT_CAP_READER_INIT 0x0200 /* Supports Reader Initialisation? */
385#define ZINT_CAP_FULL_MULTIBYTE 0x0400 /* Supports full-multibyte option? */
386#define ZINT_CAP_MASK 0x0800 /* Is mask selectable? */
387#define ZINT_CAP_STRUCTAPP 0x1000 /* Supports Structured Append? */
388#define ZINT_CAP_COMPLIANT_HEIGHT 0x2000 /* Has compliant height? */
389#define ZINT_CAP_BINDABLE 0x4000 /* Can set row separators? */
390
391/* The largest amount of data that can be encoded is 4350 4-byte UTF-8 chars in Han Xin Code */
392#define ZINT_MAX_DATA_LEN 17400
393/* Maximum number of segments allowed for (`seg_count`) */
394#define ZINT_MAX_SEG_COUNT 256
395
396/* Debug flags (`symbol->debug`) */
397#define ZINT_DEBUG_PRINT 0x0001 /* Print debug info (if any) to stdout */
398#define ZINT_DEBUG_TEST 0x0002 /* For internal test use only */
399
400#ifdef _WIN32
401# if defined(DLL_EXPORT) || defined(PIC) || defined(_USRDLL)
402# define ZINT_EXTERN __declspec(dllexport)
403# elif defined(ZINT_DLL)
404# define ZINT_EXTERN __declspec(dllimport)
405# else
406# define ZINT_EXTERN extern
407# endif
408#elif defined(__GNUC__) && __GNUC__ >= 4
409# define ZINT_EXTERN extern __attribute__((__visibility__("default")))
410#else
411# define ZINT_EXTERN extern
412#endif
413
414 /* Create a symbol structure and set fields to default values */
415 ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
416
417 /* Free any output buffers that may have been created and zeroize output fields */
418 ZINT_EXTERN void ZBarcode_Clear(struct zint_symbol *symbol);
419
420 /* Free any output buffers that may have been created and reset all fields to defaults */
421 ZINT_EXTERN void ZBarcode_Reset(struct zint_symbol *symbol);
422
423 /* Free a symbol structure, including any output buffers */
424 ZINT_EXTERN void ZBarcode_Delete(struct zint_symbol *symbol);
425
426
427 /* Encode a barcode. If `length` is 0 or negative, `source` must be NUL-terminated */
428 ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int length);
429
430 /* Encode a barcode with multiple ECI segments */
431 ZINT_EXTERN int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[],
432 const int seg_count);
433
434 /* Encode a barcode using input data from file `filename` */
435 ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename);
436
437 /* Output a previously encoded symbol to file `symbol->outfile` */
438 ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
439
440
441 /* Encode and output a symbol to file `symbol->outfile` */
442 ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, const unsigned char *source, int length,
443 int rotate_angle);
444
445 /* Encode a symbol with multiple ECI segments and output to file `symbol->outfile` */
446 ZINT_EXTERN int ZBarcode_Encode_Segs_and_Print(struct zint_symbol *symbol, const struct zint_seg segs[],
447 const int seg_count, int rotate_angle);
448
449 /* Encode a symbol using input data from file `filename` and output to file `symbol->outfile` */
450 ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, const char *filename,
451 int rotate_angle);
452
453
454 /* Output a previously encoded symbol to memory as raster (`symbol->bitmap`) */
455 ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
456
457 /* Encode and output a symbol to memory as raster (`symbol->bitmap`) */
458 ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, const unsigned char *source, int length,
459 int rotate_angle);
460
461 /* Encode a symbol with multiple ECI segments and output to memory as raster (`symbol->bitmap`) */
462 ZINT_EXTERN int ZBarcode_Encode_Segs_and_Buffer(struct zint_symbol *symbol, const struct zint_seg segs[],
463 const int seg_count, int rotate_angle);
464
465 /* Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`) */
466 ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, const char *filename,
467 int rotate_angle);
468
469
470 /* Output a previously encoded symbol to memory as vector (`symbol->vector`) */
471 ZINT_EXTERN int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
472
473 /* Encode and output a symbol to memory as vector (`symbol->vector`) */
474 ZINT_EXTERN int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, const unsigned char *source,
475 int length, int rotate_angle);
476
477 /* Encode a symbol with multiple ECI segments and output to memory as vector (`symbol->vector`) */
478 ZINT_EXTERN int ZBarcode_Encode_Segs_and_Buffer_Vector(struct zint_symbol *symbol, const struct zint_seg segs[],
479 const int seg_count, int rotate_angle);
480
481 /* Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`) */
482 ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, const char *filename,
483 int rotate_angle);
484
485
486 /* Is `symbol_id` a recognized symbology? */
487 ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
488
489 /* Copy BARCODE_XXX name of `symbol_id` into `name` buffer, NUL-terminated.
490 Returns 0 if valid, 1 if not valid */
491 ZINT_EXTERN int ZBarcode_BarcodeName(int symbol_id, char name[32]);
492
493 /* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
494 ZINT_EXTERN unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);
495
496
497 /* Return default X-dimension in mm for symbology `symbol_id`. Returns 0 on error (invalid `symbol_id`) */
498 ZINT_EXTERN float ZBarcode_Default_Xdim(int symbol_id);
499
500 /* Return the scale to use for `symbol_id` for non-zero X-dimension `x_dim_mm` at `dpmm` dots per mm for
501 `filetype`. If `dpmm` zero defaults to 12. If `filetype` NULL/empty, defaults to "GIF". Returns 0 on error */
502 ZINT_EXTERN float ZBarcode_Scale_From_XdimDp(int symbol_id, float x_dim_mm, float dpmm, const char *filetype);
503
504 /* Reverse of `ZBarcode_Scale_From_XdimDp()` above to estimate the X-dimension or dpmm given non-zero `scale` and
505 non-zero `x_dim_mm_or_dpmm`. Return value bound to dpmm max not X-dimension max. Returns 0 on error */
506 ZINT_EXTERN float ZBarcode_XdimDp_From_Scale(int symbol_id, float scale, float x_dim_mm_or_dpmm,
507 const char *filetype);
508
509
510 /* Convert UTF-8 `source` of length `length` to `eci`-encoded `dest`, setting `p_dest_length` to length of `dest`
511 on output. If `length` is 0 or negative, `source` must be NUL-terminated. Returns 0 on success, else
512 ZINT_ERROR_INVALID_OPTION or ZINT_ERROR_INVALID_DATA. Compatible with libzueci `zueci_utf8_to_eci()` */
513 ZINT_EXTERN int ZBarcode_UTF8_To_ECI(int eci, const unsigned char *source, int length, unsigned char dest[],
514 int *p_dest_length);
515
516 /* Calculate sufficient length needed to convert UTF-8 `source` of length `length` from UTF-8 to `eci`, and place
517 in `p_dest_length`. If `length` is 0 or negative, `source` must be NUL-terminated. Returns 0 on success, else
518 ZINT_ERROR_INVALID_OPTION or ZINT_ERROR_INVALID_DATA. Compatible with libzueci `zueci_dest_len_eci()` */
519 ZINT_EXTERN int ZBarcode_Dest_Len_ECI(int eci, const unsigned char *source, int length, int *p_dest_length);
520
521
522 /* Whether Zint built without PNG support */
523 ZINT_EXTERN int ZBarcode_NoPng(void);
524
525 /* Whether Zint built with GS1 Syntax Engine support */
526 ZINT_EXTERN int ZBarcode_HaveGS1SyntaxEngine(void);
527
528 /* Return the version of Zint linked to */
529 ZINT_EXTERN int ZBarcode_Version(void);
530
531#ifdef __cplusplus
532}
533#endif /* __cplusplus */
534
535/* vim: set ts=4 sw=4 et : */
536#endif /* ZINT_H */
Definition: zint.h:101
Definition: zint.h:94
Definition: zint.h:108
Definition: zint.h:76
Definition: zint.h:58
Definition: zint.h:51
Definition: zint.h:65
Definition: zint.h:85