From c2d9acd82eff54634d92ee85ba3b962ed4445db4 Mon Sep 17 00:00:00 2001 From: stskeeps Date: Sun, 4 Jun 2000 14:51:38 +0000 Subject: [PATCH] sendto_serv_butone_token_opt --- Changes | 3 +- include/struct.h | 10 ++++++ src/send.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index d6cc7562b..188733342 100644 --- a/Changes +++ b/Changes @@ -346,4 +346,5 @@ - Fixed a bug that prolly was fixed by Potvin, but was "not fixed correctly" - Fixed a crash problem in register_user and most likely fixed the "strange vhost" thing, (was a dumb bug, mising ircsprintf) -- Fixed the *** NickServ sets mode +creep SVS2MODE bug.. \ No newline at end of file +- Fixed the *** NickServ sets mode +creep SVS2MODE bug.. +- sendto_serv_butone_token_opt ().. \ No newline at end of file diff --git a/include/struct.h b/include/struct.h index c100a2d73..3fd82cb5a 100644 --- a/include/struct.h +++ b/include/struct.h @@ -175,6 +175,16 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define SetLog(x) ((x)->status = STAT_LOG) #define SetService(x) ((x)->status = STAT_SERVICE) +/* opt.. */ +#define OPT_SJOIN 0x0001 +#define OPT_NOT_SJOIN 0x0002 +#define OPT_NICKv2 0x0004 +#define OPT_NOT_NICKv2 0x0008 +#define OPT_SJOIN2 0x0010 +#define OPT_NOT_SJOIN2 0x0020 +#define OPT_UMODE2 0x0040 +#define OPT_NOT_UMODE2 0x0080 + #define FLAGS_PINGSENT 0x0001 /* Unreplied ping sent */ #define FLAGS_DEADSOCKET 0x0002 /* Local socket is dead--Exiting soon */ #define FLAGS_KILLED 0x0004 /* Prevents "QUIT" from being sent for this */ diff --git a/src/send.c b/src/send.c index 41cf54d31..f38ee8fce 100644 --- a/src/send.c +++ b/src/send.c @@ -554,6 +554,93 @@ void sendto_serv_butone_token(aClient *one, char *prefix, char *command, return; } +/* + * sendto_server_butone_token_opt + * + * Send a message to all connected servers except the client 'one'. + * with capab to tokenize, opt + */ + +void sendto_serv_butone_token_opt(aClient *one, int opt, char *prefix, char *command, + char *token, char *pattern, ...) +{ + va_list vl; + int i; + aClient *cptr; +#ifndef NO_FDLIST + int j; +#endif + char *p; + static char tcmd[1024]; + static char ccmd[1024]; + static char buff[1024]; + static char pref[100]; + + va_start(vl, pattern); + + pref[0] = '\0'; + if (strchr(prefix, '.')) + ircsprintf(pref, "@%s", find_server_aln(prefix)); + + strcpy(tcmd, token); + strcpy(ccmd, command); + strcat(tcmd, " "); + strcat(ccmd, " "); + ircvsprintf(buff, pattern, vl); + strcat(tcmd, buff); + strcat(ccmd, buff); + +#ifdef NO_FDLIST + for (i = 0; i <= highest_fd; i++) +#else + for (i = serv_fdlist.entry[j = 1]; j <= serv_fdlist.last_entry; + i = serv_fdlist.entry[++j]) +#endif + { + if (!(cptr = local[i]) || (one && cptr == one->from)) + continue; +#ifdef NO_FDLIST + if (IsServer(cptr)) +#endif + + if ((opt & OPT_NOT_SJOIN) && SupportSJOIN(cptr)) + continue; + if ((opt & OPT_NOT_NICKv2) && SupportNICKv2(cptr)) + continue; + if ((opt & OPT_NOT_SJOIN2) && SupportSJOIN2(cptr)) + continue; + if ((opt & OPT_NOT_UMODE2) && SupportUMODE2(cptr)) + continue; + if ((opt & OPT_NICKv2) && !SupportNICKv2(cptr)) + continue; + if ((opt & OPT_SJOIN) && !SupportSJOIN(cptr)) + continue; + if ((opt & OPT_SJOIN2) && !SupportSJOIN2(cptr)) + continue; + if ((opt & OPT_UMODE2) && !SupportUMODE2(cptr)) + continue; + + if (IsToken(cptr)) + { + if ((pref[0] != '\0') && SupportALN(cptr)) + sendto_one(cptr, "%s %s", pref, tcmd); + else + sendto_one(cptr, ":%s %s", prefix, + tcmd); + } + else + { + if ((pref[0] != '\0') && SupportALN(cptr)) + sendto_one(cptr, "%s %s", pref, ccmd); + else + sendto_one(cptr, ":%s %s", prefix, + ccmd); + } + } + va_end(vl); + return; +} + /* * sendto_serv_butone_quit *