3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
26 #include <glib/gi18n.h>
28 #include "bc-postnet.h"
29 #include "bc-gnubarcode.h"
31 #include "bc-iec16022.h"
32 #include "bc-iec18004.h"
37 /*========================================================*/
38 /* Private macros and constants. */
39 /*========================================================*/
42 /*========================================================*/
44 /*========================================================*/
51 gboolean text_optional;
52 gboolean can_checksum;
53 gboolean checksum_optional;
54 gchar *default_digits;
55 gboolean can_freeform;
60 /*========================================================*/
61 /* Private globals. */
62 /*========================================================*/
64 static const Backend backends[] = {
66 { "POSTNET", N_("POSTNET (any)"), gl_barcode_postnet_new,
67 FALSE, FALSE, TRUE, FALSE, "12345-6789-12", FALSE, 11},
69 { "POSTNET-5", N_("POSTNET-5 (ZIP only)"), gl_barcode_postnet_new,
70 FALSE, FALSE, TRUE, FALSE, "12345", FALSE, 5},
72 { "POSTNET-9", N_("POSTNET-9 (ZIP+4)"), gl_barcode_postnet_new,
73 FALSE, FALSE, TRUE, FALSE, "12345-6789", FALSE, 9},
75 { "POSTNET-11", N_("POSTNET-11 (DPBC)"), gl_barcode_postnet_new,
76 FALSE, FALSE, TRUE, FALSE, "12345-6789-12", FALSE, 11},
78 #ifdef HAVE_LIBBARCODE
80 { "CEPNET", N_("CEPNET"), gl_barcode_postnet_new,
81 FALSE, FALSE, TRUE, FALSE, "12345-678", FALSE, 8},
83 { "EAN", N_("EAN (any)"), gl_barcode_gnubarcode_new,
84 TRUE, TRUE, TRUE, FALSE, "000000000000 00000", FALSE, 17},
86 { "EAN-8", N_("EAN-8"), gl_barcode_gnubarcode_new,
87 TRUE, TRUE, TRUE, FALSE, "0000000", FALSE, 7},
89 { "EAN-8+2", N_("EAN-8 +2"), gl_barcode_gnubarcode_new,
90 TRUE, TRUE, TRUE, FALSE, "0000000 00", FALSE, 9},
92 { "EAN-8+5", N_("EAN-8 +5"), gl_barcode_gnubarcode_new,
93 TRUE, TRUE, TRUE, FALSE, "0000000 00000", FALSE, 12},
95 { "EAN-13", N_("EAN-13"), gl_barcode_gnubarcode_new,
96 TRUE, TRUE, TRUE, FALSE, "000000000000", FALSE, 12},
98 { "EAN-13+2", N_("EAN-13 +2"), gl_barcode_gnubarcode_new,
99 TRUE, TRUE, TRUE, FALSE, "000000000000 00", FALSE, 14},
101 { "EAN-13+5", N_("EAN-13 +5"), gl_barcode_gnubarcode_new,
102 TRUE, TRUE, TRUE, FALSE, "000000000000 00000", FALSE, 17},
104 { "UPC", N_("UPC (UPC-A or UPC-E)"), gl_barcode_gnubarcode_new,
105 TRUE, TRUE, TRUE, FALSE, "00000000000 00000", FALSE, 16},
107 { "UPC-A", N_("UPC-A"), gl_barcode_gnubarcode_new,
108 TRUE, TRUE, TRUE, FALSE, "00000000000", FALSE, 11},
110 { "UPC-A+2", N_("UPC-A +2"), gl_barcode_gnubarcode_new,
111 TRUE, TRUE, TRUE, FALSE, "00000000000 00", FALSE, 13},
113 { "UPC-A+5", N_("UPC-A +5"), gl_barcode_gnubarcode_new,
114 TRUE, TRUE, TRUE, FALSE, "00000000000 00000", FALSE, 16},
116 { "UPC-E", N_("UPC-E"), gl_barcode_gnubarcode_new,
117 TRUE, TRUE, TRUE, FALSE, "000000", FALSE, 6},
119 { "UPC-E+2", N_("UPC-E +2"), gl_barcode_gnubarcode_new,
120 TRUE, TRUE, TRUE, FALSE, "000000 00", FALSE, 8},
122 { "UPC-E+5", N_("UPC-E +5"), gl_barcode_gnubarcode_new,
123 TRUE, TRUE, TRUE, FALSE, "000000 00000", FALSE, 11},
125 { "ISBN", N_("ISBN"), gl_barcode_gnubarcode_new,
126 TRUE, TRUE, TRUE, TRUE, "0-00000-000-0", FALSE, 10},
128 { "ISBN+5", N_("ISBN +5"), gl_barcode_gnubarcode_new,
129 TRUE, TRUE, TRUE, TRUE, "0-00000-000-0 00000", FALSE, 15},
131 { "Code39", N_("Code 39"), gl_barcode_gnubarcode_new,
132 TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
134 { "Code128", N_("Code 128"), gl_barcode_gnubarcode_new,
135 TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
137 { "Code128C", N_("Code 128C"), gl_barcode_gnubarcode_new,
138 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
140 { "Code128B", N_("Code 128B"), gl_barcode_gnubarcode_new,
141 TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
143 { "I25", N_("Interleaved 2 of 5"), gl_barcode_gnubarcode_new,
144 TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
146 { "CBR", N_("Codabar"), gl_barcode_gnubarcode_new,
147 TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
149 { "MSI", N_("MSI"), gl_barcode_gnubarcode_new,
150 TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
152 { "PLS", N_("Plessey"), gl_barcode_gnubarcode_new,
153 TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
155 { "Code93", N_("Code 93"), gl_barcode_gnubarcode_new,
156 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
158 #endif /* HAVE_LIBBARCODE */
162 { "AUSP", N_("Australia Post Standard"), gl_barcode_zint_new,
163 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
165 { "AUSRP", N_("Australia Post Reply Paid"), gl_barcode_zint_new,
166 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
168 { "AUSRT", N_("Australia Post Route Code"), gl_barcode_zint_new,
169 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
171 { "AUSRD", N_("Australia Post Redirect"), gl_barcode_zint_new,
172 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
174 { "AZTEC", N_("Aztec Code"), gl_barcode_zint_new,
175 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
177 { "AZRUN", N_("Aztec Rune"), gl_barcode_zint_new,
178 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
180 { "CBR", N_("Codabar"), gl_barcode_zint_new,
181 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
183 { "Code1", N_("Code One"), gl_barcode_zint_new,
184 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
186 { "Code11", N_("Code 11"), gl_barcode_zint_new,
187 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
189 { "C16K", N_("Code 16K"), gl_barcode_zint_new,
190 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
192 { "C25M", N_("Code 2 of 5 Matrix"), gl_barcode_zint_new,
193 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
195 { "C25I", N_("Code 2 of 5 IATA"), gl_barcode_zint_new,
196 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
198 { "C25DL", N_("Code 2 of 5 Data Logic"), gl_barcode_zint_new,
199 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
201 { "Code32", N_("Code 32 (Italian Pharmacode)"), gl_barcode_zint_new,
202 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
204 { "Code39", N_("Code 39"), gl_barcode_zint_new,
205 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
207 { "Code39E", N_("Code 39 Extended"), gl_barcode_zint_new,
208 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
210 { "Code49", N_("Code 49"), gl_barcode_zint_new,
211 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
213 { "Code93", N_("Code 93"), gl_barcode_zint_new,
214 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
216 { "Code128", N_("Code 128"), gl_barcode_zint_new,
217 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
219 { "Code128B", N_("Code 128 (Mode C supression)"), gl_barcode_zint_new,
220 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
222 { "DAFT", N_("DAFT Code"), gl_barcode_zint_new,
223 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
225 { "DMTX", N_("Data Matrix"), gl_barcode_zint_new,
226 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
228 { "DPL", N_("Deutsche Post Leitcode"), gl_barcode_zint_new,
229 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
231 { "DPI", N_("Deutsche Post Identcode"), gl_barcode_zint_new,
232 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
234 { "KIX", N_("Dutch Post KIX Code"), gl_barcode_zint_new,
235 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
237 { "EAN", N_("European Article Number (EAN)"), gl_barcode_zint_new,
238 TRUE, TRUE, TRUE, FALSE, "000000000000", FALSE, 13},
240 { "GMTX", N_("Grid Matrix"), gl_barcode_zint_new,
241 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
243 { "GS1-128", N_("GS1-128"), gl_barcode_zint_new,
244 TRUE, TRUE, TRUE, FALSE, "[01]00000000000000", FALSE, 18},
246 { "RSS14", N_("GS1 DataBar-14"), gl_barcode_zint_new,
247 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
249 { "RSSLTD", "GS1 DataBar-14 Limited", gl_barcode_zint_new,
250 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
252 { "RSSEXP", "GS1 DataBar Extended", gl_barcode_zint_new,
253 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
255 { "RSSS", N_("GS1 DataBar-14 Stacked"), gl_barcode_zint_new,
256 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
258 { "RSSSO", N_("GS1 DataBar-14 Stacked Omni."), gl_barcode_zint_new,
259 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
261 { "RSSSE", N_("GS1 DataBar Extended Stacked"), gl_barcode_zint_new,
262 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
264 { "HIBC128", N_("HIBC Code 128"), gl_barcode_zint_new,
265 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
267 { "HIBC39", N_("HIBC Code 39"), gl_barcode_zint_new,
268 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
270 { "HIBCDM", N_("HIBC Data Matrix"), gl_barcode_zint_new,
271 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
273 { "HIBCQR", N_("HIBC QR Code"), gl_barcode_zint_new,
274 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
276 { "HIBCPDF", N_("HIBC PDF417"), gl_barcode_zint_new,
277 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
279 { "HIBCMPDF", N_("HIBC Micro PDF417"), gl_barcode_zint_new,
280 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
282 { "HIBCAZ", N_("HIBC Aztec Code"), gl_barcode_zint_new,
283 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
285 { "I25", N_("Interleaved 2 of 5"), gl_barcode_zint_new,
286 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
288 { "ISBN", N_("ISBN"), gl_barcode_zint_new,
289 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
291 { "ITF14", N_("ITF-14"), gl_barcode_zint_new,
292 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
294 { "JAPAN", N_("Japanese Postal"), gl_barcode_zint_new,
295 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
297 { "KOREA", N_("Korean Postal"), gl_barcode_zint_new,
298 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
300 { "LOGM", N_("LOGMARS"), gl_barcode_zint_new,
301 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
303 { "MPDF", N_("Micro PDF417"), gl_barcode_zint_new,
304 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
306 { "MQR", N_("Micro QR Code"), gl_barcode_zint_new,
307 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
309 { "MSI", N_("MSI Plessey"), gl_barcode_zint_new,
310 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
312 { "NVE", N_("NVE-18"), gl_barcode_zint_new,
313 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
315 { "PDF", N_("PDF417"), gl_barcode_zint_new,
316 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
318 { "PDFT", N_("PDF417 Truncated"), gl_barcode_zint_new,
319 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
321 { "PLAN", N_("PLANET"), gl_barcode_zint_new,
322 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
324 { "POSTNET", N_("PostNet"), gl_barcode_zint_new,
325 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
327 { "PHARMA", N_("Pharmacode"), gl_barcode_zint_new,
328 TRUE, TRUE, TRUE, FALSE, "00000", TRUE, 5},
330 { "PHARMA2", N_("Pharmacode 2-track"), gl_barcode_zint_new,
331 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
333 { "PZN", N_("Pharmazentral Nummer (PZN)"), gl_barcode_zint_new,
334 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
336 { "QR", N_("QR Code"), gl_barcode_zint_new,
337 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
339 { "RM4", N_("Royal Mail 4-State"), gl_barcode_zint_new,
340 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
342 { "TELE", N_("Telepen"), gl_barcode_zint_new,
343 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
345 { "TELEX", N_("Telepen Numeric"), gl_barcode_zint_new,
346 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
348 { "UPC-A", N_("UPC-A"), gl_barcode_zint_new,
349 TRUE, TRUE, TRUE, FALSE, "00000000000", FALSE, 11},
351 { "UPC-E", N_("UPC-E"), gl_barcode_zint_new,
352 TRUE, TRUE, TRUE, FALSE, "000000", FALSE, 6},
354 { "USPS", N_("USPS One Code"), gl_barcode_zint_new,
355 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
357 { "PLS", N_("UK Plessey"), gl_barcode_zint_new,
358 TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
360 #endif /* HAVE_LIBZINT */
362 #ifdef HAVE_LIBIEC16022
364 { "IEC16022", N_("IEC16022 (DataMatrix)"), gl_barcode_iec16022_new,
365 FALSE, FALSE, TRUE, FALSE, "12345678", TRUE, 8},
367 #endif /* HAVE_LIBIEC16022 */
369 #ifdef HAVE_LIBQRENCODE
371 { "IEC18004", N_("IEC18004 (QRCode)"), gl_barcode_iec18004_new,
372 FALSE, FALSE, TRUE, FALSE, "12345678", TRUE, 8},
374 #endif /* HAVE_LIBQRENCODE */
376 { NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL, FALSE, 0}
381 /*========================================================*/
382 /* Private function prototypes. */
383 /*========================================================*/
385 static void gl_barcode_add_shape (glBarcode *bc,
386 glBarcodeShape *shape);
388 static void gl_barcode_shape_free (glBarcodeShape *shape);
391 /*---------------------------------------------------------------------------*/
392 /* Convert id to index into above table. */
393 /*---------------------------------------------------------------------------*/
395 id_to_index (const gchar *id)
400 return 0; /* NULL request default. I.e., the first element. */
403 for (i=0; backends[i].id != NULL; i++) {
404 if (g_ascii_strcasecmp (id, backends[i].id) == 0) {
409 g_message( "Unknown barcode id \"%s\"", id );
414 /*---------------------------------------------------------------------------*/
415 /* Convert name to index into above table. */
416 /*---------------------------------------------------------------------------*/
418 name_to_index (const gchar *name)
422 g_return_val_if_fail (name!=NULL, 0);
424 for (i=0; backends[i].id != NULL; i++) {
425 if (strcmp (name, gettext (backends[i].name)) == 0) {
430 g_message( "Unknown barcode name \"%s\"", name );
435 /*****************************************************************************/
436 /* Call appropriate barcode backend to create barcode in intermediate format.*/
437 /*****************************************************************************/
439 gl_barcode_new (const gchar *id,
441 gboolean checksum_flag,
449 g_return_val_if_fail (digits!=NULL, NULL);
451 i = id_to_index (id);
452 gbc = backends[i].new (backends[i].id,
463 /*****************************************************************************/
464 /* Free previously created barcode. */
465 /*****************************************************************************/
467 gl_barcode_free (glBarcode **gbc)
473 for (p = (*gbc)->shapes; p != NULL; p = p->next) {
474 gl_barcode_shape_free ((glBarcodeShape *)p->data);
477 g_list_free ((*gbc)->shapes);
478 (*gbc)->shapes = NULL;
486 /*****************************************************************************/
488 /*****************************************************************************/
490 gl_barcode_add_line (glBarcode *bc,
496 glBarcodeShapeLine *line_shape = g_new0 (glBarcodeShapeLine, 1);
497 line_shape->type = GL_BARCODE_SHAPE_LINE;
501 line_shape->length = length;
502 line_shape->width = width;
504 gl_barcode_add_shape (bc, (glBarcodeShape *)line_shape);
508 /*****************************************************************************/
510 /*****************************************************************************/
512 gl_barcode_add_box (glBarcode *bc,
518 glBarcodeShapeBox *box_shape = g_new0 (glBarcodeShapeBox, 1);
519 box_shape->type = GL_BARCODE_SHAPE_BOX;
523 box_shape->width = width;
524 box_shape->height = height;
526 gl_barcode_add_shape (bc, (glBarcodeShape *)box_shape);
530 /*****************************************************************************/
532 /*****************************************************************************/
534 gl_barcode_add_char (glBarcode *bc,
540 glBarcodeShapeChar *char_shape = g_new0 (glBarcodeShapeChar, 1);
541 char_shape->type = GL_BARCODE_SHAPE_CHAR;
545 char_shape->fsize = fsize;
548 gl_barcode_add_shape (bc, (glBarcodeShape *)char_shape);
552 /*****************************************************************************/
554 /*****************************************************************************/
556 gl_barcode_add_string (glBarcode *bc,
563 glBarcodeShapeString *string_shape = g_new0 (glBarcodeShapeString, 1);
564 string_shape->type = GL_BARCODE_SHAPE_STRING;
568 string_shape->fsize = fsize;
569 string_shape->string = g_strndup(string, length);
571 gl_barcode_add_shape (bc, (glBarcodeShape *)string_shape);
575 /*****************************************************************************/
576 /* Add shape to barcode. */
577 /*****************************************************************************/
579 gl_barcode_add_shape (glBarcode *bc,
580 glBarcodeShape *shape)
582 g_return_if_fail (bc);
583 g_return_if_fail (shape);
585 bc->shapes = g_list_prepend (bc->shapes, shape);
589 /*****************************************************************************/
590 /* Free a shape primitive. */
591 /*****************************************************************************/
593 gl_barcode_shape_free (glBarcodeShape *shape)
598 case GL_BARCODE_SHAPE_STRING:
599 g_free (shape->string.string);
610 /*****************************************************************************/
611 /* Get a list of names for valid barcode styles. */
612 /*****************************************************************************/
614 gl_barcode_get_styles_list (void)
619 for (i=0; backends[i].id != NULL; i++) {
620 list = g_list_prepend (list, g_strdup (gettext (backends[i].name)));
623 return g_list_reverse (list);
627 /*****************************************************************************/
628 /* Free up a previously allocated list of style names. */
629 /*****************************************************************************/
631 gl_barcode_free_styles_list (GList *styles_list)
635 for (p=styles_list; p != NULL; p=p->next) {
640 g_list_free (styles_list);
644 /*****************************************************************************/
645 /* Return an appropriate set of digits for the given barcode style. */
646 /*****************************************************************************/
648 gl_barcode_default_digits (const gchar *id,
653 i = id_to_index (id);
655 if (backends[i].can_freeform) {
657 return g_strnfill (MAX (n,1), '0');
661 return g_strdup (backends[i].default_digits);
667 /*****************************************************************************/
668 /* Query text capabilities. */
669 /*****************************************************************************/
671 gl_barcode_can_text (const gchar *id)
673 return backends[id_to_index (id)].can_text;
678 gl_barcode_text_optional (const gchar *id)
680 return backends[id_to_index (id)].text_optional;
684 /*****************************************************************************/
685 /* Query checksum capabilities. */
686 /*****************************************************************************/
688 gl_barcode_can_csum (const gchar *id)
690 return backends[id_to_index (id)].can_checksum;
695 gl_barcode_csum_optional (const gchar *id)
697 return backends[id_to_index (id)].checksum_optional;
701 /*****************************************************************************/
702 /* Query if freeform input is allowed. */
703 /*****************************************************************************/
705 gl_barcode_can_freeform (const gchar *id)
707 return backends[id_to_index (id)].can_freeform;
711 /*****************************************************************************/
712 /* Query prefered number of digits of input. */
713 /*****************************************************************************/
715 gl_barcode_get_prefered_n (const gchar *id)
717 return backends[id_to_index (id)].prefered_n;
721 /*****************************************************************************/
722 /* Convert style to text. */
723 /*****************************************************************************/
725 gl_barcode_id_to_name (const gchar *id)
727 return gettext (backends[id_to_index (id)].name);
731 /*****************************************************************************/
732 /* Convert name to style. */
733 /*****************************************************************************/
735 gl_barcode_name_to_id (const gchar *name)
737 g_return_val_if_fail (name!=NULL, backends[0].id);
739 return backends[name_to_index (name)].id;
745 * Local Variables: -- emacs
747 * c-basic-offset: 8 -- emacs
748 * tab-width: 8 -- emacs
749 * indent-tabs-mode: nil -- emacs