You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

954 line
29 KiB

  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. #ifdef HAVE_CONFIG_H
  13. #include "config.h"
  14. #endif
  15. #include "php.h"
  16. #include "php_caca.h"
  17. static function_entry caca_functions[] = {
  18. PHP_FE(caca_create_canvas, NULL)
  19. PHP_FE(caca_manage_canvas, NULL)
  20. PHP_FE(caca_unmanage_canvas, NULL)
  21. PHP_FE(caca_set_canvas_size, NULL)
  22. PHP_FE(caca_get_canvas_width, NULL)
  23. PHP_FE(caca_get_canvas_height, NULL)
  24. PHP_FE(caca_get_canvas_chars, NULL)
  25. PHP_FE(caca_get_canvas_attrs, NULL)
  26. PHP_FE(caca_rand, NULL)
  27. PHP_FE(caca_get_version, NULL)
  28. PHP_FE(caca_gotoxy, NULL)
  29. PHP_FE(caca_get_cursor_x, NULL)
  30. PHP_FE(caca_get_cursor_y, NULL)
  31. PHP_FE(caca_put_char, NULL)
  32. PHP_FE(caca_get_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_get_attr, NULL)
  49. PHP_FE(caca_set_attr, NULL)
  50. PHP_FE(caca_put_attr, NULL)
  51. PHP_FE(caca_set_color_ansi, NULL)
  52. PHP_FE(caca_set_color_argb, NULL)
  53. PHP_FE(caca_attr_to_ansi, NULL)
  54. PHP_FE(caca_attr_to_ansi_fg, NULL)
  55. PHP_FE(caca_attr_to_ansi_bg, NULL)
  56. PHP_FE(caca_draw_line, NULL)
  57. PHP_FE(caca_draw_polyline, NULL)
  58. PHP_FE(caca_draw_thin_line, NULL)
  59. PHP_FE(caca_draw_thin_polyline, NULL)
  60. PHP_FE(caca_draw_circle, NULL)
  61. PHP_FE(caca_draw_ellipse, NULL)
  62. PHP_FE(caca_draw_thin_ellipse, NULL)
  63. PHP_FE(caca_fill_ellipse, NULL)
  64. PHP_FE(caca_draw_box, NULL)
  65. PHP_FE(caca_draw_thin_box, NULL)
  66. PHP_FE(caca_fill_box, NULL)
  67. PHP_FE(caca_draw_triangle, NULL)
  68. PHP_FE(caca_draw_thin_triangle, NULL)
  69. PHP_FE(caca_fill_triangle, NULL)
  70. PHP_FE(caca_get_frame_count, NULL)
  71. PHP_FE(caca_set_frame, NULL)
  72. PHP_FE(caca_set_frame_name, NULL)
  73. PHP_FE(caca_create_frame, NULL)
  74. PHP_FE(caca_free_frame, NULL)
  75. PHP_FE(caca_set_dither_palette, NULL)
  76. PHP_FE(caca_set_dither_brightness, NULL)
  77. PHP_FE(caca_get_dither_brightness, NULL)
  78. PHP_FE(caca_set_dither_gamma, NULL)
  79. PHP_FE(caca_get_dither_gamma, NULL)
  80. PHP_FE(caca_set_dither_contrast, NULL)
  81. PHP_FE(caca_get_dither_contrast, NULL)
  82. PHP_FE(caca_set_dither_antialias, NULL)
  83. PHP_FE(caca_get_dither_antialias_list, NULL)
  84. PHP_FE(caca_get_dither_antialias, NULL)
  85. PHP_FE(caca_set_dither_color, NULL)
  86. PHP_FE(caca_get_dither_color_list, NULL)
  87. PHP_FE(caca_get_dither_color, NULL)
  88. PHP_FE(caca_set_dither_charset, NULL)
  89. PHP_FE(caca_get_dither_charset_list, NULL)
  90. PHP_FE(caca_get_dither_charset, NULL)
  91. PHP_FE(caca_set_dither_algorithm, NULL)
  92. PHP_FE(caca_get_dither_algorithm_list, NULL)
  93. PHP_FE(caca_get_dither_algorithm, NULL)
  94. PHP_FE(caca_dither_bitmap, NULL)
  95. PHP_FE(caca_get_font_list, NULL)
  96. PHP_FE(caca_get_font_width, NULL)
  97. PHP_FE(caca_get_font_height, NULL)
  98. PHP_FE(caca_render_canvas, NULL)
  99. PHP_FE(caca_canvas_set_figfont, NULL)
  100. PHP_FE(caca_put_figchar, NULL)
  101. PHP_FE(caca_flush_figlet, NULL)
  102. PHP_FE(caca_file_close, NULL)
  103. PHP_FE(caca_file_tell, NULL)
  104. PHP_FE(caca_file_read, NULL)
  105. PHP_FE(caca_file_write, NULL)
  106. PHP_FE(caca_file_gets, NULL)
  107. PHP_FE(caca_file_eof, NULL)
  108. PHP_FE(caca_import_memory, NULL)
  109. PHP_FE(caca_import_file, NULL)
  110. PHP_FE(caca_get_import_list, NULL)
  111. PHP_FE(caca_get_export_list, NULL)
  112. PHP_FE(caca_create_display, NULL)
  113. PHP_FE(caca_create_display_with_driver, NULL)
  114. PHP_FE(caca_get_display_driver_list, NULL)
  115. PHP_FE(caca_get_display_driver, NULL)
  116. PHP_FE(caca_set_display_driver, NULL)
  117. PHP_FE(caca_get_canvas, NULL)
  118. PHP_FE(caca_refresh_display, NULL)
  119. PHP_FE(caca_set_display_time, NULL)
  120. PHP_FE(caca_get_display_time, NULL)
  121. PHP_FE(caca_get_display_width, NULL)
  122. PHP_FE(caca_get_display_height, NULL)
  123. PHP_FE(caca_set_display_title, NULL)
  124. PHP_FE(caca_set_mouse, NULL)
  125. PHP_FE(caca_set_cursor, NULL)
  126. PHP_FE(caca_get_event, NULL)
  127. PHP_FE(caca_get_mouse_x, NULL)
  128. PHP_FE(caca_get_mouse_y, NULL)
  129. PHP_FE(caca_get_event_type, NULL)
  130. PHP_FE(caca_get_event_key_ch, NULL)
  131. PHP_FE(caca_get_event_mouse_button, NULL)
  132. PHP_FE(caca_get_event_mouse_x, NULL)
  133. PHP_FE(caca_get_event_mouse_y, NULL)
  134. PHP_FE(caca_get_event_resize_width, NULL)
  135. PHP_FE(caca_get_event_resize_height, NULL)
  136. {NULL, NULL, NULL}
  137. };
  138. zend_module_entry caca_module_entry = {
  139. #if ZEND_MODULE_API_NO >= 20010901
  140. STANDARD_MODULE_HEADER,
  141. #endif
  142. PHP_CACA_EXTNAME,
  143. caca_functions,
  144. PHP_MINIT(caca),
  145. NULL,
  146. NULL,
  147. NULL,
  148. PHP_MINFO(caca),
  149. #if ZEND_MODULE_API_NO >= 20010901
  150. PHP_CACA_VERSION,
  151. #endif
  152. STANDARD_MODULE_PROPERTIES
  153. };
  154. #ifdef COMPILE_DL_CACA
  155. ZEND_GET_MODULE(caca)
  156. #endif
  157. PHP_MINFO_FUNCTION(caca) {
  158. php_info_print_table_start();
  159. php_info_print_table_row(2, "Caca library version", caca_get_version());
  160. php_info_print_table_end();
  161. }
  162. //--------CACA'S RESSOURCES DESTRUCTORS-----------//
  163. static void php_caca_canvas_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
  164. caca_free_canvas(rsrc->ptr);
  165. }
  166. static void php_caca_dither_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
  167. caca_free_dither(rsrc->ptr);
  168. }
  169. static void php_caca_font_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
  170. caca_free_font(rsrc->ptr);
  171. }
  172. static void php_caca_file_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
  173. }
  174. static void php_caca_display_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
  175. caca_free_display(rsrc->ptr);
  176. }
  177. static void php_caca_event_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
  178. }
  179. //--------INITIALIZATION---------//
  180. PHP_MINIT_FUNCTION(caca) {
  181. le_caca_canvas = zend_register_list_destructors_ex(php_caca_canvas_dtor, NULL, PHP_CACA_CANVAS_RES_NAME, module_number);
  182. le_caca_dither = zend_register_list_destructors_ex(php_caca_dither_dtor, NULL, PHP_CACA_DITHER_RES_NAME, module_number);
  183. le_caca_font = zend_register_list_destructors_ex(php_caca_font_dtor, NULL, PHP_CACA_FONT_RES_NAME, module_number);
  184. le_caca_file = zend_register_list_destructors_ex(php_caca_file_dtor, NULL, PHP_CACA_FILE_RES_NAME, module_number);
  185. le_caca_display = zend_register_list_destructors_ex(php_caca_display_dtor, NULL, PHP_CACA_DISPLAY_RES_NAME, module_number);
  186. le_caca_event = zend_register_list_destructors_ex(php_caca_event_dtor, NULL, PHP_CACA_EVENT_RES_NAME, module_number);
  187. REGISTER_LONG_CONSTANT("CACA_BLACK", CACA_BLACK, CONST_CS | CONST_PERSISTENT);
  188. REGISTER_LONG_CONSTANT("CACA_BLUE", CACA_BLUE, CONST_CS | CONST_PERSISTENT);
  189. REGISTER_LONG_CONSTANT("CACA_GREEN", CACA_GREEN, CONST_CS | CONST_PERSISTENT);
  190. REGISTER_LONG_CONSTANT("CACA_CYAN", CACA_CYAN, CONST_CS | CONST_PERSISTENT);
  191. REGISTER_LONG_CONSTANT("CACA_RED", CACA_RED, CONST_CS | CONST_PERSISTENT);
  192. REGISTER_LONG_CONSTANT("CACA_MAGENTA", CACA_MAGENTA, CONST_CS | CONST_PERSISTENT);
  193. REGISTER_LONG_CONSTANT("CACA_BROWN", CACA_BROWN, CONST_CS | CONST_PERSISTENT);
  194. REGISTER_LONG_CONSTANT("CACA_LIGHTGRAY", CACA_LIGHTGRAY, CONST_CS | CONST_PERSISTENT);
  195. REGISTER_LONG_CONSTANT("CACA_DARKGRAY", CACA_DARKGRAY, CONST_CS | CONST_PERSISTENT);
  196. REGISTER_LONG_CONSTANT("CACA_LIGHTBLUE", CACA_LIGHTBLUE, CONST_CS | CONST_PERSISTENT);
  197. REGISTER_LONG_CONSTANT("CACA_LIGHTGREEN", CACA_LIGHTGREEN, CONST_CS | CONST_PERSISTENT);
  198. REGISTER_LONG_CONSTANT("CACA_LIGHTCYAN", CACA_LIGHTCYAN, CONST_CS | CONST_PERSISTENT);
  199. REGISTER_LONG_CONSTANT("CACA_LIGHTRED", CACA_LIGHTRED, CONST_CS | CONST_PERSISTENT);
  200. REGISTER_LONG_CONSTANT("CACA_LIGHTMAGENTA", CACA_LIGHTMAGENTA, CONST_CS | CONST_PERSISTENT);
  201. REGISTER_LONG_CONSTANT("CACA_YELLOW", CACA_YELLOW, CONST_CS | CONST_PERSISTENT);
  202. REGISTER_LONG_CONSTANT("CACA_WHITE", CACA_WHITE, CONST_CS | CONST_PERSISTENT);
  203. REGISTER_LONG_CONSTANT("CACA_DEFAULT", CACA_DEFAULT, CONST_CS | CONST_PERSISTENT);
  204. REGISTER_LONG_CONSTANT("CACA_TRANSPARENT", CACA_TRANSPARENT, CONST_CS | CONST_PERSISTENT);
  205. REGISTER_LONG_CONSTANT("CACA_BOLD", CACA_BOLD, CONST_CS | CONST_PERSISTENT);
  206. REGISTER_LONG_CONSTANT("CACA_ITALICS", CACA_ITALICS, CONST_CS | CONST_PERSISTENT);
  207. REGISTER_LONG_CONSTANT("CACA_UNDERLINE", CACA_UNDERLINE, CONST_CS | CONST_PERSISTENT);
  208. REGISTER_LONG_CONSTANT("CACA_BLINK", CACA_BLINK, CONST_CS | CONST_PERSISTENT);
  209. REGISTER_LONG_CONSTANT("CACA_EVENT_NONE", CACA_EVENT_NONE, CONST_CS | CONST_PERSISTENT);
  210. REGISTER_LONG_CONSTANT("CACA_EVENT_KEY_PRESS", CACA_EVENT_KEY_PRESS, CONST_CS | CONST_PERSISTENT);
  211. REGISTER_LONG_CONSTANT("CACA_EVENT_KEY_RELEASE", CACA_EVENT_KEY_RELEASE, CONST_CS | CONST_PERSISTENT);
  212. REGISTER_LONG_CONSTANT("CACA_EVENT_MOUSE_PRESS", CACA_EVENT_MOUSE_PRESS, CONST_CS | CONST_PERSISTENT);
  213. REGISTER_LONG_CONSTANT("CACA_EVENT_MOUSE_RELEASE", CACA_EVENT_MOUSE_RELEASE, CONST_CS | CONST_PERSISTENT);
  214. REGISTER_LONG_CONSTANT("CACA_EVENT_MOUSE_MOTION", CACA_EVENT_MOUSE_MOTION, CONST_CS | CONST_PERSISTENT);
  215. REGISTER_LONG_CONSTANT("CACA_EVENT_RESIZE", CACA_EVENT_RESIZE, CONST_CS | CONST_PERSISTENT);
  216. REGISTER_LONG_CONSTANT("CACA_EVENT_QUIT", CACA_EVENT_QUIT, CONST_CS | CONST_PERSISTENT);
  217. REGISTER_LONG_CONSTANT("CACA_EVENT_ANY", CACA_EVENT_ANY, CONST_CS | CONST_PERSISTENT);
  218. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_A", CACA_KEY_CTRL_A, CONST_CS | CONST_PERSISTENT);
  219. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_B", CACA_KEY_CTRL_B, CONST_CS | CONST_PERSISTENT);
  220. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_C", CACA_KEY_CTRL_C, CONST_CS | CONST_PERSISTENT);
  221. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_D", CACA_KEY_CTRL_D, CONST_CS | CONST_PERSISTENT);
  222. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_E", CACA_KEY_CTRL_E, CONST_CS | CONST_PERSISTENT);
  223. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_F", CACA_KEY_CTRL_F, CONST_CS | CONST_PERSISTENT);
  224. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_G", CACA_KEY_CTRL_G, CONST_CS | CONST_PERSISTENT);
  225. REGISTER_LONG_CONSTANT("CACA_KEY_BACKSPACE", CACA_KEY_BACKSPACE, CONST_CS | CONST_PERSISTENT);
  226. REGISTER_LONG_CONSTANT("CACA_KEY_TAB", CACA_KEY_TAB, CONST_CS | CONST_PERSISTENT);
  227. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_J", CACA_KEY_CTRL_J, CONST_CS | CONST_PERSISTENT);
  228. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_K", CACA_KEY_CTRL_K, CONST_CS | CONST_PERSISTENT);
  229. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_L", CACA_KEY_CTRL_L, CONST_CS | CONST_PERSISTENT);
  230. REGISTER_LONG_CONSTANT("CACA_KEY_RETURN", CACA_KEY_RETURN, CONST_CS | CONST_PERSISTENT);
  231. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_N", CACA_KEY_CTRL_N, CONST_CS | CONST_PERSISTENT);
  232. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_O", CACA_KEY_CTRL_O, CONST_CS | CONST_PERSISTENT);
  233. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_P", CACA_KEY_CTRL_P, CONST_CS | CONST_PERSISTENT);
  234. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_Q", CACA_KEY_CTRL_Q, CONST_CS | CONST_PERSISTENT);
  235. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_R", CACA_KEY_CTRL_R, CONST_CS | CONST_PERSISTENT);
  236. REGISTER_LONG_CONSTANT("CACA_KEY_PAUSE", CACA_KEY_PAUSE, CONST_CS | CONST_PERSISTENT);
  237. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_T", CACA_KEY_CTRL_T, CONST_CS | CONST_PERSISTENT);
  238. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_U", CACA_KEY_CTRL_U, CONST_CS | CONST_PERSISTENT);
  239. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_V", CACA_KEY_CTRL_V, CONST_CS | CONST_PERSISTENT);
  240. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_W", CACA_KEY_CTRL_W, CONST_CS | CONST_PERSISTENT);
  241. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_X", CACA_KEY_CTRL_X, CONST_CS | CONST_PERSISTENT);
  242. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_Y", CACA_KEY_CTRL_Y, CONST_CS | CONST_PERSISTENT);
  243. REGISTER_LONG_CONSTANT("CACA_KEY_CTRL_Z", CACA_KEY_CTRL_Z, CONST_CS | CONST_PERSISTENT);
  244. REGISTER_LONG_CONSTANT("CACA_KEY_ESCAPE", CACA_KEY_ESCAPE, CONST_CS | CONST_PERSISTENT);
  245. REGISTER_LONG_CONSTANT("CACA_KEY_DELETE", CACA_KEY_DELETE, CONST_CS | CONST_PERSISTENT);
  246. REGISTER_LONG_CONSTANT("CACA_KEY_UP", CACA_KEY_UP, CONST_CS | CONST_PERSISTENT);
  247. REGISTER_LONG_CONSTANT("CACA_KEY_DOWN", CACA_KEY_DOWN, CONST_CS | CONST_PERSISTENT);
  248. REGISTER_LONG_CONSTANT("CACA_KEY_LEFT", CACA_KEY_LEFT, CONST_CS | CONST_PERSISTENT);
  249. REGISTER_LONG_CONSTANT("CACA_KEY_RIGHT", CACA_KEY_RIGHT, CONST_CS | CONST_PERSISTENT);
  250. REGISTER_LONG_CONSTANT("CACA_KEY_INSERT", CACA_KEY_INSERT, CONST_CS | CONST_PERSISTENT);
  251. REGISTER_LONG_CONSTANT("CACA_KEY_HOME", CACA_KEY_HOME, CONST_CS | CONST_PERSISTENT);
  252. REGISTER_LONG_CONSTANT("CACA_KEY_END", CACA_KEY_END, CONST_CS | CONST_PERSISTENT);
  253. REGISTER_LONG_CONSTANT("CACA_KEY_PAGEUP", CACA_KEY_PAGEUP, CONST_CS | CONST_PERSISTENT);
  254. REGISTER_LONG_CONSTANT("CACA_KEY_PAGEDOWN", CACA_KEY_PAGEDOWN, CONST_CS | CONST_PERSISTENT);
  255. REGISTER_LONG_CONSTANT("CACA_KEY_F1", CACA_KEY_F1, CONST_CS | CONST_PERSISTENT);
  256. REGISTER_LONG_CONSTANT("CACA_KEY_F2", CACA_KEY_F2, CONST_CS | CONST_PERSISTENT);
  257. REGISTER_LONG_CONSTANT("CACA_KEY_F3", CACA_KEY_F3, CONST_CS | CONST_PERSISTENT);
  258. REGISTER_LONG_CONSTANT("CACA_KEY_F4", CACA_KEY_F4, CONST_CS | CONST_PERSISTENT);
  259. REGISTER_LONG_CONSTANT("CACA_KEY_F5", CACA_KEY_F5, CONST_CS | CONST_PERSISTENT);
  260. REGISTER_LONG_CONSTANT("CACA_KEY_F6", CACA_KEY_F6, CONST_CS | CONST_PERSISTENT);
  261. REGISTER_LONG_CONSTANT("CACA_KEY_F7", CACA_KEY_F7, CONST_CS | CONST_PERSISTENT);
  262. REGISTER_LONG_CONSTANT("CACA_KEY_F8", CACA_KEY_F8, CONST_CS | CONST_PERSISTENT);
  263. REGISTER_LONG_CONSTANT("CACA_KEY_F9", CACA_KEY_F9, CONST_CS | CONST_PERSISTENT);
  264. REGISTER_LONG_CONSTANT("CACA_KEY_F10", CACA_KEY_F10, CONST_CS | CONST_PERSISTENT);
  265. REGISTER_LONG_CONSTANT("CACA_KEY_F11", CACA_KEY_F11, CONST_CS | CONST_PERSISTENT);
  266. REGISTER_LONG_CONSTANT("CACA_KEY_F12", CACA_KEY_F12, CONST_CS | CONST_PERSISTENT);
  267. REGISTER_LONG_CONSTANT("CACA_KEY_F13", CACA_KEY_F13, CONST_CS | CONST_PERSISTENT);
  268. REGISTER_LONG_CONSTANT("CACA_KEY_F14", CACA_KEY_F14, CONST_CS | CONST_PERSISTENT);
  269. REGISTER_LONG_CONSTANT("CACA_KEY_F15", CACA_KEY_F15, CONST_CS | CONST_PERSISTENT);
  270. return SUCCESS;
  271. }
  272. //----------SOME USEFULL MACROS---------------//
  273. #define FETCH_CANVAS(canvas) \
  274. zval *_zval; \
  275. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) { \
  276. RETURN_FALSE; \
  277. } \
  278. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  279. #define FETCH_DISPLAY(display) \
  280. zval *_zval; \
  281. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) { \
  282. RETURN_FALSE; \
  283. } \
  284. ZEND_FETCH_RESOURCE(display, caca_display_t*, &_zval, -1, PHP_CACA_DISPLAY_RES_NAME, le_caca_display);
  285. #define FETCH_EVENT(event) \
  286. zval *_zval; \
  287. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) { \
  288. RETURN_FALSE; \
  289. } \
  290. ZEND_FETCH_RESOURCE(event, caca_event_t*, &_zval, -1, PHP_CACA_EVENT_RES_NAME, le_caca_event);
  291. #define RETURN_CHAR(c) \
  292. char *str = emalloc(2); \
  293. str[0] = c; \
  294. str[1] = '\0'; \
  295. RETURN_STRING(str, 0);
  296. //-------CACA'S FUNCTIONS----------------//
  297. PHP_FUNCTION(caca_create_canvas) {
  298. long width, height = 0;
  299. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
  300. RETURN_FALSE;
  301. }
  302. caca_canvas_t *canvas = caca_create_canvas(width, height);
  303. if (!canvas) {
  304. RETURN_FALSE;
  305. }
  306. ZEND_REGISTER_RESOURCE(return_value, canvas, le_caca_canvas);
  307. }
  308. PHP_FUNCTION(caca_manage_canvas) {
  309. }
  310. PHP_FUNCTION(caca_unmanage_canvas) {
  311. }
  312. PHP_FUNCTION(caca_set_canvas_size) {
  313. zval *_zval;
  314. long width, height = 0;
  315. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &width, &height) == FAILURE) {
  316. RETURN_FALSE;
  317. }
  318. caca_canvas_t *canvas;
  319. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  320. RETURN_BOOL(caca_set_canvas_size(canvas, width, height) == 0);
  321. }
  322. PHP_FUNCTION(caca_get_canvas_width) {
  323. caca_canvas_t *canvas;
  324. FETCH_CANVAS(canvas);
  325. RETURN_LONG(caca_get_canvas_width(canvas));
  326. }
  327. PHP_FUNCTION(caca_get_canvas_height) {
  328. caca_canvas_t *canvas;
  329. FETCH_CANVAS(canvas);
  330. RETURN_LONG(caca_get_canvas_height(canvas));
  331. }
  332. PHP_FUNCTION(caca_get_canvas_chars) {
  333. caca_canvas_t *canvas;
  334. FETCH_CANVAS(canvas);
  335. RETURN_STRING(estrdup(caca_get_canvas_chars(canvas)), 0); //TODO: check that return \0 terminated string
  336. }
  337. PHP_FUNCTION(caca_get_canvas_attrs) {
  338. caca_canvas_t *canvas;
  339. FETCH_CANVAS(canvas);
  340. RETURN_STRING(estrdup(caca_get_canvas_attrs(canvas)), 0); //TODO: check that return \0 terminated string
  341. }
  342. PHP_FUNCTION(caca_rand) {
  343. long min, max = 0;
  344. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &min, &max) == FAILURE) {
  345. RETURN_FALSE;
  346. }
  347. RETURN_LONG(caca_rand(min, max));
  348. }
  349. PHP_FUNCTION(caca_get_version) {
  350. RETURN_STRING(estrdup(caca_get_version()), 0);
  351. }
  352. PHP_FUNCTION(caca_gotoxy) {
  353. zval *_zval;
  354. long x, y = 0;
  355. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &x, &y) == FAILURE) {
  356. RETURN_FALSE;
  357. }
  358. caca_canvas_t *canvas;
  359. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  360. RETURN_BOOL(caca_gotoxy(canvas, x, y) == 0);
  361. }
  362. PHP_FUNCTION(caca_get_cursor_x) {
  363. caca_canvas_t *canvas;
  364. FETCH_CANVAS(canvas);
  365. RETURN_LONG(caca_get_cursor_x(canvas));
  366. }
  367. PHP_FUNCTION(caca_get_cursor_y) {
  368. caca_canvas_t *canvas;
  369. FETCH_CANVAS(canvas);
  370. RETURN_LONG(caca_get_cursor_y(canvas));
  371. }
  372. PHP_FUNCTION(caca_put_char) {
  373. zval *_zval;
  374. long x, y, c = 0;
  375. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &_zval, &x, &y, &c) == FAILURE) {
  376. RETURN_FALSE;
  377. }
  378. caca_canvas_t *canvas;
  379. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  380. RETURN_BOOL(caca_put_char(canvas, x, y, c) == 0);
  381. }
  382. PHP_FUNCTION(caca_get_char) {
  383. zval *_zval;
  384. long x, y = 0;
  385. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &x, &y) == FAILURE) {
  386. RETURN_FALSE;
  387. }
  388. caca_canvas_t *canvas;
  389. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  390. RETURN_CHAR(caca_get_char(canvas, x, y));
  391. }
  392. PHP_FUNCTION(caca_put_str) {
  393. zval *_zval;
  394. char *str;
  395. long x, y, str_len = 0;
  396. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlls", &_zval, &x, &y, &str, &str_len) == FAILURE) {
  397. RETURN_FALSE;
  398. }
  399. caca_canvas_t *canvas;
  400. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  401. RETURN_BOOL(caca_put_str(canvas, x, y, str) == 0);
  402. }
  403. PHP_FUNCTION(caca_printf) {
  404. }
  405. PHP_FUNCTION(caca_clear_canvas) {
  406. caca_canvas_t *canvas;
  407. FETCH_CANVAS(canvas);
  408. RETURN_LONG(caca_clear_canvas(canvas));
  409. }
  410. PHP_FUNCTION(caca_set_canvas_handle) {
  411. zval *_zval;
  412. long x, y = 0;
  413. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &x, &y) == FAILURE) {
  414. RETURN_FALSE;
  415. }
  416. caca_canvas_t *canvas;
  417. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  418. RETURN_BOOL(caca_set_canvas_handle(canvas, x, y) == 0);
  419. }
  420. PHP_FUNCTION(caca_get_canvas_handle_x) {
  421. caca_canvas_t *canvas;
  422. FETCH_CANVAS(canvas);
  423. RETURN_LONG(caca_get_canvas_handle_x(canvas));
  424. }
  425. PHP_FUNCTION(caca_get_canvas_handle_y) {
  426. caca_canvas_t *canvas;
  427. FETCH_CANVAS(canvas);
  428. RETURN_LONG(caca_get_canvas_handle_y(canvas));
  429. }
  430. PHP_FUNCTION(caca_blit) {
  431. zval *_zval1, *_zval2, *_zval3 = NULL;
  432. long x, y = 0;
  433. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllr|r", &_zval1, &x, &y, &_zval2, &_zval3) == FAILURE) {
  434. RETURN_FALSE;
  435. }
  436. caca_canvas_t *dst, *src, *mask = NULL;
  437. ZEND_FETCH_RESOURCE(dst, caca_canvas_t*, &_zval1, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  438. ZEND_FETCH_RESOURCE(src, caca_canvas_t*, &_zval2, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  439. if (_zval3) {
  440. ZEND_FETCH_RESOURCE(mask, caca_canvas_t*, &_zval3, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  441. }
  442. RETURN_BOOL(caca_blit(dst, x, y, src, NULL) == 0);
  443. }
  444. PHP_FUNCTION(caca_set_canvas_boundaries) {
  445. zval *_zval;
  446. long x, y, width, height = 0;
  447. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &_zval, &x, &y, &width, &height) == FAILURE) {
  448. RETURN_FALSE;
  449. }
  450. caca_canvas_t *canvas;
  451. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  452. RETURN_BOOL(caca_set_canvas_boundaries(canvas, x, y, width, height) == 0);
  453. }
  454. PHP_FUNCTION(caca_invert) {
  455. caca_canvas_t *canvas;
  456. FETCH_CANVAS(canvas);
  457. RETURN_BOOL(caca_invert(canvas) == 0);
  458. }
  459. PHP_FUNCTION(caca_flip) {
  460. caca_canvas_t *canvas;
  461. FETCH_CANVAS(canvas);
  462. RETURN_BOOL(caca_flip(canvas) == 0);
  463. }
  464. PHP_FUNCTION(caca_flop) {
  465. caca_canvas_t *canvas;
  466. FETCH_CANVAS(canvas);
  467. RETURN_BOOL(caca_flop(canvas) == 0);
  468. }
  469. PHP_FUNCTION(caca_rotate_180) {
  470. caca_canvas_t *canvas;
  471. FETCH_CANVAS(canvas);
  472. RETURN_BOOL(caca_rotate_180(canvas) == 0);
  473. }
  474. PHP_FUNCTION(caca_rotate_left) {
  475. caca_canvas_t *canvas;
  476. FETCH_CANVAS(canvas);
  477. RETURN_BOOL(caca_rotate_left(canvas) == 0);
  478. }
  479. PHP_FUNCTION(caca_rotate_right) {
  480. caca_canvas_t *canvas;
  481. FETCH_CANVAS(canvas);
  482. RETURN_BOOL(caca_rotate_right(canvas) == 0);
  483. }
  484. PHP_FUNCTION(caca_stretch_left) {
  485. caca_canvas_t *canvas;
  486. FETCH_CANVAS(canvas);
  487. RETURN_BOOL(caca_stretch_left(canvas) == 0);
  488. }
  489. PHP_FUNCTION(caca_stretch_right) {
  490. caca_canvas_t *canvas;
  491. FETCH_CANVAS(canvas);
  492. RETURN_BOOL(caca_stretch_right(canvas) == 0);
  493. }
  494. PHP_FUNCTION(caca_get_attr) {
  495. }
  496. PHP_FUNCTION(caca_set_attr) {
  497. }
  498. PHP_FUNCTION(caca_put_attr) {
  499. }
  500. PHP_FUNCTION(caca_set_color_ansi) {
  501. zval *_zval;
  502. long foreground, background = 0;
  503. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &foreground, &background) == FAILURE) {
  504. RETURN_FALSE;
  505. }
  506. caca_canvas_t *canvas;
  507. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  508. RETURN_BOOL(caca_set_color_ansi(canvas, foreground, background) == 0);
  509. }
  510. PHP_FUNCTION(caca_set_color_argb) {
  511. }
  512. PHP_FUNCTION(caca_attr_to_ansi) {
  513. }
  514. PHP_FUNCTION(caca_attr_to_ansi_fg) {
  515. }
  516. PHP_FUNCTION(caca_attr_to_ansi_bg) {
  517. }
  518. PHP_FUNCTION(caca_draw_line) {
  519. zval *_zval;
  520. char *str;
  521. long str_len, xa, ya, xb, yb = 0;
  522. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllls", &_zval, &xa, &ya, &xb, &yb, &str, &str_len) == FAILURE) {
  523. RETURN_FALSE;
  524. }
  525. caca_canvas_t *canvas;
  526. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  527. if (str_len != 1) {
  528. RETURN_FALSE;
  529. }
  530. RETURN_BOOL(caca_draw_line(canvas, xa, ya, xb, yb, str[0]) == 0);
  531. }
  532. PHP_FUNCTION(caca_draw_polyline) {
  533. }
  534. PHP_FUNCTION(caca_draw_thin_line) {
  535. zval *_zval;
  536. long xa, ya, xb, yb = 0;
  537. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &_zval, &xa, &ya, &xb, &yb) == FAILURE) {
  538. RETURN_FALSE;
  539. }
  540. caca_canvas_t *canvas;
  541. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  542. RETURN_BOOL(caca_draw_thin_line(canvas, xa, ya, xb, yb) == 0);
  543. }
  544. PHP_FUNCTION(caca_draw_thin_polyline) {
  545. }
  546. PHP_FUNCTION(caca_draw_circle) {
  547. }
  548. PHP_FUNCTION(caca_draw_ellipse) {
  549. }
  550. PHP_FUNCTION(caca_draw_thin_ellipse) {
  551. }
  552. PHP_FUNCTION(caca_fill_ellipse) {
  553. }
  554. PHP_FUNCTION(caca_draw_box) {
  555. }
  556. PHP_FUNCTION(caca_draw_thin_box) {
  557. }
  558. PHP_FUNCTION(caca_fill_box) {
  559. }
  560. PHP_FUNCTION(caca_draw_triangle) {
  561. }
  562. PHP_FUNCTION(caca_draw_thin_triangle) {
  563. }
  564. PHP_FUNCTION(caca_fill_triangle) {
  565. }
  566. PHP_FUNCTION(caca_get_frame_count) {
  567. }
  568. PHP_FUNCTION(caca_set_frame) {
  569. }
  570. PHP_FUNCTION(caca_set_frame_name) {
  571. }
  572. PHP_FUNCTION(caca_create_frame) {
  573. }
  574. PHP_FUNCTION(caca_free_frame) {
  575. }
  576. PHP_FUNCTION(caca_set_dither_palette) {
  577. }
  578. PHP_FUNCTION(caca_set_dither_brightness) {
  579. }
  580. PHP_FUNCTION(caca_get_dither_brightness) {
  581. }
  582. PHP_FUNCTION(caca_set_dither_gamma) {
  583. }
  584. PHP_FUNCTION(caca_get_dither_gamma) {
  585. }
  586. PHP_FUNCTION(caca_set_dither_contrast) {
  587. }
  588. PHP_FUNCTION(caca_get_dither_contrast) {
  589. }
  590. PHP_FUNCTION(caca_set_dither_antialias) {
  591. }
  592. PHP_FUNCTION(caca_get_dither_antialias_list) {
  593. }
  594. PHP_FUNCTION(caca_get_dither_antialias) {
  595. }
  596. PHP_FUNCTION(caca_set_dither_color) {
  597. }
  598. PHP_FUNCTION(caca_get_dither_color_list) {
  599. }
  600. PHP_FUNCTION(caca_get_dither_color) {
  601. }
  602. PHP_FUNCTION(caca_set_dither_charset) {
  603. }
  604. PHP_FUNCTION(caca_get_dither_charset_list) {
  605. }
  606. PHP_FUNCTION(caca_get_dither_charset) {
  607. }
  608. PHP_FUNCTION(caca_set_dither_algorithm) {
  609. }
  610. PHP_FUNCTION(caca_get_dither_algorithm_list) {
  611. }
  612. PHP_FUNCTION(caca_get_dither_algorithm) {
  613. }
  614. PHP_FUNCTION(caca_dither_bitmap) {
  615. }
  616. PHP_FUNCTION(caca_get_font_list) {
  617. }
  618. PHP_FUNCTION(caca_get_font_width) {
  619. }
  620. PHP_FUNCTION(caca_get_font_height) {
  621. }
  622. PHP_FUNCTION(caca_render_canvas) {
  623. }
  624. PHP_FUNCTION(caca_canvas_set_figfont) {
  625. }
  626. PHP_FUNCTION(caca_put_figchar) {
  627. }
  628. PHP_FUNCTION(caca_flush_figlet) {
  629. }
  630. PHP_FUNCTION(caca_file_close) {
  631. }
  632. PHP_FUNCTION(caca_file_tell) {
  633. }
  634. PHP_FUNCTION(caca_file_read) {
  635. }
  636. PHP_FUNCTION(caca_file_write) {
  637. }
  638. PHP_FUNCTION(caca_file_gets) {
  639. }
  640. PHP_FUNCTION(caca_file_eof) {
  641. }
  642. PHP_FUNCTION(caca_import_memory) {
  643. zval *_zval;
  644. char *src, *type;
  645. long src_len, type_len = 0;
  646. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &_zval, &src, &src_len, &type, &type_len) == FAILURE) {
  647. RETURN_FALSE;
  648. }
  649. caca_canvas_t *canvas;
  650. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  651. RETURN_LONG(caca_import_memory(canvas, src, src_len, type));
  652. }
  653. PHP_FUNCTION(caca_import_file) {
  654. }
  655. PHP_FUNCTION(caca_get_import_list) {
  656. }
  657. PHP_FUNCTION(caca_get_export_list) {
  658. }
  659. PHP_FUNCTION(caca_create_display) {
  660. caca_canvas_t *canvas;
  661. FETCH_CANVAS(canvas);
  662. caca_display_t *display = caca_create_display(canvas);
  663. ZEND_REGISTER_RESOURCE(return_value, display, le_caca_display);
  664. }
  665. PHP_FUNCTION(caca_create_display_with_driver) {
  666. zval *_zval;
  667. char *str;
  668. long str_len = 0;
  669. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &_zval, &str, &str_len) == FAILURE) {
  670. RETURN_FALSE;
  671. }
  672. caca_canvas_t *canvas;
  673. ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
  674. caca_display_t *display = caca_create_display_with_driver(canvas, str);
  675. if (!display) {
  676. RETURN_FALSE;
  677. }
  678. ZEND_REGISTER_RESOURCE(return_value, display, le_caca_display);
  679. }
  680. PHP_FUNCTION(caca_get_display_driver_list) {
  681. }
  682. PHP_FUNCTION(caca_get_display_driver) {
  683. }
  684. PHP_FUNCTION(caca_set_display_driver) {
  685. }
  686. PHP_FUNCTION(caca_get_canvas) {
  687. }
  688. PHP_FUNCTION(caca_refresh_display) {
  689. caca_display_t *display;
  690. FETCH_DISPLAY(display);
  691. RETURN_BOOL(caca_refresh_display(display) == 0);
  692. }
  693. PHP_FUNCTION(caca_set_display_time) {
  694. zval *_zval;
  695. long value = 0;
  696. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &value) == FAILURE) {
  697. RETURN_FALSE;
  698. }
  699. caca_display_t *display;
  700. ZEND_FETCH_RESOURCE(display, caca_display_t*, &_zval, -1, PHP_CACA_DISPLAY_RES_NAME, le_caca_display);
  701. RETURN_BOOL(caca_set_display_time(display, value) == 0);
  702. }
  703. PHP_FUNCTION(caca_get_display_time) {
  704. caca_display_t *display;
  705. FETCH_DISPLAY(display);
  706. RETURN_LONG(caca_get_display_time(display)); //TODO: check return value
  707. }
  708. PHP_FUNCTION(caca_get_display_width) {
  709. caca_display_t *display;
  710. FETCH_DISPLAY(display);
  711. RETURN_LONG(caca_get_display_width(display));
  712. }
  713. PHP_FUNCTION(caca_get_display_height) {
  714. caca_display_t *display;
  715. FETCH_DISPLAY(display);
  716. RETURN_LONG(caca_get_display_height(display));
  717. }
  718. PHP_FUNCTION(caca_set_display_title) {
  719. zval *_zval;
  720. char *str;
  721. long str_len = 0;
  722. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &_zval, &str, &str_len) == FAILURE) {
  723. RETURN_FALSE;
  724. }
  725. caca_display_t *display;
  726. ZEND_FETCH_RESOURCE(display, caca_display_t*, &_zval, -1, PHP_CACA_DISPLAY_RES_NAME, le_caca_display);
  727. RETURN_BOOL(caca_set_display(display, str) == 0);
  728. }
  729. PHP_FUNCTION(caca_set_mouse) {
  730. zval *_zval;
  731. long value = 0;
  732. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &value) == FAILURE) {
  733. RETURN_FALSE;
  734. }
  735. caca_display_t *display;
  736. ZEND_FETCH_RESOURCE(display, caca_display_t*, &_zval, -1, PHP_CACA_DISPLAY_RES_NAME, le_caca_display);
  737. RETURN_BOOL(caca_set_mouse(display, value) == 0);
  738. }
  739. PHP_FUNCTION(caca_set_cursor) {
  740. zval *_zval;
  741. long value = 0;
  742. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &value) == FAILURE) {
  743. RETURN_FALSE;
  744. }
  745. caca_display_t *display;
  746. ZEND_FETCH_RESOURCE(display, caca_display_t*, &_zval, -1, PHP_CACA_DISPLAY_RES_NAME, le_caca_display);
  747. RETURN_BOOL(caca_set_cursor(display, value) == 0);
  748. }
  749. PHP_FUNCTION(caca_get_event) {
  750. zval *_zval1, *_zval2 = NULL;
  751. long g, aa = 0;
  752. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|rl", &_zval1, &g, &_zval2, &aa) == FAILURE) {
  753. RETURN_FALSE;
  754. }
  755. caca_display_t *display;
  756. ZEND_FETCH_RESOURCE(display, caca_display_t*, &_zval1, -1, PHP_CACA_DISPLAY_RES_NAME, le_caca_display);
  757. caca_event_t *event = NULL;
  758. if (_zval2) {
  759. ZEND_FETCH_RESOURCE(event, caca_event_t*, &_zval2, -1, PHP_CACA_EVENT_RES_NAME, le_caca_event);
  760. }
  761. RETURN_BOOL(caca_get_event(display, g, event, aa) == 0);
  762. }
  763. PHP_FUNCTION(caca_get_mouse_x) {
  764. caca_display_t *display;
  765. FETCH_DISPLAY(display);
  766. RETURN_LONG(caca_get_mouse_x(display));
  767. }
  768. PHP_FUNCTION(caca_get_mouse_y) {
  769. caca_display_t *display;
  770. FETCH_DISPLAY(display);
  771. RETURN_LONG(caca_get_mouse_y(display));
  772. }
  773. PHP_FUNCTION(caca_get_event_type) {
  774. }
  775. PHP_FUNCTION(caca_get_event_key_ch) {
  776. }
  777. PHP_FUNCTION(caca_get_event_mouse_button) {
  778. caca_event_t *event;
  779. FETCH_EVENT(event);
  780. RETURN_LONG(caca_get_event_mouse_button(event));
  781. }
  782. PHP_FUNCTION(caca_get_event_mouse_x) {
  783. caca_event_t *event;
  784. FETCH_EVENT(event);
  785. RETURN_LONG(caca_get_event_mouse_x(event));
  786. }
  787. PHP_FUNCTION(caca_get_event_mouse_y) {
  788. caca_event_t *event;
  789. FETCH_EVENT(event);
  790. RETURN_LONG(caca_get_event_mouse_y(event));
  791. }
  792. PHP_FUNCTION(caca_get_event_resize_width) {
  793. caca_event_t *event;
  794. FETCH_EVENT(event);
  795. RETURN_LONG(caca_get_event_resize_width(event));
  796. }
  797. PHP_FUNCTION(caca_get_event_resize_height) {
  798. caca_event_t *event;
  799. FETCH_EVENT(event);
  800. RETURN_LONG(caca_get_event_resize_height(event));
  801. }