00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef lint
00021 static const char rcsid[] = "$Id: mod_iface.c,v 1.19 2005-12-28 17:27:31 sven Exp $";
00022 #endif
00023
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <eggdrop/eggdrop.h>
00027
00028
00029 extern int perlscript_init();
00030 extern int perlscript_destroy();
00031 extern script_module_t my_script_interface;
00032 extern char *real_perl_cmd(char *text);
00033 extern event_owner_t perl_owner;
00034
00035
00036 int log_error(char *msg)
00037 {
00038 putlog(LOG_MISC, "*", _("Perl error: %s"), msg);
00039 return(0);
00040 }
00041
00042
00043 static int party_perl(partymember_t *p, char *nick, user_t *u, char *cmd, char *text)
00044 {
00045 char *retval;
00046
00047
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 }
00063
00064 static bind_list_t my_party_cmds[] = {
00065 {"n", "perl", party_perl},
00066 {0}
00067 };
00068
00069 static int perlscript_close(int why)
00070 {
00071 bind_rem_list("party", my_party_cmds);
00072
00073
00074 perlscript_destroy();
00075
00076 script_unregister_module(&my_script_interface);
00077
00078 return(0);
00079 }
00080
00081 EXPORT_SCOPE int perlscript_LTX_start(egg_module_t *modinfo);
00082
00083 int perlscript_LTX_start(egg_module_t *modinfo)
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
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 }