|
|
@@ -15,60 +15,24 @@
|
|
|
#include "match.c"
|
|
|
#include "egg_timer.h"
|
|
|
|
|
|
-extern struct dcc_t *dcc;
|
|
|
-extern struct userrec *userlist;
|
|
|
-extern int dcc_total;
|
|
|
-extern time_t now;
|
|
|
-extern mycmds cmdlist[];
|
|
|
-extern int cmdi;
|
|
|
+extern struct dcc_t *dcc;
|
|
|
+extern int dcc_total;
|
|
|
+extern mycmds cmdlist[];
|
|
|
+extern int cmdi;
|
|
|
|
|
|
-extern char dcc_prefix[];
|
|
|
|
|
|
-/* New bind table list */
|
|
|
+/* The head of the bind table linked list. */
|
|
|
static bind_table_t *bind_table_list_head = NULL;
|
|
|
-static bind_table_t *BT_link;
|
|
|
-static bind_table_t *BT_disc;
|
|
|
-static bind_table_t *BT_away;
|
|
|
-static bind_table_t *BT_dcc;
|
|
|
-static bind_table_t *BT_bot;
|
|
|
-static bind_table_t *BT_note;
|
|
|
-static bind_table_t *BT_nkch;
|
|
|
-static bind_table_t *BT_chat;
|
|
|
-static bind_table_t *BT_act;
|
|
|
-static bind_table_t *BT_bcst;
|
|
|
-static bind_table_t *BT_chon;
|
|
|
-static bind_table_t *BT_chof;
|
|
|
-static bind_table_t *BT_chpt;
|
|
|
-static bind_table_t *BT_chjn;
|
|
|
-
|
|
|
-/* Variables to control garbage collection. */
|
|
|
+
|
|
|
+/* Garbage collection stuff. */
|
|
|
static int check_bind_executing = 0;
|
|
|
static int already_scheduled = 0;
|
|
|
static void bind_table_really_del(bind_table_t *table);
|
|
|
static void bind_entry_really_del(bind_table_t *table, bind_entry_t *entry);
|
|
|
|
|
|
-
|
|
|
-extern cmd_t C_dcc[];
|
|
|
-
|
|
|
void binds_init(void)
|
|
|
{
|
|
|
bind_table_list_head = NULL;
|
|
|
- BT_link = bind_table_add("link", 2, "ss", MATCH_MASK, BIND_STACKABLE);
|
|
|
- BT_nkch = bind_table_add("nkch", 2, "ss", MATCH_MASK, BIND_STACKABLE);
|
|
|
- BT_disc = bind_table_add("disc", 1, "s", MATCH_MASK, BIND_STACKABLE);
|
|
|
- BT_away = bind_table_add("away", 3, "sis", MATCH_MASK, BIND_STACKABLE);
|
|
|
- BT_chon = bind_table_add("chon", 2, "si", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
|
|
|
- BT_chof = bind_table_add("chof", 2, "si", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
|
|
|
- BT_dcc = bind_table_add("dcc", 3, "Uis", MATCH_PARTIAL, BIND_USE_ATTR);
|
|
|
- BT_bot = bind_table_add("bot", 3, "sss", MATCH_EXACT, 0);
|
|
|
- BT_note = bind_table_add("note", 3 , "sss", MATCH_EXACT, 0);
|
|
|
- BT_chat = bind_table_add("chat", 3, "sis", MATCH_MASK, BIND_STACKABLE | BIND_BREAKABLE);
|
|
|
- BT_act = bind_table_add("act", 3, "sis", MATCH_MASK, BIND_STACKABLE);
|
|
|
- BT_bcst = bind_table_add("bcst", 3, "sis", MATCH_MASK, BIND_STACKABLE);
|
|
|
- BT_chpt = bind_table_add("chpt", 4, "ssii", MATCH_MASK, BIND_STACKABLE);
|
|
|
- BT_chjn = bind_table_add("chjn", 6, "ssisis", MATCH_MASK, BIND_STACKABLE);
|
|
|
-
|
|
|
- add_builtins("dcc", C_dcc);
|
|
|
}
|
|
|
|
|
|
static int internal_bind_cleanup()
|
|
|
@@ -401,159 +365,6 @@ int check_bind(bind_table_t *table, const char *match, struct flag_record *flags
|
|
|
return(retval);
|
|
|
}
|
|
|
|
|
|
-/* Check for tcl-bound dcc command, return 1 if found
|
|
|
- * dcc: proc-name <handle> <sock> <args...>
|
|
|
- */
|
|
|
-void check_dcc(const char *cmd, int idx, const char *text)
|
|
|
-{
|
|
|
- struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
|
|
|
- int x;
|
|
|
-#ifdef S_DCCPASS
|
|
|
- int found = 0;
|
|
|
-#endif
|
|
|
-
|
|
|
- get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
|
|
|
-
|
|
|
-#ifdef S_DCCPASS
|
|
|
- for (hm = H_dcc->first; hm; hm = hm->next) {
|
|
|
- if (!egg_strcasecmp(cmd, hm->mask)) {
|
|
|
- found = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (found) {
|
|
|
- if (has_cmd_pass(cmd)) {
|
|
|
- char *p,
|
|
|
- work[1024],
|
|
|
- pass[128];
|
|
|
- p = strchr(args, ' ');
|
|
|
- if (p)
|
|
|
- *p = 0;
|
|
|
- strncpyz(pass, args, sizeof(pass));
|
|
|
- if (check_cmd_pass(cmd, pass)) {
|
|
|
- if (p)
|
|
|
- *p = ' ';
|
|
|
- strncpyz(work, args, sizeof(work));
|
|
|
- p = work;
|
|
|
- newsplit(&p);
|
|
|
- strcpy(args, p);
|
|
|
- } else {
|
|
|
- dprintf(idx, "Invalid command password. Use %scommand password arguments\n", dcc_prefix);
|
|
|
- putlog(LOG_MISC, "*", "%s attempted %s%s with missing or incorrect command password", dcc[idx].nick, dcc_prefix, cmd);
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-#endif /* S_DCCPASS */
|
|
|
- x = check_bind(BT_dcc, cmd, &fr, dcc[idx].user, idx, text);
|
|
|
- if (x == 0)
|
|
|
- dprintf(idx, "What? You need '%shelp'\n", dcc_prefix);
|
|
|
- else if (x & BIND_RET_LOG) {
|
|
|
- putlog(LOG_CMDS, "*", "#%s# %s %s", dcc[idx].nick, cmd, text);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void check_bot(const char *nick, const char *code, const char *param)
|
|
|
-{
|
|
|
- check_bind(BT_bot, code, NULL, nick, code, param);
|
|
|
-}
|
|
|
-
|
|
|
-void check_chon(char *hand, int idx)
|
|
|
-{
|
|
|
- struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
|
|
|
- struct userrec *u;
|
|
|
-
|
|
|
- u = get_user_by_handle(userlist, hand);
|
|
|
- touch_laston(u, "partyline", now);
|
|
|
- get_user_flagrec(u, &fr, NULL);
|
|
|
- check_bind(BT_chon, hand, &fr, hand, idx);
|
|
|
-}
|
|
|
-
|
|
|
-void check_chof(char *hand, int idx)
|
|
|
-{
|
|
|
- struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
|
|
|
- struct userrec *u;
|
|
|
-
|
|
|
- u = get_user_by_handle(userlist, hand);
|
|
|
- touch_laston(u, "partyline", now);
|
|
|
- get_user_flagrec(u, &fr, NULL);
|
|
|
- check_bind(BT_chof, hand, &fr, hand, idx);
|
|
|
-}
|
|
|
-
|
|
|
-int check_chat(char *handle, int chan, const char *text)
|
|
|
-{
|
|
|
- return check_bind(BT_chat, text, NULL, handle, chan, text);
|
|
|
-}
|
|
|
-
|
|
|
-void check_act(const char *from, int chan, const char *text)
|
|
|
-{
|
|
|
- check_bind(BT_act, text, NULL, from, chan, text);
|
|
|
-}
|
|
|
-
|
|
|
-void check_bcst(const char *from, int chan, const char *text)
|
|
|
-{
|
|
|
- check_bind(BT_bcst, text, NULL, from, chan, text);
|
|
|
-}
|
|
|
-
|
|
|
-void check_nkch(const char *ohand, const char *nhand)
|
|
|
-{
|
|
|
- check_bind(BT_nkch, ohand, NULL, ohand, nhand);
|
|
|
-}
|
|
|
-
|
|
|
-void check_link(const char *bot, const char *via)
|
|
|
-{
|
|
|
- check_bind(BT_link, bot, NULL, bot, via);
|
|
|
-}
|
|
|
-
|
|
|
-void check_disc(const char *bot)
|
|
|
-{
|
|
|
- check_bind(BT_disc, bot, NULL, bot);
|
|
|
-}
|
|
|
-
|
|
|
-int check_note(const char *from, const char *to, const char *text)
|
|
|
-{
|
|
|
- return check_bind(BT_note, to, NULL, from, to, text);
|
|
|
-}
|
|
|
-
|
|
|
-void check_chjn(const char *bot, const char *nick, int chan,
|
|
|
- const char type, int sock, const char *host)
|
|
|
-{
|
|
|
- struct flag_record fr = {FR_GLOBAL, 0, 0, 0, 0, 0};
|
|
|
- char s[11], t[2];
|
|
|
-
|
|
|
- t[0] = type;
|
|
|
- t[1] = 0;
|
|
|
- switch (type) {
|
|
|
- case '^':
|
|
|
- fr.global = USER_ADMIN;
|
|
|
- break;
|
|
|
- case '*':
|
|
|
- fr.global = USER_OWNER;
|
|
|
- break;
|
|
|
- case '+':
|
|
|
- fr.global = USER_MASTER;
|
|
|
- break;
|
|
|
- case '@':
|
|
|
- fr.global = USER_OP;
|
|
|
- break;
|
|
|
- }
|
|
|
- egg_snprintf(s, sizeof s, "%d", chan);
|
|
|
- check_bind(BT_chjn, s, &fr, bot, nick, chan, t, sock, host);
|
|
|
-}
|
|
|
-
|
|
|
-void check_chpt(const char *bot, const char *hand, int sock, int chan)
|
|
|
-{
|
|
|
- char v[11];
|
|
|
-
|
|
|
- egg_snprintf(v, sizeof v, "%d", chan);
|
|
|
- check_bind(BT_chpt, v, NULL, bot, hand, sock, chan);
|
|
|
-}
|
|
|
-
|
|
|
-void check_away(const char *bot, int idx, const char *msg)
|
|
|
-{
|
|
|
- check_bind(BT_away, bot, NULL, bot, idx, msg);
|
|
|
-}
|
|
|
-
|
|
|
void add_builtins(const char *table_name, cmd_t *cmds)
|
|
|
{
|
|
|
char name[50];
|