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: scriptbind.c,v 1.18 2006-10-03 04:02:13 sven Exp $";
00022 #endif
00023
00024 #include <eggdrop/eggdrop.h>
00025 #include "egg_script_internal.h"
00026
00027
00028 static int script_bind(char *table_name, char *flags, char *mask, script_callback_t *callback);
00029 static int script_unbind(char *table_name, char *mask, char *name);
00030 static int script_rebind(char *table_name, char *flags, char *mask, char *command, char *newflags, char *newmask);
00031
00032 static int script_bind(char *table_name, char *flags, char *mask, script_callback_t *callback)
00033 {
00034 bind_table_t *table;
00035
00036 table = bind_table_lookup(table_name);
00037 if (!table) {
00038 putlog (LOG_MISC, "*", _("Script '%s' accessed non-existing bind table '%s'."),
00039 NULL, table_name);
00040 return(1);
00041 }
00042
00043 if (table->syntax) callback->syntax = strdup(table->syntax);
00044 else callback->syntax = NULL;
00045
00046 return bind_entry_add(table, flags, mask, callback->name, BIND_WANTS_CD, callback->callback, callback, callback->owner);
00047 }
00048
00049 static int script_unbind(char *table_name, char *mask, char *name)
00050 {
00051 bind_table_t *table;
00052 int retval;
00053
00054 table = bind_table_lookup(table_name);
00055 if (!table) return(1);
00056
00057 retval = bind_entry_del(table, mask, name, NULL);
00058 return(retval);
00059 }
00060
00061 static int script_rebind(char *table_name, char *flags, char *mask, char *command, char *newflags, char *newmask)
00062 {
00063 bind_table_t *table;
00064
00065 table = bind_table_lookup(table_name);
00066 if (!table) return(-1);
00067 return bind_entry_modify(table, mask, command, newflags, newmask);
00068 }
00069
00070 script_command_t script_bind_cmds[] = {
00071 {"", "bind", script_bind, NULL, 4, "sssc", "table flags mask command", SCRIPT_INTEGER, 0},
00072 {"", "unbind", script_unbind, NULL, 3, "sss", "table mask command", SCRIPT_INTEGER, 0},
00073 {"", "rebind", script_rebind, NULL, 6, "ssssss", "table flags mask command newflags newmask", SCRIPT_INTEGER, 0},
00074 {0}
00075 };