adding functions to php4 ...

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: adding functions to php4 ...
Groups: php.dev 
Request: Send a blank email to php-dev+get-28595@lists.php.net to get a copy of this message
Sorry to bug the list again, but this is my only resort at this moment. :-) The trouble is return value from PHP4 is wrong(way-off). But the called function(pwilcox) in my library(/usr/local/lib/libstat.a) works just fine by itself. Could someone tell me what did I do wrong in the following source file. It is only 70 line program. :-) Here is my new function source( ext/stat/stat.c ) file ----------<stat.c>----------------- #include "php.h" #include "php_ini.h" #include "php_stat.h" #if HAVE_STAT */ function_entry stat_functions[] = { PHP_FE(p_wilcox, NULL) {NULL, NULL, NULL} }; zend_module_entry stat_module_entry = { "stat", stat_functions, PHP_MINIT(stat), PHP_MSHUTDOWN(stat), NULL, NULL, PHP_MINFO(stat), STANDARD_MODULE_PROPERTIES }; #ifdef COMPILE_DL_STAT ZEND_GET_MODULE(stat) #endif PHP_MINIT_FUNCTION(stat) { return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(stat) { return SUCCESS; } PHP_MINFO_FUNCTION(stat) { php_info_print_table_start(); php_info_print_table_header(2, "stat support", "enabled"); php_info_print_table_end(); } PHP_FUNCTION(p_wilcox) { zval **x, **m, **n, **lower_tail, **log_p ; double a, b, c; int t, p; double d ; if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex (5, &x, &m, &n, &lower_tail, &log_p) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_double_ex(x); convert_to_double_ex(m); convert_to_double_ex(n); convert_to_long_ex(lower_tail); convert_to_long_ex(log_p); a = (*x)->value.dval; b = (*m)->value.dval; c = (*n)->value.dval; t = (*lower_tail)->value.lval; p = (*log_p)->value.lval; d =(double) pwilcox(a,b,c,t,p); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ printf("ret_pvalue=>%f\n", d); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RETURN_DOUBLE((double)d); ^^^^^^^^^^^^^^^^^^^^^^^^^^ } #endif /* HAVE_STAT */ ---------------------------------------------- Whenever I try to test my new function(p_wilcox) by calling > php -f ext/stat/stat.php THe return value is something like 1121872. But the pwilcox function itselt works just fine without php4. There must be something basic I do wrong here but I couldn't find them. Thnaks in advance. Jinsoo

« previous php.dev (#28595) next »