Browse Source

* Add php binding for functions: caca_file_write, caca_file_read

tags/v0.99.beta17
Nicolas Vion nico 16 years ago
parent
commit
77ff19864f
3 changed files with 35 additions and 0 deletions
  1. +2
    -0
      caca-php/examples/demo.php
  2. +31
    -0
      caca-php/php_caca.c
  3. +2
    -0
      caca-php/php_caca.h

+ 2
- 0
caca-php/examples/demo.php View File

@@ -361,6 +361,8 @@ function demo_triangles($cv, $bounds, $outline, $dithering) {
caca_draw_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, '#');
}

function demo_render($cv, $bounds, $outline, $dithering) {
}


main();

+ 31
- 0
caca-php/php_caca.c View File

@@ -107,9 +107,11 @@ static function_entry caca_functions[] = {
PHP_FE(caca_get_dither_algorithm_list, NULL)
PHP_FE(caca_get_dither_algorithm, NULL)
PHP_FE(caca_dither_bitmap_gd, NULL)
PHP_FE(caca_load_font, NULL)
PHP_FE(caca_get_font_list, NULL)
PHP_FE(caca_get_font_width, NULL)
PHP_FE(caca_get_font_height, NULL)
PHP_FE(caca_get_font_bloc, NULL)
PHP_FE(caca_render_canvas, NULL)
PHP_FE(caca_canvas_set_figfont, NULL)
PHP_FE(caca_put_figchar, NULL)
@@ -1198,6 +1200,9 @@ PHP_FUNCTION(caca_dither_bitmap_gd) {
RETURN_TRUE;
}

PHP_FUNCTION(caca_load_font) {
}

PHP_FUNCTION(caca_get_font_list) {
char const * const *list = caca_get_font_list();
int i;
@@ -1226,6 +1231,9 @@ PHP_FUNCTION(caca_get_font_height) {
RETURN_LONG(caca_get_font_height(font));
}

PHP_FUNCTION(caca_get_font_bloc) {
}

PHP_FUNCTION(caca_render_canvas) {
}

@@ -1286,9 +1294,32 @@ PHP_FUNCTION(caca_file_tell) {
}

PHP_FUNCTION(caca_file_read) {
zval *_zval;
long len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &len) == FAILURE) {
RETURN_FALSE;
}
caca_file_t *file;
ZEND_FETCH_RESOURCE(file, caca_file_t*, &_zval, -1, PHP_CACA_FILE_RES_NAME, le_caca_file);

char *buffer = emalloc(len);
caca_file_read(file, buffer, len);

return_value->type = IS_STRING;
return_value->value.str.len = len;
return_value->value.str.val = buffer;
}

PHP_FUNCTION(caca_file_write) {
zval *_zval;
char *buf;
long buf_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &_zval, &buf, &buf_len) == FAILURE) {
RETURN_FALSE;
}
caca_file_t *file;
ZEND_FETCH_RESOURCE(file, caca_file_t*, &_zval, -1, PHP_CACA_FILE_RES_NAME, le_caca_file);
RETURN_LONG(caca_file_write(file, buf, buf_len));
}

PHP_FUNCTION(caca_file_gets) {


+ 2
- 0
caca-php/php_caca.h View File

@@ -124,9 +124,11 @@ PHP_FUNCTION(caca_set_dither_algorithm);
PHP_FUNCTION(caca_get_dither_algorithm_list);
PHP_FUNCTION(caca_get_dither_algorithm);
PHP_FUNCTION(caca_dither_bitmap_gd);
PHP_FUNCTION(caca_load_font);
PHP_FUNCTION(caca_get_font_list);
PHP_FUNCTION(caca_get_font_width);
PHP_FUNCTION(caca_get_font_height);
PHP_FUNCTION(caca_get_font_bloc);
PHP_FUNCTION(caca_render_canvas);
PHP_FUNCTION(caca_canvas_set_figfont);
PHP_FUNCTION(caca_put_figchar);


Loading…
Cancel
Save