From 065a143ab1c4e5aab94187e51a843a31e93b146a Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Sun, 16 Apr 2000 05:12:02 +0000 Subject: [PATCH] Author: Kev Log message: make jupe_add() use a flags argument; add flags arguments (and pass appropriate values) to jupe/gline_activate/deactivate for future expansion (local activations and deactivations for global glines) git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@183 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 22 +++++++++++++++++++++- include/gline.h | 31 ++++--------------------------- include/jupe.h | 10 ++++++---- ircd/gline.c | 4 ++-- ircd/jupe.c | 20 ++++++++------------ ircd/m_gline.c | 8 ++++---- ircd/m_jupe.c | 47 ++++++++++++++++++++++------------------------- 7 files changed, 67 insertions(+), 75 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f43dd7..074c5ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,25 @@ 2000-04-16 Kevin L. Mitchell + * ircd/gline.c: add flags argument to gline_activate and + gline_deactivate for future expansion + + * ircd/m_gline.c: pass flags to gline_activate and + gline_deactivate + + * include/gline.h: add flags argument to gline_activate and + gline_deactivate + + * ircd/jupe.c: add flags argument to jupe_activate and + jupe_deactivate for future expansion + + * include/jupe.h: add flags argument to jupe_activate and + jupe_deactivate + + * ircd/m_jupe.c: pass a flags argument to jupe_add instead of + local, active; pass flags to jupe_activate and jupe_deactivate + + * include/gline.h: remove dead code + * ircd/gline.c: make gline expire times relative to CurrentTime, since that should be monotonically increasing, instead of TStime(), which can be set backwards, and which can therefore @@ -563,7 +583,7 @@ # # ChangeLog for ircu2.10.11 # -# $Id: ChangeLog,v 1.90 2000-04-16 04:30:42 kev Exp $ +# $Id: ChangeLog,v 1.91 2000-04-16 05:12:01 kev Exp $ # # Insert new changes at beginning of the change list. # diff --git a/include/gline.h b/include/gline.h index 88f16e3..7763063 100644 --- a/include/gline.h +++ b/include/gline.h @@ -70,9 +70,11 @@ extern int gline_add(struct Client *cptr, struct Client *sptr, char *userhost, char *reason, time_t expire, time_t lastmod, unsigned int flags); extern int gline_activate(struct Client *cptr, struct Client *sptr, - struct Gline *gline, time_t lastmod); + struct Gline *gline, time_t lastmod, + unsigned int flags); extern int gline_deactivate(struct Client *cptr, struct Client *sptr, - struct Gline *gline, time_t lastmod); + struct Gline *gline, time_t lastmod, + unsigned int flags); extern struct Gline *gline_find(char *userhost, unsigned int flags); extern struct Gline *gline_lookup(struct Client *cptr); extern void gline_free(struct Gline *gline); @@ -81,29 +83,4 @@ extern int gline_resend(struct Client *cptr, struct Gline *gline); extern int gline_list(struct Client *sptr, char *userhost); extern void gline_stats(struct Client *sptr); -#if 0 /* forget it! */ -#define SetActive(g) ((g)->gl_flags |= GLINE_ACTIVE) -#define ClearActive(g) ((g)->gl_flags &= ~GLINE_ACTIVE) -#define SetGlineIsIpMask(g) ((g)->gl_flags |= GLINE_IPMASK) -#define SetGlineIsLocal(g) ((g)->gl_flags |= GLINE_LOCAL) - -extern struct Gline* GlobalGlineList; -extern struct Gline* BadChanGlineList; - -extern void gline_remove_expired(time_t now); - -extern void add_gline(struct Client *sptr, int ip_mask, - char *host, char *comment, char *user, - time_t expire, int local); -extern struct Gline* make_gline(int is_ipmask, char *host, char *reason, - char *name, time_t expire); -extern struct Gline* find_gline(struct Client *cptr, struct Gline **pgline); -extern void free_gline(struct Gline *gline, struct Gline *prev); - -#ifdef BADCHAN -extern int bad_channel(const char* name); -extern void bad_channel_remove_expired(time_t now); -#endif -#endif /* 0 */ - #endif /* INCLUDED_gline_h */ diff --git a/include/jupe.h b/include/jupe.h index 5c0cf7a..4aeda46 100644 --- a/include/jupe.h +++ b/include/jupe.h @@ -56,12 +56,14 @@ struct Jupe { #define JupeLastMod(j) ((j)->ju_lastmod) extern int jupe_add(struct Client *cptr, struct Client *sptr, char *server, - char *reason, time_t expire, time_t lastmod, int local, - int active); + char *reason, time_t expire, time_t lastmod, + unsigned int flags); extern int jupe_activate(struct Client *cptr, struct Client *sptr, - struct Jupe *jupe, time_t lastmod); + struct Jupe *jupe, time_t lastmod, + unsigned int flags); extern int jupe_deactivate(struct Client *cptr, struct Client *sptr, - struct Jupe *jupe, time_t lastmod); + struct Jupe *jupe, time_t lastmod, + unsigned int flags); extern struct Jupe* jupe_find(char *server); extern void jupe_free(struct Jupe *jupe); extern void jupe_burst(struct Client *cptr); diff --git a/ircd/gline.c b/ircd/gline.c index 3ebc8ea..f1ea9c2 100644 --- a/ircd/gline.c +++ b/ircd/gline.c @@ -242,7 +242,7 @@ gline_add(struct Client *cptr, struct Client *sptr, char *userhost, int gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline, - time_t lastmod) + time_t lastmod, unsigned int flags) { assert(0 != gline); assert(!GlineIsLocal(gline)); @@ -288,7 +288,7 @@ gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline, int gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline, - time_t lastmod) + time_t lastmod, unsigned int flags) { assert(0 != gline); diff --git a/ircd/jupe.c b/ircd/jupe.c index ae2d7c8..61db6cb 100644 --- a/ircd/jupe.c +++ b/ircd/jupe.c @@ -97,10 +97,9 @@ propagate_jupe(struct Client *cptr, struct Client *sptr, struct Jupe *jupe) int jupe_add(struct Client *cptr, struct Client *sptr, char *server, char *reason, - time_t expire, time_t lastmod, int local, int active) + time_t expire, time_t lastmod, unsigned int flags) { struct Jupe *ajupe; - unsigned int flags = 0; assert(0 != server); assert(0 != reason); @@ -121,25 +120,22 @@ jupe_add(struct Client *cptr, struct Client *sptr, char *server, char *reason, sendto_op_mask(SNO_NETWORK, "%s adding %sJUPE for %s, expiring at " TIME_T_FMT ": %s", IsServer(sptr) ? sptr->name : sptr->user->server->name, - local ? "local " : "", server, expire + TSoffset, reason); + flags & JUPE_LOCAL ? "local " : "", server, + expire + TSoffset, reason); #ifdef JPATH if (IsServer(sptr)) write_log(JPATH, TIME_T_FMT " %s adding %sJUPE for %s, expiring at " TIME_T_FMT ": %s\n", TStime(), sptr->name, - local ? "local " : "", server, expire + TSoffset, reason); + flags & JUPE_LOCAL ? "local " : "", server, expire + TSoffset, + reason); else write_log(JPATH, TIME_T_FMT, " %s!%s@%s adding %sJUPE for %s, expiring at " TIME_T_FMT ": %s\n", TStime(), sptr->name, sptr->user->username, - sptr->user->host, local ? "local " : "", server, + sptr->user->host, flags & JUPE_LOCAL ? "local " : "", server, expire + TSoffset, reason); #endif /* JPATH */ - if (active) /* compute initial flags */ - flags |= JUPE_ACTIVE; - if (local) - flags |= JUPE_LOCAL; - /* make the jupe */ ajupe = make_jupe(server, reason, expire, lastmod, flags); @@ -150,7 +146,7 @@ jupe_add(struct Client *cptr, struct Client *sptr, char *server, char *reason, int jupe_activate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe, - time_t lastmod) + time_t lastmod, unsigned int flags) { assert(0 != jupe); assert(!JupeIsLocal(jupe)); @@ -187,7 +183,7 @@ jupe_activate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe, int jupe_deactivate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe, - time_t lastmod) + time_t lastmod, unsigned int flags) { assert(0 != jupe); diff --git a/ircd/m_gline.c b/ircd/m_gline.c index 7d1c695..6c52516 100644 --- a/ircd/m_gline.c +++ b/ircd/m_gline.c @@ -180,9 +180,9 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) gline_free(agline); else if (!lastmod || GlineLastMod(agline) < lastmod) { /* new mod */ if (flags & GLINE_ACTIVE) - return gline_activate(cptr, sptr, agline, lastmod); + return gline_activate(cptr, sptr, agline, lastmod, flags); else - return gline_deactivate(cptr, sptr, agline, lastmod); + return gline_deactivate(cptr, sptr, agline, lastmod, flags); } else if (GlineLastMod(agline) == lastmod) return 0; else @@ -281,10 +281,10 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) else { if (flags & GLINE_ACTIVE) return gline_activate(cptr, sptr, agline, - GlineLastMod(agline) ? TStime() : 0); + GlineLastMod(agline) ? TStime() : 0, flags); else return gline_deactivate(cptr, sptr, agline, - GlineLastMod(agline) ? TStime() : 0); + GlineLastMod(agline) ? TStime() : 0, flags); } } diff --git a/ircd/m_jupe.c b/ircd/m_jupe.c index fb606d9..3dbfba5 100644 --- a/ircd/m_jupe.c +++ b/ircd/m_jupe.c @@ -125,7 +125,7 @@ int ms_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Client *acptr = 0; struct Jupe *ajupe; - int local = 0, active = 1; + unsigned int flags = 0; time_t expire_off, lastmod; char *server = parv[2], *target = parv[1], *reason = parv[5]; @@ -142,14 +142,13 @@ int ms_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - local = 1; + flags |= JUPE_LOCAL; } - if (*server == '-') { - active = 0; + if (*server == '-') server++; - } else if (*server == '+') { - active = 1; + else if (*server == '+') { + flags |= JUPE_ACTIVE; server++; } @@ -159,21 +158,20 @@ int ms_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) ajupe = jupe_find(server); if (ajupe) { - if (JupeIsLocal(ajupe) && !local) /* global jupes override local ones */ + if (JupeIsLocal(ajupe) && !(flags & JUPE_LOCAL)) /* global over local */ jupe_free(ajupe); else if (JupeLastMod(ajupe) < lastmod) { /* new modification */ - if (active) - return jupe_activate(cptr, sptr, ajupe, lastmod); + if (flags & JUPE_ACTIVE) + return jupe_activate(cptr, sptr, ajupe, lastmod, flags); else - return jupe_deactivate(cptr, sptr, ajupe, lastmod); + return jupe_deactivate(cptr, sptr, ajupe, lastmod, flags); } else if (JupeLastMod(ajupe) == lastmod) /* no changes */ return 0; else return jupe_resend(cptr, ajupe); /* other server desynched WRT jupes */ } - return jupe_add(cptr, sptr, server, reason, expire_off, lastmod, local, - active); + return jupe_add(cptr, sptr, server, reason, expire_off, lastmod, flags); } /* @@ -194,7 +192,7 @@ int mo_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Client *acptr = 0; struct Jupe *ajupe; - int local = 0, active = 1; + unsigned int flags = 0; time_t expire_off; char *server = parv[1], *target = parv[2], *reason = parv[4]; @@ -202,12 +200,11 @@ int mo_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return jupe_list(sptr, 0); if (*server == '+') { - active = 1; + flags |= JUPE_ACTIVE; server++; - } else if (*server == '-') { - active = 0; + } else if (*server == '-') server++; - } else + else return jupe_list(sptr, server); if (parc < 5) @@ -222,11 +219,12 @@ int mo_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return send_error_to_client(sptr, ERR_NOPRIVILEGES); sendcmdto_one(acptr, CMD_JUPE, sptr, "%C %c%s %s %Tu :%s", acptr, - active ? '+' : '-', server, parv[3], TStime(), reason); + flags & JUPE_ACTIVE ? '+' : '-', server, parv[3], + TStime(), reason); return 0; } - local = 1; + flags |= JUPE_LOCAL; } else if (!IsOper(sptr)) return send_error_to_client(sptr, ERR_NOPRIVILEGES); @@ -235,18 +233,17 @@ int mo_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) ajupe = jupe_find(server); if (ajupe) { - if (JupeIsLocal(ajupe) && !local) /* global jupes override local ones */ + if (JupeIsLocal(ajupe) && !(flags & JUPE_LOCAL)) /* global over local */ jupe_free(ajupe); else { - if (active) - return jupe_activate(cptr, sptr, ajupe, TStime()); + if (flags & JUPE_ACTIVE) + return jupe_activate(cptr, sptr, ajupe, TStime(), flags); else - return jupe_deactivate(cptr, sptr, ajupe, TStime()); + return jupe_deactivate(cptr, sptr, ajupe, TStime(), flags); } } - return jupe_add(cptr, sptr, server, reason, expire_off, TStime(), local, - active); + return jupe_add(cptr, sptr, server, reason, expire_off, TStime(), flags); } #endif /* CONFIG_OPERCMDS */ -- 2.20.1