Ticket #253: lastupdate-php_rrdtool.diff

File lastupdate-php_rrdtool.diff, 3.3 KB (added by human, 2 years ago)

Patch file against original php-rrdtool module

  • php_rrdtool.h

    diff -Naur rrdtool.ori/php_rrdtool.h rrdtool/php_rrdtool.h
    old new  
    4949PHP_FUNCTION(rrd_clear_error); 
    5050PHP_FUNCTION(rrd_update); 
    5151PHP_FUNCTION(rrd_last); 
     52PHP_FUNCTION(rrd_lastupdate); 
    5253PHP_FUNCTION(rrd_create); 
    5354PHP_FUNCTION(rrdtool_info); 
    5455PHP_FUNCTION(rrdtool_logo_guid); 
  • rrdtool.c

    diff -Naur rrdtool.ori/rrdtool.c rrdtool/rrdtool.c
    old new  
    4646        PHP_FE(rrd_clear_error,                 NULL) 
    4747        PHP_FE(rrd_update,                              NULL) 
    4848        PHP_FE(rrd_last,                                NULL) 
     49        PHP_FE(rrd_lastupdate,                  NULL) 
    4950        PHP_FE(rrd_create,                              NULL) 
    5051        PHP_FE(rrdtool_info,                    NULL) 
    5152        PHP_FE(rrdtool_logo_guid,               NULL) 
     
    440441} 
    441442/* }}} */ 
    442443 
    443 /* {{{ proto int rrd_create(string file, array args_arr, int argc) 
     444/* {{{ proto int rrd_lastupdate(string file) 
     445 Gets last update of an RRD file */ 
     446PHP_FUNCTION(rrd_lastupdate) 
     447{ 
     448    pval *file; 
     449    char    **ds_names; 
     450    char    **data; 
     451    unsigned long ds_cnt, i; 
     452    time_t    retval; 
     453        pval *p_ds_cnt; 
     454        zval *p_ds_names, *p_data; 
     455     
     456    char **argv = (char **) emalloc(3 * sizeof(char *)); 
     457     
     458    if ( rrd_test_error() ) 
     459        rrd_clear_error(); 
     460     
     461    if (zend_get_parameters(ht, 1, &file) == SUCCESS) 
     462    { 
     463        convert_to_string(file); 
     464         
     465        argv[0] = "dummy"; 
     466        argv[1] = estrdup("lastupdate"); 
     467        argv[2] = estrdup(file->value.str.val); 
     468         
     469        optind = 0; opterr = 0; 
     470         
     471        if ((retval = rrd_lastupdate_s (2, &argv[1], &ds_cnt, &ds_names, &data)) != -1 ) 
     472        { 
     473            array_init(return_value); 
     474                        add_assoc_long(return_value, "last", (long) retval); 
     475            add_assoc_long(return_value, "ds_cnt", ds_cnt); 
     476             
     477            MAKE_STD_ZVAL(p_ds_names); 
     478            MAKE_STD_ZVAL(p_data); 
     479            array_init(p_ds_names); 
     480            array_init(p_data); 
     481             
     482            if (ds_names) 
     483            { 
     484                for (i = 0; i < ds_cnt; i++) 
     485                { 
     486                    add_next_index_string(p_ds_names, ds_names[i], 1); 
     487                    free(ds_names[i]); 
     488                } 
     489                free(ds_names); 
     490            } 
     491             
     492            if (data) 
     493            { 
     494                for (i = 0; i < ds_cnt; i++) 
     495                { 
     496                    add_next_index_string(p_data, data[i], 1); 
     497                    free(data[i]); 
     498                } 
     499                free(data); 
     500            } 
     501             
     502            zend_hash_update(return_value->value.ht, "ds_namv", sizeof("ds_namv"),  
     503                             (void *)&p_ds_names, sizeof(zval *), NULL); 
     504            zend_hash_update(return_value->value.ht, "data", sizeof("data"),  
     505                             (void *)&p_data, sizeof(zval *), NULL); 
     506        } 
     507        else 
     508        { 
     509            RETVAL_FALSE; 
     510        } 
     511        efree(argv[1]);  efree(argv[2]); 
     512        efree(argv); 
     513    } 
     514    else 
     515    { 
     516        WRONG_PARAM_COUNT; 
     517    } 
     518    return; 
     519} 
     520/* }}} */ 
     521 
     522    /* {{{ proto int rrd_create(string file, array args_arr, int argc) 
    444523        Create an RRD file with the options passed (passed via array) */  
    445524PHP_FUNCTION(rrd_create) 
    446525{ 

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.