-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy path_qrencode.py
More file actions
207 lines (196 loc) · 9.27 KB
/
_qrencode.py
File metadata and controls
207 lines (196 loc) · 9.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
"""This file is part of libqrencode python ctypes bindings.
Copyright (C) 2012 Matthew Baker <mu.beta.06@gmail.com>
This is free software: you can redistribute it and/or modify
it under the terms of the LGNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the LGNU Lesser General Public License
along with this software. If not, see <http://www.gnu.org/licenses/>."""
from ctypes import *
libqrencode = CDLL('libqrencode.so')
STRING = c_char_p
QR_ECLEVEL_H = 3
QR_MODE_FNC1FIRST = 6
QR_MODE_KANJI = 3
QR_ECLEVEL_Q = 2
QR_MODE_NUM = 0
QR_MODE_ECI = 5
QR_MODE_8 = 2
QR_MODE_AN = 1
QR_ECLEVEL_L = 0
QR_MODE_FNC1SECOND = 7
QR_ECLEVEL_M = 1
QR_MODE_STRUCTURE = 4
QR_MODE_NUL = -1
# values for enumeration 'QRencodeMode'
QRencodeMode = c_int # enum
# values for enumeration 'QRecLevel'
QRecLevel = c_int # enum
class _QRinput(Structure):
pass
QRinput = _QRinput
_QRinput._fields_ = [
]
QRinput_new = libqrencode.QRinput_new
QRinput_new.restype = POINTER(QRinput)
QRinput_new.argtypes = []
QRinput_new2 = libqrencode.QRinput_new2
QRinput_new2.restype = POINTER(QRinput)
QRinput_new2.argtypes = [c_int, QRecLevel]
QRinput_newMQR = libqrencode.QRinput_newMQR
QRinput_newMQR.restype = POINTER(QRinput)
QRinput_newMQR.argtypes = [c_int, QRecLevel]
QRinput_append = libqrencode.QRinput_append
QRinput_append.restype = c_int
QRinput_append.argtypes = [POINTER(QRinput), QRencodeMode, c_int, POINTER(c_ubyte)]
QRinput_appendECIheader = libqrencode.QRinput_appendECIheader
QRinput_appendECIheader.restype = c_int
QRinput_appendECIheader.argtypes = [POINTER(QRinput), c_uint]
QRinput_getVersion = libqrencode.QRinput_getVersion
QRinput_getVersion.restype = c_int
QRinput_getVersion.argtypes = [POINTER(QRinput)]
QRinput_setVersion = libqrencode.QRinput_setVersion
QRinput_setVersion.restype = c_int
QRinput_setVersion.argtypes = [POINTER(QRinput), c_int]
QRinput_getErrorCorrectionLevel = libqrencode.QRinput_getErrorCorrectionLevel
QRinput_getErrorCorrectionLevel.restype = QRecLevel
QRinput_getErrorCorrectionLevel.argtypes = [POINTER(QRinput)]
QRinput_setErrorCorrectionLevel = libqrencode.QRinput_setErrorCorrectionLevel
QRinput_setErrorCorrectionLevel.restype = c_int
QRinput_setErrorCorrectionLevel.argtypes = [POINTER(QRinput), QRecLevel]
QRinput_setVersionAndErrorCorrectionLevel = libqrencode.QRinput_setVersionAndErrorCorrectionLevel
QRinput_setVersionAndErrorCorrectionLevel.restype = c_int
QRinput_setVersionAndErrorCorrectionLevel.argtypes = [POINTER(QRinput), c_int, QRecLevel]
QRinput_free = libqrencode.QRinput_free
QRinput_free.restype = None
QRinput_free.argtypes = [POINTER(QRinput)]
QRinput_check = libqrencode.QRinput_check
QRinput_check.restype = c_int
QRinput_check.argtypes = [QRencodeMode, c_int, POINTER(c_ubyte)]
class _QRinput_Struct(Structure):
pass
QRinput_Struct = _QRinput_Struct
_QRinput_Struct._fields_ = [
]
QRinput_Struct_new = libqrencode.QRinput_Struct_new
QRinput_Struct_new.restype = POINTER(QRinput_Struct)
QRinput_Struct_new.argtypes = []
QRinput_Struct_setParity = libqrencode.QRinput_Struct_setParity
QRinput_Struct_setParity.restype = None
QRinput_Struct_setParity.argtypes = [POINTER(QRinput_Struct), c_ubyte]
QRinput_Struct_appendInput = libqrencode.QRinput_Struct_appendInput
QRinput_Struct_appendInput.restype = c_int
QRinput_Struct_appendInput.argtypes = [POINTER(QRinput_Struct), POINTER(QRinput)]
QRinput_Struct_free = libqrencode.QRinput_Struct_free
QRinput_Struct_free.restype = None
QRinput_Struct_free.argtypes = [POINTER(QRinput_Struct)]
QRinput_splitQRinputToStruct = libqrencode.QRinput_splitQRinputToStruct
QRinput_splitQRinputToStruct.restype = POINTER(QRinput_Struct)
QRinput_splitQRinputToStruct.argtypes = [POINTER(QRinput)]
QRinput_Struct_insertStructuredAppendHeaders = libqrencode.QRinput_Struct_insertStructuredAppendHeaders
QRinput_Struct_insertStructuredAppendHeaders.restype = c_int
QRinput_Struct_insertStructuredAppendHeaders.argtypes = [POINTER(QRinput_Struct)]
QRinput_setFNC1First = libqrencode.QRinput_setFNC1First
QRinput_setFNC1First.restype = c_int
QRinput_setFNC1First.argtypes = [POINTER(QRinput)]
QRinput_setFNC1Second = libqrencode.QRinput_setFNC1Second
QRinput_setFNC1Second.restype = c_int
QRinput_setFNC1Second.argtypes = [POINTER(QRinput), c_ubyte]
class QRcode(Structure):
pass
QRcode._fields_ = [
('version', c_int),
('width', c_int),
('data', POINTER(c_ubyte)),
]
class _QRcode_List(Structure):
pass
QRcode_List = _QRcode_List
_QRcode_List._fields_ = [
('code', POINTER(QRcode)),
('next', POINTER(QRcode_List)),
]
QRcode_encodeInput = libqrencode.QRcode_encodeInput
QRcode_encodeInput.restype = POINTER(QRcode)
QRcode_encodeInput.argtypes = [POINTER(QRinput)]
QRcode_encodeString = libqrencode.QRcode_encodeString
QRcode_encodeString.restype = POINTER(QRcode)
QRcode_encodeString.argtypes = [STRING, c_int, QRecLevel, QRencodeMode, c_int]
QRcode_encodeString8bit = libqrencode.QRcode_encodeString8bit
QRcode_encodeString8bit.restype = POINTER(QRcode)
QRcode_encodeString8bit.argtypes = [STRING, c_int, QRecLevel]
QRcode_encodeStringMQR = libqrencode.QRcode_encodeStringMQR
QRcode_encodeStringMQR.restype = POINTER(QRcode)
QRcode_encodeStringMQR.argtypes = [STRING, c_int, QRecLevel, QRencodeMode, c_int]
QRcode_encodeString8bitMQR = libqrencode.QRcode_encodeString8bitMQR
QRcode_encodeString8bitMQR.restype = POINTER(QRcode)
QRcode_encodeString8bitMQR.argtypes = [STRING, c_int, QRecLevel]
QRcode_encodeData = libqrencode.QRcode_encodeData
QRcode_encodeData.restype = POINTER(QRcode)
QRcode_encodeData.argtypes = [c_int, POINTER(c_ubyte), c_int, QRecLevel]
QRcode_encodeDataMQR = libqrencode.QRcode_encodeDataMQR
QRcode_encodeDataMQR.restype = POINTER(QRcode)
QRcode_encodeDataMQR.argtypes = [c_int, POINTER(c_ubyte), c_int, QRecLevel]
QRcode_free = libqrencode.QRcode_free
QRcode_free.restype = None
QRcode_free.argtypes = [POINTER(QRcode)]
QRcode_encodeInputStructured = libqrencode.QRcode_encodeInputStructured
QRcode_encodeInputStructured.restype = POINTER(QRcode_List)
QRcode_encodeInputStructured.argtypes = [POINTER(QRinput_Struct)]
QRcode_encodeStringStructured = libqrencode.QRcode_encodeStringStructured
QRcode_encodeStringStructured.restype = POINTER(QRcode_List)
QRcode_encodeStringStructured.argtypes = [STRING, c_int, QRecLevel, QRencodeMode, c_int]
QRcode_encodeString8bitStructured = libqrencode.QRcode_encodeString8bitStructured
QRcode_encodeString8bitStructured.restype = POINTER(QRcode_List)
QRcode_encodeString8bitStructured.argtypes = [STRING, c_int, QRecLevel]
QRcode_encodeDataStructured = libqrencode.QRcode_encodeDataStructured
QRcode_encodeDataStructured.restype = POINTER(QRcode_List)
QRcode_encodeDataStructured.argtypes = [c_int, POINTER(c_ubyte), c_int, QRecLevel]
QRcode_List_size = libqrencode.QRcode_List_size
QRcode_List_size.restype = c_int
QRcode_List_size.argtypes = [POINTER(QRcode_List)]
QRcode_List_free = libqrencode.QRcode_List_free
QRcode_List_free.restype = None
QRcode_List_free.argtypes = [POINTER(QRcode_List)]
QRcode_APIVersion = libqrencode.QRcode_APIVersion
QRcode_APIVersion.restype = None
QRcode_APIVersion.argtypes = [POINTER(c_int), POINTER(c_int), POINTER(c_int)]
QRcode_APIVersionString = libqrencode.QRcode_APIVersionString
QRcode_APIVersionString.restype = STRING
QRcode_APIVersionString.argtypes = []
QRcode_clearCache = libqrencode.QRcode_clearCache
QRcode_clearCache.restype = None
QRcode_clearCache.argtypes = []
MQRSPEC_VERSION_MAX = 4 # Variable c_int '4'
QRSPEC_VERSION_MAX = 40 # Variable c_int '40'
__all__ = ['QRcode_clearCache', 'QRinput_setFNC1Second',
'QRcode_List_size', 'QRinput_append', 'QRcode_List',
'QR_MODE_8', 'QR_MODE_KANJI', 'QRcode_encodeStringMQR',
'QR_MODE_FNC1FIRST', '_QRcode_List',
'QRcode_encodeString8bit', 'QRcode', 'QRcode_encodeString',
'QR_MODE_ECI', 'QRcode_encodeString8bitMQR', 'QR_MODE_NUL',
'QR_MODE_NUM', 'QRcode_encodeString8bitStructured',
'QR_ECLEVEL_Q', 'QRcode_encodeInputStructured',
'QRinput_splitQRinputToStruct', 'QRinput_Struct',
'QRinput_getVersion', 'QRcode_List_free',
'QRcode_encodeDataMQR', 'QRinput_Struct_setParity',
'QRinput_setVersion', 'QRinput_setErrorCorrectionLevel',
'QRcode_encodeStringStructured', 'QRinput_check',
'QRinput_Struct_free', 'QRinput_Struct_new',
'QR_ECLEVEL_M', 'QR_ECLEVEL_L', 'QRcode_APIVersion',
'QR_MODE_STRUCTURE', 'QRinput_appendECIheader',
'QR_MODE_FNC1SECOND',
'QRinput_Struct_insertStructuredAppendHeaders',
'QRcode_encodeData', 'QRinput', 'QRinput_new2',
'QRSPEC_VERSION_MAX', 'QRecLevel', '_QRinput',
'QRcode_encodeInput', 'QRinput_getErrorCorrectionLevel',
'QRcode_encodeDataStructured', 'QRencodeMode',
'MQRSPEC_VERSION_MAX', '_QRinput_Struct', 'QRinput_free',
'QRinput_setVersionAndErrorCorrectionLevel',
'QRinput_Struct_appendInput', 'QR_MODE_AN',
'QRcode_APIVersionString', 'QRinput_newMQR', 'QRinput_new',
'QRcode_free', 'QR_ECLEVEL_H', 'QRinput_setFNC1First']