]> git.sur5r.net Git - glabels/blob - glabels2/qrencode-3.1.0/qrinput.h
2009-09-09 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / qrencode-3.1.0 / qrinput.h
1 /*
2  * qrencode - QR Code encoder
3  *
4  * Input data chunk class
5  * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi <fukuchi@megaui.net>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or any later version.
11  *
12  * This library 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 GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #ifndef __QRINPUT_H__
23 #define __QRINPUT_H__
24
25 #include "qrencode.h"
26 #include "bitstream.h"
27
28 /******************************************************************************
29  * Entry of input data
30  *****************************************************************************/
31 typedef struct _QRinput_List QRinput_List;
32
33 struct _QRinput_List {
34         QRencodeMode mode;
35         int size;                               ///< Size of data chunk (byte).
36         unsigned char *data;    ///< Data chunk.
37         BitStream *bstream;
38         QRinput_List *next;
39 };
40
41 /******************************************************************************
42  * Input Data
43  *****************************************************************************/
44 struct _QRinput {
45         int version;
46         QRecLevel level;
47         QRinput_List *head;
48         QRinput_List *tail;
49 };
50
51 /******************************************************************************
52  * Structured append input data
53  *****************************************************************************/
54 typedef struct _QRinput_InputList QRinput_InputList;
55
56 struct _QRinput_InputList {
57         QRinput *input;
58         QRinput_InputList *next;
59 };
60
61 struct _QRinput_Struct {
62         int size;                                       ///< number of structured symbols
63         int parity;
64         QRinput_InputList *head;
65         QRinput_InputList *tail;
66 };
67
68 /**
69  * Pack all bit streams padding bits into a byte array.
70  * @param input input data.
71  * @return padded merged byte stream
72  */
73 extern unsigned char *QRinput_getByteStream(QRinput *input);
74
75
76 extern int QRinput_estimateBitsModeNum(int size);
77 extern int QRinput_estimateBitsModeAn(int size);
78 extern int QRinput_estimateBitsMode8(int size);
79 extern int QRinput_estimateBitsModeKanji(int size);
80
81 extern QRinput *QRinput_dup(QRinput *input);
82
83 extern const signed char QRinput_anTable[128];
84
85 /**
86  * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19).
87  * @param __c__ character
88  * @return value
89  */
90 #define QRinput_lookAnTable(__c__) \
91         ((__c__ & 0x80)?-1:QRinput_anTable[(int)__c__])
92
93 /**
94  * Length of a segment of structured-append header.
95  */
96 #define STRUCTURE_HEADER_BITS 20
97
98 /**
99  * Maximum number of symbols in a set of structured-appended symbols.
100  */
101 #define MAX_STRUCTURED_SYMBOLS 16
102
103 #endif /* __QRINPUT_H__ */