summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/os_stats.c126
-rw-r--r--src/servers.c133
2 files changed, 64 insertions, 195 deletions
diff --git a/src/core/os_stats.c b/src/core/os_stats.c
index 9171287f8..7e15d018e 100644
--- a/src/core/os_stats.c
+++ b/src/core/os_stats.c
@@ -103,6 +103,7 @@ int do_stats(User * u)
char timebuf[64];
char buf[512];
int buflen;
+ int i;
if (extra && stricmp(extra, "ALL") != 0) {
if (stricmp(extra, "AKILL") == 0) {
@@ -304,113 +305,30 @@ int do_stats(User * u)
}
if (extra && ((stricmp(extra, "ALL") == 0) || (stricmp(extra, "UPLINK") == 0)) && is_services_admin(u)) {
- notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER, serv_uplink->name);
buf[0] = '\0';
buflen = 511; /* How confusing, this is the amount of space left! */
- if (uplink_capab & CAPAB_NOQUIT) {
- strncat(buf, " NOQUIT", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_TSMODE) {
- strncat(buf, " TSMODE", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_UNCONNECT) {
- strncat(buf, " UNCONNECT", buflen);
- buflen -= 10;
- }
- if (uplink_capab & CAPAB_NICKIP) {
- strncat(buf, " NICKIP", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_NSJOIN) {
- strncat(buf, " SSJOIN", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_ZIP) {
- strncat(buf, " ZIP", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_BURST) {
- strncat(buf, " BURST", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_TS5) {
- strncat(buf, " TS5", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_TS3) {
- strncat(buf, " TS3", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_DKEY) {
- strncat(buf, " DKEY", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_PT4) {
- strncat(buf, " PT4", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_SCS) {
- strncat(buf, " SCS", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_QS) {
- strncat(buf, " QS", buflen);
- buflen -= 3;
- }
- if (uplink_capab & CAPAB_UID) {
- strncat(buf, " UID", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_KNOCK) {
- strncat(buf, " KNOCK", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_CLIENT) {
- strncat(buf, " CLIENT", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_IPV6) {
- strncat(buf, " IPV6", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_SSJ5) {
- strncat(buf, " SSJ5", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_SN2) {
- strncat(buf, " SN2", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_TOKEN) {
- strncat(buf, " TOKEN", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_VHOST) {
- strncat(buf, " VHOST", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_SSJ3) {
- strncat(buf, " SSJ3", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_SJB64) {
- strncat(buf, " SJB64", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_CHANMODE) {
- strncat(buf, " CHANMODES=", buflen);
- buflen -= 11;
- strncat(buf, ircd->chanmodes, buflen);
- buflen -= strlen(ircd->chanmodes);
- }
- if (uplink_capab & CAPAB_NICKCHARS) {
- strncat(buf, " NICKCHARS=", buflen);
- buflen -= 11;
- strncat(buf, ircd->nickchars, buflen);
- buflen -= strlen(ircd->nickchars);
+ for (i = 0; capab_info[i].token; i++) {
+ if (uplink_capab & capab_info[i].flag) {
+ strncat(buf, " ", buflen);
+ buflen--;
+ strncat(buf, capab_info[i].token, buflen);
+ buflen -= strlen(capab_info[i].token);
+ /* Special cases */
+ if (capab_info[i].flag == CAPAB_CHANMODE) {
+ strncat(buf, "=", buflen);
+ buflen--;
+ strncat(buf, ircd->chanmodes, buflen);
+ buflen -= strlen(ircd->chanmodes);
+ }
+ if (capab_info[i].flag == CAPAB_NICKCHARS) {
+ strncat(buf, "=", buflen);
+ buflen--;
+ strncat(buf, ircd->nickchars, buflen);
+ buflen -= strlen(ircd->nickchars);
+ }
+ }
}
+ notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER, serv_uplink->name);
notice_lang(s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf);
notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(serv_uplink));
}
diff --git a/src/servers.c b/src/servers.c
index 0a076c334..ace20dfa8 100644
--- a/src/servers.c
+++ b/src/servers.c
@@ -25,6 +25,36 @@ char *TS6SID;
/* For first_server / next_server */
static Server *server_cur;
+CapabInfo capab_info[] = {
+ {"NOQUIT", CAPAB_NOQUIT},
+ {"TSMODE", CAPAB_TSMODE},
+ {"UNCONNECT", CAPAB_UNCONNECT},
+ {"NICKIP", CAPAB_NICKIP},
+ {"SSJOIN", CAPAB_NSJOIN},
+ {"ZIP", CAPAB_ZIP},
+ {"BURST", CAPAB_BURST},
+ {"TS5", CAPAB_TS5},
+ {"TS3", CAPAB_TS3},
+ {"DKEY", CAPAB_DKEY},
+ {"PT4", CAPAB_PT4},
+ {"SCS", CAPAB_SCS},
+ {"QS", CAPAB_QS},
+ {"UID", CAPAB_UID},
+ {"KNOCK", CAPAB_KNOCK},
+ {"CLIENT", CAPAB_CLIENT},
+ {"IPV6", CAPAB_IPV6},
+ {"SSJ5", CAPAB_SSJ5},
+ {"SN2", CAPAB_SN2},
+ {"TOK1", CAPAB_TOKEN},
+ {"TOKEN", CAPAB_TOKEN},
+ {"VHOST", CAPAB_VHOST},
+ {"SSJ3", CAPAB_SSJ3},
+ {"SJB64", CAPAB_SJB64},
+ {"CHANMODES", CAPAB_CHANMODE},
+ {"NICKCHARS", CAPAB_NICKCHARS},
+ {NULL, 0}
+};
+
/*************************************************************************/
/**
@@ -402,6 +432,7 @@ void do_squit(const char *source, int ac, char **av)
void capab_parse(int ac, char **av)
{
int i;
+ int j;
char *s, *tmp;
char *temp;
@@ -412,105 +443,25 @@ void capab_parse(int ac, char **av)
s = myStrGetToken(temp, '=', 0);
tmp = myStrGetTokenRemainder(temp, '=', 1);
- if (!s) {
+ if (!s)
continue;
- }
- if (!stricmp(s, "NOQUIT")) {
- uplink_capab |= CAPAB_NOQUIT;
- }
- if (!stricmp(s, "TSMODE")) {
- uplink_capab |= CAPAB_TSMODE;
- }
- if (!stricmp(av[i], "UNCONNECT")) {
- uplink_capab |= CAPAB_UNCONNECT;
- }
- if (!stricmp(s, "NICKIP")) {
- uplink_capab |= CAPAB_NICKIP;
- /* Update the struct so that we know we can get NICKIP */
- if (!ircd->nickip) {
+ for (j = 0; capab_info[j].token; j++) {
+ if (stricmp(s, capab_info[j].token) == 0)
+ uplink_capab |= capab_info[j].flag;
+ /* Special cases */
+ if ((stricmp(s, "NICKIP") == 0) && !ircd->nickip)
ircd->nickip = 1;
- }
- }
- if (!stricmp(s, "SSJOIN")) {
- uplink_capab |= CAPAB_NSJOIN;
- }
- if (!stricmp(s, "ZIP")) {
- uplink_capab |= CAPAB_ZIP;
- }
- if (!stricmp(s, "BURST")) {
- uplink_capab |= CAPAB_BURST;
- }
- if (!stricmp(s, "TS5")) {
- uplink_capab |= CAPAB_TS5;
- }
- if (!stricmp(s, "TS3")) {
- uplink_capab |= CAPAB_TS3;
- }
- if (!stricmp(s, "DKEY")) {
- uplink_capab |= CAPAB_DKEY;
- }
- if (!stricmp(s, "PT4")) {
- uplink_capab |= CAPAB_PT4;
- }
- if (!stricmp(s, "SCS")) {
- uplink_capab |= CAPAB_SCS;
- }
- if (!stricmp(s, "QS")) {
- uplink_capab |= CAPAB_QS;
- }
- if (!stricmp(s, "UID")) {
- uplink_capab |= CAPAB_UID;
- }
- if (!stricmp(s, "KNOCK")) {
- uplink_capab |= CAPAB_KNOCK;
- }
- if (!stricmp(s, "CLIENT")) {
- uplink_capab |= CAPAB_CLIENT;
- }
- if (!stricmp(s, "IPV6")) {
- uplink_capab |= CAPAB_IPV6;
- }
- if (!stricmp(s, "SSJ5")) {
- uplink_capab |= CAPAB_SSJ5;
- }
- if (!stricmp(s, "SN2")) {
- uplink_capab |= CAPAB_SN2;
- }
- if (!stricmp(s, "TOK1")) {
- uplink_capab |= CAPAB_TOKEN;
- }
- if (!stricmp(s, "TOKEN")) {
- uplink_capab |= CAPAB_TOKEN;
- }
- if (!stricmp(s, "VHOST")) {
- uplink_capab |= CAPAB_VHOST;
- }
- if (!stricmp(s, "SSJ3")) {
- uplink_capab |= CAPAB_SSJ3;
- }
- if (!stricmp(s, "SJB64")) {
- uplink_capab |= CAPAB_SJB64;
- }
- if (!stricmp(s, "CHANMODES")) {
- uplink_capab |= CAPAB_CHANMODE;
- if (tmp) {
+ if ((stricmp(s, "CHANMODES") == 0) && tmp)
ircd->chanmodes = sstrdup(tmp);
- }
- }
- if (!stricmp(s, "NICKCHARS")) {
- uplink_capab |= CAPAB_NICKCHARS;
- if (tmp) {
+ if ((stricmp(s, "NICKCHARS") == 0) && tmp)
ircd->nickchars = sstrdup(tmp);
- }
}
- if (s) {
+
+ if (s)
free(s);
- }
- if (tmp) {
+ if (tmp)
free(tmp);
- }
-
}
}