source: libcaca/trunk/caca-php/php_caca.c @ 3089

Last change on this file since 3089 was 3089, checked in by nico, 12 years ago
  • Initial release of caca-php
File size: 11.1 KB
Line 
1/*
2 *  php-caca      Php binding for Libcaca
3 *  Copyright (c) 2008 Vion Nicolas <nico@picapo.net>
4 *
5 *
6 *  This library is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include "php.h"
18#include "php_caca.h"
19
20static function_entry caca_functions[] = {
21        PHP_FE(caca_manage_canvas, NULL)
22        PHP_FE(caca_unmanage_canvas, NULL)
23        PHP_FE(caca_set_canvas_size, NULL)
24        PHP_FE(caca_get_canvas_width, NULL)
25        PHP_FE(caca_get_canvas_height, NULL)
26        PHP_FE(caca_free_canvas, NULL)
27        PHP_FE(caca_rand, NULL)
28        PHP_FE(caca_get_version, NULL)
29        PHP_FE(caca_gotoxy, NULL)
30        PHP_FE(caca_get_cursor_x, NULL)
31        PHP_FE(caca_get_cursor_y, NULL)
32        PHP_FE(caca_put_char, NULL)
33        PHP_FE(caca_put_str, NULL)
34        PHP_FE(caca_printf, NULL)
35        PHP_FE(caca_clear_canvas, NULL)
36        PHP_FE(caca_set_canvas_handle, NULL)
37        PHP_FE(caca_get_canvas_handle_x, NULL)
38        PHP_FE(caca_get_canvas_handle_y, NULL)
39        PHP_FE(caca_blit, NULL)
40        PHP_FE(caca_set_canvas_boundaries, NULL)
41        PHP_FE(caca_invert, NULL)
42        PHP_FE(caca_flip, NULL)
43        PHP_FE(caca_flop, NULL)
44        PHP_FE(caca_rotate_left, NULL)
45        PHP_FE(caca_rotate_right, NULL)
46        PHP_FE(caca_stretch_left, NULL)
47        PHP_FE(caca_stretch_right, NULL)
48        PHP_FE(caca_set_attr, NULL)
49        PHP_FE(caca_put_attr, NULL)
50        PHP_FE(caca_set_color_ansi, NULL)
51        PHP_FE(caca_set_color_argb, NULL)
52        PHP_FE(caca_draw_line, NULL)
53        PHP_FE(caca_draw_polyline, NULL)
54        PHP_FE(caca_draw_thin_line, NULL)
55        PHP_FE(caca_draw_thin_polyline, NULL)
56        PHP_FE(caca_draw_circle, NULL)
57        PHP_FE(caca_draw_ellipse, NULL)
58        PHP_FE(caca_draw_thin_ellipse, NULL)
59        PHP_FE(caca_fill_ellipse, NULL)
60        PHP_FE(caca_draw_box, NULL)
61        PHP_FE(caca_draw_thin_box, NULL)
62        PHP_FE(caca_fill_box, NULL)
63        PHP_FE(caca_draw_triangle, NULL)
64        PHP_FE(caca_draw_thin_triangle, NULL)
65        PHP_FE(caca_fill_triangle, NULL)
66        PHP_FE(caca_get_frame_count, NULL)
67        PHP_FE(caca_set_frame, NULL)
68        PHP_FE(caca_get_frame_name, NULL)
69        PHP_FE(caca_set_frame_name, NULL)
70        PHP_FE(caca_create_frame, NULL)
71        PHP_FE(caca_free_frame, NULL)
72        PHP_FE(caca_set_dither_palette, NULL)
73        PHP_FE(caca_set_dither_brightness, NULL)
74        PHP_FE(caca_get_dither_brightness, NULL)
75        PHP_FE(caca_set_dither_gamma, NULL)
76        PHP_FE(caca_get_dither_gamma, NULL)
77        PHP_FE(caca_set_dither_contrast, NULL)
78        PHP_FE(caca_get_dither_contrast, NULL)
79        PHP_FE(caca_set_dither_antialias, NULL)
80        PHP_FE(caca_get_dither_antialias_list, NULL)
81        PHP_FE(caca_get_dither_antialias, NULL)
82        PHP_FE(caca_set_dither_color, NULL)
83        PHP_FE(caca_get_dither_color_list, NULL)
84        PHP_FE(caca_get_dither_color, NULL)
85        PHP_FE(caca_set_dither_charset, NULL)
86        PHP_FE(caca_get_dither_charset_list, NULL)
87        PHP_FE(caca_get_dither_charset, NULL)
88        PHP_FE(caca_set_dither_algorithm, NULL)
89        PHP_FE(caca_get_dither_algorithm_list, NULL)
90        PHP_FE(caca_get_dither_algorithm, NULL)
91        PHP_FE(caca_dither_bitmap, NULL)
92        PHP_FE(caca_free_dither, NULL)
93        PHP_FE(caca_get_font_list, NULL)
94        PHP_FE(caca_get_font_width, NULL)
95        PHP_FE(caca_get_font_height, NULL)
96        PHP_FE(caca_render_canvas, NULL)
97        PHP_FE(caca_free_font, NULL)
98        PHP_FE(caca_canvas_set_figfont, NULL)
99        PHP_FE(caca_put_figchar, NULL)
100        PHP_FE(caca_flush_figlet, NULL)
101        PHP_FE(caca_file_close, NULL)
102        PHP_FE(caca_file_gets, NULL)
103        PHP_FE(caca_file_eof, NULL)
104        PHP_FE(caca_get_import_list, NULL)
105        PHP_FE(caca_export_memory, NULL)
106        PHP_FE(caca_get_export_list, NULL)
107        PHP_FE(caca_get_display_driver_list, NULL)
108        PHP_FE(caca_get_display_driver, NULL)
109        PHP_FE(caca_set_display_driver, NULL)
110        PHP_FE(caca_free_display, NULL)
111        PHP_FE(caca_refresh_display, NULL)
112        PHP_FE(caca_set_display_time, NULL)
113        PHP_FE(caca_get_display_time, NULL)
114        PHP_FE(caca_get_display_width, NULL)
115        PHP_FE(caca_get_display_height, NULL)
116        PHP_FE(caca_set_display_title, NULL)
117        PHP_FE(caca_set_mouse, NULL)
118        PHP_FE(caca_set_cursor, NULL)
119        PHP_FE(caca_get_event, NULL)
120        PHP_FE(caca_get_mouse_x, NULL)
121        PHP_FE(caca_get_mouse_y, NULL)
122        PHP_FE(caca_get_event_type, NULL)
123        PHP_FE(caca_get_event_key_ch, NULL)
124        PHP_FE(caca_get_event_mouse_button, NULL)
125        PHP_FE(caca_get_event_mouse_x, NULL)
126        PHP_FE(caca_get_event_mouse_y, NULL)
127        PHP_FE(caca_get_event_resize_width, NULL)
128        PHP_FE(caca_get_event_resize_height, NULL)
129
130        {NULL, NULL, NULL}
131};
132
133zend_module_entry caca_module_entry = {
134#if ZEND_MODULE_API_NO >= 20010901
135        STANDARD_MODULE_HEADER,
136#endif
137        PHP_CACA_EXTNAME,
138        caca_functions,
139        PHP_MINIT(caca),
140        NULL,
141        NULL,
142        NULL,
143        PHP_MINFO(caca),
144#if ZEND_MODULE_API_NO >= 20010901
145        PHP_CACA_VERSION,
146#endif
147        STANDARD_MODULE_PROPERTIES
148};
149
150#ifdef COMPILE_DL_CACA
151ZEND_GET_MODULE(caca)
152#endif
153
154PHP_MINFO_FUNCTION(caca) {
155        php_info_print_table_start();
156        php_info_print_table_row(2, "Caca library version", caca_get_version());
157        php_info_print_table_end();
158}
159//--------INITIALIZATION---------//
160
161PHP_MINIT_FUNCTION(caca) {
162       
163        REGISTER_LONG_CONSTANT("CACA_BLACK", CACA_BLACK, CONST_CS | CONST_PERSISTENT);
164        REGISTER_LONG_CONSTANT("CACA_BLUE", CACA_BLUE, CONST_CS | CONST_PERSISTENT);
165        REGISTER_LONG_CONSTANT("CACA_GREEN", CACA_GREEN, CONST_CS | CONST_PERSISTENT);
166        REGISTER_LONG_CONSTANT("CACA_CYAN", CACA_CYAN, CONST_CS | CONST_PERSISTENT);
167        REGISTER_LONG_CONSTANT("CACA_RED", CACA_RED, CONST_CS | CONST_PERSISTENT);
168        REGISTER_LONG_CONSTANT("CACA_MAGENTA", CACA_MAGENTA, CONST_CS | CONST_PERSISTENT);
169        REGISTER_LONG_CONSTANT("CACA_BROWN", CACA_BROWN, CONST_CS | CONST_PERSISTENT);
170        REGISTER_LONG_CONSTANT("CACA_LIGHTGRAY", CACA_LIGHTGRAY, CONST_CS | CONST_PERSISTENT);
171        REGISTER_LONG_CONSTANT("CACA_DARKGRAY", CACA_DARKGRAY, CONST_CS | CONST_PERSISTENT);
172        REGISTER_LONG_CONSTANT("CACA_LIGHTBLUE", CACA_LIGHTBLUE, CONST_CS | CONST_PERSISTENT);
173        REGISTER_LONG_CONSTANT("CACA_LIGHTGREEN", CACA_LIGHTGREEN, CONST_CS | CONST_PERSISTENT);
174        REGISTER_LONG_CONSTANT("CACA_LIGHTCYAN", CACA_LIGHTCYAN, CONST_CS | CONST_PERSISTENT);
175        REGISTER_LONG_CONSTANT("CACA_LIGHTRED", CACA_LIGHTRED, CONST_CS | CONST_PERSISTENT);
176        REGISTER_LONG_CONSTANT("CACA_LIGHTMAGENTA", CACA_LIGHTMAGENTA, CONST_CS | CONST_PERSISTENT);
177        REGISTER_LONG_CONSTANT("CACA_YELLOW", CACA_YELLOW, CONST_CS | CONST_PERSISTENT);
178        REGISTER_LONG_CONSTANT("CACA_WHITE", CACA_WHITE, CONST_CS | CONST_PERSISTENT);
179        REGISTER_LONG_CONSTANT("CACA_DEFAULT", CACA_DEFAULT, CONST_CS | CONST_PERSISTENT);
180        REGISTER_LONG_CONSTANT("CACA_TRANSPARENT", CACA_TRANSPARENT, CONST_CS | CONST_PERSISTENT);
181        REGISTER_LONG_CONSTANT("CACA_BOLD", CACA_BOLD, CONST_CS | CONST_PERSISTENT);
182        REGISTER_LONG_CONSTANT("CACA_ITALICS", CACA_ITALICS, CONST_CS | CONST_PERSISTENT);
183        REGISTER_LONG_CONSTANT("CACA_UNDERLINE", CACA_UNDERLINE, CONST_CS | CONST_PERSISTENT);
184        REGISTER_LONG_CONSTANT("CACA_BLINK", CACA_BLINK, CONST_CS | CONST_PERSISTENT);
185
186        return SUCCESS;
187}
188
189//-------CACA'S FUNCTIONS----------------//
190
191PHP_FUNCTION(caca_manage_canvas) {
192}
193
194PHP_FUNCTION(caca_unmanage_canvas) {
195}
196
197PHP_FUNCTION(caca_set_canvas_size) {
198}
199
200PHP_FUNCTION(caca_get_canvas_width) {
201}
202
203PHP_FUNCTION(caca_get_canvas_height) {
204}
205
206PHP_FUNCTION(caca_free_canvas) {
207}
208
209PHP_FUNCTION(caca_rand) {
210}
211
212PHP_FUNCTION(caca_get_version) {
213        RETURN_STRING(estrdup(caca_get_version()), 0);
214}
215
216PHP_FUNCTION(caca_gotoxy) {
217}
218
219PHP_FUNCTION(caca_get_cursor_x) {
220}
221
222PHP_FUNCTION(caca_get_cursor_y) {
223}
224
225PHP_FUNCTION(caca_put_char) {
226}
227
228PHP_FUNCTION(caca_put_str) {
229}
230
231PHP_FUNCTION(caca_printf) {
232}
233
234PHP_FUNCTION(caca_clear_canvas) {
235}
236
237PHP_FUNCTION(caca_set_canvas_handle) {
238}
239
240PHP_FUNCTION(caca_get_canvas_handle_x) {
241}
242
243PHP_FUNCTION(caca_get_canvas_handle_y) {
244}
245
246PHP_FUNCTION(caca_blit) {
247}
248
249PHP_FUNCTION(caca_set_canvas_boundaries) {
250}
251
252PHP_FUNCTION(caca_invert) {
253}
254
255PHP_FUNCTION(caca_flip) {
256}
257
258PHP_FUNCTION(caca_flop) {
259}
260
261PHP_FUNCTION(caca_rotate_180) {
262}
263
264PHP_FUNCTION(caca_rotate_left) {
265}
266
267PHP_FUNCTION(caca_rotate_right) {
268}
269
270PHP_FUNCTION(caca_stretch_left) {
271}
272
273PHP_FUNCTION(caca_stretch_right) {
274}
275
276PHP_FUNCTION(caca_set_attr) {
277}
278
279PHP_FUNCTION(caca_put_attr) {
280}
281
282PHP_FUNCTION(caca_set_color_ansi) {
283}
284
285PHP_FUNCTION(caca_set_color_argb) {
286}
287
288PHP_FUNCTION(caca_attr_to_argb64) {
289}
290
291PHP_FUNCTION(caca_utf32_to_ascii) {
292}
293
294PHP_FUNCTION(caca_utf32_is_fullwidth) {
295}
296
297PHP_FUNCTION(caca_draw_line) {
298}
299
300PHP_FUNCTION(caca_draw_polyline) {
301}
302
303PHP_FUNCTION(caca_draw_thin_line) {
304}
305
306PHP_FUNCTION(caca_draw_thin_polyline) {
307}
308
309PHP_FUNCTION(caca_draw_circle) {
310}
311
312PHP_FUNCTION(caca_draw_ellipse) {
313}
314
315PHP_FUNCTION(caca_draw_thin_ellipse) {
316}
317
318PHP_FUNCTION(caca_fill_ellipse) {
319}
320
321PHP_FUNCTION(caca_draw_box) {
322}
323
324PHP_FUNCTION(caca_draw_thin_box) {
325}
326
327PHP_FUNCTION(caca_draw_cp437_box) {
328}
329
330PHP_FUNCTION(caca_fill_box) {
331}
332
333PHP_FUNCTION(caca_draw_triangle) {
334}
335
336PHP_FUNCTION(caca_draw_thin_triangle) {
337}
338
339PHP_FUNCTION(caca_fill_triangle) {
340}
341
342PHP_FUNCTION(caca_get_frame_count) {
343}
344
345PHP_FUNCTION(caca_set_frame) {
346}
347
348PHP_FUNCTION(caca_get_frame_name) {
349}
350
351PHP_FUNCTION(caca_set_frame_name) {
352}
353
354PHP_FUNCTION(caca_create_frame) {
355}
356
357PHP_FUNCTION(caca_free_frame) {
358}
359
360PHP_FUNCTION(caca_set_dither_palette) {
361}
362
363PHP_FUNCTION(caca_set_dither_brightness) {
364}
365
366PHP_FUNCTION(caca_get_dither_brightness) {
367}
368
369PHP_FUNCTION(caca_set_dither_gamma) {
370}
371
372PHP_FUNCTION(caca_get_dither_gamma) {
373}
374
375PHP_FUNCTION(caca_set_dither_contrast) {
376}
377
378PHP_FUNCTION(caca_get_dither_contrast) {
379}
380
381PHP_FUNCTION(caca_set_dither_antialias) {
382}
383
384PHP_FUNCTION(caca_get_dither_antialias_list) {
385}
386
387PHP_FUNCTION(caca_get_dither_antialias) {
388}
389
390PHP_FUNCTION(caca_set_dither_color) {
391}
392
393PHP_FUNCTION(caca_get_dither_color_list) {
394}
395
396PHP_FUNCTION(caca_get_dither_color) {
397}
398
399PHP_FUNCTION(caca_set_dither_charset) {
400}
401
402PHP_FUNCTION(caca_get_dither_charset_list) {
403}
404
405PHP_FUNCTION(caca_get_dither_charset) {
406}
407
408PHP_FUNCTION(caca_set_dither_algorithm) {
409}
410
411PHP_FUNCTION(caca_get_dither_algorithm_list) {
412}
413
414PHP_FUNCTION(caca_get_dither_algorithm) {
415}
416
417PHP_FUNCTION(caca_dither_bitmap) {
418}
419
420PHP_FUNCTION(caca_free_dither) {
421}
422
423PHP_FUNCTION(caca_get_font_list) {
424}
425
426PHP_FUNCTION(caca_get_font_width) {
427}
428
429PHP_FUNCTION(caca_get_font_height) {
430}
431
432PHP_FUNCTION(caca_render_canvas) {
433}
434
435PHP_FUNCTION(caca_free_font) {
436}
437
438PHP_FUNCTION(caca_canvas_set_figfont) {
439}
440
441PHP_FUNCTION(caca_put_figchar) {
442}
443
444PHP_FUNCTION(caca_flush_figlet) {
445}
446
447PHP_FUNCTION(caca_file_close) {
448}
449
450PHP_FUNCTION(caca_file_gets) {
451}
452
453PHP_FUNCTION(caca_file_eof) {
454}
455
456PHP_FUNCTION(caca_get_import_list) {
457}
458
459PHP_FUNCTION(caca_export_memory) {
460}
461
462PHP_FUNCTION(caca_get_export_list) {
463}
464
465PHP_FUNCTION(caca_get_display_driver_list) {
466}
467
468PHP_FUNCTION(caca_get_display_driver) {
469}
470
471PHP_FUNCTION(caca_set_display_driver) {
472}
473
474PHP_FUNCTION(caca_free_display) {
475}
476
477PHP_FUNCTION(caca_refresh_display) {
478}
479
480PHP_FUNCTION(caca_set_display_time) {
481}
482
483PHP_FUNCTION(caca_get_display_time) {
484}
485
486PHP_FUNCTION(caca_get_display_width) {
487}
488
489PHP_FUNCTION(caca_get_display_height) {
490}
491
492PHP_FUNCTION(caca_set_display_title) {
493}
494
495PHP_FUNCTION(caca_set_mouse) {
496}
497
498PHP_FUNCTION(caca_set_cursor) {
499}
500
501PHP_FUNCTION(caca_get_event) {
502}
503
504PHP_FUNCTION(caca_get_mouse_x) {
505}
506
507PHP_FUNCTION(caca_get_mouse_y) {
508}
509
510PHP_FUNCTION(caca_get_event_type) {
511}
512
513PHP_FUNCTION(caca_get_event_key_ch) {
514}
515
516PHP_FUNCTION(caca_get_event_key_utf8) {
517}
518
519PHP_FUNCTION(caca_get_event_mouse_button) {
520}
521
522PHP_FUNCTION(caca_get_event_mouse_x) {
523}
524
525PHP_FUNCTION(caca_get_event_mouse_y) {
526}
527
528PHP_FUNCTION(caca_get_event_resize_width) {
529}
530
531PHP_FUNCTION(caca_get_event_resize_height) {
532}
533
534
Note: See TracBrowser for help on using the repository browser.