cvs: embed /php-irssi ext-irssi.c php-core.c php-irssi-obj.c typemap.php window.c
| From: | Wez Furlong | Date: | Sun, 02 Feb 2003 19:18:28 +0000 |
| Subject: | cvs: embed /php-irssi ext-irssi.c php-core.c php-irssi-obj.c typemap.php window.c | ||
| Groups: | php.embed.cvs | ||
| Request: | Send a blank email to php-embed-cvs+get-20@lists.php.net to get a copy of this message | ||
wez Sun Feb 2 14:18:28 2003 EDT
Modified files:
/embed/php-irssi ext-irssi.c php-core.c php-irssi-obj.c typemap.php
window.c
Log:
More signal functions.
Safer signal functions (using zend_try).
Implement:
$window->print_text(IRSSI_MSGLEVEL_CLIENTNOTICE, "foobar");
Index: embed/php-irssi/ext-irssi.c diff -u embed/php-irssi/ext-irssi.c:1.12 embed/php-irssi/ext-irssi.c:1.13 --- embed/php-irssi/ext-irssi.c:1.12 Sun Feb 2 10:08:53 2003 +++ embed/php-irssi/ext-irssi.c Sun Feb 2 14:18:27 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: ext-irssi.c,v 1.12 2003/02/02 15:08:53 wez Exp $ + $Id: ext-irssi.c,v 1.13 2003/02/02 19:18:27 wez Exp $ */ #include "php-irssi.h" #include "php-signals-list.h" /* generated by php during make */ @@ -209,13 +209,18 @@ } } - call_result = call_user_function_ex(EG(function_table), - NULL, - func_name, - &retval, - sigargs->argc, - zargs, - 0, NULL TSRMLS_CC); + zend_first_try { + call_result = call_user_function_ex(EG(function_table), + NULL, + func_name, + &retval, + sigargs->argc, + zargs, + 0, NULL TSRMLS_CC); + + } zend_catch { + call_result = FAILURE; + } zend_end_try(); if (call_result == SUCCESS) { /* TODO: update any args passed by reference */ @@ -297,13 +302,16 @@ zargs[argc++] = &arg; } - call_user_function_ex(EG(function_table), - NULL, - rec->handler, - &retval, - argc, - zargs, - 0, NULL TSRMLS_CC); + zend_first_try { + call_user_function_ex(EG(function_table), + NULL, + rec->handler, + &retval, + argc, + zargs, + 0, NULL TSRMLS_CC); + } zend_catch { + } zend_end_try(); if (retval) zval_ptr_dtor(&retval); @@ -388,7 +396,65 @@ } } +/* proto void irssi_signal_stop(void) + Stop the current ongoing signal emission */ +PHP_FUNCTION(irssi_signal_stop) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + signal_stop(); +} +/* proto void irssi_signal_stop_by_name(string name) + Stop ongoing signal emission by name. */ +PHP_FUNCTION(irssi_signal_stop_by_name) +{ + char *signame; + long signame_len; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &signame, &signame_len)) { + return; + } + + signal_stop_by_name(signame); +} + +/* proto string irssi_signal_get_emitted(void) + Get the name of the signal that is currently being emitted */ +PHP_FUNCTION(irssi_signal_get_emitted) +{ + char *signame; + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + signame = (char*)signal_get_emitted(); + + if (signame) { + RETURN_STRING(signame, 1); + } else { + RETURN_NULL(); + } +} + +/* proto bool irssi_signal_is_stopped(string signalname) + return true if the specified signal was stopped */ +PHP_FUNCTION(irssi_signal_is_stopped) +{ + char *signame; + long signame_len; + int sigid; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &signame, &signame_len)) { + return; + } + + sigid = signal_get_uniq_id(signame); + + RETURN_BOOL(signal_is_stopped(sigid)); +} /* proto void irssi_signal_add(string signalname, mixed callback, [long priority, mixed sigarg]) Binds a function to a signal. priority is one of the IRSSI_PRIORITY_XXX constants */ @@ -647,6 +713,10 @@ PHP_FE(irssi_signal_emit, NULL) PHP_FE(irssi_signal_remove, NULL) PHP_FE(irssi_signal_get_arg, NULL) + PHP_FE(irssi_signal_stop, NULL) + PHP_FE(irssi_signal_stop_by_name, NULL) + PHP_FE(irssi_signal_get_emitted, NULL) + PHP_FE(irssi_signal_is_stopped, NULL) PHP_FE(irssi_timeout_add, NULL) PHP_FE(irssi_timeout_remove, NULL) PHP_FE(irssi_window_get_active, NULL) Index: embed/php-irssi/php-core.c diff -u embed/php-irssi/php-core.c:1.7 embed/php-irssi/php-core.c:1.8 --- embed/php-irssi/php-core.c:1.7 Fri Jan 31 14:44:00 2003 +++ embed/php-irssi/php-core.c Sun Feb 2 14:18:27 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: php-core.c,v 1.7 2003/01/31 19:44:00 tal Exp $ + $Id: php-core.c,v 1.8 2003/02/02 19:18:27 wez Exp $ */ #define MODULE_NAME "php/core" #include "common.h" @@ -44,7 +44,6 @@ int signal_php_output; int signal_php_error; -WINDOW_REC *target_win; /* Catch output pushed from the output buffer mechanism. * Route it to "php output" signal. @@ -147,17 +146,17 @@ /* Handler for "/php exec" command */ static void cmd_php_exec(const char *data) { - target_win = active_win; + active_win = active_win; switch (php_eval_string("php/irssi:exec", "%s", data)) { case EVAL_RET_OK: break; case EVAL_RET_ERROR: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php command failed"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php command failed"); break; case EVAL_RET_BAIL: default: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php command bailed out status=%d", EG(exit_status)); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php command bailed out status=%d", EG(exit_status)); } } @@ -170,69 +169,69 @@ /* Handler for "/php help" command */ static void cmd_php_help(const char *data) { - target_win = active_win; + active_win = active_win; - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "PHP Module:"); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "/php exec <string_to_evaluate>"); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "/php load <file>"); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "/php version"); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "/php set <ini_entry> <value>"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "PHP Module:"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "/php exec <string_to_evaluate>"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "/php load <file>"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "/php version"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "/php set <ini_entry> <value>"); } /* Handler for "/php version" command */ static void cmd_php_version(const char *data) { - target_win = active_win; + active_win = active_win; - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "PHP Module For Irssi v%s", PHP_IRSSI_VERSION); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "PHP v%s", PHP_VERSION); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "PHP Module For Irssi v%s", PHP_IRSSI_VERSION); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "PHP v%s", PHP_VERSION); } /* Handler for "/php load" command */ static void cmd_php_load(const char *data) { - target_win = active_win; + active_win = active_win; switch (php_eval_string("php/irssi:load", "include('%s');", data)) { case EVAL_RET_OK: break; case EVAL_RET_ERROR: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php failed loading %s", data); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php failed loading %s", data); case EVAL_RET_BAIL: default: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php bailed out status=%d", EG(exit_status)); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php bailed out status=%d", EG(exit_status)); } } /* default "php error" signal handler */ static void error_handler(char *message) { - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php error: %s", message); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php error: %s", message); } /* default "php output" signal handler */ static void output_handler(const char *str, unsigned int str_length) { - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "%s", str); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "%s", str); } /* autorun any .php scripts found in the users scripts/autorun dir */ static void do_autorun(void) { - target_win = active_win; + active_win = active_win; switch (php_eval_string("php/irssi:autoload", "foreach(glob('%s/scripts/autorun/*.php') as $_autorun_name) { include $_autorun_name; }", get_irssi_dir())) { case EVAL_RET_OK: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload completed"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload completed"); break; case EVAL_RET_ERROR: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload failed"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload failed"); break; case EVAL_RET_BAIL: default: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload bailed out status=%d", EG(exit_status)); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload bailed out status=%d", EG(exit_status)); } } Index: embed/php-irssi/php-irssi-obj.c diff -u embed/php-irssi/php-irssi-obj.c:1.5 embed/php-irssi/php-irssi-obj.c:1.6 --- embed/php-irssi/php-irssi-obj.c:1.5 Sat Feb 1 22:27:16 2003 +++ embed/php-irssi/php-irssi-obj.c Sun Feb 2 14:18:27 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: php-irssi-obj.c,v 1.5 2003/02/02 03:27:16 wez Exp $ + $Id: php-irssi-obj.c,v 1.6 2003/02/02 19:18:27 wez Exp $ */ #include "php-irssi.h" #include "php-irssi-obj-defs.h" @@ -102,7 +102,7 @@ return retval; } - zend_error(E_NOTICE,"Undefined property: %s", Z_STRVAL_P(member)); + zend_error(E_NOTICE, "Undefined property: %s", Z_STRVAL_P(member)); return EG(uninitialized_zval_ptr); } @@ -176,8 +176,7 @@ /* FIXME: doesn't seem quite right */ if (parent) { - *class_name = "irssi"; - *class_name_len = 5; + return FAILURE; } else { *class_name = (char*)ref->binding->classname; *class_name_len = strlen(*class_name); @@ -188,6 +187,7 @@ static int pih_compare_objects(zval *o1, zval *o2 TSRMLS_DC) { + return FAILURE; } zend_object_handlers php_irssi_handlers = { Index: embed/php-irssi/typemap.php diff -u embed/php-irssi/typemap.php:1.5 embed/php-irssi/typemap.php:1.6 --- embed/php-irssi/typemap.php:1.5 Sat Feb 1 22:27:16 2003 +++ embed/php-irssi/typemap.php Sun Feb 2 14:18:27 2003 @@ -15,18 +15,18 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: typemap.php,v 1.5 2003/02/02 03:27:16 wez Exp $ + $Id: typemap.php,v 1.6 2003/02/02 19:18:27 wez Exp $ */ /* This array describes the functions that can be used to convert between * irssi and php/ze types */ $objects_to_scan = array( - "src/core/server-rec.h" => array("SERVER_REC", "server"), - "src/core/channel-rec.h" => array("CHANNEL_REC", "channel", array("PHP_IRSSI_INH_WI_ITEM")), - "src/core/nick-rec.h" => array("NICK_REC", "nick"), - "src/core/window-item-rec.h" => array("WI_ITEM_REC", "windowitem"), - "src/fe-common/core/fe-windows.h" => array("WINDOW_REC", "window", null, "/struct _WINDOW_REC {([^}]+)}/sm"), + "src/core/server-rec.h" => array("SERVER_REC", "irssi_server"), + "src/core/channel-rec.h" => array("CHANNEL_REC", "irssi_channel", array("PHP_IRSSI_INH_WI_ITEM")), + "src/core/nick-rec.h" => array("NICK_REC", "irssi_nick"), + "src/core/window-item-rec.h" => array("WI_ITEM_REC", "irssi_windowitem"), + "src/fe-common/core/fe-windows.h" => array("WINDOW_REC", "irssi_window", null, "/struct _WINDOW_REC {([^}]+)}/sm"), ); Index: embed/php-irssi/window.c diff -u embed/php-irssi/window.c:1.1 embed/php-irssi/window.c:1.2 --- embed/php-irssi/window.c:1.1 Sat Feb 1 22:27:16 2003 +++ embed/php-irssi/window.c Sun Feb 2 14:18:27 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: window.c,v 1.1 2003/02/02 03:27:16 wez Exp $ + $Id: window.c,v 1.2 2003/02/02 19:18:27 wez Exp $ */ #include "php-irssi.h" @@ -85,12 +85,28 @@ WRONG_PARAM_COUNT; } - RETVAL_STRING(window_get_active_name(window), 1); + RETVAL_STRING((char*)window_get_active_name(window), 1); +} + +PHP_FUNCTION(window_print_text) +{ + char *text; + long text_len; + long level; + WINDOW_FETCH(); + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &level, + &text, &text_len)) { + return; + } + + printtext_window(window, level, "%s", text); } function_entry php_irssi_WINDOW_funcs[] = { PHP_NAMED_FE(set_active, PHP_FN(window_set_active), NULL) PHP_NAMED_FE(get_active_name, PHP_FN(window_get_active_name), NULL) + PHP_NAMED_FE(print_text, PHP_FN(window_print_text), NULL) NULL, NULL, NULL };
Index: embed/php-irssi/ext-irssi.c diff -u embed/php-irssi/ext-irssi.c:1.12 embed/php-irssi/ext-irssi.c:1.13 --- embed/php-irssi/ext-irssi.c:1.12 Sun Feb 2 10:08:53 2003 +++ embed/php-irssi/ext-irssi.c Sun Feb 2 14:18:27 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: ext-irssi.c,v 1.12 2003/02/02 15:08:53 wez Exp $ + $Id: ext-irssi.c,v 1.13 2003/02/02 19:18:27 wez Exp $ */ #include "php-irssi.h" #include "php-signals-list.h" /* generated by php during make */ @@ -209,13 +209,18 @@ } } - call_result = call_user_function_ex(EG(function_table), - NULL, - func_name, - &retval, - sigargs->argc, - zargs, - 0, NULL TSRMLS_CC); + zend_first_try { + call_result = call_user_function_ex(EG(function_table), + NULL, + func_name, + &retval, + sigargs->argc, + zargs, + 0, NULL TSRMLS_CC); + + } zend_catch { + call_result = FAILURE; + } zend_end_try(); if (call_result == SUCCESS) { /* TODO: update any args passed by reference */ @@ -297,13 +302,16 @@ zargs[argc++] = &arg; } - call_user_function_ex(EG(function_table), - NULL, - rec->handler, - &retval, - argc, - zargs, - 0, NULL TSRMLS_CC); + zend_first_try { + call_user_function_ex(EG(function_table), + NULL, + rec->handler, + &retval, + argc, + zargs, + 0, NULL TSRMLS_CC); + } zend_catch { + } zend_end_try(); if (retval) zval_ptr_dtor(&retval); @@ -388,7 +396,65 @@ } } +/* proto void irssi_signal_stop(void) + Stop the current ongoing signal emission */ +PHP_FUNCTION(irssi_signal_stop) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + signal_stop(); +} +/* proto void irssi_signal_stop_by_name(string name) + Stop ongoing signal emission by name. */ +PHP_FUNCTION(irssi_signal_stop_by_name) +{ + char *signame; + long signame_len; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &signame, &signame_len)) { + return; + } + + signal_stop_by_name(signame); +} + +/* proto string irssi_signal_get_emitted(void) + Get the name of the signal that is currently being emitted */ +PHP_FUNCTION(irssi_signal_get_emitted) +{ + char *signame; + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + signame = (char*)signal_get_emitted(); + + if (signame) { + RETURN_STRING(signame, 1); + } else { + RETURN_NULL(); + } +} + +/* proto bool irssi_signal_is_stopped(string signalname) + return true if the specified signal was stopped */ +PHP_FUNCTION(irssi_signal_is_stopped) +{ + char *signame; + long signame_len; + int sigid; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &signame, &signame_len)) { + return; + } + + sigid = signal_get_uniq_id(signame); + + RETURN_BOOL(signal_is_stopped(sigid)); +} /* proto void irssi_signal_add(string signalname, mixed callback, [long priority, mixed sigarg]) Binds a function to a signal. priority is one of the IRSSI_PRIORITY_XXX constants */ @@ -647,6 +713,10 @@ PHP_FE(irssi_signal_emit, NULL) PHP_FE(irssi_signal_remove, NULL) PHP_FE(irssi_signal_get_arg, NULL) + PHP_FE(irssi_signal_stop, NULL) + PHP_FE(irssi_signal_stop_by_name, NULL) + PHP_FE(irssi_signal_get_emitted, NULL) + PHP_FE(irssi_signal_is_stopped, NULL) PHP_FE(irssi_timeout_add, NULL) PHP_FE(irssi_timeout_remove, NULL) PHP_FE(irssi_window_get_active, NULL) Index: embed/php-irssi/php-core.c diff -u embed/php-irssi/php-core.c:1.7 embed/php-irssi/php-core.c:1.8 --- embed/php-irssi/php-core.c:1.7 Fri Jan 31 14:44:00 2003 +++ embed/php-irssi/php-core.c Sun Feb 2 14:18:27 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: php-core.c,v 1.7 2003/01/31 19:44:00 tal Exp $ + $Id: php-core.c,v 1.8 2003/02/02 19:18:27 wez Exp $ */ #define MODULE_NAME "php/core" #include "common.h" @@ -44,7 +44,6 @@ int signal_php_output; int signal_php_error; -WINDOW_REC *target_win; /* Catch output pushed from the output buffer mechanism. * Route it to "php output" signal. @@ -147,17 +146,17 @@ /* Handler for "/php exec" command */ static void cmd_php_exec(const char *data) { - target_win = active_win; + active_win = active_win; switch (php_eval_string("php/irssi:exec", "%s", data)) { case EVAL_RET_OK: break; case EVAL_RET_ERROR: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php command failed"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php command failed"); break; case EVAL_RET_BAIL: default: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php command bailed out status=%d", EG(exit_status)); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php command bailed out status=%d", EG(exit_status)); } } @@ -170,69 +169,69 @@ /* Handler for "/php help" command */ static void cmd_php_help(const char *data) { - target_win = active_win; + active_win = active_win; - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "PHP Module:"); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "/php exec <string_to_evaluate>"); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "/php load <file>"); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "/php version"); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "/php set <ini_entry> <value>"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "PHP Module:"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "/php exec <string_to_evaluate>"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "/php load <file>"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "/php version"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "/php set <ini_entry> <value>"); } /* Handler for "/php version" command */ static void cmd_php_version(const char *data) { - target_win = active_win; + active_win = active_win; - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "PHP Module For Irssi v%s", PHP_IRSSI_VERSION); - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "PHP v%s", PHP_VERSION); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "PHP Module For Irssi v%s", PHP_IRSSI_VERSION); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "PHP v%s", PHP_VERSION); } /* Handler for "/php load" command */ static void cmd_php_load(const char *data) { - target_win = active_win; + active_win = active_win; switch (php_eval_string("php/irssi:load", "include('%s');", data)) { case EVAL_RET_OK: break; case EVAL_RET_ERROR: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php failed loading %s", data); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php failed loading %s", data); case EVAL_RET_BAIL: default: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php bailed out status=%d", EG(exit_status)); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php bailed out status=%d", EG(exit_status)); } } /* default "php error" signal handler */ static void error_handler(char *message) { - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php error: %s", message); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php error: %s", message); } /* default "php output" signal handler */ static void output_handler(const char *str, unsigned int str_length) { - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "%s", str); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "%s", str); } /* autorun any .php scripts found in the users scripts/autorun dir */ static void do_autorun(void) { - target_win = active_win; + active_win = active_win; switch (php_eval_string("php/irssi:autoload", "foreach(glob('%s/scripts/autorun/*.php') as $_autorun_name) { include $_autorun_name; }", get_irssi_dir())) { case EVAL_RET_OK: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload completed"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload completed"); break; case EVAL_RET_ERROR: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload failed"); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload failed"); break; case EVAL_RET_BAIL: default: - printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload bailed out status=%d", EG(exit_status)); + printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php autoload bailed out status=%d", EG(exit_status)); } } Index: embed/php-irssi/php-irssi-obj.c diff -u embed/php-irssi/php-irssi-obj.c:1.5 embed/php-irssi/php-irssi-obj.c:1.6 --- embed/php-irssi/php-irssi-obj.c:1.5 Sat Feb 1 22:27:16 2003 +++ embed/php-irssi/php-irssi-obj.c Sun Feb 2 14:18:27 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: php-irssi-obj.c,v 1.5 2003/02/02 03:27:16 wez Exp $ + $Id: php-irssi-obj.c,v 1.6 2003/02/02 19:18:27 wez Exp $ */ #include "php-irssi.h" #include "php-irssi-obj-defs.h" @@ -102,7 +102,7 @@ return retval; } - zend_error(E_NOTICE,"Undefined property: %s", Z_STRVAL_P(member)); + zend_error(E_NOTICE, "Undefined property: %s", Z_STRVAL_P(member)); return EG(uninitialized_zval_ptr); } @@ -176,8 +176,7 @@ /* FIXME: doesn't seem quite right */ if (parent) { - *class_name = "irssi"; - *class_name_len = 5; + return FAILURE; } else { *class_name = (char*)ref->binding->classname; *class_name_len = strlen(*class_name); @@ -188,6 +187,7 @@ static int pih_compare_objects(zval *o1, zval *o2 TSRMLS_DC) { + return FAILURE; } zend_object_handlers php_irssi_handlers = { Index: embed/php-irssi/typemap.php diff -u embed/php-irssi/typemap.php:1.5 embed/php-irssi/typemap.php:1.6 --- embed/php-irssi/typemap.php:1.5 Sat Feb 1 22:27:16 2003 +++ embed/php-irssi/typemap.php Sun Feb 2 14:18:27 2003 @@ -15,18 +15,18 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: typemap.php,v 1.5 2003/02/02 03:27:16 wez Exp $ + $Id: typemap.php,v 1.6 2003/02/02 19:18:27 wez Exp $ */ /* This array describes the functions that can be used to convert between * irssi and php/ze types */ $objects_to_scan = array( - "src/core/server-rec.h" => array("SERVER_REC", "server"), - "src/core/channel-rec.h" => array("CHANNEL_REC", "channel", array("PHP_IRSSI_INH_WI_ITEM")), - "src/core/nick-rec.h" => array("NICK_REC", "nick"), - "src/core/window-item-rec.h" => array("WI_ITEM_REC", "windowitem"), - "src/fe-common/core/fe-windows.h" => array("WINDOW_REC", "window", null, "/struct _WINDOW_REC {([^}]+)}/sm"), + "src/core/server-rec.h" => array("SERVER_REC", "irssi_server"), + "src/core/channel-rec.h" => array("CHANNEL_REC", "irssi_channel", array("PHP_IRSSI_INH_WI_ITEM")), + "src/core/nick-rec.h" => array("NICK_REC", "irssi_nick"), + "src/core/window-item-rec.h" => array("WI_ITEM_REC", "irssi_windowitem"), + "src/fe-common/core/fe-windows.h" => array("WINDOW_REC", "irssi_window", null, "/struct _WINDOW_REC {([^}]+)}/sm"), ); Index: embed/php-irssi/window.c diff -u embed/php-irssi/window.c:1.1 embed/php-irssi/window.c:1.2 --- embed/php-irssi/window.c:1.1 Sat Feb 1 22:27:16 2003 +++ embed/php-irssi/window.c Sun Feb 2 14:18:27 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: window.c,v 1.1 2003/02/02 03:27:16 wez Exp $ + $Id: window.c,v 1.2 2003/02/02 19:18:27 wez Exp $ */ #include "php-irssi.h" @@ -85,12 +85,28 @@ WRONG_PARAM_COUNT; } - RETVAL_STRING(window_get_active_name(window), 1); + RETVAL_STRING((char*)window_get_active_name(window), 1); +} + +PHP_FUNCTION(window_print_text) +{ + char *text; + long text_len; + long level; + WINDOW_FETCH(); + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &level, + &text, &text_len)) { + return; + } + + printtext_window(window, level, "%s", text); } function_entry php_irssi_WINDOW_funcs[] = { PHP_NAMED_FE(set_active, PHP_FN(window_set_active), NULL) PHP_NAMED_FE(get_active_name, PHP_FN(window_get_active_name), NULL) + PHP_NAMED_FE(print_text, PHP_FN(window_print_text), NULL) NULL, NULL, NULL };