php_aalib.h

php_aalib.h
 1 /*
 2   +----------------------------------------------------------------------+
 3   | PHP Version 4                                                        |
 4   +----------------------------------------------------------------------+
 5   | Copyright (c) 1997-2002 The PHP Group                                |
 6   +----------------------------------------------------------------------+
 7   | This source file is subject to version 2.02 of the PHP license,      |
 8   | that is bundled with this package in the file LICENSE, and is        |
 9   | available at through the world-wide-web at                           |
10   | http://www.php.net/license/2_02.txt.                                 |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author:                                                              |
16   +----------------------------------------------------------------------+
17 
18   $Id: protos-result.xml,v 1.3 2002-12-09 09:48:03 derick Exp $ 
19 */
20 
21 #ifndef PHP_AALIB_H
22 #define PHP_AALIB_H
23 
24 extern zend_module_entry aalib_module_entry;
25 #define phpext_aalib_ptr &aalib_module_entry
26 
27 #ifdef PHP_WIN32
28 #define PHP_AALIB_API __declspec(dllexport)
29 #else
30 #define PHP_AALIB_API
31 #endif
32 
33 #ifdef ZTS
34 #include "TSRM.h"
35 #endif
36 
37 PHP_MINIT_FUNCTION(aalib);
38 PHP_MSHUTDOWN_FUNCTION(aalib);
39 PHP_RINIT_FUNCTION(aalib);
40 PHP_RSHUTDOWN_FUNCTION(aalib);
41 PHP_MINFO_FUNCTION(aalib);
42 
43 PHP_FUNCTION(confirm_aalib_compiled);   / For testing, remove later. /
44 PHP_FUNCTION(aa_init);
45 PHP_FUNCTION(aa_get_screen_height);
46 PHP_FUNCTION(aa_get_screen_width);
47 PHP_FUNCTION(aa_put_pixel);
48 PHP_FUNCTION(aa_render);
49 PHP_FUNCTION(aa_get_all);
50 PHP_FUNCTION(aa_get_lines);
51 PHP_FUNCTION(aa_get_array);
52 
53 /* 
54         Declare any global variables you may need between the BEGIN
55         and END macros here:     
56 
57 ZEND_BEGIN_MODULE_GLOBALS(aalib)
58         int   global_value;
59         char *global_string;
60 ZEND_END_MODULE_GLOBALS(aalib)
61 */
62 
63 /* In every utility function you add that needs to use variables 
64    in php_aalib_globals, call TSRM_FETCH(); after declaring other 
65    variables used by that function, or better yet, pass in TSRMLS_CC
66    after the last function argument and declare your utility function
67    with TSRMLS_DC after the last declared argument.  Always refer to
68    the globals in your function as AALIB_G(variable).  You are 
69    encouraged to rename these macros something shorter, see
70    examples in any other php module directory.
71 */
72 
73 #ifdef ZTS
74 #define AALIB_G(v) TSRMG(aalib_globals_id, zend_aalib_globals *, v)
75 #else
76 #define AALIB_G(v) (aalib_globals.v)
77 #endif
78 
79 #endif  / PHP_AALIB_H /
80 
81 
82 /*
83  * Local variables:
84  * tab-width: 4
85  * c-basic-offset: 4
86  * indent-tabs-mode: t
87  * End:
88  */



aalib.c

