[srvx-commits] CVS: services/src proto.c,1.72,1.73 mod_common.h,NONE,1.1 mod_common.c,NONE,1.1 tools
Brought to you by:
entrope
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv11746/src Modified Files: tools.h tools.c service.h service.c rules.c recdb.c proto_ircu_p10.c proto_bahamut.c proto.h policer.h policer.c opserv.c nickserv.h nickserv.c modules.h modules.c main.c log.c hash.h hash.c global.c gline.c config.h.in common.h chanserv.c alias.c Makefile.am Added Files: proto.c mod_common.h mod_common.c Removed Files: test-module.so.deps test-module.c opserv.help nickserv.help helpfile.h helpfile.c global.help chanserv.help Log Message: first step at modularizing services - the old four are gone, to be repartitioned and using a better common framework help files are moved from src/ to doc/ directory protocol backends are made dynamically loadable ***** Error reading new file: [Errno 2] No such file or directory: 'mod_common.h' ***** Error reading new file: [Errno 2] No such file or directory: 'mod_common.c' Index: tools.h =================================================================== RCS file: /cvsroot/srvx/services/src/tools.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** tools.h 2001/09/18 02:13:08 1.13 --- tools.h 2001/09/27 21:58:07 1.14 *************** *** 33,39 **** extern unsigned char channel_inverse_modes[256]; - typedef void (*oper_func_t) (struct userNode *user); - void reg_oper_func(oper_func_t handler); - void tools_init(void); --- 33,36 ---- *************** *** 74,83 **** void intervalString(char *output, time_t interval); int getipbyname(const char *name, unsigned long *ip); - void stripColor(char *src); ! const char * preposition(char *word); int ban_match_user(struct userNode *user, char *ban); int ban_match_user_host(struct userNode *user, char *hostmask, char *ban); - int set_policer_param(const char *param, void *data, void *extra); DECLARE_LIST(string_buffer, char); --- 71,78 ---- void intervalString(char *output, time_t interval); int getipbyname(const char *name, unsigned long *ip); ! const char *preposition(char *word); int ban_match_user(struct userNode *user, char *ban); int ban_match_user_host(struct userNode *user, char *hostmask, char *ban); DECLARE_LIST(string_buffer, char); Index: tools.c =================================================================== RCS file: /cvsroot/srvx/services/src/tools.c,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -r1.95 -r1.96 *** tools.c 2001/09/22 16:12:54 1.95 --- tools.c 2001/09/27 21:58:07 1.96 *************** *** 53,66 **** #include "hash.h" #include "log.h" - #include "policer.h" #include "proto.h" #include "recdb.h" #include "tools.h" ! extern struct policer_params *oper_policer_params, *luser_policer_params; ! ! static const unsigned char *user_modes = RFC1459_USER_MODE_CHARS PROTO_USER_MODE_CHARS; static unsigned char user_inverse_modes[256]; ! static const unsigned char *channel_modes = RFC1459_CHANNEL_MODE_CHARS PROTO_CHANNEL_MODE_CHARS; unsigned char channel_inverse_modes[256]; --- 53,63 ---- #include "hash.h" #include "log.h" #include "proto.h" #include "recdb.h" #include "tools.h" ! static const unsigned char *user_modes = RFC1459_USER_MODE_CHARS; static unsigned char user_inverse_modes[256]; ! static const unsigned char *channel_modes = RFC1459_CHANNEL_MODE_CHARS; unsigned char channel_inverse_modes[256]; *************** *** 790,794 **** } ! const char * preposition(char *word) { switch(word[0]) --- 787,792 ---- } ! const char * ! preposition(char *word) { switch(word[0]) *************** *** 803,815 **** return "a"; } - } - - int - set_policer_param(const char *param, void *data, void *extra) - { - struct record_data *rd = data; - const char *str = GET_RECORD_QSTRING(rd); - if (str) policer_params_set(extra, param, str); - return 0; } --- 801,804 ---- Index: service.h =================================================================== RCS file: /cvsroot/srvx/services/src/service.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** service.h 2001/09/22 16:12:54 1.1 --- service.h 2001/09/27 21:58:07 1.2 *************** *** 22,27 **** #define SERVICE_H - #include "common.h" #include "dict.h" int service_create(const char *templ_name, dict_t defn); --- 22,34 ---- #define SERVICE_H #include "dict.h" + #include "modules.h" + + struct userNode; + + struct service_template { + dict_t commands; /* string->struct service_command* */ + struct annotations notes; + }; int service_create(const char *templ_name, dict_t defn); Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/service.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** service.c 2001/09/22 16:12:54 1.1 --- service.c 2001/09/27 21:58:07 1.2 *************** *** 25,33 **** #include "service.h" - struct service_template { - dict_t commands; /* string->struct service_command* */ - struct annotations notes; - }; - static dict_t service_templates; --- 25,28 ---- Index: rules.c =================================================================== RCS file: /cvsroot/srvx/services/src/rules.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** rules.c 2001/09/22 16:12:54 1.1 --- rules.c 2001/09/27 21:58:07 1.2 *************** *** 21,24 **** --- 21,25 ---- #include "config.h" #include <ctype.h> + #include <stdlib.h> #include "dict.h" Index: recdb.c =================================================================== RCS file: /cvsroot/srvx/services/src/recdb.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** recdb.c 2001/08/19 03:06:09 1.31 --- recdb.c 2001/09/27 21:58:07 1.32 *************** *** 367,371 **** if (c != '(') ABORT(recdb, EXPECTED_OPEN_PAREN, c); slist = alloc_string_list(4); ! while (true) { c = parse_skip_ws(recdb); if (c == EOF || c == ')') break; --- 367,371 ---- if (c != '(') ABORT(recdb, EXPECTED_OPEN_PAREN, c); slist = alloc_string_list(4); ! while (1) { c = parse_skip_ws(recdb); if (c == EOF || c == ')') break; Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** proto_ircu_p10.c 2001/09/22 16:12:54 1.22 --- proto_ircu_p10.c 2001/09/27 21:58:07 1.23 *************** *** 54,58 **** --- 54,60 ---- #include "hash.h" #include "log.h" + #define PROTO_FUNC_TYPE 1 #include "proto.h" + #include "proto_ircu_p10.h" #include "timeq.h" #include "tools.h" *************** *** 63,69 **** /************************************/ - extern new_channel_func_t *ncf_list; - extern unsigned int ncf_size, ncf_used; extern int ping_freq, ping_timeout; static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); --- 65,70 ---- /************************************/ extern int ping_freq, ping_timeout; + static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); *************** *** 72,79 **** --- 73,83 ---- static unsigned int next_numeric; static unsigned int highest_numeric; + static struct module *proto_module; struct userNode_proto { char numeric[COMBO_NUMERIC_LEN+1]; }; + static unsigned int uproto_note_id; + #define UPROTO(USER) ((struct userNode_proto*)get_note(&(USER)->notes, uproto_note_id)) struct serverNode_proto { *************** *** 81,84 **** --- 85,90 ---- struct userNode *users[USERARRAYSIZE]; /* flat indexed by numeric */ }; + static unsigned int sproto_note_id; + #define SPROTO(SERVER) ((struct serverNode_proto*)get_note(&(SERVER)->notes, sproto_note_id)) /**************************************/ *************** *** 286,302 **** void irc_server(struct server *srv) - { - putsock("%s %s %d %li %li P10 %s]] :%s", - CMD_SERVER, srv->name, srv->hops, srv->boot, srv->link, srv->proto->numeric, srv->description); - } - - void - irc_jserver(struct server *srv) { ! putsock("%s %s %d %li %li J10 %s]] :%s", ! CMD_SERVER, srv->name, srv->hops + 1, srv->boot, srv->link, srv->proto->numeric, srv->description); } ! void irc_uptime(struct userNode *user) { --- 292,301 ---- void irc_server(struct server *srv) { ! putsock("%s %s %d %li %li %c10 %s]] :%s", ! CMD_SERVER, srv->name, srv->hops + 1, srv->boot, srv->link, (srv->in_burst?'J':'P'), SPROTO(srv)->numeric, srv->description); } ! static void irc_uptime(struct userNode *user) { *************** *** 309,313 **** } ! void irc_whois(struct userNode *from, struct userNode *who) { --- 308,312 ---- } ! static void irc_whois(struct userNode *from, struct userNode *who) { *************** *** 329,336 **** make_usermode(user, modes, sizeof(modes)); putsock("%s %s %s %d "FMT_TIME_T" %s %s %s %s %s :%s", ! user->uplink->proto->numeric, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, modes, b64ip, user->proto->numeric, user->info); } else { putsock("%s %s %s %d "FMT_TIME_T" %s %s %s %s :%s", ! user->uplink->proto->numeric, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, b64ip, user->proto->numeric, user->info); } } --- 328,335 ---- make_usermode(user, modes, sizeof(modes)); putsock("%s %s %s %d "FMT_TIME_T" %s %s %s %s %s :%s", ! SPROTO(user->uplink)->numeric, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, modes, b64ip, UPROTO(user)->numeric, user->info); } else { putsock("%s %s %s %d "FMT_TIME_T" %s %s %s %s :%s", ! SPROTO(user->uplink)->numeric, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, b64ip, UPROTO(user)->numeric, user->info); } } *************** *** 339,343 **** irc_nick(struct userNode *user) { ! putsock("%s %s %s "FMT_TIME_T, user->proto->numeric, CMD_NICK, user->nick, now); } --- 338,342 ---- irc_nick(struct userNode *user) { ! putsock("%s %s %s "FMT_TIME_T, UPROTO(user)->numeric, CMD_NICK, user->nick, now); } *************** *** 356,366 **** /* Quit all local users. */ ! for (i = 0; i < ArrayLength(self->proto->users); i++) { ! if (!self->proto->users[i]) continue; ! irc_quit(self->proto->users[i], message); } } ! putsock("%s %s %s %d :%s", self->proto->numeric, CMD_SQUIT, srv->name, 0, message); if (srv == self->uplink) { --- 355,365 ---- /* Quit all local users. */ ! for (i = 0; i < ArrayLength(SPROTO(self)->users); i++) { ! if (!SPROTO(self)->users[i]) continue; ! irc_quit(SPROTO(self)->users[i], message); } } ! putsock("%s %s %s %d :%s", SPROTO(self)->numeric, CMD_SQUIT, srv->name, 0, message); if (srv == self->uplink) { *************** *** 372,376 **** irc_notice(struct userNode *from, const char *to, const char *message) { ! putsock("%s %s %s :%s", from->proto->numeric, CMD_NOTICE, to, message); } --- 371,375 ---- irc_notice(struct userNode *from, const char *to, const char *message) { ! putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_NOTICE, to, message); } *************** *** 379,414 **** { if (IsChannelName(to)) { ! putsock("%s %s %s :%s", from->proto->numeric, CMD_PRIVMSG, to, message); } else { struct userNode *user = GetUser(to); ! if (user) putsock("%s %s %s :%s", from->proto->numeric, CMD_PRIVMSG, user->proto->numeric, message); } } ! void irc_eob(void) { ! putsock("%s %s", self->proto->numeric, CMD_EOB); } ! void irc_eob_ack(void) { ! putsock("%s %s", self->proto->numeric, CMD_EOB_ACK); } ! void irc_ping(const char *something) { ! putsock("%s %s :%s", self->proto->numeric, CMD_PING, something); } ! void irc_pong(const char *data) { ! putsock("%s %s %s :%s", self->proto->numeric, CMD_PONG, self->name, data); } ! void irc_pass(const char *passwd) { --- 378,413 ---- { if (IsChannelName(to)) { ! putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_PRIVMSG, to, message); } else { struct userNode *user = GetUser(to); ! if (user) putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_PRIVMSG, UPROTO(user)->numeric, message); } } ! static void irc_eob(void) { ! putsock("%s %s", SPROTO(self)->numeric, CMD_EOB); } ! static void irc_eob_ack(void) { ! putsock("%s %s", SPROTO(self)->numeric, CMD_EOB_ACK); } ! static void irc_ping(const char *something) { ! putsock("%s %s :%s", SPROTO(self)->numeric, CMD_PING, something); } ! static void irc_pong(const char *data) { ! putsock("%s %s %s :%s", SPROTO(self)->numeric, CMD_PONG, self->name, data); } ! static void irc_pass(const char *passwd) { *************** *** 424,431 **** irc_pass(passwd); - irc_jserver(self); self->in_burst = 1; burst_begin = now; burst_length = 0; timeq_add(now + ping_freq, timed_send_ping, 0); } --- 423,430 ---- irc_pass(passwd); self->in_burst = 1; burst_begin = now; burst_length = 0; + irc_server(self); timeq_add(now + ping_freq, timed_send_ping, 0); } *************** *** 434,438 **** irc_gline(const char *mask, unsigned long duration, const char *message) { ! putsock("%s %s * +%s %lu :%s", self->proto->numeric, CMD_GLINE, mask, duration, message); } --- 433,437 ---- irc_gline(const char *mask, unsigned long duration, const char *message) { ! putsock("%s %s * +%s %lu :%s", SPROTO(self)->numeric, CMD_GLINE, mask, duration, message); } *************** *** 440,444 **** irc_ungline(const char *mask) { ! putsock("%s %s * -%s", self->proto->numeric, CMD_GLINE, mask); } --- 439,443 ---- irc_ungline(const char *mask) { ! putsock("%s %s * -%s", SPROTO(self)->numeric, CMD_GLINE, mask); } *************** *** 446,450 **** irc_jupe(const char *server, unsigned long duration, const char *reason) { ! putsock("%s %s * +%s %lu "FMT_TIME_T" :%s", self->proto->numeric, CMD_JUPE, server, duration, now, reason); } --- 445,449 ---- irc_jupe(const char *server, unsigned long duration, const char *reason) { ! putsock("%s %s * +%s %lu "FMT_TIME_T" :%s", SPROTO(self)->numeric, CMD_JUPE, server, duration, now, reason); } *************** *** 452,456 **** irc_unjupe(const char *server) { ! putsock("%s %s * -%s 0 "FMT_TIME_T" :Unjuping.", self->proto->numeric, CMD_JUPE, server, now); } --- 451,455 ---- irc_unjupe(const char *server) { ! putsock("%s %s * -%s 0 "FMT_TIME_T" :Unjuping.", SPROTO(self)->numeric, CMD_JUPE, server, now); } *************** *** 465,469 **** unsigned int n; ! base_len = sprintf(burst_line, "%s %s %s " FMT_TIME_T " ", self->proto->numeric, CMD_BURST, chan->name, chan->timestamp); len = make_chanmode(chan, burst_line+base_len, sizeof(burst_line)-base_len); pos = base_len + len - 1; --- 464,468 ---- unsigned int n; ! base_len = sprintf(burst_line, "%s %s %s " FMT_TIME_T " ", SPROTO(self)->numeric, CMD_BURST, chan->name, chan->timestamp); len = make_chanmode(chan, burst_line+base_len, sizeof(burst_line)-base_len); pos = base_len + len - 1; *************** *** 479,484 **** last_mode = -1; } ! memcpy(burst_line+pos, mn->user->proto->numeric, 5); ! pos += strlen(mn->user->proto->numeric); if (mn->modes && (mn->modes != last_mode)) { last_mode = mn->modes; --- 478,483 ---- last_mode = -1; } ! memcpy(burst_line+pos, UPROTO(mn->user)->numeric, 5); ! pos += strlen(UPROTO(mn->user)->numeric); if (mn->modes && (mn->modes != last_mode)) { last_mode = mn->modes; *************** *** 520,524 **** irc_quit(struct userNode *user, const char *message) { ! putsock("%s %s :%s", user->proto->numeric, CMD_QUIT, message); } --- 519,523 ---- irc_quit(struct userNode *user, const char *message) { ! putsock("%s %s :%s", UPROTO(user)->numeric, CMD_QUIT, message); } *************** *** 537,543 **** { if (from) { ! putsock("%s %s %s :%s!%s (%s)", from->proto->numeric, CMD_KILL, target->proto->numeric, self->name, from->nick, message); } else { ! putsock("%s %s %s :%s (%s)", self->proto->numeric, CMD_KILL, target->proto->numeric, self->name, message); } } --- 536,542 ---- { if (from) { ! putsock("%s %s %s :%s!%s (%s)", UPROTO(from)->numeric, CMD_KILL, UPROTO(target)->numeric, self->name, from->nick, message); } else { ! putsock("%s %s %s :%s (%s)", SPROTO(self)->numeric, CMD_KILL, UPROTO(target)->numeric, self->name, message); } } *************** *** 549,555 **** const char *src; if ((mn = GetUserMode(target, from)) && (mn->modes & MODE_CHANOP)) { ! src = from->proto->numeric; } else { ! src = self->proto->numeric; } putsock("%s %s %s %s "FMT_TIME_T, src, CMD_MODE, target->name, modes, target->timestamp); --- 548,554 ---- const char *src; if ((mn = GetUserMode(target, from)) && (mn->modes & MODE_CHANOP)) { ! src = UPROTO(from)->numeric; } else { ! src = SPROTO(self)->numeric; } putsock("%s %s %s %s "FMT_TIME_T, src, CMD_MODE, target->name, modes, target->timestamp); *************** *** 566,572 **** { if (what->members.used == 1) { ! putsock("%s %s %s %lu", who->proto->numeric, CMD_CREATE, what->name, what->timestamp); } else { ! putsock("%s %s %s", who->proto->numeric, CMD_JOIN, what->name); } } --- 565,571 ---- { if (what->members.used == 1) { ! putsock("%s %s %s %lu", UPROTO(who)->numeric, CMD_CREATE, what->name, what->timestamp); } else { ! putsock("%s %s %s", UPROTO(who)->numeric, CMD_JOIN, what->name); } } *************** *** 575,579 **** irc_kick(struct userNode *actor, struct userNode *who, struct chanNode *from, const char *msg) { ! putsock("%s %s %s %s :%s", actor->proto->numeric, CMD_KICK, from->name, who->proto->numeric, msg); } --- 574,578 ---- irc_kick(struct userNode *actor, struct userNode *who, struct chanNode *from, const char *msg) { ! putsock("%s %s %s %s :%s", UPROTO(actor)->numeric, CMD_KICK, from->name, UPROTO(who)->numeric, msg); } *************** *** 587,591 **** irc_stats(struct userNode *from, struct server *target, char type) { ! putsock("%s STATS %c :%s", from->proto->numeric, type, target->proto->numeric); } --- 586,590 ---- irc_stats(struct userNode *from, struct server *target, char type) { ! putsock("%s STATS %c :%s", UPROTO(from)->numeric, type, SPROTO(target)->numeric); } *************** *** 593,597 **** irc_part(struct userNode *who, struct chanNode *what, const char *reason) { ! putsock("%s %s %s :%s", who->proto->numeric, CMD_PART, what->name, reason); } --- 592,596 ---- irc_part(struct userNode *who, struct chanNode *what, const char *reason) { ! putsock("%s %s %s :%s", UPROTO(who)->numeric, CMD_PART, what->name, reason); } *************** *** 648,652 **** for (i=0; i<count; i++) { ! len = strlen(list[i]->proto->numeric); if ((start < queued+3+len) || (queued >= MAXMODEPARAMS)) { while (queued) { --- 647,651 ---- for (i=0; i<count; i++) { ! len = strlen(UPROTO(list[i])->numeric); if ((start < queued+3+len) || (queued >= MAXMODEPARAMS)) { while (queued) { *************** *** 659,663 **** } start -= len; ! memcpy(buffer+start, list[i]->proto->numeric, len); buffer[--start] = ' '; queued++; --- 658,662 ---- } start -= len; ! memcpy(buffer+start, UPROTO(list[i])->numeric, len); buffer[--start] = ' '; queued++; *************** *** 700,708 **** case 'o': user = va_arg(args, struct userNode *); ! arg_text = user->proto->numeric; goto add_arg; case 'v': user = va_arg(args, struct userNode *); ! arg_text = user->proto->numeric; goto add_arg; case 'b': --- 699,707 ---- case 'o': user = va_arg(args, struct userNode *); ! arg_text = UPROTO(user)->numeric; goto add_arg; case 'v': user = va_arg(args, struct userNode *); ! arg_text = UPROTO(user)->numeric; goto add_arg; case 'b': *************** *** 802,807 **** } n = base64toint(numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); ! un = GetServerN(numeric)->proto->users[n]; ! if (!(un = s->proto->users[n])) { log(DEBUG_LOG, LOG_WARNING, "GetUserN(%s) couldn't find user!\n", numeric); } --- 801,806 ---- } n = base64toint(numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); ! un = SPROTO(s)->users[n]; ! if (!(un = SPROTO(s)->users[n])) { log(DEBUG_LOG, LOG_WARNING, "GetUserN(%s) couldn't find user!\n", numeric); } *************** *** 844,850 **** /* burst local nicks */ ! for (i=0; i<ArrayLength(self->proto->users); i++) { ! if (!self->proto->users[i]) continue; ! irc_user(self->proto->users[i]); } --- 843,849 ---- /* burst local nicks */ ! for (i=0; i<ArrayLength(SPROTO(self)->users); i++) { ! if (!SPROTO(self)->users[i]) continue; ! irc_user(SPROTO(self)->users[i]); } *************** *** 902,909 **** { struct server *new_server; new_server = AddServer(uplink, name, hops, boot, link, description); servers_num[base64toint(numeric, SERVER_NUMERIC_LEN)] = new_server; ! new_server->proto = calloc(1, sizeof(*new_server->proto)); ! safestrncpy(new_server->proto->numeric, numeric, sizeof(new_server->proto->numeric)); return new_server; } --- 901,911 ---- { struct server *new_server; + struct serverNode_proto *sproto; + new_server = AddServer(uplink, name, hops, boot, link, description); servers_num[base64toint(numeric, SERVER_NUMERIC_LEN)] = new_server; ! sproto = calloc(1, sizeof(*sproto)); ! safestrncpy(sproto->numeric, numeric, sizeof(sproto->numeric)); ! put_note(&new_server->notes, sproto_note_id, sproto); return new_server; } *************** *** 1081,1089 **** if (uNode) { unsigned long num_local; ! uNode->proto = calloc(1, sizeof(*uNode->proto)); ! safestrncpy(uNode->proto->numeric, numeric, sizeof(uNode->proto->numeric)); uNode->ip = base64toint(realip, 6); num_local = base64toint(numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); ! GetServerN(numeric)->proto->users[num_local] = uNode; if (uplink == self) irc_user(uNode); } else { --- 1083,1094 ---- if (uNode) { unsigned long num_local; ! struct userNode_proto *uproto; ! ! uproto = calloc(1, sizeof(*uproto)); ! safestrncpy(uproto->numeric, numeric, sizeof(uproto->numeric)); ! put_note(&uNode->notes, uproto_note_id, uproto); uNode->ip = base64toint(realip, 6); num_local = base64toint(numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); ! SPROTO(GetServerN(numeric))->users[num_local] = uNode; if (uplink == self) irc_user(uNode); } else { *************** *** 1093,1097 **** * comparisons. If this other user is +k, then somebody * screwed up. */ ! sprintf(kill, "%s KILL %s :%s (Nick collision.)", self->proto->numeric, numeric, self->name); irc_raw(kill); } --- 1098,1102 ---- * comparisons. If this other user is +k, then somebody * screwed up. */ ! sprintf(kill, "%s KILL %s :%s (Nick collision.)", SPROTO(self)->numeric, numeric, self->name); irc_raw(kill); } *************** *** 1104,1108 **** unsigned int last = next_numeric; do { ! if (!self->proto->users[next_numeric++]) { if (next_numeric > highest_numeric) { highest_numeric = next_numeric; --- 1109,1113 ---- unsigned int last = next_numeric; do { ! if (!SPROTO(self)->users[next_numeric++]) { if (next_numeric > highest_numeric) { highest_numeric = next_numeric; *************** *** 1121,1125 **** int local_num; if ((local_num = get_local_numeric()) == -1) return NULL; ! safestrncpy(numeric, self->proto->numeric, SERVER_NUMERIC_LEN+1); inttobase64(numeric+SERVER_NUMERIC_LEN, local_num, USER_NUMERIC_LEN); numeric[COMBO_NUMERIC_LEN] = 0; --- 1126,1130 ---- int local_num; if ((local_num = get_local_numeric()) == -1) return NULL; ! safestrncpy(numeric, SPROTO(self)->numeric, SERVER_NUMERIC_LEN+1); inttobase64(numeric+SERVER_NUMERIC_LEN, local_num, USER_NUMERIC_LEN); numeric[COMBO_NUMERIC_LEN] = 0; *************** *** 1439,1443 **** */ if (user) { ! DelUser(user, NULL, false, argv[2]); } return 1; --- 1444,1448 ---- */ if (user) { ! DelUser(user, NULL, 0, argv[2]); } return 1; *************** *** 1459,1463 **** } ! DelUser(user, NULL, false, argv[2]); return 1; } --- 1464,1468 ---- } ! DelUser(user, NULL, 0, argv[2]); return 1; } *************** *** 1501,1505 **** part_helper(struct chanNode *cn, void *data) { ! DelChannelUser(data, cn, false, 0); } --- 1506,1510 ---- part_helper(struct chanNode *cn, void *data) { ! DelChannelUser(data, cn, 0, 0); } *************** *** 1574,1578 **** { struct privmsg_desc *pd = data; ! int num = base64toint(un->proto->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); if (!pd->is_notice) { if (privmsg_funcs[num]) { --- 1579,1583 ---- { struct privmsg_desc *pd = data; ! int num = base64toint(UPROTO(un)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); if (!pd->is_notice) { if (privmsg_funcs[num]) { *************** *** 1652,1656 **** ircu_del_user(struct userNode *user) { ! user->uplink->proto->users[base64toint(user->proto->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN)] = NULL; } --- 1657,1661 ---- ircu_del_user(struct userNode *user) { ! SPROTO(user->uplink)->users[base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN)] = NULL; } *************** *** 1661,1675 **** /* clean up server's user hash tables */ for (i=0; i<USERARRAYSIZE; i++) { ! if (srv->proto->users[i]) { ! DelUser(srv->proto->users[i], NULL, false, "Server delinked"); ! srv->proto->users[i] = NULL; } } /* delete from servers_num array */ ! servers_num[base64toint(srv->proto->numeric, SERVER_NUMERIC_LEN)] = NULL; } ! void ! init_proto(void) { extern time_t boot_time; --- 1666,1679 ---- /* clean up server's user hash tables */ for (i=0; i<USERARRAYSIZE; i++) { ! if (SPROTO(srv)->users[i]) { ! DelUser(SPROTO(srv)->users[i], NULL, 0, "Server delinked"); ! SPROTO(srv)->users[i] = NULL; } } /* delete from servers_num array */ ! servers_num[base64toint(SPROTO(srv)->numeric, SERVER_NUMERIC_LEN)] = NULL; } ! LIB_LOAD_FUNC(mod_init) { extern time_t boot_time; *************** *** 1677,1680 **** --- 1681,1689 ---- char numer[COMBO_NUMERIC_LEN+1]; + /* Register things with module registry */ + proto_module = module_register("proto", MAKE_VERSION(0, 0, 0), NULL, lib); + uproto_note_id = note_register_module("struct userNode", proto_module); + sproto_note_id = note_register_module("struct server", proto_module); + /* initialize data structures */ for (i=0; i<ArrayLength(servers_num); i++) { *************** *** 1781,1784 **** --- 1790,1794 ---- /* register exit functions */ reg_exit_func(free_parse_misc); + return 0; } *************** *** 1790,1794 **** static cmd_func_t *func; ! argc = split_line(line, true, MAXNUMPARAMS, argv); cmd_arg = self->uplink ? 1 : 0; func = dict_find(irc_func_dict, argv[cmd_arg], NULL); --- 1800,1804 ---- static cmd_func_t *func; ! argc = split_line(line, 1, MAXNUMPARAMS, argv); cmd_arg = self->uplink ? 1 : 0; func = dict_find(irc_func_dict, argv[cmd_arg], NULL); *************** *** 1804,1808 **** reg_privmsg_func(struct userNode *user, privmsg_func_t handler) { ! unsigned long numeric = base64toint(user->proto->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); if (numeric > num_privmsg_funcs) { int newnum = numeric + 8; --- 1814,1818 ---- reg_privmsg_func(struct userNode *user, privmsg_func_t handler) { ! unsigned long numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); if (numeric > num_privmsg_funcs) { int newnum = numeric + 8; *************** *** 1820,1824 **** reg_notice_func(struct userNode *user, privmsg_func_t handler) { ! unsigned int numeric = base64toint(user->proto->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); if (numeric > num_notice_funcs) { int newnum = numeric + 8; --- 1830,1834 ---- reg_notice_func(struct userNode *user, privmsg_func_t handler) { ! unsigned int numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); if (numeric > num_notice_funcs) { int newnum = numeric + 8; Index: proto_bahamut.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** proto_bahamut.c 2001/09/22 16:12:54 1.12 --- proto_bahamut.c 2001/09/27 21:58:07 1.13 *************** *** 54,61 **** --- 54,64 ---- #include "hash.h" #include "log.h" + #include "modules.h" + #define PROTO_FUNC_TYPE 1 #include "proto.h" #include "timeq.h" #include "tools.h" #include "uplink.h" + #include "proto_bahamut.h" /************************************/ *************** *** 68,74 **** typedef void (*foreach_nonuser) (char *name, void *data); - extern new_channel_func_t *ncf_list; - extern unsigned int ncf_size, ncf_used; extern int ping_freq, ping_timeout; static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); --- 71,76 ---- typedef void (*foreach_nonuser) (char *name, void *data); extern int ping_freq, ping_timeout; + static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); *************** *** 103,114 **** --- 105,122 ---- } uplink; + static struct module *proto_module; + struct userNode_proto { privmsg_func_t privmsg_func; privmsg_func_t notice_func; }; + static unsigned int uproto_note_id; + #define UPROTO(USER) ((struct userNode_proto*)get_note(&(USER)->notes, uproto_note_id)) struct serverNode_proto { dict_t clients; }; + static unsigned int sproto_note_id; + #define SPROTO(SERVER) ((struct serverNode_proto*)get_note(&(SERVER)->notes, sproto_note_id)) /********************/ *************** *** 198,202 **** } ! void irc_uptime(struct userNode *user) { --- 206,210 ---- } ! static void irc_uptime(struct userNode *user) { *************** *** 209,213 **** } ! void irc_whois(struct userNode *from, struct userNode *who) { --- 217,221 ---- } ! static void irc_whois(struct userNode *from, struct userNode *who) { *************** *** 253,259 **** putsock("%s %s %d :%s", CMD_SQUIT, self->name, 0, message); ! if (srv == self->uplink) { ! close_socket(); ! } } --- 261,265 ---- putsock("%s %s %d :%s", CMD_SQUIT, self->name, 0, message); ! if (srv == self->uplink) close_socket(); } *************** *** 270,274 **** } ! void irc_ping(const char *something) { --- 276,280 ---- } ! static void irc_ping(const char *something) { *************** *** 276,280 **** } ! void irc_pong(const char *data) { --- 282,286 ---- } ! static void irc_pong(const char *data) { *************** *** 282,286 **** } ! void irc_pass(const char *passwd) { --- 288,292 ---- } ! static void irc_pass(const char *passwd) { *************** *** 592,597 **** bahamut_new_server(struct server *server) { ! server->proto = calloc(1, sizeof(*server->proto)); ! server->proto->clients = dict_new(); } --- 598,605 ---- bahamut_new_server(struct server *server) { ! struct serverNode_proto *pserver; ! pserver = calloc(1, sizeof(*pserver)); ! pserver->clients = dict_new(); ! put_note(&server->notes, sproto_note_id, pserver); } *************** *** 601,606 **** struct userNode *user = data; (void)key; (void)extra; ! printf("in bahamut_del_server_client(\"%s\", ....)\n", key); ! DelUser(user, NULL, false, "Server delinked"); return 0; } --- 609,613 ---- struct userNode *user = data; (void)key; (void)extra; ! DelUser(user, NULL, 0, "Server delinked"); return 0; } *************** *** 609,615 **** bahamut_del_server(struct server *server) { ! printf("in bahamut_del_server(\"%s\")\n", server->name); ! dict_foreach(server->proto->clients, bahamut_del_server_client, NULL); ! dict_delete(server->proto->clients); } --- 616,621 ---- bahamut_del_server(struct server *server) { ! dict_foreach(SPROTO(server)->clients, bahamut_del_server_client, NULL); ! dict_delete(SPROTO(server)->clients); } *************** *** 617,621 **** bahamut_new_user(struct userNode *user) { ! dict_insert(user->uplink->proto->clients, user->nick, user); return 0; } --- 623,627 ---- bahamut_new_user(struct userNode *user) { ! dict_insert(SPROTO(user->uplink)->clients, user->nick, user); return 0; } *************** *** 627,631 **** bahamut_del_user(struct userNode *user) { ! dict_remove(user->uplink->proto->clients, user->nick); } --- 633,637 ---- bahamut_del_user(struct userNode *user) { ! dict_remove(SPROTO(user->uplink)->clients, user->nick); } *************** *** 686,690 **** /* burst local nicks */ ! dict_foreach(self->proto->clients, burst_send_nick, 0); } --- 692,696 ---- /* burst local nicks */ ! dict_foreach(SPROTO(self)->clients, burst_send_nick, 0); } *************** *** 723,734 **** { struct privmsg_desc *pd = data; ! if (!un->proto) return; if (!pd->is_notice) { ! if (un->proto->privmsg_func) { ! un->proto->privmsg_func(un, pd->user, pd->text); } } else { ! if (un->proto->notice_func) { ! un->proto->notice_func(un, pd->user, pd->text); } } --- 729,741 ---- { struct privmsg_desc *pd = data; ! struct userNode_proto *uproto = UPROTO(un); ! if (!uproto) return; if (!pd->is_notice) { ! if (uproto->privmsg_func) { ! uproto->privmsg_func(un, pd->user, pd->text); } } else { ! if (uproto->notice_func) { ! uproto->notice_func(un, pd->user, pd->text); } } *************** *** 1088,1092 **** /* Sometimes we get a KILL then a QUIT or the like, so we don't want to * call DelUser unless we have the user in our grasp. */ ! if (user) DelUser(user, NULL, false, argv[1]); return 1; } --- 1095,1099 ---- /* Sometimes we get a KILL then a QUIT or the like, so we don't want to * call DelUser unless we have the user in our grasp. */ ! if (user) DelUser(user, NULL, 0, argv[1]); return 1; } *************** *** 1273,1277 **** } ! DelUser(user, NULL, false, argv[2]); return 1; } --- 1280,1284 ---- } ! DelUser(user, NULL, 0, argv[2]); return 1; } *************** *** 1315,1319 **** part_helper(struct chanNode *cn, void *data) { ! DelChannelUser(data, cn, false, 0); } --- 1322,1326 ---- part_helper(struct chanNode *cn, void *data) { ! DelChannelUser(data, cn, 0, 0); } *************** *** 1394,1402 **** } ! void ! init_proto(void) { extern time_t boot_time; /* set up command dictionary */ irc_func_dict = dict_new(); --- 1401,1412 ---- } ! LIB_LOAD_FUNC(mod_init) { extern time_t boot_time; + /* Register things with module registry */ + proto_module = module_register("proto", MAKE_VERSION(0, 0, 0), NULL, lib); + uproto_note_id = note_register_module("struct userNode", proto_module); + sproto_note_id = note_register_module("struct server", proto_module); /* set up command dictionary */ irc_func_dict = dict_new(); *************** *** 1459,1462 **** --- 1469,1473 ---- /* create self server */ self = AddServer(NULL, conf_server_name(), 0, boot_time, now, conf_server_desc()); + return 0; }; *************** *** 1469,1473 **** cmd_arg = (*line == ':') ? 1 : 0; ! argc = split_line(line, true, ArrayLength(argv)-cmd_arg, argv+1-cmd_arg); argv[0] = (cmd_arg == 0) ? NULL : (argv[0]+1); func = dict_find(irc_func_dict, argv[1], NULL); --- 1480,1484 ---- cmd_arg = (*line == ':') ? 1 : 0; ! argc = split_line(line, 1, ArrayLength(argv)-cmd_arg, argv+1-cmd_arg); argv[0] = (cmd_arg == 0) ? NULL : (argv[0]+1); func = dict_find(irc_func_dict, argv[1], NULL); *************** *** 1483,1488 **** reg_privmsg_func(struct userNode *user, privmsg_func_t handler) { ! if (!user->proto) user->proto = calloc(1, sizeof(*user->proto)); ! user->proto->privmsg_func = handler; } --- 1494,1503 ---- reg_privmsg_func(struct userNode *user, privmsg_func_t handler) { ! struct userNode_proto *uproto = UPROTO(user); ! if (!uproto) { ! uproto = calloc(1, sizeof(*uproto)); ! put_note(&user->notes, uproto_note_id, uproto); ! } ! uproto->privmsg_func = handler; } *************** *** 1490,1495 **** reg_notice_func(struct userNode *user, privmsg_func_t handler) { ! if (!user->proto) user->proto = calloc(1, sizeof(*user->proto)); ! user->proto->notice_func = handler; } --- 1505,1514 ---- reg_notice_func(struct userNode *user, privmsg_func_t handler) { ! struct userNode_proto *uproto = UPROTO(user); ! if (!uproto) { ! uproto = calloc(1, sizeof(*uproto)); ! put_note(&user->notes, uproto_note_id, uproto); ! } ! uproto->notice_func = handler; } Index: proto.h =================================================================== RCS file: /cvsroot/srvx/services/src/proto.h,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** proto.h 2001/09/22 16:12:54 1.42 --- proto.h 2001/09/27 21:58:07 1.43 *************** *** 22,28 **** #define PROTO_H ! #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> - #endif #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> --- 22,27 ---- #define PROTO_H ! #include <stdarg.h> #include <sys/types.h> #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> *************** *** 45,123 **** #define MODE_CHANGE_BAN 0x008 - #include PROTO_INCLUDE - - #ifndef PROTO_HAS_NUMERIC - #define PROTO_HAS_NUMERIC 0 - #endif - - #ifndef MAXLEN #define MAXLEN 512 - #endif - - #ifndef MAXNUMPARAMS #define MAXNUMPARAMS 200 - #endif - - #ifndef MAXBANS #define MAXBANS 30 ! #endif - #ifndef MAXMODEPARAMS - #define MAXMODEPARAMS MAXNUMPARAMS - #endif - - #ifndef PROTO_MODENODE_MODE_CHARS - #define PROTO_MODENODE_MODE_CHARS "" - #endif - - #ifndef PROTO_CHANNEL_MODE_CHARS - #define PROTO_CHANNEL_MODE_CHARS "" - #endif - - #ifndef PROTO_USER_MODE_CHARS - #define PROTO_USER_MODE_CHARS "" - #endif - - #ifndef CHANSERV_JOINS_CHANNELS - #define CHANSERV_JOINS_CHANNELS 1 - #endif - /********************/ /* PROTOCOL SPEWING */ /********************/ /* connection maintenance */ ! void irc_server(struct server *srv); ! void irc_uptime(struct userNode *user); ! void irc_whois(struct userNode *from, struct userNode *who); ! void irc_user(struct userNode *user); ! void irc_nick(struct userNode *user); ! void irc_pass(const char *passwd); ! void irc_introduce(const char *passwd); ! void irc_ping(const char *something); ! void irc_pong(const char *data); ! void irc_quit(struct userNode *user, const char *message); ! void irc_squit(struct server *srv, const char *message); /* messages */ ! void irc_privmsg(struct userNode *from, const char *to, const char *message); ! void irc_notice(struct userNode *from, const char *to, const char *message); /* channel maintenance */ ! void irc_join(struct userNode *who, struct chanNode *what); ! void irc_invite(struct userNode *from, struct userNode *who, struct chanNode *to); ! void irc_mode(struct userNode *from, struct chanNode *target, const char *modes); ! void irc_kick(struct userNode *actor, struct userNode *who, struct chanNode *from, const char *msg); ! void irc_part(struct userNode *who, struct chanNode *what, const char *reason); ! void irc_topic(struct userNode *who, struct chanNode *what, const char *topic); ! void irc_fetchtopic(struct userNode *from, struct chanNode *what); /* network maintenance */ ! void irc_gline(const char *host, unsigned long duration, const char *message); ! void irc_ungline(const char *mask); ! void irc_error(const char *to, const char *message); ! void irc_kill(struct userNode *from, struct userNode *target, const char *message); ! void irc_raw(const char *what); ! void irc_stats(struct userNode *from, struct server *target, char type); /********************/ --- 44,101 ---- #define MODE_CHANGE_BAN 0x008 #define MAXLEN 512 #define MAXNUMPARAMS 200 #define MAXBANS 30 ! #define MAXMODEPARAMS 6 ! #define MIN_LINE_SIZE 40 ! #define MAX_LINE_SIZE 450 ! ! typedef char *(*expand_func_t)(const char *variable); ! int send_message(struct userNode *dest, struct userNode *src, const char *format, ...); ! void proto_init(void); /********************/ /* PROTOCOL SPEWING */ /********************/ + #if PROTO_FUNC_TYPE == 1 + /* For protocol modules */ + #define PROTO_FUNC(retval, name) retval name + #elif PROTO_FUNC_TYPE == 2 + /* For proto.c, the generic binder */ + #define PROTO_FUNC(retval, name) retval (*name) + #else + /* For other files */ + #define PROTO_FUNC(retval, name) extern retval (*name) + #endif + /* connection maintenance */ ! PROTO_FUNC(void, irc_server)(struct server *srv); ! PROTO_FUNC(void, irc_user)(struct userNode *user); ! PROTO_FUNC(void, irc_nick)(struct userNode *user); ! PROTO_FUNC(void, irc_introduce)(const char *passwd); ! PROTO_FUNC(void, irc_quit)(struct userNode *user, const char *message); ! PROTO_FUNC(void, irc_squit)(struct server *srv, const char *message); /* messages */ ! PROTO_FUNC(void, irc_privmsg)(struct userNode *from, const char *to, const char *message); ! PROTO_FUNC(void, irc_notice)(struct userNode *from, const char *to, const char *message); /* channel maintenance */ ! PROTO_FUNC(void, irc_join)(struct userNode *who, struct chanNode *what); ! PROTO_FUNC(void, irc_invite)(struct userNode *from, struct userNode *who, struct chanNode *to); ! PROTO_FUNC(void, irc_mode)(struct userNode *from, struct chanNode *target, const char *modes); ! PROTO_FUNC(void, irc_kick)(struct userNode *actor, struct userNode *who, struct chanNode *from, const char *msg); ! PROTO_FUNC(void, irc_part)(struct userNode *who, struct chanNode *what, const char *reason); ! PROTO_FUNC(void, irc_topic)(struct userNode *who, struct chanNode *what, const char *topic); ! PROTO_FUNC(void, irc_fetchtopic)(struct userNode *from, struct chanNode *what); /* network maintenance */ ! PROTO_FUNC(void, irc_gline)(const char *host, unsigned long duration, const char *message); ! PROTO_FUNC(void, irc_ungline)(const char *mask); ! PROTO_FUNC(void, irc_error)(const char *to, const char *message); ! PROTO_FUNC(void, irc_kill)(struct userNode *from, struct userNode *target, const char *message); ! PROTO_FUNC(void, irc_raw)(const char *what); ! PROTO_FUNC(void, irc_stats)(struct userNode *from, struct server *target, char type); /********************/ *************** *** 125,151 **** /********************/ ! void reg_chanmsg_func(unsigned char prefix, struct userNode *service, chanmsg_func_t handler); ! void reg_privmsg_func(struct userNode *user, privmsg_func_t handler); ! void reg_notice_func(struct userNode *user, privmsg_func_t handler); ! void reg_mode_change_func(mode_change_func_t handler); - int parse_line(unsigned char *line); - /**********************/ /* MISCELLANEOUS GUNK */ /**********************/ ! void init_proto(void); ! struct userNode *add_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp); ! /* These next three functions could almost be put in hash.c, ! * since they are very similar for each protocol. However, ! * it would require exposing the innards of the per-protocol ! * fooNode_proto structs to hash.c, and I don't want to do ! * that. (In particular, ircu_p10 needs to know the numeric ! * when changing chanmode for a user.) ! */ ! void chan_apply_bans(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, char **list); ! void chan_apply_mode(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, struct userNode **list); ! void irc_change_channel_modes(struct chanNode *channel, struct userNode *source, const unsigned char *modes, va_list args); #endif /* !defined(PROTO_H) */ --- 103,122 ---- /********************/ ! PROTO_FUNC(void, reg_chanmsg_func)(unsigned char prefix, struct userNode *service, chanmsg_func_t handler); ! PROTO_FUNC(void, reg_privmsg_func)(struct userNode *user, privmsg_func_t handler); ! PROTO_FUNC(void, reg_notice_func)(struct userNode *user, privmsg_func_t handler); ! PROTO_FUNC(void, reg_mode_change_func)(mode_change_func_t handler); ! PROTO_FUNC(int, parse_line)(unsigned char *line); /**********************/ /* MISCELLANEOUS GUNK */ /**********************/ + + PROTO_FUNC(struct userNode*, add_local_user)(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp); + PROTO_FUNC(void, chan_apply_bans)(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, char **list); + PROTO_FUNC(void, chan_apply_mode)(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, struct userNode **list); + PROTO_FUNC(void, irc_change_channel_modes)(struct chanNode *channel, struct userNode *source, const unsigned char *modes, va_list args); ! #undef PROTO_FUNC #endif /* !defined(PROTO_H) */ Index: policer.h =================================================================== RCS file: /cvsroot/srvx/services/src/policer.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** policer.h 2001/03/30 21:20:10 1.5 --- policer.h 2001/09/27 21:58:07 1.6 *************** *** 41,44 **** --- 41,46 ---- int policer_conforms(struct policer *pol, policer_time_t reqtime, double weight); void policer_delete(struct policer *pol); + /* For use with dict_foreach() and dicts containing policer params */ + int set_policer_param(const char *param, void *data, void *extra); #endif /* ndef POLICER_H */ Index: policer.c =================================================================== RCS file: /cvsroot/srvx/services/src/policer.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** policer.c 2001/03/30 21:20:10 1.12 --- policer.c 2001/09/27 21:58:07 1.13 *************** *** 28,31 **** --- 28,32 ---- #include "common.h" + #include "recdb.h" #include "policer.h" *************** *** 89,91 **** --- 90,101 ---- { free(pol); + } + + int + set_policer_param(const char *param, void *data, void *extra) + { + struct record_data *rd = data; + const char *str = GET_RECORD_QSTRING(rd); + if (str) policer_params_set(extra, param, str); + return 0; } Index: opserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/opserv.c,v retrieving revision 1.212 retrieving revision 1.213 diff -C2 -r1.212 -r1.213 *** opserv.c 2001/09/22 16:12:54 1.212 --- opserv.c 2001/09/27 21:58:07 1.213 *************** *** 388,394 **** const char *OSMSG_VERSION_ID = "$Id$"; ! #define opserv_notice(target, format...) send_message(target , opserv , ## format) ! #define opserv_debug(format...) do { if (opserv_conf.debug_channel) send_channel_notice(opserv_conf.debug_channel , opserv, ## format); } while (0) ! #define opserv_alert(format...) do { if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel , opserv, ## format); } while (0) /* This function is called when a channel command (or --- 388,394 ---- const char *OSMSG_VERSION_ID = "$Id$"; ! #define opserv_notice(target, format...) send_message(target, opserv , ## format) ! #define opserv_debug(format...) do { if (opserv_conf.debug_channel) send_target_message(0, opserv_conf.debug_channel, opserv , ## format); } while (0) ! #define opserv_alert(format...) do { if (opserv_conf.alert_channel) send_target_message(0, opserv_conf.alert_channel, opserv , ## format); } while (0) /* This function is called when a channel command (or *************** *** 421,425 **** argv_shift = 1; ! argc = split_line(text, false, ArrayLength(argv)-argv_shift, argv+argv_shift); if(!argc) return; --- 421,425 ---- argv_shift = 1; ! argc = split_line(text, 0, ArrayLength(argv)-argv_shift, argv+argv_shift); if(!argc) return; *************** *** 510,514 **** { char *mask; ! OPSERV_MIN_PARMS(2, true); mask = argv[1]; if (!is_ircmask(mask)) { --- 510,514 ---- { char *mask; ! OPSERV_MIN_PARMS(2, 1); mask = argv[1]; if (!is_ircmask(mask)) { *************** *** 593,597 **** char *reason, *message; ! OPSERV_MIN_PARMS(2, false); if (argv[-1] && IsChannelName(argv[-1])) { --- 593,597 ---- char *reason, *message; ! OPSERV_MIN_PARMS(2, 0); if (argv[-1] && IsChannelName(argv[-1])) { *************** *** 627,631 **** /* This was 1 originally...but that doesn't seem right. */ ! OPSERV_MIN_PARMS(2, false); if (argv[-1] && IsChannelName(argv[-1])) { --- 627,631 ---- /* This was 1 originally...but that doesn't seem right. */ ! OPSERV_MIN_PARMS(2, 0); if (argv[-1] && IsChannelName(argv[-1])) { *************** *** 689,693 **** unsigned int count, next; ! OPSERV_MIN_PARMS(2, true); for (count=0, next=1; next<argc; next++) { if (!(list[count] = GetUser(argv[next]))) continue; --- 689,693 ---- unsigned int count, next; ! OPSERV_MIN_PARMS(2, 1); for (count=0, next=1; next<argc; next++) { if (!(list[count] = GetUser(argv[next]))) continue; *************** *** 770,774 **** void uplink_select(char *name); ! OPSERV_MIN_PARMS(2, false); unsplit_string(argv+1, argc-1); --- 770,774 ---- void uplink_select(char *name); ! OPSERV_MIN_PARMS(2, 0); unsplit_string(argv+1, argc-1); *************** *** 786,790 **** char *reason; ! OPSERV_MIN_PARMS(2, false); unsplit_string(argv+1, argc-1); --- 786,790 ---- char *reason; ! OPSERV_MIN_PARMS(2, 0); unsplit_string(argv+1, argc-1); *************** *** 804,808 **** char **restart_argv, *reason; ! OPSERV_MIN_PARMS(2, false); unsplit_string(argv+1, argc-1); --- 804,808 ---- char **restart_argv, *reason; ! OPSERV_MIN_PARMS(2, 0); unsplit_string(argv+1, argc-1); *************** *** 846,850 **** struct userNode *target; (void)channel; /* irrelevant to this command */ ! OPSERV_MIN_PARMS(2, false); target = GetUser(argv[1]); if (!target) { --- 846,850 ---- struct userNode *target; (void)channel; /* irrelevant to this command */ ! OPSERV_MIN_PARMS(2, 0); target = GetUser(argv[1]); if (!target) { *************** *** 869,873 **** { unsigned long duration; ! OPSERV_MIN_PARMS(4, false); unsplit_string(argv+3, argc-3); --- 869,873 ---- { unsigned long duration; ! OPSERV_MIN_PARMS(4, 0); unsplit_string(argv+3, argc-3); *************** *** 889,893 **** static OPSERV_FUNC(cmd_ungline) { ! OPSERV_MIN_PARMS(2, false); gline_remove(argv[1], 1); opserv_notice(user, OSMSG_GLINE_REMOVED, argv[1]); --- 889,893 ---- static OPSERV_FUNC(cmd_ungline) { ! OPSERV_MIN_PARMS(2, 0); gline_remove(argv[1], 1); opserv_notice(user, OSMSG_GLINE_REMOVED, argv[1]); *************** *** 980,984 **** struct userNode *target; ! OPSERV_MIN_PARMS(2, false); target = GetUser(argv[1]); if (!target) { --- 980,984 ---- struct userNode *target; ! OPSERV_MIN_PARMS(2, 0); target = GetUser(argv[1]); if (!target) { *************** *** 995,999 **** char *reason; ! OPSERV_MIN_PARMS(2, true); if (argc < 3) { reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); --- 995,999 ---- char *reason; ! OPSERV_MIN_PARMS(2, 1); if (argc < 3) { reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); *************** *** 1050,1054 **** char *mask; ! OPSERV_MIN_PARMS(2, true); if (argc == 2) { reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); --- 1050,1054 ---- char *mask; ! OPSERV_MIN_PARMS(2, 1); if (argc == 2) { reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); *************** *** 1139,1143 **** static OPSERV_FUNC(cmd_mode) { ! OPSERV_MIN_PARMS(2, true); unsplit_string(argv+1, argc-1); if (channel->key[0]) ChangeChannelModes(channel, opserv, "-k", channel->key); --- 1139,1143 ---- static OPSERV_FUNC(cmd_mode) { ! OPSERV_MIN_PARMS(2, 1); unsplit_string(argv+1, argc-1); if (channel->key[0]) ChangeChannelModes(channel, opserv, "-k", channel->key); *************** *** 1152,1156 **** struct userNode *target; char *usermask; ! OPSERV_MIN_PARMS(2, true); target = GetUser(argv[1]); if (!target) { --- 1152,1156 ---- struct userNode *target; char *usermask; ! OPSERV_MIN_PARMS(2, 1); target = GetUser(argv[1]); if (!target) { *************** *** 1171,1175 **** unsigned int count, next; ! OPSERV_MIN_PARMS(2, true); for (count=0, next=1; next<argc; next++) { if (!(list[count] = GetUser(argv[next]))) continue; --- 1171,1175 ---- unsigned int count, next; ! OPSERV_MIN_PARMS(2, 1); for (count=0, next=1; next<argc; next++) { if (!(list[count] = GetUser(argv[next]))) continue; *************** *** 1219,1223 **** char buffer[128]; ! OPSERV_MIN_PARMS(2, false); target = GetUser(argv[1]); if (!target) { --- 1219,1223 ---- char buffer[128]; ! OPSERV_MIN_PARMS(2, 0); target = GetUser(argv[1]); if (!target) { *************** *** 1248,1252 **** static OPSERV_FUNC(cmd_unban) { ! OPSERV_MIN_PARMS(2, true); DelChannelBan(argc-1, (char**)argv+1, channel, opserv, 1); opserv_notice(user, OSMSG_UNBAN_DONE, channel->name); --- 1248,1252 ---- static OPSERV_FUNC(cmd_unban) { ! OPSERV_MIN_PARMS(2, 1); DelChannelBan(argc-1, (char**)argv+1, channel, opserv, 1); opserv_notice(user, OSMSG_UNBAN_DONE, channel->name); *************** *** 1300,1304 **** int level; ! OPSERV_MIN_PARMS(3, false); unsplit_string(argv+1, argc-2); --- 1300,1304 ---- int level; ! OPSERV_MIN_PARMS(3, 0); unsplit_string(argv+1, argc-2); *************** *** 1318,1322 **** struct opserv_cmd *cmd; ! OPSERV_MIN_PARMS(2, false); unsplit_string(argv+1, argc-1); --- 1318,1322 ---- struct opserv_cmd *cmd; ! OPSERV_MIN_PARMS(2, 0); unsplit_string(argv+1, argc-1); *************** *** 1335,1339 **** struct opserv_cmd *cmd; ! OPSERV_MIN_PARMS(2, false); cmd = dict_find(opserv_func_dict, argv[1], NULL); if (!cmd) { --- 1335,1339 ---- struct opserv_cmd *cmd; ! OPSERV_MIN_PARMS(2, 0); cmd = dict_find(opserv_func_dict, argv[1], NULL); if (!cmd) { *************** *** 1350,1354 **** struct opserv_cmd *cmd; ! OPSERV_MIN_PARMS(2, false); cmd = dict_find(opserv_func_dict, argv[1], NULL); if (!cmd) { --- 1350,1354 ---- struct opserv_cmd *cmd; ! OPSERV_MIN_PARMS(2, 0); cmd = dict_find(opserv_func_dict, argv[1], NULL); if (!cmd) { *************** *** 1590,1594 **** static OPSERV_FUNC(cmd_stats) { ! OPSERV_MIN_PARMS(2, false); if (!strcasecmp(argv[1], "bad")) cmd_stats_bad(user); else if (!strcasecmp(argv[1], "glines")) cmd_stats_glines(user); --- 1590,1594 ---- static OPSERV_FUNC(cmd_stats) { ! OPSERV_MIN_PARMS(2, 0); if (!strcasecmp(argv[1], "bad")) cmd_stats_bad(user); else if (!strcasecmp(argv[1], "glines")) cmd_stats_glines(user); *************** *** 1617,1621 **** unsigned long addr; ! OPSERV_MIN_PARMS(2, false); for (n=1; n<argc; n++) { struct userNode *un = GetUser(argv[n]); --- 1617,1621 ---- unsigned long addr; ! OPSERV_MIN_PARMS(2, 0); for (n=1; n<argc; n++) { struct userNode *un = GetUser(argv[n]); *************** *** 1641,1645 **** unsigned int n, i; ! OPSERV_MIN_PARMS(2, false); for (n=1; n<argc; n++) { --- 1641,1645 ---- unsigned int n, i; ! OPSERV_MIN_PARMS(2, 0); for (n=1; n<argc; n++) { *************** *** 1665,1669 **** { char *linedup; ! OPSERV_MIN_PARMS(2, false); unsplit_string(argv+1, argc-1); --- 1665,1669 ---- { char *linedup; ! OPSERV_MIN_PARMS(2, 0); unsplit_string(argv+1, argc-1); *************** *** 1683,1687 **** { char *linedup; ! OPSERV_MIN_PARMS(2, false); unsplit_string(argv+1, argc-1); --- 1683,1687 ---- { char *linedup; ! OPSERV_MIN_PARMS(2, 0); unsplit_string(argv+1, argc-1); *************** *** 1711,1715 **** return NULL; } ! DelUser(resv, opserv, true, OSMSG_NICK_RESERVED); } resv = AddClone(nick, username, host, desc); --- 1711,1715 ---- return NULL; } ! DelUser(resv, opserv, 1, OSMSG_NICK_RESERVED); } resv = AddClone(nick, username, host, desc); *************** *** 1722,1726 **** struct userNode *resv; ! OPSERV_MIN_PARMS(5, false); unsplit_string(argv+4, argc-4); --- 1722,1726 ---- struct userNode *resv; ! OPSERV_MIN_PARMS(5, 0); unsplit_string(argv+4, argc-4); *************** *** 1738,1742 **** struct userNode *resv; ! OPSERV_MIN_PARMS(5, false); unsplit_string(argv+4, argc-4); --- 1738,1742 ---- struct userNode *resv; ! OPSERV_MIN_PARMS(5, 0); unsplit_string(argv+4, argc-4); *************** *** 1753,1757 **** static OPSERV_FUNC(cmd_unreserve) { ! OPSERV_MIN_PARMS(2, false); if (dict_remove(opserv_reserved_nick_dict, argv[1])) { --- 1753,1757 ---- static OPSERV_FUNC(cmd_unreserve) { ! OPSERV_MIN_PARMS(2, 0); if (dict_remove(opserv_reserved_nick_dict, argv[1])) { *************** *** 1768,1772 **** const char *reason; ! OPSERV_MIN_PARMS(2, false); unsplit_string(argv+1, argc-1); --- 1768,1772 ---- const char *reason; ! OPSERV_MIN_PARMS(2, 0); unsplit_string(argv+1, argc-1); *************** *** 1940,1944 **** unsigned int m, n; ! OPSERV_MIN_PARMS(2, false); for (n=1; n<argc; n++) { --- 1940,1944 ---- unsigned int m, n; ! OPSERV_MIN_PARMS(2, 0); for (n=1; n<argc; n++) { *************** *** 1961,1965 **** unsigned int m, n; ! OPSERV_MIN_PARMS(2, false); for (n=1; n<argc; n++) { --- 1961,1965 ---- unsigned int m, n; ! OPSERV_MIN_PARMS(2, 0); for (n=1; n<argc; n++) { *************** ***... [truncated message content] |