cvs: embed /php-irssi TODO ext-irssi.c php-core.c php-irssi.h

From: Date: Fri, 31 Jan 2003 17:59:25 +0000
Subject: cvs: embed /php-irssi TODO ext-irssi.c php-core.c php-irssi.h
Groups: php.embed.cvs 
Request: Send a blank email to php-embed-cvs+get-2@lists.php.net to get a copy of this message
tal Fri Jan 31 12:59:25 2003 EDT Modified files: /embed/php-irssi php-core.c php-irssi.h ext-irssi.c TODO Log: Changed the /php command to be more generic (as described in TODO) Index: embed/php-irssi/php-core.c diff -u embed/php-irssi/php-core.c:1.5 embed/php-irssi/php-core.c:1.6 --- embed/php-irssi/php-core.c:1.5 Thu Jan 30 13:52:29 2003 +++ embed/php-irssi/php-core.c Fri Jan 31 12:59:25 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: php-core.c,v 1.5 2003/01/30 18:52:29 tal Exp $ + $Id: php-core.c,v 1.6 2003/01/31 17:59:25 tal Exp $ */ #define MODULE_NAME "php/core" #include "common.h" @@ -28,6 +28,7 @@ #include "levels.h" #include "fe-windows.h" #include "lib-config/iconfig.h" /* FIXME: remove before .99 */ +#include "php-irssi.h" #include <php_embed.h> extern void php_irssi_module_shutdown(); @@ -50,7 +51,7 @@ * TODO: this should line-buffer the output */ static int ub_write(const char *str, unsigned int str_length TSRMLS_DC) { - signal_emit_id(signal_php_output, 2, str, str_length); + signal_emit_id(signal_php_output, 2, str, str_length); return SUCCESS; } @@ -133,12 +134,22 @@ php_embed_shutdown(TSRMLS_C); } -/* Handler for the "/php" command */ -static void cmd_php(const char *data) +/* Handler for "/php" command */ +static void cmd_php(const char *data, SERVER_REC *server, void *item) +{ + if (*data == '\0') { + data = "help"; + } + + command_runsub("php", data, server, item); +} + +/* Handler for "/php exec" command */ +static void cmd_php_exec(const char *data) { target_win = active_win; - switch (php_eval_string("php/irssi", "%s", data)) { + switch (php_eval_string("php/irssi:exec", "%s", data)) { case EVAL_RET_OK: break; case EVAL_RET_ERROR: @@ -150,6 +161,48 @@ } } +/* Handler for "/php set" command */ +static void cmd_php_set(const char *data) +{ + /* FIXME */ +} + +/* Handler for "/php help" command */ +static void cmd_php_help(const char *data) +{ + target_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>"); +} + +/* Handler for "/php version" command */ +static void cmd_php_version(const char *data) +{ + target_win = active_win; + + printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "PHP Module For Irssi v%s", PHP_IRSSI_VERSION); +} + +/* Handler for "/php load" command */ +static void cmd_php_load(const char *data) +{ + target_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); + case EVAL_RET_BAIL: + default: + printtext_window(target_win, MSGLEVEL_CLIENTCRAP, "-!- php bailed out status=%d", EG(exit_status)); + } +} + /* default "php error" signal handler */ static void error_handler(char *message) { @@ -202,6 +255,11 @@ signal_add("php error", (SIGNAL_FUNC)error_handler); command_bind("php", NULL, (SIGNAL_FUNC)cmd_php); + command_bind("php help", NULL, (SIGNAL_FUNC)cmd_php_help); + command_bind("php exec", NULL, (SIGNAL_FUNC)cmd_php_exec); + command_bind("php load", NULL, (SIGNAL_FUNC)cmd_php_load); + command_bind("php version", NULL, (SIGNAL_FUNC)cmd_php_version); + command_bind("php set", NULL, (SIGNAL_FUNC)cmd_php_set); php_eval_string("php/irssi:init", "set_include_path('%s/scripts:%s');", get_irssi_dir(), SCRIPTDIR); @@ -229,8 +287,14 @@ * although the native register_shutdown_function stuff should also * work just as well */ signal_emit("php unloading", 0); - + command_unbind("php", (SIGNAL_FUNC)cmd_php); + command_unbind("php help", (SIGNAL_FUNC)cmd_php_help); + command_unbind("php exec", (SIGNAL_FUNC)cmd_php_exec); + command_unbind("php load", (SIGNAL_FUNC)cmd_php_load); + command_unbind("php version", (SIGNAL_FUNC)cmd_php_version); + command_unbind("php set", (SIGNAL_FUNC)cmd_php_set); + signal_remove("php output", (SIGNAL_FUNC)output_handler); signal_remove("php error", (SIGNAL_FUNC)error_handler); Index: embed/php-irssi/php-irssi.h diff -u embed/php-irssi/php-irssi.h:1.3 embed/php-irssi/php-irssi.h:1.4 --- embed/php-irssi/php-irssi.h:1.3 Thu Jan 30 10:42:47 2003 +++ embed/php-irssi/php-irssi.h Fri Jan 31 12:59:25 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: php-irssi.h,v 1.3 2003/01/30 15:42:47 wez Exp $ + $Id: php-irssi.h,v 1.4 2003/01/31 17:59:25 tal Exp $ */ #define MODULE_NAME "php/core" @@ -36,6 +36,8 @@ #include "lib-config/iconfig.h" /* FIXME: remove before .99 */ #include <php_embed.h> + +#define PHP_IRSSI_VERSION "0.5-dev" enum php_irssi_arg_type_t { PIAT_STRING, Index: embed/php-irssi/ext-irssi.c diff -u embed/php-irssi/ext-irssi.c:1.3 embed/php-irssi/ext-irssi.c:1.4 --- embed/php-irssi/ext-irssi.c:1.3 Thu Jan 30 10:42:47 2003 +++ embed/php-irssi/ext-irssi.c Fri Jan 31 12:59:25 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@php.net> | +----------------------------------------------------------------------+ - $Id: ext-irssi.c,v 1.3 2003/01/30 15:42:47 wez Exp $ + $Id: ext-irssi.c,v 1.4 2003/01/31 17:59:25 tal Exp $ */ #include "php-irssi.h" #include "php-signals-list.h" /* generated by php during make */ @@ -360,6 +360,7 @@ REGISTER_LONG_CONSTANT("IRSSI_SIGNAL_PRIORITY_DEFAULT", SIGNAL_PRIORITY_DEFAULT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IRSSI_SIGNAL_PRIORITY_LOW", SIGNAL_PRIORITY_LOW, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IRSSI_SIGNAL_PRIORITY_HIGH", SIGNAL_PRIORITY_HIGH, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHP_IRSSI_VERSION", PHP_IRSSI_VERSION, CONST_CS|CONST_PERSISTENT); return SUCCESS; } @@ -395,7 +396,7 @@ NULL, NULL, NULL, - "0.5", + PHP_IRSSI_VERSION, STANDARD_MODULE_PROPERTIES }; Index: embed/php-irssi/TODO diff -u embed/php-irssi/TODO:1.1 embed/php-irssi/TODO:1.2 --- embed/php-irssi/TODO:1.1 Thu Jan 30 08:50:10 2003 +++ embed/php-irssi/TODO Fri Jan 31 12:59:25 2003 @@ -1,6 +1,6 @@ TODO: ==================================== -$Id: TODO,v 1.1 2003/01/30 13:50:10 wez Exp $ +$Id: TODO,v 1.2 2003/01/31 17:59:25 tal Exp $ o Improve genobjdefs.php so that it can find a structure definition in a header file with more junk (when compared with the *-rec.h headers). @@ -46,20 +46,10 @@ o Expose even more stuff! -o Change the /php command to work like this: +o Add multiple arguments support for /php load - Set the default include path to be the shared script dir, followed - by the user script dir. - - /php load filename[.php] filename2[.php] - - foreach arg - add .php suffix if missing - include "arg" - - /php eval $phpcode - - eval($phpcode); +o Implement /php set ;) +o Anything else? vim:tw=78:et

« previous php.embed.cvs (#2) next »