#include "src/mod/module.h"
#include "src/tandem.h"
#include <stdlib.h>
#include "assoc.h"
Go to the source code of this file.
Data Structures | |
struct | assoc_t_ |
Defines | |
#define | MODULE_NAME "assoc" |
#define | MAKING_ASSOC |
Typedefs | |
typedef struct assoc_t_ | assoc_t |
Functions | |
static void | botnet_send_assoc (int idx, int chan, char *nick, char *buf) |
static int | assoc_expmem () |
static void | link_assoc (char *bot, char *via) |
static void | kill_assoc (int chan) |
static void | kill_all_assoc () |
static void | add_assoc (char *name, int chan) |
static int | get_assoc (char *name) |
static char * | get_assoc_name (int chan) |
static void | dump_assoc (int idx) |
static int | cmd_assoc (struct userrec *u, int idx, char *par) |
static char * | assoc_close () |
EXPORT_SCOPE char * | assoc_start () |
char * | assoc_start (Function *global_funcs) |
Variables | |
static Function * | global = 0 |
static assoc_t * | assoc |
static cmd_t | mybot [] |
static cmd_t | mylink [] |
static tcl_cmds | mytcl [] |
static Function | assoc_table [] |
#define MODULE_NAME "assoc" |
Definition at line 26 of file assoc.c.
Referenced by _malloc_fdbe(), assoc_close(), assoc_start(), blowfish_start(), channel_malloc(), channels_close(), channels_start(), compress_close(), compress_start(), console_close(), console_start(), ctcp_close(), ctcp_start(), dns_close(), dns_start(), filesys_close(), filesys_start(), irc_close(), irc_start(), notes_close(), notes_start(), seen_close(), seen_start(), server_close(), server_start(), share_close(), share_start(), transfer_close(), transfer_start(), uptime_start(), wire_close(), wire_start(), woobie_close(), and woobie_start().
static void add_assoc | ( | char * | name, | |
int | chan | |||
) | [static] |
Definition at line 118 of file assoc.c.
References assoc_t_::channel, egg_strcasecmp, kill_assoc(), assoc_t_::name, assoc_t_::next, nmalloc, NULL, and strncpyz.
Referenced by cmd_assoc().
00119 { 00120 assoc_t *a, *b, *old = NULL; 00121 00122 for (a = assoc; a; a = a->next) { 00123 if (name[0] != 0 && !egg_strcasecmp(a->name, name)) { 00124 kill_assoc(a->channel); 00125 add_assoc(name, chan); 00126 return; 00127 } 00128 if (a->channel == chan) { 00129 strncpyz(a->name, name, sizeof a->name); 00130 return; 00131 } 00132 } 00133 /* Add in numerical order */ 00134 for (a = assoc; a; old = a, a = a->next) { 00135 if (a->channel > chan) { 00136 b = nmalloc(sizeof *b); 00137 b->next = a; 00138 b->channel = chan; 00139 strncpyz(b->name, name, sizeof b->name); 00140 if (old == NULL) 00141 assoc = b; 00142 else 00143 old->next = b; 00144 return; 00145 } 00146 } 00147 /* Add at the end */ 00148 b = nmalloc(sizeof *b); 00149 b->next = NULL; 00150 b->channel = chan; 00151 strncpyz(b->name, name, sizeof b->name); 00152 if (old == NULL) 00153 assoc = b; 00154 else 00155 old->next = b; 00156 }
static char* assoc_close | ( | ) | [static] |
Definition at line 386 of file assoc.c.
References del_lang_section, H_bot, H_dcc, H_link, kill_all_assoc(), MODULE_NAME, module_undepend, NULL, rem_builtins, rem_help_reference, and rem_tcl_commands.
00387 { 00388 kill_all_assoc(); 00389 rem_builtins(H_dcc, mydcc); 00390 rem_builtins(H_bot, mybot); 00391 rem_builtins(H_link, mylink); 00392 rem_tcl_commands(mytcl); 00393 rem_help_reference("assoc.help"); 00394 del_lang_section("assoc"); 00395 module_undepend(MODULE_NAME); 00396 return NULL; 00397 }
static int assoc_expmem | ( | ) | [static] |
char* assoc_start | ( | Function * | global_funcs | ) |
Definition at line 408 of file assoc.c.
References add_builtins, add_help_reference, add_lang_section, add_tcl_commands, global, H_bot, H_dcc, H_link, module_depend, MODULE_NAME, module_register, module_undepend, and NULL.
00409 { 00410 global = global_funcs; 00411 00412 module_register(MODULE_NAME, assoc_table, 2, 0); 00413 if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) { 00414 module_undepend(MODULE_NAME); 00415 return "This module requires Eggdrop 1.6.0 or later."; 00416 } 00417 assoc = NULL; 00418 add_builtins(H_dcc, mydcc); 00419 add_builtins(H_bot, mybot); 00420 add_builtins(H_link, mylink); 00421 add_lang_section("assoc"); 00422 add_tcl_commands(mytcl); 00423 add_help_reference("assoc.help"); 00424 return NULL; 00425 }
EXPORT_SCOPE char* assoc_start | ( | ) |
static void botnet_send_assoc | ( | int | idx, | |
int | chan, | |||
char * | nick, | |||
char * | buf | |||
) | [static] |
Definition at line 47 of file assoc.c.
References b_numver, bot_flags, BOT_ISOLATE, botnet_send_zapf, botnetnick, dcc, DCC_BOT, dcc_total, NEAT_BOTNET, simple_sprintf, and user.
Referenced by cmd_assoc().
00048 { 00049 char x[1024]; 00050 int idx2; 00051 00052 simple_sprintf(x, "assoc %D %s %s", chan, nick, buf); 00053 for (idx2 = 0; idx2 < dcc_total; idx2++) 00054 if ((dcc[idx2].type == &DCC_BOT) && (idx2 != idx) && 00055 (b_numver(idx2) >= NEAT_BOTNET) && 00056 !(bot_flags(dcc[idx2].user) & BOT_ISOLATE)) 00057 botnet_send_zapf(idx2, botnetnick, dcc[idx2].nick, x); 00058 }
static int cmd_assoc | ( | struct userrec * | u, | |
int | idx, | |||
char * | par | |||
) | [static] |
Definition at line 193 of file assoc.c.
References add_assoc(), ASSOC_CHAN_RANGE, ASSOC_CHNAME_FIRSTCHAR, ASSOC_CHNAME_TOOLONG, ASSOC_LCHAN_RANGE, ASSOC_NEWNAME_CHAN, ASSOC_NEWOUT_CHAN, ASSOC_NONAME_CHAN, ASSOC_PARTYLINE, ASSOC_REMNAME_CHAN, ASSOC_REMOUT_CHAN, botnet_send_assoc(), chanout_but, dcc, dprintf, dump_assoc(), userrec::flags, get_assoc_name(), GLOBAL_CHANS, kill_assoc(), LOG_CMDS, MISC_NOSUCHCMD, newsplit, NULL, putlog, and USER_BOTMAST.
00194 { 00195 char *num; 00196 int chan; 00197 00198 if (!par[0]) { 00199 putlog(LOG_CMDS, "*", "#%s# assoc", dcc[idx].nick); 00200 dump_assoc(idx); 00201 } else if (!u || !(u->flags & USER_BOTMAST)) 00202 dprintf(idx, "%s", MISC_NOSUCHCMD); 00203 else { 00204 num = newsplit(&par); 00205 if (num[0] == '*') { 00206 chan = GLOBAL_CHANS + atoi(num + 1); 00207 if ((chan < GLOBAL_CHANS) || (chan > 199999)) { 00208 dprintf(idx, "%s\n", ASSOC_LCHAN_RANGE); 00209 return 0; 00210 } 00211 } else { 00212 chan = atoi(num); 00213 if (chan == 0) { 00214 dprintf(idx, "%s\n", ASSOC_PARTYLINE); 00215 return 0; 00216 } else if ((chan < 1) || (chan >= GLOBAL_CHANS)) { 00217 dprintf(idx, "%s\n", ASSOC_CHAN_RANGE); 00218 return 0; 00219 } 00220 } 00221 if (!par[0]) { 00222 /* Remove an association */ 00223 if (get_assoc_name(chan) == NULL) { 00224 dprintf(idx, ASSOC_NONAME_CHAN, (chan < GLOBAL_CHANS) ? "" : "*", 00225 chan % GLOBAL_CHANS); 00226 return 0; 00227 } 00228 kill_assoc(chan); 00229 putlog(LOG_CMDS, "*", "#%s# assoc %d", dcc[idx].nick, chan); 00230 dprintf(idx, ASSOC_REMNAME_CHAN, (chan < GLOBAL_CHANS) ? "" : "*", 00231 chan % GLOBAL_CHANS); 00232 chanout_but(-1, chan, ASSOC_REMOUT_CHAN, dcc[idx].nick); 00233 if (chan < GLOBAL_CHANS) 00234 botnet_send_assoc(-1, chan, dcc[idx].nick, "0"); 00235 return 0; 00236 } 00237 if (strlen(par) > 20) { 00238 dprintf(idx, "%s\n", ASSOC_CHNAME_TOOLONG); 00239 return 0; 00240 } 00241 if ((par[0] >= '0') && (par[0] <= '9')) { 00242 dprintf(idx, "%s\n", ASSOC_CHNAME_FIRSTCHAR); 00243 return 0; 00244 } 00245 add_assoc(par, chan); 00246 putlog(LOG_CMDS, "*", "#%s# assoc %d %s", dcc[idx].nick, chan, par); 00247 dprintf(idx, ASSOC_NEWNAME_CHAN, (chan < GLOBAL_CHANS) ? "" : "*", 00248 chan % GLOBAL_CHANS, par); 00249 chanout_but(-1, chan, ASSOC_NEWOUT_CHAN, dcc[idx].nick, par); 00250 if (chan < GLOBAL_CHANS) 00251 botnet_send_assoc(-1, chan, dcc[idx].nick, par); 00252 } 00253 return 0; 00254 }
static void dump_assoc | ( | int | idx | ) | [static] |
Definition at line 178 of file assoc.c.
References ASSOC_CHAN, ASSOC_NAME, ASSOC_NOCHNAMES, assoc_t_::channel, dprintf, GLOBAL_CHANS, assoc_t_::name, assoc_t_::next, and NULL.
Referenced by cmd_assoc().
00179 { 00180 assoc_t *a = assoc; 00181 00182 if (a == NULL) { 00183 dprintf(idx, "%s\n", ASSOC_NOCHNAMES); 00184 return; 00185 } 00186 dprintf(idx, " %s %s\n", ASSOC_CHAN, ASSOC_NAME); 00187 for (; a && a->name[0]; a = a->next) 00188 dprintf(idx, "%c%5d %s\n", (a->channel < GLOBAL_CHANS) ? ' ' : '*', 00189 a->channel % GLOBAL_CHANS, a->name); 00190 return; 00191 }
static int get_assoc | ( | char * | name | ) | [static] |
Definition at line 158 of file assoc.c.
References assoc_t_::channel, egg_strcasecmp, assoc_t_::name, and assoc_t_::next.
static char* get_assoc_name | ( | int | chan | ) | [static] |
Definition at line 168 of file assoc.c.
References assoc_t_::channel, assoc_t_::name, assoc_t_::next, and NULL.
Referenced by cmd_assoc().
00169 { 00170 assoc_t *a; 00171 00172 for (a = assoc; a; a = a->next) 00173 if (a->channel == chan) 00174 return a->name; 00175 return NULL; 00176 }
static void kill_all_assoc | ( | ) | [static] |
static void kill_assoc | ( | int | chan | ) | [static] |
Definition at line 88 of file assoc.c.
References assoc_t_::channel, assoc_t_::next, nfree, and NULL.
Referenced by add_assoc(), and cmd_assoc().
00089 { 00090 assoc_t *a = assoc, *last = NULL; 00091 00092 while (a) { 00093 if (a->channel == chan) { 00094 if (last != NULL) 00095 last->next = a->next; 00096 else 00097 assoc = a->next; 00098 nfree(a); 00099 a = NULL; 00100 } else { 00101 last = a; 00102 a = a->next; 00103 } 00104 } 00105 }
static void link_assoc | ( | char * | bot, | |
char * | via | |||
) | [static] |
Definition at line 70 of file assoc.c.
References bot_flags, BOT_ISOLATE, botnet_send_zapf, botnetnick, assoc_t_::channel, dcc, egg_strcasecmp, assoc_t_::name, assoc_t_::next, nextbot, simple_sprintf, and user.
00071 { 00072 char x[1024]; 00073 00074 if (!egg_strcasecmp(via, botnetnick)) { 00075 int idx = nextbot(bot); 00076 assoc_t *a; 00077 00078 if (!(bot_flags(dcc[idx].user) & BOT_ISOLATE)) { 00079 for (a = assoc; a && a->name[0]; a = a->next) { 00080 simple_sprintf(x, "assoc %D %s %s", (int) a->channel, botnetnick, 00081 a->name); 00082 botnet_send_zapf(idx, botnetnick, dcc[idx].nick, x); 00083 } 00084 } 00085 } 00086 }
Function assoc_table[] [static] |
{ (Function) assoc_start, (Function) assoc_close, (Function) assoc_expmem, (Function) assoc_report, }
Function* global = 0 [static] |
Definition at line 35 of file assoc.c.
Referenced by _malloc_fdbe(), assoc_start(), blowfish_start(), channel_malloc(), channels_start(), compress_start(), console_start(), ctcp_start(), dns_start(), filesys_start(), irc_start(), notes_start(), seen_start(), server_start(), share_start(), transfer_start(), uptime_start(), wire_start(), and woobie_start().
{ {"*", "", (IntFunc) link_assoc, "assoc"}, { 0 , 0 , 0 , 0 } }