srvx-commits Mailing List for srvx IRC Services (Page 80)
Brought to you by:
entrope
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(80) |
Sep
(51) |
Oct
(94) |
Nov
(132) |
Dec
(85) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(163) |
Feb
(96) |
Mar
(70) |
Apr
(182) |
May
(173) |
Jun
(73) |
Jul
(101) |
Aug
(101) |
Sep
(71) |
Oct
(76) |
Nov
(58) |
Dec
(60) |
2003 |
Jan
(61) |
Feb
(14) |
Mar
(3) |
Apr
|
May
(7) |
Jun
(22) |
Jul
(81) |
Aug
(41) |
Sep
(34) |
Oct
(41) |
Nov
(16) |
Dec
(28) |
2004 |
Jan
(7) |
Feb
|
Mar
(3) |
Apr
(15) |
May
(11) |
Jun
(1) |
Jul
(4) |
Aug
(1) |
Sep
(4) |
Oct
(1) |
Nov
(1) |
Dec
(1) |
2005 |
Jan
(13) |
Feb
(6) |
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2009 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
(2) |
Feb
(3) |
Mar
(4) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(4) |
Jun
|
Jul
(1) |
Aug
|
Sep
(3) |
Oct
(2) |
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2025 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Entrope <en...@us...> - 2001-10-15 14:39:58
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv5265/src Modified Files: main.c Log Message: automatically load protocol module Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/main.c,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -r1.117 -r1.118 *** main.c 2001/10/14 19:45:40 1.117 --- main.c 2001/10/15 14:39:55 1.118 *************** *** 464,467 **** --- 464,468 ---- service_init(); conf_rlimits(); + module_try_load("proto"); if (replay_file) log(MAIN_LOG, LOG_INFO, "Beginning replay...\n"); |
From: Entrope <en...@us...> - 2001-10-15 14:35:19
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv3807/src Modified Files: hash.h mod_common.c mod_common.h modules.c proto.c proto_bahamut.c proto_ircu_p10.c Log Message: fix some compile errors rename exported symbols in proto_*.c from <foo> to lib<foo> so they don't collide Index: hash.h =================================================================== RCS file: /cvsroot/srvx/services/src/hash.h,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -r1.75 -r1.76 *** hash.h 2001/10/12 04:03:51 1.75 --- hash.h 2001/10/15 14:35:15 1.76 *************** *** 86,90 **** /* pointers to various other bits */ ! struct service_instance *service; }; --- 86,90 ---- /* pointers to various other bits */ ! struct service *service; }; Index: mod_common.c =================================================================== RCS file: /cvsroot/srvx/services/src/mod_common.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** mod_common.c 2001/10/12 02:03:34 1.5 --- mod_common.c 2001/10/15 14:35:15 1.6 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 69,77 **** { const char *topic, *data; ! struct service_template_common *cstn; (void)channel; ! cstn = NULL; ! if (!cstn->help) { send_message(source, bot, N_("Helpfile missing.")); return; --- 67,75 ---- { const char *topic, *data; ! struct service_common *sc; (void)channel; ! sc = NULL; ! if (!sc->help) { send_message(source, bot, N_("Helpfile missing.")); return; *************** *** 83,87 **** topic = argv[1]; } ! if (!(data = dict_find(cstn->help, topic, NULL))) { send_message(source, bot, N_("No help on that topic.")); return; --- 81,85 ---- topic = argv[1]; } ! if (!(data = dict_find(sc->help, topic, NULL))) { send_message(source, bot, N_("No help on that topic.")); return; Index: mod_common.h =================================================================== RCS file: /cvsroot/srvx/services/src/mod_common.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** mod_common.h 2001/10/10 04:51:23 1.3 --- mod_common.h 2001/10/15 14:35:15 1.4 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 30,34 **** #define COMMON_VERSION MAKE_VERSION(COMMON_MAJOR, COMMON_MINOR, COMMON_REVISION) ! struct service_template_common { dict_t help; /* help index */ }; --- 28,32 ---- #define COMMON_VERSION MAKE_VERSION(COMMON_MAJOR, COMMON_MINOR, COMMON_REVISION) ! struct service_common { dict_t help; /* help index */ }; Index: modules.c =================================================================== RCS file: /cvsroot/srvx/services/src/modules.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** modules.c 2001/10/12 04:15:16 1.19 --- modules.c 2001/10/15 14:35:15 1.20 *************** *** 63,66 **** --- 63,69 ---- #include <dlfcn.h> + #define SHLIB_PREFIX "lib" + #define SHLIB_SUFFIX ".so" + static struct shared_lib * module_load_shared_lib(const char *so_name) *************** *** 69,72 **** --- 72,76 ---- if (!(lib->handle = dlopen(so_name, RTLD_GLOBAL|RTLD_LAZY))) { + log(MAIN_LOG, LOG_ERROR, "Unable to load shared library %s: %s\n", so_name, dlerror()); free(lib); return NULL; *************** *** 101,107 **** if (dict_find(loaded_libs, name, NULL)) return 1; lib = module_load_shared_lib(name); if (!(lib_load = module_resolve_symbol(lib, "mod_init"))) { module_unload_shared_lib(lib); ! return 2; } module_list_init(&lib->modules); --- 105,112 ---- if (dict_find(loaded_libs, name, NULL)) return 1; lib = module_load_shared_lib(name); + if (!lib) return 2; if (!(lib_load = module_resolve_symbol(lib, "mod_init"))) { module_unload_shared_lib(lib); ! return 3; } module_list_init(&lib->modules); *************** *** 109,113 **** module_list_clean(&lib->modules); module_unload_shared_lib(lib); ! return res + 2; } dict_insert(loaded_libs, lib->name, lib); --- 114,118 ---- module_list_clean(&lib->modules); module_unload_shared_lib(lib); ! return res + 3; } dict_insert(loaded_libs, lib->name, lib); *************** *** 119,125 **** { struct module *mod; if ((mod = dict_find(loaded_modules, name, NULL))) return mod; - /* TODO: try to find a shared library that contains the module */ return mod; } --- 124,145 ---- { struct module *mod; + char path[256], *libname; + if ((mod = dict_find(loaded_modules, name, NULL))) return mod; + /* try to find a shared library that contains the module */ + /* first: what's specified in the configuration file */ + snprintf(path, sizeof(path), "modules/%s/path", name); + if ((libname = database_get_data(conf_db, path, RECDB_QSTRING))) { + module_load_library(libname); + if ((mod = dict_find(loaded_modules, name, NULL))) return mod; + } + /* second: use package library directory */ + snprintf(path, sizeof(path), PKGLIBDIR"/"SHLIB_PREFIX"%s"SHLIB_SUFFIX, name); + module_load_library(path); + if ((mod = dict_find(loaded_modules, name, NULL))) return mod; + /* third: use OS's default path */ + snprintf(path, sizeof(path), SHLIB_PREFIX"%s"SHLIB_SUFFIX, name); + module_load_library(path); if ((mod = dict_find(loaded_modules, name, NULL))) return mod; return mod; } Index: proto.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto.c,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -r1.78 -r1.79 *** proto.c 2001/10/12 04:03:51 1.78 --- proto.c 2001/10/15 14:35:15 1.79 *************** *** 336,343 **** { int failed = 0; - void *addr; ! #define PROTO_FUNC(rettype, name, arglist) if (!(name = get_module_symbol(pmod, #name))) { log(MAIN_LOG, LOG_ERROR, "Protocol module does not export symbol %s\n", #name); failed++; } ! #define PROTO_VARIABLE(type, name) if ((addr = get_module_symbol(pmod, #name))) { name = *(type*)addr; } else { log(MAIN_LOG, LOG_ERROR, "Protocol module does not export symbol %s\n", #name); failed++; } #include "proto.def" #undef PROTO_FUNC --- 336,342 ---- { int failed = 0; ! #define PROTO_FUNC(rettype, name, arglist) if (!(name = get_module_symbol(pmod, "lib"#name))) { log(MAIN_LOG, LOG_ERROR, "Protocol module does not export symbol %s\n", #name); failed++; } ! #define PROTO_VARIABLE(type, name) /* do nothing */ #include "proto.def" #undef PROTO_FUNC Index: proto_bahamut.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** proto_bahamut.c 2001/10/14 19:45:40 1.19 --- proto_bahamut.c 2001/10/15 14:35:16 1.20 *************** *** 32,36 **** #include "log.h" #include "modules.h" ! #define PROTO_FUNC(retval, name, arglist) retval name arglist; #define PROTO_VARIABLE(type, name) extern type name; #include "proto.h" --- 32,36 ---- #include "log.h" #include "modules.h" ! #define PROTO_FUNC(retval, name, arglist) retval lib##name arglist; #define PROTO_VARIABLE(type, name) extern type name; #include "proto.h" *************** *** 173,177 **** void ! irc_server(struct server *srv) { putsock("%s %s %d :%s", --- 173,177 ---- void ! libirc_server(struct server *srv) { putsock("%s %s %d :%s", *************** *** 180,184 **** static void ! irc_uptime(struct user *user) { char uptime[INTERVALLEN]; --- 180,184 ---- static void ! libirc_uptime(struct user *user) { char uptime[INTERVALLEN]; *************** *** 191,195 **** static void ! irc_whois(struct user *from, struct user *who) { putsock(":%s 311 %s %s %s %s * :%s", self->name, from->nick, who->nick, who->username, who->hostname, who->info); --- 191,195 ---- static void ! libirc_whois(struct user *from, struct user *who) { putsock(":%s 311 %s %s %s %s * :%s", self->name, from->nick, who->nick, who->username, who->hostname, who->info); *************** *** 202,206 **** void ! irc_user(struct user *user) { char modes[16]; --- 202,206 ---- void ! libirc_user(struct user *user) { char modes[16]; *************** *** 214,218 **** void ! irc_nick(struct user *user) { putsock(":%s %s %s "FMT_TIME_T, user->nick, CMD_NICK, user->nick, now); --- 214,218 ---- void ! libirc_nick(struct user *user) { putsock(":%s %s %s "FMT_TIME_T, user->nick, CMD_NICK, user->nick, now); *************** *** 220,224 **** void ! irc_fetchtopic(struct user *from, struct channel *target) { putsock(":%s TOPIC %s", from->nick, target->name); --- 220,224 ---- void ! libirc_fetchtopic(struct user *from, struct channel *target) { putsock(":%s TOPIC %s", from->nick, target->name); *************** *** 226,230 **** void ! irc_squit(struct server *srv, const char *message) { /* If we're squitting our uplink, services is leaving the network. */ --- 226,230 ---- void ! libirc_squit(struct server *srv, const char *message) { /* If we're squitting our uplink, services is leaving the network. */ *************** *** 238,242 **** void ! irc_notice(struct user *from, const char *to, const char *message) { putsock(":%s %s %s :%s", from->nick, CMD_NOTICE, to, message); --- 238,242 ---- void ! libirc_notice(struct user *from, const char *to, const char *message) { putsock(":%s %s %s :%s", from->nick, CMD_NOTICE, to, message); *************** *** 244,248 **** void ! irc_privmsg(struct user *from, const char *to, const char *message) { putsock(":%s %s %s :%s", from->nick, CMD_PRIVMSG, to, message); --- 244,248 ---- void ! libirc_privmsg(struct user *from, const char *to, const char *message) { putsock(":%s %s %s :%s", from->nick, CMD_PRIVMSG, to, message); *************** *** 250,254 **** static void ! irc_ping(const char *something) { putsock("%s :%s", CMD_PING, something); --- 250,254 ---- static void ! libirc_ping(const char *something) { putsock("%s :%s", CMD_PING, something); *************** *** 256,260 **** static void ! irc_pong(const char *data) { putsock("%s %s :%s", CMD_PONG, self->name, data); --- 256,260 ---- static void ! libirc_pong(const char *data) { putsock("%s %s :%s", CMD_PONG, self->name, data); *************** *** 262,266 **** static void ! irc_pass(const char *passwd) { putsock("%s %s :TS", CMD_PASS, passwd); --- 262,266 ---- static void ! libirc_pass(const char *passwd) { putsock("%s %s :TS", CMD_PASS, passwd); *************** *** 268,272 **** static void ! irc_capab(void) { putsock("%s TS3 NOQUIT SSJOIN BURST", CMD_CAPAB); --- 268,272 ---- static void ! libirc_capab(void) { putsock("%s TS3 NOQUIT SSJOIN BURST", CMD_CAPAB); *************** *** 274,278 **** static void ! irc_svinfo(void) { putsock("%s %d %d 1 :"FMT_TIME_T, CMD_SVINFO, TS_MAX, TS_MIN, now); --- 274,278 ---- static void ! libirc_svinfo(void) { putsock("%s %d %d 1 :"FMT_TIME_T, CMD_SVINFO, TS_MAX, TS_MIN, now); *************** *** 280,292 **** void ! irc_introduce(const char *passwd) { extern time_t burst_begin; extern unsigned long burst_length; ! irc_capab(); ! irc_pass(passwd); ! irc_server(self); ! irc_svinfo(); self->in_burst = 1; burst_begin = now; --- 280,292 ---- void ! libirc_introduce(const char *passwd) { extern time_t burst_begin; extern unsigned long burst_length; ! libirc_capab(); ! libirc_pass(passwd); ! libirc_server(self); ! libirc_svinfo(); self->in_burst = 1; burst_begin = now; *************** *** 296,300 **** void ! irc_gline(const char *mask, unsigned long duration, const char *message) { putsock(":%s %s * +%s "FMT_TIME_T" :%s", self->name, CMD_GLINE, mask, duration, message); --- 296,300 ---- void ! libirc_gline(const char *mask, unsigned long duration, const char *message) { putsock(":%s %s * +%s "FMT_TIME_T" :%s", self->name, CMD_GLINE, mask, duration, message); *************** *** 302,306 **** void ! irc_ungline(const char *mask) { putsock(":%s %s * -%s", self->name, CMD_GLINE, mask); --- 302,306 ---- void ! libirc_ungline(const char *mask) { putsock(":%s %s * -%s", self->name, CMD_GLINE, mask); *************** *** 308,312 **** void ! irc_jupe(const char *server, unsigned long duration, const char *reason) { putsock(":%s %s * +%s %lu "FMT_TIME_T" :%s", self->name, CMD_JUPE, server, duration, now, reason); --- 308,312 ---- void ! libirc_jupe(const char *server, unsigned long duration, const char *reason) { putsock(":%s %s * +%s %lu "FMT_TIME_T" :%s", self->name, CMD_JUPE, server, duration, now, reason); *************** *** 314,318 **** void ! irc_unjupe(const char *server) { putsock(":%s %s * -%s 0 "FMT_TIME_T" :Unjuping.", self->name, CMD_JUPE, server, now); --- 314,318 ---- void ! libirc_unjupe(const char *server) { putsock(":%s %s * -%s 0 "FMT_TIME_T" :Unjuping.", self->name, CMD_JUPE, server, now); *************** *** 320,324 **** void ! irc_quit(struct user *user, const char *message) { putsock(":%s %s :%s", user->nick, CMD_QUIT, message); --- 320,324 ---- void ! libirc_quit(struct user *user, const char *message) { putsock(":%s %s :%s", user->nick, CMD_QUIT, message); *************** *** 326,330 **** void ! irc_error(const char *to, const char *message) { if (to) { --- 326,330 ---- void ! libirc_error(const char *to, const char *message) { if (to) { *************** *** 336,340 **** void ! irc_kill(struct user *from, struct user *target, const char *message) { if (from) { --- 336,340 ---- void ! libirc_kill(struct user *from, struct user *target, const char *message) { if (from) { *************** *** 346,350 **** void ! irc_mode(struct user *from, struct channel *target, const char *modes) { putsock(":%s %s %s %s", from->nick, CMD_MODE, target->name, modes); --- 346,350 ---- void ! libirc_mode(struct user *from, struct channel *target, const char *modes) { putsock(":%s %s %s %s", from->nick, CMD_MODE, target->name, modes); *************** *** 352,356 **** void ! irc_invite(struct user *from, struct user *who, struct channel *to) { putsock(":%s %s %s %s", from->nick, CMD_INVITE, who->nick, to->name); --- 352,356 ---- void ! libirc_invite(struct user *from, struct user *who, struct channel *to) { putsock(":%s %s %s %s", from->nick, CMD_INVITE, who->nick, to->name); *************** *** 358,362 **** void ! irc_join(struct user *who, struct channel *what) { if (what->members.used == 1) { --- 358,362 ---- void ! libirc_join(struct user *who, struct channel *what) { if (what->members.used == 1) { *************** *** 368,372 **** void ! irc_kick(struct user *actor, struct user *who, struct channel *from, const char *msg) { putsock(":%s %s %s %s :%s", actor->nick, CMD_KICK, from->name, who->nick, msg); --- 368,372 ---- void ! libirc_kick(struct user *actor, struct user *who, struct channel *from, const char *msg) { putsock(":%s %s %s %s :%s", actor->nick, CMD_KICK, from->name, who->nick, msg); *************** *** 374,378 **** void ! irc_raw(const char *what) { putsock("%s", what); --- 374,378 ---- void ! libirc_raw(const char *what) { putsock("%s", what); *************** *** 380,384 **** void ! irc_stats(struct user *from, struct server *target, char type) { putsock(":%s STATS %c :%s", from->nick, type, target->name); --- 380,384 ---- void ! libirc_stats(struct user *from, struct server *target, char type) { putsock(":%s STATS %c :%s", from->nick, type, target->name); *************** *** 386,390 **** void ! irc_part(struct user *who, struct channel *what, const char *reason) { putsock(":%s %s %s :%s", who->nick, CMD_PART, what->name, reason); --- 386,390 ---- void ! libirc_part(struct user *who, struct channel *what, const char *reason) { putsock(":%s %s %s :%s", who->nick, CMD_PART, what->name, reason); *************** *** 392,396 **** void ! irc_topic(struct user *who, struct channel *what, const char *topic) { putsock(":%s %s %s :%s", who->nick, CMD_TOPIC, what->name, topic); --- 392,396 ---- void ! libirc_topic(struct user *who, struct channel *what, const char *topic) { putsock(":%s %s %s :%s", who->nick, CMD_TOPIC, what->name, topic); *************** *** 398,402 **** void ! chan_apply_bans(struct user *who, struct channel *channel, char *what, unsigned int count, char **list) { char buffer[400]; --- 398,402 ---- void ! libchan_apply_bans(struct user *who, struct channel *channel, char *what, unsigned int count, char **list) { char buffer[400]; *************** *** 414,418 **** } buffer[--start] = what[0]; ! irc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } --- 414,418 ---- } buffer[--start] = what[0]; ! libirc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } *************** *** 428,432 **** } buffer[--start] = what[0]; ! irc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } --- 428,432 ---- } buffer[--start] = what[0]; ! libirc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } *************** *** 434,438 **** void ! chan_apply_mode(struct user *who, struct channel *channel, char *what, unsigned int count, struct user **list) { char buffer[400]; --- 434,438 ---- void ! libchan_apply_mode(struct user *who, struct channel *channel, char *what, unsigned int count, struct user **list) { char buffer[400]; *************** *** 450,454 **** } buffer[--start] = what[0]; ! irc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } --- 450,454 ---- } buffer[--start] = what[0]; ! libirc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } *************** *** 464,468 **** } buffer[--start] = what[0]; ! irc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } --- 464,468 ---- } buffer[--start] = what[0]; ! libirc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } *************** *** 470,474 **** void ! irc_change_channel_modes(struct channel *channel, struct user *source, const unsigned char *modes, va_list args) { char modebuf[200]; --- 470,474 ---- void ! libirc_change_channel_modes(struct channel *channel, struct user *source, const unsigned char *modes, va_list args) { char modebuf[200]; *************** *** 551,555 **** (void)data; ! irc_ping(self->name); timeq_add(now + ping_timeout, timed_ping_timeout, 0); } --- 551,555 ---- (void)data; ! libirc_ping(self->name); timeq_add(now + ping_timeout, timed_ping_timeout, 0); } *************** *** 564,568 **** timeouts per time period exceeds some amount, the uplink could be marked as unavalable.*/ ! irc_squit(self->uplink, "Ping timeout."); } --- 564,568 ---- timeouts per time period exceeds some amount, the uplink could be marked as unavalable.*/ ! libirc_squit(self->uplink, "Ping timeout."); } *************** *** 611,615 **** struct user *user = data; (void)key; (void)extra; ! irc_user(user); return 0; } --- 611,615 ---- struct user *user = data; (void)key; (void)extra; ! libirc_user(user); return 0; } *************** *** 716,720 **** void ! reg_mode_change_func(mode_change_func_t handler) { if (mcf_used == mcf_size) { --- 716,720 ---- void ! libreg_mode_change_func(mode_change_func_t handler) { if (mcf_used == mcf_size) { *************** *** 769,773 **** this happens, though there should be a way of resetting the flag. */ ! irc_squit(self->uplink, "Incorrect password received."); } return 1; --- 769,773 ---- this happens, though there should be a way of resetting the flag. */ ! libirc_squit(self->uplink, "Incorrect password received."); } return 1; *************** *** 820,824 **** if (argc < 5) return 0; if ((atoi(argv[1]) < TS_MIN) || (atoi(argv[2]) > TS_MAX)) { ! irc_error(self->uplink->name, "We can't agree on a timestamp version. Sorry!"); return 0; } --- 820,824 ---- if (argc < 5) return 0; if ((atoi(argv[1]) < TS_MIN) || (atoi(argv[2]) > TS_MAX)) { ! libirc_error(self->uplink->name, "We can't agree on a timestamp version. Sorry!"); return 0; } *************** *** 920,924 **** if (argc < 2) return 0; ! irc_pong(argv[1]); timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); --- 920,924 ---- if (argc < 2) return 0; ! libirc_pong(argv[1]); timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); *************** *** 1118,1122 **** if (argc < 4) return 0; un = GetUser(argv[0]); ! if (un && !strcmp(argv[2], "u")) irc_uptime(un); return 1; } --- 1118,1122 ---- if (argc < 4) return 0; un = GetUser(argv[0]); ! if (un && !strcmp(argv[2], "u")) libirc_uptime(un); return 1; } *************** *** 1136,1140 **** return 0; } ! irc_whois(from, who); return 1; } --- 1136,1140 ---- return 0; } ! libirc_whois(from, who); return 1; } *************** *** 1186,1190 **** /* This doesn't get called by AddUser if uplink == self */ bahamut_new_user(uNode); ! if (uplink == self) irc_user(uNode); } else { char kill[MAXLEN]; --- 1186,1190 ---- /* This doesn't get called by AddUser if uplink == self */ bahamut_new_user(uNode); ! if (uplink == self) libirc_user(uNode); } else { char kill[MAXLEN]; *************** *** 1194,1198 **** * screwed up. */ sprintf(kill, "%s KILL %s :%s (Nick collision.)", self->name, nick, self->name); ! irc_raw(kill); } return uNode; --- 1194,1198 ---- * screwed up. */ sprintf(kill, "%s KILL %s :%s (Nick collision.)", self->name, nick, self->name); ! libirc_raw(kill); } return uNode; *************** *** 1200,1204 **** struct user * ! add_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { return bahamut_add_user(self, nick, ident, hostname, modes, userinfo, timestamp); --- 1200,1204 ---- struct user * ! libadd_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { return bahamut_add_user(self, nick, ident, hostname, modes, userinfo, timestamp); *************** *** 1458,1462 **** int ! parse_line(unsigned char *line) { static unsigned char *argv[MAXNUMPARAMS]; --- 1458,1462 ---- int ! libparse_line(unsigned char *line) { static unsigned char *argv[MAXNUMPARAMS]; *************** *** 1477,1481 **** void ! reg_privmsg_func(struct user *user, privmsg_func_t handler) { if (!user->proto) user->proto = calloc(1, sizeof(*user->proto)); --- 1477,1481 ---- void ! libreg_privmsg_func(struct user *user, privmsg_func_t handler) { if (!user->proto) user->proto = calloc(1, sizeof(*user->proto)); *************** *** 1484,1488 **** void ! reg_notice_func(struct user *user, privmsg_func_t handler) { if (!user->proto) user->proto = calloc(1, sizeof(*user->proto)); --- 1484,1488 ---- void ! libreg_notice_func(struct user *user, privmsg_func_t handler) { if (!user->proto) user->proto = calloc(1, sizeof(*user->proto)); *************** *** 1491,1495 **** void ! reg_chanmsg_func(unsigned char prefix, struct user *service, chanmsg_func_t handler) { if (chanmsg_funcs[prefix].func) { --- 1491,1495 ---- void ! libreg_chanmsg_func(unsigned char prefix, struct user *service, chanmsg_func_t handler) { if (chanmsg_funcs[prefix].func) { Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** proto_ircu_p10.c 2001/10/14 19:45:40 1.29 --- proto_ircu_p10.c 2001/10/15 14:35:16 1.30 *************** *** 31,35 **** #include "hash.h" #include "log.h" ! #define PROTO_FUNC(retval, name, arglist) retval name arglist; #define PROTO_VARIABLE(type, name) extern type name; #include "proto.h" --- 31,35 ---- #include "hash.h" #include "log.h" ! #define PROTO_FUNC(retval, name, arglist) retval lib##name arglist; #define PROTO_VARIABLE(type, name) extern type name; #include "proto.h" *************** *** 43,46 **** --- 43,50 ---- /************************************/ + extern time_t boot_time; + extern time_t burst_begin; + extern unsigned long burst_length; + #define SERVER_NUMERIC_LEN 1 #define USER_NUMERIC_LEN 2 *************** *** 272,276 **** void ! irc_server(struct server *srv) { putsock("%s %s %d %li %li %c10 %s]] :%s", --- 276,280 ---- void ! libirc_server(struct server *srv) { putsock("%s %s %d %li %li %c10 %s]] :%s", *************** *** 279,286 **** static void ! irc_uptime(struct user *user) { char uptime[INTERVALLEN]; - extern time_t boot_time; intervalString(uptime, now-boot_time); --- 283,289 ---- static void ! libirc_uptime(struct user *user) { char uptime[INTERVALLEN]; intervalString(uptime, now-boot_time); *************** *** 290,294 **** static void ! irc_whois(struct user *from, struct user *who) { putsock(":%s 311 %s %s %s %s * :%s", self->name, from->nick, who->nick, who->username, who->hostname, who->info); --- 293,297 ---- static void ! libirc_whois(struct user *from, struct user *who) { putsock(":%s 311 %s %s %s %s * :%s", self->name, from->nick, who->nick, who->username, who->hostname, who->info); *************** *** 300,304 **** void ! irc_user(struct user *user) { char b64ip[7]; --- 303,307 ---- void ! libirc_user(struct user *user) { char b64ip[7]; *************** *** 317,321 **** void ! irc_nick(struct user *user) { putsock("%s %s %s "FMT_TIME_T, UPROTO(user)->numeric, CMD_NICK, user->nick, now); --- 320,324 ---- void ! libirc_nick(struct user *user) { putsock("%s %s %s "FMT_TIME_T, UPROTO(user)->numeric, CMD_NICK, user->nick, now); *************** *** 323,327 **** void ! irc_fetchtopic(struct user *from, struct channel *target) { putsock("%s TOPIC %s", from->nick, target->name); --- 326,330 ---- void ! libirc_fetchtopic(struct user *from, struct channel *target) { putsock("%s TOPIC %s", from->nick, target->name); *************** *** 329,333 **** void ! irc_squit(struct server *srv, const char *message) { /* If we're squitting our uplink, services is leaving the network. */ --- 332,336 ---- void ! libirc_squit(struct server *srv, const char *message) { /* If we're squitting our uplink, services is leaving the network. */ *************** *** 338,342 **** for (i = 0; i < ArrayLength(SPROTO(self)->users); i++) { if (!SPROTO(self)->users[i]) continue; ! irc_quit(SPROTO(self)->users[i], message); } } --- 341,345 ---- for (i = 0; i < ArrayLength(SPROTO(self)->users); i++) { if (!SPROTO(self)->users[i]) continue; ! libirc_quit(SPROTO(self)->users[i], message); } } *************** *** 350,354 **** void ! irc_notice(struct user *from, const char *to, const char *message) { putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_NOTICE, to, message); --- 353,357 ---- void ! libirc_notice(struct user *from, const char *to, const char *message) { putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_NOTICE, to, message); *************** *** 356,360 **** void ! irc_privmsg(struct user *from, const char *to, const char *message) { if (IsChannelName(to)) { --- 359,363 ---- void ! libirc_privmsg(struct user *from, const char *to, const char *message) { if (IsChannelName(to)) { *************** *** 367,371 **** static void ! irc_eob(void) { putsock("%s %s", SPROTO(self)->numeric, CMD_EOB); --- 370,374 ---- static void ! libirc_eob(void) { putsock("%s %s", SPROTO(self)->numeric, CMD_EOB); *************** *** 373,377 **** static void ! irc_eob_ack(void) { putsock("%s %s", SPROTO(self)->numeric, CMD_EOB_ACK); --- 376,380 ---- static void ! libirc_eob_ack(void) { putsock("%s %s", SPROTO(self)->numeric, CMD_EOB_ACK); *************** *** 379,383 **** static void ! irc_ping(const char *something) { putsock("%s %s :%s", SPROTO(self)->numeric, CMD_PING, something); --- 382,386 ---- static void ! libirc_ping(const char *something) { putsock("%s %s :%s", SPROTO(self)->numeric, CMD_PING, something); *************** *** 385,389 **** static void ! irc_pong(const char *data) { putsock("%s %s %s :%s", SPROTO(self)->numeric, CMD_PONG, self->name, data); --- 388,392 ---- static void ! libirc_pong(const char *data) { putsock("%s %s %s :%s", SPROTO(self)->numeric, CMD_PONG, self->name, data); *************** *** 391,395 **** static void ! irc_pass(const char *passwd) { putsock("PASS :%s", passwd); --- 394,398 ---- static void ! libirc_pass(const char *passwd) { putsock("PASS :%s", passwd); *************** *** 397,416 **** void ! irc_introduce(const char *passwd) { ! extern int ping_freq; ! extern time_t burst_begin; ! extern unsigned long burst_length; ! ! 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); } void ! 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); --- 400,415 ---- void ! libirc_introduce(const char *passwd) { ! libirc_pass(passwd); self->in_burst = 1; burst_begin = now; burst_length = 0; ! libirc_server(self); timeq_add(now + ping_freq, timed_send_ping, 0); } void ! libirc_gline(const char *mask, unsigned long duration, const char *message) { putsock("%s %s * +%s %lu :%s", SPROTO(self)->numeric, CMD_GLINE, mask, duration, message); *************** *** 418,422 **** void ! irc_ungline(const char *mask) { putsock("%s %s * -%s", SPROTO(self)->numeric, CMD_GLINE, mask); --- 417,421 ---- void ! libirc_ungline(const char *mask) { putsock("%s %s * -%s", SPROTO(self)->numeric, CMD_GLINE, mask); *************** *** 424,428 **** void ! 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); --- 423,427 ---- void ! libirc_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); *************** *** 430,434 **** void ! irc_unjupe(const char *server) { putsock("%s %s * -%s 0 "FMT_TIME_T" :Unjuping.", SPROTO(self)->numeric, CMD_JUPE, server, now); --- 429,433 ---- void ! libirc_unjupe(const char *server) { putsock("%s %s * -%s 0 "FMT_TIME_T" :Unjuping.", SPROTO(self)->numeric, CMD_JUPE, server, now); *************** *** 436,440 **** static void ! irc_burst(struct channel *chan) { char burst_line[510]; --- 435,439 ---- static void ! libirc_burst(struct channel *chan) { char burst_line[510]; *************** *** 498,502 **** void ! irc_quit(struct user *user, const char *message) { putsock("%s %s :%s", UPROTO(user)->numeric, CMD_QUIT, message); --- 497,501 ---- void ! libirc_quit(struct user *user, const char *message) { putsock("%s %s :%s", UPROTO(user)->numeric, CMD_QUIT, message); *************** *** 504,508 **** void ! irc_error(const char *to, const char *message) { if (to) { --- 503,507 ---- void ! libirc_error(const char *to, const char *message) { if (to) { *************** *** 514,518 **** void ! irc_kill(struct user *from, struct user *target, const char *message) { if (from) { --- 513,517 ---- void ! libirc_kill(struct user *from, struct user *target, const char *message) { if (from) { *************** *** 524,528 **** void ! irc_mode(struct user *from, struct channel *target, const char *modes) { struct mode *mn; --- 523,527 ---- void ! libirc_mode(struct user *from, struct channel *target, const char *modes) { struct mode *mn; *************** *** 537,541 **** void ! irc_invite(struct user *from, struct user *who, struct channel *to) { putsock("%s %s %s %s", from->nick, CMD_INVITE, who->nick, to->name); --- 536,540 ---- void ! libirc_invite(struct user *from, struct user *who, struct channel *to) { putsock("%s %s %s %s", from->nick, CMD_INVITE, who->nick, to->name); *************** *** 543,547 **** void ! irc_join(struct user *who, struct channel *what) { if (what->members.used == 1) { --- 542,546 ---- void ! libirc_join(struct user *who, struct channel *what) { if (what->members.used == 1) { *************** *** 553,557 **** void ! irc_kick(struct user *actor, struct user *who, struct channel *from, const char *msg) { putsock("%s %s %s %s :%s", UPROTO(actor)->numeric, CMD_KICK, from->name, UPROTO(who)->numeric, msg); --- 552,556 ---- void ! libirc_kick(struct user *actor, struct user *who, struct channel *from, const char *msg) { putsock("%s %s %s %s :%s", UPROTO(actor)->numeric, CMD_KICK, from->name, UPROTO(who)->numeric, msg); *************** *** 559,563 **** void ! irc_raw(const char *what) { putsock("%s", what); --- 558,562 ---- void ! libirc_raw(const char *what) { putsock("%s", what); *************** *** 565,569 **** void ! irc_stats(struct user *from, struct server *target, char type) { putsock("%s STATS %c :%s", UPROTO(from)->numeric, type, SPROTO(target)->numeric); --- 564,568 ---- void ! libirc_stats(struct user *from, struct server *target, char type) { putsock("%s STATS %c :%s", UPROTO(from)->numeric, type, SPROTO(target)->numeric); *************** *** 571,575 **** void ! irc_part(struct user *who, struct channel *what, const char *reason) { putsock("%s %s %s :%s", UPROTO(who)->numeric, CMD_PART, what->name, reason); --- 570,574 ---- void ! libirc_part(struct user *who, struct channel *what, const char *reason) { putsock("%s %s %s :%s", UPROTO(who)->numeric, CMD_PART, what->name, reason); *************** *** 577,581 **** void ! irc_topic(struct user *who, struct channel *what, const char *topic) { putsock(":%s %s %s :%s", who->nick, CMD_TOPIC, what->name, topic); --- 576,580 ---- void ! libirc_topic(struct user *who, struct channel *what, const char *topic) { putsock(":%s %s %s :%s", who->nick, CMD_TOPIC, what->name, topic); *************** *** 583,587 **** void ! chan_apply_bans(struct user *who, struct channel *channel, char *what, unsigned int count, char **list) { char buffer[400]; --- 582,586 ---- void ! libchan_apply_bans(struct user *who, struct channel *channel, char *what, unsigned int count, char **list) { char buffer[400]; *************** *** 599,603 **** } buffer[--start] = what[0]; ! irc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } --- 598,602 ---- } buffer[--start] = what[0]; ! libirc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } *************** *** 613,617 **** } buffer[--start] = what[0]; ! irc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } --- 612,616 ---- } buffer[--start] = what[0]; ! libirc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } *************** *** 619,623 **** void ! chan_apply_mode(struct user *who, struct channel *channel, char *what, unsigned int count, struct user **list) { char buffer[400]; --- 618,622 ---- void ! libchan_apply_mode(struct user *who, struct channel *channel, char *what, unsigned int count, struct user **list) { char buffer[400]; *************** *** 635,639 **** } buffer[--start] = what[0]; ! irc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } --- 634,638 ---- } buffer[--start] = what[0]; ! libirc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } *************** *** 649,653 **** } buffer[--start] = what[0]; ! irc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } --- 648,652 ---- } buffer[--start] = what[0]; ! libirc_mode(who, channel, buffer+start); start = sizeof(buffer)-1; } *************** *** 655,659 **** void ! irc_change_channel_modes(struct channel *channel, struct user *source, const unsigned char *modes, va_list args) { char modebuf[200]; --- 654,658 ---- void ! libirc_change_channel_modes(struct channel *channel, struct user *source, const unsigned char *modes, va_list args) { char modebuf[200]; *************** *** 742,746 **** (void)data; ! irc_ping(self->name); timeq_add(now + ping_timeout, timed_ping_timeout, 0); } --- 741,745 ---- (void)data; ! libirc_ping(self->name); timeq_add(now + ping_timeout, timed_ping_timeout, 0); } *************** *** 755,759 **** timeouts per time period exceeds some amount, the uplink could be marked as unavalable.*/ ! irc_squit(self->uplink, "Ping timeout."); } --- 754,758 ---- timeouts per time period exceeds some amount, the uplink could be marked as unavalable.*/ ! libirc_squit(self->uplink, "Ping timeout."); } *************** *** 799,803 **** { (void)key; (void)extra; ! irc_burst(data); return 0; } --- 798,802 ---- { (void)key; (void)extra; ! libirc_burst(data); return 0; } *************** *** 819,823 **** if (servers_num[i]->hops == hop) ! irc_server(servers_num[i]); } } --- 818,822 ---- if (servers_num[i]->hops == hop) ! libirc_server(servers_num[i]); } } *************** *** 826,830 **** for (i=0; i<ArrayLength(SPROTO(self)->users); i++) { if (!SPROTO(self)->users[i]) continue; ! irc_user(SPROTO(self)->users[i]); } --- 825,829 ---- for (i=0; i<ArrayLength(SPROTO(self)->users); i++) { if (!SPROTO(self)->users[i]) continue; ! libirc_user(SPROTO(self)->users[i]); } *************** *** 832,836 **** dict_foreach(channels, foreach_burst_helper, NULL); ! irc_eob(); } --- 831,835 ---- dict_foreach(channels, foreach_burst_helper, NULL); ! libirc_eob(); } *************** *** 846,850 **** this happens, though there should be a way of resetting the flag. */ ! irc_squit(self->uplink, "Incorrect password received."); } return 1; --- 845,849 ---- this happens, though there should be a way of resetting the flag. */ ! libirc_squit(self->uplink, "Incorrect password received."); } return 1; *************** *** 886,890 **** new_server = AddServer(uplink, name, hops, boot, link, description); servers_num[base64toint(numeric, SERVER_NUMERIC_LEN)] = new_server; ! sproto = uplink->proto = calloc(1, sizeof(*sproto)); safestrncpy(sproto->numeric, numeric, sizeof(sproto->numeric)); return new_server; --- 885,889 ---- new_server = AddServer(uplink, name, hops, boot, link, description); servers_num[base64toint(numeric, SERVER_NUMERIC_LEN)] = new_server; ! sproto = new_server->proto = calloc(1, sizeof(*sproto)); safestrncpy(sproto->numeric, numeric, sizeof(sproto->numeric)); return new_server; *************** *** 934,938 **** if (argc < 4) return 0; ! if (un && !strcmp(argv[2], "u")) irc_uptime(un); return 1; } --- 933,937 ---- if (argc < 4) return 0; ! if (un && !strcmp(argv[2], "u")) libirc_uptime(un); return 1; } *************** *** 952,956 **** return 0; } ! irc_whois(from, who); return 1; } --- 951,955 ---- return 0; } ! libirc_whois(from, who); return 1; } *************** *** 965,969 **** if (sender == self->uplink) { uplink_set_state(CONNECTED); ! irc_eob_ack(); } return 1; --- 964,968 ---- if (sender == self->uplink) { uplink_set_state(CONNECTED); ! libirc_eob_ack(); } return 1; *************** *** 972,977 **** static CMD_FUNC(cmd_eob_ack) { - extern unsigned long burst_length; - extern time_t burst_begin; (void)argc;(void)argv; /* we don't care about these */ --- 971,974 ---- *************** *** 989,993 **** if (argc < 3) return 0; ! irc_pong(argv[2]); timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); --- 986,990 ---- if (argc < 3) return 0; ! libirc_pong(argv[2]); timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); *************** *** 1071,1075 **** num_local = base64toint(numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); SPROTO(GetServerN(numeric))->users[num_local] = uNode; ! if (uplink == self) irc_user(uNode); } else { char kill[MAXLEN]; --- 1068,1072 ---- num_local = base64toint(numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); SPROTO(GetServerN(numeric))->users[num_local] = uNode; ! if (uplink == self) libirc_user(uNode); } else { char kill[MAXLEN]; *************** *** 1079,1083 **** * screwed up. */ sprintf(kill, "%s KILL %s :%s (Nick collision.)", SPROTO(self)->numeric, numeric, self->name); ! irc_raw(kill); } return uNode; --- 1076,1080 ---- * screwed up. */ sprintf(kill, "%s KILL %s :%s (Nick collision.)", SPROTO(self)->numeric, numeric, self->name); ! libirc_raw(kill); } return uNode; *************** *** 1101,1105 **** struct user * ! add_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { char numeric[COMBO_NUMERIC_LEN+1], ip_num[7]; --- 1098,1102 ---- struct user * ! libadd_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { char numeric[COMBO_NUMERIC_LEN+1], ip_num[7]; *************** *** 1231,1235 **** void ! reg_mode_change_func(mode_change_func_t handler) { if (mcf_used == mcf_size) { --- 1228,1232 ---- void ! libreg_mode_change_func(mode_change_func_t handler) { if (mcf_used == mcf_size) { *************** *** 1657,1661 **** LIB_LOAD_FUNC(mod_init) { - extern time_t boot_time; unsigned int i; char numer[COMBO_NUMERIC_LEN+1]; --- 1654,1657 ---- *************** *** 1794,1798 **** int ! parse_line(unsigned char *line) { static unsigned char *argv[MAXNUMPARAMS]; --- 1790,1794 ---- int ! libparse_line(unsigned char *line) { static unsigned char *argv[MAXNUMPARAMS]; *************** *** 1812,1816 **** void ! reg_privmsg_func(struct user *user, privmsg_func_t handler) { unsigned long numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); --- 1808,1812 ---- void ! libreg_privmsg_func(struct user *user, privmsg_func_t handler) { unsigned long numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); *************** *** 1828,1832 **** void ! reg_notice_func(struct user *user, privmsg_func_t handler) { unsigned int numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); --- 1824,1828 ---- void ! libreg_notice_func(struct user *user, privmsg_func_t handler) { unsigned int numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); *************** *** 1844,1848 **** void ! reg_chanmsg_func(unsigned char prefix, struct user *service, chanmsg_func_t handler) { if (chanmsg_funcs[prefix].func) { --- 1840,1844 ---- void ! libreg_chanmsg_func(unsigned char prefix, struct user *service, chanmsg_func_t handler) { if (chanmsg_funcs[prefix].func) { |
From: Entrope <en...@us...> - 2001-10-15 14:33:14
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv3190/src Modified Files: conf.c Log Message: only free old conf database if it exists Index: conf.c =================================================================== RCS file: /cvsroot/srvx/services/src/conf.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** conf.c 2001/10/14 19:45:40 1.24 --- conf.c 2001/10/15 14:33:12 1.25 *************** *** 68,72 **** return 0; } ! free_database(conf_db); conf_db = new_conf; conf_call_reload_funcs(); --- 68,72 ---- return 0; } ! if (conf_db) free_database(conf_db); conf_db = new_conf; conf_call_reload_funcs(); |
From: Entrope <en...@us...> - 2001-10-15 14:33:02
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv3098/src Modified Files: Makefile.am Log Message: make srvx binary properly export symbols Index: Makefile.am =================================================================== RCS file: /cvsroot/srvx/services/src/Makefile.am,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** Makefile.am 2001/10/14 19:36:53 1.43 --- Makefile.am 2001/10/15 14:32:58 1.44 *************** *** 1,4 **** LIBS = @INTLLIBS@ @LIBS@ ! CFLAGS = -DPKGLIBDIR="\"$(pkglibdir)\"" bin_PROGRAMS = srvx --- 1,4 ---- LIBS = @INTLLIBS@ @LIBS@ ! AM_CFLAGS = -DPKGLIBDIR="\"$(pkglibdir)\"" -rdynamic bin_PROGRAMS = srvx |
From: Entrope <en...@us...> - 2001-10-14 23:31:34
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv11724/src Modified Files: Tag: rel-1_0 log.c Log Message: keep stuff in in-memory log even if a log file couldn't be opened Index: log.c =================================================================== RCS file: /cvsroot/srvx/services/src/log.c,v retrieving revision 1.27.2.9 retrieving revision 1.27.2.10 diff -C2 -r1.27.2.9 -r1.27.2.10 *** log.c 2001/09/27 12:49:31 1.27.2.9 --- log.c 2001/10/14 23:31:31 1.27.2.10 *************** *** 128,132 **** unsigned int size; - if (!logs[lt].file) return; if (!(logs[lt].severity_mask & (1 << ls))) return; --- 128,131 ---- *************** *** 148,157 **** case LOG_OTHER: default: sev = ""; break; } - fputs(sev, logs[lt].file); - va_start(arg_list, text); ! size = vfprintf(logs[lt].file, text, arg_list) + 1; va_end(arg_list); - fflush(logs[lt].file); if (!silent) { va_start(arg_list, text); --- 147,159 ---- case LOG_OTHER: default: sev = ""; break; } va_start(arg_list, text); ! if (logs[lt].file) { ! fputs(sev, logs[lt].file); ! size = vfprintf(logs[lt].file, text, arg_list) + 1; ! fflush(logs[lt].file); ! } else { ! size = vsnprintf(entry->text, 0, text, arg_list) + 1; ! } va_end(arg_list); if (!silent) { va_start(arg_list, text); |
From: Entrope <en...@us...> - 2001-10-14 23:25:56
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv10786/src Modified Files: Tag: rel-1_0 chanserv.help Log Message: clarify how !unregister works Index: chanserv.help =================================================================== RCS file: /cvsroot/srvx/services/src/Attic/chanserv.help,v retrieving revision 1.10.2.23 retrieving revision 1.10.2.24 diff -C2 -r1.10.2.23 -r1.10.2.24 *** chanserv.help 2001/09/05 01:32:47 1.10.2.23 --- chanserv.help 2001/10/14 23:25:52 1.10.2.24 *************** *** 530,533 **** --- 530,534 ---- "${command/UNREGISTER/access}", "Unregisters a channel that is registered with $b$C$b. $bIMPORTANT$b: Once the channel is unregistered, the userlist $bcannot$b be recovered.", + "If you are not network staff, you must add $bCONFIRM$b to the end of your line to confirm channel unregistration.", "$bSee Also:$b register"); "UNSUSPEND" ("$bUNSUSPEND$b", |
From: Entrope <en...@us...> - 2001-10-14 19:46:17
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv21393/src Modified Files: amorph.txt Log Message: clarify module search path Index: amorph.txt =================================================================== RCS file: /cvsroot/srvx/services/src/amorph.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** amorph.txt 2001/10/12 04:03:51 1.1 --- amorph.txt 2001/10/14 19:46:14 1.2 *************** *** 58,62 **** The search path order for loading modules is this: File named by "modules/${modname}/path" ! File in module directory (default value: ${libdir}/srvx) with module's name System library load path (i.e. no prefix to library argument) --- 58,62 ---- The search path order for loading modules is this: File named by "modules/${modname}/path" ! File in module directory (default value: ${pkglibdir}) with module's name System library load path (i.e. no prefix to library argument) |
From: Entrope <en...@us...> - 2001-10-14 19:45:43
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv21276/src Modified Files: conf.c conf.h main.c proto_bahamut.c proto_ircu_p10.c service.c service.h Log Message: revise config file interface move ping_freq, ping_timeout to protocol modules implement module search path add some service config lookup code Index: conf.c =================================================================== RCS file: /cvsroot/srvx/services/src/conf.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** conf.c 2001/10/02 16:04:36 1.23 --- conf.c 2001/10/14 19:45:40 1.24 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 32,37 **** #include "tools.h" ! static dict_t conf_db; ! static dict_t conf_server; static conf_reload_func *reload_funcs; --- 30,34 ---- #include "tools.h" ! dict_t conf_db; static conf_reload_func *reload_funcs; *************** *** 67,72 **** dict_t new_conf; ! if (!(new_conf = parse_database(conf_file_name)) ! || !(conf_server = database_get_data(new_conf, "server", RECDB_OBJECT))) { log(MAIN_LOG, LOG_ERROR, "Reverting to previous configuration\n"); return 0; --- 64,68 ---- dict_t new_conf; ! if (!(new_conf = parse_database(conf_file_name))) { log(MAIN_LOG, LOG_ERROR, "Reverting to previous configuration\n"); return 0; *************** *** 105,131 **** const char * conf_server_name(void) { ! return database_get_data(conf_server, "hostname", RECDB_QSTRING); } const char * conf_server_desc(void) { ! return database_get_data(conf_server, "description", RECDB_QSTRING); ! } ! ! int ! conf_server_num(void) { ! const char *text = database_get_data(conf_server, "numeric", RECDB_QSTRING); ! return text ? atoi(text) : -1; ! } ! ! int ! conf_server_ping_freq(void) { ! const unsigned char *text = database_get_data(conf_server, "ping_freq", RECDB_QSTRING); ! return text ? (signed)ParseInterval(text) : -1; ! } ! ! int ! conf_server_ping_timeout(void) { ! const unsigned char *text = database_get_data(conf_server, "ping_timeout", RECDB_QSTRING); ! return text ? (signed)ParseInterval(text) : -1; } --- 101,109 ---- const char * conf_server_name(void) { ! return database_get_data(conf_db, "server/hostname", RECDB_QSTRING); } const char * conf_server_desc(void) { ! return database_get_data(conf_db, "server/description", RECDB_QSTRING); } Index: conf.h =================================================================== RCS file: /cvsroot/srvx/services/src/conf.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** conf.h 2001/03/30 21:20:10 1.11 --- conf.h 2001/10/14 19:45:40 1.12 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 24,42 **** #include "dict.h" ! int conf_read(const char *conf_file_name); ! void conf_close(void); ! ! const char *conf_server_name(void); ! const char *conf_server_desc(void); ! int conf_server_num(void); ! int conf_server_ping_freq(void); ! int conf_server_ping_timeout(void); typedef void (*conf_reload_func)(void); void conf_register_reload(conf_reload_func crf); void conf_call_reload_funcs(void); - struct record_data *conf_get_node(const char *full_path); ! const char *conf_enum_root(dict_iterator_f it, void *extra); #endif --- 22,35 ---- #include "dict.h" ! extern dict_t conf_db; + int conf_read(const char *conf_file_name); typedef void (*conf_reload_func)(void); void conf_register_reload(conf_reload_func crf); void conf_call_reload_funcs(void); struct record_data *conf_get_node(const char *full_path); ! const char *conf_server_name(void); ! const char *conf_server_desc(void); ! void conf_close(void); #endif Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/main.c,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -r1.116 -r1.117 *** main.c 2001/10/13 23:51:33 1.116 --- main.c 2001/10/14 19:45:40 1.117 *************** *** 71,75 **** time_t boot_time, burst_begin, now; - int ping_freq = 120, ping_timeout = 30; int silent, quit_services; --- 71,74 ---- *************** *** 329,333 **** int main(int argc, char *argv[]) { ! int tmp, daemon; pid_t pid = 0; FILE *file_out; --- 328,332 ---- int main(int argc, char *argv[]) { ! int daemon; pid_t pid = 0; FILE *file_out; *************** *** 457,462 **** reg_exit_func(conf_close); - if ((tmp = conf_server_ping_freq()) != -1) ping_freq = tmp; - if ((tmp = conf_server_ping_timeout()) != -1) ping_timeout = tmp; modules_init(); timeq_init(); --- 456,459 ---- Index: proto_bahamut.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** proto_bahamut.c 2001/10/12 04:03:51 1.18 --- proto_bahamut.c 2001/10/14 19:45:40 1.19 *************** *** 35,38 **** --- 35,39 ---- #define PROTO_VARIABLE(type, name) extern type name; #include "proto.h" + #include "recdb.h" #include "timeq.h" #include "tools.h" *************** *** 48,53 **** 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); --- 49,54 ---- typedef void (*foreach_nonuser) (char *name, void *data); ! static int ping_freq = 60; ! static int ping_timeout = 150; static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); *************** *** 281,285 **** irc_introduce(const char *passwd) { - extern int ping_freq; extern time_t burst_begin; extern unsigned long burst_length; --- 282,285 ---- *************** *** 1374,1377 **** --- 1374,1378 ---- { extern time_t boot_time; + const char *conf_str; /* Register things with module registry */ *************** *** 1413,1418 **** dict_insert(irc_func_dict, CMD_SJOIN, cmd_sjoin); dict_insert(irc_func_dict, CMD_SVINFO, cmd_svinfo); - /* DESYNCH is just informational, so ignore it */ - dict_insert(irc_func_dict, CMD_DESYNCH, cmd_dummy); /* TODO: parse the cmd_dummy lines here */ dict_insert(irc_func_dict, CMD_VERSION, cmd_dummy); --- 1414,1417 ---- *************** *** 1441,1444 **** --- 1440,1451 ---- reg_del_user_func(bahamut_del_user); reg_exit_func(free_parse_misc); + + /* set other config data */ + if ((conf_str = database_get_data(conf_db, "server/ping_freq", RECDB_QSTRING))) { + ping_freq = ParseInterval(conf_str); + } + if ((conf_str = database_get_data(conf_db, "server/ping_timeout", RECDB_QSTRING))) { + ping_timeout = ParseInterval(conf_str); + } /* create self server */ Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** proto_ircu_p10.c 2001/10/12 04:03:51 1.28 --- proto_ircu_p10.c 2001/10/14 19:45:40 1.29 *************** *** 34,37 **** --- 34,38 ---- #define PROTO_VARIABLE(type, name) extern type name; #include "proto.h" + #include "recdb.h" #include "timeq.h" #include "tools.h" *************** *** 47,56 **** #define USERARRAYSIZE (1 << (USER_NUMERIC_LEN * 6)) - extern int ping_freq, ping_timeout; - static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); static struct server *servers_num[64]; static unsigned int next_numeric; static unsigned int highest_numeric; --- 48,57 ---- #define USERARRAYSIZE (1 << (USER_NUMERIC_LEN * 6)) static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); static struct server *servers_num[64]; + static int ping_freq = 60; + static int ping_timeout = 150; static unsigned int next_numeric; static unsigned int highest_numeric; *************** *** 1659,1662 **** --- 1660,1664 ---- unsigned int i; char numer[COMBO_NUMERIC_LEN+1]; + const char *conf_str; /* Register things with module registry */ *************** *** 1670,1673 **** --- 1672,1683 ---- proto_max_channel_bans = 30; + /* set other config data */ + if ((conf_str = database_get_data(conf_db, "server/ping_freq", RECDB_QSTRING))) { + ping_freq = ParseInterval(conf_str); + } + if ((conf_str = database_get_data(conf_db, "server/ping_timeout", RECDB_QSTRING))) { + ping_timeout = ParseInterval(conf_str); + } + /* initialize data structures */ for (i=0; i<ArrayLength(servers_num); i++) { *************** *** 1678,1682 **** /* create self server */ ! inttobase64(numer, conf_server_num(), SERVER_NUMERIC_LEN); for (i=SERVER_NUMERIC_LEN; i<COMBO_NUMERIC_LEN+1; i++) numer[i] = ']'; numer[COMBO_NUMERIC_LEN] = 0; --- 1688,1697 ---- /* create self server */ ! conf_str = database_get_data(conf_db, "server/numeric", RECDB_QSTRING); ! if (!conf_str) { ! log(MAIN_LOG, LOG_ERROR, "Missing configuration entry server/numeric\n"); ! exit(1); ! } ! inttobase64(numer, strtoul(conf_str, NULL, 0), SERVER_NUMERIC_LEN); for (i=SERVER_NUMERIC_LEN; i<COMBO_NUMERIC_LEN+1; i++) numer[i] = ']'; numer[COMBO_NUMERIC_LEN] = 0; Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/service.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** service.c 2001/10/12 02:03:34 1.5 --- service.c 2001/10/14 19:45:40 1.6 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 24,30 **** --- 22,31 ---- #include <stdlib.h> + #include "conf.h" #include "dict.h" + #include "log.h" #include "messages.h" #include "proto.h" + #include "recdb.h" #include "rules.h" #include "service.h" *************** *** 37,47 **** static struct module *service_module; ! static dict_t service_templates; void service_init(void) { service_module = module_register("service", MAKE_VERSION(SERVICE_MAJOR, SERVICE_MINOR, SERVICE_REVISION), NULL, NULL); ! service_templates = dict_new(); } --- 38,92 ---- static struct module *service_module; ! static dict_t services; /* (struct service*->user->nick)->struct service*) */ void + service_free_user(struct user *user) + { + struct service *svc; + if (!(svc = user->service)) return; + assert(user == svc->user); + free(svc->name); + free(svc); + } + + void service_init(void) { service_module = module_register("service", MAKE_VERSION(SERVICE_MAJOR, SERVICE_MINOR, SERVICE_REVISION), NULL, NULL); ! reg_del_user_func(service_free_user); ! } ! ! static struct service_command * ! service_find_command(struct service *sinst, const char *name) ! { ! struct service_command *cmd; ! while (sinst) { ! cmd = dict_find(sinst->commands, name, NULL); ! if (cmd) return cmd; ! sinst = sinst->extends; ! } ! return NULL; ! } ! ! static void * ! service_find_conf_by_name(const char *sname, const char *path, enum recdb_type type) ! { ! dict_t services, conf; ! void *res; ! ! services = database_get_data(conf_db, "services", RECDB_OBJECT); ! while (sname) { ! conf = database_get_data(services, sname, RECDB_OBJECT); ! if (!conf) return NULL; ! if ((res = database_get_data(conf, path, type))) return res; ! sname = database_get_data(conf_db, "extends", RECDB_QSTRING); ! } ! return NULL; ! } ! ! void * ! service_find_conf(struct service *sinst, const char *path, enum recdb_type type) ! { ! return service_find_conf_by_name(sinst->user->nick, path, type); } *************** *** 52,56 **** unsigned char *argv[MAXNUMPARAMS], *chan_name; unsigned int argc, shift; ! struct service_instance *sinst; struct service_command *cmd; struct expression_context rule_ctx; --- 97,101 ---- unsigned char *argv[MAXNUMPARAMS], *chan_name; unsigned int argc, shift; ! struct service *sinst; struct service_command *cmd; struct expression_context rule_ctx; *************** *** 61,65 **** sinst = bot->service; if ((argc > 0) && (argv[0][0] == '#')) { ! cmd = dict_find(sinst->templ->commands, argv[1], NULL); if (cmd->base->flags & (1 << TAKES_CHANNEL)) { shift = 1; --- 106,110 ---- sinst = bot->service; if ((argc > 0) && (argv[0][0] == '#')) { ! cmd = service_find_command(sinst, argv[1]); if (cmd->base->flags & (1 << TAKES_CHANNEL)) { shift = 1; *************** *** 70,74 **** } } else if ((argc > 1) && (argv[1][0] == '#')) { ! cmd = dict_find(sinst->templ->commands, argv[0], NULL); if (cmd->base->flags & (1 << TAKES_CHANNEL)) { shift = 1; --- 115,119 ---- } } else if ((argc > 1) && (argv[1][0] == '#')) { ! cmd = service_find_command(sinst, argv[0]); if (cmd->base->flags & (1 << TAKES_CHANNEL)) { shift = 1; *************** *** 81,85 **** } else { shift = 0; ! cmd = dict_find(sinst->templ->commands, argv[0], NULL); } if ((cmd->base->flags & (1 << TAKES_CHANNEL)) && shift) { --- 126,130 ---- } else { shift = 0; ! cmd = service_find_command(sinst, argv[0]); } if ((cmd->base->flags & (1 << TAKES_CHANNEL)) && shift) { *************** *** 107,134 **** } ! struct user * ! service_create(const char *name, dict_t params) { - struct user *user; const char *hostname, *userinfo, *trigger; ! struct service_template *templ; ! struct service_instance *sinst; ! /* Is the template defined? */ ! if (!(templ = dict_find(service_templates, name, NULL))) return NULL; /* Get the various parameters from the params dict */ ! hostname = dict_find(params, "hostname", NULL); ! userinfo = dict_find(params, "userinfo", NULL); ! trigger = dict_find(params, "trigger", NULL); /* Create the user and annotate it */ - user = add_local_user(name, name, hostname, "+oik", userinfo, now); sinst = calloc(1, sizeof(*sinst)); assert(sinst); ! sinst->templ = templ; ! user->service = sinst; ! /* Register callbacks */ ! if (trigger) reg_chanmsg_func(trigger[0], user, service_chanmsg); ! reg_privmsg_func(user, service_privmsg); ! /* TODO: finish service_create() */ ! return user; } --- 152,192 ---- } ! struct service * ! service_create(const char *name) { const char *hostname, *userinfo, *trigger; ! struct service *sinst; ! /* Check if we've already created it */ ! if ((sinst = dict_find(services, name, NULL))) return sinst; /* Get the various parameters from the params dict */ ! hostname = service_find_conf_by_name(name, "hostname", RECDB_QSTRING); ! if (!hostname) { ! log(MAIN_LOG, LOG_ERROR, "No 'hostname' entry defined for service '%s'\n", name); ! return NULL; ! } ! userinfo = service_find_conf_by_name(name, "userinfo", RECDB_QSTRING); ! if (!userinfo) { ! log(MAIN_LOG, LOG_ERROR, "No 'userinfo' entry defined for service '%s'\n", name); ! return NULL; ! } ! trigger = service_find_conf_by_name(name, "trigger", RECDB_QSTRING); /* Create the user and annotate it */ sinst = calloc(1, sizeof(*sinst)); assert(sinst); ! sinst->name = strdup(name); ! sinst->extends = service_create(service_find_conf_by_name(name, "extends", RECDB_QSTRING)); ! if (name[0] != '*') { ! struct user *user; ! user = sinst->user = add_local_user(name, name, hostname, "+oik", userinfo, now); ! user->service = sinst; ! /* Register callbacks */ ! if (trigger) reg_chanmsg_func(trigger[0], user, service_chanmsg); ! reg_privmsg_func(user, service_privmsg); ! } ! sinst->commands = dict_new(); ! /* Put into services dict */ ! dict_insert(services, sinst->name, sinst); ! /* TODO: finish service_create(): load commands, ?call callbacks? */ ! return sinst; } Index: service.h =================================================================== RCS file: /cvsroot/srvx/services/src/service.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** service.h 2001/10/10 04:51:23 1.4 --- service.h 2001/10/14 19:45:40 1.5 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 32,47 **** struct service_common; - struct service_template { - dict_t commands; /* string->struct service_command* */ - struct service_template_common *common; - }; - /* Attached as a "service" module note to "struct user" */ ! struct service_instance { ! struct service_template *templ; }; void service_init(); ! struct user *service_create(const char *templ_name, dict_t params); void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text); --- 30,45 ---- struct service_common; /* Attached as a "service" module note to "struct user" */ ! struct service { ! char *name; ! struct user *user; ! struct service *extends; ! dict_t commands; ! struct service_common *common; }; void service_init(); ! struct service *service_create(const char *name); ! void * service_find_conf(struct service *sinst, const char *path, enum recdb_type type); void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text); |
From: Entrope <en...@us...> - 2001-10-14 19:36:57
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv19609/src Modified Files: Makefile.am Log Message: remove dead "globtest" target define PKGLIBDIR in CFLAGS (for modules.c) Index: Makefile.am =================================================================== RCS file: /cvsroot/srvx/services/src/Makefile.am,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** Makefile.am 2001/10/12 02:03:34 1.42 --- Makefile.am 2001/10/14 19:36:53 1.43 *************** *** 1,3 **** --- 1,4 ---- LIBS = @INTLLIBS@ @LIBS@ + CFLAGS = -DPKGLIBDIR="\"$(pkglibdir)\"" bin_PROGRAMS = srvx *************** *** 5,9 **** libauthserv.la \ libproto_bahamut.la libproto_ircu_p10.la ! EXTRA_PROGRAMS = checkdb globtest pwcracker srvx_LDFLAGS = $(export_dynamic_flag_spec) --- 6,10 ---- libauthserv.la \ libproto_bahamut.la libproto_ircu_p10.la ! EXTRA_PROGRAMS = checkdb pwcracker srvx_LDFLAGS = $(export_dynamic_flag_spec) *************** *** 46,51 **** checkdb_SOURCES = checkdb.c recdb.c recdb.h dict-hash.c dict.h log.h saxdb.c saxdb.h pwcracker_SOURCES = pwcracker.c recdb.c recdb.h dict-splay.c dict.h log.h md5.c - globtest_SOURCES = tools.c globtest.c common.h - globtest_CFLAGS = -DGLOBTEST LINT = lclint --- 47,50 ---- |
From: Zoot <zo...@us...> - 2001-10-13 23:51:36
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv21566/src Modified Files: main.c rules.c Log Message: Fix rule parsing and add a NOT operator. Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/main.c,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -r1.115 -r1.116 *** main.c 2001/10/12 04:03:51 1.115 --- main.c 2001/10/13 23:51:33 1.116 *************** *** 53,56 **** --- 53,57 ---- #include "hash.h" #include "log.h" + #include "rules.h" #include "messages.h" #include "modules.h" *************** *** 463,466 **** --- 464,468 ---- sockcheck_init(); /* could be modularized */ hash_init(); + rules_init(); service_init(); conf_rlimits(); Index: rules.c =================================================================== RCS file: /cvsroot/srvx/services/src/rules.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** rules.c 2001/10/02 16:04:36 1.3 --- rules.c 2001/10/13 23:51:33 1.4 *************** *** 66,87 **** maxlen = pos - *string; dp = dest = malloc(maxlen); ! for (pos=*string; *pos && isalnum(*pos); pos++) *dp++ = *pos++; *dp = 0; return dest; } static struct expression * ! expr_parse_int(const unsigned char **string) { struct expression *expr; unsigned int nn, argno, num_args; struct parse_expression **args, *arg; ! if (**string++ != '(') return NULL; expr = NULL; argno = 0; num_args = 4; args = malloc(num_args*sizeof(*args)); ! while (**string && (**string != ')')) { if ((argno+1) == num_args) { num_args <<= 1; --- 66,90 ---- maxlen = pos - *string; dp = dest = malloc(maxlen); ! for (pos=*string; *pos && isalnum(*pos); pos++) *dp++ = *pos; *dp = 0; + *string = pos; return dest; } static struct expression * ! expr_parse_int(const unsigned char **input) { struct expression *expr; unsigned int nn, argno, num_args; struct parse_expression **args, *arg; + const unsigned char *string; ! string = *input; ! if (*string++ != '(') return NULL; expr = NULL; argno = 0; num_args = 4; args = malloc(num_args*sizeof(*args)); ! while (*string && (*string != ')')) { if ((argno+1) == num_args) { num_args <<= 1; *************** *** 89,113 **** } arg = args[argno++] = calloc(1, sizeof(**args)); ! if (**string == '(') { arg->type = PEXPR_EXPR; ! arg->u.expr = expr_parse_int(string); ! if (!arg->u.expr) while (**string) (*string)++; ! } else if (**string == '"') { arg->type = PEXPR_QSTRING; ! arg->u.qstring = expr_parse_string(string); ! if (!arg->u.qstring) while (**string) (*string)++; ! } else if (isalnum(**string)) { arg->type = PEXPR_TOKEN; ! arg->u.token = expr_parse_token(string); ! if (!arg->u.token) while (**string) (*string)++; } else { /* parse error, skip to end of input */ ! while (**string) (*string)++; } ! if (!**string) goto out; ! if (expr_skip_whitespace(string)) goto out; ! argno++; } ! if (!**string) goto out; /* make sure first argument (start of list) is a token */ if (args[0]->type != PEXPR_TOKEN) goto out; --- 92,115 ---- } arg = args[argno++] = calloc(1, sizeof(**args)); ! if (*string == '(') { arg->type = PEXPR_EXPR; ! arg->u.expr = expr_parse_int(&string); ! if (!arg->u.expr) while (*string) (string)++; ! } else if (*string == '"') { arg->type = PEXPR_QSTRING; ! arg->u.qstring = expr_parse_string(&string); ! if (!arg->u.qstring) while (*string) (string)++; ! } else if (isalnum(*string)) { arg->type = PEXPR_TOKEN; ! arg->u.token = expr_parse_token(&string); ! if (!arg->u.token) while (*string) (string)++; } else { /* parse error, skip to end of input */ ! while (*string) (string)++; } ! if (!*string) goto out; ! if (expr_skip_whitespace(&string)) goto out; } ! if (!*string) goto out; /* make sure first argument (start of list) is a token */ if (args[0]->type != PEXPR_TOKEN) goto out; *************** *** 116,123 **** --- 118,127 ---- if (!(expr->oper = dict_find(expr_opers, args[0]->u.token, NULL))) { free(expr); + expr = NULL; goto out; } if (expr->oper->compile(expr, argno, args)) { free(expr); + expr = NULL; goto out; } *************** *** 131,134 **** --- 135,144 ---- } free(args); + + if(*string == ')') { + string++; + } + + *input = string; return expr; } *************** *** 161,165 **** } ! static EXPR_COMPILE_FUNCTION(oper_or_compile) { unsigned int nn; --- 171,177 ---- } ! /* Compiles an operator that contains only subexpressions; ! used by the or, and operators. */ ! static EXPR_COMPILE_FUNCTION(oper_subexpr_compile) { unsigned int nn; *************** *** 178,187 **** } ! static EXPR_FREE_FUNCTION(oper_or_free) { ! unsigned int nn; ! for (nn=0; nn<expr->argc; nn++) { ! expression_free(expr->args[nn]); ! } } --- 190,196 ---- } ! static EXPR_COMPILE_FUNCTION(oper_not_compile) { ! return (argc != 2) ? 1 : oper_subexpr_compile(expr, argc, pexpr); } *************** *** 207,212 **** } ! static EXPR_COMPILE_FUNCTION(oper_true_compile) { (void)argc; (void)pexpr; expr->argc = 0; --- 216,237 ---- } ! static EXPR_EVAL_FUNCTION(oper_not_eval) { + return !expression_evaluate(expr->args[0], context); + } + + /* The counterpart to oper_subexpr_compile frees all + subexpressions; used by the or, and, not operators. */ + static EXPR_FREE_FUNCTION(oper_subexpr_free) + { + unsigned int nn; + for (nn=0; nn<expr->argc; nn++) { + expression_free(expr->args[nn]); + } + } + + /* Compiles an operator that returns a constant. */ + static EXPR_COMPILE_FUNCTION(oper_constant_compile) + { (void)argc; (void)pexpr; expr->argc = 0; *************** *** 215,223 **** } - static EXPR_FREE_FUNCTION(oper_true_free) - { - (void)expr; - } - static EXPR_EVAL_FUNCTION(oper_true_eval) { --- 240,243 ---- *************** *** 232,235 **** --- 252,261 ---- } + /* The counterpart to oper_constant_compile. */ + static EXPR_FREE_FUNCTION(oper_constant_free) + { + (void)expr; + } + void rules_init(void) *************** *** 241,268 **** op = calloc(1, sizeof(*op)); op->name = "or"; ! op->compile = oper_or_compile; op->eval = oper_or_eval; ! op->free_ = oper_or_free; register_expression_operator(op); /* Register AND operator */ op = calloc(1, sizeof(*op)); op->name = "and"; ! op->compile = oper_or_compile; /* same as "or" */ op->eval = oper_and_eval; ! op->free_ = oper_or_free; /* same as "or" */ register_expression_operator(op); /* Register TRUE operator */ op = calloc(1, sizeof(*op)); op->name = "true"; ! op->compile = oper_true_compile; op->eval = oper_true_eval; ! op->free_ = oper_true_free; register_expression_operator(op); /* Register FALSE operator */ op = calloc(1, sizeof(*op)); op->name = "false"; ! op->compile = oper_true_compile; /* same as "true" */ op->eval = oper_false_eval; ! op->free_ = oper_true_free; /* same as "true" */ register_expression_operator(op); } --- 267,301 ---- op = calloc(1, sizeof(*op)); op->name = "or"; ! op->compile = oper_subexpr_compile; op->eval = oper_or_eval; ! op->free_ = oper_subexpr_free; register_expression_operator(op); /* Register AND operator */ op = calloc(1, sizeof(*op)); op->name = "and"; ! op->compile = oper_subexpr_compile; /* same as "or" */ op->eval = oper_and_eval; ! op->free_ = oper_subexpr_free; /* same as "or" */ ! register_expression_operator(op); ! /* Register NOT operator */ ! op = calloc(1, sizeof(*op)); ! op->name = "not"; ! op->compile = oper_not_compile; ! op->eval = oper_not_eval; ! op->free_ = oper_subexpr_free; /* same as "or" */ register_expression_operator(op); /* Register TRUE operator */ op = calloc(1, sizeof(*op)); op->name = "true"; ! op->compile = oper_constant_compile; op->eval = oper_true_eval; ! op->free_ = oper_constant_free; register_expression_operator(op); /* Register FALSE operator */ op = calloc(1, sizeof(*op)); op->name = "false"; ! op->compile = oper_constant_compile; /* same as "true" */ op->eval = oper_false_eval; ! op->free_ = oper_constant_free; /* same as "true" */ register_expression_operator(op); } |
From: Entrope <en...@us...> - 2001-10-12 04:15:19
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv3355/src Modified Files: modules.c Log Message: rearrange #ifdef's so that it only checks once Index: modules.c =================================================================== RCS file: /cvsroot/srvx/services/src/modules.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** modules.c 2001/10/12 02:03:34 1.18 --- modules.c 2001/10/12 04:15:16 1.19 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 24,32 **** #include <string.h> #include <stdio.h> - #if defined(HAVE_DLFCN_H) - #include <dlfcn.h> - #else - #error No module support on your platform, sorry. - #endif #include "common.h" --- 22,25 ---- *************** *** 68,71 **** --- 61,66 ---- #if defined(HAVE_DLFCN_H) + #include <dlfcn.h> + static struct shared_lib * module_load_shared_lib(const char *so_name) *************** *** 93,96 **** --- 88,93 ---- dlclose(lib->handle); } + #else + #error No module support on your platform, sorry. #endif |
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv604/src Modified Files: hash.c hash.h main.c proto.c proto.def proto.h proto_bahamut.c proto_ircu_p10.c tools.h Added Files: amorph.txt Log Message: add nick-change callback list fix some more bugs in protocol-related stuff (init_proto() wouldn't find the "proto" module since it is called from proto's mod_init) --- NEW FILE --- Amorphous Service Modules ------------------------- Common - help, readhelp, timecmd, write, etc. StaffList - ircops, helpers, staff, etc. AuthServ - basic non-staff handle functions (plus god) AuthServAdmin - staff handle-related functions NickServ - nick registration NickServAdmin - staff nick-related function ChanServReg - basic channel registration/unreg code ChanServSwitch - transitions from X2 ChanServUsers - manipulation of channel user lists/structs ChanServChannel - channel operations ChanServAdmin - events, peek, info, last, command, search, expire, etc. ChanServToys - say, emote, unf, ping, wut, 8ball, d, etc. OpServAccess - opserv access levels for users and commands OpServAlert - alert-related things OpServChannel - addbad, addsecret, etc. OpServHost - addtrust, etc. OpServHax - channel manipulation, dump, raw OpServNetban - gline related functions OpServProxy - proxy checking control OpServClone - clone control (clone, reserve, unreserve, etc.) OpServModules - module control OpServConfig - query, set, log, loginfo OpServControl - die, reconnect, reopen, writeall, sanity, etc. OpServAlias - alias, unalias, etc. ProxyCheck - proxy checking backend (maybe) How it works ------------ The server core consists of common functionality like the configury support, G-line database, channel and user tracking, logging, module management, protocol placeholders, policer, rules/service management, time queue, uplink management and miscellaneous tools. The core then loads a special-purpose protocol module (binding several functions into pointers in the core) and any other modules the config file indicates. Each of these modules (including the protocol module) may register service commands. Each service bot is defined by an entry in a "bots" section of the config file. This defines the configuration for each bot -- especially the commands they provide. The bot entry can also contain an "extends" entry, naming another bot entry that is the template for the current bot. (If the bot entry's name starts with the character "*", the bot will not be instantiated, but can be used as a template for other bots.) The module loading works like this: In the config file, there is a section called "modules". This record is keyed by module name. Each datum in "modules" is another record, containing information on where to find the library (in the "path" key) and global configuration for that module. The search path order for loading modules is this: File named by "modules/${modname}/path" File in module directory (default value: ${libdir}/srvx) with module's name System library load path (i.e. no prefix to library argument) When a module is loaded, a function in the module called "mod_init" is called. This function may officially register the module -- this lets other modules depend on it by version, and indicates which modules it depends on. (If it depends on a module that isn't loaded, srvx tries to recursively load that module.) The module can then register service functions, callbacks, rules, etc. Index: hash.c =================================================================== RCS file: /cvsroot/srvx/services/src/hash.c,v retrieving revision 1.149 retrieving revision 1.150 diff -C2 -r1.149 -r1.150 *** hash.c 2001/10/12 02:03:34 1.149 --- hash.c 2001/10/12 04:03:51 1.150 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 249,252 **** --- 247,268 ---- } + static nick_change_func_t *ncf2_list; + static unsigned int ncf2_size = 0, ncf2_used = 0; + + void + reg_nick_change_func(nick_change_func_t handler) + { + if (ncf2_used == ncf2_size) { + if (ncf2_size) { + ncf2_size <<= 1; + ncf2_list = realloc(ncf2_list, ncf2_size*sizeof(nick_change_func_t)); + } else { + ncf2_size = 8; + ncf2_list = malloc(ncf2_size*sizeof(nick_change_func_t)); + } + } + ncf2_list[ncf2_used++] = handler; + } + static del_user_func_t *duf_list; static size_t duf_size = 0, duf_used = 0; *************** *** 380,383 **** --- 396,401 ---- void NickChange(struct user *user, const char *new_nick) { + unsigned int nn; + /* don't do anything if there's no change */ if (!strncmp(new_nick, user->nick, NICKLEN)) return; *************** *** 385,388 **** --- 403,416 ---- /* remove old entry from clients dictionary */ dict_remove2(clients, user->nick, 1); + + /* Make callbacks for nick changes. + * This needs to be done with the old nick still in place, else + * dict lookups based on user->nick will miss the user. + * It is safe to re-insert using new_nick (which may be a + * temporary pointer) since the later value of user->nick will be + * correct. */ + for (nn=0; nn<ncf2_used; nn++) { + ncf2_list[nn](user, new_nick); + } /* copy new nick */ Index: hash.h =================================================================== RCS file: /cvsroot/srvx/services/src/hash.h,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -r1.74 -r1.75 *** hash.h 2001/10/12 02:03:34 1.74 --- hash.h 2001/10/12 04:03:51 1.75 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 180,183 **** --- 178,183 ---- void DelUser(struct user *user, struct user *killer, int announce, const char *why); void ReintroduceUser(struct user *user); + typedef void (*nick_change_func_t)(struct user *user, const char *new_nick); + void reg_nick_change_func(nick_change_func_t handler); void NickChange(struct user *user, const char *new_nick); Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/main.c,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -r1.114 -r1.115 *** main.c 2001/10/02 16:04:36 1.114 --- main.c 2001/10/12 04:03:51 1.115 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 461,470 **** if ((tmp = conf_server_ping_timeout()) != -1) ping_timeout = tmp; modules_init(); - tools_init(); timeq_init(); gline_init(); sockcheck_init(); /* could be modularized */ hash_init(); - proto_init(); service_init(); conf_rlimits(); --- 459,466 ---- Index: proto.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto.c,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -r1.77 -r1.78 *** proto.c 2001/10/10 04:51:23 1.77 --- proto.c 2001/10/12 04:03:51 1.78 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 28,47 **** #include "log.h" #include "modules.h" #define PROTO_FUNC(retval, name, arglist) retval (*name) arglist; #define PROTO_VARIABLE(type, name) type name; #include "proto.h" void ! proto_init(void) { ! struct module *pmod; int failed = 0; void *addr; - pmod = module_find_loaded("proto"); - if (!pmod) { - log(MAIN_LOG, LOG_ERROR, "Unable to find protocol module\n"); - return; - } #define PROTO_FUNC(rettype, name, arglist) if (!(name = get_module_symbol(pmod, #name))) { log(MAIN_LOG, LOG_ERROR, "Protocol module does not export symbol %s\n", #name); failed++; } #define PROTO_VARIABLE(type, name) if ((addr = get_module_symbol(pmod, #name))) { name = *(type*)addr; } else { log(MAIN_LOG, LOG_ERROR, "Protocol module does not export symbol %s\n", #name); failed++; } --- 26,341 ---- #include "log.h" #include "modules.h" + #include "tools.h" #define PROTO_FUNC(retval, name, arglist) retval (*name) arglist; #define PROTO_VARIABLE(type, name) type name; #include "proto.h" + unsigned char user_inverse_modes[256]; + unsigned char channel_inverse_modes[256]; + + static void + proto_build_inverse_modes(void) { + unsigned int nn; + /* Go through and record which bit each character corresponds to. + * Since some modes don't exist in some protocols, the + * corresponding position in the *_modes string is a space; but we + * don't want to give spaces a value, so erase them afterwards. + */ + for (nn=0; proto_user_modes[nn]; nn++) { + user_inverse_modes[proto_user_modes[nn]] = nn + 1; + } + user_inverse_modes[' '] = 0; + for (nn=0; proto_channel_modes[nn]; nn++) { + channel_inverse_modes[proto_channel_modes[nn]] = nn + 1; + } + channel_inverse_modes[' '] = 0; + } + void ! mod_usermode(struct user *user, const char *mode_change) { ! unsigned long orig_modes; ! int add = 1; ! unsigned char modechar; ! ! if (!user || !mode_change || !*mode_change) return; ! orig_modes = user->modes; ! while (1) { ! switch (modechar = *mode_change++) { ! case 0: case ' ': return; ! case '+': add = 1; break; ! case '-': add = 0; break; ! default: ! if (user_inverse_modes[modechar]) { ! if (add) { ! user->modes |= (1 << (user_inverse_modes[modechar]-1)); ! } else { ! user->modes &= ~(1 << (user_inverse_modes[modechar]-1)); ! } ! } ! } ! #undef do_user_mode ! } ! /* TODO: add callback to notify things of mode changes */ ! } ! ! int ! make_usermode(struct user *user, char *out, unsigned int len) ! { ! unsigned int nn, jj=0; ! len--; /* to allow for \0 at end */ ! out[jj++] = '+'; ! for (nn=0; proto_user_modes[nn] && (jj<len); nn++) { ! if ((proto_user_modes[nn] != ' ') && (user->modes & (1 << nn))) { ! out[jj++] = proto_user_modes[nn]; ! } ! } ! out[jj++] = 0; ! return 1; ! } ! ! void ! mod_chanmode(struct channel *channel, const char *mode_change, const char *key, int limit) ! { ! int add = 1, n; ! const char *word = mode_change; ! unsigned char modechar; ! ! if (!mode_change || !*mode_change) return; ! while (*word != ' ' && *word) word++; ! while (*word == ' ') word++; ! while (1) { ! switch (modechar = *mode_change++) { ! case 0: case ' ': return; ! case '+': add = 1; break; ! case '-': add = 0; break; ! case 'k': ! if (add) { ! if (key) { ! safestrncpy(channel->key, key, sizeof(channel->key)); ! } else { ! for (n=0; *word != ' ' && *word; n++) { ! channel->key[n] = *word++; ! } ! channel->key[n] = 0; ! } ! } else { ! channel->key[0] = 0; ! } ! break; ! case 'l': ! if (add) { ! if (limit) { ! channel->limit = limit; ! } else { ! channel->limit = strtoul(word, NULL, 0); ! } ! while (*word != ' ' && *word) word++; ! while (*word == ' ') word++; ! } else { ! channel->limit = 0; ! } ! break; ! default: ! if ((n = channel_inverse_modes[modechar])) { ! if (add) { ! channel->modes |= 1 << (n-1); ! } else { ! channel->modes &= ~(1 << (n-1)); ! } ! } ! break; ! } ! } ! } ! ! int ! make_chanmode(struct channel *channel, char *out, unsigned int len) ! { ! unsigned int nn, jj=0; ! len--; /* to allow for \0 at end */ ! out[jj++] = '+'; ! for (nn=0; proto_channel_modes[nn] && (jj<len); nn++) { ! if ((proto_channel_modes[nn] != ' ') && (channel->modes & (1 << nn))) { ! out[jj++] = proto_channel_modes[nn]; ! } ! } ! if (channel->limit || channel->key[0]) { ! if (jj < len-2) { ! if (channel->limit) out[jj++] = 'l'; ! if (channel->key[0]) out[jj++] = 'k'; ! if (channel->limit) { ! if (jj < len) out[jj++] = ' '; ! jj += snprintf(out+jj, len-jj, "%d", channel->limit); ! if (jj >= len) jj = len-1; ! } ! if (channel->key[0]) { ! if (jj < len) out[jj++] = ' '; ! jj += snprintf(out+jj, len-jj, "%s", channel->key); ! if (jj >= len) jj = len-1; ! } ! } ! } ! out[jj++] = 0; ! return 1; ! } ! ! int ! verify_chanmode(const char *modes) { ! const char *word; ! int add = 1; ! unsigned char modechar; ! ! if (!modes) return 0; ! if (!*modes) return 1; ! if ((*modes != '+') && (*modes != '-')) return 0; ! word = modes; ! while (*word != ' ' && *word) word++; ! while (*word == ' ') word++; ! while (1) { ! switch (modechar = *modes++) { ! case 0: ! case ' ': ! return 1; ! case '+': add = 1; break; ! case '-': add = 0; break; ! case 'k': ! if (add && !*word) return 0; ! break; ! case 'l': ! if (add && (!*word || (strtoul(word, NULL, 0) <= 0))) return 0; ! break; ! default: ! if (!channel_inverse_modes[modechar]) return 0; ! break; ! } ! } ! } ! ! char * ! generate_hostmask(struct user *user, int options) ! { ! char *nickname, *username, *hostname; ! char *mask; ! int len, ii; ! ! /* figure out string parts */ ! if (options & GENMASK_OMITNICK) { ! nickname = NULL; ! } else if (options & GENMASK_USENICK) { ! nickname = user->nick; ! } else { ! nickname = "*"; ! } ! if (options & GENMASK_STRICT) { ! username = user->username; ! } else { ! username = alloca(strlen(user->username)+2); ! username[0] = '*'; ! strcpy(username+1, user->username + ((*user->username == '~')?1:0)); ! } ! hostname = user->hostname; ! if (options & GENMASK_STRICT) { ! /* leave hostname as is */ ! } else if ((options & GENMASK_BYIP) || !hostname[strspn(hostname, "0123456789.")]) { ! /* Should generate an IP-based hostmask. By popular acclaim, a /16 ! * hostmask is used by default. */ ! unsigned masked_ip, mask, masklen; ! masklen = 16; ! mask = ~0 << masklen; ! masked_ip = user->ip & mask; ! hostname = alloca(32); ! if (options & GENMASK_SRVXMASK) { ! sprintf(hostname, "%d.%d.%d.%d/%d", (masked_ip>>24)&0xFF, (masked_ip>>16)&0xFF, (masked_ip>>8)&0xFF, masked_ip&0xFF, masklen); ! } else { ! int ofs = 0; ! for (ii=0; ii<4; ii++) { ! if (masklen) { ! ofs += sprintf(hostname+ofs, "%d.", (masked_ip>>24)&0xFF); ! masklen -= 8; ! masked_ip <<= 8; ! } else { ! ofs += sprintf(hostname+ofs, "*."); ! } ! } ! /* Truncate the last . */ ! hostname[ofs-1] = 0; ! } ! } else { ! int cnt; ! /* This heuristic could be made smarter. Is it worth the effort? */ ! for (ii=cnt=0; hostname[ii]; ii++) { ! if (hostname[ii] == '.') cnt++; ! } ! if (cnt == 1) { ! /* only a two-level domain name; leave hostname */ ! } else if (cnt == 2) { ! for (ii=0; user->hostname[ii] != '.'; ii++) ; ! hostname = alloca(strlen(user->hostname+ii)+2); ! sprintf(hostname, "*%s", user->hostname+ii+1); ! } else { ! for (cnt=3, ii--; cnt; ii--) { ! if (user->hostname[ii] == '.') cnt--; ! } ! hostname = alloca(strlen(user->hostname+ii)+2); ! sprintf(hostname, "*%s", user->hostname+ii+1); ! } ! } ! /* Emit hostmask */ ! len = strlen(username) + strlen(hostname) + 2; ! if (nickname) { ! len += strlen(nickname) + 1; ! mask = malloc(len); ! sprintf(mask, "%s!%s@%s", nickname, username, hostname); ! } else { ! mask = malloc(len); ! sprintf(mask, "%s@%s", username, hostname); ! } ! return mask; ! } ! ! int ! user_matches_glob(struct user *user, const char *orig_glob, int include_nick) ! { ! char *glob, *marker; ! /* Make a writable copy of the glob */ ! glob = alloca(strlen(orig_glob)+1); ! strcpy(glob, orig_glob); ! /* Check the nick, if it's present */ ! if (include_nick) { ! if (!(marker = strchr(glob, '!'))) { ! log(MAIN_LOG, LOG_ERROR, "match_glob_user(\"%s\", \"%s\", %d) called, and glob doesn't include a '!'\n", user->nick, orig_glob, include_nick); ! return 0; ! } ! *marker = 0; ! if (!match_ircglob(user->nick, glob)) return 0; ! glob = marker + 1; ! } ! /* Check the ident */ ! if (!(marker = strchr(glob, '@'))) { ! log(MAIN_LOG, LOG_ERROR, "match_glob_user(\"%s\", \"%s\", %d) called, and glob doesn't include an '@'\n", user->nick, orig_glob, include_nick); ! return 0; ! } ! *marker = 0; ! if (!match_ircglob(user->username, glob)) return 0; ! glob = marker + 1; ! /* Now check the host part */ ! if (!glob[strspn(glob, "0123456789./*?")]) { ! /* Looks like an IP-based mask */ ! unsigned char userip[20]; ! sprintf(userip, "%ld.%ld.%ld.%ld", (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255); ! return match_ircglob(userip, glob); ! } else { ! /* The host part of the mask isn't IP-based */ ! return match_ircglob(user->hostname, glob); ! } ! } ! ! void ! proto_init(struct module *pmod) ! { int failed = 0; void *addr; #define PROTO_FUNC(rettype, name, arglist) if (!(name = get_module_symbol(pmod, #name))) { log(MAIN_LOG, LOG_ERROR, "Protocol module does not export symbol %s\n", #name); failed++; } #define PROTO_VARIABLE(type, name) if ((addr = get_module_symbol(pmod, #name))) { name = *(type*)addr; } else { log(MAIN_LOG, LOG_ERROR, "Protocol module does not export symbol %s\n", #name); failed++; } *************** *** 49,52 **** --- 343,347 ---- #undef PROTO_FUNC #undef PROTO_VARIABLE + proto_build_inverse_modes(); if (failed) { log(MAIN_LOG, LOG_ERROR, "%d unresolved protocol functions\n", failed); Index: proto.def =================================================================== RCS file: /cvsroot/srvx/services/src/proto.def,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** proto.def 2001/10/10 04:00:41 1.2 --- proto.def 2001/10/12 04:03:51 1.3 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 79,84 **** /****************************/ ! PROTO_VARIABLE(const char *, proto_user_modes) ! PROTO_VARIABLE(const char *, proto_channel_modes) PROTO_VARIABLE(int, proto_chanserv_joins_channels) PROTO_VARIABLE(unsigned int, proto_max_mode_args) --- 77,82 ---- /****************************/ ! PROTO_VARIABLE(const unsigned char *, proto_user_modes) ! PROTO_VARIABLE(const unsigned char *, proto_channel_modes) PROTO_VARIABLE(int, proto_chanserv_joins_channels) PROTO_VARIABLE(unsigned int, proto_max_mode_args) Index: proto.h =================================================================== RCS file: /cvsroot/srvx/services/src/proto.h,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -r1.47 -r1.48 *** proto.h 2001/10/12 02:03:34 1.47 --- proto.h 2001/10/12 04:03:51 1.48 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 28,31 **** --- 26,30 ---- struct server; struct user; + struct module; typedef void (*chanmsg_func_t) (struct user *bot, struct user *source, struct channel *chan, char *text); *************** *** 62,66 **** int user_matches_glob(struct user *user, const char *glob, int include_nick); ! void proto_init(void); /********************/ --- 61,65 ---- int user_matches_glob(struct user *user, const char *glob, int include_nick); ! void proto_init(struct module *proto_mod); /********************/ Index: proto_bahamut.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** proto_bahamut.c 2001/10/12 02:03:34 1.17 --- proto_bahamut.c 2001/10/12 04:03:51 1.18 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 1381,1386 **** /* Set protocol-specific variables */ ! proto_user_modes = "h"; ! proto_channel_modes = "rRcO"; proto_chanserv_joins_channels = 0; proto_max_mode_args = MAXNUMPARAMS; --- 1379,1384 ---- /* Set protocol-specific variables */ ! proto_user_modes = "oiws h"; ! proto_channel_modes = "psmtinrRcO"; proto_chanserv_joins_channels = 0; proto_max_mode_args = MAXNUMPARAMS; *************** *** 1448,1452 **** /* let rest of protocol stuff initialize */ ! proto_init(); return 0; }; --- 1446,1450 ---- /* let rest of protocol stuff initialize */ ! proto_init(proto_module); return 0; }; Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** proto_ircu_p10.c 2001/10/12 02:03:34 1.27 --- proto_ircu_p10.c 2001/10/12 04:03:51 1.28 *************** *** 15,20 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ */ --- 15,18 ---- *************** *** 1666,1671 **** /* Set protocol-specific variables */ ! proto_user_modes = "dkgh"; ! proto_channel_modes = ""; proto_chanserv_joins_channels = 1; proto_max_mode_args = 6; --- 1664,1669 ---- /* Set protocol-specific variables */ ! proto_user_modes = "oiwsdkgh"; ! proto_channel_modes = "psmtin"; proto_chanserv_joins_channels = 1; proto_max_mode_args = 6; *************** *** 1776,1780 **** /* let rest of protocol stuff initialize */ ! proto_init(); return 0; } --- 1774,1778 ---- /* let rest of protocol stuff initialize */ ! proto_init(proto_module); return 0; } Index: tools.h =================================================================== RCS file: /cvsroot/srvx/services/src/tools.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** tools.h 2001/10/10 04:00:41 1.15 --- tools.h 2001/10/12 04:03:51 1.16 *************** *** 29,42 **** #define disabled_string(string) (!strcasecmp((string), "off") || !strcmp((string), "0") || !strcasecmp((string), "disabled")) - struct user; - struct channel; - extern unsigned char channel_inverse_modes[256]; - - void tools_init(void); - - int getusermodes(char *sender); - void mod_usermode(struct user *user, const char *modes); - void mod_chanmode(struct channel *channel, const char *mode_change, const char *key, int limit); - int verify_chanmode(const char *modes); int split_line(unsigned char *line, int irc_colon, int argv_size, unsigned char *argv[]); --- 29,32 ---- *************** *** 44,60 **** int mmatch(const char *glob, const char *newglob); int match_ircglob(const char *text, const char *glob); - int user_matches_glob(struct user *user, const char *glob, int include_nick); int is_ircmask(const unsigned char *text); int is_gline(const unsigned char *text); - /* The "default" for generate_hostmask is to have all of these options off. */ - #define GENMASK_STRICT 1 - #define GENMASK_USENICK 2 - #define GENMASK_OMITNICK 4 /* Hurray for Kevin! */ - #define GENMASK_BYIP 8 - #define GENMASK_SRVXMASK 16 - char *generate_hostmask(struct user *user, int options); - unsigned long ParseInterval(const unsigned char *interval); unsigned long ParseVolume(const unsigned char *volume); --- 34,41 ---- *************** *** 73,85 **** const char *preposition(char *word); - int ban_match_user(struct user *user, char *ban); - int ban_match_user_host(struct user *user, char *hostmask, char *ban); DECLARE_LIST(string_buffer, char); void string_buffer_append_string(struct string_buffer *buf, const char *tail); void string_buffer_replace(struct string_buffer *buf, unsigned int from, unsigned int len, const char *repl); - - int make_chanmode(struct channel *chan, char *out, unsigned int len); - int make_usermode(struct user *user, char *out, unsigned int len); #endif /* ifdef _TOOLS_H_ */ --- 54,61 ---- |
From: Entrope <en...@us...> - 2001-10-12 03:42:06
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv27604/src Modified Files: Tag: rel-1_0 hash.h hash.c Log Message: fix possible bug in (unused) callback function, and comment why it's a hazard Index: hash.h =================================================================== RCS file: /cvsroot/srvx/services/src/hash.h,v retrieving revision 1.52.2.10 retrieving revision 1.52.2.11 diff -C2 -r1.52.2.10 -r1.52.2.11 *** hash.h 2001/09/04 18:39:36 1.52.2.10 --- hash.h 2001/10/12 03:42:02 1.52.2.11 *************** *** 190,194 **** void DelUser(userNode* user, userNode *killer, int announce, const char *why); void ReintroduceUser(userNode* user); ! typedef void (*nick_change_func_t)(struct userNode *user, const char *oldnick); void reg_nick_change_func(nick_change_func_t handler); void NickChange(userNode* user, const char *new_nick); --- 190,194 ---- void DelUser(userNode* user, userNode *killer, int announce, const char *why); void ReintroduceUser(userNode* user); ! typedef void (*nick_change_func_t)(struct userNode *user, const char *new_nick); void reg_nick_change_func(nick_change_func_t handler); void NickChange(userNode* user, const char *new_nick); Index: hash.c =================================================================== RCS file: /cvsroot/srvx/services/src/hash.c,v retrieving revision 1.121.2.15 retrieving revision 1.121.2.16 diff -C2 -r1.121.2.15 -r1.121.2.16 *** hash.c 2001/09/04 21:30:19 1.121.2.15 --- hash.c 2001/10/12 03:42:02 1.121.2.16 *************** *** 492,496 **** void NickChange(userNode* user, const char *new_nick) { - char old_nick[NICKLEN+1]; unsigned int nn; --- 492,495 ---- *************** *** 501,508 **** dict_remove(clients, user->nick); ! /* save old nick for callbacks */ ! safestrncpy(old_nick, user->nick, sizeof(old_nick)); ! /* copy new nick */ safestrncpy(user->nick, new_nick, sizeof(user->nick)); --- 500,514 ---- dict_remove(clients, user->nick); ! /* Make callbacks for nick changes. ! * This needs to be done with the old nick still in place, else ! * dict lookups based on user->nick will miss the user. ! * It is safe to re-insert using new_nick (which may be a ! * temporary pointer) since the later value of user->nick will be ! * correct. */ ! for (nn=0; nn<ncf2_used; nn++) { ! ncf2_list[nn](user, new_nick); ! } ! /* copy new nick into struct */ safestrncpy(user->nick, new_nick, sizeof(user->nick)); *************** *** 512,519 **** if (IsLocal(user->numeric)) irc_nick(user); - /* make callbacks */ - for (nn=0; nn<ncf2_used; nn++) { - ncf2_list[nn](user, old_nick); - } } --- 518,521 ---- |
From: Entrope <en...@us...> - 2001-10-12 02:03:37
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv2600/src Modified Files: tools.c service.c proto_ircu_p10.c proto_bahamut.c proto.h modules.h modules.c mod_common.c hash.h hash.c Makefile.am Added Files: authserv.h authserv.c Log Message: start fleshing out some more services rearrange protocol stuff a little (should fix some problems) --- NEW FILE --- /* authserv.h - Authentication service * Copyright 2001 srvx Development Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if !defined(AUTHSERV_H) #define AUTHSERV_H #include <sys/types.h> #include "common.h" #define AUTHSERV_MAJOR 0 #define AUTHSERV_MINOR 0 #define AUTHSERV_REVISION 0 #define AUTHSERV_VERSION MAKE_VERSION(AUTHSERV_MAJOR, AUTHSERV_MINOR, AUTHSERV_REVISION) /* HI_FLAG_* go into handle_info.flags */ #define HI_FLAG_OPER_SUSPENDED 0x00000001 #define HI_FLAG_USE_PRIVMSG 0x00000002 #define HI_FLAG_HELPER 0x00000004 #define HI_FLAG_HELPING 0x00000008 #define HI_FLAG_SUSPENDED 0x00000010 #define HI_FLAG_MIRC_COLOR 0x00000020 #define HI_FLAG_FROZEN 0x00000040 #define HI_FLAG_NODELETE 0x00000080 /* Flag characters for the above. First char is LSB, etc. */ #define HANDLE_FLAGS "Sphgscfn" /* HI_STYLE_* go into handle_info.userlist_style */ #define HI_STYLE_DEF 'd' #define HI_STYLE_ZOOT 'Z' #define HI_DEFAULT_FLAGS (HI_FLAG_MIRC_COLOR) #define HI_DEFAULT_STYLE HI_STYLE_DEF #define HANDLE_FLAGGED(hi, tok) ((hi)->flags & HI_FLAG_##tok) #define HANDLE_SET_FLAG(hi, tok) ((hi)->flags |= HI_FLAG_##tok) #define HANDLE_TOGGLE_FLAG(hi, tok) ((hi)->flags ^= HI_FLAG_##tok) #define HANDLE_CLEAR_FLAG(hi, tok) ((hi)->flags &= ~HI_FLAG_##tok) #define IsHelping(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPING)) struct handle_info { struct nick_info *nicks; /* linked list of owned nicks */ struct string_list *masks; struct user *users; struct chanList *channels; unsigned long flags; unsigned int opserv_level; unsigned int screen_width; time_t registered, lastseen; char handle[31]; char passwd[MD5_CRYPT_LENGTH+1]; char info[MAXLEN]; char userlist_style; }; struct handle_info *get_handle_info(const char *handle); struct handle_info *smart_get_handle_info(struct user *bot, struct user *source, const unsigned char *name); /* auth_funcs are called when a user gets a new handle_info. They are * called after it has been determined that the user may authenticate * under the new handle, but *before* their handle_info is changed -- * so user->handle_info still points to their previous handle (if they * were previously authenticated). */ typedef void (*auth_func_t)(struct user *user, struct handle_info *new_handle); void reg_auth_func(auth_func_t func); /* unreg_funcs are called right before a handle is unregistered. * `user' is the person who caused the handle to be unregistered (either a * client authed to the handle, or an oper). */ typedef void (*unreg_func_t)(struct user *user, struct handle_info *handle); void reg_unreg_func(unreg_func_t func); #endif --- NEW FILE --- /* authserv.c - Authentication service * Copyright 2001 srvx Development Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "config.h" #include "modules.h" #include "authserv.h" /* TODO: implement authserv */ struct handle_info *get_handle_info(const char *handle); struct handle_info *smart_get_handle_info(struct user *bot, struct user *source, const unsigned char *name); void reg_auth_func(auth_func_t func); void reg_unreg_func(unreg_func_t func); LIB_LOAD_FUNC(mod_init) { (void)lib; /* TODO: implement authserv's mod_init */ return 0; } Index: tools.c =================================================================== RCS file: /cvsroot/srvx/services/src/tools.c,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -r1.98 -r1.99 *** tools.c 2001/10/10 04:00:41 1.98 --- tools.c 2001/10/12 02:03:34 1.99 *************** *** 43,235 **** #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]; - - static void - tools_build_inverse_modes(void) { - unsigned int nn; - /* Go through and record which bit each character corresponds to. - * Since some modes don't exist in some protocols, the - * corresponding position in the *_modes string is a space; but we - * don't want to give spaces a value, so erase them afterwards. - */ - for (nn=0; user_modes[nn]; nn++) { - user_inverse_modes[user_modes[nn]] = nn + 1; - } - user_inverse_modes[' '] = 0; - for (nn=0; channel_modes[nn]; nn++) { - channel_inverse_modes[channel_modes[nn]] = nn + 1; - } - channel_inverse_modes[' '] = 0; - } - - void - mod_usermode(struct user *user, const char *mode_change) { - unsigned long orig_modes; - int add = 1; - unsigned char modechar; - - if (!user || !mode_change || !*mode_change) return; - orig_modes = user->modes; - while (1) { - switch (modechar = *mode_change++) { - case 0: case ' ': return; - case '+': add = 1; break; - case '-': add = 0; break; - default: - if (user_inverse_modes[modechar]) { - if (add) { - user->modes |= (1 << (user_inverse_modes[modechar]-1)); - } else { - user->modes &= ~(1 << (user_inverse_modes[modechar]-1)); - } - } - } - #undef do_user_mode - } - /* TODO: add callback to notify things of mode changes */ - } - - int - make_usermode(struct user *user, char *out, unsigned int len) - { - unsigned int nn, jj=0; - len--; /* to allow for \0 at end */ - out[jj++] = '+'; - for (nn=0; user_modes[nn] && (jj<len); nn++) { - if ((user_modes[nn] != ' ') && (user->modes & (1 << nn))) { - out[jj++] = user_modes[nn]; - } - } - out[jj++] = 0; - return 1; - } - - void - mod_chanmode(struct channel *channel, const char *mode_change, const char *key, int limit) - { - int add = 1, n; - const char *word = mode_change; - unsigned char modechar; - - if (!mode_change || !*mode_change) return; - while (*word != ' ' && *word) word++; - while (*word == ' ') word++; - while (1) { - switch (modechar = *mode_change++) { - case 0: case ' ': return; - case '+': add = 1; break; - case '-': add = 0; break; - case 'k': - if (add) { - if (key) { - safestrncpy(channel->key, key, sizeof(channel->key)); - } else { - for (n=0; *word != ' ' && *word; n++) { - channel->key[n] = *word++; - } - channel->key[n] = 0; - } - } else { - channel->key[0] = 0; - } - break; - case 'l': - if (add) { - if (limit) { - channel->limit = limit; - } else { - channel->limit = strtoul(word, NULL, 0); - } - while (*word != ' ' && *word) word++; - while (*word == ' ') word++; - } else { - channel->limit = 0; - } - break; - default: - if ((n = channel_inverse_modes[modechar])) { - if (add) { - channel->modes |= 1 << (n-1); - } else { - channel->modes &= ~(1 << (n-1)); - } - } - break; - } - } - } - int - make_chanmode(struct channel *channel, char *out, unsigned int len) - { - unsigned int nn, jj=0; - len--; /* to allow for \0 at end */ - out[jj++] = '+'; - for (nn=0; channel_modes[nn] && (jj<len); nn++) { - if ((channel_modes[nn] != ' ') && (channel->modes & (1 << nn))) { - out[jj++] = channel_modes[nn]; - } - } - if (channel->limit || channel->key[0]) { - if (jj < len-2) { - if (channel->limit) out[jj++] = 'l'; - if (channel->key[0]) out[jj++] = 'k'; - if (channel->limit) { - if (jj < len) out[jj++] = ' '; - jj += snprintf(out+jj, len-jj, "%d", channel->limit); - if (jj >= len) jj = len-1; - } - if (channel->key[0]) { - if (jj < len) out[jj++] = ' '; - jj += snprintf(out+jj, len-jj, "%s", channel->key); - if (jj >= len) jj = len-1; - } - } - } - out[jj++] = 0; - return 1; - } - - int - verify_chanmode(const char *modes) - { - const char *word; - int add = 1; - unsigned char modechar; - - if (!modes) return 0; - if (!*modes) return 1; - if ((*modes != '+') && (*modes != '-')) return 0; - word = modes; - while (*word != ' ' && *word) word++; - while (*word == ' ') word++; - while (1) { - switch (modechar = *modes++) { - case 0: - case ' ': - return 1; - case '+': add = 1; break; - case '-': add = 0; break; - case 'k': - if (add && !*word) return 0; - break; - case 'l': - if (add && (!*word || (strtoul(word, NULL, 0) <= 0))) return 0; - break; - default: - if (!channel_inverse_modes[modechar]) return 0; - break; - } - } - } - - int split_line(unsigned char *line, int irc_colon, int argv_size, unsigned char *argv[]) { --- 43,50 ---- *************** *** 406,446 **** int - user_matches_glob(struct user *user, const char *orig_glob, int include_nick) - { - char *glob, *marker; - /* Make a writable copy of the glob */ - glob = alloca(strlen(orig_glob)+1); - strcpy(glob, orig_glob); - /* Check the nick, if it's present */ - if (include_nick) { - if (!(marker = strchr(glob, '!'))) { - log(MAIN_LOG, LOG_ERROR, "match_glob_user(\"%s\", \"%s\", %d) called, and glob doesn't include a '!'\n", user->nick, orig_glob, include_nick); - return 0; - } - *marker = 0; - if (!match_ircglob(user->nick, glob)) return 0; - glob = marker + 1; - } - /* Check the ident */ - if (!(marker = strchr(glob, '@'))) { - log(MAIN_LOG, LOG_ERROR, "match_glob_user(\"%s\", \"%s\", %d) called, and glob doesn't include an '@'\n", user->nick, orig_glob, include_nick); - return 0; - } - *marker = 0; - if (!match_ircglob(user->username, glob)) return 0; - glob = marker + 1; - /* Now check the host part */ - if (isdigit(*glob) && !glob[strspn(glob, "0123456789./*?")]) { - /* Looks like an IP-based mask */ - unsigned char userip[20]; - sprintf(userip, "%ld.%ld.%ld.%ld", (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255); - return match_ircglob(userip, glob); - } else { - /* The host part of the mask isn't IP-based */ - return match_ircglob(user->hostname, glob); - } - } - - int is_ircmask(const unsigned char *text) { --- 221,224 ---- *************** *** 485,570 **** } - char * - generate_hostmask(struct user *user, int options) - { - char *nickname, *username, *hostname; - char *mask; - int len, ii; - - /* figure out string parts */ - if (options & GENMASK_OMITNICK) { - nickname = NULL; - } else if (options & GENMASK_USENICK) { - nickname = user->nick; - } else { - nickname = "*"; - } - if (options & GENMASK_STRICT) { - username = user->username; - } else { - username = alloca(strlen(user->username)+2); - username[0] = '*'; - strcpy(username+1, user->username + ((*user->username == '~')?1:0)); - } - hostname = user->hostname; - if (options & GENMASK_STRICT) { - /* leave hostname as is */ - } else if ((options & GENMASK_BYIP) || !hostname[strspn(hostname, "0123456789.")]) { - /* Should generate an IP-based hostmask. By popular acclaim, a /16 - * hostmask is used by default. */ - unsigned masked_ip, mask, masklen; - masklen = 16; - mask = ~0 << masklen; - masked_ip = user->ip & mask; - hostname = alloca(32); - if (options & GENMASK_SRVXMASK) { - sprintf(hostname, "%d.%d.%d.%d/%d", (masked_ip>>24)&0xFF, (masked_ip>>16)&0xFF, (masked_ip>>8)&0xFF, masked_ip&0xFF, masklen); - } else { - int ofs = 0; - for (ii=0; ii<4; ii++) { - if (masklen) { - ofs += sprintf(hostname+ofs, "%d.", (masked_ip>>24)&0xFF); - masklen -= 8; - masked_ip <<= 8; - } else { - ofs += sprintf(hostname+ofs, "*."); - } - } - /* Truncate the last . */ - hostname[ofs-1] = 0; - } - } else { - int cnt; - /* This heuristic could be made smarter. Is it worth the effort? */ - for (ii=cnt=0; hostname[ii]; ii++) { - if (hostname[ii] == '.') cnt++; - } - if (cnt == 1) { - /* only a two-level domain name; leave hostname */ - } else if (cnt == 2) { - for (ii=0; user->hostname[ii] != '.'; ii++) ; - hostname = alloca(strlen(user->hostname+ii)+2); - sprintf(hostname, "*%s", user->hostname+ii+1); - } else { - for (cnt=3, ii--; cnt; ii--) { - if (user->hostname[ii] == '.') cnt--; - } - hostname = alloca(strlen(user->hostname+ii)+2); - sprintf(hostname, "*%s", user->hostname+ii+1); - } - } - /* Emit hostmask */ - len = strlen(username) + strlen(hostname) + 2; - if (nickname) { - len += strlen(nickname) + 1; - mask = malloc(len); - sprintf(mask, "%s!%s@%s", nickname, username, hostname); - } else { - mask = malloc(len); - sprintf(mask, "%s@%s", username, hostname); - } - return mask; - } - static long TypeLength(char type) --- 263,266 ---- *************** *** 823,831 **** strcpy(buf->list+from, repl); } - - void - tools_init(void) - { - tools_build_inverse_modes(); - } - --- 519,520 ---- Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/service.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** service.c 2001/10/10 04:51:23 1.4 --- service.c 2001/10/12 02:03:34 1.5 *************** *** 25,28 **** --- 25,29 ---- #include "dict.h" + #include "messages.h" #include "proto.h" #include "rules.h" *************** *** 37,41 **** static struct module *service_module; static dict_t service_templates; - #define SINST(USER) ((USER)->service) void --- 38,41 ---- *************** *** 66,70 **** chan_name = argv[0]; } else { ! /* TODO: whine */ } } else if ((argc > 1) && (argv[1][0] == '#')) { --- 66,71 ---- chan_name = argv[0]; } else { ! send_message(source, bot, MSG_INVALID_CHANNEL); ! return; } } else if ((argc > 1) && (argv[1][0] == '#')) { *************** *** 86,106 **** } if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !chan) { ! /* TODO: whine */ return; } - /* TODO: check for authed state and whine if not */ - if ((cmd->base->flags & (1 << REQUIRE_AUTHED)) && 0) { - } /* Fill in rule context and evaluate it */ rule_ctx.user = source; rule_ctx.channel = chan; if (!expression_evaluate(cmd->rule ? cmd->rule : cmd->base->default_rule, &rule_ctx)) { ! /* TODO: whine */ ! return; ! } ! if (cmd->base->function(source, bot, chan, argc-shift, argv+shift)) { ! /* TODO: whine or something */ return; } } --- 87,101 ---- } if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !chan) { ! send_message(source, bot, MSG_INVALID_CHANNEL); return; } /* Fill in rule context and evaluate it */ rule_ctx.user = source; rule_ctx.channel = chan; if (!expression_evaluate(cmd->rule ? cmd->rule : cmd->base->default_rule, &rule_ctx)) { ! send_message(source, bot, N_("Access to $b%s$b denied."), argv[shift]); return; } + cmd->base->function(source, bot, chan, argc-shift, argv+shift); } Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** proto_ircu_p10.c 2001/10/10 04:00:41 1.26 --- proto_ircu_p10.c 2001/10/12 02:03:34 1.27 *************** *** 51,60 **** extern int ping_freq, ping_timeout; - const char *proto_user_modes = "dkgh"; - const char *proto_channel_modes = ""; - int proto_chanserv_joins_channels = 1; - unsigned int proto_max_mode_args = 6; - unsigned int proto_max_channel_bans = 30; - static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); --- 51,54 ---- *************** *** 1445,1449 **** } ! if (IsLocal(user) && IsService(user)) { /* TODO: rate limit this so silly things don't happen. */ ReintroduceUser(user); --- 1439,1443 ---- } ! if (IsLocal(user) && user->service) { /* TODO: rate limit this so silly things don't happen. */ ReintroduceUser(user); *************** *** 1671,1674 **** --- 1665,1675 ---- proto_module = module_register("proto", MAKE_VERSION(0, 0, 0), NULL, lib); + /* Set protocol-specific variables */ + proto_user_modes = "dkgh"; + proto_channel_modes = ""; + proto_chanserv_joins_channels = 1; + proto_max_mode_args = 6; + proto_max_channel_bans = 30; + /* initialize data structures */ for (i=0; i<ArrayLength(servers_num); i++) { *************** *** 1773,1776 **** --- 1774,1780 ---- /* register exit functions */ reg_exit_func(free_parse_misc); + + /* let rest of protocol stuff initialize */ + proto_init(); return 0; } Index: proto_bahamut.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** proto_bahamut.c 2001/10/10 04:00:41 1.16 --- proto_bahamut.c 2001/10/12 02:03:34 1.17 *************** *** 52,61 **** extern int ping_freq, ping_timeout; - const char *proto_user_modes = " h"; - const char *proto_channel_modes = " rRcO"; - int proto_chanserv_joins_channels = 0; - unsigned int proto_max_mode_args = MAXNUMPARAMS; - unsigned int proto_max_channel_bans = 30; - static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); --- 52,55 ---- *************** *** 109,113 **** #define CMD_ADMIN "ADMIN" #define CMD_AWAY "AWAY" - #define CMD_BURST "BURST" #define CMD_CAPAB "CAPAB" #define CMD_CLOSE "CLOSE" --- 103,106 ---- *************** *** 120,125 **** #define CMD_DIE "DIE" #define CMD_DNS "DNS" - #define CMD_EOB "END_OF_BURST" - #define CMD_EOB_ACK "EOB_ACK" #define CMD_ERROR "ERROR" #define CMD_GLINE "GLINE" --- 113,116 ---- *************** *** 670,674 **** * server; it was introduced during link authentication) */ ! /* TODO */ /* burst local nicks */ --- 661,665 ---- * server; it was introduced during link authentication) */ ! /* TODO: burst juped servers */ /* burst local nicks */ *************** *** 1255,1259 **** } ! if (IsLocal(user) && IsService(user)) { /* TODO: rate limit this so silly things don't happen. */ ReintroduceUser(user); --- 1246,1250 ---- } ! if (IsLocal(user) && user->service) { /* TODO: rate limit this so silly things don't happen. */ ReintroduceUser(user); *************** *** 1388,1394 **** /* Register things with module registry */ proto_module = module_register("proto", MAKE_VERSION(PROTO_INTERFACE_MAJOR, PROTO_INTERFACE_MINOR, 0), NULL, lib); /* set up command dictionary */ irc_func_dict = dict_new(); - dict_insert(irc_func_dict, CMD_BURST, cmd_dummy); /* just a marker */ dict_insert(irc_func_dict, CMD_CAPAB, cmd_capab); dict_insert(irc_func_dict, CMD_CREATE, cmd_create); --- 1379,1392 ---- /* Register things with module registry */ proto_module = module_register("proto", MAKE_VERSION(PROTO_INTERFACE_MAJOR, PROTO_INTERFACE_MINOR, 0), NULL, lib); + + /* Set protocol-specific variables */ + proto_user_modes = "h"; + proto_channel_modes = "rRcO"; + proto_chanserv_joins_channels = 0; + proto_max_mode_args = MAXNUMPARAMS; + proto_max_channel_bans = 30; + /* set up command dictionary */ irc_func_dict = dict_new(); dict_insert(irc_func_dict, CMD_CAPAB, cmd_capab); dict_insert(irc_func_dict, CMD_CREATE, cmd_create); *************** *** 1448,1451 **** --- 1446,1452 ---- /* create self server */ AddServer(NULL, conf_server_name(), 0, boot_time, now, conf_server_desc()); + + /* let rest of protocol stuff initialize */ + proto_init(); return 0; }; Index: proto.h =================================================================== RCS file: /cvsroot/srvx/services/src/proto.h,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -r1.46 -r1.47 *** proto.h 2001/10/10 04:00:41 1.46 --- proto.h 2001/10/12 02:03:34 1.47 *************** *** 38,44 **** #define MODE_CHANGE_BAN 0x008 - #define MAXLEN 512 - #define MAXNUMPARAMS 200 - #define MIN_LINE_SIZE 40 #define MAX_LINE_SIZE 450 --- 38,41 ---- *************** *** 46,49 **** --- 43,65 ---- typedef char *(*expand_func_t)(const char *variable); void send_message(struct user *dest, struct user *src, const char *format, ...); + + extern unsigned char user_inverse_modes[256]; + void mod_usermode(struct user *user, const char *modes); + int make_usermode(struct user *user, char *out, unsigned int len); + + extern unsigned char channel_inverse_modes[256]; + void mod_chanmode(struct channel *channel, const char *mode_change, const char *key, int limit); + int verify_chanmode(const char *modes); + int make_chanmode(struct channel *chan, char *out, unsigned int len); + + /* The "default" for generate_hostmask is to have all of these options off. */ + #define GENMASK_STRICT 1 + #define GENMASK_USENICK 2 + #define GENMASK_OMITNICK 4 /* Hurray for Kevin! */ + #define GENMASK_BYIP 8 + #define GENMASK_SRVXMASK 16 + char *generate_hostmask(struct user *user, int options); + int user_matches_glob(struct user *user, const char *glob, int include_nick); + void proto_init(void); Index: modules.h =================================================================== RCS file: /cvsroot/srvx/services/src/modules.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** modules.h 2001/10/10 04:00:41 1.8 --- modules.h 2001/10/12 02:03:34 1.9 *************** *** 60,69 **** /* In module_command.flags, bit 1<<N corresponds to (enum command_flag)N. */ enum command_flag { - REQUIRE_AUTHED, TAKES_CHANNEL, REQUIRE_CHANNEL, }; ! #define MODULE_COMMAND(NAME) int NAME(struct user *user, struct user *bot, struct channel *channel, unsigned int argc, unsigned char *argv[]) /* Represents a command loaded from a module. */ --- 60,68 ---- /* In module_command.flags, bit 1<<N corresponds to (enum command_flag)N. */ enum command_flag { TAKES_CHANNEL, REQUIRE_CHANNEL, }; ! #define MODULE_COMMAND(NAME) void NAME(struct user *source, struct user *bot, struct channel *channel, unsigned int argc, unsigned char *argv[]) /* Represents a command loaded from a module. */ Index: modules.c =================================================================== RCS file: /cvsroot/srvx/services/src/modules.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** modules.c 2001/10/10 04:00:41 1.17 --- modules.c 2001/10/12 02:03:34 1.18 *************** *** 73,77 **** struct shared_lib *lib = malloc(sizeof(*lib)); ! if (!(lib->handle = dlopen(so_name, RTLD_NOW))) { free(lib); return NULL; --- 73,77 ---- struct shared_lib *lib = malloc(sizeof(*lib)); ! if (!(lib->handle = dlopen(so_name, RTLD_GLOBAL|RTLD_LAZY))) { free(lib); return NULL; Index: mod_common.c =================================================================== RCS file: /cvsroot/srvx/services/src/mod_common.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** mod_common.c 2001/10/10 04:51:23 1.4 --- mod_common.c 2001/10/12 02:03:34 1.5 *************** *** 22,25 **** --- 22,26 ---- #include <stdlib.h> + #include "authserv.h" #include "hash.h" #include "messages.h" *************** *** 31,35 **** #include "mod_common.h" ! static struct module *common_module; /* Basic approach for help files: --- 32,36 ---- #include "mod_common.h" ! static struct module *mod_common_module; /* Basic approach for help files: *************** *** 41,53 **** * service template, look up the appropriate module's raw help entry, * and prefix the contents of that topic with the bound command name. ! * For instance, in mod_authserv_admin.help: * "oset" { * "" "This command lets opers set stuff."; * "options" "blah blah blah"; * }; ! * If "oset" was bound to "oper-set" in the service template, it would ! * result in the following help bindings: * "oper-set" "This command lets opers set stuff."; * "oper-set options" "blah blah blah"; */ static void --- 42,57 ---- * service template, look up the appropriate module's raw help entry, * and prefix the contents of that topic with the bound command name. ! * For instance, the following might be in mod_authserv_admin.help: * "oset" { * "" "This command lets opers set stuff."; * "options" "blah blah blah"; * }; ! * If "oset" were bound to "oper-set" in the service template, it ! * would result in the following help bindings: * "oper-set" "This command lets opers set stuff."; * "oper-set options" "blah blah blah"; + * + * There are also "miscellaneous" help entries, like "help nemesis". + * These are read first and thus get the highest priority. */ static void *************** *** 70,75 **** cstn = NULL; if (!cstn->help) { ! send_message(user, bot, N_("Helpfile missing.")); ! return 0; } if (argc < 2) { --- 74,79 ---- cstn = NULL; if (!cstn->help) { ! send_message(source, bot, N_("Helpfile missing.")); ! return; } if (argc < 2) { *************** *** 80,88 **** } if (!(data = dict_find(cstn->help, topic, NULL))) { ! send_message(user, bot, N_("No help on that topic.")); ! return 0; } ! send_message(user, bot, "%s", data); ! return 0; } --- 84,91 ---- } if (!(data = dict_find(cstn->help, topic, NULL))) { ! send_message(source, bot, N_("No help on that topic.")); ! return; } ! send_message(source, bot, "%s", data); } *************** *** 93,97 **** (void)channel; (void)argc; (void)argv; gettimeofday(&start, NULL); ! common_readhelp(bot, user); gettimeofday(&stop, NULL); stop.tv_sec -= start.tv_sec; --- 96,100 ---- (void)channel; (void)argc; (void)argv; gettimeofday(&start, NULL); ! common_readhelp(bot, source); gettimeofday(&stop, NULL); stop.tv_sec -= start.tv_sec; *************** *** 101,107 **** stop.tv_usec += 1000000; } ! send_message(user, bot, N_("Loaded help files for $b%s$b in "FMT_TIME_T".%06lu seconds."), bot->nick, stop.tv_sec, stop.tv_usec); ! return 0; ! return 0; } --- 104,108 ---- stop.tv_usec += 1000000; } ! send_message(source, bot, N_("Loaded help files for $b%s$b in "FMT_TIME_T".%06lu seconds."), bot->nick, stop.tv_sec, stop.tv_usec); } *************** *** 111,115 **** unsplit_string(argv+1, argc-1); gettimeofday(&start, NULL); ! service_chanmsg(bot, user, channel, argv[1]); gettimeofday(&stop, NULL); stop.tv_sec -= start.tv_sec; --- 112,116 ---- unsplit_string(argv+1, argc-1); gettimeofday(&start, NULL); ! service_chanmsg(bot, source, channel, argv[1]); gettimeofday(&stop, NULL); stop.tv_sec -= start.tv_sec; *************** *** 119,167 **** stop.tv_usec += 1000000; } ! send_message(user, bot, N_("Command $b%s$b finished in "FMT_TIME_T".%06lu seconds."), argv[1], stop.tv_sec, stop.tv_usec); ! return 0; } static MODULE_COMMAND(cmd_write) { ! (void)user; (void)bot; (void)channel; (void)argc; (void)argv; /* TODO: implement cmd_write */ - return 0; - } - - /* TODO: unkludge IsHelping() */ - #define IsHelping(USER) 1 - - static MODULE_COMMAND(cmd_god) - { - int new_helping; - (void)channel; - - if (argc > 1) { - if (enabled_string(argv[1])) new_helping = 1; - else if (disabled_string(argv[1])) new_helping = 0; - else { - send_message(user, bot, MSG_INVALID_BINARY, argv[1]); - return 0; - } - } else { - new_helping = !IsHelping(user); - } - if (new_helping) { - if (IsHelping(user)) { - send_message(user, bot, N_("You already have security override enabled.")); - return 0; - } - /* TODO: mark user as helping */ - send_message(user, bot, N_("Security override has been enabled.")); - } else { - if (!IsHelping(user)) { - send_message(user, bot, N_("You already have security override disabled.")); - return 0; - } - /* TODO: mark user as not helping */ - send_message(user, bot, N_("Security override has been disabled.")); - } - return 0; } --- 120,130 ---- stop.tv_usec += 1000000; } ! send_message(source, bot, N_("Command $b%s$b finished in "FMT_TIME_T".%06lu seconds."), argv[1], stop.tv_sec, stop.tv_usec); } static MODULE_COMMAND(cmd_write) { ! (void)source; (void)bot; (void)channel; (void)argc; (void)argv; /* TODO: implement cmd_write */ } *************** *** 173,177 **** { "timecmd", 0, NULL, cmd_timecmd }, { "write", 0, NULL, cmd_write }, - { "god", 0, NULL, cmd_god }, { NULL, 0, 0, NULL }, }; --- 136,139 ---- *************** *** 185,194 **** module_deplist_init(&deps); module_deplist_append(&deps, &hash_dependency); ! common_module = module_register("common", COMMON_VERSION, &deps, lib); ! if (!common_module) return 1; /* Register functions */ for (nn=0; cmds[nn].name; nn++) { ! if (module_define_command(common_module, cmds+nn)) return 2+nn; } --- 147,156 ---- module_deplist_init(&deps); module_deplist_append(&deps, &hash_dependency); ! mod_common_module = module_register("mod_common", COMMON_VERSION, &deps, lib); ! if (!mod_common_module) return 1; /* Register functions */ for (nn=0; cmds[nn].name; nn++) { ! if (module_define_command(mod_common_module, cmds+nn)) return 2+nn; } Index: hash.h =================================================================== RCS file: /cvsroot/srvx/services/src/hash.h,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -r1.73 -r1.74 *** hash.h 2001/10/10 04:00:41 1.73 --- hash.h 2001/10/12 02:03:34 1.74 *************** *** 42,86 **** #define RFC1459_MODENODE_MODE_CHARS "ov" - /* in channel->modes */ - #define MODE_PRIVATE 0x0001 /* Private (+p) */ - #define MODE_SECRET 0x0002 /* Secret (+s); exclusive of MODE_PRIVATE */ - #define MODE_MODERATED 0x0004 /* Moderated (+m) */ - #define MODE_TOPICLIMIT 0x0008 /* Topic semi-locked (+t) */ - #define MODE_INVITEONLY 0x0010 /* Invite only (+i) */ - #define MODE_NOPRIVMSGS 0x0020 /* No outside privmsgs (+n) */ - #define MODE_KEY 0x0040 /* Actually only used by ChanServ */ - #define MODE_LIMIT 0x0080 /* Actually only used by ChanServ */ - #define MODE_REGISTERED 0x0100 /* Channel is registered (Bahamut; +r) */ - #define MODE_REGONLY 0x0200 /* Only auth'ed users may join (Bahamut; +R) */ - #define MODE_NOCOLOR 0x0400 /* No colored msgs to channel (Bahamut; +c) */ - #define MODE_OPERONLY 0x0800 /* Only irc operators may join (Bahamut; +O) */ - #define RFC1459_CHANNEL_MODES (MODE_PRIVATE|MODE_SECRET|MODE_MODERATED|MODE_TOPICLIMIT|MODE_INVITEONLY|MODE_NOPRIVMSGS) - #define RFC1459_CHANNEL_MODE_CHARS "psmtin" - - /* in userNode->modes */ - #define FLAGS_OPER 0x0001 /* IRC Operator +o */ - #define FLAGS_INVISIBLE 0x0002 /* invisible +i */ - #define FLAGS_WALLOP 0x0004 /* receives wallops +w */ - #define FLAGS_SERVNOTICE 0x0008 /* receives server notices +s */ - #define FLAGS_DEAF 0x0010 /* deaf +d */ - #define FLAGS_SERVICE 0x0020 /* cannot be kicked, killed or deoped +k */ - #define FLAGS_GLOBAL 0x0040 /* receives global messages +g */ - #define FLAGS_HELPER 0x0080 /* (network?) helper +h */ - #define FLAGS_PERSISTENT 0x0100 /* for reserved nicks, this isn't just one-shot */ - #define FLAGS_GAGGED 0x0200 /* for gagged users */ - #define FLAGS_AWAY 0x0400 /* for away users */ - #define RFC1459_USER_MODES (FLAGS_OPER|FLAGS_INVISIBLE|FLAGS_WALLOP|FLAGS_SERVNOTICE) - #define RFC1459_USER_MODE_CHARS "oiws" - - #define IsOper(x) ((x)->modes & FLAGS_OPER) - #define IsService(x) ((x)->modes & FLAGS_SERVICE) - #define IsInvisible(x) ((x)->modes & FLAGS_INVISIBLE) - #define IsGlobal(x) ((x)->modes & FLAGS_GLOBAL) - #define IsWallOp(x) ((x)->modes & FLAGS_WALLOP) - #define IsServNotice(x) ((x)->modes & FLAGS_SERVNOTICE) - #define IsHelper(x) ((x)->modes & FLAGS_HELPER) - #define IsGagged(x) ((x)->modes & FLAGS_GAGGED) - #define IsAway(x) ((x)->modes & FLAGS_AWAY) - #define NICKLEN 31 #define USERLEN 11 --- 42,45 ---- *************** *** 98,134 **** DECLARE_LIST(serverList, struct server*); ! struct user { ! unsigned long dead : 1; ! unsigned long modes; /* user flags +isw etc... */ ! unsigned long ip; ! time_t timestamp; unsigned char nick[NICKLEN]; /* Unique name of the client */ unsigned char username[USERLEN]; /* Username on client's machine */ unsigned char info[REALLEN]; /* Additional client information */ ! unsigned char hostname[HOSTLEN]; struct server *uplink; struct modeList channels; struct user_proto *proto; struct service_instance *service; }; typedef unsigned long channel_mode_t; struct channel { char name[CHANNELLEN]; - channel_mode_t modes; - unsigned int limit; - time_t timestamp; /* creation time */ - char key[KEYLEN]; - char topic[TOPICLEN]; char topic_nick[NICKLEN]; time_t topic_time; /* time topic set */ - struct modeList members; struct banList banlist; struct channel_proto *proto; --- 57,121 ---- DECLARE_LIST(serverList, struct server*); ! /* in (struct user*)->modes */ ! #define FLAGS_OPER 0x0001 /* IRC Operator +o */ ! #define FLAGS_INVISIBLE 0x0002 /* invisible +i */ ! #define FLAGS_WALLOP 0x0004 /* receives wallops +w */ ! #define FLAGS_SERVNOTICE 0x0008 /* receives server notices +s */ ! #define FLAGS_DEAF 0x0010 /* deaf +d */ ! #define FLAGS_SERVICE 0x0020 /* cannot be kicked, killed or deoped +k */ ! #define FLAGS_GLOBAL 0x0040 /* receives global messages +g */ ! #define FLAGS_HELPER 0x0080 /* (network?) helper +h */ ! #define FLAGS_GAGGED 0x0100 /* ignored by services (srvx-only) */ ! #define FLAGS_AWAY 0x0200 /* marked as away (srvx-only) */ + #define IsOper(X) ((X)->modes & FLAGS_OPER) + #define IsGagged(X) ((X)->modes & FLAGS_GAGGED) + + struct user { unsigned char nick[NICKLEN]; /* Unique name of the client */ unsigned char username[USERLEN]; /* Username on client's machine */ unsigned char info[REALLEN]; /* Additional client information */ ! unsigned char hostname[HOSTLEN]; /* Hostname, or IP in numeric form */ struct server *uplink; struct modeList channels; + /* these are (should be) only interpreted by the protocol-related code */ + unsigned long modes; + unsigned long ip; + time_t timestamp; struct user_proto *proto; + + /* pointers to various other bits */ struct service_instance *service; }; + /* in (struct channel*)->modes */ + #define MODE_PRIVATE 0x0001 /* Private (+p) */ + #define MODE_SECRET 0x0002 /* Secret (+s); exclusive of MODE_PRIVATE */ + #define MODE_MODERATED 0x0004 /* Moderated (+m) */ + #define MODE_TOPICLIMIT 0x0008 /* Topic semi-locked (+t) */ + #define MODE_INVITEONLY 0x0010 /* Invite only (+i) */ + #define MODE_NOPRIVMSGS 0x0020 /* No outside privmsgs (+n) */ + #define MODE_REGISTERED 0x0040 /* Channel is registered (+r) */ + #define MODE_REGONLY 0x0080 /* Only auth'ed users may join (+R) */ + #define MODE_NOCOLOR 0x0100 /* No colored msgs to channel (+c) */ + #define MODE_OPERONLY 0x0200 /* Only irc operators may join (+O) */ + typedef unsigned long channel_mode_t; struct channel { char name[CHANNELLEN]; char topic[TOPICLEN]; char topic_nick[NICKLEN]; + char key[KEYLEN]; time_t topic_time; /* time topic set */ struct modeList members; struct banList banlist; + + /* These are (should be) only interpreted by protocol-specific code */ + channel_mode_t modes; + unsigned int limit; + time_t timestamp; /* creation time */ struct channel_proto *proto; Index: hash.c =================================================================== RCS file: /cvsroot/srvx/services/src/hash.c,v retrieving revision 1.148 retrieving revision 1.149 diff -C2 -r1.148 -r1.149 *** hash.c 2001/10/10 04:00:41 1.148 --- hash.c 2001/10/12 02:03:34 1.149 *************** *** 484,490 **** /* The 'banlist' was originally NULL, which i'm not sure is correct thing to do - do we really want to ignore newer ! bans? ! ! TODO: tell other server that we have the right ban list */ } --- 484,488 ---- /* The 'banlist' was originally NULL, which i'm not sure is correct thing to do - do we really want to ignore newer ! bans? */ } *************** *** 716,720 **** KickChannelUser(struct user *target, struct channel *channel, struct user *kicker, const char *why) { ! if (!target || !channel || IsService(target) || !GetUserMode(channel, target)) return; /* don't remove them from the channel, since the server will send a PART */ irc_kick(kicker, target, channel, why); --- 714,718 ---- KickChannelUser(struct user *target, struct channel *channel, struct user *kicker, const char *why) { ! if (!target || !channel || target->service || !GetUserMode(channel, target)) return; /* don't remove them from the channel, since the server will send a PART */ irc_kick(kicker, target, channel, why); *************** *** 744,748 **** unsigned int n; ! if (!kicker || !victim || !channel || IsService(victim) || !GetUserMode(channel, victim)) return; for (n=0; n<kf_used; n++) { --- 742,746 ---- unsigned int n; ! if (!kicker || !victim || !channel || victim->service || !GetUserMode(channel, victim)) return; for (n=0; n<kf_used; n++) { Index: Makefile.am =================================================================== RCS file: /cvsroot/srvx/services/src/Makefile.am,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** Makefile.am 2001/10/02 16:04:36 1.41 --- Makefile.am 2001/10/12 02:03:34 1.42 *************** *** 3,6 **** --- 3,7 ---- bin_PROGRAMS = srvx lib_LTLIBRARIES = libmod_common.la \ + libauthserv.la \ libproto_bahamut.la libproto_ircu_p10.la EXTRA_PROGRAMS = checkdb globtest pwcracker *************** *** 31,44 **** uplink.c uplink.h libmod_common_la_SOURCES = \ ! mod_common.c mod_common.h \ ! dict.h modules.h libproto_bahamut_la_SOURCES = \ - proto.h proto.def \ proto_bahamut.c libproto_ircu_p10_la_SOURCES = \ - proto.h proto.def \ proto_ircu_p10.c --- 32,45 ---- uplink.c uplink.h + libauthserv_la_SOURCES = \ + authserv.c authserv.h + libmod_common_la_SOURCES = \ ! mod_common.c mod_common.h libproto_bahamut_la_SOURCES = \ proto_bahamut.c libproto_ircu_p10_la_SOURCES = \ proto_ircu_p10.c *************** *** 50,53 **** LINT = lclint LINTOPTS = +showscan +posixlib -boolops -predboolint -noeffect ! lint: ! $(LINT) $(LINTOPTS) compat.c conf.c dict-splay.c getopt.c getopt1.c gline.c hash.c heap.c log.c main.c md5.c mod_common.c modules.c policer.c proto.c proto_bahamut.c recdb.c rules.c saxdb.c service.c timeq.c --- 51,58 ---- LINT = lclint LINTOPTS = +showscan +posixlib -boolops -predboolint -noeffect ! LINT_FILES = compat.c conf.c getopt.c getopt1.c gline.c hash.c heap.c log.c main.c md5.c modules.c policer.c proto.c recdb.c rules.c saxdb.c service.c timeq.c ! LINT_FILES += dict-splay.c # or dict-hash.c ! LINT_FILES += proto_bahamut.c # or proto_ircu_p10.c ! LINT_FILES += mod_common.c authserv.c ! lint: $(LINT_FILES) ! $(LINT) $(LINTOPTS) $^ |
From: Entrope <en...@us...> - 2001-10-10 19:11:08
|
Update of /cvsroot/srvx/services In directory usw-pr-cvs1:/tmp/cvs-serv20131 Modified Files: configure.ac Log Message: convert --enable-bounds-checking to a --with- option, since it's an external feature Index: configure.ac =================================================================== RCS file: /cvsroot/srvx/services/configure.ac,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** configure.ac 2001/10/10 04:51:23 1.13 --- configure.ac 2001/10/10 19:11:02 1.14 *************** *** 158,163 **** dnl Optional features. ! AC_ARG_ENABLE(bounds-checking, ! [ --enable-bounds-checking Enables bounds checking during compile], [AC_MSG_CHECKING(for bounds-checking capability) OLD_CFLAGS=$CFLAGS --- 158,163 ---- dnl Optional features. ! AC_ARG_WITH(bounds-checking, ! [ --with-bounds-checking Enables bounds checking during compile], [AC_MSG_CHECKING(for bounds-checking capability) OLD_CFLAGS=$CFLAGS |
From: Entrope <en...@us...> - 2001-10-10 04:51:26
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv2931/src Modified Files: service.h service.c proto.c mod_common.h mod_common.c messages.h config.h.in Log Message: start implementing mod_common functions Index: service.h =================================================================== RCS file: /cvsroot/srvx/services/src/service.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** service.h 2001/10/10 04:00:41 1.3 --- service.h 2001/10/10 04:51:23 1.4 *************** *** 34,38 **** struct service_template { dict_t commands; /* string->struct service_command* */ ! struct service_common *common; }; --- 34,38 ---- struct service_template { dict_t commands; /* string->struct service_command* */ ! struct service_template_common *common; }; *************** *** 44,47 **** --- 44,48 ---- void service_init(); struct user *service_create(const char *templ_name, dict_t params); + void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text); #endif /* !defined(SERVICE_H) */ Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/service.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** service.c 2001/10/10 04:00:41 1.3 --- service.c 2001/10/10 04:51:23 1.4 *************** *** 46,50 **** } ! static void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text) { --- 46,50 ---- } ! void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text) { Index: proto.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto.c,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -r1.76 -r1.77 *** proto.c 2001/10/10 04:00:41 1.76 --- proto.c 2001/10/10 04:51:23 1.77 *************** *** 63,68 **** int ret, use_color; ! /* expand the parameters we got .. */ ! chars_sent = 0; /* Normally, I'd pass NULL as the first parameter to vsnprintf. * But guess what? It makes FreeBSD's libc allocate a buffer that it --- 63,68 ---- int ret, use_color; ! /* translate the format string */ ! format = gettext(format); /* Normally, I'd pass NULL as the first parameter to vsnprintf. * But guess what? It makes FreeBSD's libc allocate a buffer that it Index: mod_common.h =================================================================== RCS file: /cvsroot/srvx/services/src/mod_common.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** mod_common.h 2001/10/10 04:00:41 1.2 --- mod_common.h 2001/10/10 04:51:23 1.3 *************** *** 30,34 **** #define COMMON_VERSION MAKE_VERSION(COMMON_MAJOR, COMMON_MINOR, COMMON_REVISION) ! struct service_common { dict_t help; /* help index */ }; --- 30,34 ---- #define COMMON_VERSION MAKE_VERSION(COMMON_MAJOR, COMMON_MINOR, COMMON_REVISION) ! struct service_template_common { dict_t help; /* help index */ }; Index: mod_common.c =================================================================== RCS file: /cvsroot/srvx/services/src/mod_common.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** mod_common.c 2001/10/10 04:00:41 1.3 --- mod_common.c 2001/10/10 04:51:23 1.4 *************** *** 23,28 **** --- 23,30 ---- #include "hash.h" + #include "messages.h" #include "proto.h" #include "recdb.h" + #include "service.h" #include "tools.h" *************** *** 31,44 **** static struct module *common_module; static MODULE_COMMAND(cmd_help) { ! const char *topic; ! struct service_common *cstn; ! struct record_data *rec; (void)channel; cstn = NULL; if (!cstn->help) { ! send_message(user, bot, "%s", "Helpfile missing or internal help system error."); return 0; } --- 33,74 ---- static struct module *common_module; + /* Basic approach for help files: + * + * Each module's "raw" help file contains a set of help topics, which + * correspond to one command exported by the module. Each of these + * topics contains sub-topics, including a default topic (usually + * covering the command itself). For each command bound to the + * service template, look up the appropriate module's raw help entry, + * and prefix the contents of that topic with the bound command name. + * For instance, in mod_authserv_admin.help: + * "oset" { + * "" "This command lets opers set stuff."; + * "options" "blah blah blah"; + * }; + * If "oset" was bound to "oper-set" in the service template, it would + * result in the following help bindings: + * "oper-set" "This command lets opers set stuff."; + * "oper-set options" "blah blah blah"; + */ + static void + common_readhelp(struct user *bot, struct user *user) + { + /* TODO: implement common_readhelp */ + (void)bot; (void)user; + } + + /*******************/ + /* MODULE COMMANDS */ + /*******************/ + static MODULE_COMMAND(cmd_help) { ! const char *topic, *data; ! struct service_template_common *cstn; (void)channel; cstn = NULL; if (!cstn->help) { ! send_message(user, bot, N_("Helpfile missing.")); return 0; } *************** *** 48,61 **** unsplit_string(argv+1, argc-1); topic = argv[1]; - } - if (!(rec = dict_find(cstn->help, topic, NULL))) { - send_message(user, bot, "%s", "No help on that topic."); - return 0; } ! if (rec->type != RECDB_QSTRING) { ! send_message(user, bot, "%s", "Internal help system error."); return 0; } ! send_message(user, bot, "%s", rec->d.qstring); return 0; } --- 78,87 ---- unsplit_string(argv+1, argc-1); topic = argv[1]; } ! if (!(data = dict_find(cstn->help, topic, NULL))) { ! send_message(user, bot, N_("No help on that topic.")); return 0; } ! send_message(user, bot, "%s", data); return 0; } *************** *** 63,75 **** static MODULE_COMMAND(cmd_readhelp) { ! (void)user; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_readhelp */ return 0; } static MODULE_COMMAND(cmd_timecmd) { ! (void)user; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_timecmd */ return 0; } --- 89,123 ---- static MODULE_COMMAND(cmd_readhelp) { ! struct timeval start, stop; ! ! (void)channel; (void)argc; (void)argv; ! gettimeofday(&start, NULL); ! common_readhelp(bot, user); ! gettimeofday(&stop, NULL); ! stop.tv_sec -= start.tv_sec; ! stop.tv_usec -= start.tv_usec; ! if (stop.tv_usec < 0) { ! stop.tv_sec -= 1; ! stop.tv_usec += 1000000; ! } ! send_message(user, bot, N_("Loaded help files for $b%s$b in "FMT_TIME_T".%06lu seconds."), bot->nick, stop.tv_sec, stop.tv_usec); return 0; + return 0; } static MODULE_COMMAND(cmd_timecmd) { ! struct timeval start, stop; ! unsplit_string(argv+1, argc-1); ! gettimeofday(&start, NULL); ! service_chanmsg(bot, user, channel, argv[1]); ! gettimeofday(&stop, NULL); ! stop.tv_sec -= start.tv_sec; ! stop.tv_usec -= start.tv_usec; ! if (stop.tv_usec < 0) { ! stop.tv_sec -= 1; ! stop.tv_usec += 1000000; ! } ! send_message(user, bot, N_("Command $b%s$b finished in "FMT_TIME_T".%06lu seconds."), argv[1], stop.tv_sec, stop.tv_usec); return 0; } *************** *** 82,89 **** } static MODULE_COMMAND(cmd_god) { ! (void)user; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_god */ return 0; } --- 130,166 ---- } + /* TODO: unkludge IsHelping() */ + #define IsHelping(USER) 1 + static MODULE_COMMAND(cmd_god) { ! int new_helping; ! (void)channel; ! ! if (argc > 1) { ! if (enabled_string(argv[1])) new_helping = 1; ! else if (disabled_string(argv[1])) new_helping = 0; ! else { ! send_message(user, bot, MSG_INVALID_BINARY, argv[1]); ! return 0; ! } ! } else { ! new_helping = !IsHelping(user); ! } ! if (new_helping) { ! if (IsHelping(user)) { ! send_message(user, bot, N_("You already have security override enabled.")); ! return 0; ! } ! /* TODO: mark user as helping */ ! send_message(user, bot, N_("Security override has been enabled.")); ! } else { ! if (!IsHelping(user)) { ! send_message(user, bot, N_("You already have security override disabled.")); ! return 0; ! } ! /* TODO: mark user as not helping */ ! send_message(user, bot, N_("Security override has been disabled.")); ! } return 0; } *************** *** 110,113 **** --- 187,191 ---- common_module = module_register("common", COMMON_VERSION, &deps, lib); if (!common_module) return 1; + /* Register functions */ for (nn=0; cmds[nn].name; nn++) { Index: messages.h =================================================================== RCS file: /cvsroot/srvx/services/src/messages.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** messages.h 2001/08/19 03:06:09 1.22 --- messages.h 2001/10/10 04:51:23 1.23 *************** *** 28,73 **** freak. */ ! #define MSG_VERSION "$bsrvx "VERSION"$b ("CODENAME"), Built: " __DATE__ ", " __TIME__"." ! #define MSG_SERVICE_IMMUNE "$b%s$b may not be kicked, killed, banned, or deopped." ! #define MSG_SERVICE_PRIVILEGED "$b%s$b is a privileged service." ! #define MSG_COMMAND_UNKNOWN "$b%s$b is an unknown command." ! #define MSG_COMMAND_PRIVILEGED "$b%s$b is a privileged command." ! #define MSG_COMMAND_DISABLED "$b%s$b is a disabled command." ! #define MSG_COMMAND_FLOOD "Too many commands sent, please wait." ! #define MSG_SETTING_PRIVILEGED "$b%s$b is a privileged setting." ! #define MSG_REGISTER_HANDLE "You must first register a handle with $b$N$b." ! #define MSG_AUTHENTICATE "You must first authenticate with $b$N$b." ! #define MSG_USER_AUTHENTICATE "%s must first authenticate with $b$N$b." ! #define MSG_HANDLE_UNKNOWN "Handle $b%s$b has not been registered." ! #define MSG_NICK_UNKNOWN "User with nick $b%s$b does not exist." ! #define MSG_CHANNEL_UNKNOWN "Channel with name $b%s$b does not exist." ! #define MSG_SERVER_UNKNOWN "Server with name $b%s$b does not exist or is not linked." ! #define MSG_NICKS_UNKNOWN "Some of the nicks provided are nonexistent." ! #define MSG_INVALID_GLINE "Invalid G-line '%s'." ! #define MSG_INVALID_DURATION "Invalid time span '%s'." ! #define MSG_INVALID_CHANNEL "You must provide the name of a channel that exists." ! #define MSG_CHANNEL_ABSENT "You aren't currently in $b%s$b." ! #define MSG_MISSING_PARAMS "$b%s$b requires more parameters." ! #define MSG_OPER_SUSPENDED "Your $b$O$b access has been suspended." ! #define MSG_USER_OUTRANKED "$b%s$b outranks you (command has no effect)." ! #define MSG_INVALID_CRITERIA "$b%s$b is an invalid search criteria." ! #define MSG_SEARCH_RESULTS "The following %s matched the criteria of your search:" ! #define MSG_MATCH_COUNT "Found $b%u$b matches." ! #define MSG_NO_MATCHES "Nothing matched the criteria of your search." ! #define MSG_INVALID_BINARY "$b%s$b is an invalid binary value." ! #define IDENT_FORMAT "%s [%s@%s/%ld.%ld.%ld.%ld]" #define IDENT_DATA(user) user->nick, user->username, user->hostname, (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255 --- 28,73 ---- freak. */ ! #define MSG_VERSION N_("$bsrvx "VERSION"$b ("CODENAME"), Built: " __DATE__ ", " __TIME__".") ! #define MSG_SERVICE_IMMUNE N_("$b%s$b may not be kicked, killed, banned, or deopped.") ! #define MSG_SERVICE_PRIVILEGED N_("$b%s$b is a privileged service.") ! #define MSG_COMMAND_UNKNOWN N_("$b%s$b is an unknown command.") ! #define MSG_COMMAND_PRIVILEGED N_("$b%s$b is a privileged command.") ! #define MSG_COMMAND_DISABLED N_("$b%s$b is a disabled command.") ! #define MSG_COMMAND_FLOOD N_("Too many commands sent, please wait.") ! #define MSG_SETTING_PRIVILEGED N_("$b%s$b is a privileged setting.") ! #define MSG_REGISTER_HANDLE N_("You must first register a handle with $b$N$b.") ! #define MSG_AUTHENTICATE N_("You must first authenticate with $b$N$b.") ! #define MSG_USER_AUTHENTICATE N_("%s must first authenticate with $b$N$b.") ! #define MSG_HANDLE_UNKNOWN N_("Handle $b%s$b has not been registered.") ! #define MSG_NICK_UNKNOWN N_("User with nick $b%s$b does not exist.") ! #define MSG_CHANNEL_UNKNOWN N_("Channel with name $b%s$b does not exist.") ! #define MSG_SERVER_UNKNOWN N_("Server with name $b%s$b does not exist or is not linked.") ! #define MSG_NICKS_UNKNOWN N_("Some of the nicks provided are nonexistent.") ! #define MSG_INVALID_GLINE N_("Invalid G-line '%s'.") ! #define MSG_INVALID_DURATION N_("Invalid time span '%s'.") ! #define MSG_INVALID_CHANNEL N_("You must provide the name of a channel that exists.") ! #define MSG_CHANNEL_ABSENT N_("You aren't currently in $b%s$b.") ! #define MSG_MISSING_PARAMS N_("$b%s$b requires more parameters.") ! #define MSG_OPER_SUSPENDED N_("Your $b$O$b access has been suspended.") ! #define MSG_USER_OUTRANKED N_("$b%s$b outranks you (command has no effect).") ! #define MSG_INVALID_CRITERIA N_("$b%s$b is an invalid search criteria.") ! #define MSG_SEARCH_RESULTS N_("The following %s matched the criteria of your search:") ! #define MSG_MATCH_COUNT N_("Found $b%u$b matches.") ! #define MSG_NO_MATCHES N_("Nothing matched the criteria of your search.") ! #define MSG_INVALID_BINARY N_("$b%s$b is an invalid binary value.") ! #define IDENT_FORMAT N_("%s [%s@%s/%ld.%ld.%ld.%ld]") #define IDENT_DATA(user) user->nick, user->username, user->hostname, (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255 Index: config.h.in =================================================================== RCS file: /cvsroot/srvx/services/src/config.h.in,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** config.h.in 2001/10/03 00:57:46 1.28 --- config.h.in 2001/10/10 04:51:23 1.29 *************** *** 115,118 **** --- 115,121 ---- #undef HAVE_LIBDMALLOCTH + /* Define if you have the <libintl.h> header file. */ + #undef HAVE_LIBINTL_H + /* Define if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL *************** *** 335,341 **** /* Define if your <sys/time.h> declares `struct tm'. */ #undef TM_IN_SYS_TIME - - /* Define to enable X2 transitioning features. */ - #undef TRANSITION /* Version number of package */ --- 338,341 ---- |
From: Entrope <en...@us...> - 2001-10-10 04:51:26
|
Update of /cvsroot/srvx/services In directory usw-pr-cvs1:/tmp/cvs-serv2931 Modified Files: configure.ac Log Message: start implementing mod_common functions Index: configure.ac =================================================================== RCS file: /cvsroot/srvx/services/configure.ac,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** configure.ac 2001/10/02 16:32:07 1.12 --- configure.ac 2001/10/10 04:51:23 1.13 *************** *** 1,5 **** dnl Process this file with autoconf to create a configure script. dnl Then invoke that configure script using a command line like this: ! dnl ./configure --enable-maintainer-mode --enable-transition --enable-debug dnl General initialization. --- 1,5 ---- dnl Process this file with autoconf to create a configure script. dnl Then invoke that configure script using a command line like this: ! dnl ./configure --enable-maintainer-mode --enable-debug dnl General initialization. *************** *** 86,90 **** dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi ! AC_CHECK_HEADERS(arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h pthread.h sys/resource.h sys/timeb.h sys/times.h sys/select.h sys/param.h sys/poll.h sys/socket.h sys/time.h sys/types.h unistd.h getopt.h memory.h regex.h alloca.h dlfcn.h,,) dnl portability stuff, hurray! -Jedi --- 86,90 ---- dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi ! AC_CHECK_HEADERS(arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h pthread.h sys/resource.h sys/timeb.h sys/times.h sys/select.h sys/param.h sys/poll.h sys/socket.h sys/time.h sys/types.h unistd.h getopt.h memory.h regex.h alloca.h dlfcn.h libintl.h,,) dnl portability stuff, hurray! -Jedi *************** *** 157,163 **** dnl Optional features. - AC_ARG_ENABLE(transition, - [ --enable-transition Enables X2 transition commands], - [AC_DEFINE(TRANSITION, 1, [Define to enable X2 transitioning features.])]) AC_ARG_ENABLE(bounds-checking, --- 157,160 ---- |
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv21875/src Modified Files: uplink.c tools.h tools.c service.h service.c rules.h proto_ircu_p10.c proto_bahamut.c proto.h proto.def proto.c modules.h modules.c mod_common.h mod_common.c log.h log.c hash.h hash.c gline.h gline.c Removed Files: globtest.c alias.h alias.c Log Message: various cleanups -- mostly ditch the ill-conceived and awkward "annotation" code Index: uplink.c =================================================================== RCS file: /cvsroot/srvx/services/src/uplink.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** uplink.c 2001/09/29 04:37:31 1.11 --- uplink.c 2001/10/10 04:00:41 1.12 *************** *** 29,32 **** --- 29,33 ---- #include "conf.h" + #include "hash.h" #include "log.h" #include "proto.h" Index: tools.h =================================================================== RCS file: /cvsroot/srvx/services/src/tools.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** tools.h 2001/09/27 21:58:07 1.14 --- tools.h 2001/10/10 04:00:41 1.15 *************** *** 29,34 **** #define disabled_string(string) (!strcasecmp((string), "off") || !strcmp((string), "0") || !strcasecmp((string), "disabled")) ! struct userNode; ! struct chanNode; extern unsigned char channel_inverse_modes[256]; --- 29,34 ---- #define disabled_string(string) (!strcasecmp((string), "off") || !strcmp((string), "0") || !strcasecmp((string), "disabled")) ! struct user; ! struct channel; extern unsigned char channel_inverse_modes[256]; *************** *** 36,41 **** int getusermodes(char *sender); ! void mod_usermode(struct userNode *user, const char *modes); ! void mod_chanmode(struct chanNode *channel, const char *mode_change, const char *key, int limit); int verify_chanmode(const char *modes); int split_line(unsigned char *line, int irc_colon, int argv_size, unsigned char *argv[]); --- 36,41 ---- int getusermodes(char *sender); ! void mod_usermode(struct user *user, const char *modes); ! void mod_chanmode(struct channel *channel, const char *mode_change, const char *key, int limit); int verify_chanmode(const char *modes); int split_line(unsigned char *line, int irc_colon, int argv_size, unsigned char *argv[]); *************** *** 44,48 **** int mmatch(const char *glob, const char *newglob); int match_ircglob(const char *text, const char *glob); ! int user_matches_glob(struct userNode *user, const char *glob, int include_nick); int is_ircmask(const unsigned char *text); --- 44,48 ---- int mmatch(const char *glob, const char *newglob); int match_ircglob(const char *text, const char *glob); ! int user_matches_glob(struct user *user, const char *glob, int include_nick); int is_ircmask(const unsigned char *text); *************** *** 55,59 **** #define GENMASK_BYIP 8 #define GENMASK_SRVXMASK 16 ! char *generate_hostmask(struct userNode *user, int options); unsigned long ParseInterval(const unsigned char *interval); --- 55,59 ---- #define GENMASK_BYIP 8 #define GENMASK_SRVXMASK 16 ! char *generate_hostmask(struct user *user, int options); unsigned long ParseInterval(const unsigned char *interval); *************** *** 73,78 **** 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); --- 73,78 ---- const char *preposition(char *word); ! int ban_match_user(struct user *user, char *ban); ! int ban_match_user_host(struct user *user, char *hostmask, char *ban); DECLARE_LIST(string_buffer, char); *************** *** 80,85 **** void string_buffer_replace(struct string_buffer *buf, unsigned int from, unsigned int len, const char *repl); ! int make_chanmode(struct chanNode *chan, char *out, unsigned int len); ! int make_usermode(struct userNode *user, char *out, unsigned int len); #endif /* ifdef _TOOLS_H_ */ --- 80,85 ---- void string_buffer_replace(struct string_buffer *buf, unsigned int from, unsigned int len, const char *repl); ! int make_chanmode(struct channel *chan, char *out, unsigned int len); ! int make_usermode(struct user *user, char *out, unsigned int len); #endif /* ifdef _TOOLS_H_ */ Index: tools.c =================================================================== RCS file: /cvsroot/srvx/services/src/tools.c,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -r1.97 -r1.98 *** tools.c 2001/10/03 00:57:46 1.97 --- tools.c 2001/10/10 04:00:41 1.98 *************** *** 71,75 **** void ! mod_usermode(struct userNode *user, const char *mode_change) { unsigned long orig_modes; int add = 1; --- 71,75 ---- void ! mod_usermode(struct user *user, const char *mode_change) { unsigned long orig_modes; int add = 1; *************** *** 94,102 **** #undef do_user_mode } ! /* TODO: add callback to notify things of mode changes*/ } int ! make_usermode(struct userNode *user, char *out, unsigned int len) { unsigned int nn, jj=0; --- 94,102 ---- #undef do_user_mode } ! /* TODO: add callback to notify things of mode changes */ } int ! make_usermode(struct user *user, char *out, unsigned int len) { unsigned int nn, jj=0; *************** *** 113,117 **** void ! mod_chanmode(struct chanNode *channel, const char *mode_change, const char *key, int limit) { int add = 1, n; --- 113,117 ---- void ! mod_chanmode(struct channel *channel, const char *mode_change, const char *key, int limit) { int add = 1, n; *************** *** 168,172 **** int ! make_chanmode(struct chanNode *channel, char *out, unsigned int len) { unsigned int nn, jj=0; --- 168,172 ---- int ! make_chanmode(struct channel *channel, char *out, unsigned int len) { unsigned int nn, jj=0; *************** *** 406,410 **** int ! user_matches_glob(struct userNode *user, const char *orig_glob, int include_nick) { char *glob, *marker; --- 406,410 ---- int ! user_matches_glob(struct user *user, const char *orig_glob, int include_nick) { char *glob, *marker; *************** *** 486,490 **** char * ! generate_hostmask(struct userNode *user, int options) { char *nickname, *username, *hostname; --- 486,490 ---- char * ! generate_hostmask(struct user *user, int options) { char *nickname, *username, *hostname; Index: service.h =================================================================== RCS file: /cvsroot/srvx/services/src/service.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** service.h 2001/09/27 21:58:07 1.2 --- service.h 2001/10/10 04:00:41 1.3 *************** *** 25,37 **** #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); ! struct userNode *service_instantiate(const char *name); #endif /* !defined(SERVICE_H) */ --- 25,47 ---- #include "modules.h" ! #define SERVICE_MAJOR 0 ! #define SERVICE_MINOR 0 ! #define SERVICE_REVISION 0 + struct user; + struct service_common; + struct service_template { dict_t commands; /* string->struct service_command* */ ! struct service_common *common; ! }; ! ! /* Attached as a "service" module note to "struct user" */ ! struct service_instance { ! struct service_template *templ; }; ! void service_init(); ! struct user *service_create(const char *templ_name, dict_t params); #endif /* !defined(SERVICE_H) */ Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/service.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** service.c 2001/09/27 21:58:07 1.2 --- service.c 2001/10/10 04:00:41 1.3 *************** *** 20,45 **** #include "config.h" #include "dict.h" #include "rules.h" #include "service.h" static dict_t service_templates; ! int ! service_create(const char *name, dict_t defn) { ! (void)name; (void)defn; ! if (!service_templates) service_templates = dict_new(); ! if (dict_find(service_templates, name, NULL)) return 1; ! /* TODO: finish service_create() */ ! return 2; } ! struct userNode * ! service_instantiate(const char *name) { ! (void)name; ! /* TODO: finish service_instantiate */ ! return NULL; } --- 20,139 ---- #include "config.h" + #include <assert.h> + #include <ctype.h> + #include <stdlib.h> #include "dict.h" + #include "proto.h" #include "rules.h" #include "service.h" + #include "tools.h" + struct service_command { + struct module_command *base; + struct expression *rule; + }; + + static struct module *service_module; static dict_t service_templates; + #define SINST(USER) ((USER)->service) ! void ! service_init(void) { ! service_module = module_register("service", MAKE_VERSION(SERVICE_MAJOR, SERVICE_MINOR, SERVICE_REVISION), NULL, NULL); ! service_templates = dict_new(); ! } ! ! static void ! service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text) ! { ! unsigned char *text = real_text; ! unsigned char *argv[MAXNUMPARAMS], *chan_name; ! unsigned int argc, shift; ! struct service_instance *sinst; ! struct service_command *cmd; ! struct expression_context rule_ctx; ! ! (void)source; (void)chan; ! shift = 0; ! argc = split_line(text, 0, ArrayLength(argv), argv); ! sinst = bot->service; ! if ((argc > 0) && (argv[0][0] == '#')) { ! cmd = dict_find(sinst->templ->commands, argv[1], NULL); ! if (cmd->base->flags & (1 << TAKES_CHANNEL)) { ! shift = 1; ! chan_name = argv[0]; ! } else { ! /* TODO: whine */ ! } ! } else if ((argc > 1) && (argv[1][0] == '#')) { ! cmd = dict_find(sinst->templ->commands, argv[0], NULL); ! if (cmd->base->flags & (1 << TAKES_CHANNEL)) { ! shift = 1; ! chan_name = argv[1]; ! argv[1] = argv[0]; ! argv[0] = chan_name; ! } else { ! /* Doesn't take a channel, so leave second arg in place */ ! } ! } else { ! shift = 0; ! cmd = dict_find(sinst->templ->commands, argv[0], NULL); ! } ! if ((cmd->base->flags & (1 << TAKES_CHANNEL)) && shift) { ! chan = GetChannel(argv[shift-1]); ! } ! if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !chan) { ! /* TODO: whine */ ! return; ! } ! /* TODO: check for authed state and whine if not */ ! if ((cmd->base->flags & (1 << REQUIRE_AUTHED)) && 0) { ! } ! /* Fill in rule context and evaluate it */ ! rule_ctx.user = source; ! rule_ctx.channel = chan; ! if (!expression_evaluate(cmd->rule ? cmd->rule : cmd->base->default_rule, &rule_ctx)) { ! /* TODO: whine */ ! return; ! } ! if (cmd->base->function(source, bot, chan, argc-shift, argv+shift)) { ! /* TODO: whine or something */ ! return; ! } } ! static void ! service_privmsg(struct user *bot, struct user *source, char *text) { ! /* Is this sufficient? */ ! service_chanmsg(bot, source, NULL, text); ! } ! ! struct user * ! service_create(const char *name, dict_t params) ! { ! struct user *user; ! const char *hostname, *userinfo, *trigger; ! struct service_template *templ; ! struct service_instance *sinst; ! ! /* Is the template defined? */ ! if (!(templ = dict_find(service_templates, name, NULL))) return NULL; ! /* Get the various parameters from the params dict */ ! hostname = dict_find(params, "hostname", NULL); ! userinfo = dict_find(params, "userinfo", NULL); ! trigger = dict_find(params, "trigger", NULL); ! /* Create the user and annotate it */ ! user = add_local_user(name, name, hostname, "+oik", userinfo, now); ! sinst = calloc(1, sizeof(*sinst)); ! assert(sinst); ! sinst->templ = templ; ! user->service = sinst; ! /* Register callbacks */ ! if (trigger) reg_chanmsg_func(trigger[0], user, service_chanmsg); ! reg_privmsg_func(user, service_privmsg); ! /* TODO: finish service_create() */ ! return user; } Index: rules.h =================================================================== RCS file: /cvsroot/srvx/services/src/rules.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** rules.h 2001/09/22 16:12:54 1.1 --- rules.h 2001/10/10 04:00:41 1.2 *************** *** 25,30 **** struct expression_context { ! struct userNode *user; ! struct chanNode *channel; }; --- 25,30 ---- struct expression_context { ! struct user *user; ! struct channel *channel; }; Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** proto_ircu_p10.c 2001/10/02 16:04:36 1.25 --- proto_ircu_p10.c 2001/10/10 04:00:41 1.26 *************** *** 65,80 **** 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 { char numeric[SERVER_NUMERIC_LEN+1]; ! 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)) /**************************************/ --- 65,78 ---- static struct module *proto_module; ! struct user_proto { char numeric[COMBO_NUMERIC_LEN+1]; }; ! #define UPROTO(USER) ((USER)->proto) ! struct server_proto { char numeric[SERVER_NUMERIC_LEN+1]; ! struct user *users[USERARRAYSIZE]; /* flat indexed by numeric */ }; ! #define SPROTO(SERVER) ((SERVER)->proto) /**************************************/ *************** *** 288,292 **** static void ! irc_uptime(struct userNode *user) { char uptime[INTERVALLEN]; --- 286,290 ---- static void ! irc_uptime(struct user *user) { char uptime[INTERVALLEN]; *************** *** 299,303 **** static void ! irc_whois(struct userNode *from, struct userNode *who) { putsock(":%s 311 %s %s %s %s * :%s", self->name, from->nick, who->nick, who->username, who->hostname, who->info); --- 297,301 ---- static void ! irc_whois(struct user *from, struct user *who) { putsock(":%s 311 %s %s %s %s * :%s", self->name, from->nick, who->nick, who->username, who->hostname, who->info); *************** *** 309,313 **** void ! irc_user(struct userNode *user) { char b64ip[7]; --- 307,311 ---- void ! irc_user(struct user *user) { char b64ip[7]; *************** *** 326,330 **** void ! irc_nick(struct userNode *user) { putsock("%s %s %s "FMT_TIME_T, UPROTO(user)->numeric, CMD_NICK, user->nick, now); --- 324,328 ---- void ! irc_nick(struct user *user) { putsock("%s %s %s "FMT_TIME_T, UPROTO(user)->numeric, CMD_NICK, user->nick, now); *************** *** 332,336 **** void ! irc_fetchtopic(struct userNode *from, struct chanNode *target) { putsock("%s TOPIC %s", from->nick, target->name); --- 330,334 ---- void ! irc_fetchtopic(struct user *from, struct channel *target) { putsock("%s TOPIC %s", from->nick, target->name); *************** *** 359,363 **** void ! irc_notice(struct userNode *from, const char *to, const char *message) { putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_NOTICE, to, message); --- 357,361 ---- void ! irc_notice(struct user *from, const char *to, const char *message) { putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_NOTICE, to, message); *************** *** 365,374 **** void ! irc_privmsg(struct userNode *from, const char *to, const char *message) { 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); } --- 363,372 ---- void ! irc_privmsg(struct user *from, const char *to, const char *message) { if (IsChannelName(to)) { putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_PRIVMSG, to, message); } else { ! struct user *user = GetUser(to); if (user) putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_PRIVMSG, UPROTO(user)->numeric, message); } *************** *** 445,454 **** static void ! irc_burst(struct chanNode *chan) { char burst_line[510]; int pos, base_len, len; ! struct modeNode *mn; ! struct banNode *bn; long last_mode=-1; unsigned int n; --- 443,452 ---- static void ! irc_burst(struct channel *chan) { char burst_line[510]; int pos, base_len, len; ! struct mode *mn; ! struct ban *bn; long last_mode=-1; unsigned int n; *************** *** 507,511 **** void ! irc_quit(struct userNode *user, const char *message) { putsock("%s %s :%s", UPROTO(user)->numeric, CMD_QUIT, message); --- 505,509 ---- void ! irc_quit(struct user *user, const char *message) { putsock("%s %s :%s", UPROTO(user)->numeric, CMD_QUIT, message); *************** *** 523,527 **** void ! irc_kill(struct userNode *from, struct userNode *target, const char *message) { if (from) { --- 521,525 ---- void ! irc_kill(struct user *from, struct user *target, const char *message) { if (from) { *************** *** 533,539 **** void ! irc_mode(struct userNode *from, struct chanNode *target, const char *modes) { ! struct modeNode *mn; const char *src; if ((mn = GetUserMode(target, from)) && (mn->modes & MODE_CHANOP)) { --- 531,537 ---- void ! irc_mode(struct user *from, struct channel *target, const char *modes) { ! struct mode *mn; const char *src; if ((mn = GetUserMode(target, from)) && (mn->modes & MODE_CHANOP)) { *************** *** 546,550 **** void ! irc_invite(struct userNode *from, struct userNode *who, struct chanNode *to) { putsock("%s %s %s %s", from->nick, CMD_INVITE, who->nick, to->name); --- 544,548 ---- void ! irc_invite(struct user *from, struct user *who, struct channel *to) { putsock("%s %s %s %s", from->nick, CMD_INVITE, who->nick, to->name); *************** *** 552,556 **** void ! irc_join(struct userNode *who, struct chanNode *what) { if (what->members.used == 1) { --- 550,554 ---- void ! irc_join(struct user *who, struct channel *what) { if (what->members.used == 1) { *************** *** 562,566 **** void ! 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); --- 560,564 ---- void ! irc_kick(struct user *actor, struct user *who, struct channel *from, const char *msg) { putsock("%s %s %s %s :%s", UPROTO(actor)->numeric, CMD_KICK, from->name, UPROTO(who)->numeric, msg); *************** *** 574,578 **** void ! irc_stats(struct userNode *from, struct server *target, char type) { putsock("%s STATS %c :%s", UPROTO(from)->numeric, type, SPROTO(target)->numeric); --- 572,576 ---- void ! irc_stats(struct user *from, struct server *target, char type) { putsock("%s STATS %c :%s", UPROTO(from)->numeric, type, SPROTO(target)->numeric); *************** *** 580,584 **** void ! irc_part(struct userNode *who, struct chanNode *what, const char *reason) { putsock("%s %s %s :%s", UPROTO(who)->numeric, CMD_PART, what->name, reason); --- 578,582 ---- void ! irc_part(struct user *who, struct channel *what, const char *reason) { putsock("%s %s %s :%s", UPROTO(who)->numeric, CMD_PART, what->name, reason); *************** *** 586,590 **** void ! irc_topic(struct userNode *who, struct chanNode *what, const char *topic) { putsock(":%s %s %s :%s", who->nick, CMD_TOPIC, what->name, topic); --- 584,588 ---- void ! irc_topic(struct user *who, struct channel *what, const char *topic) { putsock(":%s %s %s :%s", who->nick, CMD_TOPIC, what->name, topic); *************** *** 592,596 **** void ! chan_apply_bans(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, char **list) { char buffer[400]; --- 590,594 ---- void ! chan_apply_bans(struct user *who, struct channel *channel, char *what, unsigned int count, char **list) { char buffer[400]; *************** *** 628,632 **** void ! chan_apply_mode(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, struct userNode **list) { char buffer[400]; --- 626,630 ---- void ! chan_apply_mode(struct user *who, struct channel *channel, char *what, unsigned int count, struct user **list) { char buffer[400]; *************** *** 664,668 **** void ! irc_change_channel_modes(struct chanNode *channel, struct userNode *source, const unsigned char *modes, va_list args) { char modebuf[200]; --- 662,666 ---- void ! irc_change_channel_modes(struct channel *channel, struct user *source, const unsigned char *modes, va_list args) { char modebuf[200]; *************** *** 677,681 **** while (*modes) { switch (*modes++) { ! struct userNode *user; int number; case '+': --- 675,679 ---- while (*modes) { switch (*modes++) { ! struct user *user; int number; case '+': *************** *** 688,696 **** break; 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; --- 686,694 ---- break; case 'o': ! user = va_arg(args, struct user *); arg_text = UPROTO(user)->numeric; goto add_arg; case 'v': ! user = va_arg(args, struct user *); arg_text = UPROTO(user)->numeric; goto add_arg; *************** *** 733,739 **** /********************/ ! typedef void (*foreach_chanfunc) (struct chanNode *chan, void *data); typedef void (*foreach_nonchan) (char *name, void *data); ! typedef void (*foreach_userfunc) (struct userNode *user, void *data); typedef void (*foreach_nonuser) (char *name, void *data); static void parse_foreach(char *target_list, foreach_chanfunc cf, foreach_nonchan nc, foreach_userfunc uf, foreach_nonuser nu, void *data); --- 731,737 ---- /********************/ ! typedef void (*foreach_chanfunc) (struct channel *chan, void *data); typedef void (*foreach_nonchan) (char *name, void *data); ! typedef void (*foreach_userfunc) (struct user *user, void *data); typedef void (*foreach_nonuser) (char *name, void *data); static void parse_foreach(char *target_list, foreach_chanfunc cf, foreach_nonchan nc, foreach_userfunc uf, foreach_nonuser nu, void *data); *************** *** 773,780 **** } ! static struct userNode * GetUserN(const char *numeric) /* using numeric */ { ! struct userNode *un; struct server *s; int n; --- 771,778 ---- } ! static struct user * GetUserN(const char *numeric) /* using numeric */ { ! struct user *un; struct server *s; int n; *************** *** 798,802 **** } ! static struct userNode * GetUserX(const char *something) /* using either numeric or :Nick */ { --- 796,800 ---- } ! static struct user * GetUserX(const char *something) /* using either numeric or :Nick */ { *************** *** 891,901 **** { 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; } --- 889,898 ---- { struct server *new_server; ! struct server_proto *sproto; new_server = AddServer(uplink, name, hops, boot, link, description); servers_num[base64toint(numeric, SERVER_NUMERIC_LEN)] = new_server; ! sproto = uplink->proto = calloc(1, sizeof(*sproto)); safestrncpy(sproto->numeric, numeric, sizeof(sproto->numeric)); return new_server; } *************** *** 939,943 **** static CMD_FUNC(cmd_stats) { ! struct userNode *un = GetUserX(argv[0]); (void)argc; --- 936,940 ---- static CMD_FUNC(cmd_stats) { ! struct user *un = GetUserX(argv[0]); (void)argc; *************** *** 950,955 **** static CMD_FUNC(cmd_whois) { ! struct userNode *from; ! struct userNode *who; if (argc < 4) return 0; --- 947,952 ---- static CMD_FUNC(cmd_whois) { ! struct user *from; ! struct user *who; if (argc < 4) return 0; *************** *** 1010,1014 **** struct create_desc { ! struct userNode *user; time_t when; }; --- 1007,1011 ---- struct create_desc { ! struct user *user; time_t when; }; *************** *** 1018,1022 **** { struct create_desc *cd = data; ! struct chanNode *cn; /* We can't assume the channel create was allowed because of the --- 1015,1019 ---- { struct create_desc *cd = data; ! struct channel *cn; /* We can't assume the channel create was allowed because of the *************** *** 1030,1034 **** */ if (cn->members.used == 1) { ! struct modeNode *mn = GetUserMode(cn, cd->user); if (mn) mn->modes = MODE_CHANOP; } --- 1027,1031 ---- */ if (cn->members.used == 1) { ! struct mode *mn = GetUserMode(cn, cd->user); if (mn) mn->modes = MODE_CHANOP; } *************** *** 1060,1067 **** } ! static struct userNode * ircu_add_user(struct server *uplink, const char *nick, const char *ident, const char *hostname, const char *modes, const char *numeric, const char *userinfo, time_t timestamp, const char *realip) { ! struct userNode *uNode; if (strlen(numeric) != COMBO_NUMERIC_LEN) { --- 1057,1064 ---- } ! static struct user * ircu_add_user(struct server *uplink, const char *nick, const char *ident, const char *hostname, const char *modes, const char *numeric, const char *userinfo, time_t timestamp, const char *realip) { ! struct user *uNode; if (strlen(numeric) != COMBO_NUMERIC_LEN) { *************** *** 1073,1081 **** 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); --- 1070,1078 ---- if (uNode) { unsigned long num_local; ! struct user_proto *uproto; uproto = calloc(1, sizeof(*uproto)); safestrncpy(uproto->numeric, numeric, sizeof(uproto->numeric)); ! uNode->proto = uproto; uNode->ip = base64toint(realip, 6); num_local = base64toint(numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); *************** *** 1110,1114 **** } ! struct userNode * add_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { --- 1107,1111 ---- } ! struct user * add_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { *************** *** 1152,1161 **** static void ! BurstChannel(struct chanNode *chan, char *members, char *banlist) { unsigned int i; long mode; ! struct userNode *un; ! struct modeNode *mn; /* go through the list of users to add and add each one */ --- 1149,1158 ---- static void ! BurstChannel(struct channel *chan, char *members, char *banlist) { unsigned int i; long mode; ! struct user *un; ! struct mode *mn; /* go through the list of users to add and add each one */ *************** *** 1196,1200 **** const char *key = NULL, *modes = NULL; unsigned int limit = 0, next = 4; ! struct chanNode *channel; if (argc < 4) return 0; --- 1193,1197 ---- const char *key = NULL, *modes = NULL; unsigned int limit = 0, next = 4; ! struct channel *channel; if (argc < 4) return 0; *************** *** 1256,1260 **** static void ! call_mode_change_funcs(struct chanNode *channel, struct userNode *user, int change_type, void *change) { unsigned int n; --- 1253,1257 ---- static void ! call_mode_change_funcs(struct channel *channel, struct user *user, int change_type, void *change) { unsigned int n; *************** *** 1270,1274 **** if (argc < 4) return 0; if (!IsChannelName(argv[2])) { ! struct userNode *un = GetUser(argv[2]); if (!un) { log(MAIN_LOG, LOG_ERROR, "Unable to find user %s whose mode is changing\n", argv[2]); --- 1267,1271 ---- if (argc < 4) return 0; if (!IsChannelName(argv[2])) { ! struct user *un = GetUser(argv[2]); if (!un) { log(MAIN_LOG, LOG_ERROR, "Unable to find user %s whose mode is changing\n", argv[2]); *************** *** 1278,1287 **** return 1; } else { ! struct chanNode *cn; ! struct userNode *un; int next_arg=4, res=1, add=1, bit; const char *mchange; ! struct modeNode *mn; ! chan_mode_t mode; char orig_key[KEYLEN+1]; unsigned int orig_limit; --- 1275,1284 ---- return 1; } else { ! struct channel *cn; ! struct user *un; int next_arg=4, res=1, add=1, bit; const char *mchange; ! struct mode *mn; ! channel_mode_t mode; char orig_key[KEYLEN+1]; unsigned int orig_limit; *************** *** 1326,1330 **** case 'o': case 'v': { ! struct userNode *vic; vic = GetUserN(argv[next_arg++]); if (!vic) { --- 1323,1327 ---- case 'o': case 'v': { ! struct user *vic; vic = GetUserN(argv[next_arg++]); if (!vic) { *************** *** 1368,1373 **** static CMD_FUNC(cmd_topic) { ! static struct chanNode *cn; ! static struct userNode *un; if (argc < 4) return 0; --- 1365,1370 ---- static CMD_FUNC(cmd_topic) { ! static struct channel *cn; ! static struct user *un; if (argc < 4) return 0; *************** *** 1386,1390 **** static CMD_FUNC(cmd_num_topic) { ! static struct chanNode *cn; if (!argv[1]) return 0; --- 1383,1387 ---- static CMD_FUNC(cmd_num_topic) { ! static struct channel *cn; if (!argv[1]) return 0; *************** *** 1427,1431 **** static CMD_FUNC(cmd_quit) { ! struct userNode *user; if (argc < 3) return 0; user = GetUserX(argv[0]); --- 1424,1428 ---- static CMD_FUNC(cmd_quit) { ! struct user *user; if (argc < 3) return 0; user = GetUserX(argv[0]); *************** *** 1441,1445 **** static CMD_FUNC(cmd_kill) { ! struct userNode *user; if (argc < 3) return 0; if (!(user = GetUserX(argv[2]))) { --- 1438,1442 ---- static CMD_FUNC(cmd_kill) { ! struct user *user; if (argc < 3) return 0; if (!(user = GetUserX(argv[2]))) { *************** *** 1459,1463 **** static void ! join_helper(struct chanNode *cn, void *data) { AddChannelUser(data, cn, 0); --- 1456,1460 ---- static void ! join_helper(struct channel *cn, void *data) { AddChannelUser(data, cn, 0); *************** *** 1467,1476 **** join_helper_old_server(char *name, void *data) { ! struct userNode *un = data; ! struct chanNode *cn; cn = AddChannel(name, now, "", "", 0); AddChannelUser(un, cn, 0); if (cn->members.used == 1) { ! struct modeNode *mn = GetUserMode(cn, un); if (mn) mn->modes = MODE_CHANOP; } --- 1464,1473 ---- join_helper_old_server(char *name, void *data) { ! struct user *un = data; ! struct channel *cn; cn = AddChannel(name, now, "", "", 0); AddChannelUser(un, cn, 0); if (cn->members.used == 1) { ! struct mode *mn = GetUserMode(cn, un); if (mn) mn->modes = MODE_CHANOP; } *************** *** 1479,1483 **** static CMD_FUNC(cmd_join) { ! struct userNode *user; if (argc < 3) return 0; user = GetUserX(argv[0]); --- 1476,1480 ---- static CMD_FUNC(cmd_join) { ! struct user *user; if (argc < 3) return 0; user = GetUserX(argv[0]); *************** *** 1494,1498 **** static void ! part_helper(struct chanNode *cn, void *data) { DelChannelUser(data, cn, 0, 0); --- 1491,1495 ---- static void ! part_helper(struct channel *cn, void *data) { DelChannelUser(data, cn, 0, 0); *************** *** 1501,1505 **** static CMD_FUNC(cmd_part) { ! struct userNode *user; if (argc < 3) return 0; user = GetUserX(argv[0]); --- 1498,1502 ---- static CMD_FUNC(cmd_part) { ! struct user *user; if (argc < 3) return 0; user = GetUserX(argv[0]); *************** *** 1510,1516 **** static CMD_FUNC(cmd_kick) { ! struct userNode *victim; ! struct userNode *kicker; ! struct chanNode *channel; if (argc < 4) return 0; --- 1507,1513 ---- static CMD_FUNC(cmd_kick) { ! struct user *victim; ! struct user *kicker; ! struct channel *channel; if (argc < 4) return 0; *************** *** 1538,1542 **** static struct chanmsg_desc { chanmsg_func_t func; ! struct userNode *service; } chanmsg_funcs[256]; static privmsg_func_t *privmsg_funcs; --- 1535,1539 ---- static struct chanmsg_desc { chanmsg_func_t func; ! struct user *service; } chanmsg_funcs[256]; static privmsg_func_t *privmsg_funcs; *************** *** 1546,1550 **** struct privmsg_desc { ! struct userNode *user; unsigned char *text; unsigned int is_notice; --- 1543,1547 ---- struct privmsg_desc { ! struct user *user; unsigned char *text; unsigned int is_notice; *************** *** 1552,1556 **** static void ! privmsg_chan_helper(struct chanNode *cn, void *data) { struct privmsg_desc *pd = data; --- 1549,1553 ---- static void ! privmsg_chan_helper(struct channel *cn, void *data) { struct privmsg_desc *pd = data; *************** *** 1566,1570 **** static void ! privmsg_user_helper(struct userNode *un, void *data) { struct privmsg_desc *pd = data; --- 1563,1567 ---- static void ! privmsg_user_helper(struct user *un, void *data) { struct privmsg_desc *pd = data; *************** *** 1607,1611 **** static CMD_FUNC(cmd_away) { ! struct userNode *uNode = GetUserX(argv[0]); if (argc < 3) { --- 1604,1608 ---- static CMD_FUNC(cmd_away) { ! struct user *uNode = GetUserX(argv[0]); if (argc < 3) { *************** *** 1645,1649 **** static void ! ircu_del_user(struct userNode *user) { SPROTO(user->uplink)->users[base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN)] = NULL; --- 1642,1646 ---- static void ! ircu_del_user(struct user *user) { SPROTO(user->uplink)->users[base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN)] = NULL; *************** *** 1673,1678 **** /* 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 */ --- 1670,1673 ---- *************** *** 1800,1804 **** void ! reg_privmsg_func(struct userNode *user, privmsg_func_t handler) { unsigned long numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); --- 1795,1799 ---- void ! reg_privmsg_func(struct user *user, privmsg_func_t handler) { unsigned long numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); *************** *** 1816,1820 **** void ! reg_notice_func(struct userNode *user, privmsg_func_t handler) { unsigned int numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); --- 1811,1815 ---- void ! reg_notice_func(struct user *user, privmsg_func_t handler) { unsigned int numeric = base64toint(UPROTO(user)->numeric+SERVER_NUMERIC_LEN, USER_NUMERIC_LEN); *************** *** 1832,1836 **** void ! reg_chanmsg_func(unsigned char prefix, struct userNode *service, chanmsg_func_t handler) { if (chanmsg_funcs[prefix].func) { --- 1827,1831 ---- void ! reg_chanmsg_func(unsigned char prefix, struct user *service, chanmsg_func_t handler) { if (chanmsg_funcs[prefix].func) { *************** *** 1851,1855 **** *j = 0; if (IsChannelName(target_list)) { ! struct chanNode *chan = GetChannel(target_list); if (chan) { if (cf) cf(chan, data); --- 1846,1850 ---- *j = 0; if (IsChannelName(target_list)) { ! struct channel *chan = GetChannel(target_list); if (chan) { if (cf) cf(chan, data); *************** *** 1858,1862 **** } } else { ! struct userNode *user = GetUserN(target_list); if (user) { if (uf) uf(user, data); --- 1853,1857 ---- } } else { ! struct user *user = GetUserN(target_list); if (user) { if (uf) uf(user, data); Index: proto_bahamut.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** proto_bahamut.c 2001/10/02 16:04:36 1.15 --- proto_bahamut.c 2001/10/10 04:00:41 1.16 *************** *** 45,51 **** /************************************/ ! typedef void (*foreach_chanfunc) (struct chanNode *chan, void *data); typedef void (*foreach_nonchan) (char *name, void *data); ! typedef void (*foreach_userfunc) (struct userNode *user, void *data); typedef void (*foreach_nonuser) (char *name, void *data); --- 45,51 ---- /************************************/ ! typedef void (*foreach_chanfunc) (struct channel *chan, void *data); typedef void (*foreach_nonchan) (char *name, void *data); ! typedef void (*foreach_userfunc) (struct user *user, void *data); typedef void (*foreach_nonuser) (char *name, void *data); *************** *** 58,62 **** unsigned int proto_max_channel_bans = 30; - static void timed_send_ping(void *data); static void timed_ping_timeout(void *data); --- 58,61 ---- *************** *** 93,108 **** 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)) /********************/ --- 92,105 ---- static struct module *proto_module; ! struct user_proto { privmsg_func_t privmsg_func; privmsg_func_t notice_func; }; ! #define UPROTO(USER) ((USER)->proto) ! struct server_proto { dict_t clients; }; ! #define SPROTO(SERVER) ((SERVER)->proto) /********************/ *************** *** 193,197 **** static void ! irc_uptime(struct userNode *user) { char uptime[INTERVALLEN]; --- 190,194 ---- static void ! irc_uptime(struct user *user) { char uptime[INTERVALLEN]; *************** *** 204,208 **** static void ! irc_whois(struct userNode *from, struct userNode *who) { putsock(":%s 311 %s %s %s %s * :%s", self->name, from->nick, who->nick, who->username, who->hostname, who->info); --- 201,205 ---- static void ! irc_whois(struct user *from, struct user *who) { putsock(":%s 311 %s %s %s %s * :%s", self->name, from->nick, who->nick, who->username, who->hostname, who->info); *************** *** 215,219 **** void ! irc_user(struct userNode *user) { char modes[16]; --- 212,216 ---- void ! irc_user(struct user *user) { char modes[16]; *************** *** 227,231 **** void ! irc_nick(struct userNode *user) { putsock(":%s %s %s "FMT_TIME_T, user->nick, CMD_NICK, user->nick, now); --- 224,228 ---- void ! irc_nick(struct user *user) { putsock(":%s %s %s "FMT_TIME_T, user->nick, CMD_NICK, user->nick, now); *************** *** 233,237 **** void ! irc_fetchtopic(struct userNode *from, struct chanNode *target) { putsock(":%s TOPIC %s", from->nick, target->name); --- 230,234 ---- void ! irc_fetchtopic(struct user *from, struct channel *target) { putsock(":%s TOPIC %s", from->nick, target->name); *************** *** 251,255 **** void ! irc_notice(struct userNode *from, const char *to, const char *message) { putsock(":%s %s %s :%s", from->nick, CMD_NOTICE, to, message); --- 248,252 ---- void ! irc_notice(struct user *from, const char *to, const char *message) { putsock(":%s %s %s :%s", from->nick, CMD_NOTICE, to, message); *************** *** 257,261 **** void ! irc_privmsg(struct userNode *from, const char *to, const char *message) { putsock(":%s %s %s :%s", from->nick, CMD_PRIVMSG, to, message); --- 254,258 ---- void ! irc_privmsg(struct user *from, const char *to, const char *message) { putsock(":%s %s %s :%s", from->nick, CMD_PRIVMSG, to, message); *************** *** 334,338 **** void ! irc_quit(struct userNode *user, const char *message) { putsock(":%s %s :%s", user->nick, CMD_QUIT, message); --- 331,335 ---- void ! irc_quit(struct user *user, const char *message) { putsock(":%s %s :%s", user->nick, CMD_QUIT, message); *************** *** 350,354 **** void ! irc_kill(struct userNode *from, struct userNode *target, const char *message) { if (from) { --- 347,351 ---- void ! irc_kill(struct user *from, struct user *target, const char *message) { if (from) { *************** *** 360,364 **** void ! irc_mode(struct userNode *from, struct chanNode *target, const char *modes) { putsock(":%s %s %s %s", from->nick, CMD_MODE, target->name, modes); --- 357,361 ---- void ! irc_mode(struct user *from, struct channel *target, const char *modes) { putsock(":%s %s %s %s", from->nick, CMD_MODE, target->name, modes); *************** *** 366,370 **** void ! irc_invite(struct userNode *from, struct userNode *who, struct chanNode *to) { putsock(":%s %s %s %s", from->nick, CMD_INVITE, who->nick, to->name); --- 363,367 ---- void ! irc_invite(struct user *from, struct user *who, struct channel *to) { putsock(":%s %s %s %s", from->nick, CMD_INVITE, who->nick, to->name); *************** *** 372,376 **** void ! irc_join(struct userNode *who, struct chanNode *what) { if (what->members.used == 1) { --- 369,373 ---- void ! irc_join(struct user *who, struct channel *what) { if (what->members.used == 1) { *************** *** 382,386 **** void ! irc_kick(struct userNode *actor, struct userNode *who, struct chanNode *from, const char *msg) { putsock(":%s %s %s %s :%s", actor->nick, CMD_KICK, from->name, who->nick, msg); --- 379,383 ---- void ! irc_kick(struct user *actor, struct user *who, struct channel *from, const char *msg) { putsock(":%s %s %s %s :%s", actor->nick, CMD_KICK, from->name, who->nick, msg); *************** *** 394,398 **** void ! irc_stats(struct userNode *from, struct server *target, char type) { putsock(":%s STATS %c :%s", from->nick, type, target->name); --- 391,395 ---- void ! irc_stats(struct user *from, struct server *target, char type) { putsock(":%s STATS %c :%s", from->nick, type, target->name); *************** *** 400,404 **** void ! irc_part(struct userNode *who, struct chanNode *what, const char *reason) { putsock(":%s %s %s :%s", who->nick, CMD_PART, what->name, reason); --- 397,401 ---- void ! irc_part(struct user *who, struct channel *what, const char *reason) { putsock(":%s %s %s :%s", who->nick, CMD_PART, what->name, reason); *************** *** 406,410 **** void ! irc_topic(struct userNode *who, struct chanNode *what, const char *topic) { putsock(":%s %s %s :%s", who->nick, CMD_TOPIC, what->name, topic); --- 403,407 ---- void ! irc_topic(struct user *who, struct channel *what, const char *topic) { putsock(":%s %s %s :%s", who->nick, CMD_TOPIC, what->name, topic); *************** *** 412,416 **** void ! chan_apply_bans(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, char **list) { char buffer[400]; --- 409,413 ---- void ! chan_apply_bans(struct user *who, struct channel *channel, char *what, unsigned int count, char **list) { char buffer[400]; *************** *** 448,452 **** void ! chan_apply_mode(struct userNode *who, struct chanNode *channel, char *what, unsigned int count, struct userNode **list) { char buffer[400]; --- 445,449 ---- void ! chan_apply_mode(struct user *who, struct channel *channel, char *what, unsigned int count, struct user **list) { char buffer[400]; *************** *** 484,488 **** void ! irc_change_channel_modes(struct chanNode *channel, struct userNode *source, const unsigned char *modes, va_list args) { char modebuf[200]; --- 481,485 ---- void ! irc_change_channel_modes(struct channel *channel, struct user *source, const unsigned char *modes, va_list args) { char modebuf[200]; *************** *** 497,501 **** while (*modes) { switch (*modes++) { ! struct userNode *user; int number; case '+': --- 494,498 ---- while (*modes) { switch (*modes++) { ! struct user *user; int number; case '+': *************** *** 508,516 **** 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; --- 505,513 ---- break; case 'o': ! user = va_arg(args, struct user *); arg_text = user->nick; goto add_arg; case 'v': ! user = va_arg(args, struct user *); arg_text = user->nick; goto add_arg; *************** *** 584,591 **** 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); } --- 581,586 ---- bahamut_new_server(struct server *server) { ! server->proto = calloc(1, sizeof(*server->proto)); ! server->proto->clients = dict_new(); } *************** *** 593,597 **** bahamut_del_server_client(const char *key, void *data, void *extra) { ! struct userNode *user = data; (void)key; (void)extra; DelUser(user, NULL, 0, "Server delinked"); --- 588,592 ---- bahamut_del_server_client(const char *key, void *data, void *extra) { ! struct user *user = data; (void)key; (void)extra; DelUser(user, NULL, 0, "Server delinked"); *************** *** 607,611 **** static int ! bahamut_new_user(struct userNode *user) { dict_insert(SPROTO(user->uplink)->clients, user->nick, user); --- 602,606 ---- static int ! bahamut_new_user(struct user *user) { dict_insert(SPROTO(user->uplink)->clients, user->nick, user); *************** *** 617,621 **** static void ! bahamut_del_user(struct userNode *user) { dict_remove(SPROTO(user->uplink)->clients, user->nick); --- 612,616 ---- static void ! bahamut_del_user(struct user *user) { dict_remove(SPROTO(user->uplink)->clients, user->nick); *************** *** 625,629 **** burst_send_nick(const char *key, void *data, void *extra) { ! struct userNode *user = data; (void)key; (void)extra; irc_user(user); --- 620,624 ---- burst_send_nick(const char *key, void *data, void *extra) { ! struct user *user = data; (void)key; (void)extra; irc_user(user); *************** *** 634,639 **** burst_send_channel(const char *key, void *data, void *extra) { ! struct chanNode *channel = data; ! struct modeNode *mn; unsigned int pos, base_len, nn; char burst_line[510]; --- 629,634 ---- burst_send_channel(const char *key, void *data, void *extra) { ! struct channel *channel = data; ! struct mode *mn; unsigned int pos, base_len, nn; char burst_line[510]; *************** *** 682,686 **** struct privmsg_desc { ! struct userNode *user; unsigned char *text; unsigned int is_notice; --- 677,681 ---- struct privmsg_desc { ! struct user *user; unsigned char *text; unsigned int is_notice; *************** *** 689,693 **** static struct chanmsg_desc { chanmsg_func_t func; ! struct userNode *service; } chanmsg_funcs[256]; --- 684,688 ---- static struct chanmsg_desc { chanmsg_func_t func; ! struct user *service; } chanmsg_funcs[256]; *************** *** 698,702 **** static void ! privmsg_chan_helper(struct chanNode *cn, void *data) { struct privmsg_desc *pd = data; --- 693,697 ---- static void ! privmsg_chan_helper(struct channel *cn, void *data) { struct privmsg_desc *pd = data; *************** *** 712,719 **** static void ! privmsg_user_helper(struct userNode *un, void *data) { struct privmsg_desc *pd = data; ! struct userNode_proto *uproto = UPROTO(un); if (!uproto) return; if (!pd->is_notice) { --- 707,714 ---- static void ! privmsg_user_helper(struct user *un, void *data) { struct privmsg_desc *pd = data; ! struct user_proto *uproto = UPROTO(un); if (!uproto) return; if (!pd->is_notice) { *************** *** 747,751 **** static void ! call_mode_change_funcs(struct chanNode *channel, struct userNode *user, int change_type, void *change) { unsigned int n; --- 742,746 ---- static void ! call_mode_change_funcs(struct channel *channel, struct user *user, int change_type, void *change) { unsigned int n; *************** *** 852,856 **** { struct server *uplink; ! struct userNode *user; if (argc == 3) { /* Client nick change */ --- 847,851 ---- { struct server *uplink; ! struct user *user; if (argc == 3) { /* Client nick change */ *************** *** 882,888 **** const char *key = NULL, *modes, *name; unsigned char *names; ! struct chanNode *channel; ! struct userNode *user; ! struct modeNode *mn; if (argc < 5) return 0; --- 877,883 ---- const char *key = NULL, *modes, *name; unsigned char *names; ! struct channel *channel; ! struct user *user; ! struct mode *mn; if (argc < 5) return 0; *************** *** 948,953 **** static CMD_FUNC(cmd_topic) { ! static struct chanNode *cn; ! static struct userNode *un; if (argc < 4) return 0; --- 943,948 ---- static CMD_FUNC(cmd_topic) { ! static struct channel *cn; ! static struct user *un; if (argc < 4) return 0; *************** *** 968,972 **** if (argc < 3) return 0; if (!IsChannelName(argv[1])) { ! struct userNode *un = GetUser(argv[1]); if (!un) { log(MAIN_LOG, LOG_ERROR, "Unable to find user %s whose mode is changing\n", argv[1]); --- 963,967 ---- if (argc < 3) return 0; if (!IsChannelName(argv[1])) { ! struct user *un = GetUser(argv[1]); if (!un) { log(MAIN_LOG, LOG_ERROR, "Unable to find user %s whose mode is changing\n", argv[1]); *************** *** 976,985 **** return 1; } else { ! struct chanNode *cn = GetChannel(argv[1]); ! struct userNode *un = GetUser(argv[-1]); int next_arg=3, res=1, add=1, bit; const char *mchange; ! struct modeNode *mn; ! chan_mode_t mode; char orig_key[KEYLEN+1]; unsigned int orig_limit; --- 971,980 ---- return 1; } else { ! struct channel *cn = GetChannel(argv[1]); ! struct user *un = GetUser(argv[-1]); int next_arg=3, res=1, add=1, bit; const char *mchange; ! struct mode *mn; ! channel_mode_t mode; char orig_key[KEYLEN+1]; unsigned int orig_limit; *************** *** 1022,1026 **** case 'o': case 'v': { ! struct userNode *vic; vic = GetUser(argv[next_arg++]); if (!vic) { --- 1017,1021 ---- case 'o': case 'v': { ! struct user *vic; vic = GetUser(argv[next_arg++]); if (!vic) { *************** *** 1076,1080 **** static CMD_FUNC(cmd_quit) { ! struct userNode *user; if (argc < 2) return 0; user = GetUser(argv[-1]); --- 1071,1075 ---- static CMD_FUNC(cmd_quit) { ! struct user *user; if (argc < 2) return 0; user = GetUser(argv[-1]); *************** *** 1090,1094 **** if (argc != 3) return 0; pd.user = GetUser(argv[-1]); ! /* The gag flag is never applied to userNodes it does not belong on, so no worries. */ if (IsGagged(pd.user)) return 1; --- 1085,1089 ---- if (argc != 3) return 0; pd.user = GetUser(argv[-1]); ! /* The gag flag is never applied to users it does not belong on, so no worries. */ if (IsGagged(pd.user)) return 1; *************** *** 1130,1134 **** static CMD_FUNC(cmd_stats) { ! struct userNode *un; if (argc < 4) return 0; --- 1125,1129 ---- static CMD_FUNC(cmd_stats) { ! struct user *un; if (argc < 4) return 0; *************** *** 1140,1145 **** static CMD_FUNC(cmd_whois) { ! struct userNode *from; ! struct userNode *who; if (argc < 4) return 0; --- 1135,1140 ---- static CMD_FUNC(cmd_whois) { ! struct user *from; ! struct user *who; if (argc < 4) return 0; *************** *** 1157,1161 **** struct create_desc { ! struct userNode *user; time_t when; }; --- 1152,1156 ---- struct create_desc { ! struct user *user; time_t when; }; *************** *** 1165,1169 **** { struct create_desc *cd = data; ! struct chanNode *cn; /* We can't assume the channel create was allowed because of the --- 1160,1164 ---- { struct create_desc *cd = data; ! struct channel *cn; /* We can't assume the channel create was allowed because of the *************** *** 1177,1181 **** */ if (cn->members.used == 1) { ! struct modeNode *mn = GetUserMode(cn, cd->user); if (mn) mn->modes = MODE_CHANOP; } --- 1172,1176 ---- */ if (cn->members.used == 1) { ! struct mode *mn = GetUserMode(cn, cd->user); if (mn) mn->modes = MODE_CHANOP; } *************** *** 1193,1200 **** } ! static struct userNode * bahamut_add_user(struct server *uplink, const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { ! struct userNode *uNode; uNode = AddUser(uplink, nick, ident, hostname, modes, userinfo, timestamp); --- 1188,1195 ---- } ! static struct user * bahamut_add_user(struct server *uplink, const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { ! struct user *uNode; uNode = AddUser(uplink, nick, ident, hostname, modes, userinfo, timestamp); *************** *** 1215,1219 **** } ! struct userNode * add_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { --- 1210,1214 ---- } ! struct user * add_local_user(const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) { *************** *** 1222,1226 **** static CMD_FUNC(cmd_num_topic) { ! static struct chanNode *cn; if (argc < 3) return 0; --- 1217,1221 ---- static CMD_FUNC(cmd_num_topic) { ! static struct channel *cn; if (argc < 3) return 0; *************** *** 1253,1257 **** static CMD_FUNC(cmd_kill) { ! struct userNode *user; if (argc < 3) return 0; if (!(user = GetUser(argv[2]))) { --- 1248,1252 ---- static CMD_FUNC(cmd_kill) { ! struct user *user; if (argc < 3) return 0; if (!(user = GetUser(argv[2]))) { *************** *** 1271,1275 **** static void ! join_helper(struct chanNode *cn, void *data) { AddChannelUser(data, cn, 0); --- 1266,1270 ---- static void ! join_helper(struct channel *cn, void *data) { AddChannelUser(data, cn, 0); *************** *** 1279,1288 **** join_helper_old_server(char *name, void *data) { ! struct userNode *un = data; ! struct chanNode *cn; cn = AddChannel(name, now, "", "", 0); AddChannelUser(un, cn, 0); if (cn->members.used == 1) { ! struct modeNode *mn = GetUserMode(cn, un); if (mn) mn->modes = MODE_CHANOP; } --- 1274,1283 ---- join_helper_old_server(char *name, void *data) { ! struct user *un = data; ! struct channel *cn; cn = AddChannel(name, now, "", "", 0); AddChannelUser(un, cn, 0); if (cn->members.used == 1) { ! struct mode *mn = GetUserMode(cn, un); if (mn) mn->modes = MODE_CHANOP; } *************** *** 1291,1295 **** static CMD_FUNC(cmd_join) { ! struct userNode *user; if (argc < 3) return 0; user = GetUser(argv[0]); --- 1286,1290 ---- static CMD_FUNC(cmd_join) { ! struct user *user; if (argc < 3) return 0; user = GetUser(argv[0]); *************** *** 1306,1310 **** static void ! part_helper(struct chanNode *cn, void *data) { DelChannelUser(data, cn, 0, 0); --- 1301,1305 ---- static void ! part_helper(struct channel *cn, void *data) { DelChannelUser(data, cn, 0, 0); *************** *** 1313,1317 **** static CMD_FUNC(cmd_part) { ! struct userNode *user; if (argc < 3) return 0; user = GetUser(argv[0]); --- 1308,1312 ---- static CMD_FUNC(cmd_part) { ! struct user *user; if (argc < 3) return 0; user = GetUser(argv[0]); *************** *** 1322,1328 **** static CMD_FUNC(cmd_kick) { ! struct userNode *victim; ! struct userNode *kicker; ! struct chanNode *channel; if (argc < 4) return 0; --- 1317,1323 ---- static CMD_FUNC(cmd_kick) { ! struct user *victim; ! struct user *kicker; ! struct channel *channel; if (argc < 4) return 0; *************** *** 1350,1354 **** static CMD_FUNC(cmd_away) { ! struct userNode *uNode = GetUser(argv[0]); if (argc < 3) { --- 1345,1349 ---- static CMD_FUNC(cmd_away) { ! struct user *uNode = GetUser(argv[0]); if (argc < 3) { *************** *** 1393,1398 **** /* Register things with module registry */ proto_module = module_register("proto", MAKE_VERSION(PROTO_INTERFACE_MAJOR, PROTO_INTERFACE_MINOR, 0), N... [truncated message content] |
From: Miles P. <pet...@us...> - 2001-10-08 01:46:53
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv30628 Modified Files: Tag: rel-1_0 main.c Log Message: dont accidently pass a negative timeout to select() Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/main.c,v retrieving revision 1.94.2.14 retrieving revision 1.94.2.15 diff -C2 -r1.94.2.14 -r1.94.2.15 *** main.c 2001/09/05 04:04:01 1.94.2.14 --- main.c 2001/10/08 01:46:50 1.94.2.15 *************** *** 461,466 **** /* if we're connected, we must have some time to ping (at least) */ wakey = timeq_next(); ! select_timeout.tv_sec = wakey - now; select_timeout.tv_usec = 0; /* We're connected to the server, watch for incoming data */ FD_ZERO(&connection); --- 461,473 ---- /* if we're connected, we must have some time to ping (at least) */ wakey = timeq_next(); ! ! if ((wakey - now) < 0) { ! select_timeout.tv_sec = 0; ! } else { ! select_timeout.tv_sec = wakey - now; ! } ! select_timeout.tv_usec = 0; + /* We're connected to the server, watch for incoming data */ FD_ZERO(&connection); *************** *** 476,480 **** } /* run timeq after reading socket input */ ! if (cManager.uplink->state == CONNECTED) timeq_run(now); } else if (errno != EINTR){ log(MAIN_LOG, LOG_ERROR, "select(): %s\n", strerror(errno)); --- 483,487 ---- } /* run timeq after reading socket input */ ! timeq_run(now); } else if (errno != EINTR){ log(MAIN_LOG, LOG_ERROR, "select(): %s\n", strerror(errno)); |
From: Adrian D. <sai...@us...> - 2001-10-06 21:34:01
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv27316 Modified Files: Tag: rel-1_0 chanserv.c Log Message: In !staff, if an oper has a handle with +h, don't put them on both the oper AND helper lists. Index: chanserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.c,v retrieving revision 1.161.2.83 retrieving revision 1.161.2.84 diff -C2 -r1.161.2.83 -r1.161.2.84 *** chanserv.c 2001/09/04 18:35:55 1.161.2.83 --- chanserv.c 2001/10/06 21:33:57 1.161.2.84 *************** *** 3247,3250 **** --- 3247,3253 ---- helper = curr_helpers.list[n]; + if (IsOper(helper)) + continue; + if(IsAway(helper)) { |
From: Miles P. <pet...@us...> - 2001-10-04 03:44:56
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv12326 Modified Files: Tag: rel-1_0 sockcheck.c Log Message: fix some formatting ;I Index: sockcheck.c =================================================================== RCS file: /cvsroot/srvx/services/src/sockcheck.c,v retrieving revision 1.54.2.33 retrieving revision 1.54.2.34 diff -C2 -r1.54.2.33 -r1.54.2.34 *** sockcheck.c 2001/10/04 03:37:02 1.54.2.33 --- sockcheck.c 2001/10/04 03:44:53 1.54.2.34 *************** *** 624,634 **** */ if (pthread_mutex_lock(&tests_mutex)) { ! /* lock failure; this usually means coding error */ log(PC_LOG, LOG_ERROR, "BUG: pthread_mutex_lock(&tests_mutex) returned errno %d (%s)\n", errno, strerror(errno)); return; } ! /* Don't compare idx != 0 directly, because somebody else may have ! * reordered the tests already. */ if (client->tests->list[client->test_index] != tests->list[0]) { struct sockcheck_list *new_tests = sockcheck_list_clone(tests); --- 624,634 ---- */ if (pthread_mutex_lock(&tests_mutex)) { ! /* lock failure; this usually means coding error */ log(PC_LOG, LOG_ERROR, "BUG: pthread_mutex_lock(&tests_mutex) returned errno %d (%s)\n", errno, strerror(errno)); return; } ! /* Don't compare idx != 0 directly, because somebody else may have ! * reordered the tests already. */ if (client->tests->list[client->test_index] != tests->list[0]) { struct sockcheck_list *new_tests = sockcheck_list_clone(tests); |
From: Miles P. <pet...@us...> - 2001-10-04 03:37:05
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv10670 Modified Files: Tag: rel-1_0 sockcheck.c Log Message: out of the blue.. we shouldnt have multiple threads screwing with the test lists.. should we? Index: sockcheck.c =================================================================== RCS file: /cvsroot/srvx/services/src/sockcheck.c,v retrieving revision 1.54.2.32 retrieving revision 1.54.2.33 diff -C2 -r1.54.2.32 -r1.54.2.33 *** sockcheck.c 2001/09/30 04:03:55 1.54.2.32 --- sockcheck.c 2001/10/04 03:37:02 1.54.2.33 *************** *** 143,147 **** --- 143,151 ---- }; + /* + * List of tests protected by tests_mutex. + */ static struct sockcheck_list *tests; + static pthread_mutex_t tests_mutex = PTHREAD_MUTEX_INITIALIZER; /* Stuff used inside the worker thread, one instance per open connection. */ *************** *** 615,620 **** log(PC_LOG, LOG_INFO, "Proxy check failed for client at IP %08x hostname %s (%s)\n", client->addr->addr, client->addr->hostname, client->addr->reason); #endif ! /* Don't compare idx != 0 directly, because somebody else may have ! * reordered the tests already. */ if (client->tests->list[client->test_index] != tests->list[0]) { struct sockcheck_list *new_tests = sockcheck_list_clone(tests); --- 619,634 ---- log(PC_LOG, LOG_INFO, "Proxy check failed for client at IP %08x hostname %s (%s)\n", client->addr->addr, client->addr->hostname, client->addr->reason); #endif ! /* protect the tests list with a mutex.. ! * multiple threads shouldn't be rearranging the list ! * -Jedi ! */ ! if (pthread_mutex_lock(&tests_mutex)) { ! /* lock failure; this usually means coding error */ ! log(PC_LOG, LOG_ERROR, "BUG: pthread_mutex_lock(&tests_mutex) returned errno %d (%s)\n", errno, strerror(errno)); ! return; ! } ! ! /* Don't compare idx != 0 directly, because somebody else may have ! * reordered the tests already. */ if (client->tests->list[client->test_index] != tests->list[0]) { struct sockcheck_list *new_tests = sockcheck_list_clone(tests); *************** *** 626,629 **** --- 640,645 ---- tests = new_tests; } + + pthread_mutex_unlock(&tests_mutex); } else { log(PC_LOG, LOG_ERROR, "BUG: sockcheck_decide(\"%s\", %d): unrecognized decision\n", client->addr->hostname, decision); |
From: Entrope <en...@us...> - 2001-10-03 01:28:30
|
Update of /cvsroot/srvx/services In directory usw-pr-cvs1:/tmp/cvs-serv5701 Added Files: compile depcomp Log Message: move compile, depcomp to root directory of project --- NEW FILE --- #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. # Copyright 1999, 2000 Free Software Foundation, Inc. # Written by Tom Tromey <tr...@cy...>. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Usage: # compile PROGRAM [ARGS]... # `-o FOO.o' is removed from the args passed to the actual compile. prog=$1 shift ofile= cfile= args= while test $# -gt 0; do case "$1" in -o) # configure might choose to run compile as `compile cc -o foo foo.c'. # So we do something ugly here. ofile=$2 shift case "$ofile" in *.o | *.obj) ;; *) args="$args -o $ofile" ofile= ;; esac ;; *.c) cfile=$1 args="$args $1" ;; *) args="$args $1" ;; esac shift done if test -z "$ofile" || test -z "$cfile"; then # If no `-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # `.c' file was seen then we are probably linking. That is also # ok. exec "$prog" $args fi # Name of file we expect compiler to create. cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` # Create the lock directory. # Note: use `[/.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d while true; do if mkdir $lockdir > /dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir $lockdir; exit 1" 1 2 15 # Run the compile. "$prog" $args status=$? if test -f "$cofile"; then mv "$cofile" "$ofile" fi rmdir $lockdir exit $status --- NEW FILE --- #! /bin/sh # depcomp - compile a program generating dependencies as side-effects # Copyright 1999, 2000 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva <ol...@dc...>. if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # `libtool' can also be set to `yes' or `no'. depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> $depfile echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. This file always lives in the current directory. # Also, the AIX compiler puts `$object:' at the start of each line; # $object doesn't have directory information. stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" outname="$stripped.o" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; tru64) # The Tru64 AIX compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. tmpdepfile1="$object.d" tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` if test "$libtool" = yes; then "$@" -Wc,-MD else "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi if test -f "$tmpdepfile1"; then tmpdepfile="$tmpdepfile1" else tmpdepfile="$tmpdepfile2" fi if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a space and a tab in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. test -z "$dashmflag" && dashmflag=-M ( IFS=" " case " $* " in *" --mode=compile "*) # this is libtool, let us make it quiet for arg do # cycle over the arguments case "$arg" in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) # X makedepend ( shift cleared=no for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes esac case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift;; -*) ;; *) set fnord "$@" "$arg"; shift;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tail +3 "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 |
From: Entrope <en...@us...> - 2001-10-03 01:28:30
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv5701/src Removed Files: compile depcomp Log Message: move compile, depcomp to root directory of project --- compile DELETED --- --- depcomp DELETED --- |
From: Entrope <en...@us...> - 2001-10-03 00:57:49
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv19385/src Modified Files: config.h.in recdb.c recdb.h tools.c Log Message: get rid of further uses of HAVE_ansihdr_H, and document the list of accepted ANSI headers Index: config.h.in =================================================================== RCS file: /cvsroot/srvx/services/src/config.h.in,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** config.h.in 2001/10/02 16:04:36 1.27 --- config.h.in 2001/10/03 00:57:46 1.28 *************** *** 40,46 **** #undef HAVE_BCOPY - /* Define if you have the <ctype.h> header file. */ - #undef HAVE_CTYPE_H - /* Define if you have the `dcgettext' function. */ #undef HAVE_DCGETTEXT --- 40,43 ---- *************** *** 52,58 **** #undef HAVE_DMALLOC_H - /* Define if you have the <errno.h> header file. */ - #undef HAVE_ERRNO_H - /* Define if you have the <fcntl.h> header file. */ #undef HAVE_FCNTL_H --- 49,52 ---- *************** *** 139,145 **** #undef HAVE_MALLOC_H - /* Define if you have the <math.h> header file. */ - #undef HAVE_MATH_H - /* Define if you have the `memcpy' function. */ #undef HAVE_MEMCPY --- 133,136 ---- *************** *** 202,208 **** #undef HAVE_SETENV - /* Define if you have the <setjmp.h> header file. */ - #undef HAVE_SETJMP_H - /* Define if you have the `setlocale' function. */ #undef HAVE_SETLOCALE --- 193,196 ---- *************** *** 211,217 **** #undef HAVE_SETRLIMIT - /* Define if you have the <signal.h> header file. */ - #undef HAVE_SIGNAL_H - /* Define if struct sockaddr_in contains a sin_len field */ #undef HAVE_SIN_LEN --- 199,202 ---- *************** *** 220,226 **** #undef HAVE_SOCKET - /* Define if you have the <stdarg.h> header file. */ - #undef HAVE_STDARG_H - /* Define if you have the <stddef.h> header file. */ #undef HAVE_STDDEF_H --- 205,208 ---- *************** *** 229,235 **** #undef HAVE_STDINT_H - /* Define if you have the <stdio.h> header file. */ - #undef HAVE_STDIO_H - /* Define if you have the <stdlib.h> header file. */ #undef HAVE_STDLIB_H --- 211,214 ---- *************** *** 312,318 **** /* Define if you have the <sys/types.h> header file. */ #undef HAVE_SYS_TYPES_H - - /* Define if you have the <time.h> header file. */ - #undef HAVE_TIME_H /* Define if you have the `tsearch' function. */ --- 291,294 ---- Index: recdb.c =================================================================== RCS file: /cvsroot/srvx/services/src/recdb.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** recdb.c 2001/10/02 16:04:36 1.33 --- recdb.c 2001/10/03 00:57:46 1.34 *************** *** 20,35 **** #include "config.h" - #ifdef HAVE_CTYPE_H #include <ctype.h> - #endif - #ifdef HAVE_SETJMP_H #include <setjmp.h> - #endif - #ifdef HAVE_STDIO_H #include <stdio.h> - #endif - #ifdef HAVE_STDLIB_H #include <stdlib.h> ! #endif #include "dict.h" #include "recdb.h" --- 20,28 ---- #include "config.h" #include <ctype.h> #include <setjmp.h> #include <stdio.h> #include <stdlib.h> ! #include "dict.h" #include "recdb.h" Index: recdb.h =================================================================== RCS file: /cvsroot/srvx/services/src/recdb.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** recdb.h 2001/03/30 21:20:10 1.16 --- recdb.h 2001/10/03 00:57:46 1.17 *************** *** 24,33 **** #include "config.h" - #ifdef HAVE_STDIO_H #include <stdio.h> - #endif - #ifdef HAVE_STRING_H #include <string.h> - #endif #include "dict.h" --- 24,29 ---- Index: tools.c =================================================================== RCS file: /cvsroot/srvx/services/src/tools.c,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -r1.96 -r1.97 *** tools.c 2001/09/27 21:58:07 1.96 --- tools.c 2001/10/03 00:57:46 1.97 *************** *** 20,43 **** #include "config.h" - #ifdef HAVE_CTYPE_H #include <ctype.h> - #endif - #ifdef HAVE_NETDB_H - #include <netdb.h> - #endif - #ifdef HAVE_STDIO_H #include <stdio.h> - #endif - #ifdef HAVE_STDLIB_H #include <stdlib.h> - #endif - #ifdef HAVE_STRING_H #include <string.h> #endif #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> - #endif - #ifdef HAVE_TIME_H - #include <time.h> #endif #ifdef HAVE_SYS_SOCKET_H --- 20,33 ---- #include "config.h" #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> + #include <time.h> + #ifdef HAVE_NETDB_H + #include <netdb.h> #endif #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif #ifdef HAVE_SYS_SOCKET_H |