cvs: pecl /newt newt.c
| From: | Michael Spector | Date: | Fri, 13 Aug 2004 12:08:09 +0000 |
| Subject: | cvs: pecl /newt newt.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-1640@lists.php.net to get a copy of this message | ||
michael Fri Aug 13 08:08:09 2004 EDT
Modified files:
/pecl/newt newt.c
Log:
added functions
http://cvs.php.net/diff.php/pecl/newt/newt.c?r1=1.2&r2=1.3&ty=u
Index: pecl/newt/newt.c
diff -u pecl/newt/newt.c:1.2 pecl/newt/newt.c:1.3
--- pecl/newt/newt.c:1.2 Thu Aug 12 17:47:37 2004
+++ pecl/newt/newt.c Fri Aug 13 08:08:09 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: newt.c,v 1.2 2004/08/12 21:47:37 michael Exp $ */
+/* $Id: newt.c,v 1.3 2004/08/13 12:08:09 michael Exp $ */
#include <newt.h>
@@ -745,6 +745,7 @@
/* }}} */
/* {{{
+ * proto newt_set_suspend_callback (mixed function, mixed data)
*/
PHP_FUNCTION(newt_set_suspend_callback)
{
@@ -785,6 +786,7 @@
/* }}} */
/* {{{
+ * proto newt_set_help_callback (mixed function)
*/
PHP_FUNCTION(newt_set_help_callback)
{
@@ -1065,7 +1067,7 @@
/* }}} */
/* {{{
- * proto resource newt_radiobutton (int left, int top, string text, bool is_default, resource
prev_button)
+ * proto resource newt_radiobutton (int left, int top, string text, bool is_default [, resource
prev_button])
*/
PHP_FUNCTION(newt_radiobutton)
{
@@ -1079,10 +1081,17 @@
newtComponent radiobutton;
int argc = ZEND_NUM_ARGS();
- if (argc != 5) { WRONG_PARAM_COUNT; }
- if (zend_parse_parameters (argc, "llsbz!", &left, &top, &text,
&text_len, &is_default, &z_prev_button) == FAILURE) {
- return;
- }
+ if (argc == 4) {
+ if (zend_parse_parameters (argc, "llsb", &left, &top,
+ &text, &text_len, &is_default) == FAILURE) {
+ return;
+ }
+ } else if (argc == 5) {
+ if (zend_parse_parameters (argc, "llsbz!", &left, &top,
+ &text, &text_len, &is_default, &z_prev_button) == FAILURE) {
+ return;
+ }
+ } else { WRONG_PARAM_COUNT; }
if (z_prev_button) {
ZEND_FETCH_RESOURCE(prev_button, newtComponent, &z_prev_button, -1, le_newt_comp_name,
le_newt_comp);
@@ -1189,7 +1198,7 @@
zval * z_item;
newtComponent item;
php_unserialize_data_t var_hash;
- const char *p;
+ const char *data;
int argc = ZEND_NUM_ARGS();
if (argc != 1) { WRONG_PARAM_COUNT; }
@@ -1199,11 +1208,11 @@
ZEND_FETCH_RESOURCE(item, newtComponent, &z_item, -1, le_newt_comp_name, le_newt_comp);
- p = newtListitemGetData (item);
+ data = newtListitemGetData (item);
- if (p) {
+ if (data) {
PHP_VAR_UNSERIALIZE_INIT (var_hash);
- php_var_unserialize(&return_value, &p, p + strlen(p), &var_hash TSRMLS_CC);
+ php_var_unserialize(&return_value, &data, data + strlen(data), &var_hash TSRMLS_CC);
PHP_VAR_UNSERIALIZE_DESTROY (var_hash);
zval_copy_ctor (return_value);
@@ -1213,7 +1222,7 @@
#endif
/* {{{
- * proto newt_get_screen_size (int cols, int rows)
+ * proto newt_get_screen_size (int &cols, int &rows)
*/
PHP_FUNCTION(newt_get_screen_size)
{
@@ -1240,6 +1249,7 @@
/* }}} */
/* {{{
+ * proto resource newt_label (int left, int top, string text)
*/
PHP_FUNCTION(newt_label)
{
@@ -1599,16 +1609,92 @@
/* }}} */
/* {{{
+ * newt_listbox_get_entry (resource listbox, int num [, string &text [, mixed &data]])
*/
PHP_FUNCTION(newt_listbox_get_entry)
{
+ zval * z_listbox;
+ newtComponent listbox;
+ int num;
+ zval * z_text = NULL, * z_data = NULL;
+ char * text = NULL, * data = NULL;
+ const char *p;
+ php_unserialize_data_t var_hash;
+
+ int argc = ZEND_NUM_ARGS();
+ if (argc == 2) {
+ if (zend_parse_parameters (argc, "zl", &z_listbox, &num) == FAILURE) {
+ return;
+ }
+ } else if (argc == 3) {
+ if (zend_parse_parameters (argc, "zlz/!", &z_listbox, &num, &z_text) ==
FAILURE) {
+ return;
+ }
+ } else if (argc == 4) {
+ if (zend_parse_parameters (argc, "zlz/!z/!", &z_listbox, &num, &z_text,
&z_data) == FAILURE) {
+ return;
+ }
+ } else { WRONG_PARAM_COUNT; }
+
+ ZEND_FETCH_RESOURCE(listbox, newtComponent, &z_listbox, -1, le_newt_comp_name, le_newt_comp);
+
+ newtListboxGetEntry (listbox, num, &text, (void *)&data);
+ if (z_text) {
+ zval_dtor (z_text);
+ if (text) {
+ ZVAL_STRING (z_text, text, 1);
+ }
+ }
+ if (z_data) {
+ zval_dtor (z_data);
+ if (data) {
+ PHP_VAR_UNSERIALIZE_INIT (var_hash);
+ p = data;
+ php_var_unserialize(&z_data, &p, p + strlen(p), &var_hash TSRMLS_CC);
+ PHP_VAR_UNSERIALIZE_DESTROY (var_hash);
+ }
+ }
}
/* }}} */
/* {{{
+ * proto array newt_listbox_get_selection (resource listbox)
*/
PHP_FUNCTION(newt_listbox_get_selection)
{
+ zval * z_listbox;
+ newtComponent listbox;
+ char **retval;
+ zval * z_val;
+ int num_items;
+ php_unserialize_data_t var_hash;
+ int i;
+ const char *p;
+
+ int argc = ZEND_NUM_ARGS();
+ if (argc != 1) { WRONG_PARAM_COUNT; }
+ if (zend_parse_parameters (argc, "z", &z_listbox) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(listbox, newtComponent, &z_listbox, -1, le_newt_comp_name, le_newt_comp);
+ retval = (char **)newtListboxGetSelection (listbox, &num_items);
+
+ array_init (return_value);
+ MAKE_STD_ZVAL (z_val);
+
+ if (retval) {
+ PHP_VAR_UNSERIALIZE_INIT (var_hash);
+ for (i=0; i < num_items; i++ ) {
+ p = retval[i];
+ php_var_unserialize(&z_val, &p, p + strlen(p), &var_hash TSRMLS_CC);
+ zval_add_ref (&z_val);
+ zend_hash_next_index_insert (Z_ARRVAL_P(return_value), &z_val, sizeof(zval *), NULL);
+ SEPARATE_ZVAL (&z_val);
+ }
+ PHP_VAR_UNSERIALIZE_DESTROY (var_hash);
+ free (retval);
+ }
}
/* }}} */
@@ -1974,7 +2060,7 @@
/* }}} */
/* {{{
- * proto string newt_reflow_text (string text, int width, int flex_down, int flex_up, int
actual_width, int actual_height)
+ * proto string newt_reflow_text (string text, int width, int flex_down, int flex_up, int
&actual_width, int &actual_height)
*/
PHP_FUNCTION(newt_reflow_text)
{
@@ -2265,7 +2351,7 @@
/* }}} */
/* {{{
- * proto newt_form_run (resource form, array exit_struct)
+ * proto newt_form_run (resource form, array &exit_struct)
*/
PHP_FUNCTION(newt_form_run)
{