forked from dmtx/php-dmtx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_dmtx.h
161 lines (137 loc) · 4.5 KB
/
php_dmtx.h
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
/*
+----------------------------------------------------------------------+
| PHP Version 5 / dmtx |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 Mikko Koppanen |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Mikko Kopppanen <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_DMTX_H
/* Prevent double inclusion */
#define PHP_DMTX_H
/* Define Extension Properties */
#define PHP_DMTX_EXTNAME "dmtx"
#define PHP_DMTX_EXTVER "0.0.3-dev"
#define PHP_DMTX_SC_NAME "dmtx"
#define PHP_DMTX_READ_SC_NAME "dmtxRead"
#define PHP_DMTX_WRITE_SC_NAME "dmtxWrite"
#define PHP_DMTX_EXCEPTION_SC_NAME "dmtxException"
#define DMTXWRITE_BUFFER_SIZE 4096
/* Import configure options when building
outside of the PHP source tree */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
/* Include PHP Standard Header */
#include "php.h"
/* Include the dmtx header */
#include <dmtx.h>
/* Include magic wand header */
#if defined (IM_MAGICKWAND_HEADER_STYLE_SEVEN)
# include <MagickWand/MagickWand.h>
#elif defined (IM_MAGICKWAND_HEADER_STYLE_OLD)
# include <wand/magick-wand.h>
#else
# include <wand/MagickWand.h>
#endif
/* Some extra headers */
#include "Zend/zend_exceptions.h"
#include "Zend/zend_interfaces.h"
#include "ext/standard/php_string.h"
#include "ext/standard/info.h"
#include "php_ini.h"
#include "ext/standard/streamsfuncs.h"
/* Structure for dmtx object. */
typedef struct _php_dmtx_object {
zend_object zo;
} php_dmtx_object;
typedef struct _php_dmtx_scan_region {
long x_min;
long x_max;
long y_min;
long y_max;
zend_bool active;
} php_dmtx_scan_region;
/**
* Encoding schemes
*/
typedef enum {
PhpDmtxSchemeAscii,
PhpDmtxSchemeC40,
PhpDmtxSchemeText,
PhpDmtxSchemeX12,
PhpDmtxSchemeEdifact,
PhpDmtxSchemeBase256
} PhpDmtxScheme;
typedef struct _php_dmtx_read_opts {
long timeout_ms;
long start;
long limit;
long symbol;
long shrink;
int scheme; // added
} php_dmtx_read_opts;
/* Structure for dmtx object. */
typedef struct _php_dmtx_read_object {
zend_object zo;
MagickWand *magick_wand;
php_dmtx_read_opts options;
php_dmtx_scan_region scan_region;
} php_dmtx_read_object;
/* Structure for dmtx object. */
typedef struct _php_dmtx_write_object {
zend_object zo;
char message[DMTXWRITE_BUFFER_SIZE];
int message_len;
MagickWand *magick_wand;
int scheme; // added
} php_dmtx_write_object;
/* Method declarations, dmtx class is just
* for holding the constants */
/* dmtxRead class */
PHP_METHOD(dmtxread, __construct);
PHP_METHOD(dmtxread, loadfile);
PHP_METHOD(dmtxread, loadstring);
PHP_METHOD(dmtxread, settimeout);
PHP_METHOD(dmtxread, setlimit);
PHP_METHOD(dmtxread, setshrink);
PHP_METHOD(dmtxread, setsymbolshape);
PHP_METHOD(dmtxread, setscanregion);
PHP_METHOD(dmtxread, setscheme); // added
PHP_METHOD(dmtxread, gettimeout);
PHP_METHOD(dmtxread, getlimit);
PHP_METHOD(dmtxread, getshrink);
PHP_METHOD(dmtxread, getsymbolshape);
PHP_METHOD(dmtxread, getscanregion);
PHP_METHOD(dmtxread, getscheme); // added
PHP_METHOD(dmtxread, getinfo);
PHP_METHOD(dmtxread, unsetscanregion);
/* dmtxWrite class */
PHP_METHOD(dmtxwrite, __construct);
PHP_METHOD(dmtxwrite, setmessage);
PHP_METHOD(dmtxwrite, setscheme); // added
PHP_METHOD(dmtxwrite, getscheme); // added
PHP_METHOD(dmtxwrite, save);
#define PHP_DMTX_NO_FILENAME_ERROR 1
#define PHP_DMTX_ALLOW_URL_FOPEN_ERROR 2
#define PHP_DMTX_UNABLE_TO_READ_FILENAME_ERROR 3
#define PHP_DMTX_FILENAME_TOO_LONG_ERROR 4
#define PHP_DMTX_OPEN_BASEDIR_ERROR 5
#define PHP_DMTX_SAFE_MODE_ERROR 6
/* Define the entry point symbol
* Zend will use when loading this module */
extern zend_module_entry dmtx_module_entry;
#define phpext_dmtx_ptr &dmtx_module_entry
#endif /* PHP_DMTX_H */