aalib.c
  1 /*
  2   +----------------------------------------------------------------------+
  3   | PHP Version 4                                                        |
  4   +----------------------------------------------------------------------+
  5   | Copyright (c) 1997-2002 The PHP Group                                |
  6   +----------------------------------------------------------------------+
  7   | This source file is subject to version 2.02 of the PHP license,      |
  8   | that is bundled with this package in the file LICENSE, and is        |
  9   | available at through the world-wide-web at                           |
 10   | http://www.php.net/license/2_02.txt.                                 |
 11   | If you did not receive a copy of the PHP license and are unable to   |
 12   | obtain it through the world-wide-web, please send a note to          |
 13   | license@php.net so we can mail you a copy immediately.               |
 14   +----------------------------------------------------------------------+
 15   | Author:                                                              |
 16   +----------------------------------------------------------------------+
 17 
 18   $Id: protos-result.xml,v 1.3 2002-12-09 09:48:03 derick Exp $ 
 19 */
 20 
 21 #ifdef HAVE_CONFIG_H
 22 #include "config.h"
 23 #endif
 24 
 25 #include "php.h"
 26 #include "php_ini.h"
 27 #include "ext/standard/info.h"
 28 #include "php_aalib.h"
 29 
 30 /* If you declare any globals in php_aalib.h uncomment this:
 31 ZEND_DECLARE_MODULE_GLOBALS(aalib)
 32 */
 33 
 34 / True global resources - no need for thread safety here /
 35 static int le_aalib;
 36 
 37 /* {{{ aalib_functions[]
 38  *
 39  * Every user visible function must have an entry in aalib_functions[].
 40  */
 41 function_entry aalib_functions[] = {
 42         PHP_FE(confirm_aalib_compiled,  NULL)           / For testing, remove later. /
 43         PHP_FE(aa_init, NULL)
 44         PHP_FE(aa_get_screen_height,    NULL)
 45         PHP_FE(aa_get_screen_width,     NULL)
 46         PHP_FE(aa_put_pixel,    NULL)
 47         PHP_FE(aa_render,       NULL)
 48         PHP_FE(aa_get_all,      NULL)
 49         PHP_FE(aa_get_lines,    NULL)
 50         PHP_FE(aa_get_array,    NULL)
 51         {NULL, NULL, NULL}      / Must be the last line in aalib_functions[] /
 52 };
 53 / }}} /
 54 
 55 /* {{{ aalib_module_entry
 56  */
 57 zend_module_entry aalib_module_entry = {
 58 #if ZEND_MODULE_API_NO >= 20010901
 59         STANDARD_MODULE_HEADER,
 60 #endif
 61         "aalib",
 62         aalib_functions,
 63         PHP_MINIT(aalib),
 64         PHP_MSHUTDOWN(aalib),
 65         PHP_RINIT(aalib),               / Replace with NULL if there's nothing to do at request start /
 66         PHP_RSHUTDOWN(aalib),   / Replace with NULL if there's nothing to do at request end /
 67         PHP_MINFO(aalib),
 68 #if ZEND_MODULE_API_NO >= 20010901
 69         "0.1", / Replace with version number for your extension /
 70 #endif
 71         STANDARD_MODULE_PROPERTIES
 72 };
 73 / }}} /
 74 
 75 #ifdef COMPILE_DL_AALIB
 76 ZEND_GET_MODULE(aalib)
 77 #endif
 78 
 79 /* {{{ PHP_INI
 80  */
 81 /* Remove comments and fill if you need to have entries in php.ini
 82 PHP_INI_BEGIN()
 83     STD_PHP_INI_ENTRY("aalib.global_value",      "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_aalib_globals, aalib_globals)
 84     STD_PHP_INI_ENTRY("aalib.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_aalib_globals, aalib_globals)
 85 PHP_INI_END()
 86 */
 87 / }}} /
 88 
 89 /* {{{ php_aalib_init_globals
 90  */
 91 /* Uncomment this function if you have INI entries
 92 static void php_aalib_init_globals(zend_aalib_globals *aalib_globals)
 93 {
 94         aalib_globals->global_value = 0;
 95         aalib_globals->global_string = NULL;
 96 }
 97 */
 98 / }}} /
 99 
