svn: /pecl/rrd/trunk/ rrd.c tests/rrd_016.phpt

From: Date: Sun, 15 Aug 2010 21:59:40 +0000
Subject: svn: /pecl/rrd/trunk/ rrd.c tests/rrd_016.phpt
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-14599@lists.php.net to get a copy of this message
koubel Sun, 15 Aug 2010 21:59:40 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=302278 Log: rrd_tune implemented, test also Changed paths: U pecl/rrd/trunk/rrd.c A pecl/rrd/trunk/tests/rrd_016.phpt Modified: pecl/rrd/trunk/rrd.c =================================================================== --- pecl/rrd/trunk/rrd.c 2010-08-15 18:10:06 UTC (rev 302277) +++ pecl/rrd/trunk/rrd.c 2010-08-15 21:59:40 UTC (rev 302278) @@ -409,6 +409,45 @@ } /* }}} */ +/* {{{ proto int rrd_tune(string file, array options) + Tune an RRD file with the options passed (passed via array) */ +PHP_FUNCTION(rrd_tune) +{ + char *filename; + int filename_length; + zval *zv_arr_options; + rrd_args *argv; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa", &filename, + &filename_length, &zv_arr_options) == FAILURE) { + return; + } + + if (!zend_hash_num_elements(Z_ARRVAL_P(zv_arr_options))) { + zend_error(E_WARNING, "options array mustn't be empty"); + RETURN_FALSE; + } + + if (php_check_open_basedir(filename TSRMLS_CC)) RETURN_FALSE; + + argv = rrd_args_init_by_phparray("tune", filename, zv_arr_options TSRMLS_CC); + if (!argv) { + zend_error(E_WARNING, "cannot allocate arguments options"); + RETURN_FALSE; + } + + if (rrd_test_error()) rrd_clear_error(); + + /* call rrd_tune and test if fails */ + if (rrd_tune(argv->count-1, &argv->args[1]) == -1 ) { + RETVAL_FALSE; + } else { + RETVAL_TRUE; + } + rrd_args_free(argv); +} +/* }}} */ + /* {{{ arguments */ ZEND_BEGIN_ARG_INFO(arginfo_rrd_fetch, 0) ZEND_ARG_INFO(0, file) @@ -438,6 +477,10 @@ ZEND_ARG_INFO(0, options) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_rrd_tune, 0) + ZEND_ARG_INFO(0, file) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ */ @@ -452,6 +495,7 @@ PHP_FE(rrd_last, arginfo_rrd_last) PHP_FE(rrd_lastupdate, arginfo_rrd_lastupdate) PHP_FE(rrd_restore, arginfo_rrd_restore) + PHP_FE(rrd_tune, arginfo_rrd_tune) {NULL, NULL, NULL} }; /* }}} */ Added: pecl/rrd/trunk/tests/rrd_016.phpt =================================================================== --- pecl/rrd/trunk/tests/rrd_016.phpt (rev 0) +++ pecl/rrd/trunk/tests/rrd_016.phpt 2010-08-15 21:59:40 UTC (rev 302278) @@ -0,0 +1,18 @@ +--TEST-- +rrd_tune test +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +$destFile = dirname(__FILE__) . "/tune-test.rrd"; +copy(dirname(__FILE__) . "/testData/speed.rrd", $destFile); +var_dump(rrd_tune($destFile, array("--data-source-rename=speed:new-speed"))); +var_dump(rrd_tune($destFile, array("--lala"))); +//maybe bug in rrd_tune? +var_dump(rrd_tune($destFile, array("true"))); +?> +--EXPECTF-- +bool(true) +bool(false) +bool(true) +DS[new-speed] typ: COUNTER hbt: 600 min: nan max: nan Property changes on: pecl/rrd/trunk/tests/rrd_016.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native

« previous php.pecl.cvs (#14599) next »