From a1ce9ba4b3c64a9f7daf82d88b40381afebd5222 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 3 Jul 2013 18:13:17 +0000 Subject: - White-space commit / style corrections git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2343 82007160-df01-0410-b94d-b575c5fd34c7 --- modules/m_cap.c | 58 ++++++++++++++++++++-------------------- modules/m_connect.c | 24 ++++++++++------- modules/m_rehash.c | 39 ++++++++++++++++++++++++++- modules/m_trace.c | 76 ++++++++++++++++++++++++++--------------------------- 4 files changed, 120 insertions(+), 77 deletions(-) (limited to 'modules') diff --git a/modules/m_cap.c b/modules/m_cap.c index 842c1c9..93e3698 100644 --- a/modules/m_cap.c +++ b/modules/m_cap.c @@ -57,13 +57,13 @@ static struct capabilities size_t namelen; } capab_list[] = { #define _CAP(cap, flags, name) \ - { (cap), (flags), (name), sizeof(name) - 1 } + { (cap), (flags), (name), sizeof(name) - 1 } _CAP(CAP_MULTI_PREFIX, 0, "multi-prefix"), _CAP(CAP_AWAY_NOTIFY, 0, "away-notify") #undef _CAP }; -#define CAPAB_LIST_LEN (sizeof(capab_list) / sizeof(struct capabilities)) +#define CAPAB_LIST_LEN (sizeof(capab_list) / sizeof(struct capabilities)) static int capab_sort(const struct capabilities *cap1, const struct capabilities *cap2) @@ -76,8 +76,8 @@ capab_search(const char *key, const struct capabilities *cap) { const char *rb = cap->name; - while (ToLower(*key) == ToLower(*rb)) /* walk equivalent part of strings */ - if (*key++ == '\0') /* hit the end, all right... */ + while (ToLower(*key) == ToLower(*rb)) /* walk equivalent part of strings */ + if (*key++ == '\0') /* hit the end, all right... */ return 0; else /* OK, let's move on... */ rb++; @@ -97,7 +97,7 @@ find_cap(const char **caplist_p, int *neg_p) const char *caplist = *caplist_p; struct capabilities *cap = NULL; - *neg_p = 0; /* clear negative flag... */ + *neg_p = 0; /* clear negative flag... */ if (!inited) { @@ -113,8 +113,8 @@ find_cap(const char **caplist_p, int *neg_p) /* We are now at the beginning of an element of the list; is it negative? */ if (*caplist == '-') { - ++caplist; /* yes; step past the flag... */ - *neg_p = 1; /* remember that it is negative... */ + ++caplist; /* yes; step past the flag... */ + *neg_p = 1; /* remember that it is negative... */ } /* OK, now see if we can look up the capability... */ @@ -126,13 +126,13 @@ find_cap(const char **caplist_p, int *neg_p) { /* Couldn't find the capability; advance to first whitespace character */ while (*caplist && !IsSpace(*caplist)) - ++caplist; + ++caplist; } else - caplist += cap->namelen; /* advance to end of capability name */ + caplist += cap->namelen; /* advance to end of capability name */ } - assert(caplist != *caplist_p || !*caplist); /* we *must* advance */ + assert(caplist != *caplist_p || !*caplist); /* we *must* advance */ /* move ahead in capability list string--or zero pointer if we hit end */ *caplist_p = *caplist ? caplist : 0; @@ -192,13 +192,13 @@ send_caplist(struct Client *source_p, unsigned int set, pfx[pfx_len] = '\0'; - len = capab_list[i].namelen + pfx_len; /* how much we'd add... */ + len = capab_list[i].namelen + pfx_len; /* how much we'd add... */ if (sizeof(capbuf) < (clen + loc + len + 15)) { /* would add too much; must flush */ sendto_one(source_p, "%s* :%s", cmdbuf, capbuf); - capbuf[(loc = 0)] = '\0'; /* re-terminate the buffer... */ + capbuf[(loc = 0)] = '\0'; /* re-terminate the buffer... */ } loc += snprintf(capbuf + loc, sizeof(capbuf) - loc, @@ -207,16 +207,16 @@ send_caplist(struct Client *source_p, unsigned int set, sendto_one(source_p, "%s:%s", cmdbuf, capbuf); - return 0; /* convenience return */ + return 0; /* convenience return */ } static int cap_ls(struct Client *source_p, const char *caplist) { - if (IsUnknown(source_p)) /* registration hasn't completed; suspend it... */ + if (IsUnknown(source_p)) /* registration hasn't completed; suspend it... */ source_p->localClient->registration |= REG_NEED_CAP; - return send_caplist(source_p, 0, 0, "LS"); /* send list of capabilities */ + return send_caplist(source_p, 0, 0, "LS"); /* send list of capabilities */ } static int @@ -229,16 +229,16 @@ cap_req(struct Client *source_p, const char *caplist) unsigned int as = source_p->localClient->cap_active; /* active set */ int neg = 0; - if (IsUnknown(source_p)) /* registration hasn't completed; suspend it... */ + if (IsUnknown(source_p)) /* registration hasn't completed; suspend it... */ source_p->localClient->registration |= REG_NEED_CAP; - while (cl) { /* walk through the capabilities list... */ + while (cl) { /* walk through the capabilities list... */ if (!(cap = find_cap(&cl, &neg)) /* look up capability... */ - || (!neg && (cap->flags & CAPFL_PROHIBIT)) /* is it prohibited? */ - || (neg && (cap->flags & CAPFL_STICKY))) { /* is it sticky? */ + || (!neg && (cap->flags & CAPFL_PROHIBIT)) /* is it prohibited? */ + || (neg && (cap->flags & CAPFL_STICKY))) { /* is it sticky? */ sendto_one(source_p, ":%s CAP %s NAK :%s", me.name, source_p->name[0] ? source_p->name : "*", caplist); - return 0; /* can't complete requested op... */ + return 0; /* can't complete requested op... */ } if (neg) @@ -286,12 +286,12 @@ cap_ack(struct Client *source_p, const char *caplist) while (cl) { /* walk through the capabilities list... */ - if (!(cap = find_cap(&cl, &neg)) || /* look up capability... */ - (neg ? (source_p->localClient->cap_active & cap->cap) : - !(source_p->localClient->cap_active & cap->cap))) /* uh... */ + if (!(cap = find_cap(&cl, &neg)) || /* look up capability... */ + (neg ? (source_p->localClient->cap_active & cap->cap) : + !(source_p->localClient->cap_active & cap->cap))) /* uh... */ continue; - if (neg) /* set or clear the active capability... */ + if (neg) /* set or clear the active capability... */ source_p->localClient->cap_active &= ~cap->cap; else source_p->localClient->cap_active |= cap->cap; @@ -328,8 +328,8 @@ cap_clear(struct Client *source_p, const char *caplist) static int cap_end(struct Client *source_p, const char *caplist) { - if (!IsUnknown(source_p)) /* registration has completed... */ - return 0; /* so just ignore the message... */ + if (!IsUnknown(source_p)) /* registration has completed... */ + return 0; /* so just ignore the message... */ /* capability negotiation is now done... */ source_p->localClient->registration &= ~REG_NEED_CAP; @@ -341,7 +341,7 @@ cap_end(struct Client *source_p, const char *caplist) return 0; } - return 0; /* Can't do registration yet... */ + return 0; /* Can't do registration yet... */ } static int @@ -383,12 +383,12 @@ m_cap(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) const char *subcmd = NULL, *caplist = NULL; struct subcmd *cmd = NULL; - if (EmptyString(parv[1])) /* a subcommand is required */ + if (EmptyString(parv[1])) /* a subcommand is required */ return; subcmd = parv[1]; - if (parc > 2) /* a capability list was provided */ + if (parc > 2) /* a capability list was provided */ caplist = parv[2]; /* find the subcommand handler */ diff --git a/modules/m_connect.c b/modules/m_connect.c index 775fb50..4f38fa7 100644 --- a/modules/m_connect.c +++ b/modules/m_connect.c @@ -88,7 +88,7 @@ mo_connect(struct Client *client_p, struct Client *source_p, if ((target_p = hash_find_server(parv[1]))) { sendto_one(source_p, - ":%s NOTICE %s :Connect: Server %s already exists from %s.", + ":%s NOTICE %s :Connect: Server %s already exists from %s.", me.name, source_p->name, parv[1], target_p->from->name); return; } @@ -107,7 +107,8 @@ mo_connect(struct Client *client_p, struct Client *source_p, } } - /* Get port number from user, if given. If not specified, + /* + * Get port number from user, if given. If not specified, * use the default form configuration structure. If missing * from there, then use the precompiled default. */ @@ -144,7 +145,8 @@ mo_connect(struct Client *client_p, struct Client *source_p, conf->port = port; - /* at this point we should be calling connect_server with a valid + /* + * at this point we should be calling connect_server with a valid * C:line and a valid port in the C:line */ if (serv_connect(conf, source_p)) @@ -163,7 +165,8 @@ mo_connect(struct Client *client_p, struct Client *source_p, me.name, source_p->name, conf->name, conf->port); } - /* client is either connecting with all the data it needs or has been + /* + * Client is either connecting with all the data it needs or has been * destroyed */ conf->port = tmpport; @@ -189,8 +192,8 @@ ms_connect(struct Client *client_p, struct Client *source_p, struct MaskItem *conf = NULL; const struct Client *target_p = NULL; - if (hunt_server(client_p, source_p, - ":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME) + if (hunt_server(client_p, source_p, ":%s CONNECT %s %s :%s", + 3, parc, parv) != HUNTED_ISME) return; if (EmptyString(parv[1])) @@ -203,7 +206,7 @@ ms_connect(struct Client *client_p, struct Client *source_p, if ((target_p = hash_find_server(parv[1]))) { sendto_one(source_p, - ":%s NOTICE %s :Connect: Server %s already exists from %s.", + ":%s NOTICE %s :Connect: Server %s already exists from %s.", me.name, source_p->name, parv[1], target_p->from->name); return; } @@ -222,7 +225,8 @@ ms_connect(struct Client *client_p, struct Client *source_p, } } - /* Get port number from user, if given. If not specified, + /* + * Get port number from user, if given. If not specified, * use the default form configuration structure. If missing * from there, then use the precompiled default. */ @@ -232,7 +236,9 @@ ms_connect(struct Client *client_p, struct Client *source_p, { port = atoi(parv[2]); - /* if someone sends port 0, and we have a config port.. use it */ + /* + * if someone sends port 0, and we have a config port.. use it + */ if (port == 0 && conf->port) port = conf->port; else if (port <= 0) diff --git a/modules/m_rehash.c b/modules/m_rehash.c index d039def..60da725 100644 --- a/modules/m_rehash.c +++ b/modules/m_rehash.c @@ -37,6 +37,19 @@ #include "motd.h" +struct RehashStruct +{ + const char *name; + void (*handler)(); +}; + +static const struct RehashStruct rehash_cmd_table[] = +{ + { "MOTD", rehash_motd }, + { "DNS", rehash_dns }, + { NULL, NULL } +}; + /* * mo_rehash - REHASH message handler * @@ -45,6 +58,7 @@ static void mo_rehash(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { + const struct RehashStruct *tab = rehash_cmd_table; int found = 0; if (!HasOFlag(source_p, OPER_FLAG_REHASH)) @@ -54,7 +68,30 @@ mo_rehash(struct Client *client_p, struct Client *source_p, return; } - if (!EmptyString(parv[1])) + if (EmptyString(parv[1])) + { + sendto_one(source_p, form_str(RPL_REHASHING), + me.name, source_p->name, ConfigFileEntry.configfile); + sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, + "%s is rehashing server config file", + get_oper_name(source_p)); + ilog(LOG_TYPE_IRCD, "REHASH From %s", get_oper_name(source_p)); + rehash(0); + return; + } + + for (; tab->handler; ++tab) + { + if (!irccmp(tab->name, parv[1])) + { + + + + + + + + { if (irccmp(parv[1], "DNS") == 0) { diff --git a/modules/m_trace.c b/modules/m_trace.c index 160b6ac..4b86162 100644 --- a/modules/m_trace.c +++ b/modules/m_trace.c @@ -206,7 +206,7 @@ do_actual_trace(struct Client *source_p, int parc, char *parv[]) { const char *name; target_p = hash_find_client(tname); - + if (target_p && IsClient(target_p)) { name = get_client_name(target_p, HIDE_IP); @@ -214,7 +214,7 @@ do_actual_trace(struct Client *source_p, int parc, char *parv[]) if (HasUMode(target_p, UMODE_OPER)) { sendto_one(source_p, form_str(RPL_TRACEOPERATOR), - from, to, get_client_class(&target_p->localClient->confs), name, + from, to, get_client_class(&target_p->localClient->confs), name, IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost, CurrentTime - target_p->localClient->lasttime, idle_time_get(source_p, target_p)); @@ -223,12 +223,12 @@ do_actual_trace(struct Client *source_p, int parc, char *parv[]) { sendto_one(source_p,form_str(RPL_TRACEUSER), from, to, get_client_class(&target_p->localClient->confs), name, - IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost, + IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost, CurrentTime - target_p->localClient->lasttime, idle_time_get(source_p, target_p)); } } - + sendto_one(source_p, form_str(RPL_ENDOFTRACE), from, to, tname); return; @@ -240,8 +240,8 @@ do_actual_trace(struct Client *source_p, int parc, char *parv[]) target_p = ptr->data; if (HasUMode(target_p, UMODE_INVISIBLE) && dow && - !(MyConnect(source_p) && HasUMode(source_p, UMODE_OPER)) && - !HasUMode(target_p, UMODE_OPER) && (target_p != source_p)) + !(MyConnect(source_p) && HasUMode(source_p, UMODE_OPER)) && + !HasUMode(target_p, UMODE_OPER) && (target_p != source_p)) continue; if (!doall && wilds && match(tname, target_p->name)) continue; @@ -322,12 +322,12 @@ report_this_status(struct Client *source_p, struct Client *target_p, int dow) { case STAT_CONNECTING: sendto_one(source_p, form_str(RPL_TRACECONNECTING), - from, to, class_name, - HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name); + from, to, class_name, + HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name); break; case STAT_HANDSHAKE: sendto_one(source_p, form_str(RPL_TRACEHANDSHAKE), - from, to, class_name, + from, to, class_name, HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name); break; case STAT_ME: @@ -335,8 +335,8 @@ report_this_status(struct Client *source_p, struct Client *target_p, int dow) case STAT_UNKNOWN: /* added time -Taner */ sendto_one(source_p, form_str(RPL_TRACEUNKNOWN), - from, to, class_name, name, target_p->sockhost, - target_p->localClient->firsttime ? /* TBD: can't be 0 */ + from, to, class_name, name, target_p->sockhost, + target_p->localClient->firsttime ? /* TBD: can't be 0 */ CurrentTime - target_p->localClient->firsttime : -1); break; case STAT_CLIENT: @@ -345,49 +345,49 @@ report_this_status(struct Client *source_p, struct Client *target_p, int dow) * but anyone can see all the opers. */ if ((HasUMode(source_p, UMODE_OPER) && - (MyClient(source_p) || !(dow && HasUMode(target_p, UMODE_INVISIBLE)))) - || !dow || HasUMode(target_p, UMODE_OPER)) - { + (MyClient(source_p) || !(dow && HasUMode(target_p, UMODE_INVISIBLE)))) + || !dow || HasUMode(target_p, UMODE_OPER)) + { if (HasUMode(target_p, UMODE_ADMIN) && !ConfigFileEntry.hide_spoof_ips) - sendto_one(source_p, form_str(RPL_TRACEOPERATOR), + sendto_one(source_p, form_str(RPL_TRACEOPERATOR), from, to, class_name, name, HasUMode(source_p, UMODE_ADMIN) ? target_p->sockhost : "255.255.255.255", CurrentTime - target_p->localClient->lasttime, idle_time_get(source_p, target_p)); - - else if (HasUMode(target_p, UMODE_OPER)) + + else if (HasUMode(target_p, UMODE_OPER)) { - if (ConfigFileEntry.hide_spoof_ips) - sendto_one(source_p, form_str(RPL_TRACEOPERATOR), - from, to, class_name, name, - IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost, - CurrentTime - target_p->localClient->lasttime, - idle_time_get(source_p, target_p)); - else + if (ConfigFileEntry.hide_spoof_ips) + sendto_one(source_p, form_str(RPL_TRACEOPERATOR), + from, to, class_name, name, + IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost, + CurrentTime - target_p->localClient->lasttime, + idle_time_get(source_p, target_p)); + else sendto_one(source_p, form_str(RPL_TRACEOPERATOR), from, to, class_name, name, MyOper(source_p) ? target_p->sockhost : (IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost), CurrentTime - target_p->localClient->lasttime, idle_time_get(source_p, target_p)); - } - else + } + else { if (ConfigFileEntry.hide_spoof_ips) - sendto_one(source_p, form_str(RPL_TRACEUSER), - from, to, class_name, name, + sendto_one(source_p, form_str(RPL_TRACEUSER), + from, to, class_name, name, IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost, - CurrentTime - target_p->localClient->lasttime, - idle_time_get(source_p, target_p)); - else + CurrentTime - target_p->localClient->lasttime, + idle_time_get(source_p, target_p)); + else sendto_one(source_p, form_str(RPL_TRACEUSER), from, to, class_name, name, MyOper(source_p) ? target_p->sockhost : (IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost), CurrentTime - target_p->localClient->lasttime, idle_time_get(source_p, target_p)); - } - } + } + } break; case STAT_SERVER: { @@ -400,14 +400,14 @@ report_this_status(struct Client *source_p, struct Client *target_p, int dow) name = get_client_name(target_p, MASK_IP); sendto_one(source_p, form_str(RPL_TRACESERVER), - from, to, class_name, servers, - clients, name, *(target_p->serv->by) ? - target_p->serv->by : "*", "*", - me.name, CurrentTime - target_p->localClient->lasttime); + from, to, class_name, servers, + clients, name, *(target_p->serv->by) ? + target_p->serv->by : "*", "*", + me.name, CurrentTime - target_p->localClient->lasttime); break; } - default: /* ...we actually shouldn't come here... --msa */ + default: /* ...we actually shouldn't come here... --msa */ sendto_one(source_p, form_str(RPL_TRACENEWTYPE), from, to, name); break; -- cgit