]> git.sur5r.net Git - glabels/blob - src/bc-builtin.c
Imported Upstream version 3.0.0
[glabels] / src / bc-builtin.c
1 /*
2  *  bc-builtin.c
3  *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of gLabels.
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 /*
22  * This module implements the BUILTIN barcode specified in the USPS
23  * publication 25, Mar 2001.
24  */
25
26 #include <config.h>
27
28 #include "bc-builtin.h"
29
30 #include "debug.h"
31
32
33 /*========================================================*/
34 /* Private macros and constants.                          */
35 /*========================================================*/
36
37
38 /*===========================================*/
39 /* Private globals                           */
40 /*===========================================*/
41
42
43 /*===========================================*/
44 /* Local function prototypes                 */
45 /*===========================================*/
46
47
48 /****************************************************************************/
49 /* Generate list of lines that form the barcode for the given digits.       */
50 /****************************************************************************/
51 lglBarcode *
52 gl_barcode_builtin_new (const gchar    *id,
53                         gboolean        text_flag,
54                         gboolean        checksum_flag,
55                         gdouble         w,
56                         gdouble         h,
57                         const gchar    *digits)
58 {
59         if ( (g_ascii_strcasecmp (id, "POSTNET") == 0) )
60         {
61                 return lgl_barcode_create (LGL_BARCODE_TYPE_POSTNET, text_flag, checksum_flag, w, h, digits);
62         }
63         if ( (g_ascii_strcasecmp (id, "POSTNET-5") == 0) )
64         {
65                 return lgl_barcode_create (LGL_BARCODE_TYPE_POSTNET_5, text_flag, checksum_flag, w, h, digits);
66         }
67         if ( (g_ascii_strcasecmp (id, "POSTNET-9") == 0) )
68         {
69                 return lgl_barcode_create (LGL_BARCODE_TYPE_POSTNET_9, text_flag, checksum_flag, w, h, digits);
70         }
71         if ( (g_ascii_strcasecmp (id, "POSTNET-11") == 0) )
72         {
73                 return lgl_barcode_create (LGL_BARCODE_TYPE_POSTNET_11, text_flag, checksum_flag, w, h, digits);
74         }
75         if ( (g_ascii_strcasecmp (id, "CEPNET") == 0) )
76         {
77                 return lgl_barcode_create (LGL_BARCODE_TYPE_CEPNET, text_flag, checksum_flag, w, h, digits);
78         }
79         if ( (g_ascii_strcasecmp (id, "ONECODE") == 0) )
80         {
81                 return lgl_barcode_create (LGL_BARCODE_TYPE_ONECODE, text_flag, checksum_flag, w, h, digits);
82         }
83         if ( (g_ascii_strcasecmp (id, "Code39") == 0) )
84         {
85                 return lgl_barcode_create (LGL_BARCODE_TYPE_CODE39, text_flag, checksum_flag, w, h, digits);
86         }
87         if ( (g_ascii_strcasecmp (id, "Code39Ext") == 0) )
88         {
89                 return lgl_barcode_create (LGL_BARCODE_TYPE_CODE39_EXT, text_flag, checksum_flag, w, h, digits);
90         }
91
92         g_message ("Invalid builtin barcode ID: \"%s\"\n", id);
93         return NULL;
94 }
95
96
97
98 /*
99  * Local Variables:       -- emacs
100  * mode: C                -- emacs
101  * c-basic-offset: 8      -- emacs
102  * tab-width: 8           -- emacs
103  * indent-tabs-mode: nil  -- emacs
104  * End:                   -- emacs
105  */