Thread: [srvx-commits] CVS: services/src tools.h,1.12,1.13 tools.c,1.93,1.94 sockcheck.h,1.8,1.9 sockcheck.c
Brought to you by:
entrope
From: Entrope <en...@us...> - 2001-09-18 02:13:12
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv7175/src Modified Files: tools.h tools.c sockcheck.h sockcheck.c proto_ircu_p10.h proto_ircu_p10.c proto_bahamut.h proto_bahamut.c proto.h opserv.c nickserv.c main.c helpfile.c hash.h hash.c global.c common.h chanserv.c Log Message: hide all the per-protocol fooNode bits inside proto_*.c Index: tools.h =================================================================== RCS file: /cvsroot/srvx/services/src/tools.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** tools.h 2001/08/24 20:33:45 1.12 --- tools.h 2001/09/18 02:13:08 1.13 *************** *** 31,34 **** --- 31,35 ---- struct userNode; struct chanNode; + extern unsigned char channel_inverse_modes[256]; typedef void (*oper_func_t) (struct userNode *user); *************** *** 86,91 **** int make_chanmode(struct chanNode *chan, char *out, unsigned int len); int make_usermode(struct userNode *user, char *out, unsigned int len); - - char *intoa(unsigned long addr); #endif /* ifdef _TOOLS_H_ */ --- 87,90 ---- Index: tools.c =================================================================== RCS file: /cvsroot/srvx/services/src/tools.c,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -r1.93 -r1.94 *** tools.c 2001/08/24 21:05:31 1.93 --- tools.c 2001/09/18 02:13:08 1.94 *************** *** 91,95 **** static unsigned char user_inverse_modes[256]; static const unsigned char *channel_modes = RFC1459_CHANNEL_MODE_CHARS PROTO_CHANNEL_MODE_CHARS; ! static unsigned char channel_inverse_modes[256]; static void --- 91,95 ---- 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]; static void *************** *** 883,893 **** memmove(buf->list+from+repl_len, buf->list+from+len, strlen(buf->list+from+len)); strcpy(buf->list+from, repl); - } - - char *intoa(unsigned long addr) { - struct in_addr in; - - in.s_addr = addr; - return inet_ntoa(in); } --- 883,886 ---- Index: sockcheck.h =================================================================== RCS file: /cvsroot/srvx/services/src/sockcheck.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** sockcheck.h 2001/08/19 03:06:09 1.8 --- sockcheck.h 2001/09/18 02:13:08 1.9 *************** *** 34,38 **** void sockcheck_init(void); const char *sockcheck_add_test(const char *desc); ! void sockcheck_queue_address(unsigned long addr, const char *name); int sockcheck_uncache_host(const char *name); void sockcheck_get_stats(struct sockcheck_stats *stats); --- 34,38 ---- void sockcheck_init(void); const char *sockcheck_add_test(const char *desc); ! void sockcheck_queue_address(unsigned long addr); int sockcheck_uncache_host(const char *name); void sockcheck_get_stats(struct sockcheck_stats *stats); Index: sockcheck.c =================================================================== RCS file: /cvsroot/srvx/services/src/sockcheck.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -r1.60 -r1.61 *** sockcheck.c 2001/08/19 03:06:09 1.60 --- sockcheck.c 2001/09/18 02:13:08 1.61 *************** *** 232,238 **** void ! sockcheck_queue_address(unsigned long addr, const char *name) { sockcheck_cache_info sci; if (disable_sockcheck) return; if (pending_ip_pipe[1] == -1) return; /* something went wrong in worker */ --- 232,242 ---- void ! sockcheck_queue_address(unsigned long addr) { sockcheck_cache_info sci; + unsigned long haddr; + int namelen; + char buff[32], *name; + if (disable_sockcheck) return; if (pending_ip_pipe[1] == -1) return; /* something went wrong in worker */ *************** *** 242,245 **** --- 246,252 ---- return; } + haddr = ntohl(addr); + namelen = snprintf(buff, sizeof(buff), " %ld.%ld.%ld.%ld", (haddr >> 24) & 255, (haddr >> 16) & 255, (haddr >> 8) & 255, haddr & 255) - 1; + name = buff + 1; sci = dict_find(checked_ip_dict, name, NULL); if ((sci != NULL) *************** *** 248,255 **** if (sci->decision == REJECT) sockcheck_issue_gline(sci); } else { - int namelen = strlen(name) + 1; - unsigned char *buff = alloca(namelen); buff[0] = namelen; - memcpy(buff+1, name, namelen - 1); if (!sci) { sci = malloc(sizeof(*sci) + namelen); --- 255,259 ---- Index: proto_ircu_p10.h =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** proto_ircu_p10.h 2001/08/24 21:05:31 1.4 --- proto_ircu_p10.h 2001/09/18 02:13:09 1.5 *************** *** 30,51 **** #define COMBO_NUMERIC_LEN (SERVER_NUMERIC_LEN+USER_NUMERIC_LEN) - #define PROTO_HAS_NUMERIC 1 #define PROTO_USER_MODE_CHARS "dkgh" - - struct userNode_proto { - char numeric[COMBO_NUMERIC_LEN+1]; - }; - - struct chanNode_proto { - }; - - struct serverNode_proto { - char numeric[SERVER_NUMERIC_LEN+1]; - struct userNode *users[USERARRAYSIZE]; /* flat indexed by numeric */ - }; - - #define MODE_TARGET_USER(USER) ((USER)->proto.numeric) - #define PRIVMSG_TARGET_USER(USER) ((USER)->proto.numeric) - #define PRIVMSG_TARGET_CHANNEL(CHANNEL) ((CHANNEL)->name) #endif /* !defined(PROTO_IRCU_P10_H) */ --- 30,34 ---- Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** proto_ircu_p10.c 2001/08/24 20:33:45 1.20 --- proto_ircu_p10.c 2001/09/18 02:13:09 1.21 *************** *** 73,76 **** --- 73,85 ---- static unsigned int highest_numeric; + struct userNode_proto { + char numeric[COMBO_NUMERIC_LEN+1]; + }; + + struct serverNode_proto { + char numeric[SERVER_NUMERIC_LEN+1]; + struct userNode *users[USERARRAYSIZE]; /* flat indexed by numeric */ + }; + /**************************************/ /* NUMERIC CONVERSIONS (base64<->int) */ *************** *** 279,283 **** { putsock("%s %s %d %li %li P10 %s]] :%s", ! CMD_SERVER, srv->name, srv->hops, srv->boot, srv->link, srv->proto.numeric, srv->description); } --- 288,292 ---- { putsock("%s %s %d %li %li P10 %s]] :%s", ! CMD_SERVER, srv->name, srv->hops, srv->boot, srv->link, srv->proto->numeric, srv->description); } *************** *** 286,290 **** { 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); } --- 295,299 ---- { 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); } *************** *** 320,327 **** 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); } } --- 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); } } *************** *** 330,334 **** irc_nick(struct userNode *user) { ! putsock("%s %s %s "FMT_TIME_T, user->proto.numeric, CMD_NICK, user->nick, now); } --- 339,343 ---- irc_nick(struct userNode *user) { ! putsock("%s %s %s "FMT_TIME_T, user->proto->numeric, CMD_NICK, user->nick, now); } *************** *** 347,357 **** /* 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) { --- 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) { *************** *** 363,367 **** irc_notice(struct userNode *from, const char *to, const char *message) { ! putsock("%s %s %s :%s", from->proto.numeric, CMD_NOTICE, to, message); } --- 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); } *************** *** 369,373 **** irc_privmsg(struct userNode *from, const char *to, const char *message) { ! putsock("%s %s %s :%s", from->proto.numeric, CMD_PRIVMSG, to, message); } --- 378,387 ---- irc_privmsg(struct userNode *from, const char *to, const char *message) { ! 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); ! } } *************** *** 375,379 **** irc_eob(void) { ! putsock("%s %s", self->proto.numeric, CMD_EOB); } --- 389,393 ---- irc_eob(void) { ! putsock("%s %s", self->proto->numeric, CMD_EOB); } *************** *** 381,385 **** irc_eob_ack(void) { ! putsock("%s %s", self->proto.numeric, CMD_EOB_ACK); } --- 395,399 ---- irc_eob_ack(void) { ! putsock("%s %s", self->proto->numeric, CMD_EOB_ACK); } *************** *** 387,391 **** irc_ping(const char *something) { ! putsock("%s %s :%s", self->proto.numeric, CMD_PING, something); } --- 401,405 ---- irc_ping(const char *something) { ! putsock("%s %s :%s", self->proto->numeric, CMD_PING, something); } *************** *** 393,397 **** irc_pong(const char *data) { ! putsock("%s %s %s :%s", self->proto.numeric, CMD_PONG, self->name, data); } --- 407,411 ---- irc_pong(const char *data) { ! putsock("%s %s %s :%s", self->proto->numeric, CMD_PONG, self->name, data); } *************** *** 420,424 **** 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); } --- 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); } *************** *** 426,430 **** irc_ungline(const char *mask) { ! putsock("%s %s * -%s", self->proto.numeric, CMD_GLINE, mask); } --- 440,444 ---- irc_ungline(const char *mask) { ! putsock("%s %s * -%s", self->proto->numeric, CMD_GLINE, mask); } *************** *** 432,436 **** 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); } --- 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); } *************** *** 438,442 **** irc_unjupe(const char *server) { ! putsock("%s %s * -%s 0 "FMT_TIME_T" :Unjuping.", self->proto.numeric, CMD_JUPE, server, now); } --- 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 **** 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; --- 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; *************** *** 465,470 **** 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; --- 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; *************** *** 506,510 **** irc_quit(struct userNode *user, const char *message) { ! putsock("%s %s :%s", user->proto.numeric, CMD_QUIT, message); } --- 520,524 ---- irc_quit(struct userNode *user, const char *message) { ! putsock("%s %s :%s", user->proto->numeric, CMD_QUIT, message); } *************** *** 523,529 **** { 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); } } --- 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); } } *************** *** 535,541 **** 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); --- 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); *************** *** 552,558 **** { 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); } } --- 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); } } *************** *** 561,565 **** 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); } --- 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); } *************** *** 573,577 **** irc_stats(struct userNode *from, struct server *target, char type) { ! putsock("%s STATS %c :%s", from->proto.numeric, type, target->proto.numeric); } --- 587,591 ---- irc_stats(struct userNode *from, struct server *target, char type) { ! putsock("%s STATS %c :%s", from->proto->numeric, type, target->proto->numeric); } *************** *** 579,583 **** irc_part(struct userNode *who, struct chanNode *what, const char *reason) { ! putsock("%s %s %s :%s", who->proto.numeric, CMD_PART, what->name, reason); } --- 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); } *************** *** 588,591 **** --- 602,743 ---- } + void + chan_apply_bans(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, char **list) + { + char buffer[400]; + unsigned int start, i, here_len, queued; + + queued = 0; + start = sizeof(buffer)-1; + buffer[start] = 0; + for (i=0; i<count; i++) { + here_len = strlen(list[i]); + if ((start < queued+here_len+3) || (queued >= MAXMODEPARAMS)) { + while (queued) { + buffer[--start] = what[1]; + queued--; + } + buffer[--start] = what[0]; + irc_mode(who, channel, buffer+start); + start = sizeof(buffer)-1; + } + start -= here_len; + memcpy(buffer+start, list[i], here_len); /* omit terminator */ + buffer[--start] = ' '; + queued++; + } + if (queued) { + while (queued) { + buffer[--start] = what[1]; + queued--; + } + buffer[--start] = what[0]; + irc_mode(who, channel, buffer+start); + start = sizeof(buffer)-1; + } + } + + void + chan_apply_mode(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, struct userNode **list) + { + char buffer[400]; + unsigned int start, i, queued, len; + queued = 0; + start = sizeof(buffer)-1; + buffer[start] = 0; + + for (i=0; i<count; i++) { + len = strlen(list[i]->proto->numeric); + if ((start < queued+3+len) || (queued >= MAXMODEPARAMS)) { + while (queued) { + buffer[--start] = what[1]; + queued--; + } + buffer[--start] = what[0]; + irc_mode(who, channel, buffer+start); + start = sizeof(buffer)-1; + } + start -= len; + memcpy(buffer+start, list[i]->proto->numeric, len); + buffer[--start] = ' '; + queued++; + } + if (queued) { + while (queued) { + buffer[--start] = what[1]; + queued--; + } + buffer[--start] = what[0]; + irc_mode(who, channel, buffer+start); + start = sizeof(buffer)-1; + } + } + + void + irc_change_channel_modes(struct chanNode *channel, struct userNode *source, const unsigned char *modes, va_list args) + { + char modebuf[200]; + char argbuf[MAXLEN], numbuf[16]; + unsigned int add, mode_pos, base_mode_pos, arg_pos, arg_limit, arg_len; + const char *arg_text; + + add = 1; + arg_pos = 0; + mode_pos = base_mode_pos = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s +", source->nick, channel->name); + arg_limit = MAXLEN - 10; + while (*modes) { + switch (*modes++) { + struct userNode *user; + int number; + case '+': + if (!add) modebuf[mode_pos++] = '+'; + add = 1; + break; + case '-': + if (add) modebuf[mode_pos++] = '-'; + add = 0; + break; + 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': + arg_text = va_arg(args, const char *); + goto add_arg; + case 'l': + number = va_arg(args, int); + snprintf(numbuf, sizeof(numbuf), "%d", number); + arg_text = numbuf; + goto add_arg; + case 'k': + arg_text = va_arg(args, const char *); + goto add_arg; + add_arg: + arg_len = strlen(arg_text); + if ((arg_pos + mode_pos + arg_len >= arg_limit) + || (mode_pos+1 == sizeof(modebuf))) { + modebuf[mode_pos] = 0; + /* -1 in argbuf because of trailing space */ + argbuf[arg_pos-1] = 0; + putsock("%s %s", modebuf, argbuf); + mode_pos = base_mode_pos; + arg_pos = 0; + } + modebuf[mode_pos++] = modes[-1]; + memcpy(argbuf + arg_pos, arg_text, arg_len); + arg_pos += arg_len; + argbuf[arg_pos++] = ' '; + break; + default: + modebuf[mode_pos++] = modes[-1]; + break; + } + } + } + /********************/ /* PROTOCOL PARSING */ *************** *** 650,655 **** } 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); } --- 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); } *************** *** 692,698 **** /* burst local nicks */ ! for (i=0; i<ArrayLength(self->proto.users); i++) { ! if (!self->proto.users[i]) continue; ! irc_user(self->proto.users[i]); } --- 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]); } *************** *** 752,756 **** new_server = AddServer(uplink, name, hops, boot, link, description); servers_num[base64toint(numeric, SERVER_NUMERIC_LEN)] = new_server; ! safestrncpy(new_server->proto.numeric, numeric, sizeof(new_server->proto.numeric)); return new_server; } --- 904,909 ---- 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; } *************** *** 928,935 **** if (uNode) { unsigned long num_local; ! 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 { --- 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 { *************** *** 939,943 **** * 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); } --- 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); } *************** *** 950,954 **** unsigned int last = next_numeric; do { ! if (!self->proto.users[next_numeric++]) { if (next_numeric > highest_numeric) { highest_numeric = next_numeric; --- 1104,1108 ---- unsigned int last = next_numeric; do { ! if (!self->proto->users[next_numeric++]) { if (next_numeric > highest_numeric) { highest_numeric = next_numeric; *************** *** 967,971 **** 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; --- 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; *************** *** 1037,1041 **** while (banlist[i] != ' ' && banlist[i]) i++; while (banlist[i] == ' ') banlist[i++]='\0'; ! AddChannelBan(1, &ban, chan, NULL, now, 0); } } --- 1191,1195 ---- while (banlist[i] != ' ' && banlist[i]) i++; while (banlist[i] == ' ') banlist[i++]='\0'; ! ChangeChannelModes(chan, NULL, "*+b", ban); } } *************** *** 1200,1207 **** char *ban = argv[next_arg++]; if (add) { ! AddChannelBan(1, &ban, cn, GetUserX(argv[0]), now, 0); if (un) call_mode_change_funcs(cn, un, MODE_CHANGE_BAN, ban); ! } ! else DelChannelBan(1, &ban, cn, NULL, 0); break; } } --- 1354,1362 ---- char *ban = argv[next_arg++]; if (add) { ! ChangeChannelModes(cn, GetUserX(argv[0]), "*+b", ban); if (un) call_mode_change_funcs(cn, un, MODE_CHANGE_BAN, ban); ! } else { ! ChangeChannelModes(cn, GetUserX(argv[0]), "*-b", ban); ! } break; } } *************** *** 1419,1423 **** { 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]) { --- 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]) { *************** *** 1497,1501 **** ircu_del_user(struct userNode *user) { ! user->uplink->proto.users[base64toint(user->proto.numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN)] = NULL; } --- 1652,1656 ---- ircu_del_user(struct userNode *user) { ! user->uplink->proto->users[base64toint(user->proto->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN)] = NULL; } *************** *** 1506,1516 **** /* 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; } --- 1661,1671 ---- /* 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; } *************** *** 1649,1653 **** 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; --- 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; *************** *** 1665,1669 **** 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; --- 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; Index: proto_bahamut.h =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** proto_bahamut.h 2001/08/29 15:14:40 1.7 --- proto_bahamut.h 2001/09/18 02:13:09 1.8 *************** *** 30,48 **** #define CHANSERV_JOINS_CHANNELS 0 - struct userNode_proto { - privmsg_func_t privmsg_func; - privmsg_func_t notice_func; - }; - - struct chanNode_proto { - }; - - struct serverNode_proto { - dict_t clients; - }; - - #define MODE_TARGET_USER(USER) ((USER)->nick) - #define PRIVMSG_TARGET_USER(USER) ((USER)->nick) - #define PRIVMSG_TARGET_CHANNEL(CHANNEL) ((CHANNEL)->name) - #endif /* !defined(PROTO_BAHAMUT_H) */ --- 30,32 ---- Index: proto_bahamut.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** proto_bahamut.c 2001/08/24 20:33:45 1.10 --- proto_bahamut.c 2001/09/18 02:13:09 1.11 *************** *** 103,106 **** --- 103,115 ---- } uplink; + struct userNode_proto { + privmsg_func_t privmsg_func; + privmsg_func_t notice_func; + }; + + struct serverNode_proto { + dict_t clients; + }; + /********************/ /* BAHAMUT COMMANDS */ *************** *** 410,413 **** --- 419,560 ---- } + void + chan_apply_bans(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, char **list) + { + char buffer[400]; + unsigned int start, i, here_len, queued; + + queued = 0; + start = sizeof(buffer)-1; + buffer[start] = 0; + for (i=0; i<count; i++) { + here_len = strlen(list[i]); + if ((start < queued+here_len+3) || (queued >= MAXMODEPARAMS)) { + while (queued) { + buffer[--start] = what[1]; + queued--; + } + buffer[--start] = what[0]; + irc_mode(who, channel, buffer+start); + start = sizeof(buffer)-1; + } + start -= here_len; + memcpy(buffer+start, list[i], here_len); /* omit terminator */ + buffer[--start] = ' '; + queued++; + } + if (queued) { + while (queued) { + buffer[--start] = what[1]; + queued--; + } + buffer[--start] = what[0]; + irc_mode(who, channel, buffer+start); + start = sizeof(buffer)-1; + } + } + + void + chan_apply_mode(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, struct userNode **list) + { + char buffer[400]; + unsigned int start, i, queued, len; + queued = 0; + start = sizeof(buffer)-1; + buffer[start] = 0; + + for (i=0; i<count; i++) { + len = strlen(list[i]->nick); + if ((start < queued+3+len) || (queued >= MAXMODEPARAMS)) { + while (queued) { + buffer[--start] = what[1]; + queued--; + } + buffer[--start] = what[0]; + irc_mode(who, channel, buffer+start); + start = sizeof(buffer)-1; + } + start -= len; + memcpy(buffer+start, list[i]->nick, len); + buffer[--start] = ' '; + queued++; + } + if (queued) { + while (queued) { + buffer[--start] = what[1]; + queued--; + } + buffer[--start] = what[0]; + irc_mode(who, channel, buffer+start); + start = sizeof(buffer)-1; + } + } + + void + irc_change_channel_modes(struct chanNode *channel, struct userNode *source, const unsigned char *modes, va_list args) + { + char modebuf[200]; + char argbuf[MAXLEN], numbuf[16]; + unsigned int add, mode_pos, base_mode_pos, arg_pos, arg_limit, arg_len; + const char *arg_text; + + add = 1; + arg_pos = 0; + mode_pos = base_mode_pos = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s +", source->nick, channel->name); + arg_limit = MAXLEN - 10; + while (*modes) { + switch (*modes++) { + struct userNode *user; + int number; + case '+': + if (!add) modebuf[mode_pos++] = '+'; + add = 1; + break; + case '-': + if (add) modebuf[mode_pos++] = '-'; + add = 0; + break; + case 'o': + user = va_arg(args, struct userNode *); + arg_text = user->nick; + goto add_arg; + case 'v': + user = va_arg(args, struct userNode *); + arg_text = user->nick; + goto add_arg; + case 'b': + arg_text = va_arg(args, const char *); + goto add_arg; + case 'l': + number = va_arg(args, int); + snprintf(numbuf, sizeof(numbuf), "%d", number); + arg_text = numbuf; + goto add_arg; + case 'k': + arg_text = va_arg(args, const char *); + goto add_arg; + add_arg: + arg_len = strlen(arg_text); + if ((arg_pos + mode_pos + arg_len >= arg_limit) + || (mode_pos+1 == sizeof(modebuf))) { + modebuf[mode_pos] = 0; + /* -1 in argbuf because of trailing space */ + argbuf[arg_pos-1] = 0; + putsock("%s %s", modebuf, argbuf); + mode_pos = base_mode_pos; + arg_pos = 0; + } + modebuf[mode_pos++] = modes[-1]; + memcpy(argbuf + arg_pos, arg_text, arg_len); + arg_pos += arg_len; + argbuf[arg_pos++] = ' '; + break; + default: + modebuf[mode_pos++] = modes[-1]; + break; + } + } + } + /********************/ /* PROTOCOL HELPERS */ *************** *** 445,449 **** bahamut_new_server(struct server *server) { ! server->proto.clients = dict_new(); } --- 592,597 ---- bahamut_new_server(struct server *server) { ! server->proto = calloc(1, sizeof(*server->proto)); ! server->proto->clients = dict_new(); } *************** *** 462,467 **** { printf("in bahamut_del_server(\"%s\")\n", server->name); ! dict_foreach(server->proto.clients, bahamut_del_server_client, NULL); ! dict_delete(server->proto.clients); } --- 610,615 ---- { printf("in bahamut_del_server(\"%s\")\n", server->name); ! dict_foreach(server->proto->clients, bahamut_del_server_client, NULL); ! dict_delete(server->proto->clients); } *************** *** 469,473 **** bahamut_new_user(struct userNode *user) { ! dict_insert(user->uplink->proto.clients, user->nick, user); return 0; } --- 617,621 ---- bahamut_new_user(struct userNode *user) { ! dict_insert(user->uplink->proto->clients, user->nick, user); return 0; } *************** *** 479,483 **** bahamut_del_user(struct userNode *user) { ! dict_remove(user->uplink->proto.clients, user->nick); } --- 627,631 ---- bahamut_del_user(struct userNode *user) { ! dict_remove(user->uplink->proto->clients, user->nick); } *************** *** 538,542 **** /* burst local nicks */ ! dict_foreach(self->proto.clients, burst_send_nick, 0); } --- 686,690 ---- /* burst local nicks */ ! dict_foreach(self->proto->clients, burst_send_nick, 0); } *************** *** 575,585 **** { struct privmsg_desc *pd = data; if (!pd->is_notice) { ! if (un->proto.privmsg_func) { ! un->proto.privmsg_func(pd->user, pd->text); } } else { ! if (un->proto.notice_func) { ! un->proto.notice_func(pd->user, pd->text); } } --- 723,734 ---- { struct privmsg_desc *pd = data; + if (!un->proto) return; if (!pd->is_notice) { ! if (un->proto->privmsg_func) { ! un->proto->privmsg_func(pd->user, pd->text); } } else { ! if (un->proto->notice_func) { ! un->proto->notice_func(pd->user, pd->text); } } *************** *** 598,602 **** } else { mcf_size = 8; ! mcf_list = malloc(mcf_size*sizeof(mode_change_func_t)); } } --- 747,751 ---- } else { mcf_size = 8; ! mcf_list = calloc(mcf_size, sizeof(mode_change_func_t)); } } *************** *** 902,909 **** char *ban = argv[next_arg++]; if (add) { ! AddChannelBan(1, &ban, cn, GetUser(argv[-1]), now, 0); if (un) call_mode_change_funcs(cn, un, MODE_CHANGE_BAN, ban); ! } ! else DelChannelBan(1, &ban, cn, NULL, 0); break; } } --- 1051,1059 ---- char *ban = argv[next_arg++]; if (add) { ! ChangeChannelModes(cn, GetUser(argv[-1]), 0, "*+b", ban); if (un) call_mode_change_funcs(cn, un, MODE_CHANGE_BAN, ban); ! } else { ! ChangeChannelModes(cn, GetUser(argv[-1]), 0, "*-b", ban); ! } break; } } *************** *** 1295,1304 **** /* set up privmsg and notice callbacks */ num_privmsg_funcs = 16; ! privmsg_funcs = malloc(sizeof(privmsg_func_t)*num_privmsg_funcs); ! memset(privmsg_funcs, 0, sizeof(privmsg_func_t)*num_privmsg_funcs); num_notice_funcs = 16; ! notice_funcs = malloc(sizeof(privmsg_func_t)*num_notice_funcs); ! memset(notice_funcs, 0, sizeof(privmsg_func_t)*num_notice_funcs); /* register callbacks to us */ --- 1445,1452 ---- /* set up privmsg and notice callbacks */ num_privmsg_funcs = 16; ! privmsg_funcs = calloc(num_privmsg_funcs, sizeof(privmsg_func_t)); num_notice_funcs = 16; ! notice_funcs = calloc(num_notice_funcs, sizeof(privmsg_func_t)); /* register callbacks to us */ *************** *** 1335,1339 **** reg_privmsg_func(struct userNode *user, privmsg_func_t handler) { ! user->proto.privmsg_func = handler; } --- 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; } *************** *** 1341,1345 **** reg_notice_func(struct userNode *user, privmsg_func_t handler) { ! user->proto.notice_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; } Index: proto.h =================================================================== RCS file: /cvsroot/srvx/services/src/proto.h,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** proto.h 2001/08/29 15:14:40 1.40 --- proto.h 2001/09/18 02:13:09 1.41 *************** *** 138,141 **** --- 138,151 ---- 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) */ Index: opserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/opserv.c,v retrieving revision 1.209 retrieving revision 1.210 diff -C2 -r1.209 -r1.210 *** opserv.c 2001/08/24 20:33:45 1.209 --- opserv.c 2001/09/18 02:13:09 1.210 *************** *** 1628,1632 **** if (getipbyname(scanhost, &addr)) { ! sockcheck_queue_address(addr, scanhost); opserv_notice(user, OSMSG_ADDRESS_QUEUED, scanhost); } else { --- 1628,1632 ---- if (getipbyname(scanhost, &addr)) { ! sockcheck_queue_address(addr); opserv_notice(user, OSMSG_ADDRESS_QUEUED, scanhost); } else { *************** *** 1846,1850 **** { if (user->ip) { ! sockcheck_queue_address(htonl(user->ip), intoa(htonl(user->ip))); } return 0; --- 1846,1850 ---- { if (user->ip) { ! sockcheck_queue_address(htonl(user->ip)); } return 0; *************** *** 2964,2968 **** { (void)extra; ! sockcheck_queue_address(match->ip, match->hostname); return 0; } --- 2964,2968 ---- { (void)extra; ! sockcheck_queue_address(match->ip); return 0; } Index: nickserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/nickserv.c,v retrieving revision 1.154 retrieving revision 1.155 diff -C2 -r1.154 -r1.155 *** nickserv.c 2001/08/19 03:06:09 1.154 --- nickserv.c 2001/09/18 02:13:09 1.155 *************** *** 55,58 **** --- 55,59 ---- #include "nickserv.h" #include "policer.h" + #include "proto.h" #include "recdb.h" #include "timeq.h" Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/main.c,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -r1.109 -r1.110 *** main.c 2001/08/24 20:33:45 1.109 --- main.c 2001/09/18 02:13:09 1.110 *************** *** 62,65 **** --- 62,66 ---- #include "modules.h" #include "policer.h" + #include "proto.h" #include "recdb.h" #include "timeq.h" Index: helpfile.c =================================================================== RCS file: /cvsroot/srvx/services/src/helpfile.c,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** helpfile.c 2001/08/19 03:06:09 1.43 --- helpfile.c 2001/09/18 02:13:09 1.44 *************** *** 267,271 **** va_start(ap, format); ! res = vsend_message(PRIVMSG_TARGET_USER(dest), src, dest->handle_info, 0, NULL, format, ap); va_end(ap); return res; --- 267,271 ---- va_start(ap, format); ! res = vsend_message(dest->nick, src, dest->handle_info, 0, NULL, format, ap); va_end(ap); return res; *************** *** 348,352 **** va_list ap; va_start(ap, format); ! res = vsend_message(PRIVMSG_TARGET_USER(dest), src, dest->handle_info, 0, expand, format, ap); va_end(ap); return res; --- 348,352 ---- va_list ap; va_start(ap, format); ! res = vsend_message(dest->nick, src, dest->handle_info, 0, expand, format, ap); va_end(ap); return res; Index: hash.h =================================================================== RCS file: /cvsroot/srvx/services/src/hash.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -r1.68 -r1.69 *** hash.h 2001/08/19 03:06:09 1.68 --- hash.h 2001/09/18 02:13:09 1.69 *************** *** 94,99 **** struct userNode { - struct userNode_proto proto; - unsigned long dead : 1; unsigned long modes; /* user flags +isw etc... */ --- 94,97 ---- *************** *** 109,112 **** --- 107,112 ---- struct modeList channels; + /* from proto */ + struct userNode_proto *proto; /* from nickserv */ struct handle_info *handle_info; *************** *** 119,124 **** struct chanNode { - struct chanNode_proto proto; - char name[CHANNELLEN + 1]; chan_mode_t modes; --- 119,122 ---- *************** *** 138,141 **** --- 136,140 ---- struct chanData *channel_info; + struct channelNode_proto *proto; }; *************** *** 156,160 **** struct server { - struct serverNode_proto proto; time_t boot, link; unsigned int hops, clients, in_burst; --- 155,158 ---- *************** *** 163,166 **** --- 161,165 ---- struct server *uplink; + struct serverNode_proto *proto; struct serverList children; }; *************** *** 209,212 **** --- 208,212 ---- void DelChannel(struct chanNode* channel); + void ChangeChannelModes(struct chanNode *channel, struct userNode *source, const char *modes, ...); struct modeNode *AddChannelUser(struct userNode *user, struct chanNode *channel, int is_burst); Index: hash.c =================================================================== RCS file: /cvsroot/srvx/services/src/hash.c,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -r1.142 -r1.143 *** hash.c 2001/08/19 03:06:09 1.142 --- hash.c 2001/09/18 02:13:09 1.143 *************** *** 377,389 **** for (n = 0; n < user->channels.used; n++) { struct modeNode *mn = user->channels.list[n]; ! char modes[128]; irc_join(user, mn->channel); ! switch (mn->modes & (MODE_CHANOP | MODE_VOICE)) { ! case 0: modes[0] = 0; break; ! case MODE_VOICE: snprintf(modes, sizeof(modes), "+v %s", MODE_TARGET_USER(user)); break; ! case MODE_CHANOP: snprintf(modes, sizeof(modes), "+o %s", MODE_TARGET_USER(user)); break; ! case MODE_CHANOP|MODE_VOICE: snprintf(modes, sizeof(modes), "+ov %s %s", MODE_TARGET_USER(user), MODE_TARGET_USER(user)); break; ! } ! if (modes[0]) irc_mode(user, mn->channel, modes); } } --- 377,389 ---- for (n = 0; n < user->channels.used; n++) { struct modeNode *mn = user->channels.list[n]; ! unsigned int pos = 0; ! char modes[16]; ! irc_join(user, mn->channel); ! modes[pos++] = '+'; ! if (mn->modes & MODE_CHANOP) modes[pos++] = 'o'; ! if (mn->modes & MODE_VOICE) modes[pos++] = 'v'; ! modes[pos] = 0; ! if (modes[1]) ChangeChannelModes(mn->channel, user, modes, user, user); } } *************** *** 572,575 **** --- 572,637 ---- } + void + ChangeChannelModes(struct chanNode *channel, struct userNode *source, const char *modes_real, ...) + { + va_list args; + const unsigned char *modes = modes_real; + char *ban_text; + int is_add = 1, bit; + + va_start(args, modes_real); + if (*modes == '*') modes++; + while (*modes) { + switch (*modes++) { + struct userNode *user; + struct modeNode *mn; + case '+': is_add = 1; break; + case '-': is_add = 0; break; + case 'o': + user = va_arg(args, struct userNode *); + if (!(mn = GetUserMode(channel, user))) break; + if (is_add) { + mn->modes |= MODE_CHANOP; + } else { + mn->modes &= ~MODE_CHANOP; + } + break; + case 'v': + user = va_arg(args, struct userNode *); + if (!(mn = GetUserMode(channel, user))) break; + if (is_add) { + mn->modes |= MODE_VOICE; + } else { + mn->modes &= ~MODE_VOICE; + } + break; + case 'b': + ban_text = va_arg(args, char *); + if (is_add) { + AddChannelBan(1, &ban_text, channel, source, now, *modes_real != '*'); + } else { + DelChannelBan(1, &ban_text, channel, source, *modes_real != '*'); + } + break; + default: + bit = channel_inverse_modes[*modes]; + if (bit) { + if (is_add) { + channel->modes |= 1 << (bit - 1); + } else { + channel->modes &= ~(1 << (bit - 1)); + } + } + break; + } + } + va_end(args); + if (modes_real[0] != '*') { + va_start(args, modes_real); + irc_change_channel_modes(channel, source, modes, args); + va_end(args); + } + } + struct modeNode * AddChannelUser(struct userNode *user, struct chanNode *channel, int is_burst) *************** *** 696,771 **** DelChannelUser(victim, channel, 0, 0); - } - - static void - chan_apply_bans(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, char **list) - { - char buffer[400]; - unsigned int start, i, here_len, queued; - - queued = 0; - start = sizeof(buffer)-1; - buffer[start] = 0; - for (i=0; i<count; i++) { - here_len = strlen(list[i]); - if ((start < queued+here_len+3) || (queued >= MAXMODEPARAMS)) { - while (queued) { - buffer[--start] = what[1]; - queued--; - } - buffer[--start] = what[0]; - irc_mode(who, channel, buffer+start); - start = sizeof(buffer)-1; - } - start -= here_len; - memcpy(buffer+start, list[i], here_len); /* omit terminator */ - buffer[--start] = ' '; - queued++; - } - if (queued) { - while (queued) { - buffer[--start] = what[1]; - queued--; - } - buffer[--start] = what[0]; - irc_mode(who, channel, buffer+start); - start = sizeof(buffer)-1; - } - } - - static void - chan_apply_mode(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, struct userNode **list) - { - char buffer[400]; - unsigned int start, i, queued, len; - queued = 0; - start = sizeof(buffer)-1; - buffer[start] = 0; - - for (i=0; i<count; i++) { - len = strlen(MODE_TARGET_USER(list[i])); - if ((start < queued+3+len) || (queued >= MAXMODEPARAMS)) { - while (queued) { - buffer[--start] = what[1]; - queued--; - } - buffer[--start] = what[0]; - irc_mode(who, channel, buffer+start); - start = sizeof(buffer)-1; - } - start -= len; - memcpy(buffer+start, MODE_TARGET_USER(list[i]), len); - buffer[--start] = ' '; - queued++; - } - if (queued) { - while (queued) { - buffer[--start] = what[1]; - queued--; - } - buffer[--start] = what[0]; - irc_mode(who, channel, buffer+start); - start = sizeof(buffer)-1; - } } --- 758,761 ---- Index: global.c =================================================================== RCS file: /cvsroot/srvx/services/src/global.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** global.c 2001/08/19 03:06:09 1.35 --- global.c 2001/09/18 02:13:09 1.36 *************** *** 51,54 **** --- 51,55 ---- #include "nickserv.h" #include "policer.h" + #include "proto.h" #include "recdb.h" #include "timeq.h" *************** *** 359,363 **** } ! #define notice_user(USER, MESSAGE) notice_target(PRIVMSG_TARGET_USER(USER), MESSAGE) static int --- 360,364 ---- } ! #define notice_user(USER, MESSAGE) notice_target((USER)->nick, MESSAGE) static int Index: common.h =================================================================== RCS file: /cvsroot/srvx/services/src/common.h,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -r1.66 -r1.67 *** common.h 2001/08/19 03:06:09 1.66 --- common.h 2001/09/18 02:13:09 1.67 *************** *** 62,65 **** --- 62,68 ---- #endif + #define MAXLEN 512 + #define MAXNUMPARAMS 200 + #define ArrayLength(x) (sizeof(x)/sizeof(x[0])) #define safestrncpy(dest, src, len) do { char *d = (dest); unsigned int l = (len); strncpy(d, (src), l); d[l-1] = 0; } while (0) Index: chanserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.c,v retrieving revision 1.182 retrieving revision 1.183 diff -C2 -r1.182 -r1.183 *** chanserv.c 2001/08/29 15:14:40 1.182 --- chanserv.c 2001/09/18 02:13:09 1.183 *************** *** 1723,1726 **** --- 1723,1727 ---- } + #if CHANSERV_JOINS_CHANNELS static CHANSERV_FUNC(cmd_opchan) { *************** *** 1735,1738 **** --- 1736,1740 ---- return 1; } + #endif static int *************** *** 2044,2048 **** static CHANSERV_FUNC(cmd_down) { - char *change; struct modeNode *mn; (void)argv;(void)argc; --- 2046,2049 ---- *************** *** 2061,2071 **** } ! DelChannelOp(1, &user, channel, channel->channel_info->bot, 0); ! DelChannelVoice(1, &user, channel, channel->channel_info->bot, 0); ! ! change = alloca(6 + 2*strlen(MODE_TARGET_USER(user))); ! sprintf(change, "-ov %s %s", MODE_TARGET_USER(user), MODE_TARGET_USER(user)); ! irc_mode(channel->channel_info->bot, channel, change); ! return 1; } --- 2062,2066 ---- } ! ChangeChannelModes(channel, channel->channel_info->bot, "-ov", user, user); return 1; } *************** *** 4591,4595 **** sprintf(info, "[%s] %s", user->nick, uData->info); ! irc_privmsg(channel->channel_info->bot, PRIVMSG_TARGET_CHANNEL(channel), info); } --- 4586,4590 ---- sprintf(info, "[%s] %s", user->nick, uData->info); ! irc_privmsg(channel->channel_info->bot, channel->name, info); } *************** *** 4801,4813 **** if(protect_user(victim, user, channel->channel_info)) { ! char *change; ! ! DelChannelOp(1, &user, channel, channel->channel_info->bot, 0); ! AddChannelOp(1, &victim, channel, channel->channel_info->bot, 0); ! ! change = alloca(7+2*strlen(MODE_TARGET_USER(victim))); ! sprintf(change, "+o-o %s %s", MODE_TARGET_USER(victim), MODE_TARGET_USER(user)); ! ! irc_mode(channel->channel_info->bot, channel, change); chanserv_notice(user, CSMSG_USER_PROTECTED, victim->nick); } --- 4796,4800 ---- if(protect_user(victim, user, channel->channel_info)) { ! ChangeChannelModes(channel, channel->channel_info->bot, "+o-o", victim, user); chanserv_notice(user, CSMSG_USER_PROTECTED, victim->nick); } *************** *** 6091,6095 **** oldcs = GetUser(chanserv_conf.old_chanserv_name); if (oldcs) { ! irc_privmsg(chanserv, PRIVMSG_TARGET_USER(oldcs), text); } else { log(CS_LOG, LOG_ERROR, "Could not find user %s to privmsg!\n", chanserv_conf.old_chanserv_name); --- 6078,6082 ---- oldcs = GetUser(chanserv_conf.old_chanserv_name); if (oldcs) { ! irc_privmsg(chanserv, oldcs->nick, text); } else { log(CS_LOG, LOG_ERROR, "Could not find user %s to privmsg!\n", chanserv_conf.old_chanserv_name); |