cvs: pecl /newt newt.c php_newt.h
| From: | Michael Spector | Date: | Sun, 15 Aug 2004 15:50:52 +0000 |
| Subject: | cvs: pecl /newt newt.c php_newt.h | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-1664@lists.php.net to get a copy of this message | ||
michael Sun Aug 15 11:50:52 2004 EDT
Modified files:
/pecl/newt newt.c php_newt.h
Log:
* implemented newt_win_ternary() and newt_win_choice() using calling to PHP functions
http://cvs.php.net/diff.php/pecl/newt/newt.c?r1=1.7&r2=1.8&ty=u
Index: pecl/newt/newt.c
diff -u pecl/newt/newt.c:1.7 pecl/newt/newt.c:1.8
--- pecl/newt/newt.c:1.7 Sun Aug 15 11:34:16 2004
+++ pecl/newt/newt.c Sun Aug 15 11:50:52 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: newt.c,v 1.7 2004/08/15 15:34:16 michael Exp $ */
+/* $Id: newt.c,v 1.8 2004/08/15 15:50:52 michael Exp $ */
#include <newt.h>
@@ -413,7 +413,7 @@
/* {{{
* proto newt_call_php_function
*/
-void newt_call_php_function (INTERNAL_FUNCTION_PARAMETERS, const char *func_name, zval **ret_val,
int argc, zval ***args)
+void newt_call_php_function (INTERNAL_FUNCTION_PARAMETERS, char *func_name, zval **ret_val, int
argc, zval ***args)
{
zval *z_func_name;
@@ -3201,7 +3201,7 @@
int argc = ZEND_NUM_ARGS();
if (argc < 3) { WRONG_PARAM_COUNT; }
- args = (zval **) emalloc (sizeof(zval **) * argc);
+ args = (zval ***) emalloc (sizeof(zval **) * argc);
if (zend_get_parameters_array_ex (argc, args) == FAILURE) {
return;
@@ -3248,16 +3248,71 @@
/* }}} */
/* {{{
+ * proto int newt_win_choice (string title, string button1_text, string button2_text, string format
[, mixed args [, mixed...]])
*/
PHP_FUNCTION(newt_win_choice)
{
+ char *title, *button1_text, *button2_text, *text;
+ zval ***args, *z_text = NULL;
+ int button_id;
+
+ int argc = ZEND_NUM_ARGS();
+ if (argc < 4) { WRONG_PARAM_COUNT; }
+
+ args = (zval ***) emalloc (sizeof(zval **) * argc);
+
+ if (zend_get_parameters_array_ex (argc, args) == FAILURE) {
+ return;
+ }
+
+ title = Z_STRVAL_PP(args[0]);
+ button1_text = Z_STRVAL_PP(args[1]);
+ button2_text = Z_STRVAL_PP(args[2]);
+
+ newt_call_php_function (INTERNAL_FUNCTION_PARAM_PASSTHRU, "sprintf", &z_text,
argc-3, args+3);
+
+ if(z_text) {
+ text = Z_STRVAL_P(z_text);
+ }
+ button_id = newtWinChoice (title, button1_text, button2_text, text);
+ efree (args);
+
+ RETURN_LONG (button_id);
}
/* }}} */
/* {{{
+ * proto int newt_win_ternary (string title, string button1_text, string button2_text, string
button3_text, string format [, mixed args [, mixed...]])
*/
PHP_FUNCTION(newt_win_ternary)
{
+ char *title, *button1_text, *button2_text, *button3_text, *text;
+ zval ***args, *z_text = NULL;
+ int button_id;
+
+ int argc = ZEND_NUM_ARGS();
+ if (argc < 5) { WRONG_PARAM_COUNT; }
+
+ args = (zval ***) emalloc (sizeof(zval **) * argc);
+
+ if (zend_get_parameters_array_ex (argc, args) == FAILURE) {
+ return;
+ }
+
+ title = Z_STRVAL_PP(args[0]);
+ button1_text = Z_STRVAL_PP(args[1]);
+ button2_text = Z_STRVAL_PP(args[2]);
+ button3_text = Z_STRVAL_PP(args[3]);
+
+ newt_call_php_function (INTERNAL_FUNCTION_PARAM_PASSTHRU, "sprintf", &z_text,
argc-4, args+4);
+
+ if(z_text) {
+ text = Z_STRVAL_P(z_text);
+ }
+ button_id = newtWinTernary (title, button1_text, button2_text, button3_text, text);
+ efree (args);
+
+ RETURN_LONG (button_id);
}
/* }}} */
http://cvs.php.net/diff.php/pecl/newt/php_newt.h?r1=1.2&r2=1.3&ty=u
Index: pecl/newt/php_newt.h
diff -u pecl/newt/php_newt.h:1.2 pecl/newt/php_newt.h:1.3
--- pecl/newt/php_newt.h:1.2 Sun Aug 15 11:34:16 2004
+++ pecl/newt/php_newt.h Sun Aug 15 11:50:52 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_newt.h,v 1.2 2004/08/15 15:34:16 michael Exp $ */
+/* $Id: php_newt.h,v 1.3 2004/08/15 15:50:52 michael Exp $ */
#include <newt.h>
@@ -202,7 +202,7 @@
void newt_entry_filter_callback_wrapper (newtComponent entry, newt_data_st * cb, int ch, int
cursor);
void newt_suspend_callback_wrapper (newt_data_st * cb);
void newt_help_callback_wrapper (newtComponent form, char *help);
-void newt_call_php_function (INTERNAL_FUNCTION_PARAMETERS, const char *func_name, zval **ret_val,
int argc, zval ***args);
+void newt_call_php_function (INTERNAL_FUNCTION_PARAMETERS, char *func_name, zval **ret_val, int
argc, zval ***args);
#ifdef ZTS
#define NEWT_G(v) TSRMG(newt_globals_id, zend_newt_globals *, v)