100 /* {{{ PHP_MINIT_FUNCTION
101  */
102 PHP_MINIT_FUNCTION(aalib)
103 {
104         /* If you have INI entries, uncomment these lines 
105         ZEND_INIT_MODULE_GLOBALS(aalib, php_aalib_init_globals, NULL);
106         REGISTER_INI_ENTRIES();
107         */
108         return SUCCESS;
109 }
110 / }}} /
111 
112 /* {{{ PHP_MSHUTDOWN_FUNCTION
113  */
114 PHP_MSHUTDOWN_FUNCTION(aalib)
115 {
116         /* uncomment this line if you have INI entries
117         UNREGISTER_INI_ENTRIES();
118         */
119         return SUCCESS;
120 }
121 / }}} /
122 
123 / Remove if there's nothing to do at request start /
124 /* {{{ PHP_RINIT_FUNCTION
125  */
126 PHP_RINIT_FUNCTION(aalib)
127 {
128         return SUCCESS;
129 }
130 / }}} /
131 
132 / Remove if there's nothing to do at request end /
133 /* {{{ PHP_RSHUTDOWN_FUNCTION
134  */
135 PHP_RSHUTDOWN_FUNCTION(aalib)
136 {
137         return SUCCESS;
138 }
139 / }}} /
140 
141 /* {{{ PHP_MINFO_FUNCTION
142  */
143 PHP_MINFO_FUNCTION(aalib)
144 {
145         php_info_print_table_start();
146         php_info_print_table_header(2, "aalib support", "enabled");
147         php_info_print_table_end();
148 
149         /* Remove comments if you have entries in php.ini
150         DISPLAY_INI_ENTRIES();
151         */
152 }
153 / }}} /
154 
155 
156 /* Remove the following function when you have succesfully modified config.m4
157    so that your module can be compiled into PHP, it exists only for testing
158    purposes. */
159 
160 / Every user-visible function in PHP should document itself in the source /
161 /* {{{ proto string confirm_aalib_compiled(string arg)
162    Return a string to confirm that the module is compiled in */
163 PHP_FUNCTION(confirm_aalib_compiled)
164 {
165         char *arg = NULL;
166         int arg_len, len;
167         char string[256];
168 
169         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
170                 return;
171         }
172 
173         len = sprintf(string, "Congratulations! You have successfully modified ext/.78s/config.m4. Module .78s is now compiled into PHP.", "aalib", arg);
174         RETURN_STRINGL(string, len, 1);
175 }
176 / }}} /
177 /* The previous line is meant for vim and emacs, so it can correctly fold and 
178    unfold functions in source code. See the corresponding marks just before 
179    function definition, where the functions purpose is also documented. Please 
180    follow this convention for the convenience of others editing your code.
181 */
182 
183 /* {{{ proto resource aa_init()
184    Initialize the AA library */
185 PHP_FUNCTION(aa_init)
186 {
187         if (ZEND_NUM_ARGS() != 0) {
188                 WRONG_PARAM_COUNT;
189         }
190         php_error(E_WARNING, "aa_init: not yet implemented");
191 }
192 / }}} /
193 
194 /* {{{ proto int aa_get_screen_height(resource c)
195    Get the screen height */
196 PHP_FUNCTION(aa_get_screen_height)
197 {
198         int argc = ZEND_NUM_ARGS();
199         int c_id = -1;
200         zval *c = NULL;
201 
202         if (zend_parse_parameters(argc TSRMLS_CC, "r", &c) == FAILURE) 
203                 return;
204 
205         if (c) {
206                 ZEND_FETCH_RESOURCE(???, ???, &c, c_id, "???", ???_rsrc_id);
207         }
208 
209         php_error(E_WARNING, "aa_get_screen_height: not yet implemented");
210 }
211 / }}} /
212 
213 /* {{{ proto int aa_get_screen_width(resource c)
214    Get the screen width */
215 PHP_FUNCTION(aa_get_screen_width)
216 {
217         int argc = ZEND_NUM_ARGS();
218         int c_id = -1;
219         zval *c = NULL;
220 
221         if (zend_parse_parameters(argc TSRMLS_CC, "r", &c) == FAILURE) 
222                 return;
223 
224         if (c) {
225                 ZEND_FETCH_RESOURCE(???, ???, &c, c_id, "???", ???_rsrc_id);
226         }
227 
228         php_error(E_WARNING, "aa_get_screen_width: not yet implemented");
229 }
230 / }}} /
231 
232 /* {{{ proto void aa_put_pixel(resource c, int x, int y, int value)
233    Draw a pixel */
234 PHP_FUNCTION(aa_put_pixel)
235 {
236         int argc = ZEND_NUM_ARGS();
237         int c_id = -1;
238         long x;
239         long y;
240         long value;
241         zval *c = NULL;
242 
243         if (zend_parse_parameters(argc TSRMLS_CC, "rlll", &c, &x, &y, &value) == FAILURE) 
244                 return;
245 
246         if (c) {
247                 ZEND_FETCH_RESOURCE(???, ???, &c, c_id, "???", ???_rsrc_id);
248         }
249 
250         php_error(E_WARNING, "aa_put_pixel: not yet implemented");
251 }
252 / }}} /
253 
254 /* {{{ proto void aa_render(resource c [, int contrast [, int dither [, int inversion [, int randomval]]]])
255    Render the image */
256 PHP_FUNCTION(aa_render)
257 {
258         int argc = ZEND_NUM_ARGS();
259         int c_id = -1;
260         long contrast;
261         long dither;
262         long inversion;
263         long randomval;
264         zval *c = NULL;
265 
266         if (zend_parse_parameters(argc TSRMLS_CC, "r|llll", &c, &contrast, &dither, &inversion, &randomval) == FAILURE) 
267                 return;
268 
269         if (c) {
270                 ZEND_FETCH_RESOURCE(???, ???, &c, c_id, "???", ???_rsrc_id);
271         }
272 
273         php_error(E_WARNING, "aa_render: not yet implemented");
274 }
275 / }}} /
276 
277 /* {{{ proto string aa_get_all(resource c)
278    Get the result as one string */
279 PHP_FUNCTION(aa_get_all)
280 {
281         int argc = ZEND_NUM_ARGS();
282         int c_id = -1;
283         zval *c = NULL;
284 
285         if (zend_parse_parameters(argc TSRMLS_CC, "r", &c) == FAILURE) 
286                 return;
287 
288         if (c) {
289                 ZEND_FETCH_RESOURCE(???, ???, &c, c_id, "???", ???_rsrc_id);
290         }
291 
292         php_error(E_WARNING, "aa_get_all: not yet implemented");
293 }
294 / }}} /
295 
296 /* {{{ proto array aa_get_lines(resource c)
297    Get the result with one line in an array element */
298 PHP_FUNCTION(aa_get_lines)
299 {
300         int argc = ZEND_NUM_ARGS();
301         int c_id = -1;
302         zval *c = NULL;
303 
304         if (zend_parse_parameters(argc TSRMLS_CC, "r", &c) == FAILURE) 
305                 return;
306 
307         if (c) {
308                 ZEND_FETCH_RESOURCE(???, ???, &c, c_id, "???", ???_rsrc_id);
309         }
310 
311         php_error(E_WARNING, "aa_get_lines: not yet implemented");
312 }
313 / }}} /
314 
315 /* {{{ proto array aa_get_array(resource c)
316    Get the result with one element per pixel */
317 PHP_FUNCTION(aa_get_array)
318 {
319         int argc = ZEND_NUM_ARGS();
320         int c_id = -1;
321         zval *c = NULL;
322 
323         if (zend_parse_parameters(argc TSRMLS_CC, "r", &c) == FAILURE) 
324                 return;
325 
326         if (c) {
327                 ZEND_FETCH_RESOURCE(???, ???, &c, c_id, "???", ???_rsrc_id);
328         }
329 
330         php_error(E_WARNING, "aa_get_array: not yet implemented");
331 }
332 / }}} /
333 
334 
335 /*
336  * Local variables:
337  * tab-width: 4
338  * c-basic-offset: 4
339  * End:
340  * vim600: noet sw=4 ts=4 fdm=marker
341  * vim<600: noet sw=4 ts=4
342  */