#include <stdio.h>
#include <stdlib.h>
#include <eggdrop/eggdrop.h>
Go to the source code of this file.
Functions | |
int | perlscript_init () |
int | perlscript_destroy () |
char * | real_perl_cmd (char *text) |
int | log_error (char *msg) |
static int | party_perl (partymember_t *p, char *nick, user_t *u, char *cmd, char *text) |
static int | perlscript_close (int why) |
EXPORT_SCOPE int | perlscript_LTX_start (egg_module_t *modinfo) |
Variables | |
static const char | rcsid [] = "$Id: mod_iface.c,v 1.19 2005-12-28 17:27:31 sven Exp $" |
script_module_t | my_script_interface |
event_owner_t | perl_owner |
static bind_list_t | my_party_cmds [] |
int log_error | ( | char * | msg | ) |
Definition at line 36 of file mod_iface.c.
References _, LOG_MISC, and putlog().
Referenced by my_load_script(), and my_perl_callbacker().
static int party_perl | ( | partymember_t * | p, | |
char * | nick, | |||
user_t * | u, | |||
char * | cmd, | |||
char * | text | |||
) | [static] |
Definition at line 43 of file mod_iface.c.
References _, BIND_RET_LOG, egg_isowner(), user::handle, partymember_write(), and real_perl_cmd().
00044 { 00045 char *retval; 00046 00047 /* You must be owner to use this command. */ 00048 if (!u || !egg_isowner(u->handle)) { 00049 partymember_write(p, _("Sorry, you must be a permanent owner to use this command."), -1); 00050 return(BIND_RET_LOG); 00051 } 00052 00053 if (!text) { 00054 partymember_write(p, _("Syntax: .perl <perlexpression>"), -1); 00055 return(0); 00056 } 00057 00058 retval = real_perl_cmd(text); 00059 partymember_write(p, retval, -1); 00060 free(retval); 00061 return(0); 00062 }
static int perlscript_close | ( | int | why | ) | [static] |
Definition at line 69 of file mod_iface.c.
References bind_rem_list(), perlscript_destroy(), and script_unregister_module().
Referenced by perlscript_LTX_start().
00070 { 00071 bind_rem_list("party", my_party_cmds); 00072 00073 /* Destroy interpreter. */ 00074 perlscript_destroy(); 00075 00076 script_unregister_module(&my_script_interface); 00077 00078 return(0); 00079 }
int perlscript_destroy | ( | ) |
Definition at line 539 of file perlscript.c.
References ginterp.
Referenced by perlscript_close().
00540 { 00541 PL_perl_destruct_level = 1; 00542 perl_destruct(ginterp); 00543 perl_free(ginterp); 00544 return(0); 00545 }
int perlscript_init | ( | ) |
Definition at line 529 of file perlscript.c.
References ginterp, init_xs_stuff(), and NULL.
Referenced by perlscript_LTX_start().
00530 { 00531 char *embedding[] = {"", "-e", "0"}; 00532 00533 ginterp = perl_alloc(); 00534 perl_construct(ginterp); 00535 perl_parse(ginterp, init_xs_stuff, 3, embedding, NULL); 00536 return(0); 00537 }
int perlscript_LTX_start | ( | egg_module_t * | modinfo | ) |
Definition at line 83 of file mod_iface.c.
References egg_module::author, bind_add_list(), egg_module::close_func, egg_module::description, event_owner_b::module, egg_module::name, perlscript_close(), perlscript_init(), script_playback(), script_register_module(), and egg_module::version.
00084 { 00085 perl_owner.module = modinfo; 00086 00087 modinfo->name = "perlscript"; 00088 modinfo->author = "eggdev"; 00089 modinfo->version = "1.0.0"; 00090 modinfo->description = "provides perl scripting support"; 00091 modinfo->close_func = perlscript_close; 00092 00093 /* Initialize interpreter. */ 00094 perlscript_init(); 00095 00096 script_register_module(&my_script_interface); 00097 script_playback(&my_script_interface); 00098 00099 bind_add_list("party", my_party_cmds); 00100 return(0); 00101 }
char* real_perl_cmd | ( | char * | text | ) |
Definition at line 504 of file perlscript.c.
References egg_mprintf().
Referenced by party_perl().
00505 { 00506 SV *result; 00507 char *msg, *retval; 00508 int len; 00509 00510 result = eval_pv(text, FALSE); 00511 if (SvTRUE(ERRSV)) { 00512 msg = SvPV(ERRSV, len); 00513 retval = egg_mprintf("Perl error: %s", msg); 00514 } 00515 else { 00516 msg = SvPV(result, len); 00517 retval = egg_mprintf("Perl result: %s\n", msg); 00518 } 00519 00520 return(retval); 00521 }
bind_list_t my_party_cmds[] [static] |
Definition at line 50 of file perlscript.c.
Definition at line 58 of file perlscript.c.
const char rcsid[] = "$Id: mod_iface.c,v 1.19 2005-12-28 17:27:31 sven Exp $" [static] |
Definition at line 21 of file mod_iface.c.