* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: ircd_loader.c,v 1.1 2002/01/04 09:15:07 a1kmm Exp $
+ * $Id: ircd_loader.c,v 1.2 2002/01/04 11:06:15 a1kmm Exp $
*/
#include "setup.h"
#include <stdio.h>
struct Channel *GlobalChannelList = NULL;
BlockHeap *channel_heap;
BlockHeap *ban_heap;
-struct Client *uplink=NULL;
+struct Client *uplink = NULL;
int MaxConnectionCount = 1;
-int MaxClientCount = 1;
+int MaxClientCount = 1;
int refresh_user_links = 0;
/*
* stats stuff
*/
-static struct ServerStatistics ircst;
-struct ServerStatistics* ServerStats = &ircst;
+static struct ServerStatistics ircst;
+struct ServerStatistics *ServerStats = &ircst;
int
main(int argc, char **argv)
{
#ifndef STATIC_MODULES
void *mod;
- int (*ircd_main)(int, char **);
- mod = dlopen(IRCD_PREFIX"/modules/main/ircd.so",
- RTLD_NOW | RTLD_GLOBAL);
+ int (*ircd_main) (int, char **);
+ mod = dlopen(IRCD_PREFIX "/modules/main/ircd.so", RTLD_NOW | RTLD_GLOBAL);
if (mod == NULL)
{
fprintf(stderr,
- "Could not load "IRCD_PREFIX
+ "Could not load " IRCD_PREFIX
"/modules/main/ircd.so: %s\n", dlerror());
exit(-1);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_die.c,v 1.1 2002/01/04 10:57:31 a1kmm Exp $
+ * $Id: m_die.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include "parse.h"
#include "modules.h"
-static void mo_die(struct Client*, struct Client*, int, char**);
+static void mo_die(struct Client *, struct Client *, int, char **);
struct Message die_msgtab = {
"DIE", 0, 0, 1, 0, MFLG_SLOW, 0,
mod_del_cmd(&die_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_die - DIE command handler
*/
-static void mo_die(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_die(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Client* target_p;
+ struct Client *target_p;
dlink_node *ptr;
if (!IsOperDie(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You need die = yes;", me.name, parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need die = yes;", me.name,
+ parv[0]);
+ return;
+ }
if (parc < 2)
- {
- sendto_one(source_p,":%s NOTICE %s :Need server name /die %s",
- me.name,source_p->name,me.name);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Need server name /die %s",
+ me.name, source_p->name, me.name);
+ return;
+ }
else
+ {
+ if (irccmp(parv[1], me.name))
{
- if (irccmp(parv[1], me.name))
- {
- sendto_one(source_p,":%s NOTICE %s :Mismatch on /die %s",
- me.name,source_p->name,me.name);
- return;
- }
+ sendto_one(source_p, ":%s NOTICE %s :Mismatch on /die %s",
+ me.name, source_p->name, me.name);
+ return;
}
+ }
- for(ptr = lclient_list.head; ptr; ptr = ptr->next)
- {
- target_p = ptr->data;
+ for (ptr = lclient_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
- sendto_one(target_p,
- ":%s NOTICE %s :Server Terminating. %s",
- me.name, target_p->name,
- get_client_name(source_p, HIDE_IP));
- }
+ sendto_one(target_p,
+ ":%s NOTICE %s :Server Terminating. %s",
+ me.name, target_p->name, get_client_name(source_p, HIDE_IP));
+ }
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
- {
- target_p = ptr->data;
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
- sendto_one(target_p, ":%s ERROR :Terminated by %s",
- me.name, get_client_name(source_p, HIDE_IP));
- }
+ sendto_one(target_p, ":%s ERROR :Terminated by %s",
+ me.name, get_client_name(source_p, HIDE_IP));
+ }
/*
* XXX we called flush_connections() here. Read server_reboot()
exit(0);
/* NOT REACHED */
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_kick.c,v 1.1 2002/01/04 10:57:31 a1kmm Exp $
+ * $Id: m_kick.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include <string.h>
-static void m_kick(struct Client*, struct Client*, int, char**);
-static void ms_kick(struct Client*, struct Client*, int, char**);
+static void m_kick(struct Client *, struct Client *, int, char **);
+static void ms_kick(struct Client *, struct Client *, int, char **);
struct Message kick_msgtab = {
"KICK", 0, 0, 3, 0, MFLG_SLOW, 0,
mod_del_cmd(&kick_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** m_kick
** parv[2] = client to kick
** parv[3] = kick comment
*/
-static void m_kick(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_kick(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Client *who;
struct Channel *chptr;
struct Channel *vchan;
- int chasing = 0;
- char *comment;
- char *name;
- char *p = (char *)NULL;
- char *user;
- static char buf[BUFSIZE];
+ int chasing = 0;
+ char *comment;
+ char *name;
+ char *p = (char *)NULL;
+ char *user;
+ static char buf[BUFSIZE];
if (*parv[2] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "KICK");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "KICK");
+ return;
+ }
comment = (BadPtr(parv[3])) ? parv[2] : parv[3];
if (strlen(comment) > (size_t) TOPICLEN)
comment[TOPICLEN] = '\0';
*buf = '\0';
- if( (p = strchr(parv[1],',')) )
+ if ((p = strchr(parv[1], ',')))
*p = '\0';
name = parv[1];
chptr = hash_find_channel(name);
if (!chptr)
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), me.name, parv[0], name);
+ return;
+ }
+
+ if (HasVchans(chptr))
+ {
+ vchan = map_vchan(chptr, source_p);
+ if (vchan != 0)
+ {
+ chptr = vchan;
+ }
+ }
+
+ if (!IsServer(source_p) && !is_any_op(chptr, source_p))
+ {
+ /* was a user, not a server, and user isn't seen as a chanop here */
+
+ if (MyConnect(source_p))
{
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ /* user on _my_ server, with no chanops.. so go away */
+
+ sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, parv[0], name);
return;
}
- if (HasVchans(chptr))
+ if (chptr->channelts == 0)
{
- vchan = map_vchan(chptr,source_p);
- if(vchan != 0)
- {
- chptr = vchan;
- }
- }
+ /* If its a TS 0 channel, do it the old way */
- if (!IsServer(source_p) && !is_any_op(chptr, source_p) )
- {
- /* was a user, not a server, and user isn't seen as a chanop here */
-
- if(MyConnect(source_p))
- {
- /* user on _my_ server, with no chanops.. so go away */
-
- sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
- me.name, parv[0], name);
- return;
- }
-
- if(chptr->channelts == 0)
- {
- /* If its a TS 0 channel, do it the old way */
-
- sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
- me.name, parv[0], name);
- return;
- }
-
- /* Its a user doing a kick, but is not showing as chanop locally
- * its also not a user ON -my- server, and the channel has a TS.
- * There are two cases we can get to this point then...
- *
- * 1) connect burst is happening, and for some reason a legit
- * op has sent a KICK, but the SJOIN hasn't happened yet or
- * been seen. (who knows.. due to lag...)
- *
- * 2) The channel is desynced. That can STILL happen with TS
- *
- * Now, the old code roger wrote, would allow the KICK to
- * go through. Thats quite legit, but lets weird things like
- * KICKS by users who appear not to be chanopped happen,
- * or even neater, they appear not to be on the channel.
- * This fits every definition of a desync, doesn't it? ;-)
- * So I will allow the KICK, otherwise, things are MUCH worse.
- * But I will warn it as a possible desync.
- *
- * -Dianora
- */
+ sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
+ me.name, parv[0], name);
+ return;
}
- if( (p = strchr(parv[2],',')) )
+ /* Its a user doing a kick, but is not showing as chanop locally
+ * its also not a user ON -my- server, and the channel has a TS.
+ * There are two cases we can get to this point then...
+ *
+ * 1) connect burst is happening, and for some reason a legit
+ * op has sent a KICK, but the SJOIN hasn't happened yet or
+ * been seen. (who knows.. due to lag...)
+ *
+ * 2) The channel is desynced. That can STILL happen with TS
+ *
+ * Now, the old code roger wrote, would allow the KICK to
+ * go through. Thats quite legit, but lets weird things like
+ * KICKS by users who appear not to be chanopped happen,
+ * or even neater, they appear not to be on the channel.
+ * This fits every definition of a desync, doesn't it? ;-)
+ * So I will allow the KICK, otherwise, things are MUCH worse.
+ * But I will warn it as a possible desync.
+ *
+ * -Dianora
+ */
+ }
+
+ if ((p = strchr(parv[2], ',')))
*p = '\0';
- user = parv[2]; /* strtoken(&p2, parv[2], ","); */
+ user = parv[2]; /* strtoken(&p2, parv[2], ","); */
if (!(who = find_chasing(source_p, user, &chasing)))
+ {
+ return;
+ }
+
+ if (IsMember(who, chptr))
+ {
+ /* half ops cannot kick full chanops */
+ if (is_half_op(chptr, source_p) && is_any_op(chptr, who))
{
+ sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
+ me.name, parv[0], name);
return;
}
-
- if (IsMember(who, chptr))
+ /* jdc
+ * - In the case of a server kicking a user (i.e. CLEARCHAN),
+ * the kick should show up as coming from the server which did
+ * the kick.
+ * - Personally, flame and I believe that server kicks shouldn't
+ * be sent anyways. Just waiting for some oper to abuse it...
+ */
+ if (IsServer(source_p))
+ {
+ sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
+ source_p->name, name, who->name, comment);
+ }
+ else if (chptr->mode.mode & MODE_HIDEOPS)
{
- /* half ops cannot kick full chanops */
- if (is_half_op(chptr,source_p) && is_any_op(chptr,who))
- {
- sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
- me.name, parv[0], name);
- return;
- }
- /* jdc
- * - In the case of a server kicking a user (i.e. CLEARCHAN),
- * the kick should show up as coming from the server which did
- * the kick.
- * - Personally, flame and I believe that server kicks shouldn't
- * be sent anyways. Just waiting for some oper to abuse it...
+ /* jdc -- Non-chanops get kicked from me.name, not
+ * who->name (themselves).
*/
- if (IsServer(source_p))
- {
- sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
- source_p->name, name, who->name, comment);
- }
- else if(chptr->mode.mode & MODE_HIDEOPS)
- {
- /* jdc -- Non-chanops get kicked from me.name, not
- * who->name (themselves).
- */
- sendto_channel_local(NON_CHANOPS, chptr,
- ":%s KICK %s %s :%s",
- me.name,
- name, who->name, comment);
-
- sendto_channel_local(ONLY_CHANOPS_HALFOPS, chptr,
- ":%s!%s@%s KICK %s %s :%s",
- source_p->name,
- source_p->username,
- source_p->host,
- name,
- who->name, comment);
- }
- else
- {
- sendto_channel_local(ALL_MEMBERS, chptr,
- ":%s!%s@%s KICK %s %s :%s",
- source_p->name,
- source_p->username,
- source_p->host,
- name, who->name, comment);
- }
-
- sendto_server(client_p, NULL, chptr, NOCAPS, NOCAPS, NOFLAGS,
- ":%s KICK %s %s :%s",
- parv[0], chptr->chname,
- who->name, comment);
- remove_user_from_channel(chptr, who, 0);
+ sendto_channel_local(NON_CHANOPS, chptr,
+ ":%s KICK %s %s :%s",
+ me.name, name, who->name, comment);
+
+ sendto_channel_local(ONLY_CHANOPS_HALFOPS, chptr,
+ ":%s!%s@%s KICK %s %s :%s",
+ source_p->name,
+ source_p->username,
+ source_p->host, name, who->name, comment);
+ }
+ else
+ {
+ sendto_channel_local(ALL_MEMBERS, chptr,
+ ":%s!%s@%s KICK %s %s :%s",
+ source_p->name,
+ source_p->username,
+ source_p->host, name, who->name, comment);
}
+
+ sendto_server(client_p, NULL, chptr, NOCAPS, NOCAPS, NOFLAGS,
+ ":%s KICK %s %s :%s",
+ parv[0], chptr->chname, who->name, comment);
+ remove_user_from_channel(chptr, who, 0);
+ }
else
sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
me.name, parv[0], user, name);
}
-static void ms_kick(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_kick(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
if (*parv[2] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "KICK");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "KICK");
+ return;
+ }
m_kick(client_p, source_p, parc, parv);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_kill.c,v 1.1 2002/01/04 10:57:31 a1kmm Exp $
+ * $Id: m_kill.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
-#include "hash.h" /* for find_client() */
+#include "hash.h" /* for find_client() */
#include "ircd.h"
#include "numeric.h"
#include "s_log.h"
static char buf[BUFSIZE];
-static void ms_kill(struct Client*, struct Client*, int, char**);
-static void mo_kill(struct Client*, struct Client*, int, char**);
+static void ms_kill(struct Client *, struct Client *, int, char **);
+static void mo_kill(struct Client *, struct Client *, int, char **);
static void relay_kill(struct Client *, struct Client *, struct Client *,
const char *, const char *);
mod_del_cmd(&kill_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** mo_kill
** parv[1] = kill victim
** parv[2] = kill path
*/
-static void mo_kill(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_kill(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Client* target_p;
- const char* inpath = client_p->name;
- char* user;
- char* reason;
+ struct Client *target_p;
+ const char *inpath = client_p->name;
+ char *user;
+ char *reason;
user = parv[1];
- reason = parv[2]; /* Either defined or NULL (parc >= 2!!) */
+ reason = parv[2]; /* Either defined or NULL (parc >= 2!!) */
if (!IsOperGlobalKill(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You need global_kill = yes;",me.name,parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need global_kill = yes;",
+ me.name, parv[0]);
+ return;
+ }
if (!BadPtr(reason))
- {
- if(strlen(reason) > (size_t) KILLLEN)
- reason[KILLLEN] = '\0';
- }
+ {
+ if (strlen(reason) > (size_t) KILLLEN)
+ reason[KILLLEN] = '\0';
+ }
else
reason = "<No reason given>";
if ((target_p = find_client(user)) == NULL)
+ {
+ /*
+ ** If the user has recently changed nick, automatically
+ ** rewrite the KILL for this new nickname--this keeps
+ ** servers in synch when nick change and kill collide
+ */
+ if ((target_p = get_history(user, (long)KILLCHASETIMELIMIT)) == NULL)
{
- /*
- ** If the user has recently changed nick, automatically
- ** rewrite the KILL for this new nickname--this keeps
- ** servers in synch when nick change and kill collide
- */
- if ((target_p = get_history(user, (long)KILLCHASETIMELIMIT)) == NULL)
- {
- sendto_one(source_p, form_str(ERR_NOSUCHNICK),
- me.name, parv[0], user);
- return;
- }
- sendto_one(source_p,":%s NOTICE %s :KILL changed from %s to %s",
- me.name, parv[0], user, target_p->name);
- }
- if (IsServer(target_p) || IsMe(target_p))
- {
- sendto_one(source_p, form_str(ERR_CANTKILLSERVER),
- me.name, parv[0]);
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], user);
return;
}
+ sendto_one(source_p, ":%s NOTICE %s :KILL changed from %s to %s",
+ me.name, parv[0], user, target_p->name);
+ }
+ if (IsServer(target_p) || IsMe(target_p))
+ {
+ sendto_one(source_p, form_str(ERR_CANTKILLSERVER), me.name, parv[0]);
+ return;
+ }
if (!MyConnect(target_p) && (!IsOperGlobalKill(source_p)))
- {
- sendto_one(source_p, ":%s NOTICE %s :Nick %s isnt on your server",
- me.name, parv[0], target_p->name);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Nick %s isnt on your server",
+ me.name, parv[0], target_p->name);
+ return;
+ }
#if 0
- ircsprintf(buf, "%s!%s (%s)",
- inpath, client_p->username, reason);
+ ircsprintf(buf, "%s!%s (%s)", inpath, client_p->username, reason);
#endif
- if(MyConnect(target_p))
+ if (MyConnect(target_p))
sendto_one(target_p, ":%s KILL %s :%s", parv[0], target_p->name, reason);
/* Do not change the format of this message. There's no point in changing messages
* that have been around for ever, for no reason.. */
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Received KILL message for %s. From %s Path: %s (%s)",
- target_p->name, parv[0], me.name, reason);
+ "Received KILL message for %s. From %s Path: %s (%s)",
+ target_p->name, parv[0], me.name, reason);
- ilog(L_INFO,"KILL From %s For %s Path %s (%s)",
+ ilog(L_INFO, "KILL From %s For %s Path %s (%s)",
parv[0], target_p->name, me.name, reason);
/*
- ** And pass on the message to other servers. Note, that if KILL
- ** was changed, the message has to be sent to all links, also
- ** back.
- ** Suicide kills are NOT passed on --SRB
- */
+ ** And pass on the message to other servers. Note, that if KILL
+ ** was changed, the message has to be sent to all links, also
+ ** back.
+ ** Suicide kills are NOT passed on --SRB
+ */
if (!MyConnect(target_p))
- {
- relay_kill(client_p, source_p, target_p, inpath, reason);
- /*
- ** Set FLAGS_KILLED. This prevents exit_one_client from sending
- ** the unnecessary QUIT for this. (This flag should never be
- ** set in any other place)
- */
- target_p->flags |= FLAGS_KILLED;
- }
+ {
+ relay_kill(client_p, source_p, target_p, inpath, reason);
+ /*
+ ** Set FLAGS_KILLED. This prevents exit_one_client from sending
+ ** the unnecessary QUIT for this. (This flag should never be
+ ** set in any other place)
+ */
+ target_p->flags |= FLAGS_KILLED;
+ }
exit_client(client_p, target_p, source_p, reason);
}
** parv[1] = kill victim
** parv[2] = kill path
*/
-static void ms_kill(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_kill(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Client* target_p;
- char* user;
- char* reason;
- int chasing = 0;
+ struct Client *target_p;
+ char *user;
+ char *reason;
+ int chasing = 0;
*buf = '\0';
if (*parv[1] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "KILL");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "KILL");
+ return;
+ }
user = parv[1];
split it up, or make the path ourselves using the info
we know.. (host/user/name).. for now we use the latter --fl */
- if(IsServer(source_p))
+ if (IsServer(source_p))
ircsprintf(buf, "%s", source_p->name);
else
ircsprintf(buf, "%s!%s!%s!%s", source_p->user->server, source_p->host,
source_p->username, source_p->name);
if ((target_p = find_client(user)) == NULL)
+ {
+ /*
+ * If the user has recently changed nick, but only if its
+ * not an uid, automatically rewrite the KILL for this new nickname.
+ * --this keeps servers in synch when nick change and kill collide
+ */
+ if ((*user == '.') ||
+ (!(target_p = get_history(user, (long)KILLCHASETIMELIMIT))))
{
- /*
- * If the user has recently changed nick, but only if its
- * not an uid, automatically rewrite the KILL for this new nickname.
- * --this keeps servers in synch when nick change and kill collide
- */
- if( (*user == '.') ||
- (!(target_p = get_history(user, (long)KILLCHASETIMELIMIT))))
- {
- sendto_one(source_p, form_str(ERR_NOSUCHNICK),
- me.name, parv[0], user);
- return;
- }
- sendto_one(source_p,":%s NOTICE %s :KILL changed from %s to %s",
- me.name, parv[0], user, target_p->name);
- chasing = 1;
- }
- if (IsServer(target_p) || IsMe(target_p))
- {
- sendto_one(source_p, form_str(ERR_CANTKILLSERVER),
- me.name, parv[0]);
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], user);
return;
}
+ sendto_one(source_p, ":%s NOTICE %s :KILL changed from %s to %s",
+ me.name, parv[0], user, target_p->name);
+ chasing = 1;
+ }
+ if (IsServer(target_p) || IsMe(target_p))
+ {
+ sendto_one(source_p, form_str(ERR_CANTKILLSERVER), me.name, parv[0]);
+ return;
+ }
#if 0
/* If we make the path ourselves, there can never BE a bogus path */
if (BadPtr(path))
- path = "*no-path*"; /* Bogus server sending??? */
+ path = "*no-path*"; /* Bogus server sending??? */
#endif
/*
- ** Notify all *local* opers about the KILL (this includes the one
- ** originating the kill, if from this server--the special numeric
- ** reply message is not generated anymore).
- **
- ** Note: "target_p->name" is used instead of "user" because we may
- ** have changed the target because of the nickname change.
- */
- if(BadPtr(parv[2]))
- reason = "<No reason given>";
+ ** Notify all *local* opers about the KILL (this includes the one
+ ** originating the kill, if from this server--the special numeric
+ ** reply message is not generated anymore).
+ **
+ ** Note: "target_p->name" is used instead of "user" because we may
+ ** have changed the target because of the nickname change.
+ */
+ if (BadPtr(parv[2]))
+ reason = "<No reason given>";
else
- {
- reason = strchr(parv[2], ' ');
- if(reason)
- reason++;
- else
- reason = parv[2];
- }
+ {
+ reason = strchr(parv[2], ' ');
+ if (reason)
+ reason++;
+ else
+ reason = parv[2];
+ }
/* dont send clients kills from a hidden server */
- if(MyConnect(target_p))
+ if (MyConnect(target_p))
{
- if(ConfigServerHide.hide_servers && IsServer(source_p) &&
- !IsOper(source_p))
+ if (ConfigServerHide.hide_servers && IsServer(source_p) &&
+ !IsOper(source_p))
sendto_one(target_p, ":%s KILL %s :%s",
me.name, target_p->name, reason);
else
- sendto_one(target_p, ":%s KILL %s :%s", parv[0], target_p->name, reason);
+ sendto_one(target_p, ":%s KILL %s :%s", parv[0], target_p->name,
+ reason);
}
/* Be warned, this message must be From %s, or it confuses clients
* so dont change it to From: or the case or anything! -- fl -- db */
- if (IsOper(source_p)) /* send it normally */
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Received KILL message for %s. From %s Path: %s %s",
- target_p->name, parv[0], source_p->user->server, reason);
- }
+ if (IsOper(source_p)) /* send it normally */
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Received KILL message for %s. From %s Path: %s %s",
+ target_p->name, parv[0], source_p->user->server,
+ reason);
+ }
else
- {
- sendto_realops_flags(FLAGS_SKILL, L_ALL,
- "Received KILL message for %s. From %s %s",
- target_p->name, parv[0], reason);
- }
+ {
+ sendto_realops_flags(FLAGS_SKILL, L_ALL,
+ "Received KILL message for %s. From %s %s",
+ target_p->name, parv[0], reason);
+ }
- ilog(L_INFO,"KILL From %s For %s Path %s %s",
+ ilog(L_INFO, "KILL From %s For %s Path %s %s",
parv[0], target_p->name, parv[0], reason);
/*
- ** And pass on the message to other servers. Note, that if KILL
- ** was changed, the message has to be sent to all links, also
- ** back.
- ** Suicide kills are NOT passed on --SRB
- */
+ ** And pass on the message to other servers. Note, that if KILL
+ ** was changed, the message has to be sent to all links, also
+ ** back.
+ ** Suicide kills are NOT passed on --SRB
+ */
if (!MyConnect(target_p) || !MyConnect(source_p) || !IsOper(source_p))
- {
- relay_kill(client_p, source_p, target_p, buf, reason);
-
- /*
- ** Set FLAGS_KILLED. This prevents exit_one_client from sending
- ** the unnecessary QUIT for this. (This flag should never be
- ** set in any other place)
- */
- target_p->flags |= FLAGS_KILLED;
- }
+ {
+ relay_kill(client_p, source_p, target_p, buf, reason);
+
+ /*
+ ** Set FLAGS_KILLED. This prevents exit_one_client from sending
+ ** the unnecessary QUIT for this. (This flag should never be
+ ** set in any other place)
+ */
+ target_p->flags |= FLAGS_KILLED;
+ }
- exit_client(client_p, target_p, source_p, reason );
+ exit_client(client_p, target_p, source_p, reason);
}
-static void relay_kill(struct Client *one, struct Client *source_p,
- struct Client *target_p,
- const char *inpath,
- const char *reason)
+static void
+relay_kill(struct Client *one, struct Client *source_p,
+ struct Client *target_p, const char *inpath, const char *reason)
{
dlink_node *ptr;
struct Client *client_p;
int introduce_killed_client;
- char* user;
-
+ char *user;
+
/* LazyLinks:
* Check if each lazylink knows about target_p.
* If it does, send the kill, introducing source_p if required.
* -davidt
*/
- if(IsServer(source_p))
+ if (IsServer(source_p))
introduce_killed_client = 0;
else
introduce_killed_client = 1;
- for( ptr = serv_list.head; ptr; ptr = ptr->next )
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
{
- client_p = (struct Client *) ptr->data;
-
- if( !client_p || client_p == one )
+ client_p = (struct Client *)ptr->data;
+
+ if (!client_p || client_p == one)
continue;
- if( !introduce_killed_client )
+ if (!introduce_killed_client)
{
- if( ServerInfo.hub && IsCapable(client_p, CAP_LL) )
+ if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
{
- if(((client_p->localClient->serverMask &
- target_p->lazyLinkClientExists) == 0))
+ if (((client_p->localClient->serverMask &
+ target_p->lazyLinkClientExists) == 0))
{
/* target isn't known to lazy leaf, skip it */
continue;
}
/* force introduction of killed client but check that
* its not on the server we're bursting too.. */
- else if(strcmp(target_p->user->server,client_p->name))
+ else if (strcmp(target_p->user->server, client_p->name))
client_burst_if_needed(client_p, target_p);
/* introduce source of kill */
else
user = target_p->name;
- if(MyClient(source_p))
- {
- sendto_one(client_p, ":%s KILL %s :%s!%s!%s!%s (%s)",
- source_p->name, user,
- me.name, source_p->host, source_p->username,
- source_p->name, reason);
- }
+ if (MyClient(source_p))
+ {
+ sendto_one(client_p, ":%s KILL %s :%s!%s!%s!%s (%s)",
+ source_p->name, user,
+ me.name, source_p->host, source_p->username,
+ source_p->name, reason);
+ }
else
- {
- sendto_one(client_p, ":%s KILL %s :%s %s",
- source_p->name, user,
- inpath, reason);
- }
+ {
+ sendto_one(client_p, ":%s KILL %s :%s %s",
+ source_p->name, user, inpath, reason);
+ }
}
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_mode.c,v 1.1 2002/01/04 10:57:32 a1kmm Exp $
+ * $Id: m_mode.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include "modules.h"
#include "packet.h"
-static void m_mode(struct Client*, struct Client*, int, char**);
+static void m_mode(struct Client *, struct Client *, int, char **);
struct Message mode_msgtab = {
"MODE", 0, 0, 2, 0, MFLG_SLOW, 0,
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_mode - MODE command handler
* parv[0] - sender
* parv[1] - channel
*/
-static void m_mode(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_mode(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Channel* chptr=NULL;
- struct Channel* vchan;
- struct Channel* root;
- static char modebuf[MODEBUFLEN];
- static char parabuf[MODEBUFLEN];
+ struct Channel *chptr = NULL;
+ struct Channel *vchan;
+ struct Channel *root;
+ static char modebuf[MODEBUFLEN];
+ static char parabuf[MODEBUFLEN];
int n = 2;
-
+
/* Now, try to find the channel in question */
if (!IsChanPrefix(parv[1][0]))
- {
- /* if here, it has to be a non-channel name */
- user_mode(client_p, source_p, parc, parv);
- return;
- }
+ {
+ /* if here, it has to be a non-channel name */
+ user_mode(client_p, source_p, parc, parv);
+ return;
+ }
/* Finish the flood grace period... */
SetFloodDone(source_p);
if (!check_channel_name(parv[1]))
- {
- sendto_one(source_p, form_str(ERR_BADCHANNAME),
- me.name, parv[0], (unsigned char *)parv[1]);
- return;
- }
-
+ {
+ sendto_one(source_p, form_str(ERR_BADCHANNAME),
+ me.name, parv[0], (unsigned char *)parv[1]);
+ return;
+ }
+
chptr = hash_find_channel(parv[1]);
if (chptr == NULL)
+ {
+ /* if chptr isn't found locally, it =could= exist
+ * on the uplink. So ask.
+ */
+
+ /* LazyLinks */
+ /* this was segfaulting if we had no servers linked.
+ * -pro
+ */
+ /* only send a mode upstream if a local client sent this request
+ * -davidt
+ */
+ if (MyClient(source_p) && !ServerInfo.hub && uplink &&
+ IsCapable(uplink, CAP_LL))
{
- /* if chptr isn't found locally, it =could= exist
- * on the uplink. So ask.
- */
-
- /* LazyLinks */
- /* this was segfaulting if we had no servers linked.
- * -pro
- */
- /* only send a mode upstream if a local client sent this request
- * -davidt
- */
- if (MyClient(source_p) && !ServerInfo.hub && uplink &&
- IsCapable(uplink, CAP_LL))
- {
#if 0
- /* cache the channel if it exists on uplink
- * If the channel as seen by the uplink, has vchans,
- * the uplink will have to SJOIN all of those.
- */
- /* Lets not for now -db */
-
- sendto_one(uplink, ":%s CBURST %s",
- me.name, parv[1]);
-
+ /* cache the channel if it exists on uplink
+ * If the channel as seen by the uplink, has vchans,
+ * the uplink will have to SJOIN all of those.
+ */
+ /* Lets not for now -db */
+
+ sendto_one(uplink, ":%s CBURST %s", me.name, parv[1]);
+
#endif
- sendto_one(uplink, ":%s MODE %s %s",
- source_p->name, parv[1], (parv[2] ? parv[2] : ""));
- return;
- }
- else
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, parv[0], parv[1]);
- return;
- }
+ sendto_one(uplink, ":%s MODE %s %s",
+ source_p->name, parv[1], (parv[2] ? parv[2] : ""));
+ return;
+ }
+ else
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, parv[0], parv[1]);
+ return;
}
-
+ }
+
/* Now known the channel exists */
root = chptr;
if ((parc > 2) && parv[2][0] == '!')
+ {
+ struct Client *target_p;
+ if (!(target_p = find_client(++parv[2])))
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), me.name,
+ parv[0], root->chname);
+ return;
+ }
+ if ((chptr = map_vchan(root, target_p)) == NULL)
{
- struct Client *target_p;
- if (!(target_p = find_client(++parv[2])))
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), me.name,
- parv[0], root->chname);
- return;
- }
- if ((chptr = map_vchan(root, target_p)) == NULL)
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), me.name,
- parv[0], root->chname);
- return;
- }
- n++;
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), me.name,
+ parv[0], root->chname);
+ return;
}
+ n++;
+ }
else
+ {
+ if (HasVchans(chptr))
{
- if (HasVchans(chptr))
- {
- if ((vchan = map_vchan(chptr,source_p)) != NULL)
- chptr = vchan; /* root = chptr, chptr = vchan */
-
- /* XXX - else? the user isn't on any vchan, so we
- * end up giving them the mode of the root
- * channel. MODE #vchan !nick ? (ugh)
- */
- }
- else if (IsVchan(chptr))
- {
- vchan = find_bchan(chptr);
- root = vchan; /* root = vchan, chptr = chptr */
-
- /* XXX - else? the user isn't on any vchan,
- * but they asked for MODE ##vchan_12345
- * we send MODE #vchan
- */
- }
- }
+ if ((vchan = map_vchan(chptr, source_p)) != NULL)
+ chptr = vchan; /* root = chptr, chptr = vchan */
- if (parc < n+1)
+ /* XXX - else? the user isn't on any vchan, so we
+ * end up giving them the mode of the root
+ * channel. MODE #vchan !nick ? (ugh)
+ */
+ }
+ else if (IsVchan(chptr))
{
- channel_modes(chptr, source_p, modebuf, parabuf);
- sendto_one(source_p, form_str(RPL_CHANNELMODEIS),
- me.name, parv[0], parv[1],
- modebuf, parabuf);
-
- /* Let opers see the "true" TS everyone else see's
- * the top root chan TS
+ vchan = find_bchan(chptr);
+ root = vchan; /* root = vchan, chptr = chptr */
+
+ /* XXX - else? the user isn't on any vchan,
+ * but they asked for MODE ##vchan_12345
+ * we send MODE #vchan
*/
- if (!IsOper(source_p))
- sendto_one(source_p, form_str(RPL_CREATIONTIME),
- me.name, parv[0],
- parv[1], root->channelts);
- else
- sendto_one(source_p, form_str(RPL_CREATIONTIME),
- me.name, parv[0],
- parv[1], chptr->channelts);
}
+ }
+
+ if (parc < n + 1)
+ {
+ channel_modes(chptr, source_p, modebuf, parabuf);
+ sendto_one(source_p, form_str(RPL_CHANNELMODEIS),
+ me.name, parv[0], parv[1], modebuf, parabuf);
+
+ /* Let opers see the "true" TS everyone else see's
+ * the top root chan TS
+ */
+ if (!IsOper(source_p))
+ sendto_one(source_p, form_str(RPL_CREATIONTIME),
+ me.name, parv[0], parv[1], root->channelts);
+ else
+ sendto_one(source_p, form_str(RPL_CREATIONTIME),
+ me.name, parv[0], parv[1], chptr->channelts);
+ }
else
- set_channel_mode(client_p, source_p, chptr, parc - n, parv + n,
+ set_channel_mode(client_p, source_p, chptr, parc - n, parv + n,
root->chname);
}
-
-
-
-
* modules/m_nick.c
* Copyright (C) 2001 Hybrid Development Team
*
- * $Id: m_nick.c,v 1.1 2002/01/04 10:57:32 a1kmm Exp $
+ * $Id: m_nick.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "handlers.h"
#include <string.h>
#include <assert.h>
-static void mr_nick(struct Client *, struct Client *, int, char**);
-static void m_nick(struct Client *, struct Client *, int, char**);
-static void ms_nick(struct Client *, struct Client *, int, char**);
+static void mr_nick(struct Client *, struct Client *, int, char **);
+static void m_nick(struct Client *, struct Client *, int, char **);
+static void ms_nick(struct Client *, struct Client *, int, char **);
-static void ms_client(struct Client *, struct Client *, int, char**);
+static void ms_client(struct Client *, struct Client *, int, char **);
static int nick_from_server(struct Client *, struct Client *, int, char **,
time_t, char *);
static int client_from_server(struct Client *, struct Client *, int, char **,
time_t, char *);
-static int check_clean_nick(struct Client *, struct Client *,
+static int check_clean_nick(struct Client *, struct Client *,
char *, char *, char *);
static int check_clean_user(struct Client *, char *, char *, char *);
static int check_clean_host(struct Client *, char *, char *, char *);
static int clean_host_name(char *);
static int perform_nick_collides(struct Client *, struct Client *,
- struct Client *, int, char **, time_t, char *);
-
+ struct Client *, int, char **, time_t,
+ char *);
+
struct Message nick_msgtab = {
"NICK", 0, 0, 1, 0, MFLG_SLOW, 0,
mod_del_cmd(&client_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* parv[0] = sender prefix
* parv[1] = nickname
*/
-static void mr_nick(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mr_nick(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Client *target_p, *uclient_p;
- char nick[NICKLEN + 2];
- char* s;
+ struct Client *target_p, *uclient_p;
+ char nick[NICKLEN + 2];
+ char *s;
dlink_node *ptr;
-
- if(parc < 2)
+
+ if (parc < 2)
{
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
me.name, BadPtr(parv[0]) ? "*" : parv[0]);
nick[NICKLEN] = '\0';
/* check the nickname is ok */
- if(!clean_nick_name(nick))
+ if (!clean_nick_name(nick))
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
me.name, BadPtr(parv[0]) ? "*" : parv[0], parv[1]);
}
/* check if the nick is resv'd */
- if(find_nick_resv(nick))
+ if (find_nick_resv(nick))
{
sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
me.name, BadPtr(parv[0]) ? "*" : parv[0], nick);
if (!(target_p = find_client(nick)))
{
- if(!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
{
/* We don't know anyone called nick, but our hub might */
- for(ptr = unknown_list.head; ptr; ptr = ptr->next)
+ for (ptr = unknown_list.head; ptr; ptr = ptr->next)
{
uclient_p = ptr->data;
- if(!strcmp(nick, uclient_p->llname))
- {
-
- /* We're already waiting for a reply about this nick
- * for someone else. */
+ if (!strcmp(nick, uclient_p->llname))
+ {
+
+ /* We're already waiting for a reply about this nick
+ * for someone else. */
- sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, "*", nick);
- return;
- }
+ sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, "*",
+ nick);
+ return;
+ }
}
/* Set their llname so we can find them later */
strcpy(source_p->llname, nick);
/* Ask the hub about their requested name */
- sendto_one(uplink, ":%s NBURST %s %s !%s", me.name, nick,
- nick, nick);
+ sendto_one(uplink, ":%s NBURST %s %s !%s", me.name, nick, nick, nick);
/* wait for LLNICK */
return;
return;
}
}
- else /* nickname is in use */
+ else /* nickname is in use */
{
sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, "*", nick);
}
* parv[0] = sender prefix
* parv[1] = nickname
*/
- static void m_nick(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_nick(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char nick[NICKLEN + 2];
- struct Client *target_p;
+ char nick[NICKLEN + 2];
+ struct Client *target_p;
- if(parc < 2)
+ if (parc < 2)
{
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, parv[0]);
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
return;
}
nick[NICKLEN] = '\0';
/* check the nickname is ok */
- if(!clean_nick_name(nick))
+ if (!clean_nick_name(nick))
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
me.name, parv[0], nick);
return;
}
- if(find_nick_resv(nick))
+ if (find_nick_resv(nick))
{
sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
me.name, parv[0], nick);
* equivalent nicknames ie: [nick] -> {nick}
*/
- if(target_p == source_p)
+ if (target_p == source_p)
{
/* check the nick isnt exactly the same */
- if(strcmp(target_p->name, nick))
+ if (strcmp(target_p->name, nick))
{
change_local_nick(client_p, source_p, nick);
- return;
+ return;
}
else
{
/* client is doing :old NICK old
- * ignore it..
- */
+ * ignore it..
+ */
return;
}
}
/* if the client that has the nick isnt registered yet (nick but no
* user) then drop the unregged client
*/
- if(IsUnknown(target_p))
+ if (IsUnknown(target_p))
{
/* the old code had an if(MyConnect(target_p)) here.. but I cant see
* how that can happen, m_nick() is local only --fl_
*/
-
+
exit_client(NULL, target_p, &me, "Overridden");
change_local_nick(client_p, source_p, nick);
return;
}
else
{
- if(!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
{
/* The uplink might know someone by this name already. */
sendto_one(uplink, ":%s NBURST %s %s %s", me.name, nick,
}
else
{
- change_local_nick(client_p,source_p,nick);
+ change_local_nick(client_p, source_p, nick);
return;
}
}
* parv[7] = server
* parv[8] = ircname
*/
-static void ms_nick(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_nick(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Client* target_p;
- char nick[NICKLEN + 2];
- time_t newts = 0;
+ struct Client *target_p;
+ char nick[NICKLEN + 2];
+ time_t newts = 0;
- if(parc < 2)
+ if (parc < 2)
{
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
return;
}
/* parc == 3 on nickchange, parc == 9 on new nick */
- if((parc != 3) && (parc != 9))
+ if ((parc != 3) && (parc != 9))
return;
/* fix the length of the nick */
strncpy_irc(nick, parv[1], NICKLEN);
nick[NICKLEN] = '\0';
- if(check_clean_nick(client_p, source_p, nick, parv[1], parv[7]))
+ if (check_clean_nick(client_p, source_p, nick, parv[1], parv[7]))
return;
if (parc == 9)
- {
- if (check_clean_user(client_p, nick, parv[5], parv[7]) ||
- check_clean_host(client_p, nick, parv[6], parv[7]))
- return;
-
- /* check the length of the clients gecos */
- if(strlen(parv[8]) > REALLEN)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL, "Long realname from server %s for %s",
- parv[7], parv[1]);
- parv[8][REALLEN] = '\0';
- }
+ {
+ if (check_clean_user(client_p, nick, parv[5], parv[7]) ||
+ check_clean_host(client_p, nick, parv[6], parv[7]))
+ return;
- if (IsServer(source_p))
- newts = atol(parv[3]);
- }
- else
+ /* check the length of the clients gecos */
+ if (strlen(parv[8]) > REALLEN)
{
- if (!IsServer(source_p))
- newts = atol(parv[2]);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Long realname from server %s for %s", parv[7],
+ parv[1]);
+ parv[8][REALLEN] = '\0';
}
+ if (IsServer(source_p))
+ newts = atol(parv[3]);
+ }
+ else
+ {
+ if (!IsServer(source_p))
+ newts = atol(parv[2]);
+ }
+
/* if the nick doesnt exist, allow it and process like normal */
if (!(target_p = find_client(nick)))
{
- nick_from_server(client_p,source_p,parc,parv,newts,nick);
+ nick_from_server(client_p, source_p, parc, parv, newts, nick);
return;
}
/* we're not living in the past anymore, an unknown client is local only. */
- if(IsUnknown(target_p))
+ if (IsUnknown(target_p))
{
exit_client(NULL, target_p, &me, "Overridden");
- nick_from_server(client_p,source_p,parc,parv,newts,nick);
+ nick_from_server(client_p, source_p, parc, parv, newts, nick);
return;
}
- if(target_p == source_p)
+ if (target_p == source_p)
{
- if(strcmp(target_p->name, nick))
+ if (strcmp(target_p->name, nick))
{
/* client changing case of nick */
- nick_from_server(client_p,source_p,parc,parv,newts,nick);
+ nick_from_server(client_p, source_p, parc, parv, newts, nick);
return;
}
else
perform_nick_collides(source_p, client_p, target_p,
parc, parv, newts, nick);
-
+
}
/*
* ms_client()
*/
-static void ms_client(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_client(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Client* target_p;
- char nick[NICKLEN + 2];
- time_t newts = 0;
- char *id;
- char *name;
+ struct Client *target_p;
+ char nick[NICKLEN + 2];
+ time_t newts = 0;
+ char *id;
+ char *name;
id = parv[8];
name = parv[9];
nick[NICKLEN] = '\0';
/* check the nicknames, usernames and hostnames are ok */
- if(check_clean_nick(client_p, source_p, nick, parv[1], parv[7]) ||
- check_clean_user(client_p, nick, parv[5], parv[7]) ||
- check_clean_host(client_p, nick, parv[6], parv[7]))
+ if (check_clean_nick(client_p, source_p, nick, parv[1], parv[7]) ||
+ check_clean_user(client_p, nick, parv[5], parv[7]) ||
+ check_clean_host(client_p, nick, parv[6], parv[7]))
return;
/* check length of clients gecos */
if (strlen(name) > REALLEN)
{
- sendto_realops_flags(FLAGS_ALL, L_ALL, "Long realname from server %s for %s",
- parv[0], parv[1]);
- name[REALLEN] = '\0';
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Long realname from server %s for %s", parv[0],
+ parv[1]);
+ name[REALLEN] = '\0';
}
newts = atol(parv[3]);
-
+
if (!(target_p = find_client(nick)))
{
- client_from_server(client_p,source_p,parc,parv,newts,nick);
+ client_from_server(client_p, source_p, parc, parv, newts, nick);
return;
}
- if(IsUnknown(target_p))
+ if (IsUnknown(target_p))
{
exit_client(NULL, target_p, &me, "Overridden");
- client_from_server(client_p,source_p,parc,parv,newts,nick);
+ client_from_server(client_p, source_p, parc, parv, newts, nick);
return;
}
perform_nick_collides(source_p, client_p, target_p,
parc, parv, newts, nick);
-}
+}
/*
* side effects - if nickname is erroneous, or a different length to
* truncated nickname, return 1
*/
-static int check_clean_nick(struct Client *client_p, struct Client *source_p,
- char *nick, char *newnick, char *server)
+static int
+check_clean_nick(struct Client *client_p, struct Client *source_p,
+ char *nick, char *newnick, char *server)
{
/* the old code did some wacky stuff here, if the nick is invalid, kill it
* and dont bother messing at all
*/
- if(!clean_nick_name(nick) || strcmp(nick, newnick))
+ if (!clean_nick_name(nick) || strcmp(nick, newnick))
{
ServerStats->is_kill++;
sendto_realops_flags(FLAGS_DEBUG, L_ALL,
me.name, newnick, me.name);
/* bad nick change */
- if(source_p != client_p)
+ if (source_p != client_p)
{
kill_client_ll_serv_butone(client_p, source_p,
- "%s (Bad Nickname)",
- me.name);
+ "%s (Bad Nickname)", me.name);
source_p->flags |= FLAGS_KILLED;
exit_client(client_p, source_p, &me, "Bad Nickname");
}
* output - none
* side effects - if username is erroneous, return 1
*/
-static int check_clean_user(struct Client *client_p, char *nick,
- char *user, char *server)
+static int
+check_clean_user(struct Client *client_p, char *nick,
+ char *user, char *server)
{
- if(strlen(user) > USERLEN)
+ if (strlen(user) > USERLEN)
{
ServerStats->is_kill++;
sendto_realops_flags(FLAGS_DEBUG, L_ALL,
"Long Username: %s Nickname: %s From: %s(via %s)",
- user, nick, server, client_p->name);
+ user, nick, server, client_p->name);
sendto_one(client_p, ":%s KILL %s :%s (Bad Username)",
me.name, nick, me.name);
-
+
return 1;
}
- if(!clean_user_name(user))
+ if (!clean_user_name(user))
sendto_realops_flags(FLAGS_DEBUG, L_ALL,
"Bad Username: %s Nickname: %s From: %s(via %s)",
- user, nick, server, client_p->name);
-
+ user, nick, server, client_p->name);
+
return 0;
}
* output - none
* side effects - if hostname is erroneous, return 1
*/
-static int check_clean_host(struct Client *client_p, char *nick,
- char *host, char *server)
+static int
+check_clean_host(struct Client *client_p, char *nick,
+ char *host, char *server)
{
- if(strlen(host) > HOSTLEN)
+ if (strlen(host) > HOSTLEN)
{
ServerStats->is_kill++;
sendto_realops_flags(FLAGS_DEBUG, L_ALL,
"Long Hostname: %s Nickname: %s From: %s(via %s)",
- host, nick, server, client_p->name);
+ host, nick, server, client_p->name);
sendto_one(client_p, ":%s KILL %s :%s (Bad Hostname)",
me.name, nick, me.name);
return 1;
}
- if(!clean_host_name(host))
+ if (!clean_host_name(host))
sendto_realops_flags(FLAGS_DEBUG, L_ALL,
"Bad Hostname: %s Nickname: %s From: %s(via %s)",
- host, nick, server, client_p->name);
+ host, nick, server, client_p->name);
return 0;
}
* output - none
* side effects - walks through the nickname, returning 0 if erroneous
*/
-static int clean_nick_name(char *nick)
+static int
+clean_nick_name(char *nick)
{
assert(nick);
if (*nick == '-' || IsDigit(*nick))
return 0;
- for(; *nick; nick++)
+ for (; *nick; nick++)
{
- if(!IsNickChar(*nick))
+ if (!IsNickChar(*nick))
return 0;
}
* output - none
* side effects - walks through the username, returning 0 if erroneous
*/
-static int clean_user_name(char *user)
+static int
+clean_user_name(char *user)
{
assert(user);
- for(; *user; user++)
+ for (; *user; user++)
{
- if(!IsUserChar(*user))
+ if (!IsUserChar(*user))
return 0;
}
* output - none
* side effects - walks through the hostname, returning 0 if erroneous
*/
-static int clean_host_name(char *host)
+static int
+clean_host_name(char *host)
{
assert(host);
- for(; *host; host++)
+ for (; *host; host++)
{
- if(!IsHostChar(*host))
+ if (!IsHostChar(*host))
return 0;
}
*/
static int
nick_from_server(struct Client *client_p, struct Client *source_p, int parc,
- char *parv[], time_t newts,char *nick)
+ char *parv[], time_t newts, char *nick)
{
- if(IsServer(source_p))
+ if (IsServer(source_p))
{
/* A server introducing a new client, change source */
source_p = make_client(client_p);
if (ConfigFileEntry.hub && IsCapable(client_p, CAP_LL))
add_lazylinkclient(client_p, source_p);
- if(parc > 2)
+ if (parc > 2)
source_p->hopcount = atoi(parv[2]);
- if(newts)
+ if (newts)
source_p->tsinfo = newts;
else
{
if (parc > 8)
{
- int flag;
- char *m;
-
- /* parse usermodes */
- m = &parv[4][1];
- while (*m)
- {
- flag = user_modes_from_c_to_bitmask[(unsigned char)*m];
- if(!(source_p->umodes & FLAGS_INVISIBLE) && (flag & FLAGS_INVISIBLE))
- Count.invisi++;
- if(!(source_p->umodes & FLAGS_OPER) && (flag & FLAGS_OPER))
- Count.oper++;
-
- source_p->umodes |= flag & SEND_UMODES;
- m++;
+ int flag;
+ char *m;
+
+ /* parse usermodes */
+ m = &parv[4][1];
+ while (*m)
+ {
+ flag = user_modes_from_c_to_bitmask[(unsigned char)*m];
+ if (!(source_p->umodes & FLAGS_INVISIBLE) && (flag & FLAGS_INVISIBLE))
+ Count.invisi++;
+ if (!(source_p->umodes & FLAGS_OPER) && (flag & FLAGS_OPER))
+ Count.oper++;
+
+ source_p->umodes |= flag & SEND_UMODES;
+ m++;
}
return do_remote_user(nick, client_p, source_p, parv[5], parv[6],
parv[7], parv[8], NULL);
}
}
- else if(source_p->name[0])
+ else if (source_p->name[0])
{
/* client changing their nick */
- if(irccmp(parv[0], nick))
+ if (irccmp(parv[0], nick))
source_p->tsinfo = newts ? newts : CurrentTime;
sendto_common_channels_local(source_p, ":%s!%s@%s NICK :%s",
- source_p->name,source_p->username,source_p->host,
- nick);
+ source_p->name, source_p->username,
+ source_p->host, nick);
if (source_p->user)
{
- add_history(source_p,1);
+ add_history(source_p, 1);
sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, NOFLAGS,
":%s NICK %s :%lu",
- parv[0], nick, (unsigned long) source_p->tsinfo);
+ parv[0], nick, (unsigned long)source_p->tsinfo);
}
}
/* set the new nick name */
- if(source_p->name[0])
+ if (source_p->name[0])
del_from_client_hash_table(source_p->name, source_p);
strcpy(source_p->name, nick);
*/
static int
client_from_server(struct Client *client_p, struct Client *source_p, int parc,
- char *parv[], time_t newts,char *nick)
+ char *parv[], time_t newts, char *nick)
{
char *name;
char *id;
while (*m)
{
flag = user_modes_from_c_to_bitmask[(unsigned char)*m];
- if(flag & FLAGS_INVISIBLE)
+ if (flag & FLAGS_INVISIBLE)
Count.invisi++;
- if(flag & FLAGS_OPER)
+ if (flag & FLAGS_OPER)
Count.oper++;
source_p->umodes |= flag & SEND_UMODES;
return do_remote_user(nick, client_p, source_p, parv[5], parv[6],
parv[7], name, id);
-}
-
-static int
-perform_nick_collides(struct Client *source_p, struct Client *client_p,
- struct Client *target_p, int parc, char *parv[],
- time_t newts, char *nick)
+}
+
+static int
+perform_nick_collides(struct Client *source_p, struct Client *client_p,
+ struct Client *target_p, int parc, char *parv[],
+ time_t newts, char *nick)
{
int sameuser;
-
+
/* server introducing new nick */
- if(IsServer(source_p))
+ if (IsServer(source_p))
{
/* if we dont have a ts, or their TS's are the same, kill both */
- if(!newts || !target_p->tsinfo ||
- (newts == target_p->tsinfo))
+ if (!newts || !target_p->tsinfo || (newts == target_p->tsinfo))
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
"Nick collision on %s(%s <- %s)(both killed)",
- target_p->name, target_p->from->name,
- client_p->name);
-
- if(ServerInfo.hub && IsCapable(client_p,CAP_LL))
+ target_p->name, target_p->from->name,
+ client_p->name);
+
+ if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
add_lazylinkclient(client_p, target_p);
kill_client_ll_serv_butone(NULL, target_p,
- "%s (Nick collision (new))",
- me.name);
+ "%s (Nick collision (new))", me.name);
ServerStats->is_kill++;
sendto_one(target_p, form_str(ERR_NICKCOLLISION),
me.name, target_p->name, target_p->name);
else
{
sameuser = (target_p->user) && !irccmp(target_p->username, parv[5])
- && !irccmp(target_p->host, parv[6]);
-
+ && !irccmp(target_p->host, parv[6]);
+
/* if the users are the same (loaded a client on a different server)
* and the new users ts is older, or the users are different and the
* new users ts is newer, ignore the new client and let it do the kill
*/
if ((sameuser && newts < target_p->tsinfo) ||
- (!sameuser && newts > target_p->tsinfo))
+ (!sameuser && newts > target_p->tsinfo))
{
client_burst_if_needed(client_p, target_p);
- return 0;
+ return 0;
}
else
{
- if(sameuser)
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Nick collision on %s(%s <- %s)(older killed)",
- target_p->name, target_p->from->name,
- client_p->name);
+ if (sameuser)
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Nick collision on %s(%s <- %s)(older killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
else
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Nick collision on %s(%s <- %s)(newer killed)",
- target_p->name, target_p->from->name,
- client_p->name);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Nick collision on %s(%s <- %s)(newer killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
ServerStats->is_kill++;
- sendto_one(target_p, form_str(ERR_NICKCOLLISION),
- me.name, target_p->name, target_p->name);
+ sendto_one(target_p, form_str(ERR_NICKCOLLISION),
+ me.name, target_p->name, target_p->name);
/* if it came from a LL server, itd have been source_p,
- * so we dont need to mark target_p as known
- */
- kill_client_ll_serv_butone(source_p, target_p,
- "%s (Nick collision (new))",
- me.name);
+ * so we dont need to mark target_p as known
+ */
+ kill_client_ll_serv_butone(source_p, target_p,
+ "%s (Nick collision (new))", me.name);
target_p->flags |= FLAGS_KILLED;
- (void)exit_client(client_p, target_p, &me, "Nick collision");
-
- if(parc == 9)
- nick_from_server(client_p,source_p,parc,parv,newts,nick);
- else if(parc == 10)
- client_from_server(client_p,source_p,parc,parv,newts,nick);
-
- return 0;
+ (void)exit_client(client_p, target_p, &me, "Nick collision");
+
+ if (parc == 9)
+ nick_from_server(client_p, source_p, parc, parv, newts, nick);
+ else if (parc == 10)
+ client_from_server(client_p, source_p, parc, parv, newts, nick);
+
+ return 0;
}
}
}
/* its a client changing nick and causing a collide */
- if(!newts || !target_p->tsinfo || (newts == target_p->tsinfo) ||
- !source_p->user)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Nick change collision from %s to %s(%s <- %s)(both killed)",
- source_p->name, target_p->name, target_p->from->name,
- client_p->name);
-
- ServerStats->is_kill++;
- sendto_one(target_p, form_str(ERR_NICKCOLLISION),
- me.name, target_p->name, target_p->name);
+ if (!newts || !target_p->tsinfo || (newts == target_p->tsinfo) ||
+ !source_p->user)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Nick change collision from %s to %s(%s <- %s)(both killed)",
+ source_p->name, target_p->name, target_p->from->name,
+ client_p->name);
+
+ ServerStats->is_kill++;
+ sendto_one(target_p, form_str(ERR_NICKCOLLISION),
+ me.name, target_p->name, target_p->name);
+
+ /* if we got the message from a LL, it knows about source_p */
+ kill_client_ll_serv_butone(NULL, source_p,
+ "%s (Nick change collision)", me.name);
- /* if we got the message from a LL, it knows about source_p */
- kill_client_ll_serv_butone(NULL, source_p,
- "%s (Nick change collision)",
- me.name);
+ ServerStats->is_kill++;
+ /* If we got the message from a LL, ensure it gets the kill */
+ if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
+ add_lazylinkclient(client_p, target_p);
+
+ kill_client_ll_serv_butone(NULL, target_p,
+ "%s (Nick change collision)", me.name);
+
+ target_p->flags |= FLAGS_KILLED;
+ exit_client(NULL, target_p, &me, "Nick collision(new)");
+ source_p->flags |= FLAGS_KILLED;
+ exit_client(client_p, source_p, &me, "Nick collision(old)");
+ return 0;
+ }
+ else
+ {
+ sameuser = !irccmp(target_p->username, source_p->username) &&
+ !irccmp(target_p->host, source_p->host);
+
+ if ((sameuser && newts < target_p->tsinfo) ||
+ (!sameuser && newts > target_p->tsinfo))
+ {
+ if (sameuser)
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Nick change collision from %s to %s(%s <- %s)(older killed)",
+ source_p->name, target_p->name,
+ target_p->from->name, client_p->name);
+ else
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Nick change collision from %s to %s(%s <- %s)(newer killed)",
+ source_p->name, target_p->name,
+ target_p->from->name, client_p->name);
ServerStats->is_kill++;
- /* If we got the message from a LL, ensure it gets the kill */
- if(ServerInfo.hub && IsCapable(client_p,CAP_LL))
- add_lazylinkclient(client_p, target_p);
- kill_client_ll_serv_butone(NULL, target_p,
- "%s (Nick change collision)",
- me.name);
+ /* this won't go back to the incoming link, so LL doesnt matter */
+ kill_client_ll_serv_butone(client_p, source_p,
+ "%s (Nick change collision)", me.name);
- target_p->flags |= FLAGS_KILLED;
- exit_client(NULL, target_p, &me, "Nick collision(new)");
source_p->flags |= FLAGS_KILLED;
- exit_client(client_p, source_p, &me, "Nick collision(old)");
+
+ if (sameuser)
+ exit_client(client_p, source_p, &me, "Nick collision(old)");
+ else
+ exit_client(client_p, source_p, &me, "Nick collision(new)");
return 0;
}
else
{
- sameuser = !irccmp(target_p->username, source_p->username) &&
- !irccmp(target_p->host, source_p->host);
+ if (sameuser)
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Nick collision on %s(%s <- %s)(older killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
+ else
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Nick collision on %s(%s <- %s)(newer killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
- if ((sameuser && newts < target_p->tsinfo) ||
- (!sameuser && newts > target_p->tsinfo))
- {
- if(sameuser)
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Nick change collision from %s to %s(%s <- %s)(older killed)",
- source_p->name, target_p->name, target_p->from->name,
- client_p->name);
- else
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Nick change collision from %s to %s(%s <- %s)(newer killed)",
- source_p->name, target_p->name, target_p->from->name,
- client_p->name);
+ kill_client_ll_serv_butone(source_p, target_p,
+ "%s (Nick collision)", me.name);
- ServerStats->is_kill++;
+ ServerStats->is_kill++;
+ sendto_one(target_p, form_str(ERR_NICKCOLLISION),
+ me.name, target_p->name, target_p->name);
- /* this won't go back to the incoming link, so LL doesnt matter */
- kill_client_ll_serv_butone(client_p, source_p,
- "%s (Nick change collision)",
- me.name);
-
- source_p->flags |= FLAGS_KILLED;
-
- if(sameuser)
- exit_client(client_p, source_p, &me, "Nick collision(old)");
- else
- exit_client(client_p, source_p, &me, "Nick collision(new)");
- return 0;
- }
- else
- {
- if(sameuser)
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Nick collision on %s(%s <- %s)(older killed)",
- target_p->name, target_p->from->name,
- client_p->name);
- else
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Nick collision on %s(%s <- %s)(newer killed)",
- target_p->name, target_p->from->name,
- client_p->name);
-
- kill_client_ll_serv_butone(source_p, target_p,
- "%s (Nick collision)",
- me.name);
-
- ServerStats->is_kill++;
- sendto_one(target_p, form_str(ERR_NICKCOLLISION),
- me.name, target_p->name, target_p->name);
-
- target_p->flags |= FLAGS_KILLED;
- (void)exit_client(client_p, target_p, &me, "Nick collision");
- }
- }
-
- /*
- if(HasID(source_p))
+ target_p->flags |= FLAGS_KILLED;
+ (void)exit_client(client_p, target_p, &me, "Nick collision");
+ }
+ }
+
+ /*
+ if(HasID(source_p))
client_from_server(client_p,source_p,parc,parv,newts,nick);
- else
+ else
+ */
+
+ /* we should only ever call nick_from_server() here, as
+ * this is a client changing nick, not a new client
*/
-
- /* we should only ever call nick_from_server() here, as
- * this is a client changing nick, not a new client
- */
- nick_from_server(client_p,source_p,parc,parv,newts,nick);
+ nick_from_server(client_p, source_p, parc, parv, newts, nick);
return 0;
}
-
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_part.c,v 1.1 2002/01/04 10:57:32 a1kmm Exp $
+ * $Id: m_part.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include "channel.h"
#include "vchannel.h"
#include "client.h"
-#include "common.h" /* bleah */
+#include "common.h" /* bleah */
#include "hash.h"
#include "irc_string.h"
#include "ircd.h"
#include <string.h>
#include <assert.h>
-static void m_part(struct Client*, struct Client*, int, char**);
+static void m_part(struct Client *, struct Client *, int, char **);
void check_spambot_warning(struct Client *source_p, const char *name);
struct Message part_msgtab = {
{
mod_del_cmd(&part_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
static void part_one_client(struct Client *client_p,
- struct Client *source_p,
- char *name, char *reason);
+ struct Client *source_p,
+ char *name, char *reason);
/*
** parv[1] = channel
** parv[2] = reason
*/
-static void m_part(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_part(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- char *p, *name;
- char reason[TOPICLEN+1];
+ char *p, *name;
+ char reason[TOPICLEN + 1];
if (*parv[1] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "PART");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "PART");
+ return;
+ }
reason[0] = '\0';
if (parc > 2)
strncpy_irc(reason, parv[2], TOPICLEN);
- name = strtoken( &p, parv[1], ",");
+ name = strtoken(&p, parv[1], ",");
/* Finish the flood grace period... */
SetFloodDone(source_p);
/* if its my client, and isn't an oper */
- while(name)
+ while (name)
{
part_one_client(client_p, source_p, name, reason);
name = strtoken(&p, (char *)NULL, ",");
* output - none
* side effects - remove ONE client given the channel name
*/
-static void part_one_client(struct Client *client_p,
- struct Client *source_p,
- char *name,
- char *reason)
+static void
+part_one_client(struct Client *client_p,
+ struct Client *source_p, char *name, char *reason)
{
struct Channel *chptr;
struct Channel *bchan;
if ((chptr = hash_find_channel(name)) == NULL)
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, source_p->name, name);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, source_p->name, name);
+ return;
+ }
if (IsVchan(chptr) || HasVchans(chptr))
+ {
+ if (HasVchans(chptr))
+ {
+ /* Set chptr to actual channel, bchan to the base channel */
+ bchan = chptr;
+ chptr = map_vchan(bchan, source_p);
+ }
+ else
{
- if(HasVchans(chptr))
- {
- /* Set chptr to actual channel, bchan to the base channel */
- bchan = chptr;
- chptr = map_vchan(bchan,source_p);
- }
- else
- {
- /* chptr = chptr; */
- bchan = find_bchan(chptr);
- }
+ /* chptr = chptr; */
+ bchan = find_bchan(chptr);
}
+ }
else
- bchan = chptr; /* not a vchan */
+ bchan = chptr; /* not a vchan */
if (!chptr || !bchan || !IsMember(source_p, chptr))
- {
- sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
- me.name, source_p->name, name);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
+ me.name, source_p->name, name);
+ return;
+ }
if (MyConnect(source_p) && !IsOper(source_p))
- check_spambot_warning(source_p, NULL);
+ check_spambot_warning(source_p, NULL);
/*
* Remove user from the old channel (if any)
* only allow /part reasons in -m chans
*/
- if(reason[0] && (is_any_op(chptr, source_p) || !MyConnect(source_p) ||
- ((can_send(chptr, source_p) > 0 &&
- (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
- < CurrentTime))))
- {
- sendto_server(client_p, NULL, chptr, CAP_UID, NOCAPS, NOFLAGS,
- ":%s PART %s :%s", ID(source_p), chptr->chname,
- reason);
- sendto_server(client_p, NULL, chptr, NOCAPS, CAP_UID, NOFLAGS,
- ":%s PART %s :%s", source_p->name, chptr->chname,
- reason);
- sendto_channel_local(ALL_MEMBERS,
- chptr, ":%s!%s@%s PART %s :%s",
- source_p->name,
- source_p->username,
- source_p->host,
- bchan->chname,
- reason);
- }
+ if (reason[0] && (is_any_op(chptr, source_p) || !MyConnect(source_p) ||
+ ((can_send(chptr, source_p) > 0 &&
+ (source_p->firsttime +
+ ConfigFileEntry.anti_spam_exit_message_time) <
+ CurrentTime))))
+ {
+ sendto_server(client_p, NULL, chptr, CAP_UID, NOCAPS, NOFLAGS,
+ ":%s PART %s :%s", ID(source_p), chptr->chname, reason);
+ sendto_server(client_p, NULL, chptr, NOCAPS, CAP_UID, NOFLAGS,
+ ":%s PART %s :%s", source_p->name, chptr->chname, reason);
+ sendto_channel_local(ALL_MEMBERS,
+ chptr, ":%s!%s@%s PART %s :%s",
+ source_p->name,
+ source_p->username,
+ source_p->host, bchan->chname, reason);
+ }
else
- {
- sendto_server(client_p, NULL, chptr, CAP_UID, NOCAPS, NOFLAGS,
- ":%s PART %s", ID(source_p), chptr->chname);
- sendto_server(client_p, NULL, chptr, NOCAPS, CAP_UID, NOFLAGS,
- ":%s PART %s", source_p->name, chptr->chname);
- sendto_channel_local(ALL_MEMBERS,
- chptr, ":%s!%s@%s PART %s",
- source_p->name,
- source_p->username,
- source_p->host,
- bchan->chname);
- }
+ {
+ sendto_server(client_p, NULL, chptr, CAP_UID, NOCAPS, NOFLAGS,
+ ":%s PART %s", ID(source_p), chptr->chname);
+ sendto_server(client_p, NULL, chptr, NOCAPS, CAP_UID, NOFLAGS,
+ ":%s PART %s", source_p->name, chptr->chname);
+ sendto_channel_local(ALL_MEMBERS,
+ chptr, ":%s!%s@%s PART %s",
+ source_p->name,
+ source_p->username, source_p->host, bchan->chname);
+ }
remove_user_from_channel(chptr, source_p, 0);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_quit.c,v 1.1 2002/01/04 10:57:32 a1kmm Exp $
+ * $Id: m_quit.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "modules.h"
#include "s_conf.h"
-static void m_quit(struct Client*, struct Client*, int, char**);
-static void ms_quit(struct Client*, struct Client*, int, char**);
+static void m_quit(struct Client *, struct Client *, int, char **);
+static void ms_quit(struct Client *, struct Client *, int, char **);
struct Message quit_msgtab = {
"QUIT", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
mod_del_cmd(&quit_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** m_quit
** parv[0] = sender prefix
** parv[1] = comment
*/
-static void m_quit(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_quit(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
char *comment = (parc > 1 && parv[1]) ? parv[1] : client_p->name;
- char reason [TOPICLEN + 1];
+ char reason[TOPICLEN + 1];
source_p->flags |= FLAGS_NORMALEX;
if (strlen(comment) > (size_t) TOPICLEN)
comment[TOPICLEN] = '\0';
if (ConfigFileEntry.client_exit && comment[0])
- {
+ {
#ifndef VMS
- snprintf(reason, TOPICLEN, "Client Exit: %s", comment);
+ snprintf(reason, TOPICLEN, "Client Exit: %s", comment);
#else
- sprintf(reason, "Client Exit: %s", comment);
+ sprintf(reason, "Client Exit: %s", comment);
#endif
- comment = reason;
- }
-
- if(!IsOper(source_p) &&
- (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
- > CurrentTime)
- {
- comment = "Client Quit";
- }
+ comment = reason;
+ }
+
+ if (!IsOper(source_p) &&
+ (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
+ > CurrentTime)
+ {
+ comment = "Client Quit";
+ }
exit_client(client_p, source_p, source_p, comment);
}
** parv[0] = sender prefix
** parv[1] = comment
*/
-static void ms_quit(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_quit(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
char *comment = (parc > 1 && parv[1]) ? parv[1] : client_p->name;
exit_client(client_p, source_p, source_p, comment);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_server.c,v 1.1 2002/01/04 10:57:32 a1kmm Exp $
+ * $Id: m_server.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "tools.h"
-#include "handlers.h" /* m_server prototype */
-#include "client.h" /* client struct */
-#include "common.h" /* TRUE bleah */
+#include "handlers.h" /* m_server prototype */
+#include "client.h" /* client struct */
+#include "common.h" /* TRUE bleah */
#include "event.h"
-#include "hash.h" /* add_to_client_hash_table */
-#include "irc_string.h" /* strncpy_irc */
-#include "ircd.h" /* me */
-#include "list.h" /* make_server */
-#include "numeric.h" /* ERR_xxx */
-#include "s_conf.h" /* struct ConfItem */
-#include "s_log.h" /* log level defines */
-#include "s_serv.h" /* server_estab, check_server, my_name_for_link */
-#include "s_stats.h" /* ServerStats */
-#include "scache.h" /* find_or_add */
-#include "send.h" /* sendto_one */
+#include "hash.h" /* add_to_client_hash_table */
+#include "irc_string.h" /* strncpy_irc */
+#include "ircd.h" /* me */
+#include "list.h" /* make_server */
+#include "numeric.h" /* ERR_xxx */
+#include "s_conf.h" /* struct ConfItem */
+#include "s_log.h" /* log level defines */
+#include "s_serv.h" /* server_estab, check_server, my_name_for_link */
+#include "s_stats.h" /* ServerStats */
+#include "scache.h" /* find_or_add */
+#include "send.h" /* sendto_one */
#include "motd.h"
#include "msg.h"
#include "parse.h"
#include <string.h>
#include <stdlib.h>
-static void mr_server(struct Client*, struct Client*, int, char **);
-static void ms_server(struct Client*, struct Client*, int, char **);
+static void mr_server(struct Client *, struct Client *, int, char **);
+static void ms_server(struct Client *, struct Client *, int, char **);
static int set_server_gecos(struct Client *, char *);
};
#ifndef STATIC_MODULES
-void
+void
_modinit(void)
{
mod_add_cmd(&server_msgtab);
{
mod_del_cmd(&server_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
int bogus_host(char *host);
* parv[2] = serverinfo/hopcount
* parv[3] = serverinfo
*/
-static void mr_server(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mr_server(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char info[REALLEN + 1];
- char *name;
- struct Client *target_p;
+ char info[REALLEN + 1];
+ char *name;
+ struct Client *target_p;
int hop;
if (parc < 4)
- {
- sendto_one(client_p,"ERROR :No servername");
- exit_client(client_p, client_p, client_p, "Wrong number of args");
- return;
- }
+ {
+ sendto_one(client_p, "ERROR :No servername");
+ exit_client(client_p, client_p, client_p, "Wrong number of args");
+ return;
+ }
name = parv[1];
hop = atoi(parv[2]);
* Reject a direct nonTS server connection if we're TS_ONLY -orabidoo
*/
if (!DoesTS(client_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,"Link %s dropped, non-TS server",
- get_client_name(client_p, HIDE_IP));
- sendto_realops_flags(FLAGS_ALL, L_OPER,"Link %s dropped, non-TS server",
- get_client_name(client_p, MASK_IP));
- exit_client(client_p, client_p, client_p, "Non-TS server");
- return;
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN, "Link %s dropped, non-TS server",
+ get_client_name(client_p, HIDE_IP));
+ sendto_realops_flags(FLAGS_ALL, L_OPER, "Link %s dropped, non-TS server",
+ get_client_name(client_p, MASK_IP));
+ exit_client(client_p, client_p, client_p, "Non-TS server");
+ return;
+ }
if (bogus_host(name))
{
if (ConfigFileEntry.warn_no_nline)
{
sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Unauthorized server connection attempt from %s: No entry for "
- "servername %s", get_client_name(client_p, HIDE_IP), name);
+ "Unauthorized server connection attempt from %s: No entry for "
+ "servername %s", get_client_name(client_p,
+ HIDE_IP), name);
sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Unauthorized server connection attempt from %s: No entry for "
- "servername %s", get_client_name(client_p, MASK_IP), name);
+ "Unauthorized server connection attempt from %s: No entry for "
+ "servername %s", get_client_name(client_p,
+ MASK_IP), name);
}
-
+
exit_client(client_p, client_p, client_p, "Invalid servername.");
return;
break;
-
+
case -2:
sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Unauthorized server connection attempt from %s: Bad password "
- "for server %s", get_client_name(client_p, HIDE_IP), name);
+ "Unauthorized server connection attempt from %s: Bad password "
+ "for server %s", get_client_name(client_p,
+ HIDE_IP), name);
sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Unauthorized server connection attempt from %s: Bad password "
- "for server %s", get_client_name(client_p, MASK_IP), name);
+ "Unauthorized server connection attempt from %s: Bad password "
+ "for server %s", get_client_name(client_p,
+ MASK_IP), name);
exit_client(client_p, client_p, client_p, "Invalid password.");
return;
break;
-
+
case -3:
sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Unauthorized server connection attempt from %s: Invalid host "
- "for server %s", get_client_name(client_p, HIDE_IP), name);
+ "Unauthorized server connection attempt from %s: Invalid host "
+ "for server %s", get_client_name(client_p,
+ HIDE_IP), name);
sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Unauthorized server connection attempt from %s: Invalid host "
- "for server %s", get_client_name(client_p, MASK_IP), name);
+ "Unauthorized server connection attempt from %s: Invalid host "
+ "for server %s", get_client_name(client_p,
+ MASK_IP), name);
exit_client(client_p, client_p, client_p, "Invalid host.");
return;
break;
}
-
- if ((target_p = server_exists(name)))
- {
- /*
- * This link is trying feed me a server that I already have
- * access through another path -- multiple paths not accepted
- * currently, kill this link immediately!!
- *
- * Rather than KILL the link which introduced it, KILL the
- * youngest of the two links. -avalon
- *
- * Definitely don't do that here. This is from an unregistered
- * connect - A1kmm.
- */
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Attempt to re-introduce server %s from %s", name,
- get_client_name(client_p, HIDE_IP));
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Attempt to re-introduce server %s from %s", name,
- get_client_name(client_p, MASK_IP));
+ if ((target_p = server_exists(name)))
+ {
+ /*
+ * This link is trying feed me a server that I already have
+ * access through another path -- multiple paths not accepted
+ * currently, kill this link immediately!!
+ *
+ * Rather than KILL the link which introduced it, KILL the
+ * youngest of the two links. -avalon
+ *
+ * Definitely don't do that here. This is from an unregistered
+ * connect - A1kmm.
+ */
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Attempt to re-introduce server %s from %s", name,
+ get_client_name(client_p, HIDE_IP));
+
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Attempt to re-introduce server %s from %s", name,
+ get_client_name(client_p, MASK_IP));
+
+ sendto_one(client_p, "ERROR :Server already exists.");
+ exit_client(client_p, client_p, client_p, "Server Exists");
+ return;
+ }
- sendto_one(client_p, "ERROR :Server already exists.");
- exit_client(client_p, client_p, client_p, "Server Exists");
- return;
+ if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
+ {
+ if (IsCapable(client_p, CAP_HUB))
+ {
+ ClearCap(client_p, CAP_LL);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** LazyLinks to a hub from a hub, thats a no-no.");
}
-
- if(ServerInfo.hub && IsCapable(client_p, CAP_LL))
+ else
{
- if(IsCapable(client_p, CAP_HUB))
- {
- ClearCap(client_p,CAP_LL);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** LazyLinks to a hub from a hub, thats a no-no.");
- }
- else
- {
- client_p->localClient->serverMask = nextFreeMask();
-
- if(!client_p->localClient->serverMask)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "serverMask is full!");
- /* try and negotiate a non LL connect */
- ClearCap(client_p,CAP_LL);
- }
- }
+ client_p->localClient->serverMask = nextFreeMask();
+
+ if (!client_p->localClient->serverMask)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "serverMask is full!");
+ /* try and negotiate a non LL connect */
+ ClearCap(client_p, CAP_LL);
+ }
}
+ }
else if (IsCapable(client_p, CAP_LL))
+ {
+ if (!IsCapable(client_p, CAP_HUB))
{
- if(!IsCapable(client_p, CAP_HUB))
- {
- ClearCap(client_p,CAP_LL);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** LazyLinks to a leaf from a leaf, thats a no-no.");
- }
+ ClearCap(client_p, CAP_LL);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** LazyLinks to a leaf from a leaf, thats a no-no.");
}
+ }
/*
* if we are connecting (Handshake), we already have the name from the
* parv[2] = serverinfo/hopcount
* parv[3] = serverinfo
*/
-static void ms_server(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_server(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char info[REALLEN + 1];
- /* same size as in s_misc.c */
- char* name;
- struct Client* target_p;
- struct Client* bclient_p;
- struct ConfItem* aconf;
- int hop;
- int hlined = 0;
- int llined = 0;
- dlink_node *ptr;
+ char info[REALLEN + 1];
+ /* same size as in s_misc.c */
+ char *name;
+ struct Client *target_p;
+ struct Client *bclient_p;
+ struct ConfItem *aconf;
+ int hop;
+ int hlined = 0;
+ int llined = 0;
+ dlink_node *ptr;
/* Just to be sure -A1kmm. */
if (!IsServer(source_p))
- return;
+ return;
if (parc < 4)
- {
- sendto_one(client_p,"ERROR :No servername");
- return;
- }
+ {
+ sendto_one(client_p, "ERROR :No servername");
+ return;
+ }
name = parv[1];
hop = atoi(parv[2]);
info[REALLEN] = '\0';
if ((target_p = server_exists(name)))
+ {
+ /*
+ * This link is trying feed me a server that I already have
+ * access through another path -- multiple paths not accepted
+ * currently, kill this link immediately!!
+ *
+ * Rather than KILL the link which introduced it, KILL the
+ * youngest of the two links. -avalon
+ *
+ * I think that we should exit the link itself, not the introducer,
+ * and we should always exit the most recently received(i.e. the
+ * one we are receiving this SERVER for. -A1kmm
+ *
+ * You *cant* do this, if you link somewhere, it bursts you a server
+ * that already exists, then sends you a client burst, you squit the
+ * server, but you keep getting the burst of clients on a server that
+ * doesnt exist, although ircd can handle it, its not a realistic
+ * solution.. --fl_
+ */
+ /* It is behind a host-masked server. Completely ignore the
+ * server message(don't propagate or we will delink from whoever
+ * we propagate to). -A1kmm */
+ if (irccmp(target_p->name, name) && target_p->from == client_p)
+ return;
+
+ if (client_p->firsttime > target_p->from->firsttime)
{
- /*
- * This link is trying feed me a server that I already have
- * access through another path -- multiple paths not accepted
- * currently, kill this link immediately!!
- *
- * Rather than KILL the link which introduced it, KILL the
- * youngest of the two links. -avalon
- *
- * I think that we should exit the link itself, not the introducer,
- * and we should always exit the most recently received(i.e. the
- * one we are receiving this SERVER for. -A1kmm
- *
- * You *cant* do this, if you link somewhere, it bursts you a server
- * that already exists, then sends you a client burst, you squit the
- * server, but you keep getting the burst of clients on a server that
- * doesnt exist, although ircd can handle it, its not a realistic
- * solution.. --fl_
- */
- /* It is behind a host-masked server. Completely ignore the
- * server message(don't propagate or we will delink from whoever
- * we propagate to). -A1kmm */
- if (irccmp(target_p->name, name) && target_p->from==client_p)
- return;
-
- if(client_p->firsttime > target_p->from->firsttime)
- {
- sendto_one(client_p, "ERROR :Server %s already exists", name);
-
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Link %s cancelled, server %s already exists",
- get_client_name(client_p, SHOW_IP), name);
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Link %s cancelled, server %s already exists",
- client_p->name, name);
-
- exit_client(client_p, client_p, &me, "Server Exists");
- return;
- }
- else
- {
- sendto_one(target_p->from, "ERROR :Server %s already exists", name);
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Link %s cancelled, server %s reintroduced by %s",
- get_client_name(target_p->from, SHOW_IP),
- name, client_p->name);
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Link %s cancelled, server %s reintroduced by %s",
- target_p->from->name, name, client_p->name);
+ sendto_one(client_p, "ERROR :Server %s already exists", name);
- exit_client(target_p->from, target_p->from, &me, "Server Exists");
- return;
- }
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Link %s cancelled, server %s already exists",
+ get_client_name(client_p, SHOW_IP), name);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Link %s cancelled, server %s already exists",
+ client_p->name, name);
+
+ exit_client(client_p, client_p, &me, "Server Exists");
+ return;
+ }
+ else
+ {
+ sendto_one(target_p->from, "ERROR :Server %s already exists", name);
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Link %s cancelled, server %s reintroduced by %s",
+ get_client_name(target_p->from, SHOW_IP),
+ name, client_p->name);
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Link %s cancelled, server %s reintroduced by %s",
+ target_p->from->name, name, client_p->name);
+
+ exit_client(target_p->from, target_p->from, &me, "Server Exists");
+ return;
+ }
}
-
+
/*
* User nicks never have '.' in them and server names
* must always have '.' in them.
*/
- if (strchr(name,'.') == NULL)
- {
- /*
- * Server trying to use the same name as a person. Would
- * cause a fair bit of confusion. Enough to make it hellish
- * for a while and servers to send stuff to the wrong place.
- */
- sendto_one(client_p,"ERROR :Nickname %s already exists!", name);
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Link %s cancelled: Server/nick collision on %s",
- /* inpath */ get_client_name(client_p, HIDE_IP), name);
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Link %s cancelled: Server/nick collision on %s",
- get_client_name(client_p, MASK_IP), name);
- exit_client(client_p, client_p, client_p, "Nick as Server");
- return;
- }
+ if (strchr(name, '.') == NULL)
+ {
+ /*
+ * Server trying to use the same name as a person. Would
+ * cause a fair bit of confusion. Enough to make it hellish
+ * for a while and servers to send stuff to the wrong place.
+ */
+ sendto_one(client_p, "ERROR :Nickname %s already exists!", name);
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Link %s cancelled: Server/nick collision on %s",
+ /* inpath */ get_client_name(client_p, HIDE_IP),
+ name);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Link %s cancelled: Server/nick collision on %s",
+ get_client_name(client_p, MASK_IP), name);
+ exit_client(client_p, client_p, client_p, "Nick as Server");
+ return;
+ }
/*
* Server is informing about a new server behind
* server links...
*/
if (parc == 1 || info[0] == '\0')
- {
- sendto_one(client_p, "ERROR :No server info specified for %s", name);
- return;
- }
+ {
+ sendto_one(client_p, "ERROR :No server info specified for %s", name);
+ return;
+ }
/*
* See if the newly found server is behind a guaranteed
*
*/
- for (aconf = ConfigItemList; aconf; aconf=aconf->next)
+ for (aconf = ConfigItemList; aconf; aconf = aconf->next)
+ {
+ if ((aconf->status & (CONF_LEAF | CONF_HUB)) == 0)
+ continue;
+
+ if (match(aconf->name, client_p->name))
{
- if ((aconf->status & (CONF_LEAF|CONF_HUB)) == 0)
- continue;
-
- if (match(aconf->name, client_p->name))
- {
- if (aconf->status == CONF_HUB)
- {
- if(match(aconf->host, name))
- hlined++;
- }
- else if (aconf->status == CONF_LEAF)
- {
- if(match(aconf->host, name))
- llined++;
- }
- }
+ if (aconf->status == CONF_HUB)
+ {
+ if (match(aconf->host, name))
+ hlined++;
+ }
+ else if (aconf->status == CONF_LEAF)
+ {
+ if (match(aconf->host, name))
+ llined++;
+ }
}
+ }
/* Ok, this way this works is
*
*
* connect {
* name = "irc.somehub.fi";
- * hub_mask="*";
- * leaf_mask="*.edu";
+ * hub_mask="*";
+ * leaf_mask="*.edu";
*...
* Would allow this server in finland to hub anything but
* .edu's
*/
/* Ok, check client_p can hub the new server, and make sure it's not a LL */
- if (!hlined || (IsCapable(client_p, CAP_LL) && !IsCapable(client_p, CAP_HUB)))
+ if (!hlined
+ || (IsCapable(client_p, CAP_LL) && !IsCapable(client_p, CAP_HUB)))
+ {
+ /* OOOPs nope can't HUB */
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN, "Non-Hub link %s introduced %s.",
+ get_client_name(client_p, HIDE_IP), name);
+
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Non-Hub link %s introduced %s.",
+ get_client_name(client_p, MASK_IP), name);
+ /* If it is new, we are probably misconfigured, so split the
+ * non-hub server introducing this. Otherwise, split the new
+ * server. -A1kmm. */
+ if ((CurrentTime - source_p->firsttime) < 20)
{
- /* OOOPs nope can't HUB */
- sendto_realops_flags(FLAGS_ALL, L_ADMIN, "Non-Hub link %s introduced %s.",
- get_client_name(client_p, HIDE_IP), name);
-
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Non-Hub link %s introduced %s.",
- get_client_name(client_p, MASK_IP), name);
- /* If it is new, we are probably misconfigured, so split the
- * non-hub server introducing this. Otherwise, split the new
- * server. -A1kmm. */
- if ((CurrentTime - source_p->firsttime) < 20)
- {
- exit_client(NULL, source_p, &me, "No matching hub_mask.");
- return;
- }
- else
- {
- sendto_one(source_p, ":%s SQUIT %s :Sorry, no matching hub_mask.",
- me.name, name);
- return;
- }
+ exit_client(NULL, source_p, &me, "No matching hub_mask.");
+ return;
+ }
+ else
+ {
+ sendto_one(source_p, ":%s SQUIT %s :Sorry, no matching hub_mask.",
+ me.name, name);
+ return;
}
+ }
/* Check for the new server being leafed behind this HUB */
if (llined)
+ {
+ /* OOOPs nope can't HUB this leaf */
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "link %s introduced leafed %s.",
+ get_client_name(client_p, HIDE_IP), name);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "link %s introduced leafed %s.",
+ get_client_name(client_p, MASK_IP), name);
+ /* If it is new, we are probably misconfigured, so split the
+ * non-hub server introducing this. Otherwise, split the new
+ * server. -A1kmm.
+ */
+ if ((CurrentTime - source_p->firsttime) < 20)
{
- /* OOOPs nope can't HUB this leaf */
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "link %s introduced leafed %s.",
- get_client_name(client_p, HIDE_IP), name);
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "link %s introduced leafed %s.",
- get_client_name(client_p, MASK_IP), name);
- /* If it is new, we are probably misconfigured, so split the
- * non-hub server introducing this. Otherwise, split the new
- * server. -A1kmm.
- */
- if ((CurrentTime - source_p->firsttime) < 20)
- {
- exit_client(NULL, source_p, &me, "Leafed Server.");
- return;
- }
- else
- {
- sendto_one(source_p, ":%s SQUIT %s :Sorry, Leafed server.",
- me.name, name);
- return;
- }
+ exit_client(NULL, source_p, &me, "Leafed Server.");
+ return;
+ }
+ else
+ {
+ sendto_one(source_p, ":%s SQUIT %s :Sorry, Leafed server.",
+ me.name, name);
+ return;
}
+ }
target_p = make_client(client_p);
make_server(target_p);
* (domain name matching)
*/
for (ptr = serv_list.head; ptr; ptr = ptr->next)
+ {
+ bclient_p = ptr->data;
+
+ if (bclient_p == client_p)
+ continue;
+ if (!(aconf = bclient_p->serv->sconf))
{
- bclient_p = ptr->data;
-
- if (bclient_p == client_p)
- continue;
- if (!(aconf = bclient_p->serv->sconf))
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Lost N-line for %s on %s. Closing",
- get_client_name(client_p, HIDE_IP), name);
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Lost N-line for %s on %s. Closing",
- get_client_name(client_p, MASK_IP), name);
- exit_client(client_p, client_p, client_p, "Lost N line");
- return;
- }
- if (match(my_name_for_link(me.name, aconf), target_p->name))
- continue;
-
- sendto_one(bclient_p, ":%s SERVER %s %d :%s%s",
- parv[0], target_p->name, hop + 1,
- target_p->hidden_server ? "(H) " : "",
- target_p->info);
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Lost N-line for %s on %s. Closing",
+ get_client_name(client_p, HIDE_IP), name);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Lost N-line for %s on %s. Closing",
+ get_client_name(client_p, MASK_IP), name);
+ exit_client(client_p, client_p, client_p, "Lost N line");
+ return;
}
-
+ if (match(my_name_for_link(me.name, aconf), target_p->name))
+ continue;
+
+ sendto_one(bclient_p, ":%s SERVER %s %d :%s%s",
+ parv[0], target_p->name, hop + 1,
+ target_p->hidden_server ? "(H) " : "", target_p->info);
+ }
+
sendto_realops_flags(FLAGS_EXTERNAL, L_ALL,
"Server %s being introduced by %s",
- target_p->name, source_p->name);
+ target_p->name, source_p->name);
}
* output - none
* side effects - servers gecos field is set
*/
-int set_server_gecos(struct Client *client_p, char *info)
+int
+set_server_gecos(struct Client *client_p, char *info)
{
/* check the info for [IP] */
- if(info[0])
+ if (info[0])
{
char *p;
char *s;
char *t;
-
+
s = info;
-
+
/* we should only check the first word for an ip */
- if((p = strchr(s, ' ')))
+ if ((p = strchr(s, ' ')))
*p = '\0';
-
+
/* check for a ] which would symbolise an [IP] */
- if((t = strchr(s, ']')))
+ if ((t = strchr(s, ']')))
{
/* set s to after the first space */
- if(p)
+ if (p)
s = ++p;
else
s = NULL;
}
/* no ], put the space back */
- else if(p)
+ else if (p)
*p = ' ';
/* p may have been set to a trailing space, so check s exists and that
* it isnt \0 */
- if(s && (*s != '\0'))
+ if (s && (*s != '\0'))
{
/* a space? if not (H) could be the last part of info.. */
- if((p = strchr(s, ' ')))
+ if ((p = strchr(s, ' ')))
*p = '\0';
-
+
/* check for (H) which is a hidden server */
- if(!strcmp(s, "(H)"))
+ if (!strcmp(s, "(H)"))
{
client_p->hidden_server = 1;
/* if there was no space.. theres nothing to set info to */
- if(p)
- s = ++p;
- else
- s = NULL;
+ if (p)
+ s = ++p;
+ else
+ s = NULL;
}
- else if(p)
+ else if (p)
*p = ' ';
-
+
/* if there was a trailing space, s could point to \0, so check */
- if(s && (*s != '\0'))
+ if (s && (*s != '\0'))
strncpy_irc(client_p->info, s, REALLEN);
else
strncpy_irc(client_p->info, "(Unknown Location)", REALLEN);
* output - 1 if a bogus hostname input, 0 if its valid
* side effects - none
*/
-int bogus_host(char *host)
+int
+bogus_host(char *host)
{
int bogus_server = 0;
char *s;
int dots = 0;
- for( s = host; *s; s++ )
+ for (s = host; *s; s++)
+ {
+ if (!IsServChar(*s))
{
- if (!IsServChar(*s))
- {
- bogus_server = 1;
- break;
- }
- if ('.' == *s)
- ++dots;
+ bogus_server = 1;
+ break;
}
+ if ('.' == *s)
+ ++dots;
+ }
- if (!dots || bogus_server )
+ if (!dots || bogus_server)
return 1;
return 0;
* inputs - servername
* output - 1 if server exists, 0 if doesnt exist
*/
-struct Client *server_exists(char *servername)
+struct Client *
+server_exists(char *servername)
{
struct Client *target_p;
dlink_node *ptr;
- for(ptr = global_serv_list.head; ptr; ptr = ptr->next)
+ for (ptr = global_serv_list.head; ptr; ptr = ptr->next)
{
target_p = ptr->data;
- if(match(target_p->name, servername) ||
- match(servername, target_p->name))
+ if (match(target_p->name, servername) ||
+ match(servername, target_p->name))
return target_p;
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_sjoin.c,v 1.1 2002/01/04 10:57:32 a1kmm Exp $
+ * $Id: m_sjoin.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include <string.h>
#include <assert.h>
-static void ms_sjoin(struct Client*, struct Client*, int, char**);
+static void ms_sjoin(struct Client *, struct Client *, int, char **);
struct Message sjoin_msgtab = {
"SJOIN", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&sjoin_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* ms_sjoin
* all the specified users while sending JOIN/MODEs to local clients
*/
-static char modebuf[MODEBUFLEN];
-static char parabuf[MODEBUFLEN];
-static char *para[MAXMODEPARAMS];
-static char *mbuf;
-static int pargs;
+static char modebuf[MODEBUFLEN];
+static char parabuf[MODEBUFLEN];
+static char *para[MAXMODEPARAMS];
+static char *mbuf;
+static int pargs;
-static void set_final_mode(struct Mode *mode,struct Mode *oldmode);
+static void set_final_mode(struct Mode *mode, struct Mode *oldmode);
static void remove_our_modes(int type,
- struct Channel *chptr, struct Channel *top_chptr,
- struct Client *source_p);
+ struct Channel *chptr, struct Channel *top_chptr,
+ struct Client *source_p);
static void remove_a_mode(int hide_or_not,
struct Channel *chptr, struct Channel *top_chptr,
- struct Client *source_p, dlink_list *list, char flag);
+ struct Client *source_p, dlink_list * list,
+ char flag);
-static void ms_sjoin(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_sjoin(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Channel *chptr;
- struct Channel *top_chptr=NULL; /* XXX vchans */
- struct Client *target_p, *lclient_p;
- time_t newts;
- time_t oldts;
- time_t tstosend;
- static struct Mode mode, *oldmode;
- int args = 0;
- int keep_our_modes = 1;
- int keep_new_modes = 1;
- int doesop = 0;
- int fl;
- int people = 0;
- int num_prefix=0;
- int vc_ts = 0;
- int isnew;
- int buflen = 0;
- register char *s, *hops, *nhops;
- static char buf[2*BUFSIZE]; /* buffer for modes and prefix */
- static char sjbuf_hops[BUFSIZE]; /* buffer with halfops as % */
- static char sjbuf_nhops[BUFSIZE]; /* buffer with halfops as @ */
- char *p; /* pointer used making sjbuf */
+ struct Channel *top_chptr = NULL; /* XXX vchans */
+ struct Client *target_p, *lclient_p;
+ time_t newts;
+ time_t oldts;
+ time_t tstosend;
+ static struct Mode mode, *oldmode;
+ int args = 0;
+ int keep_our_modes = 1;
+ int keep_new_modes = 1;
+ int doesop = 0;
+ int fl;
+ int people = 0;
+ int num_prefix = 0;
+ int vc_ts = 0;
+ int isnew;
+ int buflen = 0;
+ register char *s, *hops, *nhops;
+ static char buf[2 * BUFSIZE]; /* buffer for modes and prefix */
+ static char sjbuf_hops[BUFSIZE]; /* buffer with halfops as % */
+ static char sjbuf_nhops[BUFSIZE]; /* buffer with halfops as @ */
+ char *p; /* pointer used making sjbuf */
int hide_or_not;
int i;
dlink_node *m;
if (IsClient(source_p) || parc < 5)
return;
-
+
if (!IsChannelName(parv[2]))
return;
if (!check_channel_name(parv[2]))
mode.key[0] = '\0';;
s = parv[3];
while (*s)
- switch(*(s++))
- {
+ switch (*(s++))
+ {
case 'i':
mode.mode |= MODE_INVITEONLY;
break;
case 'k':
strncpy_irc(mode.key, parv[4 + args], KEYLEN);
args++;
- if (parc < 5+args)
+ if (parc < 5 + args)
return;
break;
case 'l':
- mode.limit = atoi(parv[4+args]);
+ mode.limit = atoi(parv[4 + args]);
args++;
- if (parc < 5+args)
+ if (parc < 5 + args)
return;
break;
- }
+ }
*parabuf = '\0';
if ((chptr = get_or_create_channel(source_p, parv[2], &isnew)) == NULL)
- return; /* channel name too long? */
+ return; /* channel name too long? */
/* XXX vchan cruft */
/* vchans are encoded as "##mainchanname_timestamp" */
- if ( (parv[2][1] == '#') && (ConfigChannel.use_vchans) )
+ if ((parv[2][1] == '#') && (ConfigChannel.use_vchans))
+ {
+ char *subp;
+
+ /* possible sub vchan being sent along ? */
+ if ((subp = strrchr(parv[2], '_')))
{
- char *subp;
-
- /* possible sub vchan being sent along ? */
- if ((subp = strrchr(parv[2],'_')))
- {
- vc_ts = atol(subp+1);
- /*
- * XXX - Could be a vchan, but we can't be _sure_
- *
- * We now test the timestamp matches below,
- * but that can still be faked.
- *
- * If there was some way to pass an extra bit of
- * information over non-hybrid-7 servers, through SJOIN,
- * we could tell other servers that it's a vchan.
- * That's probably not possible, unfortunately :(
- */
-
- *subp = '\0'; /* fugly hack for now ... */
-
- /* + 1 skip the extra '#' in the name */
- if ((top_chptr = hash_find_channel(parv[2] + 1)) != NULL)
- {
- /* If the vchan is already in the vchan_list for this
- * root, don't re-add it.
- */
- /* Compare timestamps too */
- if (dlinkFind(&top_chptr->vchan_list,chptr) == NULL &&
- newts == vc_ts)
- {
- m = make_dlink_node();
- dlinkAdd(chptr, m, &top_chptr->vchan_list);
- chptr->root_chptr=top_chptr;
- }
- }
- /* check TS before creating a root channel */
- else if (newts == vc_ts)
- {
- top_chptr = get_or_create_channel(source_p, (parv[2] + 1), NULL);
- m = make_dlink_node();
- dlinkAdd(chptr, m, &top_chptr->vchan_list);
- chptr->root_chptr=top_chptr;
- /* let users access it somehow... */
- chptr->vchan_id[0] = '!';
- chptr->vchan_id[1] = '\0';
- }
-
- *subp = '_'; /* fugly hack, restore '_' */
- }
+ vc_ts = atol(subp + 1);
+ /*
+ * XXX - Could be a vchan, but we can't be _sure_
+ *
+ * We now test the timestamp matches below,
+ * but that can still be faked.
+ *
+ * If there was some way to pass an extra bit of
+ * information over non-hybrid-7 servers, through SJOIN,
+ * we could tell other servers that it's a vchan.
+ * That's probably not possible, unfortunately :(
+ */
+
+ *subp = '\0'; /* fugly hack for now ... */
+
+ /* + 1 skip the extra '#' in the name */
+ if ((top_chptr = hash_find_channel(parv[2] + 1)) != NULL)
+ {
+ /* If the vchan is already in the vchan_list for this
+ * root, don't re-add it.
+ */
+ /* Compare timestamps too */
+ if (dlinkFind(&top_chptr->vchan_list, chptr) == NULL &&
+ newts == vc_ts)
+ {
+ m = make_dlink_node();
+ dlinkAdd(chptr, m, &top_chptr->vchan_list);
+ chptr->root_chptr = top_chptr;
+ }
+ }
+ /* check TS before creating a root channel */
+ else if (newts == vc_ts)
+ {
+ top_chptr = get_or_create_channel(source_p, (parv[2] + 1), NULL);
+ m = make_dlink_node();
+ dlinkAdd(chptr, m, &top_chptr->vchan_list);
+ chptr->root_chptr = top_chptr;
+ /* let users access it somehow... */
+ chptr->vchan_id[0] = '!';
+ chptr->vchan_id[1] = '\0';
+ }
+
+ *subp = '_'; /* fugly hack, restore '_' */
}
+ }
oldts = chptr->channelts;
- doesop = (parv[4+args][0] == '@' || parv[4+args][1] == '@');
+ doesop = (parv[4 + args][0] == '@' || parv[4 + args][1] == '@');
oldmode = &chptr->mode;
#ifdef IGNORE_BOGUS_TS
if (newts < 800000000)
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ALL,
- "*** Bogus TS %lu on %s ignored from %s",
- (unsigned long) newts,
- chptr->chname,
- client_p->name);
+ {
+ sendto_realops_flags(FLAGS_DEBUG, L_ALL,
+ "*** Bogus TS %lu on %s ignored from %s",
+ (unsigned long)newts, chptr->chname, client_p->name);
- newts = (oldts==0) ? oldts : 800000000;
- }
+ newts = (oldts == 0) ? oldts : 800000000;
+ }
#endif
/*
chptr->channelts = tstosend = newts;
/* Remote is sending users to a permanent channel.. we need to drop our
* version and use theirs, to keep compatibility -- fl */
- else if (chptr->users == 0 && parv[4+args][0])
- {
- keep_our_modes = NO;
- chptr->channelts = tstosend = newts;
- }
+ else if (chptr->users == 0 && parv[4 + args][0])
+ {
+ keep_our_modes = NO;
+ chptr->channelts = tstosend = newts;
+ }
/* They're not sending users, lets just ignore it and carry on */
- else if (chptr->users == 0 && !parv[4+args][0])
+ else if (chptr->users == 0 && !parv[4 + args][0])
return;
/* It isnt a perm channel, do normal timestamp rules */
else if (newts == oldts)
tstosend = oldts;
else if (newts < oldts)
- {
- keep_our_modes = NO;
- chptr->channelts = tstosend = newts;
- }
+ {
+ keep_our_modes = NO;
+ chptr->channelts = tstosend = newts;
+ }
else
- {
- keep_new_modes = NO;
- tstosend = oldts;
- }
+ {
+ keep_new_modes = NO;
+ tstosend = oldts;
+ }
if (!keep_new_modes)
mode = *oldmode;
else if (keep_our_modes)
- {
- mode.mode |= oldmode->mode;
- if (oldmode->limit > mode.limit)
- mode.limit = oldmode->limit;
- if (strcmp(mode.key, oldmode->key) < 0)
- strcpy(mode.key, oldmode->key);
- }
+ {
+ mode.mode |= oldmode->mode;
+ if (oldmode->limit > mode.limit)
+ mode.limit = oldmode->limit;
+ if (strcmp(mode.key, oldmode->key) < 0)
+ strcpy(mode.key, oldmode->key);
+ }
if (mode.mode & MODE_HIDEOPS)
hide_or_not = ONLY_CHANOPS_HALFOPS;
if (!(MODE_HIDEOPS & mode.mode) && (MODE_HIDEOPS & oldmode->mode))
sync_channel_oplists(chptr, MODE_ADD);
- set_final_mode(&mode,oldmode);
+ set_final_mode(&mode, oldmode);
chptr->mode = mode;
/* Lost the TS, other side wins, so remove modes on this side */
if (!keep_our_modes)
- {
- remove_our_modes(hide_or_not, chptr, top_chptr, source_p);
- }
- if(!keep_our_modes)
- chptr->ts_winner = NO;
+ {
+ remove_our_modes(hide_or_not, chptr, top_chptr, source_p);
+ }
+ if (!keep_our_modes)
+ chptr->ts_winner = NO;
else
- chptr->ts_winner = YES;
-
+ chptr->ts_winner = YES;
+
if (*modebuf != '\0')
- {
- /* This _SHOULD_ be to ALL_MEMBERS
- * It contains only +aimnstlki, etc */
- if (top_chptr != NULL)
- sendto_channel_local(ALL_MEMBERS,
- chptr, ":%s MODE %s %s %s",
- me.name,
- top_chptr->chname, modebuf, parabuf);
- else
- sendto_channel_local(ALL_MEMBERS,
- chptr, ":%s MODE %s %s %s",
- me.name,
- chptr->chname, modebuf, parabuf);
- }
+ {
+ /* This _SHOULD_ be to ALL_MEMBERS
+ * It contains only +aimnstlki, etc */
+ if (top_chptr != NULL)
+ sendto_channel_local(ALL_MEMBERS,
+ chptr, ":%s MODE %s %s %s",
+ me.name, top_chptr->chname, modebuf, parabuf);
+ else
+ sendto_channel_local(ALL_MEMBERS,
+ chptr, ":%s MODE %s %s %s",
+ me.name, chptr->chname, modebuf, parabuf);
+ }
*modebuf = *parabuf = '\0';
if (parv[3][0] != '0' && keep_new_modes)
- {
- channel_modes(chptr, source_p, modebuf, parabuf);
- }
+ {
+ channel_modes(chptr, source_p, modebuf, parabuf);
+ }
else
- {
- modebuf[0] = '0';
- modebuf[1] = '\0';
- }
+ {
+ modebuf[0] = '0';
+ modebuf[1] = '\0';
+ }
buflen = ircsprintf(buf, ":%s SJOIN %lu %s %s %s :",
- parv[0],
- (unsigned long) tstosend,
- parv[2], modebuf, parabuf);
+ parv[0],
+ (unsigned long)tstosend, parv[2], modebuf, parabuf);
/* check we can fit a nick on the end, as well as \r\n\0 and a prefix "
* @+".
*/
if (buflen >= (BUFSIZE - 6 - NICKLEN))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Long SJOIN from server: %s(via %s) (ignored)",
- source_p->name, client_p->name);
- return;
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Long SJOIN from server: %s(via %s) (ignored)",
+ source_p->name, client_p->name);
+ return;
+ }
mbuf = modebuf;
para[0] = para[1] = para[2] = para[3] = "";
hops = sjbuf_hops;
nhops = sjbuf_nhops;
- s = parv[args+4];
+ s = parv[args + 4];
/* remove any leading spaces */
- while(*s == ' ')
+ while (*s == ' ')
{
s++;
}
-
+
/* if theres a space, theres going to be more than one nick, change the
* first space to \0, so s is just the first nick, and point p to the
* second nick
}
while (s)
+ {
+ fl = 0;
+ num_prefix = 0;
+
+ for (i = 0; i < 2; i++)
{
- fl = 0;
- num_prefix = 0;
-
- for (i = 0; i < 2; i++)
- {
- if (*s == '@')
- {
- fl |= MODE_CHANOP;
- if (keep_new_modes)
- {
- *hops++ = *s;
- *nhops++ = *s;
- num_prefix++;
- }
-
- s++;
- }
- else if (*s == '+')
- {
- fl |= MODE_VOICE;
- if (keep_new_modes)
- {
- *hops++ = *s;
- *nhops++ = *s;
- num_prefix++;
- }
-
- s++;
- }
- else if (*s == '%')
- {
- fl |= MODE_HALFOP;
- if (keep_new_modes)
- {
- *hops++ = *s;
- *nhops++ = '@';
- num_prefix++;
- }
-
- s++;
- }
- }
-
- /* if the client doesnt exist, backtrack over the prefix (@%+) that we
- * just added and skip to the next nick
- */
- if (!(target_p = find_client(s)))
+ if (*s == '@')
{
- sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name,
- source_p->name, s);
+ fl |= MODE_CHANOP;
+ if (keep_new_modes)
+ {
+ *hops++ = *s;
+ *nhops++ = *s;
+ num_prefix++;
+ }
- hops -= num_prefix;
- *hops = '\0';
+ s++;
+ }
+ else if (*s == '+')
+ {
+ fl |= MODE_VOICE;
+ if (keep_new_modes)
+ {
+ *hops++ = *s;
+ *nhops++ = *s;
+ num_prefix++;
+ }
- nhops -= num_prefix;
- *nhops = '\0';
+ s++;
+ }
+ else if (*s == '%')
+ {
+ fl |= MODE_HALFOP;
+ if (keep_new_modes)
+ {
+ *hops++ = *s;
+ *nhops++ = '@';
+ num_prefix++;
+ }
- goto nextnick;
+ s++;
}
+ }
- target_p = NULL;
-
- /* copy the nick to the two buffers */
- hops += ircsprintf(hops, "%s ", s);
- nhops += ircsprintf(nhops, "%s ", s);
- assert((hops-sjbuf_hops) < sizeof(sjbuf_hops) &&
- (nhops-sjbuf_nhops) < sizeof(sjbuf_nhops));
-
- if (!keep_new_modes)
- {
- if (fl & MODE_CHANOP)
- {
- fl = MODE_DEOPPED;
- }
- else
- {
- fl = 0;
- }
- }
-
- if (!(target_p = find_chasing(source_p, s, NULL)))
- goto nextnick;
- if (target_p->from != client_p)
- goto nextnick;
- if (!IsPerson(target_p))
- goto nextnick;
-
- people++;
-
- /* LazyLinks - Introduce unknown clients before sending the sjoin */
- if (ServerInfo.hub)
- {
- for (m = serv_list.head; m; m = m->next)
- {
- lclient_p = m->data;
-
- /* Hopefully, the server knows about it's own clients. */
- if (client_p == lclient_p)
- continue;
-
- /* Ignore non lazylinks */
- if (!IsCapable(lclient_p,CAP_LL))
- continue;
-
- /* Ignore servers we won't tell anyway */
- if (!(RootChan(chptr)->lazyLinkChannelExists &
- lclient_p->localClient->serverMask) )
- continue;
-
- /* Ignore servers that already know target_p */
- if (!(target_p->lazyLinkClientExists &
- lclient_p->localClient->serverMask) )
- {
- /* Tell LazyLink Leaf about client_p,
- * as the leaf is about to get a SJOIN */
- sendnick_TS( lclient_p, target_p );
- add_lazylinkclient(lclient_p,target_p);
- }
- }
- }
-
- if (!IsMember(target_p, chptr))
- {
- add_user_to_channel(chptr, target_p, fl);
- /* XXX vchan stuff */
-
- if (top_chptr)
- {
- add_vchan_to_client_cache(target_p,top_chptr, chptr);
- sendto_channel_local(ALL_MEMBERS,chptr, ":%s!%s@%s JOIN :%s",
- target_p->name,
- target_p->username,
- target_p->host,
- top_chptr->chname);
- }
- else
- {
- sendto_channel_local(ALL_MEMBERS,chptr, ":%s!%s@%s JOIN :%s",
- target_p->name,
- target_p->username,
- target_p->host,
- parv[2]);
- }
- }
+ /* if the client doesnt exist, backtrack over the prefix (@%+) that we
+ * just added and skip to the next nick
+ */
+ if (!(target_p = find_client(s)))
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name,
+ source_p->name, s);
+
+ hops -= num_prefix;
+ *hops = '\0';
+
+ nhops -= num_prefix;
+ *nhops = '\0';
+
+ goto nextnick;
+ }
+
+ target_p = NULL;
+ /* copy the nick to the two buffers */
+ hops += ircsprintf(hops, "%s ", s);
+ nhops += ircsprintf(nhops, "%s ", s);
+ assert((hops - sjbuf_hops) < sizeof(sjbuf_hops) &&
+ (nhops - sjbuf_nhops) < sizeof(sjbuf_nhops));
+
+ if (!keep_new_modes)
+ {
if (fl & MODE_CHANOP)
- {
- *mbuf++ = 'o';
- para[pargs++] = s;
- }
- else if (fl & MODE_VOICE)
- {
- *mbuf++ = 'v';
- para[pargs++] = s;
- }
- else if (fl & MODE_HALFOP)
- {
- *mbuf++ = 'h';
- para[pargs++] = s;
- }
+ {
+ fl = MODE_DEOPPED;
+ }
+ else
+ {
+ fl = 0;
+ }
+ }
+
+ if (!(target_p = find_chasing(source_p, s, NULL)))
+ goto nextnick;
+ if (target_p->from != client_p)
+ goto nextnick;
+ if (!IsPerson(target_p))
+ goto nextnick;
+
+ people++;
+
+ /* LazyLinks - Introduce unknown clients before sending the sjoin */
+ if (ServerInfo.hub)
+ {
+ for (m = serv_list.head; m; m = m->next)
+ {
+ lclient_p = m->data;
- if (pargs >= MAXMODEPARAMS)
+ /* Hopefully, the server knows about it's own clients. */
+ if (client_p == lclient_p)
+ continue;
+
+ /* Ignore non lazylinks */
+ if (!IsCapable(lclient_p, CAP_LL))
+ continue;
+
+ /* Ignore servers we won't tell anyway */
+ if (!(RootChan(chptr)->lazyLinkChannelExists &
+ lclient_p->localClient->serverMask))
+ continue;
+
+ /* Ignore servers that already know target_p */
+ if (!(target_p->lazyLinkClientExists &
+ lclient_p->localClient->serverMask))
{
- *mbuf = '\0';
- sendto_channel_local(hide_or_not, chptr,
- ":%s MODE %s %s %s %s %s %s",
- me.name,
- RootChan(chptr)->chname,
- modebuf,
- para[0],para[1],para[2],para[3]);
- mbuf = modebuf;
- *mbuf++ = '+';
- para[0] = para[1] = para[2] = para[3] = "";
- pargs = 0;
+ /* Tell LazyLink Leaf about client_p,
+ * as the leaf is about to get a SJOIN */
+ sendnick_TS(lclient_p, target_p);
+ add_lazylinkclient(lclient_p, target_p);
}
+ }
+ }
-nextnick:
- /* p points to the next nick */
- s = p;
-
- /* if there was a trailing space and p was pointing to it, then we
- * need to exit.. this has the side effect of breaking double spaces
- * in an sjoin.. but that shouldnt happen anyway
- */
- if (s && (*s == '\0'))
- s = p = NULL;
-
- /* if p was NULL due to no spaces, s wont exist due to the above, so
- * we cant check it for spaces.. if there are no spaces, then when
- * we next get here, s will be NULL
- */
- if (s && ((p = strchr(s, ' ')) != NULL))
+ if (!IsMember(target_p, chptr))
+ {
+ add_user_to_channel(chptr, target_p, fl);
+ /* XXX vchan stuff */
+
+ if (top_chptr)
+ {
+ add_vchan_to_client_cache(target_p, top_chptr, chptr);
+ sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
+ target_p->name,
+ target_p->username,
+ target_p->host, top_chptr->chname);
+ }
+ else
{
- *p++ = '\0';
+ sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
+ target_p->name,
+ target_p->username, target_p->host, parv[2]);
}
}
-
- *mbuf = '\0';
- if (pargs)
+
+ if (fl & MODE_CHANOP)
+ {
+ *mbuf++ = 'o';
+ para[pargs++] = s;
+ }
+ else if (fl & MODE_VOICE)
{
+ *mbuf++ = 'v';
+ para[pargs++] = s;
+ }
+ else if (fl & MODE_HALFOP)
+ {
+ *mbuf++ = 'h';
+ para[pargs++] = s;
+ }
+
+ if (pargs >= MAXMODEPARAMS)
+ {
+ *mbuf = '\0';
sendto_channel_local(hide_or_not, chptr,
":%s MODE %s %s %s %s %s %s",
me.name,
RootChan(chptr)->chname,
- modebuf,
- para[0], para[1], para[2], para[3]);
+ modebuf, para[0], para[1], para[2], para[3]);
+ mbuf = modebuf;
+ *mbuf++ = '+';
+ para[0] = para[1] = para[2] = para[3] = "";
+ pargs = 0;
+ }
+
+ nextnick:
+ /* p points to the next nick */
+ s = p;
+
+ /* if there was a trailing space and p was pointing to it, then we
+ * need to exit.. this has the side effect of breaking double spaces
+ * in an sjoin.. but that shouldnt happen anyway
+ */
+ if (s && (*s == '\0'))
+ s = p = NULL;
+
+ /* if p was NULL due to no spaces, s wont exist due to the above, so
+ * we cant check it for spaces.. if there are no spaces, then when
+ * we next get here, s will be NULL
+ */
+ if (s && ((p = strchr(s, ' ')) != NULL))
+ {
+ *p++ = '\0';
}
+ }
+
+ *mbuf = '\0';
+ if (pargs)
+ {
+ sendto_channel_local(hide_or_not, chptr,
+ ":%s MODE %s %s %s %s %s %s",
+ me.name,
+ RootChan(chptr)->chname,
+ modebuf, para[0], para[1], para[2], para[3]);
+ }
if (!people)
return;
/* relay the SJOIN to other servers */
- for(m = serv_list.head; m; m = m->next)
- {
- target_p = m->data;
+ for (m = serv_list.head; m; m = m->next)
+ {
+ target_p = m->data;
- if (target_p == client_p->from)
+ if (target_p == client_p->from)
+ continue;
+
+ /* skip lazylinks that don't know about this server */
+ if (ServerInfo.hub && IsCapable(target_p, CAP_LL))
+ {
+ if (!(RootChan(chptr)->lazyLinkChannelExists &
+ target_p->localClient->serverMask))
continue;
+ }
- /* skip lazylinks that don't know about this server */
- if (ServerInfo.hub && IsCapable(target_p,CAP_LL))
- {
- if (!(RootChan(chptr)->lazyLinkChannelExists &
- target_p->localClient->serverMask) )
- continue;
- }
+ /* Its a blank sjoin, ugh */
+ if (!parv[4 + args][0])
+ return;
- /* Its a blank sjoin, ugh */
- if (!parv[4+args][0])
- return;
-
- if (IsCapable(target_p, CAP_HOPS))
- sendto_one(target_p, "%s %s", buf, sjbuf_hops);
- else
- sendto_one(target_p, "%s %s", buf, sjbuf_nhops);
- }
+ if (IsCapable(target_p, CAP_HOPS))
+ sendto_one(target_p, "%s %s", buf, sjbuf_hops);
+ else
+ sendto_one(target_p, "%s %s", buf, sjbuf_nhops);
+ }
}
/*
* side effects -
*/
-struct mode_letter {
+struct mode_letter
+{
int mode;
char letter;
};
struct mode_letter flags[] = {
- { MODE_NOPRIVMSGS, 'n' },
- { MODE_TOPICLIMIT, 't' },
- { MODE_SECRET, 's' },
- { MODE_MODERATED, 'm' },
- { MODE_INVITEONLY, 'i' },
- { MODE_PRIVATE, 'p' },
- { MODE_HIDEOPS, 'a' },
- { 0, 0 }
+ {MODE_NOPRIVMSGS, 'n'},
+ {MODE_TOPICLIMIT, 't'},
+ {MODE_SECRET, 's'},
+ {MODE_MODERATED, 'm'},
+ {MODE_INVITEONLY, 'i'},
+ {MODE_PRIVATE, 'p'},
+ {MODE_HIDEOPS, 'a'},
+ {0, 0}
};
-static void set_final_mode(struct Mode *mode,struct Mode *oldmode)
+static void
+set_final_mode(struct Mode *mode, struct Mode *oldmode)
{
int what = 0;
- char *pbuf=parabuf;
- int len;
- int i;
+ char *pbuf = parabuf;
+ int len;
+ int i;
for (i = 0; flags[i].letter; i++)
+ {
+ if ((flags[i].mode & mode->mode) && !(flags[i].mode & oldmode->mode))
{
- if ((flags[i].mode & mode->mode) && !(flags[i].mode & oldmode->mode))
- {
- if (what != 1)
- {
- *mbuf++ = '+';
- what = 1;
- }
- *mbuf++ = flags[i].letter;
- }
+ if (what != 1)
+ {
+ *mbuf++ = '+';
+ what = 1;
+ }
+ *mbuf++ = flags[i].letter;
}
+ }
for (i = 0; flags[i].letter; i++)
+ {
+ if ((flags[i].mode & oldmode->mode) && !(flags[i].mode & mode->mode))
{
- if ((flags[i].mode & oldmode->mode) && !(flags[i].mode & mode->mode))
- {
- if (what != -1)
- {
- *mbuf++ = '-';
- what = -1;
- }
- *mbuf++ = flags[i].letter;
- }
+ if (what != -1)
+ {
+ *mbuf++ = '-';
+ what = -1;
+ }
+ *mbuf++ = flags[i].letter;
}
+ }
if (oldmode->limit && !mode->limit)
+ {
+ if (what != -1)
{
- if (what != -1)
- {
- *mbuf++ = '-';
- what = -1;
- }
- *mbuf++ = 'l';
+ *mbuf++ = '-';
+ what = -1;
}
+ *mbuf++ = 'l';
+ }
if (oldmode->key[0] && !mode->key[0])
+ {
+ if (what != -1)
{
- if (what != -1)
- {
- *mbuf++ = '-';
- what = -1;
- }
- *mbuf++ = 'k';
- len = ircsprintf(pbuf,"%s ", oldmode->key);
- pbuf += len;
- pargs++;
+ *mbuf++ = '-';
+ what = -1;
}
+ *mbuf++ = 'k';
+ len = ircsprintf(pbuf, "%s ", oldmode->key);
+ pbuf += len;
+ pargs++;
+ }
if (mode->limit && oldmode->limit != mode->limit)
+ {
+ if (what != 1)
{
- if (what != 1)
- {
- *mbuf++ = '+';
- what = 1;
- }
- *mbuf++ = 'l';
- len = ircsprintf(pbuf, "%d ", mode->limit);
- pbuf += len;
- pargs++;
+ *mbuf++ = '+';
+ what = 1;
}
+ *mbuf++ = 'l';
+ len = ircsprintf(pbuf, "%d ", mode->limit);
+ pbuf += len;
+ pargs++;
+ }
if (mode->key[0] && strcmp(oldmode->key, mode->key))
+ {
+ if (what != 1)
{
- if (what != 1)
- {
- *mbuf++ = '+';
- what = 1;
- }
- *mbuf++ = 'k';
- len = ircsprintf(pbuf, "%s ", mode->key);
- pbuf += len;
- pargs++;
+ *mbuf++ = '+';
+ what = 1;
}
+ *mbuf++ = 'k';
+ len = ircsprintf(pbuf, "%s ", mode->key);
+ pbuf += len;
+ pargs++;
+ }
*mbuf = '\0';
}
* side effects - Go through the local members, remove all their
* chanop modes etc., this side lost the TS.
*/
-static void remove_our_modes( int hide_or_not,
- struct Channel *chptr, struct Channel *top_chptr,
- struct Client *source_p)
+static void
+remove_our_modes(int hide_or_not,
+ struct Channel *chptr, struct Channel *top_chptr,
+ struct Client *source_p)
{
- remove_a_mode(hide_or_not, chptr, top_chptr, source_p, &chptr->chanops, 'o');
- remove_a_mode(hide_or_not, chptr, top_chptr, source_p, &chptr->halfops, 'h');
+ remove_a_mode(hide_or_not, chptr, top_chptr, source_p, &chptr->chanops,
+ 'o');
+ remove_a_mode(hide_or_not, chptr, top_chptr, source_p, &chptr->halfops,
+ 'h');
remove_a_mode(hide_or_not, chptr, top_chptr, source_p, &chptr->voiced, 'v');
remove_a_mode(hide_or_not, chptr, top_chptr, source_p,
&chptr->chanops_voiced, 'o');
remove_a_mode(hide_or_not, chptr, top_chptr, source_p,
- &chptr->chanops_voiced, 'v');
+ &chptr->chanops_voiced, 'v');
/* Move all voice/ops etc. to non opped list */
dlinkMoveList(&chptr->chanops, &chptr->peons);
* output - NONE
* side effects - remove ONE mode from a channel
*/
-static void remove_a_mode( int hide_or_not,
- struct Channel *chptr, struct Channel *top_chptr,
- struct Client *source_p, dlink_list *list, char flag)
+static void
+remove_a_mode(int hide_or_not,
+ struct Channel *chptr, struct Channel *top_chptr,
+ struct Client *source_p, dlink_list * list, char flag)
{
dlink_node *ptr;
struct Client *target_p;
if (IsVchan(chptr) && top_chptr)
chname = top_chptr->chname;
- ircsprintf(buf,":%s MODE %s ", me.name, chname);
+ ircsprintf(buf, ":%s MODE %s ", me.name, chname);
for (ptr = list->head; ptr && ptr->data; ptr = ptr->next)
- {
- target_p = ptr->data;
- lpara[count++] = target_p->name;
-
- *mbuf++ = flag;
-
- if (count >= MAXMODEPARAMS)
- {
- *mbuf = '\0';
- sendto_channel_local(hide_or_not, chptr,
- ":%s MODE %s %s %s %s %s %s",
- me.name,
- chname,
- lmodebuf,
- lpara[0], lpara[1], lpara[2], lpara[3] );
-
- mbuf = lmodebuf;
- *mbuf++ = '-';
- count = 0;
- lpara[0] = lpara[1] = lpara[2] = lpara[3] = "";
- }
- }
+ {
+ target_p = ptr->data;
+ lpara[count++] = target_p->name;
- if (count != 0)
+ *mbuf++ = flag;
+
+ if (count >= MAXMODEPARAMS)
{
- *mbuf = '\0';
+ *mbuf = '\0';
sendto_channel_local(hide_or_not, chptr,
- ":%s MODE %s %s %s %s %s %s",
- me.name,
- chname,
- lmodebuf,
- lpara[0], lpara[1], lpara[2], lpara[3] );
+ ":%s MODE %s %s %s %s %s %s",
+ me.name,
+ chname,
+ lmodebuf, lpara[0], lpara[1], lpara[2], lpara[3]);
+ mbuf = lmodebuf;
+ *mbuf++ = '-';
+ count = 0;
+ lpara[0] = lpara[1] = lpara[2] = lpara[3] = "";
}
+ }
+
+ if (count != 0)
+ {
+ *mbuf = '\0';
+ sendto_channel_local(hide_or_not, chptr,
+ ":%s MODE %s %s %s %s %s %s",
+ me.name,
+ chname,
+ lmodebuf, lpara[0], lpara[1], lpara[2], lpara[3]);
+
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_squit.c,v 1.1 2002/01/04 10:57:32 a1kmm Exp $
+ * $Id: m_squit.c,v 1.2 2002/01/04 11:06:34 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
-#include "common.h" /* FALSE bleah */
+#include "common.h" /* FALSE bleah */
#include "irc_string.h"
#include "ircd.h"
#include "numeric.h"
#include <assert.h>
-static void ms_squit(struct Client*, struct Client*, int, char**);
-static void mo_squit(struct Client*, struct Client*, int, char**);
+static void ms_squit(struct Client *, struct Client *, int, char **);
+static void mo_squit(struct Client *, struct Client *, int, char **);
struct Message squit_msgtab = {
"SQUIT", 0, 0, 1, 0, MFLG_SLOW, 0,
{
mod_del_cmd(&squit_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
-struct squit_parms
+struct squit_parms
{
char *server_name;
struct Client *target_p;
};
static struct squit_parms *find_squit(struct Client *client_p,
- struct Client *source_p,
- char *server);
+ struct Client *source_p, char *server);
/*
* parv[1] = server name
* parv[2] = comment
*/
-static void mo_squit(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_squit(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct squit_parms *found_squit;
- char *comment = (parc > 2 && parv[2]) ? parv[2] : client_p->name;
+ char *comment = (parc > 2 && parv[2]) ? parv[2] : client_p->name;
if (!IsOperRemote(source_p))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need remote = yes;", me.name,
+ parv[0]);
+ return;
+ }
+
+ if (parc < 2)
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "SQUIT");
+ return;
+ }
+
+ if ((found_squit = find_squit(client_p, source_p, parv[1])))
+ {
+ if (MyConnect(found_squit->target_p))
{
- sendto_one(source_p,":%s NOTICE %s :You need remote = yes;",me.name,parv[0]);
- return;
- }
-
- if(parc < 2)
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "SQUIT");
- return;
- }
-
- if( (found_squit = find_squit(client_p,source_p,parv[1])) )
- {
- if(MyConnect(found_squit->target_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Received SQUIT %s from %s (%s)",
- found_squit->target_p->name,
- get_client_name(source_p, HIDE_IP), comment);
- ilog(L_NOTICE, "Received SQUIT %s from %s (%s)",
- found_squit->target_p->name, get_client_name(source_p, HIDE_IP),
- comment);
- }
- exit_client(client_p, found_squit->target_p, source_p, comment);
- return;
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Received SQUIT %s from %s (%s)",
+ found_squit->target_p->name,
+ get_client_name(source_p, HIDE_IP), comment);
+ ilog(L_NOTICE, "Received SQUIT %s from %s (%s)",
+ found_squit->target_p->name, get_client_name(source_p, HIDE_IP),
+ comment);
}
+ exit_client(client_p, found_squit->target_p, source_p, comment);
+ return;
+ }
else
- {
- sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
- me.name, parv[0], parv[1]);
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
+ me.name, parv[0], parv[1]);
+ }
}
/*
* parv[1] = server name
* parv[2] = comment
*/
-static void ms_squit(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_squit(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct squit_parms *found_squit;
- char *comment = (parc > 2 && parv[2]) ? parv[2] : client_p->name;
-
- if(parc < 2)
+ char *comment = (parc > 2 && parv[2]) ? parv[2] : client_p->name;
+
+ if (parc < 2)
+ {
+ exit_client(client_p, client_p, source_p, comment);
+ return;
+ }
+
+ if ((found_squit = find_squit(client_p, source_p, parv[1])))
+ {
+ /*
+ ** Notify all opers, if my local link is remotely squitted
+ */
+ if (MyConnect(found_squit->target_p))
{
- exit_client(client_p, client_p, source_p, comment);
- return;
- }
+ sendto_wallops_flags(FLAGS_WALLOP, &me,
+ "Remote SQUIT %s from %s (%s)",
+ found_squit->server_name, source_p->name, comment);
+
+ sendto_server(NULL, NULL, NULL, NOCAPS, NOCAPS, NOFLAGS,
+ ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
+ me.name, found_squit->server_name,
+ source_p->name, comment);
+
+ ilog(L_TRACE, "SQUIT From %s : %s (%s)", parv[0],
+ found_squit->server_name, comment);
- if( (found_squit = find_squit(client_p, source_p, parv[1])) )
- {
- /*
- ** Notify all opers, if my local link is remotely squitted
- */
- if (MyConnect(found_squit->target_p))
- {
- sendto_wallops_flags(FLAGS_WALLOP, &me,
- "Remote SQUIT %s from %s (%s)",
- found_squit->server_name,
- source_p->name, comment);
-
- sendto_server(NULL, NULL, NULL, NOCAPS, NOCAPS, NOFLAGS,
- ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
- me.name, found_squit->server_name,
- source_p->name, comment);
-
- ilog(L_TRACE, "SQUIT From %s : %s (%s)", parv[0],
- found_squit->server_name, comment);
-
- }
- exit_client(client_p, found_squit->target_p, source_p, comment);
- return;
}
+ exit_client(client_p, found_squit->target_p, source_p, comment);
+ return;
+ }
}
* output - pointer to struct containing found squit or none if not found
* side effects -
*/
-static struct squit_parms *find_squit(struct Client *client_p,
- struct Client *source_p,
- char *server)
+static struct squit_parms *
+find_squit(struct Client *client_p, struct Client *source_p, char *server)
{
static struct squit_parms found_squit;
static struct Client *target_p;
found_squit.server_name = NULL;
/*
- ** To accomodate host masking, a squit for a masked server
- ** name is expanded if the incoming mask is the same as
- ** the server name for that link to the name of link.
- */
+ ** To accomodate host masking, a squit for a masked server
+ ** name is expanded if the incoming mask is the same as
+ ** the server name for that link to the name of link.
+ */
if ((*server == '*') && IsServer(client_p))
+ {
+ aconf = client_p->serv->sconf;
+ if (aconf)
{
- aconf = client_p->serv->sconf;
- if (aconf)
- {
- if (!irccmp(server, my_name_for_link(me.name, aconf)))
- {
- found_squit.server_name = client_p->name;
- found_squit.target_p = client_p;
- }
- }
+ if (!irccmp(server, my_name_for_link(me.name, aconf)))
+ {
+ found_squit.server_name = client_p->name;
+ found_squit.target_p = client_p;
+ }
}
+ }
/*
- ** The following allows wild cards in SQUIT. Only useful
- ** when the command is issued by an oper.
- */
- for (target_p = GlobalClientList; (target_p = next_client(target_p, server));
- target_p = target_p->next)
- {
- if (IsServer(target_p) || IsMe(target_p))
- break;
- }
+ ** The following allows wild cards in SQUIT. Only useful
+ ** when the command is issued by an oper.
+ */
+ for (target_p = GlobalClientList;
+ (target_p = next_client(target_p, server)); target_p = target_p->next)
+ {
+ if (IsServer(target_p) || IsMe(target_p))
+ break;
+ }
found_squit.target_p = target_p;
found_squit.server_name = server;
if (target_p && IsMe(target_p))
+ {
+ if (IsClient(client_p))
{
- if (IsClient(client_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You are trying to squit me.",me.name,client_p->name);
- found_squit.target_p = NULL;
- }
- else
- {
- found_squit.target_p = client_p;
- found_squit.server_name = client_p->name;
- }
-
+ sendto_one(source_p, ":%s NOTICE %s :You are trying to squit me.",
+ me.name, client_p->name);
+ found_squit.target_p = NULL;
}
+ else
+ {
+ found_squit.target_p = client_p;
+ found_squit.server_name = client_p->name;
+ }
+
+ }
- if(found_squit.target_p != NULL)
+ if (found_squit.target_p != NULL)
return &found_squit;
else
- return( NULL );
+ return (NULL);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_accept.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_accept.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
-#include "hash.h" /* for find_client() */
+#include "hash.h" /* for find_client() */
#include "ircd.h"
#include "list.h"
#include "numeric.h"
#include "parse.h"
#include "modules.h"
-static void m_accept(struct Client*, struct Client*, int, char**);
+static void m_accept(struct Client *, struct Client *, int, char **);
static void build_nicklist(struct Client *, char *, char *, char *);
static void add_accept(struct Client *, struct Client *);
static void list_accepts(struct Client *);
struct Message accept_msgtab = {
- "ACCEPT", 0, 0, 2, 0, MFLG_SLOW | MFLG_UNREG, 0,
+ "ACCEPT", 0, 0, 2, 0, MFLG_SLOW | MFLG_UNREG, 0,
{m_unregistered, m_accept, m_ignore, m_accept}
};
mod_del_cmd(&accept_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_accept - ACCEPT command handler
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void m_accept(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_accept(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
char *nick;
char *p = NULL;
static char delbuf[BUFSIZE];
struct Client *target_p;
int accept_num;
-
- if(*parv[1] == '*')
+
+ if (*parv[1] == '*')
{
list_accepts(source_p);
return;
build_nicklist(source_p, addbuf, delbuf, parv[1]);
/* parse the delete list */
- for(nick = strtoken(&p, delbuf, ","); nick != NULL;
- nick = strtoken(&p, NULL, ","))
+ for (nick = strtoken(&p, delbuf, ","); nick != NULL;
+ nick = strtoken(&p, NULL, ","))
{
/* shouldnt happen, but lets be paranoid */
- if(((target_p = find_client(nick)) == NULL) || !IsPerson(target_p))
+ if (((target_p = find_client(nick)) == NULL) || !IsPerson(target_p))
{
sendto_one(source_p, form_str(ERR_NOSUCHNICK),
me.name, source_p->name, nick);
}
/* user isnt on clients accept list */
- if(!accept_message(target_p, source_p))
+ if (!accept_message(target_p, source_p))
{
sendto_one(source_p, form_str(ERR_ACCEPTNOT),
me.name, source_p->name, target_p->name);
del_from_accept(target_p, source_p);
}
- /* get the number of accepts they have */
+ /* get the number of accepts they have */
accept_num = dlink_list_length(&source_p->allow_list);
-
+
/* parse the add list */
- for(nick = strtoken(&p, addbuf, ","); nick;
- nick = strtoken(&p, NULL, ","), accept_num++)
+ for (nick = strtoken(&p, addbuf, ","); nick;
+ nick = strtoken(&p, NULL, ","), accept_num++)
{
/* shouldnt happen, but lets be paranoid */
- if(((target_p = find_client(nick)) == NULL) || !IsPerson(target_p))
+ if (((target_p = find_client(nick)) == NULL) || !IsPerson(target_p))
{
sendto_one(source_p, form_str(ERR_NOSUCHNICK),
me.name, source_p->name, nick);
}
/* user is already on clients accept list */
- if(accept_message(target_p, source_p))
+ if (accept_message(target_p, source_p))
{
sendto_one(source_p, form_str(ERR_ACCEPTEXIST),
me.name, source_p->name, target_p->name);
continue;
}
- if(accept_num >= ConfigFileEntry.max_accept)
+ if (accept_num >= ConfigFileEntry.max_accept)
{
- sendto_one(source_p, form_str(ERR_ACCEPTFULL),
- me.name, source_p->name);
+ sendto_one(source_p, form_str(ERR_ACCEPTFULL), me.name, source_p->name);
return;
}
-
+
/* why is this here? */
/* del_from accept(target_p, source_p); */
add_accept(source_p, target_p);
}
+
/*
* build_nicklist()
*
* output -
* side effects - addbuf/delbuf are modified to give valid nicks
*/
-static void build_nicklist(struct Client *source_p, char *addbuf,
- char *delbuf, char *nicks)
+static void
+build_nicklist(struct Client *source_p, char *addbuf,
+ char *delbuf, char *nicks)
{
char *name;
char *p;
del = lenadd = lendel = 0;
/* build list of clients to add into addbuf, clients to remove in delbuf */
- for(name = strtoken(&p, nicks, ","); name;
- name = strtoken(&p, (char *)NULL, ","), del = 0)
+ for (name = strtoken(&p, nicks, ","); name;
+ name = strtoken(&p, (char *)NULL, ","), del = 0)
{
- if(*name == '-')
+ if (*name == '-')
{
del = 1;
name++;
}
- if(((target_p = find_client(name)) == NULL) || !IsPerson(target_p))
+ if (((target_p = find_client(name)) == NULL) || !IsPerson(target_p))
{
sendto_one(source_p, form_str(ERR_NOSUCHNICK),
me.name, source_p->name, name);
}
/* we're deleting a client */
- if(del)
+ if (del)
{
- if(*delbuf)
+ if (*delbuf)
(void)strcat(delbuf, ",");
-
+
(void)strncat(delbuf, name, BUFSIZE - lendel - 1);
lendel += strlen(name) + 1;
}
/* adding a client */
else
{
- if(*addbuf)
+ if (*addbuf)
(void)strcat(addbuf, ",");
(void)strncat(addbuf, name, BUFSIZE - lenadd - 1);
* output - none
* side effects - target is added to clients list
*/
-static void add_accept(struct Client *source_p,
- struct Client *target_p)
+static void
+add_accept(struct Client *source_p, struct Client *target_p)
{
dlink_node *m;
m = make_dlink_node();
dlinkAdd(target_p, m, &source_p->allow_list);
- m = make_dlink_node()
- dlinkAdd(source_p, m, &target_p->on_allow_list);
+ m = make_dlink_node()dlinkAdd(source_p, m, &target_p->on_allow_list);
}
-
+
/*
* list_accepts()
* output - none
* side effects - print accept list to client
*/
-static void list_accepts(struct Client *source_p)
+static void
+list_accepts(struct Client *source_p)
{
dlink_node *ptr;
struct Client *target_p;
char nicks[BUFSIZE];
- int len=0;
- int len2=0;
- int count=0;
-
+ int len = 0;
+ int len2 = 0;
+ int count = 0;
+
*nicks = '\0';
- len2= strlen(source_p->name) + 10;
+ len2 = strlen(source_p->name) + 10;
- for(ptr = source_p->allow_list.head; ptr; ptr = ptr->next)
+ for (ptr = source_p->allow_list.head; ptr; ptr = ptr->next)
{
target_p = ptr->data;
- if(target_p)
+ if (target_p)
{
- if((len + strlen(target_p->name) + len2 > BUFSIZE) || count > 14)
+ if ((len + strlen(target_p->name) + len2 > BUFSIZE) || count > 14)
{
sendto_one(source_p, form_str(RPL_ACCEPTLIST),
- me.name, source_p->name, nicks);
-
- len = count = 0;
- *nicks = '\0';
+ me.name, source_p->name, nicks);
+
+ len = count = 0;
+ *nicks = '\0';
}
- ircsprintf(nicks+len, "%s ", target_p->name);
-
+ ircsprintf(nicks + len, "%s ", target_p->name);
+
count++;
len += strlen(target_p->name) + 1;
}
}
- if(*nicks)
+ if (*nicks)
sendto_one(source_p, form_str(RPL_ACCEPTLIST),
me.name, source_p->name, nicks);
- sendto_one(source_p, form_str(RPL_ENDOFACCEPT),
- me.name, source_p->name);
+ sendto_one(source_p, form_str(RPL_ENDOFACCEPT), me.name, source_p->name);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_admin.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_admin.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "hook.h"
#include "modules.h"
-static void m_admin(struct Client*, struct Client*, int, char**);
-static void mr_admin(struct Client*, struct Client*, int, char**);
-static void ms_admin(struct Client*, struct Client*, int, char**);
-static void do_admin( struct Client *source_p );
+static void m_admin(struct Client *, struct Client *, int, char **);
+static void mr_admin(struct Client *, struct Client *, int, char **);
+static void ms_admin(struct Client *, struct Client *, int, char **);
+static void do_admin(struct Client *source_p);
static void admin_spy(struct Client *);
struct Message admin_msgtab = {
- "ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
+ "ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
{mr_admin, m_admin, ms_admin, ms_admin}
};
#ifndef STATIC_MODULES
hook_del_event("doing_admin");
mod_del_cmd(&admin_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mr_admin - ADMIN command handler
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void mr_admin(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mr_admin(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- static time_t last_used=0L;
-
- if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
- {
- sendto_one(source_p,form_str(RPL_LOAD2HI), me.name,
- BadPtr(parv[0]) ? "*" : parv[0]);
- return;
- }
+ static time_t last_used = 0L;
+
+ if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
+ {
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name,
+ BadPtr(parv[0]) ? "*" : parv[0]);
+ return;
+ }
else
last_used = CurrentTime;
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void m_admin(struct Client *client_p, struct Client *source_p, int parc,
- char *parv[])
+static void
+m_admin(struct Client *client_p, struct Client *source_p, int parc,
+ char *parv[])
{
- static time_t last_used=0L;
+ static time_t last_used = 0L;
- if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
- {
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,parv[0]);
- return;
- }
+ if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
+ {
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
+ return;
+ }
else
last_used = CurrentTime;
if (!ConfigServerHide.disable_remote)
- {
- if (hunt_server(client_p,source_p,":%s ADMIN :%s",1,parc,parv) != HUNTED_ISME)
- return;
- }
+ {
+ if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) !=
+ HUNTED_ISME)
+ return;
+ }
do_admin(source_p);
}
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void ms_admin(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_admin(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if (hunt_server(client_p,source_p,":%s ADMIN :%s",1,parc,parv) != HUNTED_ISME)
+ if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) !=
+ HUNTED_ISME)
return;
- do_admin( source_p );
+ do_admin(source_p);
}
* output - none
* side effects - admin info is sent to client given
*/
-static void do_admin( struct Client *source_p )
+static void
+do_admin(struct Client *source_p)
{
char *nick;
nick = BadPtr(source_p->name) ? "*" : source_p->name;
- sendto_one(source_p, form_str(RPL_ADMINME),
- me.name, nick, me.name);
+ sendto_one(source_p, form_str(RPL_ADMINME), me.name, nick, me.name);
if (AdminInfo.name != NULL)
sendto_one(source_p, form_str(RPL_ADMINLOC1),
- me.name, nick, AdminInfo.name);
+ me.name, nick, AdminInfo.name);
if (AdminInfo.description != NULL)
sendto_one(source_p, form_str(RPL_ADMINLOC2),
- me.name, nick, AdminInfo.description);
+ me.name, nick, AdminInfo.description);
if (AdminInfo.email != NULL)
sendto_one(source_p, form_str(RPL_ADMINEMAIL),
- me.name, nick, AdminInfo.email);
+ me.name, nick, AdminInfo.email);
}
/* admin_spy()
* output - none
* side effects - event doing_admin is called
*/
-static void admin_spy(struct Client *source_p)
+static void
+admin_spy(struct Client *source_p)
{
struct hook_spy_data data;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_away.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_away.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include <stdlib.h>
-static void m_away(struct Client*, struct Client*, int, char**);
+static void m_away(struct Client *, struct Client *, int, char **);
struct Message away_msgtab = {
"AWAY", 0, 0, 0, 0, MFLG_SLOW, 0,
{
mod_del_cmd(&away_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
/***********************************************************************
* m_away() - Added 14 Dec 1988 by jto.
** parv[0] = sender prefix
** parv[1] = away message
*/
-static void m_away(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_away(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- char *away, *awy2 = parv[1];
+ char *away, *awy2 = parv[1];
/* make sure the user exists */
if (!(source_p->user))
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ALL,
- "Got AWAY from nil user, from %s (%s)",
- client_p->name, source_p->name);
- return;
- }
+ {
+ sendto_realops_flags(FLAGS_DEBUG, L_ALL,
+ "Got AWAY from nil user, from %s (%s)",
+ client_p->name, source_p->name);
+ return;
+ }
away = source_p->user->away;
if (parc < 2 || !*awy2)
+ {
+ /* Marking as not away */
+
+ if (away)
{
- /* Marking as not away */
-
- if (away)
- {
- /* we now send this only if they were away before --is */
- sendto_server(client_p, source_p, NULL, CAP_UID, NOCAPS,
- NOFLAGS, ":%s AWAY", ID(source_p));
- sendto_server(client_p, source_p, NULL, NOCAPS, CAP_UID,
- NOFLAGS, ":%s AWAY", source_p->name);
- MyFree(away);
- source_p->user->away = NULL;
- }
- if (MyConnect(source_p))
- sendto_one(source_p, form_str(RPL_UNAWAY),
- me.name, parv[0]);
- return;
+ /* we now send this only if they were away before --is */
+ sendto_server(client_p, source_p, NULL, CAP_UID, NOCAPS,
+ NOFLAGS, ":%s AWAY", ID(source_p));
+ sendto_server(client_p, source_p, NULL, NOCAPS, CAP_UID,
+ NOFLAGS, ":%s AWAY", source_p->name);
+ MyFree(away);
+ source_p->user->away = NULL;
}
+ if (MyConnect(source_p))
+ sendto_one(source_p, form_str(RPL_UNAWAY), me.name, parv[0]);
+ return;
+ }
/* Marking as away */
-
+
if (MyConnect(source_p) && !IsOper(source_p) &&
- (CurrentTime-source_p->user->last_away)<ConfigFileEntry.pace_wait)
- {
- sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
- return;
- }
+ (CurrentTime - source_p->user->last_away) < ConfigFileEntry.pace_wait)
+ {
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
+ return;
+ }
source_p->user->last_away = CurrentTime;
else
MyFree(away);
- away = (char *)MyMalloc(strlen(awy2)+1);
- strcpy(away,awy2);
+ away = (char *)MyMalloc(strlen(awy2) + 1);
+ strcpy(away, awy2);
source_p->user->away = away;
if (MyConnect(source_p))
sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, parv[0]);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_capab.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_capab.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "parse.h"
#include "modules.h"
-static void mr_capab(struct Client*, struct Client*, int, char**);
+static void mr_capab(struct Client *, struct Client *, int, char **);
struct Message capab_msgtab = {
"CAPAB", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
mod_del_cmd(&capab_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* parv[1] = space-separated list of capabilities
*
*/
-static void mr_capab(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mr_capab(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct Capability *cap;
int i;
- char* p;
- char* s;
+ char *p;
+ char *s;
#ifdef HAVE_LIBCRYPTO
struct EncCapability *ecap;
unsigned int cipher = 0;
else
client_p->localClient->caps |= CAP_CAP;
- for (i=1; i<parc; i++)
+ for (i = 1; i < parc; i++)
{
for (s = strtoken(&p, parv[i], " "); s; s = strtoken(&p, NULL, " "))
{
#ifdef HAVE_LIBCRYPTO
- if ( (strncmp(s, "ENC:", 4) == 0) )
+ if ((strncmp(s, "ENC:", 4) == 0))
{
/* Skip the "ENC:" portion */
s += 4;
*/
for (ecap = CipherTable; ecap->name; ecap++)
{
- if ( (!irccmp(ecap->name, s)) && (ecap->cap & CAP_ENC_MASK))
+ if ((!irccmp(ecap->name, s)) && (ecap->cap & CAP_ENC_MASK))
{
cipher = ecap->cap;
break;
return;
}
}
- else /* normal capab */
+ else /* normal capab */
#endif
for (cap = captab; cap->name; cap++)
{
break;
}
}
- } /* for */
- } /* for */
+ } /* for */
+ } /* for */
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_cburst.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_cburst.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "tools.h"
#include "channel.h"
#include "ircd.h"
#include "list.h"
#include "numeric.h"
-#include "s_serv.h" /* captab, send_channel_burst */
+#include "s_serv.h" /* captab, send_channel_burst */
#include "s_user.h"
#include "send.h"
#include "msg.h"
#include <string.h>
#include <stdlib.h>
-static void ms_cburst(struct Client*, struct Client*, int, char**);
+static void ms_cburst(struct Client *, struct Client *, int, char **);
struct Message cburst_msgtab = {
"CBURST", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0L,
mod_del_cmd(&cburst_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** m_cburst
* the given LL capable server.
*/
-static void
+static void
ms_cburst(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+ struct Client *source_p, int parc, char *parv[])
{
char *name;
char *nick;
char *key;
struct Channel *chptr;
- if( parc < 2 || *parv[1] == '\0' )
- return;
+ if (parc < 2 || *parv[1] == '\0')
+ return;
name = parv[1];
- if( parc > 2 )
+ if (parc > 2)
nick = parv[2];
else
nick = NULL;
- if( parc > 3 )
+ if (parc > 3)
key = parv[3];
else
key = "";
#ifdef DEBUGLL
sendto_realops_flags(FLAGS_ALL, L_ALL, "CBURST called by %s for %s %s %s",
- client_p->name,
- name,
- nick ? nick : "",
- key ? key : "" );
+ client_p->name,
+ name, nick ? nick : "", key ? key : "");
#endif
- if((chptr = hash_find_channel(name)) == NULL)
+ if ((chptr = hash_find_channel(name)) == NULL)
{
- if((!nick) || (nick && *nick!='!'))
+ if ((!nick) || (nick && *nick != '!'))
{
chptr = get_or_create_channel(source_p, name, NULL);
- chptr->channelts = (time_t)(-1); /* highest possible TS so its always
- * over-ruled
- */
+ chptr->channelts = (time_t) (-1); /* highest possible TS so its always
+ * over-ruled
+ */
chptr->users_last = CurrentTime;
}
- else if(nick && *nick=='!')
+ else if (nick && *nick == '!')
{
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, nick+1, name);
+ me.name, nick + 1, name);
return;
}
}
- if(IsCapable(client_p,CAP_LL))
- {
- burst_channel(client_p,chptr);
+ if (IsCapable(client_p, CAP_LL))
+ {
+ burst_channel(client_p, chptr);
- if(nick)
- sendto_one(client_p,":%s LLJOIN %s %s %s", me.name, name,
- nick, key);
- }
+ if (nick)
+ sendto_one(client_p, ":%s LLJOIN %s %s %s", me.name, name, nick, key);
+ }
else
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** CBURST request received from non LL capable server! [%s]",
- client_p->name);
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** CBURST request received from non LL capable server! [%s]",
+ client_p->name);
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_challenge.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_challenge.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include <stdlib.h>
#include <string.h>
#include "irc_string.h"
#include "s_log.h"
-int oper_up( struct Client *source_p, struct ConfItem *aconf );
+int oper_up(struct Client *source_p, struct ConfItem *aconf);
#ifndef HAVE_LIBCRYPTO
/* Maybe this should be an error or something?-davidt */
return;
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
#else
-static void m_challenge(struct Client*, struct Client*, int, char**);
-void binary_to_hex( unsigned char * bin, char * hex, int length );
+static void m_challenge(struct Client *, struct Client *, int, char **);
+void binary_to_hex(unsigned char *bin, char *hex, int length);
/* We have openssl support, so include /CHALLENGE */
struct Message challenge_msgtab = {
mod_del_cmd(&challenge_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_challenge - generate RSA challenge for wouldbe oper
* parv[1] = operator to challenge for, or +response
*
*/
-static void m_challenge( struct Client *client_p, struct Client *source_p,
- int parc, char *parv[] )
+static void
+m_challenge(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char * challenge;
+ char *challenge;
dlink_node *ptr;
struct ConfItem *aconf, *oconf;
- if(!(source_p->user) || !source_p->localClient)
+ if (!(source_p->user) || !source_p->localClient)
return;
-
+
if (*parv[1] == '+')
+ {
+ /* Ignore it if we aren't expecting this... -A1kmm */
+ if (!source_p->user->response)
+ return;
+
+ if (irccmp(source_p->user->response, ++parv[1]))
+ {
+ sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name,
+ source_p->name);
+ return;
+ }
+
+ if (!
+ (aconf = find_conf_by_name(source_p->user->auth_oper, CONF_OPERATOR)))
{
- /* Ignore it if we aren't expecting this... -A1kmm */
- if (!source_p->user->response)
- return;
-
- if (irccmp(source_p->user->response, ++parv[1]))
- {
- sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name,
- source_p->name);
- return;
- }
-
- if (!(aconf = find_conf_by_name(source_p->user->auth_oper, CONF_OPERATOR)))
- {
- sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
- return;
- }
+ sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
+ return;
+ }
ptr = source_p->localClient->confs.head;
oconf = ptr->data;
- detach_conf(source_p,oconf);
-
- if(attach_conf(source_p, aconf) != 0)
- {
- sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
- me.name,source_p->name);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Failed OPER attempt by %s (%s@%s) can't attach conf!",
- source_p->name, source_p->username, source_p->host);
- attach_conf(source_p, oconf);
- return;
- }
-
- /* Now make them an oper and tell the realops... */
- oper_up(source_p, aconf);
- ilog(L_TRACE, "OPER %s by %s!%s@%s",
- source_p->user->auth_oper, source_p->name, source_p->username, source_p->host);
- log_oper(source_p, source_p->user->auth_oper);
- MyFree(source_p->user->response);
- MyFree(source_p->user->auth_oper);
- source_p->user->response = NULL;
- source_p->user->auth_oper = NULL;
- return;
+ detach_conf(source_p, oconf);
+
+ if (attach_conf(source_p, aconf) != 0)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Can't attach conf!",
+ me.name, source_p->name);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Failed OPER attempt by %s (%s@%s) can't attach conf!",
+ source_p->name, source_p->username,
+ source_p->host);
+ attach_conf(source_p, oconf);
+ return;
}
-
+
+ /* Now make them an oper and tell the realops... */
+ oper_up(source_p, aconf);
+ ilog(L_TRACE, "OPER %s by %s!%s@%s",
+ source_p->user->auth_oper, source_p->name, source_p->username,
+ source_p->host);
+ log_oper(source_p, source_p->user->auth_oper);
+ MyFree(source_p->user->response);
+ MyFree(source_p->user->auth_oper);
+ source_p->user->response = NULL;
+ source_p->user->auth_oper = NULL;
+ return;
+ }
+
MyFree(source_p->user->response);
MyFree(source_p->user->auth_oper);
source_p->user->response = NULL;
source_p->user->response = NULL;
if (!(aconf = find_conf_exact(parv[1], source_p->username, source_p->host,
- CONF_OPERATOR)) &&
- !(aconf = find_conf_exact(parv[1], source_p->username,
+ CONF_OPERATOR)) &&
+ !(aconf = find_conf_exact(parv[1], source_p->username,
source_p->localClient->sockhost,
CONF_OPERATOR)))
- {
- sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
+ return;
+ }
if (!aconf->rsa_public_key)
- {
- sendto_one (source_p, ":%s NOTICE %s :I'm sorry, PK authentication "
- "is not enabled for your oper{} block.", me.name,
- parv[0]);
- return;
- }
- if (
- !generate_challenge (&challenge, &(source_p->user->response), aconf->rsa_public_key)
- )
- {
- sendto_one (source_p, form_str(RPL_RSACHALLENGE), me.name, parv[0],
- challenge);
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :I'm sorry, PK authentication "
+ "is not enabled for your oper{} block.", me.name, parv[0]);
+ return;
+ }
+ if (!generate_challenge
+ (&challenge, &(source_p->user->response), aconf->rsa_public_key))
+ {
+ sendto_one(source_p, form_str(RPL_RSACHALLENGE), me.name, parv[0],
+ challenge);
+ }
DupString(source_p->user->auth_oper, aconf->name);
MyFree(challenge);
return;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_cjoin.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_cjoin.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include "channel_mode.h"
#include "vchannel.h"
#include "client.h"
-#include "common.h" /* bleah */
+#include "common.h" /* bleah */
#include "hash.h"
#include "irc_string.h"
#include "ircd.h"
#include <stdlib.h>
#include <string.h>
-static void m_cjoin(struct Client*, struct Client*, int, char**);
+static void m_cjoin(struct Client *, struct Client *, int, char **);
struct Message cjoin_msgtab = {
"CJOIN", 0, 0, 2, 0, MFLG_SLOW, 0,
mod_del_cmd(&cjoin_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** m_cjoin
** parv[1] = channel
** parv[2] = channel password (key)
*/
-static void m_cjoin(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_cjoin(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- static char jbuf[BUFSIZE];
+ static char jbuf[BUFSIZE];
struct Channel *chptr = NULL;
struct Channel *vchan_chptr = NULL;
struct Channel *root_vchan = NULL;
- char *name;
- char *p = NULL;
+ char *name;
+ char *p = NULL;
if (!(source_p->user))
- {
- /* something is *fucked* - bail */
- return;
- }
+ {
+ /* something is *fucked* - bail */
+ return;
+ }
- if(ConfigChannel.use_vchans == 0)
+ if (ConfigChannel.use_vchans == 0)
{
- sendto_one(source_p, form_str(ERR_VCHANDISABLED),
- me.name, parv[0]);
+ sendto_one(source_p, form_str(ERR_VCHANDISABLED), me.name, parv[0]);
return;
}
-
+
if (ConfigChannel.vchans_oper_only && !IsOper(source_p))
{
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
- me.name, parv[0]);
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
return;
}
if (*parv[1] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "CJOIN");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "CJOIN");
+ return;
+ }
/* Ok, only allowed to CJOIN already existing channels
*jbuf = '\0';
name = parv[1];
- if ( (p = strchr(name,',')) )
+ if ((p = strchr(name, ',')))
*p = '\0';
if (!check_channel_name(name))
- {
- sendto_one(source_p, form_str(ERR_BADCHANNAME),
- me.name, parv[0], (unsigned char*) name);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_BADCHANNAME),
+ me.name, parv[0], (unsigned char *)name);
+ return;
+ }
if (*name == '&')
- {
- sendto_one(source_p, form_str(ERR_BADCHANNAME),
- me.name, parv[0], (unsigned char*) name);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_BADCHANNAME),
+ me.name, parv[0], (unsigned char *)name);
+ return;
+ }
if (!IsChannelName(name))
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, parv[0], name);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), me.name, parv[0], name);
+ return;
+ }
(void)strncpy(jbuf, name, sizeof(jbuf) - 1);
if ((chptr = hash_find_channel(name)) == NULL)
+ {
+ /* if chptr isn't found locally, it =could= exist
+ * on the uplink. So ask.
+ */
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
{
- /* if chptr isn't found locally, it =could= exist
- * on the uplink. So ask.
+ /* cache the channel if it exists on uplink
+ * If the channel as seen by the uplink, has vchans,
+ * the uplink will have to SJOIN all of those.
*/
- if ( !ServerInfo.hub && uplink &&
- IsCapable(uplink, CAP_LL))
- {
- /* cache the channel if it exists on uplink
- * If the channel as seen by the uplink, has vchans,
- * the uplink will have to SJOIN all of those.
- */
- sendto_one(uplink, ":%s CBURST %s !%s",
- me.name, parv[1], source_p->name);
-
- return;
- }
- else
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, source_p->name, name);
- }
+ sendto_one(uplink, ":%s CBURST %s !%s",
+ me.name, parv[1], source_p->name);
+
return;
}
+ else
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, source_p->name, name);
+ }
+ return;
+ }
- if (! (vchan_chptr = cjoin_channel(chptr, source_p, name)) )
+ if (!(vchan_chptr = cjoin_channel(chptr, source_p, name)))
return;
root_vchan = chptr;
chptr = vchan_chptr;
-
+
/*
- ** Complete user entry to the new channel
- */
+ ** Complete user entry to the new channel
+ */
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
sendto_channel_local(ALL_MEMBERS, chptr,
- ":%s!%s@%s JOIN :%s",
- source_p->name,
- source_p->username,
- source_p->host,
- root_vchan->chname);
+ ":%s!%s@%s JOIN :%s",
+ source_p->name,
+ source_p->username,
+ source_p->host, root_vchan->chname);
sendto_server(client_p, NULL, chptr, NOCAPS, NOCAPS, NOFLAGS,
":%s SJOIN %lu %s + :@%s",
me.name,
- (unsigned long) chptr->channelts,
- chptr->chname,
- source_p->name);
+ (unsigned long)chptr->channelts,
+ chptr->chname, source_p->name);
vchan_chptr->mode.mode |= MODE_TOPICLIMIT;
vchan_chptr->mode.mode |= MODE_NOPRIVMSGS;
- sendto_channel_local(ALL_MEMBERS,chptr,
- ":%s MODE %s +nt",
- me.name,
- root_vchan->chname);
+ sendto_channel_local(ALL_MEMBERS, chptr,
+ ":%s MODE %s +nt", me.name, root_vchan->chname);
sendto_server(source_p, NULL, vchan_chptr, NOCAPS, NOCAPS, NOFLAGS,
- ":%s MODE %s +nt",
- me.name,
- vchan_chptr->chname);
+ ":%s MODE %s +nt", me.name, vchan_chptr->chname);
del_invite(vchan_chptr, source_p);
channel_member_names(source_p, vchan_chptr, root_vchan->chname, 1);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_close.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_close.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include "parse.h"
#include "modules.h"
-static void mo_close(struct Client*, struct Client*, int, char**);
+static void mo_close(struct Client *, struct Client *, int, char **);
struct Message close_msgtab = {
"CLOSE", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&close_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_close - CLOSE message handler
* - added by Darren Reed Jul 13 1992.
*/
-static void mo_close(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_close(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Client *target_p;
- dlink_node *ptr;
- dlink_node *ptr_next;
- int closed = 0;
+ struct Client *target_p;
+ dlink_node *ptr;
+ dlink_node *ptr_next;
+ int closed = 0;
for (ptr = unknown_list.head; ptr; ptr = ptr_next)
- {
- target_p = ptr->data;
- ptr_next = ptr->next;
+ {
+ target_p = ptr->data;
+ ptr_next = ptr->next;
- /* Which list would connecting servers be found in? serv_list ? */
+ /* Which list would connecting servers be found in? serv_list ? */
#if 0
- if (!IsUnknown(target_p) && !IsConnecting(target_p) &&
- !IsHandshake(target_p) && !IsDoingKauth(target_p))
- continue;
+ if (!IsUnknown(target_p) && !IsConnecting(target_p) &&
+ !IsHandshake(target_p) && !IsDoingKauth(target_p))
+ continue;
#endif
- sendto_one(source_p, form_str(RPL_CLOSING), me.name, parv[0],
- get_client_name(target_p, SHOW_IP), target_p->status);
- (void)exit_client(target_p, target_p, target_p, "Oper Closing");
- closed++;
- }
+ sendto_one(source_p, form_str(RPL_CLOSING), me.name, parv[0],
+ get_client_name(target_p, SHOW_IP), target_p->status);
+ (void)exit_client(target_p, target_p, target_p, "Oper Closing");
+ closed++;
+ }
sendto_one(source_p, form_str(RPL_CLOSEEND), me.name, parv[0], closed);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_connect.c,v 1.1 2002/01/04 09:13:13 a1kmm Exp $
+ * $Id: m_connect.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "modules.h"
#include <assert.h>
-#include <stdlib.h> /* atoi */
+#include <stdlib.h> /* atoi */
-static void mo_connect(struct Client*, struct Client*, int, char**);
-static void ms_connect(struct Client*, struct Client*, int, char**);
+static void mo_connect(struct Client *, struct Client *, int, char **);
+static void ms_connect(struct Client *, struct Client *, int, char **);
struct Message connect_msgtab = {
"CONNECT", 0, 0, 2, 0, MFLG_SLOW, 0,
mod_del_cmd(&connect_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_connect - CONNECT command handler
* parv[2] = port number
* parv[3] = remote server
*/
-static void mo_connect(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+static void
+mo_connect(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- int port;
- int tmpport;
- struct ConfItem* aconf;
- struct Client* target_p;
+ int port;
+ int tmpport;
+ struct ConfItem *aconf;
+ struct Client *target_p;
/* always privileged with handlers */
if (MyConnect(source_p) && !IsOperRemote(source_p) && parc > 3)
- {
- sendto_one(source_p,":%s NOTICE %s :You need remote = yes;", me.name, parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need remote = yes;", me.name,
+ parv[0]);
+ return;
+ }
if (hunt_server(client_p, source_p,
":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME)
- {
- return;
- }
+ {
+ return;
+ }
if (*parv[1] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "CONNECT");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "CONNECT");
+ return;
+ }
if ((target_p = find_server(parv[1])))
- {
- sendto_one(source_p, ":%s NOTICE %s :Connect: Server %s already exists from %s.",
- me.name, parv[0], parv[1],
- target_p->from->name);
- return;
- }
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Connect: Server %s already exists from %s.",
+ me.name, parv[0], parv[1], target_p->from->name);
+ return;
+ }
/*
* try to find the name, then host, if both fail notify ops and bail
*/
if (!(aconf = find_conf_by_name(parv[1], CONF_SERVER)))
+ {
+ if (!(aconf = find_conf_by_host(parv[1], CONF_SERVER)))
{
- if (!(aconf = find_conf_by_host(parv[1], CONF_SERVER)))
- {
- sendto_one(source_p,
- "NOTICE %s :Connect: Host %s not listed in ircd.conf",
- parv[0], parv[1]);
- return;
- }
+ sendto_one(source_p,
+ "NOTICE %s :Connect: Host %s not listed in ircd.conf",
+ parv[0], parv[1]);
+ return;
}
+ }
assert(0 != aconf);
/*
* Get port number from user, if given. If not specified,
*/
tmpport = port = aconf->port;
if (parc > 2 && !EmptyString(parv[2]))
+ {
+ if ((port = atoi(parv[2])) <= 0)
{
- if ((port = atoi(parv[2])) <= 0)
- {
- sendto_one(source_p, "NOTICE %s :Connect: Illegal port number",
- parv[0]);
- return;
- }
- }
- else if (port <= 0 && (port = PORTNUM) <= 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :Connect: missing port number",
- me.name, parv[0]);
+ sendto_one(source_p, "NOTICE %s :Connect: Illegal port number",
+ parv[0]);
return;
}
+ }
+ else if (port <= 0 && (port = PORTNUM) <= 0)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Connect: missing port number",
+ me.name, parv[0]);
+ return;
+ }
/*
* Notify all operators about remote connect requests
*/
- ilog(L_TRACE, "CONNECT From %s : %s %s",
+ ilog(L_TRACE, "CONNECT From %s : %s %s",
parv[0], parv[1], parv[2] ? parv[2] : "");
aconf->port = port;
* C:line and a valid port in the C:line
*/
if (serv_connect(aconf, source_p))
- {
- if (IsOperAdmin(source_p))
- sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s[%s].%d",
- me.name, parv[0], aconf->host, aconf->name, aconf->port);
- else
- sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s.%d",
- me.name, parv[0], aconf->name, aconf->port);
+ {
+ if (IsOperAdmin(source_p))
+ sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s[%s].%d",
+ me.name, parv[0], aconf->host, aconf->name, aconf->port);
+ else
+ sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s.%d",
+ me.name, parv[0], aconf->name, aconf->port);
- }
+ }
else
- {
- sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d",
- me.name, parv[0], aconf->name,aconf->port);
+ {
+ sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d",
+ me.name, parv[0], aconf->name, aconf->port);
- }
+ }
/*
* client is either connecting with all the data it needs or has been
* destroyed
* parv[2] = port number
* parv[3] = remote server
*/
-static void ms_connect(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+static void
+ms_connect(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- int port;
- int tmpport;
- struct ConfItem* aconf;
- struct Client* target_p;
+ int port;
+ int tmpport;
+ struct ConfItem *aconf;
+ struct Client *target_p;
if (hunt_server(client_p, source_p,
":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME)
- {
- return;
- }
+ {
+ return;
+ }
if (*parv[1] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "CONNECT");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "CONNECT");
+ return;
+ }
if ((target_p = find_server(parv[1])))
- {
- sendto_one(source_p, ":%s NOTICE %s :Connect: Server %s %s %s.",
- me.name, parv[0], parv[1], "already exists from",
- target_p->from->name);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Connect: Server %s %s %s.",
+ me.name, parv[0], parv[1], "already exists from",
+ target_p->from->name);
+ return;
+ }
/*
* try to find the name, then host, if both fail notify ops and bail
*/
- if (!(aconf = find_conf_by_name(parv[1], CONF_SERVER))) {
- if (!(aconf = find_conf_by_host(parv[1], CONF_SERVER))) {
+ if (!(aconf = find_conf_by_name(parv[1], CONF_SERVER)))
+ {
+ if (!(aconf = find_conf_by_host(parv[1], CONF_SERVER)))
+ {
sendto_one(source_p,
":%s NOTICE %s :Connect: Host %s not listed in ircd.conf",
me.name, parv[0], parv[1]);
*/
tmpport = port = aconf->port;
if (parc > 2 && !EmptyString(parv[2]))
- {
- port = atoi(parv[2]);
+ {
+ port = atoi(parv[2]);
- /* if someone sends port 0, and we have a config port.. use it */
- if(port == 0 && aconf->port)
- port = aconf->port;
- else if(port <= 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :Connect: Illegal port number",
- me.name, parv[0]);
- return;
- }
- }
- else if (port <= 0 && (port = PORTNUM) <= 0)
+ /* if someone sends port 0, and we have a config port.. use it */
+ if (port == 0 && aconf->port)
+ port = aconf->port;
+ else if (port <= 0)
{
- sendto_one(source_p, ":%s NOTICE %s :Connect: missing port number",
+ sendto_one(source_p, ":%s NOTICE %s :Connect: Illegal port number",
me.name, parv[0]);
return;
}
+ }
+ else if (port <= 0 && (port = PORTNUM) <= 0)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Connect: missing port number",
+ me.name, parv[0]);
+ return;
+ }
/*
* Notify all operators about remote connect requests
*/
sendto_wallops_flags(FLAGS_WALLOP, &me,
- "Remote CONNECT %s %d from %s",
- parv[1], port,
- get_client_name(source_p, MASK_IP));
+ "Remote CONNECT %s %d from %s",
+ parv[1], port, get_client_name(source_p, MASK_IP));
sendto_server(NULL, NULL, NULL, NOCAPS, NOCAPS, NOFLAGS,
":%s WALLOPS :Remote CONNECT %s %d from %s",
- me.name, parv[1], port,
- get_client_name(source_p, MASK_IP));
+ me.name, parv[1], port, get_client_name(source_p, MASK_IP));
- ilog(L_TRACE, "CONNECT From %s : %s %d",
- parv[0], parv[1], port);
+ ilog(L_TRACE, "CONNECT From %s : %s %d", parv[0], parv[1], port);
aconf->port = port;
/*
*/
if (serv_connect(aconf, source_p))
sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s.%d",
- me.name, parv[0], aconf->name, aconf->port);
+ me.name, parv[0], aconf->name, aconf->port);
else
- sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d",
- me.name, parv[0], aconf->name,aconf->port);
+ sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d",
+ me.name, parv[0], aconf->name, aconf->port);
/*
* client is either connecting with all the data it needs or has been
* destroyed
*/
aconf->port = tmpport;
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_cryptlink.c,v 1.1 2002/01/04 09:13:16 a1kmm Exp $
+ * $Id: m_cryptlink.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
/*
#include <assert.h>
#include "handlers.h"
-#include "client.h" /* client struct */
-#include "ircd.h" /* me */
+#include "client.h" /* client struct */
+#include "ircd.h" /* me */
#include "modules.h"
-#include "numeric.h" /* ERR_xxx */
-#include "send.h" /* sendto_one */
+#include "numeric.h" /* ERR_xxx */
+#include "send.h" /* sendto_one */
#ifdef HAVE_LIBCRYPTO
#include <openssl/rsa.h>
#include "msg.h"
#include "parse.h"
-#include "irc_string.h" /* strncpy_irc */
+#include "irc_string.h" /* strncpy_irc */
#include "tools.h"
#include "memory.h"
-#include "common.h" /* TRUE bleah */
+#include "common.h" /* TRUE bleah */
#include "event.h"
-#include "hash.h" /* add_to_client_hash_table */
+#include "hash.h" /* add_to_client_hash_table */
#include "md5.h"
-#include "list.h" /* make_server */
-#include "s_conf.h" /* struct ConfItem */
+#include "list.h" /* make_server */
+#include "s_conf.h" /* struct ConfItem */
-#include "s_log.h" /* log level defines */
-#include "s_serv.h" /* server_estab, check_server, my_name_for_link */
-#include "s_stats.h" /* ServerStats */
-#include "scache.h" /* find_or_add */
+#include "s_log.h" /* log level defines */
+#include "s_serv.h" /* server_estab, check_server, my_name_for_link */
+#include "s_stats.h" /* ServerStats */
+#include "scache.h" /* find_or_add */
#include "motd.h"
#ifndef HAVE_LIBCRYPTO
#ifndef STATIC_MODULES
/* XXX - print error? */
-void _modinit(void) {}
-void _moddeinit(void) {}
+void
+_modinit(void)
+{
+}
+
+void
+_moddeinit(void)
+{
+}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
#else
struct CryptLinkStruct
{
- char *cmd; /* CRYPTLINK <command> to match */
- void (*handler)(); /* Function to call */
+ char *cmd; /* CRYPTLINK <command> to match */
+ void (*handler) (); /* Function to call */
};
-static struct CryptLinkStruct cryptlink_cmd_table[] =
-{
- /* command function */
- { "AUTH", cryptlink_auth, },
- { "SERV", cryptlink_serv, },
+static struct CryptLinkStruct cryptlink_cmd_table[] = {
+ /* command function */
+ {"AUTH", cryptlink_auth,},
+ {"SERV", cryptlink_serv,},
/* End of table */
- { (char *) 0, (void (*)()) 0, }
+ {(char *)0, (void (*)())0,}
};
#ifndef STATIC_MODULES
-void
+void
_modinit(void)
{
mod_add_cmd(&cryptlink_msgtab);
mod_del_cmd(&cryptlink_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
* parv[2] == cipher (eg. BF/256)
* parv[3] == keyphrase
*/
-static void mr_cryptlink(struct Client *client_p,
- struct Client *source_p,
- int parc, char *parv[])
+static void
+mr_cryptlink(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
int i;
* cryptlink_auth - CRYPTLINK AUTH message handler
* parv[1] = secret key
*/
-static void cryptlink_auth(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+cryptlink_auth(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct EncCapability *ecap;
struct ConfItem *aconf;
- int enc_len;
- int len;
+ int enc_len;
+ int len;
char *enc;
char *key;
for (ecap = CipherTable; ecap->name; ecap++)
{
- if ( (!irccmp(ecap->name, parv[2])) &&
- (IsCapableEnc(client_p, ecap->cap)) )
+ if ((!irccmp(ecap->name, parv[2])) && (IsCapableEnc(client_p, ecap->cap)))
{
client_p->localClient->in_cipher = ecap;
break;
return;
}
- if ( verify_private_key() == -1 )
+ if (verify_private_key() == -1)
{
sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "verify_private_key() returned -1. Check log for information.");
+ "verify_private_key() returned -1. Check log for information.");
}
key = MyMalloc(RSA_size(ServerInfo.rsa_private_key));
- len = RSA_private_decrypt( enc_len, (unsigned char *)enc,(unsigned char *)key,
- ServerInfo.rsa_private_key,
- RSA_PKCS1_PADDING );
+ len =
+ RSA_private_decrypt(enc_len, (unsigned char *)enc, (unsigned char *)key,
+ ServerInfo.rsa_private_key, RSA_PKCS1_PADDING);
- if ( len < client_p->localClient->in_cipher->keylen )
+ if (len < client_p->localClient->in_cipher->keylen)
{
report_crypto_errors();
if (len < 0)
{
cryptlink_error(client_p, "AUTH",
- "Decryption failed",
- "Malformed CRYPTLINK AUTH reply");
+ "Decryption failed", "Malformed CRYPTLINK AUTH reply");
}
else
{
if (!aconf)
{
cryptlink_error(client_p, "AUTH",
- "Lost C-line for server",
- "Lost C-line" );
+ "Lost C-line for server", "Lost C-line");
return;
}
if (!(client_p->localClient->out_cipher ||
- (client_p->localClient->out_cipher = check_cipher(client_p, aconf))))
+ (client_p->localClient->out_cipher = check_cipher(client_p, aconf))))
{
cryptlink_error(client_p, "AUTH",
"Couldn't find compatible cipher",
* parv[3] == keyphrase
* parv[4] == :server info (M-line)
*/
-static void cryptlink_serv(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+cryptlink_serv(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char info[REALLEN + 1];
- char *name;
- struct Client *target_p;
- char *key = client_p->localClient->out_key;
- char *b64_key;
+ char info[REALLEN + 1];
+ char *name;
+ struct Client *target_p;
+ char *key = client_p->localClient->out_key;
+ char *b64_key;
struct ConfItem *aconf;
- char *encrypted;
- char *p;
- int enc_len;
+ char *encrypted;
+ char *p;
+ int enc_len;
/*
- if (client_p->name[0] != 0)
- return;
- */
+ if (client_p->name[0] != 0)
+ return;
+ */
- if ( (parc < 5) || (*parv[4] == '\0') )
+ if ((parc < 5) || (*parv[4] == '\0'))
{
cryptlink_error(client_p, "SERV", "Invalid params",
"CRYPTLINK SERV - Invalid params");
return;
}
- if ( (name = parse_cryptserv_args(client_p, parv, parc, info, key)) == NULL )
+ if ((name = parse_cryptserv_args(client_p, parv, parc, info, key)) == NULL)
{
cryptlink_error(client_p, "SERV", "Invalid params",
"CRYPTLINK SERV - Invalid params");
if (ConfigFileEntry.warn_no_nline)
{
cryptlink_error(client_p, "SERV",
- "Unauthorised server connection attempt: No entry for server",
- NULL);
+ "Unauthorised server connection attempt: No entry for server",
+ NULL);
}
exit_client(client_p, client_p, client_p, "Invalid server name");
return;
break;
case -2:
cryptlink_error(client_p, "SERV",
- "Unauthorised server connection attempt: CRYPTLINK not "
- "enabled on remote server",
- "CRYPTLINK not enabled");
+ "Unauthorised server connection attempt: CRYPTLINK not "
+ "enabled on remote server", "CRYPTLINK not enabled");
return;
break;
case -3:
cryptlink_error(client_p, "SERV",
- "Unauthorised server connection attempt: Invalid host",
- "Invalid host");
+ "Unauthorised server connection attempt: Invalid host",
+ "Invalid host");
return;
break;
}
if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
{
- if(IsCapable(client_p, CAP_HUB))
- {
- ClearCap(client_p,CAP_LL);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** LazyLinks to a hub from a hub, thats a no-no.");
- }
- else
+ if (IsCapable(client_p, CAP_HUB))
+ {
+ ClearCap(client_p, CAP_LL);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** LazyLinks to a hub from a hub, thats a no-no.");
+ }
+ else
+ {
+ client_p->localClient->serverMask = nextFreeMask();
+
+ if (!client_p->localClient->serverMask)
{
- client_p->localClient->serverMask = nextFreeMask();
-
- if(!client_p->localClient->serverMask)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "serverMask is full!");
- /* try and negotiate a non LL connect */
- ClearCap(client_p,CAP_LL);
- }
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "serverMask is full!");
+ /* try and negotiate a non LL connect */
+ ClearCap(client_p, CAP_LL);
}
+ }
}
else if (IsCapable(client_p, CAP_LL))
{
- if (!IsCapable(client_p, CAP_HUB))
- {
- ClearCap(client_p,CAP_LL);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** LazyLinks to a leaf from a leaf, thats a no-no.");
- }
+ if (!IsCapable(client_p, CAP_HUB))
+ {
+ ClearCap(client_p, CAP_LL);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** LazyLinks to a leaf from a leaf, thats a no-no.");
+ }
}
- aconf = find_conf_name(&client_p->localClient->confs,
- name, CONF_SERVER);
+ aconf = find_conf_name(&client_p->localClient->confs, name, CONF_SERVER);
if (!aconf)
{
cryptlink_error(client_p, "AUTH",
- "Lost C-line for server",
- "Lost C-line" );
+ "Lost C-line for server", "Lost C-line");
return;
}
p = info;
- if(!strncmp(info, "(H)", 3))
+ if (!strncmp(info, "(H)", 3))
{
client_p->hidden_server = 1;
- if((p = strchr(info, ' ')))
+ if ((p = strchr(info, ' ')))
{
p++;
- if(*p == '\0')
+ if (*p == '\0')
p = "(Unknown Location)";
}
else
client_p->hopcount = 0;
if (!(client_p->localClient->out_cipher ||
- (client_p->localClient->out_cipher = check_cipher(client_p, aconf))))
+ (client_p->localClient->out_cipher = check_cipher(client_p, aconf))))
{
cryptlink_error(client_p, "AUTH",
"Couldn't find compatible cipher",
enc_len = RSA_public_encrypt(client_p->localClient->out_cipher->keylen,
(unsigned char *)key,
(unsigned char *)encrypted,
- aconf->rsa_public_key,
- RSA_PKCS1_PADDING);
+ aconf->rsa_public_key, RSA_PKCS1_PADDING);
if (enc_len <= 0)
{
report_crypto_errors();
MyFree(encrypted);
cryptlink_error(client_p, "AUTH",
- "Couldn't encrypt data",
- "Couldn't encrypt data");
+ "Couldn't encrypt data", "Couldn't encrypt data");
return;
}
}
sendto_one(client_p, "CRYPTLINK AUTH %s %s",
- client_p->localClient->out_cipher->name,
- b64_key);
+ client_p->localClient->out_cipher->name, b64_key);
SetCryptOut(client_p);
MyFree(b64_key);
* output - NULL if invalid params, server name otherwise
* side effects - parv[2] is trimmed to HOSTLEN size if needed.
*/
-static char *parse_cryptserv_args(struct Client *client_p,
- char *parv[], int parc, char *info,
- char *key)
+static char *
+parse_cryptserv_args(struct Client *client_p,
+ char *parv[], int parc, char *info, char *key)
{
char *name;
unsigned char *tmp, *out;
name = parv[2];
/* parv[2] contains encrypted auth data */
- if ( !(decoded_len = unbase64_block((char **)&tmp, parv[3],
- strlen(parv[3]))) )
+ if (!(decoded_len = unbase64_block((char **)&tmp, parv[3],
+ strlen(parv[3]))))
{
- cryptlink_error(client_p, "SERV",
- "Couldn't base64 decode data",
- NULL);
- return(NULL);
+ cryptlink_error(client_p, "SERV", "Couldn't base64 decode data", NULL);
+ return (NULL);
}
if (verify_private_key() == -1)
{
sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "verify_private_key() returned -1. Check log for information.");
+ "verify_private_key() returned -1. Check log for information.");
}
out = MyMalloc(RSA_size(ServerInfo.rsa_private_key));
len = RSA_private_decrypt(decoded_len, tmp, out,
- ServerInfo.rsa_private_key,
- RSA_PKCS1_PADDING );
+ ServerInfo.rsa_private_key, RSA_PKCS1_PADDING);
MyFree(tmp);
cryptlink_error(client_p, "AUTH", "Not enough random data sent", NULL);
}
MyFree(out);
- return(NULL);
+ return (NULL);
}
memcpy(key, out, CIPHERKEYLEN);
name[HOSTLEN] = '\0';
}
- return(name);
+ return (name);
}
/*
* output - 1 if a bogus hostname input, 0 if its valid
* side effects - none
*/
-static int bogus_host(char *host)
+static int
+bogus_host(char *host)
{
int bogus_server = 0;
int dots = 0;
char *s;
- for (s = host; *s; s++ )
+ for (s = host; *s; s++)
{
if (!IsServChar(*s))
{
}
}
- if ( (!dots) || (bogus_server) )
+ if ((!dots) || (bogus_server))
return 1;
return 0;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_dmem.c,v 1.1 2002/01/04 09:13:16 a1kmm Exp $
+ * $Id: m_dmem.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "parse.h"
#include "modules.h"
-static void mo_dmem(struct Client*, struct Client*, int, char**);
+static void mo_dmem(struct Client *, struct Client *, int, char **);
struct Message dmem_msgtab = {
"DMEM", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&dmem_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
#ifdef MEMDEBUG
-void ReportAllocated(struct Client*);
+void ReportAllocated(struct Client *);
#endif
/*
*
*/
static void
-mo_dmem(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
+mo_dmem(struct Client *client_p, struct Client *source_p, int parc,
+ char *parv[])
{
#ifdef MEMDEBUG
if (parc < 2)
log_memory();
#else
sendto_one(source_p, ":%s NOTICE %s :Compiled without memory debugging",
- me.name, source_p->name);
+ me.name, source_p->name);
#endif
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_drop.c,v 1.1 2002/01/04 09:13:16 a1kmm Exp $
+ * $Id: m_drop.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "tools.h"
#include "channel.h"
#include "ircd.h"
#include "list.h"
#include "numeric.h"
-#include "s_serv.h" /* captab */
+#include "s_serv.h" /* captab */
#include "s_user.h"
#include "send.h"
#include "handlers.h"
#include <string.h>
#include <stdlib.h>
-static void ms_drop(struct Client *,struct Client *,int,char **);
+static void ms_drop(struct Client *, struct Client *, int, char **);
struct Message drop_msgtab = {
"DROP", 0, 0, 2, 0, MFLG_SLOW | MFLG_UNREG, 0L,
mod_del_cmd(&drop_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** ms_drop
**
** "drop" a channel from consideration on a lazy link
*/
-static void ms_drop(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_drop(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
char *name;
struct Channel *chptr;
- if(parc < 2 || *parv[1] == '\0')
+ if (parc < 2 || *parv[1] == '\0')
return;
name = parv[1];
#ifdef DEBUGLL
- sendto_realops(FLAGS_ALL, "DROP called by %s for %s", client_p->name, name );
+ sendto_realops(FLAGS_ALL, "DROP called by %s for %s", client_p->name, name);
#endif
- if((chptr=hash_find_channel(name)) == NULL)
+ if ((chptr = hash_find_channel(name)) == NULL)
return;
- if(client_p->localClient->serverMask) /* JIC */
+ if (client_p->localClient->serverMask) /* JIC */
chptr->lazyLinkChannelExists &= ~client_p->localClient->serverMask;
return;
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_eob.c,v 1.1 2002/01/04 09:13:16 a1kmm Exp $
+ * $Id: m_eob.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "modules.h"
#include <stdlib.h>
-static void ms_eob(struct Client*, struct Client*, int, char**);
+static void ms_eob(struct Client *, struct Client *, int, char **);
struct Message eob_msgtab = {
- "EOB", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
+ "EOB", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
{m_unregistered, m_ignore, ms_eob, m_ignore}
};
#ifndef STATIC_MODULES
mod_del_cmd(&eob_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* ms_eob - EOB command handler
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void ms_eob(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_eob(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "End of burst from %s (%d seconds)",
- source_p->name,
- (signed int)(CurrentTime - source_p->firsttime));
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "End of burst from %s (%d seconds)",
+ source_p->name,
+ (signed int)(CurrentTime - source_p->firsttime));
- SetEob(client_p);
+ SetEob(client_p);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_gline.c,v 1.1 2002/01/04 09:13:16 a1kmm Exp $
+ * $Id: m_gline.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include <assert.h>
#include "list.h"
/* internal functions */
-static void set_local_gline(
- const char *oper_nick,
+static void set_local_gline(const char *oper_nick,
const char *oper_user,
const char *oper_host,
const char *oper_server,
const char *user,
- const char *host,
- const char *reason);
+ const char *host, const char *reason);
-static void log_gline_request(const char*,const char*,const char*,
- const char* oper_server,
- const char *,const char *,const char *);
+static void log_gline_request(const char *, const char *, const char *,
+ const char *oper_server,
+ const char *, const char *, const char *);
-static void log_gline(struct Client *,struct gline_pending *,
- const char *, const char *,const char *,
- const char* oper_server,
- const char *,const char *,const char *);
+static void log_gline(struct Client *, struct gline_pending *,
+ const char *, const char *, const char *,
+ const char *oper_server,
+ const char *, const char *, const char *);
static void check_majority_gline(struct Client *source_p,
static int majority_gline(struct Client *source_p,
const char *oper_nick, const char *oper_username,
- const char *oper_host,
+ const char *oper_host,
const char *oper_server,
const char *user,
- const char *host,
- const char *reason);
+ const char *host, const char *reason);
static void add_new_majority_gline(const char *, const char *, const char *,
const char *, const char *, const char *,
static int check_wild_gline(char *, char *);
static int invalid_gline(struct Client *, char *, char *, char *);
-
-static void ms_gline(struct Client*, struct Client*, int, char**);
-static void mo_gline(struct Client*, struct Client*, int, char**);
+
+static void ms_gline(struct Client *, struct Client *, int, char **);
+static void mo_gline(struct Client *, struct Client *, int, char **);
struct Message gline_msgtab = {
- "GLINE", 0, 0, 3, 0, MFLG_SLOW, 0,
- {m_unregistered, m_not_oper, ms_gline, mo_gline}
+ "GLINE", 0, 0, 3, 0, MFLG_SLOW, 0,
+ {m_unregistered, m_not_oper, ms_gline, mo_gline}
};
#ifndef STATIC_MODULES
void
_modinit(void)
{
- mod_add_cmd(&gline_msgtab);
+ mod_add_cmd(&gline_msgtab);
}
void
mod_del_cmd(&gline_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_gline()
*
*/
-static void mo_gline(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+mo_gline(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
char *user = NULL;
- char *host = NULL; /* user and host of GLINE "victim" */
- const char *reason = NULL; /* reason for "victims" demise */
+ char *host = NULL; /* user and host of GLINE "victim" */
+ const char *reason = NULL; /* reason for "victims" demise */
char tempuser[USERLEN + 2];
char temphost[HOSTLEN + 1];
if (ConfigFileEntry.glines)
+ {
+ if (!IsOperGline(source_p))
{
- if (!IsOperGline(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You need gline = yes;",me.name,parv[0]);
- return;
- }
-
- if ( (host = strchr(parv[1], '@')) || *parv[1] == '*' )
- {
- /* Explicit user@host mask given */
-
- if(host) /* Found user@host */
- {
- user = parv[1]; /* here is user part */
- *(host++) = '\0'; /* and now here is host */
- }
- else
- {
- user = "*"; /* no @ found, assume its *@somehost */
- host = parv[1];
- }
-
- if (!*host) /* duh. no host found, assume its '*' host */
- host = "*";
-
- strncpy_irc(tempuser, user, USERLEN + 1); /* allow for '*' */
- tempuser[USERLEN + 1] = '\0';
- strncpy_irc(temphost, host, HOSTLEN);
- temphost[HOSTLEN] = '\0';
- user = tempuser;
- host = temphost;
- }
- else
- {
- sendto_one(source_p, ":%s NOTICE %s :Can't G-Line a nick use user@host",
- me.name,
- parv[0]);
- return;
- }
-
- if(invalid_gline(source_p, user, host, parv[2]))
- return;
-
- /* Not enough non-wild characters were found, assume they are trying to gline *@*. */
- if (check_wild_gline(user, host))
- {
- if (MyClient(source_p))
- sendto_one(source_p,
- ":%s NOTICE %s :Please include at least %d non-wildcard characters with the user@host",
- me.name, parv[0], ConfigFileEntry.min_nonwildcard);
- return;
- }
-
- reason = parv[2];
-
- /* If at least 3 opers agree this user should be G lined then do it */
-
- check_majority_gline(source_p,
- source_p->name,
- (const char *)source_p->username,
- source_p->host,
- me.name,
- user,
- host,
- reason);
-
- /* 4 param version for hyb-7 servers */
- sendto_server(NULL, source_p, NULL, CAP_GLN|CAP_UID, NOCAPS,
- LL_ICLIENT,
- ":%s GLINE %s %s :%s",
- ID(source_p),
- user,
- host,
- reason);
- sendto_server(NULL, source_p, NULL, CAP_GLN, CAP_UID,
- LL_ICLIENT,
- ":%s GLINE %s %s :%s",
- source_p->name,
- user,
- host,
- reason);
-
- /* 8 param for hyb-6 */
- sendto_server(NULL, NULL, NULL, CAP_UID, CAP_GLN, NOFLAGS,
- ":%s GLINE %s %s %s %s %s %s :%s",
- me.name, ID(source_p), source_p->username,
- source_p->host, source_p->user->server, user, host,
- reason);
- sendto_server(NULL, NULL, NULL, NOCAPS, CAP_GLN|CAP_UID, NOFLAGS,
- ":%s GLINE %s %s %s %s %s %s :%s",
- me.name, source_p->name, source_p->username,
- source_p->host, source_p->user->server, user, host,
- reason);
+ sendto_one(source_p, ":%s NOTICE %s :You need gline = yes;", me.name,
+ parv[0]);
+ return;
+ }
+ if ((host = strchr(parv[1], '@')) || *parv[1] == '*')
+ {
+ /* Explicit user@host mask given */
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s!%s@%s on %s is requesting gline for [%s@%s] [%s]",
- source_p->name,
- source_p->username,
- source_p->host,
- me.name,
- user,
- host,
- reason);
- log_gline_request(source_p->name,
- (const char *)source_p->username,
- source_p->host,me.name,
- user,host,reason);
+ if (host) /* Found user@host */
+ {
+ user = parv[1]; /* here is user part */
+ *(host++) = '\0'; /* and now here is host */
+ }
+ else
+ {
+ user = "*"; /* no @ found, assume its *@somehost */
+ host = parv[1];
+ }
+
+ if (!*host) /* duh. no host found, assume its '*' host */
+ host = "*";
+
+ strncpy_irc(tempuser, user, USERLEN + 1); /* allow for '*' */
+ tempuser[USERLEN + 1] = '\0';
+ strncpy_irc(temphost, host, HOSTLEN);
+ temphost[HOSTLEN] = '\0';
+ user = tempuser;
+ host = temphost;
}
- else
+ else
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Can't G-Line a nick use user@host",
+ me.name, parv[0]);
+ return;
+ }
+
+ if (invalid_gline(source_p, user, host, parv[2]))
+ return;
+
+ /* Not enough non-wild characters were found, assume they are trying to gline *@*. */
+ if (check_wild_gline(user, host))
{
- sendto_one(source_p,":%s NOTICE %s :GLINE disabled",me.name,parv[0]);
+ if (MyClient(source_p))
+ sendto_one(source_p,
+ ":%s NOTICE %s :Please include at least %d non-wildcard characters with the user@host",
+ me.name, parv[0], ConfigFileEntry.min_nonwildcard);
+ return;
}
+
+ reason = parv[2];
+
+ /* If at least 3 opers agree this user should be G lined then do it */
+
+ check_majority_gline(source_p,
+ source_p->name,
+ (const char *)source_p->username,
+ source_p->host, me.name, user, host, reason);
+
+ /* 4 param version for hyb-7 servers */
+ sendto_server(NULL, source_p, NULL, CAP_GLN | CAP_UID, NOCAPS,
+ LL_ICLIENT,
+ ":%s GLINE %s %s :%s", ID(source_p), user, host, reason);
+ sendto_server(NULL, source_p, NULL, CAP_GLN, CAP_UID,
+ LL_ICLIENT,
+ ":%s GLINE %s %s :%s", source_p->name, user, host, reason);
+
+ /* 8 param for hyb-6 */
+ sendto_server(NULL, NULL, NULL, CAP_UID, CAP_GLN, NOFLAGS,
+ ":%s GLINE %s %s %s %s %s %s :%s",
+ me.name, ID(source_p), source_p->username,
+ source_p->host, source_p->user->server, user, host, reason);
+ sendto_server(NULL, NULL, NULL, NOCAPS, CAP_GLN | CAP_UID, NOFLAGS,
+ ":%s GLINE %s %s %s %s %s %s :%s",
+ me.name, source_p->name, source_p->username,
+ source_p->host, source_p->user->server, user, host, reason);
+
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s!%s@%s on %s is requesting gline for [%s@%s] [%s]",
+ source_p->name,
+ source_p->username,
+ source_p->host, me.name, user, host, reason);
+ log_gline_request(source_p->name,
+ (const char *)source_p->username,
+ source_p->host, me.name, user, host, reason);
+ }
+ else
+ {
+ sendto_one(source_p, ":%s NOTICE %s :GLINE disabled", me.name, parv[0]);
+ }
}
/*
* GLINES is not defined.
*/
-static void ms_gline(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_gline(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
/* These are needed for hyb6 compatibility.. if its ever removed we can
* just use source_p->username etc..
*/
- const char *oper_nick = NULL; /* nick of oper requesting GLINE */
- const char *oper_user = NULL; /* username of oper requesting GLINE */
- const char *oper_host = NULL; /* hostname of oper requesting GLINE */
- const char *oper_server = NULL; /* server of oper requesting GLINE */
+ const char *oper_nick = NULL; /* nick of oper requesting GLINE */
+ const char *oper_user = NULL; /* username of oper requesting GLINE */
+ const char *oper_host = NULL; /* hostname of oper requesting GLINE */
+ const char *oper_server = NULL; /* server of oper requesting GLINE */
char *user = NULL;
- char *host = NULL; /* user and host of GLINE "victim" */
- const char *reason = NULL; /* reason for "victims" demise */
+ char *host = NULL; /* user and host of GLINE "victim" */
+ const char *reason = NULL; /* reason for "victims" demise */
struct Client *acptr;
/* hyb-7 style gline (post beta3) */
- if(parc == 4 && IsPerson(source_p))
- {
- oper_nick = parv[0];
- oper_user = source_p->username;
- oper_host = source_p->host;
- oper_server = source_p->user->server;
- user = parv[1];
- host = parv[2];
- reason = parv[3];
- }
+ if (parc == 4 && IsPerson(source_p))
+ {
+ oper_nick = parv[0];
+ oper_user = source_p->username;
+ oper_host = source_p->host;
+ oper_server = source_p->user->server;
+ user = parv[1];
+ host = parv[2];
+ reason = parv[3];
+ }
/* or it's a hyb-6 style */
- else if(parc == 8 && IsServer(source_p))
- {
- oper_nick = parv[1];
- oper_user = parv[2];
- oper_host = parv[3];
- oper_server = parv[4];
- user = parv[5];
- host = parv[6];
- reason = parv[7];
- }
+ else if (parc == 8 && IsServer(source_p))
+ {
+ oper_nick = parv[1];
+ oper_user = parv[2];
+ oper_host = parv[3];
+ oper_server = parv[4];
+ user = parv[5];
+ host = parv[6];
+ reason = parv[7];
+ }
/* none of the above */
else
return;
* and its faked, as the oper isnt sending the gline..
* check they're real --fl_ */
/* we need acptr for LL introduction anyway -davidt */
- if((acptr = find_server(oper_server)))
+ if ((acptr = find_server(oper_server)))
{
- if((acptr = find_client(oper_nick)) == NULL)
+ if ((acptr = find_client(oper_nick)) == NULL)
return;
}
else
return;
- if(invalid_gline(acptr, user, host, (char *)reason))
+ if (invalid_gline(acptr, user, host, (char *)reason))
return;
-
+
/* send in hyb-7 to compatable servers */
sendto_server(client_p, acptr, NULL, CAP_GLN, NOCAPS, LL_ICLIENT,
- ":%s GLINE %s %s :%s",
- oper_nick,
- user,
- host,
- reason);
+ ":%s GLINE %s %s :%s", oper_nick, user, host, reason);
/* hyb-6 version to the rest */
sendto_server(client_p, NULL, NULL, NOCAPS, CAP_GLN, NOFLAGS,
":%s GLINE %s %s %s %s %s %s :%s",
oper_server, user, host, reason);
if (ConfigFileEntry.glines)
+ {
+ /* I dont like the idea of checking for x non-wildcard chars in a
+ * gline.. it could lead to a desync... but we have to stop people
+ * glining *@*.. -- fl */
+ if (check_wild_gline(user, host))
{
- /* I dont like the idea of checking for x non-wildcard chars in a
- * gline.. it could lead to a desync... but we have to stop people
- * glining *@*.. -- fl */
- if (check_wild_gline(user, host))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s!%s@%s on %s is requesting a gline without %d non-wildcard characters for [%s@%s] [%s]",
- oper_nick, oper_user, oper_host, oper_server, ConfigFileEntry.min_nonwildcard,
- user, host, reason);
- return;
- }
-
- log_gline_request(oper_nick,oper_user,oper_host,oper_server,
- user,host,reason);
-
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s!%s@%s on %s is requesting gline for [%s@%s] [%s]",
- oper_nick,
- oper_user,
- oper_host,
- oper_server,
- user,
- host,
- reason);
-
- /* If at least 3 opers agree this user should be G lined then do it */
- check_majority_gline(source_p,
- oper_nick,
- oper_user,
- oper_host,
- oper_server,
- user,
- host,
- reason);
+ "%s!%s@%s on %s is requesting a gline without %d non-wildcard characters for [%s@%s] [%s]",
+ oper_nick, oper_user, oper_host, oper_server,
+ ConfigFileEntry.min_nonwildcard, user, host,
+ reason);
+ return;
}
+
+ log_gline_request(oper_nick, oper_user, oper_host, oper_server,
+ user, host, reason);
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s!%s@%s on %s is requesting gline for [%s@%s] [%s]",
+ oper_nick,
+ oper_user,
+ oper_host, oper_server, user, host, reason);
+
+ /* If at least 3 opers agree this user should be G lined then do it */
+ check_majority_gline(source_p,
+ oper_nick,
+ oper_user,
+ oper_host, oper_server, user, host, reason);
+ }
}
/*
p = user;
while ((tmpch = *p++))
+ {
+ if (!IsKWildChar(tmpch))
{
- if (!IsKWildChar(tmpch))
- {
- /*
- * If we find enough non-wild characters, we can
- * break - no point in searching further.
- */
- if (++nonwild >= ConfigFileEntry.min_nonwildcard)
- break;
- }
+ /*
+ * If we find enough non-wild characters, we can
+ * break - no point in searching further.
+ */
+ if (++nonwild >= ConfigFileEntry.min_nonwildcard)
+ break;
}
+ }
- if (nonwild < ConfigFileEntry.min_nonwildcard)
+ if (nonwild < ConfigFileEntry.min_nonwildcard)
+ {
+ /*
+ * The user portion did not contain enough non-wild
+ * characters, try the host.
+ */
+ p = host;
+ while ((tmpch = *p++))
{
- /*
- * The user portion did not contain enough non-wild
- * characters, try the host.
- */
- p = host;
- while ((tmpch = *p++))
- {
- if (!IsKWildChar(tmpch))
- if (++nonwild >= ConfigFileEntry.min_nonwildcard)
- break;
- }
- }
-
- if (nonwild < ConfigFileEntry.min_nonwildcard)
- return 1;
- else
- return 0;
+ if (!IsKWildChar(tmpch))
+ if (++nonwild >= ConfigFileEntry.min_nonwildcard)
+ break;
+ }
+ }
+
+ if (nonwild < ConfigFileEntry.min_nonwildcard)
+ return 1;
+ else
+ return 0;
}
/* invalid_gline
* - pointer to reason
* outputs - 1 if invalid, 0 if valid
*/
-static int invalid_gline(struct Client *source_p, char *luser, char *lhost,
- char *lreason)
+static int
+invalid_gline(struct Client *source_p, char *luser, char *lhost,
+ char *lreason)
{
- if(strchr(luser, '!'))
+ if (strchr(luser, '!'))
{
sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in gline",
me.name, source_p->name);
*/
static void
check_majority_gline(struct Client *source_p,
- const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char *oper_server,
- const char *user,
- const char *host,
- const char *reason)
+ const char *oper_nick,
+ const char *oper_user,
+ const char *oper_host,
+ const char *oper_server,
+ const char *user, const char *host, const char *reason)
{
- if(majority_gline(source_p,oper_nick,oper_user, oper_host,
- oper_server, user, host, reason))
+ if (majority_gline(source_p, oper_nick, oper_user, oper_host,
+ oper_server, user, host, reason))
{
- set_local_gline(oper_nick,oper_user,oper_host,oper_server,
- user,host,reason);
+ set_local_gline(oper_nick, oper_user, oper_host, oper_server,
+ user, host, reason);
cleanup_glines();
}
}
* output - NONE
* side effects -
*/
-static void set_local_gline(const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char *oper_server,
- const char *user,
- const char *host,
- const char *reason)
+static void
+set_local_gline(const char *oper_nick,
+ const char *oper_user,
+ const char *oper_host,
+ const char *oper_server,
+ const char *user, const char *host, const char *reason)
{
char buffer[IRCD_BUFSIZE];
struct ConfItem *aconf;
const char *current_date;
current_date = smalldate((time_t) 0);
-
+
aconf = make_conf();
aconf->status = CONF_KILL;
DupString(aconf->host, host);
- ircsprintf(buffer, "%s (%s)",reason,current_date);
-
+ ircsprintf(buffer, "%s (%s)", reason, current_date);
+
DupString(aconf->passwd, buffer);
DupString(aconf->name, (char *)user);
DupString(aconf->host, (char *)host);
aconf->hold = CurrentTime + ConfigFileEntry.gline_time;
add_gline(aconf);
-
+
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s!%s@%s on %s has triggered gline for [%s@%s] [%s]",
- oper_nick,
- oper_user,
- oper_host,
- oper_server,
- user,
- host,
- reason);
+ "%s!%s@%s on %s has triggered gline for [%s@%s] [%s]",
+ oper_nick,
+ oper_user, oper_host, oper_server, user, host, reason);
check_klines();
}
*
*/
static void
-log_gline_request(
- const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char* oper_server,
- const char *user,
- const char *host,
- const char *reason)
+log_gline_request(const char *oper_nick,
+ const char *oper_user,
+ const char *oper_host,
+ const char *oper_server,
+ const char *user, const char *host, const char *reason)
{
- char buffer[2*BUFSIZE];
- char filenamebuf[PATH_MAX + 1];
+ char buffer[2 * BUFSIZE];
+ char filenamebuf[PATH_MAX + 1];
static char timebuffer[MAX_DATE_STRING];
- struct tm* tmptr;
- FBFILE* out;
+ struct tm *tmptr;
+ FBFILE *out;
- if(ConfigFileEntry.glinefile == NULL)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem opening glinefile");
- return;
- }
+ if (ConfigFileEntry.glinefile == NULL)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem opening glinefile");
+ return;
+ }
- ircsprintf(filenamebuf, "%s.%s",
- ConfigFileEntry.glinefile, small_file_date((time_t)0));
- if ( (out = fbopen(filenamebuf, "+a")) == NULL )
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem opening %s: %s",
- filenamebuf, strerror(errno));
- return;
- }
+ ircsprintf(filenamebuf, "%s.%s",
+ ConfigFileEntry.glinefile, small_file_date((time_t) 0));
+ if ((out = fbopen(filenamebuf, "+a")) == NULL)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem opening %s: %s",
+ filenamebuf, strerror(errno));
+ return;
+ }
tmptr = localtime(&CurrentTime);
strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
ircsprintf(buffer,
- "#Gline for %s@%s [%s] requested by %s!%s@%s on %s at %s\n",
- user,host,reason,
- oper_nick,oper_user,oper_host,oper_server,
- timebuffer);
+ "#Gline for %s@%s [%s] requested by %s!%s@%s on %s at %s\n",
+ user, host, reason,
+ oper_nick, oper_user, oper_host, oper_server, timebuffer);
if (fbputs(buffer, out) == -1)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem writing to %s (%s)",
- filenamebuf, strerror(errno));
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem writing to %s (%s)",
+ filenamebuf, strerror(errno));
+ }
fbclose(out);
}
*/
static void
log_gline(struct Client *source_p,
- struct gline_pending *gline_pending_ptr,
- const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char *oper_server,
- const char *user,
- const char *host,
- const char *reason)
+ struct gline_pending *gline_pending_ptr,
+ const char *oper_nick,
+ const char *oper_user,
+ const char *oper_host,
+ const char *oper_server,
+ const char *user, const char *host, const char *reason)
{
- char buffer[2*BUFSIZE];
- char filenamebuf[PATH_MAX + 1];
- static char timebuffer[MAX_DATE_STRING + 1];
- struct tm* tmptr;
- FBFILE *out;
+ char buffer[2 * BUFSIZE];
+ char filenamebuf[PATH_MAX + 1];
+ static char timebuffer[MAX_DATE_STRING + 1];
+ struct tm *tmptr;
+ FBFILE *out;
- if(ConfigFileEntry.glinefile == NULL)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem opening glinefile.");
- return;
- }
+ if (ConfigFileEntry.glinefile == NULL)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem opening glinefile.");
+ return;
+ }
- ircsprintf(filenamebuf, "%s.%s",
- ConfigFileEntry.glinefile, small_file_date((time_t) 0));
+ ircsprintf(filenamebuf, "%s.%s",
+ ConfigFileEntry.glinefile, small_file_date((time_t) 0));
if ((out = fbopen(filenamebuf, "a")) == NULL)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem opening %s",filenamebuf);
- return;
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem opening %s",
+ filenamebuf);
+ return;
+ }
tmptr = localtime(&CurrentTime);
strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
- ircsprintf(buffer,"#Gline for %s@%s %s added by the following\n",
- user,host,timebuffer);
+ ircsprintf(buffer, "#Gline for %s@%s %s added by the following\n",
+ user, host, timebuffer);
- if (fbputs(buffer,out) == -1)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem writing to %s",filenamebuf);
- fbclose(out);
- return;
- }
+ if (fbputs(buffer, out) == -1)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem writing to %s",
+ filenamebuf);
+ fbclose(out);
+ return;
+ }
ircsprintf(buffer, "#%s!%s@%s on %s [%s]\n",
- gline_pending_ptr->oper_nick1,
- gline_pending_ptr->oper_user1,
- gline_pending_ptr->oper_host1,
- gline_pending_ptr->oper_server1,
- (gline_pending_ptr->reason1)?
- (gline_pending_ptr->reason1):"No reason");
-
- if (fbputs(buffer,out) == -1)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem writing to %s",filenamebuf);
- return;
- }
+ gline_pending_ptr->oper_nick1,
+ gline_pending_ptr->oper_user1,
+ gline_pending_ptr->oper_host1,
+ gline_pending_ptr->oper_server1,
+ (gline_pending_ptr->reason1) ?
+ (gline_pending_ptr->reason1) : "No reason");
+
+ if (fbputs(buffer, out) == -1)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem writing to %s",
+ filenamebuf);
+ return;
+ }
ircsprintf(buffer, "#%s!%s@%s on %s [%s]\n",
- gline_pending_ptr->oper_nick2,
- gline_pending_ptr->oper_user2,
- gline_pending_ptr->oper_host2,
- gline_pending_ptr->oper_server2,
- (gline_pending_ptr->reason2)?
- (gline_pending_ptr->reason2):"No reason");
-
- if (fbputs(buffer,out) == -1)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem writing to %s",filenamebuf);
- fbclose(out);
- return;
- }
+ gline_pending_ptr->oper_nick2,
+ gline_pending_ptr->oper_user2,
+ gline_pending_ptr->oper_host2,
+ gline_pending_ptr->oper_server2,
+ (gline_pending_ptr->reason2) ?
+ (gline_pending_ptr->reason2) : "No reason");
+
+ if (fbputs(buffer, out) == -1)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem writing to %s",
+ filenamebuf);
+ fbclose(out);
+ return;
+ }
ircsprintf(buffer, "#%s!%s@%s on %s [%s]\n",
- oper_nick,
- oper_user,
- oper_host,
- oper_server,
- (reason)?reason:"No reason");
+ oper_nick,
+ oper_user,
+ oper_host, oper_server, (reason) ? reason : "No reason");
- if (fbputs(buffer,out) == -1)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem writing to %s",filenamebuf);
- fbclose(out);
- return;
- }
+ if (fbputs(buffer, out) == -1)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem writing to %s",
+ filenamebuf);
+ fbclose(out);
+ return;
+ }
ircsprintf(buffer, "\"%s\",\"%s\",\"%s %s\",\"%s\",%lu\n",
- user,
- host,
- reason,
- timebuffer,
- oper_nick,
- (unsigned long) CurrentTime);
-
- if (fbputs(buffer,out) == -1)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"*** Problem writing to %s",filenamebuf);
- fbclose(out);
- return;
- }
+ user,
+ host, reason, timebuffer, oper_nick, (unsigned long)CurrentTime);
+
+ if (fbputs(buffer, out) == -1)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "*** Problem writing to %s",
+ filenamebuf);
+ fbclose(out);
+ return;
+ }
fbclose(out);
}
*
*/
static void
-add_new_majority_gline(const char* oper_nick,
- const char* oper_user,
- const char* oper_host,
- const char* oper_server,
- const char* user,
- const char* host,
- const char* reason)
+add_new_majority_gline(const char *oper_nick,
+ const char *oper_user,
+ const char *oper_host,
+ const char *oper_server,
+ const char *user, const char *host, const char *reason)
{
dlink_node *pending_node;
- struct gline_pending *pending = (struct gline_pending*)
+ struct gline_pending *pending = (struct gline_pending *)
MyMalloc(sizeof(struct gline_pending));
strncpy_irc(pending->oper_nick1, oper_nick, NICKLEN);
*/
static int
majority_gline(struct Client *source_p,
- const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char* oper_server,
- const char *user,
- const char *host,
- const char *reason)
+ const char *oper_nick,
+ const char *oper_user,
+ const char *oper_host,
+ const char *oper_server,
+ const char *user, const char *host, const char *reason)
{
dlink_node *pending_node;
struct gline_pending *gline_pending_ptr;
/* if its already glined, why bother? :) -- fl_ */
- if(find_is_glined(host, user))
+ if (find_is_glined(host, user))
return NO;
-
+
/* special case condition where there are no pending glines */
- if (dlink_list_length(&pending_glines) == 0) /* first gline request placed */
- {
- add_new_majority_gline(oper_nick, oper_user, oper_host, oper_server,
- user, host, reason);
- return NO;
- }
+ if (dlink_list_length(&pending_glines) == 0) /* first gline request placed */
+ {
+ add_new_majority_gline(oper_nick, oper_user, oper_host, oper_server,
+ user, host, reason);
+ return NO;
+ }
for (pending_node = pending_glines.head;
pending_node; pending_node = pending_node->next)
- {
- gline_pending_ptr = pending_node->data;
+ {
+ gline_pending_ptr = pending_node->data;
- if( (irccmp(gline_pending_ptr->user,user) == 0) &&
- (irccmp(gline_pending_ptr->host,host) == 0 ) )
+ if ((irccmp(gline_pending_ptr->user, user) == 0) &&
+ (irccmp(gline_pending_ptr->host, host) == 0))
+ {
+ if (((irccmp(gline_pending_ptr->oper_user1, oper_user) == 0) ||
+ (irccmp(gline_pending_ptr->oper_host1, oper_host) == 0)) ||
+ (irccmp(gline_pending_ptr->oper_server1, oper_server) == 0))
+ {
+ /* This oper or server has already "voted" */
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "oper or server has already voted");
+ return NO;
+ }
+
+ if (gline_pending_ptr->oper_user2[0] != '\0')
+ {
+ /* if two other opers on two different servers have voted yes */
+
+ if (((irccmp(gline_pending_ptr->oper_user2, oper_user) == 0) ||
+ (irccmp(gline_pending_ptr->oper_host2, oper_host) == 0)) ||
+ (irccmp(gline_pending_ptr->oper_server2, oper_server) == 0))
{
- if(((irccmp(gline_pending_ptr->oper_user1,oper_user) == 0) ||
- (irccmp(gline_pending_ptr->oper_host1,oper_host) == 0)) ||
- (irccmp(gline_pending_ptr->oper_server1,oper_server) == 0) )
- {
- /* This oper or server has already "voted" */
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "oper or server has already voted");
- return NO;
- }
-
- if(gline_pending_ptr->oper_user2[0] != '\0')
- {
- /* if two other opers on two different servers have voted yes */
-
- if(((irccmp(gline_pending_ptr->oper_user2,oper_user)==0) ||
- (irccmp(gline_pending_ptr->oper_host2,oper_host)==0)) ||
- (irccmp(gline_pending_ptr->oper_server2,oper_server)==0))
- {
- /* This oper or server has already "voted" */
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "oper or server has already voted");
- return NO;
- }
-
- log_gline(source_p,gline_pending_ptr,
- oper_nick,oper_user,oper_host,oper_server,
- user,host,reason);
- return YES;
- }
- else
- {
- strncpy_irc(gline_pending_ptr->oper_nick2, oper_nick, NICKLEN);
- strncpy_irc(gline_pending_ptr->oper_user2, oper_user, USERLEN);
- strncpy_irc(gline_pending_ptr->oper_host2, oper_host, HOSTLEN);
- DupString(gline_pending_ptr->reason2, reason);
- gline_pending_ptr->oper_server2 = find_or_add(oper_server);
- gline_pending_ptr->last_gline_time = CurrentTime;
- gline_pending_ptr->time_request2 = CurrentTime;
- return NO;
- }
+ /* This oper or server has already "voted" */
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "oper or server has already voted");
+ return NO;
}
+
+ log_gline(source_p, gline_pending_ptr,
+ oper_nick, oper_user, oper_host, oper_server,
+ user, host, reason);
+ return YES;
+ }
+ else
+ {
+ strncpy_irc(gline_pending_ptr->oper_nick2, oper_nick, NICKLEN);
+ strncpy_irc(gline_pending_ptr->oper_user2, oper_user, USERLEN);
+ strncpy_irc(gline_pending_ptr->oper_host2, oper_host, HOSTLEN);
+ DupString(gline_pending_ptr->reason2, reason);
+ gline_pending_ptr->oper_server2 = find_or_add(oper_server);
+ gline_pending_ptr->last_gline_time = CurrentTime;
+ gline_pending_ptr->time_request2 = CurrentTime;
+ return NO;
+ }
}
+ }
/* Didn't find this user@host gline in pending gline list
* so add it.
*/
user, host, reason);
return NO;
}
-
-
* modules/m_help.c
* Copyright (C) 2001 Hybrid Development Team
*
- * $Id: m_help.c,v 1.1 2002/01/04 09:13:16 a1kmm Exp $
+ * $Id: m_help.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "parse.h"
#include "modules.h"
-static void m_help(struct Client*, struct Client*, int, char**);
-static void mo_help(struct Client*, struct Client*, int, char**);
-static void mo_uhelp(struct Client*, struct Client*, int, char**);
+static void m_help(struct Client *, struct Client *, int, char **);
+static void mo_help(struct Client *, struct Client *, int, char **);
+static void mo_uhelp(struct Client *, struct Client *, int, char **);
static void dohelp(struct Client *, char *, char *, char *);
static void sendhelpfile(struct Client *, char *, char *, char *);
};
#ifndef STATIC_MODULES
- void
+void
_modinit(void)
{
mod_add_cmd(&help_msgtab);
mod_add_cmd(&uhelp_msgtab);
}
- void
+void
_moddeinit(void)
{
mod_del_cmd(&help_msgtab);
mod_del_cmd(&uhelp_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_help - HELP message handler
* parv[0] = sender prefix
*/
-static void m_help(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_help(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
static time_t last_used = 0;
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
{
/* safe enough to give this on a local connect only */
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,parv[0]);
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
return;
}
else
last_used = CurrentTime;
}
- if(parc > 1)
+ if (parc > 1)
dohelp(source_p, UHPATH, parv[1], parv[0]);
else
dohelp(source_p, UHPATH, NULL, parv[0]);
* mo_help - HELP message handler
* parv[0] = sender prefix
*/
-static void mo_help(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_help(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if(parc > 1)
+ if (parc > 1)
dohelp(source_p, HPATH, parv[1], parv[0]);
else
dohelp(source_p, HPATH, NULL, parv[0]);
* parv[0] = sender prefix
*/
-static void mo_uhelp(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_uhelp(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if(parc > 1)
+ if (parc > 1)
dohelp(source_p, UHPATH, parv[1], parv[0]);
else
dohelp(source_p, UHPATH, NULL, parv[0]);
}
-static void dohelp(struct Client *source_p, char *hpath,
- char *topic, char *nick)
+static void
+dohelp(struct Client *source_p, char *hpath, char *topic, char *nick)
{
char path[MAXPATHLEN + 1];
struct stat sb;
}
}
else
- topic = "index"; /* list available help topics */
+ topic = "index"; /* list available help topics */
if (strchr(topic, '/'))
{
return;
}
-static void sendhelpfile(struct Client *source_p, char *path,
- char *topic, char *nick)
+static void
+sendhelpfile(struct Client *source_p, char *path, char *topic, char *nick)
{
FILE *file;
char line[HELPLEN];
sendto_one(source_p, form_str(RPL_ENDOFHELP), me.name, nick, topic);
return;
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_info.c,v 1.1 2002/01/04 09:13:19 a1kmm Exp $
+ * $Id: m_info.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include <time.h>
static void send_info_text(struct Client *source_p);
static void info_spy(struct Client *);
-static void m_info(struct Client*, struct Client*, int, char**);
-static void ms_info(struct Client*, struct Client*, int, char**);
-static void mo_info(struct Client*, struct Client*, int, char**);
+static void m_info(struct Client *, struct Client *, int, char **);
+static void ms_info(struct Client *, struct Client *, int, char **);
+static void mo_info(struct Client *, struct Client *, int, char **);
struct Message info_msgtab = {
"INFO", 0, 0, 0, 0, MFLG_SLOW, 0,
hook_del_event("doing_info");
mod_del_cmd(&info_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
void send_info_text(struct Client *source_p);
*/
struct InfoStruct
{
- char * name; /* Displayed variable name */
- unsigned int output_type; /* See below #defines */
- void * option; /* Pointer reference to the value */
- char * desc; /* ASCII description of the variable */
+ char *name; /* Displayed variable name */
+ unsigned int output_type; /* See below #defines */
+ void *option; /* Pointer reference to the value */
+ char *desc; /* ASCII description of the variable */
};
/* Types for output_type in InfoStruct */
-#define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
-#define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
-#define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
-#define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
-#define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
-#define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
-
-static struct InfoStruct info_table[] =
-{
+#define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
+#define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
+#define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
+#define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
+#define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
+#define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
+
+static struct InfoStruct info_table[] = {
/* --[ START OF TABLE ]-------------------------------------------- */
{
- "anti_nick_flood",
- OUTPUT_BOOLEAN,
- &ConfigFileEntry.anti_nick_flood,
- "NICK flood protection"
- },
- {
- "anti_spam_exit_message_time",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.anti_spam_exit_message_time,
- "Duration a client must be connected for to have an exit message"
- },
- {
- "caller_id_wait",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.caller_id_wait,
- "Minimum delay between notifying UMODE +g users of messages"
- },
- {
- "client_exit",
- OUTPUT_BOOLEAN,
- &ConfigFileEntry.client_exit,
- "Prepend 'Client Exit:' to user QUIT messages"
- },
- {
- "client_flood",
- OUTPUT_BOOLEAN,
- &ConfigFileEntry.client_flood,
- "Number of lines before a client Excess Flood's",
- },
- {
- "dots_in_ident",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.dots_in_ident,
- "Number of permissable dots in an ident"
- },
- {
- "failed_oper_notice",
- OUTPUT_BOOLEAN,
- &ConfigFileEntry.failed_oper_notice,
- "Inform opers if someone /oper's with the wrong password"
- },
- {
- /* fname_operlog is a char [] */
- "fname_operlog",
- OUTPUT_STRING_PTR,
- &ConfigFileEntry.fname_operlog,
- "Operator log file"
- },
- {
- /* fname_foperlog is a char [] */
- "fname_foperlog",
- OUTPUT_STRING_PTR,
- &ConfigFileEntry.fname_foperlog,
- "Failed operator log file"
- },
- {
- /* fname_userlog is a char [] */
- "fname_userlog",
- OUTPUT_STRING_PTR,
- &ConfigFileEntry.fname_userlog,
- "User log file"
- },
- {
- "glines",
- OUTPUT_BOOLEAN,
- &ConfigFileEntry.glines,
- "G-line (network-wide K-line) support"
- },
- {
- "gline_time",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.gline_time,
- "Expiry time for G-lines"
- },
- {
- "hub",
- OUTPUT_BOOLEAN_YN,
- &ServerInfo.hub,
- "Server is a hub"
- },
- {
- "idletime",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.idletime,
- "Number of minutes before a client is considered idle"
- },
- {
- "kline_with_connection_closed",
- OUTPUT_BOOLEAN_YN,
- &ConfigFileEntry.kline_with_connection_closed,
- "K-lined clients sign off with 'Connection closed'"
- },
- {
- "kline_with_reason",
- OUTPUT_BOOLEAN_YN,
- &ConfigFileEntry.kline_with_reason,
- "Display K-line reason to client on disconnect"
- },
- {
- "knock_delay",
- OUTPUT_DECIMAL,
- &ConfigChannel.knock_delay,
- "Delay between KNOCK attempts"
- },
- {
- "links_delay",
- OUTPUT_DECIMAL,
- &ConfigServerHide.links_delay,
- "Links rehash delay"
- },
- {
- "max_accept",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.max_accept,
- "Maximum nicknames on accept list",
- },
- {
- "max_chans_per_user",
- OUTPUT_DECIMAL,
- &ConfigChannel.max_chans_per_user,
- "Maximum number of channels a user can join"
- },
- {
- "max_nick_changes",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.max_nick_changes,
- "NICK change threshhold setting"
- },
- {
- "max_nick_time",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.max_nick_time,
- "NICK flood protection time interval"
- },
- {
- "max_targets",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.max_targets,
- "The maximum number of PRIVMSG/NOTICE targets"
- },
- {
- "maxbans",
- OUTPUT_DECIMAL,
- &ConfigChannel.maxbans,
- "Total +b/e/I modes allowed in a channel",
- },
- {
- "maximum_links",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.maximum_links,
- "Class default maximum links count",
- },
- {
- "min_nonwildcard",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.min_nonwildcard,
- "Minimum non-wildcard chars in K/G lines",
- },
- {
- "network_name",
- OUTPUT_STRING,
- &ServerInfo.network_name,
- "Network name"
- },
- {
- "network_desc",
- OUTPUT_STRING,
- &ServerInfo.network_desc,
- "Network description"
- },
- {
- "no_oper_flood",
- OUTPUT_BOOLEAN,
- &ConfigFileEntry.no_oper_flood,
- "Disable flood control for operators",
- },
- {
- "non_redundant_klines",
- OUTPUT_BOOLEAN,
- &ConfigFileEntry.non_redundant_klines,
- "Check for and disallow redundant K-lines"
- },
- {
- "pace_wait",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.pace_wait,
- "Minimum delay between uses of certain commands"
- },
- {
- "quiet_on_ban",
- OUTPUT_BOOLEAN_YN,
- &ConfigChannel.quiet_on_ban,
- "Banned users may not send text to a channel"
- },
- {
- "short_motd",
- OUTPUT_BOOLEAN_YN,
- &ConfigFileEntry.short_motd,
- "Do not show MOTD; only tell clients they should read it"
- },
- {
- "stats_i_oper_only",
- OUTPUT_BOOLEAN2,
- &ConfigFileEntry.stats_i_oper_only,
- "STATS I output is only shown to operators",
- },
- {
- "stats_k_oper_only",
- OUTPUT_BOOLEAN2,
- &ConfigFileEntry.stats_k_oper_only,
- "STATS K output is only shown to operators",
- },
- {
- "stats_o_oper_only",
- OUTPUT_BOOLEAN_YN,
- &ConfigFileEntry.stats_o_oper_only,
- "STATS O output is only shown to operators"
- },
- {
- "ts_max_delta",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.ts_max_delta,
- "Maximum permitted TS delta from another server"
- },
- {
- "use_except",
- OUTPUT_BOOLEAN_YN,
- &ConfigChannel.use_except,
- "Enable chanmode +e (ban exceptions)",
- },
- {
- "use_halfops",
- OUTPUT_BOOLEAN_YN,
- &ConfigChannel.use_halfops,
- "Enable chanmode +h (halfops)",
- },
- {
- "use_invex",
- OUTPUT_BOOLEAN_YN,
- &ConfigChannel.use_invex,
- "Enable chanmode +I (invite exceptions)",
- },
- {
- "use_knock",
- OUTPUT_BOOLEAN_YN,
- &ConfigChannel.use_knock,
- "Enable /KNOCK",
- },
- {
- "ts_warn_delta",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.ts_warn_delta,
- "Maximum permitted TS delta before displaying a warning"
- },
- {
- "vchans_oper_only",
- OUTPUT_BOOLEAN_YN,
- &ConfigChannel.vchans_oper_only,
- "Restrict use of /CJOIN to opers"
- },
- {
- "warn_no_nline",
- OUTPUT_BOOLEAN,
- &ConfigFileEntry.warn_no_nline,
- "Display warning if connecting server lacks N-line"
- },
- {
- "whois_wait",
- OUTPUT_DECIMAL,
- &ConfigFileEntry.whois_wait,
- "Delay (in seconds) between remote WHOIS requests"
- },
+ "anti_nick_flood",
+ OUTPUT_BOOLEAN,
+ &ConfigFileEntry.anti_nick_flood,
+ "NICK flood protection"},
+ {
+ "anti_spam_exit_message_time",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.anti_spam_exit_message_time,
+ "Duration a client must be connected for to have an exit message"},
+ {
+ "caller_id_wait",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.caller_id_wait,
+ "Minimum delay between notifying UMODE +g users of messages"},
+ {
+ "client_exit",
+ OUTPUT_BOOLEAN,
+ &ConfigFileEntry.client_exit,
+ "Prepend 'Client Exit:' to user QUIT messages"},
+ {
+ "client_flood",
+ OUTPUT_BOOLEAN,
+ &ConfigFileEntry.client_flood,
+ "Number of lines before a client Excess Flood's",
+ },
+ {
+ "dots_in_ident",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.dots_in_ident,
+ "Number of permissable dots in an ident"},
+ {
+ "failed_oper_notice",
+ OUTPUT_BOOLEAN,
+ &ConfigFileEntry.failed_oper_notice,
+ "Inform opers if someone /oper's with the wrong password"},
+ {
+ /* fname_operlog is a char [] */
+ "fname_operlog",
+ OUTPUT_STRING_PTR,
+ &ConfigFileEntry.fname_operlog,
+ "Operator log file"},
+ {
+ /* fname_foperlog is a char [] */
+ "fname_foperlog",
+ OUTPUT_STRING_PTR,
+ &ConfigFileEntry.fname_foperlog,
+ "Failed operator log file"},
+ {
+ /* fname_userlog is a char [] */
+ "fname_userlog",
+ OUTPUT_STRING_PTR,
+ &ConfigFileEntry.fname_userlog,
+ "User log file"},
+ {
+ "glines",
+ OUTPUT_BOOLEAN,
+ &ConfigFileEntry.glines,
+ "G-line (network-wide K-line) support"},
+ {
+ "gline_time",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.gline_time,
+ "Expiry time for G-lines"},
+ {
+ "hub",
+ OUTPUT_BOOLEAN_YN,
+ &ServerInfo.hub,
+ "Server is a hub"},
+ {
+ "idletime",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.idletime,
+ "Number of minutes before a client is considered idle"},
+ {
+ "kline_with_connection_closed",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigFileEntry.kline_with_connection_closed,
+ "K-lined clients sign off with 'Connection closed'"},
+ {
+ "kline_with_reason",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigFileEntry.kline_with_reason,
+ "Display K-line reason to client on disconnect"},
+ {
+ "knock_delay",
+ OUTPUT_DECIMAL,
+ &ConfigChannel.knock_delay,
+ "Delay between KNOCK attempts"},
+ {
+ "links_delay",
+ OUTPUT_DECIMAL,
+ &ConfigServerHide.links_delay,
+ "Links rehash delay"},
+ {
+ "max_accept",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.max_accept,
+ "Maximum nicknames on accept list",
+ },
+ {
+ "max_chans_per_user",
+ OUTPUT_DECIMAL,
+ &ConfigChannel.max_chans_per_user,
+ "Maximum number of channels a user can join"},
+ {
+ "max_nick_changes",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.max_nick_changes,
+ "NICK change threshhold setting"},
+ {
+ "max_nick_time",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.max_nick_time,
+ "NICK flood protection time interval"},
+ {
+ "max_targets",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.max_targets,
+ "The maximum number of PRIVMSG/NOTICE targets"},
+ {
+ "maxbans",
+ OUTPUT_DECIMAL,
+ &ConfigChannel.maxbans,
+ "Total +b/e/I modes allowed in a channel",
+ },
+ {
+ "maximum_links",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.maximum_links,
+ "Class default maximum links count",
+ },
+ {
+ "min_nonwildcard",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.min_nonwildcard,
+ "Minimum non-wildcard chars in K/G lines",
+ },
+ {
+ "network_name",
+ OUTPUT_STRING,
+ &ServerInfo.network_name,
+ "Network name"},
+ {
+ "network_desc",
+ OUTPUT_STRING,
+ &ServerInfo.network_desc,
+ "Network description"},
+ {
+ "no_oper_flood",
+ OUTPUT_BOOLEAN,
+ &ConfigFileEntry.no_oper_flood,
+ "Disable flood control for operators",
+ },
+ {
+ "non_redundant_klines",
+ OUTPUT_BOOLEAN,
+ &ConfigFileEntry.non_redundant_klines,
+ "Check for and disallow redundant K-lines"},
+ {
+ "pace_wait",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.pace_wait,
+ "Minimum delay between uses of certain commands"},
+ {
+ "quiet_on_ban",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigChannel.quiet_on_ban,
+ "Banned users may not send text to a channel"},
+ {
+ "short_motd",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigFileEntry.short_motd,
+ "Do not show MOTD; only tell clients they should read it"},
+ {
+ "stats_i_oper_only",
+ OUTPUT_BOOLEAN2,
+ &ConfigFileEntry.stats_i_oper_only,
+ "STATS I output is only shown to operators",
+ },
+ {
+ "stats_k_oper_only",
+ OUTPUT_BOOLEAN2,
+ &ConfigFileEntry.stats_k_oper_only,
+ "STATS K output is only shown to operators",
+ },
+ {
+ "stats_o_oper_only",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigFileEntry.stats_o_oper_only,
+ "STATS O output is only shown to operators"},
+ {
+ "ts_max_delta",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.ts_max_delta,
+ "Maximum permitted TS delta from another server"},
+ {
+ "use_except",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigChannel.use_except,
+ "Enable chanmode +e (ban exceptions)",
+ },
+ {
+ "use_halfops",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigChannel.use_halfops,
+ "Enable chanmode +h (halfops)",
+ },
+ {
+ "use_invex",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigChannel.use_invex,
+ "Enable chanmode +I (invite exceptions)",
+ },
+ {
+ "use_knock",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigChannel.use_knock,
+ "Enable /KNOCK",
+ },
+ {
+ "ts_warn_delta",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.ts_warn_delta,
+ "Maximum permitted TS delta before displaying a warning"},
+ {
+ "vchans_oper_only",
+ OUTPUT_BOOLEAN_YN,
+ &ConfigChannel.vchans_oper_only,
+ "Restrict use of /CJOIN to opers"},
+ {
+ "warn_no_nline",
+ OUTPUT_BOOLEAN,
+ &ConfigFileEntry.warn_no_nline,
+ "Display warning if connecting server lacks N-line"},
+ {
+ "whois_wait",
+ OUTPUT_DECIMAL,
+ &ConfigFileEntry.whois_wait,
+ "Delay (in seconds) between remote WHOIS requests"},
/* --[ END OF TABLE ]---------------------------------------------- */
{
- (char *) 0,
- (unsigned int) 0,
- (void *) 0,
- (char *) 0
- }
+ (char *)0,
+ (unsigned int)0,
+ (void *)0,
+ (char *)0}
};
/*
** parv[1] = servername
*/
-static void m_info(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_info(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- static time_t last_used=0L;
+ static time_t last_used = 0L;
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
{
/* safe enough to give this on a local connect only */
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,parv[0]);
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
return;
}
else
if (!ConfigServerHide.disable_remote)
{
- if (hunt_server(client_p,source_p,
- ":%s INFO :%s", 1, parc, parv) != HUNTED_ISME)
+ if (hunt_server(client_p, source_p,
+ ":%s INFO :%s", 1, parc, parv) != HUNTED_ISME)
{
return;
}
sendto_one(source_p, form_str(RPL_ENDOFINFO), me.name, parv[0]);
-} /* m_info() */
+} /* m_info() */
/*
** mo_info
** parv[0] = sender prefix
** parv[1] = servername
*/
-static void mo_info(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
-
+static void
+mo_info(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if (hunt_server(client_p,source_p,":%s INFO :%s",1,parc,parv) == HUNTED_ISME)
+ if (hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) ==
+ HUNTED_ISME)
{
info_spy(source_p);
-
+
send_info_text(source_p);
send_conf_options(source_p);
send_birthdate_online_time(source_p);
sendto_one(source_p, form_str(RPL_ENDOFINFO), me.name, parv[0]);
}
-} /* mo_info() */
+} /* mo_info() */
/*
** ms_info
** parv[0] = sender prefix
** parv[1] = servername
*/
-static void ms_info(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
-
+static void
+ms_info(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if(!IsClient(source_p))
- return;
-
- if (hunt_server(client_p,source_p,":%s INFO :%s",1,parc,parv) == HUNTED_ISME)
+ if (!IsClient(source_p))
+ return;
+
+ if (hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) ==
+ HUNTED_ISME)
{
info_spy(source_p);
-
+
/* I dont see sending Hybrid-team as anything but a waste of bandwidth..
* so its disabled for now. --fl_
*/
/* send_info_text(source_p); */
/* I dont see why remote opers need this, but.. */
- if(IsOper(source_p))
+ if (IsOper(source_p))
send_conf_options(source_p);
-
+
send_birthdate_online_time(source_p);
- sendto_one(source_p, form_str(RPL_ENDOFINFO),
- me.name, parv[0]);
+ sendto_one(source_p, form_str(RPL_ENDOFINFO), me.name, parv[0]);
}
-} /* ms_info() */
+} /* ms_info() */
/*
* output - none
* side effects - info text is sent to client
*/
-static void send_info_text(struct Client *source_p)
+static void
+send_info_text(struct Client *source_p)
{
char **text = infotext;
while (*text)
{
- sendto_one(source_p, form_str(RPL_INFO), me.name, source_p->name, *text++);
+ sendto_one(source_p, form_str(RPL_INFO), me.name, source_p->name,
+ *text++);
}
sendto_one(source_p, form_str(RPL_INFO), me.name, source_p->name, "");
* output - none
* side effects - birthdate and online time are sent
*/
-static void send_birthdate_online_time(struct Client *source_p)
+static void
+send_birthdate_online_time(struct Client *source_p)
{
sendto_one(source_p,
- ":%s %d %s :Birth Date: %s, compile # %s",
- me.name,
- RPL_INFO,
- source_p->name,
- creation,
- generation);
+ ":%s %d %s :Birth Date: %s, compile # %s",
+ me.name, RPL_INFO, source_p->name, creation, generation);
sendto_one(source_p,
- ":%s %d %s :On-line since %s",
- me.name,
- RPL_INFO,
- source_p->name,
- myctime(me.firsttime));
+ ":%s %d %s :On-line since %s",
+ me.name, RPL_INFO, source_p->name, myctime(me.firsttime));
}
/*
* output - none
* side effects - send config options to client
*/
-static void send_conf_options(struct Client *source_p)
+static void
+send_conf_options(struct Client *source_p)
{
Info *infoptr;
int i = 0;
* (mostly from config.h)
*/
for (infoptr = MyInformation; infoptr->name; infoptr++)
+ {
+ if (infoptr->intvalue)
+ {
+ sendto_one(source_p,
+ ":%s %d %s :%-30s %-5d [%-30s]",
+ me.name,
+ RPL_INFO,
+ source_p->name,
+ infoptr->name, infoptr->intvalue, infoptr->desc);
+ }
+ else
{
- if (infoptr->intvalue)
+ sendto_one(source_p,
+ ":%s %d %s :%-30s %-5s [%-30s]",
+ me.name,
+ RPL_INFO,
+ source_p->name,
+ infoptr->name, infoptr->strvalue, infoptr->desc);
+ }
+ }
+
+ /*
+ * Parse the info_table[] and do the magic.
+ */
+ for (i = 0; info_table[i].name; i++)
+ {
+ switch (info_table[i].output_type)
+ {
+ /*
+ * For "char *" references
+ */
+ case OUTPUT_STRING:
{
- sendto_one(source_p,
- ":%s %d %s :%-30s %-5d [%-30s]",
- me.name,
- RPL_INFO,
- source_p->name,
- infoptr->name,
- infoptr->intvalue,
- infoptr->desc);
+ char *option = *((char **)info_table[i].option);
+
+ sendto_one(source_p,
+ ":%s %d %s :%-30s %-5s [%-30s]",
+ me.name,
+ RPL_INFO,
+ source_p->name,
+ info_table[i].name,
+ option ? option : "NONE",
+ info_table[i].desc ? info_table[i].desc : "<none>");
+
+ break;
}
- else
+ /*
+ * For "char foo[]" references
+ */
+ case OUTPUT_STRING_PTR:
{
- sendto_one(source_p,
- ":%s %d %s :%-30s %-5s [%-30s]",
- me.name,
- RPL_INFO,
- source_p->name,
- infoptr->name,
- infoptr->strvalue,
- infoptr->desc);
+ char *option = (char *)info_table[i].option;
+
+ sendto_one(source_p,
+ ":%s %d %s :%-30s %-5s [%-30s]",
+ me.name,
+ RPL_INFO,
+ source_p->name,
+ info_table[i].name,
+ option ? option : "NONE",
+ info_table[i].desc ? info_table[i].desc : "<none>");
+
+ break;
+ }
+ /*
+ * Output info_table[i].option as a decimal value.
+ */
+ case OUTPUT_DECIMAL:
+ {
+ int option = *((int *)info_table[i].option);
+
+ sendto_one(source_p,
+ ":%s %d %s :%-30s %-5d [%-30s]",
+ me.name,
+ RPL_INFO,
+ source_p->name,
+ info_table[i].name,
+ option,
+ info_table[i].desc ? info_table[i].desc : "<none>");
+
+ break;
}
- }
- /*
- * Parse the info_table[] and do the magic.
- */
- for (i = 0; info_table[i].name; i++)
- {
- switch (info_table[i].output_type)
- {
- /*
- * For "char *" references
- */
- case OUTPUT_STRING:
- {
- char *option = *((char **) info_table[i].option);
-
- sendto_one(source_p,
- ":%s %d %s :%-30s %-5s [%-30s]",
- me.name,
- RPL_INFO,
- source_p->name,
- info_table[i].name,
- option ? option : "NONE",
- info_table[i].desc ? info_table[i].desc : "<none>");
-
- break;
- }
- /*
- * For "char foo[]" references
- */
- case OUTPUT_STRING_PTR:
- {
- char *option = (char *) info_table[i].option;
-
- sendto_one(source_p,
- ":%s %d %s :%-30s %-5s [%-30s]",
- me.name,
- RPL_INFO,
- source_p->name,
- info_table[i].name,
- option ? option : "NONE",
- info_table[i].desc ? info_table[i].desc : "<none>");
-
- break;
- }
- /*
- * Output info_table[i].option as a decimal value.
- */
- case OUTPUT_DECIMAL:
- {
- int option = *((int *) info_table[i].option);
-
- sendto_one(source_p,
- ":%s %d %s :%-30s %-5d [%-30s]",
- me.name,
- RPL_INFO,
- source_p->name,
- info_table[i].name,
- option,
- info_table[i].desc ? info_table[i].desc : "<none>");
-
- break;
- }
-
- /*
- * Output info_table[i].option as "ON" or "OFF"
- */
- case OUTPUT_BOOLEAN:
- {
- int option = *((int *) info_table[i].option);
-
- sendto_one(source_p,
- ":%s %d %s :%-30s %-5s [%-30s]",
- me.name,
- RPL_INFO,
- source_p->name,
- info_table[i].name,
- option ? "ON" : "OFF",
- info_table[i].desc ? info_table[i].desc : "<none>");
-
- break;
- }
- /*
- * Output info_table[i].option as "YES" or "NO"
- */
- case OUTPUT_BOOLEAN_YN:
- {
- int option = *((int *) info_table[i].option);
-
- sendto_one(source_p,
- ":%s %d %s :%-30s %-5s [%-30s]",
- me.name,
- RPL_INFO,
- source_p->name,
- info_table[i].name,
- option ? "YES" : "NO",
- info_table[i].desc ? info_table[i].desc : "<none>");
-
- break;
- }
- } /* switch (info_table[i].output_type) */
- } /* forloop */
+ /*
+ * Output info_table[i].option as "ON" or "OFF"
+ */
+ case OUTPUT_BOOLEAN:
+ {
+ int option = *((int *)info_table[i].option);
+
+ sendto_one(source_p,
+ ":%s %d %s :%-30s %-5s [%-30s]",
+ me.name,
+ RPL_INFO,
+ source_p->name,
+ info_table[i].name,
+ option ? "ON" : "OFF",
+ info_table[i].desc ? info_table[i].desc : "<none>");
+
+ break;
+ }
+ /*
+ * Output info_table[i].option as "YES" or "NO"
+ */
+ case OUTPUT_BOOLEAN_YN:
+ {
+ int option = *((int *)info_table[i].option);
+
+ sendto_one(source_p,
+ ":%s %d %s :%-30s %-5s [%-30s]",
+ me.name,
+ RPL_INFO,
+ source_p->name,
+ info_table[i].name,
+ option ? "YES" : "NO",
+ info_table[i].desc ? info_table[i].desc : "<none>");
+
+ break;
+ }
+ } /* switch (info_table[i].output_type) */
+ } /* forloop */
/* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
- ** in order for it to show up properly to opers who issue INFO
- */
+ ** in order for it to show up properly to opers who issue INFO
+ */
/* jdc -- Only send compile information to admins. */
if (IsOperAdmin(source_p))
{
sendto_one(source_p,
- ":%s %d %s :Compiled on [%s]",
- me.name,
- RPL_INFO,
- source_p->name,
- platform);
+ ":%s %d %s :Compiled on [%s]",
+ me.name, RPL_INFO, source_p->name, platform);
}
sendto_one(source_p, form_str(RPL_INFO), me.name, source_p->name, "");
* output - none
* side effects - hook doing_info is called
*/
-static void info_spy(struct Client *source_p)
+static void
+info_spy(struct Client *source_p)
{
struct hook_spy_data data;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_invite.c,v 1.1 2002/01/04 09:13:19 a1kmm Exp $
+ * $Id: m_invite.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
mod_del_cmd(&invite_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
vchan = chptr;
if (IsVchan(chptr))
chptr = chptr->root_chptr;
-
+
if (MyClient(source_p) && !IsMember(source_p, vchan))
{
sendto_one(source_p, form_str(ERR_NOTONCHANNEL), me.name, parv[0],
if ((vchan2 = map_vchan(chptr, target_p)))
{
- if (MyClient(source_p) && (vchan2->mode.mode & MODE_SECRET)==0)
+ if (MyClient(source_p) && (vchan2->mode.mode & MODE_SECRET) == 0)
sendto_one(source_p, form_str(ERR_USERONCHANNEL), me.name, parv[0],
parv[1], parv[2]);
return;
chptr->chname);
}
sendto_channel_remote(source_p, client_p,
- ONLY_CHANOPS_HALFOPS, NOCAPS, NOCAPS,
- chptr, ":%s INVITE %s :%s", parv[0],
+ ONLY_CHANOPS_HALFOPS, NOCAPS, NOCAPS,
+ chptr, ":%s INVITE %s :%s", parv[0],
target_p->name, vchan->chname);
if (!MyConnect(target_p) && target_p->from->serial != current_serial)
target_p->name, vchan->chname);
if (vchan->mode.mode & MODE_PRIVATE)
sendto_channel_local(ONLY_CHANOPS_HALFOPS, vchan,
- ":%s NOTICE %s :%s is inviting %s to %s.", me.name, chptr->chname,
- source_p->name, target_p->name, chptr->chname);
+ ":%s NOTICE %s :%s is inviting %s to %s.", me.name,
+ chptr->chname, source_p->name, target_p->name,
+ chptr->chname);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_ison.c,v 1.1 2002/01/04 09:13:19 a1kmm Exp $
+ * $Id: m_ison.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "msg.h"
#include "parse.h"
#include "modules.h"
-#include "s_conf.h" /* ConfigFileEntry */
-#include "s_serv.h" /* uplink/IsCapable */
+#include "s_conf.h" /* ConfigFileEntry */
+#include "s_serv.h" /* uplink/IsCapable */
#include <string.h>
static int do_ison(struct Client *up, struct Client *source_p,
int parc, char *parv[]);
-static void m_ison(struct Client*, struct Client*, int, char**);
-static void ms_ison(struct Client*, struct Client*, int, char**);
+static void m_ison(struct Client *, struct Client *, int, char **);
+static void ms_ison(struct Client *, struct Client *, int, char **);
struct Message ison_msgtab = {
"ISON", 0, 0, 1, 1, MFLG_SLOW, 0,
#ifndef STATIC_MODULES
- void
+void
_modinit(void)
{
mod_add_cmd(&ison_msgtab);
}
- void
+void
_moddeinit(void)
{
mod_del_cmd(&ison_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
static char buf[BUFSIZE];
* format:
* ISON :nicklist
*/
-static void m_ison(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_ison(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct Client *up = NULL;
* exists...
* ISON :nicklist
*/
-static void ms_ison(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_ison(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
do_ison(NULL, source_p, parc, parv);
}
-static int do_ison(struct Client *up, struct Client *source_p,
- int parc, char *parv[])
+static int
+do_ison(struct Client *up, struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p;
char *nick;
if ((target_p = find_person(nick)))
{
len = strlen(target_p->name);
- if( (current_insert_point + (len + 5)) < (buf + sizeof(buf)) )
+ if ((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
{
- memcpy((void *)current_insert_point,
- (void *)target_p->name, len);
+ memcpy((void *)current_insert_point, (void *)target_p->name, len);
current_insert_point += len;
*current_insert_point++ = ' ';
}
{
/* Build up a single list, for use if we relay.. */
len = strlen(nick);
- if((current_insert_point2 + len + 5) < (buf2 + sizeof(buf2)))
+ if ((current_insert_point2 + len + 5) < (buf2 + sizeof(buf2)))
{
- memcpy((void *)current_insert_point2,
- (void *)nick, len);
+ memcpy((void *)current_insert_point2, (void *)nick, len);
current_insert_point2 += len;
*current_insert_point2++ = ' ';
}
}
}
}
- if(done)
+ if (done)
break;
}
* --Rodder */
*current_insert_point = '\0';
- *current_insert_point2 = '\0';
-
+ *current_insert_point2 = '\0';
+
if (relay_to_hub)
sendto_one(up, ":%s ISON :%s", source_p->name, buf2);
else
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_join.c,v 1.1 2002/01/04 09:13:21 a1kmm Exp $
+ * $Id: m_join.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include "channel_mode.h"
#include "vchannel.h"
#include "client.h"
-#include "common.h" /* bleah */
+#include "common.h" /* bleah */
#include "resv.h"
#include "hash.h"
#include "irc_string.h"
#include <string.h>
#include <assert.h>
-static void m_join(struct Client*, struct Client*, int, char**);
-static void ms_join(struct Client*, struct Client*, int, char**);
+static void m_join(struct Client *, struct Client *, int, char **);
+static void ms_join(struct Client *, struct Client *, int, char **);
struct Message join_msgtab = {
"JOIN", 0, 0, 2, 0, MFLG_SLOW, 0,
{
mod_del_cmd(&join_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
static void do_join_0(struct Client *client_p, struct Client *source_p);
*/
static void
m_join(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+ struct Client *source_p, int parc, char *parv[])
{
struct Channel *chptr = NULL;
struct Channel *vchan_chptr = NULL;
struct Channel *root_chptr = NULL;
int joining_vchan = 0;
- char *name, *key = NULL;
- char *vkey = NULL; /* !key for vchans */
- int i, flags = 0;
- char *p = NULL, *p2 = NULL, *p3 = NULL, *pvc = NULL;
- int vc_ts;
- int successful_join_count = 0; /* Number of channels successfully joined */
-
+ char *name, *key = NULL;
+ char *vkey = NULL; /* !key for vchans */
+ int i, flags = 0;
+ char *p = NULL, *p2 = NULL, *p3 = NULL, *pvc = NULL;
+ int vc_ts;
+ int successful_join_count = 0; /* Number of channels successfully joined */
+
if (*parv[1] == '\0')
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "JOIN");
+ return;
+ }
+
+ if (parc > 3)
+ {
+ key = strtoken(&p2, parv[3], ",");
+ vkey = strtoken(&p3, parv[2], ",");
+ }
+ else if (parc > 2)
+ {
+ key = strtoken(&p2, parv[2], ",");
+ vkey = key;
+ }
+
+ for (name = strtoken(&p, parv[1], ","); name;
+ key = (key) ? strtoken(&p2, NULL, ",") : NULL,
+ vkey = (parc > 3) ? ((vkey) ? strtoken(&p3, NULL, ",") : NULL) : key,
+ name = strtoken(&p, NULL, ","))
+ {
+
+ if (!check_channel_name(name))
{
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "JOIN");
- return;
+ sendto_one(source_p, form_str(ERR_BADCHANNAME),
+ me.name, source_p->name, (unsigned char *)name);
+ continue;
}
- if (parc > 3)
+ /*
+ ** JOIN 0 sends out a part for all channels a user
+ ** has joined.
+ **
+ ** this should be either disabled or selectable in
+ ** config file .. it's abused a lot more than it's
+ ** used these days :/ --is
+ */
+ if (*name == '0' && !atoi(name))
{
- key = strtoken(&p2, parv[3], ",");
- vkey = strtoken(&p3, parv[2], ",");
+ if (source_p->user->channel.head == NULL)
+ continue;
+
+ do_join_0(&me, source_p);
+ continue;
}
- else if (parc > 2)
+
+ /* check it begins with # or & */
+ else if (!IsChannelName(name))
{
- key = strtoken(&p2, parv[2], ",");
- vkey = key;
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, source_p->name, name);
+ continue;
}
- for (name = strtoken(&p, parv[1], ","); name;
- key = (key) ? strtoken(&p2, NULL, ",") : NULL,
- vkey = (parc>3) ? ((vkey) ? strtoken(&p3, NULL, ",") : NULL) : key,
- name = strtoken(&p, NULL, ","))
+ if (ConfigServerHide.disable_local_channels && (*name == '&'))
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, source_p->name, name);
+ continue;
+ }
+
+ /* check the length */
+ if (strlen(name) > CHANNELLEN)
{
+ sendto_one(source_p, form_str(ERR_BADCHANNAME),
+ me.name, source_p->name, name);
+ continue;
+ }
+
+ /* see if its resv'd */
+ if (find_channel_resv(name))
+ {
+ sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
+ me.name, source_p->name, name);
+ continue;
+ }
- if(!check_channel_name(name))
+ /* look for the channel */
+ if ((chptr = hash_find_channel(name)) != NULL)
+ {
+ if (splitmode && (*name != '&') && ConfigChannel.no_join_on_split)
{
- sendto_one(source_p, form_str(ERR_BADCHANNAME),
- me.name, source_p->name, (unsigned char*)name);
+ sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
+ me.name, source_p->name, name);
continue;
}
- /*
- ** JOIN 0 sends out a part for all channels a user
- ** has joined.
- **
- ** this should be either disabled or selectable in
- ** config file .. it's abused a lot more than it's
- ** used these days :/ --is
- */
- if (*name == '0' && !atoi(name))
+ /* Check if they want to join a subchan or something */
+ vchan_chptr = select_vchan(chptr, source_p, vkey, name);
+
+ if (!vchan_chptr)
+ continue;
+
+ if (vchan_chptr != chptr)
{
- if (source_p->user->channel.head == NULL)
- continue;
-
- do_join_0(&me,source_p);
- continue;
+ joining_vchan = 1;
+ root_chptr = chptr;
+ chptr = vchan_chptr;
}
-
- /* check it begins with # or & */
- else if(!IsChannelName(name))
+ else
{
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, source_p->name, name);
- continue;
+ joining_vchan = 0;
+ root_chptr = chptr;
}
- if(ConfigServerHide.disable_local_channels &&
- (*name == '&'))
+ if (chptr->users == 0)
+ flags = CHFL_CHANOP;
+ else
+ flags = 0;
+ }
+ else
+ {
+ if (splitmode && (*name != '&') &&
+ (ConfigChannel.no_create_on_split
+ || ConfigChannel.no_join_on_split))
{
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, source_p->name, name);
+ sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
+ me.name, source_p->name, name);
continue;
}
- /* check the length */
- if (strlen(name) > CHANNELLEN)
+ flags = CHFL_CHANOP;
+ if (!ServerInfo.hub)
{
- sendto_one(source_p, form_str(ERR_BADCHANNAME),
- me.name, source_p->name, name);
- continue;
+ /* LazyLinks */
+ if ((*name != '&') && uplink && IsCapable(uplink, CAP_LL))
+ {
+ sendto_one(uplink, ":%s CBURST %s %s %s",
+ me.name, name, source_p->name, key ? key : "");
+ /* And wait for LLJOIN */
+ return;
+ }
}
-
- /* see if its resv'd */
- if(find_channel_resv(name))
- {
- sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
- me.name, source_p->name, name);
- continue;
- }
-
- /* look for the channel */
- if((chptr = hash_find_channel(name)) != NULL)
- {
- if(splitmode && (*name != '&') && ConfigChannel.no_join_on_split)
- {
- sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
- me.name, source_p->name, name);
- continue;
- }
-
- /* Check if they want to join a subchan or something */
- vchan_chptr = select_vchan(chptr, source_p, vkey, name);
-
- if (!vchan_chptr)
- continue;
-
- if (vchan_chptr != chptr)
- {
- joining_vchan = 1;
- root_chptr = chptr;
- chptr = vchan_chptr;
- }
- else
- {
- joining_vchan = 0;
- root_chptr = chptr;
- }
-
- if (chptr->users == 0)
- flags = CHFL_CHANOP;
- else
- flags = 0;
- }
- else
- {
- if(splitmode && (*name != '&') &&
- (ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split))
- {
- sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
- me.name, source_p->name, name);
- continue;
- }
-
- flags = CHFL_CHANOP;
- if(!ServerInfo.hub)
- {
- /* LazyLinks */
- if( (*name != '&') && uplink
- && IsCapable(uplink, CAP_LL) )
- {
- sendto_one(uplink,":%s CBURST %s %s %s",
- me.name,name,source_p->name, key ? key: "" );
- /* And wait for LLJOIN */
- return;
- }
- }
- }
-
- if ((source_p->user->joined >= ConfigChannel.max_chans_per_user) &&
- (!IsOper(source_p) || (source_p->user->joined >=
- ConfigChannel.max_chans_per_user*3)))
- {
- sendto_one(source_p, form_str(ERR_TOOMANYCHANNELS),
- me.name, parv[0], name);
- if(successful_join_count)
- source_p->localClient->last_join_time = CurrentTime;
- return;
- }
-
- if(flags == 0) /* if channel doesn't exist, don't penalize */
- successful_join_count++;
-
- if(!chptr) /* If I already have a chptr, no point doing this */
- {
- chptr = get_or_create_channel(source_p, name, NULL);
- root_chptr = chptr;
- }
-
- if(chptr)
- {
- if (IsMember(source_p, chptr)) /* already a member, ignore this */
- continue;
- }
- else
- {
- sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
- me.name, parv[0], name);
- if(successful_join_count > 0)
- successful_join_count--;
- continue;
- }
+ }
+
+ if ((source_p->user->joined >= ConfigChannel.max_chans_per_user) &&
+ (!IsOper(source_p) || (source_p->user->joined >=
+ ConfigChannel.max_chans_per_user * 3)))
+ {
+ sendto_one(source_p, form_str(ERR_TOOMANYCHANNELS),
+ me.name, parv[0], name);
+ if (successful_join_count)
+ source_p->localClient->last_join_time = CurrentTime;
+ return;
+ }
+
+ if (flags == 0) /* if channel doesn't exist, don't penalize */
+ successful_join_count++;
+
+ if (!chptr) /* If I already have a chptr, no point doing this */
+ {
+ chptr = get_or_create_channel(source_p, name, NULL);
+ root_chptr = chptr;
+ }
+
+ if (chptr)
+ {
+ if (IsMember(source_p, chptr)) /* already a member, ignore this */
+ continue;
+ }
+ else
+ {
+ sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
+ me.name, parv[0], name);
+ if (successful_join_count > 0)
+ successful_join_count--;
+ continue;
+ }
if (!IsOper(source_p))
- check_spambot_warning(source_p, name);
-
- /*
- * can_join checks for +i key, bans.
- */
+ check_spambot_warning(source_p, name);
- if ( (i = can_join(source_p, chptr, key)) )
- {
- sendto_one(source_p,
- form_str(i), me.name, parv[0], name);
- if(successful_join_count > 0)
- successful_join_count--;
- continue;
- }
+ /*
+ * can_join checks for +i key, bans.
+ */
- /*
- ** Complete user entry to the new channel (if any)
- */
-
- add_user_to_channel(chptr, source_p, flags);
+ if ((i = can_join(source_p, chptr, key)))
+ {
+ sendto_one(source_p, form_str(i), me.name, parv[0], name);
+ if (successful_join_count > 0)
+ successful_join_count--;
+ continue;
+ }
- if (joining_vchan)
- {
- add_vchan_to_client_cache(source_p,root_chptr,chptr);
- }
+ /*
+ ** Complete user entry to the new channel (if any)
+ */
- /*
- ** Set timestamp if appropriate, and propagate
- */
+ add_user_to_channel(chptr, source_p, flags);
- if (flags & CHFL_CHANOP)
- {
- chptr->channelts = CurrentTime;
+ if (joining_vchan)
+ {
+ add_vchan_to_client_cache(source_p, root_chptr, chptr);
+ }
+
+ /*
+ ** Set timestamp if appropriate, and propagate
+ */
+ if (flags & CHFL_CHANOP)
+ {
+ chptr->channelts = CurrentTime;
+
+ /*
+ * XXX - this is a rather ugly hack.
+ *
+ * Unfortunately, there's no way to pass
+ * the fact that it is a vchan through SJOIN...
+ */
+
+ /* Prevent users creating a fake vchan */
+ if (name[0] == '#' && name[1] == '#')
+ {
+ if ((pvc = strrchr(name + 3, '_')))
+ {
/*
- * XXX - this is a rather ugly hack.
- *
- * Unfortunately, there's no way to pass
- * the fact that it is a vchan through SJOIN...
+ * OK, name matches possible vchan:
+ * ##channel_blah
*/
+ pvc++; /* point pvc after last _ */
+ vc_ts = atol(pvc);
- /* Prevent users creating a fake vchan */
- if (name[0] == '#' && name[1] == '#')
- {
- if ((pvc = strrchr(name+3, '_')))
- {
- /*
- * OK, name matches possible vchan:
- * ##channel_blah
- */
- pvc++; /* point pvc after last _ */
- vc_ts = atol(pvc);
-
- /*
- * if blah is the same as the TS, up the TS
- * by one, to prevent this channel being
- * seen as a vchan
- */
- if (vc_ts == CurrentTime)
- chptr->channelts++;
- }
- }
-
- sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
- LL_ICLIENT,
- ":%s SJOIN %lu %s + :@%s",
- me.name,
- (unsigned long) chptr->channelts,
- chptr->chname,
- parv[0]);
- }
- else
- {
- sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
- LL_ICLIENT,
- ":%s SJOIN %lu %s + :%s",
- me.name,
- (unsigned long) chptr->channelts,
- chptr->chname,
- parv[0]);
+ /*
+ * if blah is the same as the TS, up the TS
+ * by one, to prevent this channel being
+ * seen as a vchan
+ */
+ if (vc_ts == CurrentTime)
+ chptr->channelts++;
}
+ }
- /*
- ** notify all other users on the new channel
- */
- sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
- source_p->name,
- source_p->username,
- source_p->host,
- root_chptr->chname);
-
- if( flags & CHFL_CHANOP )
- {
- chptr->mode.mode |= MODE_TOPICLIMIT;
- chptr->mode.mode |= MODE_NOPRIVMSGS;
-
- sendto_channel_local(ONLY_CHANOPS_HALFOPS,chptr,
- ":%s MODE %s +nt",
- me.name,
- root_chptr->chname);
-
- sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
- LL_ICLIENT,
- ":%s MODE %s +nt",
- me.name,
- chptr->chname);
- }
-
- del_invite(chptr, source_p);
-
- if (chptr->topic[0] != '\0')
- {
- sendto_one(source_p, form_str(RPL_TOPIC), me.name,
- parv[0], root_chptr->chname, chptr->topic);
-
- if (!(chptr->mode.mode & MODE_HIDEOPS) ||
- (flags & CHFL_CHANOP) || (flags & CHFL_HALFOP))
- {
- sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
- me.name, parv[0], root_chptr->chname,
- chptr->topic_info,
- chptr->topic_time);
- }
- else /* Hide from nonops */
- {
- sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
- me.name, parv[0], root_chptr->chname,
- me.name,
- chptr->topic_time);
- }
- }
-
- channel_member_names(source_p, chptr, root_chptr->chname, 1);
-
- if(successful_join_count)
- source_p->localClient->last_join_time = CurrentTime;
+ sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
+ LL_ICLIENT,
+ ":%s SJOIN %lu %s + :@%s",
+ me.name,
+ (unsigned long)chptr->channelts, chptr->chname, parv[0]);
+ }
+ else
+ {
+ sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
+ LL_ICLIENT,
+ ":%s SJOIN %lu %s + :%s",
+ me.name,
+ (unsigned long)chptr->channelts, chptr->chname, parv[0]);
}
+
+ /*
+ ** notify all other users on the new channel
+ */
+ sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
+ source_p->name,
+ source_p->username,
+ source_p->host, root_chptr->chname);
+
+ if (flags & CHFL_CHANOP)
+ {
+ chptr->mode.mode |= MODE_TOPICLIMIT;
+ chptr->mode.mode |= MODE_NOPRIVMSGS;
+
+ sendto_channel_local(ONLY_CHANOPS_HALFOPS, chptr,
+ ":%s MODE %s +nt", me.name, root_chptr->chname);
+
+ sendto_server(client_p, source_p, chptr, NOCAPS, NOCAPS,
+ LL_ICLIENT, ":%s MODE %s +nt", me.name, chptr->chname);
+ }
+
+ del_invite(chptr, source_p);
+
+ if (chptr->topic[0] != '\0')
+ {
+ sendto_one(source_p, form_str(RPL_TOPIC), me.name,
+ parv[0], root_chptr->chname, chptr->topic);
+
+ if (!(chptr->mode.mode & MODE_HIDEOPS) ||
+ (flags & CHFL_CHANOP) || (flags & CHFL_HALFOP))
+ {
+ sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
+ me.name, parv[0], root_chptr->chname,
+ chptr->topic_info, chptr->topic_time);
+ }
+ else /* Hide from nonops */
+ {
+ sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
+ me.name, parv[0], root_chptr->chname,
+ me.name, chptr->topic_time);
+ }
+ }
+
+ channel_member_names(source_p, chptr, root_chptr->chname, 1);
+
+ if (successful_join_count)
+ source_p->localClient->last_join_time = CurrentTime;
+ }
}
/*
* and use it for the TimeStamp on a new channel.
*/
-static void
+static void
ms_join(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+ struct Client *source_p, int parc, char *parv[])
{
char *name;
int new_ts;
if (!(source_p->user))
return;
-
+
name = parv[1];
if ((name[0] == '0') && (name[1] == '\0'))
+ {
+ do_join_0(client_p, source_p);
+ }
+ else
+ {
+ if (parc > 2)
{
- do_join_0(client_p, source_p);
+ new_ts = atoi(parv[2]);
}
- else
+ else
{
- if(parc > 2)
- {
- new_ts = atoi(parv[2]);
- }
- else
- {
- ts_warn("User on %s remotely JOINing new channel with no TS",
- source_p->user->server);
- }
+ ts_warn("User on %s remotely JOINing new channel with no TS",
+ source_p->user->server);
}
+ }
}
/*
* anti spambot code.
*/
-static void do_join_0(struct Client *client_p, struct Client *source_p)
+static void
+do_join_0(struct Client *client_p, struct Client *source_p)
{
- struct Channel *chptr=NULL;
- dlink_node *lp;
+ struct Channel *chptr = NULL;
+ dlink_node *lp;
sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, NOFLAGS,
":%s JOIN 0", source_p->name);
if (source_p->user->channel.head &&
MyConnect(source_p) && !IsOper(source_p))
- check_spambot_warning(source_p, NULL);
+ check_spambot_warning(source_p, NULL);
while ((lp = source_p->user->channel.head))
- {
- chptr = lp->data;
- sendto_channel_local(ALL_MEMBERS,chptr, ":%s!%s@%s PART %s",
- source_p->name,
- source_p->username,
- source_p->host,
- RootChan(chptr)->chname);
- remove_user_from_channel(chptr, source_p, 0);
- }
+ {
+ chptr = lp->data;
+ sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s",
+ source_p->name,
+ source_p->username,
+ source_p->host, RootChan(chptr)->chname);
+ remove_user_from_channel(chptr, source_p, 0);
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_kline.c,v 1.1 2002/01/04 09:13:21 a1kmm Exp $
+ * $Id: m_kline.c,v 1.2 2002/01/04 11:06:18 a1kmm Exp $
*/
#include "tools.h"
#include "m_kline.h"
#include <errno.h>
#include <time.h>
-static void mo_kline(struct Client *,struct Client *,int,char **);
-static void ms_kline(struct Client *,struct Client *,int,char **);
-static void mo_dline(struct Client *,struct Client *,int,char **);
+static void mo_kline(struct Client *, struct Client *, int, char **);
+static void ms_kline(struct Client *, struct Client *, int, char **);
+static void mo_dline(struct Client *, struct Client *, int, char **);
struct Message kline_msgtab = {
"KLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
mod_del_cmd(&kline_msgtab);
mod_del_cmd(&dline_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
/* Local function prototypes */
-static time_t valid_tkline(struct Client *source_p, char *string);
+static time_t valid_tkline(struct Client *source_p, char *string);
static char *cluster(char *);
static int find_user_host(struct Client *source_p,
char *user_host_or_nick, char *user, char *host);
static int valid_comment(struct Client *source_p, char *comment);
static int valid_user_host(struct Client *source_p, char *user, char *host);
static int valid_wild_card(char *user, char *host);
-static int already_placed_kline(struct Client*, char*, char*);
+static int already_placed_kline(struct Client *, char *, char *);
static void apply_kline(struct Client *source_p, struct ConfItem *aconf,
const char *reason, const char *oper_reason,
- const char *current_date, time_t cur_time);
+ const char *current_date, time_t cur_time);
static void apply_tkline(struct Client *source_p, struct ConfItem *aconf,
const char *current_date, int temporary_kline_time);
char buffer[IRCD_BUFSIZE];
-char user[USERLEN+2];
-char host[HOSTLEN+2];
+char user[USERLEN + 2];
+char host[HOSTLEN + 2];
#define MAX_EXT_REASON 100
* side effects - k line is added
*
*/
-static void mo_kline(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char **parv)
+static void
+mo_kline(struct Client *client_p,
+ struct Client *source_p, int parc, char **parv)
{
char *reason = "No Reason";
char *oper_reason;
- const char* current_date;
- const char* target_server=NULL;
+ const char *current_date;
+ const char *target_server = NULL;
struct ConfItem *aconf;
- time_t tkline_time=0;
+ time_t tkline_time = 0;
time_t cur_time;
if (!IsOperK(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You need kline = yes;",
- me.name,source_p->name);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need kline = yes;",
+ me.name, source_p->name);
+ return;
+ }
parv++;
parc--;
- tkline_time = valid_tkline(source_p,*parv);
+ tkline_time = valid_tkline(source_p, *parv);
if (tkline_time == -1)
- return;
- else if( tkline_time > 0 )
- {
- parv++;
- parc--;
- }
+ return;
+ else if (tkline_time > 0)
+ {
+ parv++;
+ parc--;
+ }
if (parc == 0)
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, source_p->name, "KLINE");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, source_p->name, "KLINE");
+ return;
+ }
if (find_user_host(source_p, *parv, user, host) == 0)
- return;
+ return;
parc--;
parv++;
if (parc != 0)
+ {
+ if (irccmp(*parv, "ON") == 0)
{
- if (irccmp(*parv,"ON") == 0)
- {
- parc--;
- parv++;
- if(parc == 0)
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, source_p->name, "KLINE");
- return;
- }
- target_server = *parv;
- parc--;
- parv++;
- }
+ parc--;
+ parv++;
+ if (parc == 0)
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, source_p->name, "KLINE");
+ return;
+ }
+ target_server = *parv;
+ parc--;
+ parv++;
}
+ }
- if(parc != 0)
+ if (parc != 0)
reason = *parv;
- if(valid_user_host(source_p, user,host))
- return;
+ if (valid_user_host(source_p, user, host))
+ return;
- if(valid_wild_card(user,host))
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Please include at least %d non-wildcard characters with the user@host",
- me.name,
- source_p->name,
- ConfigFileEntry.min_nonwildcard);
- return;
- }
+ if (valid_wild_card(user, host))
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Please include at least %d non-wildcard characters with the user@host",
+ me.name, source_p->name, ConfigFileEntry.min_nonwildcard);
+ return;
+ }
- if(!valid_comment(source_p, reason))
+ if (!valid_comment(source_p, reason))
return;
-
+
cur_time = time(NULL);
current_date = smalldate(cur_time);
aconf = make_conf();
aconf->port = 0;
- if(target_server != NULL)
- {
- sendto_server(NULL, source_p, NULL, CAP_KLN, NOCAPS, LL_ICLIENT,
- ":%s KLINE %s %lu %s %s :%s",
- source_p->name,
- target_server,
- (unsigned long) tkline_time,
- user, host, reason);
-
- /* If we are sending it somewhere that doesnt include us, we stop
- * else we apply it locally too
- */
- if (!match(target_server, me.name))
- return;
- }
+ if (target_server != NULL)
+ {
+ sendto_server(NULL, source_p, NULL, CAP_KLN, NOCAPS, LL_ICLIENT,
+ ":%s KLINE %s %lu %s %s :%s",
+ source_p->name,
+ target_server,
+ (unsigned long)tkline_time, user, host, reason);
+
+ /* If we are sending it somewhere that doesnt include us, we stop
+ * else we apply it locally too
+ */
+ if (!match(target_server, me.name))
+ return;
+ }
if (already_placed_kline(source_p, user, host))
- return;
+ return;
/* Look for an oper reason */
if ((oper_reason = strchr(reason, '|')) != NULL)
- {
- *oper_reason = '\0';
- oper_reason++;
- }
+ {
+ *oper_reason = '\0';
+ oper_reason++;
+ }
- if(tkline_time)
- {
- ircsprintf(buffer,
- "Temporary K-line %d min. - %s (%s)",
- (int)(tkline_time/60),
- reason,
- current_date);
- DupString(aconf->passwd, buffer);
- apply_tkline(source_p, aconf, current_date, tkline_time);
- }
+ if (tkline_time)
+ {
+ ircsprintf(buffer,
+ "Temporary K-line %d min. - %s (%s)",
+ (int)(tkline_time / 60), reason, current_date);
+ DupString(aconf->passwd, buffer);
+ apply_tkline(source_p, aconf, current_date, tkline_time);
+ }
else
- {
- ircsprintf(buffer, "%s (%s)",
- reason,
- current_date);
- DupString(aconf->passwd, buffer);
- apply_kline(source_p, aconf, reason, oper_reason,
- current_date, cur_time);
- }
-} /* mo_kline() */
+ {
+ ircsprintf(buffer, "%s (%s)", reason, current_date);
+ DupString(aconf->passwd, buffer);
+ apply_kline(source_p, aconf, reason, oper_reason, current_date, cur_time);
+ }
+} /* mo_kline() */
/*
* ms_kline()
*
*
*/
-static void ms_kline(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_kline(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
const char *current_date;
- struct ConfItem *aconf=NULL;
- int tkline_time;
+ struct ConfItem *aconf = NULL;
+ int tkline_time;
time_t cur_time;
char *kuser;
char *khost;
char *kreason;
- if(parc != 6)
+ if (parc != 6)
return;
/* parv[0] parv[1] parv[2] parv[3] parv[4] parv[5] */
/* oper target_server tkline_time user host reason */
sendto_server(client_p, source_p, NULL, CAP_KLN, NOCAPS, LL_ICLIENT,
":%s KLINE %s %s %s %s :%s",
- parv[0], parv[1],
- parv[2], parv[3],
- parv[4], parv[5]);
+ parv[0], parv[1], parv[2], parv[3], parv[4], parv[5]);
kuser = parv[3];
khost = parv[4];
kreason = parv[5];
- if(!match(parv[1],me.name))
+ if (!match(parv[1], me.name))
return;
- if(!IsPerson(source_p))
+ if (!IsPerson(source_p))
return;
- if(valid_user_host(source_p, kuser, khost))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** %s!%s@%s on %s is requesting an Invalid K-Line for [%s@%s] [%s]",
- source_p->name, source_p->username, source_p->host, source_p->user->server,
- kuser, khost, kreason);
- return;
- }
+ if (valid_user_host(source_p, kuser, khost))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** %s!%s@%s on %s is requesting an Invalid K-Line for [%s@%s] [%s]",
+ source_p->name, source_p->username, source_p->host,
+ source_p->user->server, kuser, khost, kreason);
+ return;
+ }
- if(valid_wild_card(kuser, khost))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** %s!%s@%s on %s is requesting a K-Line without %d wildcard chars for [%s@%s] [%s]",
- source_p->name, source_p->username, source_p->host, source_p->user->server,
- ConfigFileEntry.min_nonwildcard, kuser, khost, kreason);
- return;
- }
-
- if(!valid_comment(source_p, kreason))
+ if (valid_wild_card(kuser, khost))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** %s!%s@%s on %s is requesting a K-Line without %d wildcard chars for [%s@%s] [%s]",
+ source_p->name, source_p->username, source_p->host,
+ source_p->user->server,
+ ConfigFileEntry.min_nonwildcard, kuser, khost,
+ kreason);
+ return;
+ }
+
+ if (!valid_comment(source_p, kreason))
return;
tkline_time = atoi(parv[2]);
- if(find_u_conf((char *)source_p->user->server, source_p->username, source_p->host))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** Received K-Line for [%s@%s] [%s], from %s!%s@%s on %s",
- kuser,
- khost,
- kreason,
- source_p->name,
- source_p->username,
- source_p->host,
- source_p->user->server);
-
- /* We check if the kline already exists after we've announced its
- * arrived, to avoid confusing opers - fl
- */
- if (already_placed_kline(source_p, kuser, khost))
- return;
+ if (find_u_conf
+ ((char *)source_p->user->server, source_p->username, source_p->host))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** Received K-Line for [%s@%s] [%s], from %s!%s@%s on %s",
+ kuser,
+ khost,
+ kreason,
+ source_p->name,
+ source_p->username,
+ source_p->host, source_p->user->server);
+
+ /* We check if the kline already exists after we've announced its
+ * arrived, to avoid confusing opers - fl
+ */
+ if (already_placed_kline(source_p, kuser, khost))
+ return;
- aconf = make_conf();
+ aconf = make_conf();
- aconf->status = CONF_KILL;
- DupString(aconf->user, kuser);
- DupString(aconf->host, khost);
- DupString(aconf->passwd, kreason);
- current_date = smalldate((time_t) 0);
+ aconf->status = CONF_KILL;
+ DupString(aconf->user, kuser);
+ DupString(aconf->host, khost);
+ DupString(aconf->passwd, kreason);
+ current_date = smalldate((time_t) 0);
- cur_time = time(NULL);
+ cur_time = time(NULL);
- if(tkline_time)
- apply_tkline(source_p, aconf, current_date, tkline_time);
- else
- apply_kline(source_p, aconf, aconf->passwd, NULL,
- current_date, cur_time);
+ if (tkline_time)
+ apply_tkline(source_p, aconf, current_date, tkline_time);
+ else
+ apply_kline(source_p, aconf, aconf->passwd, NULL,
+ current_date, cur_time);
- }
-} /* ms_kline() */
+ }
+} /* ms_kline() */
/*
* apply_kline
* side effects - kline as given, is added to the hashtable
* and conf file
*/
-static void
+static void
apply_kline(struct Client *source_p, struct ConfItem *aconf,
- const char *reason, const char *oper_reason,
- const char *current_date, time_t cur_time)
+ const char *reason, const char *oper_reason,
+ const char *current_date, time_t cur_time)
{
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
WriteKlineOrDline(KLINE_TYPE, source_p, aconf->user, aconf->host,
- reason, oper_reason, current_date, cur_time);
+ reason, oper_reason, current_date, cur_time);
/* Now, activate kline against current online clients */
check_klines();
}
* output - NONE
* side effects - tkline as given is placed
*/
-static void apply_tkline(struct Client *source_p, struct ConfItem *aconf,
- const char *current_date, int tkline_time)
+static void
+apply_tkline(struct Client *source_p, struct ConfItem *aconf,
+ const char *current_date, int tkline_time)
{
- aconf->hold = CurrentTime + tkline_time;
- add_temp_kline(aconf);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s added temporary %d min. K-Line for [%s@%s] [%s]",
- source_p->name, tkline_time/60, aconf->user, aconf->host,
- aconf->passwd);
- sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line for [%s@%s]",
- me.name, source_p->name, tkline_time/60, aconf->user, aconf->host);
- ilog(L_TRACE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
- source_p->name, tkline_time/60, aconf->user, aconf->host, aconf->passwd);
- check_klines();
+ aconf->hold = CurrentTime + tkline_time;
+ add_temp_kline(aconf);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s added temporary %d min. K-Line for [%s@%s] [%s]",
+ source_p->name, tkline_time / 60, aconf->user,
+ aconf->host, aconf->passwd);
+ sendto_one(source_p,
+ ":%s NOTICE %s :Added temporary %d min. K-Line for [%s@%s]",
+ me.name, source_p->name, tkline_time / 60, aconf->user,
+ aconf->host);
+ ilog(L_TRACE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
+ source_p->name, tkline_time / 60, aconf->user, aconf->host,
+ aconf->passwd);
+ check_klines();
}
/*
* - 0 if not an integer number, else the number
* side effects - none
*/
-static time_t valid_tkline(struct Client *source_p, char *p)
+static time_t
+valid_tkline(struct Client *source_p, char *p)
{
time_t result = 0;
- while(*p)
+ while (*p)
+ {
+ if (IsDigit(*p))
{
- if(IsDigit(*p))
- {
- result *= 10;
- result += ((*p) & 0xF);
- p++;
- }
- else
- return(0);
+ result *= 10;
+ result += ((*p) & 0xF);
+ p++;
}
+ else
+ return (0);
+ }
/* in the degenerate case where oper does a /quote kline 0 user@host :reason
* i.e. they specifically use 0, I am going to return 1 instead
* as a return value of non-zero is used to flag it as a temporary kline
*/
- if(result == 0)
+ if (result == 0)
result = 1;
- if(result > (24*60))
- result = (24*60); /* Max it at 24 hours */
+ if (result > (24 * 60))
+ result = (24 * 60); /* Max it at 24 hours */
- result = (time_t)result * (time_t)60; /* turn it into seconds */
+ result = (time_t) result *(time_t) 60; /* turn it into seconds */
- return(result);
+ return (result);
}
/*
* side effects - NONE
*
*/
-static char *cluster(char *hostname)
+static char *
+cluster(char *hostname)
{
static char result[HOSTLEN + 1]; /* result to return */
- char temphost[HOSTLEN + 1]; /* work place */
- char *ipp; /* used to find if host is ip # only */
- char *host_mask; /* used to find host mask portion to '*' */
- char *zap_point = NULL; /* used to zap last nnn portion of an ip # */
- char *tld; /* Top Level Domain */
- int is_ip_number; /* flag if its an ip # */
- int number_of_dots; /* count number of dots for both ip# and
+ char temphost[HOSTLEN + 1]; /* work place */
+ char *ipp; /* used to find if host is ip # only */
+ char *host_mask; /* used to find host mask portion to '*' */
+ char *zap_point = NULL; /* used to zap last nnn portion of an ip # */
+ char *tld; /* Top Level Domain */
+ int is_ip_number; /* flag if its an ip # */
+ int number_of_dots; /* count number of dots for both ip# and
domain klines */
if (!hostname)
- return (char *) NULL; /* EEK! */
+ return (char *)NULL; /* EEK! */
/* If a '@' is found in the hostname, this is bogus
* and must have been introduced by server that doesn't
* I could also legitimately return (char *)NULL as above.
*/
- if(strchr(hostname,'@'))
- {
- strncpy_irc(result, hostname, HOSTLEN);
- result[HOSTLEN] = '\0';
- return(result);
- }
+ if (strchr(hostname, '@'))
+ {
+ strncpy_irc(result, hostname, HOSTLEN);
+ result[HOSTLEN] = '\0';
+ return (result);
+ }
strncpy_irc(temphost, hostname, HOSTLEN);
temphost[HOSTLEN] = '\0';
- is_ip_number = YES; /* assume its an IP# */
+ is_ip_number = YES; /* assume its an IP# */
ipp = temphost;
number_of_dots = 0;
while (*ipp)
+ {
+ if (*ipp == '.')
{
- if( *ipp == '.' )
- {
- number_of_dots++;
+ number_of_dots++;
- if(number_of_dots == 3)
- zap_point = ipp;
- ipp++;
- }
- else if(!IsDigit(*ipp))
- {
- is_ip_number = NO;
- break;
- }
+ if (number_of_dots == 3)
+ zap_point = ipp;
ipp++;
}
-
- if(is_ip_number && (number_of_dots == 3))
+ else if (!IsDigit(*ipp))
{
- zap_point++;
- *zap_point++ = '*'; /* turn 111.222.333.444 into */
- *zap_point = '\0'; /* 111.222.333.* */
- strncpy_irc(result, temphost, HOSTLEN);
- result[HOSTLEN] = '\0';
- return(result);
+ is_ip_number = NO;
+ break;
}
+ ipp++;
+ }
+
+ if (is_ip_number && (number_of_dots == 3))
+ {
+ zap_point++;
+ *zap_point++ = '*'; /* turn 111.222.333.444 into */
+ *zap_point = '\0'; /* 111.222.333.* */
+ strncpy_irc(result, temphost, HOSTLEN);
+ result[HOSTLEN] = '\0';
+ return (result);
+ }
else
+ {
+ tld = strrchr(temphost, '.');
+ if (tld)
{
- tld = strrchr(temphost, '.');
- if(tld)
- {
- number_of_dots = 2;
- if(tld[3]) /* its at least a 3 letter tld
- i.e. ".com" tld[3] = 'm' not
- '\0' */
- /* 4 letter tld's are coming */
- number_of_dots = 1;
-
- if(tld != temphost) /* in these days of dns spoofers ...*/
- host_mask = tld - 1; /* Look for host portion to '*' */
- else
- host_mask = tld; /* degenerate case hostname is
- '.com' etc. */
-
- while (host_mask != temphost)
- {
- if(*host_mask == '.')
- number_of_dots--;
- if(number_of_dots == 0)
- {
- result[0] = '*';
- strncpy_irc(result + 1, host_mask, HOSTLEN - 1);
- result[HOSTLEN] = '\0';
- return(result);
- }
- host_mask--;
- }
- result[0] = '*'; /* foo.com => *foo.com */
- strncpy_irc(result + 1, temphost, HOSTLEN - 1);
- result[HOSTLEN] = '\0';
- }
- else /* no tld found oops. just return it as is */
+ number_of_dots = 2;
+ if (tld[3]) /* its at least a 3 letter tld
+ i.e. ".com" tld[3] = 'm' not
+ '\0' */
+ /* 4 letter tld's are coming */
+ number_of_dots = 1;
+
+ if (tld != temphost) /* in these days of dns spoofers ... */
+ host_mask = tld - 1; /* Look for host portion to '*' */
+ else
+ host_mask = tld; /* degenerate case hostname is
+ '.com' etc. */
+
+ while (host_mask != temphost)
+ {
+ if (*host_mask == '.')
+ number_of_dots--;
+ if (number_of_dots == 0)
{
- strncpy_irc(result, temphost, HOSTLEN);
+ result[0] = '*';
+ strncpy_irc(result + 1, host_mask, HOSTLEN - 1);
result[HOSTLEN] = '\0';
- return(result);
+ return (result);
}
+ host_mask--;
+ }
+ result[0] = '*'; /* foo.com => *foo.com */
+ strncpy_irc(result + 1, temphost, HOSTLEN - 1);
+ result[HOSTLEN] = '\0';
}
+ else /* no tld found oops. just return it as is */
+ {
+ strncpy_irc(result, temphost, HOSTLEN);
+ result[HOSTLEN] = '\0';
+ return (result);
+ }
+ }
return (result);
}
* side effects - D line is added
*
*/
-static void mo_dline(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_dline(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
char *dlhost, *reason, *oper_reason;
#ifndef IPV6
struct ConfItem *aconf;
int bits, t;
char dlbuffer[1024];
- const char* current_date;
+ const char *current_date;
time_t cur_time;
- if(!IsOperK(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You need kline = yes;",me.name,parv[0]);
- return;
- }
+ if (!IsOperK(source_p))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need kline = yes;", me.name,
+ parv[0]);
+ return;
+ }
dlhost = parv[1];
strncpy_irc(cidr_form_host, dlhost, HOSTLEN);
cidr_form_host[HOSTLEN] = '\0';
- if ((t=parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
+ if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
{
#ifdef IPV6
- sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.",
- me.name, parv[0]);
- return;
+ sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.",
+ me.name, parv[0]);
+ return;
#else
- if (!(target_p = find_chasing(source_p, parv[1], NULL)))
- return;
+ if (!(target_p = find_chasing(source_p, parv[1], NULL)))
+ return;
- if(!target_p->user)
- return;
- t = HM_IPV4;
- if (IsServer(target_p))
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Can't DLINE a server silly",
- me.name, parv[0]);
- return;
- }
-
- if(!MyConnect(target_p))
- {
- sendto_one(source_p,
- ":%s NOTICE :%s :Can't DLINE nick on another server",
- me.name, parv[0]);
- return;
- }
+ if (!target_p->user)
+ return;
+ t = HM_IPV4;
+ if (IsServer(target_p))
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Can't DLINE a server silly",
+ me.name, parv[0]);
+ return;
+ }
- if(IsExemptKline(target_p))
- {
- sendto_one(source_p,
- ":%s NOTICE %s :%s is E-lined",me.name,parv[0],
- target_p->name);
- return;
- }
+ if (!MyConnect(target_p))
+ {
+ sendto_one(source_p,
+ ":%s NOTICE :%s :Can't DLINE nick on another server",
+ me.name, parv[0]);
+ return;
+ }
- /*
- * XXX - this is always a fixed length output, we can get away
- * with strcpy here
- *
- * strncpy_irc(cidr_form_host, inetntoa((char *)&target_p->ip), 32);
- * cidr_form_host[32] = '\0';
- */
- strcpy(cidr_form_host, inetntoa((char*) &target_p->localClient->ip));
-
- if ((p = strchr(cidr_form_host,'.')) == NULL)
- return;
- /* 192. <- p */
+ if (IsExemptKline(target_p))
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :%s is E-lined", me.name, parv[0],
+ target_p->name);
+ return;
+ }
- p++;
- if ((p = strchr(p,'.')) == NULL)
- return;
- /* 192.168. <- p */
+ /*
+ * XXX - this is always a fixed length output, we can get away
+ * with strcpy here
+ *
+ * strncpy_irc(cidr_form_host, inetntoa((char *)&target_p->ip), 32);
+ * cidr_form_host[32] = '\0';
+ */
+ strcpy(cidr_form_host, inetntoa((char *)&target_p->localClient->ip));
- p++;
- if ((p = strchr(p,'.')) == NULL)
- return;
- /* 192.168.0. <- p */
+ if ((p = strchr(cidr_form_host, '.')) == NULL)
+ return;
+ /* 192. <- p */
- p++;
- *p++ = '0';
- *p++ = '/';
- *p++ = '2';
- *p++ = '4';
- *p++ = '\0';
- dlhost = cidr_form_host;
-
- bits = 0xFFFFFF00L;
+ p++;
+ if ((p = strchr(p, '.')) == NULL)
+ return;
+ /* 192.168. <- p */
+
+ p++;
+ if ((p = strchr(p, '.')) == NULL)
+ return;
+ /* 192.168.0. <- p */
+
+ p++;
+ *p++ = '0';
+ *p++ = '/';
+ *p++ = '2';
+ *p++ = '4';
+ *p++ = '\0';
+ dlhost = cidr_form_host;
+
+ bits = 0xFFFFFF00L;
/* XXX: Fix me for IPV6 */
#endif
- }
+ }
- if (parc > 2) /* host :reason */
- {
- if ( valid_comment(source_p,parv[2]) == 0 )
- return;
+ if (parc > 2) /* host :reason */
+ {
+ if (valid_comment(source_p, parv[2]) == 0)
+ return;
- if(*parv[2])
- reason = parv[2];
- else
- reason = "No reason";
- }
+ if (*parv[2])
+ reason = parv[2];
+ else
+ reason = "No reason";
+ }
else
reason = "No reason";
- if(IsOperAdmin(source_p))
+ if (IsOperAdmin(source_p))
+ {
+ if (bits < 8)
{
- if (bits < 8)
- {
- sendto_one(source_p,
- ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.",
- me.name, parv[0]);
- return;
- }
+ sendto_one(source_p,
+ ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.",
+ me.name, parv[0]);
+ return;
}
+ }
else
+ {
+ if (bits < 24)
{
- if (bits < 24)
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Dline bitmasks less than 24 are for admins only.",
- me.name, parv[0]);
- return;
- }
+ sendto_one(source_p,
+ ":%s NOTICE %s :Dline bitmasks less than 24 are for admins only.",
+ me.name, parv[0]);
+ return;
}
+ }
#ifdef IPV6
if (t == HM_IPV6)
- t = AF_INET6;
+ t = AF_INET6;
else
#endif
- t = AF_INET;
- if (ConfigFileEntry.non_redundant_klines &&
- (aconf = find_dline(&daddr, t)) )
- {
- char *creason;
- creason = aconf->passwd ? aconf->passwd : "<No Reason>";
- if (IsConfExemptKline(aconf))
- sendto_one(source_p, ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
- me.name, parv[0], dlhost, aconf->host, creason);
- else
- sendto_one(source_p, ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
- me.name, parv[0], dlhost, aconf->host, creason);
- return;
+ t = AF_INET;
+ if (ConfigFileEntry.non_redundant_klines && (aconf = find_dline(&daddr, t)))
+ {
+ char *creason;
+ creason = aconf->passwd ? aconf->passwd : "<No Reason>";
+ if (IsConfExemptKline(aconf))
+ sendto_one(source_p, ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
+ me.name, parv[0], dlhost, aconf->host, creason);
+ else
+ sendto_one(source_p, ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
+ me.name, parv[0], dlhost, aconf->host, creason);
+ return;
}
cur_time = time(0);
current_date = smalldate(cur_time);
/* Look for an oper reason */
if ((oper_reason = strchr(reason, '|')) != NULL)
- {
- *oper_reason = '\0';
- oper_reason++;
- }
+ {
+ *oper_reason = '\0';
+ oper_reason++;
+ }
- ircsprintf(dlbuffer, "%s (%s)",reason, current_date);
+ ircsprintf(dlbuffer, "%s (%s)", reason, current_date);
aconf->status = CONF_DLINE;
DupString(aconf->host, dlhost);
* Write dline to configuration file
*/
WriteKlineOrDline(DLINE_TYPE, source_p, NULL, dlhost, reason,
- oper_reason, current_date, cur_time);
+ oper_reason, current_date, cur_time);
check_klines();
-} /* m_dline() */
+} /* m_dline() */
/*
* find_user_host
* output - 0 if not ok to kline, 1 to kline i.e. if valid user host
* side effects -
*/
-static int find_user_host(struct Client *source_p,
- char *user_host_or_nick, char *luser, char *lhost)
+static int
+find_user_host(struct Client *source_p,
+ char *user_host_or_nick, char *luser, char *lhost)
{
struct Client *target_p;
char *hostp;
- if ( (hostp = strchr(user_host_or_nick, '@')) || *user_host_or_nick == '*' )
- {
- /* Explicit user@host mask given */
-
- if(hostp) /* I'm a little user@host */
- {
- *(hostp++) = '\0'; /* short and squat */
- strncpy(luser,user_host_or_nick,USERLEN); /* here is my user */
- strncpy(lhost,hostp,HOSTLEN); /* here is my host */
- }
- else
- {
- luser[0] = '*'; /* no @ found, assume its *@somehost */
- luser[1] = '\0';
- strncpy(lhost,user_host_or_nick,HOSTLEN);
- }
+ if ((hostp = strchr(user_host_or_nick, '@')) || *user_host_or_nick == '*')
+ {
+ /* Explicit user@host mask given */
- return 1;
+ if (hostp) /* I'm a little user@host */
+ {
+ *(hostp++) = '\0'; /* short and squat */
+ strncpy(luser, user_host_or_nick, USERLEN); /* here is my user */
+ strncpy(lhost, hostp, HOSTLEN); /* here is my host */
}
- else
+ else
{
- /* Try to find user@host mask from nick */
+ luser[0] = '*'; /* no @ found, assume its *@somehost */
+ luser[1] = '\0';
+ strncpy(lhost, user_host_or_nick, HOSTLEN);
+ }
- if (!(target_p = find_chasing(source_p, user_host_or_nick, NULL)))
- return 0;
+ return 1;
+ }
+ else
+ {
+ /* Try to find user@host mask from nick */
- if(!target_p->user)
- return 0;
+ if (!(target_p = find_chasing(source_p, user_host_or_nick, NULL)))
+ return 0;
- if (IsServer(target_p))
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Can't KLINE a server, use @'s where appropriate",
- me.name, source_p->name);
- return 0;
- }
+ if (!target_p->user)
+ return 0;
- if(IsExemptKline(target_p))
- {
- if(!IsServer(source_p))
- sendto_one(source_p,
- ":%s NOTICE %s :%s is E-lined",me.name,source_p->name,
- target_p->name);
- return 0;
- }
+ if (IsServer(target_p))
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Can't KLINE a server, use @'s where appropriate",
+ me.name, source_p->name);
+ return 0;
+ }
- /* turn the "user" bit into "*user", blow away '~'
- * if found in original user name (non-idented)
- */
+ if (IsExemptKline(target_p))
+ {
+ if (!IsServer(source_p))
+ sendto_one(source_p,
+ ":%s NOTICE %s :%s is E-lined", me.name, source_p->name,
+ target_p->name);
+ return 0;
+ }
- strncpy_irc(luser, target_p->username, USERLEN);
- if (*target_p->username == '~')
- luser[0] = '*';
+ /* turn the "user" bit into "*user", blow away '~'
+ * if found in original user name (non-idented)
+ */
- strncpy_irc(lhost,cluster(target_p->host),HOSTLEN);
- }
+ strncpy_irc(luser, target_p->username, USERLEN);
+ if (*target_p->username == '~')
+ luser[0] = '*';
+
+ strncpy_irc(lhost, cluster(target_p->host), HOSTLEN);
+ }
return 1;
}
* output - 1 if not valid user or host, 0 if valid
* side effects -
*/
-static int valid_user_host(struct Client *source_p, char *luser, char *lhost)
+static int
+valid_user_host(struct Client *source_p, char *luser, char *lhost)
{
/*
* Check for # in user@host
*/
- if(strchr(lhost, '#') || strchr(luser, '#'))
+ if (strchr(lhost, '#') || strchr(luser, '#'))
{
sendto_one(source_p, ":%s NOTICE %s :Invalid character '#' in kline",
- me.name, source_p->name);
+ me.name, source_p->name);
return 1;
}
/* Dont let people kline *!ident@host, as the ! is invalid.. */
- if(strchr(luser, '!'))
+ if (strchr(luser, '!'))
{
sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in kline",
me.name, source_p->name);
* output - 0 if not valid, 1 if valid
* side effects -
*/
-static int valid_wild_card(char *luser, char *lhost)
+static int
+valid_wild_card(char *luser, char *lhost)
{
char *p;
char tmpch;
* output - 0 if no valid comment, 1 if valid
* side effects - NONE
*/
-static int valid_comment(struct Client *source_p, char *comment)
+static int
+valid_comment(struct Client *source_p, char *comment)
{
- if(strchr(comment, '"'))
- {
- if(!IsServer(source_p))
- sendto_one(source_p,
- ":%s NOTICE %s :Invalid character '\"' in comment",
- me.name, source_p->name);
- return 0;
- }
+ if (strchr(comment, '"'))
+ {
+ if (!IsServer(source_p))
+ sendto_one(source_p,
+ ":%s NOTICE %s :Invalid character '\"' in comment",
+ me.name, source_p->name);
+ return 0;
+ }
return 1;
}
static int
already_placed_kline(struct Client *source_p, char *luser, char *lhost)
{
- char *reason;
- struct irc_inaddr iphost, *piphost;
- struct ConfItem *aconf;
- int t;
- if (ConfigFileEntry.non_redundant_klines)
- {
- if ((t=parse_netmask(lhost, &iphost, &t)) != HM_HOST)
+ char *reason;
+ struct irc_inaddr iphost, *piphost;
+ struct ConfItem *aconf;
+ int t;
+ if (ConfigFileEntry.non_redundant_klines)
{
+ if ((t = parse_netmask(lhost, &iphost, &t)) != HM_HOST)
+ {
#ifdef IPV6
- if (t == HM_IPV6)
- t = AF_INET6;
- else
+ if (t == HM_IPV6)
+ t = AF_INET6;
+ else
#endif
- t = AF_INET;
- piphost = &iphost;
- }
- else
- {
- t = 0;
- piphost = NULL;
- }
- if ((aconf = find_conf_by_address(lhost, piphost, CONF_KILL, t, luser)))
- {
- reason = aconf->passwd ? aconf->passwd : "<No Reason>";
- /* Remote servers can set klines, so if its a dupe we warn all
- * local opers and leave it at that
- */
- if (IsServer(source_p))
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** Remote K-Line [%s@%s] already K-Lined by [%s@%s] - %s",
- luser, lhost, aconf->user, aconf->host, reason);
- else
- sendto_one(source_p,
- ":%s NOTICE %s :[%s@%s] already K-Lined by [%s@%s] - %s",
- me.name, source_p->name, luser, lhost, aconf->user,
- aconf->host, reason);
- return 1;
+ t = AF_INET;
+ piphost = &iphost;
+ }
+ else
+ {
+ t = 0;
+ piphost = NULL;
+ }
+ if ((aconf = find_conf_by_address(lhost, piphost, CONF_KILL, t, luser)))
+ {
+ reason = aconf->passwd ? aconf->passwd : "<No Reason>";
+ /* Remote servers can set klines, so if its a dupe we warn all
+ * local opers and leave it at that
+ */
+ if (IsServer(source_p))
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** Remote K-Line [%s@%s] already K-Lined by [%s@%s] - %s",
+ luser, lhost, aconf->user, aconf->host, reason);
+ else
+ sendto_one(source_p,
+ ":%s NOTICE %s :[%s@%s] already K-Lined by [%s@%s] - %s",
+ me.name, source_p->name, luser, lhost, aconf->user,
+ aconf->host, reason);
+ return 1;
+ }
}
- }
- return 0;
+ return 0;
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_knock.c,v 1.1 2002/01/04 09:13:22 a1kmm Exp $
+ * $Id: m_knock.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include <string.h>
-static void m_knock(struct Client*, struct Client*, int, char**);
-static void ms_knock(struct Client *, struct Client *, int, char**);
+static void m_knock(struct Client *, struct Client *, int, char **);
+static void ms_knock(struct Client *, struct Client *, int, char **);
static void parse_knock_local(struct Client *, struct Client *,
int, char **, char *);
mod_del_cmd(&knockll_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/* m_knock
* dont know about, for us to answer.
*/
-static void m_knock(struct Client *client_p,
- struct Client *source_p,
- int parc, char *parv[])
+static void
+m_knock(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
char *sockhost = NULL;
-
- if((ConfigChannel.use_knock == 0) && MyClient(source_p))
- {
- sendto_one(source_p, form_str(ERR_KNOCKDISABLED),
- me.name, source_p->name);
- return;
- }
+
+ if ((ConfigChannel.use_knock == 0) && MyClient(source_p))
+ {
+ sendto_one(source_p, form_str(ERR_KNOCKDISABLED),
+ me.name, source_p->name);
+ return;
+ }
/* a remote KNOCKLL request, check we're capable of handling it.. */
- if(!MyConnect(source_p))
+ if (!MyConnect(source_p))
{
- if(!ServerInfo.hub || !IsCapable(client_p, CAP_LL) || parc < 3)
+ if (!ServerInfo.hub || !IsCapable(client_p, CAP_LL) || parc < 3)
return;
else
{
* exists.. done here to save messing in parse_knock_local()
*/
sockhost = parv[2];
-
- if(parc > 3)
+
+ if (parc > 3)
{
parv[2] = parv[3];
parv[3] = NULL;
parc--;
}
}
-
- if(IsClient(source_p))
+
+ if (IsClient(source_p))
parse_knock_local(client_p, source_p, parc, parv, sockhost);
}
* parv[1] = channel
* parv[2] = vchan id
*/
-
-static void ms_knock(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+
+static void
+ms_knock(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- if(IsClient(source_p))
+ if (IsClient(source_p))
parse_knock_remote(client_p, source_p, parc, parv);
}
* or sends failure message to source_p
*/
-static void parse_knock_local(struct Client *client_p,
- struct Client *source_p,
- int parc, char *parv[], char *sockhost)
+static void
+parse_knock_local(struct Client *client_p,
+ struct Client *source_p,
+ int parc, char *parv[], char *sockhost)
{
/* We will cut at the first comma reached, however we will not *
* process anything afterwards. */
- struct Channel *chptr,*vchan_chptr;
+ struct Channel *chptr, *vchan_chptr;
char *p, *name, *key;
name = parv[1];
key = (parc > 2) ? parv[2] : NULL;
- if( (p = strchr(name,',')) )
+ if ((p = strchr(name, ',')))
*p = '\0';
- if(!IsChannelName(name))
+ if (!IsChannelName(name))
{
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, parv[0], name);
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), me.name, parv[0], name);
return;
}
- if(!(chptr = hash_find_channel(name)))
+ if (!(chptr = hash_find_channel(name)))
{
- if(!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
{
sendto_one(uplink, ":%s KNOCKLL %s %s %s",
source_p->name, parv[1],
- IsIPSpoof(source_p) ? "255.255.255.255" :
- source_p->localClient->sockhost,
- (parc > 2) ? parv[2] : "");
+ IsIPSpoof(source_p) ? "255.255.255.255" :
+ source_p->localClient->sockhost, (parc > 2) ? parv[2] : "");
}
else
{
}
if (IsVchanTop(chptr))
+ {
+ /* They specified a vchan basename */
+ if (on_sub_vchan(chptr, source_p))
{
- /* They specified a vchan basename */
- if(on_sub_vchan(chptr,source_p))
- {
- sendto_one(source_p, form_str(ERR_KNOCKONCHAN),
- me.name, source_p->name, name);
- return;
- }
- if (key && key[0] == '!')
- {
- /* Make "KNOCK #channel !" work like JOIN */
- if (!key[1])
- {
- show_vchans(source_p, chptr, "knock");
- return;
- }
-
- /* Find a matching vchan */
- if ((vchan_chptr = find_vchan(chptr, key)))
- {
- chptr = vchan_chptr;
- }
- else
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, parv[0], name);
- return;
- }
- }
+ sendto_one(source_p, form_str(ERR_KNOCKONCHAN),
+ me.name, source_p->name, name);
+ return;
+ }
+ if (key && key[0] == '!')
+ {
+ /* Make "KNOCK #channel !" work like JOIN */
+ if (!key[1])
+ {
+ show_vchans(source_p, chptr, "knock");
+ return;
+ }
+
+ /* Find a matching vchan */
+ if ((vchan_chptr = find_vchan(chptr, key)))
+ {
+ chptr = vchan_chptr;
+ }
else
- {
- /* No key specified */
- show_vchans(source_p, chptr, "knock");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, parv[0], name);
+ return;
+ }
}
- else if (IsVchan(chptr))
+ else
{
- /* Don't allow KNOCK'ing a vchans 'real' name */
- sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name, parv[0],
- name);
+ /* No key specified */
+ show_vchans(source_p, chptr, "knock");
return;
}
+ }
+ else if (IsVchan(chptr))
+ {
+ /* Don't allow KNOCK'ing a vchans 'real' name */
+ sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name, parv[0], name);
+ return;
+ }
else
+ {
+ /* Normal channel, just be sure they aren't on it */
+ if (IsMember(source_p, chptr))
{
- /* Normal channel, just be sure they aren't on it */
- if (IsMember(source_p, chptr))
- {
- sendto_one(source_p, form_str(ERR_KNOCKONCHAN),
- me.name, source_p->name, name);
- return;
- }
- }
-
- if(!((chptr->mode.mode & MODE_INVITEONLY) ||
- (*chptr->mode.key) ||
- (chptr->mode.limit && chptr->users >= chptr->mode.limit )
- ))
- {
- sendto_one(source_p, form_str(ERR_CHANOPEN),
+ sendto_one(source_p, form_str(ERR_KNOCKONCHAN),
me.name, source_p->name, name);
return;
}
+ }
+
+ if (!((chptr->mode.mode & MODE_INVITEONLY) ||
+ (*chptr->mode.key) ||
+ (chptr->mode.limit && chptr->users >= chptr->mode.limit)))
+ {
+ sendto_one(source_p, form_str(ERR_CHANOPEN),
+ me.name, source_p->name, name);
+ return;
+ }
/* don't allow a knock if the user is banned, or the channel is secret */
if ((chptr->mode.mode & MODE_SECRET) ||
(sockhost && is_banned_knock(chptr, source_p, sockhost)) ||
(!sockhost && is_banned(chptr, source_p)))
- {
- sendto_one(source_p, form_str(ERR_CANNOTSENDTOCHAN), me.name, parv[0],
- name);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_CANNOTSENDTOCHAN), me.name, parv[0],
+ name);
+ return;
+ }
/* flood protection:
* allow one knock per user per knock_delay
*
* we only limit local requests..
*/
- if(MyClient(source_p) &&
- (source_p->localClient->last_knock + ConfigChannel.knock_delay) > CurrentTime)
+ if (MyClient(source_p) &&
+ (source_p->localClient->last_knock + ConfigChannel.knock_delay) >
+ CurrentTime)
{
sendto_one(source_p, form_str(ERR_TOOMANYKNOCK),
me.name, source_p->name, parv[1], "user");
return;
}
- else if((chptr->last_knock +
- ConfigChannel.knock_delay_channel) > CurrentTime)
+ else if ((chptr->last_knock +
+ ConfigChannel.knock_delay_channel) > CurrentTime)
{
sendto_one(source_p, form_str(ERR_TOOMANYKNOCK),
me.name, source_p->name, parv[1], "channel");
* side effects - knock is checked for validity, if valid send_knock() is
* called
*/
-static void parse_knock_remote(struct Client *client_p,
- struct Client *source_p,
- int parc, char *parv[])
+static void
+parse_knock_remote(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- struct Channel *chptr,*vchan_chptr;
+ struct Channel *chptr, *vchan_chptr;
char *p, *name, *key;
name = parv[1];
key = (parc > 2) ? parv[2] : NULL;
- if( (p = strchr(name,',')) )
+ if ((p = strchr(name, ',')))
*p = '\0';
- if(!IsChannelName(name) || !(chptr = hash_find_channel(name)))
+ if (!IsChannelName(name) || !(chptr = hash_find_channel(name)))
return;
- if(IsVchanTop(chptr))
+ if (IsVchanTop(chptr))
{
- if(on_sub_vchan(chptr,source_p))
+ if (on_sub_vchan(chptr, source_p))
return;
- if(key && (key[0] == '!') && (vchan_chptr = find_vchan(chptr, key)))
+ if (key && (key[0] == '!') && (vchan_chptr = find_vchan(chptr, key)))
chptr = vchan_chptr;
else
return;
}
- else if(IsVchan(chptr) || IsMember(source_p, chptr))
+ else if (IsVchan(chptr) || IsMember(source_p, chptr))
return;
-
- if(!((chptr->mode.mode & MODE_INVITEONLY) ||
- (*chptr->mode.key) ||
- (chptr->mode.limit && chptr->users >= chptr->mode.limit)))
+
+ if (!((chptr->mode.mode & MODE_INVITEONLY) ||
+ (*chptr->mode.key) ||
+ (chptr->mode.limit && chptr->users >= chptr->mode.limit)))
return;
- if(chptr)
+ if (chptr)
send_knock(client_p, source_p, chptr, name, key, 0);
return;
* side effects - knock is sent locally (if enabled) and propagated
*/
-static void send_knock(struct Client *client_p, struct Client *source_p,
- struct Channel *chptr, char *name, char *key,
- int llclient)
+static void
+send_knock(struct Client *client_p, struct Client *source_p,
+ struct Channel *chptr, char *name, char *key, int llclient)
{
chptr->last_knock = CurrentTime;
- if(MyClient(source_p))
+ if (MyClient(source_p))
{
source_p->localClient->last_knock = CurrentTime;
sendto_one(source_p, form_str(RPL_KNOCKDLVR),
me.name, source_p->name, name);
}
- else if(llclient == 1)
+ else if (llclient == 1)
sendto_one(source_p, form_str(RPL_KNOCKDLVR),
me.name, source_p->name, name);
- if(source_p->user != NULL)
- {
- if(ConfigChannel.use_knock)
- sendto_channel_local(ONLY_CHANOPS_HALFOPS,
- chptr,
- form_str(RPL_KNOCK),
- me.name,
- source_p->name,
- name,
- source_p->name,
- source_p->username,
- source_p->host);
-
- sendto_server(client_p, source_p, chptr, CAP_KNOCK, NOCAPS, LL_ICLIENT,
- ":%s KNOCK %s %s",
- source_p->name, name, key ? key : "");
- }
+ if (source_p->user != NULL)
+ {
+ if (ConfigChannel.use_knock)
+ sendto_channel_local(ONLY_CHANOPS_HALFOPS,
+ chptr,
+ form_str(RPL_KNOCK),
+ me.name,
+ source_p->name,
+ name,
+ source_p->name,
+ source_p->username, source_p->host);
+
+ sendto_server(client_p, source_p, chptr, CAP_KNOCK, NOCAPS, LL_ICLIENT,
+ ":%s KNOCK %s %s", source_p->name, name, key ? key : "");
+ }
return;
}
* output -
* side effects - return check_banned_knock()
*/
-static int is_banned_knock(struct Channel *chptr, struct Client *who,
- char *sockhost)
+static int
+is_banned_knock(struct Channel *chptr, struct Client *who, char *sockhost)
{
char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
- if(!IsPerson(who))
+ if (!IsPerson(who))
return 0;
- ircsprintf(src_host,"%s!%s@%s", who->name, who->username, who->host);
- ircsprintf(src_iphost,"%s!%s@%s", who->name, who->username, sockhost);
+ ircsprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
+ ircsprintf(src_iphost, "%s!%s@%s", who->name, who->username, sockhost);
return (check_banned_knock(chptr, who, src_host, src_iphost));
}
* output -
* side effects - return CHFL_EXCEPTION, CHFL_BAN or 0
*/
-static int check_banned_knock(struct Channel *chptr, struct Client *who,
- char *s, char *s2)
+static int
+check_banned_knock(struct Channel *chptr, struct Client *who,
+ char *s, char *s2)
{
dlink_node *ban;
dlink_node *except;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_links.c,v 1.1 2002/01/04 09:13:22 a1kmm Exp $
+ * $Id: m_links.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include <assert.h>
#include <string.h>
-static void m_links(struct Client*, struct Client*, int, char**);
-static void mo_links(struct Client*, struct Client*, int, char**);
-static void ms_links(struct Client*, struct Client*, int, char**);
+static void m_links(struct Client *, struct Client *, int, char **);
+static void mo_links(struct Client *, struct Client *, int, char **);
+static void ms_links(struct Client *, struct Client *, int, char **);
struct Message links_msgtab = {
"LINKS", 0, 0, 0, 0, MFLG_SLOW, 0,
void
_modinit(void)
{
- hook_add_event("doing_links");
+ hook_add_event("doing_links");
mod_add_cmd(&links_msgtab);
}
void
_moddeinit(void)
{
- hook_del_event("doing_links");
+ hook_del_event("doing_links");
mod_del_cmd(&links_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_links - LINKS message handler
* parv[2] = servername mask
*/
-static void m_links(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_links(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
if (!ConfigServerHide.flatten_links)
- {
- mo_links(client_p, source_p, parc, parv);
- return;
- }
+ {
+ mo_links(client_p, source_p, parc, parv);
+ return;
+ }
SendMessageFile(source_p, &ConfigFileEntry.linksfile);
-
+
/*
* Print our own info so at least it looks like a normal links
* then print out the file (which may or may not be empty)
*/
-
+
sendto_one(source_p, form_str(RPL_LINKS),
- me.name, parv[0], me.name, me.name,
- 0, me.info);
-
+ me.name, parv[0], me.name, me.name, 0, me.info);
+
sendto_one(source_p, form_str(RPL_ENDOFLINKS), me.name, parv[0], "*");
}
-static void mo_links(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_links(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char* mask = "";
- struct Client* target_p;
- char clean_mask[2 * HOSTLEN + 4];
- char* p;
+ char *mask = "";
+ struct Client *target_p;
+ char clean_mask[2 * HOSTLEN + 4];
+ char *p;
struct hook_links_data hd;
-
+
dlink_node *ptr;
if (parc > 2)
- {
- if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, parc, parv)
- != HUNTED_ISME)
- return;
- mask = parv[2];
- }
+ {
+ if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, parc, parv)
+ != HUNTED_ISME)
+ return;
+ mask = parv[2];
+ }
else if (parc == 2)
mask = parv[1];
assert(0 != mask);
- if (*mask) /* only necessary if there is a mask */
- mask = collapse(clean_string(clean_mask, (const unsigned char*) mask, 2 * HOSTLEN));
+ if (*mask) /* only necessary if there is a mask */
+ mask =
+ collapse(clean_string
+ (clean_mask, (const unsigned char *)mask, 2 * HOSTLEN));
hd.client_p = client_p;
hd.source_p = source_p;
hd.mask = mask;
hd.parc = parc;
hd.parv = parv;
-
+
hook_call_event("doing_links", &hd);
-
+
for (ptr = global_serv_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
+
+ if (*mask && !match(mask, target_p->name))
+ continue;
+
+ if (target_p->info[0])
{
- target_p = ptr->data;
-
- if (*mask && !match(mask, target_p->name))
- continue;
-
- if(target_p->info[0])
- {
- if( (p = strchr(target_p->info,']')) )
- p += 2; /* skip the nasty [IP] part */
- else
- p = target_p->info;
- }
+ if ((p = strchr(target_p->info, ']')))
+ p += 2; /* skip the nasty [IP] part */
else
- p = "(Unknown Location)";
-
- /* We just send the reply, as if theyre here theres either no SHIDE,
- * or theyre an oper..
- */
- sendto_one(source_p, form_str(RPL_LINKS),
- me.name, parv[0], target_p->name, target_p->serv->up,
- target_p->hopcount, p);
+ p = target_p->info;
}
-
+ else
+ p = "(Unknown Location)";
+
+ /* We just send the reply, as if theyre here theres either no SHIDE,
+ * or theyre an oper..
+ */
+ sendto_one(source_p, form_str(RPL_LINKS),
+ me.name, parv[0], target_p->name, target_p->serv->up,
+ target_p->hopcount, p);
+ }
+
sendto_one(source_p, form_str(RPL_ENDOFLINKS), me.name, parv[0],
EmptyString(mask) ? "*" : mask);
}
* parv[1] = server to query
* parv[2] = servername mask
*/
-static void ms_links(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_links(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, parc, parv)
!= HUNTED_ISME)
return;
- if(IsOper(source_p))
- m_links(client_p,source_p,parc,parv);
+ if (IsOper(source_p))
+ m_links(client_p, source_p, parc, parv);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_list.c,v 1.1 2002/01/04 09:13:22 a1kmm Exp $
+ * $Id: m_list.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include <string.h>
#include <stdlib.h>
-static void m_list(struct Client*, struct Client*, int, char**);
-static void ms_list(struct Client*, struct Client*, int, char**);
-static void mo_list(struct Client*, struct Client*, int, char**);
+static void m_list(struct Client *, struct Client *, int, char **);
+static void ms_list(struct Client *, struct Client *, int, char **);
+static void mo_list(struct Client *, struct Client *, int, char **);
static int list_all_channels(struct Client *);
-static void list_one_channel(struct Client *,struct Channel *);
+static void list_one_channel(struct Client *, struct Channel *);
struct Message list_msgtab = {
"LIST", 0, 0, 0, 0, MFLG_SLOW, 0,
{
mod_del_cmd(&list_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
static int list_all_channels(struct Client *source_p);
-static int list_named_channel(struct Client *source_p,char *name);
+static int list_named_channel(struct Client *source_p, char *name);
/*
** parv[0] = sender prefix
** parv[1] = channel
*/
-static void m_list(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_list(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- static time_t last_used=0L;
+ static time_t last_used = 0L;
/* If not a LazyLink connection, see if its still paced */
/* If we're forwarding this to uplinks.. it should be paced due to the
* traffic involved in /list.. -- fl_ */
- if( ( (last_used + ConfigFileEntry.pace_wait) > CurrentTime) )
- {
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,parv[0]);
- return;
- }
+ if (((last_used + ConfigFileEntry.pace_wait) > CurrentTime))
+ {
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
+ return;
+ }
else
last_used = CurrentTime;
/* If its a LazyLinks connection, let uplink handle the list */
- if( uplink && IsCapable(uplink,CAP_LL) )
- {
- if(parc < 2)
- sendto_one( uplink, ":%s LIST", source_p->name );
- else
- sendto_one( uplink, ":%s LIST %s", source_p->name, parv[1] );
- return;
- }
+ if (uplink && IsCapable(uplink, CAP_LL))
+ {
+ if (parc < 2)
+ sendto_one(uplink, ":%s LIST", source_p->name);
+ else
+ sendto_one(uplink, ":%s LIST %s", source_p->name, parv[1]);
+ return;
+ }
/* If no arg, do all channels *whee*, else just one channel */
if (parc < 2 || BadPtr(parv[1]))
- {
- list_all_channels(source_p);
- }
+ {
+ list_all_channels(source_p);
+ }
else
- {
- list_named_channel(source_p,parv[1]);
- }
+ {
+ list_named_channel(source_p, parv[1]);
+ }
}
** parv[0] = sender prefix
** parv[1] = channel
*/
-static void mo_list(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+mo_list(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
/* If its a LazyLinks connection, let uplink handle the list
* even for opers!
*/
- if( uplink && IsCapable( uplink, CAP_LL) )
- {
- if(parc < 2)
- sendto_one( uplink, ":%s LIST", source_p->name );
- else
- sendto_one( uplink, ":%s LIST %s", source_p->name, parv[1] );
- return;
- }
+ if (uplink && IsCapable(uplink, CAP_LL))
+ {
+ if (parc < 2)
+ sendto_one(uplink, ":%s LIST", source_p->name);
+ else
+ sendto_one(uplink, ":%s LIST %s", source_p->name, parv[1]);
+ return;
+ }
/* If no arg, do all channels *whee*, else just one channel */
if (parc < 2 || BadPtr(parv[1]))
- {
- list_all_channels(source_p);
- }
+ {
+ list_all_channels(source_p);
+ }
else
- {
- list_named_channel(source_p,parv[1]);
- }
+ {
+ list_named_channel(source_p, parv[1]);
+ }
}
/*
** parv[0] = sender prefix
** parv[1] = channel
*/
-static void ms_list(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_list(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
/* Only allow remote list if LazyLink request */
- if( ServerInfo.hub )
+ if (ServerInfo.hub)
+ {
+ if (!IsCapable(client_p->from, CAP_LL) && !MyConnect(source_p))
+ return;
+
+ if (parc < 2 || BadPtr(parv[1]))
{
- if(!IsCapable(client_p->from,CAP_LL) && !MyConnect(source_p))
- return;
-
- if (parc < 2 || BadPtr(parv[1]))
- {
- list_all_channels(source_p);
- }
- else
- {
- list_named_channel(source_p,parv[1]);
- }
+ list_all_channels(source_p);
+ }
+ else
+ {
+ list_named_channel(source_p, parv[1]);
}
+ }
}
/*
* output - 0/1
* side effects - list all channels to source_p
*/
-static int list_all_channels(struct Client *source_p)
+static int
+list_all_channels(struct Client *source_p)
{
struct Channel *chptr;
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
- for ( chptr = GlobalChannelList; chptr; chptr = chptr->nextch )
- {
- if ( !source_p->user ||
- (SecretChannel(chptr) && !IsMember(source_p, chptr)))
- continue;
- list_one_channel(source_p,chptr);
- }
+ for (chptr = GlobalChannelList; chptr; chptr = chptr->nextch)
+ {
+ if (!source_p->user ||
+ (SecretChannel(chptr) && !IsMember(source_p, chptr)))
+ continue;
+ list_one_channel(source_p, chptr);
+ }
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
return 0;
-}
-
+}
+
/*
* list_named_channel
* inputs - pointer to client requesting list
* output - 0/1
* side effects - list all channels to source_p
*/
-static int list_named_channel(struct Client *source_p,char *name)
+static int
+list_named_channel(struct Client *source_p, char *name)
{
- char id_and_topic[TOPICLEN+NICKLEN+6]; /* <!!>, space and null */
+ char id_and_topic[TOPICLEN + NICKLEN + 6]; /* <!!>, space and null */
dlink_node *ptr;
struct Channel *chptr;
struct Channel *root_chptr;
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
- if((p = strchr(name,',')))
+ if ((p = strchr(name, ',')))
*p = '\0';
-
- if(*name == '\0')
- {
- sendto_one(source_p, form_str(ERR_NOSUCHNICK),me.name, source_p->name, name);
- sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
- return 0;
- }
+
+ if (*name == '\0')
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name,
+ name);
+ sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
+ return 0;
+ }
chptr = hash_find_channel(name);
if (chptr == NULL)
- {
- sendto_one(source_p, form_str(ERR_NOSUCHNICK),me.name, source_p->name, name);
- sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
- return 0;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name,
+ name);
+ sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
+ return 0;
+ }
if (HasVchans(chptr))
ircsprintf(id_and_topic, "<!%s> %s", pick_vchan_id(chptr), chptr->topic);
if (ShowChannel(source_p, chptr))
sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
chptr->chname, chptr->users, id_and_topic);
-
+
/* Deal with subvchans */
-
+
for (ptr = chptr->vchan_list.head; ptr; ptr = ptr->next)
+ {
+ tmpchptr = ptr->data;
+
+ if (ShowChannel(source_p, tmpchptr))
{
- tmpchptr = ptr->data;
-
- if (ShowChannel(source_p, tmpchptr))
- {
- root_chptr = find_bchan(tmpchptr);
- ircsprintf(id_and_topic, "<!%s> %s", pick_vchan_id(tmpchptr), tmpchptr->topic);
- sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
- root_chptr->chname, tmpchptr->users, id_and_topic);
- }
+ root_chptr = find_bchan(tmpchptr);
+ ircsprintf(id_and_topic, "<!%s> %s", pick_vchan_id(tmpchptr),
+ tmpchptr->topic);
+ sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
+ root_chptr->chname, tmpchptr->users, id_and_topic);
}
-
+ }
+
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
return 0;
}
* ouput - none
* side effects -
*/
-static void list_one_channel(struct Client *source_p, struct Channel *chptr)
+static void
+list_one_channel(struct Client *source_p, struct Channel *chptr)
{
struct Channel *root_chptr;
- char id_and_topic[TOPICLEN+NICKLEN+6]; /* <!!>, plus space and null */
+ char id_and_topic[TOPICLEN + NICKLEN + 6]; /* <!!>, plus space and null */
- if(IsVchan(chptr) || HasVchans(chptr))
+ if (IsVchan(chptr) || HasVchans(chptr))
+ {
+ root_chptr = find_bchan(chptr);
+
+ if (root_chptr != NULL)
{
- root_chptr = find_bchan(chptr);
-
- if(root_chptr != NULL)
- {
- ircsprintf(id_and_topic, "<!%s> %s", pick_vchan_id(chptr), chptr->topic);
- sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
- root_chptr->chname, chptr->users, id_and_topic);
- }
- else
- {
- ircsprintf(id_and_topic, "<!%s> %s", pick_vchan_id(chptr), chptr->topic);
- sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
- chptr->chname, chptr->users, id_and_topic);
- }
+ ircsprintf(id_and_topic, "<!%s> %s", pick_vchan_id(chptr),
+ chptr->topic);
+ sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
+ root_chptr->chname, chptr->users, id_and_topic);
}
- else
+ else
{
+ ircsprintf(id_and_topic, "<!%s> %s", pick_vchan_id(chptr),
+ chptr->topic);
sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
- chptr->chname, chptr->users, chptr->topic);
+ chptr->chname, chptr->users, id_and_topic);
}
+ }
+ else
+ {
+ sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
+ chptr->chname, chptr->users, chptr->topic);
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_lljoin.c,v 1.1 2002/01/04 09:13:25 a1kmm Exp $
+ * $Id: m_lljoin.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "tools.h"
#include "channel.h"
#include <string.h>
#include <stdlib.h>
-static void ms_lljoin(struct Client *,struct Client *,int,char **);
+static void ms_lljoin(struct Client *, struct Client *, int, char **);
struct Message lljoin_msgtab = {
"LLJOIN", 0, 0, 3, 0, MFLG_SLOW | MFLG_UNREG, 0L,
mod_del_cmd(&lljoin_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_lljoin
* this is now..
*
*/
-static void ms_lljoin(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_lljoin(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
char *chname = NULL;
char *nick = NULL;
char *key = NULL;
char *vkey = NULL;
char *pvc = NULL;
- int vc_ts;
- int flags;
- int i;
+ int vc_ts;
+ int flags;
+ int i;
struct Client *target_p;
struct Channel *chptr, *vchan_chptr, *root_vchan;
int cjoin = 0;
- if(uplink && !IsCapable(uplink,CAP_LL))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** LLJOIN requested from non LL server %s",
- client_p->name);
- return;
- }
+ if (uplink && !IsCapable(uplink, CAP_LL))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** LLJOIN requested from non LL server %s",
+ client_p->name);
+ return;
+ }
chname = parv[1];
- if(chname == NULL)
+ if (chname == NULL)
return;
nick = parv[2];
- if(nick == NULL)
+ if (nick == NULL)
return;
if (nick[0] == '!')
cjoin = 1;
nick++;
}
-
- if(parc > 4)
+
+ if (parc > 4)
{
key = parv[4];
vkey = parv[3];
}
- else if(parc >3)
+ else if (parc > 3)
{
key = vkey = parv[3];
}
target_p = find_client(nick);
- if( !target_p || !target_p->user )
+ if (!target_p || !target_p->user)
return;
- if( !MyClient(target_p) )
+ if (!MyClient(target_p))
return;
chptr = hash_find_channel(chname);
if (cjoin)
{
- if(!chptr) /* Uhm, bad! */
+ if (!chptr) /* Uhm, bad! */
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "LLJOIN %s %s called by %s, but root chan doesn't exist!",
- chname, nick, client_p->name);
+ "LLJOIN %s %s called by %s, but root chan doesn't exist!",
+ chname, nick, client_p->name);
return;
}
flags = CHFL_CHANOP;
- if(! (vchan_chptr = cjoin_channel(chptr, target_p, chname)))
+ if (!(vchan_chptr = cjoin_channel(chptr, target_p, chname)))
return;
root_vchan = chptr;
chptr = vchan_chptr = get_or_create_channel(target_p, chname, NULL);
flags = CHFL_CHANOP;
}
-
+
if (vchan_chptr != chptr)
{
root_vchan = chptr;
else
root_vchan = chptr;
- if(!chptr || !root_vchan)
+ if (!chptr || !root_vchan)
return;
if (chptr->users == 0)
/* check_spambot_warning(target_p, chname); */
/* They _could_ join a channel twice due to lag */
- if(chptr)
+ if (chptr)
{
if (IsMember(target_p, chptr)) /* already a member, ignore this */
return;
return;
}
- if( (i = can_join(target_p, chptr, key)) )
+ if ((i = can_join(target_p, chptr, key)))
{
- sendto_one(target_p,
- form_str(i), me.name, nick, root_vchan->chname);
+ sendto_one(target_p, form_str(i), me.name, nick, root_vchan->chname);
return;
}
}
if ((target_p->user->joined >= ConfigChannel.max_chans_per_user) &&
- (!IsOper(target_p) || (target_p->user->joined >=
- ConfigChannel.max_chans_per_user*3)))
- {
- sendto_one(target_p, form_str(ERR_TOOMANYCHANNELS),
- me.name, nick, root_vchan->chname );
- return;
- }
-
- if(flags == CHFL_CHANOP)
+ (!IsOper(target_p) || (target_p->user->joined >=
+ ConfigChannel.max_chans_per_user * 3)))
+ {
+ sendto_one(target_p, form_str(ERR_TOOMANYCHANNELS),
+ me.name, nick, root_vchan->chname);
+ return;
+ }
+
+ if (flags == CHFL_CHANOP)
+ {
+ chptr->channelts = CurrentTime;
+ /*
+ * XXX - this is a rather ugly hack.
+ *
+ * Unfortunately, there's no way to pass
+ * the fact that it is a vchan through SJOIN...
+ */
+ /* Prevent users creating a fake vchan */
+ if (chname[0] == '#' && chname[1] == '#')
{
- chptr->channelts = CurrentTime;
- /*
- * XXX - this is a rather ugly hack.
- *
- * Unfortunately, there's no way to pass
- * the fact that it is a vchan through SJOIN...
- */
- /* Prevent users creating a fake vchan */
- if (chname[0] == '#' && chname[1] == '#')
- {
- if ((pvc = strrchr(chname+3, '_')))
- {
- /*
- * OK, name matches possible vchan:
- * ##channel_blah
- */
- pvc++; /* point pvc after last _ */
- vc_ts = atol(pvc);
- /*
- * if blah is the same as the TS, up the TS
- * by one, to prevent this channel being
- * seen as a vchan
- */
- if (vc_ts == CurrentTime)
- chptr->channelts++;
- }
- }
-
- sendto_one(uplink,
- ":%s SJOIN %lu %s + :@%s",
- me.name,
- (unsigned long) chptr->channelts,
- chptr->chname,
- nick);
+ if ((pvc = strrchr(chname + 3, '_')))
+ {
+ /*
+ * OK, name matches possible vchan:
+ * ##channel_blah
+ */
+ pvc++; /* point pvc after last _ */
+ vc_ts = atol(pvc);
+ /*
+ * if blah is the same as the TS, up the TS
+ * by one, to prevent this channel being
+ * seen as a vchan
+ */
+ if (vc_ts == CurrentTime)
+ chptr->channelts++;
+ }
}
+
+ sendto_one(uplink,
+ ":%s SJOIN %lu %s + :@%s",
+ me.name, (unsigned long)chptr->channelts, chptr->chname, nick);
+ }
else if ((flags == CHFL_HALFOP) && (IsCapable(uplink, CAP_HOPS)))
- {
- sendto_one(uplink,
- ":%s SJOIN %lu %s + :%%%s",
- me.name,
- (unsigned long) chptr->channelts,
- chptr->chname,
- nick);
- }
+ {
+ sendto_one(uplink,
+ ":%s SJOIN %lu %s + :%%%s",
+ me.name, (unsigned long)chptr->channelts, chptr->chname, nick);
+ }
else
- {
- sendto_one(uplink,
- ":%s SJOIN %lu %s + :%s",
- me.name,
- (unsigned long) chptr->channelts,
- chptr->chname,
- nick);
- }
+ {
+ sendto_one(uplink,
+ ":%s SJOIN %lu %s + :%s",
+ me.name, (unsigned long)chptr->channelts, chptr->chname, nick);
+ }
add_user_to_channel(chptr, target_p, flags);
- if ( chptr != root_vchan )
- add_vchan_to_client_cache(target_p,root_vchan,chptr);
-
+ if (chptr != root_vchan)
+ add_vchan_to_client_cache(target_p, root_vchan, chptr);
+
sendto_channel_local(ALL_MEMBERS, chptr,
- ":%s!%s@%s JOIN :%s",
- target_p->name,
- target_p->username,
- target_p->host,
- root_vchan->chname);
-
- if( flags & CHFL_CHANOP )
+ ":%s!%s@%s JOIN :%s",
+ target_p->name,
+ target_p->username,
+ target_p->host, root_vchan->chname);
+
+ if (flags & CHFL_CHANOP)
{
chptr->mode.mode |= MODE_TOPICLIMIT;
chptr->mode.mode |= MODE_NOPRIVMSGS;
-
- sendto_channel_local(ALL_MEMBERS,chptr,
- ":%s MODE %s +nt",
- me.name, root_vchan->chname);
- sendto_one(uplink,
- ":%s MODE %s +nt",
- me.name, chptr->chname);
+
+ sendto_channel_local(ALL_MEMBERS, chptr,
+ ":%s MODE %s +nt", me.name, root_vchan->chname);
+ sendto_one(uplink, ":%s MODE %s +nt", me.name, chptr->chname);
}
channel_member_names(target_p, chptr, chname, 1);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_llnick.c,v 1.1 2002/01/04 09:13:25 a1kmm Exp $
+ * $Id: m_llnick.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "tools.h"
#include "client.h"
#include <string.h>
#include <stdlib.h>
-static void ms_llnick(struct Client*, struct Client*, int, char**);
+static void ms_llnick(struct Client *, struct Client *, int, char **);
struct Message llnick_msgtab = {
"LLNICK", 0, 0, 3, 0, MFLG_SLOW | MFLG_UNREG, 0L,
mod_del_cmd(&llnick_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_llnick
* parv[3] = old nick
*
*/
-static void ms_llnick(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_llnick(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
char *nick;
char *nick_old = NULL;
int exists = 0;
int new = 0;
dlink_node *ptr;
-
- if(!IsCapable(client_p,CAP_LL) || !IsCapable(client_p, CAP_HUB))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** LLNICK requested from non LL server %s",
- client_p->name);
- return;
- }
+
+ if (!IsCapable(client_p, CAP_LL) || !IsCapable(client_p, CAP_HUB))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** LLNICK requested from non LL server %s",
+ client_p->name);
+ return;
+ }
if (parc < 4)
return;
if (*parv[1] == 'Y')
exists = 1;
-
+
nick = parv[2];
nick_old = parv[3];
if (new)
{
- nick_old++; /* skip '!' */
+ nick_old++; /* skip '!' */
/* New user -- find them */
- for( ptr = unknown_list.head; ptr; ptr = ptr->next )
+ for (ptr = unknown_list.head; ptr; ptr = ptr->next)
{
- if( !strcmp(nick_old, ((struct Client *)ptr->data)->llname) )
+ if (!strcmp(nick_old, ((struct Client *)ptr->data)->llname))
{
target_p = ptr->data;
- *target_p->llname = '\0'; /* unset their temp-nick */
+ *target_p->llname = '\0'; /* unset their temp-nick */
break;
}
}
- if (!target_p) /* Can't find them -- maybe they got a different nick */
+ if (!target_p) /* Can't find them -- maybe they got a different nick */
return;
}
else
{
/* Existing user changing nickname */
target_p = find_client(nick_old);
-
- if (!target_p) /* Can't find them -- maybe they got a different nick */
+
+ if (!target_p) /* Can't find them -- maybe they got a different nick */
return;
}
/* Don't try this on a remote client... */
if (!MyConnect(target_p))
return;
-
- if(find_client(nick) || exists)
+
+ if (find_client(nick) || exists)
{
/* The nick they want is in use. complain */
sendto_one(target_p, form_str(ERR_NICKNAMEINUSE), me.name,
- new ? "*" : nick_old,
- nick);
+ new ? "*" : nick_old, nick);
return;
}
- if(new)
+ if (new)
set_initial_nick(target_p, target_p, nick);
else
change_local_nick(target_p, target_p, nick);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_locops.c,v 1.1 2002/01/04 09:13:25 a1kmm Exp $
+ * $Id: m_locops.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "parse.h"
#include "modules.h"
-static void m_locops(struct Client *,struct Client *,int,char **);
+static void m_locops(struct Client *, struct Client *, int, char **);
struct Message locops_msgtab = {
"LOCOPS", 0, 0, 2, 0, MFLG_SLOW, 0,
mod_del_cmd(&locops_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_locops - LOCOPS message handler
* parv[0] = sender prefix
* parv[1] = message text
*/
-static void m_locops(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_locops(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
char *message = NULL;
message = parv[1];
if (EmptyString(message))
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "LOCOPS");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "LOCOPS");
+ return;
+ }
sendto_wallops_flags(FLAGS_LOCOPS, source_p, "LOCOPS - %s", message);
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_lusers.c,v 1.1 2002/01/04 09:13:25 a1kmm Exp $
+ * $Id: m_lusers.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "ircd.h"
#include "numeric.h"
-#include "s_serv.h" /* hunt_server */
-#include "s_user.h" /* show_lusers */
+#include "s_serv.h" /* hunt_server */
+#include "s_user.h" /* show_lusers */
#include "send.h"
#include "s_conf.h"
#include "msg.h"
/* XXX LazyLinks ? */
-static void m_lusers(struct Client*, struct Client*, int, char**);
-static void ms_lusers(struct Client*, struct Client*, int, char**);
+static void m_lusers(struct Client *, struct Client *, int, char **);
+static void ms_lusers(struct Client *, struct Client *, int, char **);
struct Message lusers_msgtab = {
"LUSERS", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&lusers_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_lusers - LUSERS message handler
* 199970918 JRL hacked to ignore parv[1] completely and require parc > 3
* to cause a force
*/
-static void m_lusers(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_lusers(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
static time_t last_used = 0;
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
- {
- /* safe enough to give this on a local connect only */
- if (MyClient(source_p))
- sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
- return;
- }
+ {
+ /* safe enough to give this on a local connect only */
+ if (MyClient(source_p))
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
+ return;
+ }
else
last_used = CurrentTime;
if (parc > 2 && !ConfigServerHide.disable_remote)
- {
- if (hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv) != HUNTED_ISME)
- return;
- }
+ {
+ if (hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv) !=
+ HUNTED_ISME)
+ return;
+ }
show_lusers(source_p);
}
* 199970918 JRL hacked to ignore parv[1] completely and require parc > 3
* to cause a force
*/
-static void ms_lusers(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_lusers(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
if (parc > 2)
+ {
+ if (hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv)
+ != HUNTED_ISME)
{
- if(hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- {
- return;
- }
+ return;
}
+ }
show_lusers(source_p);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_message.c,v 1.1 2002/01/04 09:13:25 a1kmm Exp $
+ * $Id: m_message.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
mod_del_cmd(¬ice_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
{
int i;
-#if 0 /* Allow servers to send notices to individual people */
+#if 0 /* Allow servers to send notices to individual people */
if (!IsPerson(source_p))
return;
#endif
static int
build_target_list(int p_or_n, char *command, struct Client *client_p,
- struct Client *source_p, char *nicks_channels,
- char *text)
+ struct Client *source_p, char *nicks_channels, char *text)
{
int type;
char *p, *nick, *target_list, ncbuf[BUFSIZE];
target_list = ncbuf;
}
else
- target_list = nicks_channels; /* skip strcpy for non-lazyleafs */
+ target_list = nicks_channels; /* skip strcpy for non-lazyleafs */
ntargets = 0;
continue;
}
}
-
+
/* @#channel or +#channel message ? */
type = 0;
if ((chptr = hash_find_channel(nick)) != NULL)
{
- if(!is_any_op(chptr, source_p) && !is_voiced(chptr, source_p))
+ if (!is_any_op(chptr, source_p) && !is_voiced(chptr, source_p))
{
sendto_one(source_p, form_str(ERR_NOSUCHNICK),
me.name, source_p->name, with_prefix);
continue;
}
-
+
if (!duplicate_ptr(chptr))
{
targets[ntargets].ptr = (void *)chptr;
}
}
- if(IsOper(source_p) && ((*nick == '$') || strchr(nick, '@')))
+ if (IsOper(source_p) && ((*nick == '$') || strchr(nick, '@')))
{
handle_opers(p_or_n, command, client_p, source_p, nick, text);
continue;
{
if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
return -1;
- else if(p_or_n != NOTICE)
+ else if (p_or_n != NOTICE)
sendto_one(source_p, form_str(ERR_NOSUCHNICK),
- me.name, source_p->name, nick);
+ me.name, source_p->name, nick);
continue;
}
}
return;
sendto_channel_remote(source_p, client_p, type, CAP_CHW, NOCAPS, vchan,
- ":%s %s %c%s :%s", source_p->name, command, c,
- vchan->chname, text);
+ ":%s %s %c%s :%s", source_p->name, command, c,
+ vchan->chname, text);
/* non CAP_CHW servers? */
}
**
** Armin, 8Jun90 (gruner@informatik.tu-muenchen.de)
*/
- if(*nick == '$')
+ if (*nick == '$')
{
- if((*(nick+1) == '$' || *(nick+1) == '#'))
+ if ((*(nick + 1) == '$' || *(nick + 1) == '#'))
nick++;
- else if(MyOper(source_p))
+ else if (MyOper(source_p))
{
- sendto_one(source_p,
+ sendto_one(source_p,
":%s NOTICE %s :The command %s %s is no longer supported, please use $%s",
- me.name, source_p->name, command, nick, nick);
+ me.name, source_p->name, command, nick, nick);
return;
}
-
+
if (!(s = (char *)strrchr(nick, '.')))
{
sendto_one(source_p, form_str(ERR_NOTOPLEVEL),
me.name, source_p->name, nick);
return;
}
-
+
sendto_match_butone(IsServer(client_p) ? client_p : NULL, source_p,
nick + 1,
(*nick == '#') ? MATCH_HOST : MATCH_SERVER,
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_motd.c,v 1.1 2002/01/04 09:13:25 a1kmm Exp $
+ * $Id: m_motd.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "client.h"
#include "tools.h"
#include "handlers.h"
#include "hook.h"
#include "msg.h"
-#include "s_serv.h" /* hunt_server */
+#include "s_serv.h" /* hunt_server */
#include "parse.h"
#include "modules.h"
#include "s_conf.h"
#include <time.h>
static void mr_motd(struct Client *, struct Client *, int, char **);
-static void m_motd(struct Client*, struct Client*, int, char**);
-static void mo_motd(struct Client*, struct Client*, int, char**);
+static void m_motd(struct Client *, struct Client *, int, char **);
+static void mo_motd(struct Client *, struct Client *, int, char **);
static void motd_spy(struct Client *);
mod_del_cmd(&motd_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/* mr_motd()
*
* parv[0] = sender prefix
*/
-static void mr_motd(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mr_motd(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
/* allow unregistered clients to see the motd, but exit them */
- SendMessageFile(source_p,&ConfigFileEntry.motd);
+ SendMessageFile(source_p, &ConfigFileEntry.motd);
exit_client(client_p, source_p, source_p, "Client Exit after MOTD");
}
** parv[0] = sender prefix
** parv[1] = servername
*/
-static void m_motd(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_motd(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
static time_t last_used = 0;
- if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
- {
- /* safe enough to give this on a local connect only */
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,source_p->name);
- return;
- }
+ if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
+ {
+ /* safe enough to give this on a local connect only */
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name);
+ return;
+ }
else
last_used = CurrentTime;
/* This is safe enough to use during non hidden server mode */
- if(!ConfigServerHide.disable_remote)
- {
- if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1,parc,parv)!=HUNTED_ISME)
- return;
- }
+ if (!ConfigServerHide.disable_remote)
+ {
+ if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) !=
+ HUNTED_ISME)
+ return;
+ }
motd_spy(source_p);
-
- SendMessageFile(source_p,&ConfigFileEntry.motd);
+
+ SendMessageFile(source_p, &ConfigFileEntry.motd);
}
/*
** parv[0] = sender prefix
** parv[1] = servername
*/
-static void mo_motd(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_motd(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if(IsServer(source_p))
+ if (IsServer(source_p))
return;
- if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1,parc,parv)!=HUNTED_ISME)
+ if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) !=
+ HUNTED_ISME)
return;
motd_spy(source_p);
-
- SendMessageFile(source_p,&ConfigFileEntry.motd);
+
+ SendMessageFile(source_p, &ConfigFileEntry.motd);
}
/* motd_spy()
* output - none
* side effects - hook doing_motd is called
*/
-static void motd_spy(struct Client *source_p)
+static void
+motd_spy(struct Client *source_p)
{
struct hook_spy_data data;
hook_call_event("doing_motd", &data);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_names.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_names.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include "channel_mode.h"
#include "vchannel.h"
#include "client.h"
-#include "common.h" /* bleah */
+#include "common.h" /* bleah */
#include "hash.h"
#include "irc_string.h"
#include "ircd.h"
static void names_all_visible_channels(struct Client *source_p);
static void names_non_public_non_secret(struct Client *source_p);
-static void m_names(struct Client*, struct Client*, int, char**);
-static void ms_names(struct Client*, struct Client*, int, char**);
+static void m_names(struct Client *, struct Client *, int, char **);
+static void ms_names(struct Client *, struct Client *, int, char **);
struct Message names_msgtab = {
"NAMES", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&names_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/************************************************************************
** parv[1] = channel
** parv[2] = vkey
*/
-static void m_names(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
-{
+static void
+m_names(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
+{
struct Channel *vchan = NULL;
struct Channel *ch2ptr = NULL;
char *s;
char *vkey = NULL;
if (!BadPtr(para))
+ {
+ if ((s = strchr(para, ',')))
+ *s = '\0';
+
+ if (parc > 2)
+ vkey = parv[2];
+
+ if (!check_channel_name(para))
{
- if( (s = strchr(para, ',')) )
- *s = '\0';
+ sendto_one(source_p, form_str(ERR_BADCHANNAME),
+ me.name, parv[0], (unsigned char *)para);
+ return;
+ }
- if (parc > 2)
- vkey = parv[2];
+ if ((ch2ptr = hash_find_channel(para)) != NULL)
+ {
+ if (HasVchans(ch2ptr))
+ {
+ vchan = map_vchan(ch2ptr, source_p);
- if (!check_channel_name(para))
- {
- sendto_one(source_p, form_str(ERR_BADCHANNAME),
- me.name, parv[0], (unsigned char *)para);
+ if ((vkey && !vkey[1]) || (!vchan && !vkey))
+ {
+ show_vchans(source_p, ch2ptr, "names");
return;
}
-
- if ((ch2ptr = hash_find_channel(para)) != NULL)
+ else if (vkey && vkey[1])
{
- if (HasVchans(ch2ptr))
- {
- vchan = map_vchan(ch2ptr, source_p);
-
- if ((vkey && !vkey[1]) || (!vchan && !vkey))
- {
- show_vchans(source_p, ch2ptr, "names");
- return;
- }
- else if (vkey && vkey[1])
- {
- vchan = find_vchan(ch2ptr, vkey);
- if(!vchan)
- return;
- }
- channel_member_names(source_p, vchan, ch2ptr->chname, 1);
- }
- else
- {
- channel_member_names(source_p, ch2ptr, ch2ptr->chname, 1);
- }
+ vchan = find_vchan(ch2ptr, vkey);
+ if (!vchan)
+ return;
}
+ channel_member_names(source_p, vchan, ch2ptr->chname, 1);
+ }
else
- sendto_one(source_p, form_str(RPL_ENDOFNAMES), me.name,
- parv[0], para);
+ {
+ channel_member_names(source_p, ch2ptr, ch2ptr->chname, 1);
+ }
}
+ else
+ sendto_one(source_p, form_str(RPL_ENDOFNAMES), me.name, parv[0], para);
+ }
else
- {
- names_all_visible_channels(source_p);
- names_non_public_non_secret(source_p);
- sendto_one(source_p, form_str(RPL_ENDOFNAMES), me.name, parv[0],
- "*");
- }
+ {
+ names_all_visible_channels(source_p);
+ names_non_public_non_secret(source_p);
+ sendto_one(source_p, form_str(RPL_ENDOFNAMES), me.name, parv[0], "*");
+ }
}
/*
* side effects - lists all visible channels whee!
*/
-static void names_all_visible_channels(struct Client *source_p)
+static void
+names_all_visible_channels(struct Client *source_p)
{
struct Channel *chptr;
struct Channel *bchan;
- char *chname=NULL;
+ char *chname = NULL;
/*
* First, do all visible channels (public and the one user self is)
*/
for (chptr = GlobalChannelList; chptr; chptr = chptr->nextch)
+ {
+ if (IsVchan(chptr))
{
- if (IsVchan(chptr))
- {
- bchan = find_bchan (chptr);
- if (bchan != NULL)
- chname = bchan->chname;
- }
- else
- chname = chptr->chname;
+ bchan = find_bchan(chptr);
+ if (bchan != NULL)
+ chname = bchan->chname;
+ }
+ else
+ chname = chptr->chname;
- /* Find users on same channel (defined by chptr) */
+ /* Find users on same channel (defined by chptr) */
- channel_member_names( source_p, chptr, chname, 0);
- }
+ channel_member_names(source_p, chptr, chname, 0);
+ }
}
/*
* side effects - lists all non public non secret channels
*/
-static void names_non_public_non_secret(struct Client *source_p)
+static void
+names_non_public_non_secret(struct Client *source_p)
{
int mlen;
int tlen;
int cur_len;
int reply_to_send = NO;
int dont_show = NO;
- dlink_node *lp;
+ dlink_node *lp;
struct Client *c2ptr;
- struct Channel *ch3ptr=NULL;
+ struct Channel *ch3ptr = NULL;
char buf[BUFSIZE];
char *t;
- ircsprintf(buf,form_str(RPL_NAMREPLY),
- me.name,source_p->name," * * :");
+ ircsprintf(buf, form_str(RPL_NAMREPLY), me.name, source_p->name, " * * :");
mlen = strlen(buf);
cur_len = mlen;
/* Second, do all non-public, non-secret channels in one big sweep */
for (c2ptr = GlobalClientList; c2ptr; c2ptr = c2ptr->next)
+ {
+ if (!IsPerson(c2ptr) || IsInvisible(c2ptr))
+ continue;
+ /*
+ * dont show a client if they are on a secret channel or
+ * they are on a channel source_p is on since they have already
+ * been shown earlier. -avalon
+ */
+ for (lp = c2ptr->user->channel.head; lp; lp = lp->next)
{
- if (!IsPerson(c2ptr) || IsInvisible(c2ptr))
- continue;
- /*
- * dont show a client if they are on a secret channel or
- * they are on a channel source_p is on since they have already
- * been shown earlier. -avalon
- */
- for( lp = c2ptr->user->channel.head; lp; lp = lp->next )
- {
- ch3ptr = lp->data;
-
- if ( (!PubChannel(ch3ptr) || IsMember(source_p, ch3ptr)) ||
- (SecretChannel(ch3ptr)))
- {
- dont_show = YES;
- break;
- }
- }
- if (dont_show) /* on any secret channels or shown already? */
- continue;
+ ch3ptr = lp->data;
+
+ if ((!PubChannel(ch3ptr) || IsMember(source_p, ch3ptr)) ||
+ (SecretChannel(ch3ptr)))
+ {
+ dont_show = YES;
+ break;
+ }
+ }
+ if (dont_show) /* on any secret channels or shown already? */
+ continue;
- if(lp == NULL) /* Nothing to do. yay */
- continue;
+ if (lp == NULL) /* Nothing to do. yay */
+ continue;
- if ( (cur_len + NICKLEN + 2) > (BUFSIZE - 3))
- {
- sendto_one(source_p, "%s", buf);
- cur_len = mlen;
- t = buf + mlen;
- }
+ if ((cur_len + NICKLEN + 2) > (BUFSIZE - 3))
+ {
+ sendto_one(source_p, "%s", buf);
+ cur_len = mlen;
+ t = buf + mlen;
+ }
- if(ch3ptr->mode.mode & MODE_HIDEOPS)
- ircsprintf(t," %s ", c2ptr->name);
- else
- ircsprintf(t,"%s%s ", channel_chanop_or_voice(ch3ptr, c2ptr),
- c2ptr->name);
+ if (ch3ptr->mode.mode & MODE_HIDEOPS)
+ ircsprintf(t, " %s ", c2ptr->name);
+ else
+ ircsprintf(t, "%s%s ", channel_chanop_or_voice(ch3ptr, c2ptr),
+ c2ptr->name);
- tlen = strlen(t);
- cur_len += tlen;
- t += tlen;
+ tlen = strlen(t);
+ cur_len += tlen;
+ t += tlen;
- reply_to_send = YES;
+ reply_to_send = YES;
- }
+ }
if (reply_to_send)
- sendto_one(source_p, "%s", buf );
+ sendto_one(source_p, "%s", buf);
}
-static void ms_names( struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
-{
+static void
+ms_names(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
+{
/* If its running as a hub, and linked with lazy links
* then allow leaf to use normal client m_names()
* other wise, ignore it.
*/
- if( ServerInfo.hub )
- {
- if(!IsCapable(client_p->from,CAP_LL))
- return;
- }
+ if (ServerInfo.hub)
+ {
+ if (!IsCapable(client_p->from, CAP_LL))
+ return;
+ }
- m_names(client_p,source_p,parc,parv);
+ m_names(client_p, source_p, parc, parv);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_nburst.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_nburst.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "tools.h"
#include "channel.h"
#include <string.h>
#include <stdlib.h>
-static void ms_nburst(struct Client*, struct Client*, int, char**);
+static void ms_nburst(struct Client *, struct Client *, int, char **);
struct Message nburst_msgtab = {
"NBURST", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0L,
mod_del_cmd(&nburst_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** m_nburst
* the given LL capable server.
*/
-static void ms_nburst(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_nburst(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
char *nick;
char *nick_new = NULL;
struct Client *target_p;
char status;
- if( parc < 2 || *parv[1] == '\0' )
- return;
+ if (parc < 2 || *parv[1] == '\0')
+ return;
nick = parv[1];
- if( parc > 2 )
+ if (parc > 2)
nick_new = parv[2];
- if( parc > 3 )
+ if (parc > 3)
nick_old = parv[3];
if (!ServerInfo.hub && IsCapable(client_p, CAP_LL))
#ifdef DEBUGLL
sendto_realops_flags(FLAGS_ALL, L_ALL, "NBURST called by %s for %s %s %s",
- client_p->name,
- nick,
- nick_new ? nick_new : "",
- nick_old ? nick_old : "" );
+ client_p->name,
+ nick,
+ nick_new ? nick_new : "", nick_old ? nick_old : "");
#endif
status = 'N';
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_oper.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_oper.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include <unistd.h>
-static struct ConfItem *find_password_aconf(char *name, struct Client *source_p);
+static struct ConfItem *find_password_aconf(char *name,
+ struct Client *source_p);
static int match_oper_password(char *password, struct ConfItem *aconf);
-int oper_up( struct Client *source_p, struct ConfItem *aconf );
+int oper_up(struct Client *source_p, struct ConfItem *aconf);
#ifdef CRYPT_OPER_PASSWORD
-extern char *crypt();
+extern char *crypt();
#endif /* CRYPT_OPER_PASSWORD */
-static void m_oper(struct Client*, struct Client*, int, char**);
-static void ms_oper(struct Client*, struct Client*, int, char**);
-static void mo_oper(struct Client*, struct Client*, int, char**);
+static void m_oper(struct Client *, struct Client *, int, char **);
+static void ms_oper(struct Client *, struct Client *, int, char **);
+static void mo_oper(struct Client *, struct Client *, int, char **);
struct Message oper_msgtab = {
"OPER", 0, 0, 3, 0, MFLG_SLOW, 0,
- {m_unregistered, m_oper, ms_oper, mo_oper}
+ {m_unregistered, m_oper, ms_oper, mo_oper}
};
#ifndef STATIC_MODULES
mod_del_cmd(&oper_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** parv[1] = oper name
** parv[2] = oper password
*/
-static void m_oper(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_oper(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct ConfItem *aconf;
struct ConfItem *oconf = NULL;
- char *name;
- char *password;
+ char *name;
+ char *password;
dlink_node *ptr;
name = parv[1];
password = parv[2];
if (EmptyString(password))
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, source_p->name, "OPER");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, source_p->name, "OPER");
+ return;
+ }
- if( (aconf = find_password_aconf(name,source_p)) == NULL)
+ if ((aconf = find_password_aconf(name, source_p)) == NULL)
+ {
+ sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
+ if (ConfigFileEntry.failed_oper_notice)
{
- sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
- if (ConfigFileEntry.failed_oper_notice)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Failed OPER attempt - host mismatch by %s (%s@%s)",
- source_p->name, source_p->username, source_p->host);
- }
- return;
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Failed OPER attempt - host mismatch by %s (%s@%s)",
+ source_p->name, source_p->username,
+ source_p->host);
}
+ return;
+ }
- if ( match_oper_password(password,aconf) )
+ if (match_oper_password(password, aconf))
+ {
+ /*
+ 20001216:
+ detach old iline
+ -einride
+ */
+ ptr = source_p->localClient->confs.head;
+ if (ptr)
{
- /*
- 20001216:
- detach old iline
- -einride
- */
- ptr = source_p->localClient->confs.head;
- if (ptr)
- {
-
- oconf = ptr->data;
- detach_conf(source_p,oconf);
- }
- if( attach_conf(source_p, aconf) != 0 )
- {
- sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
- me.name,source_p->name);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Failed OPER attempt by %s (%s@%s) can't attach conf!",
- source_p->name, source_p->username, source_p->host);
- /*
- 20001216:
- Reattach old iline
- -einride
- */
- attach_conf(source_p, oconf);
- return;
- }
+ oconf = ptr->data;
+ detach_conf(source_p, oconf);
+ }
- oper_up( source_p, aconf );
-
- ilog(L_TRACE, "OPER %s by %s!%s@%s",
- name, source_p->name, source_p->username, source_p->host);
- log_oper(source_p, name);
+ if (attach_conf(source_p, aconf) != 0)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Can't attach conf!",
+ me.name, source_p->name);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Failed OPER attempt by %s (%s@%s) can't attach conf!",
+ source_p->name, source_p->username,
+ source_p->host);
+ /*
+ 20001216:
+ Reattach old iline
+ -einride
+ */
+ attach_conf(source_p, oconf);
return;
}
+
+ oper_up(source_p, aconf);
+
+ ilog(L_TRACE, "OPER %s by %s!%s@%s",
+ name, source_p->name, source_p->username, source_p->host);
+ log_oper(source_p, name);
+ return;
+ }
else
+ {
+ sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, parv[0]);
+ if (ConfigFileEntry.failed_oper_notice)
{
- sendto_one(source_p,form_str(ERR_PASSWDMISMATCH),me.name, parv[0]);
- if (ConfigFileEntry.failed_oper_notice)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Failed OPER attempt by %s (%s@%s)",
- source_p->name, source_p->username, source_p->host);
- }
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Failed OPER attempt by %s (%s@%s)",
+ source_p->name, source_p->username,
+ source_p->host);
}
+ }
}
/*
** parv[1] = oper name
** parv[2] = oper password
*/
-static void mo_oper(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_oper(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, parv[0]);
SendMessageFile(source_p, &ConfigFileEntry.opermotd);
** parv[1] = oper name
** parv[2] = oper password
*/
-static void ms_oper(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_oper(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
/* if message arrived from server, trust it, and set to oper */
-
+
if (!IsOper(source_p))
- {
- if (source_p->status == STAT_CLIENT)
- source_p->handler = OPER_HANDLER;
-
- source_p->flags |= FLAGS_OPER;
- Count.oper++;
- sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, NOFLAGS,
- ":%s MODE %s :+o", parv[0], parv[0]);
- }
+ {
+ if (source_p->status == STAT_CLIENT)
+ source_p->handler = OPER_HANDLER;
+
+ source_p->flags |= FLAGS_OPER;
+ Count.oper++;
+ sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, NOFLAGS,
+ ":%s MODE %s :+o", parv[0], parv[0]);
+ }
}
/*
* output -
*/
-struct ConfItem *find_password_aconf(char *name, struct Client *source_p)
+struct ConfItem *
+find_password_aconf(char *name, struct Client *source_p)
{
struct ConfItem *aconf;
!(aconf = find_conf_exact(name, source_p->username,
source_p->localClient->sockhost,
CONF_OPERATOR)))
- {
- return 0;
- }
- return(aconf);
+ {
+ return 0;
+ }
+ return (aconf);
}
/*
* side effects - none
*/
-static int match_oper_password(char *password,
- struct ConfItem *aconf)
+static int
+match_oper_password(char *password, struct ConfItem *aconf)
{
char *encr;
#ifdef CRYPT_OPER_PASSWORD
/* use first two chars of the password they send in as salt */
/* If the password in the conf is MD5, and ircd is linked
- ** to scrypt on FreeBSD, or the standard crypt library on
- ** glibc Linux, then this code will work fine on generating
- ** the proper encrypted hash for comparison.
- */
+ ** to scrypt on FreeBSD, or the standard crypt library on
+ ** glibc Linux, then this code will work fine on generating
+ ** the proper encrypted hash for comparison.
+ */
/* passwd may be NULL pointer. Head it off at the pass... */
if (aconf->passwd == NULL)
encr = "";
#else
encr = password;
-#endif /* CRYPT_OPER_PASSWORD */
+#endif /* CRYPT_OPER_PASSWORD */
if (strcmp(encr, aconf->passwd) == 0)
return YES;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_operwall.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_operwall.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "parse.h"
#include "modules.h"
-static void mo_operwall(struct Client*, struct Client*, int, char**);
-static void ms_operwall(struct Client*, struct Client*, int, char**);
+static void mo_operwall(struct Client *, struct Client *, int, char **);
+static void ms_operwall(struct Client *, struct Client *, int, char **);
struct Message operwall_msgtab = {
"OPERWALL", 0, 0, 2, 0, MFLG_SLOW, 0,
mod_del_cmd(&operwall_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_operwall - OPERWALL message handler
* parv[1] = message text
*/
-static void mo_operwall(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_operwall(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
char *message = parv[1];
if (EmptyString(message))
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "OPERWALL");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "OPERWALL");
+ return;
+ }
sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
":%s OPERWALL :%s", parv[0], message);
* parv[1] = message text
*/
-static void ms_operwall(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_operwall(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
char *message = parv[1];
if (EmptyString(message))
- {
- if (MyClient(source_p))
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "OPERWALL");
- return;
- }
+ {
+ if (MyClient(source_p))
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "OPERWALL");
+ return;
+ }
sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
":%s OPERWALL :%s", parv[0], message);
sendto_wallops_flags(FLAGS_OPERWALL, source_p, "%s", message);
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_pass.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_pass.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
-#include "handlers.h" /* m_pass prototype */
-#include "client.h" /* client struct */
-#include "irc_string.h" /* strncpy_irc */
-#include "send.h" /* sendto_one */
-#include "numeric.h" /* ERR_xxx */
-#include "ircd.h" /* me */
+#include "handlers.h" /* m_pass prototype */
+#include "client.h" /* client struct */
+#include "irc_string.h" /* strncpy_irc */
+#include "send.h" /* sendto_one */
+#include "numeric.h" /* ERR_xxx */
+#include "ircd.h" /* me */
#include "msg.h"
#include "parse.h"
#include "modules.h"
-static void mr_pass(struct Client*, struct Client*, int, char**);
+static void mr_pass(struct Client *, struct Client *, int, char **);
struct Message pass_msgtab = {
"PASS", 0, 0, 2, 0, MFLG_SLOW | MFLG_UNREG, 0,
mod_del_cmd(&pass_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_pass() - Added Sat, 4 March 1989
* parv[1] = password
* parv[2] = optional extra version information
*/
-static void mr_pass(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mr_pass(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
const char *password = parv[1];
if (EmptyString(password))
- {
- sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, BadPtr(parv[0]) ? "*" : parv[0], "PASS");
- return;
- }
+ {
+ sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, BadPtr(parv[0]) ? "*" : parv[0], "PASS");
+ return;
+ }
strncpy_irc(client_p->localClient->passwd, password, PASSWDLEN);
if (parc > 2)
- {
- /*
- * It looks to me as if orabidoo wanted to have more
- * than one set of option strings possible here...
- * i.e. ":AABBTS" as long as TS was the last two chars
- * however, as we are now using CAPAB, I think we can
- * safely assume if there is a ":TS" then its a TS server
- * -Dianora
- */
- if (0 == irccmp(parv[2], "TS") && client_p->tsinfo == 0)
- client_p->tsinfo = TS_DOESTS;
- }
+ {
+ /*
+ * It looks to me as if orabidoo wanted to have more
+ * than one set of option strings possible here...
+ * i.e. ":AABBTS" as long as TS was the last two chars
+ * however, as we are now using CAPAB, I think we can
+ * safely assume if there is a ":TS" then its a TS server
+ * -Dianora
+ */
+ if (0 == irccmp(parv[2], "TS") && client_p->tsinfo == 0)
+ client_p->tsinfo = TS_DOESTS;
+ }
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_ping.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_ping.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "hash.h"
#include "s_conf.h"
-static void m_ping(struct Client*, struct Client*, int, char**);
-static void ms_ping(struct Client*, struct Client*, int, char**);
+static void m_ping(struct Client *, struct Client *, int, char **);
+static void ms_ping(struct Client *, struct Client *, int, char **);
struct Message ping_msgtab = {
"PING", 0, 0, 1, 0, MFLG_SLOW, 0,
mod_del_cmd(&ping_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** m_ping
** parv[1] = origin
** parv[2] = destination
*/
-static void m_ping(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_ping(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p;
- char *origin, *destination;
+ char *origin, *destination;
if (parc < 2 || *parv[1] == '\0')
{
}
origin = parv[1];
- destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
+ destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
if (ConfigServerHide.disable_remote && !IsOper(source_p))
{
- sendto_one(source_p,":%s PONG %s :%s", me.name,
- (destination) ? destination : me.name, origin);
- return;
+ sendto_one(source_p, ":%s PONG %s :%s", me.name,
+ (destination) ? destination : me.name, origin);
+ return;
}
/* Screw this, origin == clients nick if remote, what they sent if local --fl_ */
/* We're sending it across servers.. origin == client_p->name --fl_ */
origin = client_p->name;
if ((target_p = find_server(destination)))
- sendto_one(target_p,":%s PING %s :%s", parv[0],
- origin, destination);
+ sendto_one(target_p, ":%s PING %s :%s", parv[0], origin, destination);
else
{
sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
}
}
else
- sendto_one(source_p,":%s PONG %s :%s", me.name,
+ sendto_one(source_p, ":%s PONG %s :%s", me.name,
(destination) ? destination : me.name, origin);
}
-static void ms_ping(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_ping(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p;
- char *origin, *destination;
+ char *origin, *destination;
if (parc < 2 || *parv[1] == '\0')
{
origin = parv[1];
#endif
origin = source_p->name;
- destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
+ destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
#if 0
target_p = find_client(origin, NULL);
if (!EmptyString(destination) && !match(destination, me.name))
{
if ((target_p = find_server(destination)))
- sendto_one(target_p,":%s PING %s :%s", parv[0],
- origin, destination);
+ sendto_one(target_p, ":%s PING %s :%s", parv[0], origin, destination);
else
{
sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
}
}
else
- sendto_one(source_p,":%s PONG %s :%s", me.name,
+ sendto_one(source_p, ":%s PONG %s :%s", me.name,
(destination) ? destination : me.name, origin);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_pong.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_pong.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "ircd.h"
#include "handlers.h"
#include "s_user.h"
#include "client.h"
-#include "hash.h" /* for find_client() */
+#include "hash.h" /* for find_client() */
#include "numeric.h"
#include "s_conf.h"
#include "send.h"
#include "hash.h"
#include "modules.h"
-static void mr_pong(struct Client*, struct Client*, int, char**);
-static void ms_pong(struct Client*, struct Client*, int, char**);
+static void mr_pong(struct Client *, struct Client *, int, char **);
+static void ms_pong(struct Client *, struct Client *, int, char **);
struct Message pong_msgtab = {
"PONG", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0,
mod_del_cmd(&pong_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
-static void ms_pong(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_pong(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p;
- char *origin, *destination;
+ char *origin, *destination;
if (parc < 2 || *parv[1] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
+ return;
+ }
origin = parv[1];
destination = parv[2];
* case can be made to allow them only from servers). -Shadowfax
*/
if (!EmptyString(destination) && !match(destination, me.name))
+ {
+ if ((target_p = find_client(destination)) ||
+ (target_p = find_server(destination)))
+ sendto_one(target_p, ":%s PONG %s %s", parv[0], origin, destination);
+ else
{
- if ((target_p = find_client(destination)) ||
- (target_p = find_server(destination)))
- sendto_one(target_p,":%s PONG %s %s",
- parv[0], origin, destination);
- else
- {
- sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
- me.name, parv[0], destination);
- return;
- }
+ sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
+ me.name, parv[0], destination);
+ return;
}
+ }
#ifdef DEBUGMODE
else
return;
}
-static void mr_pong(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+mr_pong(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
if (parc == 2 && *parv[1] != '\0')
+ {
+ if (ConfigFileEntry.ping_cookie && source_p->user && source_p->name[0])
{
- if(ConfigFileEntry.ping_cookie && source_p->user && source_p->name[0])
+ unsigned long incoming_ping = strtoul(parv[1], (char **)NULL, 10);
+ if (incoming_ping)
{
- unsigned long incoming_ping = strtoul(parv[1], (char **)NULL, 10);
- if(incoming_ping)
- {
- if(source_p->random_ping == incoming_ping)
- {
- char buf[USERLEN+1];
- strlcpy(buf, source_p->username, USERLEN);
- source_p->flags2 |= FLAGS2_PING_COOKIE;
- register_local_user(client_p, source_p, source_p->name, buf);
- } else
- {
- sendto_one(source_p, form_str(ERR_WRONGPONG), me.name, source_p->name, source_p->random_ping);
- return;
- }
- }
+ if (source_p->random_ping == incoming_ping)
+ {
+ char buf[USERLEN + 1];
+ strlcpy(buf, source_p->username, USERLEN);
+ source_p->flags2 |= FLAGS2_PING_COOKIE;
+ register_local_user(client_p, source_p, source_p->name, buf);
+ }
+ else
+ {
+ sendto_one(source_p, form_str(ERR_WRONGPONG), me.name,
+ source_p->name, source_p->random_ping);
+ return;
+ }
}
-
- } else
- sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
-
+ }
+
+ }
+ else
+ sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
+
source_p->flags &= ~FLAGS_PINGSENT;
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_post.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_post.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "modules.h"
#include "s_conf.h"
-static void mr_post(struct Client*, struct Client*, int, char**);
+static void mr_post(struct Client *, struct Client *, int, char **);
struct Message post_msgtab = {
"POST", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
mod_del_cmd(&post_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** mr_post
** parv[0] = sender prefix
** parv[1] = comment
*/
-static void mr_post(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+mr_post(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
sendto_realops_flags(FLAGS_REJ, L_ALL,
"Client rejected for POST command: [%s@%s]",
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_rehash.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_rehash.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "parse.h"
#include "modules.h"
-static void mo_rehash(struct Client*, struct Client*, int, char**);
+static void mo_rehash(struct Client *, struct Client *, int, char **);
struct Message rehash_msgtab = {
"REHASH", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&rehash_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_rehash - REHASH message handler
*
*/
-static void mo_rehash(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_rehash(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
int found = NO;
- if ( !IsOperRehash(source_p) )
- {
- sendto_one(source_p,":%s NOTICE %s :You need rehash = yes;", me.name, parv[0]);
- return;
- }
+ if (!IsOperRehash(source_p))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need rehash = yes;", me.name,
+ parv[0]);
+ return;
+ }
if (parc > 1)
+ {
+ if (irccmp(parv[1], "CHANNELS") == 0)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s is forcing cleanup of channels", parv[0]);
+ found = YES;
+ }
+ else if (irccmp(parv[1], "DNS") == 0)
{
- if (irccmp(parv[1],"CHANNELS") == 0)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s is forcing cleanup of channels",parv[0]);
- found = YES;
- }
- else if(irccmp(parv[1],"DNS") == 0)
- {
- sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0], "DNS");
- sendto_realops_flags(FLAGS_ALL, L_ALL,"%s is rehashing DNS",
- get_oper_name(source_p));
- restart_resolver(); /* re-read /etc/resolv.conf AGAIN?
+ sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0], "DNS");
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%s is rehashing DNS",
+ get_oper_name(source_p));
+ restart_resolver(); /* re-read /etc/resolv.conf AGAIN?
and close/re-open res socket */
- found = YES;
- }
- else if(irccmp(parv[1],"MOTD") == 0)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s is forcing re-reading of MOTD file",
- get_oper_name(source_p));
- ReadMessageFile( &ConfigFileEntry.motd );
- found = YES;
- }
- else if(irccmp(parv[1],"OMOTD") == 0)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s is forcing re-reading of OPER MOTD file",
- get_oper_name(source_p));
- ReadMessageFile( &ConfigFileEntry.opermotd );
- found = YES;
- }
- else if(irccmp(parv[1],"HELP") == 0)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s is forcing re-reading of oper and user help files",
- parv[0]);
- ReadMessageFile( &ConfigFileEntry.helpfile );
- ReadMessageFile( &ConfigFileEntry.uhelpfile );
- found = YES;
- }
- if(found)
- {
- ilog(L_NOTICE, "REHASH %s From %s\n", parv[1],
- get_client_name(source_p, HIDE_IP));
- return;
- }
- else
- {
- sendto_one(source_p,":%s NOTICE %s :rehash one of :CHANNELS DNS HELP MOTD OMOTD" ,me.name,source_p->name);
- return;
- }
+ found = YES;
}
- else
+ else if (irccmp(parv[1], "MOTD") == 0)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s is forcing re-reading of MOTD file",
+ get_oper_name(source_p));
+ ReadMessageFile(&ConfigFileEntry.motd);
+ found = YES;
+ }
+ else if (irccmp(parv[1], "OMOTD") == 0)
{
- sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0],
- ConfigFileEntry.configfile);
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s is rehashing server config file",
- get_oper_name(source_p));
- ilog(L_NOTICE, "REHASH From %s[%s]", get_oper_name(source_p),
- source_p->localClient->sockhost);
- rehash(0);
+ "%s is forcing re-reading of OPER MOTD file",
+ get_oper_name(source_p));
+ ReadMessageFile(&ConfigFileEntry.opermotd);
+ found = YES;
+ }
+ else if (irccmp(parv[1], "HELP") == 0)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s is forcing re-reading of oper and user help files",
+ parv[0]);
+ ReadMessageFile(&ConfigFileEntry.helpfile);
+ ReadMessageFile(&ConfigFileEntry.uhelpfile);
+ found = YES;
+ }
+ if (found)
+ {
+ ilog(L_NOTICE, "REHASH %s From %s\n", parv[1],
+ get_client_name(source_p, HIDE_IP));
return;
}
+ else
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :rehash one of :CHANNELS DNS HELP MOTD OMOTD",
+ me.name, source_p->name);
+ return;
+ }
+ }
+ else
+ {
+ sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0],
+ ConfigFileEntry.configfile);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s is rehashing server config file",
+ get_oper_name(source_p));
+ ilog(L_NOTICE, "REHASH From %s[%s]", get_oper_name(source_p),
+ source_p->localClient->sockhost);
+ rehash(0);
+ return;
+ }
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_restart.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_restart.c,v 1.2 2002/01/04 11:06:19 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
mod_del_cmd(&restart_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_restart
*
*/
-static void mo_restart(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+mo_restart(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- char buf[BUFSIZE];
+ char buf[BUFSIZE];
dlink_node *ptr;
struct Client *target_p;
-
+
if (!MyClient(source_p) || !IsOper(source_p))
- {
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
+ return;
+ }
- if ( !IsOperDie(source_p) )
- {
- sendto_one(source_p,":%s NOTICE %s :You have no D flag", me.name, parv[0]);
- return;
- }
+ if (!IsOperDie(source_p))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You have no D flag", me.name,
+ parv[0]);
+ return;
+ }
if (parc < 2)
{
sendto_one(source_p, ":%s NOTICE %s :Need server name /restart %s",
- me.name, source_p->name, me.name);
+ me.name, source_p->name, me.name);
return;
}
else
if (irccmp(parv[1], me.name))
{
sendto_one(source_p, ":%s NOTICE %s :Mismatch on /restart %s",
- me.name, source_p->name, me.name);
+ me.name, source_p->name, me.name);
return;
}
}
-
- for(ptr = lclient_list.head; ptr; ptr = ptr->next)
+
+ for (ptr = lclient_list.head; ptr; ptr = ptr->next)
{
target_p = ptr->data;
sendto_one(target_p,
":%s NOTICE %s :Server Restarting. %s",
- me.name, target_p->name,
- get_client_name(source_p, HIDE_IP));
+ me.name, target_p->name, get_client_name(source_p, HIDE_IP));
}
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
{
target_p = ptr->data;
sendto_one(target_p, ":%s ERROR :Restart by %s",
me.name, get_client_name(source_p, HIDE_IP));
}
-
+
ircsprintf(buf, "Server RESTART by %s", get_client_name(source_p, HIDE_IP));
restart(buf);
}
-
* modules/m_resv.c
* Copyright (C) 2001 Hybrid Development Team
*
- * $Id: m_resv.c,v 1.1 2002/01/04 09:13:28 a1kmm Exp $
+ * $Id: m_resv.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
mod_del_cmd(&unresv_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* parv[1] = channel/nick to forbid
*/
-static void mo_resv(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_resv(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if(BadPtr(parv[1]))
+ if (BadPtr(parv[1]))
return;
- if(IsChannelName(parv[1]))
+ if (IsChannelName(parv[1]))
{
struct ResvChannel *resv_p;
-
+
resv_p = create_channel_resv(parv[1], parv[2], 0);
-
- if(!(resv_p))
+
+ if (!(resv_p))
{
sendto_one(source_p,
":%s NOTICE %s :A RESV has already been placed on channel: %s",
me.name, source_p->name, parv[1]);
return;
}
-
+
sendto_one(source_p,
":%s NOTICE %s :A local RESV has been placed on channel: %s [%s]",
me.name, source_p->name, resv_p->name, resv_p->reason);
-
+
sendto_realops_flags(FLAGS_ALL, L_ALL,
"%s has placed a local RESV on channel: %s [%s]",
- get_oper_name(source_p),
- resv_p->name, resv_p->reason);
+ get_oper_name(source_p),
+ resv_p->name, resv_p->reason);
}
- else if(clean_resv_nick(parv[1]))
+ else if (clean_resv_nick(parv[1]))
{
struct ResvNick *resv_p;
- if((strchr(parv[1], '*') || strchr(parv[1], '?')) && !IsAdmin(source_p))
+ if ((strchr(parv[1], '*') || strchr(parv[1], '?')) && !IsAdmin(source_p))
{
sendto_one(source_p,
":%s NOTICE %s :You must be an admin to perform a wildcard RESV",
- me.name, source_p->name);
+ me.name, source_p->name);
return;
}
resv_p = create_nick_resv(parv[1], parv[2], 0);
- if(!(resv_p))
+ if (!(resv_p))
{
sendto_one(source_p,
":%s NOTICE %s :A RESV has already been placed on nick: %s",
- me.name, source_p->name, parv[1]);
+ me.name, source_p->name, parv[1]);
return;
}
sendto_one(source_p,
":%s NOTICE %s :A local RESV has been placed on nick: %s [%s]",
- me.name, source_p->name,
- resv_p->name, resv_p->reason);
+ me.name, source_p->name, resv_p->name, resv_p->reason);
sendto_realops_flags(FLAGS_ALL, L_ALL,
"%s has placed a local RESV on nick: %s [%s]",
- get_oper_name(source_p),
- resv_p->name, resv_p->reason);
- }
+ get_oper_name(source_p),
+ resv_p->name, resv_p->reason);
+ }
else
- sendto_one(source_p,
- ":%s NOTICE %s :You have specified an invalid resv: [%s]",
- me.name, source_p->name, parv[1]);
+ sendto_one(source_p,
+ ":%s NOTICE %s :You have specified an invalid resv: [%s]",
+ me.name, source_p->name, parv[1]);
}
/*
* parv[1] = channel/nick to unforbid
*/
-static void mo_unresv(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_unresv(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if(IsChannelName(parv[1]))
+ if (IsChannelName(parv[1]))
{
struct ResvChannel *resv_p;
-
- if(!ResvChannelList ||
- !(resv_p = (struct ResvChannel *)hash_find_resv(parv[1])))
+
+ if (!ResvChannelList ||
+ !(resv_p = (struct ResvChannel *)hash_find_resv(parv[1])))
{
- sendto_one(source_p,
+ sendto_one(source_p,
":%s NOTICE %s :A RESV does not exist for channel: %s",
- me.name, source_p->name, parv[1]);
+ me.name, source_p->name, parv[1]);
return;
}
-
- else if(resv_p->conf)
+
+ else if (resv_p->conf)
{
sendto_one(source_p,
- ":%s NOTICE %s :The RESV for channel: %s is in the config file and must be removed by hand.",
+ ":%s NOTICE %s :The RESV for channel: %s is in the config file and must be removed by hand.",
me.name, source_p->name, parv[1]);
- return;
+ return;
}
/* otherwise, delete it */
else
sendto_one(source_p,
":%s NOTICE %s :The local RESV has been removed on channel: %s",
- me.name, source_p->name, parv[1]);
-
+ me.name, source_p->name, parv[1]);
+
sendto_realops_flags(FLAGS_ALL, L_ALL,
"%s has removed the local RESV for channel: %s",
- get_oper_name(source_p), parv[1]);
-
+ get_oper_name(source_p), parv[1]);
+
}
}
- else if(clean_resv_nick(parv[1]))
+ else if (clean_resv_nick(parv[1]))
{
struct ResvNick *resv_p;
- if(!ResvNickList || !(resv_p = return_nick_resv(parv[1])))
+ if (!ResvNickList || !(resv_p = return_nick_resv(parv[1])))
{
sendto_one(source_p,
":%s NOTICE %s :A RESV does not exist for nick: %s",
- me.name, source_p->name, parv[1]);
+ me.name, source_p->name, parv[1]);
return;
}
- else if(resv_p->conf)
+ else if (resv_p->conf)
{
sendto_one(source_p,
- ":%s NOTICE %s :The RESV for nick: %s is in the config file and must be removed by hand.",
- me.name, source_p->name, parv[1]);
+ ":%s NOTICE %s :The RESV for nick: %s is in the config file and must be removed by hand.",
+ me.name, source_p->name, parv[1]);
return;
}
sendto_one(source_p,
":%s NOTICE %s :The local RESV has been removed on nick: %s",
- me.name, source_p->name, parv[1]);
+ me.name, source_p->name, parv[1]);
sendto_realops_flags(FLAGS_ALL, L_ALL,
"%s has removed the local RESV for nick: %s",
- get_oper_name(source_p), parv[1]);
+ get_oper_name(source_p), parv[1]);
}
}
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_set.c,v 1.1 2002/01/04 09:13:30 a1kmm Exp $ */
+ * $Id: m_set.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $ */
/* rewritten by jdc */
#include "s_bsd.h"
#include "s_serv.h"
#include "send.h"
-#include "common.h" /* for NO */
+#include "common.h" /* for NO */
#include "channel.h"
#include "s_log.h"
#include "s_conf.h"
#include "parse.h"
#include "modules.h"
-#include <stdlib.h> /* atoi */
+#include <stdlib.h> /* atoi */
-static void mo_set(struct Client*, struct Client*, int, char**);
+static void mo_set(struct Client *, struct Client *, int, char **);
struct Message set_msgtab = {
"SET", 0, 0, 0, 0, MFLG_SLOW, 0,
};
#ifndef STATIC_MODULES
- void
+void
_modinit(void)
{
mod_add_cmd(&set_msgtab);
}
- void
+void
_moddeinit(void)
{
mod_del_cmd(&set_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/* Structure used for the SET table itself */
struct SetStruct
{
- char *name;
- void (*handler)();
- int wants_char; /* 1 if it expects (char *, [int]) */
- int wants_int; /* 1 if it expects ([char *], int) */
+ char *name;
+ void (*handler) ();
+ int wants_char; /* 1 if it expects (char *, [int]) */
+ int wants_int; /* 1 if it expects ([char *], int) */
/* eg: 0, 1 == only an int arg
* eg: 1, 1 == char and int args */
* -davidt
*/
-static struct SetStruct set_cmd_table[] =
-{
- /* name function string arg int arg */
+static struct SetStruct set_cmd_table[] = {
+ /* name function string arg int arg */
/* -------------------------------------------------------- */
- { "AUTOCONN", quote_autoconn, 1, 1 },
- { "AUTOCONNALL", quote_autoconnall, 0, 1 },
- { "FLOODCOUNT", quote_floodcount, 0, 1 },
- { "IDLETIME", quote_idletime, 0, 1 },
- { "LOG", quote_log, 0, 1 },
- { "MAX", quote_max, 0, 1 },
- { "MSGLOCALE", quote_msglocale, 1, 0 },
- { "SPAMNUM", quote_spamnum, 0, 1 },
- { "SPAMTIME", quote_spamtime, 0, 1 },
- { "SPLITMODE", quote_splitmode, 0, 1 },
- { "SPLITNUM", quote_splitnum, 0, 1 },
- { "SPLITUSERS", quote_splitusers, 0, 1 },
+ {"AUTOCONN", quote_autoconn, 1, 1},
+ {"AUTOCONNALL", quote_autoconnall, 0, 1},
+ {"FLOODCOUNT", quote_floodcount, 0, 1},
+ {"IDLETIME", quote_idletime, 0, 1},
+ {"LOG", quote_log, 0, 1},
+ {"MAX", quote_max, 0, 1},
+ {"MSGLOCALE", quote_msglocale, 1, 0},
+ {"SPAMNUM", quote_spamnum, 0, 1},
+ {"SPAMTIME", quote_spamtime, 0, 1},
+ {"SPLITMODE", quote_splitmode, 0, 1},
+ {"SPLITNUM", quote_splitnum, 0, 1},
+ {"SPLITUSERS", quote_splitusers, 0, 1},
/* -------------------------------------------------------- */
- { (char *) 0, (void (*)()) 0, 0, 0 }
+ {(char *)0, (void (*)())0, 0, 0}
};
* list_quote_commands() sends the client all the available commands.
* Four to a line for now.
*/
-static void list_quote_commands(struct Client *source_p)
+static void
+list_quote_commands(struct Client *source_p)
{
int i;
- int j=0;
+ int j = 0;
char *names[4];
sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
names[0] = names[1] = names[2] = names[3] = "";
- for (i=0; set_cmd_table[i].handler; i++)
+ for (i = 0; set_cmd_table[i].handler; i++)
{
names[j++] = set_cmd_table[i].name;
- if(j > 3)
+ if (j > 3)
{
sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
me.name, source_p->name,
- names[0], names[1],
- names[2],names[3]);
+ names[0], names[1], names[2], names[3]);
j = 0;
names[0] = names[1] = names[2] = names[3] = "";
}
}
- if(j)
+ if (j)
sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
me.name, source_p->name,
- names[0], names[1],
- names[2],names[3]);
+ names[0], names[1], names[2], names[3]);
}
/* SET AUTOCONN */
-static void quote_autoconn( struct Client *source_p, char *arg, int newval)
+static void
+quote_autoconn(struct Client *source_p, char *arg, int newval)
{
set_autoconn(source_p, source_p->name, arg, newval);
}
/* SET AUTOCONNALL */
-static void quote_autoconnall( struct Client *source_p, int newval)
+static void
+quote_autoconnall(struct Client *source_p, int newval)
{
- if(newval >= 0)
+ if (newval >= 0)
{
- sendto_realops_flags(FLAGS_ALL, L_ALL,"%s has changed AUTOCONNALL to %i",
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%s has changed AUTOCONNALL to %i",
source_p->name, newval);
GlobalSetOptions.autoconn = newval;
/* SET FLOODCOUNT */
-static void quote_floodcount( struct Client *source_p, int newval)
+static void
+quote_floodcount(struct Client *source_p, int newval)
{
- if(newval >= 0)
+ if (newval >= 0)
{
GlobalSetOptions.floodcount = newval;
sendto_realops_flags(FLAGS_ALL, L_ALL,
}
/* SET IDLETIME */
-static void quote_idletime( struct Client *source_p, int newval )
+static void
+quote_idletime(struct Client *source_p, int newval)
{
- if(newval >= 0)
+ if (newval >= 0)
{
if (newval == 0)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
"%s has changed IDLETIME to %i",
source_p->name, newval);
- GlobalSetOptions.idletime = (newval*60);
+ GlobalSetOptions.idletime = (newval * 60);
}
}
else
{
sendto_one(source_p, ":%s NOTICE %s :IDLETIME is currently %i",
- me.name, source_p->name, GlobalSetOptions.idletime/60);
+ me.name, source_p->name, GlobalSetOptions.idletime / 60);
}
}
/* SET LOG */
-static void quote_log( struct Client *source_p, int newval )
+static void
+quote_log(struct Client *source_p, int newval)
{
const char *log_level_as_string;
set_log_level(newval);
log_level_as_string = get_log_level_as_string(newval);
- sendto_realops_flags(FLAGS_ALL, L_ALL,"%s has changed LOG level to %i (%s)",
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s has changed LOG level to %i (%s)",
source_p->name, newval, log_level_as_string);
}
else
}
/* SET MAX */
-static void quote_max( struct Client *source_p, int newval )
+static void
+quote_max(struct Client *source_p, int newval)
{
if (newval > 0)
{
if (newval > MASTER_MAX)
{
sendto_one(source_p,
- ":%s NOTICE %s :You cannot set MAXCLIENTS to > MASTER_MAX (%d)",
- me.name, source_p->name, MASTER_MAX);
+ ":%s NOTICE %s :You cannot set MAXCLIENTS to > MASTER_MAX (%d)",
+ me.name, source_p->name, MASTER_MAX);
return;
}
if (newval < 32)
{
sendto_one(source_p,
- ":%s NOTICE %s :You cannot set MAXCLIENTS to < 32 (%d:%d)",
- me.name, source_p->name, GlobalSetOptions.maxclients, highest_fd);
+ ":%s NOTICE %s :You cannot set MAXCLIENTS to < 32 (%d:%d)",
+ me.name, source_p->name, GlobalSetOptions.maxclients,
+ highest_fd);
return;
}
GlobalSetOptions.maxclients = newval;
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s!%s@%s set new MAXCLIENTS to %d (%d current)",
- source_p->name, source_p->username, source_p->host,
- GlobalSetOptions.maxclients, Count.local);
+ "%s!%s@%s set new MAXCLIENTS to %d (%d current)",
+ source_p->name, source_p->username, source_p->host,
+ GlobalSetOptions.maxclients, Count.local);
return;
}
else
{
sendto_one(source_p, ":%s NOTICE %s :Current Maxclients = %d (%d)",
- me.name, source_p->name,
- GlobalSetOptions.maxclients, Count.local);
+ me.name, source_p->name,
+ GlobalSetOptions.maxclients, Count.local);
}
}
/* SET MSGLOCALE */
-static void quote_msglocale( struct Client *source_p, char *locale )
+static void
+quote_msglocale(struct Client *source_p, char *locale)
{
#ifdef USE_GETTEXT
- if(locale)
+ if (locale)
{
char langenv[BUFSIZE];
- ircsprintf(langenv,"LANGUAGE=%s",locale);
+ ircsprintf(langenv, "LANGUAGE=%s", locale);
putenv(langenv);
sendto_one(source_p, ":%s NOTICE %s :Set MSGLOCALE to '%s'",
- me.name, source_p->name,
- getenv("LANGUAGE") ? getenv("LANGUAGE") : "<unset>");
+ me.name, source_p->name,
+ getenv("LANGUAGE") ? getenv("LANGUAGE") : "<unset>");
}
else
{
sendto_one(source_p, ":%s NOTICE %s :MSGLOCALE is currently '%s'",
- me.name, source_p->name,
- (getenv("LANGUAGE")) ? getenv("LANGUAGE") : "<unset>");
+ me.name, source_p->name,
+ (getenv("LANGUAGE")) ? getenv("LANGUAGE") : "<unset>");
}
#else
sendto_one(source_p, ":%s NOTICE %s :No gettext() support available.",
- me.name, source_p->name);
+ me.name, source_p->name);
#endif
}
/* SET SPAMNUM */
-static void quote_spamnum( struct Client *source_p, int newval )
+static void
+quote_spamnum(struct Client *source_p, int newval)
{
if (newval > 0)
{
{
GlobalSetOptions.spam_num = MIN_SPAM_NUM;
}
- else /* if (newval < MIN_SPAM_NUM) */
+ else /* if (newval < MIN_SPAM_NUM) */
{
GlobalSetOptions.spam_num = newval;
}
- sendto_realops_flags(FLAGS_ALL, L_ALL,"%s has changed SPAMNUM to %i",
- source_p->name, GlobalSetOptions.spam_num);
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%s has changed SPAMNUM to %i",
+ source_p->name, GlobalSetOptions.spam_num);
}
else
{
sendto_one(source_p, ":%s NOTICE %s :SPAMNUM is currently %i",
- me.name,
- source_p->name, GlobalSetOptions.spam_num);
+ me.name, source_p->name, GlobalSetOptions.spam_num);
}
}
/* SET SPAMTIME */
-static void quote_spamtime( struct Client *source_p, int newval )
+static void
+quote_spamtime(struct Client *source_p, int newval)
{
if (newval > 0)
{
{
GlobalSetOptions.spam_time = MIN_SPAM_TIME;
}
- else /* if (newval < MIN_SPAM_TIME) */
+ else /* if (newval < MIN_SPAM_TIME) */
{
GlobalSetOptions.spam_time = newval;
}
- sendto_realops_flags(FLAGS_ALL, L_ALL,"%s has changed SPAMTIME to %i",
- source_p->name, GlobalSetOptions.spam_time);
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%s has changed SPAMTIME to %i",
+ source_p->name, GlobalSetOptions.spam_time);
}
else
{
sendto_one(source_p, ":%s NOTICE %s :SPAMTIME is currently %i",
- me.name,
- source_p->name, GlobalSetOptions.spam_time);
+ me.name, source_p->name, GlobalSetOptions.spam_time);
}
}
/* SET SPLITMODE */
-static void quote_splitmode(struct Client *source_p, int newval)
+static void
+quote_splitmode(struct Client *source_p, int newval)
{
- if(newval >= 0)
+ if (newval >= 0)
{
- if((newval > 0) && !splitmode)
+ if ((newval > 0) && !splitmode)
{
- sendto_realops_flags(FLAGS_ALL, L_ALL,
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
"%s is manually activating splitmode",
get_oper_name(source_p));
sendto_one(source_p, ":%s NOTICE %s :SPLITMODE has been activated",
me.name, source_p->name);
splitmode = 1;
}
- else if((newval == 0) && splitmode)
+ else if ((newval == 0) && splitmode)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
"%s is manually deactivating splitmode",
- get_oper_name(source_p));
+ get_oper_name(source_p));
sendto_one(source_p, ":%s NOTICE %s :SPLITMODE has been deactivated",
me.name, source_p->name);
-
+
splitmode = 0;
/* we might be deactivating an automatic splitmode, so pull the event */
}
}
else
- sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %i",
+ sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %i",
me.name, source_p->name, splitmode);
}
/* SET SPLITNUM */
-static void quote_splitnum(struct Client *source_p, int newval)
+static void
+quote_splitnum(struct Client *source_p, int newval)
{
- if(newval >= 0)
+ if (newval >= 0)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s has changed SPLITNUM to %i",
- source_p->name, newval);
+ "%s has changed SPLITNUM to %i",
+ source_p->name, newval);
split_servers = newval;
}
else
- sendto_one(source_p, ":%s NOTICE %s :SPLITNUM is currently %i",
+ sendto_one(source_p, ":%s NOTICE %s :SPLITNUM is currently %i",
me.name, source_p->name, split_servers);
}
/* SET SPLITUSERS */
-static void quote_splitusers(struct Client *source_p, int newval)
+static void
+quote_splitusers(struct Client *source_p, int newval)
{
- if(newval >= 0)
+ if (newval >= 0)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s has changed SPLITUSERS to %i",
- source_p->name, newval);
+ "%s has changed SPLITUSERS to %i",
+ source_p->name, newval);
split_users = newval;
}
else
- sendto_one(source_p, ":%s NOTICE %s :SPLITUSERS is currently %i",
+ sendto_one(source_p, ":%s NOTICE %s :SPLITUSERS is currently %i",
me.name, source_p->name, split_users);
}
* mo_set - SET command handler
* set options while running
*/
-static void mo_set(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_set(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
int newval;
int i, n;
- char *arg=NULL;
- char *intarg=NULL;
+ char *arg = NULL;
+ char *intarg = NULL;
if (parc > 1)
{
* lookup, but at least it's better than a big-ass switch/case
* statement.
*/
- for (i=0; set_cmd_table[i].handler; i++)
+ for (i = 0; set_cmd_table[i].handler; i++)
{
if (!irccmp(set_cmd_table[i].name, parv[1]))
{
*/
n = 2;
- if(set_cmd_table[i].wants_char)
+ if (set_cmd_table[i].wants_char)
{
arg = parv[n++];
}
- if(set_cmd_table[i].wants_int)
+ if (set_cmd_table[i].wants_int)
{
intarg = parv[n++];
}
- if( (n - 1) > parc )
+ if ((n - 1) > parc)
{
- if(parc > 2)
+ if (parc > 2)
sendto_one(source_p,
":%s NOTICE %s :SET %s expects (\"%s%s\") args",
me.name, source_p->name, set_cmd_table[i].name,
(set_cmd_table[i].wants_char ? "string, " : ""),
- (set_cmd_table[i].wants_char ? "int" : "")
- );
+ (set_cmd_table[i].wants_char ? "int" : ""));
}
- if(parc <= 2)
+ if (parc <= 2)
{
arg = NULL;
intarg = NULL;
}
- if(set_cmd_table[i].wants_int && (parc > 2))
+ if (set_cmd_table[i].wants_int && (parc > 2))
{
- if(intarg)
+ if (intarg)
{
- if(!irccmp(intarg, "yes") || !irccmp(intarg, "on"))
+ if (!irccmp(intarg, "yes") || !irccmp(intarg, "on"))
newval = 1;
else if (!irccmp(intarg, "no") || !irccmp(intarg, "off"))
newval = 0;
newval = -1;
}
- if(newval < 0)
+ if (newval < 0)
{
sendto_one(source_p,
":%s NOTICE %s :Value less than 0 illegal for %s",
- me.name, source_p->name,
- set_cmd_table[i].name);
+ me.name, source_p->name, set_cmd_table[i].name);
return;
}
else
newval = -1;
- if(set_cmd_table[i].wants_char)
+ if (set_cmd_table[i].wants_char)
{
- if(set_cmd_table[i].wants_int)
- set_cmd_table[i].handler( source_p, arg, newval );
+ if (set_cmd_table[i].wants_int)
+ set_cmd_table[i].handler(source_p, arg, newval);
else
- set_cmd_table[i].handler( source_p, arg );
+ set_cmd_table[i].handler(source_p, arg);
return;
}
else
{
- if(set_cmd_table[i].wants_int)
- set_cmd_table[i].handler( source_p, newval );
+ if (set_cmd_table[i].wants_int)
+ set_cmd_table[i].handler(source_p, newval);
else
/* Just in case someone actually wants a
* set function that takes no args.. *shrug* */
- set_cmd_table[i].handler( source_p );
+ set_cmd_table[i].handler(source_p);
return;
}
}
* Code here will be executed when a /QUOTE SET command is not
* found within set_cmd_table.
*/
- sendto_one(source_p, ":%s NOTICE %s :Variable not found.", me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :Variable not found.", me.name,
+ parv[0]);
return;
}
list_quote_commands(source_p);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_stats.c,v 1.1 2002/01/04 09:13:30 a1kmm Exp $
+ * $Id: m_stats.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
-#include "tools.h" /* dlink_node/dlink_list */
-#include "handlers.h" /* m_pass prototype */
-#include "class.h" /* report_classes */
-#include "client.h" /* Client */
-#include "common.h" /* TRUE/FALSE */
-#include "irc_string.h" /* strncpy_irc */
-#include "ircd.h" /* me */
-#include "listener.h" /* show_ports */
+#include "tools.h" /* dlink_node/dlink_list */
+#include "handlers.h" /* m_pass prototype */
+#include "class.h" /* report_classes */
+#include "client.h" /* Client */
+#include "common.h" /* TRUE/FALSE */
+#include "irc_string.h" /* strncpy_irc */
+#include "ircd.h" /* me */
+#include "listener.h" /* show_ports */
#include "s_gline.h"
#include "ircd_handler.h"
-#include "msg.h" /* Message */
-#include "hostmask.h" /* report_mtrie_conf_links */
-#include "numeric.h" /* ERR_xxx */
-#include "scache.h" /* list_scache */
-#include "send.h" /* sendto_one */
-#include "fdlist.h" /* PF and friends */
-#include "s_bsd.h" /* highest_fd */
-#include "s_conf.h" /* ConfItem, report_configured_links */
-#include "s_debug.h" /* send_usage */
-#include "s_misc.h" /* serv_info */
-#include "s_serv.h" /* hunt_server */
-#include "s_stats.h" /* tstats */
-#include "s_user.h" /* show_opers */
-#include "event.h" /* events */
+#include "msg.h" /* Message */
+#include "hostmask.h" /* report_mtrie_conf_links */
+#include "numeric.h" /* ERR_xxx */
+#include "scache.h" /* list_scache */
+#include "send.h" /* sendto_one */
+#include "fdlist.h" /* PF and friends */
+#include "s_bsd.h" /* highest_fd */
+#include "s_conf.h" /* ConfItem, report_configured_links */
+#include "s_debug.h" /* send_usage */
+#include "s_misc.h" /* serv_info */
+#include "s_serv.h" /* hunt_server */
+#include "s_stats.h" /* tstats */
+#include "s_user.h" /* show_opers */
+#include "event.h" /* events */
#include "linebuf.h"
#include "parse.h"
#include "modules.h"
#include "hook.h"
-#include "resv.h" /* report_resv */
+#include "resv.h" /* report_resv */
#include <string.h>
#include <time.h>
-static void m_stats(struct Client*, struct Client*, int, char**);
-static void mo_stats(struct Client*, struct Client*, int, char**);
-static void ms_stats(struct Client*, struct Client*, int, char**);
+static void m_stats(struct Client *, struct Client *, int, char **);
+static void mo_stats(struct Client *, struct Client *, int, char **);
+static void ms_stats(struct Client *, struct Client *, int, char **);
struct Message stats_msgtab = {
"STATS", 0, 0, 2, 0, MFLG_SLOW, 0,
mod_del_cmd(&stats_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
-const char* Lformat = ":%s %d %s %s %u %u %u %u %u :%u %u %s";
+const char *Lformat = ":%s %d %s %s %u %u %u %u %u :%u %u %s";
static char *parse_stats_args(int, char **, int *, int *);
struct StatsStruct
{
char letter;
- void (*handler)();
- int need_oper;
- int need_admin;
+ void (*handler) ();
+ int need_oper;
+ int need_admin;
};
static void stats_adns_servers(struct Client *);
static void stats_class(struct Client *);
static void stats_memory(struct Client *);
static void stats_servlinks(struct Client *);
-static void stats_ltrace(struct Client *, int, char**);
+static void stats_ltrace(struct Client *, int, char **);
static void stats_ziplinks(struct Client *);
/* This table contains the possible stats items, in order:
* /stats name, function to call, operonly? adminonly? /stats letter
* case only matters in the stats letter column.. -- fl_ */
-static struct StatsStruct stats_cmd_table[] =
-{
+static struct StatsStruct stats_cmd_table[] = {
/* letter function need_oper need_admin */
- { 'a', stats_adns_servers, 1, 1, },
- { 'A', stats_adns_servers, 1, 1, },
- { 'c', stats_connect, 1, 0, },
- { 'C', stats_connect, 1, 0, },
- { 'd', stats_deny, 1, 0, },
- { 'D', stats_deny, 1, 0, },
- { 'e', stats_exempt, 1, 0, },
- { 'E', stats_events, 1, 1, },
- { 'f', fd_dump, 1, 1, },
- { 'F', fd_dump, 1, 1, },
- { 'g', stats_glines, 1, 0, },
- { 'G', stats_glines, 1, 0, },
- { 'h', stats_hubleaf, 1, 0, },
- { 'H', stats_hubleaf, 1, 0, },
- { 'i', stats_auth, 0, 0, },
- { 'I', stats_auth, 0, 0, },
- { 'k', stats_tklines, 0, 0, },
- { 'K', stats_klines, 0, 0, },
- { 'l', stats_ltrace, 1, 0, },
- { 'L', stats_ltrace, 1, 0, },
- { 'm', stats_messages, 0, 0, },
- { 'M', stats_messages, 0, 0, },
- { 'o', stats_oper, 0, 0, },
- { 'O', stats_oper, 0, 0, },
- { 'p', stats_operedup, 0, 0, },
- { 'P', stats_ports, 0, 0, },
- { 'q', stats_resv, 1, 0, },
- { 'Q', stats_resv, 1, 0, },
- { 'r', stats_usage, 1, 0, },
- { 'R', stats_usage, 1, 0, },
- { 't', stats_tstats, 1, 0, },
- { 'T', stats_tstats, 1, 0, },
- { 'u', stats_uptime, 0, 0, },
- { 'U', stats_shared, 1, 0, },
- { 'v', stats_servers, 1, 0, },
- { 'V', stats_servers, 1, 0, },
- { 'x', stats_gecos, 1, 0, },
- { 'X', stats_gecos, 1, 0, },
- { 'y', stats_class, 1, 0, },
- { 'Y', stats_class, 1, 0, },
- { 'z', stats_memory, 1, 0, },
- { 'Z', stats_ziplinks, 1, 0, },
- { '?', stats_servlinks, 0, 0, },
- { (char) 0, (void (*)()) 0, 0, 0, }
+ {'a', stats_adns_servers, 1, 1,},
+ {'A', stats_adns_servers, 1, 1,},
+ {'c', stats_connect, 1, 0,},
+ {'C', stats_connect, 1, 0,},
+ {'d', stats_deny, 1, 0,},
+ {'D', stats_deny, 1, 0,},
+ {'e', stats_exempt, 1, 0,},
+ {'E', stats_events, 1, 1,},
+ {'f', fd_dump, 1, 1,},
+ {'F', fd_dump, 1, 1,},
+ {'g', stats_glines, 1, 0,},
+ {'G', stats_glines, 1, 0,},
+ {'h', stats_hubleaf, 1, 0,},
+ {'H', stats_hubleaf, 1, 0,},
+ {'i', stats_auth, 0, 0,},
+ {'I', stats_auth, 0, 0,},
+ {'k', stats_tklines, 0, 0,},
+ {'K', stats_klines, 0, 0,},
+ {'l', stats_ltrace, 1, 0,},
+ {'L', stats_ltrace, 1, 0,},
+ {'m', stats_messages, 0, 0,},
+ {'M', stats_messages, 0, 0,},
+ {'o', stats_oper, 0, 0,},
+ {'O', stats_oper, 0, 0,},
+ {'p', stats_operedup, 0, 0,},
+ {'P', stats_ports, 0, 0,},
+ {'q', stats_resv, 1, 0,},
+ {'Q', stats_resv, 1, 0,},
+ {'r', stats_usage, 1, 0,},
+ {'R', stats_usage, 1, 0,},
+ {'t', stats_tstats, 1, 0,},
+ {'T', stats_tstats, 1, 0,},
+ {'u', stats_uptime, 0, 0,},
+ {'U', stats_shared, 1, 0,},
+ {'v', stats_servers, 1, 0,},
+ {'V', stats_servers, 1, 0,},
+ {'x', stats_gecos, 1, 0,},
+ {'X', stats_gecos, 1, 0,},
+ {'y', stats_class, 1, 0,},
+ {'Y', stats_class, 1, 0,},
+ {'z', stats_memory, 1, 0,},
+ {'Z', stats_ziplinks, 1, 0,},
+ {'?', stats_servlinks, 0, 0,},
+ {(char)0, (void (*)())0, 0, 0,}
};
/*
* if found execute it.
*/
-static void m_stats(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_stats(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
int i;
char statchar;
static time_t last_used = 0;
/* Check the user is actually allowed to do /stats, and isnt flooding */
- if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
- {
- /* safe enough to give this on a local connect only */
- if(MyClient(source_p))
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,parv[0]);
- return;
- }
+ if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
+ {
+ /* safe enough to give this on a local connect only */
+ if (MyClient(source_p))
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
+ return;
+ }
else
- {
- last_used = CurrentTime;
- }
+ {
+ last_used = CurrentTime;
+ }
/* Is the stats meant for us? */
if (!ConfigServerHide.disable_remote)
- {
- if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv) != HUNTED_ISME)
- return;
- }
+ {
+ if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, parc, parv) !=
+ HUNTED_ISME)
+ return;
+ }
statchar = parv[1][0];
- for (i=0; stats_cmd_table[i].handler; i++)
+ for (i = 0; stats_cmd_table[i].handler; i++)
{
if (stats_cmd_table[i].letter == statchar)
{
/* The stats table says what privs are needed, so check --fl_ */
- if(stats_cmd_table[i].need_oper || stats_cmd_table[i].need_admin)
+ if (stats_cmd_table[i].need_oper || stats_cmd_table[i].need_admin)
{
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),me.name,source_p->name);
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name,
+ source_p->name);
break;
}
/* Blah, stats L needs the parameters, none of the others do.. */
- if(statchar == 'L' || statchar == 'l')
+ if (statchar == 'L' || statchar == 'l')
stats_cmd_table[i].handler(source_p, parc, parv);
else
stats_cmd_table[i].handler(source_p);
/* Send the end of stats notice, and the stats_spy */
sendto_one(source_p, form_str(RPL_ENDOFSTATS), me.name, parv[0], parv[1]);
- if((statchar != 'L') && (statchar != 'l'))
+ if ((statchar != 'L') && (statchar != 'l'))
stats_spy(source_p, statchar);
}
* if found execute it.
*/
-static void mo_stats(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_stats(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
int i;
char statchar;
- if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv) != HUNTED_ISME)
- return;
+ if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, parc, parv) !=
+ HUNTED_ISME)
+ return;
- statchar=parv[1][0];
+ statchar = parv[1][0];
- for (i=0; stats_cmd_table[i].handler; i++)
+ for (i = 0; stats_cmd_table[i].handler; i++)
{
if (stats_cmd_table[i].letter == statchar)
{
/* Called for remote clients and for local opers, so check need_admin
* and need_oper
*/
- if((stats_cmd_table[i].need_admin && !IsOperAdmin(source_p)) ||
- (stats_cmd_table[i].need_oper && !IsOper(source_p)))
+ if ((stats_cmd_table[i].need_admin && !IsOperAdmin(source_p)) ||
+ (stats_cmd_table[i].need_oper && !IsOper(source_p)))
{
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),me.name,source_p->name);
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name,
+ source_p->name);
break;
}
/* Blah, stats L needs the parameters, none of the others do.. */
- if(statchar == 'L' || statchar == 'l')
+ if (statchar == 'L' || statchar == 'l')
stats_cmd_table[i].handler(source_p, parc, parv, statchar);
else
stats_cmd_table[i].handler(source_p);
/* Send the end of stats notice, and the stats_spy */
sendto_one(source_p, form_str(RPL_ENDOFSTATS), me.name, parv[0], parv[1]);
- if((statchar != 'L') && (statchar != 'l'))
+ if ((statchar != 'L') && (statchar != 'l'))
stats_spy(source_p, statchar);
}
-static void stats_adns_servers(struct Client *source_p)
+static void
+stats_adns_servers(struct Client *source_p)
{
report_adns_servers(source_p);
}
-static void stats_connect(struct Client *source_p)
+static void
+stats_connect(struct Client *source_p)
{
report_configured_links(source_p, CONF_SERVER);
}
* output - none
* side effects - client is given dline list.
*/
-static void stats_deny(struct Client *source_p)
+static void
+stats_deny(struct Client *source_p)
{
char *name, *host, *pass, *user, *classname;
struct AddressRec *arec;
struct ConfItem *aconf;
int i, port;
- for (i=0; i < ATABLE_SIZE; i++)
+ for (i = 0; i < ATABLE_SIZE; i++)
{
- for (arec = atable[i]; arec; arec=arec->next)
+ for (arec = atable[i]; arec; arec = arec->next)
{
if (arec->type == CONF_DLINE)
{
aconf = arec->aconf;
- get_printable_conf(aconf, &name, &host, &pass, &user, &port,
- &classname);
-
- sendto_one(source_p, form_str(RPL_STATSDLINE), me.name,
- source_p->name, 'D', host, pass);
+ get_printable_conf(aconf, &name, &host, &pass, &user, &port,
+ &classname);
+
+ sendto_one(source_p, form_str(RPL_STATSDLINE), me.name,
+ source_p->name, 'D', host, pass);
}
}
}
* output - none
* side effects - client is given list of exempt blocks
*/
-static void stats_exempt(struct Client *source_p)
+static void
+stats_exempt(struct Client *source_p)
{
char *name, *host, *pass, *user, *classname;
struct AddressRec *arec;
struct ConfItem *aconf;
int i, port;
- for (i=0; i<ATABLE_SIZE; i++)
+ for (i = 0; i < ATABLE_SIZE; i++)
{
- for (arec = atable[i]; arec; arec=arec->next)
+ for (arec = atable[i]; arec; arec = arec->next)
{
if (arec->type == CONF_EXEMPTDLINE)
{
aconf = arec->aconf;
- get_printable_conf(aconf, &name, &host, &pass,
- &user, &port, &classname);
-
- sendto_one(source_p, form_str(RPL_STATSDLINE), me.name,
- source_p->name, 'e', host, pass);
+ get_printable_conf(aconf, &name, &host, &pass,
+ &user, &port, &classname);
+
+ sendto_one(source_p, form_str(RPL_STATSDLINE), me.name,
+ source_p->name, 'e', host, pass);
}
}
}
}
-static void stats_events(struct Client *source_p)
+static void
+stats_events(struct Client *source_p)
{
show_events(source_p);
}
* output - none
* side effects - client is shown list of glines
*/
-static void stats_glines(struct Client *source_p)
+static void
+stats_glines(struct Client *source_p)
{
- if(ConfigFileEntry.glines)
+ if (ConfigFileEntry.glines)
{
dlink_node *pending_node;
dlink_node *gline_node;
sendto_one(source_p, ":%s NOTICE %s :Pending G-lines",
me.name, source_p->name);
- for(pending_node = pending_glines.head; pending_node;
- pending_node = pending_node->next)
+ for (pending_node = pending_glines.head; pending_node;
+ pending_node = pending_node->next)
{
glp_ptr = pending_node->data;
-
+
tmptr = localtime(&glp_ptr->time_request1);
strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
sendto_one(source_p,
- ":%s NOTICE %s :1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
- me.name, source_p->name, glp_ptr->oper_nick1,
- glp_ptr->oper_user1, glp_ptr->oper_host1,
- glp_ptr->oper_server1, timebuffer,
- glp_ptr->user, glp_ptr->host, glp_ptr->reason1);
+ ":%s NOTICE %s :1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
+ me.name, source_p->name, glp_ptr->oper_nick1,
+ glp_ptr->oper_user1, glp_ptr->oper_host1,
+ glp_ptr->oper_server1, timebuffer,
+ glp_ptr->user, glp_ptr->host, glp_ptr->reason1);
- if(glp_ptr->oper_nick2[0])
+ if (glp_ptr->oper_nick2[0])
{
tmptr = localtime(&glp_ptr->time_request2);
- strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
- sendto_one(source_p,
- ":%s NOTICE %s :2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
- me.name, source_p->name, glp_ptr->oper_nick2,
- glp_ptr->oper_user2, glp_ptr->oper_host2,
- glp_ptr->oper_server2, timebuffer,
- glp_ptr->user, glp_ptr->host, glp_ptr->reason2);
+ strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
+ sendto_one(source_p,
+ ":%s NOTICE %s :2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
+ me.name, source_p->name, glp_ptr->oper_nick2,
+ glp_ptr->oper_user2, glp_ptr->oper_host2,
+ glp_ptr->oper_server2, timebuffer,
+ glp_ptr->user, glp_ptr->host, glp_ptr->reason2);
}
}
sendto_one(source_p, ":%s NOTICE %s :End of Pending G-lines",
me.name, source_p->name);
- for(gline_node = glines.head; gline_node; gline_node = gline_node->next)
+ for (gline_node = glines.head; gline_node; gline_node = gline_node->next)
{
kill_ptr = gline_node->data;
- if(kill_ptr->host)
+ if (kill_ptr->host)
host = kill_ptr->host;
else
host = "*";
- if(kill_ptr->name)
+ if (kill_ptr->name)
name = kill_ptr->name;
else
name = "*";
- if(kill_ptr->passwd)
+ if (kill_ptr->passwd)
reason = kill_ptr->passwd;
else
reason = "No Reason";
}
}
else
- sendto_one(source_p, ":%s NOTICE %s :This server does not support G-Lines",
- me.name, source_p->name);
+ sendto_one(source_p,
+ ":%s NOTICE %s :This server does not support G-Lines", me.name,
+ source_p->name);
}
-static void stats_hubleaf(struct Client *source_p)
+static void
+stats_hubleaf(struct Client *source_p)
{
- report_configured_links(source_p, CONF_HUB|CONF_LEAF);
+ report_configured_links(source_p, CONF_HUB | CONF_LEAF);
}
-static void stats_auth(struct Client *source_p)
+static void
+stats_auth(struct Client *source_p)
{
/* Oper only, if unopered, return ERR_NOPRIVS */
- if((ConfigFileEntry.stats_i_oper_only == 2) && !IsOper(source_p))
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
- me.name, source_p->name);
+ if ((ConfigFileEntry.stats_i_oper_only == 2) && !IsOper(source_p))
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, source_p->name);
/* If unopered, Only return matching auth blocks */
- else if((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper(source_p))
+ else if ((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper(source_p))
{
struct ConfItem *aconf;
char *name, *host, *pass, *user, *classname;
int port;
- if(MyConnect(source_p))
+ if (MyConnect(source_p))
aconf = find_conf_by_address(source_p->host,
&source_p->localClient->ip,
- CONF_CLIENT,
- source_p->localClient->aftype,
- source_p->username);
+ CONF_CLIENT,
+ source_p->localClient->aftype,
+ source_p->username);
else
aconf = find_conf_by_address(source_p->host, NULL, CONF_CLIENT,
0, source_p->username);
- if(aconf == NULL)
+ if (aconf == NULL)
return;
-
- get_printable_conf(aconf, &name, &host, &pass, &user,
- &port, &classname);
+
+ get_printable_conf(aconf, &name, &host, &pass, &user, &port, &classname);
sendto_one(source_p, form_str(RPL_STATSILINE), me.name,
source_p->name, (IsConfRestricted(aconf)) ? 'i' : 'I',
- name, show_iline_prefix(source_p, aconf, user), host,
- port, classname);
+ name, show_iline_prefix(source_p, aconf, user), host,
+ port, classname);
}
/* Theyre opered, or allowed to see all auth blocks */
}
-static void stats_tklines(struct Client *source_p)
+static void
+stats_tklines(struct Client *source_p)
{
/* Oper only, if unopered, return ERR_NOPRIVS */
- if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
- me.name, source_p->name);
+ if ((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, source_p->name);
/* If unopered, Only return matching klines */
- else if((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
+ else if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
report_Klines(source_p, 1, 1);
/* Theyre opered, or allowed to see all klines */
}
-static void stats_klines(struct Client *source_p)
+static void
+stats_klines(struct Client *source_p)
{
/* Oper only, if unopered, return ERR_NOPRIVS */
- if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
- me.name, source_p->name);
+ if ((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, source_p->name);
/* If unopered, Only return matching klines */
- else if((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
+ else if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
report_Klines(source_p, 0, 1);
/* Theyre opered, or allowed to see all klines */
report_Klines(source_p, 0, 0);
}
-static void stats_messages(struct Client *source_p)
+static void
+stats_messages(struct Client *source_p)
{
report_messages(source_p);
}
-static void stats_oper(struct Client *source_p)
+static void
+stats_oper(struct Client *source_p)
{
if (!IsOper(source_p) && ConfigFileEntry.stats_o_oper_only)
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),me.name,source_p->name);
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, source_p->name);
else
report_configured_links(source_p, CONF_OPERATOR);
}
* output - none
* side effects - client is shown a list of active opers
*/
-static void stats_operedup(struct Client *source_p)
+static void
+stats_operedup(struct Client *source_p)
{
struct Client *target_p;
struct ConfItem *aconf;
dlink_node *oper_ptr;
dlink_node *ptr;
- int j=0;
+ int j = 0;
- for(oper_ptr = oper_list.head; oper_ptr; oper_ptr = oper_ptr->next)
+ for (oper_ptr = oper_list.head; oper_ptr; oper_ptr = oper_ptr->next)
{
target_p = oper_ptr->data;
sendto_one(source_p, ":%s %d %s :[O][%s] %s (%s@%s) Idle: %d",
me.name, RPL_STATSDEBUG, source_p->name,
- oper_privs_as_string(target_p, aconf->port),
- target_p->name, target_p->username, target_p->host,
- (int)(CurrentTime - target_p->user->last));
+ oper_privs_as_string(target_p, aconf->port),
+ target_p->name, target_p->username, target_p->host,
+ (int)(CurrentTime - target_p->user->last));
}
else
{
sendto_one(source_p, ":%s %d %s :[O] %s (%s@%s) Idle: %d",
me.name, RPL_STATSDEBUG, source_p->name,
- target_p->name, target_p->username, target_p->host,
- (int)(CurrentTime - target_p->user->last));
+ target_p->name, target_p->username, target_p->host,
+ (int)(CurrentTime - target_p->user->last));
}
}
stats_p_spy(source_p);
}
-static void stats_ports(struct Client *source_p)
+static void
+stats_ports(struct Client *source_p)
{
if (!IsOper(source_p) && ConfigFileEntry.stats_P_oper_only)
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),me.name,source_p->name);
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, source_p->name);
else
show_ports(source_p);
}
-static void stats_resv(struct Client *source_p)
+static void
+stats_resv(struct Client *source_p)
{
report_resv(source_p);
}
-static void stats_usage(struct Client *source_p)
+static void
+stats_usage(struct Client *source_p)
{
send_usage(source_p);
}
-static void stats_tstats(struct Client *source_p)
+static void
+stats_tstats(struct Client *source_p)
{
tstats(source_p);
}
-static void stats_uptime(struct Client *source_p)
+static void
+stats_uptime(struct Client *source_p)
{
time_t now;
- now = CurrentTime - me.since;
- sendto_one(source_p, form_str(RPL_STATSUPTIME), me.name, source_p->name,
- now/86400, (now/3600)%24, (now/60)%60, now%60);
- if(!ConfigServerHide.disable_remote || IsOper(source_p))
- sendto_one(source_p, form_str(RPL_STATSCONN), me.name, source_p->name,
- MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
+ now = CurrentTime - me.since;
+ sendto_one(source_p, form_str(RPL_STATSUPTIME), me.name, source_p->name,
+ now / 86400, (now / 3600) % 24, (now / 60) % 60, now % 60);
+ if (!ConfigServerHide.disable_remote || IsOper(source_p))
+ sendto_one(source_p, form_str(RPL_STATSCONN), me.name, source_p->name,
+ MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
}
-static void stats_shared(struct Client *source_p)
+static void
+stats_shared(struct Client *source_p)
{
report_specials(source_p, CONF_ULINE, RPL_STATSULINE);
}
* output - none
* side effects - client is shown lists of who connected servers
*/
-static void stats_servers(struct Client *source_p)
+static void
+stats_servers(struct Client *source_p)
{
struct Client *target_p;
dlink_node *ptr;
- int j=0;
-
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
+ int j = 0;
+
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
{
target_p = ptr->data;
sendto_one(source_p, ":%s %d %s :%s (%s!%s@%s) Idle: %d",
me.name, RPL_STATSDEBUG, source_p->name,
- target_p->name,
- (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
- "*", "*", (int)(CurrentTime - target_p->lasttime));
+ target_p->name,
+ (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
+ "*", "*", (int)(CurrentTime - target_p->lasttime));
}
sendto_one(source_p, ":%s %d %s :%d Server(s)", me.name, RPL_STATSDEBUG,
source_p->name, j);
}
-static void stats_gecos(struct Client *source_p)
+static void
+stats_gecos(struct Client *source_p)
{
report_specials(source_p, CONF_XLINE, RPL_STATSXLINE);
}
-static void stats_class(struct Client *source_p)
+static void
+stats_class(struct Client *source_p)
{
report_classes(source_p);
}
-static void stats_memory(struct Client *source_p)
+static void
+stats_memory(struct Client *source_p)
{
count_memory(source_p);
}
-static void stats_ziplinks(struct Client *source_p)
+static void
+stats_ziplinks(struct Client *source_p)
{
dlink_node *ptr;
struct Client *target_p;
int sent_data = 0;
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
{
target_p = ptr->data;
if (IsCapable(target_p, CAP_ZIP))
{
- sendto_one(source_p, ":%s %d %s :ZipLinks stats for %s send[%.2f%% compression (%lu bytes data/%lu bytes wire)] recv[%.2f%% compression (%lu bytes data/%lu bytes wire)]",
+ sendto_one(source_p,
+ ":%s %d %s :ZipLinks stats for %s send[%.2f%% compression (%lu bytes data/%lu bytes wire)] recv[%.2f%% compression (%lu bytes data/%lu bytes wire)]",
me.name, RPL_STATSDEBUG, source_p->name, target_p->name,
target_p->localClient->zipstats.out_ratio,
target_p->localClient->zipstats.out,
me.name, RPL_STATSDEBUG, source_p->name, sent_data);
}
-static void stats_servlinks(struct Client *source_p)
+static void
+stats_servlinks(struct Client *source_p)
{
static char Sformat[] = ":%s %d %s %s %u %u %u %u %u :%u %u %s";
long uptime, sendK, receiveK;
- struct Client *target_p;
+ struct Client *target_p;
dlink_node *ptr;
int j = 0;
- if(ConfigServerHide.flatten_links && !IsOper(source_p))
+ if (ConfigServerHide.flatten_links && !IsOper(source_p))
{
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),me.name, source_p->name);
+ sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, source_p->name);
return;
}
sendK = receiveK = 0;
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
{
target_p = ptr->data;
receiveK += target_p->localClient->receiveK;
sendto_one(source_p, Sformat, me.name, RPL_STATSLINKINFO,
- source_p->name,
+ source_p->name,
IsOperAdmin(source_p) ? get_client_name(target_p, SHOW_IP)
- : get_client_name(target_p, MASK_IP),
+ : get_client_name(target_p, MASK_IP),
(int)linebuf_len(&target_p->localClient->buf_sendq),
(int)target_p->localClient->sendM,
(int)target_p->localClient->sendK,
(int)target_p->localClient->receiveM,
(int)target_p->localClient->receiveK,
CurrentTime - target_p->firsttime,
- (CurrentTime > target_p->since) ? (CurrentTime - target_p->since): 0,
+ (CurrentTime >
+ target_p->since) ? (CurrentTime - target_p->since) : 0,
IsOper(source_p) ? show_capabilities(target_p) : "TS");
}
-
+
sendto_one(source_p, ":%s %d %s :%u total server(s)",
me.name, RPL_STATSDEBUG, source_p->name, j);
sendto_one(source_p, ":%s %d %s :Sent total : %7.2f %s",
- me.name, RPL_STATSDEBUG, source_p->name,
- _GMKv(sendK), _GMKs(sendK));
+ me.name, RPL_STATSDEBUG, source_p->name,
+ _GMKv(sendK), _GMKs(sendK));
sendto_one(source_p, ":%s %d %s :Recv total : %7.2f %s",
me.name, RPL_STATSDEBUG, source_p->name,
- _GMKv(receiveK), _GMKs(receiveK));
+ _GMKv(receiveK), _GMKs(receiveK));
uptime = (CurrentTime - me.since);
sendto_one(source_p, ":%s %d %s :Server send: %7.2f %s (%4.1f K/s)",
me.name, RPL_STATSDEBUG, source_p->name,
- _GMKv(me.localClient->sendK), _GMKs(me.localClient->sendK),
- (float)((float)me.localClient->sendK / (float)uptime));
+ _GMKv(me.localClient->sendK), _GMKs(me.localClient->sendK),
+ (float)((float)me.localClient->sendK / (float)uptime));
sendto_one(source_p, ":%s %d %s :Server recv: %7.2f %s (%4.1f K/s)",
me.name, RPL_STATSDEBUG, source_p->name,
- _GMKv(me.localClient->receiveK),
- _GMKs(me.localClient->receiveK),
- (float)((float)me.localClient->receiveK / (float)uptime));
+ _GMKv(me.localClient->receiveK),
+ _GMKs(me.localClient->receiveK),
+ (float)((float)me.localClient->receiveK / (float)uptime));
}
-static void stats_ltrace(struct Client *source_p, int parc, char *parv[])
+static void
+stats_ltrace(struct Client *source_p, int parc, char *parv[])
{
- int doall = 0;
- int wilds = 0;
- char *name=NULL;
- char statchar;
-
- name = parse_stats_args(parc,parv,&doall,&wilds);
+ int doall = 0;
+ int wilds = 0;
+ char *name = NULL;
+ char statchar;
+
+ name = parse_stats_args(parc, parv, &doall, &wilds);
- if(name)
+ if (name)
{
- statchar=parv[1][0];
+ statchar = parv[1][0];
stats_L(source_p, name, doall, wilds, statchar);
stats_L_spy(source_p, statchar, name);
* parv[2] = server name (current server defaulted, if omitted)
*/
-static void ms_stats(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_stats(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv)!=HUNTED_ISME)
+ if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, parc, parv) !=
+ HUNTED_ISME)
return;
mo_stats(client_p, source_p, parc, parv);
* output - NONE
* side effects -
*/
-static void stats_L(struct Client *source_p,char *name,int doall,
- int wilds,char statchar)
+static void
+stats_L(struct Client *source_p, char *name, int doall,
+ int wilds, char statchar)
{
stats_L_list(source_p, name, doall, wilds, &unknown_list, statchar);
stats_L_list(source_p, name, doall, wilds, &lclient_list, statchar);
stats_L_list(source_p, name, doall, wilds, &serv_list, statchar);
}
-static void stats_L_list(struct Client *source_p,char *name, int doall, int wilds,
- dlink_list *list,char statchar)
+static void
+stats_L_list(struct Client *source_p, char *name, int doall, int wilds,
+ dlink_list * list, char statchar)
{
dlink_node *ptr;
struct Client *target_p;
* are invisible not being visible to 'foreigners' who use
* a wild card based search to list it.
*/
- for(ptr = list->head;ptr;ptr = ptr->next)
+ for (ptr = list->head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
+
+ if (IsInvisible(target_p) && (doall || wilds) &&
+ !(MyConnect(source_p) && IsOper(source_p)) &&
+ !IsOper(target_p) && (target_p != source_p))
+ continue;
+ if (!doall && wilds && !match(name, target_p->name))
+ continue;
+ if (!(doall || wilds) && irccmp(name, target_p->name))
+ continue;
+
+ /* This basically shows ips for our opers if its not a server/admin, or
+ * its one of our admins. */
+ if (MyClient(source_p) && IsOper(source_p) &&
+ (IsOperAdmin(source_p) ||
+ (!IsServer(target_p) && !IsAdmin(target_p) &&
+ !IsHandshake(target_p) && !IsConnecting(target_p))))
{
- target_p = ptr->data;
-
- if (IsInvisible(target_p) && (doall || wilds) &&
- !(MyConnect(source_p) && IsOper(source_p)) &&
- !IsOper(target_p) && (target_p != source_p))
- continue;
- if (!doall && wilds && !match(name, target_p->name))
- continue;
- if (!(doall || wilds) && irccmp(name, target_p->name))
- continue;
-
- /* This basically shows ips for our opers if its not a server/admin, or
- * its one of our admins. */
- if(MyClient(source_p) && IsOper(source_p) &&
- (IsOperAdmin(source_p) ||
- (!IsServer(target_p) && !IsAdmin(target_p) &&
- !IsHandshake(target_p) && !IsConnecting(target_p))))
- {
- sendto_one(source_p, Lformat, me.name,
- RPL_STATSLINKINFO, source_p->name,
- (IsUpper(statchar)) ?
- get_client_name(target_p, SHOW_IP) :
- get_client_name(target_p, HIDE_IP),
- (int)linebuf_len(&target_p->localClient->buf_sendq),
- (int)target_p->localClient->sendM,
- (int)target_p->localClient->sendK,
- (int)target_p->localClient->receiveM,
- (int)target_p->localClient->receiveK,
- CurrentTime - target_p->firsttime,
- (CurrentTime > target_p->since) ? (CurrentTime - target_p->since):0,
- IsServer(target_p) ? show_capabilities(target_p) : "-");
- }
- else
- {
- /* If its a hidden ip, an admin, or a server, mask the real IP */
- if(IsIPSpoof(target_p) || IsServer(target_p) || IsAdmin(target_p)
- || IsHandshake(target_p) || IsConnecting(target_p))
- sendto_one(source_p, Lformat, me.name,
- RPL_STATSLINKINFO, source_p->name,
- get_client_name(target_p, MASK_IP),
- (int)linebuf_len(&target_p->localClient->buf_sendq),
- (int)target_p->localClient->sendM,
- (int)target_p->localClient->sendK,
- (int)target_p->localClient->receiveM,
- (int)target_p->localClient->receiveK,
- CurrentTime - target_p->firsttime,
- (CurrentTime > target_p->since) ? (CurrentTime - target_p->since):0,
- IsServer(target_p) ? show_capabilities(target_p) : "-");
- else /* show the real IP */
- sendto_one(source_p, Lformat, me.name,
- RPL_STATSLINKINFO, source_p->name,
- (IsUpper(statchar)) ?
- get_client_name(target_p, SHOW_IP) :
- get_client_name(target_p, HIDE_IP),
- (int)linebuf_len(&target_p->localClient->buf_sendq),
- (int)target_p->localClient->sendM,
- (int)target_p->localClient->sendK,
- (int)target_p->localClient->receiveM,
- (int)target_p->localClient->receiveK,
- CurrentTime - target_p->firsttime,
- (CurrentTime > target_p->since) ? (CurrentTime - target_p->since):0,
- IsServer(target_p) ? show_capabilities(target_p) : "-");
- }
+ sendto_one(source_p, Lformat, me.name,
+ RPL_STATSLINKINFO, source_p->name,
+ (IsUpper(statchar)) ?
+ get_client_name(target_p, SHOW_IP) :
+ get_client_name(target_p, HIDE_IP),
+ (int)linebuf_len(&target_p->localClient->buf_sendq),
+ (int)target_p->localClient->sendM,
+ (int)target_p->localClient->sendK,
+ (int)target_p->localClient->receiveM,
+ (int)target_p->localClient->receiveK,
+ CurrentTime - target_p->firsttime,
+ (CurrentTime >
+ target_p->since) ? (CurrentTime - target_p->since) : 0,
+ IsServer(target_p) ? show_capabilities(target_p) : "-");
+ }
+ else
+ {
+ /* If its a hidden ip, an admin, or a server, mask the real IP */
+ if (IsIPSpoof(target_p) || IsServer(target_p) || IsAdmin(target_p)
+ || IsHandshake(target_p) || IsConnecting(target_p))
+ sendto_one(source_p, Lformat, me.name,
+ RPL_STATSLINKINFO, source_p->name,
+ get_client_name(target_p, MASK_IP),
+ (int)linebuf_len(&target_p->localClient->buf_sendq),
+ (int)target_p->localClient->sendM,
+ (int)target_p->localClient->sendK,
+ (int)target_p->localClient->receiveM,
+ (int)target_p->localClient->receiveK,
+ CurrentTime - target_p->firsttime,
+ (CurrentTime >
+ target_p->since) ? (CurrentTime - target_p->since) : 0,
+ IsServer(target_p) ? show_capabilities(target_p) : "-");
+ else /* show the real IP */
+ sendto_one(source_p, Lformat, me.name,
+ RPL_STATSLINKINFO, source_p->name,
+ (IsUpper(statchar)) ?
+ get_client_name(target_p, SHOW_IP) :
+ get_client_name(target_p, HIDE_IP),
+ (int)linebuf_len(&target_p->localClient->buf_sendq),
+ (int)target_p->localClient->sendM,
+ (int)target_p->localClient->sendK,
+ (int)target_p->localClient->receiveM,
+ (int)target_p->localClient->receiveK,
+ CurrentTime - target_p->firsttime,
+ (CurrentTime >
+ target_p->since) ? (CurrentTime - target_p->since) : 0,
+ IsServer(target_p) ? show_capabilities(target_p) : "-");
}
+ }
}
/*
* any damage with stats requests now anyway. So, why show them?
* -Dianora
*/
-static void stats_spy(struct Client *source_p, char statchar)
+static void
+stats_spy(struct Client *source_p, char statchar)
{
struct hook_stats_data data;
* ouput -
* side effects - call hook doing_stats_p
*/
-static void stats_p_spy(struct Client *source_p)
+static void
+stats_p_spy(struct Client *source_p)
{
struct hook_stats_data data;
* side effects - a notice is sent to opers, IF spy mode is configured
* in the conf file.
*/
-static void stats_L_spy(struct Client *source_p, char statchar, char *name)
+static void
+stats_L_spy(struct Client *source_p, char statchar, char *name)
{
struct hook_stats_data data;
* common parse routine for m_stats args
*
*/
-static char *parse_stats_args(int parc,char *parv[],int *doall,int *wilds)
+static char *
+parse_stats_args(int parc, char *parv[], int *doall, int *wilds)
{
char *name;
- if(parc > 2)
- {
- name = parv[2];
- if (!irccmp(name, me.name))
- *doall = 2;
- else if (match(name, me.name))
- *doall = 1;
- if (strchr(name, '*') || strchr(name, '?'))
- *wilds = 1;
-
- return(name);
- }
+ if (parc > 2)
+ {
+ name = parv[2];
+ if (!irccmp(name, me.name))
+ *doall = 2;
+ else if (match(name, me.name))
+ *doall = 1;
+ if (strchr(name, '*') || strchr(name, '?'))
+ *wilds = 1;
+
+ return (name);
+ }
else
- return(NULL);
+ return (NULL);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_svinfo.c,v 1.1 2002/01/04 09:13:30 a1kmm Exp $
+ * $Id: m_svinfo.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
-#include "common.h" /* TRUE bleah */
+#include "common.h" /* TRUE bleah */
#include "irc_string.h"
#include "ircd.h"
#include "numeric.h"
#include <time.h>
#include <stdlib.h>
-static void ms_svinfo(struct Client*, struct Client*, int, char**);
+static void ms_svinfo(struct Client *, struct Client *, int, char **);
struct Message svinfo_msgtab = {
"SVINFO", 0, 0, 4, 0, MFLG_SLOW, 0,
mod_del_cmd(&svinfo_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* ms_svinfo - SVINFO message handler
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
-static void ms_svinfo(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_svinfo(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
time_t deltat;
time_t theirtime;
return;
if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
- {
- /*
- * a server with the wrong TS version connected; since we're
- * TS_ONLY we can't fall back to the non-TS protocol so
- * we drop the link -orabidoo
- */
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Link %s dropped, wrong TS protocol version (%s,%s)",
- get_client_name(source_p, SHOW_IP), parv[1], parv[2]);
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Link %s dropped, wrong TS protocol version (%s,%s)",
- get_client_name(source_p, MASK_IP), parv[1], parv[2]);
- exit_client(source_p, source_p, source_p, "Incompatible TS version");
- return;
- }
+ {
+ /*
+ * a server with the wrong TS version connected; since we're
+ * TS_ONLY we can't fall back to the non-TS protocol so
+ * we drop the link -orabidoo
+ */
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Link %s dropped, wrong TS protocol version (%s,%s)",
+ get_client_name(source_p, SHOW_IP), parv[1],
+ parv[2]);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Link %s dropped, wrong TS protocol version (%s,%s)",
+ get_client_name(source_p, MASK_IP), parv[1],
+ parv[2]);
+ exit_client(source_p, source_p, source_p, "Incompatible TS version");
+ return;
+ }
/*
* since we're here, might as well set CurrentTime while we're at it
deltat = abs(theirtime - CurrentTime);
if (deltat > ConfigFileEntry.ts_max_delta)
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
- get_client_name(source_p, SHOW_IP),
- (unsigned long) CurrentTime,
- (unsigned long) theirtime,
- (int) deltat);
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
- get_client_name(source_p, MASK_IP),
- (unsigned long) CurrentTime,
- (unsigned long) theirtime,
- (int) deltat);
- ilog(L_NOTICE,
- "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
- get_client_name(source_p, SHOW_IP),
- (unsigned long) CurrentTime,
- (unsigned long) theirtime,
- (int) deltat);
- exit_client(source_p, source_p, source_p, "Excessive TS delta");
- return;
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
+ get_client_name(source_p, SHOW_IP),
+ (unsigned long)CurrentTime,
+ (unsigned long)theirtime, (int)deltat);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
+ get_client_name(source_p, MASK_IP),
+ (unsigned long)CurrentTime,
+ (unsigned long)theirtime, (int)deltat);
+ ilog(L_NOTICE,
+ "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
+ get_client_name(source_p, SHOW_IP),
+ (unsigned long)CurrentTime, (unsigned long)theirtime, (int)deltat);
+ exit_client(source_p, source_p, source_p, "Excessive TS delta");
+ return;
+ }
if (deltat > ConfigFileEntry.ts_warn_delta)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Link %s notable TS delta (my TS=%lu, their TS=%lu, delta=%d)",
- source_p->name,
- (unsigned long) CurrentTime,
- (unsigned long) theirtime,
- (int) deltat);
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Link %s notable TS delta (my TS=%lu, their TS=%lu, delta=%d)",
+ source_p->name,
+ (unsigned long)CurrentTime,
+ (unsigned long)theirtime, (int)deltat);
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_testline.c,v 1.1 2002/01/04 09:13:30 a1kmm Exp $
+ * $Id: m_testline.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include <string.h>
-static void mo_testline(struct Client*, struct Client*, int, char**);
+static void mo_testline(struct Client *, struct Client *, int, char **);
struct Message testline_msgtab = {
"TESTLINE", 0, 0, 0, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_ignore, mo_testline}
};
-
+
#ifndef STATIC_MODULES
void
_modinit(void)
{
mod_del_cmd(&testline_msgtab);
}
-
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_testline
*
* i.e. /quote testline user@host,ip
*
- */
-
-static void mo_testline(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+ */
+
+static void
+mo_testline(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct ConfItem *aconf;
struct irc_inaddr ip;
int host_mask;
char *host, *pass, *user, *name, *classname, *given_host, *given_name, *p;
int port, t;
-
+
if (parc > 1)
+ {
+ given_name = parv[1];
+ if (!(p = (char *)strchr(given_name, '@')))
{
- given_name = parv[1];
- if (!(p = (char*)strchr(given_name,'@')))
+ if ((t = parse_netmask(given_name, &ip, &host_mask)) != HM_HOST)
{
- if ((t=parse_netmask(given_name, &ip, &host_mask))!= HM_HOST)
- {
aconf = find_dline(&ip,
#ifdef IPV6
- (t==HM_IPV6) ? AF_INET6 : AF_INET
+ (t == HM_IPV6) ? AF_INET6 : AF_INET
#else
- AF_INET
+ AF_INET
#endif
- );
+ );
if (aconf)
{
- get_printable_conf(aconf, &name, &host, &pass, &user, &port,&classname);
- if (aconf->status & CONF_EXEMPTDLINE)
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Exempt D-line host [%s] pass [%s]",
- me.name, parv[0], host, pass);
- } else {
- sendto_one(source_p,
- ":%s NOTICE %s :D-line host [%s] pass [%s]", me.name,
- parv[0], host, pass);
- }
- } else
- sendto_one(source_p, ":%s NOTICE %s :No D-line found",
- me.name, parv[0]);
- } else
- {
+ get_printable_conf(aconf, &name, &host, &pass, &user, &port,
+ &classname);
+ if (aconf->status & CONF_EXEMPTDLINE)
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Exempt D-line host [%s] pass [%s]",
+ me.name, parv[0], host, pass);
+ }
+ else
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :D-line host [%s] pass [%s]", me.name,
+ parv[0], host, pass);
+ }
+ }
+ else
+ sendto_one(source_p, ":%s NOTICE %s :No D-line found",
+ me.name, parv[0]);
+ }
+ else
+ {
sendto_one(source_p, ":%s NOTICE %s :usage: user@host|ip",
me.name, parv[0]);
- }
- return;
}
- *p = '\0';
- p++;
- given_host = p;
- if ((t=parse_netmask(given_host, &ip, &host_mask)) != HM_HOST)
- aconf = find_address_conf(given_host, given_name, &ip,
+ return;
+ }
+ *p = '\0';
+ p++;
+ given_host = p;
+ if ((t = parse_netmask(given_host, &ip, &host_mask)) != HM_HOST)
+ aconf = find_address_conf(given_host, given_name, &ip,
#ifdef IPV6
- (t==HM_IPV6)?AF_INET6 : AF_INET
+ (t == HM_IPV6) ? AF_INET6 : AF_INET
#else
- AF_INET
+ AF_INET
#endif
- );
- else
- aconf = find_address_conf(given_host, given_name, NULL, 0);
-
- if(aconf)
- {
- get_printable_conf(aconf, &name, &host, &pass, &user, &port, &classname);
-
- if(aconf->status & CONF_KILL)
- {
- sendto_one(source_p,
- ":%s NOTICE %s :%c-line name [%s] host [%s] pass [%s]",
- me.name, parv[0],
- (aconf->flags & CONF_FLAGS_TEMPORARY) ? 'k' : 'K',
- user, host, pass);
- }
- else if(aconf->status & CONF_CLIENT)
- {
- sendto_one(source_p,
-":%s NOTICE %s :I-line mask [%s] prefix [%s] name [%s] host [%s] port [%d] class [%s]",
- me.name, parv[0],
- name,
- show_iline_prefix(source_p,aconf,user),
- user,
- host,
- port,
- classname);
-
- }
- }
- else
- sendto_one(source_p, ":%s NOTICE %s :No aconf found",
- me.name, parv[0]);
+ );
+ else
+ aconf = find_address_conf(given_host, given_name, NULL, 0);
+
+ if (aconf)
+ {
+ get_printable_conf(aconf, &name, &host, &pass, &user, &port,
+ &classname);
+
+ if (aconf->status & CONF_KILL)
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :%c-line name [%s] host [%s] pass [%s]",
+ me.name, parv[0],
+ (aconf->flags & CONF_FLAGS_TEMPORARY) ? 'k' : 'K',
+ user, host, pass);
+ }
+ else if (aconf->status & CONF_CLIENT)
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :I-line mask [%s] prefix [%s] name [%s] host [%s] port [%d] class [%s]",
+ me.name, parv[0],
+ name,
+ show_iline_prefix(source_p, aconf, user),
+ user, host, port, classname);
+
+ }
}
+ else
+ sendto_one(source_p, ":%s NOTICE %s :No aconf found", me.name, parv[0]);
+ }
else
sendto_one(source_p, ":%s NOTICE %s :usage: user@host|ip",
me.name, parv[0]);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_time.c,v 1.1 2002/01/04 09:13:30 a1kmm Exp $
+ * $Id: m_time.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "parse.h"
#include "modules.h"
-static void m_time(struct Client*, struct Client*, int, char**);
-static void mo_time(struct Client*, struct Client*, int, char**);
+static void m_time(struct Client *, struct Client *, int, char **);
+static void mo_time(struct Client *, struct Client *, int, char **);
struct Message time_msgtab = {
"TIME", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&time_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_time
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void m_time(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_time(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
/* This is safe enough to use during non hidden server mode */
- if(!ConfigServerHide.disable_remote)
- {
- if (hunt_server(client_p,source_p,":%s TIME :%s",1,parc,parv) != HUNTED_ISME)
- return;
- }
+ if (!ConfigServerHide.disable_remote)
+ {
+ if (hunt_server(client_p, source_p, ":%s TIME :%s", 1, parc, parv) !=
+ HUNTED_ISME)
+ return;
+ }
sendto_one(source_p, form_str(RPL_TIME), me.name,
parv[0], me.name, date(0));
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void mo_time(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_time(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if (hunt_server(client_p,source_p,":%s TIME :%s",1,parc,parv) == HUNTED_ISME)
- sendto_one(source_p, form_str(RPL_TIME), me.name,
- parv[0], me.name, date(0));
+ if (hunt_server(client_p, source_p, ":%s TIME :%s", 1, parc, parv) ==
+ HUNTED_ISME)
+ sendto_one(source_p, form_str(RPL_TIME), me.name, parv[0], me.name,
+ date(0));
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_topic.c,v 1.1 2002/01/04 09:13:33 a1kmm Exp $
+ * $Id: m_topic.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include <string.h>
#include <stdlib.h>
-static void m_topic(struct Client*, struct Client*, int, char**);
-static void ms_topic(struct Client*, struct Client*, int, char**);
+static void m_topic(struct Client *, struct Client *, int, char **);
+static void ms_topic(struct Client *, struct Client *, int, char **);
struct Message topic_msgtab = {
"TOPIC", 0, 0, 2, 0, MFLG_SLOW, 0,
mod_del_cmd(&topic_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_topic
* parv[1] = channel name
* parv[2] = new topic, if setting topic
*/
-static void m_topic(struct Client *client_p,
- struct Client *source_p,
- int parc, char *parv[])
+static void
+m_topic(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Channel *chptr = NULL;
struct Channel *root_chan, *vchan;
- char *p = NULL;
-
- if ((p = strchr(parv[1],',')))
+ char *p = NULL;
+
+ if ((p = strchr(parv[1], ',')))
*p = '\0';
if (parv[1] && IsChannelName(parv[1]))
+ {
+ chptr = hash_find_channel(parv[1]);
+
+ if (chptr == NULL)
+ {
+ /* if chptr isn't found locally, it =could= exist
+ * on the uplink. so forward reqeuest
+ */
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
+ {
+ sendto_one(uplink, ":%s TOPIC %s %s",
+ source_p->name, parv[1], ((parc > 2) ? parv[2] : ""));
+ return;
+ }
+ else
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, parv[0], parv[1]);
+ return;
+ }
+ }
+
+ root_chan = chptr;
+
+ if (HasVchans(chptr))
+ {
+ vchan = map_vchan(chptr, source_p);
+ if (vchan != NULL)
+ chptr = vchan;
+ }
+ else if (IsVchan(chptr))
+ root_chan = RootChan(chptr);
+
+ /* setting topic */
+ if (parc > 2)
{
- chptr = hash_find_channel(parv[1]);
- if(chptr == NULL)
+ if (!IsMember(source_p, chptr))
+ {
+ sendto_one(source_p, form_str(ERR_NOTONCHANNEL), me.name, parv[0],
+ parv[1]);
+ return;
+ }
+ if ((chptr->mode.mode & MODE_TOPICLIMIT) == 0 ||
+ is_any_op(chptr, source_p))
{
- /* if chptr isn't found locally, it =could= exist
- * on the uplink. so forward reqeuest
+ /* setting a topic */
+ /*
+ * chptr zeroed
*/
- if(!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
+ strncpy_irc(chptr->topic, parv[2], TOPICLEN);
+
+
+ ircsprintf(chptr->topic_info, "%s!%s@%s",
+ source_p->name, source_p->username, source_p->host);
+
+ chptr->topic_time = CurrentTime;
+
+ sendto_server(client_p, NULL, chptr, NOCAPS, NOCAPS, NOFLAGS,
+ ":%s TOPIC %s :%s",
+ parv[0], chptr->chname, chptr->topic);
+ if (chptr->mode.mode & MODE_HIDEOPS)
{
- sendto_one(uplink, ":%s TOPIC %s %s",
- source_p->name, parv[1],
- ((parc > 2) ? parv[2] : ""));
- return;
+ sendto_channel_local(ONLY_CHANOPS_HALFOPS,
+ chptr, ":%s!%s@%s TOPIC %s :%s",
+ source_p->name,
+ source_p->username,
+ source_p->host,
+ root_chan->chname, chptr->topic);
+
+ sendto_channel_local(NON_CHANOPS,
+ chptr, ":%s TOPIC %s :%s",
+ me.name, root_chan->chname, chptr->topic);
}
else
{
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, parv[0], parv[1]);
- return;
+ sendto_channel_local(ALL_MEMBERS,
+ chptr, ":%s!%s@%s TOPIC %s :%s",
+ source_p->name,
+ source_p->username,
+ source_p->host,
+ root_chan->chname, chptr->topic);
}
}
+ else
+ sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
+ me.name, parv[0], parv[1]);
+ }
+ else /* only asking for topic */
+ {
+ if (!IsMember(source_p, chptr) && SecretChannel(chptr))
+ {
+ sendto_one(source_p, form_str(ERR_NOTONCHANNEL), me.name, parv[0],
+ parv[1]);
+ return;
+ }
+ if (chptr->topic[0] == '\0')
+ sendto_one(source_p, form_str(RPL_NOTOPIC),
+ me.name, parv[0], parv[1]);
+ else
+ {
+ sendto_one(source_p, form_str(RPL_TOPIC),
+ me.name, parv[0], root_chan->chname, chptr->topic);
- root_chan = chptr;
-
- if (HasVchans(chptr))
- {
- vchan = map_vchan(chptr,source_p);
- if(vchan != NULL)
- chptr = vchan;
- }
- else if (IsVchan(chptr))
- root_chan = RootChan(chptr);
-
- /* setting topic */
- if (parc > 2)
- {
-
- if (!IsMember(source_p, chptr))
- {
- sendto_one(source_p, form_str(ERR_NOTONCHANNEL), me.name, parv[0],
- parv[1]);
- return;
- }
- if ((chptr->mode.mode & MODE_TOPICLIMIT) == 0 ||
- is_any_op(chptr,source_p))
- {
- /* setting a topic */
- /*
- * chptr zeroed
- */
- strncpy_irc(chptr->topic, parv[2], TOPICLEN);
-
-
- ircsprintf(chptr->topic_info, "%s!%s@%s",
- source_p->name, source_p->username, source_p->host);
-
- chptr->topic_time = CurrentTime;
-
- sendto_server(client_p, NULL, chptr, NOCAPS, NOCAPS, NOFLAGS,
- ":%s TOPIC %s :%s",
- parv[0], chptr->chname,
- chptr->topic);
- if(chptr->mode.mode & MODE_HIDEOPS)
- {
- sendto_channel_local(ONLY_CHANOPS_HALFOPS,
- chptr, ":%s!%s@%s TOPIC %s :%s",
- source_p->name,
- source_p->username,
- source_p->host,
- root_chan->chname,
- chptr->topic);
-
- sendto_channel_local(NON_CHANOPS,
- chptr, ":%s TOPIC %s :%s",
- me.name,
- root_chan->chname,
- chptr->topic);
- }
- else
- {
- sendto_channel_local(ALL_MEMBERS,
- chptr, ":%s!%s@%s TOPIC %s :%s",
- source_p->name,
- source_p->username,
- source_p->host,
- root_chan->chname, chptr->topic);
- }
- }
- else
- sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
- me.name, parv[0], parv[1]);
- }
- else /* only asking for topic */
- {
- if (!IsMember(source_p, chptr) && SecretChannel(chptr))
- {
- sendto_one(source_p, form_str(ERR_NOTONCHANNEL), me.name, parv[0],
- parv[1]);
- return;
- }
- if (chptr->topic[0] == '\0')
- sendto_one(source_p, form_str(RPL_NOTOPIC),
- me.name, parv[0], parv[1]);
- else
- {
- sendto_one(source_p, form_str(RPL_TOPIC),
- me.name, parv[0],
- root_chan->chname, chptr->topic);
-
- if(!(chptr->mode.mode & MODE_HIDEOPS) ||
- is_any_op(chptr,source_p))
- {
- sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
- me.name, parv[0], root_chan->chname,
- chptr->topic_info,
- chptr->topic_time);
- }
- /* client on LL needing the topic - if we have serverhide, say
- * its the actual LL server that set the topic, not us the
- * uplink -- fl_
- */
- else if(ConfigServerHide.hide_servers && !MyClient(source_p)
- && IsCapable(client_p, CAP_LL) && ServerInfo.hub)
- {
- sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
- me.name, parv[0], root_chan->chname,
- client_p->name, chptr->topic_time);
- }
- /* just normal topic hiding.. */
- else
- {
- sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
- me.name, parv[0], root_chan->chname,
- me.name,
- chptr->topic_time);
- }
- }
+ if (!(chptr->mode.mode & MODE_HIDEOPS) || is_any_op(chptr, source_p))
+ {
+ sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
+ me.name, parv[0], root_chan->chname,
+ chptr->topic_info, chptr->topic_time);
}
+ /* client on LL needing the topic - if we have serverhide, say
+ * its the actual LL server that set the topic, not us the
+ * uplink -- fl_
+ */
+ else if (ConfigServerHide.hide_servers && !MyClient(source_p)
+ && IsCapable(client_p, CAP_LL) && ServerInfo.hub)
+ {
+ sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
+ me.name, parv[0], root_chan->chname,
+ client_p->name, chptr->topic_time);
+ }
+ /* just normal topic hiding.. */
+ else
+ {
+ sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
+ me.name, parv[0], root_chan->chname,
+ me.name, chptr->topic_time);
+ }
+ }
}
+ }
else
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, parv[0], parv[1]);
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, parv[0], parv[1]);
+ }
}
/*
*
* Let servers always set a topic
*/
-static void ms_topic(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_topic(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Channel *chptr = NULL;
-
+
if (!IsServer(source_p))
{
m_topic(client_p, source_p, parc, parv);
return;
}
- if( parc < 5 )
+ if (parc < 5)
return;
if (parv[1] && IsChannelName(parv[1]))
- {
- if ((chptr = hash_find_channel(parv[1])) == NULL)
- return;
+ {
+ if ((chptr = hash_find_channel(parv[1])) == NULL)
+ return;
+
+ strncpy_irc(chptr->topic, parv[4], TOPICLEN);
- strncpy_irc(chptr->topic, parv[4], TOPICLEN);
-
- strncpy_irc(chptr->topic_info, parv[2], USERHOST_REPLYLEN);
+ strncpy_irc(chptr->topic_info, parv[2], USERHOST_REPLYLEN);
- chptr->topic_time = atoi(parv[3]);
+ chptr->topic_time = atoi(parv[3]);
- if(chptr->mode.mode & MODE_HIDEOPS)
- {
- sendto_channel_local(ONLY_CHANOPS_HALFOPS,
- chptr, ":%s!%s@%s TOPIC %s :%s",
- me.name,
- source_p->username,
- source_p->host,
- parv[1],
- chptr->topic);
+ if (chptr->mode.mode & MODE_HIDEOPS)
+ {
+ sendto_channel_local(ONLY_CHANOPS_HALFOPS,
+ chptr, ":%s!%s@%s TOPIC %s :%s",
+ me.name,
+ source_p->username,
+ source_p->host, parv[1], chptr->topic);
- sendto_channel_local(NON_CHANOPS,
- chptr, ":%s TOPIC %s :%s",
- me.name,
- parv[1],
- chptr->topic);
+ sendto_channel_local(NON_CHANOPS,
+ chptr, ":%s TOPIC %s :%s",
+ me.name, parv[1], chptr->topic);
- }
- else
- {
- sendto_channel_local(ALL_MEMBERS,
- chptr, ":%s!%s@%s TOPIC %s :%s",
- me.name,
- source_p->username,
- source_p->host,
- parv[1], chptr->topic);
- }
}
+ else
+ {
+ sendto_channel_local(ALL_MEMBERS,
+ chptr, ":%s!%s@%s TOPIC %s :%s",
+ me.name,
+ source_p->username,
+ source_p->host, parv[1], chptr->topic);
+ }
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_trace.c,v 1.1 2002/01/04 09:13:33 a1kmm Exp $
+ * $Id: m_trace.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
#include "class.h"
#include <time.h>
static void m_trace(struct Client *, struct Client *, int, char **);
-static void ms_trace(struct Client*, struct Client*, int, char**);
-static void mo_trace(struct Client*, struct Client*, int, char**);
+static void ms_trace(struct Client *, struct Client *, int, char **);
+static void mo_trace(struct Client *, struct Client *, int, char **);
static void trace_spy(struct Client *);
hook_del_event("doing_trace");
mod_del_cmd(&trace_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
-static int report_this_status(struct Client *source_p, struct Client *target_p,int dow,
- int link_u_p, int link_u_s);
+static int report_this_status(struct Client *source_p,
+ struct Client *target_p, int dow, int link_u_p,
+ int link_u_s);
/*
* parv[0] = sender prefix
* parv[1] = target client/server to trace
*/
-static void m_trace(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_trace(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
char *tname;
** parv[0] = sender prefix
** parv[1] = servername
*/
-static void mo_trace(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_trace(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- struct Client *target_p = NULL;
- struct Class *cltmp;
- char *tname;
- int doall, link_s[MAXCONNECTIONS], link_u[MAXCONNECTIONS];
- int cnt = 0, wilds, dow;
+ struct Client *target_p = NULL;
+ struct Class *cltmp;
+ char *tname;
+ int doall, link_s[MAXCONNECTIONS], link_u[MAXCONNECTIONS];
+ int cnt = 0, wilds, dow;
static time_t now;
dlink_node *ptr;
char *looking_for = parv[0];
- if(!IsClient(source_p))
+ if (!IsClient(source_p))
return;
-
+
if (parc > 2)
if (hunt_server(client_p, source_p, ":%s TRACE %s :%s", 2, parc, parv))
return;
-
+
if (parc > 1)
tname = parv[1];
else
tname = me.name;
switch (hunt_server(client_p, source_p, ":%s TRACE :%s", 1, parc, parv))
+ {
+ case HUNTED_PASS: /* note: gets here only if parv[1] exists */
{
- case HUNTED_PASS: /* note: gets here only if parv[1] exists */
- {
- struct Client *ac2ptr;
-
- ac2ptr = next_client_double(GlobalClientList, tname);
- if (ac2ptr)
- sendto_one(source_p, form_str(RPL_TRACELINK), me.name, looking_for,
- ircd_version, debugmode, tname, ac2ptr->from->name);
- else
- sendto_one(source_p, form_str(RPL_TRACELINK), me.name, looking_for,
- ircd_version, debugmode, tname, "ac2ptr_is_NULL!!");
- return;
- }
+ struct Client *ac2ptr;
+
+ ac2ptr = next_client_double(GlobalClientList, tname);
+ if (ac2ptr)
+ sendto_one(source_p, form_str(RPL_TRACELINK), me.name, looking_for,
+ ircd_version, debugmode, tname, ac2ptr->from->name);
+ else
+ sendto_one(source_p, form_str(RPL_TRACELINK), me.name, looking_for,
+ ircd_version, debugmode, tname, "ac2ptr_is_NULL!!");
+ return;
+ }
case HUNTED_ISME:
break;
default:
return;
- }
+ }
trace_spy(source_p);
- doall = (parv[1] && (parc > 1)) ? match(tname, me.name): TRUE;
+ doall = (parv[1] && (parc > 1)) ? match(tname, me.name) : TRUE;
wilds = !parv[1] || strchr(tname, '*') || strchr(tname, '?');
dow = wilds || doall;
-
+
now = time(NULL);
- if(!IsOper(source_p) || !dow) /* non-oper traces must be full nicks */
- /* lets also do this for opers tracing nicks */
- {
- const char* name;
- const char* class_name;
- char ipaddr[HOSTIPLEN];
+ if (!IsOper(source_p) || !dow) /* non-oper traces must be full nicks */
+ /* lets also do this for opers tracing nicks */
+ {
+ const char *name;
+ const char *class_name;
+ char ipaddr[HOSTIPLEN];
- target_p = find_client(tname);
-
- if(target_p && IsPerson(target_p))
- {
- name = get_client_name(target_p, HIDE_IP);
- inetntop(target_p->localClient->aftype, &IN_ADDR(target_p->localClient->ip), ipaddr, HOSTIPLEN);
+ target_p = find_client(tname);
- class_name = get_client_class(target_p);
+ if (target_p && IsPerson(target_p))
+ {
+ name = get_client_name(target_p, HIDE_IP);
+ inetntop(target_p->localClient->aftype,
+ &IN_ADDR(target_p->localClient->ip), ipaddr, HOSTIPLEN);
- if (IsOper(target_p))
- {
- sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
- me.name, parv[0], class_name, name,
- MyOper(source_p) ? ipaddr :
- (IsIPSpoof(target_p) ? "255.255.255.255" : ipaddr),
- now - target_p->lasttime,
- (target_p->user) ? (now - target_p->user->last) : 0);
- }
- else
- {
- sendto_one(source_p,form_str(RPL_TRACEUSER),
- me.name, parv[0], class_name, name,
- MyOper(source_p) ? ipaddr :
- (IsIPSpoof(target_p) ? "255.255.255.255" : ipaddr),
- now - target_p->lasttime,
- (target_p->user)?(now - target_p->user->last):0);
- }
+ class_name = get_client_class(target_p);
+
+ if (IsOper(target_p))
+ {
+ sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
+ me.name, parv[0], class_name, name,
+ MyOper(source_p) ? ipaddr :
+ (IsIPSpoof(target_p) ? "255.255.255.255" : ipaddr),
+ now - target_p->lasttime,
+ (target_p->user) ? (now - target_p->user->last) : 0);
+ }
+ else
+ {
+ sendto_one(source_p, form_str(RPL_TRACEUSER),
+ me.name, parv[0], class_name, name,
+ MyOper(source_p) ? ipaddr :
+ (IsIPSpoof(target_p) ? "255.255.255.255" : ipaddr),
+ now - target_p->lasttime,
+ (target_p->user) ? (now - target_p->user->last) : 0);
}
-
- sendto_one(source_p, form_str(RPL_ENDOFTRACE),me.name,
- parv[0], tname);
- return;
}
- memset((void *)link_s,0,sizeof(link_s));
- memset((void *)link_u,0,sizeof(link_u));
+ sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name, parv[0], tname);
+ return;
+ }
+
+ memset((void *)link_s, 0, sizeof(link_s));
+ memset((void *)link_u, 0, sizeof(link_u));
/*
* Count up all the servers and clients in a downlink.
*/
if (doall)
- {
+ {
for (target_p = GlobalClientList; target_p; target_p = target_p->next)
- {
+ {
if (IsPerson(target_p))
- {
- link_u[target_p->from->fd]++;
- }
+ {
+ link_u[target_p->from->fd]++;
+ }
else if (IsServer(target_p))
- {
- link_s[target_p->from->fd]++;
- }
- }
- }
-
+ {
+ link_s[target_p->from->fd]++;
+ }
+ }
+ }
+
/* report all direct connections */
for (ptr = lclient_list.head; ptr; ptr = ptr->next)
- {
- target_p = ptr->data;
-
- if (IsInvisible(target_p) && dow &&
- !(MyConnect(source_p) && IsOper(source_p)) &&
- !IsOper(target_p) && (target_p != source_p))
- continue;
- if (!doall && wilds && !match(tname, target_p->name))
- continue;
- if (!dow && irccmp(tname, target_p->name))
- continue;
-
- cnt = report_this_status(source_p,target_p,dow,0,0);
- }
+ {
+ target_p = ptr->data;
+
+ if (IsInvisible(target_p) && dow &&
+ !(MyConnect(source_p) && IsOper(source_p)) &&
+ !IsOper(target_p) && (target_p != source_p))
+ continue;
+ if (!doall && wilds && !match(tname, target_p->name))
+ continue;
+ if (!dow && irccmp(tname, target_p->name))
+ continue;
+
+ cnt = report_this_status(source_p, target_p, dow, 0, 0);
+ }
for (ptr = serv_list.head; ptr; ptr = ptr->next)
- {
- target_p = ptr->data;
+ {
+ target_p = ptr->data;
- if (!doall && wilds && !match(tname, target_p->name))
- continue;
- if (!dow && irccmp(tname, target_p->name))
- continue;
+ if (!doall && wilds && !match(tname, target_p->name))
+ continue;
+ if (!dow && irccmp(tname, target_p->name))
+ continue;
- cnt = report_this_status(source_p, target_p, dow,
- link_u[target_p->fd],
- link_s[target_p->fd]);
- }
+ cnt = report_this_status(source_p, target_p, dow,
+ link_u[target_p->fd], link_s[target_p->fd]);
+ }
/* This section is to report the unknowns */
for (ptr = unknown_list.head; ptr; ptr = ptr->next)
- {
- target_p = ptr->data;
+ {
+ target_p = ptr->data;
- if (!doall && wilds && !match(tname, target_p->name))
- continue;
- if (!dow && irccmp(tname, target_p->name))
- continue;
+ if (!doall && wilds && !match(tname, target_p->name))
+ continue;
+ if (!dow && irccmp(tname, target_p->name))
+ continue;
- cnt = report_this_status(source_p,target_p,dow,0,0);
- }
+ cnt = report_this_status(source_p, target_p, dow, 0, 0);
+ }
/*
* Add these lines to summarize the above which can get rather long
* and messy when done remotely - Avalon
*/
if (!SendWallops(source_p) || !cnt)
- {
- /* redundant given we dont allow trace from non-opers anyway.. but its
- * left here in case that should ever change --fl
- */
- if(!cnt)
- sendto_one(source_p, form_str(RPL_TRACESERVER),
- me.name, parv[0], 0, link_s[me.fd],
- link_u[me.fd], me.name, "*", "*", me.name);
-
- /* let the user have some idea that its at the end of the
- * trace
- */
- sendto_one(source_p, form_str(RPL_ENDOFTRACE),me.name,
- parv[0],tname);
- return;
- }
-
+ {
+ /* redundant given we dont allow trace from non-opers anyway.. but its
+ * left here in case that should ever change --fl
+ */
+ if (!cnt)
+ sendto_one(source_p, form_str(RPL_TRACESERVER),
+ me.name, parv[0], 0, link_s[me.fd],
+ link_u[me.fd], me.name, "*", "*", me.name);
+
+ /* let the user have some idea that its at the end of the
+ * trace
+ */
+ sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name, parv[0], tname);
+ return;
+ }
+
for (cltmp = ClassList; doall && cltmp; cltmp = cltmp->next)
if (Links(cltmp) > 0)
sendto_one(source_p, form_str(RPL_TRACECLASS), me.name,
parv[0], ClassName(cltmp), Links(cltmp));
-
- sendto_one(source_p, form_str(RPL_ENDOFTRACE),me.name, parv[0],tname);
+
+ sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name, parv[0], tname);
}
** parv[0] = sender prefix
** parv[1] = servername
*/
-static void ms_trace(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+ms_trace(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
if (hunt_server(client_p, source_p, ":%s TRACE %s :%s", 2, parc, parv))
return;
- if( IsOper(source_p) )
- mo_trace(client_p,source_p,parc,parv);
+ if (IsOper(source_p))
+ mo_trace(client_p, source_p, parc, parv);
return;
}
* output - counter of number of hits
* side effects - NONE
*/
-static int report_this_status(struct Client *source_p, struct Client *target_p,
- int dow, int link_u_p, int link_s_p)
+static int
+report_this_status(struct Client *source_p, struct Client *target_p,
+ int dow, int link_u_p, int link_s_p)
{
- const char* name;
- const char* class_name;
- char ip[HOSTIPLEN];
- int cnt=0;
+ const char *name;
+ const char *class_name;
+ char ip[HOSTIPLEN];
+ int cnt = 0;
static time_t now;
- inetntop(target_p->localClient->aftype, &IN_ADDR(target_p->localClient->ip), ip, HOSTIPLEN);
+ inetntop(target_p->localClient->aftype, &IN_ADDR(target_p->localClient->ip),
+ ip, HOSTIPLEN);
name = get_client_name(target_p, HIDE_IP);
class_name = get_client_class(target_p);
- now = time(NULL);
+ now = time(NULL);
- switch(target_p->status)
- {
+ switch (target_p->status)
+ {
case STAT_CONNECTING:
sendto_one(source_p, form_str(RPL_TRACECONNECTING), me.name,
- source_p->name, class_name,
- IsOperAdmin(source_p) ? name : target_p->name);
-
+ source_p->name, class_name,
+ IsOperAdmin(source_p) ? name : target_p->name);
+
cnt++;
break;
case STAT_HANDSHAKE:
sendto_one(source_p, form_str(RPL_TRACEHANDSHAKE), me.name,
- source_p->name, class_name,
+ source_p->name, class_name,
IsOperAdmin(source_p) ? name : target_p->name);
-
+
cnt++;
break;
case STAT_ME:
case STAT_UNKNOWN:
/* added time -Taner */
sendto_one(source_p, form_str(RPL_TRACEUNKNOWN),
- me.name, source_p->name, class_name, name, ip,
- target_p->firsttime ? CurrentTime - target_p->firsttime : -1);
+ me.name, source_p->name, class_name, name, ip,
+ target_p->firsttime ? CurrentTime -
+ target_p->firsttime : -1);
cnt++;
break;
case STAT_CLIENT:
* but anyone can see all the opers.
*/
if ((IsOper(source_p) &&
- (MyClient(source_p) || !(dow && IsInvisible(target_p))))
- || !dow || IsOper(target_p))
- {
- if (IsAdmin(target_p))
- sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
- me.name, source_p->name, class_name, name,
- IsOperAdmin(source_p) ? ip : "255.255.255.255",
- now - target_p->lasttime,
- (target_p->user) ? (now - target_p->user->last) : 0);
-
- else if (IsOper(target_p))
- sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
- me.name, source_p->name, class_name, name,
- MyOper(source_p) ? ip :
- (IsIPSpoof(target_p) ? "255.255.255.255" : ip),
- now - target_p->lasttime,
- (target_p->user)?(now - target_p->user->last):0);
-
- else
- sendto_one(source_p, form_str(RPL_TRACEUSER),
- me.name, source_p->name, class_name, name,
- MyOper(source_p) ? ip :
- (IsIPSpoof(target_p) ? "255.255.255.255" : ip),
- now - target_p->lasttime,
- (target_p->user)?(now - target_p->user->last):0);
- cnt++;
- }
+ (MyClient(source_p) || !(dow && IsInvisible(target_p))))
+ || !dow || IsOper(target_p))
+ {
+ if (IsAdmin(target_p))
+ sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
+ me.name, source_p->name, class_name, name,
+ IsOperAdmin(source_p) ? ip : "255.255.255.255",
+ now - target_p->lasttime,
+ (target_p->user) ? (now - target_p->user->last) : 0);
+
+ else if (IsOper(target_p))
+ sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
+ me.name, source_p->name, class_name, name,
+ MyOper(source_p) ? ip :
+ (IsIPSpoof(target_p) ? "255.255.255.255" : ip),
+ now - target_p->lasttime,
+ (target_p->user) ? (now - target_p->user->last) : 0);
+
+ else
+ sendto_one(source_p, form_str(RPL_TRACEUSER),
+ me.name, source_p->name, class_name, name,
+ MyOper(source_p) ? ip :
+ (IsIPSpoof(target_p) ? "255.255.255.255" : ip),
+ now - target_p->lasttime,
+ (target_p->user) ? (now - target_p->user->last) : 0);
+ cnt++;
+ }
break;
case STAT_SERVER:
- if(!IsOperAdmin(source_p))
+ if (!IsOperAdmin(source_p))
name = get_client_name(target_p, MASK_IP);
sendto_one(source_p, form_str(RPL_TRACESERVER),
- me.name, source_p->name, class_name, link_s_p,
- link_u_p, name, *(target_p->serv->by) ?
- target_p->serv->by : "*", "*",
- me.name, now - target_p->lasttime);
+ me.name, source_p->name, class_name, link_s_p,
+ link_u_p, name, *(target_p->serv->by) ?
+ target_p->serv->by : "*", "*",
+ me.name, now - target_p->lasttime);
cnt++;
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), me.name,
- source_p->name, name);
+ source_p->name, name);
cnt++;
break;
- }
+ }
- return(cnt);
+ return (cnt);
}
/* trace_spy()
* output - none
* side effects - hook event doing_trace is called
*/
-static void trace_spy(struct Client *source_p)
+static void
+trace_spy(struct Client *source_p)
{
struct hook_spy_data data;
hook_call_event("doing_trace", &data);
}
-
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
- * $Id: m_unkline.c,v 1.1 2002/01/04 09:13:33 a1kmm Exp $
+ * $Id: m_unkline.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
#include <string.h>
#include <unistd.h>
-static void mo_unkline(struct Client*, struct Client*, int, char**);
-static void mo_undline(struct Client*, struct Client*, int, char**);
-static void mo_ungline(struct Client*, struct Client*, int, char**);
+static void mo_unkline(struct Client *, struct Client *, int, char **);
+static void mo_undline(struct Client *, struct Client *, int, char **);
+static void mo_ungline(struct Client *, struct Client *, int, char **);
struct Message msgtabs[] = {
{"UNKLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_error, mo_unkline}},
{"UNDLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
- {m_unregistered, m_not_oper, m_error, mo_undline}},
+ {m_unregistered, m_not_oper, m_error, mo_undline}},
{"UNGLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_error, mo_ungline}}
};
mod_del_cmd(&msgtabs[1]);
mod_del_cmd(&msgtabs[2]);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
-static int flush_write(struct Client *, FBFILE* , char *, char *);
-static int remove_tkline_match(char *,char *);
+static int flush_write(struct Client *, FBFILE *, char *, char *);
+static int remove_tkline_match(char *, char *);
/*
*
*
*/
-static void mo_unkline (struct Client *client_p,struct Client *source_p,
- int parc,char *parv[])
+static void
+mo_unkline(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
FBFILE *in, *out;
- int pairme=0,error_on_write = NO;
+ int pairme = 0, error_on_write = NO;
char buf[BUFSIZE], buff[BUFSIZE], temppath[BUFSIZE], *user, *host, *p;
- const char *filename; /* filename to use for unkline */
+ const char *filename; /* filename to use for unkline */
mode_t oldumask;
ircsprintf(temppath, "%s.tmp", ConfigFileEntry.klinefile);
-
+
if (!IsOperUnkline(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You need unkline = yes;",me.name,parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need unkline = yes;", me.name,
+ parv[0]);
+ return;
+ }
if (parc < 2)
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, source_p->name, "UNKLINE");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, source_p->name, "UNKLINE");
+ return;
+ }
if ((host = strchr(parv[1], '@')) || *parv[1] == '*')
+ {
+ /* Explicit user@host mask given */
+
+ if (host) /* Found user@host */
{
- /* Explicit user@host mask given */
-
- if(host) /* Found user@host */
- {
- user = parv[1]; /* here is user part */
- *(host++) = '\0'; /* and now here is host */
- }
- else
- {
- user = "*"; /* no @ found, assume its *@somehost */
- host = parv[1];
- }
+ user = parv[1]; /* here is user part */
+ *(host++) = '\0'; /* and now here is host */
}
- else
+ else
{
- sendto_one(source_p, ":%s NOTICE %s :Invalid parameters",
- me.name, source_p->name);
- return;
+ user = "*"; /* no @ found, assume its *@somehost */
+ host = parv[1];
}
+ }
+ else
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Invalid parameters",
+ me.name, source_p->name);
+ return;
+ }
if (remove_tkline_match(host, user))
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Un-klined [%s@%s] from temporary k-lines",
- me.name, parv[0],user, host);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s has removed the temporary K-Line for: [%s@%s]",
- get_oper_name(source_p), user, host);
- ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]", parv[0], user,
- host);
- return;
- }
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Un-klined [%s@%s] from temporary k-lines",
+ me.name, parv[0], user, host);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s has removed the temporary K-Line for: [%s@%s]",
+ get_oper_name(source_p), user, host);
+ ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]", parv[0], user,
+ host);
+ return;
+ }
filename = get_conf_name(KLINE_TYPE);
if ((in = fbopen(filename, "r")) == 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, parv[0],
- filename);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, parv[0],
+ filename);
+ return;
+ }
oldumask = umask(0);
if ((out = fbopen(temppath, "w")) == 0)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, parv[0],
+ temppath);
+ fbclose(in);
+ umask(oldumask);
+ return;
+ }
+ umask(oldumask);
+
+ while (fbgets(buf, sizeof(buf), in))
+ {
+ char *found_host, *found_user;
+
+ strncpy_irc(buff, buf, BUFSIZE - 1)[BUFSIZE - 1] = 0;
+
+ if ((p = strchr(buff, '\n')) != NULL)
+ *p = '\0';
+
+ if ((*buff == '\0') || (*buff == '#'))
{
- sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, parv[0],
- temppath);
- fbclose(in);
- umask(oldumask);
- return;
+ if (!error_on_write)
+ flush_write(source_p, out, buf, temppath);
+ continue;
+ }
+
+ if ((found_user = getfield(buff)) == NULL)
+ {
+ if (!error_on_write)
+ flush_write(source_p, out, buf, temppath);
+ continue;
+ }
+
+ if ((found_host = getfield(NULL)) == NULL)
+ {
+ if (!error_on_write)
+ flush_write(source_p, out, buf, temppath);
+ continue;
}
- umask(oldumask);
- while (fbgets(buf, sizeof(buf), in))
+ if ((irccmp(host, found_host) == 0) && (irccmp(user, found_user) == 0))
{
- char *found_host, *found_user;
-
- strncpy_irc(buff, buf, BUFSIZE-1)[BUFSIZE-1] = 0;
-
- if ((p = strchr(buff,'\n')) != NULL)
- *p = '\0';
-
- if ((*buff == '\0') || (*buff == '#'))
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
-
- if ((found_user = getfield(buff)) == NULL)
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
-
- if ((found_host = getfield(NULL)) == NULL)
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
-
- if ((irccmp(host,found_host) == 0) && (irccmp(user,found_user) == 0))
- {
- pairme++;
- }
- else
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- }
+ pairme++;
}
+ else
+ {
+ if (!error_on_write)
+ flush_write(source_p, out, buf, temppath);
+ }
+ }
fbclose(in);
fbclose(out);
/* If there was an error on a write above, then its been reported
* and I am not going to trash the original kline /conf file
*/
- if(!error_on_write)
- {
- (void)rename(temppath, filename);
- rehash(0);
- }
+ if (!error_on_write)
+ {
+ (void)rename(temppath, filename);
+ rehash(0);
+ }
else
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Couldn't write temp kline file, aborted",
- me.name,source_p->name);
- return;
- }
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Couldn't write temp kline file, aborted",
+ me.name, source_p->name);
+ return;
+ }
- if(!pairme)
- {
- sendto_one(source_p, ":%s NOTICE %s :No K-Line for %s@%s",
- me.name, source_p->name,user,host);
- return;
- }
-
- sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
- me.name, source_p->name, user,host);
+ if (!pairme)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :No K-Line for %s@%s",
+ me.name, source_p->name, user, host);
+ return;
+ }
+
+ sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
+ me.name, source_p->name, user, host);
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s has removed the K-Line for: [%s@%s]",
- get_oper_name(source_p), user, host);
+ "%s has removed the K-Line for: [%s@%s]",
+ get_oper_name(source_p), user, host);
- ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
- source_p->name, user, host);
- return;
+ ilog(L_NOTICE, "%s removed K-Line for [%s@%s]", source_p->name, user, host);
+ return;
}
/*
* -Dianora
*/
-static int flush_write(struct Client *source_p, FBFILE* out, char *buf,
- char *temppath)
+static int
+flush_write(struct Client *source_p, FBFILE * out, char *buf, char *temppath)
{
int error_on_write = (fbputs(buf, out) < 0) ? YES : NO;
if (error_on_write)
- {
- sendto_one(source_p,":%s NOTICE %s :Unable to write to %s",
- me.name, source_p->name, temppath );
- fbclose(out);
- if(temppath != (char *)NULL)
- (void)unlink(temppath);
- }
- return(error_on_write);
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Unable to write to %s",
+ me.name, source_p->name, temppath);
+ fbclose(out);
+ if (temppath != (char *)NULL)
+ (void)unlink(temppath);
+ }
+ return (error_on_write);
}
/* static int remove_tkline_match(char *host, char *user)
int nm_t, cnm_t, bits, cbits;
nm_t = parse_netmask(host, &addr, &bits);
- for (tk_n=temporary_klines.head; tk_n; tk_n=tk_n->next)
- {
- tk_c = (struct ConfItem*)tk_n->data;
- cnm_t = parse_netmask(tk_c->host, &caddr, &cbits);
- if (cnm_t != nm_t || irccmp(user, tk_c->user))
- continue;
- if ((nm_t==HM_HOST && !irccmp(tk_c->host, host)) ||
- (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
+ for (tk_n = temporary_klines.head; tk_n; tk_n = tk_n->next)
+ {
+ tk_c = (struct ConfItem *)tk_n->data;
+ cnm_t = parse_netmask(tk_c->host, &caddr, &cbits);
+ if (cnm_t != nm_t || irccmp(user, tk_c->user))
+ continue;
+ if ((nm_t == HM_HOST && !irccmp(tk_c->host, host)) ||
+ (nm_t == HM_IPV4 && bits == cbits && match_ipv4(&addr, &caddr, bits))
#ifdef IPV6
- || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
+ || (nm_t == HM_IPV6 && bits == cbits
+ && match_ipv6(&addr, &caddr, bits))
#endif
- )
- {
- dlinkDelete(tk_n, &temporary_klines);
- free_dlink_node(tk_n);
- delete_one_address_conf(tk_c->host, tk_c);
- return YES;
- }
+ )
+ {
+ dlinkDelete(tk_n, &temporary_klines);
+ free_dlink_node(tk_n);
+ delete_one_address_conf(tk_c->host, tk_c);
+ return YES;
}
+ }
return NO;
}
** parv[1] = dline to remove
*/
static void
-mo_undline (struct Client *client_p, struct Client *source_p,
- int parc,char *parv[])
+mo_undline(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- FBFILE* in;
- FBFILE* out;
- char buf[BUFSIZE], buff[BUFSIZE], temppath[BUFSIZE], *p;
- const char *filename,*cidr, *found_cidr;
+ FBFILE *in;
+ FBFILE *out;
+ char buf[BUFSIZE], buff[BUFSIZE], temppath[BUFSIZE], *p;
+ const char *filename, *cidr, *found_cidr;
int pairme = NO, error_on_write = NO;
mode_t oldumask;
ircsprintf(temppath, "%s.tmp", ConfigFileEntry.dlinefile);
if (!IsOperUnkline(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You need unkline = yes;",me.name,
- parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need unkline = yes;", me.name,
+ parv[0]);
+ return;
+ }
cidr = parv[1];
#if 0
- if ((type=parse_netmask(cidr,&ip_host,&ip_mask)) == HM_HOST)
- {
- sendto_one(source_p, ":%s NOTICE %s :Invalid parameters",
- me.name, parv[0]);
- return;
- }
+ if ((type = parse_netmask(cidr, &ip_host, &ip_mask)) == HM_HOST)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Invalid parameters",
+ me.name, parv[0]);
+ return;
+ }
#endif
filename = get_conf_name(DLINE_TYPE);
if ((in = fbopen(filename, "r")) == 0)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Cannot open %s",
+ me.name, parv[0], filename);
+ return;
+ }
+
+ oldumask = umask(0); /* ircd is normally too paranoid */
+ if ((out = fbopen(temppath, "w")) == 0)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Cannot open %s",
+ me.name, parv[0], temppath);
+ fbclose(in);
+ umask(oldumask); /* Restore the old umask */
+ return;
+ }
+ umask(oldumask); /* Restore the old umask */
+
+ while (fbgets(buf, sizeof(buf), in))
+ {
+ strncpy_irc(buff, buf, BUFSIZE - 1)[BUFSIZE - 1] = 0;
+
+ if ((p = strchr(buff, '\n')) != NULL)
+ *p = '\0';
+
+ if ((*buff == '\0') || (*buff == '#'))
{
- sendto_one(source_p, ":%s NOTICE %s :Cannot open %s",
- me.name,parv[0],filename);
- return;
+ if (!error_on_write)
+ flush_write(source_p, out, buf, temppath);
+ continue;
}
- oldumask = umask(0); /* ircd is normally too paranoid */
- if ( (out = fbopen(temppath, "w")) == 0)
+ if ((found_cidr = getfield(buff)) == NULL)
{
- sendto_one(source_p, ":%s NOTICE %s :Cannot open %s",
- me.name,parv[0],temppath);
- fbclose(in);
- umask(oldumask); /* Restore the old umask */
- return;
+ if (!error_on_write)
+ flush_write(source_p, out, buf, temppath);
+ continue;
}
- umask(oldumask); /* Restore the old umask */
- while(fbgets(buf, sizeof(buf), in))
+ if (irccmp(found_cidr, cidr) == 0)
{
- strncpy_irc(buff, buf, BUFSIZE-1)[BUFSIZE-1] = 0;
-
- if ((p = strchr(buff,'\n')) != NULL)
- *p = '\0';
-
- if ((*buff == '\0') || (*buff == '#'))
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
-
- if ((found_cidr = getfield(buff)) == NULL)
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
-
- if (irccmp(found_cidr,cidr) == 0)
- {
- pairme++;
- }
- else
- {
- if(!error_on_write)
- flush_write(source_p, out, buf, temppath);
- continue;
- }
-
+ pairme++;
+ }
+ else
+ {
+ if (!error_on_write)
+ flush_write(source_p, out, buf, temppath);
+ continue;
}
+ }
+
fbclose(in);
fbclose(out);
if (!error_on_write)
- {
+ {
- (void)rename(temppath, filename);
- rehash(0);
- }
+ (void)rename(temppath, filename);
+ rehash(0);
+ }
else
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Couldn't write D-line file, aborted",
- me.name, parv[0]);
- return;
- }
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Couldn't write D-line file, aborted",
+ me.name, parv[0]);
+ return;
+ }
if (!pairme)
- {
- sendto_one(source_p, ":%s NOTICE %s :No D-Line for %s", me.name,
- parv[0],cidr);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :No D-Line for %s", me.name,
+ parv[0], cidr);
+ return;
+ }
sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
- me.name, parv[0], cidr);
- sendto_realops_flags(FLAGS_ALL, L_ALL, "%s has removed the D-Line for: [%s]",
- get_oper_name(source_p), cidr);
- ilog(L_NOTICE, "%s removed D-Line for [%s]", get_oper_name(source_p),
- cidr);
+ me.name, parv[0], cidr);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s has removed the D-Line for: [%s]",
+ get_oper_name(source_p), cidr);
+ ilog(L_NOTICE, "%s removed D-Line for [%s]", get_oper_name(source_p), cidr);
}
/*
** parv[1] = gline to remove
*/
-static void mo_ungline(struct Client *client_p, struct Client *source_p,
- int parc,char *parv[])
+static void
+mo_ungline(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char *user,*host;
+ char *user, *host;
if (!ConfigFileEntry.glines)
- {
- sendto_one(source_p,":%s NOTICE %s :UNGLINE disabled",me.name,parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :UNGLINE disabled", me.name, parv[0]);
+ return;
+ }
if (!IsOperUnkline(source_p) || !IsOperGline(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :You need unkline = yes;",
- me.name,parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You need unkline = yes;",
+ me.name, parv[0]);
+ return;
+ }
- if ( (host = strchr(parv[1], '@')) || *parv[1] == '*' )
- {
- /* Explicit user@host mask given */
-
- if(host) /* Found user@host */
- {
- user = parv[1]; /* here is user part */
- *(host++) = '\0'; /* and now here is host */
- }
- else
- {
- user = "*"; /* no @ found, assume its *@somehost */
- host = parv[1];
- }
- }
- else
- {
- sendto_one(source_p, ":%s NOTICE %s :Invalid parameters",
- me.name, parv[0]);
- return;
- }
+ if ((host = strchr(parv[1], '@')) || *parv[1] == '*')
+ {
+ /* Explicit user@host mask given */
- if(remove_gline_match(user, host))
+ if (host) /* Found user@host */
{
- sendto_one(source_p, ":%s NOTICE %s :Un-glined [%s@%s]",
- me.name, parv[0],user, host);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s has removed the G-Line for: [%s@%s]",
- get_oper_name(source_p), user, host );
- ilog(L_NOTICE, "%s removed G-Line for [%s@%s]",
- get_oper_name(source_p), user, host);
- return;
+ user = parv[1]; /* here is user part */
+ *(host++) = '\0'; /* and now here is host */
}
- else
+ else
{
- sendto_one(source_p, ":%s NOTICE %s :No G-Line for %s@%s",
- me.name, parv[0],user,host);
- return;
+ user = "*"; /* no @ found, assume its *@somehost */
+ host = parv[1];
}
+ }
+ else
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Invalid parameters",
+ me.name, parv[0]);
+ return;
+ }
+
+ if (remove_gline_match(user, host))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Un-glined [%s@%s]",
+ me.name, parv[0], user, host);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s has removed the G-Line for: [%s@%s]",
+ get_oper_name(source_p), user, host);
+ ilog(L_NOTICE, "%s removed G-Line for [%s@%s]",
+ get_oper_name(source_p), user, host);
+ return;
+ }
+ else
+ {
+ sendto_one(source_p, ":%s NOTICE %s :No G-Line for %s@%s",
+ me.name, parv[0], user, host);
+ return;
+ }
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_user.c,v 1.1 2002/01/04 09:13:33 a1kmm Exp $
+ * $Id: m_user.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#define UFLAGS (FLAGS_INVISIBLE|FLAGS_WALLOP|FLAGS_SERVNOTICE)
-static void mr_user(struct Client*, struct Client*, int, char**);
+static void mr_user(struct Client *, struct Client *, int, char **);
struct Message user_msgtab = {
"USER", 0, 0, 5, 0, MFLG_SLOW, 0L,
mod_del_cmd(&user_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** mr_user
** parv[3] = server host name (used only from other servers)
** parv[4] = users real name info
*/
-static void mr_user(struct Client* client_p, struct Client* source_p,
- int parc, char *parv[])
+static void
+mr_user(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char* p;
-
- if ((p = strchr(parv[1],'@')))
- *p = '\0';
+ char *p;
+
+ if ((p = strchr(parv[1], '@')))
+ *p = '\0';
if (*parv[4] == '\0')
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, BadPtr(parv[0]) ? "*" : parv[0], "USER");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, BadPtr(parv[0]) ? "*" : parv[0], "USER");
+ return;
+ }
- do_local_user(parv[0], client_p, source_p,
- parv[1], /* username */
- parv[2], /* host */
- parv[3], /* server */
- parv[4] /* users real name */ );
+ do_local_user(parv[0], client_p, source_p, parv[1], /* username */
+ parv[2], /* host */
+ parv[3], /* server */
+ parv[4] /* users real name */ );
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_userhost.c,v 1.1 2002/01/04 09:13:33 a1kmm Exp $
+ * $Id: m_userhost.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
static char buf[BUFSIZE];
-static void m_userhost(struct Client*, struct Client*, int, char**);
+static void m_userhost(struct Client *, struct Client *, int, char **);
struct Message userhost_msgtab = {
"USERHOST", 0, 0, 1, 0, MFLG_SLOW, 0,
mod_del_cmd(&userhost_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
* the need for complicated requests like WHOIS. It returns user/host
* information only (no spurious AWAY labels or channels).
*/
-static void m_userhost(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_userhost(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p;
- char response[NICKLEN*2+USERLEN+HOSTLEN+30];
+ char response[NICKLEN * 2 + USERLEN + HOSTLEN + 30];
char *t;
- int i, n; /* loop counter */
+ int i, n; /* loop counter */
int cur_len;
int rl;
- cur_len = ircsprintf(buf,form_str(RPL_USERHOST),me.name, parv[0], "");
+ cur_len = ircsprintf(buf, form_str(RPL_USERHOST), me.name, parv[0], "");
t = buf + cur_len;
- for ( i = 0; i < 5; i++)
- {
- if (parv[i+1] == NULL)
- break;
+ for (i = 0; i < 5; i++)
+ {
+ if (parv[i + 1] == NULL)
+ break;
- if ((target_p = find_person(parv[i+1])) != NULL)
- {
- /*
- * Show real IP for USERHOST on yourself.
- * This is needed for things like mIRC, which do a server-based
- * lookup (USERHOST) to figure out what the clients' local IP
- * is. Useful for things like NAT, and dynamic dial-up users.
- */
- /*
- * If a lazyleaf relayed us this request, we don't know
- * the clients real IP.
- * So, if you're on a lazyleaf, and you send a userhost
- * including your nick and the nick of someone not known to
- * the leaf, you'll get your spoofed IP. tough.
- */
- if (MyClient(target_p) && (target_p == source_p))
- {
- rl = ircsprintf(response, "%s%s=%c%s@%s ",
- target_p->name,
- IsOper(target_p) ? "*" : "",
- (target_p->user->away) ? '-' : '+',
- target_p->username,
- target_p->localClient->sockhost);
- }
- else
- {
- rl = ircsprintf(response, "%s%s=%c%s@%s ",
- target_p->name,
- IsOper(target_p) ? "*" : "",
- (target_p->user->away) ? '-' : '+',
- target_p->username,
- target_p->host);
- }
+ if ((target_p = find_person(parv[i + 1])) != NULL)
+ {
+ /*
+ * Show real IP for USERHOST on yourself.
+ * This is needed for things like mIRC, which do a server-based
+ * lookup (USERHOST) to figure out what the clients' local IP
+ * is. Useful for things like NAT, and dynamic dial-up users.
+ */
+ /*
+ * If a lazyleaf relayed us this request, we don't know
+ * the clients real IP.
+ * So, if you're on a lazyleaf, and you send a userhost
+ * including your nick and the nick of someone not known to
+ * the leaf, you'll get your spoofed IP. tough.
+ */
+ if (MyClient(target_p) && (target_p == source_p))
+ {
+ rl = ircsprintf(response, "%s%s=%c%s@%s ",
+ target_p->name,
+ IsOper(target_p) ? "*" : "",
+ (target_p->user->away) ? '-' : '+',
+ target_p->username, target_p->localClient->sockhost);
+ }
+ else
+ {
+ rl = ircsprintf(response, "%s%s=%c%s@%s ",
+ target_p->name,
+ IsOper(target_p) ? "*" : "",
+ (target_p->user->away) ? '-' : '+',
+ target_p->username, target_p->host);
+ }
- if((rl + cur_len) < (BUFSIZE-10))
- {
- ircsprintf(t,"%s",response);
- t += rl;
- cur_len += rl;
- }
- else
- break;
- }
- else if ( !ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) )
+ if ((rl + cur_len) < (BUFSIZE - 10))
+ {
+ ircsprintf(t, "%s", response);
+ t += rl;
+ cur_len += rl;
+ }
+ else
+ break;
+ }
+ else if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
+ {
+ t = buf;
+ for (n = 0; n < 5; n++)
+ {
+ if (parv[n + 1])
{
- t = buf;
- for( n = 0; n < 5; n++ )
- {
- if( parv[n+1] )
- {
- rl = ircsprintf(t, "%s ", parv[n+1]);
- t += rl;
- }
- else
- break;
- }
- /* Relay upstream, and let hub reply */
- sendto_one(uplink, ":%s USERHOST %s", parv[0], buf );
- return;
+ rl = ircsprintf(t, "%s ", parv[n + 1]);
+ t += rl;
}
+ else
+ break;
+ }
+ /* Relay upstream, and let hub reply */
+ sendto_one(uplink, ":%s USERHOST %s", parv[0], buf);
+ return;
}
+ }
sendto_one(source_p, "%s", buf);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_users.c,v 1.1 2002/01/04 09:13:33 a1kmm Exp $
+ * $Id: m_users.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "parse.h"
#include "modules.h"
-static void m_users(struct Client*, struct Client*, int, char**);
-static void mo_users(struct Client*, struct Client*, int, char**);
+static void m_users(struct Client *, struct Client *, int, char **);
+static void mo_users(struct Client *, struct Client *, int, char **);
struct Message users_msgtab = {
"USERS", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&users_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void m_users(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+m_users(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if(!ConfigServerHide.disable_remote)
+ if (!ConfigServerHide.disable_remote)
{
- if(hunt_server(client_p,source_p,":%s USERS :%s",1,parc,parv) != HUNTED_ISME)
+ if (hunt_server(client_p, source_p, ":%s USERS :%s", 1, parc, parv) !=
+ HUNTED_ISME)
return;
}
-
+
sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, parv[0],
- ConfigServerHide.hide_servers ? Count.total : Count.local,
- ConfigServerHide.hide_servers ? Count.max_tot : Count.max_loc);
+ ConfigServerHide.hide_servers ? Count.total : Count.local,
+ ConfigServerHide.hide_servers ? Count.max_tot : Count.max_loc);
sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, parv[0],
- Count.total, Count.max_tot);
+ Count.total, Count.max_tot);
}
/*
* parv[0] = sender prefix
* parv[1] = servername
*/
-static void mo_users(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static void
+mo_users(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if (hunt_server(client_p,source_p,":%s USERS :%s",1,parc,parv) == HUNTED_ISME)
- {
- if(!IsOper(source_p) && ConfigServerHide.hide_servers)
- sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, parv[0],
- Count.total, Count.max_tot);
- else
- sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, parv[0],
- Count.local, Count.max_loc);
-
- sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, parv[0],
+ if (hunt_server(client_p, source_p, ":%s USERS :%s", 1, parc, parv) ==
+ HUNTED_ISME)
+ {
+ if (!IsOper(source_p) && ConfigServerHide.hide_servers)
+ sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, parv[0],
Count.total, Count.max_tot);
- }
-}
+ else
+ sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, parv[0],
+ Count.local, Count.max_loc);
+ sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, parv[0],
+ Count.total, Count.max_tot);
+ }
+}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_version.c,v 1.1 2002/01/04 09:13:35 a1kmm Exp $
+ * $Id: m_version.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include <string.h>
#include "handlers.h"
#include "parse.h"
#include "modules.h"
-static char* confopts(struct Client *source_p);
+static char *confopts(struct Client *source_p);
-static void m_version(struct Client*, struct Client*, int, char**);
-static void ms_version(struct Client*, struct Client*, int, char**);
-static void mo_version(struct Client*, struct Client*, int, char**);
+static void m_version(struct Client *, struct Client *, int, char **);
+static void ms_version(struct Client *, struct Client *, int, char **);
+static void mo_version(struct Client *, struct Client *, int, char **);
struct Message version_msgtab = {
"VERSION", 0, 0, 0, 0, MFLG_SLOW, 0,
mod_del_cmd(&version_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
* m_version - VERSION command handler
* parv[0] = sender prefix
* parv[1] = remote server
*/
-static void m_version(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+static void
+m_version(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- static time_t last_used=0L;
+ static time_t last_used = 0L;
- if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
+ if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
{
/* safe enough to give this on a local connect only */
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,parv[0]);
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
return;
}
else
{
last_used = CurrentTime;
}
-
+
if (!ConfigServerHide.disable_remote)
{
if (hunt_server(client_p, source_p, ":%s VERSION :%s",
1, parc, parv) != HUNTED_ISME)
return;
}
-
+
sendto_one(source_p, form_str(RPL_VERSION), me.name,
- parv[0], ircd_version, serno, debugmode,
- me.name, confopts(source_p), serveropts);
-
+ parv[0], ircd_version, serno, debugmode,
+ me.name, confopts(source_p), serveropts);
+
show_isupport(source_p);
}
* parv[0] = sender prefix
* parv[1] = remote server
*/
-static void mo_version(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+static void
+mo_version(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
-
- if (hunt_server(client_p, source_p, ":%s VERSION :%s",
- 1, parc, parv) != HUNTED_ISME)
+
+ if (hunt_server(client_p, source_p, ":%s VERSION :%s",
+ 1, parc, parv) != HUNTED_ISME)
return;
-
- sendto_one(source_p, form_str(RPL_VERSION), me.name, parv[0], ircd_version,
- serno, debugmode, me.name, confopts(source_p), serveropts);
-
+
+ sendto_one(source_p, form_str(RPL_VERSION), me.name, parv[0], ircd_version,
+ serno, debugmode, me.name, confopts(source_p), serveropts);
+
show_isupport(source_p);
-
+
return;
}
* parv[0] = sender prefix
* parv[1] = remote server
*/
-static void ms_version(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+static void
+ms_version(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- if (hunt_server(client_p, source_p, ":%s VERSION :%s",
+ if (hunt_server(client_p, source_p, ":%s VERSION :%s",
1, parc, parv) == HUNTED_ISME)
{
sendto_one(source_p, form_str(RPL_VERSION), me.name,
* output - ircd.conf option string
* side effects - none
*/
-static char* confopts(struct Client *source_p)
+static char *
+confopts(struct Client *source_p)
{
static char result[15];
char *p;
-
+
result[0] = '\0';
p = result;
*p++ = 'D';
#endif
- if(ConfigChannel.use_except)
+ if (ConfigChannel.use_except)
*p++ = 'e';
-
+
if (ConfigFileEntry.glines)
*p++ = 'g';
- *p++ = 'G';
+ *p++ = 'G';
/* might wanna hide this :P */
- if (ServerInfo.hub &&
- (!ConfigServerHide.disable_remote || IsOper(source_p)) )
- {
- *p++ = 'H';
- }
+ if (ServerInfo.hub &&
+ (!ConfigServerHide.disable_remote || IsOper(source_p)))
+ {
+ *p++ = 'H';
+ }
- if(ConfigChannel.use_invex)
+ if (ConfigChannel.use_invex)
*p++ = 'I';
- if(ConfigChannel.use_knock)
+ if (ConfigChannel.use_knock)
*p++ = 'K';
-
+
*p++ = 'M';
#ifdef CRYPT_OPER_PASSWORD
#ifdef IPV6
*p++ = '6';
#endif
-
+
*p = '\0';
return result;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_wallops.c,v 1.1 2002/01/04 09:13:35 a1kmm Exp $
+ * $Id: m_wallops.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
#include "modules.h"
#include "client.h"
-static void ms_wallops(struct Client*, struct Client*, int, char**);
-static void mo_wallops(struct Client*, struct Client*, int, char**);
+static void ms_wallops(struct Client *, struct Client *, int, char **);
+static void mo_wallops(struct Client *, struct Client *, int, char **);
struct Message wallops_msgtab = {
"WALLOPS", 0, 0, 2, 0, MFLG_SLOW, 0,
{
mod_del_cmd(&wallops_msgtab);
}
-
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
/*
* mo_wallops (write to *all* opers currently online)
* parv[0] = sender prefix
* parv[1] = message text
*/
-static void mo_wallops(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
-{
- char* message;
+static void
+mo_wallops(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
+{
+ char *message;
message = parv[1];
-
+
if (EmptyString(message))
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "WALLOPS");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "WALLOPS");
+ return;
+ }
sendto_wallops_flags(FLAGS_OPERWALL, source_p, "%s", message);
sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
* parv[0] = sender prefix
* parv[1] = message text
*/
-static void ms_wallops(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
-{
- char* message;
+static void
+ms_wallops(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
+{
+ char *message;
message = parv[1];
-
+
if (EmptyString(message))
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "WALLOPS");
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "WALLOPS");
+ return;
+ }
- if(IsClient(source_p))
+ if (IsClient(source_p))
sendto_wallops_flags(FLAGS_OPERWALL, source_p, "%s", message);
else
- sendto_wallops_flags(FLAGS_WALLOP, source_p, "%s", message);
+ sendto_wallops_flags(FLAGS_WALLOP, source_p, "%s", message);
sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
":%s WALLOPS :%s", parv[0], message);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_who.c,v 1.1 2002/01/04 09:13:35 a1kmm Exp $
+ * $Id: m_who.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "tools.h"
-#include "common.h" /* bleah */
+#include "common.h" /* bleah */
#include "handlers.h"
#include "client.h"
#include "channel.h"
#include "parse.h"
#include "modules.h"
-static void m_who(struct Client*, struct Client*, int, char**);
-static void ms_who(struct Client*, struct Client*, int, char**);
+static void m_who(struct Client *, struct Client *, int, char **);
+static void ms_who(struct Client *, struct Client *, int, char **);
struct Message who_msgtab = {
"WHO", 0, 0, 2, 0, MFLG_SLOW, 0,
{
mod_del_cmd(&who_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
static void do_who_on_channel(struct Client *source_p,
- struct Channel *chptr, char *real_name,
- int server_oper, int member);
+ struct Channel *chptr, char *real_name,
+ int server_oper, int member);
static void do_who_list(struct Client *source_p, struct Channel *chptr,
- dlink_list *peons_list, dlink_list *chanops_list,
+ dlink_list * peons_list, dlink_list * chanops_list,
#ifdef REQUIRE_OANDV
- dlink_list *chanops_voiced_list,
+ dlink_list * chanops_voiced_list,
#endif
- dlink_list *halfops_list, dlink_list *voiced_list,
- char *chanop_flag, char *halfop_flag, char *voiced_flag,
- char *chname);
+ dlink_list * halfops_list, dlink_list * voiced_list,
+ char *chanop_flag, char *halfop_flag,
+ char *voiced_flag, char *chname);
static void who_global(struct Client *source_p, char *mask, int server_oper);
static void do_who(struct Client *source_p,
- struct Client *target_p,
- char *chname,
- char *op_flags);
+ struct Client *target_p, char *chname, char *op_flags);
/*
** parv[1] = nickname mask list
** parv[2] = additional selection flag, only 'o' for now.
*/
-static void m_who(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_who(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p;
- char *mask = parc > 1 ? parv[1] : NULL;
+ char *mask = parc > 1 ? parv[1] : NULL;
dlink_node *lp;
- struct Channel *chptr=NULL;
+ struct Channel *chptr = NULL;
struct Channel *vchan;
struct Channel *mychannel = NULL;
- char flags[MAX_SUBLISTS][2];
- int server_oper = parc > 2 ? (*parv[2] == 'o' ): 0; /* Show OPERS only */
- int member;
+ char flags[MAX_SUBLISTS][2];
+ int server_oper = parc > 2 ? (*parv[2] == 'o') : 0; /* Show OPERS only */
+ int member;
/* See if mask is there, collapse it or return if not there */
if (mask != (char *)NULL)
- {
- (void)collapse(mask);
+ {
+ (void)collapse(mask);
- if (*mask == '\0')
- {
- sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], "*" );
- return;
- }
- }
- else
+ if (*mask == '\0')
{
- who_global(source_p, mask, server_oper);
- sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], "*" );
+ sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], "*");
return;
}
+ }
+ else
+ {
+ who_global(source_p, mask, server_oper);
+ sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], "*");
+ return;
+ }
/* mask isn't NULL at this point. repeat after me... -db */
/* '/who *' */
- if ((*(mask+1) == (char) 0) && (*mask == '*'))
- {
- if (source_p->user)
- if ((lp = source_p->user->channel.head))
- mychannel = lp->data;
-
- if (!mychannel)
- {
- sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], "*");
- return;
- }
+ if ((*(mask + 1) == (char)0) && (*mask == '*'))
+ {
+ if (source_p->user)
+ if ((lp = source_p->user->channel.head))
+ mychannel = lp->data;
- if (HasVchans(mychannel))
- {
- vchan = map_vchan(mychannel,source_p);
- if(vchan != 0)
- do_who_on_channel(source_p,vchan,"*",NO,YES);
- else
- do_who_on_channel(source_p,mychannel,"*",NO,YES);
- }
- else
- do_who_on_channel(source_p, mychannel, "*", NO, YES);
+ if (!mychannel)
+ {
sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], "*");
return;
}
+ if (HasVchans(mychannel))
+ {
+ vchan = map_vchan(mychannel, source_p);
+ if (vchan != 0)
+ do_who_on_channel(source_p, vchan, "*", NO, YES);
+ else
+ do_who_on_channel(source_p, mychannel, "*", NO, YES);
+ }
+ else
+ do_who_on_channel(source_p, mychannel, "*", NO, YES);
+ sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], "*");
+ return;
+ }
+
/* '/who #some_channel' */
if (IsChannelName(mask))
+ {
+ /*
+ * List all users on a given channel
+ */
+ chptr = hash_find_channel(mask);
+ if (chptr != NULL)
{
- /*
- * List all users on a given channel
- */
- chptr = hash_find_channel(mask);
- if (chptr != NULL)
- {
- if (HasVchans(chptr))
- {
- vchan = map_vchan(chptr,source_p);
-
- /* If vchan not 0, that makes them a member automatically */
- if ( vchan != 0 )
- do_who_on_channel(source_p, vchan, chptr->chname, NO, YES);
- else
- {
- if ( IsMember(source_p, chptr) )
- do_who_on_channel(source_p, chptr, chptr->chname, NO, YES);
- else if(!SecretChannel(chptr))
- do_who_on_channel(source_p, chptr, chptr->chname, NO, NO);
- }
- }
- else
- {
- if ( IsMember(source_p, chptr) )
- do_who_on_channel(source_p, chptr, chptr->chname, NO, YES);
- else if(!SecretChannel(chptr))
- do_who_on_channel(source_p, chptr, chptr->chname, NO, NO);
- }
- }
- sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], mask );
- return;
+ if (HasVchans(chptr))
+ {
+ vchan = map_vchan(chptr, source_p);
+
+ /* If vchan not 0, that makes them a member automatically */
+ if (vchan != 0)
+ do_who_on_channel(source_p, vchan, chptr->chname, NO, YES);
+ else
+ {
+ if (IsMember(source_p, chptr))
+ do_who_on_channel(source_p, chptr, chptr->chname, NO, YES);
+ else if (!SecretChannel(chptr))
+ do_who_on_channel(source_p, chptr, chptr->chname, NO, NO);
+ }
+ }
+ else
+ {
+ if (IsMember(source_p, chptr))
+ do_who_on_channel(source_p, chptr, chptr->chname, NO, YES);
+ else if (!SecretChannel(chptr))
+ do_who_on_channel(source_p, chptr, chptr->chname, NO, NO);
+ }
}
+ sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], mask);
+ return;
+ }
/* '/who nick' */
if (((target_p = find_client(mask)) != NULL) &&
IsPerson(target_p) && (!server_oper || IsOper(target_p)))
+ {
+ struct Channel *bchan;
+ char *chname = NULL;
+ int isinvis = 0;
+
+ if (IsServer(client_p))
+ client_burst_if_needed(client_p, target_p);
+
+ isinvis = IsInvisible(target_p);
+ for (lp = target_p->user->channel.head; lp; lp = lp->next)
{
- struct Channel *bchan;
- char *chname=NULL;
- int isinvis = 0;
-
- if(IsServer(client_p))
- client_burst_if_needed(client_p,target_p);
-
- isinvis = IsInvisible(target_p);
- for (lp = target_p->user->channel.head; lp; lp = lp->next)
- {
- chptr = lp->data;
- chname = chptr->chname;
-
- member = IsMember(source_p, chptr);
- if (isinvis && !member)
- continue;
- if (member || (!isinvis && PubChannel(chptr)))
- {
- break;
- }
- }
-
- if (chptr != NULL)
- {
- if (IsVchan(chptr))
- {
- bchan = find_bchan (chptr);
- if (bchan != NULL)
- chname = bchan->chname;
- }
-
- /* XXX globalize this inside m_who.c ? */
- /* jdc -- Check is_any_op() for +o > +h > +v priorities */
- set_channel_mode_flags( flags, chptr, source_p );
-
- if (is_chan_op(chptr,target_p))
- do_who(source_p, target_p, chname, flags[0]);
- else if(is_half_op(chptr,target_p))
- do_who(source_p, target_p, chname, flags[1]);
- else if(is_voiced(chptr,target_p))
- do_who(source_p, target_p, chname, flags[2]);
- else
- do_who(source_p, target_p, chname, "");
- }
- else
- {
- do_who(source_p, target_p, NULL, "");
- }
+ chptr = lp->data;
+ chname = chptr->chname;
- sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], mask );
- return;
+ member = IsMember(source_p, chptr);
+ if (isinvis && !member)
+ continue;
+ if (member || (!isinvis && PubChannel(chptr)))
+ {
+ break;
+ }
+ }
+
+ if (chptr != NULL)
+ {
+ if (IsVchan(chptr))
+ {
+ bchan = find_bchan(chptr);
+ if (bchan != NULL)
+ chname = bchan->chname;
+ }
+
+ /* XXX globalize this inside m_who.c ? */
+ /* jdc -- Check is_any_op() for +o > +h > +v priorities */
+ set_channel_mode_flags(flags, chptr, source_p);
+
+ if (is_chan_op(chptr, target_p))
+ do_who(source_p, target_p, chname, flags[0]);
+ else if (is_half_op(chptr, target_p))
+ do_who(source_p, target_p, chname, flags[1]);
+ else if (is_voiced(chptr, target_p))
+ do_who(source_p, target_p, chname, flags[2]);
+ else
+ do_who(source_p, target_p, chname, "");
}
+ else
+ {
+ do_who(source_p, target_p, NULL, "");
+ }
+
+ sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], mask);
+ return;
+ }
/* '/who 0' */
if ((*(mask + 1) == '\0') && (*mask == '0'))
{
}
/* Wasn't a nick, wasn't a channel, wasn't a '*' so ... */
who_global(source_p, mask, server_oper);
- sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], mask );
+ sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, parv[0], mask);
}
/* who_common_channel
* marks matched clients.
*
*/
-static void who_common_channel(struct Client *source_p,dlink_list chain,
- char *mask,int server_oper, int *maxmatches)
+static void
+who_common_channel(struct Client *source_p, dlink_list chain,
+ char *mask, int server_oper, int *maxmatches)
{
dlink_node *clp;
- struct Client *target_p;
+ struct Client *target_p;
for (clp = chain.head; clp; clp = clp->next)
- {
- target_p = clp->data;
-
- if (!IsInvisible(target_p) || IsMarked(target_p))
- continue;
-
- if (server_oper && !IsOper(target_p))
- continue;
-
- SetMark(target_p);
-
- if (!mask ||
- match(mask, target_p->name) || match(mask, target_p->username) ||
- match(mask, target_p->host) || match(mask, target_p->user->server) ||
- match(mask, target_p->info))
- {
-
- do_who(source_p, target_p, NULL, "");
-
- if (*maxmatches > 0)
- {
- --(*maxmatches);
- if(*maxmatches == 0)
- return;
- }
-
- }
- }
+ {
+ target_p = clp->data;
+
+ if (!IsInvisible(target_p) || IsMarked(target_p))
+ continue;
+
+ if (server_oper && !IsOper(target_p))
+ continue;
+
+ SetMark(target_p);
+
+ if (!mask ||
+ match(mask, target_p->name) || match(mask, target_p->username) ||
+ match(mask, target_p->host) || match(mask, target_p->user->server) ||
+ match(mask, target_p->info))
+ {
+
+ do_who(source_p, target_p, NULL, "");
+
+ if (*maxmatches > 0)
+ {
+ --(*maxmatches);
+ if (*maxmatches == 0)
+ return;
+ }
+
+ }
+ }
}
/*
* this is slightly expensive on EFnet ...
*/
-static void who_global(struct Client *source_p,char *mask, int server_oper)
+static void
+who_global(struct Client *source_p, char *mask, int server_oper)
{
- struct Channel *chptr=NULL;
+ struct Channel *chptr = NULL;
struct Client *target_p;
- dlink_node *lp;
- int maxmatches = 500;
+ dlink_node *lp;
+ int maxmatches = 500;
/* first, list all matching INvisible clients on common channels */
for (lp = source_p->user->channel.head; lp; lp = lp->next)
{
- chptr = lp->data;
- who_common_channel(source_p,chptr->chanops,mask,server_oper,&maxmatches);
- who_common_channel(source_p,chptr->chanops_voiced,mask,server_oper,&maxmatches);
- who_common_channel(source_p,chptr->halfops,mask,server_oper,&maxmatches);
- who_common_channel(source_p,chptr->voiced,mask,server_oper,&maxmatches);
- who_common_channel(source_p,chptr->peons,mask,server_oper,&maxmatches);
+ chptr = lp->data;
+ who_common_channel(source_p, chptr->chanops, mask, server_oper,
+ &maxmatches);
+ who_common_channel(source_p, chptr->chanops_voiced, mask, server_oper,
+ &maxmatches);
+ who_common_channel(source_p, chptr->halfops, mask, server_oper,
+ &maxmatches);
+ who_common_channel(source_p, chptr->voiced, mask, server_oper,
+ &maxmatches);
+ who_common_channel(source_p, chptr->peons, mask, server_oper,
+ &maxmatches);
}
/* second, list all matching visible clients */
if (!mask ||
match(mask, target_p->name) || match(mask, target_p->username) ||
- match(mask, target_p->host) || match(mask, target_p->user->server) ||
- match(mask, target_p->info))
+ match(mask, target_p->host) || match(mask, target_p->user->server) ||
+ match(mask, target_p->info))
{
-
+
do_who(source_p, target_p, NULL, "");
if (maxmatches > 0)
{
--maxmatches;
- if( maxmatches == 0 )
- return;
+ if (maxmatches == 0)
+ return;
}
}
* side effects - do a who on given channel
*/
-static void do_who_on_channel(struct Client *source_p,
- struct Channel *chptr,
- char *chname,
- int server_oper, int member)
+static void
+do_who_on_channel(struct Client *source_p,
+ struct Channel *chptr,
+ char *chname, int server_oper, int member)
{
char flags[MAX_SUBLISTS][2];
/* jdc -- Check is_any_op() for +o > +h > +v priorities */
- set_channel_mode_flags( flags, chptr, source_p );
+ set_channel_mode_flags(flags, chptr, source_p);
- do_who_list(source_p, chptr,
- &chptr->peons,
- &chptr->chanops,
+ do_who_list(source_p, chptr, &chptr->peons, &chptr->chanops,
#ifdef REQUIRE_OANDV
&chptr->chanops_voiced,
#endif
&chptr->halfops,
- &chptr->voiced,
- flags[0],
- flags[1],
- flags[2],
- chname);
+ &chptr->voiced, flags[0], flags[1], flags[2], chname);
}
-static void do_who_list(struct Client *source_p, struct Channel *chptr,
- dlink_list *peons_list,
- dlink_list *chanops_list,
+static void
+do_who_list(struct Client *source_p, struct Channel *chptr,
+ dlink_list * peons_list, dlink_list * chanops_list,
#ifdef REQUIRE_OANDV
- dlink_list *chanops_voiced_list,
+ dlink_list * chanops_voiced_list,
#endif
- dlink_list *halfops_list,
- dlink_list *voiced_list,
- char *chanop_flag,
- char *halfop_flag,
- char *voiced_flag,
- char *chname)
+ dlink_list * halfops_list,
+ dlink_list * voiced_list,
+ char *chanop_flag,
+ char *halfop_flag, char *voiced_flag, char *chname)
{
dlink_node *chanops_ptr;
dlink_node *peons_ptr;
dlink_node *chanops_voiced_ptr;
#endif
struct Client *target_p;
- int done=0;
+ int done = 0;
- peons_ptr = peons_list->head;
+ peons_ptr = peons_list->head;
chanops_ptr = chanops_list->head;
halfops_ptr = halfops_list->head;
- voiced_ptr = voiced_list->head;
+ voiced_ptr = voiced_list->head;
#ifdef REQUIRE_OANDV
chanops_voiced_ptr = chanops_voiced_list->head;
#endif
#endif
while (done != NUMLISTS)
- {
- done = 0;
+ {
+ done = 0;
- if(peons_ptr != NULL)
- {
- target_p = peons_ptr->data;
- do_who(source_p, target_p, chname, "");
- peons_ptr = peons_ptr->next;
- }
- else
- done++;
+ if (peons_ptr != NULL)
+ {
+ target_p = peons_ptr->data;
+ do_who(source_p, target_p, chname, "");
+ peons_ptr = peons_ptr->next;
+ }
+ else
+ done++;
- if(chanops_ptr != NULL)
- {
- target_p = chanops_ptr->data;
- do_who(source_p, target_p, chname, chanop_flag);
- chanops_ptr = chanops_ptr->next;
- }
- else
- done++;
+ if (chanops_ptr != NULL)
+ {
+ target_p = chanops_ptr->data;
+ do_who(source_p, target_p, chname, chanop_flag);
+ chanops_ptr = chanops_ptr->next;
+ }
+ else
+ done++;
- if(halfops_ptr != NULL)
- {
- target_p = halfops_ptr->data;
- do_who(source_p, target_p, chname, halfop_flag);
- halfops_ptr = halfops_ptr->next;
- }
- else
- done++;
+ if (halfops_ptr != NULL)
+ {
+ target_p = halfops_ptr->data;
+ do_who(source_p, target_p, chname, halfop_flag);
+ halfops_ptr = halfops_ptr->next;
+ }
+ else
+ done++;
- if(voiced_ptr != NULL)
- {
- target_p = voiced_ptr->data;
- if(target_p == source_p && is_voiced(chptr, source_p) && chptr->mode.mode & MODE_HIDEOPS)
- do_who(source_p, target_p, chname, "+");
- else
- do_who(source_p, target_p, chname, voiced_flag);
- voiced_ptr = voiced_ptr->next;
- }
+ if (voiced_ptr != NULL)
+ {
+ target_p = voiced_ptr->data;
+ if (target_p == source_p && is_voiced(chptr, source_p)
+ && chptr->mode.mode & MODE_HIDEOPS)
+ do_who(source_p, target_p, chname, "+");
else
- done++;
+ do_who(source_p, target_p, chname, voiced_flag);
+ voiced_ptr = voiced_ptr->next;
+ }
+ else
+ done++;
- if(chanops_voiced_ptr != NULL)
- {
- target_p = chanops_voiced_ptr->data;
- do_who(source_p, target_p, chname, chanop_flag);
- chanops_voiced_ptr = chanops_voiced_ptr->next;
- }
- else
- done++;
+ if (chanops_voiced_ptr != NULL)
+ {
+ target_p = chanops_voiced_ptr->data;
+ do_who(source_p, target_p, chname, chanop_flag);
+ chanops_voiced_ptr = chanops_voiced_ptr->next;
}
+ else
+ done++;
+ }
}
/*
* side effects - do a who on given person
*/
-static void do_who(struct Client *source_p,
- struct Client *target_p,
- char *chname,
- char *op_flags)
+static void
+do_who(struct Client *source_p,
+ struct Client *target_p, char *chname, char *op_flags)
{
- char status[5];
+ char status[5];
- ircsprintf(status,"%c%s%s",
- target_p->user->away ? 'G' : 'H',
- IsOper(target_p) ? "*" : "", op_flags );
+ ircsprintf(status, "%c%s%s",
+ target_p->user->away ? 'G' : 'H',
+ IsOper(target_p) ? "*" : "", op_flags);
- if(ConfigServerHide.hide_servers)
- {
- sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name,
- (chname) ? (chname) : "*",
- target_p->username,
- target_p->host, IsOper(source_p) ? target_p->user->server : "*",
- target_p->name,
- status, 0, target_p->info);
- }
+ if (ConfigServerHide.hide_servers)
+ {
+ sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name,
+ (chname) ? (chname) : "*",
+ target_p->username,
+ target_p->host,
+ IsOper(source_p) ? target_p->user->server : "*",
+ target_p->name, status, 0, target_p->info);
+ }
else
- {
- sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name,
- (chname) ? (chname) : "*",
- target_p->username,
- target_p->host, target_p->user->server, target_p->name,
- status, target_p->hopcount, target_p->info);
- }
+ {
+ sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name,
+ (chname) ? (chname) : "*",
+ target_p->username,
+ target_p->host, target_p->user->server, target_p->name,
+ status, target_p->hopcount, target_p->info);
+ }
}
/*
** parv[1] = nickname mask list
** parv[2] = additional selection flag, only 'o' for now.
*/
-static void ms_who(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_who(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
/* If its running as a hub, and linked with lazy links
* then allow leaf to use normal client m_who()
* other wise, ignore it.
*/
- if( ServerInfo.hub )
- {
- if(!IsCapable(client_p->from,CAP_LL))
- return;
- }
+ if (ServerInfo.hub)
+ {
+ if (!IsCapable(client_p->from, CAP_LL))
+ return;
+ }
- m_who(client_p,source_p,parc,parv);
+ m_who(client_p, source_p, parc, parv);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_whois.c,v 1.1 2002/01/04 09:13:35 a1kmm Exp $
+ * $Id: m_whois.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include <string.h>
#include <time.h>
#include "tools.h"
-#include "common.h" /* bleah */
+#include "common.h" /* bleah */
#include "handlers.h"
#include "client.h"
#include "hash.h"
-#include "common.h" /* bleah */
+#include "common.h" /* bleah */
#include "channel.h"
#include "channel_mode.h"
#include "vchannel.h"
int parc, char *parv[]);
static int single_whois(struct Client *source_p, struct Client *target_p,
int wilds, int glob);
-static void whois_person(struct Client *source_p,struct Client *target_p,int glob);
-static int global_whois(struct Client *source_p, char *nick, int wilds, int glob);
+static void whois_person(struct Client *source_p, struct Client *target_p,
+ int glob);
+static int global_whois(struct Client *source_p, char *nick, int wilds,
+ int glob);
-static void m_whois(struct Client*, struct Client*, int, char**);
-static void ms_whois(struct Client*, struct Client*, int, char**);
-static void mo_whois(struct Client*, struct Client*, int, char**);
+static void m_whois(struct Client *, struct Client *, int, char **);
+static void ms_whois(struct Client *, struct Client *, int, char **);
+static void mo_whois(struct Client *, struct Client *, int, char **);
struct Message whois_msgtab = {
"WHOIS", 0, 0, 0, 0, MFLG_SLOW, 0L,
mod_del_cmd(&whois_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+char *_version = "$Revision: 1.2 $";
#endif
/*
** m_whois
** parv[0] = sender prefix
** parv[1] = nickname masklist
*/
-static void m_whois(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_whois(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
static time_t last_used = 0;
-
+
if (parc < 2)
+ {
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
+ return;
+ }
+
+ if (parc > 2)
+ {
+ /* seeing as this is going across servers, we should limit it */
+ if ((last_used + ConfigFileEntry.whois_wait) > CurrentTime)
{
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, parv[0]);
+ if (MyClient(source_p))
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name);
return;
}
+ else
+ last_used = CurrentTime;
- if(parc > 2)
- {
- /* seeing as this is going across servers, we should limit it */
- if((last_used + ConfigFileEntry.whois_wait) > CurrentTime)
- {
- if(MyClient(source_p))
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,source_p->name);
- return;
- }
- else
- last_used = CurrentTime;
-
- /* if we have serverhide enabled, they can either ask the clients
- * server, or our server.. I dont see why they would need to ask
- * anything else for info about the client.. --fl_
- */
- if(ConfigServerHide.disable_remote)
- parv[1] = parv[2];
-
- if (hunt_server(client_p,source_p,":%s WHOIS %s :%s", 1, parc, parv) !=
- HUNTED_ISME)
- {
- return;
- }
+ /* if we have serverhide enabled, they can either ask the clients
+ * server, or our server.. I dont see why they would need to ask
+ * anything else for info about the client.. --fl_
+ */
+ if (ConfigServerHide.disable_remote)
parv[1] = parv[2];
+ if (hunt_server(client_p, source_p, ":%s WHOIS %s :%s", 1, parc, parv) !=
+ HUNTED_ISME)
+ {
+ return;
}
- do_whois(client_p,source_p,parc,parv);
+ parv[1] = parv[2];
+
+ }
+ do_whois(client_p, source_p, parc, parv);
}
/*
** parv[0] = sender prefix
** parv[1] = nickname masklist
*/
-static void mo_whois(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+mo_whois(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- if(parc < 2)
- {
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, parv[0]);
- return;
- }
+ if (parc < 2)
+ {
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
+ return;
+ }
- if(parc > 2)
+ if (parc > 2)
+ {
+ if (hunt_server(client_p, source_p, ":%s WHOIS %s :%s", 1, parc, parv) !=
+ HUNTED_ISME)
{
- if (hunt_server(client_p,source_p,":%s WHOIS %s :%s", 1, parc, parv) !=
- HUNTED_ISME)
- {
- return;
- }
- parv[1] = parv[2];
+ return;
}
+ parv[1] = parv[2];
+ }
- do_whois(client_p,source_p,parc,parv);
+ do_whois(client_p, source_p, parc, parv);
}
* output -
* side effects -
*/
-static int do_whois(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static int
+do_whois(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct Client *target_p;
- char *nick;
- char *p = NULL;
- int found=NO;
- int wilds;
- int glob=0;
-
+ char *nick;
+ char *p = NULL;
+ int found = NO;
+ int wilds;
+ int glob = 0;
+
/* This lets us make all "whois nick" queries look the same, and all
* "whois nick nick" queries look the same. We have to pass it all
* the way down to whois_person() though -- fl */
- if(parc > 2)
+ if (parc > 2)
glob = 1;
nick = parv[1];
- if ( (p = strchr(parv[1],',')) )
+ if ((p = strchr(parv[1], ',')))
*p = '\0';
(void)collapse(nick);
wilds = (strchr(nick, '?') || strchr(nick, '*'));
- if(!wilds)
+ if (!wilds)
+ {
+ if ((target_p = find_client(nick)) != NULL)
{
- if((target_p = find_client(nick)) != NULL)
- {
- /* im being asked to reply to a client that isnt mine..
- * I cant answer authoritively, so better make it non-detailed
- */
- if(!MyClient(target_p))
- glob=0;
-
- if (IsServer(client_p))
- client_burst_if_needed(client_p,target_p);
-
- if(IsPerson(target_p))
- {
- (void)single_whois(source_p,target_p,wilds,glob);
- found = YES;
- }
- }
- else
- {
- if (!ServerInfo.hub && uplink && IsCapable(uplink,CAP_LL))
- {
- if(glob == 1)
- sendto_one(uplink,":%s WHOIS %s :%s",
- source_p->name, nick, nick);
- else
- sendto_one(uplink,":%s WHOIS %s",
- source_p->name, nick);
- return 0;
- }
- }
+ /* im being asked to reply to a client that isnt mine..
+ * I cant answer authoritively, so better make it non-detailed
+ */
+ if (!MyClient(target_p))
+ glob = 0;
+
+ if (IsServer(client_p))
+ client_burst_if_needed(client_p, target_p);
+
+ if (IsPerson(target_p))
+ {
+ (void)single_whois(source_p, target_p, wilds, glob);
+ found = YES;
+ }
+ }
+ else
+ {
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
+ {
+ if (glob == 1)
+ sendto_one(uplink, ":%s WHOIS %s :%s", source_p->name, nick, nick);
+ else
+ sendto_one(uplink, ":%s WHOIS %s", source_p->name, nick);
+ return 0;
+ }
}
+ }
else
+ {
+ /* disallow wild card whois on lazylink leafs for now */
+
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
{
- /* disallow wild card whois on lazylink leafs for now */
-
- if (!ServerInfo.hub && uplink && IsCapable(uplink,CAP_LL))
- {
- return 0;
- }
- /* Oh-oh wilds is true so have to do it the hard expensive way */
- found = global_whois(source_p,nick,wilds,glob);
+ return 0;
}
+ /* Oh-oh wilds is true so have to do it the hard expensive way */
+ found = global_whois(source_p, nick, wilds, glob);
+ }
- if(found)
+ if (found)
sendto_one(source_p, form_str(RPL_ENDOFWHOIS), me.name, parv[0], parv[1]);
else
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], nick);
* Side Effects - do a single whois on given client
* writing results to source_p
*/
-static int global_whois(struct Client *source_p, char *nick,
- int wilds, int glob)
+static int
+global_whois(struct Client *source_p, char *nick, int wilds, int glob)
{
struct Client *target_p;
int found = NO;
for (target_p = GlobalClientList; (target_p = next_client(target_p, nick));
target_p = target_p->next)
- {
- if (IsServer(target_p))
- continue;
- /*
- * I'm always last :-) and target_p->next == NULL!!
- */
- if (IsMe(target_p))
- break;
- /*
- * 'Rules' established for sending a WHOIS reply:
- *
- *
- * - if wildcards are being used dont send a reply if
- * the querier isnt any common channels and the
- * client in question is invisible and wildcards are
- * in use (allow exact matches only);
- *
- * - only send replies about common or public channels
- * the target user(s) are on;
- */
+ {
+ if (IsServer(target_p))
+ continue;
+ /*
+ * I'm always last :-) and target_p->next == NULL!!
+ */
+ if (IsMe(target_p))
+ break;
+ /*
+ * 'Rules' established for sending a WHOIS reply:
+ *
+ *
+ * - if wildcards are being used dont send a reply if
+ * the querier isnt any common channels and the
+ * client in question is invisible and wildcards are
+ * in use (allow exact matches only);
+ *
+ * - only send replies about common or public channels
+ * the target user(s) are on;
+ */
- if(!IsRegistered(target_p))
- continue;
+ if (!IsRegistered(target_p))
+ continue;
- if(single_whois(source_p, target_p, wilds, glob))
- found = 1;
- }
+ if (single_whois(source_p, target_p, wilds, glob))
+ found = 1;
+ }
return (found);
}
* Side Effects - do a single whois on given client
* writing results to source_p
*/
-static int single_whois(struct Client *source_p,struct Client *target_p,
- int wilds, int glob)
+static int
+single_whois(struct Client *source_p, struct Client *target_p,
+ int wilds, int glob)
{
dlink_node *ptr;
struct Channel *chptr;
int invis;
int member;
int showperson;
-
+
if (target_p->name[0] == '\0')
name = "?";
else
name = target_p->name;
- if( target_p->user == NULL )
- {
- sendto_one(source_p, form_str(RPL_WHOISUSER), me.name,
- source_p->name, name,
- target_p->username, target_p->host, target_p->info);
- sendto_one(source_p, form_str(RPL_WHOISSERVER),
- me.name, source_p->name, name, "<Unknown>",
- "*Not On This Net*");
- return 0;
- }
+ if (target_p->user == NULL)
+ {
+ sendto_one(source_p, form_str(RPL_WHOISUSER), me.name,
+ source_p->name, name,
+ target_p->username, target_p->host, target_p->info);
+ sendto_one(source_p, form_str(RPL_WHOISSERVER),
+ me.name, source_p->name, name, "<Unknown>",
+ "*Not On This Net*");
+ return 0;
+ }
invis = IsInvisible(target_p);
member = (target_p->user->channel.head) ? 1 : 0;
showperson = (wilds && !invis && !member) || !wilds;
for (ptr = target_p->user->channel.head; ptr; ptr = ptr->next)
+ {
+ chptr = ptr->data;
+ member = IsMember(source_p, chptr);
+ if (invis && !member)
+ continue;
+ if (member || (!invis && PubChannel(chptr)))
+ {
+ showperson = 1;
+ break;
+ }
+ if (!invis && HiddenChannel(chptr) && !SecretChannel(chptr))
{
- chptr = ptr->data;
- member = IsMember(source_p, chptr);
- if (invis && !member)
- continue;
- if (member || (!invis && PubChannel(chptr)))
- {
- showperson = 1;
- break;
- }
- if (!invis && HiddenChannel(chptr) && !SecretChannel(chptr))
- {
- showperson = 1;
- break;
- }
+ showperson = 1;
+ break;
}
+ }
- if(showperson)
- whois_person(source_p,target_p,glob);
+ if (showperson)
+ whois_person(source_p, target_p, glob);
return 0;
}
* Output - NONE
* Side Effects -
*/
-static void whois_person(struct Client *source_p,struct Client *target_p, int glob)
+static void
+whois_person(struct Client *source_p, struct Client *target_p, int glob)
{
char buf[BUFSIZE];
char *chname;
char *server_name;
- dlink_node *lp;
+ dlink_node *lp;
struct Client *a2client_p;
struct Channel *chptr;
struct Channel *bchan;
int tlen;
int reply_to_send = NO;
struct hook_mfunc_data hd;
-
+
a2client_p = find_server(target_p->user->server);
-
+
sendto_one(source_p, form_str(RPL_WHOISUSER), me.name,
- source_p->name, target_p->name,
- target_p->username, target_p->host, target_p->info);
+ source_p->name, target_p->name,
+ target_p->username, target_p->host, target_p->info);
server_name = (char *)target_p->user->server;
ircsprintf(buf, form_str(RPL_WHOISCHANNELS),
- me.name, source_p->name, target_p->name, "");
+ me.name, source_p->name, target_p->name, "");
mlen = strlen(buf);
cur_len = mlen;
t = buf + mlen;
for (lp = target_p->user->channel.head; lp; lp = lp->next)
+ {
+ chptr = lp->data;
+ chname = chptr->chname;
+
+ if (IsVchan(chptr))
{
- chptr = lp->data;
- chname = chptr->chname;
-
- if (IsVchan(chptr))
- {
- bchan = find_bchan (chptr);
- if (bchan != NULL)
- chname = bchan->chname;
- }
-
- if (ShowChannel(source_p, chptr))
- {
-
- if ((cur_len + strlen(chname) + 2) > (BUFSIZE - 4))
- {
- sendto_one(source_p, "%s", buf);
- cur_len = mlen;
- t = buf + mlen;
- }
-
- if (chptr->mode.mode & MODE_HIDEOPS && !is_any_op(chptr,source_p))
- {
- ircsprintf(t,"%s ",chname);
- }
- else
- {
- ircsprintf(t,"%s%s ", channel_chanop_or_voice(chptr,target_p),
- chname);
- }
+ bchan = find_bchan(chptr);
+ if (bchan != NULL)
+ chname = bchan->chname;
+ }
+
+ if (ShowChannel(source_p, chptr))
+ {
+
+ if ((cur_len + strlen(chname) + 2) > (BUFSIZE - 4))
+ {
+ sendto_one(source_p, "%s", buf);
+ cur_len = mlen;
+ t = buf + mlen;
+ }
+
+ if (chptr->mode.mode & MODE_HIDEOPS && !is_any_op(chptr, source_p))
+ {
+ ircsprintf(t, "%s ", chname);
+ }
+ else
+ {
+ ircsprintf(t, "%s%s ", channel_chanop_or_voice(chptr, target_p),
+ chname);
+ }
- tlen = strlen(t);
- t += tlen;
- cur_len += tlen;
- reply_to_send = YES;
+ tlen = strlen(t);
+ t += tlen;
+ cur_len += tlen;
+ reply_to_send = YES;
- }
}
+ }
if (reply_to_send)
sendto_one(source_p, "%s", buf);
-
- if ((IsOper(source_p) || !ConfigServerHide.hide_servers) || target_p == source_p)
- sendto_one(source_p, form_str(RPL_WHOISSERVER),
- me.name, source_p->name, target_p->name, server_name,
- a2client_p?a2client_p->info:"*Not On This Net*");
+
+ if ((IsOper(source_p) || !ConfigServerHide.hide_servers)
+ || target_p == source_p)
+ sendto_one(source_p, form_str(RPL_WHOISSERVER), me.name, source_p->name,
+ target_p->name, server_name,
+ a2client_p ? a2client_p->info : "*Not On This Net*");
else
sendto_one(source_p, form_str(RPL_WHOISSERVER),
- me.name, source_p->name, target_p->name,
- ServerInfo.network_name,
- ServerInfo.network_desc);
+ me.name, source_p->name, target_p->name,
+ ServerInfo.network_name, ServerInfo.network_desc);
if (target_p->user->away)
sendto_one(source_p, form_str(RPL_AWAY), me.name,
- source_p->name, target_p->name, target_p->user->away);
+ source_p->name, target_p->name, target_p->user->away);
if (IsOper(target_p))
- {
- sendto_one(source_p, form_str(RPL_WHOISOPERATOR),
- me.name, source_p->name, target_p->name);
+ {
+ sendto_one(source_p, form_str(RPL_WHOISOPERATOR),
+ me.name, source_p->name, target_p->name);
- if (IsAdmin(target_p))
- sendto_one(source_p, form_str(RPL_WHOISADMIN),
- me.name, source_p->name, target_p->name);
- }
+ if (IsAdmin(target_p))
+ sendto_one(source_p, form_str(RPL_WHOISADMIN),
+ me.name, source_p->name, target_p->name);
+ }
- if ( (glob == 1) || (MyConnect(target_p) && (IsOper(source_p) ||
- !ConfigServerHide.hide_servers)) || (target_p == source_p) )
- {
- sendto_one(source_p, form_str(RPL_WHOISIDLE),
- me.name, source_p->name, target_p->name,
- CurrentTime - target_p->user->last,
- target_p->firsttime);
- }
+ if ((glob == 1) || (MyConnect(target_p) && (IsOper(source_p) ||
+ !ConfigServerHide.hide_servers))
+ || (target_p == source_p))
+ {
+ sendto_one(source_p, form_str(RPL_WHOISIDLE),
+ me.name, source_p->name, target_p->name,
+ CurrentTime - target_p->user->last, target_p->firsttime);
+ }
hd.client_p = target_p;
hd.source_p = source_p;
/* although we should fill in parc and parv, we don't ..
be careful of this when writing whois hooks */
- if(MyClient(source_p))
+ if (MyClient(source_p))
hook_call_event("doing_whois", &hd);
-
+
return;
}
* that can happen, and as people might not understand the code, I
* stuck heavy comments in it.. it looks ugly.. but at least you
* know what it does.. --fl_ */
-static void ms_whois(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+ms_whois(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
/* its a misconfigured server */
if (parc < 2)
- {
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
+ return;
+ }
/* its a client doing a remote whois:
* :parv[0] WHOIS parv[1] :parv[2]
* parv[1] == server to reply to the request
* parv[2] == the client we are whois'ing
*/
- if(parc > 2)
+ if (parc > 2)
{
struct Client *target_p;
-
+
/* check if parv[1] is a client.. (most common) */
- if((target_p = find_client(parv[1])) == NULL)
+ if ((target_p = find_client(parv[1])) == NULL)
{
/* ok, parv[1] isnt a client, is it a server? */
- if((target_p = find_server(parv[1])) == NULL)
+ if ((target_p = find_server(parv[1])) == NULL)
{
/* its not a server either.. theyve sent a bad whois */
sendto_one(source_p, form_str(ERR_NOSUCHSERVER), me.name,
- parv[0], parv[1]);
+ parv[0], parv[1]);
return;
}
}
/* if parv[1] isnt my client, or me, someone else is supposed
* to be handling the request.. so send it to them
*/
- if(!MyClient(target_p) && !IsMe(target_p))
+ if (!MyClient(target_p) && !IsMe(target_p))
{
/* we're being asked to forward a whois request to a LL to answer,
* if the target isnt on that server.. answer it for them, as the
* LL might not know that the target exists..
*/
- if(MyConnect(target_p) && ServerInfo.hub &&
- IsCapable(target_p, CAP_LL))
+ if (MyConnect(target_p) && ServerInfo.hub &&
+ IsCapable(target_p, CAP_LL))
{
struct Client *whois_p;
/* try to find the client */
- whois_p = find_client(parv[2]);
- if (whois_p)
- {
- /* check the server being asked to perform the whois, is that
- * clients uplink */
- if(whois_p->servptr != target_p)
- {
- /* they asked the LL for info on a client it didnt know about..
- * as we're answering for them, make sure its non-detailed
- */
- parv[1] = parv[2];
- parc = 2;
-
+ whois_p = find_client(parv[2]);
+ if (whois_p)
+ {
+ /* check the server being asked to perform the whois, is that
+ * clients uplink */
+ if (whois_p->servptr != target_p)
+ {
+ /* they asked the LL for info on a client it didnt know about..
+ * as we're answering for them, make sure its non-detailed
+ */
+ parv[1] = parv[2];
+ parc = 2;
+
do_whois(client_p, source_p, parc, parv);
- return;
- }
-
- /* the server is that clients uplink, get them to do it */
- else
- {
- client_burst_if_needed(target_p->from, source_p);
- sendto_one(target_p->from, ":%s WHOIS %s :%s", parv[0], parv[1],
- parv[2]);
return;
}
- }
-
- /* the client doesnt exist.. erk! */
- else
- {
- /* set parv[1] = parv[2], then let do_whois handle the error */
- parv[1] = parv[2];
- do_whois(client_p, source_p, parc, parv);
- return;
- }
+
+ /* the server is that clients uplink, get them to do it */
+ else
+ {
+ client_burst_if_needed(target_p->from, source_p);
+ sendto_one(target_p->from, ":%s WHOIS %s :%s", parv[0], parv[1],
+ parv[2]);
+ return;
+ }
+ }
+
+ /* the client doesnt exist.. erk! */
+ else
+ {
+ /* set parv[1] = parv[2], then let do_whois handle the error */
+ parv[1] = parv[2];
+ do_whois(client_p, source_p, parc, parv);
+ return;
+ }
}
/* its not a lazylink.. forward it as it is */
else
{
/* client_burst_if_needed(target_p->from, source_p);
- * the target isnt a LL.. why would I need to burst? */
+ * the target isnt a LL.. why would I need to burst? */
sendto_one(target_p->from, ":%s WHOIS %s :%s", parv[0], parv[1],
parv[2]);
- return;
+ return;
}
}
- /* ok, the target is either us, or a client on our server, so perform the whois
- * but first, parv[1] == server to perform the whois on, parv[2] == person
- * to whois, so make parv[1] = parv[2] so do_whois is ok -- fl_
- */
+ /* ok, the target is either us, or a client on our server, so perform the whois
+ * but first, parv[1] == server to perform the whois on, parv[2] == person
+ * to whois, so make parv[1] = parv[2] so do_whois is ok -- fl_
+ */
parv[1] = parv[2];
- do_whois(client_p,source_p,parc,parv);
+ do_whois(client_p, source_p, parc, parv);
return;
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
-* $Id: m_whowas.c,v 1.1 2002/01/04 09:13:35 a1kmm Exp $
+* $Id: m_whowas.c,v 1.2 2002/01/04 11:06:20 a1kmm Exp $
*/
#include "whowas.h"
#include "handlers.h"
#include <string.h>
#include <stdlib.h>
-static void m_whowas(struct Client*, struct Client*, int, char**);
-static void mo_whowas(struct Client*, struct Client*, int, char**);
+static void m_whowas(struct Client *, struct Client *, int, char **);
+static void mo_whowas(struct Client *, struct Client *, int, char **);
struct Message whowas_msgtab = {
"WHOWAS", 0, 0, 0, 0, MFLG_SLOW, 0L,
{
mod_del_cmd(&whowas_msgtab);
}
-char *_version = "$Revision: 1.1 $";
+
+char *_version = "$Revision: 1.2 $";
#endif
static int whowas_do(struct Client *client_p, struct Client *source_p,
int parc, char *parv[]);
** parv[0] = sender prefix
** parv[1] = nickname queried
*/
-static void m_whowas(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+m_whowas(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
- static time_t last_used=0L;
+ static time_t last_used = 0L;
if (parc < 2)
- {
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, parv[0]);
- return;
- }
-
- if((last_used + ConfigFileEntry.whois_wait) > CurrentTime)
- {
- sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,source_p->name);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
+ return;
+ }
+
+ if ((last_used + ConfigFileEntry.whois_wait) > CurrentTime)
+ {
+ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name);
+ return;
+ }
else
- {
- last_used = CurrentTime;
- }
+ {
+ last_used = CurrentTime;
+ }
- whowas_do(client_p,source_p,parc,parv);
+ whowas_do(client_p, source_p, parc, parv);
}
-static void mo_whowas(struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+mo_whowas(struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
if (parc < 2)
- {
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, parv[0]);
- return;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
+ return;
+ }
- whowas_do(client_p,source_p,parc,parv);
+ whowas_do(client_p, source_p, parc, parv);
}
-static int whowas_do(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+static int
+whowas_do(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
struct Whowas *temp;
int cur = 0;
- int max = -1, found = 0;
- char *p, *nick;
+ int max = -1, found = 0;
+ char *p, *nick;
if (parc < 2)
- {
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, parv[0]);
- return 0;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]);
+ return 0;
+ }
if (parc > 2)
max = atoi(parv[2]);
if (parc > 3)
- if (hunt_server(client_p,source_p,":%s WHOWAS %s %s :%s", 3,parc,parv))
+ if (hunt_server
+ (client_p, source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv))
return 0;
- if((p = strchr(parv[1],',')))
- *p = '\0';
+ if ((p = strchr(parv[1], ',')))
+ *p = '\0';
nick = parv[1];
temp = WHOWASHASH[hash_whowas_name(nick)];
found = 0;
- for(;temp;temp=temp->next)
+ for (; temp; temp = temp->next)
+ {
+ if (!irccmp(nick, temp->name))
{
- if (!irccmp(nick, temp->name))
- {
- sendto_one(source_p, form_str(RPL_WHOWASUSER),
- me.name, parv[0], temp->name,
- temp->username,
- temp->hostname,
- temp->realname);
-
- if (ConfigServerHide.hide_servers && !IsOper(source_p))
- sendto_one(source_p, form_str(RPL_WHOISSERVER),
- me.name, parv[0], temp->name,
- ServerInfo.network_name, myctime(temp->logoff));
- else
- sendto_one(source_p, form_str(RPL_WHOISSERVER),
- me.name, parv[0], temp->name,
- temp->servername, myctime(temp->logoff));
- cur++;
- found++;
- }
- if (max > 0 && cur >= max)
- break;
+ sendto_one(source_p, form_str(RPL_WHOWASUSER),
+ me.name, parv[0], temp->name,
+ temp->username, temp->hostname, temp->realname);
+
+ if (ConfigServerHide.hide_servers && !IsOper(source_p))
+ sendto_one(source_p, form_str(RPL_WHOISSERVER),
+ me.name, parv[0], temp->name,
+ ServerInfo.network_name, myctime(temp->logoff));
+ else
+ sendto_one(source_p, form_str(RPL_WHOISSERVER),
+ me.name, parv[0], temp->name,
+ temp->servername, myctime(temp->logoff));
+ cur++;
+ found++;
}
+ if (max > 0 && cur >= max)
+ break;
+ }
if (!found)
- sendto_one(source_p, form_str(ERR_WASNOSUCHNICK),
- me.name, parv[0], nick);
+ sendto_one(source_p, form_str(ERR_WASNOSUCHNICK), me.name, parv[0], nick);
sendto_one(source_p, form_str(RPL_ENDOFWHOWAS), me.name, parv[0], parv[1]);
return 0;
/*
- * $Id: adns.c,v 1.1 2002/01/04 09:13:41 a1kmm Exp $
+ * $Id: adns.c,v 1.2 2002/01/04 11:06:38 a1kmm Exp $
* adns.c functions to enter libadns
*
* Written by Aaron Sethman <androsyn@ratbox.org>
* Output: None
* Side effects: Sends a list of DNS servers to source_p
*/
-void report_adns_servers(struct Client *source_p)
+void
+report_adns_servers(struct Client *source_p)
{
- int x;
- char buf[16]; /* XXX: adns only deals with ipv4 dns servers so this is okay */
- for(x = 0; x < dns_state->nservers; x++)
- {
- inetntop(AF_INET, &dns_state->servers[x].addr.s_addr, buf, 16);
- sendto_one(source_p, form_str(RPL_STATSALINE), me.name, source_p->name, buf);
- }
+ int x;
+ char buf[16]; /* XXX: adns only deals with ipv4 dns servers so this is okay */
+ for (x = 0; x < dns_state->nservers; x++)
+ {
+ inetntop(AF_INET, &dns_state->servers[x].addr.s_addr, buf, 16);
+ sendto_one(source_p, form_str(RPL_STATSALINE), me.name, source_p->name,
+ buf);
+ }
}
/* void delete_adns_queries(struct DNSQuery *q)
* Output: None
* Side effects: Cancels a DNS query.
*/
-void delete_adns_queries(struct DNSQuery *q)
+void
+delete_adns_queries(struct DNSQuery *q)
{
- if (q != NULL && q->query != NULL)
- adns_cancel(q->query);
-}
+ if (q != NULL && q->query != NULL)
+ adns_cancel(q->query);
+}
/* void restart_resolver(void)
* Input: None
* Output: None
* Side effects: Tears down any old ADNS sockets..reloads the conf
*/
-void restart_resolver(void)
+void
+restart_resolver(void)
{
dns_cancel_all();
adns_finish(dns_state);
* Side effects: Reads the ADNS configuration and sets up the ADNS server
* polling and query timeouts.
*/
-void init_resolver(void)
+void
+init_resolver(void)
{
- int r;
+ int r;
- r =adns_init(&dns_state, adns_if_noautosys, 0);
- if(dns_state == NULL) {
- ilog(L_CRIT, "Error opening /etc/resolv.conf: %s; r = %d", strerror(errno), r);
- exit(76);
- }
- eventAdd("timeout_adns", timeout_adns, NULL, 2);
- dns_select();
+ r = adns_init(&dns_state, adns_if_noautosys, 0);
+ if (dns_state == NULL)
+ {
+ ilog(L_CRIT, "Error opening /etc/resolv.conf: %s; r = %d",
+ strerror(errno), r);
+ exit(76);
+ }
+ eventAdd("timeout_adns", timeout_adns, NULL, 2);
+ dns_select();
}
/* void timeout_adns(void *ptr);
* Side effects: Cancel any old(expired) DNS queries.
* Note: Called by the event code.
*/
-void timeout_adns(void *ptr)
+void
+timeout_adns(void *ptr)
{
- adns_processtimeouts(dns_state, &SystemTime);
+ adns_processtimeouts(dns_state, &SystemTime);
}
/* void dns_writeable(int fd, void *ptr)
* Side effects: Write any queued buffers out.
* Note: Called by the fd system.
*/
-void dns_writeable(int fd, void *ptr)
+void
+dns_writeable(int fd, void *ptr)
{
- adns_processwriteable(dns_state, fd, &SystemTime);
- dns_select();
+ adns_processwriteable(dns_state, fd, &SystemTime);
+ dns_select();
}
/*
* Output: None.
* Side effects: Cancels all pending DNS requests
*/
-
-static void dns_cancel_all(void)
+
+static void
+dns_cancel_all(void)
{
- adns_query q, r;
- adns_answer *answer;
- struct DNSQuery *query;
- adns_forallqueries_begin(dns_state);
- while((q = adns_forallqueries_next(dns_state, (void **)&r)) != NULL)
- {
- adns_cancel(q);
- adns__query_done(q);
- adns_check(dns_state, &q, &answer, (void **)&query);
- assert(query->callback != NULL);
- query->query = NULL;
- query->callback(query->ptr, NULL);
- }
+ adns_query q, r;
+ adns_answer *answer;
+ struct DNSQuery *query;
+ adns_forallqueries_begin(dns_state);
+ while ((q = adns_forallqueries_next(dns_state, (void **)&r)) != NULL)
+ {
+ adns_cancel(q);
+ adns__query_done(q);
+ adns_check(dns_state, &q, &answer, (void **)&query);
+ assert(query->callback != NULL);
+ query->query = NULL;
+ query->callback(query->ptr, NULL);
+ }
}
/* void dns_do_callbacks(void)
* Side effects: Call all the callbacks(into the ircd core) for the
* results of a DNS resolution.
*/
-void dns_do_callbacks(void)
+void
+dns_do_callbacks(void)
{
- adns_query q, r;
- adns_answer *answer;
- struct DNSQuery *query;
- adns_forallqueries_begin(dns_state);
- while((q = adns_forallqueries_next(dns_state, (void **)&r)) != NULL)
- {
- switch(adns_check(dns_state, &q, &answer, (void **)&query)) {
- case 0:
- /* Looks like we got a winner */
- assert(query->callback != NULL);
- query->query = NULL;
- query->callback(query->ptr, answer);
- break;
- case EAGAIN:
- /* Go into the queue again */
- break;
- default:
- assert(query->callback != NULL);
- /* Awww we failed, what a shame */
- query->query = NULL;
- query->callback(query->ptr, NULL);
- break;
- }
- }
+ adns_query q, r;
+ adns_answer *answer;
+ struct DNSQuery *query;
+ adns_forallqueries_begin(dns_state);
+ while ((q = adns_forallqueries_next(dns_state, (void **)&r)) != NULL)
+ {
+ switch (adns_check(dns_state, &q, &answer, (void **)&query))
+ {
+ case 0:
+ /* Looks like we got a winner */
+ assert(query->callback != NULL);
+ query->query = NULL;
+ query->callback(query->ptr, answer);
+ break;
+ case EAGAIN:
+ /* Go into the queue again */
+ break;
+ default:
+ assert(query->callback != NULL);
+ /* Awww we failed, what a shame */
+ query->query = NULL;
+ query->callback(query->ptr, NULL);
+ break;
+ }
+ }
}
/* void dns_readable(int fd, void *ptr)
* Side effects: Read DNS responses from DNS servers.
* Note: Called by the fd system.
*/
-void dns_readable(int fd, void *ptr)
+void
+dns_readable(int fd, void *ptr)
{
- adns_processreadable(dns_state, fd, &SystemTime);
- dns_do_callbacks();
- dns_select();
+ adns_processreadable(dns_state, fd, &SystemTime);
+ dns_do_callbacks();
+ dns_select();
}
/* void dns_select(void)
* Side effects: Re-register ADNS fds with the fd system. Also calls the
* callbacks into core ircd.
*/
-void dns_select(void)
+void
+dns_select(void)
{
- struct adns_pollfd pollfds[MAXFD_POLL];
- int npollfds, i, fd;
- adns__consistency(dns_state,0,cc_entex);
- npollfds = adns__pollfds(dns_state, pollfds);
- for(i = 0; i < npollfds; i++)
- {
- fd = pollfds[i].fd;
- if (pollfds[i].events & ADNS_POLLIN)
- comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ, dns_readable, NULL, 0);
- if (pollfds[i].events & ADNS_POLLOUT)
- comm_setselect(fd, FDLIST_SERVICE, COMM_SELECT_WRITE, dns_writeable, NULL, 0);
- }
- /* Call our callbacks, now that they may have some relevant data...
- */
+ struct adns_pollfd pollfds[MAXFD_POLL];
+ int npollfds, i, fd;
+ adns__consistency(dns_state, 0, cc_entex);
+ npollfds = adns__pollfds(dns_state, pollfds);
+ for (i = 0; i < npollfds; i++)
+ {
+ fd = pollfds[i].fd;
+ if (pollfds[i].events & ADNS_POLLIN)
+ comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ, dns_readable, NULL,
+ 0);
+ if (pollfds[i].events & ADNS_POLLOUT)
+ comm_setselect(fd, FDLIST_SERVICE, COMM_SELECT_WRITE, dns_writeable,
+ NULL, 0);
+ }
+ /* Call our callbacks, now that they may have some relevant data...
+ */
/*
*dns_do_callbacks();
*/
* Side effects: Sets up a query structure and sends off a DNS query to
* the DNS server to resolve an "A"(address) entry by name.
*/
-void adns_gethost(const char *name, int aftype, struct DNSQuery *req)
+void
+adns_gethost(const char *name, int aftype, struct DNSQuery *req)
{
- assert(dns_state->nservers > 0);
-#ifdef IPV6
- if (aftype == AF_INET6)
- adns_submit(dns_state, name, adns_r_addr6, adns_qf_owner, req,
- &req->query);
- else
+ assert(dns_state->nservers > 0);
+#ifdef IPV6
+ if (aftype == AF_INET6)
+ adns_submit(dns_state, name, adns_r_addr6, adns_qf_owner, req,
+ &req->query);
+ else
#endif
- adns_submit(dns_state, name, adns_r_addr, adns_qf_owner, req,
- &req->query);
+ adns_submit(dns_state, name, adns_r_addr, adns_qf_owner, req,
+ &req->query);
}
* Side effects: Sets up a query entry and sends it to the DNS server to
* resolve an IP address to a domain name.
*/
-void adns_getaddr(struct irc_inaddr *addr, int aftype,
- struct DNSQuery *req)
+void
+adns_getaddr(struct irc_inaddr *addr, int aftype, struct DNSQuery *req)
{
- struct irc_sockaddr ipn;
- assert(dns_state->nservers > 0);
+ struct irc_sockaddr ipn;
+ assert(dns_state->nservers > 0);
#ifdef IPV6
- if (aftype == AF_INET6)
+ if (aftype == AF_INET6)
{
- ipn.sins.sin6.sin6_family = AF_INET6;
- ipn.sins.sin6.sin6_port = 0;
- memcpy(&ipn.sins.sin6.sin6_addr.s6_addr, &addr->sins.sin6.s6_addr,
- sizeof(struct in6_addr));
- adns_submit_reverse(dns_state, (struct sockaddr *)&ipn.sins.sin6,
- adns_r_ptr_ip6, adns_qf_owner|adns_qf_cname_loose|adns_qf_quoteok_anshost, req, &req->query);
- } else
+ ipn.sins.sin6.sin6_family = AF_INET6;
+ ipn.sins.sin6.sin6_port = 0;
+ memcpy(&ipn.sins.sin6.sin6_addr.s6_addr, &addr->sins.sin6.s6_addr,
+ sizeof(struct in6_addr));
+ adns_submit_reverse(dns_state, (struct sockaddr *)&ipn.sins.sin6,
+ adns_r_ptr_ip6,
+ adns_qf_owner | adns_qf_cname_loose |
+ adns_qf_quoteok_anshost, req, &req->query);
+ }
+ else
{
- ipn.sins.sin.sin_family = AF_INET;
- ipn.sins.sin.sin_port = 0;
- ipn.sins.sin.sin_addr.s_addr = addr->sins.sin.s_addr;
- adns_submit_reverse(dns_state, (struct sockaddr *)&ipn.sins.sin,
- adns_r_ptr, adns_qf_owner|adns_qf_cname_loose|adns_qf_quoteok_anshost, req, &req->query);
+ ipn.sins.sin.sin_family = AF_INET;
+ ipn.sins.sin.sin_port = 0;
+ ipn.sins.sin.sin_addr.s_addr = addr->sins.sin.s_addr;
+ adns_submit_reverse(dns_state, (struct sockaddr *)&ipn.sins.sin,
+ adns_r_ptr,
+ adns_qf_owner | adns_qf_cname_loose |
+ adns_qf_quoteok_anshost, req, &req->query);
}
#else
ipn.sins.sin.sin_family = AF_INET;
ipn.sins.sin.sin_port = 0;
ipn.sins.sin.sin_addr.s_addr = addr->sins.sin.s_addr;
adns_submit_reverse(dns_state, (struct sockaddr *)&ipn.sins.sin,
- adns_r_ptr, adns_qf_owner|adns_qf_cname_loose|adns_qf_quoteok_anshost, req, &req->query);
+ adns_r_ptr,
+ adns_qf_owner | adns_qf_cname_loose |
+ adns_qf_quoteok_anshost, req, &req->query);
#endif
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: balloc.c,v 1.2 2002/01/04 10:57:36 a1kmm Exp $
+ * $Id: balloc.c,v 1.3 2002/01/04 11:06:38 a1kmm Exp $
*/
/* A note on the algorithm:
struct BHBlock
{
- dlink_node blockn;
- int usedcount;
- /*
- pseudo-struct BHElement elements[elsperblock];
- */
+ dlink_node blockn;
+ int usedcount;
+ /*
+ pseudo-struct BHElement elements[elsperblock];
+ */
};
-void BlockHeapAddBlock(BlockHeap *bh);
+void BlockHeapAddBlock(BlockHeap * bh);
/* Called once to setup the blockheap code... */
void
initBlockHeap(void)
{
- /* The old block-heap did weird stuff with /dev/zero here which I think
- * we could and probably should avoid, and just use MyMalloc to get
- * blocks(it shouldn't happen too often anyway). -A1kmm */
+ /* The old block-heap did weird stuff with /dev/zero here which I think
+ * we could and probably should avoid, and just use MyMalloc to get
+ * blocks(it shouldn't happen too often anyway). -A1kmm */
}
/* Add a block to the blockheap... */
void
-BlockHeapAddBlock(BlockHeap *bh)
+BlockHeapAddBlock(BlockHeap * bh)
{
- char *d;
- int i;
- struct BHBlock *bhb = MyMalloc(bh->blocksize);
- dlinkAdd(bhb, &bhb->blockn, &bh->blocks);
- d = ((char*)bhb) + sizeof(struct BHBlock);
- bhb->usedcount = 0;
- /* On the front is the best because of memory caches/swap/paging. */
- for (i=0; i<bh->elsperblock; i++)
- {
- dlinkAdd(bhb,
- (dlink_node*)d, &bh->f_elements);
- d += sizeof(dlink_node) + bh->elsize;
- }
+ char *d;
+ int i;
+ struct BHBlock *bhb = MyMalloc(bh->blocksize);
+ dlinkAdd(bhb, &bhb->blockn, &bh->blocks);
+ d = ((char *)bhb) + sizeof(struct BHBlock);
+ bhb->usedcount = 0;
+ /* On the front is the best because of memory caches/swap/paging. */
+ for (i = 0; i < bh->elsperblock; i++)
+ {
+ dlinkAdd(bhb, (dlink_node *) d, &bh->f_elements);
+ d += sizeof(dlink_node) + bh->elsize;
+ }
}
/* Create a blockheap... */
-BlockHeap*
+BlockHeap *
BlockHeapCreate(int elsize, int elsperblock)
{
- BlockHeap *bh = MyMalloc(sizeof(*bh));
+ BlockHeap *bh = MyMalloc(sizeof(*bh));
#ifdef MEMDEBUG
- /* Squeeze in the memory header too... -A1kmm */
- elsize += sizeof(MemoryEntry);
+ /* Squeeze in the memory header too... -A1kmm */
+ elsize += sizeof(MemoryEntry);
#endif
- memset(bh, 0, 2*sizeof(dlink_list));
- bh->elsize = elsize;
- bh->elsperblock = elsperblock;
- bh->blocksize = elsperblock * (elsize + sizeof(dlink_node)) +
- sizeof(struct BHBlock);
- return bh;
+ memset(bh, 0, 2 * sizeof(dlink_list));
+ bh->elsize = elsize;
+ bh->elsperblock = elsperblock;
+ bh->blocksize = elsperblock * (elsize + sizeof(dlink_node)) +
+ sizeof(struct BHBlock);
+ return bh;
}
/* Allocate an element from the free pool, making new blocks if needed.
*/
-void*
-_BlockHeapAlloc(BlockHeap *bh)
+void *
+_BlockHeapAlloc(BlockHeap * bh)
{
- char *d;
- if (bh->f_elements.head == NULL)
- BlockHeapAddBlock(bh);
- d = (char*)(bh->f_elements.head + 1);
- ((struct BHBlock*)bh->f_elements.head->data)->usedcount++;
- bh->f_elements.head = bh->f_elements.head->next;
- if (bh->f_elements.head == NULL)
- bh->f_elements.tail = NULL;
- else
- bh->f_elements.head->prev = NULL;
- /* No need to "frob" when debugging here, it is done on initial
- * MyMalloc and after each free. -A1kmm */
- return d;
+ char *d;
+ if (bh->f_elements.head == NULL)
+ BlockHeapAddBlock(bh);
+ d = (char *)(bh->f_elements.head + 1);
+ ((struct BHBlock *)bh->f_elements.head->data)->usedcount++;
+ bh->f_elements.head = bh->f_elements.head->next;
+ if (bh->f_elements.head == NULL)
+ bh->f_elements.tail = NULL;
+ else
+ bh->f_elements.head->prev = NULL;
+ /* No need to "frob" when debugging here, it is done on initial
+ * MyMalloc and after each free. -A1kmm */
+ return d;
}
/* Release an element back into the pool... */
void
-_BlockHeapFree(BlockHeap *bh, void *el)
+_BlockHeapFree(BlockHeap * bh, void *el)
{
- dlink_node *dln = (el-sizeof(dlink_node));
+ dlink_node *dln = (el - sizeof(dlink_node));
#ifdef MEMDEBUG
- mem_frob(el, bh->elsize);
+ mem_frob(el, bh->elsize);
#endif
- ((struct BHBlock*)dln->data)->usedcount--;
- /* On the front is the best because of memory caches/swap/paging.
- * It also should make garbage collection work better... -A1kmm */
- dlinkAdd(dln->data, dln, &bh->f_elements);
+ ((struct BHBlock *)dln->data)->usedcount--;
+ /* On the front is the best because of memory caches/swap/paging.
+ * It also should make garbage collection work better... -A1kmm */
+ dlinkAdd(dln->data, dln, &bh->f_elements);
}
/* Destroy a blockheap... */
void
-BlockHeapDestroy(BlockHeap *bh)
+BlockHeapDestroy(BlockHeap * bh)
{
- struct BHBlock *bhb;
- for (bhb = (struct BHBlock*)bh->blocks.head; bhb;
- bhb = (struct BHBlock*)bhb->blockn.next)
- MyFree(bhb);
+ struct BHBlock *bhb;
+ for (bhb = (struct BHBlock *)bh->blocks.head; bhb;
+ bhb = (struct BHBlock *)bhb->blockn.next)
+ MyFree(bhb);
}
/* Destroy empty blocks. Note that this is slow because we put off all
* collector doesn't take 10s...
**/
void
-BlockHeapGarbageCollect(BlockHeap *bh)
+BlockHeapGarbageCollect(BlockHeap * bh)
{
- struct BHBlock *bhb, *bhbn;
- char *d;
- int i;
- for (bhb=(struct BHBlock*)bh->blocks.head; bhb; bhb=bhbn)
- {
- bhbn = (struct BHBlock*)bhb->blockn.next;
- if (bhb->usedcount != 0)
- continue;
- d = (char*)(bhb+1);
- for (i=0; i<bh->elsperblock; i++)
- {
- dlinkDelete((dlink_node*)d, &bh->f_elements);
- d += sizeof(dlink_node) + bh->elsize;
- }
- dlinkDelete(&bhb->blockn, &bh->blocks);
- MyFree(bhb);
- }
+ struct BHBlock *bhb, *bhbn;
+ char *d;
+ int i;
+ for (bhb = (struct BHBlock *)bh->blocks.head; bhb; bhb = bhbn)
+ {
+ bhbn = (struct BHBlock *)bhb->blockn.next;
+ if (bhb->usedcount != 0)
+ continue;
+ d = (char *)(bhb + 1);
+ for (i = 0; i < bh->elsperblock; i++)
+ {
+ dlinkDelete((dlink_node *) d, &bh->f_elements);
+ d += sizeof(dlink_node) + bh->elsize;
+ }
+ dlinkDelete(&bhb->blockn, &bh->blocks);
+ MyFree(bhb);
+ }
}
#endif
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: channel.c,v 1.1 2002/01/04 09:13:43 a1kmm Exp $
+ * $Id: channel.c,v 1.2 2002/01/04 11:06:38 a1kmm Exp $
*/
#include "tools.h"
#include "channel.h"
static void delete_members(struct Channel *chptr, dlink_list * list);
static void send_mode_list(struct Client *client_p, char *chname,
- dlink_list *top, char flag, int clear);
+ dlink_list * top, char flag, int clear);
static int check_banned(struct Channel *chptr, struct Client *who,
- char *s, char *s2);
+ char *s, char *s2);
static char buf[BUFSIZE];
static char modebuf[MODEBUFLEN], parabuf[MODEBUFLEN];
*
* Initializes the channel blockheap
*/
-static void channelheap_garbage_collect(void *unused)
+static void
+channelheap_garbage_collect(void *unused)
{
BlockHeapGarbageCollect(channel_heap);
BlockHeapGarbageCollect(ban_heap);
}
-void init_channels(void)
+void
+init_channels(void)
{
channel_heap = BlockHeapCreate(sizeof(struct Channel), 1024);
ban_heap = BlockHeapCreate(sizeof(struct Ban), 2048);
send_members(client_p, modebuf, parabuf, chptr, &chptr->chanops, "@");
#ifdef REQUIRE_OANDV
- send_members(client_p, modebuf, parabuf, chptr, &chptr->chanops_voiced, "@+");
+ send_members(client_p, modebuf, parabuf, chptr, &chptr->chanops_voiced,
+ "@+");
#endif
if (IsCapable(client_p, CAP_HOPS))
* It should never happen but...
*/
/* persistent channel */
- if (perm == 0 || (chptr->channelts + ConfigChannel.persist_time) > CurrentTime)
+ if (perm == 0
+ || (chptr->channelts + ConfigChannel.persist_time) > CurrentTime)
destroy_channel(chptr);
}
}
}
else
{
- if(chptr->users == 0)
+ if (chptr->users == 0)
{
- if((chptr->channelts + ConfigChannel.persist_time) > CurrentTime)
- {
- if(uplink && IsCapable(uplink, CAP_LL))
- sendto_one(uplink, ":%s DROP %s", me.name, chptr->chname);
- destroy_channel(chptr);
- }
+ if ((chptr->channelts + ConfigChannel.persist_time) > CurrentTime)
+ {
+ if (uplink && IsCapable(uplink, CAP_LL))
+ sendto_one(uplink, ":%s DROP %s", me.name, chptr->chname);
+ destroy_channel(chptr);
+ }
}
else
{
if ((CurrentTime - chptr->users_last >= CLEANUP_CHANNELS_TIME))
{
- if (uplink
- && IsCapable(uplink, CAP_LL) && (chptr->locusers == 0))
+ if (uplink && IsCapable(uplink, CAP_LL) && (chptr->locusers == 0))
{
sendto_one(uplink, ":%s DROP %s", me.name, chptr->chname);
destroy_channel(chptr);
if (!IsPerson(who))
return (0);
- ircsprintf(src_host,"%s!%s@%s", who->name, who->username, who->host);
- ircsprintf(src_iphost,"%s!%s@%s", who->name, who->username,
- who->localClient->sockhost);
+ ircsprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
+ ircsprintf(src_iphost, "%s!%s@%s", who->name, who->username,
+ who->localClient->sockhost);
return (check_banned(chptr, who, src_host, src_iphost));
}
assert(source_p->localClient != NULL);
ircsprintf(src_host,
- "%s!%s@%s", source_p->name, source_p->username, source_p->host);
- ircsprintf(src_iphost,"%s!%s@%s", source_p->name, source_p->username,
- source_p->localClient->sockhost);
+ "%s!%s@%s", source_p->name, source_p->username, source_p->host);
+ ircsprintf(src_iphost, "%s!%s@%s", source_p->name, source_p->username,
+ source_p->localClient->sockhost);
if ((check_banned(chptr, source_p, src_host, src_iphost)) == CHFL_BAN)
return (ERR_BANNEDFROMCHAN);
for (ptr = chptr->invexlist.head; ptr; ptr = ptr->next)
{
invex = ptr->data;
- if (match(invex->banstr, src_host) || match(invex->banstr, src_iphost))
+ if (match(invex->banstr, src_host)
+ || match(invex->banstr, src_iphost))
break;
}
if (ptr == NULL)
int
can_send(struct Channel *chptr, struct Client *source_p)
{
- if(MyClient(source_p) && find_channel_resv(chptr->chname))
+ if (MyClient(source_p) && find_channel_resv(chptr->chname))
return CAN_SEND_NO;
-
+
if (is_any_op(chptr, source_p))
return CAN_SEND_OPV;
if (is_voiced(chptr, source_p))
* side effects - compares usercount and servercount against their split
* values and adjusts splitmode accordingly
*/
-void check_splitmode()
+void
+check_splitmode()
{
- if(splitmode)
+ if (splitmode)
{
- if((Count.server >= split_servers) &&
- (Count.total >= split_users))
+ if ((Count.server >= split_servers) && (Count.total >= split_users))
{
splitmode = 0;
-
+
sendto_realops_flags(FLAGS_ALL, L_ALL,
"Network rejoined, deactivating splitmode");
eventDelete(check_splitmode, NULL);
}
else
{
- if((Count.server < split_servers) &&
- (Count.total < split_users))
+ if ((Count.server < split_servers) && (Count.total < split_users))
{
splitmode = 1;
- sendto_realops_flags(FLAGS_ALL,L_ALL,
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
"Network split, activating splitmode");
eventAdd("check_splitmode", check_splitmode, NULL, 60);
}
}
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: channel_mode.c,v 1.1 2002/01/04 09:13:52 a1kmm Exp $
+ * $Id: channel_mode.c,v 1.2 2002/01/04 11:06:39 a1kmm Exp $
*/
#include "tools.h"
#include "channel.h"
char *, int);
static int change_channel_membership(struct Channel *chptr,
- dlink_list *to_list,
- dlink_list *loc_to_list,
+ dlink_list * to_list,
+ dlink_list * loc_to_list,
struct Client *who);
/* some small utility functions */
int old_mask_pos;
char *nick = "*", *user = "*", *host = "*";
char *t, *at, *ex;
- char ne = 0, ue = 0, he = 0; /* save values at nick[NICKLEN], et all */
+ char ne = 0, ue = 0, he = 0; /* save values at nick[NICKLEN], et all */
mask = check_string(mask);
if (BUFSIZE - mask_pos < strlen(mask) + 5)
he = host[HOSTLEN];
host[HOSTLEN] = '\0';
}
-
+
mask_pos += ircsprintf(mask_buf + mask_pos, "%s!%s@%s", nick, user, host)
+ 1;
y |= channel_capabs[c];
}
chcap_combos[m].cap_yes = y;
- chcap_combos[m].cap_no = n;
+ chcap_combos[m].cap_no = n;
}
}
int i;
mode_type = (long)d;
-
+
/* dont allow halfops to set +-p, as this controls whether they can set
* +-h or not.. all other simple modes are ok
*/
- if((alev < CHACCESS_HALFOP) ||
- ((mode_type == MODE_PRIVATE) && (alev < CHACCESS_CHANOP)))
+ if ((alev < CHACCESS_HALFOP) ||
+ ((mode_type == MODE_PRIVATE) && (alev < CHACCESS_CHANOP)))
{
if (!(*errors & SM_ERR_NOOPS))
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name,
else if ((dir == MODE_DEL) && (chptr->mode.mode & MODE_HIDEOPS))
{
chptr->mode.mode &= ~MODE_HIDEOPS;
-
+
for (i = 0; i < mode_count_plus; i++)
{
if (mode_changes_plus[i].letter == c)
return;
raw_mask = parv[(*parn)++];
-
+
if (IsServer(client_p))
mask = raw_mask;
else
mask = pretty_mask(raw_mask);
-
+
/* Cant do this - older servers dont.. it WILL cause a desync, but should
* be limited by our input buffer anyway --fl_
*
/* will cause a desync, cant be done */
#if 0
- if (strlen(mask) > NICKLEN+USERLEN+HOSTLEN)
+ if (strlen(mask) > NICKLEN + USERLEN + HOSTLEN)
return;
-#endif
+#endif
/* If we're adding a NEW id */
if ((dir == MODE_ADD) && add_id(source_p, chptr, mask, CHFL_EXCEPTION) == 0)
mask = pretty_mask(raw_mask);
/* will cause a desync, cant be done */
-#if 0
- if (strlen(mask) > NICKLEN+USERLEN+HOSTLEN)
+#if 0
+ if (strlen(mask) > NICKLEN + USERLEN + HOSTLEN)
return;
-#endif
+#endif
if ((dir == MODE_ADD) && add_id(source_p, chptr, mask, CHFL_INVEX) == 0)
{
#endif
t_voice = is_voiced(chptr, targ_p);
- if (((dir == MODE_ADD) && t_op) ||
- ((dir == MODE_DEL) && !t_op))
+ if (((dir == MODE_ADD) && t_op) || ((dir == MODE_DEL) && !t_op))
return;
if (MyClient(source_p) && (mode_limit++ > 4))
#ifndef REQUIRE_OANDV
|| mode_changes_plus[i].letter == 'v'
#endif
- )
- && !irccmp(mode_changes_plus[i].arg, opnick))
+ ) && !irccmp(mode_changes_plus[i].arg, opnick))
{
if (mode_changes_plus[i].letter == 'o')
wasnt_opped = 1;
#ifndef REQUIRE_OANDV
|| mode_changes_minus[i].letter == 'v'
#endif
- )
- && !irccmp(mode_changes_minus[i].arg, opnick))
+ ) && !irccmp(mode_changes_minus[i].arg, opnick))
{
if (mode_changes_minus[i].letter == 'o')
{
- mode_changes_minus[i].letter = 0; /* clear the mode */
+ mode_changes_minus[i].letter = 0; /* clear the mode */
was_opped = 1;
}
else if (mode_changes_minus[i].letter == 'v')
if (resync_ops[i].client_p == targ_p)
resync_ops[i].client_p = NULL;
}
- if (!wasnt_opped && MyClient(targ_p) &&
- chptr->mode.mode & MODE_HIDEOPS)
+ if (!wasnt_opped && MyClient(targ_p) && chptr->mode.mode & MODE_HIDEOPS)
{
resync_ops[resync_count].client_p = targ_p;
resync_ops[resync_count].dir = dir;
* control whether they can (de)halfop...
*/
if (alev <
- ((chptr->mode.mode & MODE_PRIVATE) ?
- CHACCESS_CHANOP : CHACCESS_HALFOP))
+ ((chptr->mode.mode & MODE_PRIVATE) ? CHACCESS_CHANOP : CHACCESS_HALFOP))
{
if (!(*errors & SM_ERR_NOOPS))
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name,
return;
}
- if (((dir == MODE_ADD) && (t_hop || t_op)) ||
- ((dir == MODE_DEL) && !t_hop))
+ if (((dir == MODE_ADD) && (t_hop || t_op)) || ((dir == MODE_DEL) && !t_hop))
return;
#ifdef BOUNCE_BAD_HOPS
resync_ops[resync_count++].sync = was_opped ? 0 : 1;
}
}
- else
- { /* MODE_DEL */
+ else
+ { /* MODE_DEL */
if (wasnt_hopped == 0)
{
mode_changes_minus[mode_count_minus].letter = 'h';
if (resync_ops[i].client_p == targ_p)
resync_ops[i].client_p = NULL;
}
- if (!wasnt_hopped && MyClient(targ_p) &&
- chptr->mode.mode & MODE_HIDEOPS)
+ if (!wasnt_hopped && MyClient(targ_p) && chptr->mode.mode & MODE_HIDEOPS)
{
resync_ops[resync_count].client_p = targ_p;
resync_ops[resync_count].dir = dir;
if (
#ifndef REQUIRE_OANDV
- t_op ||
+ t_op ||
#endif
- t_hop ||
- (dir == MODE_ADD && t_voice) ||
- (dir == MODE_DEL && !t_voice))
+ t_hop || (dir == MODE_ADD && t_voice) || (dir == MODE_DEL && !t_voice))
return;
/* Remove other changes... */
{
#ifdef REQUIRE_OANDV
if (t_op)
- change_channel_membership(chptr, &chptr->chanops,&chptr->locchanops,
+ change_channel_membership(chptr, &chptr->chanops, &chptr->locchanops,
targ_p);
else
#endif
struct ChannelMode
{
- void (*func) (struct Client *client_p, struct Client *source_p,
- struct Channel *chptr, int parc, int *parn, char **parv,
+ void (*func) (struct Client * client_p, struct Client * source_p,
+ struct Channel * chptr, int parc, int *parn, char **parv,
int *errors, int alev, int dir, char c, void *d,
const char *chname);
void *d;
* MODE_PEON for peon level access.
* Side-effects: None.
*/
- static int
+static int
get_channel_access(struct Client *source_p, struct Channel *chptr)
{
/* Let hacked servers in for now... */
nc = 0;
pbl = 0;
parabuf[0] = 0;
- if ((cap & CAP_UID) && source_p->user &&
- (source_p->user->id[0] == '.'))
+ if ((cap & CAP_UID) && source_p->user && (source_p->user->id[0] == '.'))
mbl = ircsprintf(modebuf, ":%s MODE %s ", source_p->user->id,
chptr->chname);
else
- mbl = ircsprintf(modebuf, ":%s MODE %s ", source_p->name,
- chptr->chname);
+ mbl = ircsprintf(modebuf, ":%s MODE %s ", source_p->name, chptr->chname);
if (mode_count_minus > 0)
{
* which even then won't work as we don't always know the uid -A1kmm.
*/
if ((arg != NULL) && ((mc == MAXMODEPARAMS) ||
- ((strlen(arg) + mbl + pbl + 2) > BUFSIZE)))
+ ((strlen(arg) + mbl + pbl + 2) > BUFSIZE)))
{
if (nc != 0)
sendto_server(client_p, source_p, chptr, cap, nocap,
LL_ICHAN | LL_ICLIENT, "%s %s", modebuf, parabuf);
nc = 0;
mc = 0;
- if ((cap & CAP_UID) && source_p->user &&
- (source_p->user->id[0] == '.'))
+ if ((cap & CAP_UID) && source_p->user && (source_p->user->id[0] == '.'))
mbl = ircsprintf(modebuf, ":%s MODE %s -", source_p->user->id,
chptr->chname);
else
arg = mode_changes_plus[i].id;
nc++;
- if ((arg != NULL) && ((mc == MAXMODEPARAMS) ||
+ if ((arg != NULL) && ((mc == MAXMODEPARAMS) ||
((strlen(arg) + mbl + pbl + 2) > BUFSIZE)))
{
if (mbl && modebuf[mbl - 1] == '+')
LL_ICLIENT, "%s %s", modebuf, parabuf);
nc = 0;
mc = 0;
- if ((cap & CAP_UID) && source_p->user &&
- (source_p->user->id[0] == '.'))
+ if ((cap & CAP_UID) && source_p->user && (source_p->user->id[0] == '.'))
mbl = ircsprintf(modebuf, ":%s MODE %s +", source_p->user->id,
chptr->chname);
else
/* bail out if we have nothing to do... */
if (!(mode_count_plus || mode_count_minus || bounce_count || resync_count))
return;
-
+
/* Send any resyncs that we need to send... */
/* XXX - setting -a removes hideops, yet still needs a resync.. */
- for (i = 0; i < resync_count; i++)
+ for (i = 0; i < resync_count; i++)
+ {
+ if (resync_ops[i].client_p == NULL)
{
- if (resync_ops[i].client_p == NULL)
- {
- if (resync_ops[i].whole_chan)
- sync_channel_oplists(chptr, resync_ops[i].dir);
- else
- continue;
- }
- if (resync_ops[i].sync)
- {
- sync_oplists(chptr, resync_ops[i].client_p,
- resync_ops[i].dir, chname);
- }
- if (resync_ops[i].dir == MODE_ADD && resync_ops[i].c == 'v')
- sendto_one(resync_ops[i].client_p, ":%s MODE %s +v %s", me.name,
- chname, resync_ops[i].client_p->name);
- else if (resync_ops[i].send)
- sendto_one(resync_ops[i].client_p, ":%s MODE %s -%c %s", me.name,
- chname, resync_ops[i].c, resync_ops[i].client_p->name);
+ if (resync_ops[i].whole_chan)
+ sync_channel_oplists(chptr, resync_ops[i].dir);
+ else
+ continue;
}
+ if (resync_ops[i].sync)
+ {
+ sync_oplists(chptr, resync_ops[i].client_p, resync_ops[i].dir, chname);
+ }
+ if (resync_ops[i].dir == MODE_ADD && resync_ops[i].c == 'v')
+ sendto_one(resync_ops[i].client_p, ":%s MODE %s +v %s", me.name,
+ chname, resync_ops[i].client_p->name);
+ else if (resync_ops[i].send)
+ sendto_one(resync_ops[i].client_p, ":%s MODE %s -%c %s", me.name,
+ chname, resync_ops[i].c, resync_ops[i].client_p->name);
+ }
/* Send all mode changes to the chanops/halfops, and even peons if
* we are not +a...
continue;
nc++;
if (mode_changes_minus[i].arg != NULL &&
- ((mc == MAXMODEPARAMS) ||
- ((strlen(mode_changes_minus[i].arg) + mbl + pbl + 2) > BUFSIZE)))
+ ((mc == MAXMODEPARAMS) ||
+ ((strlen(mode_changes_minus[i].arg) + mbl + pbl + 2) > BUFSIZE)))
{
if (mbl && modebuf[mbl - 1] == '-')
modebuf[mbl - 1] = '\0';
mbl = ircsprintf(modebuf, ":%s MODE %s -", me.name, chname);
else
mbl = ircsprintf(modebuf, ":%s!%s@%s MODE %s -", source_p->name,
- source_p->username, source_p->host, chname);
+ source_p->username, source_p->host, chname);
pbl = 0;
parabuf[0] = '\0';
mbl = ircsprintf(modebuf, ":%s MODE %s +", me.name, chname);
else
mbl = ircsprintf(modebuf, ":%s!%s@%s MODE %s +", source_p->name,
- source_p->username, source_p->host, chname);
+ source_p->username, source_p->host, chname);
pbl = 0;
parabuf[0] = '\0';
nc = 0;
mc = 0;
-
+
mbl = ircsprintf(modebuf, ":%s MODE %s -", me.name, chname);
pbl = 0;
parabuf[0] = '\0';
nc++;
if (mode_bounces[i].arg != NULL &&
- ((mc == MAXMODEPARAMS) ||
- ((strlen(mode_bounces[i].arg) + mbl + pbl + 2) > BUFSIZE)))
+ ((mc == MAXMODEPARAMS) ||
+ ((strlen(mode_bounces[i].arg) + mbl + pbl + 2) > BUFSIZE)))
{
if (nc != 0)
sendto_one(client_p, "%s %s", modebuf, parabuf);
for (i = 0; i < NCHCAP_COMBOS; i++)
if (chcap_combos[i].count != 0)
send_cap_mode_changes(client_p, source_p, chptr,
- chcap_combos[i].cap_yes,
- chcap_combos[i].cap_no);
+ chcap_combos[i].cap_yes, chcap_combos[i].cap_no);
}
/* void set_channel_mode(struct Client *client_p, struct Client *source_p,
ModeTable[table_position].func(client_p, source_p, chptr,
parc, &parn,
parv, &errors, alevel, dir, c,
- ModeTable[table_position].d,
- chname);
+ ModeTable[table_position].d, chname);
break;
}
for (ptr = list->head; ptr && ptr->data; ptr = ptr->next)
{
target_p = ptr->data;
-
+
sync_oplists(chptr, target_p, dir, RootChan(chptr)->chname);
}
-
+
list = &chptr->locvoiced;
for (ptr = list->head; ptr && ptr->data; ptr = ptr->next)
{
target_p = ptr->data;
-
+
sync_oplists(chptr, target_p, dir, RootChan(chptr)->chname);
}
}
dlink_node *ptr = NULL;
struct Client *cl;
struct Channel *ch;
- for (cl=GlobalClientList; cl; cl=cl->next)
+ for (cl = GlobalClientList; cl; cl = cl->next)
{
if (!IsRegisteredUser(cl) || IsDead(cl))
continue;
- for (ptr=cl->user->channel.head; ptr; ptr=ptr->next)
+ for (ptr = cl->user->channel.head; ptr; ptr = ptr->next)
{
dlink_node *ptr2;
int matched = 0, matched_local;
- ch = (struct Channel*)ptr->data;
+ ch = (struct Channel *)ptr->data;
if (!MyConnect(cl))
matched_local = -1;
else
}
SEARCH_LIST(chanops)
#ifdef REQUIRE_OANDV
- SEARCH_LIST(chanops_voiced)
+ SEARCH_LIST(chanops_voiced)
#endif
- SEARCH_LIST(halfops)
- SEARCH_LIST(voiced)
- SEARCH_LIST(peons)
+ SEARCH_LIST(halfops) SEARCH_LIST(voiced) SEARCH_LIST(peons)
#undef SEARCH_LIST
- assert(matched);
+ assert(matched);
assert(matched_local);
}
}
- for (ch=GlobalChannelList; ch; ch=NULL /*ch->nextch */)
+ for (ch = GlobalChannelList; ch; ch = NULL /*ch->nextch */ )
{
#define SEARCH_LIST(listname) \
for (ptr=ch->listname.head; ptr; ptr=ptr->next) \
} \
assert(matched); \
}
- SEARCH_LIST(chanops)
- SEARCH_LIST(halfops)
+ SEARCH_LIST(chanops) SEARCH_LIST(halfops)
#ifdef REQUIRE_OANDV
- SEARCH_LIST(chanops_voiced)
+ SEARCH_LIST(chanops_voiced)
#endif
- SEARCH_LIST(voiced)
- SEARCH_LIST(peons)
- }
+ SEARCH_LIST(voiced) SEARCH_LIST(peons)}
}
#endif
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: class.c,v 1.1 2002/01/04 09:13:52 a1kmm Exp $
+ * $Id: class.c,v 1.2 2002/01/04 11:06:39 a1kmm Exp $
*/
#include "tools.h"
#include "class.h"
#define BAD_PING -2
#define BAD_CLIENT_CLASS -3
-struct Class* ClassList;
+struct Class *ClassList;
-struct Class *make_class()
+struct Class *
+make_class()
{
- struct Class *tmp;
+ struct Class *tmp;
tmp = (struct Class *)MyMalloc(sizeof(struct Class));
tmp->className = NULL;
return tmp;
}
-void free_class(struct Class *tmp)
+void
+free_class(struct Class *tmp)
{
MyFree(tmp->className);
MyFree((char *)tmp);
* output - ping frequency
* side effects - NONE
*/
-static int get_conf_ping(struct ConfItem *aconf)
+static int
+get_conf_ping(struct ConfItem *aconf)
{
if ((aconf) && ClassPtr(aconf))
return (ConfPingFreq(aconf));
- Debug((DEBUG_DEBUG,"No Ping For %s",
- (aconf) ? aconf->name : "*No Conf*"));
+ Debug((DEBUG_DEBUG, "No Ping For %s", (aconf) ? aconf->name : "*No Conf*"));
return (BAD_PING);
}
* output - pointer to name of class
* side effects - NONE
*/
-const char* get_client_class(struct Client *target_p)
+const char *
+get_client_class(struct Client *target_p)
{
dlink_node *ptr;
struct ConfItem *aconf;
- const char* retc = "unknown";
+ const char *retc = "unknown";
- if (target_p && !IsMe(target_p) && (target_p->localClient->confs.head))
+ if (target_p && !IsMe(target_p) && (target_p->localClient->confs.head))
for (ptr = target_p->localClient->confs.head; ptr; ptr = ptr->next)
- {
- aconf = ptr->data;
- if(aconf->className == NULL)
- retc = "default";
- else
- retc= aconf->className;
- }
+ {
+ aconf = ptr->data;
+ if (aconf->className == NULL)
+ retc = "default";
+ else
+ retc = aconf->className;
+ }
- Debug((DEBUG_DEBUG,"Returning Class %s For %s",retc,target_p->name));
+ Debug((DEBUG_DEBUG, "Returning Class %s For %s", retc, target_p->name));
return (retc);
}
* output - ping frequency
* side effects - NONE
*/
-int get_client_ping(struct Client *target_p)
+int
+get_client_ping(struct Client *target_p)
{
- int ping = 0;
- int ping2;
- struct ConfItem *aconf;
- dlink_node *nlink;
+ int ping = 0;
+ int ping2;
+ struct ConfItem *aconf;
+ dlink_node *nlink;
- if(target_p->localClient->confs.head != NULL)
+ if (target_p->localClient->confs.head != NULL)
+ {
+ for (nlink = target_p->localClient->confs.head; nlink;
+ nlink = nlink->next)
{
- for(nlink = target_p->localClient->confs.head; nlink; nlink = nlink->next)
- {
- aconf = nlink->data;
- if (aconf->status & (CONF_CLIENT|CONF_SERVER))
- {
- ping2 = get_conf_ping(aconf);
- if ((ping2 != BAD_PING) && ((ping > ping2) || !ping))
- ping = ping2;
- }
- }
+ aconf = nlink->data;
+ if (aconf->status & (CONF_CLIENT | CONF_SERVER))
+ {
+ ping2 = get_conf_ping(aconf);
+ if ((ping2 != BAD_PING) && ((ping > ping2) || !ping))
+ ping = ping2;
+ }
}
+ }
else
- {
- ping = DEFAULT_PINGFREQUENCY;
- Debug((DEBUG_DEBUG,"No Attached Confs"));
- }
+ {
+ ping = DEFAULT_PINGFREQUENCY;
+ Debug((DEBUG_DEBUG, "No Attached Confs"));
+ }
if (ping <= 0)
ping = DEFAULT_PINGFREQUENCY;
- Debug((DEBUG_DEBUG,"Client %s Ping %d", target_p->name, ping));
+ Debug((DEBUG_DEBUG, "Client %s Ping %d", target_p->name, ping));
return (ping);
}
* output - connection frequency
* side effects - NONE
*/
-int get_con_freq(struct Class *clptr)
+int
+get_con_freq(struct Class *clptr)
{
if (clptr)
return (ConFreq(clptr));
* if no present entry is found, then create a new one and add it in
* immediately after the first one (class 0).
*/
-void add_class(char *classname,
- int ping,
- int confreq,
- int maxli,
- long sendq)
+void
+add_class(char *classname, int ping, int confreq, int maxli, long sendq)
{
struct Class *t, *p;
- if(!classname)
+ if (!classname)
return;
t = find_class(classname);
if (t == ClassList)
- {
- p = make_class();
- p->next = t->next;
- t->next = p;
- }
+ {
+ p = make_class();
+ p->next = t->next;
+ t->next = p;
+ }
else
p = t;
Debug((DEBUG_DEBUG,
/* classname already known to be non NULL */
MyFree(ClassName(p));
- DupString(ClassName(p),classname);
+ DupString(ClassName(p), classname);
ConFreq(p) = confreq;
PingFreq(p) = ping;
MaxLinks(p) = maxli;
* output - corresponding class pointer
* side effects - NONE
*/
-struct Class *find_class(char* classname)
+struct Class *
+find_class(char *classname)
{
struct Class *cltmp;
- if(classname == NULL)
- {
- return(ClassList); /* return class 0 */
- }
+ if (classname == NULL)
+ {
+ return (ClassList); /* return class 0 */
+ }
for (cltmp = ClassList; cltmp; cltmp = cltmp->next)
- if (!strcmp(ClassName(cltmp),classname))
+ if (!strcmp(ClassName(cltmp), classname))
return cltmp;
return ClassList;
}
* output - NONE
* side effects -
*/
-void check_class()
+void
+check_class()
{
struct Class *cltmp, *cltmp2;
Debug((DEBUG_DEBUG, "Class check:"));
for (cltmp2 = cltmp = ClassList; cltmp; cltmp = cltmp2->next)
+ {
+ Debug((DEBUG_DEBUG,
+ "ClassName %s Class %d : CF: %d PF: %d ML: %d LI: %d SQ: %ld",
+ ClassName(cltmp), ClassType(cltmp), ConFreq(cltmp),
+ PingFreq(cltmp), MaxLinks(cltmp), Links(cltmp), MaxSendq(cltmp)));
+ if (MaxLinks(cltmp) < 0)
{
- Debug((DEBUG_DEBUG,
- "ClassName %s Class %d : CF: %d PF: %d ML: %d LI: %d SQ: %ld",
- ClassName(cltmp),ClassType(cltmp), ConFreq(cltmp), PingFreq(cltmp),
- MaxLinks(cltmp), Links(cltmp), MaxSendq(cltmp)));
- if (MaxLinks(cltmp) < 0)
- {
- cltmp2->next = cltmp->next;
- if (Links(cltmp) <= 0)
- free_class(cltmp);
- }
- else
- cltmp2 = cltmp;
+ cltmp2->next = cltmp->next;
+ if (Links(cltmp) <= 0)
+ free_class(cltmp);
}
+ else
+ cltmp2 = cltmp;
+ }
}
/*
* output - NONE
* side effects -
*/
-void initclass()
+void
+initclass()
{
ClassList = make_class();
ClassType(ClassList) = 0;
- DupString(ClassName(ClassList),"default");
+ DupString(ClassName(ClassList), "default");
ConFreq(ClassList) = DEFAULT_CONNECTFREQUENCY;
PingFreq(ClassList) = DEFAULT_PINGFREQUENCY;
MaxLinks(ClassList) = ConfigFileEntry.maximum_links;
* output - NONE
* side effects - class report is done to this client
*/
-void report_classes(struct Client *source_p)
+void
+report_classes(struct Client *source_p)
{
struct Class *cltmp;
* output - sendq for this client as found from its class
* side effects - NONE
*/
-long get_sendq(struct Client *client_p)
+long
+get_sendq(struct Client *client_p)
{
- int sendq = DEFAULT_SENDQ, retc = BAD_CLIENT_CLASS;
- dlink_node *ptr;
- struct Class *cl;
+ int sendq = DEFAULT_SENDQ, retc = BAD_CLIENT_CLASS;
+ dlink_node *ptr;
+ struct Class *cl;
struct ConfItem *aconf;
- if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
+ if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
for (ptr = client_p->localClient->confs.head; ptr; ptr = ptr->next)
- {
- aconf = ptr->data;
- if(aconf == NULL)
- continue;
+ {
+ aconf = ptr->data;
+ if (aconf == NULL)
+ continue;
- if ( !(cl = aconf->c_class))
- continue;
+ if (!(cl = aconf->c_class))
+ continue;
- if (ClassType(cl) > retc)
- sendq = MaxSendq(cl);
- }
+ if (ClassType(cl) > retc)
+ sendq = MaxSendq(cl);
+ }
return sendq;
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: client.c,v 1.1 2002/01/04 09:13:54 a1kmm Exp $
+ * $Id: client.c,v 1.2 2002/01/04 11:06:39 a1kmm Exp $
*/
#include "tools.h"
#include "client.h"
#include <unistd.h>
#include <sys/stat.h>
-static void check_pings_list(dlink_list *list);
-static void check_unknowns_list(dlink_list *list);
+static void check_pings_list(dlink_list * list);
+static void check_unknowns_list(dlink_list * list);
static void free_exited_clients(void *unused);
static EVH check_pings;
-static int remote_client_count=0;
-static int local_client_count=0;
+static int remote_client_count = 0;
+static int local_client_count = 0;
static BlockHeap *client_heap = NULL;
static BlockHeap *lclient_heap = NULL;
* output - NONE
* side effect - Does garbage collection of client heaps
*/
-
-static void client_heap_gc(void *unused)
+
+static void
+client_heap_gc(void *unused)
{
BlockHeapGarbageCollect(client_heap);
BlockHeapGarbageCollect(lclient_heap);
* output - NONE
* side effects - initialize client free memory
*/
-void init_client(void)
+void
+init_client(void)
{
remote_client_count = 0;
local_client_count = 0;
* Every 30 seconds is plenty -- db
*/
client_heap = BlockHeapCreate(sizeof(struct Client), 10000);
- lclient_heap = BlockHeapCreate(sizeof(struct LocalUser), 512);
+ lclient_heap = BlockHeapCreate(sizeof(struct LocalUser), 512);
eventAdd("check_pings", check_pings, NULL, 30);
eventAdd("free_exited_clients()", &free_exited_clients, NULL, 4);
eventAdd("client_heap_gc", client_heap_gc, NULL, 30);
* associated with the client defined by
* 'from'). ('from' is a local client!!).
*/
-struct Client* make_client(struct Client* from)
+struct Client *
+make_client(struct Client *from)
{
- struct Client* client_p = NULL;
+ struct Client *client_p = NULL;
struct LocalUser *localClient;
dlink_node *m;
client_p = BlockHeapAlloc(client_heap);
- memset(client_p, 0, sizeof(struct Client));
+ memset(client_p, 0, sizeof(struct Client));
if (from == NULL)
- {
- client_p->from = client_p; /* 'from' of local client is self! */
- client_p->since = client_p->lasttime = client_p->firsttime = CurrentTime;
+ {
+ client_p->from = client_p; /* 'from' of local client is self! */
+ client_p->since = client_p->lasttime = client_p->firsttime = CurrentTime;
- localClient = (struct LocalUser *)BlockHeapAlloc(lclient_heap);
- memset(localClient, 0, sizeof(struct LocalUser));
+ localClient = (struct LocalUser *)BlockHeapAlloc(lclient_heap);
+ memset(localClient, 0, sizeof(struct LocalUser));
- client_p->localClient = localClient;
- client_p->localClient->ctrlfd = -1;
+ client_p->localClient = localClient;
+ client_p->localClient->ctrlfd = -1;
#ifndef HAVE_SOCKETPAIR
- client_p->localClient->ctrlfd_r = -1;
-#endif
- /* as good a place as any... */
- m = make_dlink_node();
- dlinkAdd(client_p, m, &unknown_list);
- ++local_client_count;
- }
+ client_p->localClient->ctrlfd_r = -1;
+#endif
+ /* as good a place as any... */
+ m = make_dlink_node();
+ dlinkAdd(client_p, m, &unknown_list);
+ ++local_client_count;
+ }
else
- { /* from is not NULL */
- client_p->localClient = NULL;
- client_p->from = from; /* 'from' of local client is self! */
- ++remote_client_count;
- }
+ { /* from is not NULL */
+ client_p->localClient = NULL;
+ client_p->from = from; /* 'from' of local client is self! */
+ ++remote_client_count;
+ }
client_p->status = STAT_UNKNOWN;
client_p->fd = -1;
strcpy(client_p->username, "unknown");
#if 0
client_p->name[0] = '\0';
- client_p->flags = 0;
- client_p->next = NULL;
- client_p->prev = NULL;
- client_p->hnext = NULL;
- client_p->lnext = NULL;
- client_p->lprev = NULL;
- client_p->user = NULL;
- client_p->serv = NULL;
+ client_p->flags = 0;
+ client_p->next = NULL;
+ client_p->prev = NULL;
+ client_p->hnext = NULL;
+ client_p->lnext = NULL;
+ client_p->lprev = NULL;
+ client_p->user = NULL;
+ client_p->serv = NULL;
client_p->servptr = NULL;
- client_p->whowas = NULL;
+ client_p->whowas = NULL;
client_p->allow_list.head = NULL;
client_p->allow_list.tail = NULL;
client_p->on_allow_list.head = NULL;
return client_p;
}
-void _free_client(struct Client* client_p)
+void
+_free_client(struct Client *client_p)
{
assert(0 != client_p);
assert(&me != client_p);
/* If localClient is non NULL, its a local client */
if (client_p->localClient != NULL)
- {
- if (-1 < client_p->fd)
- fd_close(client_p->fd);
+ {
+ if (-1 < client_p->fd)
+ fd_close(client_p->fd);
#ifndef NDEBUG
- mem_frob(client_p->localClient, sizeof(struct LocalUser));
+ mem_frob(client_p->localClient, sizeof(struct LocalUser));
#endif
- BlockHeapFree(lclient_heap, client_p->localClient);
- --local_client_count;
- assert(local_client_count >= 0);
- }
+ BlockHeapFree(lclient_heap, client_p->localClient);
+ --local_client_count;
+ assert(local_client_count >= 0);
+ }
else
- {
- --remote_client_count;
- }
+ {
+ --remote_client_count;
+ }
#ifndef NDEBUG
mem_frob(client_p, sizeof(struct Client));
static void
check_pings(void *notused)
-{
+{
check_pings_list(&lclient_list);
check_pings_list(&serv_list);
check_unknowns_list(&unknown_list);
* side effects -
*/
static void
-check_pings_list(dlink_list *list)
+check_pings_list(dlink_list * list)
{
- char scratch[32]; /* way too generous but... */
- struct Client *client_p; /* current local client_p being examined */
- int ping = 0; /* ping time value from client */
- dlink_node *ptr, *next_ptr;
+ char scratch[32]; /* way too generous but... */
+ struct Client *client_p; /* current local client_p being examined */
+ int ping = 0; /* ping time value from client */
+ dlink_node *ptr, *next_ptr;
for (ptr = list->head; ptr; ptr = next_ptr)
+ {
+ next_ptr = ptr->next;
+ client_p = ptr->data;
+
+ /*
+ ** Note: No need to notify opers here. It's
+ ** already done when "FLAGS_DEADSOCKET" is set.
+ */
+ if (client_p->flags & FLAGS_DEADSOCKET)
+ {
+ if (client_p->flags & FLAGS_SENDQEX)
+ {
+ exit_client(client_p, client_p, &me, "SendQ exceeded");
+ continue;
+ }
+ exit_client(client_p, client_p, &me, "Dead socket");
+ continue;
+ }
+ if (IsPerson(client_p))
{
- next_ptr = ptr->next;
- client_p = ptr->data;
+ if (!IsExemptKline(client_p) &&
+ GlobalSetOptions.idletime &&
+ !IsOper(client_p) &&
+ !IsIdlelined(client_p) &&
+ ((CurrentTime - client_p->user->last) > GlobalSetOptions.idletime))
+ {
+ struct ConfItem *aconf;
- /*
- ** Note: No need to notify opers here. It's
- ** already done when "FLAGS_DEADSOCKET" is set.
- */
- if (client_p->flags & FLAGS_DEADSOCKET)
- {
- if (client_p->flags & FLAGS_SENDQEX)
- {
- exit_client(client_p, client_p, &me, "SendQ exceeded");
- continue;
- }
- exit_client(client_p, client_p, &me, "Dead socket");
- continue;
- }
- if (IsPerson(client_p))
- {
- if( !IsExemptKline(client_p) &&
- GlobalSetOptions.idletime &&
- !IsOper(client_p) &&
- !IsIdlelined(client_p) &&
- ((CurrentTime - client_p->user->last) > GlobalSetOptions.idletime))
- {
- struct ConfItem *aconf;
-
- aconf = make_conf();
- aconf->status = CONF_KILL;
-
- DupString(aconf->host, client_p->host);
- DupString(aconf->passwd, "idle exceeder" );
- DupString(aconf->name, client_p->username);
- aconf->port = 0;
- aconf->hold = CurrentTime + 60;
- add_temp_kline(aconf);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Idle time limit exceeded for %s - temp k-lining",
- get_client_name(client_p, HIDE_IP));
-
-
- (void)exit_client(client_p, client_p, &me, aconf->passwd);
- continue;
- }
- }
+ aconf = make_conf();
+ aconf->status = CONF_KILL;
- if (!IsRegistered(client_p))
- ping = CONNECTTIMEOUT;
- else
- ping = get_client_ping(client_p);
+ DupString(aconf->host, client_p->host);
+ DupString(aconf->passwd, "idle exceeder");
+ DupString(aconf->name, client_p->username);
+ aconf->port = 0;
+ aconf->hold = CurrentTime + 60;
+ add_temp_kline(aconf);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Idle time limit exceeded for %s - temp k-lining",
+ get_client_name(client_p, HIDE_IP));
- if (ping < (CurrentTime - client_p->lasttime))
+
+ (void)exit_client(client_p, client_p, &me, aconf->passwd);
+ continue;
+ }
+ }
+
+ if (!IsRegistered(client_p))
+ ping = CONNECTTIMEOUT;
+ else
+ ping = get_client_ping(client_p);
+
+ if (ping < (CurrentTime - client_p->lasttime))
+ {
+ /*
+ * If the client/server hasnt talked to us in 2*ping seconds
+ * and it has a ping time, then close its connection.
+ */
+ if (((CurrentTime - client_p->lasttime) >= (2 * ping) &&
+ (client_p->flags & FLAGS_PINGSENT)))
+ {
+ if (IsServer(client_p) || IsConnecting(client_p) ||
+ IsHandshake(client_p))
{
- /*
- * If the client/server hasnt talked to us in 2*ping seconds
- * and it has a ping time, then close its connection.
- */
- if (((CurrentTime - client_p->lasttime) >= (2 * ping) &&
- (client_p->flags & FLAGS_PINGSENT)))
- {
- if (IsServer(client_p) || IsConnecting(client_p) ||
- IsHandshake(client_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "No response from %s, closing link",
- get_client_name(client_p, HIDE_IP));
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "No response from %s, closing link",
- get_client_name(client_p, MASK_IP));
- ilog(L_NOTICE, "No response from %s, closing link",
- get_client_name(client_p, HIDE_IP));
- }
- (void)ircsprintf(scratch,
- "Ping timeout: %d seconds",
- (int)(CurrentTime - client_p->lasttime));
-
- (void)exit_client(client_p, client_p, &me, scratch);
- continue;
- }
- else if ((client_p->flags & FLAGS_PINGSENT) == 0)
- {
- /*
- * if we havent PINGed the connection and we havent
- * heard from it in a while, PING it to make sure
- * it is still alive.
- */
- client_p->flags |= FLAGS_PINGSENT;
- /* not nice but does the job */
- client_p->lasttime = CurrentTime - ping;
- sendto_one(client_p, "PING :%s", me.name);
- }
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "No response from %s, closing link",
+ get_client_name(client_p, HIDE_IP));
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "No response from %s, closing link",
+ get_client_name(client_p, MASK_IP));
+ ilog(L_NOTICE, "No response from %s, closing link",
+ get_client_name(client_p, HIDE_IP));
}
- /* ping_timeout: */
+ (void)ircsprintf(scratch,
+ "Ping timeout: %d seconds",
+ (int)(CurrentTime - client_p->lasttime));
+ (void)exit_client(client_p, client_p, &me, scratch);
+ continue;
+ }
+ else if ((client_p->flags & FLAGS_PINGSENT) == 0)
+ {
+ /*
+ * if we havent PINGed the connection and we havent
+ * heard from it in a while, PING it to make sure
+ * it is still alive.
+ */
+ client_p->flags |= FLAGS_PINGSENT;
+ /* not nice but does the job */
+ client_p->lasttime = CurrentTime - ping;
+ sendto_one(client_p, "PING :%s", me.name);
+ }
}
+ /* ping_timeout: */
+
+ }
}
/*
* side effects - unknown clients get marked for termination after n seconds
*/
static void
-check_unknowns_list(dlink_list *list)
+check_unknowns_list(dlink_list * list)
{
dlink_node *ptr, *next_ptr;
struct Client *client_p;
- for(ptr = list->head; ptr; ptr = next_ptr)
- {
- next_ptr = ptr->next;
- client_p = ptr->data;
+ for (ptr = list->head; ptr; ptr = next_ptr)
+ {
+ next_ptr = ptr->next;
+ client_p = ptr->data;
- /*
- * Check UNKNOWN connections - if they have been in this state
- * for > 30s, close them.
- */
+ /*
+ * Check UNKNOWN connections - if they have been in this state
+ * for > 30s, close them.
+ */
- if (client_p->firsttime ? ((CurrentTime - client_p->firsttime) > 30) : 0)
- {
- (void)exit_client(client_p, client_p, &me, "Connection timed out");
- }
+ if (client_p->firsttime ? ((CurrentTime - client_p->firsttime) > 30) : 0)
+ {
+ (void)exit_client(client_p, client_p, &me, "Connection timed out");
}
+ }
}
/*
* side effects - Check all connections for a pending kline against the
* client, exit the client if a kline matches.
*/
-void
+void
check_klines(void)
-{
- struct Client *client_p; /* current local client_p being examined */
- struct ConfItem *aconf = (struct ConfItem *)NULL;
- char *reason; /* pointer to reason string */
- dlink_node *ptr, *next_ptr;
-
+{
+ struct Client *client_p; /* current local client_p being examined */
+ struct ConfItem *aconf = (struct ConfItem *)NULL;
+ char *reason; /* pointer to reason string */
+ dlink_node *ptr, *next_ptr;
+
for (ptr = lclient_list.head; ptr; ptr = next_ptr)
+ {
+ next_ptr = ptr->next;
+ client_p = ptr->data;
+
+ if (IsMe(client_p))
+ continue;
+
+ /* if there is a returned struct ConfItem then kill it */
+ if ((aconf = find_dline(&client_p->localClient->ip,
+ client_p->localClient->aftype)))
{
- next_ptr = ptr->next;
- client_p = ptr->data;
-
- if (IsMe(client_p))
- continue;
-
- /* if there is a returned struct ConfItem then kill it */
- if ((aconf = find_dline(&client_p->localClient->ip,
- client_p->localClient->aftype)))
- {
- if (aconf->status & CONF_EXEMPTDLINE)
- continue;
-
- sendto_realops_flags(FLAGS_ALL, L_ALL,"DLINE active for %s",
- get_client_name(client_p, HIDE_IP));
-
- if (ConfigFileEntry.kline_with_connection_closed &&
- ConfigFileEntry.kline_with_reason)
- {
- reason = "Connection closed";
-
- if(IsPerson(client_p))
- sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name,
- aconf->passwd ? aconf->passwd : "D-lined");
- else
- sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
- }
- else
- {
- if(ConfigFileEntry.kline_with_connection_closed)
- reason = "Connection closed";
- else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
- reason = aconf->passwd;
- else
- reason = "D-lined";
-
- if(IsPerson(client_p))
- sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name, reason);
- else
- sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
- }
-
- (void)exit_client(client_p, client_p, &me, reason );
- continue; /* and go examine next fd/client_p */
- }
-
- if (IsPerson(client_p))
- {
- if (ConfigFileEntry.glines &&
- (aconf = find_gkill(client_p, client_p->username)))
- {
- if (IsExemptKline(client_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "GLINE over-ruled for %s, client is kline_exempt",
- get_client_name(client_p, HIDE_IP));
- continue;
- }
-
- if (IsExemptGline(client_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "GLINE over-ruled for %s, client is gline_exempt",
- get_client_name(client_p, HIDE_IP));
- continue;
- }
-
- sendto_realops_flags(FLAGS_ALL, L_ALL, "GLINE active for %s",
- get_client_name(client_p, HIDE_IP));
-
- if(ConfigFileEntry.kline_with_connection_closed &&
- ConfigFileEntry.kline_with_reason)
- {
- reason = "Connection closed";
-
- sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name,
- aconf->passwd ? aconf->passwd : "G-lined");
- }
- else
- {
- if(ConfigFileEntry.kline_with_connection_closed)
- reason = "Connection closed";
- else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
- reason = aconf->passwd;
- else
- reason = "G-lined";
-
- sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name, reason);
- }
-
- (void)exit_client(client_p, client_p, &me, reason);
- /* and go examine next fd/client_p */
- continue;
- }
- else if((aconf = find_kill(client_p)))
- {
- /* if there is a returned struct ConfItem.. then kill it */
- if (IsExemptKline(client_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "KLINE over-ruled for %s, client is kline_exempt",
- get_client_name(client_p, HIDE_IP));
- continue;
- }
-
- sendto_realops_flags(FLAGS_ALL, L_ALL, "KLINE active for %s",
- get_client_name(client_p, HIDE_IP));
-
- if(ConfigFileEntry.kline_with_connection_closed &&
- ConfigFileEntry.kline_with_reason)
- {
- reason = "Connection closed";
-
- sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name,
- aconf->passwd ? aconf->passwd : "K-lined");
- }
- else
- {
- if(ConfigFileEntry.kline_with_connection_closed)
- reason = "Connection closed";
- else if(ConfigFileEntry.kline_with_reason && aconf->passwd)
- reason = aconf->passwd;
- else
- reason = "K-lined";
-
- sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name, reason);
- }
-
- (void)exit_client(client_p, client_p, &me, reason);
- continue;
- }
- }
+ if (aconf->status & CONF_EXEMPTDLINE)
+ continue;
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "DLINE active for %s",
+ get_client_name(client_p, HIDE_IP));
+
+ if (ConfigFileEntry.kline_with_connection_closed &&
+ ConfigFileEntry.kline_with_reason)
+ {
+ reason = "Connection closed";
+
+ if (IsPerson(client_p))
+ sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
+ me.name, client_p->name,
+ aconf->passwd ? aconf->passwd : "D-lined");
+ else
+ sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
+ }
+ else
+ {
+ if (ConfigFileEntry.kline_with_connection_closed)
+ reason = "Connection closed";
+ else if (ConfigFileEntry.kline_with_reason && aconf->passwd)
+ reason = aconf->passwd;
+ else
+ reason = "D-lined";
+
+ if (IsPerson(client_p))
+ sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
+ me.name, client_p->name, reason);
+ else
+ sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
+ }
+
+ (void)exit_client(client_p, client_p, &me, reason);
+ continue; /* and go examine next fd/client_p */
+ }
+
+ if (IsPerson(client_p))
+ {
+ if (ConfigFileEntry.glines &&
+ (aconf = find_gkill(client_p, client_p->username)))
+ {
+ if (IsExemptKline(client_p))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "GLINE over-ruled for %s, client is kline_exempt",
+ get_client_name(client_p, HIDE_IP));
+ continue;
+ }
+
+ if (IsExemptGline(client_p))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "GLINE over-ruled for %s, client is gline_exempt",
+ get_client_name(client_p, HIDE_IP));
+ continue;
+ }
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "GLINE active for %s",
+ get_client_name(client_p, HIDE_IP));
+
+ if (ConfigFileEntry.kline_with_connection_closed &&
+ ConfigFileEntry.kline_with_reason)
+ {
+ reason = "Connection closed";
+
+ sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
+ me.name, client_p->name,
+ aconf->passwd ? aconf->passwd : "G-lined");
+ }
+ else
+ {
+ if (ConfigFileEntry.kline_with_connection_closed)
+ reason = "Connection closed";
+ else if (ConfigFileEntry.kline_with_reason && aconf->passwd)
+ reason = aconf->passwd;
+ else
+ reason = "G-lined";
+
+ sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
+ me.name, client_p->name, reason);
+ }
+
+ (void)exit_client(client_p, client_p, &me, reason);
+ /* and go examine next fd/client_p */
+ continue;
+ }
+ else if ((aconf = find_kill(client_p)))
+ {
+ /* if there is a returned struct ConfItem.. then kill it */
+ if (IsExemptKline(client_p))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "KLINE over-ruled for %s, client is kline_exempt",
+ get_client_name(client_p, HIDE_IP));
+ continue;
+ }
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "KLINE active for %s",
+ get_client_name(client_p, HIDE_IP));
+
+ if (ConfigFileEntry.kline_with_connection_closed &&
+ ConfigFileEntry.kline_with_reason)
+ {
+ reason = "Connection closed";
+
+ sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
+ me.name, client_p->name,
+ aconf->passwd ? aconf->passwd : "K-lined");
+ }
+ else
+ {
+ if (ConfigFileEntry.kline_with_connection_closed)
+ reason = "Connection closed";
+ else if (ConfigFileEntry.kline_with_reason && aconf->passwd)
+ reason = aconf->passwd;
+ else
+ reason = "K-lined";
+
+ sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
+ me.name, client_p->name, reason);
+ }
+
+ (void)exit_client(client_p, client_p, &me, reason);
+ continue;
+ }
}
+ }
}
/*
* output - NONE
* side effects -
*/
-static void update_client_exit_stats(struct Client* client_p)
+static void
+update_client_exit_stats(struct Client *client_p)
{
if (IsServer(client_p))
- {
- --Count.server;
- sendto_realops_flags(FLAGS_EXTERNAL, L_ALL,
- "Server %s split from %s",
- client_p->name, client_p->servptr->name);
- }
+ {
+ --Count.server;
+ sendto_realops_flags(FLAGS_EXTERNAL, L_ALL,
+ "Server %s split from %s",
+ client_p->name, client_p->servptr->name);
+ }
else if (IsClient(client_p))
- {
- --Count.total;
- if (IsOper(client_p))
- --Count.oper;
- if (IsInvisible(client_p))
- --Count.invisi;
- }
-
- if(!splitmode &&
- (ConfigChannel.no_join_on_split || ConfigChannel.no_create_on_split))
+ {
+ --Count.total;
+ if (IsOper(client_p))
+ --Count.oper;
+ if (IsInvisible(client_p))
+ --Count.invisi;
+ }
+
+ if (!splitmode &&
+ (ConfigChannel.no_join_on_split || ConfigChannel.no_create_on_split))
check_splitmode();
}
* side effects -
*/
static void
-release_client_state(struct Client* client_p)
+release_client_state(struct Client *client_p)
{
if (client_p->user)
+ {
+ if (IsPerson(client_p))
{
- if (IsPerson(client_p))
- {
- add_history(client_p,0);
- off_history(client_p);
- }
- free_user(client_p->user, client_p); /* try this here */
+ add_history(client_p, 0);
+ off_history(client_p);
}
+ free_user(client_p->user, client_p); /* try this here */
+ }
if (client_p->serv)
- {
- if (client_p->serv->user)
- free_user(client_p->serv->user, client_p);
- MyFree((char*) client_p->serv);
- }
+ {
+ if (client_p->serv->user)
+ free_user(client_p->serv->user, client_p);
+ MyFree((char *)client_p->serv);
+ }
}
/*
* and placed it here. - avalon
*/
void
-remove_client_from_list(struct Client* client_p)
+remove_client_from_list(struct Client *client_p)
{
assert(0 != client_p);
-
+
/* A client made with make_client()
* is on the unknown_list until removed.
* If it =does= happen to exit before its removed from that list
* short circuit that case now -db
*/
if (!client_p->prev && !client_p->next)
- {
- return;
- }
+ {
+ return;
+ }
if (client_p->prev)
client_p->prev->next = client_p->next;
else
- {
- GlobalClientList = client_p->next;
- GlobalClientList->prev = NULL;
- }
+ {
+ GlobalClientList = client_p->next;
+ GlobalClientList->prev = NULL;
+ }
if (client_p->next)
client_p->next->prev = client_p->prev;
/* Functions taken from +CSr31, paranoified to check that the client
** isn't on a llist already when adding, and is there when removing -orabidoo
*/
-void add_client_to_llist(struct Client **bucket, struct Client *client)
+void
+add_client_to_llist(struct Client **bucket, struct Client *client)
{
if (!client->lprev && !client->lnext)
- {
- client->lprev = NULL;
- if ((client->lnext = *bucket) != NULL)
- client->lnext->lprev = client;
- *bucket = client;
- }
+ {
+ client->lprev = NULL;
+ if ((client->lnext = *bucket) != NULL)
+ client->lnext->lprev = client;
+ *bucket = client;
+ }
}
void
del_client_from_llist(struct Client **bucket, struct Client *client)
{
if (client->lprev)
- {
- client->lprev->lnext = client->lnext;
- }
+ {
+ client->lprev->lnext = client->lnext;
+ }
else if (*bucket == client)
- {
- *bucket = client->lnext;
- }
+ {
+ *bucket = client->lnext;
+ }
if (client->lnext)
- {
- client->lnext->lprev = client->lprev;
- }
+ {
+ client->lnext->lprev = client->lprev;
+ }
client->lnext = client->lprev = NULL;
}
* the old. 'name' is now assumed to be a null terminated
* string and the search is the for server and user.
*/
-struct Client *find_userhost(char *user, char *host,
- struct Client *client_p, int *count)
+struct Client *
+find_userhost(char *user, char *host, struct Client *client_p, int *count)
{
- struct Client *c2ptr;
- struct Client *res = client_p;
+ struct Client *c2ptr;
+ struct Client *res = client_p;
*count = 0;
if (collapse(user))
- for (c2ptr = GlobalClientList; c2ptr; c2ptr = c2ptr->next)
+ for (c2ptr = GlobalClientList; c2ptr; c2ptr = c2ptr->next)
+ {
+ if (!MyClient(c2ptr)) /* implies mine and a user */
+ continue;
+ if ((!host || match(host, c2ptr->host)) &&
+ irccmp(user, c2ptr->username) == 0)
{
- if (!MyClient(c2ptr)) /* implies mine and a user */
- continue;
- if ((!host || match(host, c2ptr->host)) &&
- irccmp(user, c2ptr->username) == 0)
- {
- (*count)++;
- res = c2ptr;
- }
+ (*count)++;
+ res = c2ptr;
}
+ }
return res;
}
* HandleMatchingClient;
*
*/
-struct Client*
-next_client(struct Client *next, /* First client to check */
- const char* ch) /* search string (may include wilds) */
+struct Client *
+next_client(struct Client *next, /* First client to check */
+ const char *ch) /* search string (may include wilds) */
{
struct Client *tmp = next;
if (next != tmp)
return next;
- for ( ; next; next = next->next)
- {
- if (match(ch,next->name)) break;
- }
+ for (; next; next = next->next)
+ {
+ if (match(ch, next->name))
+ break;
+ }
return next;
}
* HandleMatchingClient;
*
*/
-struct Client*
+struct Client *
next_client_double(struct Client *next, /* First client to check */
- const char* ch) /* search string (may include wilds) */
+ const char *ch) /* search string (may include wilds) */
{
struct Client *tmp = next;
return NULL;
if (next != tmp)
return next;
- for ( ; next; next = next->next)
- {
- if (match(ch,next->name) || match(next->name,ch))
- break;
- }
+ for (; next; next = next->next)
+ {
+ if (match(ch, next->name) || match(next->name, ch))
+ break;
+ }
return next;
}
* output - return client pointer
* side effects -
*/
-struct Client *find_person(char *name)
+struct Client *
+find_person(char *name)
{
- struct Client *c2ptr;
+ struct Client *c2ptr;
c2ptr = find_client(name);
find_chasing(struct Client *source_p, char *user, int *chasing)
{
struct Client *who = find_client(user);
-
+
if (chasing)
*chasing = 0;
if (who)
return who;
if (!(who = get_history(user, (long)KILLCHASETIMELIMIT)))
- {
- sendto_one(source_p, form_str(ERR_NOSUCHNICK),
- me.name, source_p->name, user);
- return ((struct Client *)NULL);
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK),
+ me.name, source_p->name, user);
+ return ((struct Client *)NULL);
+ }
if (chasing)
*chasing = 1;
return who;
* other thing generated for remotes...
*/
int
-check_registered_user(struct Client* client)
+check_registered_user(struct Client *client)
{
if (!IsRegisteredUser(client))
- {
- sendto_one(client, form_str(ERR_NOTREGISTERED), me.name, "*");
- return -1;
- }
+ {
+ sendto_one(client, form_str(ERR_NOTREGISTERED), me.name, "*");
+ return -1;
+ }
return 0;
}
* or user)
*/
int
-check_registered(struct Client* client)
+check_registered(struct Client *client)
{
if (!IsRegistered(client))
- {
- sendto_one(client, form_str(ERR_NOTREGISTERED), me.name, "*");
- return -1;
- }
+ {
+ sendto_one(client, form_str(ERR_NOTREGISTERED), me.name, "*");
+ return -1;
+ }
return 0;
}
* to modify what it points!!!
*/
-const char*
-get_client_name(struct Client* client, int showip)
+const char *
+get_client_name(struct Client *client, int showip)
{
static char nbuf[HOSTLEN * 2 + USERLEN + 5];
assert(0 != client);
if (MyConnect(client))
- {
- if (!irccmp(client->name, client->host))
- return client->name;
+ {
+ if (!irccmp(client->name, client->host))
+ return client->name;
- /* And finally, let's get the host information, ip or name */
- switch (showip)
- {
- case SHOW_IP:
- ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
- client->localClient->sockhost);
- break;
- case MASK_IP:
- ircsprintf(nbuf, "%s[%s@255.255.255.255]", client->name,
- client->username);
- break;
- default:
- ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
- client->host);
- }
- return nbuf;
+ /* And finally, let's get the host information, ip or name */
+ switch (showip)
+ {
+ case SHOW_IP:
+ ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
+ client->localClient->sockhost);
+ break;
+ case MASK_IP:
+ ircsprintf(nbuf, "%s[%s@255.255.255.255]", client->name,
+ client->username);
+ break;
+ default:
+ ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
+ client->host);
}
+ return nbuf;
+ }
/* As pointed out by Adel Mezibra
* Neph|l|m@EFnet. Was missing a return here.
{
dlink_node *ptr, *next;
struct Client *target_p;
-
- for(ptr = dead_list.head; ptr; ptr = next)
+
+ for (ptr = dead_list.head; ptr; ptr = next)
+ {
+ target_p = ptr->data;
+ next = ptr->next;
+ if (ptr->data == NULL)
{
- target_p = ptr->data;
- next = ptr->next;
- if (ptr->data == NULL)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Warning: null client on dead_list!");
- dlinkDelete(ptr, &dead_list);
- free_dlink_node(ptr);
- continue;
- }
- release_client_state(target_p);
- free_client(target_p);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Warning: null client on dead_list!");
dlinkDelete(ptr, &dead_list);
free_dlink_node(ptr);
+ continue;
}
+ release_client_state(target_p);
+ free_client(target_p);
+ dlinkDelete(ptr, &dead_list);
+ free_dlink_node(ptr);
+ }
}
/*
** Exit one client, local or remote. Assuming all dependents have
** been already removed, and socket closed for local client.
*/
-static void exit_one_client(struct Client *client_p, struct
- Client *source_p, struct Client *from,
- const char* comment)
+static void
+exit_one_client(struct Client *client_p, struct
+ Client *source_p, struct Client *from, const char *comment)
{
- struct Client* target_p;
+ struct Client *target_p;
dlink_node *lp;
dlink_node *next_lp;
if (IsServer(source_p))
- {
- if (source_p->servptr && source_p->servptr->serv)
- del_client_from_llist(&(source_p->servptr->serv->servers),
- source_p);
- else
- ts_warn("server %s without servptr!", source_p->name);
-
- if(!IsMe(source_p))
- remove_server_from_list(source_p);
- }
+ {
+ if (source_p->servptr && source_p->servptr->serv)
+ del_client_from_llist(&(source_p->servptr->serv->servers), source_p);
+ else
+ ts_warn("server %s without servptr!", source_p->name);
+
+ if (!IsMe(source_p))
+ remove_server_from_list(source_p);
+ }
else if (source_p->servptr && source_p->servptr->serv)
- del_client_from_llist(&(source_p->servptr->serv->users), source_p);
+ del_client_from_llist(&(source_p->servptr->serv->users), source_p);
/* there are clients w/o a servptr: unregistered ones */
/*
- ** For a server or user quitting, propogate the information to
- ** other servers (except to the one where is came from (client_p))
- */
+ ** For a server or user quitting, propogate the information to
+ ** other servers (except to the one where is came from (client_p))
+ */
if (IsMe(source_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "ERROR: tried to exit me! : %s", comment);
- return; /* ...must *never* exit self!! */
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "ERROR: tried to exit me! : %s", comment);
+ return; /* ...must *never* exit self!! */
+ }
else if (IsServer(source_p))
+ {
+ /*
+ ** Old sendto_serv_but_one() call removed because we now
+ ** need to send different names to different servers
+ ** (domain name matching)
+ */
+ /*
+ ** The bulk of this is done in remove_dependents now, all
+ ** we have left to do is send the SQUIT upstream. -orabidoo
+ */
+ if (source_p->localClient && (source_p->localClient->ctrlfd > -1))
+ fd_close(source_p->localClient->ctrlfd);
+
+ target_p = source_p->from;
+ if (target_p && IsServer(target_p) && target_p != client_p
+ && !IsMe(target_p) && (source_p->flags & FLAGS_KILLED) == 0)
+ sendto_one(target_p, ":%s SQUIT %s :%s", from->name, source_p->name,
+ comment);
+ }
+ else if (!(IsPerson(source_p)))
+ /* ...this test is *dubious*, would need
+ ** some thought.. but for now it plugs a
+ ** nasty hole in the server... --msa
+ */
+ ; /* Nothing */
+ else if (source_p->name[0]) /* ...just clean all others with QUIT... */
+ {
+ /*
+ ** If this exit is generated from "m_kill", then there
+ ** is no sense in sending the QUIT--KILL's have been
+ ** sent instead.
+ */
+ if ((source_p->flags & FLAGS_KILLED) == 0)
{
- /*
- ** Old sendto_serv_but_one() call removed because we now
- ** need to send different names to different servers
- ** (domain name matching)
- */
- /*
- ** The bulk of this is done in remove_dependents now, all
- ** we have left to do is send the SQUIT upstream. -orabidoo
- */
- if (source_p->localClient && (source_p->localClient->ctrlfd > -1))
- fd_close(source_p->localClient->ctrlfd);
-
- target_p = source_p->from;
- if (target_p && IsServer(target_p) && target_p != client_p && !IsMe(target_p) &&
- (source_p->flags & FLAGS_KILLED) == 0)
- sendto_one(target_p, ":%s SQUIT %s :%s", from->name, source_p->name, comment);
+ sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS,
+ NOFLAGS, ":%s QUIT :%s", source_p->name, comment);
}
- else if (!(IsPerson(source_p)))
- /* ...this test is *dubious*, would need
- ** some thought.. but for now it plugs a
- ** nasty hole in the server... --msa
- */
- ; /* Nothing */
- else if (source_p->name[0]) /* ...just clean all others with QUIT... */
+ /*
+ ** If a person is on a channel, send a QUIT notice
+ ** to every client (person) on the same channel (so
+ ** that the client can show the "**signoff" message).
+ ** (Note: The notice is to the local clients *only*)
+ */
+ if (source_p->user)
{
- /*
- ** If this exit is generated from "m_kill", then there
- ** is no sense in sending the QUIT--KILL's have been
- ** sent instead.
- */
- if ((source_p->flags & FLAGS_KILLED) == 0)
- {
- sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS,
- NOFLAGS, ":%s QUIT :%s", source_p->name, comment);
- }
- /*
- ** If a person is on a channel, send a QUIT notice
- ** to every client (person) on the same channel (so
- ** that the client can show the "**signoff" message).
- ** (Note: The notice is to the local clients *only*)
- */
- if (source_p->user)
- {
- sendto_common_channels_local(source_p, ":%s!%s@%s QUIT :%s",
- source_p->name,
- source_p->username,
- source_p->host,
- comment);
-
- for (lp = source_p->user->channel.head; lp; lp = next_lp)
- {
- next_lp = lp->next;
- remove_user_from_channel(lp->data,source_p, 1);
- }
-
- /* Clean up invitefield */
- for (lp = source_p->user->invited.head; lp; lp = next_lp)
- {
- next_lp = lp->next;
- del_invite(lp->data, source_p);
- }
-
- /* Clean up allow lists */
- del_all_accepts(source_p);
-
- if (HasID(source_p))
- del_from_id_hash_table(source_p->user->id, source_p);
-
- /* again, this is all that is needed */
- }
+ sendto_common_channels_local(source_p, ":%s!%s@%s QUIT :%s",
+ source_p->name,
+ source_p->username,
+ source_p->host, comment);
+
+ for (lp = source_p->user->channel.head; lp; lp = next_lp)
+ {
+ next_lp = lp->next;
+ remove_user_from_channel(lp->data, source_p, 1);
+ }
+
+ /* Clean up invitefield */
+ for (lp = source_p->user->invited.head; lp; lp = next_lp)
+ {
+ next_lp = lp->next;
+ del_invite(lp->data, source_p);
+ }
+
+ /* Clean up allow lists */
+ del_all_accepts(source_p);
+
+ if (HasID(source_p))
+ del_from_id_hash_table(source_p->user->id, source_p);
+
+ /* again, this is all that is needed */
}
-
+ }
+
/*
* Remove source_p from the client lists
*/
** a link gets a SQUIT, it doesn't need any QUIT/SQUITs for clients depending
** on that one -orabidoo
*/
-static void recurse_send_quits(struct Client *client_p, struct Client *source_p, struct Client *to,
- const char* comment, /* for servers */
- const char* myname)
+static void
+recurse_send_quits(struct Client *client_p, struct Client *source_p, struct Client *to, const char *comment, /* for servers */
+ const char *myname)
{
struct Client *target_p;
* of dependents, just send the SQUIT
*/
- if (IsCapable(to,CAP_QS))
+ if (IsCapable(to, CAP_QS))
+ {
+ if (match(myname, source_p->name))
{
- if (match(myname, source_p->name))
- {
- for (target_p = source_p->serv->users; target_p; target_p = target_p->lnext)
- sendto_one(to, ":%s QUIT :%s", target_p->name, comment);
- for (target_p = source_p->serv->servers; target_p; target_p = target_p->lnext)
- recurse_send_quits(client_p, target_p, to, comment, myname);
- }
- else
- sendto_one(to, "SQUIT %s :%s", source_p->name, me.name);
- }
- else
- {
- for (target_p = source_p->serv->users; target_p; target_p = target_p->lnext)
+ for (target_p = source_p->serv->users; target_p;
+ target_p = target_p->lnext)
sendto_one(to, ":%s QUIT :%s", target_p->name, comment);
- for (target_p = source_p->serv->servers; target_p; target_p = target_p->lnext)
+ for (target_p = source_p->serv->servers; target_p;
+ target_p = target_p->lnext)
recurse_send_quits(client_p, target_p, to, comment, myname);
- if (!match(myname, source_p->name))
- sendto_one(to, "SQUIT %s :%s", source_p->name, me.name);
}
+ else
+ sendto_one(to, "SQUIT %s :%s", source_p->name, me.name);
+ }
+ else
+ {
+ for (target_p = source_p->serv->users; target_p;
+ target_p = target_p->lnext)
+ sendto_one(to, ":%s QUIT :%s", target_p->name, comment);
+ for (target_p = source_p->serv->servers; target_p;
+ target_p = target_p->lnext)
+ recurse_send_quits(client_p, target_p, to, comment, myname);
+ if (!match(myname, source_p->name))
+ sendto_one(to, "SQUIT %s :%s", source_p->name, me.name);
+ }
}
/*
/*
* added sanity test code.... source_p->serv might be NULL...
*/
-static void recurse_remove_clients(struct Client* source_p, const char* comment)
+static void
+recurse_remove_clients(struct Client *source_p, const char *comment)
{
struct Client *target_p;
if (IsMe(source_p))
return;
- if (!source_p->serv) /* oooops. uh this is actually a major bug */
+ if (!source_p->serv) /* oooops. uh this is actually a major bug */
return;
- while ( (target_p = source_p->serv->servers) )
- {
- recurse_remove_clients(target_p, comment);
- /*
- ** a server marked as "KILLED" won't send a SQUIT
- ** in exit_one_client() -orabidoo
- */
- target_p->flags |= FLAGS_KILLED;
- exit_one_client(NULL, target_p, &me, me.name);
- }
-
- while ( (target_p = source_p->serv->users) )
- {
- target_p->flags |= FLAGS_KILLED;
- exit_one_client(NULL, target_p, &me, comment);
- }
+ while ((target_p = source_p->serv->servers))
+ {
+ recurse_remove_clients(target_p, comment);
+ /*
+ ** a server marked as "KILLED" won't send a SQUIT
+ ** in exit_one_client() -orabidoo
+ */
+ target_p->flags |= FLAGS_KILLED;
+ exit_one_client(NULL, target_p, &me, me.name);
+ }
+
+ while ((target_p = source_p->serv->users))
+ {
+ target_p->flags |= FLAGS_KILLED;
+ exit_one_client(NULL, target_p, &me, comment);
+ }
}
/*
** all necessary QUITs and SQUITs. source_p itself is still on the lists,
** and its SQUITs have been sent except for the upstream one -orabidoo
*/
-static void remove_dependents(struct Client* client_p,
- struct Client* source_p,
- struct Client* from,
- const char* comment,
- const char* comment1)
+static void
+remove_dependents(struct Client *client_p,
+ struct Client *source_p,
+ struct Client *from,
+ const char *comment, const char *comment1)
{
struct Client *to;
struct ConfItem *aconf;
- static char myname[HOSTLEN+1];
+ static char myname[HOSTLEN + 1];
dlink_node *ptr;
- for(ptr = serv_list.head; ptr; ptr=ptr->next)
- {
- to = ptr->data;
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
+ {
+ to = ptr->data;
- if (IsMe(to) ||to == source_p->from || (to == client_p && IsCapable(to,CAP_QS)))
- continue;
+ if (IsMe(to) || to == source_p->from
+ || (to == client_p && IsCapable(to, CAP_QS)))
+ continue;
- /* MyConnect(source_p) is rotten at this point: if source_p
- * was mine, ->from is NULL.
- */
- /* The WALLOPS isn't needed here as pointed out by
- * comstud, since m_squit already does the notification.
- */
+ /* MyConnect(source_p) is rotten at this point: if source_p
+ * was mine, ->from is NULL.
+ */
+ /* The WALLOPS isn't needed here as pointed out by
+ * comstud, since m_squit already does the notification.
+ */
- if ((aconf = to->serv->sconf))
- strncpy_irc(myname, my_name_for_link(me.name, aconf), HOSTLEN);
- else
- strncpy_irc(myname, me.name, HOSTLEN);
- recurse_send_quits(client_p, source_p, to, comment1, myname);
- }
+ if ((aconf = to->serv->sconf))
+ strncpy_irc(myname, my_name_for_link(me.name, aconf), HOSTLEN);
+ else
+ strncpy_irc(myname, me.name, HOSTLEN);
+ recurse_send_quits(client_p, source_p, to, comment1, myname);
+ }
recurse_remove_clients(source_p, comment1);
}
** CLIENT_EXITED if (client_p == source_p)
** 0 if (client_p != source_p)
*/
-int exit_client(
-struct Client* client_p, /*
- ** The local client originating the exit or NULL, if this
- ** exit is generated by this server for internal reasons.
- ** This will not get any of the generated messages.
- */
-struct Client* source_p, /* Client exiting */
-struct Client* from, /* Client firing off this Exit, never NULL! */
-const char* comment /* Reason for the exit */
- )
+int
+exit_client(struct Client *client_p, /*
+ ** The local client originating the exit or NULL, if this
+ ** exit is generated by this server for internal reasons.
+ ** This will not get any of the generated messages.
+ */
+ struct Client *source_p, /* Client exiting */
+ struct Client *from, /* Client firing off this Exit, never NULL! */
+ const char *comment /* Reason for the exit */
+ )
{
- struct Client *target_p;
- struct Client *next;
+ struct Client *target_p;
+ struct Client *next;
char comment1[HOSTLEN + HOSTLEN + 2];
dlink_node *m;
/* source_p->flags |= FLAGS_DEADSOCKET; */
if (MyConnect(source_p))
+ {
+ /* Attempt to flush any queued data */
+ if (source_p->fd > -1)
+ send_queued_write(source_p->fd, source_p);
+ if (source_p->flags & FLAGS_IPHASH)
+ remove_one_ip(&source_p->localClient->ip);
+
+ delete_adns_queries(source_p->localClient->dns_query);
+ delete_identd_queries(source_p);
+ client_flush_input(source_p);
+
+ /* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING
+ * STAT_HANDSHAKE or STAT_UNKNOWN
+ * all of which are lumped together into unknown_list
+ *
+ * In all above cases IsRegistered() will not be true.
+ */
+ if (!IsRegistered(source_p))
{
- /* Attempt to flush any queued data */
- if (source_p->fd > -1)
- send_queued_write(source_p->fd, source_p);
- if (source_p->flags & FLAGS_IPHASH)
- remove_one_ip(&source_p->localClient->ip);
-
- delete_adns_queries(source_p->localClient->dns_query);
- delete_identd_queries(source_p);
- client_flush_input(source_p);
-
- /* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING
- * STAT_HANDSHAKE or STAT_UNKNOWN
- * all of which are lumped together into unknown_list
- *
- * In all above cases IsRegistered() will not be true.
- */
- if (!IsRegistered(source_p))
- {
- m = dlinkFind(&unknown_list,source_p);
- if( m != NULL )
- {
- dlinkDelete(m, &unknown_list);
- free_dlink_node(m);
- }
- }
- if (IsOper(source_p))
- {
- m = dlinkFind(&oper_list,source_p);
- if( m != NULL )
- {
- dlinkDelete(m, &oper_list);
- free_dlink_node(m);
- }
- }
- if (IsClient(source_p))
- {
- Count.local--;
-
- if(IsPerson(source_p)) /* a little extra paranoia */
- {
- m = dlinkFind(&lclient_list,source_p);
- if( m != NULL )
- {
- dlinkDelete(m,&lclient_list);
- free_dlink_node(m);
- }
- }
- }
+ m = dlinkFind(&unknown_list, source_p);
+ if (m != NULL)
+ {
+ dlinkDelete(m, &unknown_list);
+ free_dlink_node(m);
+ }
+ }
+ if (IsOper(source_p))
+ {
+ m = dlinkFind(&oper_list, source_p);
+ if (m != NULL)
+ {
+ dlinkDelete(m, &oper_list);
+ free_dlink_node(m);
+ }
+ }
+ if (IsClient(source_p))
+ {
+ Count.local--;
- /* As soon as a client is known to be a server of some sort
- * it has to be put on the serv_list, or SJOIN's to this new server
- * from the connect burst will not be seen.
- */
- if (IsServer(source_p) || IsConnecting(source_p) ||
- IsHandshake(source_p))
- {
- m = dlinkFind(&serv_list,source_p);
- if( m != NULL )
- {
- dlinkDelete(m,&serv_list);
- free_dlink_node(m);
- unset_chcap_usage_counts(source_p);
- }
- }
-
- if (IsServer(source_p))
+ if (IsPerson(source_p)) /* a little extra paranoia */
+ {
+ m = dlinkFind(&lclient_list, source_p);
+ if (m != NULL)
{
- Count.myserver--;
- if(ServerInfo.hub)
- remove_lazylink_flags(source_p->localClient->serverMask);
- else
- uplink = NULL;
+ dlinkDelete(m, &lclient_list);
+ free_dlink_node(m);
}
+ }
+ }
- source_p->flags |= FLAGS_CLOSING;
-
- if (IsPerson(source_p))
- sendto_realops_flags(FLAGS_CCONN, L_ALL,
- "Client exiting: %s (%s@%s) [%s] [%s]",
- source_p->name, source_p->username, source_p->host,
- comment, source_p->localClient->sockhost);
-
- log_user_exit(source_p);
-
- if (source_p->fd >= 0)
- {
- if (client_p != NULL && source_p != client_p)
- sendto_one(source_p, "ERROR :Closing Link: %s %s (%s)",
- source_p->host, source_p->name, comment);
- else
- sendto_one(source_p, "ERROR :Closing Link: %s (%s)",
- source_p->host, comment);
- }
- /*
- ** Currently only server connections can have
- ** depending remote clients here, but it does no
- ** harm to check for all local clients. In
- ** future some other clients than servers might
- ** have remotes too...
- **
- ** Close the Client connection first and mark it
- ** so that no messages are attempted to send to it.
- ** (The following *must* make MyConnect(source_p) == FALSE!).
- ** It also makes source_p->from == NULL, thus it's unnecessary
- ** to test whether "source_p != target_p" in the following loops.
- */
- close_connection(source_p);
+ /* As soon as a client is known to be a server of some sort
+ * it has to be put on the serv_list, or SJOIN's to this new server
+ * from the connect burst will not be seen.
+ */
+ if (IsServer(source_p) || IsConnecting(source_p) || IsHandshake(source_p))
+ {
+ m = dlinkFind(&serv_list, source_p);
+ if (m != NULL)
+ {
+ dlinkDelete(m, &serv_list);
+ free_dlink_node(m);
+ unset_chcap_usage_counts(source_p);
+ }
}
- if(IsServer(source_p))
- {
- if(ConfigServerHide.hide_servers)
- {
- /*
- ** Replaces the name of the splitting server with
- ** a.server.on.<networkname>.net
- ** when a client exits from a split, in an attempt to
- ** hide topology but let clients detect a split still.
- */
- ircsprintf(comment1,"%s a.server.on.%s.net",me.name, ServerInfo.network_name);
- }
+ if (IsServer(source_p))
+ {
+ Count.myserver--;
+ if (ServerInfo.hub)
+ remove_lazylink_flags(source_p->localClient->serverMask);
+ else
+ uplink = NULL;
+ }
+
+ source_p->flags |= FLAGS_CLOSING;
+
+ if (IsPerson(source_p))
+ sendto_realops_flags(FLAGS_CCONN, L_ALL,
+ "Client exiting: %s (%s@%s) [%s] [%s]",
+ source_p->name, source_p->username, source_p->host,
+ comment, source_p->localClient->sockhost);
+
+ log_user_exit(source_p);
+
+ if (source_p->fd >= 0)
+ {
+ if (client_p != NULL && source_p != client_p)
+ sendto_one(source_p, "ERROR :Closing Link: %s %s (%s)",
+ source_p->host, source_p->name, comment);
+ else
+ sendto_one(source_p, "ERROR :Closing Link: %s (%s)",
+ source_p->host, comment);
+ }
+ /*
+ ** Currently only server connections can have
+ ** depending remote clients here, but it does no
+ ** harm to check for all local clients. In
+ ** future some other clients than servers might
+ ** have remotes too...
+ **
+ ** Close the Client connection first and mark it
+ ** so that no messages are attempted to send to it.
+ ** (The following *must* make MyConnect(source_p) == FALSE!).
+ ** It also makes source_p->from == NULL, thus it's unnecessary
+ ** to test whether "source_p != target_p" in the following loops.
+ */
+ close_connection(source_p);
+ }
+
+ if (IsServer(source_p))
+ {
+ if (ConfigServerHide.hide_servers)
+ {
+ /*
+ ** Replaces the name of the splitting server with
+ ** a.server.on.<networkname>.net
+ ** when a client exits from a split, in an attempt to
+ ** hide topology but let clients detect a split still.
+ */
+ ircsprintf(comment1, "%s a.server.on.%s.net", me.name,
+ ServerInfo.network_name);
+ }
+ else
+ {
+ if ((source_p->serv) && (source_p->serv->up))
+ strcpy(comment1, source_p->serv->up);
else
- {
- if((source_p->serv) && (source_p->serv->up))
- strcpy(comment1, source_p->serv->up);
- else
- strcpy(comment1, "<Unknown>" );
+ strcpy(comment1, "<Unknown>");
- strcat(comment1," ");
- strcat(comment1, source_p->name);
- }
+ strcat(comment1, " ");
+ strcat(comment1, source_p->name);
+ }
- remove_dependents(client_p, source_p, from, comment, comment1);
+ remove_dependents(client_p, source_p, from, comment, comment1);
- if (source_p->servptr == &me)
+ if (source_p->servptr == &me)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s was connected for %d seconds. %d/%d sendK/recvK.",
+ source_p->name,
+ (int)(CurrentTime - source_p->firsttime),
+ source_p->localClient->sendK,
+ source_p->localClient->receiveK);
+ ilog(L_NOTICE, "%s was connected for %d seconds. %d/%d sendK/recvK.",
+ source_p->name, CurrentTime - source_p->firsttime,
+ source_p->localClient->sendK, source_p->localClient->receiveK);
+
+ /* Just for paranoia... this shouldn't be necessary if the
+ ** remove_dependents() stuff works, but it's still good
+ ** to do it. MyConnect(source_p) has been set to false,
+ ** so we look at servptr, which should be ok -orabidoo
+ */
+ for (target_p = GlobalClientList; target_p; target_p = next)
+ {
+ next = target_p->next;
+ if (!IsServer(target_p) && target_p->from == source_p)
{
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s was connected for %d seconds. %d/%d sendK/recvK.",
- source_p->name, (int)(CurrentTime - source_p->firsttime),
- source_p->localClient->sendK,
- source_p->localClient->receiveK);
- ilog(L_NOTICE, "%s was connected for %d seconds. %d/%d sendK/recvK.",
- source_p->name, CurrentTime - source_p->firsttime,
- source_p->localClient->sendK, source_p->localClient->receiveK);
-
- /* Just for paranoia... this shouldn't be necessary if the
- ** remove_dependents() stuff works, but it's still good
- ** to do it. MyConnect(source_p) has been set to false,
- ** so we look at servptr, which should be ok -orabidoo
- */
- for (target_p = GlobalClientList; target_p; target_p = next)
- {
- next = target_p->next;
- if (!IsServer(target_p) && target_p->from == source_p)
- {
- ts_warn("Dependent client %s not on llist!?",
- target_p->name);
- exit_one_client(NULL, target_p, &me, comment1);
- }
- }
- /*
- ** Second SQUIT all servers behind this link
- */
- for (target_p = GlobalClientList; target_p; target_p = next)
- {
- next = target_p->next;
- if (IsServer(target_p) && target_p->from == source_p)
- {
- ts_warn("Dependent server %s not on llist!?",
- target_p->name);
- exit_one_client(NULL, target_p, &me, me.name);
- }
- }
- }
+ ts_warn("Dependent client %s not on llist!?", target_p->name);
+ exit_one_client(NULL, target_p, &me, comment1);
}
+ }
+ /*
+ ** Second SQUIT all servers behind this link
+ */
+ for (target_p = GlobalClientList; target_p; target_p = next)
+ {
+ next = target_p->next;
+ if (IsServer(target_p) && target_p->from == source_p)
+ {
+ ts_warn("Dependent server %s not on llist!?", target_p->name);
+ exit_one_client(NULL, target_p, &me, me.name);
+ }
+ }
+ }
+ }
exit_one_client(client_p, source_p, from, comment);
return client_p == source_p ? CLIENT_EXITED : 0;
*/
/* XXX one common Client list now */
-void count_local_client_memory(int *count,
- int *local_client_memory_used)
+void
+count_local_client_memory(int *count, int *local_client_memory_used)
{
*count = local_client_count;
*local_client_memory_used = local_client_count *
/*
* Count up remote client memory
*/
-void count_remote_client_memory(int *count,
- int *remote_client_memory_used)
+void
+count_remote_client_memory(int *count, int *remote_client_memory_used)
{
*count = remote_client_count;
*remote_client_memory_used = remote_client_count * sizeof(struct Client);
* output - 1 if accept this message 0 if not
* side effects - See if source is on target's allow list
*/
-int accept_message(struct Client *source, struct Client *target)
+int
+accept_message(struct Client *source, struct Client *target)
{
dlink_node *ptr;
struct Client *target_p;
- for(ptr = target->allow_list.head; ptr; ptr = ptr->next )
- {
- target_p = ptr->data;
- if(source == target_p)
- return 1;
- }
+ for (ptr = target->allow_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
+ if (source == target_p)
+ return 1;
+ }
return 0;
}
* Walk through the target's accept list, remove if source is found,
* Then walk through the source's on_accept_list remove target if found.
*/
-void del_from_accept(struct Client *source, struct Client *target)
+void
+del_from_accept(struct Client *source, struct Client *target)
{
dlink_node *ptr;
dlink_node *ptr2;
struct Client *target_p;
for (ptr = target->allow_list.head; ptr; ptr = next_ptr)
+ {
+ next_ptr = ptr->next;
+
+ target_p = ptr->data;
+ if (source == target_p)
{
- next_ptr = ptr->next;
-
- target_p = ptr->data;
- if(source == target_p)
- {
- dlinkDelete(ptr, &target->allow_list);
- free_dlink_node(ptr);
-
- for (ptr2 = source->on_allow_list.head; ptr2;
- ptr2 = next_ptr2)
- {
- next_ptr2 = ptr2->next;
-
- target_p = ptr2->data;
- if (target == target_p)
- {
- dlinkDelete(ptr2, &source->on_allow_list);
- free_dlink_node(ptr2);
- }
- }
- }
+ dlinkDelete(ptr, &target->allow_list);
+ free_dlink_node(ptr);
+
+ for (ptr2 = source->on_allow_list.head; ptr2; ptr2 = next_ptr2)
+ {
+ next_ptr2 = ptr2->next;
+
+ target_p = ptr2->data;
+ if (target == target_p)
+ {
+ dlinkDelete(ptr2, &source->on_allow_list);
+ free_dlink_node(ptr2);
+ }
+ }
}
+ }
}
/*
* side effects - Walk through given clients allow_list and on_allow_list
* remove all references to this client
*/
-void del_all_accepts(struct Client *client_p)
+void
+del_all_accepts(struct Client *client_p)
{
dlink_node *ptr;
dlink_node *next_ptr;
struct Client *target_p;
for (ptr = client_p->allow_list.head; ptr; ptr = next_ptr)
- {
- next_ptr = ptr->next;
- target_p = ptr->data;
- if(target_p != NULL)
- del_from_accept(target_p,client_p);
- }
+ {
+ next_ptr = ptr->next;
+ target_p = ptr->data;
+ if (target_p != NULL)
+ del_from_accept(target_p, client_p);
+ }
for (ptr = client_p->on_allow_list.head; ptr; ptr = next_ptr)
- {
- next_ptr = ptr->next;
- target_p = ptr->data;
- if(target_p != NULL)
- del_from_accept(client_p, target_p);
- }
+ {
+ next_ptr = ptr->next;
+ target_p = ptr->data;
+ if (target_p != NULL)
+ del_from_accept(client_p, target_p);
+ }
}
* client.
*/
int
-set_initial_nick(struct Client *client_p, struct Client *source_p,
- char *nick)
+set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick)
{
- char buf[USERLEN + 1];
- /* Client setting NICK the first time */
-
- /* This had to be copied here to avoid problems.. */
- source_p->tsinfo = CurrentTime;
- if (source_p->name[0])
- del_from_client_hash_table(source_p->name, source_p);
- strcpy(source_p->name, nick);
- add_to_client_hash_table(nick, source_p);
- /* fd_desc is long enough */
- fd_note(client_p->fd, "Nick: %s", nick);
-
- /* They have the nick they want now.. */
- *client_p->llname = '\0';
-
- if (source_p->user)
- {
- strncpy_irc(buf, source_p->username, USERLEN);
- buf[USERLEN] = '\0';
- /*
- * USER already received, now we have NICK.
- * *NOTE* For servers "NICK" *must* precede the
- * user message (giving USER before NICK is possible
- * only for local client connection!). register_user
- * may reject the client and call exit_client for it
- * --must test this and exit m_nick too!!!
- */
+ char buf[USERLEN + 1];
+ /* Client setting NICK the first time */
+
+ /* This had to be copied here to avoid problems.. */
+ source_p->tsinfo = CurrentTime;
+ if (source_p->name[0])
+ del_from_client_hash_table(source_p->name, source_p);
+ strcpy(source_p->name, nick);
+ add_to_client_hash_table(nick, source_p);
+ /* fd_desc is long enough */
+ fd_note(client_p->fd, "Nick: %s", nick);
+
+ /* They have the nick they want now.. */
+ *client_p->llname = '\0';
+
+ if (source_p->user)
+ {
+ strncpy_irc(buf, source_p->username, USERLEN);
+ buf[USERLEN] = '\0';
+ /*
+ * USER already received, now we have NICK.
+ * *NOTE* For servers "NICK" *must* precede the
+ * user message (giving USER before NICK is possible
+ * only for local client connection!). register_user
+ * may reject the client and call exit_client for it
+ * --must test this and exit m_nick too!!!
+ */
#ifdef USE_IAUTH
- /*
- * Send the client to the iauth module for verification
- */
- BeginAuthorization(source_p);
+ /*
+ * Send the client to the iauth module for verification
+ */
+ BeginAuthorization(source_p);
#else
- if (register_local_user(client_p, source_p, nick, buf) == CLIENT_EXITED)
- return CLIENT_EXITED;
+ if (register_local_user(client_p, source_p, nick, buf) == CLIENT_EXITED)
+ return CLIENT_EXITED;
#endif
- }
- return 0;
+ }
+ return 0;
}
/*
* side effects - changes nick of a LOCAL user
*
*/
-int change_local_nick(struct Client *client_p, struct Client *source_p,
- char *nick)
+int
+change_local_nick(struct Client *client_p, struct Client *source_p,
+ char *nick)
{
/*
- ** Client just changing his/her nick. If he/she is
- ** on a channel, send note of change to all clients
- ** on that channel. Propagate notice to other servers.
- */
+ ** Client just changing his/her nick. If he/she is
+ ** on a channel, send note of change to all clients
+ ** on that channel. Propagate notice to other servers.
+ */
source_p->tsinfo = CurrentTime;
- if( (source_p->localClient->last_nick_change +
+ if ((source_p->localClient->last_nick_change +
ConfigFileEntry.max_nick_time) < CurrentTime)
source_p->localClient->number_of_nick_changes = 0;
source_p->localClient->last_nick_change = CurrentTime;
source_p->localClient->number_of_nick_changes++;
- if((ConfigFileEntry.anti_nick_flood &&
- (source_p->localClient->number_of_nick_changes
- <= ConfigFileEntry.max_nick_changes)) ||
- !ConfigFileEntry.anti_nick_flood ||
- (IsOper(source_p) && ConfigFileEntry.no_oper_flood))
+ if ((ConfigFileEntry.anti_nick_flood &&
+ (source_p->localClient->number_of_nick_changes
+ <= ConfigFileEntry.max_nick_changes)) ||
+ !ConfigFileEntry.anti_nick_flood ||
+ (IsOper(source_p) && ConfigFileEntry.no_oper_flood))
+ {
+ sendto_realops_flags(FLAGS_NCHANGE, L_ALL,
+ "Nick change: From %s to %s [%s@%s]",
+ source_p->name, nick, source_p->username,
+ source_p->host);
+
+ sendto_common_channels_local(source_p, ":%s!%s@%s NICK :%s",
+ source_p->name, source_p->username,
+ source_p->host, nick);
+ if (source_p->user)
{
- sendto_realops_flags(FLAGS_NCHANGE, L_ALL,
- "Nick change: From %s to %s [%s@%s]",
- source_p->name, nick, source_p->username,
- source_p->host);
-
- sendto_common_channels_local(source_p, ":%s!%s@%s NICK :%s",
- source_p->name, source_p->username, source_p->host,
- nick);
- if (source_p->user)
- {
- add_history(source_p,1);
-
- /* Only hubs care about lazy link nicks not being sent on yet
- * lazylink leafs/leafs always send their nicks up to hub,
- * hence must always propogate nick changes.
- * hubs might not propogate a nick change, if the leaf
- * does not know about that client yet.
- */
- sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS,
- NOFLAGS, ":%s NICK %s :%lu", source_p->name,
- nick, (unsigned long) source_p->tsinfo);
- }
+ add_history(source_p, 1);
+
+ /* Only hubs care about lazy link nicks not being sent on yet
+ * lazylink leafs/leafs always send their nicks up to hub,
+ * hence must always propogate nick changes.
+ * hubs might not propogate a nick change, if the leaf
+ * does not know about that client yet.
+ */
+ sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS,
+ NOFLAGS, ":%s NICK %s :%lu", source_p->name,
+ nick, (unsigned long)source_p->tsinfo);
}
+ }
else
- {
- sendto_one(source_p,
- form_str(ERR_NICKTOOFAST),me.name, source_p->name,
- source_p->name, nick, ConfigFileEntry.max_nick_time);
- return 0;
- }
+ {
+ sendto_one(source_p,
+ form_str(ERR_NICKTOOFAST), me.name, source_p->name,
+ source_p->name, nick, ConfigFileEntry.max_nick_time);
+ return 0;
+ }
/* Finally, add to hash */
del_from_client_hash_table(source_p->name, source_p);
return 1;
}
-
-
* ----------------------------------------------------------------------------
*
* $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $
- *
+ * $Id: crypt.c,v 1.2 2002/01/04 11:06:39 a1kmm Exp $
*/
#include <unistd.h>
typedef unsigned int u_int32_t;
/* MD5 context. */
-typedef struct MD5Context {
- u_int32_t state[4]; /* state (ABCD) */
- u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
+typedef struct MD5Context
+{
+ u_int32_t state[4]; /* state (ABCD) */
+ u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
-} MD5_CTX;
+}
+MD5_CTX;
-void MD5Init (MD5_CTX *);
-void MD5Update (MD5_CTX *, const unsigned char *, unsigned int);
-void MD5Pad (MD5_CTX *);
-void MD5Final (unsigned char [16], MD5_CTX *);
-char * MD5End(MD5_CTX *, char *);
-char * MD5File(const char *, char *);
-char * MD5Data(const unsigned char *, unsigned int, char *);
+void MD5Init(MD5_CTX *);
+void MD5Update(MD5_CTX *, const unsigned char *, unsigned int);
+void MD5Pad(MD5_CTX *);
+void MD5Final(unsigned char[16], MD5_CTX *);
+char *MD5End(MD5_CTX *, char *);
+char *MD5File(const char *, char *);
+char *MD5Data(const unsigned char *, unsigned int, char *);
-static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
+ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
void
_crypt_to64(s, v, n)
- char *s;
- unsigned long v;
- int n;
+ char *s;
+ unsigned long v;
+ int n;
{
- while (--n >= 0) {
- *s++ = itoa64[v&0x3f];
- v >>= 6;
- }
+ while (--n >= 0)
+ {
+ *s++ = itoa64[v & 0x3f];
+ v >>= 6;
+ }
}
/*
char *
crypt(const char *pw, const char *salt)
{
- static char *magic = "$1$"; /*
- * This string is magic for
- * this algorithm. Having
- * it this way, we can get
- * get better later on
- */
- static char passwd[120], *p;
- static const char *sp,*ep;
- unsigned char final[MD5_SIZE];
- int sl,pl,i;
- MD5_CTX ctx,ctx1;
- unsigned long l;
-
- /* Refine the Salt first */
- sp = salt;
-
- /* If it starts with the magic string, then skip that */
- if(!strncmp(sp,magic,strlen(magic)))
- sp += strlen(magic);
-
- /* It stops at the first '$', max 8 chars */
- for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
- continue;
-
- /* get the length of the true salt */
- sl = ep - sp;
-
- MD5Init(&ctx);
-
- /* The password first, since that is what is most unknown */
- MD5Update(&ctx,(const unsigned char *)pw,strlen(pw));
-
- /* Then our magic string */
- MD5Update(&ctx,(const unsigned char *)magic,strlen(magic));
-
- /* Then the raw salt */
- MD5Update(&ctx,(const unsigned char *)sp,sl);
-
- /* Then just as many characters of the MD5(pw,salt,pw) */
- MD5Init(&ctx1);
- MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
- MD5Update(&ctx1,(const unsigned char *)sp,sl);
- MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
- MD5Final(final,&ctx1);
- for(pl = strlen(pw); pl > 0; pl -= MD5_SIZE)
- MD5Update(&ctx,final,pl>MD5_SIZE ? MD5_SIZE : pl);
-
- /* Don't leave anything around in vm they could use. */
- memset(final,0,sizeof final);
-
- /* Then something really weird... */
- for (i = strlen(pw); i ; i >>= 1)
- if(i&1)
- MD5Update(&ctx, final, 1);
- else
- MD5Update(&ctx, (const unsigned char *)pw, 1);
-
- /* Now make the output string */
- strcpy(passwd,magic);
- strncat(passwd,sp,sl);
- strcat(passwd,"$");
-
- MD5Final(final,&ctx);
-
- /*
- * and now, just to make sure things don't run too fast
- * On a 60 Mhz Pentium this takes 34 msec, so you would
- * need 30 seconds to build a 1000 entry dictionary...
- */
- for(i=0;i<1000;i++) {
- MD5Init(&ctx1);
- if(i & 1)
- MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
- else
- MD5Update(&ctx1,final,MD5_SIZE);
-
- if(i % 3)
- MD5Update(&ctx1,(const unsigned char *)sp,sl);
-
- if(i % 7)
- MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
-
- if(i & 1)
- MD5Update(&ctx1,final,MD5_SIZE);
- else
- MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
- MD5Final(final,&ctx1);
- }
-
- p = passwd + strlen(passwd);
-
- l = (final[ 0]<<16) | (final[ 6]<<8) | final[12];
- _crypt_to64(p,l,4); p += 4;
- l = (final[ 1]<<16) | (final[ 7]<<8) | final[13];
- _crypt_to64(p,l,4); p += 4;
- l = (final[ 2]<<16) | (final[ 8]<<8) | final[14];
- _crypt_to64(p,l,4); p += 4;
- l = (final[ 3]<<16) | (final[ 9]<<8) | final[15];
- _crypt_to64(p,l,4); p += 4;
- l = (final[ 4]<<16) | (final[10]<<8) | final[ 5];
- _crypt_to64(p,l,4); p += 4;
- l = final[11] ;
- _crypt_to64(p,l,2); p += 2;
- *p = '\0';
-
- /* Don't leave anything around in vm they could use. */
- memset(final,0,sizeof final);
-
- return passwd;
+ static char *magic = "$1$"; /*
+ * This string is magic for
+ * this algorithm. Having
+ * it this way, we can get
+ * get better later on
+ */
+ static char passwd[120], *p;
+ static const char *sp, *ep;
+ unsigned char final[MD5_SIZE];
+ int sl, pl, i;
+ MD5_CTX ctx, ctx1;
+ unsigned long l;
+
+ /* Refine the Salt first */
+ sp = salt;
+
+ /* If it starts with the magic string, then skip that */
+ if (!strncmp(sp, magic, strlen(magic)))
+ sp += strlen(magic);
+
+ /* It stops at the first '$', max 8 chars */
+ for (ep = sp; *ep && *ep != '$' && ep < (sp + 8); ep++)
+ continue;
+
+ /* get the length of the true salt */
+ sl = ep - sp;
+
+ MD5Init(&ctx);
+
+ /* The password first, since that is what is most unknown */
+ MD5Update(&ctx, (const unsigned char *)pw, strlen(pw));
+
+ /* Then our magic string */
+ MD5Update(&ctx, (const unsigned char *)magic, strlen(magic));
+
+ /* Then the raw salt */
+ MD5Update(&ctx, (const unsigned char *)sp, sl);
+
+ /* Then just as many characters of the MD5(pw,salt,pw) */
+ MD5Init(&ctx1);
+ MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw));
+ MD5Update(&ctx1, (const unsigned char *)sp, sl);
+ MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw));
+ MD5Final(final, &ctx1);
+ for (pl = strlen(pw); pl > 0; pl -= MD5_SIZE)
+ MD5Update(&ctx, final, pl > MD5_SIZE ? MD5_SIZE : pl);
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final, 0, sizeof final);
+
+ /* Then something really weird... */
+ for (i = strlen(pw); i; i >>= 1)
+ if (i & 1)
+ MD5Update(&ctx, final, 1);
+ else
+ MD5Update(&ctx, (const unsigned char *)pw, 1);
+
+ /* Now make the output string */
+ strcpy(passwd, magic);
+ strncat(passwd, sp, sl);
+ strcat(passwd, "$");
+
+ MD5Final(final, &ctx);
+
+ /*
+ * and now, just to make sure things don't run too fast
+ * On a 60 Mhz Pentium this takes 34 msec, so you would
+ * need 30 seconds to build a 1000 entry dictionary...
+ */
+ for (i = 0; i < 1000; i++)
+ {
+ MD5Init(&ctx1);
+ if (i & 1)
+ MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw));
+ else
+ MD5Update(&ctx1, final, MD5_SIZE);
+
+ if (i % 3)
+ MD5Update(&ctx1, (const unsigned char *)sp, sl);
+
+ if (i % 7)
+ MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw));
+
+ if (i & 1)
+ MD5Update(&ctx1, final, MD5_SIZE);
+ else
+ MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw));
+ MD5Final(final, &ctx1);
+ }
+
+ p = passwd + strlen(passwd);
+
+ l = (final[0] << 16) | (final[6] << 8) | final[12];
+ _crypt_to64(p, l, 4);
+ p += 4;
+ l = (final[1] << 16) | (final[7] << 8) | final[13];
+ _crypt_to64(p, l, 4);
+ p += 4;
+ l = (final[2] << 16) | (final[8] << 8) | final[14];
+ _crypt_to64(p, l, 4);
+ p += 4;
+ l = (final[3] << 16) | (final[9] << 8) | final[15];
+ _crypt_to64(p, l, 4);
+ p += 4;
+ l = (final[4] << 16) | (final[10] << 8) | final[5];
+ _crypt_to64(p, l, 4);
+ p += 4;
+ l = final[11];
+ _crypt_to64(p, l, 2);
+ p += 2;
+ *p = '\0';
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final, 0, sizeof final);
+
+ return passwd;
}
/*
#include <string.h>
-static void MD5Transform (u_int32_t [4], const unsigned char [64]);
+static void MD5Transform(u_int32_t[4], const unsigned char[64]);
/*
* Encodes input (u_int32_t) into output (unsigned char). Assumes len is
*/
static void
-Encode (output, input, len)
- unsigned char *output;
- u_int32_t *input;
- unsigned int len;
+Encode(output, input, len)
+ unsigned char *output;
+ u_int32_t *input;
+ unsigned int len;
{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (unsigned char)(input[i] & 0xff);
- output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
- }
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ {
+ output[j] = (unsigned char)(input[i] & 0xff);
+ output[j + 1] = (unsigned char)((input[i] >> 8) & 0xff);
+ output[j + 2] = (unsigned char)((input[i] >> 16) & 0xff);
+ output[j + 3] = (unsigned char)((input[i] >> 24) & 0xff);
+ }
}
/*
*/
static void
-Decode (output, input, len)
- u_int32_t *output;
- const unsigned char *input;
- unsigned int len;
+Decode(output, input, len)
+ u_int32_t *output;
+ const unsigned char *input;
+ unsigned int len;
{
- unsigned int i, j;
+ unsigned int i, j;
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((u_int32_t)input[j]) | (((u_int32_t)input[j+1]) << 8) |
- (((u_int32_t)input[j+2]) << 16) | (((u_int32_t)input[j+3]) << 24);
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ output[i] = ((u_int32_t) input[j]) | (((u_int32_t) input[j + 1]) << 8) |
+ (((u_int32_t) input[j + 2]) << 16) | (((u_int32_t) input[j + 3]) << 24);
}
static unsigned char PADDING[64] = {
/* MD5 initialization. Begins an MD5 operation, writing a new context. */
void
-MD5Init (context)
- MD5_CTX *context;
+MD5Init(context)
+ MD5_CTX *context;
{
- context->count[0] = context->count[1] = 0;
+ context->count[0] = context->count[1] = 0;
- /* Load magic initialization constants. */
- context->state[0] = 0x67452301;
- context->state[1] = 0xefcdab89;
- context->state[2] = 0x98badcfe;
- context->state[3] = 0x10325476;
+ /* Load magic initialization constants. */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xefcdab89;
+ context->state[2] = 0x98badcfe;
+ context->state[3] = 0x10325476;
}
/*
*/
void
-MD5Update (context, input, inputLen)
- MD5_CTX *context;
- const unsigned char *input;
- unsigned int inputLen;
+MD5Update(context, input, inputLen)
+ MD5_CTX *context;
+ const unsigned char *input;
+ unsigned int inputLen;
{
- unsigned int i, index, partLen;
+ unsigned int i, index, partLen;
- /* Compute number of bytes mod 64 */
- index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+ /* Compute number of bytes mod 64 */
+ index = (unsigned int)((context->count[0] >> 3) & 0x3F);
- /* Update number of bits */
- if ((context->count[0] += ((u_int32_t)inputLen << 3))
- < ((u_int32_t)inputLen << 3))
- context->count[1]++;
- context->count[1] += ((u_int32_t)inputLen >> 29);
+ /* Update number of bits */
+ if ((context->count[0] += ((u_int32_t) inputLen << 3))
+ < ((u_int32_t) inputLen << 3))
+ context->count[1]++;
+ context->count[1] += ((u_int32_t) inputLen >> 29);
- partLen = 64 - index;
+ partLen = 64 - index;
- /* Transform as many times as possible. */
- if (inputLen >= partLen) {
- memcpy((void *)&context->buffer[index], (const void *)input,
- partLen);
- MD5Transform (context->state, context->buffer);
+ /* Transform as many times as possible. */
+ if (inputLen >= partLen)
+ {
+ memcpy((void *)&context->buffer[index], (const void *)input, partLen);
+ MD5Transform(context->state, context->buffer);
- for (i = partLen; i + 63 < inputLen; i += 64)
- MD5Transform (context->state, &input[i]);
+ for (i = partLen; i + 63 < inputLen; i += 64)
+ MD5Transform(context->state, &input[i]);
- index = 0;
- }
- else
- i = 0;
+ index = 0;
+ }
+ else
+ i = 0;
- /* Buffer remaining input */
- memcpy ((void *)&context->buffer[index], (const void *)&input[i],
- inputLen-i);
+ /* Buffer remaining input */
+ memcpy((void *)&context->buffer[index], (const void *)&input[i],
+ inputLen - i);
}
/*
*/
void
-MD5Pad (context)
- MD5_CTX *context;
+MD5Pad(context)
+ MD5_CTX *context;
{
- unsigned char bits[8];
- unsigned int index, padLen;
+ unsigned char bits[8];
+ unsigned int index, padLen;
- /* Save number of bits */
- Encode (bits, context->count, 8);
+ /* Save number of bits */
+ Encode(bits, context->count, 8);
- /* Pad out to 56 mod 64. */
- index = (unsigned int)((context->count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
- MD5Update (context, PADDING, padLen);
+ /* Pad out to 56 mod 64. */
+ index = (unsigned int)((context->count[0] >> 3) & 0x3f);
+ padLen = (index < 56) ? (56 - index) : (120 - index);
+ MD5Update(context, PADDING, padLen);
- /* Append length (before padding) */
- MD5Update (context, bits, 8);
+ /* Append length (before padding) */
+ MD5Update(context, bits, 8);
}
/*
*/
void
-MD5Final (digest, context)
- unsigned char digest[16];
- MD5_CTX *context;
+MD5Final(digest, context)
+ unsigned char digest[16];
+ MD5_CTX *context;
{
- /* Do padding. */
- MD5Pad (context);
+ /* Do padding. */
+ MD5Pad(context);
- /* Store state in digest */
- Encode (digest, context->state, 16);
+ /* Store state in digest */
+ Encode(digest, context->state, 16);
- /* Zeroize sensitive information. */
- memset ((void *)context, 0, sizeof (*context));
+ /* Zeroize sensitive information. */
+ memset((void *)context, 0, sizeof(*context));
}
/* MD5 basic transformation. Transforms state based on block. */
static void
-MD5Transform (state, block)
- u_int32_t state[4];
- const unsigned char block[64];
+MD5Transform(state, block)
+ u_int32_t state[4];
+ const unsigned char block[64];
{
- u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+ u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
- Decode (x, block, 64);
+ Decode(x, block, 64);
- /* Round 1 */
+ /* Round 1 */
#define S11 7
#define S12 12
#define S13 17
#define S14 22
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
+ FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
+ FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
+ FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
+ FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
+ FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
+ FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
+ FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
+ FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
+ FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
+ FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
+ FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+ FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+ FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+ FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+ FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+ FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
#define S21 5
#define S22 9
#define S23 14
#define S24 20
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
+ GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
+ GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
+ GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+ GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
+ GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
+ GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+ GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
+ GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
+ GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+ GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
+ GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
+ GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+ GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
+ GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
+ GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
#define S31 4
#define S32 11
#define S33 16
#define S34 23
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
+ HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
+ HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
+ HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+ HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+ HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
+ HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
+ HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
+ HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+ HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+ HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
+ HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
+ HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
+ HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
+ HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+ HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+ HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
#define S41 6
#define S42 10
#define S43 15
#define S44 21
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information. */
- memset ((void *)x, 0, sizeof (x));
+ II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
+ II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
+ II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+ II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
+ II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+ II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
+ II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+ II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
+ II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
+ II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+ II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
+ II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+ II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
+ II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+ II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
+ II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ /* Zeroize sensitive information. */
+ memset((void *)x, 0, sizeof(x));
}
-/* debug.c - debugging functions */
+/* debug.c - debugging functions
+ * $Id: debug.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
+ */
#include <stdio.h>
#include <stdarg.h>
debug_tab dtab[] = {
/* the second field here is always 0, unless you
want this to be enabled by default.. */
- {"send", 0},
- {"error", 0},
+ {"send", 0}
+ ,
+ {"error", 0}
+ ,
{NULL, 0}
};
* This function creates a new debugging entity, with the name specified.
*/
-void
+void
add_mod_debug(char *what)
{
dmtab = realloc(dmtab, sizeof(debug_tab) * (num_debug_mod + 1));
* supplied is written to stdout. Otherwise no action is taken.
*/
-void
+void
deprintf(char *what, char *fmt, ...)
{
#ifdef DEBUGMODE
va_start(ap, fmt);
- if(!debugging(what))
- {
- return;
- }
+ if (!debugging(what))
+ {
+ return;
+ }
vsnprintf(buffer, sizeof(buffer) - 1, fmt, ap);
* to "to".
*/
-int
+int
set_debug(char *what, int to)
{
debug_tab *tab;
-
+
tab = find_debug_tab(what);
-
- if (tab)
- {
- tab->debugging = to;
- return 0;
- }
- else
- {
- return 1;
- }
+
+ if (tab)
+ {
+ tab->debugging = to;
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
}
/*
debug_tab *
find_debug_tab(char *what)
{
- int i;
+ int i;
debug_tab *tab = NULL;
- for (i = 0; dtab[i].name; i++)
+ for (i = 0; dtab[i].name; i++)
+ {
+ if (!strcmp(dtab[i].name, what))
{
- if (!strcmp(dtab[i].name, what))
- {
- tab = &dtab[i];
- }
+ tab = &dtab[i];
}
+ }
- for (i = 0; i < num_debug_mod; i++)
+ for (i = 0; i < num_debug_mod; i++)
+ {
+ if (!strcmp(dmtab[i].name, what))
{
- if (!strcmp(dmtab[i].name, what))
- {
- tab = &dtab[i];
- }
+ tab = &dtab[i];
}
+ }
return tab;
}
* Enables debugging for the entity "what", if it exists.
*/
-int
+int
enable_debug(char *what)
{
debug_tab *tab;
tab = find_debug_tab(what);
- if (tab)
- {
- tab->debugging = 1;
- return 0;
- }
+ if (tab)
+ {
+ tab->debugging = 1;
+ return 0;
+ }
/* else not found */
return -1;
}
* Disbles debugging for the entity "what", if it exists.
*/
-int
+int
disable_debug(char *what)
{
debug_tab *tab;
tab = find_debug_tab(what);
- if (tab)
- {
- tab->debugging = 0;
- return 0;
- }
-
+ if (tab)
+ {
+ tab->debugging = 0;
+ return 0;
+ }
+
/* else not found */
return -1;
}
* debugged.
*/
-int
+int
debugging(char *what)
{
debug_tab *tab;
tab = find_debug_tab(what);
- if (!tab)
+ if (!tab)
return 0;
return tab->debugging;
*
* This code was borrowed from the squid web cache by Adrian Chadd.
*
- * $Id: event.c,v 1.1 2002/01/04 09:13:56 a1kmm Exp $
+ * $Id: event.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*
* Original header follows:
*
*/
void
-eventAdd(const char *name, EVH *func, void *arg, time_t when)
+eventAdd(const char *name, EVH * func, void *arg, time_t when)
{
int i;
-
+
/* find first inactive index, or use next index */
for (i = 0; i < event_count; i++)
if (!event_table[i].active)
event_table[i].name = name;
event_table[i].arg = arg;
event_table[i].when = CurrentTime + when;
- event_table[i].frequency = when;
+ event_table[i].frequency = when;
event_table[i].active = 1;
if ((event_table[i].when < event_time_min) || (event_time_min == -1))
*/
void
-eventDelete(EVH *func, void *arg)
+eventDelete(EVH * func, void *arg)
{
int i;
-
+
i = eventFind(func, arg);
if (i == -1)
return;
-
+
event_table[i].name = NULL;
event_table[i].func = NULL;
event_table[i].arg = NULL;
* Side Effects: Adds the event to the event list within +- 1/3 of the
* specified frequency.
*/
-
+
void
-eventAddIsh(const char *name, EVH *func, void *arg, time_t delta_ish)
+eventAddIsh(const char *name, EVH * func, void *arg, time_t delta_ish)
{
if (delta_ish >= 3.0)
- {
- const time_t two_third = (2 * delta_ish) / 3;
- delta_ish = two_third + ((random() % 1000) * two_third) / 1000;
- /*
- * XXX I hate the above magic, I don't even know if its right.
- * Grr. -- adrian
- */
- }
+ {
+ const time_t two_third = (2 * delta_ish) / 3;
+ delta_ish = two_third + ((random() % 1000) * two_third) / 1000;
+ /*
+ * XXX I hate the above magic, I don't even know if its right.
+ * Grr. -- adrian
+ */
+ }
eventAdd(name, func, arg, delta_ish);
}
return;
for (i = 0; i < event_count; i++)
+ {
+ if (event_table[i].active && (event_table[i].when <= CurrentTime))
{
- if (event_table[i].active && (event_table[i].when <= CurrentTime))
- {
- last_event_ran = event_table[i].name;
- event_table[i].func(event_table[i].arg);
- event_table[i].when = CurrentTime + event_table[i].frequency;
- event_time_min = -1;
- }
+ last_event_ran = event_table[i].name;
+ event_table[i].func(event_table[i].arg);
+ event_table[i].when = CurrentTime + event_table[i].frequency;
+ event_time_min = -1;
}
+ }
}
* Output: Specifies the next time eventRun() should be run
* Side Effects: None
*/
-
+
time_t
eventNextTime(void)
{
int i;
if (event_count == 0)
- return (CurrentTime+1);
+ return (CurrentTime + 1);
else if (event_time_min == -1)
+ {
+ for (i = 0; i < event_count; i++)
{
- for (i = 0; i < event_count; i++)
- {
- if (event_table[i].active && ((event_table[i].when < event_time_min) || (event_time_min == -1)))
- event_time_min = event_table[i].when;
- }
+ if (event_table[i].active
+ && ((event_table[i].when < event_time_min)
+ || (event_time_min == -1)))
+ event_time_min = event_table[i].when;
}
+ }
return event_time_min;
}
*/
int
-eventFind(EVH *func, void *arg)
+eventFind(EVH * func, void *arg)
{
int i;
for (i = 0; i < event_count; i++)
- {
- if ((event_table[i].func == func) &&
- (event_table[i].arg == arg) &&
- event_table[i].active)
- return i;
- }
+ {
+ if ((event_table[i].func == func) &&
+ (event_table[i].arg == arg) && event_table[i].active)
+ return i;
+ }
return -1;
}
if (last_event_ran)
sendto_one(source_p, ":%s NOTICE %s :*** Last event to run: %s",
- me.name, source_p->name,
- last_event_ran);
+ me.name, source_p->name, last_event_ran);
sendto_one(source_p,
- ":%s NOTICE %s :*** Operation Next Execution",
- me.name, source_p->name);
+ ":%s NOTICE %s :*** Operation Next Execution",
+ me.name, source_p->name);
for (i = 0; i < event_count; i++)
+ {
+ if (event_table[i].active)
{
- if (event_table[i].active)
- {
- sendto_one(source_p,
- ":%s NOTICE %s :*** %-20s %-3d seconds",
- me.name, source_p->name, event_table[i].name,
- (int)(event_table[i].when - CurrentTime));
- }
+ sendto_one(source_p,
+ ":%s NOTICE %s :*** %-20s %-3d seconds",
+ me.name, source_p->name, event_table[i].name,
+ (int)(event_table[i].when - CurrentTime));
}
- sendto_one(source_p, ":%s NOTICE %s :*** Finished", me.name, source_p->name);
+ }
+ sendto_one(source_p, ":%s NOTICE %s :*** Finished", me.name,
+ source_p->name);
}
/*
else
event_table[i].when = 0;
}
-
-
* fdlist.c maintain lists of file descriptors
*
*
- * $Id: fdlist.c,v 1.1 2002/01/04 09:13:56 a1kmm Exp $
+ * $Id: fdlist.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include "fdlist.h"
-#include "client.h" /* struct Client */
+#include "client.h" /* struct Client */
#include "event.h"
-#include "ircd.h" /* GlobalSetOptions */
-#include "s_bsd.h" /* highest_fd */
-#include "config.h" /* option settings */
+#include "ircd.h" /* GlobalSetOptions */
+#include "s_bsd.h" /* highest_fd */
+#include "config.h" /* option settings */
#include "send.h"
#include "memory.h"
#include <stdarg.h>
static void fdlist_update_biggest(int fd, int opening);
/* Highest FD and number of open FDs .. */
-int highest_fd = -1; /* Its -1 because we haven't started yet -- adrian */
+int highest_fd = -1; /* Its -1 because we haven't started yet -- adrian */
int number_fd = 0;
static void
fdlist_update_biggest(int fd, int opening)
-{
+{
if (fd < highest_fd)
return;
assert(fd < MAXCONNECTIONS);
if (fd > highest_fd)
- {
- /*
- * assert that we are not closing a FD bigger than
- * our known biggest FD
- */
- assert(opening);
- highest_fd = fd;
- return;
- }
+ {
+ /*
+ * assert that we are not closing a FD bigger than
+ * our known biggest FD
+ */
+ assert(opening);
+ highest_fd = fd;
+ return;
+ }
/* if we are here, then fd == Biggest_FD */
/*
* assert that we are closing the biggest FD; we can't be
}
-void fdlist_init(void)
+void
+fdlist_init(void)
{
static int initialized = 0;
assert(0 == initialized);
if (!initialized)
- {
- /* Since we're doing this once .. */
- fd_table = MyMalloc((MAXCONNECTIONS + 1) * sizeof(fde_t));
- memset(fd_table, 0, sizeof(fde_t) * (MAXCONNECTIONS+1));
- initialized = 1;
- }
+ {
+ /* Since we're doing this once .. */
+ fd_table = MyMalloc((MAXCONNECTIONS + 1) * sizeof(fde_t));
+ memset(fd_table, 0, sizeof(fde_t) * (MAXCONNECTIONS + 1));
+ initialized = 1;
+ }
}
/* Called to open a given filedescriptor */
assert(fd >= 0);
if (F->flags.open)
- {
+ {
#ifdef NOTYET
- debug(51, 1) ("WARNING: Closing open FD %4d\n", fd);
+ debug(51, 1) ("WARNING: Closing open FD %4d\n", fd);
#endif
- fd_close(fd);
- }
+ fd_close(fd);
+ }
assert(!F->flags.open);
#ifdef NOTYET
debug(51, 3) ("fd_open FD %d %s\n", fd, desc);
/* All disk fd's MUST go through file_close() ! */
assert(F->type != FD_FILE);
if (F->type == FD_FILE)
- {
- assert(F->read_handler == NULL);
- assert(F->write_handler == NULL);
- }
+ {
+ assert(F->read_handler == NULL);
+ assert(F->write_handler == NULL);
+ }
#ifdef NOTYET
debug(51, 3) ("fd_close FD %d %s\n", fd, F->desc);
#endif
- comm_setselect(fd, FDLIST_NONE, COMM_SELECT_WRITE|COMM_SELECT_READ,
- NULL, NULL, 0);
+ comm_setselect(fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ,
+ NULL, NULL, 0);
F->flags.open = 0;
fdlist_update_biggest(fd, 0);
int i;
for (i = 0; i <= highest_fd; i++)
- {
- if (!fd_table[i].flags.open)
- continue;
-
- sendto_one(source_p, ":%s NOTICE %s :*** fd %d, desc '%s'", me.name,
- source_p->name, i, fd_table[i].desc);
- }
- sendto_one(source_p, ":%s NOTICE %s :*** Finished", me.name, source_p->name);
+ {
+ if (!fd_table[i].flags.open)
+ continue;
+
+ sendto_one(source_p, ":%s NOTICE %s :*** fd %d, desc '%s'", me.name,
+ source_p->name, i, fd_table[i].desc);
+ }
+ sendto_one(source_p, ":%s NOTICE %s :*** Finished", me.name,
+ source_p->name);
}
/*
{
va_list args;
int len;
-
+
if (format)
- {
- va_start(args, format);
- len = vsprintf_irc(fd_table[fd].desc, format, args);
- assert(len < FD_DESC_SZ); /* + '\0' */
- va_end(args);
- }
+ {
+ va_start(args, format);
+ len = vsprintf_irc(fd_table[fd].desc, format, args);
+ assert(len < FD_DESC_SZ); /* + '\0' */
+ va_end(args);
+ }
else
fd_table[fd].desc[0] = '\0';
}
-
-
-
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Co Center
*
- * $Id: fileio.c,v 1.1 2002/01/04 09:13:56 a1kmm Exp $
+ * $Id: fileio.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*
* 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
*/
#include "fileio.h"
#include "irc_string.h"
-#include "client.h" /* for FLAGS_ALL */
-#include "send.h" /* sendto_realops_flags */
+#include "client.h" /* for FLAGS_ALL */
+#include "send.h" /* sendto_realops_flags */
#include "memory.h"
/* The following are to get the fd manipulation routines. eww. */
#include "fdlist.h"
-#include <stdio.h> /* BUFSIZ, EOF */
-#include <stdlib.h> /* malloc, free */
-#include <fcntl.h> /* O_RDONLY, O_WRONLY, ... */
-#include <unistd.h> /* read, write, open, close */
-#include <assert.h> /* assert */
+#include <stdio.h> /* BUFSIZ, EOF */
+#include <stdlib.h> /* malloc, free */
+#include <fcntl.h> /* O_RDONLY, O_WRONLY, ... */
+#include <unistd.h> /* read, write, open, close */
+#include <assert.h> /* assert */
#include <errno.h>
#include <string.h>
int
file_open(const char *filename, int mode, int fmode)
{
- int fd;
- fd = open(filename, mode, fmode);
- if (fd == MASTER_MAX) {
- fd_close(fd); /* Too many FDs! */
- errno = ENFILE;
- fd = -1;
- } else if (fd >= 0)
- fd_open(fd, FD_FILE, filename);
-
- return fd;
+ int fd;
+ fd = open(filename, mode, fmode);
+ if (fd == MASTER_MAX)
+ {
+ fd_close(fd); /* Too many FDs! */
+ errno = ENFILE;
+ fd = -1;
+ }
+ else if (fd >= 0)
+ fd_open(fd, FD_FILE, filename);
+
+ return fd;
}
void
file_close(int fd)
{
- /*
- * Debug - we set type to FD_FILECLOSE so we can get trapped
- * in fd_close() with type == FD_FILE. This will allow us to
- * convert all abusers of fd_close() of a FD_FILE fd over
- * to file_close() .. mwahaha!
- */
- assert(fd_table[fd].type == FD_FILE);
- fd_table[fd].type = FD_FILECLOSE;
- fd_close(fd);
+ /*
+ * Debug - we set type to FD_FILECLOSE so we can get trapped
+ * in fd_close() with type == FD_FILE. This will allow us to
+ * convert all abusers of fd_close() of a FD_FILE fd over
+ * to file_close() .. mwahaha!
+ */
+ assert(fd_table[fd].type == FD_FILE);
+ fd_table[fd].type = FD_FILECLOSE;
+ fd_close(fd);
}
-FBFILE* fbopen(const char* filename, const char* mode)
+FBFILE *
+fbopen(const char *filename, const char *mode)
{
int openmode = 0;
int pmode = 0;
- FBFILE* fb = NULL;
+ FBFILE *fb = NULL;
int fd;
assert(filename);
assert(mode);
{
switch (*mode)
{
- case 'r':
- openmode = O_RDONLY;
- break;
- case 'w':
- openmode = O_WRONLY | O_CREAT | O_TRUNC;
- pmode = 0644;
- break;
- case 'a':
- openmode = O_WRONLY | O_CREAT | O_APPEND;
- pmode = 0644;
- break;
- case '+':
- openmode &= ~(O_RDONLY | O_WRONLY);
- openmode |= O_RDWR;
- break;
- default:
- break;
+ case 'r':
+ openmode = O_RDONLY;
+ break;
+ case 'w':
+ openmode = O_WRONLY | O_CREAT | O_TRUNC;
+ pmode = 0644;
+ break;
+ case 'a':
+ openmode = O_WRONLY | O_CREAT | O_APPEND;
+ pmode = 0644;
+ break;
+ case '+':
+ openmode &= ~(O_RDONLY | O_WRONLY);
+ openmode |= O_RDWR;
+ break;
+ default:
+ break;
}
++mode;
}
- if ((fd = file_open(filename, openmode, pmode)) == -1) {
+ if ((fd = file_open(filename, openmode, pmode)) == -1)
+ {
return fb;
}
return fb;
}
-FBFILE* fdbopen(int fd, const char* mode)
+FBFILE *
+fdbopen(int fd, const char *mode)
{
/*
* ignore mode, if file descriptor hasn't been opened with the
* correct mode, the first use will fail
*/
- FBFILE* fb = (FBFILE*) MyMalloc(sizeof(FBFILE));
- if (NULL != fb) {
+ FBFILE *fb = (FBFILE *) MyMalloc(sizeof(FBFILE));
+ if (NULL != fb)
+ {
fb->ptr = fb->endp = fb->buf;
fb->fd = fd;
fb->flags = 0;
return fb;
}
-void fbclose(FBFILE* fb)
+void
+fbclose(FBFILE * fb)
{
assert(fb);
file_close(fb->fd);
MyFree(fb);
}
-static int fbfill(FBFILE* fb)
+static int
+fbfill(FBFILE * fb)
{
int n;
assert(fb);
n = read(fb->fd, fb->buf, BUFSIZ);
if (0 < n)
{
- fb->ptr = fb->buf;
+ fb->ptr = fb->buf;
fb->endp = fb->buf + n;
}
else if (n < 0)
return n;
}
-int fbgetc(FBFILE* fb)
+int
+fbgetc(FBFILE * fb)
{
assert(fb);
- if(fb->pbptr)
+ if (fb->pbptr)
{
- if( (fb->pbptr == (fb->pbuf+BUFSIZ)) ||
- (!*fb->pbptr) )
+ if ((fb->pbptr == (fb->pbuf + BUFSIZ)) || (!*fb->pbptr))
fb->pbptr = NULL;
}
return EOF;
}
-void fbungetc(char c, FBFILE* fb)
+void
+fbungetc(char c, FBFILE * fb)
{
assert(fb);
- if(!fb->pbptr)
+ if (!fb->pbptr)
{
- fb->pbptr = fb->pbuf+BUFSIZ;
+ fb->pbptr = fb->pbuf + BUFSIZ;
}
- if(fb->pbptr != fb->pbuf)
+ if (fb->pbptr != fb->pbuf)
{
fb->pbptr--;
*fb->pbptr = c;
}
}
-char* fbgets(char* buf, size_t len, FBFILE* fb)
+char *
+fbgets(char *buf, size_t len, FBFILE * fb)
{
- char* p = buf;
+ char *p = buf;
assert(buf);
assert(fb);
assert(0 < len);
- if(fb->pbptr)
+ if (fb->pbptr)
{
- strncpy_irc(buf,fb->pbptr,len);
+ strncpy_irc(buf, fb->pbptr, len);
fb->pbptr = NULL;
- return(buf);
+ return (buf);
}
if (fb->ptr == fb->endp && fbfill(fb) < 1)
return 0;
- --len;
+ --len;
while (len--)
{
*p = *fb->ptr++;
*p = '\0';
return buf;
}
-
-int fbputs(const char* str, FBFILE* fb)
+
+int
+fbputs(const char *str, FBFILE * fb)
{
int n = -1;
assert(str);
return n;
}
-int fbstat(struct stat* sb, FBFILE* fb)
+int
+fbstat(struct stat *sb, FBFILE * fb)
{
assert(sb);
assert(fb);
return fstat(fb->fd, sb);
}
-
-
+/* $Id: getopt.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
+ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* loop through each argument */
for (;;)
+ {
+ int found = 0;
+
+ (*argc)--;
+ (*argv)++;
+
+ if (*argc < 1)
+ {
+ return;
+ }
+
+ /* check if it *is* an arg.. */
+ if ((*argv)[0][0] != OPTCHAR)
{
- int found = 0;
-
- (*argc)--;
- (*argv)++;
-
- if (*argc < 1)
- {
- return;
- }
-
- /* check if it *is* an arg.. */
- if ((*argv)[0][0] != OPTCHAR)
- {
- return;
- }
-
- (*argv)[0]++;
-
- /* search through our argument list, and see if it matches */
- for (i = 0; opts[i].opt; i++)
- {
- if (!strcmp(opts[i].opt, (*argv)[0]))
- {
- /* found our argument */
- found = 1;
-
- switch (opts[i].argtype)
- {
- case YESNO:
- *((int *)opts[i].argloc) = 1;
- break;
- case INTEGER:
- if (*argc < 2)
- {
- fprintf(stderr, "Error: option '%c%s' requires an argument\n",
- OPTCHAR, opts[i].opt);
- usage((*argv)[0]);
- }
-
- *((int *)opts[i].argloc) = atoi((*argv)[1]);
- break;
- case STRING:
- if (*argc < 2)
- {
- fprintf(stderr, "error: option '%c%s' requires an argument\n",
- OPTCHAR, opts[i].opt);
- usage(progname);
- }
-
- *((char**)opts[i].argloc) = malloc(strlen((*argv)[1]) + 1);
- strcpy(*((char**)opts[i].argloc), (*argv)[1]);
- break;
-
- case USAGE:
- usage(progname);
- /*NOTREACHED*/
+ return;
+ }
+
+ (*argv)[0]++;
+
+ /* search through our argument list, and see if it matches */
+ for (i = 0; opts[i].opt; i++)
+ {
+ if (!strcmp(opts[i].opt, (*argv)[0]))
+ {
+ /* found our argument */
+ found = 1;
+
+ switch (opts[i].argtype)
+ {
+ case YESNO:
+ *((int *)opts[i].argloc) = 1;
+ break;
+ case INTEGER:
+ if (*argc < 2)
+ {
+ fprintf(stderr, "Error: option '%c%s' requires an argument\n",
+ OPTCHAR, opts[i].opt);
+ usage((*argv)[0]);
+ }
+
+ *((int *)opts[i].argloc) = atoi((*argv)[1]);
+ break;
+ case STRING:
+ if (*argc < 2)
+ {
+ fprintf(stderr, "error: option '%c%s' requires an argument\n",
+ OPTCHAR, opts[i].opt);
+ usage(progname);
+ }
+ *((char **)opts[i].argloc) = malloc(strlen((*argv)[1]) + 1);
+ strcpy(*((char **)opts[i].argloc), (*argv)[1]);
+ break;
+
+ case USAGE:
+ usage(progname);
+ /*NOTREACHED*/
#ifdef DEBUGMODE
- case ENDEBUG:
- if (*argc < 2)
- {
- fprintf(stderr, "error: option '%c%s' requires an argument\n",
- OPTCHAR, opts[i].opt);
- usage(progname);
- }
-
- if (enable_debug((*argv)[1]) == -1)
- {
- fprintf(stderr, "error: '%s' unknown for debugging\n",
- (*argv)[1]);
- fprintf(stderr, "ircd: exiting on error.\n");
- exit(EXIT_FAILURE);
- }
- break;
+ case ENDEBUG:
+ if (*argc < 2)
+ {
+ fprintf(stderr, "error: option '%c%s' requires an argument\n",
+ OPTCHAR, opts[i].opt);
+ usage(progname);
+ }
+
+ if (enable_debug((*argv)[1]) == -1)
+ {
+ fprintf(stderr, "error: '%s' unknown for debugging\n",
+ (*argv)[1]);
+ fprintf(stderr, "ircd: exiting on error.\n");
+ exit(EXIT_FAILURE);
+ }
+ break;
#endif
- default:
- fprintf(stderr, "Error: internal error in parseargs() at %s:%d\n",
- __FILE__, __LINE__);
- exit(EXIT_FAILURE);
- }
- }
- }
- if (!found)
- {
- fprintf(stderr, "error: unknown argument '%c%s'\n", OPTCHAR, (*argv)[0]);
- usage(progname);
- }
+ default:
+ fprintf(stderr, "Error: internal error in parseargs() at %s:%d\n",
+ __FILE__, __LINE__);
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+ if (!found)
+ {
+ fprintf(stderr, "error: unknown argument '%c%s'\n", OPTCHAR,
+ (*argv)[0]);
+ usage(progname);
}
+ }
}
-void
+void
usage(char *name)
{
int i = 0;
-
+
fprintf(stderr, "Usage: %s [options]\n", name);
fprintf(stderr, "Where valid options are:\n");
-
+
for (i = 0; myopts[i].opt; i++)
- {
- fprintf(stderr, "\t%c%-10s %-20s%s\n", OPTCHAR, myopts[i].opt,
- (myopts[i].argtype == YESNO || myopts[i].argtype == USAGE) ? "" :
- myopts[i].argtype == INTEGER ? "<number>" : "<string>",
- myopts[i].desc);
- }
-
+ {
+ fprintf(stderr, "\t%c%-10s %-20s%s\n", OPTCHAR, myopts[i].opt,
+ (myopts[i].argtype == YESNO || myopts[i].argtype == USAGE) ? "" :
+ myopts[i].argtype == INTEGER ? "<number>" : "<string>",
+ myopts[i].desc);
+ }
+
exit(EXIT_FAILURE);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: hash.c,v 1.1 2002/01/04 09:13:57 a1kmm Exp $
+ * $Id: hash.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include <sys/types.h>
#include <errno.h>
#include <assert.h>
-#include <fcntl.h> /* O_RDWR ... */
+#include <fcntl.h> /* O_RDWR ... */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
* Contributed by James L. Davis
*/
-static unsigned int hash_channel_name(const char* name);
+static unsigned int hash_channel_name(const char *name);
#ifdef DEBUGMODE
-static struct HashEntry* clientTable = NULL;
-static struct HashEntry* channelTable = NULL;
-static struct HashEntry* idTable = NULL;
-static struct HashEntry* resvTable = NULL;
+static struct HashEntry *clientTable = NULL;
+static struct HashEntry *channelTable = NULL;
+static struct HashEntry *idTable = NULL;
+static struct HashEntry *resvTable = NULL;
static int clhits;
static int clmiss;
static int chhits;
*/
extern BlockHeap *channel_heap;
-struct HashEntry hash_get_channel_block(int i)
+struct HashEntry
+hash_get_channel_block(int i)
{
return channelTable[i];
}
-size_t hash_get_channel_table_size(void)
+size_t
+hash_get_channel_table_size(void)
{
return sizeof(struct HashEntry) * CH_MAX;
}
-size_t hash_get_client_table_size(void)
+size_t
+hash_get_client_table_size(void)
{
return sizeof(struct HashEntry) * U_MAX;
}
-size_t hash_get_resv_table_size(void)
+size_t
+hash_get_resv_table_size(void)
{
return sizeof(struct HashEntry) * R_MAX;
}
* The order shown above is just one instant of the server.
*/
-static unsigned
-int hash_nick_name(const char* name)
+static unsigned int
+hash_nick_name(const char *name)
{
unsigned int h = 0;
while (*name)
- {
- h = (h << 4) - (h + (unsigned char)ToLower(*name++));
- }
+ {
+ h = (h << 4) - (h + (unsigned char)ToLower(*name++));
+ }
- return(h & (U_MAX - 1));
+ return (h & (U_MAX - 1));
}
/*
* IDs are a easy to hash -- they're already evenly distributed,
* and they are always case sensitive. -orabidoo
*/
-static unsigned int
+static unsigned int
hash_id(const char *nname)
{
- unsigned int h = 0;
-
- while (*nname) {
- h = (h << 4) - (h + (unsigned char)*nname++);
- }
+ unsigned int h = 0;
- return (h & (U_MAX - 1));
+ while (*nname)
+ {
+ h = (h << 4) - (h + (unsigned char)*nname++);
+ }
+
+ return (h & (U_MAX - 1));
}
+
/*
* hash_channel_name
*
* is little or no point hashing on a full channel name which maybe 255 chars
* long.
*/
-static unsigned
-int hash_channel_name(const char* name)
+static unsigned int
+hash_channel_name(const char *name)
{
int i = 30;
unsigned int h = 0;
while (*name && --i)
- {
- h = (h << 4) - (h + (unsigned char)ToLower(*name++));
- }
+ {
+ h = (h << 4) - (h + (unsigned char)ToLower(*name++));
+ }
return (h & (CH_MAX - 1));
}
* calculate a hash value on at most the first 30 characters and add
* it to the resv hash
*/
-static unsigned
-int hash_resv_channel(const char *name)
+static unsigned int
+hash_resv_channel(const char *name)
{
int i = 30;
unsigned int h = 0;
h = (h << 4) - (h + (unsigned char)ToLower(*name++));
}
- return (h & (R_MAX -1));
+ return (h & (R_MAX - 1));
}
/*
*
* Nullify the hashtable and its contents so it is completely empty.
*/
-static void clear_client_hash_table()
+static void
+clear_client_hash_table()
{
#ifdef DEBUGMODE
clhits = 0;
clmiss = 0;
- if(!clientTable)
- clientTable = (struct HashEntry*) MyMalloc(U_MAX * sizeof(struct HashEntry));
+ if (!clientTable)
+ clientTable =
+ (struct HashEntry *)MyMalloc(U_MAX * sizeof(struct HashEntry));
#endif
memset(clientTable, 0, sizeof(struct HashEntry) * U_MAX);
}
*
* Nullify the hashtable and its contents so it is completely empty.
*/
-static void clear_id_hash_table()
+static void
+clear_id_hash_table()
{
#ifdef DEBUGMODE
/* XXX -
* idmiss = 0;
* -cosine
*/
- if(!idTable)
- idTable = (struct HashEntry*) MyMalloc(U_MAX * sizeof(struct HashEntry));
+ if (!idTable)
+ idTable = (struct HashEntry *)MyMalloc(U_MAX * sizeof(struct HashEntry));
#endif
memset(idTable, 0, sizeof(struct HashEntry) * U_MAX);
}
chmiss = 0;
chhits = 0;
if (!channelTable)
- channelTable = (struct HashEntry*) MyMalloc(CH_MAX *
+ channelTable = (struct HashEntry *)MyMalloc(CH_MAX *
sizeof(struct HashEntry));
#endif
memset(channelTable, 0, sizeof(struct HashEntry) * CH_MAX);
#ifdef DEBUGMODE
rmiss = 0;
rhits = 0;
- if(!resvTable)
- resvTable = (struct HashEntry*) MyMalloc(R_MAX *
+ if (!resvTable)
+ resvTable = (struct HashEntry *)MyMalloc(R_MAX *
sizeof(struct HashEntry));
#endif
memset(resvTable, 0, sizeof(struct HashEntry) * R_MAX);
}
-void
+void
init_hash(void)
{
clear_client_hash_table();
int
add_to_id_hash_table(char *name, struct Client *client_p)
{
- unsigned int hashv;
+ unsigned int hashv;
hashv = hash_id(name);
client_p->idhnext = (struct Client *)idTable[hashv].list;
/*
* add_to_client_hash_table
*/
-void
-add_to_client_hash_table(const char* name, struct Client* client_p)
+void
+add_to_client_hash_table(const char *name, struct Client *client_p)
{
unsigned int hashv;
assert(name != NULL);
assert(client_p != NULL);
hashv = hash_nick_name(name);
- client_p->hnext = (struct Client*) clientTable[hashv].list;
- clientTable[hashv].list = (void*) client_p;
+ client_p->hnext = (struct Client *)clientTable[hashv].list;
+ clientTable[hashv].list = (void *)client_p;
++clientTable[hashv].links;
++clientTable[hashv].hits;
}
* add_to_channel_hash_table
*/
void
-add_to_channel_hash_table(const char* name, struct Channel* chptr)
+add_to_channel_hash_table(const char *name, struct Channel *chptr)
{
unsigned int hashv;
assert(name != NULL);
assert(chptr != NULL);
hashv = hash_channel_name(name);
- chptr->hnextch = (struct Channel*) channelTable[hashv].list;
- channelTable[hashv].list = (void*) chptr;
+ chptr->hnextch = (struct Channel *)channelTable[hashv].list;
+ channelTable[hashv].list = (void *)chptr;
++channelTable[hashv].links;
++channelTable[hashv].hits;
}
hashv = hash_resv_channel(name);
- resv_p->hnext = (struct ResvChannel *) resvTable[hashv].list;
- resvTable[hashv].list = (void*)resv_p;
+ resv_p->hnext = (struct ResvChannel *)resvTable[hashv].list;
+ resvTable[hashv].list = (void *)resv_p;
++resvTable[hashv].links;
++resvTable[hashv].hits;
}
* hash table
*/
void
-del_from_id_hash_table(const char* id, struct Client* client_p)
+del_from_id_hash_table(const char *id, struct Client *client_p)
{
- struct Client* found_client;
- struct Client* prev = NULL;
- unsigned int hashv;
+ struct Client *found_client;
+ struct Client *prev = NULL;
+ unsigned int hashv;
assert(id != NULL);
assert(client_p != NULL);
hashv = hash_id(id);
- found_client = (struct Client*) idTable[hashv].list;
+ found_client = (struct Client *)idTable[hashv].list;
- for ( ; found_client; found_client = found_client->idhnext)
+ for (; found_client; found_client = found_client->idhnext)
+ {
+ if (found_client == client_p)
{
- if (found_client == client_p)
- {
- if (prev)
- prev->idhnext = found_client->idhnext;
- else
- idTable[hashv].list = (void*) found_client->idhnext;
- found_client->idhnext = NULL;
-
- assert(idTable[hashv].links > 0);
- if (idTable[hashv].links > 0)
- --idTable[hashv].links;
- return;
- }
- prev = found_client;
+ if (prev)
+ prev->idhnext = found_client->idhnext;
+ else
+ idTable[hashv].list = (void *)found_client->idhnext;
+ found_client->idhnext = NULL;
+
+ assert(idTable[hashv].links > 0);
+ if (idTable[hashv].links > 0)
+ --idTable[hashv].links;
+ return;
}
+ prev = found_client;
+ }
Debug((DEBUG_ERROR, "%#x !in tab %s[%s] %#x %#x %#x %d %d %#x",
- client_p, client_p->name, client_p->from ? client_p->from->host : "??host",
- client_p->from, client_p->next, client_p->prev, client_p->fd,
- client_p->status, client_p->user));
+ client_p, client_p->name,
+ client_p->from ? client_p->from->host : "??host", client_p->from,
+ client_p->next, client_p->prev, client_p->fd, client_p->status,
+ client_p->user));
}
/*
* hash table
*/
void
-del_from_client_hash_table(const char* name, struct Client* client_p)
+del_from_client_hash_table(const char *name, struct Client *client_p)
{
- struct Client* found_client;
- struct Client* prev = NULL;
- unsigned int hashv;
+ struct Client *found_client;
+ struct Client *prev = NULL;
+ unsigned int hashv;
assert(name != NULL);
assert(client_p != NULL);
hashv = hash_nick_name(name);
- found_client = (struct Client*) clientTable[hashv].list;
+ found_client = (struct Client *)clientTable[hashv].list;
- for ( ; found_client; found_client = found_client->hnext)
+ for (; found_client; found_client = found_client->hnext)
+ {
+ if (found_client == client_p)
{
- if (found_client == client_p)
- {
- if (prev)
- prev->hnext = found_client->hnext;
- else
- clientTable[hashv].list = (void*) found_client->hnext;
- found_client->hnext = NULL;
-
- assert(clientTable[hashv].links > 0);
- if (clientTable[hashv].links > 0)
- --clientTable[hashv].links;
- return;
- }
- prev = found_client;
+ if (prev)
+ prev->hnext = found_client->hnext;
+ else
+ clientTable[hashv].list = (void *)found_client->hnext;
+ found_client->hnext = NULL;
+
+ assert(clientTable[hashv].links > 0);
+ if (clientTable[hashv].links > 0)
+ --clientTable[hashv].links;
+ return;
}
+ prev = found_client;
+ }
Debug((DEBUG_ERROR, "%#x !in tab %s[%s] %#x %#x %#x %d %d %#x",
- client_p, client_p->name, client_p->from ? client_p->from->host : "??host",
- client_p->from, client_p->next, client_p->prev, client_p->fd,
- client_p->status, client_p->user));
+ client_p, client_p->name,
+ client_p->from ? client_p->from->host : "??host", client_p->from,
+ client_p->next, client_p->prev, client_p->fd, client_p->status,
+ client_p->user));
}
/*
* del_from_channel_hash_table
*/
-void
-del_from_channel_hash_table(const char* name, struct Channel* chptr)
+void
+del_from_channel_hash_table(const char *name, struct Channel *chptr)
{
- struct Channel* found_chptr;
- struct Channel* prev = NULL;
- unsigned int hashv;
+ struct Channel *found_chptr;
+ struct Channel *prev = NULL;
+ unsigned int hashv;
assert(name != NULL);
assert(chptr != NULL);
hashv = hash_channel_name(name);
- found_chptr = (struct Channel*) channelTable[hashv].list;
+ found_chptr = (struct Channel *)channelTable[hashv].list;
- for ( ; found_chptr; found_chptr = found_chptr->hnextch)
+ for (; found_chptr; found_chptr = found_chptr->hnextch)
+ {
+ if (found_chptr == chptr)
{
- if (found_chptr == chptr)
- {
- if (prev)
- prev->hnextch = found_chptr->hnextch;
- else
- channelTable[hashv].list = (void*) found_chptr->hnextch;
- found_chptr->hnextch = NULL;
-
- assert(channelTable[hashv].links > 0);
- if (channelTable[hashv].links > 0)
- --channelTable[hashv].links;
- return;
- }
- prev = found_chptr;
+ if (prev)
+ prev->hnextch = found_chptr->hnextch;
+ else
+ channelTable[hashv].list = (void *)found_chptr->hnextch;
+ found_chptr->hnextch = NULL;
+
+ assert(channelTable[hashv].links > 0);
+ if (channelTable[hashv].links > 0)
+ --channelTable[hashv].links;
+ return;
}
+ prev = found_chptr;
+ }
}
/*
* del_from_resv_hash_table()
*/
-void
+void
del_from_resv_hash_table(const char *name, struct ResvChannel *rptr)
{
struct ResvChannel *found_chptr;
- struct ResvChannel *prev=NULL;
+ struct ResvChannel *prev = NULL;
unsigned int hashv;
assert(name != NULL);
hashv = hash_resv_channel(name);
- found_chptr = (struct ResvChannel *) resvTable[hashv].list;
+ found_chptr = (struct ResvChannel *)resvTable[hashv].list;
- for( ; found_chptr; found_chptr = found_chptr->hnext)
+ for (; found_chptr; found_chptr = found_chptr->hnext)
{
- if(found_chptr == rptr)
+ if (found_chptr == rptr)
{
- if(prev)
+ if (prev)
prev->hnext = found_chptr->hnext;
else
- resvTable[hashv].list = (void*)found_chptr->hnext;
+ resvTable[hashv].list = (void *)found_chptr->hnext;
- found_chptr->hnext=NULL;
+ found_chptr->hnext = NULL;
assert(resvTable[hashv].links > 0);
--resvTable[hashv].links;
return;
}
}
-}
-
+}
+
/*
* find_id
*/
{
struct Client *found_client;
unsigned int hashv;
-
+
if (name == NULL)
return NULL;
{
if (found_client->user && strcmp(name, found_client->user->id) == 0)
{
- return(found_client);
+ return (found_client);
}
}
-
+
return (NULL);
}
* output - pointer to client pointer
* side effects - none
*/
-struct Client*
-find_client(const char* name)
+struct Client *
+find_client(const char *name)
{
- struct Client* found_client;
- unsigned int hashv;
+ struct Client *found_client;
+ unsigned int hashv;
assert(name != NULL);
- if (*name == '.') /* it's an ID .. */
+ if (*name == '.') /* it's an ID .. */
return (find_id(name));
hashv = hash_nick_name(name);
- found_client = (struct Client*) clientTable[hashv].list;
+ found_client = (struct Client *)clientTable[hashv].list;
- for ( ; found_client; found_client = found_client->hnext)
+ for (; found_client; found_client = found_client->hnext)
if (irccmp(name, found_client->name) == 0)
- {
+ {
#ifdef DEBUGMODE
- ++clhits;
+ ++clhits;
#endif
- return (found_client);
- }
+ return (found_client);
+ }
#ifdef DEBUGMODE
++clmiss;
#endif
-
+
return (NULL);
}
* also made const correct
* --Bleep
*/
-static struct Client*
-hash_find_masked_server(const char* name)
+static struct Client *
+hash_find_masked_server(const char *name)
{
- char buf[HOSTLEN + 1];
- char* p = buf;
- char* s;
- struct Client* server;
+ char buf[HOSTLEN + 1];
+ char *p = buf;
+ char *s;
+ struct Client *server;
if ('*' == *name || '.' == *name)
return 0;
buf[HOSTLEN] = '\0';
while ((s = strchr(p, '.')) != 0)
- {
- *--s = '*';
- /*
- * Dont need to check IsServer() here since nicknames cant
- * have *'s in them anyway.
- */
- if ((server = find_client(s)))
- return server;
- p = s + 2;
- }
+ {
+ *--s = '*';
+ /*
+ * Dont need to check IsServer() here since nicknames cant
+ * have *'s in them anyway.
+ */
+ if ((server = find_client(s)))
+ return server;
+ p = s + 2;
+ }
return 0;
}
* given server not found
* side effects -
*/
-struct Client*
-find_server(const char* name)
+struct Client *
+find_server(const char *name)
{
- struct Client* found_server;
- unsigned int hashv;
+ struct Client *found_server;
+ unsigned int hashv;
if (name == NULL)
- return(NULL);
+ return (NULL);
hashv = hash_nick_name(name);
- found_server = (struct Client*) clientTable[hashv].list;
+ found_server = (struct Client *)clientTable[hashv].list;
- for ( ; found_server; found_server = found_server->hnext)
+ for (; found_server; found_server = found_server->hnext)
+ {
+ if (!IsServer(found_server) && !IsMe(found_server))
+ continue;
+ if (irccmp(name, found_server->name) == 0)
{
- if (!IsServer(found_server) && !IsMe(found_server))
- continue;
- if (irccmp(name, found_server->name) == 0)
- {
#ifdef DEBUGMODE
- ++clhits;
+ ++clhits;
#endif
- return (found_server);
- }
+ return (found_server);
}
-
+ }
+
#ifndef DEBUGMODE
return hash_find_masked_server(name);
* output -
* side effects -
*/
-struct Channel*
-hash_find_channel(const char* name)
+struct Channel *
+hash_find_channel(const char *name)
{
- struct Channel* found_chptr;
+ struct Channel *found_chptr;
unsigned int hashv;
-
+
assert(name != NULL);
hashv = hash_channel_name(name);
- found_chptr = (struct Channel*) channelTable[hashv].list;
+ found_chptr = (struct Channel *)channelTable[hashv].list;
+
+ for (; found_chptr; found_chptr = found_chptr->hnextch)
- for ( ; found_chptr; found_chptr = found_chptr->hnextch)
-
if (irccmp(name, found_chptr->chname) == 0)
- {
+ {
#ifdef DEBUGMODE
- ++chhits;
+ ++chhits;
#endif
- return(found_chptr);
- }
+ return (found_chptr);
+ }
#ifdef DEBUGMODE
++chmiss;
#endif
- return(NULL);
+ return (NULL);
}
/*
len = strlen(chname);
if (len > CHANNELLEN)
+ {
+ if (IsServer(client_p))
{
- if (IsServer(client_p))
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ALL,
- "*** Long channel name from %s (%d > %d): %s",
- client_p->name,
- len,
- CHANNELLEN,
- chname);
- }
- len = CHANNELLEN;
- *(chname + CHANNELLEN) = '\0';
+ sendto_realops_flags(FLAGS_DEBUG, L_ALL,
+ "*** Long channel name from %s (%d > %d): %s",
+ client_p->name, len, CHANNELLEN, chname);
}
+ len = CHANNELLEN;
+ *(chname + CHANNELLEN) = '\0';
+ }
hashv = hash_channel_name(chname);
- for ( found_chptr = (struct Channel*) channelTable[hashv].list;
- found_chptr; found_chptr = found_chptr->hnextch)
+ for (found_chptr = (struct Channel *)channelTable[hashv].list;
+ found_chptr; found_chptr = found_chptr->hnextch)
+ {
+ if (irccmp(chname, found_chptr->chname) == 0)
{
- if (irccmp(chname, found_chptr->chname) == 0)
- {
#ifdef DEBUGMODE
- ++chhits;
+ ++chhits;
#endif
- if(isnew != NULL)
- *isnew = 0;
- return(found_chptr);
- }
+ if (isnew != NULL)
+ *isnew = 0;
+ return (found_chptr);
+ }
#ifdef DEBUGMODE
- ++chmiss;
+ ++chmiss;
#endif
- }
+ }
- if(isnew != NULL)
+ if (isnew != NULL)
*isnew = 1;
chptr = BlockHeapAlloc(channel_heap);
- memset(chptr, 0, sizeof(*chptr)-CHANNELLEN);
+ memset(chptr, 0, sizeof(*chptr) - CHANNELLEN);
strcpy(chptr->chname, chname);
if (GlobalChannelList)
chptr->prevch = NULL;
chptr->nextch = GlobalChannelList;
GlobalChannelList = chptr;
- chptr->channelts = CurrentTime; /* doesn't hurt to set it here */
+ chptr->channelts = CurrentTime; /* doesn't hurt to set it here */
- chptr->hnextch = (struct Channel*) channelTable[hashv].list;
- channelTable[hashv].list = (void*) chptr;
+ chptr->hnextch = (struct Channel *)channelTable[hashv].list;
+ channelTable[hashv].list = (void *)chptr;
++channelTable[hashv].links;
++channelTable[hashv].hits;
unsigned int hashv;
assert(name != NULL);
-
+
hashv = hash_resv_channel(name);
- found_chptr = (struct ResvChannel *) resvTable[hashv].list;
+ found_chptr = (struct ResvChannel *)resvTable[hashv].list;
- for( ; found_chptr; found_chptr = found_chptr->hnext)
+ for (; found_chptr; found_chptr = found_chptr->hnext)
{
- if(!irccmp(name, found_chptr->name))
+ if (!irccmp(name, found_chptr->name))
{
#ifdef DEBUGMODE
++rhits;
-#endif
- return(found_chptr);
+#endif
+ return (found_chptr);
}
}
#ifdef DEBUGMODE
++rmiss;
#endif
-
- return(NULL);
-}
-
-
-
-
-
+ return (NULL);
+}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: hook.c,v 1.1 2002/01/04 09:14:02 a1kmm Exp $
+ * $Id: hook.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
/* hooks are used by modules to hook into events called by other parts of
void
init_hooks(void)
{
- memset(&hooks, 0, sizeof(hooks));
+ memset(&hooks, 0, sizeof(hooks));
#ifndef NDEBUG
- hook_add_event("iosend");
- hook_add_event("iorecv");
- hook_add_event("iorecvctrl");
+ hook_add_event("iosend");
+ hook_add_event("iorecv");
+ hook_add_event("iorecvctrl");
#endif
- hook_add_event("burst_channel");
+ hook_add_event("burst_channel");
}
static hook *
new_hook(char *name)
{
- hook *h;
-
- h = MyMalloc(sizeof(hook));
- memset(h, 0, sizeof(*h));
- DupString(h->name, name);
- return h;
+ hook *h;
+
+ h = MyMalloc(sizeof(hook));
+ memset(h, 0, sizeof(*h));
+ DupString(h->name, name);
+ return h;
}
int
hook_add_event(char *name)
{
- dlink_node *node;
- hook *newhook;
-
- node = make_dlink_node();
- newhook = new_hook(name);
-
- dlinkAdd(newhook, node, &hooks);
- return 0;
+ dlink_node *node;
+ hook *newhook;
+
+ node = make_dlink_node();
+ newhook = new_hook(name);
+
+ dlinkAdd(newhook, node, &hooks);
+ return 0;
}
int
hook_del_event(char *name)
{
- dlink_node *node;
- hook *h;
-
- for (node = hooks.head; node; node = node->next)
- {
- h = node->data;
-
- if (!strcmp(h->name, name)) {
- dlinkDelete(node, &hooks);
- MyFree(h);
- return 0;
- }
- }
- return 0;
+ dlink_node *node;
+ hook *h;
+
+ for (node = hooks.head; node; node = node->next)
+ {
+ h = node->data;
+
+ if (!strcmp(h->name, name))
+ {
+ dlinkDelete(node, &hooks);
+ MyFree(h);
+ return 0;
+ }
+ }
+ return 0;
}
static hook *
find_hook(char *name)
{
- dlink_node *node;
- hook *h;
-
- for (node = hooks.head; node; node = node->next)
- {
- h = node->data;
-
- if (!strcmp(h->name, name))
- return h;
- }
- return NULL;
+ dlink_node *node;
+ hook *h;
+
+ for (node = hooks.head; node; node = node->next)
+ {
+ h = node->data;
+
+ if (!strcmp(h->name, name))
+ return h;
+ }
+ return NULL;
}
-int
-hook_del_hook(char *event, hookfn *fn)
+int
+hook_del_hook(char *event, hookfn * fn)
{
- hook *h;
- dlink_node *node, *nnode;
- h = find_hook(event);
- if (!h)
- return -1;
-
- for (node = h->hooks.head; node; node = node->next)
- {
- nnode = node->next;
- if (fn == node->data)
+ hook *h;
+ dlink_node *node, *nnode;
+ h = find_hook(event);
+ if (!h)
+ return -1;
+
+ for (node = h->hooks.head; node; node = node->next)
{
- dlinkDelete(node, &h->hooks);
- free_dlink_node(node);
- }
- }
- return 0;
+ nnode = node->next;
+ if (fn == node->data)
+ {
+ dlinkDelete(node, &h->hooks);
+ free_dlink_node(node);
+ }
+ }
+ return 0;
}
int
-hook_add_hook(char *event, hookfn *fn)
+hook_add_hook(char *event, hookfn * fn)
{
- hook *h;
- dlink_node *node;
-
- h = find_hook(event);
- if (!h)
- return -1;
-
- node = make_dlink_node();
-
- dlinkAdd(fn, node, &h->hooks);
- return 0;
+ hook *h;
+ dlink_node *node;
+
+ h = find_hook(event);
+ if (!h)
+ return -1;
+
+ node = make_dlink_node();
+
+ dlinkAdd(fn, node, &h->hooks);
+ return 0;
}
int
hook_call_event(char *event, void *data)
{
- hook *h;
- dlink_node *node;
- hookfn fn;
-
- h = find_hook(event);
- if (!h)
- return -1;
-
- for (node = h->hooks.head; node; node = node->next)
- {
- fn = (hookfn)node->data;
-
- if (fn(data) != 0)
- return 0;
- }
- return 0;
-}
+ hook *h;
+ dlink_node *node;
+ hookfn fn;
-
+ h = find_hook(event);
+ if (!h)
+ return -1;
+
+ for (node = h->hooks.head; node; node = node->next)
+ {
+ fn = (hookfn) node->data;
+
+ if (fn(data) != 0)
+ return 0;
+ }
+ return 0;
+}
* 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.
- * $Id: hostmask.c,v 1.1 2002/01/04 09:14:02 a1kmm Exp $
+ * $Id: hostmask.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include <stdlib.h>
const char *p;
/* And yes - we have to check p after strchr and p after increment for
* NULL -kre */
- for (p = name; p != NULL; )
+ for (p = name; p != NULL;)
{
for (arec = atable[hash_text(p)]; arec; arec = arec->next)
if ((arec->type == (type & ~0x1)) &&
hprecv = arec->precedence;
hprec = arec->aconf;
}
- p = strchr(p, '.');
- if (p != NULL)
- p++;
- else
- break;
+ p = strchr(p, '.');
+ if (p != NULL)
+ p++;
+ else
+ break;
}
for (arec = atable[0]; arec; arec = arec->next)
if (arec->type == (type & ~0x1) &&
* sender, so prepare the strings for comparing --fl_ */
sendto_one(client_p, form_str(RPL_STATSILINE), me.name,
- client_p->name, (IsConfRestricted(aconf)) ? 'i' : 'I', name,
- show_iline_prefix(client_p, aconf, user),
- host, port, classname);
+ client_p->name, (IsConfRestricted(aconf)) ? 'i' : 'I',
+ name, show_iline_prefix(client_p, aconf, user), host, port,
+ classname);
}
}
if (mask)
{
- aconf = find_address_conf(client_p->host, client_p->username,
- NULL, 0);
- if (!aconf || (aconf->status & CONF_KILL) == 0)
- return;
- get_printable_conf(aconf, &name, &host, &pass, &user, &port,
- &classname);
- sendto_one(client_p, form_str(RPL_STATSKLINE), me.name,
- client_p->name, c, host, user, pass);
- return;
+ aconf = find_address_conf(client_p->host, client_p->username, NULL, 0);
+ if (!aconf || (aconf->status & CONF_KILL) == 0)
+ return;
+ get_printable_conf(aconf, &name, &host, &pass, &user, &port, &classname);
+ sendto_one(client_p, form_str(RPL_STATSKLINE), me.name,
+ client_p->name, c, host, user, pass);
+ return;
}
for (i = 0; i < ATABLE_SIZE; i++)
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: irc_string.c,v 1.1 2002/01/04 09:14:02 a1kmm Exp $
+ * $Id: irc_string.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include "config.h"
#include "tools.h"
#include <ctype.h>
#include <time.h>
-#ifndef INADDRSZ
+#ifndef INADDRSZ
#define INADDRSZ 4
#endif
*
* Thu Nov 24 18:22:48 1986
*/
-const char* myctime(time_t value)
+const char *
+myctime(time_t value)
{
static char buf[32];
- char* p;
+ char *p;
strcpy(buf, ctime(&value));
if ((p = strchr(buf, '\n')) != NULL)
* annoying opers, lets clean up what is sent to local opers
* -Dianora
*/
-char*
-clean_string(char* dest, const unsigned char* src, size_t len)
+char *
+clean_string(char *dest, const unsigned char *src, size_t len)
{
- char* d = dest;
+ char *d = dest;
assert(0 != dest);
assert(0 != src);
- len -= 3; /* allow for worst case, '^A\0' */
+ len -= 3; /* allow for worst case, '^A\0' */
while (*src && (len > 0))
+ {
+ if (*src & 0x80) /* if high bit is set */
{
- if(*src & 0x80) /* if high bit is set */
- {
- *d++ = '.';
- --len;
- }
- else if(!IsPrint(*src)) /* if NOT printable */
- {
- *d++ = '^';
- --len;
- *d++ = 0x40 + *src; /* turn it into a printable */
- }
- else
- *d++ = *src;
- ++src;
+ *d++ = '.';
+ --len;
+ }
+ else if (!IsPrint(*src)) /* if NOT printable */
+ {
+ *d++ = '^';
--len;
+ *d++ = 0x40 + *src; /* turn it into a printable */
}
+ else
+ *d++ = *src;
+ ++src;
+ --len;
+ }
*d = '\0';
return dest;
}
*
* NOTE: jdc: I have a gut feeling there's a faster way to do this.
*/
-char *strip_tabs(char *dest, const unsigned char *src, size_t len)
+char *
+strip_tabs(char *dest, const unsigned char *src, size_t len)
{
char *d = dest;
/* Sanity check; we don't want anything nasty... */
{
if (*src == '\t')
{
- *d++ = ' '; /* Translate the tab into a space */
+ *d++ = ' '; /* Translate the tab into a space */
}
else
{
- *d++ = *src; /* Copy src to dst */
+ *d++ = *src; /* Copy src to dst */
}
++src;
--len;
}
- *d = '\0'; /* Null terminate, thanks and goodbye */
+ *d = '\0'; /* Null terminate, thanks and goodbye */
return dest;
}
* argv 9/90
*
*/
-char* strtoken(char** save, char* str, char* fs)
+char *
+strtoken(char **save, char *str, char *fs)
{
- char* pos = *save; /* keep last position across calls */
- char* tmp;
+ char *pos = *save; /* keep last position across calls */
+ char *tmp;
if (str)
- pos = str; /* new string scan */
+ pos = str; /* new string scan */
while (pos && *pos && strchr(fs, *pos) != NULL)
- ++pos; /* skip leading separators */
+ ++pos; /* skip leading separators */
if (!pos || !*pos)
- return (pos = *save = NULL); /* string contains only sep's */
+ return (pos = *save = NULL); /* string contains only sep's */
- tmp = pos; /* now, keep position of the token */
+ tmp = pos; /* now, keep position of the token */
while (*pos && strchr(fs, *pos) == NULL)
- ++pos; /* skip content of the token */
+ ++pos; /* skip content of the token */
if (*pos)
- *pos++ = '\0'; /* remove first sep after the token */
+ *pos++ = '\0'; /* remove first sep after the token */
else
- pos = NULL; /* end of string */
+ pos = NULL; /* end of string */
*save = pos;
return tmp;
/*
* From: Thomas Helvey <tomh@inxpress.net>
*/
-static const char *IpQuadTab[] =
-{
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
- "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
- "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
- "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
- "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
- "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
- "60", "61", "62", "63", "64", "65", "66", "67", "68", "69",
- "70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
- "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
- "90", "91", "92", "93", "94", "95", "96", "97", "98", "99",
+static const char *IpQuadTab[] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
+ "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
+ "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
+ "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
+ "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
+ "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
+ "60", "61", "62", "63", "64", "65", "66", "67", "68", "69",
+ "70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
+ "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
+ "90", "91", "92", "93", "94", "95", "96", "97", "98", "99",
"100", "101", "102", "103", "104", "105", "106", "107", "108", "109",
"110", "111", "112", "113", "114", "115", "116", "117", "118", "119",
"120", "121", "122", "123", "124", "125", "126", "127", "128", "129",
* inet_ntoa -- its broken on some Ultrix/Dynix too. -avalon
*/
-const char* inetntoa(const char* in)
+const char *
+inetntoa(const char *in)
{
static char buf[16];
char *bufptr = buf;
- const unsigned char *a = (const unsigned char*)in;
+ const unsigned char *a = (const unsigned char *)in;
const char *n;
- n = IpQuadTab[ *a++ ];
+ n = IpQuadTab[*a++];
while (*n)
*bufptr++ = *n++;
*bufptr++ = '.';
- n = IpQuadTab[ *a++ ];
- while ( *n )
+ n = IpQuadTab[*a++];
+ while (*n)
*bufptr++ = *n++;
*bufptr++ = '.';
- n = IpQuadTab[ *a++ ];
- while ( *n )
+ n = IpQuadTab[*a++];
+ while (*n)
*bufptr++ = *n++;
*bufptr++ = '.';
- n = IpQuadTab[ *a ];
- while ( *n )
+ n = IpQuadTab[*a];
+ while (*n)
*bufptr++ = *n++;
*bufptr = '\0';
return buf;
}
+
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
-static const char *inet_ntop4 (const u_char *src, char *dst, unsigned int size);
+static const char *inet_ntop4(const u_char * src, char *dst,
+ unsigned int size);
#ifdef IPV6
-static const char *inet_ntop6 (const u_char *src, char *dst, unsigned int size);
+static const char *inet_ntop6(const u_char * src, char *dst,
+ unsigned int size);
#endif
/* const char *
static const char *
inet_ntop4(const unsigned char *src, char *dst, unsigned int size)
{
- if(size < 16)
- return NULL;
- return strcpy(dst, inetntoa((const char *)src));
+ if (size < 16)
+ return NULL;
+ return strcpy(dst, inetntoa((const char *)src));
}
/* const char *
static const char *
inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
{
- /*
- * Note that int32_t and int16_t need only be "at least" large enough
- * to contain a value of the specified size. On some systems, like
- * Crays, there is no such thing as an integer variable with 16 bits.
- * Keep this in mind if you think this function should have been coded
- * to use pointer overlays. All the world's not a VAX.
- */
- char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
- struct { int base, len; } best, cur;
- u_int words[IN6ADDRSZ / INT16SZ];
- int i;
-
- /*
- * Preprocess:
- * Copy the input (bytewise) array into a wordwise array.
- * Find the longest run of 0x00's in src[] for :: shorthanding.
- */
- memset(words, '\0', sizeof words);
- for (i = 0; i < IN6ADDRSZ; i += 2)
- words[i / 2] = (src[i] << 8) | src[i + 1];
- best.base = -1;
- cur.base = -1;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
- if (words[i] == 0) {
- if (cur.base == -1)
- cur.base = i, cur.len = 1;
- else
- cur.len++;
- } else {
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- cur.base = -1;
- }
- }
- }
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- }
- if (best.base != -1 && best.len < 2)
- best.base = -1;
-
- /*
- * Format the result.
- */
- tp = tmp;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
- /* Are we inside the best run of 0x00's? */
- if (best.base != -1 && i >= best.base &&
- i < (best.base + best.len)) {
- if (i == best.base)
- *tp++ = ':';
- continue;
- }
- /* Are we following an initial run of 0x00s or any real hex? */
- if (i != 0)
- *tp++ = ':';
- /* Is this address an encapsulated IPv4? */
- if (i == 6 && best.base == 0 &&
- (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
- if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
- return (NULL);
- tp += strlen(tp);
- break;
- }
- tp += SPRINTF((tp, "%x", words[i]));
- }
- /* Was it a trailing run of 0x00's? */
- if (best.base != -1 && (best.base + best.len) ==
- (IN6ADDRSZ / INT16SZ))
- *tp++ = ':';
- *tp++ = '\0';
-
- /*
- * Check for overflow, copy, and we're done.
- */
-
- if ((tp - tmp) > size) {
- return (NULL);
- }
- return strcpy(dst, tmp);
+ /*
+ * Note that int32_t and int16_t need only be "at least" large enough
+ * to contain a value of the specified size. On some systems, like
+ * Crays, there is no such thing as an integer variable with 16 bits.
+ * Keep this in mind if you think this function should have been coded
+ * to use pointer overlays. All the world's not a VAX.
+ */
+ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
+ struct
+ {
+ int base, len;
+ }
+ best, cur;
+ u_int words[IN6ADDRSZ / INT16SZ];
+ int i;
+
+ /*
+ * Preprocess:
+ * Copy the input (bytewise) array into a wordwise array.
+ * Find the longest run of 0x00's in src[] for :: shorthanding.
+ */
+ memset(words, '\0', sizeof words);
+ for (i = 0; i < IN6ADDRSZ; i += 2)
+ words[i / 2] = (src[i] << 8) | src[i + 1];
+ best.base = -1;
+ cur.base = -1;
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
+ {
+ if (words[i] == 0)
+ {
+ if (cur.base == -1)
+ cur.base = i, cur.len = 1;
+ else
+ cur.len++;
+ }
+ else
+ {
+ if (cur.base != -1)
+ {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ cur.base = -1;
+ }
+ }
+ }
+ if (cur.base != -1)
+ {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ }
+ if (best.base != -1 && best.len < 2)
+ best.base = -1;
+
+ /*
+ * Format the result.
+ */
+ tp = tmp;
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
+ {
+ /* Are we inside the best run of 0x00's? */
+ if (best.base != -1 && i >= best.base && i < (best.base + best.len))
+ {
+ if (i == best.base)
+ *tp++ = ':';
+ continue;
+ }
+ /* Are we following an initial run of 0x00s or any real hex? */
+ if (i != 0)
+ *tp++ = ':';
+ /* Is this address an encapsulated IPv4? */
+ if (i == 6 && best.base == 0 &&
+ (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
+ {
+ if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp)))
+ return (NULL);
+ tp += strlen(tp);
+ break;
+ }
+ tp += SPRINTF((tp, "%x", words[i]));
+ }
+ /* Was it a trailing run of 0x00's? */
+ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
+ *tp++ = ':';
+ *tp++ = '\0';
+
+ /*
+ * Check for overflow, copy, and we're done.
+ */
+
+ if ((tp - tmp) > size)
+ {
+ return (NULL);
+ }
+ return strcpy(dst, tmp);
}
#endif
* author:
* Paul Vixie, 1996.
*/
-const char *inetntop(int af, const void *src, char *dst, unsigned int size)
+const char *
+inetntop(int af, const void *src, char *dst, unsigned int size)
{
- switch (af) {
- case AF_INET:
- return (inet_ntop4(src, dst, size));
+ switch (af)
+ {
+ case AF_INET:
+ return (inet_ntop4(src, dst, size));
#ifdef IPV6
- case AF_INET6:
- if(IN6_IS_ADDR_V4MAPPED((const struct in6_addr *)src) ||
- IN6_IS_ADDR_V4COMPAT((const struct in6_addr *)src))
- return(inet_ntop4((unsigned char *)&((struct in6_addr *)src)->s6_addr[12], dst, size));
- else
- return (inet_ntop6(src, dst, size));
-
+ case AF_INET6:
+ if (IN6_IS_ADDR_V4MAPPED((const struct in6_addr *)src) ||
+ IN6_IS_ADDR_V4COMPAT((const struct in6_addr *)src))
+ return (inet_ntop4
+ ((unsigned char *)&((struct in6_addr *)src)->s6_addr[12], dst,
+ size));
+ else
+ return (inet_ntop6(src, dst, size));
+
#endif
- default:
- return (NULL);
- }
- /* NOTREACHED */
+ default:
+ return (NULL);
+ }
+ /* NOTREACHED */
}
/*
*/
static int
inet_pton4(src, dst)
- const char *src;
- u_char *dst;
+ const char *src;
+ u_char *dst;
{
- int saw_digit, octets, ch;
- u_char tmp[INADDRSZ], *tp;
-
- saw_digit = 0;
- octets = 0;
- *(tp = tmp) = 0;
- while ((ch = *src++) != '\0') {
-
- if (ch >= '0' && ch <= '9') {
- u_int new = *tp * 10 + (ch - '0');
-
- if (new > 255)
- return (0);
- *tp = new;
- if (! saw_digit) {
- if (++octets > 4)
- return (0);
- saw_digit = 1;
- }
- } else if (ch == '.' && saw_digit) {
- if (octets == 4)
- return (0);
- *++tp = 0;
- saw_digit = 0;
- } else
- return (0);
- }
- if (octets < 4)
- return (0);
- memcpy(dst, tmp, INADDRSZ);
- return (1);
+ int saw_digit, octets, ch;
+ u_char tmp[INADDRSZ], *tp;
+
+ saw_digit = 0;
+ octets = 0;
+ *(tp = tmp) = 0;
+ while ((ch = *src++) != '\0')
+ {
+
+ if (ch >= '0' && ch <= '9')
+ {
+ u_int new = *tp * 10 + (ch - '0');
+
+ if (new > 255)
+ return (0);
+ *tp = new;
+ if (!saw_digit)
+ {
+ if (++octets > 4)
+ return (0);
+ saw_digit = 1;
+ }
+ }
+ else if (ch == '.' && saw_digit)
+ {
+ if (octets == 4)
+ return (0);
+ *++tp = 0;
+ saw_digit = 0;
+ }
+ else
+ return (0);
+ }
+ if (octets < 4)
+ return (0);
+ memcpy(dst, tmp, INADDRSZ);
+ return (1);
}
#ifdef IPV6
static int
inet_pton6(src, dst)
- const char *src;
- u_char *dst;
+ const char *src;
+ u_char *dst;
{
- static const char xdigits[] = "0123456789abcdef";
- u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
- const char *curtok;
- int ch, saw_xdigit;
- u_int val;
-
- tp = memset(tmp, '\0', IN6ADDRSZ);
- endp = tp + IN6ADDRSZ;
- colonp = NULL;
- /* Leading :: requires some special handling. */
- if (*src == ':')
- if (*++src != ':')
- return (0);
- curtok = src;
- saw_xdigit = 0;
- val = 0;
- while ((ch = tolower (*src++)) != '\0') {
- const char *pch;
-
- pch = strchr(xdigits, ch);
- if (pch != NULL) {
- val <<= 4;
- val |= (pch - xdigits);
- if (val > 0xffff)
- return (0);
- saw_xdigit = 1;
- continue;
- }
- if (ch == ':') {
- curtok = src;
- if (!saw_xdigit) {
- if (colonp)
- return (0);
- colonp = tp;
- continue;
- } else if (*src == '\0') {
- return (0);
- }
- if (tp + INT16SZ > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
- saw_xdigit = 0;
- val = 0;
- continue;
- }
- if(*src != '\0' && ch == '.')
- {
- if ( ((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) {
- tp += INADDRSZ;
- saw_xdigit = 0;
- break; /* '\0' was seen by inet_pton4(). */
- }
- } else
- continue;
- return (0);
- }
- if (saw_xdigit) {
- if (tp + INT16SZ > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
- }
- if (colonp != NULL) {
- /*
- * Since some memmove()'s erroneously fail to handle
- * overlapping regions, we'll do the shift by hand.
- */
- const int n = tp - colonp;
- int i;
-
- if (tp == endp)
- return (0);
- for (i = 1; i <= n; i++) {
- endp[- i] = colonp[n - i];
- colonp[n - i] = 0;
- }
- tp = endp;
- }
- if (tp != endp)
- return (0);
- memcpy(dst, tmp, IN6ADDRSZ);
- return (1);
+ static const char xdigits[] = "0123456789abcdef";
+ u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
+ const char *curtok;
+ int ch, saw_xdigit;
+ u_int val;
+
+ tp = memset(tmp, '\0', IN6ADDRSZ);
+ endp = tp + IN6ADDRSZ;
+ colonp = NULL;
+ /* Leading :: requires some special handling. */
+ if (*src == ':')
+ if (*++src != ':')
+ return (0);
+ curtok = src;
+ saw_xdigit = 0;
+ val = 0;
+ while ((ch = tolower(*src++)) != '\0')
+ {
+ const char *pch;
+
+ pch = strchr(xdigits, ch);
+ if (pch != NULL)
+ {
+ val <<= 4;
+ val |= (pch - xdigits);
+ if (val > 0xffff)
+ return (0);
+ saw_xdigit = 1;
+ continue;
+ }
+ if (ch == ':')
+ {
+ curtok = src;
+ if (!saw_xdigit)
+ {
+ if (colonp)
+ return (0);
+ colonp = tp;
+ continue;
+ }
+ else if (*src == '\0')
+ {
+ return (0);
+ }
+ if (tp + INT16SZ > endp)
+ return (0);
+ *tp++ = (u_char) (val >> 8) & 0xff;
+ *tp++ = (u_char) val & 0xff;
+ saw_xdigit = 0;
+ val = 0;
+ continue;
+ }
+ if (*src != '\0' && ch == '.')
+ {
+ if (((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0)
+ {
+ tp += INADDRSZ;
+ saw_xdigit = 0;
+ break; /* '\0' was seen by inet_pton4(). */
+ }
+ }
+ else
+ continue;
+ return (0);
+ }
+ if (saw_xdigit)
+ {
+ if (tp + INT16SZ > endp)
+ return (0);
+ *tp++ = (u_char) (val >> 8) & 0xff;
+ *tp++ = (u_char) val & 0xff;
+ }
+ if (colonp != NULL)
+ {
+ /*
+ * Since some memmove()'s erroneously fail to handle
+ * overlapping regions, we'll do the shift by hand.
+ */
+ const int n = tp - colonp;
+ int i;
+
+ if (tp == endp)
+ return (0);
+ for (i = 1; i <= n; i++)
+ {
+ endp[-i] = colonp[n - i];
+ colonp[n - i] = 0;
+ }
+ tp = endp;
+ }
+ if (tp != endp)
+ return (0);
+ memcpy(dst, tmp, IN6ADDRSZ);
+ return (1);
}
#endif
int
inetpton(af, src, dst)
- int af;
- const char *src;
- void *dst;
+ int af;
+ const char *src;
+ void *dst;
{
- switch (af) {
- case AF_INET:
- return (inet_pton4(src, dst));
+ switch (af)
+ {
+ case AF_INET:
+ return (inet_pton4(src, dst));
#ifdef IPV6
- case AF_INET6:
- /* Somebody might have passed as an IPv4 address this is sick but it works */
- if(inet_pton4(src, dst))
- {
- char tmp[HOSTIPLEN];
- ircsprintf(tmp, "::ffff:%s", src);
- return (inet_pton6(tmp, dst));
- }
- else
- return (inet_pton6(src, dst));
+ case AF_INET6:
+ /* Somebody might have passed as an IPv4 address this is sick but it works */
+ if (inet_pton4(src, dst))
+ {
+ char tmp[HOSTIPLEN];
+ ircsprintf(tmp, "::ffff:%s", src);
+ return (inet_pton6(tmp, dst));
+ }
+ else
+ return (inet_pton6(src, dst));
#endif
- default:
- return (-1);
- }
- /* NOTREACHED */
+ default:
+ return (-1);
+ }
+ /* NOTREACHED */
}
/*
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
#ifndef HAVE_STRLCAT
-size_t strlcat(char *dst, const char *src, size_t siz)
+size_t
+strlcat(char *dst, const char *src, size_t siz)
{
- char *d = dst;
- const char *s = src;
- size_t n = siz, dlen;
-
- while (*d != '\0' && n-- != 0)
- d++;
- dlen = d - dst;
- n = siz - dlen;
-
- if (n == 0)
- return(dlen + strlen(s));
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
- *d = '\0';
- return(dlen + (s - src)); /* count does not include NUL */
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz, dlen;
+
+ while (*d != '\0' && n-- != 0)
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return (dlen + strlen(s));
+ while (*s != '\0')
+ {
+ if (n != 1)
+ {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+ return (dlen + (s - src)); /* count does not include NUL */
}
#endif
#ifndef HAVE_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t siz)
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
{
- char *d = dst;
- const char *s = src;
- size_t n = siz;
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0)
+ {
+ do
+ {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0)
+ {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return (s - src - 1); /* count does not include NUL */
}
#endif
#undef strncpy_irc
#endif
-char* strncpy_irc(char* s1, const char* s2, size_t n)
+char *
+strncpy_irc(char *s1, const char *s2, size_t n)
{
char *endp = s1 + n;
char *s = s1;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: ircd.c,v 1.1 2002/01/04 09:14:05 a1kmm Exp $
+ * $Id: ircd.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include <sys/types.h>
#include "motd.h"
#include "ircd_handler.h"
#include "md5.h"
-#include "msg.h" /* msgtab */
+#include "msg.h" /* msgtab */
#include "hostmask.h"
#include "numeric.h"
#include "parse.h"
#include "s_debug.h"
#include "s_log.h"
#include "s_misc.h"
-#include "s_serv.h" /* try_connections */
+#include "s_serv.h" /* try_connections */
#include "s_stats.h"
#include "scache.h"
#include "send.h"
struct SetOptions GlobalSetOptions;
/* configuration set from ircd.conf */
-struct config_file_entry ConfigFileEntry;
+struct config_file_entry ConfigFileEntry;
/* server info set from ircd.conf */
struct server_info ServerInfo;
/* admin info set from ircd.conf */
struct admin_info AdminInfo;
-struct Counter Count;
-struct ServerState_t server_state;
+struct Counter Count;
+struct ServerState_t server_state;
struct timeval SystemTime;
-int ServerRunning; /* GLOBAL - server execution state */
+int ServerRunning; /* GLOBAL - server execution state */
struct Client me; /* That's me */
-struct LocalUser meLocalUser; /* That's also part of me */
+struct LocalUser meLocalUser; /* That's also part of me */
-struct Client* GlobalClientList = 0; /* Pointer to beginning of Client list */
+struct Client *GlobalClientList = 0; /* Pointer to beginning of Client list */
struct JupedChannel *JupedChannelList = 0;
-/* unknown/client pointer lists */
+/* unknown/client pointer lists */
dlink_list unknown_list; /* unknown clients ON this server only */
dlink_list lclient_list; /* local clients only ON this server */
dlink_list serv_list; /* local servers to this server ONLY */
dlink_list dead_list; /* clients that have exited, to be freed */
dlink_list lazylink_channels; /* known about lazylink channels on HUB */
-dlink_list lazylink_nicks; /* known about lazylink nicks on HUB */
+dlink_list lazylink_nicks; /* known about lazylink nicks on HUB */
-int callbacks_called; /* A measure of server load... */
+int callbacks_called; /* A measure of server load... */
-static unsigned long initialVMTop = 0; /* top of virtual memory at init */
-static const char * logFileName = LPATH;
-static const char * pidFileName = PPATH;
+static unsigned long initialVMTop = 0; /* top of virtual memory at init */
+static const char *logFileName = LPATH;
+static const char *pidFileName = PPATH;
-char** myargv;
-int dorehash = 0;
-int debuglevel = -1; /* Server debug level */
-char* debugmode = ""; /* -"- -"- -"- */
-time_t nextconnect = 1; /* time for next try_connections call */
+char **myargv;
+int dorehash = 0;
+int debuglevel = -1; /* Server debug level */
+char *debugmode = ""; /* -"- -"- -"- */
+time_t nextconnect = 1; /* time for next try_connections call */
/* Set to zero because it should be initialized later using
* initialize_server_capabs
*/
-int default_server_capabs = 0x00000000;
+int default_server_capabs = 0x00000000;
int splitmode;
int split_users;
/*
* get_vm_top - get the operating systems notion of the resident set size
*/
-static unsigned long get_vm_top(void)
+static unsigned long
+get_vm_top(void)
{
/*
* NOTE: sbrk is not part of the ANSI C library or the POSIX.1 standard
* returned. We really shouldn't be using it here but...
*/
#ifndef VMS
- void* vptr = sbrk(0);
- return (unsigned long) vptr;
+ void *vptr = sbrk(0);
+ return (unsigned long)vptr;
#else
return 0;
#endif
/*
* get_maxrss - get the operating systems notion of the resident set size
*/
-unsigned long get_maxrss(void)
+unsigned long
+get_maxrss(void)
{
return get_vm_top() - initialVMTop;
}
{
printf("ircd: version %s\n", ircd_version);
printf("ircd: pid %d\n", pid);
- printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
- : "foreground", ConfigFileEntry.dpath);
+ printf("ircd: running in %s mode from %s\n",
+ !server_state.foreground ? "background" : "foreground",
+ ConfigFileEntry.dpath);
}
/*
* output - none
* side effects - if boot_daemon flag is not set, don't daemonize
*/
-static void
+static void
init_sys(void)
{
#if defined(RLIMIT_FD_MAX) && !defined(VMS)
struct rlimit limit;
if (!getrlimit(RLIMIT_FD_MAX, &limit))
+ {
+
+ if (limit.rlim_max < MAXCONNECTIONS)
{
+ fprintf(stderr, "ircd fd table too big\n");
+ fprintf(stderr, "Hard Limit: %ld IRC max: %d\n",
+ (long)limit.rlim_max, MAXCONNECTIONS);
+ fprintf(stderr, "Fix MAXCONNECTIONS\n");
+ exit(-1);
+ }
- if (limit.rlim_max < MAXCONNECTIONS)
- {
- fprintf(stderr,"ircd fd table too big\n");
- fprintf(stderr,"Hard Limit: %ld IRC max: %d\n",
- (long) limit.rlim_max, MAXCONNECTIONS);
- fprintf(stderr,"Fix MAXCONNECTIONS\n");
- exit(-1);
- }
-
- limit.rlim_cur = limit.rlim_max; /* make soft limit the max */
- if (setrlimit(RLIMIT_FD_MAX, &limit) == -1)
- {
- fprintf(stderr,"error setting max fd's to %ld\n",
- (long) limit.rlim_cur);
- exit(EXIT_FAILURE);
- }
+ limit.rlim_cur = limit.rlim_max; /* make soft limit the max */
+ if (setrlimit(RLIMIT_FD_MAX, &limit) == -1)
+ {
+ fprintf(stderr, "error setting max fd's to %ld\n",
+ (long)limit.rlim_cur);
+ exit(EXIT_FAILURE);
}
-#endif /* RLIMIT_FD_MAX */
+ }
+#endif /* RLIMIT_FD_MAX */
}
int
{
#ifndef VMS
int pid;
-
- if((pid = fork()) < 0)
- {
- perror("fork");
- exit(EXIT_FAILURE);
- }
+
+ if ((pid = fork()) < 0)
+ {
+ perror("fork");
+ exit(EXIT_FAILURE);
+ }
else if (pid > 0)
- {
- print_startup(pid);
- exit(EXIT_SUCCESS);
- }
+ {
+ print_startup(pid);
+ exit(EXIT_SUCCESS);
+ }
setsid();
/* fclose(stdin);
- fclose(stdout);
- fclose(stderr); */
+ fclose(stdout);
+ fclose(stderr); */
#else
/* if we get here, assume we've been detached.
better set a process name. */
static int printVersion = 0;
struct lgetopt myopts[] = {
- {"dlinefile", &ConfigFileEntry.dlinefile,
+ {"dlinefile", &ConfigFileEntry.dlinefile,
STRING, "File to use for dlines.conf"},
- {"configfile", &ConfigFileEntry.configfile,
+ {"configfile", &ConfigFileEntry.configfile,
STRING, "File to use for ircd.conf"},
- {"klinefile", &ConfigFileEntry.klinefile,
+ {"klinefile", &ConfigFileEntry.klinefile,
STRING, "File to use for klines.conf"},
- {"logfile", &logFileName,
+ {"logfile", &logFileName,
STRING, "File to use for ircd.log"},
- {"pidfile", &pidFileName,
+ {"pidfile", &pidFileName,
STRING, "File to use for process ID"},
- {"foreground", &server_state.foreground,
+ {"foreground", &server_state.foreground,
YESNO, "Run in foreground (don't detach)"},
- {"version", &printVersion,
+ {"version", &printVersion,
YESNO, "Print version and exit"},
#ifdef DEBUGMODE
- {"debug", NULL,
+ {"debug", NULL,
ENDEBUG, "Enable debugging for a certain value"},
#endif
{"help", NULL, USAGE, "Print this text"},
struct timeval newtime;
newtime.tv_sec = 0;
newtime.tv_usec = 0;
- if(gettimeofday(&newtime, NULL) == -1)
- {
- ilog(L_ERROR, "Clock Failure (%d)", errno);
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Clock Failure (%d), TS can be corrupted", errno);
-
- restart("Clock Failure");
- }
+ if (gettimeofday(&newtime, NULL) == -1)
+ {
+ ilog(L_ERROR, "Clock Failure (%d)", errno);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Clock Failure (%d), TS can be corrupted", errno);
+
+ restart("Clock Failure");
+ }
if (newtime.tv_sec < CurrentTime)
- {
- ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)",
- (unsigned long) newtime.tv_sec,
- (unsigned long) CurrentTime);
- report_error(L_ALL, to_send, me.name, 0);
- set_back_events(CurrentTime - newtime.tv_sec);
- }
+ {
+ ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)",
+ (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
+ report_error(L_ALL, to_send, me.name, 0);
+ set_back_events(CurrentTime - newtime.tv_sec);
+ }
SystemTime.tv_sec = newtime.tv_sec;
SystemTime.tv_usec = newtime.tv_usec;
}
static void
io_loop(void)
{
- int empty_cycles=0, st=0, delay;
+ int empty_cycles = 0, st = 0, delay;
while (ServerRunning)
- {
- /* Run pending events, then get the number of seconds to the next
- * event
- */
+ {
+ /* Run pending events, then get the number of seconds to the next
+ * event
+ */
- delay = eventNextTime();
- if (delay <= CurrentTime)
- eventRun();
-
- /* Check on the last activity, sleep for up to 1/2s if we are idle... */
- if (callbacks_called > 0)
- empty_cycles = 0;
-
- /* Reset the callback counter... */
- callbacks_called = 0;
-
- if (empty_cycles++ > 10)
- comm_select((st=((empty_cycles-10)*10)>500 ? 500 : st));
- else
- comm_select(0);
-
- /*
- * Check to see whether we have to rehash the configuration ..
- */
- if (dorehash)
- {
- rehash(1);
- dorehash = 0;
- }
+ delay = eventNextTime();
+ if (delay <= CurrentTime)
+ eventRun();
+
+ /* Check on the last activity, sleep for up to 1/2s if we are idle... */
+ if (callbacks_called > 0)
+ empty_cycles = 0;
+
+ /* Reset the callback counter... */
+ callbacks_called = 0;
+
+ if (empty_cycles++ > 10)
+ comm_select((st = ((empty_cycles - 10) * 10) > 500 ? 500 : st));
+ else
+ comm_select(0);
+
+ /*
+ * Check to see whether we have to rehash the configuration ..
+ */
+ if (dorehash)
+ {
+ rehash(1);
+ dorehash = 0;
}
+ }
}
/*
* output - none
* side effects - This sets all global set options needed
*/
-static void initialize_global_set_options(void)
+static void
+initialize_global_set_options(void)
{
- memset( &GlobalSetOptions, 0, sizeof(GlobalSetOptions));
+ memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
/* memset( &ConfigFileEntry, 0, sizeof(ConfigFileEntry)); */
GlobalSetOptions.maxclients = MAX_CLIENTS;
GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
GlobalSetOptions.spam_num = MAX_JOIN_LEAVE_COUNT;
- if(ConfigFileEntry.default_floodcount)
+ if (ConfigFileEntry.default_floodcount)
GlobalSetOptions.floodcount = ConfigFileEntry.default_floodcount;
else
GlobalSetOptions.floodcount = 10;
split_users = ConfigChannel.split_server_count;
split_servers = ConfigChannel.split_user_count;
- if(split_users && split_servers)
+ if (split_users && split_servers)
splitmode = 1;
/* memset( &ConfigChannel, 0, sizeof(ConfigChannel)); */
- /* End of global set options */
+ /* End of global set options */
}
* output - none
* side effects - Set up all message files needed, motd etc.
*/
-static void initialize_message_files(void)
+static void
+initialize_message_files(void)
{
- InitMessageFile( HELP_MOTD, HPATH, &ConfigFileEntry.helpfile );
- InitMessageFile( UHELP_MOTD, UHPATH, &ConfigFileEntry.uhelpfile );
- InitMessageFile( USER_MOTD, MPATH, &ConfigFileEntry.motd );
- InitMessageFile( OPER_MOTD, OPATH, &ConfigFileEntry.opermotd );
- InitMessageFile( USER_LINKS, LIPATH, &ConfigFileEntry.linksfile );
-
- ReadMessageFile( &ConfigFileEntry.helpfile );
- ReadMessageFile( &ConfigFileEntry.uhelpfile );
- ReadMessageFile( &ConfigFileEntry.motd );
- ReadMessageFile( &ConfigFileEntry.opermotd );
- ReadMessageFile( &ConfigFileEntry.linksfile );
+ InitMessageFile(HELP_MOTD, HPATH, &ConfigFileEntry.helpfile);
+ InitMessageFile(UHELP_MOTD, UHPATH, &ConfigFileEntry.uhelpfile);
+ InitMessageFile(USER_MOTD, MPATH, &ConfigFileEntry.motd);
+ InitMessageFile(OPER_MOTD, OPATH, &ConfigFileEntry.opermotd);
+ InitMessageFile(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile);
+
+ ReadMessageFile(&ConfigFileEntry.helpfile);
+ ReadMessageFile(&ConfigFileEntry.uhelpfile);
+ ReadMessageFile(&ConfigFileEntry.motd);
+ ReadMessageFile(&ConfigFileEntry.opermotd);
+ ReadMessageFile(&ConfigFileEntry.linksfile);
}
/*
* inputs - none
* output - none
*/
-static void initialize_server_capabs(void)
+static void
+initialize_server_capabs(void)
{
/* Default server CAPAB, as defined by CAP_MASK in s_serv.h */
default_server_capabs = CAP_MASK;
* output - none
* side effects - write the pid of the ircd to filename
*/
-static void write_pidfile(const char *filename)
+static void
+write_pidfile(const char *filename)
{
- FBFILE* fb;
+ FBFILE *fb;
char buff[32];
if ((fb = fbopen(filename, "w")))
{
- unsigned int pid = (unsigned int) getpid();
+ unsigned int pid = (unsigned int)getpid();
- ircsprintf(buff,"%u\n", pid);
- if ((fbputs(buff, fb) == -1))
- {
- ilog(L_ERROR,"Error writing %u to pid file %s (%s)",
- pid, filename, strerror(errno));
- }
- fbclose(fb);
- return;
+ ircsprintf(buff, "%u\n", pid);
+ if ((fbputs(buff, fb) == -1))
+ {
+ ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
+ pid, filename, strerror(errno));
+ }
+ fbclose(fb);
+ return;
}
else
{
* list. if it is, gracefully exits
* -kre
*/
-static void check_pidfile(const char *filename)
+static void
+check_pidfile(const char *filename)
{
- FBFILE* fb;
+ FBFILE *fb;
char buff[32];
pid_t pidfromfile;
/* Don't do logging here, since we don't have log() initialised */
if ((fb = fbopen(filename, "r")))
+ {
+ if (fbgets(buff, 20, fb) == NULL)
{
- if (fbgets(buff, 20, fb) == NULL)
- {
- /*
- log(L_ERROR, "Error reading from pid file %s (%s)", filename,
- strerror(errno));
- */
- }
- else
- {
- pidfromfile = atoi(buff);
- if (!kill(pidfromfile, 0))
- {
- /* log(L_ERROR, "Server is already running"); */
- printf("ircd: daemon is already running\n");
- exit(-1);
- }
- }
- fbclose(fb);
+ /*
+ log(L_ERROR, "Error reading from pid file %s (%s)", filename,
+ strerror(errno));
+ */
}
- else
+ else
{
- /* log(L_ERROR, "Error opening pid file %s", filename); */
+ pidfromfile = atoi(buff);
+ if (!kill(pidfromfile, 0))
+ {
+ /* log(L_ERROR, "Server is already running"); */
+ printf("ircd: daemon is already running\n");
+ exit(-1);
+ }
}
+ fbclose(fb);
+ }
+ else
+ {
+ /* log(L_ERROR, "Error opening pid file %s", filename); */
+ }
}
/*
* side effects - setups corefile to system limits.
* -kre
*/
-static void setup_corefile(void)
+static void
+setup_corefile(void)
{
#ifndef VMS
- struct rlimit rlim; /* resource limits */
+ struct rlimit rlim; /* resource limits */
/* Set corefilesize to maximum */
if (!getrlimit(RLIMIT_CORE, &rlim))
- {
- rlim.rlim_cur = rlim.rlim_max;
- setrlimit(RLIMIT_CORE, &rlim);
- }
+ {
+ rlim.rlim_cur = rlim.rlim_max;
+ setrlimit(RLIMIT_CORE, &rlim);
+ }
#endif
}
* side effects - Reaps zombies periodically
* -AndroSyn
*/
-static void cleanup_zombies(void *unused)
+static void
+cleanup_zombies(void *unused)
{
int status;
waitpid(-1, &status, WNOHANG);
serv_list.head = serv_list.tail = NULL;
global_serv_list.head = global_serv_list.tail = NULL;
- GlobalClientList = &me; /* Pointer to beginning of Client list */
+ GlobalClientList = &me; /* Pointer to beginning of Client list */
memset((void *)&Count, 0, sizeof(Count));
memset((void *)&server_state, 0, sizeof(server_state));
- Count.server = 1; /* us */
+ Count.server = 1; /* us */
memset((void *)&ServerInfo, 0, sizeof(ServerInfo));
memset((void *)&AdminInfo, 0, sizeof(AdminInfo));
init_chcap_usage_counts();
ConfigFileEntry.dpath = DPATH;
- ConfigFileEntry.configfile = CPATH; /* Server configuration file */
- ConfigFileEntry.klinefile = KPATH; /* Server kline file */
- ConfigFileEntry.dlinefile = DLPATH; /* dline file */
- ConfigFileEntry.glinefile = GPATH; /* gline log file */
+ ConfigFileEntry.configfile = CPATH; /* Server configuration file */
+ ConfigFileEntry.klinefile = KPATH; /* Server kline file */
+ ConfigFileEntry.dlinefile = DLPATH; /* dline file */
+ ConfigFileEntry.glinefile = GPATH; /* gline log file */
myargv = argv;
- umask(077); /* better safe than sorry --SRB */
+ umask(077); /* better safe than sorry --SRB */
parseargs(&argc, &argv, myopts);
setup_signals();
/* We need this to initialise the fd array before anything else */
fdlist_init();
- init_netio(); /* This needs to be setup early ! -- adrian */
+ init_netio(); /* This needs to be setup early ! -- adrian */
/* Check if there is pidfile and daemon already running */
check_pidfile(pidFileName);
/* Init the event subsystem */
initBlockHeap();
init_dlink_nodes();
initialize_message_files();
- linebuf_init(); /* set up some linebuf stuff to control paging */
+ linebuf_init(); /* set up some linebuf stuff to control paging */
init_hash();
id_init();
- clear_scache_hash_table(); /* server cache name table */
- clear_ip_hash_table(); /* client host ip hash table */
- init_host_hash(); /* Host-hashtable. */
+ clear_scache_hash_table(); /* server cache name table */
+ clear_ip_hash_table(); /* client host ip hash table */
+ init_host_hash(); /* Host-hashtable. */
clear_hash_parse();
init_client();
initUser();
load_core_modules(1);
#endif
initServerMask();
- init_auth(); /* Initialise the auth code */
- init_resolver(); /* Needs to be setup before the io loop */
- read_conf_files(YES); /* cold start init conf files */
+ init_auth(); /* Initialise the auth code */
+ init_resolver(); /* Needs to be setup before the io loop */
+ read_conf_files(YES); /* cold start init conf files */
- initialize_server_capabs(); /* Set up default_server_capabs */
+ initialize_server_capabs(); /* Set up default_server_capabs */
initialize_global_set_options();
if (ServerInfo.name == NULL)
{
fprintf(stderr,
- "ERROR: No server name specified in serverinfo block.\n");
- ilog(L_CRIT,
- "No server name specified in serverinfo block.");
+ "ERROR: No server name specified in serverinfo block.\n");
+ ilog(L_CRIT, "No server name specified in serverinfo block.");
exit(EXIT_FAILURE);
}
/* Can't use strncpy_irc here because we didn't malloc enough... -A1kmm */
strncpy(me.name, ServerInfo.name, HOSTLEN);
- /* serverinfo{} description must exist. If not, error out.*/
+ /* serverinfo{} description must exist. If not, error out. */
if (ServerInfo.description == NULL)
{
fprintf(stderr,
- "ERROR: No server description specified in serverinfo block.\n");
+ "ERROR: No server description specified in serverinfo block.\n");
ilog(L_CRIT,
- "ERROR: No server description specified in serverinfo block.");
+ "ERROR: No server description specified in serverinfo block.");
exit(EXIT_FAILURE);
}
strncpy(me.info, ServerInfo.description, REALLEN);
#ifdef USE_GETTEXT
- /*
- * For 'locale' try (in this order):
- * Config entry "msglocale" (yyparse() will overwrite LANGUAGE)
- * Env variable "LANGUAGE"
- * Default of "" (so don't overwrite LANGUAGE here)
- */
+ /*
+ * For 'locale' try (in this order):
+ * Config entry "msglocale" (yyparse() will overwrite LANGUAGE)
+ * Env variable "LANGUAGE"
+ * Default of "" (so don't overwrite LANGUAGE here)
+ */
if (!getenv("LANGUAGE"))
{
}
textdomain("ircd-hybrid");
- bindtextdomain("ircd-hybrid" , MSGPATH);
+ bindtextdomain("ircd-hybrid", MSGPATH);
#endif
#ifdef USE_IAUTH
if (iAuth.socket == NOSOCK)
{
fprintf(stderr, "Unable to connect to IAuth server\n");
- exit (EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
#endif
me.serv->up = me.name;
me.lasttime = me.since = me.firsttime = CurrentTime;
add_to_client_hash_table(me.name, &me);
-
- add_server_to_list(&me); /* add ourselves to global_serv_list */
-
+
+ add_server_to_list(&me); /* add ourselves to global_serv_list */
+
check_class();
write_pidfile(pidFileName);
-
+
ilog(L_NOTICE, "Server Ready");
-
- eventAdd("cleanup_channels", cleanup_channels, NULL, CLEANUP_CHANNELS_TIME);
+
+ eventAdd("cleanup_channels", cleanup_channels, NULL,
+ CLEANUP_CHANNELS_TIME);
eventAdd("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
/* We want try_connections to be called as soon as possible now! -- adrian */
/* No, 'cause after a restart it would cause all sorts of nick collides */
- eventAdd("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
+ eventAdd("try_connections", try_connections, NULL,
+ STARTUP_CONNECTIONS_TIME);
eventAdd("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
/* Setup the timeout check. I'll shift it later :) -- adrian */
eventAdd("comm_checktimeouts", comm_checktimeouts, NULL, 1);
- eventAdd("cleanup_zombies", cleanup_zombies, NULL, 30);
-
+ eventAdd("cleanup_zombies", cleanup_zombies, NULL, 30);
+
#ifdef PACE_CONNECT
- if (ConfigFileEntry.throttle_time > 0)
- eventAdd("flush_expired_ips", flush_expired_ips, NULL, ConfigFileEntry.throttle_time);
- else
- eventAdd("flush_expired_ips", flush_expired_ips, NULL, 300);
+ if (ConfigFileEntry.throttle_time > 0)
+ eventAdd("flush_expired_ips", flush_expired_ips, NULL,
+ ConfigFileEntry.throttle_time);
+ else
+ eventAdd("flush_expired_ips", flush_expired_ips, NULL, 300);
#endif
if (ConfigServerHide.links_delay > 0)
- eventAdd("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
+ eventAdd("write_links_file", write_links_file, NULL,
+ ConfigServerHide.links_delay);
else
ConfigServerHide.links_disabled = 1;
- if(splitmode)
+ if (splitmode)
eventAdd("check_splitmode", check_splitmode, NULL, 60);
ServerRunning = 1;
#ifndef STATIC_MODULES
- } /* ircd_ready == 0*/
+ } /* ircd_ready == 0 */
#endif
ircd_ready = 1;
io_loop();
return 0;
}
-
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: ircd_signal.c,v 1.1 2002/01/04 09:14:10 a1kmm Exp $
+ * $Id: ircd_signal.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include <signal.h>
#include <stdlib.h>
#include "ircd_signal.h"
-#include "ircd.h" /* dorehash */
-#include "restart.h" /* server_reboot */
+#include "ircd.h" /* dorehash */
+#include "restart.h" /* server_reboot */
#include "s_log.h"
#include "memory.h"
#include "s_bsd.h"
/*
* dummy_handler - don't know if this is really needed but if alarm is still
* being used we probably will
- */
-static void dummy_handler(int sig)
+ */
+static void
+dummy_handler(int sig)
{
/* Empty */
}
/*
* sigterm_handler - exit the server
*/
-static void sigterm_handler(int sig)
+static void
+sigterm_handler(int sig)
{
/* XXX we had a flush_connections() here - we should close all the
* connections and flush data. read server_reboot() for my explanation.
ilog(L_CRIT, "Server killed By SIGTERM");
exit(-1);
}
-
+
/*
* sighup_handler - reread the server configuration
*/
-static void sighup_handler(int sig)
+static void
+sighup_handler(int sig)
{
dorehash = 1;
}
/*
* sigint_handler - restart the server
*/
-static void sigint_handler(int sig)
+static void
+sigint_handler(int sig)
{
static int restarting = 0;
- if (server_state.foreground)
- {
- ilog(L_WARN, "Server exiting on SIGINT");
- exit(0);
- }
+ if (server_state.foreground)
+ {
+ ilog(L_WARN, "Server exiting on SIGINT");
+ exit(0);
+ }
else
+ {
+ ilog(L_WARN, "Server Restarting on SIGINT");
+ if (restarting == 0)
{
- ilog(L_WARN, "Server Restarting on SIGINT");
- if (restarting == 0)
- {
- restarting = 1;
- server_reboot();
- }
+ restarting = 1;
+ server_reboot();
}
+ }
}
/*
* setup_signals - initialize signal handlers for server
*/
-void setup_signals()
+void
+setup_signals()
{
struct sigaction act;
#endif
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: ircdauth.c,v 1.1 2002/01/04 09:14:10 a1kmm Exp $
+ * $Id: ircdauth.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include <stdio.h>
/*
* Array of pointers to each parameter IAuth sends
*/
-static char *param[MAXPARAMS + 1];
-static int paramc; /* param count */
-static char *nextparam = NULL; /* pointer to next parameter */
+static char *param[MAXPARAMS + 1];
+static int paramc; /* param count */
+static char *nextparam = NULL; /* pointer to next parameter */
/*
* If the data read into buffer[] contains several lines,
int
ConnectToIAuth()
-
{
- struct sockaddr_in ServAddr;
- struct hostent *hostptr;
- struct in_addr *ptr;
-
- iAuth.socket = comm_open(AF_INET, SOCK_STREAM, 0, "iAuth socket");
- if (iAuth.socket < 0)
- {
- report_error(L_ALL, "ConnectToIAuth(): Unable to open stream socket to %s: %s",
- iAuth.hostname,
- errno);
- iAuth.socket = NOSOCK;
- return(NOSOCK);
- }
+ struct sockaddr_in ServAddr;
+ struct hostent *hostptr;
+ struct in_addr *ptr;
+
+ iAuth.socket = comm_open(AF_INET, SOCK_STREAM, 0, "iAuth socket");
+ if (iAuth.socket < 0)
+ {
+ report_error(L_ALL,
+ "ConnectToIAuth(): Unable to open stream socket to %s: %s",
+ iAuth.hostname, errno);
+ iAuth.socket = NOSOCK;
+ return (NOSOCK);
+ }
/*
* bingo - this is blocking :(
*/
ilog(L_ERROR, "looking up: %s\n", iAuth.hostname);
- if ((hostptr = gethostbyname(iAuth.hostname)) == NULL)
- {
+ if ((hostptr = gethostbyname(iAuth.hostname)) == NULL)
+ {
ilog(L_ERROR, "unsuccessful lookup\n");
- ilog(L_ERROR,
- "Unable to connect to IAuth server: Unknown host");
-
- fd_close(iAuth.socket);
- iAuth.socket = NOSOCK;
- return(NOSOCK);
- }
-
- memset((void *) &ServAddr, 0, sizeof(ServAddr));
-
- ptr = (struct in_addr *) *hostptr->h_addr_list;
- ServAddr.sin_addr.s_addr = ptr->s_addr;
-
- ServAddr.sin_family = AF_INET;
- ServAddr.sin_port = htons(iAuth.port);
-
- if (!set_non_blocking(iAuth.socket))
- {
- ilog(L_ERROR,
- "ConnectToIAuth(): set_non_blocking() failed");
- fd_close(iAuth.socket);
- iAuth.socket = NOSOCK;
- return (NOSOCK);
- }
-
- if (connect(iAuth.socket, (struct sockaddr *) &ServAddr, sizeof(ServAddr)) < 0)
- {
- if (errno != EINPROGRESS)
- {
- ilog(L_ERROR,
- "Unable to connect to IAuth server: %s",
- strerror(errno));
- fd_close(iAuth.socket);
- iAuth.socket = NOSOCK;
- return(NOSOCK);
- }
- }
-
- SetIAuthConnect(iAuth);
+ ilog(L_ERROR, "Unable to connect to IAuth server: Unknown host");
+
+ fd_close(iAuth.socket);
+ iAuth.socket = NOSOCK;
+ return (NOSOCK);
+ }
+
+ memset((void *)&ServAddr, 0, sizeof(ServAddr));
+
+ ptr = (struct in_addr *)*hostptr->h_addr_list;
+ ServAddr.sin_addr.s_addr = ptr->s_addr;
+
+ ServAddr.sin_family = AF_INET;
+ ServAddr.sin_port = htons(iAuth.port);
+
+ if (!set_non_blocking(iAuth.socket))
+ {
+ ilog(L_ERROR, "ConnectToIAuth(): set_non_blocking() failed");
+ fd_close(iAuth.socket);
+ iAuth.socket = NOSOCK;
+ return (NOSOCK);
+ }
+
+ if (connect(iAuth.socket, (struct sockaddr *)&ServAddr, sizeof(ServAddr)) <
+ 0)
+ {
+ if (errno != EINPROGRESS)
+ {
+ ilog(L_ERROR, "Unable to connect to IAuth server: %s", strerror(errno));
+ fd_close(iAuth.socket);
+ iAuth.socket = NOSOCK;
+ return (NOSOCK);
+ }
+ }
+
+ SetIAuthConnect(iAuth);
comm_setselect(iAuth.socket, FDLIST_SERVER, COMM_SELECT_WRITE,
CompleteIAuthConnection, NULL, 0);
- return(iAuth.socket);
-} /* ConnectToIAuth() */
+ return (iAuth.socket);
+} /* ConnectToIAuth() */
/*
CompleteIAuthConnection()
static void
CompleteIAuthConnection(int fd, void *notused)
-
{
- int errval;
- unsigned int errlen;
-
- ClearIAuthConnect(iAuth);
-
- errval = 0;
- errlen = sizeof(errval);
- if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&errval, &errlen) < 0)
- {
- ilog(L_ERROR,
- "CompleteIAuthConnection(): getsockopt(SO_ERROR) failed: %s",
- strerror(errno));
+ int errval;
+ unsigned int errlen;
+
+ ClearIAuthConnect(iAuth);
+
+ errval = 0;
+ errlen = sizeof(errval);
+ if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&errval, &errlen) < 0)
+ {
+ ilog(L_ERROR,
+ "CompleteIAuthConnection(): getsockopt(SO_ERROR) failed: %s",
+ strerror(errno));
/* return 0; */
return;
- }
-
- if (errval > 0)
- {
- ilog(L_ERROR,
- "Connect to IAuth server (%s:%d) failed: %s",
- iAuth.hostname,
- iAuth.port,
- strerror(errval));
- /*return 0;*/
+ }
+
+ if (errval > 0)
+ {
+ ilog(L_ERROR,
+ "Connect to IAuth server (%s:%d) failed: %s",
+ iAuth.hostname, iAuth.port, strerror(errval));
+ /*return 0; */
return;
- }
+ }
- comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ,
- ParseIAuth, NULL, 0);
+ comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ, ParseIAuth, NULL, 0);
- /*return (1);*/
-} /* CompleteIAuthConnection() */
+ /*return (1); */
+} /* CompleteIAuthConnection() */
/*
BeginAuthorization()
void
BeginAuthorization(struct Client *client)
-
{
- char buf[BUFSIZE];
- int len;
+ char buf[BUFSIZE];
+ int len;
- assert(iAuth.socket != NOSOCK);
+ assert(iAuth.socket != NOSOCK);
- /*
- * The client ID will be the memory address of the
- * client. This is acceptable, because as long
- * as the client exists, no other client will have
- * the same address, thus ensuring a unique ID for
- * each client.
- */
+ /*
+ * The client ID will be the memory address of the
+ * client. This is acceptable, because as long
+ * as the client exists, no other client will have
+ * the same address, thus ensuring a unique ID for
+ * each client.
+ */
- /* XXX - the IPv6 code is very broken */
- len = sprintf(buf,
+ /* XXX - the IPv6 code is very broken */
+ len = sprintf(buf,
#ifdef IPV6
- "DoAuth %p %s %s %s %lu %s\n",
+ "DoAuth %p %s %s %s %lu %s\n",
#else
- "DoAuth %p %s %s %s %u %s\n",
+ "DoAuth %p %s %s %s %u %s\n",
#endif
- client,
- client->name,
- client->username,
- client->host,
+ client, client->name, client->username, client->host,
#ifdef IPV6
- (long unsigned int)0,
+ (long unsigned int)0,
/* (unsigned int) client->localClient->ip6.s6_addr, */
#else
- (unsigned int) client->localClient->ip.sins.sin.s_addr,
+ (unsigned int)client->localClient->ip.sins.sin.s_addr,
#endif
- client->localClient->passwd);
+ client->localClient->passwd);
send(iAuth.socket, buf, len, 0);
-} /* BeginAuthorization() */
+} /* BeginAuthorization() */
/*
SendIAuth()
void
SendIAuth(char *format, ...)
-
{
- va_list args;
- char buf[BUFSIZE];
- int len;
+ va_list args;
+ char buf[BUFSIZE];
+ int len;
- assert(iAuth.socket != NOSOCK);
+ assert(iAuth.socket != NOSOCK);
- va_start(args, format);
+ va_start(args, format);
- len = vsprintf(buf, format, args);
+ len = vsprintf(buf, format, args);
- va_end(args);
+ va_end(args);
- send(iAuth.socket, buf, len, 0);
-} /* SendIAuth() */
+ send(iAuth.socket, buf, len, 0);
+} /* SendIAuth() */
/*
ParseIAuth()
static void
ParseIAuth(int fd, void *notused)
-
{
- int length; /* number of bytes we read */
- char *ch;
- char *linech;
+ int length; /* number of bytes we read */
+ char *ch;
+ char *linech;
- /* read in a line */
- length = recv(fd, buffer, BUFSIZE, 0);
+ /* read in a line */
+ length = recv(fd, buffer, BUFSIZE, 0);
- if ((length == (-1)) && ((errno == EWOULDBLOCK) || (errno == EAGAIN)))
- return; /* no error - there's just nothing to read */
+ if ((length == (-1)) && ((errno == EWOULDBLOCK) || (errno == EAGAIN)))
+ return; /* no error - there's just nothing to read */
- if (length <= 0)
- {
- ilog(L_ERROR, "Read error from server: %s",
- strerror(errno));
+ if (length <= 0)
+ {
+ ilog(L_ERROR, "Read error from server: %s", strerror(errno));
return;
- #if 0
- return 0; /* the connection was closed */
- #endif
- }
-
- /*
- * buffer may not be big enough to read the whole last line
- * so it may contain only part of it
- */
- buffer[length] = '\0';
-
- fprintf(stderr, "%s", buffer);
-
- /*
- * buffer could possibly contain several lines of info,
- * especially if this is the inital connect burst, so go
- * through, and record each line (until we hit a \n) and
- * process it separately
- */
-
- ch = buffer;
- linech = spill + offset;
-
- /*
- * The following routine works something like this:
- * buffer may contain several full lines, and then
- * a partial line. If this is the case, loop through
- * buffer, storing each character in 'spill' until
- * we hit a \n or \r. When we do, process the line.
- * When we hit the end of buffer, spill will contain
- * the partial line that buffer had, and offset will
- * contain the index of spill where we left off, so the
- * next time we recv() from the hub, the beginning
- * characters of buffer will be appended to the end of
- * spill, thus forming a complete line.
- * If buffer does not contain a partial line, then
- * linech will simply point to the first index of 'spill'
- * (offset will be zero) after we process all of buffer's
- * lines, and we can continue normally from there.
- */
-
- while (*ch)
- {
- char tmp;
-
- tmp = *ch;
- if (IsEol(tmp))
- {
- *linech = '\0';
-
- if (nextparam)
- {
- /*
- * It is possible nextparam will not be NULL here
- * if there is a line like:
- * BadAuth id :Blah
- * where the text after the colon does not have
- * any spaces, so we reach the \n and do not
- * execute the code below which sets the next
- * index of param[] to nextparam. Do it here.
- */
- param[paramc++] = nextparam;
- }
-
- /*
- * Make sure paramc is non-zero, because if the line
- * starts with a \n, we will immediately come here,
- * without initializing param[0]
- */
- if (paramc)
- {
- /* process the line */
- ProcessIAuthData(paramc, param);
- }
-
- linech = spill;
- offset = 0;
- paramc = 0;
- nextparam = NULL;
-
- /*
- * If the line ends in \r\n, then this algorithm would
- * have only picked up the \r. We don't want an entire
- * other loop to do the \n, so advance ch here.
- */
- if (IsEol(*(ch + 1)))
- ch++;
- }
- else
- {
- /* make sure we don't overflow spill[] */
- if (linech >= (spill + (sizeof(spill) - 1)))
- {
- ch++;
- continue;
- }
-
- *linech++ = tmp;
- if (tmp == ' ')
- {
- /*
- * Only set the space character to \0 if this is
- * the very first parameter, or if nextparam is
- * not NULL. If nextparam is NULL, then we've hit
- * a parameter that starts with a colon (:), so
- * leave it as a whole parameter.
- */
- if (nextparam || (paramc == 0))
- *(linech - 1) = '\0';
-
- if (paramc == 0)
- {
- /*
- * Its the first parameter - set it to the beginning
- * of spill
- */
- param[paramc++] = spill;
- nextparam = linech;
- }
- else if (nextparam)
- {
- param[paramc++] = nextparam;
- if (*nextparam == ':')
- {
- /*
- * We've hit a colon, set nextparam to NULL,
- * so we know not to set any more spaces to \0
- */
- nextparam = NULL;
-
- /*
- * Unfortunately, the first space has already
- * been set to \0 above, so reset to to a
- * space character
- */
- *(linech - 1) = ' ';
- }
- else
- nextparam = linech;
-
- if (paramc >= MAXPARAMS)
- nextparam = NULL;
- }
- }
- ++offset;
- }
-
- /*
- * Advance ch to go to the next letter in the buffer
- */
- ++ch;
- } /* while (*ch) */
+#if 0
+ return 0; /* the connection was closed */
+#endif
+ }
+
+ /*
+ * buffer may not be big enough to read the whole last line
+ * so it may contain only part of it
+ */
+ buffer[length] = '\0';
+
+ fprintf(stderr, "%s", buffer);
+
+ /*
+ * buffer could possibly contain several lines of info,
+ * especially if this is the inital connect burst, so go
+ * through, and record each line (until we hit a \n) and
+ * process it separately
+ */
+
+ ch = buffer;
+ linech = spill + offset;
+
+ /*
+ * The following routine works something like this:
+ * buffer may contain several full lines, and then
+ * a partial line. If this is the case, loop through
+ * buffer, storing each character in 'spill' until
+ * we hit a \n or \r. When we do, process the line.
+ * When we hit the end of buffer, spill will contain
+ * the partial line that buffer had, and offset will
+ * contain the index of spill where we left off, so the
+ * next time we recv() from the hub, the beginning
+ * characters of buffer will be appended to the end of
+ * spill, thus forming a complete line.
+ * If buffer does not contain a partial line, then
+ * linech will simply point to the first index of 'spill'
+ * (offset will be zero) after we process all of buffer's
+ * lines, and we can continue normally from there.
+ */
+
+ while (*ch)
+ {
+ char tmp;
+
+ tmp = *ch;
+ if (IsEol(tmp))
+ {
+ *linech = '\0';
+
+ if (nextparam)
+ {
+ /*
+ * It is possible nextparam will not be NULL here
+ * if there is a line like:
+ * BadAuth id :Blah
+ * where the text after the colon does not have
+ * any spaces, so we reach the \n and do not
+ * execute the code below which sets the next
+ * index of param[] to nextparam. Do it here.
+ */
+ param[paramc++] = nextparam;
+ }
+
+ /*
+ * Make sure paramc is non-zero, because if the line
+ * starts with a \n, we will immediately come here,
+ * without initializing param[0]
+ */
+ if (paramc)
+ {
+ /* process the line */
+ ProcessIAuthData(paramc, param);
+ }
+
+ linech = spill;
+ offset = 0;
+ paramc = 0;
+ nextparam = NULL;
+
+ /*
+ * If the line ends in \r\n, then this algorithm would
+ * have only picked up the \r. We don't want an entire
+ * other loop to do the \n, so advance ch here.
+ */
+ if (IsEol(*(ch + 1)))
+ ch++;
+ }
+ else
+ {
+ /* make sure we don't overflow spill[] */
+ if (linech >= (spill + (sizeof(spill) - 1)))
+ {
+ ch++;
+ continue;
+ }
+
+ *linech++ = tmp;
+ if (tmp == ' ')
+ {
+ /*
+ * Only set the space character to \0 if this is
+ * the very first parameter, or if nextparam is
+ * not NULL. If nextparam is NULL, then we've hit
+ * a parameter that starts with a colon (:), so
+ * leave it as a whole parameter.
+ */
+ if (nextparam || (paramc == 0))
+ *(linech - 1) = '\0';
+
+ if (paramc == 0)
+ {
+ /*
+ * Its the first parameter - set it to the beginning
+ * of spill
+ */
+ param[paramc++] = spill;
+ nextparam = linech;
+ }
+ else if (nextparam)
+ {
+ param[paramc++] = nextparam;
+ if (*nextparam == ':')
+ {
+ /*
+ * We've hit a colon, set nextparam to NULL,
+ * so we know not to set any more spaces to \0
+ */
+ nextparam = NULL;
+
+ /*
+ * Unfortunately, the first space has already
+ * been set to \0 above, so reset to to a
+ * space character
+ */
+ *(linech - 1) = ' ';
+ }
+ else
+ nextparam = linech;
+
+ if (paramc >= MAXPARAMS)
+ nextparam = NULL;
+ }
+ }
+ ++offset;
+ }
+
+ /*
+ * Advance ch to go to the next letter in the buffer
+ */
+ ++ch;
+ } /* while (*ch) */
/*
* We need to register for another read
*/
- comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ,
- ParseIAuth, NULL, 0);
-} /* ParseIAuth() */
+ comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ, ParseIAuth, NULL, 0);
+} /* ParseIAuth() */
/*
ProcessIAuthData()
static void
ProcessIAuthData(int parc, char **parv)
-
{
- int len;
+ int len;
- len = strlen(parv[0]);
+ len = strlen(parv[0]);
- if (!strncasecmp(parv[0], "DoneAuth", len))
- GoodAuth(parc, parv);
- else if (!strncasecmp(parv[0], "BadAuth", len))
- BadAuth(parc, parv);
-} /* ProcessIAuthData() */
+ if (!strncasecmp(parv[0], "DoneAuth", len))
+ GoodAuth(parc, parv);
+ else if (!strncasecmp(parv[0], "BadAuth", len))
+ BadAuth(parc, parv);
+} /* ProcessIAuthData() */
/*
GoodAuth()
static void
GoodAuth(int parc, char **parv)
-
{
struct AuthRequest *auth;
long id;
for (aptr = auth_client_list.head; aptr; aptr = aptr->next)
{
- auth = (struct AuthRequest *) aptr->data;
+ auth = (struct AuthRequest *)aptr->data;
/*
* Remember: the client id is the memory address
* of auth->client, so if it matches id, we
* found our client.
*/
- if ((void *) auth->client == (void *) id)
+ if ((void *)auth->client == (void *)id)
{
/*
* Use IAuth's username, because it may be different
GreetUser(auth->client);
remove_auth_request(auth);
-
+
break;
}
}
-} /* GoodAuth() */
+} /* GoodAuth() */
/*
* GreetUser()
static void
GreetUser(struct Client *client)
-
{
static char ubuf[12];
dlink_node *m;
client->user->last = CurrentTime;
sendto_realops_flags(FLAGS_CCONN,
- "Client connecting: %s (%s@%s) [%s] {%s}",
- client->name,
- client->username,
- client->host,
+ "Client connecting: %s (%s@%s) [%s] {%s}",
+ client->name, client->username, client->host,
/* XXX - the IPv6 code is very broken */
#ifdef IPV6
- "",
- /*inetntoa((char *)&client->localClient->ip6),*/
+ "",
+ /*inetntoa((char *)&client->localClient->ip6), */
#else
- inetntoa((char *)&client->localClient->ip),
+ inetntoa((char *)&client->localClient->ip),
#endif
- get_client_class(client));
+ get_client_class(client));
if ((++Count.local) > Count.max_loc)
- {
- Count.max_loc = Count.local;
- if (!(Count.max_loc % 10))
- sendto_realops_flags(FLAGS_ALL, L_ALL,"New Max Local Clients: %d",
- Count.max_loc);
- }
+ {
+ Count.max_loc = Count.local;
+ if (!(Count.max_loc % 10))
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "New Max Local Clients: %d",
+ Count.max_loc);
+ }
SetClient(client);
client->servptr = find_server(client->user->server);
if (!client->servptr)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"Ghost killed: %s on invalid server %s",
- client->name,
- client->user->server);
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Ghost killed: %s on invalid server %s",
+ client->name, client->user->server);
- sendto_one(client, ":%s KILL %s: %s (Ghosted, %s doesn't exist)",
- me.name,
- client->name,
- me.name,
- client->user->server);
+ sendto_one(client, ":%s KILL %s: %s (Ghosted, %s doesn't exist)",
+ me.name, client->name, me.name, client->user->server);
- client->flags |= FLAGS_KILLED;
+ client->flags |= FLAGS_KILLED;
+
+ exit_client(NULL, client, &me, "Ghost");
+ return;
+ }
- exit_client(NULL, client, &me, "Ghost");
- return;
- }
-
add_client_to_llist(&(client->servptr->serv->users), client);
/* Increment our total user count here */
if (++Count.total > Count.max_tot)
Count.max_tot = Count.total;
-
+
sendto_one(client, form_str(RPL_WELCOME),
- me.name,
- client->name,
- client->name);
+ me.name, client->name, client->name);
- /* This is a duplicate of the NOTICE but see below...*/
+ /* This is a duplicate of the NOTICE but see below... */
sendto_one(client, form_str(RPL_YOURHOST),
- me.name,
- client->name,
- get_listener_name(client->localClient->listener), version);
-
+ me.name,
+ client->name,
+ get_listener_name(client->localClient->listener), version);
+
/*
- ** Don't mess with this one - IRCII needs it! -Avalon
- */
+ ** Don't mess with this one - IRCII needs it! -Avalon
+ */
sendto_one(client,
- "NOTICE %s :*** Your host is %s, running version %s",
- client->name,
- get_listener_name(client->localClient->listener),
- version);
+ "NOTICE %s :*** Your host is %s, running version %s",
+ client->name,
+ get_listener_name(client->localClient->listener), version);
- sendto_one(client, form_str(RPL_CREATED),
- me.name,
- client->name,
- creation);
+ sendto_one(client, form_str(RPL_CREATED), me.name, client->name, creation);
sendto_one(client, form_str(RPL_MYINFO),
- me.name,
- client->name,
- me.name,
- version);
+ me.name, client->name, me.name, version);
show_lusers(client);
- if(ConfigFileEntry.short_motd) {
- sendto_one(client,"NOTICE %s :*** Notice -- motd was last changed at %s",
- client->name,
- ConfigFileEntry.motd.lastChangedDate);
-
+ if (ConfigFileEntry.short_motd)
+ {
+ sendto_one(client, "NOTICE %s :*** Notice -- motd was last changed at %s",
+ client->name, ConfigFileEntry.motd.lastChangedDate);
+
sendto_one(client,
- "NOTICE %s :*** Notice -- Please read the motd if you haven't read it",
- client->name);
+ "NOTICE %s :*** Notice -- Please read the motd if you haven't read it",
+ client->name);
sendto_one(client, form_str(RPL_MOTDSTART),
- me.name,
- client->name,
- me.name);
+ me.name, client->name, me.name);
sendto_one(client,
- form_str(RPL_MOTD),
- me.name,
- client->name,
- "*** This is the short motd ***");
-
- sendto_one(client, form_str(RPL_ENDOFMOTD),
- me.name,
- client->name);
+ form_str(RPL_MOTD),
+ me.name, client->name, "*** This is the short motd ***");
+
+ sendto_one(client, form_str(RPL_ENDOFMOTD), me.name, client->name);
}
else
send_umode(NULL, client, 0, SEND_UMODES, ubuf);
if (!*ubuf)
- {
- ubuf[0] = '+';
- ubuf[1] = '\0';
- }
-
+ {
+ ubuf[0] = '+';
+ ubuf[1] = '\0';
+ }
+
#if 0
m = make_dlink_node();
dlinkAdd(client, m, &lclient_list);
#if 0
sendto_serv_butone(client,
- "NICK %s %d %lu %s %s %s %s :%s",
- client->name,
- client->hopcount + 1,
- client->tsinfo,
- ubuf,
- client->username,
- client->host,
- client->user->server,
- client->info);
+ "NICK %s %d %lu %s %s %s %s :%s",
+ client->name,
+ client->hopcount + 1,
+ client->tsinfo,
+ ubuf,
+ client->username,
+ client->host, client->user->server, client->info);
#endif
- if (!ServerInfo.hub && uplink && IsCapable(uplink,CAP_LL))
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
{
sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
- client->name,
- client->hopcount+1,
- (unsigned long) client->tsinfo,
- ubuf,
- client->username, client->host,
- client->user->server, client->info);
+ client->name,
+ client->hopcount + 1,
+ (unsigned long)client->tsinfo,
+ ubuf,
+ client->username, client->host,
+ client->user->server, client->info);
}
else
{
sendto_server(NULL, NULL, NULL, NOCAPS, CAP_LL,
NOFLAGS, "NICK %s %d %lu %s %s %s %s :%s",
client->name,
- client->hopcount+1,
- (unsigned long) client->tsinfo,
+ client->hopcount + 1,
+ (unsigned long)client->tsinfo,
ubuf,
client->username, client->host,
client->user->server, client->info);
{
send_umode_out(client, client, 0);
}
-} /* GreetUser() */
+} /* GreetUser() */
/*
BadAuth()
static void
BadAuth(int parc, char **parv)
-
{
struct AuthRequest *auth;
long id;
id = strtol(parv[1], 0, 0);
if ((auth = FindAuthClient(id)))
- {
- exit_client(auth->client, auth->client, &me, parv[2] + 1);
- }
-} /* BadAuth() */
+ {
+ exit_client(auth->client, auth->client, &me, parv[2] + 1);
+ }
+} /* BadAuth() */
*
* (C) 1988 University of Oulu,Computing Center and Jarkko Oikarinen"
*
- * $Id: kdparse.c,v 1.1 2002/01/04 09:14:10 a1kmm Exp $
+ * $Id: kdparse.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include <sys/types.h>
* Side Effects - Parse one new style K line
*/
-void parse_k_file(FBFILE *file)
+void
+parse_k_file(FBFILE * file)
{
struct ConfItem *aconf;
- char* user_field=(char *)NULL;
- char* reason_field=(char *)NULL;
- char* host_field=(char *)NULL;
- char line[BUFSIZE];
- char* p;
+ char *user_field = (char *)NULL;
+ char *reason_field = (char *)NULL;
+ char *host_field = (char *)NULL;
+ char line[BUFSIZE];
+ char *p;
while (fbgets(line, sizeof(line), file))
- {
- if ((p = strchr(line, '\n')))
- *p = '\0';
+ {
+ if ((p = strchr(line, '\n')))
+ *p = '\0';
- if ((*line == '\0') || (*line == '#'))
- continue;
+ if ((*line == '\0') || (*line == '#'))
+ continue;
- if ((user_field = getfield(line)) == NULL)
- continue;
+ if ((user_field = getfield(line)) == NULL)
+ continue;
- if ((host_field = getfield(NULL)) == NULL)
- continue;
+ if ((host_field = getfield(NULL)) == NULL)
+ continue;
- if ((reason_field = getfield(NULL)) == NULL)
- continue;
-
- aconf = make_conf();
- aconf->status = CONF_KILL;
- conf_add_fields(aconf,host_field,reason_field,user_field,0,NULL);
+ if ((reason_field = getfield(NULL)) == NULL)
+ continue;
- if (aconf->host != NULL)
- add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
- }
+ aconf = make_conf();
+ aconf->status = CONF_KILL;
+ conf_add_fields(aconf, host_field, reason_field, user_field, 0, NULL);
+
+ if (aconf->host != NULL)
+ add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
+ }
}
/*
* Side Effects - Parse one new style D line
*/
-void parse_d_file(FBFILE *file)
+void
+parse_d_file(FBFILE * file)
{
struct ConfItem *aconf;
- char* reason_field=(char *)NULL;
- char* host_field=(char *)NULL;
- char line[BUFSIZE];
- char* p;
+ char *reason_field = (char *)NULL;
+ char *host_field = (char *)NULL;
+ char line[BUFSIZE];
+ char *p;
while (fbgets(line, sizeof(line), file))
- {
- if ((p = strchr(line, '\n')))
- *p = '\0';
-
- if ((*line == '\0') || (line[0] == '#'))
- continue;
-
- if ((host_field = getfield(line)) == NULL)
- continue;
-
- if ((reason_field = getfield(NULL)) == NULL)
- continue;
-
- aconf = make_conf();
- aconf->status = CONF_DLINE;
- conf_add_fields(aconf,host_field,reason_field,"",0,NULL);
- conf_add_d_conf(aconf);
- }
+ {
+ if ((p = strchr(line, '\n')))
+ *p = '\0';
+
+ if ((*line == '\0') || (line[0] == '#'))
+ continue;
+
+ if ((host_field = getfield(line)) == NULL)
+ continue;
+
+ if ((reason_field = getfield(NULL)) == NULL)
+ continue;
+
+ aconf = make_conf();
+ aconf->status = CONF_DLINE;
+ conf_add_fields(aconf, host_field, reason_field, "", 0, NULL);
+ conf_add_d_conf(aconf);
+ }
}
/*
* output - next field
* side effects - field breakup for ircd.conf file.
*/
-char *getfield(char *newline)
+char *
+getfield(char *newline)
{
static char *line = (char *)NULL;
- char *end, *field;
-
+ char *end, *field;
+
if (newline)
line = newline;
if (line == (char *)NULL)
- return((char *)NULL);
+ return ((char *)NULL);
field = line;
/* XXX make this skip to first " if present */
- if(*field == '"')
+ if (*field == '"')
field++;
else
- return((char *)NULL); /* mal-formed field */
-
- if ((end = strchr(line,',')) == NULL)
- {
- end = line + strlen(line);
- line = (char *)NULL;
- /* XXX verify properly terminating " */
- if(*end == '"')
- *end = '\0';
- else
- return((char *)NULL);
- }
+ return ((char *)NULL); /* mal-formed field */
+
+ if ((end = strchr(line, ',')) == NULL)
+ {
+ end = line + strlen(line);
+ line = (char *)NULL;
+ /* XXX verify properly terminating " */
+ if (*end == '"')
+ *end = '\0';
+ else
+ return ((char *)NULL);
+ }
else
- {
- line = end + 1;
- --end;
- if(*end == '"')
- *end = '\0';
- else
- return((char *)NULL);
- }
- return(field);
+ {
+ line = end + 1;
+ --end;
+ if (*end == '"')
+ *end = '\0';
+ else
+ return ((char *)NULL);
+ }
+ return (field);
}
-
* The idea here is that we should really be maintaining pre-munged
* buffer "lines" which we can later refcount to save needless copies.
*
- * $Id: linebuf.c,v 1.1 2002/01/04 09:14:12 a1kmm Exp $
+ * $Id: linebuf.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include <errno.h>
* Initialise the linebuf mechanism
*/
-static void linebuf_garbage_collect(void *unused)
+static void
+linebuf_garbage_collect(void *unused)
{
BlockHeapGarbageCollect(linebuf_heap);
}
-
+
void
linebuf_init(void)
{
- linebuf_heap = BlockHeapCreate(sizeof(buf_line_t), 2048);
+ linebuf_heap = BlockHeapCreate(sizeof(buf_line_t), 2048);
eventAddIsh("linebuf_garbage_collect", linebuf_garbage_collect, NULL, 30);
}
t = BlockHeapAlloc(linebuf_heap);
assert(t != NULL);
t->refcount = 0;
- return(t);
+ return (t);
}
void
-linebuf_free(buf_line_t *p)
+linebuf_free(buf_line_t * p)
{
- BlockHeapFree(linebuf_heap, p);
+ BlockHeapFree(linebuf_heap, p);
}
/*
* It will be initially empty.
*/
static buf_line_t *
-linebuf_new_line(buf_head_t *bufhead)
+linebuf_new_line(buf_head_t * bufhead)
{
buf_line_t *bufline;
dlink_node *node;
++bufline_count;
node = make_dlink_node();
-
+
bufline->len = 0;
bufline->terminated = 0;
bufline->flushing = 0;
* We've finished with the given line, so deallocate it
*/
static void
-linebuf_done_line(buf_head_t *bufhead, buf_line_t *bufline,
- dlink_node *node)
+linebuf_done_line(buf_head_t * bufhead, buf_line_t * bufline,
+ dlink_node * node)
{
/* Remove it from the linked list */
dlinkDelete(node, &bufhead->list);
linebuf_skip_crlf(char *ch, int len)
{
int orig_len = len;
-
+
/* First, skip until the first non-CRLF */
- for(; len; len--, ch++)
- {
- if (*ch == '\r')
- break;
- else if(*ch == '\n')
- break;
- }
+ for (; len; len--, ch++)
+ {
+ if (*ch == '\r')
+ break;
+ else if (*ch == '\n')
+ break;
+ }
/* Then, skip until the last CRLF */
- for(; len; len--, ch++)
- {
- if ((*ch != '\r') && (*ch != '\n'))
- break;
- }
+ for (; len; len--, ch++)
+ {
+ if ((*ch != '\r') && (*ch != '\n'))
+ break;
+ }
assert(orig_len > len);
- return(orig_len - len);
+ return (orig_len - len);
}
* attach a CR/LF/NUL to the end of the line, and update the length.
*/
static void
-linebuf_terminate_crlf(buf_head_t *bufhead, buf_line_t *bufline)
+linebuf_terminate_crlf(buf_head_t * bufhead, buf_line_t * bufline)
{
bufline->buf[bufline->len++] = '\r';
bufline->buf[bufline->len++] = '\n';
* Initialise the new buffer
*/
void
-linebuf_newbuf(buf_head_t *bufhead)
+linebuf_newbuf(buf_head_t * bufhead)
{
/* not much to do right now :) */
memset(bufhead, 0, sizeof(buf_head_t));
{
/* This way, it can be called for remote client as well */
- if(client_p->localClient == NULL)
+ if (client_p->localClient == NULL)
return;
linebuf_donebuf(&client_p->localClient->buf_recvq);
* Flush all the lines associated with this buffer
*/
void
-linebuf_donebuf(buf_head_t *bufhead)
+linebuf_donebuf(buf_head_t * bufhead)
{
- while (bufhead->list.head != NULL)
- {
- linebuf_done_line(bufhead, (buf_line_t *)bufhead->list.head->data,
- bufhead->list.head);
- }
+ while (bufhead->list.head != NULL)
+ {
+ linebuf_done_line(bufhead, (buf_line_t *) bufhead->list.head->data,
+ bufhead->list.head);
+ }
}
/*
* -Aaron
*/
static int
-linebuf_copy_line(buf_head_t *bufhead, buf_line_t *bufline,
+linebuf_copy_line(buf_head_t * bufhead, buf_line_t * bufline,
char *data, int len)
{
- int cpylen = 0; /* how many bytes we've copied */
- char *ch = data; /* Pointer to where we are in the read data */
+ int cpylen = 0; /* how many bytes we've copied */
+ char *ch = data; /* Pointer to where we are in the read data */
char *bufch = bufline->buf + bufline->len;
int clen = 0; /* how many bytes we've processed,
and don't ever want to see again.. */
clen = cpylen = linebuf_skip_crlf(ch, len);
/* This is the ~overflow case..This doesn't happen often.. */
- if(cpylen > (BUF_DATA_SIZE - bufline->len - 1))
+ if (cpylen > (BUF_DATA_SIZE - bufline->len - 1))
+ {
+ memcpy(bufch, ch, (BUF_DATA_SIZE - bufline->len - 1));
+ bufline->buf[BUF_DATA_SIZE - 1] = '\0';
+ bufch = bufline->buf + BUF_DATA_SIZE - 2;
+ while (cpylen && (*bufch == '\r' || *bufch == '\n'))
{
- memcpy(bufch, ch, (BUF_DATA_SIZE - bufline->len - 1));
- bufline->buf[BUF_DATA_SIZE-1] = '\0';
- bufch = bufline->buf + BUF_DATA_SIZE - 2;
- while(cpylen && (*bufch == '\r' || *bufch == '\n'))
- {
- *bufch = '\0';
- cpylen--;
- bufch--;
- }
- bufline->terminated = 1;
- bufline->len = BUF_DATA_SIZE - 1;
- bufhead->len += BUF_DATA_SIZE - 1;
- return clen;
+ *bufch = '\0';
+ cpylen--;
+ bufch--;
}
+ bufline->terminated = 1;
+ bufline->len = BUF_DATA_SIZE - 1;
+ bufhead->len += BUF_DATA_SIZE - 1;
+ return clen;
+ }
memcpy(bufch, ch, cpylen);
bufch += cpylen;
*bufch = '\0';
bufch--;
- if(*bufch != '\r' && *bufch != '\n')
- {
- /* No linefeed, bail for the next time */
- bufhead->len += cpylen;
- bufline->len += cpylen;
- bufline->terminated = 0;
- return clen;
- }
+ if (*bufch != '\r' && *bufch != '\n')
+ {
+ /* No linefeed, bail for the next time */
+ bufhead->len += cpylen;
+ bufline->len += cpylen;
+ bufline->terminated = 0;
+ return clen;
+ }
/* Yank the CRLF off this, replace with a \0 */
- while(cpylen && (*bufch == '\r' || *bufch == '\n'))
- {
- *bufch = '\0';
- cpylen--;
- bufch--;
- }
-
+ while (cpylen && (*bufch == '\r' || *bufch == '\n'))
+ {
+ *bufch = '\0';
+ cpylen--;
+ bufch--;
+ }
+
bufline->terminated = 1;
bufhead->len += cpylen;
bufline->len += cpylen;
* -David-T
*/
static int
-linebuf_copy_raw(buf_head_t *bufhead, buf_line_t *bufline,
+linebuf_copy_raw(buf_head_t * bufhead, buf_line_t * bufline,
char *data, int len)
{
- char *ch = data; /* Pointer to where we are in the read data */
+ char *ch = data; /* Pointer to where we are in the read data */
char *bufch = bufline->buf + bufline->len;
int clen = 0; /* how many bytes we've processed,
and don't ever want to see again.. */
int remaining;
-
+
/* If its full or terminated, ignore it */
if ((bufline->len == BUF_DATA_SIZE) || (bufline->terminated == 1))
return 0;
* to dodge copious copies.
*/
int
-linebuf_parse(buf_head_t *bufhead, char *data, int len, int raw)
+linebuf_parse(buf_head_t * bufhead, char *data, int len, int raw)
{
buf_line_t *bufline;
int cpylen;
/* First, if we have a partial buffer, try to squeze data into it */
if (bufhead->list.tail != NULL)
- {
- /* Check we're doing the partial buffer thing */
- bufline = bufhead->list.tail->data;
- assert(!bufline->flushing);
- /* just try, the worst it could do is *reject* us .. */
- if (raw) /* if we could be dealing with 8-bit data */
- cpylen = linebuf_copy_raw(bufhead, bufline, data, len);
- else
- cpylen = linebuf_copy_line(bufhead, bufline, data, len);
- linecnt++;
- /* If we've copied the same as what we've got, quit now */
- if (cpylen == len)
- return linecnt; /* all the data done so soon? */
-
- /* Skip the data and update len .. */
- len -= cpylen;
- assert(len >= 0);
- data += cpylen;
- }
+ {
+ /* Check we're doing the partial buffer thing */
+ bufline = bufhead->list.tail->data;
+ assert(!bufline->flushing);
+ /* just try, the worst it could do is *reject* us .. */
+ if (raw) /* if we could be dealing with 8-bit data */
+ cpylen = linebuf_copy_raw(bufhead, bufline, data, len);
+ else
+ cpylen = linebuf_copy_line(bufhead, bufline, data, len);
+ linecnt++;
+ /* If we've copied the same as what we've got, quit now */
+ if (cpylen == len)
+ return linecnt; /* all the data done so soon? */
+
+ /* Skip the data and update len .. */
+ len -= cpylen;
+ assert(len >= 0);
+ data += cpylen;
+ }
- /* Next, the loop */
- while (len > 0)
- {
- /* We obviously need a new buffer, so .. */
- bufline = linebuf_new_line(bufhead);
-
- /* And parse */
- if (raw) /* if we could be dealing with 8-bit data */
- cpylen = linebuf_copy_raw(bufhead, bufline, data, len);
- else
- cpylen = linebuf_copy_line(bufhead, bufline, data, len);
- len -= cpylen;
- assert(len >= 0);
- data += cpylen;
- linecnt++;
- }
- return linecnt;
+ /* Next, the loop */
+ while (len > 0)
+ {
+ /* We obviously need a new buffer, so .. */
+ bufline = linebuf_new_line(bufhead);
+
+ /* And parse */
+ if (raw) /* if we could be dealing with 8-bit data */
+ cpylen = linebuf_copy_raw(bufhead, bufline, data, len);
+ else
+ cpylen = linebuf_copy_line(bufhead, bufline, data, len);
+ len -= cpylen;
+ assert(len >= 0);
+ data += cpylen;
+ linecnt++;
+ }
+ return linecnt;
}
* data into the given buffer and free the underlying linebuf.
*/
int
-linebuf_get(buf_head_t *bufhead, char *buf, int buflen, int partial,
- int raw)
+linebuf_get(buf_head_t * bufhead, char *buf, int buflen, int partial, int raw)
{
buf_line_t *bufline;
int cpylen;
/* make sure we have a line */
if (bufhead->list.head == NULL)
- return 0; /* Obviously not.. hrm. */
+ return 0; /* Obviously not.. hrm. */
- bufline = bufhead->list.head->data;
+ bufline = bufhead->list.head->data;
/* make sure that the buffer was actually *terminated */
if (!(partial || bufline->terminated))
- return 0; /* Wait for more data! */
+ return 0; /* Wait for more data! */
/* make sure we've got the space, including the NULL */
cpylen = bufline->len;
if (bufline->raw && !raw)
{
/* skip leading EOL characters */
- while(cpylen && (*start == '\r' || *start == '\n'))
+ while (cpylen && (*start == '\r' || *start == '\n'))
{
start++;
cpylen--;
}
/* skip trailing EOL characters */
- ch = &start[cpylen-1];
- while(cpylen && (*ch == '\r' || *ch == '\n'))
+ ch = &start[cpylen - 1];
+ while (cpylen && (*ch == '\r' || *ch == '\n'))
{
ch--;
cpylen--;
}
}
- memcpy(buf, start, cpylen+1);
+ memcpy(buf, start, cpylen + 1);
/* convert CR/LF to NUL */
buf[cpylen] = '\0';
* without copying the data (using refcounts).
*/
void
-linebuf_attach(buf_head_t *bufhead, buf_head_t *new)
+linebuf_attach(buf_head_t * bufhead, buf_head_t * new)
{
dlink_node *new_node;
dlink_node *node;
buf_line_t *line;
-
+
for (node = new->list.head; node; node = node->next)
{
- line = (buf_line_t *)node->data;
+ line = (buf_line_t *) node->data;
new_node = make_dlink_node();
dlinkAddTail(line, new_node, &bufhead->list);
* Then format/va_args is appended to the buffer.
*/
void
-linebuf_putmsg(buf_head_t *bufhead, const char *format, va_list va_args,
+linebuf_putmsg(buf_head_t * bufhead, const char *format, va_list va_args,
const char *prefixfmt, ...)
{
buf_line_t *bufline;
int len = 0;
va_list prefix_args;
-
+
/* make sure the previous line is terminated */
if (bufhead->list.tail)
- {
- bufline = bufhead->list.tail->data;
- assert(bufline->terminated);
- }
+ {
+ bufline = bufhead->list.tail->data;
+ assert(bufline->terminated);
+ }
/* Create a new line */
bufline = linebuf_new_line(bufhead);
if (va_args)
{
len += vsnprintf((bufline->buf + len), (BUF_DATA_SIZE - len), format,
- va_args);
+ va_args);
}
-
+
/* Truncate the data if required */
if (len > 510)
len = 510;
/* Chop trailing CRLF's .. */
- len--; /* change len to index of last char */
+ len--; /* change len to index of last char */
while ((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n') ||
(bufline->buf[len] == '\0'))
len--;
bufline->buf[++len] = '\r';
bufline->buf[++len] = '\n';
- bufline->buf[++len] = '\0'; /* this restores len to correct length */
+ bufline->buf[++len] = '\0'; /* this restores len to correct length */
- bufline->len = len;
+ bufline->len = len;
bufhead->len += len;
bufline->terminated = 1;
* DO know you are getting a single line.
*/
void
-linebuf_put(buf_head_t *bufhead, char *buf, int buflen)
+linebuf_put(buf_head_t * bufhead, char *buf, int buflen)
{
buf_line_t *bufline;
/* make sure the previous line is terminated */
if (bufhead->list.tail)
- {
- bufline = bufhead->list.tail->data;
- assert(bufline->terminated);
- }
+ {
+ bufline = bufhead->list.tail->data;
+ assert(bufline->terminated);
+ }
/* Create a new line */
bufline = linebuf_new_line(bufhead);
* we have a CRLF.
*/
int
-linebuf_flush(int fd, buf_head_t *bufhead)
+linebuf_flush(int fd, buf_head_t * bufhead)
{
buf_line_t *bufline;
int retval;
-
+
/* Check we actually have a first buffer */
if (bufhead->list.head == NULL)
- {
- /* nope, so we return none .. */
- errno = EWOULDBLOCK;
- return -1;
- }
+ {
+ /* nope, so we return none .. */
+ errno = EWOULDBLOCK;
+ return -1;
+ }
bufline = bufhead->list.head->data;
/* And that its actually full .. */
if (!bufline->terminated)
- {
- errno = EWOULDBLOCK;
- return -1;
- }
-
+ {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+
/* Check we're flushing the first buffer */
if (!bufline->flushing)
- {
- bufline->flushing = 1;
- bufhead->writeofs = 0;
- }
+ {
+ bufline->flushing = 1;
+ bufhead->writeofs = 0;
+ }
/* Now, try writing data */
retval = write(fd, bufline->buf + bufhead->writeofs, bufline->len
- - bufhead->writeofs);
-
+ - bufhead->writeofs);
+
/* Deal with return code */
if (retval < 0)
return retval;
/* if we've written everything *and* the CRLF, deallocate and update
bufhead */
if (bufhead->writeofs == bufline->len)
- {
- bufhead->writeofs = 0;
- assert(bufhead->len >=0);
- linebuf_done_line(bufhead, bufline, bufhead->list.head);
- }
+ {
+ bufhead->writeofs = 0;
+ assert(bufhead->len >= 0);
+ linebuf_done_line(bufhead, bufline, bufhead->list.head);
+ }
/* Return line length */
return retval;
* count linebufs for s_debug
*/
-void count_linebuf_memory(int *count, u_long *linebuf_memory_used)
+void
+count_linebuf_memory(int *count, u_long * linebuf_memory_used)
{
*count = bufline_count;
*linebuf_memory_used = bufline_count * sizeof(buf_line_t);
*
* (C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen
*
- * $Id: list.c,v 1.1 2002/01/04 09:14:12 a1kmm Exp $
+ * $Id: list.c,v 1.2 2002/01/04 11:06:40 a1kmm Exp $
*/
#include "tools.h"
#include "channel.h"
#include <stdlib.h>
/* XXX assummed 32 bit ints */
-int links_count=0;
-int user_count=0;
+int links_count = 0;
+int user_count = 0;
/*
* initUser
*
*/
static BlockHeap *user_heap;
-void initUser(void)
+void
+initUser(void)
{
user_heap = BlockHeapCreate(sizeof(struct User), 1024);
- if(!user_heap)
- outofmemory();
+ if (!user_heap)
+ outofmemory();
}
+
/*
* make_user
*
* side effects - add's an User information block to a client
* if it was not previously allocated.
*/
-struct User* make_user(struct Client *client_p)
+struct User *
+make_user(struct Client *client_p)
{
- struct User *user;
+ struct User *user;
user = client_p->user;
if (!user)
- {
- user = (struct User *)BlockHeapAlloc(user_heap);
+ {
+ user = (struct User *)BlockHeapAlloc(user_heap);
- ++user_count;
+ ++user_count;
- memset(user, 0, sizeof(*user));
- user->refcnt = 1;
- client_p->user = user;
- }
+ memset(user, 0, sizeof(*user));
+ user->refcnt = 1;
+ client_p->user = user;
+ }
return user;
}
* side effects - add's an Server information block to a client
* if it was not previously allocated.
*/
-struct Server *make_server(struct Client *client_p)
+struct Server *
+make_server(struct Client *client_p)
{
- struct Server* serv = client_p->serv;
+ struct Server *serv = client_p->serv;
if (!serv)
- {
- serv = (struct Server *)MyMalloc(sizeof(struct Server));
- memset(serv, 0, sizeof(*serv));
+ {
+ serv = (struct Server *)MyMalloc(sizeof(struct Server));
+ memset(serv, 0, sizeof(*serv));
- /* The commented out lines here are
- * for documentation purposes only
- * as they are zeroed by MyMalloc above
- */
+ /* The commented out lines here are
+ * for documentation purposes only
+ * as they are zeroed by MyMalloc above
+ */
#if 0
- serv->user = NULL;
- serv->users = NULL;
- serv->servers = NULL;
- *serv->by = '\0';
- serv->up = (char *)NULL;
+ serv->user = NULL;
+ serv->users = NULL;
+ serv->servers = NULL;
+ *serv->by = '\0';
+ serv->up = (char *)NULL;
#endif
- client_p->serv = serv;
- }
+ client_p->serv = serv;
+ }
return client_p->serv;
}
* side effects - Decrease user reference count by one and release block,
* if count reaches 0
*/
-void _free_user(struct User* user, struct Client* client_p)
+void
+_free_user(struct User *user, struct Client *client_p)
{
if (--user->refcnt <= 0)
+ {
+ if (user->away)
+ MyFree((char *)user->away);
+ /*
+ * sanity check
+ */
+ if (user->joined || user->refcnt < 0 ||
+ user->invited.head || user->channel.head)
{
- if (user->away)
- MyFree((char *)user->away);
- /*
- * sanity check
- */
- if (user->joined || user->refcnt < 0 ||
- user->invited.head || user->channel.head)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "* %#lx user (%s!%s@%s) %#lx %#lx %#lx %d %d *",
- (unsigned long)client_p, client_p ? client_p->name : "<noname>",
- client_p->username, client_p->host, (unsigned long)user,
- (unsigned long)user->invited.head,
- (unsigned long)user->channel.head, user->joined,
- user->refcnt);
- assert(!user->joined);
- assert(!user->refcnt);
- assert(!user->invited.head);
- assert(!user->channel.head);
- }
-
- BlockHeapFree(user_heap, user);
- --user_count;
- assert(user_count >= 0);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "* %#lx user (%s!%s@%s) %#lx %#lx %#lx %d %d *",
+ (unsigned long)client_p,
+ client_p ? client_p->name : "<noname>",
+ client_p->username, client_p->host,
+ (unsigned long)user,
+ (unsigned long)user->invited.head,
+ (unsigned long)user->channel.head, user->joined,
+ user->refcnt);
+ assert(!user->joined);
+ assert(!user->refcnt);
+ assert(!user->invited.head);
+ assert(!user->channel.head);
}
+
+ BlockHeapFree(user_heap, user);
+ --user_count;
+ assert(user_count >= 0);
+ }
}
*
*/
static BlockHeap *dnode_heap;
-void init_dlink_nodes(void)
+void
+init_dlink_nodes(void)
{
dnode_heap = BlockHeapCreate(sizeof(dlink_node), 1024);
- if(dnode_heap == NULL)
- outofmemory();
+ if (dnode_heap == NULL)
+ outofmemory();
}
-
+
/*
* make_dlink_node
*
* side effects - NONE
*/
#ifndef MEMDEBUG
-dlink_node*
+dlink_node *
_make_dlink_node(void)
{
dlink_node *lp;
- lp = (dlink_node *)BlockHeapAlloc(dnode_heap);;
+ lp = (dlink_node *) BlockHeapAlloc(dnode_heap);;
++links_count;
lp->next = NULL;
return lp;
}
#else
-dlink_node*
+dlink_node *
_make_dlink_node(const char *file, int line)
{
- char nambuf[50];
- dlink_node *lp;
- #define DLINK_DBG_PREFIX "DLINK:"
- strcpy(nambuf, DLINK_DBG_PREFIX);
- strncpy_irc(nambuf+sizeof(DLINK_DBG_PREFIX)-1, file,
- sizeof(nambuf)-sizeof(DLINK_DBG_PREFIX));
+ char nambuf[50];
+ dlink_node *lp;
+#define DLINK_DBG_PREFIX "DLINK:"
+ strcpy(nambuf, DLINK_DBG_PREFIX);
+ strncpy_irc(nambuf + sizeof(DLINK_DBG_PREFIX) - 1, file,
+ sizeof(nambuf) - sizeof(DLINK_DBG_PREFIX));
#ifdef NOBALLOC
- lp = _MyMalloc(sizeof(*lp), nambuf, line);
+ lp = _MyMalloc(sizeof(*lp), nambuf, line);
#else
- lp = memlog(_BlockHeapAlloc(dnode_heap), sizeof(*lp), nambuf, line);
+ lp = memlog(_BlockHeapAlloc(dnode_heap), sizeof(*lp), nambuf, line);
#endif
- lp->next = NULL;
- lp->prev = NULL;
- ++links_count;
- return lp;
+ lp->next = NULL;
+ lp->prev = NULL;
+ ++links_count;
+ return lp;
}
#endif
* output - NONE
* side effects - free given dlink_node
*/
-void _free_dlink_node(dlink_node *ptr)
+void
+_free_dlink_node(dlink_node * ptr)
{
#ifdef NOBALLOC
MyFree(ptr);
* output - NONE
* side effects - NONE
*/
-void count_user_memory(int *count,int *user_memory_used)
+void
+count_user_memory(int *count, int *user_memory_used)
{
*count = user_count;
*user_memory_used = user_count * sizeof(struct User);
* output - NONE
* side effects - NONE
*/
-void count_links_memory(int *count,int *links_memory_used)
+void
+count_links_memory(int *count, int *links_memory_used)
{
*count = links_count;
*links_memory_used = links_count * sizeof(dlink_node);
}
-
-
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: listener.c,v 1.1 2002/01/04 09:14:18 a1kmm Exp $
+ * $Id: listener.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include "config.h"
#include "listener.h"
static PF accept_connection;
-static struct Listener* ListenerPollList = NULL;
+static struct Listener *ListenerPollList = NULL;
-struct Listener* make_listener(int port, struct irc_inaddr *addr)
+struct Listener *
+make_listener(int port, struct irc_inaddr *addr)
{
- struct Listener* listener =
- (struct Listener*) MyMalloc(sizeof(struct Listener));
+ struct Listener *listener =
+ (struct Listener *)MyMalloc(sizeof(struct Listener));
memset(listener, 0, sizeof(*listener));
assert(0 != listener);
- listener->name = me.name;
- listener->fd = -1;
- copy_s_addr(IN_ADDR(listener->addr),PIN_ADDR(addr));
+ listener->name = me.name;
+ listener->fd = -1;
+ copy_s_addr(IN_ADDR(listener->addr), PIN_ADDR(addr));
- listener->port = port;
+ listener->port = port;
listener->next = NULL;
return listener;
}
-void free_listener(struct Listener* listener)
+void
+free_listener(struct Listener *listener)
{
assert(0 != listener);
/*
*/
if (listener == ListenerPollList)
ListenerPollList = listener->next;
- else {
- struct Listener* prev = ListenerPollList;
- for ( ; prev; prev = prev->next) {
- if (listener == prev->next) {
+ else
+ {
+ struct Listener *prev = ListenerPollList;
+ for (; prev; prev = prev->next)
+ {
+ if (listener == prev->next)
+ {
prev->next = listener->next;
break;
}
MyFree(listener);
}
-#define PORTNAMELEN 6 /* ":31337" */
+#define PORTNAMELEN 6 /* ":31337" */
/*
* get_listener_name - return displayable listener name and port
* returns "host.foo.org:6667" for a given listener
*/
-const char* get_listener_name(const struct Listener* listener)
+const char *
+get_listener_name(const struct Listener *listener)
{
static char buf[HOSTLEN + HOSTLEN + PORTNAMELEN + 4];
assert(0 != listener);
- ircsprintf(buf, "%s[%s/%u]",
- me.name, listener->name, listener->port);
+ ircsprintf(buf, "%s[%s/%u]", me.name, listener->name, listener->port);
return buf;
}
* output - none
* side effects - show ports
*/
-void show_ports(struct Client* source_p)
+void
+show_ports(struct Client *source_p)
{
- struct Listener* listener = 0;
+ struct Listener *listener = 0;
for (listener = ListenerPollList; listener; listener = listener->next)
- {
- sendto_one(source_p, form_str(RPL_STATSPLINE),
- me.name,
- source_p->name,
- 'P',
- listener->port,
- IsOperAdmin(source_p) ? listener->name : me.name,
- listener->ref_count,
- (listener->active)?"active":"disabled");
- }
+ {
+ sendto_one(source_p, form_str(RPL_STATSPLINE),
+ me.name,
+ source_p->name,
+ 'P',
+ listener->port,
+ IsOperAdmin(source_p) ? listener->name : me.name,
+ listener->ref_count,
+ (listener->active) ? "active" : "disabled");
+ }
}
/*
#define HYBRID_SOMAXCONN SOMAXCONN
#endif
-static int inetport(struct Listener* listener)
+static int
+inetport(struct Listener *listener)
{
struct irc_sockaddr lsin;
- int fd;
- int opt = 1;
+ int fd;
+ int opt = 1;
/*
* At first, open a new socket
fd = comm_open(DEF_FAM, SOCK_STREAM, 0, "Listener socket");
#ifdef IPV6
- if (!IN6_ARE_ADDR_EQUAL((struct in6_addr *)&listener->addr, &in6addr_any)) {
+ if (!IN6_ARE_ADDR_EQUAL((struct in6_addr *)&listener->addr, &in6addr_any))
+ {
#else
- if (INADDR_ANY != listener->addr.sins.sin.s_addr) {
+ if (INADDR_ANY != listener->addr.sins.sin.s_addr)
+ {
#endif
inetntop(DEF_FAM, &IN_ADDR(listener->addr), listener->vhost, HOSTLEN);
listener->name = listener->vhost;
}
- if (-1 == fd) {
+ if (-1 == fd)
+ {
report_error(L_ALL, "opening listener socket %s:%s",
get_listener_name(listener), errno);
return 0;
}
- else if ((HARD_FDLIMIT - 10) < fd) {
+ else if ((HARD_FDLIMIT - 10) < fd)
+ {
report_error(L_ALL, "no more connections left for listener %s:%s",
get_listener_name(listener), errno);
fd_close(fd);
* XXX - we don't want to do all this crap for a listener
* set_sock_opts(listener);
*/
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*) &opt, sizeof(opt))) {
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)))
+ {
report_error(L_ALL, "setting SO_REUSEADDR for listener %s:%s",
get_listener_name(listener), errno);
fd_close(fd);
S_PORT(lsin) = htons(listener->port);
- if (bind(fd, (struct sockaddr*) &SOCKADDR(lsin),
- sizeof(struct irc_sockaddr)))
+ if (bind(fd, (struct sockaddr *)&SOCKADDR(lsin),
+ sizeof(struct irc_sockaddr)))
{
report_error(L_ALL, "binding listener socket %s:%s",
get_listener_name(listener), errno);
return 0;
}
- if (listen(fd, HYBRID_SOMAXCONN)) {
+ if (listen(fd, HYBRID_SOMAXCONN))
+ {
report_error(L_ALL, "listen failed for %s:%s",
get_listener_name(listener), errno);
fd_close(fd);
comm_setselect(fd, FDLIST_SERVICE, COMM_SELECT_READ, accept_connection,
- listener, 0);
+ listener, 0);
return 1;
}
-static struct Listener* find_listener(int port, struct irc_inaddr *addr)
+static struct Listener *
+find_listener(int port, struct irc_inaddr *addr)
{
- struct Listener* listener = NULL;
- struct Listener* last_closed = NULL;
+ struct Listener *listener = NULL;
+ struct Listener *last_closed = NULL;
for (listener = ListenerPollList; listener; listener = listener->next)
{
- if ( (port == listener->port) &&
- (!memcmp(&PIN_ADDR(addr),
- &IN_ADDR(listener->addr),
- sizeof(struct irc_inaddr))))
+ if ((port == listener->port) &&
+ (!memcmp(&PIN_ADDR(addr),
+ &IN_ADDR(listener->addr), sizeof(struct irc_inaddr))))
{
/* Try to return an open listener, otherwise reuse a closed one */
if (listener->fd == -1)
* vhost_ip - if non-null must contain a valid IP address string in
* the format "255.255.255.255"
*/
-void add_listener(int port, const char* vhost_ip)
+void
+add_listener(int port, const char *vhost_ip)
{
- struct Listener* listener;
- struct irc_inaddr vaddr;
+ struct Listener *listener;
+ struct irc_inaddr vaddr;
/*
* if no port in conf line, don't bother
#else
copy_s_addr(IN_ADDR(vaddr), INADDR_ANY);
#endif
- if (vhost_ip) {
- if(inetpton(DEF_FAM, vhost_ip, &IN_ADDR(vaddr)) <= 0)
+ if (vhost_ip)
+ {
+ if (inetpton(DEF_FAM, vhost_ip, &IN_ADDR(vaddr)) <= 0)
return;
}
/*
* close_listener - close a single listener
*/
-void close_listener(struct Listener* listener)
+void
+close_listener(struct Listener *listener)
{
assert(0 != listener);
/*
* close_listeners - close and free all listeners that are not being used
*/
-void close_listeners()
+void
+close_listeners()
{
- struct Listener* listener;
- struct Listener* listener_next = 0;
+ struct Listener *listener;
+ struct Listener *listener_next = 0;
/*
* close all 'extra' listening ports we have
*/
- for (listener = ListenerPollList; listener; listener = listener_next) {
+ for (listener = ListenerPollList; listener; listener = listener_next)
+ {
listener_next = listener->next;
close_listener(listener);
}
#define TOOFAST_WARNING "ERROR :Trying to reconnect too fast.\r\n"
#define DLINE_WARNING "ERROR :You have been D-lined.\r\n"
-static void accept_connection(int pfd, void *data)
+static void
+accept_connection(int pfd, void *data)
{
- static time_t last_oper_notice = 0;
+ static time_t last_oper_notice = 0;
struct irc_sockaddr sai;
struct irc_inaddr addr;
- int fd;
+ int fd;
int pe;
- struct Listener * listener = data;
+ struct Listener *listener = data;
assert(0 != listener);
copy_s_addr(IN_ADDR(addr), S_ADDR(sai));
#ifdef IPV6
- if((IN6_IS_ADDR_V4MAPPED(&IN_ADDR2(addr))) ||
- (IN6_IS_ADDR_V4COMPAT(&IN_ADDR2(addr))))
+ if ((IN6_IS_ADDR_V4MAPPED(&IN_ADDR2(addr))) ||
+ (IN6_IS_ADDR_V4COMPAT(&IN_ADDR2(addr))))
{
- memmove(&addr.sins.sin.s_addr, addr.sins.sin6.s6_addr+12,
- sizeof(struct in_addr));
+ memmove(&addr.sins.sin.s_addr, addr.sins.sin6.s6_addr + 12,
+ sizeof(struct in_addr));
- sai.sins.sin.sin_family = AF_INET;
+ sai.sins.sin.sin_family = AF_INET;
}
#endif
if (fd < 0)
+ {
+ /*
+ * slow down the whining to opers bit
+ */
+ if ((last_oper_notice + 20) <= CurrentTime)
{
- /*
- * slow down the whining to opers bit
- */
- if((last_oper_notice + 20) <= CurrentTime)
- {
- report_error(L_ALL, "Error accepting connection %s:%s",
- listener->name, errno);
- last_oper_notice = CurrentTime;
- }
- /* Re-register a new IO request for the next accept .. */
- comm_setselect(listener->fd, FDLIST_SERVICE, COMM_SELECT_READ,
- accept_connection, listener, 0);
- return;
+ report_error(L_ALL, "Error accepting connection %s:%s",
+ listener->name, errno);
+ last_oper_notice = CurrentTime;
}
+ /* Re-register a new IO request for the next accept .. */
+ comm_setselect(listener->fd, FDLIST_SERVICE, COMM_SELECT_READ,
+ accept_connection, listener, 0);
+ return;
+ }
/*
* check for connection limit
*/
if ((MAXCONNECTIONS - 10) < fd)
+ {
+ ++ServerStats->is_ref;
+ /*
+ * slow down the whining to opers bit
+ */
+ if ((last_oper_notice + 20) <= CurrentTime)
{
- ++ServerStats->is_ref;
- /*
- * slow down the whining to opers bit
- */
- if((last_oper_notice + 20) <= CurrentTime)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"All connections in use. (%s)",
- get_listener_name(listener));
- last_oper_notice = CurrentTime;
- }
- send(fd, "ERROR :All connections in use\r\n", 32, 0);
- fd_close(fd);
- /* Re-register a new IO request for the next accept .. */
- comm_setselect(listener->fd, FDLIST_SERVICE, COMM_SELECT_READ,
- accept_connection, listener, 0);
- return;
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "All connections in use. (%s)",
+ get_listener_name(listener));
+ last_oper_notice = CurrentTime;
}
+ send(fd, "ERROR :All connections in use\r\n", 32, 0);
+ fd_close(fd);
+ /* Re-register a new IO request for the next accept .. */
+ comm_setselect(listener->fd, FDLIST_SERVICE, COMM_SELECT_READ,
+ accept_connection, listener, 0);
+ return;
+ }
/* Do an initial check we aren't connecting too fast or with too many
* from this IP... */
if ((pe = conf_connect_allowed(&addr, sai.sins.sin.sin_family)) != 0)
{
- ServerStats->is_ref++;
- switch (pe)
- {
- case BANNED_CLIENT:
- send(fd, DLINE_WARNING, sizeof(DLINE_WARNING)-1, 0);
- break;
+ ServerStats->is_ref++;
+ switch (pe)
+ {
+ case BANNED_CLIENT:
+ send(fd, DLINE_WARNING, sizeof(DLINE_WARNING) - 1, 0);
+ break;
#ifdef PACE_CONNECT
- case TOO_FAST:
- send(fd, TOOFAST_WARNING, sizeof(TOOFAST_WARNING)-1, 0);
- break;
+ case TOO_FAST:
+ send(fd, TOOFAST_WARNING, sizeof(TOOFAST_WARNING) - 1, 0);
+ break;
#endif
- }
- fd_close(fd);
- /* Re-register a new IO request for the next accept .. */
- comm_setselect(listener->fd, FDLIST_SERVICE, COMM_SELECT_READ,
- accept_connection, listener, 0);
- return;
+ }
+ fd_close(fd);
+ /* Re-register a new IO request for the next accept .. */
+ comm_setselect(listener->fd, FDLIST_SERVICE, COMM_SELECT_READ,
+ accept_connection, listener, 0);
+ return;
}
ServerStats->is_ac++;
/* Re-register a new IO request for the next accept .. */
comm_setselect(listener->fd, FDLIST_SERVICE, COMM_SELECT_READ,
- accept_connection, listener, 0);
+ accept_connection, listener, 0);
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_error.c,v 1.1 2002/01/04 09:14:18 a1kmm Exp $
+ * $Id: m_error.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include "handlers.h"
#include "client.h"
-#include "common.h" /* FALSE */
+#include "common.h" /* FALSE */
#include "ircd.h"
#include "numeric.h"
#include "send.h"
struct Message error_msgtab = {
- "ERROR", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0,
+ "ERROR", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0,
{m_error, m_ignore, ms_error, m_ignore}
};
* parv[0] = sender prefix
* parv[*] = parameters
*/
-void m_error(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+void
+m_error(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char* para;
+ char *para;
para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";
-
+
deprintf("error", "Received ERROR message from %s: %s",
- source_p->name, para);
+ source_p->name, para);
if (client_p == source_p)
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "ERROR :from %s -- %s",
- get_client_name(client_p, HIDE_IP), para);
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "ERROR :from %s -- %s",
- get_client_name(client_p, MASK_IP), para);
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "ERROR :from %s -- %s",
+ get_client_name(client_p, HIDE_IP), para);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "ERROR :from %s -- %s",
+ get_client_name(client_p, MASK_IP), para);
+ }
else
- {
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "ERROR :from %s via %s -- %s",
- source_p->name, get_client_name(client_p, MASK_IP), para);
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,"ERROR :from %s via %s -- %s",
- source_p->name,
- get_client_name(client_p, HIDE_IP), para);
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "ERROR :from %s via %s -- %s",
+ source_p->name, get_client_name(client_p, MASK_IP),
+ para);
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN, "ERROR :from %s via %s -- %s",
+ source_p->name, get_client_name(client_p, HIDE_IP),
+ para);
+ }
exit_client(client_p, source_p, source_p, "ERROR");
}
-void ms_error(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+void
+ms_error(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- char* para;
+ char *para;
para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";
-
+
deprintf("error", "Received ERROR message from %s: %s",
- source_p->name, para);
+ source_p->name, para);
if (client_p == source_p)
- sendto_realops_flags(FLAGS_ALL, L_ALL,"ERROR :from %s -- %s",
- get_client_name(client_p, MASK_IP), para);
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "ERROR :from %s -- %s",
+ get_client_name(client_p, MASK_IP), para);
else
- sendto_realops_flags(FLAGS_ALL, L_ALL,"ERROR :from %s via %s -- %s", source_p->name,
- get_client_name(client_p, MASK_IP), para);
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "ERROR :from %s via %s -- %s",
+ source_p->name, get_client_name(client_p, MASK_IP),
+ para);
}
* Cleanup of collapse and match
* Moved static calls variable to match
* Added asserts for null pointers
- * $Id: match.c,v 1.1 2002/01/04 09:14:18 a1kmm Exp $
+ * $Id: match.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*
*/
#include "irc_string.h"
-#include "config.h" /* RFC1035_ANAL */
+#include "config.h" /* RFC1035_ANAL */
#include "client.h"
#include <assert.h>
-#include <string.h> /* strrchr */
+#include <string.h> /* strrchr */
#include <ctype.h>
#include <stdlib.h>
#include "ircd.h"
* if a line matches a mask, true (1) is returned, otherwise false (0)
* is returned.
*/
-#define MATCH_MAX_CALLS 512 /* ACK! This dies when it's less that this
- and we have long lines to parse */
-int match(const char *mask, const char *name)
+#define MATCH_MAX_CALLS 512 /* ACK! This dies when it's less that this
+ and we have long lines to parse */
+int
+match(const char *mask, const char *name)
{
- const unsigned char* m = (const unsigned char*) mask;
- const unsigned char* n = (const unsigned char*) name;
- const unsigned char* ma = (const unsigned char*) mask;
- const unsigned char* na = (const unsigned char*) name;
- int wild = 0;
- int calls = 0;
- int quote = 0;
+ const unsigned char *m = (const unsigned char *)mask;
+ const unsigned char *n = (const unsigned char *)name;
+ const unsigned char *ma = (const unsigned char *)mask;
+ const unsigned char *na = (const unsigned char *)name;
+ int wild = 0;
+ int calls = 0;
+ int quote = 0;
assert(0 != mask);
assert(0 != name);
if (!mask || !name)
return 0;
- while (calls++ < MATCH_MAX_CALLS) {
+ while (calls++ < MATCH_MAX_CALLS)
+ {
if (quote)
quote++;
if (quote == 3)
quote = 0;
if (*m == '\\' && !quote)
- {
- m++;
- quote = 1;
- continue;
- }
- if (!quote && *m == '*') {
+ {
+ m++;
+ quote = 1;
+ continue;
+ }
+ if (!quote && *m == '*')
+ {
/*
* XXX - shouldn't need to spin here, the mask should have been
* collapsed before match is called
while (*m == '*')
m++;
if (*m == '\\')
- {
- m++;
- /* This means it is an invalid mask -A1kmm. */
- if (!*m)
- return 0;
- quote = 2;
- }
+ {
+ m++;
+ /* This means it is an invalid mask -A1kmm. */
+ if (!*m)
+ return 0;
+ quote = 2;
+ }
wild = 1;
ma = m;
na = n;
}
- if (!*m) {
+ if (!*m)
+ {
if (!*n)
return 1;
if (quote)
return 0;
- for (m--; (m > (const unsigned char*) mask) && (*m == '?'); m--)
+ for (m--; (m > (const unsigned char *)mask) && (*m == '?'); m--)
;
- if (*m == '*' && (m > (const unsigned char*) mask))
+ if (*m == '*' && (m > (const unsigned char *)mask))
return 1;
if (!wild)
return 0;
m = ma;
n = ++na;
}
- else if (!*n) {
+ else if (!*n)
+ {
/*
* XXX - shouldn't need to spin here, the mask should have been
* collapsed before match is called
m++;
return (*m == 0);
}
- if (ToLower(*m) != ToLower(*n) && !(!quote && *m == '?')) {
+ if (ToLower(*m) != ToLower(*n) && !(!quote && *m == '?'))
+ {
if (!wild)
return 0;
m = ma;
n = ++na;
}
- else {
+ else
+ {
if (*m)
m++;
if (*n)
char *
collapse(char *pattern)
{
- char *p = pattern, *po = pattern;
- char c;
- int f = 0;
+ char *p = pattern, *po = pattern;
+ char c;
+ int f = 0;
+
+ if (!p)
+ return NULL;
- if (!p)
- return NULL;
-
- while ((c = *p++))
- {
+ while ((c = *p++))
+ {
if (!(f & 2) && c == '*')
- {
- if (!(f & 1))
- *po++ = '*';
- f |= 1;
- }
+ {
+ if (!(f & 1))
+ *po++ = '*';
+ f |= 1;
+ }
else if (!(f & 2) && c == '\\')
- {
- *po++ = '\\';
- f |= 2;
- }
+ {
+ *po++ = '\\';
+ f |= 2;
+ }
else
- {
- *po++ = c;
- f &= ~3;
- }
- }
- *po++ = 0;
- return pattern;
+ {
+ *po++ = c;
+ f &= ~3;
+ }
+ }
+ *po++ = 0;
+ return pattern;
}
/*
* <0, if s1 lexicographically less than s2
* >0, if s1 lexicographically greater than s2
*/
-int irccmp(const char *s1, const char *s2)
+int
+irccmp(const char *s1, const char *s2)
{
- const unsigned char* str1 = (const unsigned char*) s1;
- const unsigned char* str2 = (const unsigned char*) s2;
- int res;
+ const unsigned char *str1 = (const unsigned char *)s1;
+ const unsigned char *str2 = (const unsigned char *)s2;
+ int res;
assert(0 != s1);
assert(0 != s2);
- while ((res = ToUpper(*str1) - ToUpper(*str2)) == 0) {
+ while ((res = ToUpper(*str1) - ToUpper(*str2)) == 0)
+ {
if (*str1 == '\0')
return 0;
str1++;
return (res);
}
-int ircncmp(const char* s1, const char *s2, int n)
+int
+ircncmp(const char *s1, const char *s2, int n)
{
- const unsigned char* str1 = (const unsigned char*) s1;
- const unsigned char* str2 = (const unsigned char*) s2;
+ const unsigned char *str1 = (const unsigned char *)s1;
+ const unsigned char *str2 = (const unsigned char *)s2;
int res;
assert(0 != s1);
assert(0 != s2);
- while ((res = ToUpper(*str1) - ToUpper(*str2)) == 0) {
- str1++; str2++; n--;
+ while ((res = ToUpper(*str1) - ToUpper(*str2)) == 0)
+ {
+ str1++;
+ str2++;
+ n--;
if (n == 0 || (*str1 == '\0' && *str2 == '\0'))
return 0;
}
return (res);
}
+
#ifdef DEAD_CODE
-unsigned long textip_to_ul(const char *ip)
+unsigned long
+textip_to_ul(const char *ip)
{
- unsigned long ipr=0;
- unsigned int octet=0;
+ unsigned long ipr = 0;
+ unsigned int octet = 0;
char c;
- while((c=*ip)) {
- if(isdigit((int)c)) {
+ while ((c = *ip))
+ {
+ if (isdigit((int)c))
+ {
octet *= 10;
octet += (*ip & 0xF);
- } else if(c == '.') {
+ }
+ else if (c == '.')
+ {
ipr <<= 8;
ipr += octet;
octet = 0;
- } else if(c=='/')break;
+ }
+ else if (c == '/')
+ break;
ip++;
}
ipr <<= 8;
ipr += octet;
return ipr;
}
-#endif
-const unsigned char ToLowerTab[] = {
+#endif
+const unsigned char ToLowerTab[] = {
0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
-const unsigned char ToUpperTab[] = {
+const unsigned char ToUpperTab[] = {
0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
- 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
+ 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
/*
* for channel names
*/
const unsigned int CharAttrs[] = {
-/* 0 */ CNTRL_C,
-/* 1 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 2 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 3 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 4 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 5 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 6 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 7 BEL */ CNTRL_C|NONEOS_C,
-/* 8 \b */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 9 \t */ CNTRL_C|SPACE_C|CHAN_C|NONEOS_C,
-/* 10 \n */ CNTRL_C|SPACE_C|CHAN_C|NONEOS_C|EOL_C,
-/* 11 \v */ CNTRL_C|SPACE_C|CHAN_C|NONEOS_C,
-/* 12 \f */ CNTRL_C|SPACE_C|CHAN_C|NONEOS_C,
-/* 13 \r */ CNTRL_C|SPACE_C|CHAN_C|NONEOS_C|EOL_C,
-/* 14 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 15 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 16 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 17 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 18 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 19 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 20 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 21 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 22 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 23 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 24 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 25 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 26 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 27 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 28 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 29 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 30 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* 31 */ CNTRL_C|CHAN_C|NONEOS_C,
-/* SP */ PRINT_C|SPACE_C,
-/* ! */ PRINT_C|KWILD_C|CHAN_C|NONEOS_C,
-/* " */ PRINT_C|CHAN_C|NONEOS_C,
-/* # */ PRINT_C|CHANPFX_C|CHAN_C|NONEOS_C,
-/* $ */ PRINT_C|CHAN_C|NONEOS_C|USER_C,
-/* % */ PRINT_C|CHAN_C|NONEOS_C,
-/* & */ PRINT_C|CHANPFX_C|CHAN_C|NONEOS_C,
-/* ' */ PRINT_C|CHAN_C|NONEOS_C,
-/* ( */ PRINT_C|CHAN_C|NONEOS_C,
-/* ) */ PRINT_C|CHAN_C|NONEOS_C,
-/* * */ PRINT_C|KWILD_C|CHAN_C|NONEOS_C|SERV_C,
-/* + */ PRINT_C|CHAN_C|NONEOS_C,
-/* , */ PRINT_C|NONEOS_C,
-/* - */ PRINT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* . */ PRINT_C|KWILD_C|CHAN_C|NONEOS_C|USER_C|HOST_C|SERV_C,
-/* / */ PRINT_C|CHAN_C|NONEOS_C,
-/* 0 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 1 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 2 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 3 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 4 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 5 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 6 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 7 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 8 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* 9 */ PRINT_C|DIGIT_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* : */ PRINT_C|CHAN_C|NONEOS_C|HOST_C,
-/* ; */ PRINT_C|CHAN_C|NONEOS_C,
-/* < */ PRINT_C|CHAN_C|NONEOS_C,
-/* = */ PRINT_C|CHAN_C|NONEOS_C,
-/* > */ PRINT_C|CHAN_C|NONEOS_C,
-/* ? */ PRINT_C|KWILD_C|CHAN_C|NONEOS_C,
-/* @ */ PRINT_C|KWILD_C|CHAN_C|NONEOS_C,
-/* A */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* B */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* C */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* D */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* E */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* F */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* G */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* H */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* I */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* J */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* K */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* L */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* M */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* N */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* O */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* P */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* Q */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* R */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* S */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* T */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* U */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* V */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* W */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* X */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* Y */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* Z */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* [ */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* \ */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* ] */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* ^ */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* _ */ PRINT_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* ` */ PRINT_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* a */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* b */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* c */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* d */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* e */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* f */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* g */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* h */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* i */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* j */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* k */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* l */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* m */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* n */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* o */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* p */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* q */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* r */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* s */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* t */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* u */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* v */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* w */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* x */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* y */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* z */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C|HOST_C,
-/* { */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* | */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* } */ PRINT_C|ALPHA_C|NICK_C|CHAN_C|NONEOS_C|USER_C,
-/* ~ */ PRINT_C|ALPHA_C|CHAN_C|NONEOS_C|USER_C,
-/* del */ CHAN_C|NONEOS_C,
-/* 0x80 */ CHAN_C|NONEOS_C,
-/* 0x81 */ CHAN_C|NONEOS_C,
-/* 0x82 */ CHAN_C|NONEOS_C,
-/* 0x83 */ CHAN_C|NONEOS_C,
-/* 0x84 */ CHAN_C|NONEOS_C,
-/* 0x85 */ CHAN_C|NONEOS_C,
-/* 0x86 */ CHAN_C|NONEOS_C,
-/* 0x87 */ CHAN_C|NONEOS_C,
-/* 0x88 */ CHAN_C|NONEOS_C,
-/* 0x89 */ CHAN_C|NONEOS_C,
-/* 0x8A */ CHAN_C|NONEOS_C,
-/* 0x8B */ CHAN_C|NONEOS_C,
-/* 0x8C */ CHAN_C|NONEOS_C,
-/* 0x8D */ CHAN_C|NONEOS_C,
-/* 0x8E */ CHAN_C|NONEOS_C,
-/* 0x8F */ CHAN_C|NONEOS_C,
-/* 0x90 */ CHAN_C|NONEOS_C,
-/* 0x91 */ CHAN_C|NONEOS_C,
-/* 0x92 */ CHAN_C|NONEOS_C,
-/* 0x93 */ CHAN_C|NONEOS_C,
-/* 0x94 */ CHAN_C|NONEOS_C,
-/* 0x95 */ CHAN_C|NONEOS_C,
-/* 0x96 */ CHAN_C|NONEOS_C,
-/* 0x97 */ CHAN_C|NONEOS_C,
-/* 0x98 */ CHAN_C|NONEOS_C,
-/* 0x99 */ CHAN_C|NONEOS_C,
-/* 0x9A */ CHAN_C|NONEOS_C,
-/* 0x9B */ CHAN_C|NONEOS_C,
-/* 0x9C */ CHAN_C|NONEOS_C,
-/* 0x9D */ CHAN_C|NONEOS_C,
-/* 0x9E */ CHAN_C|NONEOS_C,
-/* 0x9F */ CHAN_C|NONEOS_C,
-/* 0xA0 */ CHAN_C|NONEOS_C,
-/* 0xA1 */ CHAN_C|NONEOS_C,
-/* 0xA2 */ CHAN_C|NONEOS_C,
-/* 0xA3 */ CHAN_C|NONEOS_C,
-/* 0xA4 */ CHAN_C|NONEOS_C,
-/* 0xA5 */ CHAN_C|NONEOS_C,
-/* 0xA6 */ CHAN_C|NONEOS_C,
-/* 0xA7 */ CHAN_C|NONEOS_C,
-/* 0xA8 */ CHAN_C|NONEOS_C,
-/* 0xA9 */ CHAN_C|NONEOS_C,
-/* 0xAA */ CHAN_C|NONEOS_C,
-/* 0xAB */ CHAN_C|NONEOS_C,
-/* 0xAC */ CHAN_C|NONEOS_C,
-/* 0xAD */ CHAN_C|NONEOS_C,
-/* 0xAE */ CHAN_C|NONEOS_C,
-/* 0xAF */ CHAN_C|NONEOS_C,
-/* 0xB0 */ CHAN_C|NONEOS_C,
-/* 0xB1 */ CHAN_C|NONEOS_C,
-/* 0xB2 */ CHAN_C|NONEOS_C,
-/* 0xB3 */ CHAN_C|NONEOS_C,
-/* 0xB4 */ CHAN_C|NONEOS_C,
-/* 0xB5 */ CHAN_C|NONEOS_C,
-/* 0xB6 */ CHAN_C|NONEOS_C,
-/* 0xB7 */ CHAN_C|NONEOS_C,
-/* 0xB8 */ CHAN_C|NONEOS_C,
-/* 0xB9 */ CHAN_C|NONEOS_C,
-/* 0xBA */ CHAN_C|NONEOS_C,
-/* 0xBB */ CHAN_C|NONEOS_C,
-/* 0xBC */ CHAN_C|NONEOS_C,
-/* 0xBD */ CHAN_C|NONEOS_C,
-/* 0xBE */ CHAN_C|NONEOS_C,
-/* 0xBF */ CHAN_C|NONEOS_C,
-/* 0xC0 */ CHAN_C|NONEOS_C,
-/* 0xC1 */ CHAN_C|NONEOS_C,
-/* 0xC2 */ CHAN_C|NONEOS_C,
-/* 0xC3 */ CHAN_C|NONEOS_C,
-/* 0xC4 */ CHAN_C|NONEOS_C,
-/* 0xC5 */ CHAN_C|NONEOS_C,
-/* 0xC6 */ CHAN_C|NONEOS_C,
-/* 0xC7 */ CHAN_C|NONEOS_C,
-/* 0xC8 */ CHAN_C|NONEOS_C,
-/* 0xC9 */ CHAN_C|NONEOS_C,
-/* 0xCA */ CHAN_C|NONEOS_C,
-/* 0xCB */ CHAN_C|NONEOS_C,
-/* 0xCC */ CHAN_C|NONEOS_C,
-/* 0xCD */ CHAN_C|NONEOS_C,
-/* 0xCE */ CHAN_C|NONEOS_C,
-/* 0xCF */ CHAN_C|NONEOS_C,
-/* 0xD0 */ CHAN_C|NONEOS_C,
-/* 0xD1 */ CHAN_C|NONEOS_C,
-/* 0xD2 */ CHAN_C|NONEOS_C,
-/* 0xD3 */ CHAN_C|NONEOS_C,
-/* 0xD4 */ CHAN_C|NONEOS_C,
-/* 0xD5 */ CHAN_C|NONEOS_C,
-/* 0xD6 */ CHAN_C|NONEOS_C,
-/* 0xD7 */ CHAN_C|NONEOS_C,
-/* 0xD8 */ CHAN_C|NONEOS_C,
-/* 0xD9 */ CHAN_C|NONEOS_C,
-/* 0xDA */ CHAN_C|NONEOS_C,
-/* 0xDB */ CHAN_C|NONEOS_C,
-/* 0xDC */ CHAN_C|NONEOS_C,
-/* 0xDD */ CHAN_C|NONEOS_C,
-/* 0xDE */ CHAN_C|NONEOS_C,
-/* 0xDF */ CHAN_C|NONEOS_C,
-/* 0xE0 */ CHAN_C|NONEOS_C,
-/* 0xE1 */ CHAN_C|NONEOS_C,
-/* 0xE2 */ CHAN_C|NONEOS_C,
-/* 0xE3 */ CHAN_C|NONEOS_C,
-/* 0xE4 */ CHAN_C|NONEOS_C,
-/* 0xE5 */ CHAN_C|NONEOS_C,
-/* 0xE6 */ CHAN_C|NONEOS_C,
-/* 0xE7 */ CHAN_C|NONEOS_C,
-/* 0xE8 */ CHAN_C|NONEOS_C,
-/* 0xE9 */ CHAN_C|NONEOS_C,
-/* 0xEA */ CHAN_C|NONEOS_C,
-/* 0xEB */ CHAN_C|NONEOS_C,
-/* 0xEC */ CHAN_C|NONEOS_C,
-/* 0xED */ CHAN_C|NONEOS_C,
-/* 0xEE */ CHAN_C|NONEOS_C,
-/* 0xEF */ CHAN_C|NONEOS_C,
-/* 0xF0 */ CHAN_C|NONEOS_C,
-/* 0xF1 */ CHAN_C|NONEOS_C,
-/* 0xF2 */ CHAN_C|NONEOS_C,
-/* 0xF3 */ CHAN_C|NONEOS_C,
-/* 0xF4 */ CHAN_C|NONEOS_C,
-/* 0xF5 */ CHAN_C|NONEOS_C,
-/* 0xF6 */ CHAN_C|NONEOS_C,
-/* 0xF7 */ CHAN_C|NONEOS_C,
-/* 0xF8 */ CHAN_C|NONEOS_C,
-/* 0xF9 */ CHAN_C|NONEOS_C,
-/* 0xFA */ CHAN_C|NONEOS_C,
-/* 0xFB */ CHAN_C|NONEOS_C,
-/* 0xFC */ CHAN_C|NONEOS_C,
-/* 0xFD */ CHAN_C|NONEOS_C,
-/* 0xFE */ CHAN_C|NONEOS_C,
-/* 0xFF */ CHAN_C|NONEOS_C
+/* 0 */ CNTRL_C,
+/* 1 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 2 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 3 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 4 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 5 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 6 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 7 BEL */ CNTRL_C | NONEOS_C,
+/* 8 \b */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 9 \t */ CNTRL_C | SPACE_C | CHAN_C | NONEOS_C,
+/* 10 \n */ CNTRL_C | SPACE_C | CHAN_C | NONEOS_C | EOL_C,
+/* 11 \v */ CNTRL_C | SPACE_C | CHAN_C | NONEOS_C,
+/* 12 \f */ CNTRL_C | SPACE_C | CHAN_C | NONEOS_C,
+/* 13 \r */ CNTRL_C | SPACE_C | CHAN_C | NONEOS_C | EOL_C,
+/* 14 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 15 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 16 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 17 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 18 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 19 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 20 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 21 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 22 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 23 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 24 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 25 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 26 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 27 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 28 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 29 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 30 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* 31 */ CNTRL_C | CHAN_C | NONEOS_C,
+/* SP */ PRINT_C | SPACE_C,
+/* ! */ PRINT_C | KWILD_C | CHAN_C | NONEOS_C,
+/* " */ PRINT_C | CHAN_C | NONEOS_C,
+/* # */ PRINT_C | CHANPFX_C | CHAN_C | NONEOS_C,
+/* $ */ PRINT_C | CHAN_C | NONEOS_C | USER_C,
+/* % */ PRINT_C | CHAN_C | NONEOS_C,
+/* & */ PRINT_C | CHANPFX_C | CHAN_C | NONEOS_C,
+/* ' */ PRINT_C | CHAN_C | NONEOS_C,
+/* ( */ PRINT_C | CHAN_C | NONEOS_C,
+/* ) */ PRINT_C | CHAN_C | NONEOS_C,
+/* * */ PRINT_C | KWILD_C | CHAN_C | NONEOS_C | SERV_C,
+/* + */ PRINT_C | CHAN_C | NONEOS_C,
+/* , */ PRINT_C | NONEOS_C,
+/* - */ PRINT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* . */ PRINT_C | KWILD_C | CHAN_C | NONEOS_C | USER_C | HOST_C | SERV_C,
+/* / */ PRINT_C | CHAN_C | NONEOS_C,
+/* 0 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 1 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 2 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 3 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 4 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 5 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 6 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 7 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 8 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* 9 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* : */ PRINT_C | CHAN_C | NONEOS_C | HOST_C,
+/* ; */ PRINT_C | CHAN_C | NONEOS_C,
+/* < */ PRINT_C | CHAN_C | NONEOS_C,
+/* = */ PRINT_C | CHAN_C | NONEOS_C,
+/* > */ PRINT_C | CHAN_C | NONEOS_C,
+/* ? */ PRINT_C | KWILD_C | CHAN_C | NONEOS_C,
+/* @ */ PRINT_C | KWILD_C | CHAN_C | NONEOS_C,
+/* A */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* B */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* C */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* D */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* E */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* F */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* G */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* H */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* I */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* J */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* K */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* L */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* M */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* N */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* O */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* P */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* Q */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* R */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* S */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* T */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* U */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* V */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* W */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* X */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* Y */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* Z */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* [ */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* \ */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* ] */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* ^ */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* _ */ PRINT_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* ` */ PRINT_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* a */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* b */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* c */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* d */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* e */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* f */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* g */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* h */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* i */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* j */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* k */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* l */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* m */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* n */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* o */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* p */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* q */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* r */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* s */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* t */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* u */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* v */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* w */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* x */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* y */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* z */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
+/* { */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* | */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* } */ PRINT_C | ALPHA_C | NICK_C | CHAN_C | NONEOS_C | USER_C,
+/* ~ */ PRINT_C | ALPHA_C | CHAN_C | NONEOS_C | USER_C,
+/* del */ CHAN_C | NONEOS_C,
+/* 0x80 */ CHAN_C | NONEOS_C,
+/* 0x81 */ CHAN_C | NONEOS_C,
+/* 0x82 */ CHAN_C | NONEOS_C,
+/* 0x83 */ CHAN_C | NONEOS_C,
+/* 0x84 */ CHAN_C | NONEOS_C,
+/* 0x85 */ CHAN_C | NONEOS_C,
+/* 0x86 */ CHAN_C | NONEOS_C,
+/* 0x87 */ CHAN_C | NONEOS_C,
+/* 0x88 */ CHAN_C | NONEOS_C,
+/* 0x89 */ CHAN_C | NONEOS_C,
+/* 0x8A */ CHAN_C | NONEOS_C,
+/* 0x8B */ CHAN_C | NONEOS_C,
+/* 0x8C */ CHAN_C | NONEOS_C,
+/* 0x8D */ CHAN_C | NONEOS_C,
+/* 0x8E */ CHAN_C | NONEOS_C,
+/* 0x8F */ CHAN_C | NONEOS_C,
+/* 0x90 */ CHAN_C | NONEOS_C,
+/* 0x91 */ CHAN_C | NONEOS_C,
+/* 0x92 */ CHAN_C | NONEOS_C,
+/* 0x93 */ CHAN_C | NONEOS_C,
+/* 0x94 */ CHAN_C | NONEOS_C,
+/* 0x95 */ CHAN_C | NONEOS_C,
+/* 0x96 */ CHAN_C | NONEOS_C,
+/* 0x97 */ CHAN_C | NONEOS_C,
+/* 0x98 */ CHAN_C | NONEOS_C,
+/* 0x99 */ CHAN_C | NONEOS_C,
+/* 0x9A */ CHAN_C | NONEOS_C,
+/* 0x9B */ CHAN_C | NONEOS_C,
+/* 0x9C */ CHAN_C | NONEOS_C,
+/* 0x9D */ CHAN_C | NONEOS_C,
+/* 0x9E */ CHAN_C | NONEOS_C,
+/* 0x9F */ CHAN_C | NONEOS_C,
+/* 0xA0 */ CHAN_C | NONEOS_C,
+/* 0xA1 */ CHAN_C | NONEOS_C,
+/* 0xA2 */ CHAN_C | NONEOS_C,
+/* 0xA3 */ CHAN_C | NONEOS_C,
+/* 0xA4 */ CHAN_C | NONEOS_C,
+/* 0xA5 */ CHAN_C | NONEOS_C,
+/* 0xA6 */ CHAN_C | NONEOS_C,
+/* 0xA7 */ CHAN_C | NONEOS_C,
+/* 0xA8 */ CHAN_C | NONEOS_C,
+/* 0xA9 */ CHAN_C | NONEOS_C,
+/* 0xAA */ CHAN_C | NONEOS_C,
+/* 0xAB */ CHAN_C | NONEOS_C,
+/* 0xAC */ CHAN_C | NONEOS_C,
+/* 0xAD */ CHAN_C | NONEOS_C,
+/* 0xAE */ CHAN_C | NONEOS_C,
+/* 0xAF */ CHAN_C | NONEOS_C,
+/* 0xB0 */ CHAN_C | NONEOS_C,
+/* 0xB1 */ CHAN_C | NONEOS_C,
+/* 0xB2 */ CHAN_C | NONEOS_C,
+/* 0xB3 */ CHAN_C | NONEOS_C,
+/* 0xB4 */ CHAN_C | NONEOS_C,
+/* 0xB5 */ CHAN_C | NONEOS_C,
+/* 0xB6 */ CHAN_C | NONEOS_C,
+/* 0xB7 */ CHAN_C | NONEOS_C,
+/* 0xB8 */ CHAN_C | NONEOS_C,
+/* 0xB9 */ CHAN_C | NONEOS_C,
+/* 0xBA */ CHAN_C | NONEOS_C,
+/* 0xBB */ CHAN_C | NONEOS_C,
+/* 0xBC */ CHAN_C | NONEOS_C,
+/* 0xBD */ CHAN_C | NONEOS_C,
+/* 0xBE */ CHAN_C | NONEOS_C,
+/* 0xBF */ CHAN_C | NONEOS_C,
+/* 0xC0 */ CHAN_C | NONEOS_C,
+/* 0xC1 */ CHAN_C | NONEOS_C,
+/* 0xC2 */ CHAN_C | NONEOS_C,
+/* 0xC3 */ CHAN_C | NONEOS_C,
+/* 0xC4 */ CHAN_C | NONEOS_C,
+/* 0xC5 */ CHAN_C | NONEOS_C,
+/* 0xC6 */ CHAN_C | NONEOS_C,
+/* 0xC7 */ CHAN_C | NONEOS_C,
+/* 0xC8 */ CHAN_C | NONEOS_C,
+/* 0xC9 */ CHAN_C | NONEOS_C,
+/* 0xCA */ CHAN_C | NONEOS_C,
+/* 0xCB */ CHAN_C | NONEOS_C,
+/* 0xCC */ CHAN_C | NONEOS_C,
+/* 0xCD */ CHAN_C | NONEOS_C,
+/* 0xCE */ CHAN_C | NONEOS_C,
+/* 0xCF */ CHAN_C | NONEOS_C,
+/* 0xD0 */ CHAN_C | NONEOS_C,
+/* 0xD1 */ CHAN_C | NONEOS_C,
+/* 0xD2 */ CHAN_C | NONEOS_C,
+/* 0xD3 */ CHAN_C | NONEOS_C,
+/* 0xD4 */ CHAN_C | NONEOS_C,
+/* 0xD5 */ CHAN_C | NONEOS_C,
+/* 0xD6 */ CHAN_C | NONEOS_C,
+/* 0xD7 */ CHAN_C | NONEOS_C,
+/* 0xD8 */ CHAN_C | NONEOS_C,
+/* 0xD9 */ CHAN_C | NONEOS_C,
+/* 0xDA */ CHAN_C | NONEOS_C,
+/* 0xDB */ CHAN_C | NONEOS_C,
+/* 0xDC */ CHAN_C | NONEOS_C,
+/* 0xDD */ CHAN_C | NONEOS_C,
+/* 0xDE */ CHAN_C | NONEOS_C,
+/* 0xDF */ CHAN_C | NONEOS_C,
+/* 0xE0 */ CHAN_C | NONEOS_C,
+/* 0xE1 */ CHAN_C | NONEOS_C,
+/* 0xE2 */ CHAN_C | NONEOS_C,
+/* 0xE3 */ CHAN_C | NONEOS_C,
+/* 0xE4 */ CHAN_C | NONEOS_C,
+/* 0xE5 */ CHAN_C | NONEOS_C,
+/* 0xE6 */ CHAN_C | NONEOS_C,
+/* 0xE7 */ CHAN_C | NONEOS_C,
+/* 0xE8 */ CHAN_C | NONEOS_C,
+/* 0xE9 */ CHAN_C | NONEOS_C,
+/* 0xEA */ CHAN_C | NONEOS_C,
+/* 0xEB */ CHAN_C | NONEOS_C,
+/* 0xEC */ CHAN_C | NONEOS_C,
+/* 0xED */ CHAN_C | NONEOS_C,
+/* 0xEE */ CHAN_C | NONEOS_C,
+/* 0xEF */ CHAN_C | NONEOS_C,
+/* 0xF0 */ CHAN_C | NONEOS_C,
+/* 0xF1 */ CHAN_C | NONEOS_C,
+/* 0xF2 */ CHAN_C | NONEOS_C,
+/* 0xF3 */ CHAN_C | NONEOS_C,
+/* 0xF4 */ CHAN_C | NONEOS_C,
+/* 0xF5 */ CHAN_C | NONEOS_C,
+/* 0xF6 */ CHAN_C | NONEOS_C,
+/* 0xF7 */ CHAN_C | NONEOS_C,
+/* 0xF8 */ CHAN_C | NONEOS_C,
+/* 0xF9 */ CHAN_C | NONEOS_C,
+/* 0xFA */ CHAN_C | NONEOS_C,
+/* 0xFB */ CHAN_C | NONEOS_C,
+/* 0xFC */ CHAN_C | NONEOS_C,
+/* 0xFD */ CHAN_C | NONEOS_C,
+/* 0xFE */ CHAN_C | NONEOS_C,
+/* 0xFF */ CHAN_C | NONEOS_C
};
-
-
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: md5.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
+ *
************************************************************************/
#include <sys/types.h>
**
*/
-static u_int32_t seed[MD5_BLOCK_SIZE] = {
- 0x67452301 , 0xefcdab89 , 0x98badcfe , 0x10325476 ,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0
+static u_int32_t seed[MD5_BLOCK_SIZE] = {
+ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0
};
-static unsigned char *seed_char = (unsigned char *)seed;
+static unsigned char *seed_char = (unsigned char *)seed;
-static u_int32_t databuf_int[MD5_HASH_SIZE];
-static char *databuf = (char *)databuf_int;
+static u_int32_t databuf_int[MD5_HASH_SIZE];
+static char *databuf = (char *)databuf_int;
static int ork[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12,
- 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2,
- 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12,
+ 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2,
+ 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9
};
static int ors[64] = {
- 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
- 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
- 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
- 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
+ 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
+ 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
+ 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
+ 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
};
-static u_int32_t t[64] = {
- 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
- 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
- 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
- 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
-
- 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
- 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
- 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
- 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
-
- 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
- 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
- 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
- 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
-
- 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
- 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
- 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
- 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
+static u_int32_t t[64] = {
+ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
+ 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
+ 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
+ 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
+
+ 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
+ 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
+ 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
+ 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
+
+ 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
+ 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
+ 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
+ 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
+
+ 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
+ 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
+ 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
+ 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
};
/*
** Should not include any 'flag' characters like @ and %, or special chars
** like : * and #, but 8bit accented stuff is quite ok -orabidoo
*/
-static char printable7[] =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[\\]{|}^ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüý";
-
-static char printable6[] =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[]{}";
-
-static char base64_chars[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-
-static char base64_values[] =
- {
-/* 00-15 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-/* 16-31 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-/* 32-47 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
-/* 48-63 */ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1,
-/* 64-79 */ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
-/* 80-95 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-/* 96-111 */ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-/* 112-127 */ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-/* 128-143 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-/* 144-159 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-/* 160-175 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-/* 186-191 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-/* 192-207 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-/* 208-223 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-/* 224-239 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+static char printable7[] =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[\\]{|}^ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüý";
+
+static char printable6[] =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[]{}";
+
+static char base64_chars[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+
+static char base64_values[] = {
+/* 00-15 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
+/* 16-31 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
+/* 32-47 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1,
+ 63,
+/* 48-63 */ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1,
+/* 64-79 */ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+/* 80-95 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1,
+ -1,
+/* 96-111 */ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+ 40,
+/* 112-127 */ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1,
+ -1,
+/* 128-143 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
+/* 144-159 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
+/* 160-175 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
+/* 186-191 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
+/* 192-207 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
+/* 208-223 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
+/* 224-239 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,
/* 240-255 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
- };
+};
-void id_init()
+void
+id_init()
{
int fd;
- struct tmpcrap
+ struct tmpcrap
{
struct timeval tv;
int pid;
int ppid;
- } st;
+ }
+ st;
gettimeofday(&st.tv, NULL);
st.pid = getpid();
alarm(3);
fd = open(RPATH, O_RDONLY);
if (fd > 0)
- {
- read(fd, databuf, 16);
- close(fd);
- alarm(0);
- md5_block(databuf_int, seed, seed);
- }
+ {
+ read(fd, databuf, 16);
+ close(fd);
+ alarm(0);
+ md5_block(databuf_int, seed, seed);
+ }
else
alarm(0);
#endif
}
-void save_random()
+void
+save_random()
{
int fd;
#ifdef RPATH
alarm(3);
- fd = open(RPATH, O_WRONLY|O_CREAT|O_TRUNC);
+ fd = open(RPATH, O_WRONLY | O_CREAT | O_TRUNC);
if (fd > 0)
- {
- write(fd, seed_char, 16);
+ {
+ write(fd, seed_char, 16);
/* by default on VMS, files can only be read by their owner */
#ifndef VMS
- fchmod(fd, 0600);
+ fchmod(fd, 0600);
#endif
- close(fd);
- }
+ close(fd);
+ }
alarm(0);
#endif
}
-void md5_block(u_int32_t *in, u_int32_t *out, u_int32_t *x)
+void
+md5_block(u_int32_t * in, u_int32_t * out, u_int32_t * x)
{
u_int32_t a, b, c, d;
int i, j;
b = in[1];
c = in[2];
d = in[3];
- for (i=0; i<4; i++)
- {
- j = 4*i;
- a = b + rotl(a + F(b, c, d) + x[ork[j]] + t[j], ors[j]);
- d = a + rotl(d + F(a, b, c) + x[ork[j+1]] + t[j+1], ors[j+1]);
- c = d + rotl(c + F(d, a, b) + x[ork[j+2]] + t[j+2], ors[j+2]);
- b = c + rotl(b + F(c, d, a) + x[ork[j+3]] + t[j+3], ors[j+3]);
- }
- for (i=0; i<4; i++)
- {
- j = 4*i + 16;
- a = b + rotl(a + G(b, c, d) + x[ork[j]] + t[j], ors[j]);
- d = a + rotl(d + G(a, b, c) + x[ork[j+1]] + t[j+1], ors[j+1]);
- c = d + rotl(c + G(d, a, b) + x[ork[j+2]] + t[j+2], ors[j+2]);
- b = c + rotl(b + G(c, d, a) + x[ork[j+3]] + t[j+3], ors[j+3]);
- }
- for (i=0; i<4; i++)
- {
- j = 4*i + 32;
- a = b + rotl(a + H(b, c, d) + x[ork[j]] + t[j], ors[j]);
- d = a + rotl(d + H(a, b, c) + x[ork[j+1]] + t[j+1], ors[j+1]);
- c = d + rotl(c + H(d, a, b) + x[ork[j+2]] + t[j+2], ors[j+2]);
- b = c + rotl(b + H(c, d, a) + x[ork[j+3]] + t[j+3], ors[j+3]);
- }
- for (i=0; i<4; i++)
- {
- j = 4*i + 48;
- a = b + rotl(a + I(b, c, d) + x[ork[j]] + t[j], ors[j]);
- d = a + rotl(d + I(a, b, c) + x[ork[j+1]] + t[j+1], ors[j+1]);
- c = d + rotl(c + I(d, a, b) + x[ork[j+2]] + t[j+2], ors[j+2]);
- b = c + rotl(b + I(c, d, a) + x[ork[j+3]] + t[j+3], ors[j+3]);
- }
+ for (i = 0; i < 4; i++)
+ {
+ j = 4 * i;
+ a = b + rotl(a + F(b, c, d) + x[ork[j]] + t[j], ors[j]);
+ d = a + rotl(d + F(a, b, c) + x[ork[j + 1]] + t[j + 1], ors[j + 1]);
+ c = d + rotl(c + F(d, a, b) + x[ork[j + 2]] + t[j + 2], ors[j + 2]);
+ b = c + rotl(b + F(c, d, a) + x[ork[j + 3]] + t[j + 3], ors[j + 3]);
+ }
+ for (i = 0; i < 4; i++)
+ {
+ j = 4 * i + 16;
+ a = b + rotl(a + G(b, c, d) + x[ork[j]] + t[j], ors[j]);
+ d = a + rotl(d + G(a, b, c) + x[ork[j + 1]] + t[j + 1], ors[j + 1]);
+ c = d + rotl(c + G(d, a, b) + x[ork[j + 2]] + t[j + 2], ors[j + 2]);
+ b = c + rotl(b + G(c, d, a) + x[ork[j + 3]] + t[j + 3], ors[j + 3]);
+ }
+ for (i = 0; i < 4; i++)
+ {
+ j = 4 * i + 32;
+ a = b + rotl(a + H(b, c, d) + x[ork[j]] + t[j], ors[j]);
+ d = a + rotl(d + H(a, b, c) + x[ork[j + 1]] + t[j + 1], ors[j + 1]);
+ c = d + rotl(c + H(d, a, b) + x[ork[j + 2]] + t[j + 2], ors[j + 2]);
+ b = c + rotl(b + H(c, d, a) + x[ork[j + 3]] + t[j + 3], ors[j + 3]);
+ }
+ for (i = 0; i < 4; i++)
+ {
+ j = 4 * i + 48;
+ a = b + rotl(a + I(b, c, d) + x[ork[j]] + t[j], ors[j]);
+ d = a + rotl(d + I(a, b, c) + x[ork[j + 1]] + t[j + 1], ors[j + 1]);
+ c = d + rotl(c + I(d, a, b) + x[ork[j + 2]] + t[j + 2], ors[j + 2]);
+ b = c + rotl(b + I(c, d, a) + x[ork[j + 3]] + t[j + 3], ors[j + 3]);
+ }
a += in[0];
b += in[1];
* base64_block will allocate and return a new block of memory
* using MyMalloc(). It should be freed after use.
*/
-int base64_block(char **output, char *data, int len)
+int
+base64_block(char **output, char *data, int len)
{
unsigned char *out;
- unsigned char *in = (unsigned char*)data;
+ unsigned char *in = (unsigned char *)data;
unsigned long int q_in;
int i;
int count = 0;
out = MyMalloc(((((len + 2) - ((len + 2) % 3)) / 3) * 4) + 1);
/* process 24 bits at a time */
- for( i = 0; i < len; i += 3)
+ for (i = 0; i < len; i += 3)
{
q_in = 0;
- if ( i + 2 < len )
+ if (i + 2 < len)
{
- q_in = (in[i+2] & 0xc0) << 2;
- q_in |= in[i+2];
+ q_in = (in[i + 2] & 0xc0) << 2;
+ q_in |= in[i + 2];
}
- if ( i + 1 < len )
+ if (i + 1 < len)
{
- q_in |= (in[i+1] & 0x0f) << 10;
- q_in |= (in[i+1] & 0xf0) << 12;
+ q_in |= (in[i + 1] & 0x0f) << 10;
+ q_in |= (in[i + 1] & 0xf0) << 12;
}
- q_in |= (in[i] & 0x03) << 20;
- q_in |= in[i] << 22;
+ q_in |= (in[i] & 0x03) << 20;
+ q_in |= in[i] << 22;
q_in &= 0x3f3f3f3f;
- out[count++] = base64_chars[((q_in >> 24) )];
+ out[count++] = base64_chars[((q_in >> 24))];
out[count++] = base64_chars[((q_in >> 16) & 0xff)];
- out[count++] = base64_chars[((q_in >> 8) & 0xff)];
- out[count++] = base64_chars[((q_in ) & 0xff)];
+ out[count++] = base64_chars[((q_in >> 8) & 0xff)];
+ out[count++] = base64_chars[((q_in) & 0xff)];
}
- if ( (i - len) > 0 )
+ if ((i - len) > 0)
{
- out[count-1] = '=';
- if ( (i - len) > 1 )
- out[count-2] = '=';
+ out[count - 1] = '=';
+ if ((i - len) > 1)
+ out[count - 2] = '=';
}
out[count] = '\0';
* unbase64_block will allocate and return a new block of memory
* using MyMalloc(). It should be freed after use.
*/
-int unbase64_block(char **output, char *data, int len)
+int
+unbase64_block(char **output, char *data, int len)
{
unsigned char *out;
- unsigned char *in = (unsigned char*)data;
+ unsigned char *in = (unsigned char *)data;
unsigned long int q_in;
int i;
int count = 0;
- if ( ( len % 4 ) != 0 )
+ if ((len % 4) != 0)
return 0;
out = MyMalloc(((len / 4) * 3) + 1);
/* process 32 bits at a time */
- for( i = 0; (i + 3) < len; i+=4)
+ for (i = 0; (i + 3) < len; i += 4)
{
/* compress input (chars a, b, c and d) as follows:
* (after converting ascii -> base64 value)
q_in = 0;
- if (base64_values[in[i+3]] > -1)
- q_in |= base64_values[in[i+3]] ;
- if (base64_values[in[i+2]] > -1)
- q_in |= base64_values[in[i+2]] << 6;
- if (base64_values[in[i+1]] > -1)
- q_in |= base64_values[in[i+1]] << 12;
- if (base64_values[in[i ]] > -1)
- q_in |= base64_values[in[i ]] << 18;
+ if (base64_values[in[i + 3]] > -1)
+ q_in |= base64_values[in[i + 3]];
+ if (base64_values[in[i + 2]] > -1)
+ q_in |= base64_values[in[i + 2]] << 6;
+ if (base64_values[in[i + 1]] > -1)
+ q_in |= base64_values[in[i + 1]] << 12;
+ if (base64_values[in[i]] > -1)
+ q_in |= base64_values[in[i]] << 18;
out[count++] = (q_in >> 16) & 0xff;
- out[count++] = (q_in >> 8) & 0xff;
- out[count++] = (q_in ) & 0xff;
+ out[count++] = (q_in >> 8) & 0xff;
+ out[count++] = (q_in) & 0xff;
}
- if (in[i-1] == '=') count--;
- if (in[i-2] == '=') count--;
+ if (in[i - 1] == '=')
+ count--;
+ if (in[i - 2] == '=')
+ count--;
out[count] = '\0';
*output = (char *)out;
return count;
}
-void id_reseed(char *in, int len)
+void
+id_reseed(char *in, int len)
{
int i;
- for (i=0; i<len; i++)
- databuf[i%(4*MD5_HASH_SIZE)] += in[i];
- md5_block(databuf_int, seed, seed);
+ for (i = 0; i < len; i++)
+ databuf[i % (4 * MD5_HASH_SIZE)] += in[i];
+ md5_block(databuf_int, seed, seed);
}
-char *id_get()
+char *
+id_get()
{
- static char id[ID_GEN_LEN+1];
+ static char id[ID_GEN_LEN + 1];
int i;
md5_block(databuf_int, seed, seed);
id[0] = '.';
- for (i=1; i<ID_GEN_LEN; i++)
+ for (i = 1; i < ID_GEN_LEN; i++)
id[i] = printable7[seed_char[i] & 127];
id[ID_GEN_LEN] = '\0';
return id;
}
-char *cookie_get()
+char *
+cookie_get()
{
- static char cookie[COOKIELEN+1];
+ static char cookie[COOKIELEN + 1];
int i;
databuf_int[0]++;
md5_block(databuf_int, seed, seed);
- for (i=0; i<COOKIELEN; i++)
+ for (i = 0; i < COOKIELEN; i++)
cookie[i] = printable6[seed_char[i] & 63];
cookie[COOKIELEN] = '\0';
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: memory.c,v 1.1 2002/01/04 09:14:18 a1kmm Exp $
+ * $Id: memory.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include <stdlib.h>
#include <string.h>
#define DATA(me) (void*)(((char*)me)+sizeof(MemoryEntry))
-void *memlog(void *d, int s, char *f, int l)
+void *
+memlog(void *d, int s, char *f, int l)
{
- MemoryEntry *mme;
- mme = (MemoryEntry *) d;
- d += sizeof(MemoryEntry);
- mme->next = first_mem_entry;
- mme->last = NULL;
- if (first_mem_entry != NULL)
- first_mem_entry->last = mme;
- first_mem_entry = mme;
- if (l > 0)
- mme->line = l;
- else
- *mme->file = 0;
- if (f != NULL)
- strncpy(mme->file, f,
- sizeof(mme->file) - 1)[sizeof(mme->file) - 1] = 0;
- else
- *mme->file = 0;
- mme->ts = CurrentTime;
- mme->size = s;
- return d;
+ MemoryEntry *mme;
+ mme = (MemoryEntry *) d;
+ d += sizeof(MemoryEntry);
+ mme->next = first_mem_entry;
+ mme->last = NULL;
+ if (first_mem_entry != NULL)
+ first_mem_entry->last = mme;
+ first_mem_entry = mme;
+ if (l > 0)
+ mme->line = l;
+ else
+ *mme->file = 0;
+ if (f != NULL)
+ strncpy(mme->file, f, sizeof(mme->file) - 1)[sizeof(mme->file) - 1] = 0;
+ else
+ *mme->file = 0;
+ mme->ts = CurrentTime;
+ mme->size = s;
+ return d;
}
-void memulog(void *m)
+void
+memulog(void *m)
{
- MemoryEntry *mme;
- m -= sizeof(MemoryEntry);
- mme = (MemoryEntry *) m;
- if (mme->last != NULL)
- mme->last->next = mme->next;
- if (mme->next != NULL)
- mme->next->last = mme->last;
- if (first_mem_entry == mme)
- first_mem_entry = mme->next;
+ MemoryEntry *mme;
+ m -= sizeof(MemoryEntry);
+ mme = (MemoryEntry *) m;
+ if (mme->last != NULL)
+ mme->last->next = mme->next;
+ if (mme->next != NULL)
+ mme->next->last = mme->last;
+ if (first_mem_entry == mme)
+ first_mem_entry = mme->next;
}
MemoryEntry *first_mem_entry = NULL;
-void *_MyMalloc(size_t size, char *file, int line)
+void *
+_MyMalloc(size_t size, char *file, int line)
{
- void *what = malloc(size + sizeof(MemoryEntry));
- if (what == NULL)
- outofmemory();
- memfrob(what, sizeof(MemoryEntry) + size);
- return memlog(what, size, file, line);
+ void *what = malloc(size + sizeof(MemoryEntry));
+ if (what == NULL)
+ outofmemory();
+ memfrob(what, sizeof(MemoryEntry) + size);
+ return memlog(what, size, file, line);
}
-void _MyFree(void *what, char *file, int line)
+void
+_MyFree(void *what, char *file, int line)
{
- if(what != NULL) {
- memulog(what);
- free(what - sizeof(MemoryEntry));
- }
+ if (what != NULL)
+ {
+ memulog(what);
+ free(what - sizeof(MemoryEntry));
+ }
}
-void *_MyRealloc(void *what, size_t size, char *file, int line)
+void *
+_MyRealloc(void *what, size_t size, char *file, int line)
{
- MemoryEntry *mme;
- if (!what)
- return _MyMalloc(size, file, line);
- if (!size) {
- _MyFree(what, file, line);
- return NULL;
- }
- mme = (MemoryEntry *) ((char *) what - sizeof(MemoryEntry));
- mme = realloc(mme, size + sizeof(MemoryEntry));
- mme->size = size;
- if (mme->next != NULL)
- mme->next->last = mme;
- if (mme->last != NULL)
- mme->last->next = mme;
- else
- first_mem_entry = mme;
- return DATA(mme);
+ MemoryEntry *mme;
+ if (!what)
+ return _MyMalloc(size, file, line);
+ if (!size)
+ {
+ _MyFree(what, file, line);
+ return NULL;
+ }
+ mme = (MemoryEntry *) ((char *)what - sizeof(MemoryEntry));
+ mme = realloc(mme, size + sizeof(MemoryEntry));
+ mme->size = size;
+ if (mme->next != NULL)
+ mme->next->last = mme;
+ if (mme->last != NULL)
+ mme->last->next = mme;
+ else
+ first_mem_entry = mme;
+ return DATA(mme);
}
-void _DupString(char **x, const char *y, char *file, int line)
+void
+_DupString(char **x, const char *y, char *file, int line)
{
- *x = _MyMalloc(strlen(y) + 1, file, line);
- strcpy(*x, y);
+ *x = _MyMalloc(strlen(y) + 1, file, line);
+ strcpy(*x, y);
}
void ReportAllocated(struct Client *);
-void ReportAllocated(struct Client *client_p)
+void
+ReportAllocated(struct Client *client_p)
{
- int i = 2000;
- MemoryEntry *mme;
- sendto_one(client_p, ":%s NOTICE %s :*** -- Memory Allocation Report",
- me.name, client_p->name);
- for (i = 0, mme = first_mem_entry; i < 1000 && mme;
- mme = mme->next, i++)
- sendto_one(client_p,
- ":%s NOTICE %s :*** -- %u bytes allocated for %lus at %s:%d",
- me.name, client_p->name, mme->size,
- CurrentTime - mme->ts, mme->file, mme->line);
+ int i = 2000;
+ MemoryEntry *mme;
+ sendto_one(client_p, ":%s NOTICE %s :*** -- Memory Allocation Report",
+ me.name, client_p->name);
+ for (i = 0, mme = first_mem_entry; i < 1000 && mme; mme = mme->next, i++)
sendto_one(client_p,
- ":%s NOTICE %s :*** -- End Memory Allocation Report",
- me.name, client_p->name);
+ ":%s NOTICE %s :*** -- %u bytes allocated for %lus at %s:%d",
+ me.name, client_p->name, mme->size,
+ CurrentTime - mme->ts, mme->file, mme->line);
+ sendto_one(client_p,
+ ":%s NOTICE %s :*** -- End Memory Allocation Report",
+ me.name, client_p->name);
}
-void log_memory(void)
+void
+log_memory(void)
{
- MemoryEntry *mme;
- int fd;
- char buffer[200];
- fd = open("memory.log", O_CREAT | O_WRONLY);
- for (mme = first_mem_entry; mme; mme = mme->next) {
- sprintf(buffer, "%u bytes allocated for %lus at %s:%d\n",
- mme->size, CurrentTime - mme->ts, mme->file, mme->line);
- write(fd, buffer, strlen(buffer));
- }
- close(fd);
+ MemoryEntry *mme;
+ int fd;
+ char buffer[200];
+ fd = open("memory.log", O_CREAT | O_WRONLY);
+ for (mme = first_mem_entry; mme; mme = mme->next)
+ {
+ sprintf(buffer, "%u bytes allocated for %lus at %s:%d\n",
+ mme->size, CurrentTime - mme->ts, mme->file, mme->line);
+ write(fd, buffer, strlen(buffer));
+ }
+ close(fd);
}
-#else /* MEMDEBUG */
+#else /* MEMDEBUG */
/*
* MyMalloc - allocate memory, call outofmemory on failure
*/
-void *_MyMalloc(size_t size)
+void *
+_MyMalloc(size_t size)
{
- void *ret = calloc(1, size);
- if (ret == NULL)
- outofmemory();
- return ret;
+ void *ret = calloc(1, size);
+ if (ret == NULL)
+ outofmemory();
+ return ret;
}
/*
* MyRealloc - reallocate memory, call outofmemory on failure
*/
-void *_MyRealloc(void *x, size_t y)
+void *
+_MyRealloc(void *x, size_t y)
{
- char *ret = realloc(x, y);
+ char *ret = realloc(x, y);
- if (!ret)
- outofmemory();
- return ret;
+ if (!ret)
+ outofmemory();
+ return ret;
}
-void _MyFree(void *x)
+void
+_MyFree(void *x)
{
- if(x)
- free((x));
+ if (x)
+ free((x));
}
-void _DupString(char **x, const char *y)
+void
+_DupString(char **x, const char *y)
{
- (*x) = MyMalloc(strlen(y) + 1);
- strcpy((*x), y);
+ (*x) = MyMalloc(strlen(y) + 1);
+ strcpy((*x), y);
}
-#endif /* !MEMDEBUG */
+#endif /* !MEMDEBUG */
/*
* outofmemory()
* output - NONE
* side effects - simply try to report there is a problem. Abort if it was called more than once
*/
-void outofmemory()
+void
+outofmemory()
{
- static int was_here = 0;
+ static int was_here = 0;
- if (was_here)
- abort();
+ if (was_here)
+ abort();
- was_here = 1;
+ was_here = 1;
- ilog(L_CRIT, "Out of memory: restarting server...");
+ ilog(L_CRIT, "Out of memory: restarting server...");
#ifdef MEMDEBUG
- log_memory();
+ log_memory();
#endif
- restart("Out of Memory");
+ restart("Out of Memory");
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: modules-dld.c,v 1.1 2002/01/04 09:14:21 a1kmm Exp $
+ * $Id: modules-dld.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*
* This is based on modules.c, but for OSes like HP-UX which use shl_open
* instead of dlopen
#include "list.h"
#ifndef RTLD_NOW
-#define RTLD_NOW RTLD_LAZY /* openbsd deficiency */
+#define RTLD_NOW RTLD_LAZY /* openbsd deficiency */
#endif
static char unknown_ver[] = "<unknown>";
struct module **modlist = NULL;
-static char *core_module_table[] =
-{
+static char *core_module_table[] = {
"m_die.so",
"m_kick.so",
"m_kill.so",
static dlink_list mod_paths;
-static void mo_modload(struct Client*, struct Client*, int, char**);
-static void mo_modlist(struct Client*, struct Client*, int, char**);
-static void mo_modreload(struct Client*, struct Client*, int, char**);
-static void mo_modunload(struct Client*, struct Client*, int, char**);
-static void mo_modrestart(struct Client*, struct Client*, int, char**);
+static void mo_modload(struct Client *, struct Client *, int, char **);
+static void mo_modlist(struct Client *, struct Client *, int, char **);
+static void mo_modreload(struct Client *, struct Client *, int, char **);
+static void mo_modunload(struct Client *, struct Client *, int, char **);
+static void mo_modrestart(struct Client *, struct Client *, int, char **);
struct Message modload_msgtab = {
- "MODLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
+ "MODLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_ignore, mo_modload}
};
struct Message modunload_msgtab = {
- "MODUNLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
+ "MODUNLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_ignore, mo_modunload}
};
};
struct Message modlist_msgtab = {
- "MODLIST", 0, 0, 0, 0, MFLG_SLOW, 0,
+ "MODLIST", 0, 0, 0, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_ignore, mo_modlist}
};
struct Message modrestart_msgtab = {
- "MODRESTART", 0, 0, 0, 0, MFLG_SLOW, 0,
- {m_unregistered, m_not_oper, m_ignore, mo_modrestart}
+ "MODRESTART", 0, 0, 0, 0, MFLG_SLOW, 0,
+ {m_unregistered, m_not_oper, m_ignore, mo_modrestart}
};
void
modules_init(void)
{
- mod_add_cmd(&modload_msgtab);
- mod_add_cmd(&modunload_msgtab);
- mod_add_cmd(&modreload_msgtab);
- mod_add_cmd(&modlist_msgtab);
- mod_add_cmd(&modrestart_msgtab);
+ mod_add_cmd(&modload_msgtab);
+ mod_add_cmd(&modunload_msgtab);
+ mod_add_cmd(&modreload_msgtab);
+ mod_add_cmd(&modlist_msgtab);
+ mod_add_cmd(&modrestart_msgtab);
}
static struct module_path *
{
dlink_node *pathst = mod_paths.head;
struct module_path *mpath;
-
+
if (!pathst)
return NULL;
- for (; pathst; pathst = pathst->next) {
- mpath = (struct module_path *)pathst->data;
-
- if (!strcmp(path, mpath->path))
- return mpath;
+ for (; pathst; pathst = pathst->next)
+ {
+ mpath = (struct module_path *)pathst->data;
+
+ if (!strcmp(path, mpath->path))
+ return mpath;
}
-
+
return NULL;
}
{
struct module_path *pathst;
dlink_node *node;
-
+
if (mod_find_path(path))
return;
- pathst = MyMalloc (sizeof (struct module_path));
+ pathst = MyMalloc(sizeof(struct module_path));
node = make_dlink_node();
-
+
strcpy(pathst->path, path);
dlinkAdd(pathst, node, &mod_paths);
}
char *
irc_basename(char *path)
{
- char *mod_basename = MyMalloc (strlen (path) + 1);
+ char *mod_basename = MyMalloc(strlen(path) + 1);
char *s;
- if (!(s = strrchr (path, '/')))
+ if (!(s = strrchr(path, '/')))
s = path;
else
s++;
- (void)strcpy (mod_basename, s);
+ (void)strcpy(mod_basename, s);
return mod_basename;
}
-int
-findmodule_byname (char *name)
+int
+findmodule_byname(char *name)
{
int i;
- for (i = 0; i < num_mods; i++)
+ for (i = 0; i < num_mods; i++)
{
- if (!irccmp (modlist[i]->name, name))
+ if (!irccmp(modlist[i]->name, name))
return i;
}
return -1;
* output - 0 if successful, -1 if error
* side effects - module is unloaded
*/
-int unload_one_module (char *name, int warn)
+int
+unload_one_module(char *name, int warn)
{
int modindex;
- void (*deinitfunc)(void) = NULL;
+ void (*deinitfunc) (void) = NULL;
- if ((modindex = findmodule_byname (name)) == -1)
+ if ((modindex = findmodule_byname(name)) == -1)
return -1;
- if(shl_findsym(modlist[modindex]->address, "_moddeinit", TYPE_UNDEFINED, &deinitfunc) == 0)
- deinitfunc ();
+ if (shl_findsym
+ (modlist[modindex]->address, "_moddeinit", TYPE_UNDEFINED,
+ &deinitfunc) == 0)
+ deinitfunc();
else
- if(shl_findsym(modlist[modindex]->address, "__moddeinit", TYPE_UNDEFINED. &deinitfunc) == 0)
- deinitfunc ();
+ if (shl_findsym
+ (modlist[modindex]->address, "__moddeinit",
+ TYPE_UNDEFINED. & deinitfunc) == 0)
+ deinitfunc();
shl_unload(modlist[modindex]->address);
MyFree(modlist[modindex]->name);
- memcpy( &modlist[modindex], &modlist[modindex+1],
- sizeof(struct module) * ((num_mods-1) - modindex) );
+ memcpy(&modlist[modindex], &modlist[modindex + 1],
+ sizeof(struct module) * ((num_mods - 1) - modindex));
- if(num_mods != 0)
+ if (num_mods != 0)
num_mods--;
- if(warn == 1)
- {
- ilog (L_INFO, "Module %s unloaded", name);
- sendto_realops_flags(FLAGS_ALL, L_ALL,"Module %s unloaded", name);
- }
+ if (warn == 1)
+ {
+ ilog(L_INFO, "Module %s unloaded", name);
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Module %s unloaded", name);
+ }
return 0;
}
/* load all modules from MPATH */
void
-load_all_modules (int warn)
+load_all_modules(int warn)
{
- DIR *system_module_dir = NULL;
- struct dirent *ldirent = NULL;
- char module_fq_name[PATH_MAX + 1];
+ DIR *system_module_dir = NULL;
+ struct dirent *ldirent = NULL;
+ char module_fq_name[PATH_MAX + 1];
modules_init();
-
- modlist = (struct module **)MyMalloc ( sizeof (struct module) *
- (MODS_INCREMENT));
+
+ modlist = (struct module **)MyMalloc(sizeof(struct module) *
+ (MODS_INCREMENT));
max_mods = MODS_INCREMENT;
- system_module_dir = opendir (AUTOMODPATH);
+ system_module_dir = opendir(AUTOMODPATH);
if (system_module_dir == NULL)
{
- ilog (L_WARN, "Could not load modules from %s: %s",
- AUTOMODPATH, strerror (errno));
+ ilog(L_WARN, "Could not load modules from %s: %s",
+ AUTOMODPATH, strerror(errno));
return;
}
- while ((ldirent = readdir (system_module_dir)) != NULL)
+ while ((ldirent = readdir(system_module_dir)) != NULL)
{
- if (ldirent->d_name [strlen (ldirent->d_name) - 3] == '.' &&
- ldirent->d_name [strlen (ldirent->d_name) - 2] == 's' &&
- ldirent->d_name [strlen (ldirent->d_name) - 1] == 'o')
+ if (ldirent->d_name[strlen(ldirent->d_name) - 3] == '.' &&
+ ldirent->d_name[strlen(ldirent->d_name) - 2] == 's' &&
+ ldirent->d_name[strlen(ldirent->d_name) - 1] == 'o')
{
- (void)sprintf (module_fq_name, "%s/%s", AUTOMODPATH,
- ldirent->d_name);
- (void)load_a_module (module_fq_name, warn, 0);
+ (void)sprintf(module_fq_name, "%s/%s", AUTOMODPATH, ldirent->d_name);
+ (void)load_a_module(module_fq_name, warn, 0);
}
}
- (void)closedir (system_module_dir);
+ (void)closedir(system_module_dir);
}
void
char module_name[MAXPATHLEN];
int i;
- for(i = 0; core_module_table[i]; i++)
+ for (i = 0; core_module_table[i]; i++)
{
- sprintf(module_name, "%s/%s",
- MODPATH, core_module_table[i]);
+ sprintf(module_name, "%s/%s", MODPATH, core_module_table[i]);
- if(load_a_module(module_name, warn, 1) == -1)
+ if (load_a_module(module_name, warn, 1) == -1)
{
ilog(L_CRIT, "Error loading core module %s: terminating ircd",
core_module_table[i]);
}
int
-load_one_module (char *path)
+load_one_module(char *path)
{
- char modpath[MAXPATHLEN];
- dlink_node *pathst;
- struct module_path *mpath;
-
- struct stat statbuf;
-
- if (strchr(path, '/')) /* absolute path, try it */
- return load_a_module(path, 1, 0);
-
- for (pathst = mod_paths.head; pathst; pathst = pathst->next)
- {
- mpath = (struct module_path *)pathst->data;
-
- sprintf(modpath, "%s/%s", mpath->path, path);
- if (stat(modpath, &statbuf) == 0)
- return load_a_module(modpath, 1, 0);
- }
-
- sendto_realops_flags (FLAGS_ALL, "Cannot locate module %s", path);
- ilog(L_WARN, "Cannot locate module %s", path);
- return -1;
+ char modpath[MAXPATHLEN];
+ dlink_node *pathst;
+ struct module_path *mpath;
+
+ struct stat statbuf;
+
+ if (strchr(path, '/')) /* absolute path, try it */
+ return load_a_module(path, 1, 0);
+
+ for (pathst = mod_paths.head; pathst; pathst = pathst->next)
+ {
+ mpath = (struct module_path *)pathst->data;
+
+ sprintf(modpath, "%s/%s", mpath->path, path);
+ if (stat(modpath, &statbuf) == 0)
+ return load_a_module(modpath, 1, 0);
+ }
+
+ sendto_realops_flags(FLAGS_ALL, "Cannot locate module %s", path);
+ ilog(L_WARN, "Cannot locate module %s", path);
+ return -1;
}
-
+
/*
* load_a_module
* side effects - loads a module if successful
*/
int
-load_a_module (char *path, int warn, int core)
+load_a_module(char *path, int warn, int core)
{
void *tmpptr = NULL;
char *mod_basename;
- void (*initfunc)(void) = NULL;
+ void (*initfunc) (void) = NULL;
char **verp;
char *ver;
mod_basename = irc_basename(path);
tmpptr = shl_load(path, BIND_IMMEDIATE);
- tmpptr = dlopen (path, RTLD_NOW);
+ tmpptr = dlopen(path, RTLD_NOW);
if (tmpptr == NULL)
{
- const char *err = strerror(errno);
-
- sendto_realops_flags (FLAGS_ALL,
- "Error loading module %s: %s",
- mod_basename, err);
- ilog (L_WARN, "Error loading module %s: %s", mod_basename, err);
- MyFree (mod_basename);
- return -1;
+ const char *err = strerror(errno);
+
+ sendto_realops_flags(FLAGS_ALL,
+ "Error loading module %s: %s", mod_basename, err);
+ ilog(L_WARN, "Error loading module %s: %s", mod_basename, err);
+ MyFree(mod_basename);
+ return -1;
}
- if(shl_findsym (tmpptr, "_modinit", TYPE_UNDEFINED, &initfunc) == -1)
+ if (shl_findsym(tmpptr, "_modinit", TYPE_UNDEFINED, &initfunc) == -1)
{
- if(shl_findsym(tmpptr, "__modinit", TYPE_UNDEFINE, &initfunc) == -1)
+ if (shl_findsym(tmpptr, "__modinit", TYPE_UNDEFINE, &initfunc) == -1)
{
- sendto_realops_flags (FLAGS_ALL,
- "Module %s has no _modinit() function",
- mod_basename);
- ilog (L_WARN, "Module %s has no _modinit() function", mod_basename);
- shl_unload (tmpptr);
- MyFree (mod_basename);
- return -1;
+ sendto_realops_flags(FLAGS_ALL,
+ "Module %s has no _modinit() function",
+ mod_basename);
+ ilog(L_WARN, "Module %s has no _modinit() function", mod_basename);
+ shl_unload(tmpptr);
+ MyFree(mod_basename);
+ return -1;
}
}
- if(shl_findsym(tmpptr, "_version", TYPE_UNDEFINED, &verp) == -1)
+ if (shl_findsym(tmpptr, "_version", TYPE_UNDEFINED, &verp) == -1)
{
- if(shl_findsym(tmpptr, "__version", TYPE_UNDEFINED, &verp) == -1)
- ver = unknown_ver;
+ if (shl_findsym(tmpptr, "__version", TYPE_UNDEFINED, &verp) == -1)
+ ver = unknown_ver;
else
- ver = verp;
- } else
+ ver = verp;
+ }
+ else
ver = *verp;
increase_modlist();
- modlist [num_mods] = MyMalloc (sizeof (struct module));
- modlist [num_mods]->address = tmpptr;
- modlist [num_mods]->version = ver;
+ modlist[num_mods] = MyMalloc(sizeof(struct module));
+ modlist[num_mods]->address = tmpptr;
+ modlist[num_mods]->version = ver;
modlist[num_mods]->core = core;
- DupString(modlist [num_mods]->name, mod_basename );
+ DupString(modlist[num_mods]->name, mod_basename);
num_mods++;
- initfunc ();
+ initfunc();
- if(warn == 1)
- {
- sendto_realops_flags (FLAGS_ALL, "Module %s [version: %s] loaded at 0x%lx",
- mod_basename, ver, (unsigned long)tmpptr);
- ilog (L_WARN, "Module %s [version: %s] loaded at 0x%x",
- mod_basename, ver, tmpptr);
- }
- MyFree (mod_basename);
+ if (warn == 1)
+ {
+ sendto_realops_flags(FLAGS_ALL, "Module %s [version: %s] loaded at 0x%lx",
+ mod_basename, ver, (unsigned long)tmpptr);
+ ilog(L_WARN, "Module %s [version: %s] loaded at 0x%x",
+ mod_basename, ver, tmpptr);
+ }
+ MyFree(mod_basename);
return 0;
}
* output - NONE
* side effects - expand the size of modlist if necessary
*/
-static void increase_modlist(void)
+static void
+increase_modlist(void)
{
struct module **new_modlist = NULL;
- if((num_mods + 1) < max_mods)
+ if ((num_mods + 1) < max_mods)
return;
- new_modlist = (struct module **)MyMalloc ( sizeof (struct module) *
- (max_mods + MODS_INCREMENT));
+ new_modlist = (struct module **)MyMalloc(sizeof(struct module) *
+ (max_mods + MODS_INCREMENT));
memcpy((void *)new_modlist,
(void *)modlist, sizeof(struct module) * num_mods);
/* load a module .. */
static void
-mo_modload (struct Client *client_p, struct Client *source_p, int parc, char **parv)
+mo_modload(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
char *m_bn;
if (!IsOperAdmin(source_p))
{
- sendto_one(source_p, ":%s NOTICE %s :You have no A flag", me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag", me.name,
+ parv[0]);
return;
}
- m_bn = irc_basename (parv[1]);
+ m_bn = irc_basename(parv[1]);
- if (findmodule_byname (m_bn) != -1)
+ if (findmodule_byname(m_bn) != -1)
{
- sendto_one (source_p, ":%s NOTICE %s :Module %s is already loaded",
- me.name, source_p->name, m_bn);
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is already loaded",
+ me.name, source_p->name, m_bn);
return;
}
- load_one_module (parv[1]);
+ load_one_module(parv[1]);
MyFree(m_bn);
}
/* unload a module .. */
static void
-mo_modunload (struct Client *client_p, struct Client *source_p, int parc, char **parv)
+mo_modunload(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
char *m_bn;
int modindex;
- if (!IsOperAdmin (source_p))
+ if (!IsOperAdmin(source_p))
{
- sendto_one (source_p, ":%s NOTICE %s :You have no A flag",
- me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag",
+ me.name, parv[0]);
return;
}
- m_bn = irc_basename (parv[1]);
+ m_bn = irc_basename(parv[1]);
- if((modindex = findmodule_byname (m_bn)) == -1)
+ if ((modindex = findmodule_byname(m_bn)) == -1)
{
- sendto_one (source_p, ":%s NOTICE %s :Module %s is not loaded",
- me.name, source_p->name, m_bn);
- MyFree (m_bn);
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
+ me.name, source_p->name, m_bn);
+ MyFree(m_bn);
return;
}
- if(modlist[modindex]->core == 1)
+ if (modlist[modindex]->core == 1)
{
sendto_one(source_p,
":%s NOTICE %s :Module %s is a core module and may not be unloaded",
- me.name, source_p->name, m_bn);
+ me.name, source_p->name, m_bn);
MyFree(m_bn);
return;
}
- if( unload_one_module (m_bn, 1) == -1 )
+ if (unload_one_module(m_bn, 1) == -1)
{
- sendto_one (source_p, ":%s NOTICE %s :Module %s is not loaded",
- me.name, source_p->name, m_bn);
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
+ me.name, source_p->name, m_bn);
}
- MyFree (m_bn);
+ MyFree(m_bn);
}
/* unload and load in one! */
static void
-mo_modreload (struct Client *client_p, struct Client *source_p, int parc, char **parv)
+mo_modreload(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
char *m_bn;
int modindex;
int check_core;
- if (!IsOperAdmin (source_p))
- {
- sendto_one (source_p, ":%s NOTICE %s :You have no A flag",
- me.name, parv[0]);
- return;
- }
+ if (!IsOperAdmin(source_p))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag",
+ me.name, parv[0]);
+ return;
+ }
- m_bn = irc_basename (parv[1]);
+ m_bn = irc_basename(parv[1]);
- if((modindex = findmodule_byname (m_bn)) == -1)
- {
- sendto_one (source_p, ":%s NOTICE %s :Module %s is not loaded",
- me.name, source_p->name, m_bn);
- MyFree (m_bn);
- return;
- }
+ if ((modindex = findmodule_byname(m_bn)) == -1)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
+ me.name, source_p->name, m_bn);
+ MyFree(m_bn);
+ return;
+ }
check_core = modlist[modindex]->core;
-
- if( unload_one_module (m_bn, 1) == -1 )
- {
- sendto_one (source_p, ":%s NOTICE %s :Module %s is not loaded",
- me.name, source_p->name, m_bn);
- MyFree (m_bn);
- return;
- }
- if((load_one_module(parv[1]) == -1) && check_core)
+ if (unload_one_module(m_bn, 1) == -1)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
+ me.name, source_p->name, m_bn);
+ MyFree(m_bn);
+ return;
+ }
+
+ if ((load_one_module(parv[1]) == -1) && check_core)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
"Error reloading core module: %s: terminating ircd",
- parv[1]);
+ parv[1]);
ilog(L_CRIT, "Error loading core module %s: terminating ircd", parv[1]);
exit(0);
}
/* list modules .. */
static void
-mo_modlist (struct Client *client_p, struct Client *source_p, int parc, char **parv)
+mo_modlist(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
int i;
- if (!IsOperAdmin (source_p))
+ if (!IsOperAdmin(source_p))
{
- sendto_one (source_p, ":%s NOTICE %s :You have no A flag",
- me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag",
+ me.name, parv[0]);
return;
}
- for(i = 0; i < num_mods; i++ )
+ for (i = 0; i < num_mods; i++)
{
- if(parc > 1)
+ if (parc > 1)
{
- if(match(parv[1],modlist[i]->name))
+ if (match(parv[1], modlist[i]->name))
{
sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0],
modlist[i]->name, modlist[i]->address,
else
{
sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0],
- modlist[i]->name, modlist[i]->address,
- modlist[i]->version);
+ modlist[i]->name, modlist[i]->address, modlist[i]->version);
}
}
-
+
sendto_one(source_p, form_str(RPL_ENDOFMODLIST), me.name, parv[0]);
}
/* unload and reload all modules */
static void
-mo_modrestart (struct Client *client_p, struct Client *source_p, int parc, char **parv)
-
+mo_modrestart(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
int modnum;
- if (!IsOperAdmin (source_p))
+ if (!IsOperAdmin(source_p))
{
- sendto_one (source_p, ":%s NOTICE %s :You have no A flag",
- me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag",
+ me.name, parv[0]);
return;
}
modnum = num_mods;
while (num_mods)
- unload_one_module(modlist[0]->name, 0);
+ unload_one_module(modlist[0]->name, 0);
load_all_modules(0);
load_core_modules(0);
rehash(0);
- sendto_realops_flags (FLAGS_ALL, "Module Restart: %d modules unloaded, %d modules loaded",
- modnum, num_mods);
+ sendto_realops_flags(FLAGS_ALL,
+ "Module Restart: %d modules unloaded, %d modules loaded",
+ modnum, num_mods);
ilog(L_WARN, "Module Restart: %d modules unloaded, %d modules loaded",
- modnum, num_mods);
+ modnum, num_mods);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: modules.c,v 1.1 2002/01/04 09:14:21 a1kmm Exp $
+ * $Id: modules.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include "config.h"
#ifndef STATIC_MODULES
#ifndef RTLD_NOW
-#define RTLD_NOW RTLD_LAZY /* openbsd deficiency */
+#define RTLD_NOW RTLD_LAZY /* openbsd deficiency */
#endif
static char unknown_ver[] = "<unknown>";
struct module **modlist = NULL;
-static char *core_module_table[] =
-{
+static char *core_module_table[] = {
"m_die.so",
"m_kick.so",
"m_kill.so",
static dlink_list mod_paths;
-static void mo_modload(struct Client*, struct Client*, int, char**);
-static void mo_modlist(struct Client*, struct Client*, int, char**);
-static void mo_modreload(struct Client*, struct Client*, int, char**);
-static void mo_modunload(struct Client*, struct Client*, int, char**);
-static void mo_modrestart(struct Client*, struct Client*, int, char**);
+static void mo_modload(struct Client *, struct Client *, int, char **);
+static void mo_modlist(struct Client *, struct Client *, int, char **);
+static void mo_modreload(struct Client *, struct Client *, int, char **);
+static void mo_modunload(struct Client *, struct Client *, int, char **);
+static void mo_modrestart(struct Client *, struct Client *, int, char **);
struct Message modload_msgtab = {
- "MODLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
+ "MODLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_ignore, mo_modload}
};
struct Message modunload_msgtab = {
- "MODUNLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
+ "MODUNLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_ignore, mo_modunload}
};
};
struct Message modlist_msgtab = {
- "MODLIST", 0, 0, 0, 0, MFLG_SLOW, 0,
+ "MODLIST", 0, 0, 0, 0, MFLG_SLOW, 0,
{m_unregistered, m_not_oper, m_ignore, mo_modlist}
};
struct Message modrestart_msgtab = {
- "MODRESTART", 0, 0, 0, 0, MFLG_SLOW, 0,
- {m_unregistered, m_not_oper, m_ignore, mo_modrestart}
+ "MODRESTART", 0, 0, 0, 0, MFLG_SLOW, 0,
+ {m_unregistered, m_not_oper, m_ignore, mo_modrestart}
};
extern struct Message error_msgtab;
void
modules_init(void)
{
- mod_add_cmd(&modload_msgtab);
- mod_add_cmd(&modunload_msgtab);
- mod_add_cmd(&modreload_msgtab);
- mod_add_cmd(&modlist_msgtab);
- mod_add_cmd(&modrestart_msgtab);
- mod_add_cmd(&error_msgtab);
+ mod_add_cmd(&modload_msgtab);
+ mod_add_cmd(&modunload_msgtab);
+ mod_add_cmd(&modreload_msgtab);
+ mod_add_cmd(&modlist_msgtab);
+ mod_add_cmd(&modrestart_msgtab);
+ mod_add_cmd(&error_msgtab);
}
/* mod_find_path()
{
dlink_node *pathst = mod_paths.head;
struct module_path *mpath;
-
+
if (!pathst)
return NULL;
- for (; pathst; pathst = pathst->next) {
- mpath = (struct module_path *)pathst->data;
-
- if (!strcmp(path, mpath->path))
- return mpath;
+ for (; pathst; pathst = pathst->next)
+ {
+ mpath = (struct module_path *)pathst->data;
+
+ if (!strcmp(path, mpath->path))
+ return mpath;
}
-
+
return NULL;
}
{
struct module_path *pathst;
dlink_node *node;
-
+
if (mod_find_path(path))
return;
- pathst = MyMalloc (sizeof (struct module_path));
+ pathst = MyMalloc(sizeof(struct module_path));
node = make_dlink_node();
-
+
strcpy(pathst->path, path);
dlinkAdd(pathst, node, &mod_paths);
}
struct module_path *pathst;
dlink_node *node, *next;
- for(node = mod_paths.head; node; node = next)
- {
- next = node->next;
- pathst = (struct module_path *)node->data;
- dlinkDelete(node, &mod_paths);
- free_dlink_node(node);
- MyFree(pathst);
- }
+ for (node = mod_paths.head; node; node = next)
+ {
+ next = node->next;
+ pathst = (struct module_path *)node->data;
+ dlinkDelete(node, &mod_paths);
+ free_dlink_node(node);
+ MyFree(pathst);
+ }
}
/* irc_basename
char *
irc_basename(char *path)
{
- char *mod_basename = MyMalloc (strlen (path) + 1);
+ char *mod_basename = MyMalloc(strlen(path) + 1);
char *s;
- if (!(s = strrchr (path, '/')))
+ if (!(s = strrchr(path, '/')))
s = path;
else
s++;
- (void)strcpy (mod_basename, s);
+ (void)strcpy(mod_basename, s);
return mod_basename;
}
* side effects -
*/
-int
-findmodule_byname (char *name)
+int
+findmodule_byname(char *name)
{
int i;
- for (i = 0; i < num_mods; i++)
- {
- if (!irccmp (modlist[i]->name, name))
- return i;
- }
+ for (i = 0; i < num_mods; i++)
+ {
+ if (!irccmp(modlist[i]->name, name))
+ return i;
+ }
return -1;
}
* output - 0 if successful, -1 if error
* side effects - module is unloaded
*/
-int unload_one_module (char *name, int warn)
+int
+unload_one_module(char *name, int warn)
{
int modindex;
- void (*deinitfunc)(void) = NULL;
+ void (*deinitfunc) (void) = NULL;
- if ((modindex = findmodule_byname (name)) == -1)
+ if ((modindex = findmodule_byname(name)) == -1)
return -1;
- if( (deinitfunc = (void (*)(void))dlsym (modlist[modindex]->address,
- "_moddeinit"))
- || (deinitfunc = (void (*)(void))dlsym (modlist[modindex]->address,
- "__moddeinit")))
+ if ((deinitfunc = (void (*)(void))dlsym(modlist[modindex]->address,
+ "_moddeinit"))
+ || (deinitfunc = (void (*)(void))dlsym(modlist[modindex]->address,
+ "__moddeinit")))
{
- deinitfunc ();
+ deinitfunc();
}
dlclose(modlist[modindex]->address);
MyFree(modlist[modindex]->name);
- memcpy( &modlist[modindex], &modlist[modindex+1],
- sizeof(struct module) * ((num_mods-1) - modindex) );
+ memcpy(&modlist[modindex], &modlist[modindex + 1],
+ sizeof(struct module) * ((num_mods - 1) - modindex));
- if(num_mods != 0)
+ if (num_mods != 0)
num_mods--;
- if(warn == 1)
- {
- ilog (L_INFO, "Module %s unloaded", name);
- sendto_realops_flags(FLAGS_ALL, L_ALL,"Module %s unloaded", name);
- }
+ if (warn == 1)
+ {
+ ilog(L_INFO, "Module %s unloaded", name);
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Module %s unloaded", name);
+ }
return 0;
}
* side effects -
*/
void
-load_all_modules (int warn)
+load_all_modules(int warn)
{
- DIR *system_module_dir = NULL;
- struct dirent *ldirent = NULL;
- char module_fq_name[PATH_MAX + 1];
- int len;
+ DIR *system_module_dir = NULL;
+ struct dirent *ldirent = NULL;
+ char module_fq_name[PATH_MAX + 1];
+ int len;
modules_init();
-
- modlist = (struct module **)MyMalloc ( sizeof (struct module) *
- (MODS_INCREMENT));
+
+ modlist = (struct module **)MyMalloc(sizeof(struct module) *
+ (MODS_INCREMENT));
max_mods = MODS_INCREMENT;
- system_module_dir = opendir (AUTOMODPATH);
+ system_module_dir = opendir(AUTOMODPATH);
if (system_module_dir == NULL)
- {
- ilog (L_WARN, "Could not load modules from %s: %s",
- AUTOMODPATH, strerror (errno));
- return;
- }
+ {
+ ilog(L_WARN, "Could not load modules from %s: %s",
+ AUTOMODPATH, strerror(errno));
+ return;
+ }
- while ((ldirent = readdir (system_module_dir)) != NULL)
+ while ((ldirent = readdir(system_module_dir)) != NULL)
+ {
+ len = strlen(ldirent->d_name);
+
+ if ((len > 3) &&
+ (ldirent->d_name[len - 3] == '.') &&
+ (ldirent->d_name[len - 2] == 's') &&
+ (ldirent->d_name[len - 1] == 'o'))
{
- len = strlen(ldirent->d_name);
-
- if ((len > 3) &&
- (ldirent->d_name[len-3] == '.') &&
- (ldirent->d_name[len-2] == 's') &&
- (ldirent->d_name[len-1] == 'o'))
- {
- (void)sprintf (module_fq_name, "%s/%s", AUTOMODPATH,
- ldirent->d_name);
- (void)load_a_module (module_fq_name, warn, 0);
- }
+ (void)sprintf(module_fq_name, "%s/%s", AUTOMODPATH, ldirent->d_name);
+ (void)load_a_module(module_fq_name, warn, 0);
}
+ }
- (void)closedir (system_module_dir);
+ (void)closedir(system_module_dir);
}
/* load_core_modules()
char module_name[MAXPATHLEN];
int i;
- for(i = 0; core_module_table[i]; i++)
+ for (i = 0; core_module_table[i]; i++)
{
- sprintf(module_name, "%s/core/%s",
- MODPATH, core_module_table[i]);
-
- if(load_a_module(module_name, warn, 1) == -1)
+ sprintf(module_name, "%s/core/%s", MODPATH, core_module_table[i]);
+
+ if (load_a_module(module_name, warn, 1) == -1)
{
- ilog(L_CRIT, "Error loading core module %s: terminating ircd",
+ ilog(L_CRIT, "Error loading core module %s: terminating ircd",
core_module_table[i]);
exit(0);
}
* side effects -
*/
int
-load_one_module (char *path)
+load_one_module(char *path)
{
char modpath[MAXPATHLEN];
dlink_node *pathst;
struct module_path *mpath;
-
+
struct stat statbuf;
- if (strchr(path, '/')) /* absolute path, try it */
+ if (strchr(path, '/')) /* absolute path, try it */
return load_a_module(path, 1, 0);
for (pathst = mod_paths.head; pathst; pathst = pathst->next)
- {
- mpath = (struct module_path *)pathst->data;
-
- sprintf(modpath, "%s/%s", mpath->path, path);
- if (stat(modpath, &statbuf) == 0)
- return load_a_module(modpath, 1, 0);
- }
-
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Cannot locate module %s", path);
+ {
+ mpath = (struct module_path *)pathst->data;
+
+ sprintf(modpath, "%s/%s", mpath->path, path);
+ if (stat(modpath, &statbuf) == 0)
+ return load_a_module(modpath, 1, 0);
+ }
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Cannot locate module %s", path);
ilog(L_WARN, "Cannot locate module %s", path);
return -1;
}
-
+
/*
* load_a_module()
* side effects - loads a module if successful
*/
int
-load_a_module (char *path, int warn, int core)
+load_a_module(char *path, int warn, int core)
{
void *tmpptr = NULL;
char *mod_basename;
- void (*initfunc)(void) = NULL;
+ void (*initfunc) (void) = NULL;
char **verp;
char *ver;
mod_basename = irc_basename(path);
- tmpptr = dlopen (path, RTLD_NOW);
+ tmpptr = dlopen(path, RTLD_NOW);
if (tmpptr == NULL)
{
- const char *err = dlerror();
-
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Error loading module %s: %s",
- mod_basename, err);
- ilog (L_WARN, "Error loading module %s: %s", mod_basename, err);
- MyFree (mod_basename);
- return -1;
+ const char *err = dlerror();
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Error loading module %s: %s", mod_basename, err);
+ ilog(L_WARN, "Error loading module %s: %s", mod_basename, err);
+ MyFree(mod_basename);
+ return -1;
}
- initfunc = (void (*)(void))dlsym (tmpptr, "_modinit");
- if (initfunc == NULL
- && (initfunc = (void (*)(void))dlsym(tmpptr, "__modinit")) == NULL)
+ initfunc = (void (*)(void))dlsym(tmpptr, "_modinit");
+ if (initfunc == NULL
+ && (initfunc = (void (*)(void))dlsym(tmpptr, "__modinit")) == NULL)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Module %s has no _modinit() function",
- mod_basename);
- ilog (L_WARN, "Module %s has no _modinit() function", mod_basename);
- (void)dlclose (tmpptr);
- MyFree (mod_basename);
+ "Module %s has no _modinit() function",
+ mod_basename);
+ ilog(L_WARN, "Module %s has no _modinit() function", mod_basename);
+ (void)dlclose(tmpptr);
+ MyFree(mod_basename);
return -1;
}
- verp = (char **)dlsym (tmpptr, "_version");
- if (verp == NULL
- && (verp = (char **)dlsym (tmpptr, "__version")) == NULL)
+ verp = (char **)dlsym(tmpptr, "_version");
+ if (verp == NULL && (verp = (char **)dlsym(tmpptr, "__version")) == NULL)
ver = unknown_ver;
else
ver = *verp;
increase_modlist();
- modlist [num_mods] = MyMalloc (sizeof (struct module));
- modlist [num_mods]->address = tmpptr;
- modlist [num_mods]->version = ver;
+ modlist[num_mods] = MyMalloc(sizeof(struct module));
+ modlist[num_mods]->address = tmpptr;
+ modlist[num_mods]->version = ver;
modlist[num_mods]->core = core;
- DupString(modlist [num_mods]->name, mod_basename );
+ DupString(modlist[num_mods]->name, mod_basename);
num_mods++;
- initfunc ();
+ initfunc();
- if(warn == 1)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Module %s [version: %s] loaded at 0x%lx",
- mod_basename, ver, (unsigned long)tmpptr);
- ilog (L_WARN, "Module %s [version: %s] loaded at 0x%x",
- mod_basename, ver, tmpptr);
- }
- MyFree (mod_basename);
+ if (warn == 1)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Module %s [version: %s] loaded at 0x%lx",
+ mod_basename, ver, (unsigned long)tmpptr);
+ ilog(L_WARN, "Module %s [version: %s] loaded at 0x%x",
+ mod_basename, ver, tmpptr);
+ }
+ MyFree(mod_basename);
return 0;
}
* output - NONE
* side effects - expand the size of modlist if necessary
*/
-static void increase_modlist(void)
+static void
+increase_modlist(void)
{
struct module **new_modlist = NULL;
- if((num_mods + 1) < max_mods)
+ if ((num_mods + 1) < max_mods)
return;
- new_modlist = (struct module **)MyMalloc ( sizeof (struct module) *
- (max_mods + MODS_INCREMENT));
+ new_modlist = (struct module **)MyMalloc(sizeof(struct module) *
+ (max_mods + MODS_INCREMENT));
memcpy((void *)new_modlist,
(void *)modlist, sizeof(struct module) * num_mods);
/* load a module .. */
static void
-mo_modload (struct Client *client_p, struct Client *source_p, int parc, char **parv)
+mo_modload(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
char *m_bn;
if (!IsOperAdmin(source_p))
{
- sendto_one(source_p, ":%s NOTICE %s :You have no A flag", me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag", me.name,
+ parv[0]);
return;
}
- m_bn = irc_basename (parv[1]);
+ m_bn = irc_basename(parv[1]);
- if (findmodule_byname (m_bn) != -1)
+ if (findmodule_byname(m_bn) != -1)
{
- sendto_one (source_p, ":%s NOTICE %s :Module %s is already loaded",
- me.name, source_p->name, m_bn);
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is already loaded",
+ me.name, source_p->name, m_bn);
return;
}
- load_one_module (parv[1]);
+ load_one_module(parv[1]);
MyFree(m_bn);
}
/* unload a module .. */
static void
-mo_modunload (struct Client *client_p, struct Client *source_p, int parc, char **parv)
+mo_modunload(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
char *m_bn;
int modindex;
- if (!IsOperAdmin (source_p))
+ if (!IsOperAdmin(source_p))
{
- sendto_one (source_p, ":%s NOTICE %s :You have no A flag",
- me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag",
+ me.name, parv[0]);
return;
}
- m_bn = irc_basename (parv[1]);
+ m_bn = irc_basename(parv[1]);
- if((modindex = findmodule_byname (m_bn)) == -1)
+ if ((modindex = findmodule_byname(m_bn)) == -1)
{
- sendto_one (source_p, ":%s NOTICE %s :Module %s is not loaded",
- me.name, source_p->name, m_bn);
- MyFree (m_bn);
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
+ me.name, source_p->name, m_bn);
+ MyFree(m_bn);
return;
}
- if(modlist[modindex]->core == 1)
+ if (modlist[modindex]->core == 1)
{
- sendto_one(source_p,
+ sendto_one(source_p,
":%s NOTICE %s :Module %s is a core module and may not be unloaded",
- me.name, source_p->name, m_bn);
+ me.name, source_p->name, m_bn);
MyFree(m_bn);
return;
}
- if( unload_one_module (m_bn, 1) == -1 )
+ if (unload_one_module(m_bn, 1) == -1)
{
- sendto_one (source_p, ":%s NOTICE %s :Module %s is not loaded",
- me.name, source_p->name, m_bn);
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
+ me.name, source_p->name, m_bn);
}
- MyFree (m_bn);
+ MyFree(m_bn);
}
/* unload and load in one! */
static void
-mo_modreload (struct Client *client_p, struct Client *source_p, int parc, char **parv)
+mo_modreload(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
char *m_bn;
int modindex;
int check_core;
- if (!IsOperAdmin (source_p))
- {
- sendto_one (source_p, ":%s NOTICE %s :You have no A flag",
- me.name, parv[0]);
- return;
- }
+ if (!IsOperAdmin(source_p))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag",
+ me.name, parv[0]);
+ return;
+ }
- m_bn = irc_basename (parv[1]);
+ m_bn = irc_basename(parv[1]);
- if((modindex = findmodule_byname(m_bn)) == -1)
- {
- sendto_one (source_p, ":%s NOTICE %s :Module %s is not loaded",
- me.name, source_p->name, m_bn);
- MyFree (m_bn);
- return;
- }
+ if ((modindex = findmodule_byname(m_bn)) == -1)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
+ me.name, source_p->name, m_bn);
+ MyFree(m_bn);
+ return;
+ }
check_core = modlist[modindex]->core;
- if( unload_one_module (m_bn, 1) == -1 )
- {
- sendto_one (source_p, ":%s NOTICE %s :Module %s is not loaded",
- me.name, source_p->name, m_bn);
- MyFree (m_bn);
- return;
- }
+ if (unload_one_module(m_bn, 1) == -1)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
+ me.name, source_p->name, m_bn);
+ MyFree(m_bn);
+ return;
+ }
- if((load_one_module(parv[1]) == -1) && check_core)
+ if ((load_one_module(parv[1]) == -1) && check_core)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
"Error reloading core module: %s: terminating ircd",
- parv[1]);
+ parv[1]);
ilog(L_CRIT, "Error loading core module %s: terminating ircd", parv[1]);
exit(0);
}
/* list modules .. */
static void
-mo_modlist (struct Client *client_p, struct Client *source_p, int parc, char **parv)
+mo_modlist(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
int i;
- if (!IsOperAdmin (source_p))
+ if (!IsOperAdmin(source_p))
{
- sendto_one (source_p, ":%s NOTICE %s :You have no A flag",
- me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag",
+ me.name, parv[0]);
return;
}
- for(i = 0; i < num_mods; i++ )
+ for (i = 0; i < num_mods; i++)
{
- if(parc>1)
+ if (parc > 1)
{
- if(match(parv[1],modlist[i]->name))
+ if (match(parv[1], modlist[i]->name))
{
sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0],
modlist[i]->name, modlist[i]->address,
else
{
sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0],
- modlist[i]->name, modlist[i]->address,
- modlist[i]->version);
+ modlist[i]->name, modlist[i]->address, modlist[i]->version);
}
}
-
+
sendto_one(source_p, form_str(RPL_ENDOFMODLIST), me.name, parv[0]);
}
/* unload and reload all modules */
static void
-mo_modrestart (struct Client *client_p, struct Client *source_p, int parc, char **parv)
-
+mo_modrestart(struct Client *client_p, struct Client *source_p, int parc,
+ char **parv)
{
int modnum;
- if (!IsOperAdmin (source_p))
+ if (!IsOperAdmin(source_p))
{
- sendto_one (source_p, ":%s NOTICE %s :You have no A flag",
- me.name, parv[0]);
+ sendto_one(source_p, ":%s NOTICE %s :You have no A flag",
+ me.name, parv[0]);
return;
}
modnum = num_mods;
while (num_mods)
- unload_one_module(modlist[0]->name, 0);
+ unload_one_module(modlist[0]->name, 0);
load_all_modules(0);
load_core_modules(0);
rehash(0);
-
+
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Module Restart: %d modules unloaded, %d modules loaded",
- modnum, num_mods);
+ "Module Restart: %d modules unloaded, %d modules loaded",
+ modnum, num_mods);
ilog(L_WARN, "Module Restart: %d modules unloaded, %d modules loaded",
- modnum, num_mods);
+ modnum, num_mods);
}
#else /* STATIC_MODULES */
void
load_all_modules(int warn)
{
- mod_add_cmd(&error_msgtab);
- mod_add_cmd(&accept_msgtab);
- mod_add_cmd(&admin_msgtab);
- mod_add_cmd(&away_msgtab);
- mod_add_cmd(&capab_msgtab);
- mod_add_cmd(&cburst_msgtab);
- mod_add_cmd(&cjoin_msgtab);
- mod_add_cmd(&client_msgtab);
- mod_add_cmd(&close_msgtab);
- mod_add_cmd(&connect_msgtab);
+ mod_add_cmd(&error_msgtab);
+ mod_add_cmd(&accept_msgtab);
+ mod_add_cmd(&admin_msgtab);
+ mod_add_cmd(&away_msgtab);
+ mod_add_cmd(&capab_msgtab);
+ mod_add_cmd(&cburst_msgtab);
+ mod_add_cmd(&cjoin_msgtab);
+ mod_add_cmd(&client_msgtab);
+ mod_add_cmd(&close_msgtab);
+ mod_add_cmd(&connect_msgtab);
#ifdef HAVE_LIBCRYPTO
- mod_add_cmd(&challenge_msgtab);
- mod_add_cmd(&cryptlink_msgtab);
+ mod_add_cmd(&challenge_msgtab);
+ mod_add_cmd(&cryptlink_msgtab);
#endif
- mod_add_cmd(&die_msgtab);
- mod_add_cmd(&dmem_msgtab);
- mod_add_cmd(&drop_msgtab);
- mod_add_cmd(&eob_msgtab);
- mod_add_cmd(&gline_msgtab);
- mod_add_cmd(&help_msgtab);
- mod_add_cmd(&info_msgtab);
- mod_add_cmd(&invite_msgtab);
- mod_add_cmd(&ison_msgtab);
- mod_add_cmd(&join_msgtab);
- mod_add_cmd(&kick_msgtab);
- mod_add_cmd(&kill_msgtab);
- mod_add_cmd(&kline_msgtab);
- mod_add_cmd(&dline_msgtab);
- mod_add_cmd(&knock_msgtab);
- mod_add_cmd(&knockll_msgtab);
- mod_add_cmd(&links_msgtab);
- mod_add_cmd(&list_msgtab);
- mod_add_cmd(&lljoin_msgtab);
- mod_add_cmd(&llnick_msgtab);
- mod_add_cmd(&locops_msgtab);
- mod_add_cmd(&lusers_msgtab);
- mod_add_cmd(&privmsg_msgtab);
- mod_add_cmd(¬ice_msgtab);
- mod_add_cmd(&mode_msgtab);
- mod_add_cmd(&motd_msgtab);
- mod_add_cmd(&names_msgtab);
- mod_add_cmd(&nburst_msgtab);
- mod_add_cmd(&nick_msgtab);
- mod_add_cmd(&oper_msgtab);
- mod_add_cmd(&operwall_msgtab);
- mod_add_cmd(&part_msgtab);
- mod_add_cmd(&pass_msgtab);
- mod_add_cmd(&ping_msgtab);
- mod_add_cmd(&pong_msgtab);
- mod_add_cmd(&post_msgtab);
- mod_add_cmd(&quit_msgtab);
- mod_add_cmd(&rehash_msgtab);
- mod_add_cmd(&restart_msgtab);
- mod_add_cmd(&resv_msgtab);
- mod_add_cmd(&server_msgtab);
- mod_add_cmd(&set_msgtab);
- mod_add_cmd(&sjoin_msgtab);
- mod_add_cmd(&squit_msgtab);
- mod_add_cmd(&stats_msgtab);
- mod_add_cmd(&svinfo_msgtab);
- mod_add_cmd(&testline_msgtab);
- mod_add_cmd(&time_msgtab);
- mod_add_cmd(&topic_msgtab);
- mod_add_cmd(&trace_msgtab);
- mod_add_cmd(&msgtabs[0]);
- mod_add_cmd(&msgtabs[1]);
- mod_add_cmd(&msgtabs[2]);
- mod_add_cmd(&unresv_msgtab);
- mod_add_cmd(&user_msgtab);
- mod_add_cmd(&userhost_msgtab);
- mod_add_cmd(&users_msgtab);
- mod_add_cmd(&version_msgtab);
- mod_add_cmd(&wallops_msgtab);
- mod_add_cmd(&who_msgtab);
- mod_add_cmd(&whois_msgtab);
- mod_add_cmd(&whowas_msgtab);
+ mod_add_cmd(&die_msgtab);
+ mod_add_cmd(&dmem_msgtab);
+ mod_add_cmd(&drop_msgtab);
+ mod_add_cmd(&eob_msgtab);
+ mod_add_cmd(&gline_msgtab);
+ mod_add_cmd(&help_msgtab);
+ mod_add_cmd(&info_msgtab);
+ mod_add_cmd(&invite_msgtab);
+ mod_add_cmd(&ison_msgtab);
+ mod_add_cmd(&join_msgtab);
+ mod_add_cmd(&kick_msgtab);
+ mod_add_cmd(&kill_msgtab);
+ mod_add_cmd(&kline_msgtab);
+ mod_add_cmd(&dline_msgtab);
+ mod_add_cmd(&knock_msgtab);
+ mod_add_cmd(&knockll_msgtab);
+ mod_add_cmd(&links_msgtab);
+ mod_add_cmd(&list_msgtab);
+ mod_add_cmd(&lljoin_msgtab);
+ mod_add_cmd(&llnick_msgtab);
+ mod_add_cmd(&locops_msgtab);
+ mod_add_cmd(&lusers_msgtab);
+ mod_add_cmd(&privmsg_msgtab);
+ mod_add_cmd(¬ice_msgtab);
+ mod_add_cmd(&mode_msgtab);
+ mod_add_cmd(&motd_msgtab);
+ mod_add_cmd(&names_msgtab);
+ mod_add_cmd(&nburst_msgtab);
+ mod_add_cmd(&nick_msgtab);
+ mod_add_cmd(&oper_msgtab);
+ mod_add_cmd(&operwall_msgtab);
+ mod_add_cmd(&part_msgtab);
+ mod_add_cmd(&pass_msgtab);
+ mod_add_cmd(&ping_msgtab);
+ mod_add_cmd(&pong_msgtab);
+ mod_add_cmd(&post_msgtab);
+ mod_add_cmd(&quit_msgtab);
+ mod_add_cmd(&rehash_msgtab);
+ mod_add_cmd(&restart_msgtab);
+ mod_add_cmd(&resv_msgtab);
+ mod_add_cmd(&server_msgtab);
+ mod_add_cmd(&set_msgtab);
+ mod_add_cmd(&sjoin_msgtab);
+ mod_add_cmd(&squit_msgtab);
+ mod_add_cmd(&stats_msgtab);
+ mod_add_cmd(&svinfo_msgtab);
+ mod_add_cmd(&testline_msgtab);
+ mod_add_cmd(&time_msgtab);
+ mod_add_cmd(&topic_msgtab);
+ mod_add_cmd(&trace_msgtab);
+ mod_add_cmd(&msgtabs[0]);
+ mod_add_cmd(&msgtabs[1]);
+ mod_add_cmd(&msgtabs[2]);
+ mod_add_cmd(&unresv_msgtab);
+ mod_add_cmd(&user_msgtab);
+ mod_add_cmd(&userhost_msgtab);
+ mod_add_cmd(&users_msgtab);
+ mod_add_cmd(&version_msgtab);
+ mod_add_cmd(&wallops_msgtab);
+ mod_add_cmd(&who_msgtab);
+ mod_add_cmd(&whois_msgtab);
+ mod_add_cmd(&whowas_msgtab);
}
#endif /* STATIC_MODULES */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: motd.c,v 1.1 2002/01/04 09:14:21 a1kmm Exp $
+ * $Id: motd.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include <sys/types.h>
** InitMessageFile
**
*/
-void InitMessageFile(MotdType motdType, char *fileName, MessageFile *motd)
- {
- strncpy_irc(motd->fileName, fileName, PATH_MAX);
- motd->fileName[PATH_MAX] = '\0';
- motd->motdType = motdType;
- motd->contentsOfFile = NULL;
- motd->lastChangedDate[0] = '\0';
- }
+void
+InitMessageFile(MotdType motdType, char *fileName, MessageFile * motd)
+{
+ strncpy_irc(motd->fileName, fileName, PATH_MAX);
+ motd->fileName[PATH_MAX] = '\0';
+ motd->motdType = motdType;
+ motd->contentsOfFile = NULL;
+ motd->lastChangedDate[0] = '\0';
+}
/*
** SendMessageFile
** user requested motd, but not on each connecting client.
*/
-int SendMessageFile(struct Client *source_p, MessageFile *motdToPrint)
+int
+SendMessageFile(struct Client *source_p, MessageFile * motdToPrint)
{
MessageFileLine *linePointer;
MotdType motdType;
char *nick;
- if(motdToPrint != NULL)
+ if (motdToPrint != NULL)
motdType = motdToPrint->motdType;
else
return -1;
- switch(motdType)
- {
+ switch (motdType)
+ {
case USER_MOTD:
nick = BadPtr(source_p->name) ? "*" : source_p->name;
-
- if (motdToPrint->contentsOfFile == (MessageFileLine *)NULL)
- {
- sendto_one(source_p, form_str(ERR_NOMOTD), me.name, nick);
- return 0;
- }
+
+ if (motdToPrint->contentsOfFile == (MessageFileLine *) NULL)
+ {
+ sendto_one(source_p, form_str(ERR_NOMOTD), me.name, nick);
+ return 0;
+ }
sendto_one(source_p, form_str(RPL_MOTDSTART), me.name, nick, me.name);
- for(linePointer = motdToPrint->contentsOfFile;linePointer;
- linePointer = linePointer->next)
- {
- sendto_one(source_p,
- form_str(RPL_MOTD),
- me.name, nick, linePointer->line);
- }
+ for (linePointer = motdToPrint->contentsOfFile; linePointer;
+ linePointer = linePointer->next)
+ {
+ sendto_one(source_p,
+ form_str(RPL_MOTD), me.name, nick, linePointer->line);
+ }
sendto_one(source_p, form_str(RPL_ENDOFMOTD), me.name, nick);
return 0;
/* NOT REACHED */
break;
case USER_LINKS:
- if (motdToPrint->contentsOfFile == (MessageFileLine *)NULL)
- return -1;
-
- for(linePointer = motdToPrint->contentsOfFile;linePointer;
- linePointer = linePointer->next)
- {
- sendto_one(source_p, ":%s 364 %s %s",
- me.name, source_p->name, linePointer->line);
- }
+ if (motdToPrint->contentsOfFile == (MessageFileLine *) NULL)
+ return -1;
+
+ for (linePointer = motdToPrint->contentsOfFile; linePointer;
+ linePointer = linePointer->next)
+ {
+ sendto_one(source_p, ":%s 364 %s %s",
+ me.name, source_p->name, linePointer->line);
+ }
/* NOT REACHED */
return 0;
break;
case OPER_MOTD:
- if (motdToPrint->contentsOfFile == (MessageFileLine *)NULL)
- {
+ if (motdToPrint->contentsOfFile == (MessageFileLine *) NULL)
+ {
/* sendto_one(source_p, ":%s NOTICE %s :No OPER MOTD", me.name,
* source_p->name); */
- return -1;
- }
- sendto_one(source_p,":%s NOTICE %s :Start of OPER MOTD",me.name,source_p->name);
+ return -1;
+ }
+ sendto_one(source_p, ":%s NOTICE %s :Start of OPER MOTD", me.name,
+ source_p->name);
break;
case HELP_MOTD:
default:
return 0;
/* NOT REACHED */
- }
+ }
- sendto_one(source_p,":%s NOTICE %s :%s",me.name,source_p->name,
+ sendto_one(source_p, ":%s NOTICE %s :%s", me.name, source_p->name,
motdToPrint->lastChangedDate);
- for(linePointer = motdToPrint->contentsOfFile;linePointer;
- linePointer = linePointer->next)
- {
- sendto_one(source_p,
- ":%s NOTICE %s :%s",
- me.name, source_p->name, linePointer->line);
- }
+ for (linePointer = motdToPrint->contentsOfFile; linePointer;
+ linePointer = linePointer->next)
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :%s",
+ me.name, source_p->name, linePointer->line);
+ }
sendto_one(source_p, ":%s NOTICE %s :End", me.name, source_p->name);
return 0;
}
* side effects -
*/
-int ReadMessageFile(MessageFile *MessageFileptr)
+int
+ReadMessageFile(MessageFile * MessageFileptr)
{
struct stat sb;
struct tm *local_tm;
char buffer[MESSAGELINELEN];
char *p;
- FBFILE* file;
+ FBFILE *file;
- if( stat(MessageFileptr->fileName, &sb) < 0 )
+ if (stat(MessageFileptr->fileName, &sb) < 0)
return -1;
- for( mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr)
- {
- next_mptr = mptr->next;
- MyFree(mptr);
- }
+ for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr)
+ {
+ next_mptr = mptr->next;
+ MyFree(mptr);
+ }
MessageFileptr->contentsOfFile = NULL;
"%d/%d/%d %d:%d",
local_tm->tm_mday,
local_tm->tm_mon + 1,
- 1900 + local_tm->tm_year,
- local_tm->tm_hour,
- local_tm->tm_min);
+ 1900 + local_tm->tm_year, local_tm->tm_hour, local_tm->tm_min);
if ((file = fbopen(MessageFileptr->fileName, "r")) == 0)
- return(-1);
+ return (-1);
while (fbgets(buffer, MESSAGELINELEN, file))
+ {
+ if ((p = strchr(buffer, '\n')))
+ *p = '\0';
+ newMessageLine = (MessageFileLine *) MyMalloc(sizeof(MessageFileLine));
+
+ strncpy_irc(newMessageLine->line, buffer, MESSAGELINELEN);
+ newMessageLine->line[MESSAGELINELEN] = '\0';
+ newMessageLine->next = (MessageFileLine *) NULL;
+
+ if (MessageFileptr->contentsOfFile)
{
- if ((p = strchr(buffer, '\n')))
- *p = '\0';
- newMessageLine = (MessageFileLine*) MyMalloc(sizeof(MessageFileLine));
-
- strncpy_irc(newMessageLine->line, buffer, MESSAGELINELEN);
- newMessageLine->line[MESSAGELINELEN] = '\0';
- newMessageLine->next = (MessageFileLine *)NULL;
-
- if (MessageFileptr->contentsOfFile)
- {
- if (currentMessageLine)
- currentMessageLine->next = newMessageLine;
- currentMessageLine = newMessageLine;
- }
- else
- {
- MessageFileptr->contentsOfFile = newMessageLine;
- currentMessageLine = newMessageLine;
- }
+ if (currentMessageLine)
+ currentMessageLine->next = newMessageLine;
+ currentMessageLine = newMessageLine;
}
+ else
+ {
+ MessageFileptr->contentsOfFile = newMessageLine;
+ currentMessageLine = newMessageLine;
+ }
+ }
fbclose(file);
- return(0);
+ return (0);
}
-
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: numeric.c,v 1.1 2002/01/04 09:14:21 a1kmm Exp $
+ * $Id: numeric.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include <sys/types.h>
#include "numeric.h"
#include "irc_string.h"
-#include "common.h" /* NULL cripes */
+#include "common.h" /* NULL cripes */
#include "memory.h"
#include "messages.tab"
* output - corresponding string
* side effects - NONE
*/
-const char* form_str(int numeric)
+const char *
+form_str(int numeric)
{
const char *num_ptr;
return (num_ptr);
}
-
-
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
- * $Id: packet.c,v 1.1 2002/01/04 09:14:23 a1kmm Exp $
- */
+ * $Id: packet.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
+ */
#include <stdio.h>
#include <string.h>
#include "memory.h"
#include "hook.h"
-static char readBuf[READBUF_SIZE];
+static char readBuf[READBUF_SIZE];
/*
*/
static void
parse_client_queued(struct Client *client_p)
-{
- int dolen = 0, checkflood = 1;
- struct LocalUser *lclient_p = client_p->localClient;
-
- if (IsServer(client_p))
- {
- while ((dolen = linebuf_get(&client_p->localClient->buf_recvq,
- readBuf, READBUF_SIZE, LINEBUF_COMPLETE,
- LINEBUF_PARSED)) > 0)
+{
+ int dolen = 0, checkflood = 1;
+ struct LocalUser *lclient_p = client_p->localClient;
+
+ if (IsServer(client_p))
{
- if (!IsDead(client_p))
- client_dopacket(client_p, readBuf, dolen);
- if (IsDead(client_p))
- {
- if (client_p->localClient)
+ while ((dolen = linebuf_get(&client_p->localClient->buf_recvq,
+ readBuf, READBUF_SIZE, LINEBUF_COMPLETE,
+ LINEBUF_PARSED)) > 0)
{
- linebuf_donebuf(&client_p->localClient->buf_recvq);
- linebuf_donebuf(&client_p->localClient->buf_sendq);
+ if (!IsDead(client_p))
+ client_dopacket(client_p, readBuf, dolen);
+ if (IsDead(client_p))
+ {
+ if (client_p->localClient)
+ {
+ linebuf_donebuf(&client_p->localClient->buf_recvq);
+ linebuf_donebuf(&client_p->localClient->buf_sendq);
+ }
+ return;
+ }
}
- return;
- }
}
- } else {
- checkflood = 0;
- if (ConfigFileEntry.no_oper_flood && IsOper(client_p))
- checkflood = 0;
+ else
+ {
+ checkflood = 0;
+ if (ConfigFileEntry.no_oper_flood && IsOper(client_p))
+ checkflood = 0;
/*
* Handle flood protection here - if we exceed our flood limit on
* messages in this loop, we simply drop out of the loop prematurely.
* -- adrian
*/
- for (;;)
- {
- if (checkflood && (lclient_p->sent_parsed > lclient_p->allow_read))
- break;
- dolen = linebuf_get(&client_p->localClient->buf_recvq, readBuf,
- READBUF_SIZE, LINEBUF_COMPLETE, LINEBUF_PARSED);
- if (!dolen)
- break;
- client_dopacket(client_p, readBuf, dolen);
- lclient_p->sent_parsed++;
+ for (;;)
+ {
+ if (checkflood && (lclient_p->sent_parsed > lclient_p->allow_read))
+ break;
+ dolen = linebuf_get(&client_p->localClient->buf_recvq, readBuf,
+ READBUF_SIZE, LINEBUF_COMPLETE, LINEBUF_PARSED);
+ if (!dolen)
+ break;
+ client_dopacket(client_p, readBuf, dolen);
+ lclient_p->sent_parsed++;
+ }
}
- }
}
/*
void
flood_recalc(int fd, void *data)
{
- struct Client *client_p = data;
- struct LocalUser *lclient_p = client_p->localClient;
- int max_flood_per_sec = MAX_FLOOD_PER_SEC;
-
- /* This can happen in the event that the client detached. */
- if (!lclient_p)
- return;
- /* If we're a server, skip to the end. Realising here that this call is
- * cheap and it means that if a op is downgraded they still get considered
- * for anti-flood protection ..
- */
- if (!IsPrivileged(client_p))
- {
- /* Is the grace period still active? */
- if (client_p->user && !IsFloodDone(client_p))
- max_flood_per_sec = MAX_FLOOD_PER_SEC_I;
- /* ok, we have to recalculate the number of messages we can receive
- * in this second, based upon what happened in the last second.
- * If we still exceed the flood limit, don't move the parsed limit.
- * If we are below the flood limit, increase the flood limit.
- * -- adrian
+ struct Client *client_p = data;
+ struct LocalUser *lclient_p = client_p->localClient;
+ int max_flood_per_sec = MAX_FLOOD_PER_SEC;
+
+ /* This can happen in the event that the client detached. */
+ if (!lclient_p)
+ return;
+ /* If we're a server, skip to the end. Realising here that this call is
+ * cheap and it means that if a op is downgraded they still get considered
+ * for anti-flood protection ..
*/
- /* Set to 1 to start with, let it rise/fall after that... */
- if (lclient_p->allow_read == 0)
- lclient_p->allow_read = 1;
- else if (lclient_p->actually_read < lclient_p->allow_read)
- /* Raise the allowed messages if we flooded under the limit */
- lclient_p->allow_read++;
- else
- /* Drop the limit to avoid flooding .. */
- lclient_p->allow_read--;
- /* Enforce floor/ceiling restrictions */
- if (lclient_p->allow_read < 1)
- lclient_p->allow_read = 1;
- else if (lclient_p->allow_read > max_flood_per_sec)
- lclient_p->allow_read = max_flood_per_sec;
- }
- /* Reset the sent-per-second count */
- lclient_p->sent_parsed = 0;
- lclient_p->actually_read = 0;
- parse_client_queued(client_p);
- /* And now, try flushing .. */
- if (!IsDead(client_p))
- {
- /* and finally, reset the flood check */
- comm_setflush(fd, 1000, flood_recalc, client_p);
- }
+ if (!IsPrivileged(client_p))
+ {
+ /* Is the grace period still active? */
+ if (client_p->user && !IsFloodDone(client_p))
+ max_flood_per_sec = MAX_FLOOD_PER_SEC_I;
+ /* ok, we have to recalculate the number of messages we can receive
+ * in this second, based upon what happened in the last second.
+ * If we still exceed the flood limit, don't move the parsed limit.
+ * If we are below the flood limit, increase the flood limit.
+ * -- adrian
+ */
+ /* Set to 1 to start with, let it rise/fall after that... */
+ if (lclient_p->allow_read == 0)
+ lclient_p->allow_read = 1;
+ else if (lclient_p->actually_read < lclient_p->allow_read)
+ /* Raise the allowed messages if we flooded under the limit */
+ lclient_p->allow_read++;
+ else
+ /* Drop the limit to avoid flooding .. */
+ lclient_p->allow_read--;
+ /* Enforce floor/ceiling restrictions */
+ if (lclient_p->allow_read < 1)
+ lclient_p->allow_read = 1;
+ else if (lclient_p->allow_read > max_flood_per_sec)
+ lclient_p->allow_read = max_flood_per_sec;
+ }
+ /* Reset the sent-per-second count */
+ lclient_p->sent_parsed = 0;
+ lclient_p->actually_read = 0;
+ parse_client_queued(client_p);
+ /* And now, try flushing .. */
+ if (!IsDead(client_p))
+ {
+ /* and finally, reset the flood check */
+ comm_setflush(fd, 1000, flood_recalc, client_p);
+ }
}
/*
reply = &lserver->slinkrpl;
/* if the server died, kill it off now -davidt */
- if(IsDead(server))
+ if (IsDead(server))
{
exit_client(server, server, &me,
(server->flags & FLAGS_SENDQEX) ?
- "SendQ exceeded" : "Dead socket");
+ "SendQ exceeded" : "Dead socket");
return;
}
if (length <= 0)
{
- if((length == -1) && ignoreErrno(errno))
+ if ((length == -1) && ignoreErrno(errno))
goto nodata;
error_exit_client(server, length);
return;
length = read(fd, len, (2 - reply->gotdatalen));
if (length <= 0)
{
- if((length == -1) && ignoreErrno(errno))
+ if ((length == -1) && ignoreErrno(errno))
goto nodata;
error_exit_client(server, length);
return;
}
if (reply->gotdatalen < 2)
- return; /* wait for more data */
+ return; /* wait for more data */
}
if (reply->readdata < reply->datalen) /* try to get any remaining data */
(reply->datalen - reply->readdata));
if (length <= 0)
{
- if((length == -1) && ignoreErrno(errno))
+ if ((length == -1) && ignoreErrno(errno))
goto nodata;
error_exit_client(server, length);
return;
reply->readdata += length;
if (reply->readdata < reply->datalen)
- return; /* wait for more data */
+ return; /* wait for more data */
}
#ifndef NDEBUG
hdata.data = NULL;
hook_call_event("iorecvctrl", &hdata);
#endif
-
+
/* we now have the command and any data, pass it off to the handler */
- (*replydef->handler)(reply->command, reply->datalen, reply->data, server);
+ (*replydef->handler) (reply->command, reply->datalen, reply->data, server);
- /* reset SlinkRpl */
+ /* reset SlinkRpl */
if (reply->datalen > 0)
MyFree(reply->data);
reply->command = 0;
comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ,
read_ctrl_packet, server, 0);
}
-
+
/*
* read_packet - Read a 'packet' of data from a connection and process it.
*/
struct hook_io_data hdata;
#endif
/* if the client is dead, kill it off now -davidt */
- if(IsDead(client_p))
+ if (IsDead(client_p))
{
exit_client(client_p, client_p, &me,
(client_p->flags & FLAGS_SENDQEX) ?
- "SendQ exceeded" : "Dead socket");
+ "SendQ exceeded" : "Dead socket");
return;
}
if (length <= 0)
{
- if((length == -1) && ignoreErrno(errno))
+ if ((length == -1) && ignoreErrno(errno))
{
comm_setselect(fd_r, FDLIST_IDLECLIENT, COMM_SELECT_READ,
- read_packet, client_p, 0);
+ read_packet, client_p, 0);
return;
- }
+ }
error_exit_client(client_p, length);
return;
}
hdata.len = length;
hook_call_event("iorecv", &hdata);
#endif
-
+
if (client_p->lasttime < CurrentTime)
client_p->lasttime = CurrentTime;
if (client_p->lasttime > client_p->since)
binary = 1;
lbuf_len = linebuf_parse(&client_p->localClient->buf_recvq,
- readBuf, length, binary);
+ readBuf, length, binary);
if (lbuf_len < 0)
{
}
lclient_p->actually_read += lbuf_len;
-
+
/* Check to make sure we're not flooding */
if (IsPerson(client_p) &&
- (linebuf_alloclen(&client_p->localClient->buf_recvq) >
- ConfigFileEntry.client_flood)) {
- if (!(ConfigFileEntry.no_oper_flood && IsOper(client_p)))
- {
- exit_client(client_p, client_p, client_p, "Excess Flood");
- return;
- }
+ (linebuf_alloclen(&client_p->localClient->buf_recvq) >
+ ConfigFileEntry.client_flood))
+ {
+ if (!(ConfigFileEntry.no_oper_flood && IsOper(client_p)))
+ {
+ exit_client(client_p, client_p, client_p, "Excess Flood");
+ return;
}
+ }
/* Attempt to parse what we have */
parse_client_queued(client_p);
if (!IsDead(client_p))
{
/* If we get here, we need to register for another COMM_SELECT_READ */
- if (PARSE_AS_SERVER(client_p)) {
+ if (PARSE_AS_SERVER(client_p))
+ {
comm_setselect(fd_r, FDLIST_SERVER, COMM_SELECT_READ,
- read_packet, client_p, 0);
- } else {
+ read_packet, client_p, 0);
+ }
+ else
+ {
comm_setselect(fd_r, FDLIST_IDLECLIENT, COMM_SELECT_READ,
- read_packet, client_p, 0);
+ read_packet, client_p, 0);
}
}
}
* with client_p of "local" variation, which contains all the
* necessary fields (buffer etc..)
*/
-void client_dopacket(struct Client *client_p, char *buffer, size_t length)
+void
+client_dopacket(struct Client *client_p, char *buffer, size_t length)
{
assert(client_p != NULL);
assert(buffer != NULL);
*/
client_p->localClient->receiveB += length;
- if (client_p->localClient->receiveB > 1023) {
- client_p->localClient->receiveK += (client_p->localClient->receiveB >> 10);
- client_p->localClient->receiveB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
+ if (client_p->localClient->receiveB > 1023)
+ {
+ client_p->localClient->receiveK +=
+ (client_p->localClient->receiveB >> 10);
+ client_p->localClient->receiveB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
}
me.localClient->receiveB += length;
if (me.localClient->receiveB > 1023)
- {
- me.localClient->receiveK += (me.localClient->receiveB >> 10);
- me.localClient->receiveB &= 0x03ff;
- }
+ {
+ me.localClient->receiveK += (me.localClient->receiveB >> 10);
+ me.localClient->receiveB &= 0x03ff;
+ }
parse(client_p, buffer, buffer + length);
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: parse.c,v 1.1 2002/01/04 09:14:23 a1kmm Exp $
+ * $Id: parse.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include <assert.h>
/*
* NOTE: parse() should not be called recursively by other functions!
*/
-static char *sender;
-static char *para[MAXPARA+1];
+static char *sender;
+static char *para[MAXPARA + 1];
-static int cancel_clients (struct Client *, struct Client *, char *);
-static void remove_unknown (struct Client *, char *, char *);
+static int cancel_clients(struct Client *, struct Client *, char *);
+static void remove_unknown(struct Client *, char *, char *);
-static void do_numeric (char [], struct Client *,
- struct Client *, int, char **);
+static void do_numeric(char[], struct Client *,
+ struct Client *, int, char **);
-static void handle_command(struct Message *, struct Client *,
- struct Client *, int, char **);
+static void handle_command(struct Message *, struct Client *,
+ struct Client *, int, char **);
static int hash(char *p);
static struct Message *hash_parse(char *);
int x = 1;
parv[x] = NULL;
- while(*buf == ' ') /* skip leading spaces */
+ while (*buf == ' ') /* skip leading spaces */
buf++;
- if(*buf == '\0') /* ignore all-space args */
+ if (*buf == '\0') /* ignore all-space args */
return x;
-
- do
+
+ do
{
- if (*buf == ':') /* Last parameter */
+ if (*buf == ':') /* Last parameter */
{
buf++;
parv[x++] = buf;
{
parv[x++] = buf;
parv[x] = NULL;
- if((p = strchr(buf, ' ')) != NULL)
+ if ((p = strchr(buf, ' ')) != NULL)
{
*p++ = '\0';
buf = p;
}
else
return x;
- }
- while(*buf == ' ')
+ }
+ while (*buf == ' ')
buf++;
- if(*buf == '\0')
+ if (*buf == '\0')
return x;
- } while(x < MAXPARA - 1);
-
+ } while (x < MAXPARA - 1);
+
parv[x++] = p;
parv[x] = NULL;
return x;
*
* NOTE: parse() should not be called recusively by any other functions!
*/
-void parse(struct Client *client_p, char *pbuffer, char *bufend)
+void
+parse(struct Client *client_p, char *pbuffer, char *bufend)
{
- struct Client* from = client_p;
- char* ch;
- char* s;
- char* end;
- int i;
- int paramcount, mpara=0;
- char* numeric = 0;
- struct Message* mptr;
-
+ struct Client *from = client_p;
+ char *ch;
+ char *s;
+ char *end;
+ int i;
+ int paramcount, mpara = 0;
+ char *numeric = 0;
+ struct Message *mptr;
+
Debug((DEBUG_DEBUG, "Parsing %s:", pbuffer));
assert(!IsDead(client_p));
assert(client_p->fd >= 0);
- assert((bufend-pbuffer) < 512);
+ assert((bufend - pbuffer) < 512);
- for (ch = pbuffer; *ch == ' '; ch++) /* skip spaces */
+ for (ch = pbuffer; *ch == ' '; ch++) /* skip spaces */
/* null statement */ ;
para[0] = from->name;
if (*ch == ':')
- {
- ch++;
+ {
+ ch++;
- /*
- ** Copy the prefix to 'sender' assuming it terminates
- ** with SPACE (or NULL, which is an error, though).
- */
-
- sender = ch;
-
- if((s = strchr(ch, ' ')))
- {
- *s = '\0';
- s++;
- ch = s;
- }
-
- i = 0;
-
- if (*sender && IsServer(client_p))
- {
- from = find_client(sender);
- if (from == NULL)
- {
- from = find_server(sender);
- if(from == NULL)
- from = find_id(sender);
- }
-
- /* Hmm! If the client corresponding to the
- * prefix is not found--what is the correct
- * action??? Now, I will ignore the message
- * (old IRC just let it through as if the
- * prefix just wasn't there...) --msa
- */
- if (from == NULL)
- {
- Debug((DEBUG_ERROR, "Unknown prefix (%s)(%s) from (%s)",
- sender, pbuffer, client_p->name));
- ServerStats->is_unpf++;
-
- remove_unknown(client_p, sender, pbuffer);
-
- return;
- }
-
- para[0] = from->name;
-
- if (from->from != client_p)
- {
- ServerStats->is_wrdi++;
- Debug((DEBUG_ERROR, "Message (%s) coming from (%s)",
- pbuffer, client_p->name));
-
- cancel_clients(client_p, from, pbuffer);
- return;
- }
- }
- while(*ch == ' ')
- ch++;
+ /*
+ ** Copy the prefix to 'sender' assuming it terminates
+ ** with SPACE (or NULL, which is an error, though).
+ */
+
+ sender = ch;
+
+ if ((s = strchr(ch, ' ')))
+ {
+ *s = '\0';
+ s++;
+ ch = s;
}
- if (*ch == '\0')
+ i = 0;
+
+ if (*sender && IsServer(client_p))
{
- ServerStats->is_empt++;
- Debug((DEBUG_NOTICE, "Empty message from host %s:%s",
- client_p->name, from->name));
- return;
+ from = find_client(sender);
+ if (from == NULL)
+ {
+ from = find_server(sender);
+ if (from == NULL)
+ from = find_id(sender);
+ }
+
+ /* Hmm! If the client corresponding to the
+ * prefix is not found--what is the correct
+ * action??? Now, I will ignore the message
+ * (old IRC just let it through as if the
+ * prefix just wasn't there...) --msa
+ */
+ if (from == NULL)
+ {
+ Debug((DEBUG_ERROR, "Unknown prefix (%s)(%s) from (%s)",
+ sender, pbuffer, client_p->name));
+ ServerStats->is_unpf++;
+
+ remove_unknown(client_p, sender, pbuffer);
+
+ return;
+ }
+
+ para[0] = from->name;
+
+ if (from->from != client_p)
+ {
+ ServerStats->is_wrdi++;
+ Debug((DEBUG_ERROR, "Message (%s) coming from (%s)",
+ pbuffer, client_p->name));
+
+ cancel_clients(client_p, from, pbuffer);
+ return;
+ }
}
+ while (*ch == ' ')
+ ch++;
+ }
+
+ if (*ch == '\0')
+ {
+ ServerStats->is_empt++;
+ Debug((DEBUG_NOTICE, "Empty message from host %s:%s",
+ client_p->name, from->name));
+ return;
+ }
/*
- ** Extract the command code from the packet. Point s to the end
- ** of the command code and calculate the length using pointer
- ** arithmetic. Note: only need length for numerics and *all*
- ** numerics must have parameters and thus a space after the command
- ** code. -avalon
- *
- * ummm????
- */
+ ** Extract the command code from the packet. Point s to the end
+ ** of the command code and calculate the length using pointer
+ ** arithmetic. Note: only need length for numerics and *all*
+ ** numerics must have parameters and thus a space after the command
+ ** code. -avalon
+ *
+ * ummm????
+ */
/* EOB is 3 chars long but is not a numeric */
- if( *(ch + 3) == ' ' && /* ok, lets see if its a possible numeric.. */
- IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2)) )
- {
- mptr = (struct Message *)NULL;
- numeric = ch;
- paramcount = MAXPARA;
- ServerStats->is_num++;
- s = ch + 3; /* I know this is ' ' from above if */
- *s++ = '\0'; /* blow away the ' ', and point s to next part */
- }
+ if (*(ch + 3) == ' ' && /* ok, lets see if its a possible numeric.. */
+ IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2)))
+ {
+ mptr = (struct Message *)NULL;
+ numeric = ch;
+ paramcount = MAXPARA;
+ ServerStats->is_num++;
+ s = ch + 3; /* I know this is ' ' from above if */
+ *s++ = '\0'; /* blow away the ' ', and point s to next part */
+ }
else
- {
- int ii = 0;
-
- if( (s = strchr(ch, ' ')) )
- *s++ = '\0';
-
- mptr = hash_parse(ch);
-
- if (!mptr || !mptr->cmd)
- {
- /*
- ** Note: Give error message *only* to recognized
- ** persons. It's a nightmare situation to have
- ** two programs sending "Unknown command"'s or
- ** equivalent to each other at full blast....
- ** If it has got to person state, it at least
- ** seems to be well behaving. Perhaps this message
- ** should never be generated, though... --msa
- ** Hm, when is the buffer empty -- if a command
- ** code has been found ?? -Armin
- */
- if (pbuffer[0] != '\0')
- {
- if (IsPerson(from))
- sendto_one(from,
- ":%s %d %s %s :Unknown command",
- me.name, ERR_UNKNOWNCOMMAND,
- from->name, ch);
- Debug((DEBUG_ERROR,"Unknown (%s) from %s",
- ch, get_client_name(client_p, SHOW_IP)));
- }
- ServerStats->is_unco++;
- return;
- }
-
- paramcount = mptr->parameters;
- mpara = mptr->maxpara;
-
- ii = bufend - ((s) ? s : ch);
- mptr->bytes += ii;
+ {
+ int ii = 0;
+
+ if ((s = strchr(ch, ' ')))
+ *s++ = '\0';
+
+ mptr = hash_parse(ch);
+
+ if (!mptr || !mptr->cmd)
+ {
+ /*
+ ** Note: Give error message *only* to recognized
+ ** persons. It's a nightmare situation to have
+ ** two programs sending "Unknown command"'s or
+ ** equivalent to each other at full blast....
+ ** If it has got to person state, it at least
+ ** seems to be well behaving. Perhaps this message
+ ** should never be generated, though... --msa
+ ** Hm, when is the buffer empty -- if a command
+ ** code has been found ?? -Armin
+ */
+ if (pbuffer[0] != '\0')
+ {
+ if (IsPerson(from))
+ sendto_one(from,
+ ":%s %d %s %s :Unknown command",
+ me.name, ERR_UNKNOWNCOMMAND, from->name, ch);
+ Debug((DEBUG_ERROR, "Unknown (%s) from %s",
+ ch, get_client_name(client_p, SHOW_IP)));
+ }
+ ServerStats->is_unco++;
+ return;
}
+ paramcount = mptr->parameters;
+ mpara = mptr->maxpara;
+
+ ii = bufend - ((s) ? s : ch);
+ mptr->bytes += ii;
+ }
+
end = bufend - 1;
-
+
/* XXX this should be done before parse() is called */
- if(*end == '\n') *end-- = '\0';
- if(*end == '\r') *end = '\0';
+ if (*end == '\n')
+ *end-- = '\0';
+ if (*end == '\r')
+ *end = '\0';
i = 0;
-
+
if (s)
i = string_to_array(s, para);
if (mptr == (struct Message *)NULL)
- {
- do_numeric(numeric, client_p, from, i, para);
- return;
- }
+ {
+ do_numeric(numeric, client_p, from, i, para);
+ return;
+ }
handle_command(mptr, client_p, from, i, para);
#ifdef INTENSIVE_DEBUG
#endif
}
-static void
+static void
handle_command(struct Message *mptr, struct Client *client_p,
struct Client *from, int i, char *hpara[MAXPARA])
{
MessageHandler handler = 0;
-
- if(IsServer(client_p))
+
+ if (IsServer(client_p))
mptr->rcount++;
mptr->count++;
-
+
/* New patch to avoid server flooding from unregistered connects
- Pie-Man 07/27/2000 */
-
+
if (!IsRegistered(client_p))
- {
- /* if its from a possible server connection
- * ignore it.. more than likely its a header thats sneaked through
- */
-
- if((IsHandshake(client_p) || IsConnecting(client_p)
- || IsServer(client_p))
- && !(mptr->flags & MFLG_UNREG))
- return;
- }
+ {
+ /* if its from a possible server connection
+ * ignore it.. more than likely its a header thats sneaked through
+ */
+
+ if ((IsHandshake(client_p) || IsConnecting(client_p)
+ || IsServer(client_p)) && !(mptr->flags & MFLG_UNREG))
+ return;
+ }
handler = mptr->handlers[client_p->handler];
-
+
/* check right amount of params is passed... --is */
if (i < mptr->parameters)
- {
- if(IsServer(client_p))
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Not enough parameters for command %s from servers %s! (%d < %d)",
- mptr->cmd, client_p->name, i, mptr->parameters);
- sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, BadPtr(hpara[0]) ? "*" : hpara[0], mptr->cmd);
- return;
- }
+ {
+ if (IsServer(client_p))
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Not enough parameters for command %s from servers %s! (%d < %d)",
+ mptr->cmd, client_p->name, i, mptr->parameters);
+ sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, BadPtr(hpara[0]) ? "*" : hpara[0], mptr->cmd);
+ return;
+ }
- (*handler)(client_p, from, i, hpara);
+ (*handler) (client_p, from, i, hpara);
return;
}
* any other keyword hash routine is used.
*
*/
-void clear_hash_parse()
+void
+clear_hash_parse()
{
- memset(msg_hash_table,0,sizeof(msg_hash_table));
+ memset(msg_hash_table, 0, sizeof(msg_hash_table));
}
/* mod_add_cmd
struct MessageHash *ptr;
struct MessageHash *last_ptr = NULL;
struct MessageHash *new_ptr;
- int msgindex;
+ int msgindex;
assert(msg != NULL);
msgindex = hash(msg->cmd);
- for(ptr = msg_hash_table[msgindex]; ptr; ptr = ptr->next )
- {
- if (strcasecmp(msg->cmd,ptr->cmd) == 0)
- return; /* Its already added */
- last_ptr = ptr;
- }
+ for (ptr = msg_hash_table[msgindex]; ptr; ptr = ptr->next)
+ {
+ if (strcasecmp(msg->cmd, ptr->cmd) == 0)
+ return; /* Its already added */
+ last_ptr = ptr;
+ }
new_ptr = (struct MessageHash *)MyMalloc(sizeof(struct MessageHash));
new_ptr->next = NULL;
- DupString(new_ptr->cmd,msg->cmd);
+ DupString(new_ptr->cmd, msg->cmd);
new_ptr->msg = msg;
msg->count = 0;
msg->rcount = 0;
msg->bytes = 0;
- if(last_ptr == NULL)
+ if (last_ptr == NULL)
msg_hash_table[msgindex] = new_ptr;
else
last_ptr->next = new_ptr;
* output - none
* side effects - unload this one command name
*/
-void mod_del_cmd(struct Message *msg)
+void
+mod_del_cmd(struct Message *msg)
{
struct MessageHash *ptr;
struct MessageHash *last_ptr = NULL;
- int msgindex;
+ int msgindex;
assert(msg != NULL);
msgindex = hash(msg->cmd);
- for(ptr = msg_hash_table[msgindex]; ptr; ptr = ptr->next )
+ for (ptr = msg_hash_table[msgindex]; ptr; ptr = ptr->next)
+ {
+ if (strcasecmp(msg->cmd, ptr->cmd) == 0)
{
- if(strcasecmp(msg->cmd,ptr->cmd) == 0)
- {
- MyFree(ptr->cmd);
- if(last_ptr != NULL)
- last_ptr->next = ptr->next;
- else
- msg_hash_table[msgindex] = ptr->next;
- MyFree(ptr);
- return;
- }
- last_ptr = ptr;
+ MyFree(ptr->cmd);
+ if (last_ptr != NULL)
+ last_ptr->next = ptr->next;
+ else
+ msg_hash_table[msgindex] = ptr->next;
+ MyFree(ptr);
+ return;
}
+ last_ptr = ptr;
+ }
}
/* hash_parse
* output - pointer to struct Message
* side effects -
*/
-struct Message *hash_parse(char *cmd)
+struct Message *
+hash_parse(char *cmd)
{
struct MessageHash *ptr;
- int msgindex;
+ int msgindex;
msgindex = hash(cmd);
- for(ptr = msg_hash_table[msgindex]; ptr; ptr = ptr->next )
+ for (ptr = msg_hash_table[msgindex]; ptr; ptr = ptr->next)
+ {
+ if (strcasecmp(cmd, ptr->cmd) == 0)
{
- if(strcasecmp(cmd,ptr->cmd) == 0)
- {
- return(ptr->msg);
- }
+ return (ptr->msg);
}
+ }
return NULL;
}
static int
hash(char *p)
{
- int hash_val=0;
+ int hash_val = 0;
- while(*p)
- {
- hash_val += ((int)(*p)&0xDF);
- p++;
- }
+ while (*p)
+ {
+ hash_val += ((int)(*p) & 0xDF);
+ p++;
+ }
- return(hash_val % MAX_MSG_HASH);
+ return (hash_val % MAX_MSG_HASH);
}
/*
* output - NONE
* side effects - NONE
*/
-void report_messages(struct Client *source_p)
+void
+report_messages(struct Client *source_p)
{
int i;
struct MessageHash *ptr;
for (i = 0; i < MAX_MSG_HASH; i++)
+ {
+ for (ptr = msg_hash_table[i]; ptr; ptr = ptr->next)
{
- for (ptr = msg_hash_table[i]; ptr; ptr = ptr->next)
- {
- assert(ptr->msg != NULL);
- assert(ptr->cmd != NULL);
-
- sendto_one(source_p, form_str(RPL_STATSCOMMANDS),
- me.name, source_p->name, ptr->cmd,
- ptr->msg->count, ptr->msg->bytes,
- ptr->msg->rcount);
- }
+ assert(ptr->msg != NULL);
+ assert(ptr->cmd != NULL);
+
+ sendto_one(source_p, form_str(RPL_STATSCOMMANDS),
+ me.name, source_p->name, ptr->cmd,
+ ptr->msg->count, ptr->msg->bytes, ptr->msg->rcount);
}
+ }
}
/*
* output -
* side effects -
*/
-static int cancel_clients(struct Client *client_p,
- struct Client *source_p,
- char *cmd)
+static int
+cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd)
{
/*
* kill all possible points that are causing confusion here,
*/
/*
- ** with TS, fake prefixes are a common thing, during the
- ** connect burst when there's a nick collision, and they
- ** must be ignored rather than killed because one of the
- ** two is surviving.. so we don't bother sending them to
- ** all ops everytime, as this could send 'private' stuff
- ** from lagged clients. we do send the ones that cause
- ** servers to be dropped though, as well as the ones from
- ** non-TS servers -orabidoo
- */
+ ** with TS, fake prefixes are a common thing, during the
+ ** connect burst when there's a nick collision, and they
+ ** must be ignored rather than killed because one of the
+ ** two is surviving.. so we don't bother sending them to
+ ** all ops everytime, as this could send 'private' stuff
+ ** from lagged clients. we do send the ones that cause
+ ** servers to be dropped though, as well as the ones from
+ ** non-TS servers -orabidoo
+ */
/*
* Incorrect prefix for a server from some connection. If it is a
* client trying to be annoying, just QUIT them, if it is a server
* then the same deal.
*/
if (IsServer(source_p) || IsMe(source_p))
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ADMIN,
+ {
+ sendto_realops_flags(FLAGS_DEBUG, L_ADMIN,
"Message for %s[%s] from %s",
source_p->name, source_p->from->name,
get_client_name(client_p, SHOW_IP));
- sendto_realops_flags(FLAGS_DEBUG, L_OPER,
- "Message for %s[%s] from %s",
- source_p->name, source_p->from->name,
- get_client_name(client_p, MASK_IP));
-
- if (IsServer(client_p))
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ALL,
- "Not dropping server %s (%s) for Fake Direction",
- client_p->name, source_p->name);
- return -1;
- }
-
- if (IsClient(client_p))
- sendto_realops_flags(FLAGS_DEBUG, L_ALL,
+ sendto_realops_flags(FLAGS_DEBUG, L_OPER,
+ "Message for %s[%s] from %s",
+ source_p->name, source_p->from->name,
+ get_client_name(client_p, MASK_IP));
+
+ if (IsServer(client_p))
+ {
+ sendto_realops_flags(FLAGS_DEBUG, L_ALL,
+ "Not dropping server %s (%s) for Fake Direction",
+ client_p->name, source_p->name);
+ return -1;
+ }
+
+ if (IsClient(client_p))
+ sendto_realops_flags(FLAGS_DEBUG, L_ALL,
"Would have dropped client %s (%s@%s) [%s from %s]",
client_p->name, client_p->username, client_p->host,
client_p->user->server, client_p->from->name);
- return -1;
+ return -1;
- /*
- return exit_client(client_p, client_p, &me, "Fake Direction");
- */
- }
+ /*
+ return exit_client(client_p, client_p, &me, "Fake Direction");
+ */
+ }
/*
* Ok, someone is trying to impose as a client and things are
* confused. If we got the wrong prefix from a server, send out a
* kill, else just exit the lame client.
*/
if (IsServer(client_p))
- {
+ {
/*
- ** If the fake prefix is coming from a TS server, discard it
- ** silently -orabidoo
- **
- ** all servers must be TS these days --is
- */
- if (source_p->user)
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ADMIN,
- "Message for %s[%s@%s!%s] from %s (TS, ignored)",
- source_p->name, source_p->username, source_p->host,
- source_p->from->name, get_client_name(client_p, SHOW_IP));
-
- sendto_realops_flags(FLAGS_DEBUG, L_OPER,
- "Message for %s[%s@%s!%s] from %s (TS, ignored)",
- source_p->name, source_p->username, source_p->host,
- source_p->from->name, get_client_name(client_p, MASK_IP));
- }
-
- return 0;
- }
+ ** If the fake prefix is coming from a TS server, discard it
+ ** silently -orabidoo
+ **
+ ** all servers must be TS these days --is
+ */
+ if (source_p->user)
+ {
+ sendto_realops_flags(FLAGS_DEBUG, L_ADMIN,
+ "Message for %s[%s@%s!%s] from %s (TS, ignored)",
+ source_p->name, source_p->username, source_p->host,
+ source_p->from->name, get_client_name(client_p,
+ SHOW_IP));
+
+ sendto_realops_flags(FLAGS_DEBUG, L_OPER,
+ "Message for %s[%s@%s!%s] from %s (TS, ignored)",
+ source_p->name, source_p->username, source_p->host,
+ source_p->from->name, get_client_name(client_p,
+ MASK_IP));
+ }
+
+ return 0;
+ }
return exit_client(client_p, client_p, &me, "Fake prefix");
}
* output -
* side effects -
*/
-static void remove_unknown(struct Client *client_p,
- char *lsender,
- char *lbuffer)
+static void
+remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
{
if (!IsRegistered(client_p))
return;
if (IsClient(client_p))
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ALL,
- "Weirdness: Unknown client prefix (%s) from %s, Ignoring %s",
+ {
+ sendto_realops_flags(FLAGS_DEBUG, L_ALL,
+ "Weirdness: Unknown client prefix (%s) from %s, Ignoring %s",
lbuffer,
get_client_name(client_p, HIDE_IP), lsender);
- return;
- }
+ return;
+ }
/*
* Not from a server so don't need to worry about it.
sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)",
me.name, lsender, me.name);
else
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ADMIN,
- "Unknown prefix (%s) from %s, Squitting %s",
- lbuffer, get_client_name(client_p, SHOW_IP), lsender);
-
- sendto_realops_flags(FLAGS_DEBUG, L_OPER,
- "Unknown prefix (%s) from %s, Squitting %s",
- lbuffer, client_p->name, lsender);
-
- sendto_one(client_p, ":%s SQUIT %s :(Unknown prefix (%s) from %s)",
- me.name, lsender, lbuffer, client_p->name);
- }
+ {
+ sendto_realops_flags(FLAGS_DEBUG, L_ADMIN,
+ "Unknown prefix (%s) from %s, Squitting %s",
+ lbuffer, get_client_name(client_p, SHOW_IP),
+ lsender);
+
+ sendto_realops_flags(FLAGS_DEBUG, L_OPER,
+ "Unknown prefix (%s) from %s, Squitting %s",
+ lbuffer, client_p->name, lsender);
+
+ sendto_one(client_p, ":%s SQUIT %s :(Unknown prefix (%s) from %s)",
+ me.name, lsender, lbuffer, client_p->name);
+ }
}
** sending back a neat error message -- big danger of creating
** a ping pong error message...
*/
-static void do_numeric(char numeric[],
- struct Client *client_p,
- struct Client *source_p,
- int parc,
- char *parv[])
+static void
+do_numeric(char numeric[],
+ struct Client *client_p,
+ struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p;
struct Channel *chptr;
return;
/* Remap low number numerics. */
- if(numeric[0] == '0')
+ if (numeric[0] == '0')
numeric[0] = '1';
/*
- ** Prepare the parameter portion of the message into 'buffer'.
- ** (Because the buffer is twice as large as the message buffer
- ** for the socket, no overflow can occur here... ...on current
- ** assumptions--bets are off, if these are changed --msa)
- ** Note: if buffer is non-empty, it will begin with SPACE.
- */
+ ** Prepare the parameter portion of the message into 'buffer'.
+ ** (Because the buffer is twice as large as the message buffer
+ ** for the socket, no overflow can occur here... ...on current
+ ** assumptions--bets are off, if these are changed --msa)
+ ** Note: if buffer is non-empty, it will begin with SPACE.
+ */
if (parc > 1)
{
- char *t = buffer; /* Current position within the buffer */
+ char *t = buffer; /* Current position within the buffer */
int i;
- int tl; /* current length of presently being built string in t */
+ int tl; /* current length of presently being built string in t */
for (i = 2; i < (parc - 1); i++)
{
- tl = ircsprintf(t," %s", parv[i]);
+ tl = ircsprintf(t, " %s", parv[i]);
t += tl;
}
- ircsprintf(t," :%s", parv[parc-1]);
+ ircsprintf(t, " :%s", parv[parc - 1]);
}
if ((target_p = find_client(parv[1])) != NULL)
{
- if (IsMe(target_p))
+ if (IsMe(target_p))
{
/*
* We shouldn't get numerics sent to us,
* any numerics we do get indicate a bug somewhere..
*/
sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "*** %s(via %s) sent a %s numeric to me: %s",
- source_p->name, client_p->name, numeric, buffer);
+ "*** %s(via %s) sent a %s numeric to me: %s",
+ source_p->name, client_p->name, numeric, buffer);
return;
}
- else if (target_p->from == client_p)
+ else if (target_p->from == client_p)
{
/* This message changed direction (nick collision?)
* ignore it.
return;
}
/* Fake it for server hiding, if its our client */
- if(ConfigServerHide.hide_servers &&
- MyClient(target_p) && !IsOper(target_p))
+ if (ConfigServerHide.hide_servers &&
+ MyClient(target_p) && !IsOper(target_p))
sendto_one(target_p, ":%s %s %s%s", me.name, numeric, parv[1], buffer);
else
- sendto_one(target_p, ":%s %s %s%s", source_p->name, numeric, parv[1], buffer);
+ sendto_one(target_p, ":%s %s %s%s", source_p->name, numeric, parv[1],
+ buffer);
return;
}
else if ((chptr = hash_find_channel(parv[1])) != NULL)
sendto_channel_local(ALL_MEMBERS, chptr,
- ":%s %s %s %s",
- source_p->name,
- numeric, RootChan(chptr)->chname, buffer);
+ ":%s %s %s %s",
+ source_p->name,
+ numeric, RootChan(chptr)->chname, buffer);
}
* output -
* side effects - just returns a nastyogram to given user
*/
-void m_not_oper(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+void
+m_not_oper(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
}
-void m_unregistered(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+void
+m_unregistered(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
/* bit of a hack.
* I don't =really= want to waste a bit in a flag
* is fully registered..
*/
- if( client_p->localClient->number_of_nick_changes == 0 )
- {
- sendto_one(client_p, ":%s %d * %s :Register first.",
- me.name, ERR_NOTREGISTERED, parv[0]);
- client_p->localClient->number_of_nick_changes++;
- }
+ if (client_p->localClient->number_of_nick_changes == 0)
+ {
+ sendto_one(client_p, ":%s %d * %s :Register first.",
+ me.name, ERR_NOTREGISTERED, parv[0]);
+ client_p->localClient->number_of_nick_changes++;
+ }
}
-void m_registered(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+void
+m_registered(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- sendto_one(client_p, form_str(ERR_ALREADYREGISTRED),
- me.name, parv[0]);
+ sendto_one(client_p, form_str(ERR_ALREADYREGISTRED), me.name, parv[0]);
}
-void m_ignore(struct Client* client_p, struct Client* source_p,
- int parc, char* parv[])
+void
+m_ignore(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
return;
}
-
/*
* restart.c
*
- * $Id: restart.c,v 1.1 2002/01/04 09:14:23 a1kmm Exp $
+ * $Id: restart.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include "tools.h"
#include "restart.h"
#include "send.h"
#include "s_debug.h"
#include "s_log.h"
-#include "client.h" /* for FLAGS_ALL */
+#include "client.h" /* for FLAGS_ALL */
#include "memory.h"
#include <unistd.h>
/* external var */
-extern char** myargv;
+extern char **myargv;
-void restart(char *mesg)
+void
+restart(char *mesg)
{
- static int was_here = NO; /* redundant due to restarting flag below */
+ static int was_here = NO; /* redundant due to restarting flag below */
if (was_here)
abort();
was_here = YES;
ilog(L_NOTICE, "Restarting Server because: %s, memory data limit: %ld",
- mesg, get_maxrss());
+ mesg, get_maxrss());
server_reboot();
}
-void server_reboot(void)
+void
+server_reboot(void)
{
int i;
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Restarting server...");
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Restarting server...");
ilog(L_NOTICE, "Restarting server...");
/*
exit(-1);
}
-
-
* resv.c
* Copyright (C) 2001 Hybrid Development Team
*
- * $Id: resv.c,v 1.1 2002/01/04 09:14:26 a1kmm Exp $
+ * $Id: resv.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include "tools.h"
#include "restart.h"
#include "s_debug.h"
#include "numeric.h"
#include "s_log.h"
-#include "client.h"
+#include "client.h"
#include "memory.h"
#include "resv.h"
#include "hash.h"
len = strlen(name);
- if(len > CHANNELLEN)
+ if (len > CHANNELLEN)
{
len = CHANNELLEN;
name[CHANNELLEN] = '\0';
}
- if(strlen(reason) > TOPICLEN)
+ if (strlen(reason) > TOPICLEN)
reason[TOPICLEN] = '\0';
resv_p = (struct ResvChannel *)hash_find_resv(name);
return NULL;
resv_p = (struct ResvChannel *)MyMalloc(sizeof(struct ResvChannel) + len
- + strlen(reason) + 1);
+ + strlen(reason) + 1);
strcpy(resv_p->name, name);
DupString(resv_p->reason, reason);
resv_p->conf = conf;
- if(ResvChannelList != NULL)
+ if (ResvChannelList != NULL)
ResvChannelList->prev = resv_p;
resv_p->next = ResvChannelList;
len = strlen(name);
- if(len > NICKLEN)
+ if (len > NICKLEN)
{
len = NICKLEN;
name[NICKLEN] = '\0';
}
- if(strlen(reason) > TOPICLEN)
+ if (strlen(reason) > TOPICLEN)
reason[TOPICLEN] = '\0';
- if(find_nick_resv(name))
+ if (find_nick_resv(name))
return NULL;
resv_p = (struct ResvNick *)MyMalloc(sizeof(struct ResvNick) + len
- + strlen(reason) + 1);
+ + strlen(reason) + 1);
strcpy(resv_p->name, name);
DupString(resv_p->reason, reason);
resv_p->conf = conf;
- if(ResvNickList)
+ if (ResvNickList)
ResvNickList->prev = resv_p;
resv_p->next = ResvNickList;
return resv_p;
}
-int
+int
clear_conf_resv()
{
struct ResvChannel *resv_cp;
struct ResvNick *resv_np;
struct ResvNick *next_np;
- for(resv_cp = ResvChannelList; resv_cp; resv_cp = next_cp)
+ for (resv_cp = ResvChannelList; resv_cp; resv_cp = next_cp)
{
next_cp = resv_cp->next;
- if(resv_cp->conf)
+ if (resv_cp->conf)
delete_channel_resv(resv_cp);
}
- for(resv_np = ResvNickList; resv_np; resv_np = next_np)
+ for (resv_np = ResvNickList; resv_np; resv_np = next_np)
{
next_np = resv_np->next;
- if(resv_np->conf)
+ if (resv_np->conf)
delete_nick_resv(resv_np);
}
-
+
return 0;
}
-int
+int
delete_channel_resv(struct ResvChannel *resv_p)
{
- if(!(resv_p))
+ if (!(resv_p))
return 0;
del_from_resv_hash_table(resv_p->name, resv_p);
- if(resv_p->prev)
+ if (resv_p->prev)
resv_p->prev->next = resv_p->next;
else
ResvChannelList = resv_p->next;
- if(resv_p->next)
+ if (resv_p->next)
resv_p->next->prev = resv_p->prev;
MyFree((char *)resv_p);
return 1;
}
-int
+int
delete_nick_resv(struct ResvNick *resv_p)
{
- if(!(resv_p))
+ if (!(resv_p))
return 0;
- if(resv_p->prev)
+ if (resv_p->prev)
resv_p->prev->next = resv_p->next;
else
ResvNickList = resv_p->next;
- if(resv_p->next)
+ if (resv_p->next)
resv_p->next->prev = resv_p->prev;
MyFree((char *)resv_p);
return 1;
}
-int
+int
find_nick_resv(char *name)
{
struct ResvNick *resv_p;
- for(resv_p = ResvNickList; resv_p; resv_p = resv_p->next)
+ for (resv_p = ResvNickList; resv_p; resv_p = resv_p->next)
{
- if(match(resv_p->name, name))
+ if (match(resv_p->name, name))
return 1;
}
-
+
return 0;
}
{
struct ResvNick *resv_p;
- for(resv_p = ResvNickList; resv_p; resv_p = resv_p->next)
+ for (resv_p = ResvNickList; resv_p; resv_p = resv_p->next)
{
- if(!(irccmp(resv_p->name, name)))
+ if (!(irccmp(resv_p->name, name)))
return resv_p;
}
return NULL;
}
-void
+void
report_resv(struct Client *source_p)
{
struct ResvChannel *resv_cp;
struct ResvNick *resv_np;
- for(resv_cp = ResvChannelList; resv_cp; resv_cp = resv_cp->next)
+ for (resv_cp = ResvChannelList; resv_cp; resv_cp = resv_cp->next)
sendto_one(source_p, form_str(RPL_STATSQLINE),
me.name, source_p->name,
- resv_cp->conf ? 'Q' : 'q',
- resv_cp->name, resv_cp->reason);
+ resv_cp->conf ? 'Q' : 'q', resv_cp->name, resv_cp->reason);
- for(resv_np = ResvNickList; resv_np; resv_np = resv_np->next)
+ for (resv_np = ResvNickList; resv_np; resv_np = resv_np->next)
sendto_one(source_p, form_str(RPL_STATSQLINE),
me.name, source_p->name,
- resv_np->conf ? 'Q' : 'q',
- resv_np->name, resv_np->reason);
-}
+ resv_np->conf ? 'Q' : 'q', resv_np->name, resv_np->reason);
+}
int
clean_resv_nick(char *nick)
{
char tmpch;
- int as=0;
- int q=0;
- int ch=0;
+ int as = 0;
+ int q = 0;
+ int ch = 0;
- if(*nick == '-' || IsDigit(*nick))
+ if (*nick == '-' || IsDigit(*nick))
return 0;
-
- while((tmpch = *nick++))
+
+ while ((tmpch = *nick++))
{
- if(tmpch == '?')
+ if (tmpch == '?')
q++;
- else if(tmpch == '*')
+ else if (tmpch == '*')
as++;
- else if(IsNickChar(tmpch))
+ else if (IsNickChar(tmpch))
ch++;
else
return 0;
}
- if(!ch && as)
+ if (!ch && as)
return 0;
return 1;
}
-
*
*
*
- * $Id: rsa.c,v 1.1 2002/01/04 09:14:26 a1kmm Exp $
+ * $Id: rsa.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include "config.h"
#include "rsa.h"
#include "s_conf.h"
#include "s_log.h"
-#include "client.h" /* CIPHERKEYLEN .. eww */
+#include "client.h" /* CIPHERKEYLEN .. eww */
#ifdef HAVE_LIBCRYPTO
void report_crypto_errors(void);
int verify_private_key(void);
-static void binary_to_hex( unsigned char * bin, char * hex, int length );
+static void binary_to_hex(unsigned char *bin, char *hex, int length);
+
-
/*
* report_crypto_errors - Dump crypto error list to log
*/
-void report_crypto_errors(void)
+void
+report_crypto_errors(void)
{
unsigned long e = 0;
unsigned long cnt = 0;
ERR_load_crypto_strings();
- while ( (cnt < 100) && (e = ERR_get_error()) )
+ while ((cnt < 100) && (e = ERR_get_error()))
{
ilog(L_CRIT, "SSL error: %s", ERR_error_string(e, 0));
cnt++;
/*
* verify_private_key - reread private key and verify against inmem key
*/
-int verify_private_key(void)
+int
+verify_private_key(void)
{
- BIO * file;
- RSA * key;
- RSA * mkey;
+ BIO *file;
+ RSA *key;
+ RSA *mkey;
/* If the rsa_private_key directive isn't found, error out. */
if (ServerInfo.rsa_private_key == NULL)
{
ilog(L_NOTICE, "rsa_private_key in serverinfo{} is not defined.");
- return(-1);
+ return (-1);
}
/* If rsa_private_key_file isn't available, error out. */
if (ServerInfo.rsa_private_key_file == NULL)
{
ilog(L_NOTICE, "Internal error: rsa_private_key_file isn't defined.");
- return(-1);
+ return (-1);
}
file = BIO_new_file(ServerInfo.rsa_private_key_file, "r");
if (file == NULL)
{
ilog(L_NOTICE, "Failed to open private key file - can't validate it");
- return(-1);
+ return (-1);
}
/*
* For some reason the system thinks PEM_read_bio_RSAPrivateKey
* is returning an int, not a RSA *.
* androsyn -- Thats because you didn't have a prototype and including
- * pem.h breaks things for some reason..
+ * pem.h breaks things for some reason..
*/
key = (RSA *) PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
{
ilog(L_NOTICE, "PEM_read_bio_RSAPrivateKey() failed; possibly not RSA?");
report_crypto_errors();
- return(-1);
+ return (-1);
}
BIO_set_close(file, BIO_CLOSE);
*/
if (mkey->pad != key->pad)
ilog(L_CRIT, "Private key corrupted: pad %i != pad %i",
- mkey->pad, key->pad);
+ mkey->pad, key->pad);
if (mkey->version != key->version)
ilog(L_CRIT, "Private key corrupted: version %i != version %i",
- mkey->version, key->version);
+ mkey->version, key->version);
if (BN_cmp(mkey->n, key->n))
ilog(L_CRIT, "Private key corrupted: n differs");
ilog(L_CRIT, "Private key corrupted: iqmp differs");
RSA_free(key);
- return(0);
+ return (0);
}
-static void binary_to_hex( unsigned char * bin, char * hex, int length )
+static void
+binary_to_hex(unsigned char *bin, char *hex, int length)
{
- char * trans = "0123456789ABCDEF";
+ char *trans = "0123456789ABCDEF";
int i;
- for( i = 0; i < length; i++ )
+ for (i = 0; i < length; i++)
{
- hex[i<<1] = trans[bin[i] >> 4];
- hex[(i<<1)+1] = trans[bin[i] & 0xf];
+ hex[i << 1] = trans[bin[i] >> 4];
+ hex[(i << 1) + 1] = trans[bin[i] & 0xf];
}
- hex[i<<1] = '\0';
+ hex[i << 1] = '\0';
}
-int get_randomness( unsigned char * buf, int length )
+int
+get_randomness(unsigned char *buf, int length)
{
- /* Seed OpenSSL PRNG with EGD enthropy pool -kre */
- if (ConfigFileEntry.use_egd &&
- (ConfigFileEntry.egdpool_path != NULL))
- {
- if (RAND_egd(ConfigFileEntry.egdpool_path) == -1)
- return -1;
- }
-
- if ( RAND_status() )
- return RAND_bytes( buf, length );
- else /* XXX - abort? */
- return RAND_pseudo_bytes( buf, length );
+ /* Seed OpenSSL PRNG with EGD enthropy pool -kre */
+ if (ConfigFileEntry.use_egd && (ConfigFileEntry.egdpool_path != NULL))
+ {
+ if (RAND_egd(ConfigFileEntry.egdpool_path) == -1)
+ return -1;
+ }
+
+ if (RAND_status())
+ return RAND_bytes(buf, length);
+ else /* XXX - abort? */
+ return RAND_pseudo_bytes(buf, length);
}
-int generate_challenge( char **, char **, RSA *);
-int generate_challenge( char ** r_challenge, char ** r_response, RSA *rsa )
+int generate_challenge(char **, char **, RSA *);
+int
+generate_challenge(char **r_challenge, char **r_response, RSA * rsa)
{
unsigned char secret[32], *tmp;
unsigned long length, ret;
- if(!rsa)
- return -1;
+ if (!rsa)
+ return -1;
get_randomness(secret, 32);
*r_response = MyMalloc(65);
binary_to_hex(secret, *r_response, 32);
tmp = MyMalloc(length);
ret = RSA_public_encrypt(32, secret, tmp, rsa, RSA_PKCS1_PADDING);
- *r_challenge = MyMalloc( (length << 1) + 1 );
- binary_to_hex( tmp, *r_challenge, length );
- (*r_challenge)[length<<1] = 0;
+ *r_challenge = MyMalloc((length << 1) + 1);
+ binary_to_hex(tmp, *r_challenge, length);
+ (*r_challenge)[length << 1] = 0;
MyFree(tmp);
if (ret < 0)
{
report_crypto_errors();
- return(-1);
+ return (-1);
}
- return(0);
+ return (0);
}
#endif /* HAVE_LIBCRYPTO */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_auth.c,v 1.1 2002/01/04 09:14:26 a1kmm Exp $
+ * $Id: s_auth.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*
* Changes:
* July 6, 1999 - Rewrote most of the code here. When a client connects
#include "client.h"
#include "common.h"
#include "event.h"
-#include "fdlist.h" /* fdlist_add */
+#include "fdlist.h" /* fdlist_add */
#include "irc_string.h"
#include "ircd.h"
#include "ircdauth.h"
#include "memory.h"
#include "config.h"
-#include <netdb.h> /* struct hostent */
+#include <netdb.h> /* struct hostent */
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
* a bit different approach
* this replaces the original sendheader macros
*/
-static struct {
- const char* message;
- size_t length;
-} HeaderMessages [] = {
+static struct
+{
+ const char *message;
+ size_t length;
+}
+HeaderMessages[] =
+{
/* 123456789012345678901234567890123456789012345678901234567890 */
- { "NOTICE AUTH :*** Looking up your hostname...\r\n", 46 },
- { "NOTICE AUTH :*** Found your hostname\r\n", 38 },
- { "NOTICE AUTH :*** Found your hostname, cached\r\n", 46 },
- { "NOTICE AUTH :*** Couldn't look up your hostname\r\n", 49 },
- { "NOTICE AUTH :*** Checking Ident\r\n", 33 },
- { "NOTICE AUTH :*** Got Ident response\r\n", 37 },
- { "NOTICE AUTH :*** No Ident response\r\n", 36 },
- { "NOTICE AUTH :*** Your forward and reverse DNS do not match, " \
- "ignoring hostname.\r\n", 80 },
- { "NOTICE AUTH :*** Your hostname is too long, ignoring hostname\r\n", 63 }
+ {
+ "NOTICE AUTH :*** Looking up your hostname...\r\n", 46}
+ ,
+ {
+ "NOTICE AUTH :*** Found your hostname\r\n", 38}
+ ,
+ {
+ "NOTICE AUTH :*** Found your hostname, cached\r\n", 46}
+ ,
+ {
+ "NOTICE AUTH :*** Couldn't look up your hostname\r\n", 49}
+ ,
+ {
+ "NOTICE AUTH :*** Checking Ident\r\n", 33}
+ ,
+ {
+ "NOTICE AUTH :*** Got Ident response\r\n", 37}
+ ,
+ {
+ "NOTICE AUTH :*** No Ident response\r\n", 36}
+ ,
+ {
+ "NOTICE AUTH :*** Your forward and reverse DNS do not match, "
+ "ignoring hostname.\r\n", 80}
+ ,
+ {
+ "NOTICE AUTH :*** Your hostname is too long, ignoring hostname\r\n", 63}
};
-typedef enum {
+typedef enum
+{
REPORT_DO_DNS,
REPORT_FIN_DNS,
REPORT_FIN_DNSC,
REPORT_FAIL_ID,
REPORT_IP_MISMATCH,
REPORT_HOST_TOOLONG
-} ReportType;
+}
+ReportType;
#define sendheader(c, r) \
send((c)->fd, HeaderMessages[(r)].message, HeaderMessages[(r)].length, 0)
/*
* make_auth_request - allocate a new auth request
*/
-static struct AuthRequest* make_auth_request(struct Client* client)
+static struct AuthRequest *
+make_auth_request(struct Client *client)
{
- struct AuthRequest* request =
+ struct AuthRequest *request =
(struct AuthRequest *)MyMalloc(sizeof(struct AuthRequest));
- request->fd = -1;
- request->client = client;
+ request->fd = -1;
+ request->client = client;
request->timeout = CurrentTime + CONNECTTIMEOUT;
return request;
}
/*
* free_auth_request - cleanup auth request allocations
*/
-void free_auth_request(struct AuthRequest* request)
+void
+free_auth_request(struct AuthRequest *request)
{
MyFree(request);
}
/*
* unlink_auth_request - remove auth request from a list
*/
-static void unlink_auth_request(struct AuthRequest* request, dlink_list *list)
+static void
+unlink_auth_request(struct AuthRequest *request, dlink_list * list)
{
dlink_node *ptr;
dlink_node *next_ptr;
struct AuthRequest *auth;
- for (ptr = list->head; ptr; ptr = next_ptr )
+ for (ptr = list->head; ptr; ptr = next_ptr)
+ {
+ next_ptr = ptr->next;
+ auth = ptr->data;
+
+ if (auth == request)
{
- next_ptr = ptr->next;
- auth = ptr->data;
-
- if (auth == request)
- {
- dlinkDelete(ptr, list);
- free_dlink_node(ptr);
- return;
- }
+ dlinkDelete(ptr, list);
+ free_dlink_node(ptr);
+ return;
}
+ }
}
/*
* link_auth_request - add auth request to a list
*/
-static void link_auth_request(struct AuthRequest* request, dlink_list *list)
+static void
+link_auth_request(struct AuthRequest *request, dlink_list * list)
{
dlink_node *m;
* this adds the client into the local client lists so it can be read by
* the main io processing loop
*/
-static void release_auth_client(struct Client* client)
+static void
+release_auth_client(struct Client *client)
{
if (client->fd > highest_fd)
highest_fd = client->fd;
comm_setflush(client->fd, 1000, flood_recalc, client);
add_client_to_list(client);
comm_setselect(client->fd, FDLIST_IDLECLIENT, COMM_SELECT_READ, read_packet,
- client, 0);
+ client, 0);
}
-
+
/*
* auth_dns_callback - called when resolver query finishes
* if the query resulted in a successful search, hp will contain
* set the client on it's way to a connection completion, regardless
* of success of failure
*/
-static void auth_dns_callback(void* vptr, adns_answer* reply)
+static void
+auth_dns_callback(void *vptr, adns_answer * reply)
{
-
- struct AuthRequest* auth = (struct AuthRequest*) vptr;
+
+ struct AuthRequest *auth = (struct AuthRequest *)vptr;
char *str = auth->client->host;
ClearDNSPending(auth);
*auth->client->host = '\0';
- if(reply && (reply->status == adns_s_ok))
+ if (reply && (reply->status == adns_s_ok))
+ {
+ if (strlen(*reply->rrs.str) < HOSTLEN)
{
- if(strlen(*reply->rrs.str) < HOSTLEN)
- {
- strcpy(str, *reply->rrs.str);
- sendheader(auth->client, REPORT_FIN_DNS);
- }
- else
- {
-#ifdef IPV6
- if(*auth->client->localClient->sockhost == ':')
- {
- strcat(str, "0");
- }
- if(auth->client->localClient->aftype == AF_INET6 && ConfigFileEntry.dot_in_ip6_addr == 1)
- {
- strcat(str, auth->client->localClient->sockhost);
- strcat(str, ".");
- } else
-#endif
- strcat(str, auth->client->localClient->sockhost);
- sendheader(auth->client, REPORT_HOST_TOOLONG);
- }
+ strcpy(str, *reply->rrs.str);
+ sendheader(auth->client, REPORT_FIN_DNS);
}
- else
+ else
{
#ifdef IPV6
- if(*auth->client->localClient->sockhost == ':')
+ if (*auth->client->localClient->sockhost == ':')
{
- strcat(str, "0");
+ strcat(str, "0");
}
- if(auth->client->localClient->aftype == AF_INET6 && ConfigFileEntry.dot_in_ip6_addr == 1)
+ if (auth->client->localClient->aftype == AF_INET6
+ && ConfigFileEntry.dot_in_ip6_addr == 1)
{
strcat(str, auth->client->localClient->sockhost);
strcat(str, ".");
- sendheader(auth->client, REPORT_FAIL_DNS);
- } else
+ }
+ else
#endif
- strcat(str, auth->client->localClient->sockhost);
+ strcat(str, auth->client->localClient->sockhost);
+ sendheader(auth->client, REPORT_HOST_TOOLONG);
+ }
+ }
+ else
+ {
+#ifdef IPV6
+ if (*auth->client->localClient->sockhost == ':')
+ {
+ strcat(str, "0");
+ }
+ if (auth->client->localClient->aftype == AF_INET6
+ && ConfigFileEntry.dot_in_ip6_addr == 1)
+ {
+ strcat(str, auth->client->localClient->sockhost);
+ strcat(str, ".");
sendheader(auth->client, REPORT_FAIL_DNS);
}
+ else
+#endif
+ strcat(str, auth->client->localClient->sockhost);
+ sendheader(auth->client, REPORT_FAIL_DNS);
+ }
MyFree(reply);
MyFree(auth->client->localClient->dns_query);
auth->client->localClient->dns_query = NULL;
if (!IsDoingAuth(auth))
- {
- unlink_auth_request(auth, &auth_poll_list);
- release_auth_client(auth->client);
+ {
+ unlink_auth_request(auth, &auth_poll_list);
+ release_auth_client(auth->client);
#ifdef USE_IAUTH
- ilog(L_ERROR, "Linking to auth client list");
- link_auth_request(auth, &auth_client_list);
+ ilog(L_ERROR, "Linking to auth client list");
+ link_auth_request(auth, &auth_client_list);
#else
- free_auth_request(auth);
+ free_auth_request(auth);
#endif
- }
+ }
}
/*
* authsenderr - handle auth send errors
*/
-static void auth_error(struct AuthRequest* auth)
+static void
+auth_error(struct AuthRequest *auth)
{
++ServerStats->is_abad;
* identifing process fail, it is aborted and the user is given a username
* of "unknown".
*/
-static int start_auth_query(struct AuthRequest* auth)
+static int
+start_auth_query(struct AuthRequest *auth)
{
/* struct sockaddr_in sock; */
struct irc_sockaddr localaddr;
socklen_t locallen = sizeof(struct irc_sockaddr);
- int fd;
+ int fd;
if ((fd = comm_open(DEF_FAM, SOCK_STREAM, 0, "ident")) == -1)
- {
- report_error(L_ALL, "creating auth stream socket %s:%s",
- get_client_name(auth->client, SHOW_IP), errno);
- ilog(L_ERROR, "Unable to create auth socket for %s:%m",
- get_client_name(auth->client, SHOW_IP));
- ++ServerStats->is_abad;
- return 0;
- }
+ {
+ report_error(L_ALL, "creating auth stream socket %s:%s",
+ get_client_name(auth->client, SHOW_IP), errno);
+ ilog(L_ERROR, "Unable to create auth socket for %s:%m",
+ get_client_name(auth->client, SHOW_IP));
+ ++ServerStats->is_abad;
+ return 0;
+ }
if ((MAXCONNECTIONS - 10) < fd)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"Can't allocate fd for auth on %s",
- get_client_name(auth->client, SHOW_IP));
- fd_close(fd);
- return 0;
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Can't allocate fd for auth on %s",
+ get_client_name(auth->client, SHOW_IP));
+ fd_close(fd);
+ return 0;
+ }
sendheader(auth->client, REPORT_DO_ID);
if (!set_non_blocking(fd))
- {
- report_error(L_ALL, NONB_ERROR_MSG, get_client_name(auth->client, SHOW_IP), errno);
- fd_close(fd);
- return 0;
- }
+ {
+ report_error(L_ALL, NONB_ERROR_MSG,
+ get_client_name(auth->client, SHOW_IP), errno);
+ fd_close(fd);
+ return 0;
+ }
/*
* get the local address of the client and bind to that to
* and machines with multiple IP addresses are common now
*/
memset(&localaddr, 0, locallen);
- getsockname(auth->client->fd, (struct sockaddr*)&SOCKADDR(localaddr), (unsigned int*)&locallen);
+ getsockname(auth->client->fd, (struct sockaddr *)&SOCKADDR(localaddr),
+ (unsigned int *)&locallen);
S_PORT(localaddr) = htons(0);
auth->fd = fd;
SetAuthConnect(auth);
-
- comm_connect_tcp(fd, auth->client->localClient->sockhost, 113,
- (struct sockaddr *)&SOCKADDR(localaddr), locallen, auth_connect_callback, auth, DEF_FAM, 10);
- return 1; /* We suceed here for now */
+
+ comm_connect_tcp(fd, auth->client->localClient->sockhost, 113,
+ (struct sockaddr *)&SOCKADDR(localaddr), locallen,
+ auth_connect_callback, auth, DEF_FAM, 10);
+ return 1; /* We suceed here for now */
}
/*
* Output - NULL if no valid ident found, otherwise pointer to name
* Side effects -
*/
-static char* GetValidIdent(char *buf)
+static char *
+GetValidIdent(char *buf)
{
- int remp = 0;
- int locp = 0;
- char* colon1Ptr;
- char* colon2Ptr;
- char* colon3Ptr;
- char* commaPtr;
- char* remotePortString;
+ int remp = 0;
+ int locp = 0;
+ char *colon1Ptr;
+ char *colon2Ptr;
+ char *colon3Ptr;
+ char *commaPtr;
+ char *remotePortString;
/* All this to get rid of a sscanf() fun. */
remotePortString = buf;
-
- colon1Ptr = strchr(remotePortString,':');
- if(!colon1Ptr)
+
+ colon1Ptr = strchr(remotePortString, ':');
+ if (!colon1Ptr)
return 0;
*colon1Ptr = '\0';
colon1Ptr++;
- colon2Ptr = strchr(colon1Ptr,':');
- if(!colon2Ptr)
+ colon2Ptr = strchr(colon1Ptr, ':');
+ if (!colon2Ptr)
return 0;
*colon2Ptr = '\0';
colon2Ptr++;
commaPtr = strchr(remotePortString, ',');
- if(!commaPtr)
+ if (!commaPtr)
return 0;
*commaPtr = '\0';
commaPtr++;
remp = atoi(remotePortString);
- if(!remp)
+ if (!remp)
return 0;
-
+
locp = atoi(commaPtr);
- if(!locp)
+ if (!locp)
return 0;
/* look for USERID bordered by first pair of colons */
- if(!strstr(colon1Ptr, "USERID"))
+ if (!strstr(colon1Ptr, "USERID"))
return 0;
- colon3Ptr = strchr(colon2Ptr,':');
- if(!colon3Ptr)
+ colon3Ptr = strchr(colon2Ptr, ':');
+ if (!colon3Ptr)
return 0;
-
+
*colon3Ptr = '\0';
colon3Ptr++;
- return(colon3Ptr);
+ return (colon3Ptr);
}
/*
* start_auth - starts auth (identd) and dns queries for a client
*/
-void start_auth(struct Client* client)
+void
+start_auth(struct Client *client)
{
- struct AuthRequest* auth = 0;
+ struct AuthRequest *auth = 0;
assert(0 != client);
auth = make_auth_request(client);
sendheader(client, REPORT_DO_DNS);
/* No DNS cache now, remember? -- adrian */
- adns_getaddr(&client->localClient->ip, client->localClient->aftype, client->localClient->dns_query);
+ adns_getaddr(&client->localClient->ip, client->localClient->aftype,
+ client->localClient->dns_query);
SetDNSPending(auth);
start_auth_query(auth);
{
dlink_node *ptr;
dlink_node *next_ptr;
- struct AuthRequest* auth;
+ struct AuthRequest *auth;
for (ptr = auth_poll_list.head; ptr; ptr = next_ptr)
+ {
+ next_ptr = ptr->next;
+ auth = ptr->data;
+
+ if (auth->timeout < CurrentTime)
{
- next_ptr = ptr->next;
- auth = ptr->data;
-
- if (auth->timeout < CurrentTime)
- {
- if (auth->fd >= 0)
- fd_close(auth->fd);
-
- if (IsDoingAuth(auth))
- sendheader(auth->client, REPORT_FAIL_ID);
- if (IsDNSPending(auth))
- {
- delete_adns_queries(auth->client->localClient->dns_query);
- auth->client->localClient->dns_query->query = NULL;
- sendheader(auth->client, REPORT_FAIL_DNS);
- }
- ilog(L_INFO, "DNS/AUTH timeout %s",
- get_client_name(auth->client, SHOW_IP));
-
- auth->client->since = CurrentTime;
- release_auth_client(auth->client);
- dlinkDelete(ptr, &auth_poll_list);
- free_dlink_node(ptr);
+ if (auth->fd >= 0)
+ fd_close(auth->fd);
+
+ if (IsDoingAuth(auth))
+ sendheader(auth->client, REPORT_FAIL_ID);
+ if (IsDNSPending(auth))
+ {
+ delete_adns_queries(auth->client->localClient->dns_query);
+ auth->client->localClient->dns_query->query = NULL;
+ sendheader(auth->client, REPORT_FAIL_DNS);
+ }
+ ilog(L_INFO, "DNS/AUTH timeout %s",
+ get_client_name(auth->client, SHOW_IP));
+
+ auth->client->since = CurrentTime;
+ release_auth_client(auth->client);
+ dlinkDelete(ptr, &auth_poll_list);
+ free_dlink_node(ptr);
#ifdef USE_IAUTH
- ilog(L_ERROR, "linking to auth client list 3");
- link_auth_request(auth, &auth_client_list);
+ ilog(L_ERROR, "linking to auth client list 3");
+ link_auth_request(auth, &auth_client_list);
#else
- free_auth_request(auth);
+ free_auth_request(auth);
#endif
- }
}
+ }
}
/*
* a write buffer far greater than this message to store it in should
* problems arise. -avalon
*/
-static
-void auth_connect_callback(int fd, int error, void *data)
+static void
+auth_connect_callback(int fd, int error, void *data)
{
struct AuthRequest *auth = data;
struct sockaddr_in us;
/* Check the error */
if (error != COMM_OK)
- {
- /* We had an error during connection :( */
- auth_error(auth);
- return;
- }
+ {
+ /* We had an error during connection :( */
+ auth_error(auth);
+ return;
+ }
- if (getsockname(auth->client->fd, (struct sockaddr *)&us, (unsigned int*)&ulen) ||
- getpeername(auth->client->fd, (struct sockaddr *)&them, (unsigned int*)&tlen))
- {
- ilog(L_INFO, "auth get{sock,peer}name error for %s:%m",
- get_client_name(auth->client, SHOW_IP));
- auth_error(auth);
- return;
- }
+ if (getsockname
+ (auth->client->fd, (struct sockaddr *)&us, (unsigned int *)&ulen)
+ || getpeername(auth->client->fd, (struct sockaddr *)&them,
+ (unsigned int *)&tlen))
+ {
+ ilog(L_INFO, "auth get{sock,peer}name error for %s:%m",
+ get_client_name(auth->client, SHOW_IP));
+ auth_error(auth);
+ return;
+ }
ircsprintf(authbuf, "%u , %u\r\n",
- (unsigned int) ntohs(them.sin_port),
- (unsigned int) ntohs(us.sin_port));
+ (unsigned int)ntohs(them.sin_port),
+ (unsigned int)ntohs(us.sin_port));
if (send(auth->fd, authbuf, strlen(authbuf), 0) == -1)
- {
- auth_error(auth);
- return;
- }
+ {
+ auth_error(auth);
+ return;
+ }
ClearAuthConnect(auth);
SetAuthPending(auth);
/* Its idle, because we don't mind this taking a little time -- adrian */
comm_setselect(auth->fd, FDLIST_IDLECLIENT, COMM_SELECT_READ,
- read_auth_reply, auth, 0);
+ read_auth_reply, auth, 0);
}
read_auth_reply(int fd, void *data)
{
struct AuthRequest *auth = data;
- char* s=(char *)NULL;
- char* t=(char *)NULL;
- int len;
- int count;
- char buf[AUTH_BUFSIZ + 1]; /* buffer to read auth reply into */
+ char *s = (char *)NULL;
+ char *t = (char *)NULL;
+ int len;
+ int count;
+ char buf[AUTH_BUFSIZ + 1]; /* buffer to read auth reply into */
len = recv(auth->fd, buf, AUTH_BUFSIZ, 0);
-
+
if (len < 0 && ignoreErrno(errno))
{
comm_setselect(fd, FDLIST_IDLECLIENT, COMM_SELECT_READ,
}
if (len > 0)
+ {
+ buf[len] = '\0';
+
+ if ((s = GetValidIdent(buf)))
{
- buf[len] = '\0';
-
- if( (s = GetValidIdent(buf)) )
- {
- t = auth->client->username;
- for (count = USERLEN; *s && count; s++)
- {
- if(*s == '@')
- {
- break;
- }
- if ( !IsSpace(*s) && *s != ':' )
- {
- *t++ = *s;
- count--;
- }
- }
- *t = '\0';
- }
+ t = auth->client->username;
+ for (count = USERLEN; *s && count; s++)
+ {
+ if (*s == '@')
+ {
+ break;
+ }
+ if (!IsSpace(*s) && *s != ':')
+ {
+ *t++ = *s;
+ count--;
+ }
+ }
+ *t = '\0';
}
+ }
fd_close(auth->fd);
auth->fd = -1;
ClearAuth(auth);
-
+
if (!s)
- {
- ++ServerStats->is_abad;
- strcpy(auth->client->username, "unknown");
- }
+ {
+ ++ServerStats->is_abad;
+ strcpy(auth->client->username, "unknown");
+ }
else
- {
- sendheader(auth->client, REPORT_FIN_ID);
- ++ServerStats->is_asuc;
- SetGotId(auth->client);
- }
+ {
+ sendheader(auth->client, REPORT_FIN_ID);
+ ++ServerStats->is_asuc;
+ SetGotId(auth->client);
+ }
if (!IsDNSPending(auth))
- {
- unlink_auth_request(auth, &auth_poll_list);
- release_auth_client(auth->client);
+ {
+ unlink_auth_request(auth, &auth_poll_list);
+ release_auth_client(auth->client);
#ifdef USE_IAUTH
ilog(L_ERROR, "linking to auth client list 4");
- link_auth_request(auth, &auth_client_list);
+ link_auth_request(auth, &auth_client_list);
#else
- free_auth_request(auth);
+ free_auth_request(auth);
#endif
- }
+ }
}
/*
void
remove_auth_request(struct AuthRequest *auth)
-
{
unlink_auth_request(auth, &auth_client_list);
free_auth_request(auth);
-} /* remove_auth_request() */
+} /* remove_auth_request() */
/*
* FindAuthClient()
struct AuthRequest *auth;
for (ptr = auth_client_list.head; ptr; ptr = ptr->next)
- {
- auth = ptr->data;
- if( auth->client == (struct Client *)id)
- return auth;
- }
+ {
+ auth = ptr->data;
+ if (auth->client == (struct Client *)id)
+ return auth;
+ }
return (NULL);
-} /* FindAuthClient() */
+} /* FindAuthClient() */
/*
* delete_identd_queries()
*
*/
-void
+void
delete_identd_queries(struct Client *target_p)
{
dlink_node *ptr;
dlink_node *next_ptr;
- struct AuthRequest* auth;
+ struct AuthRequest *auth;
for (ptr = auth_poll_list.head; ptr; ptr = next_ptr)
+ {
+ auth = ptr->data;
+ next_ptr = ptr->next;
+
+ if (auth->client == target_p)
{
- auth = ptr->data;
- next_ptr = ptr->next;
-
- if(auth->client == target_p)
- {
- if (auth->fd >= 0)
- fd_close(auth->fd);
- dlinkDelete(ptr, &auth_poll_list);
- free_auth_request(auth);
- free_dlink_node(ptr);
- }
+ if (auth->fd >= 0)
+ fd_close(auth->fd);
+ dlinkDelete(ptr, &auth_poll_list);
+ free_auth_request(auth);
+ free_dlink_node(ptr);
}
+ }
for (ptr = auth_client_list.head; ptr; ptr = next_ptr)
+ {
+ auth = ptr->data;
+ next_ptr = ptr->next;
+
+ if (auth->client == target_p)
{
- auth = ptr->data;
- next_ptr = ptr->next;
-
- if(auth->client == target_p)
- {
- if (auth->fd >= 0)
- fd_close(auth->fd);
- dlinkDelete(ptr, &auth_client_list);
- free_auth_request(auth);
- free_dlink_node(ptr);
- }
+ if (auth->fd >= 0)
+ fd_close(auth->fd);
+ dlinkDelete(ptr, &auth_client_list);
+ free_auth_request(auth);
+ free_dlink_node(ptr);
}
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_bsd.c,v 1.1 2002/01/04 09:14:30 a1kmm Exp $
+ * $Id: s_bsd.c,v 1.2 2002/01/04 11:06:41 a1kmm Exp $
*/
#include "config.h"
#include "fdlist.h"
#include <sys/ioctl.h>
#include <sys/resource.h>
#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h> /* NOFILE */
+#include <sys/param.h> /* NOFILE */
#endif
#include <arpa/inet.h>
#define INADDR_NONE ((unsigned int) 0xffffffff)
#endif
-const char* const NONB_ERROR_MSG = "set_non_blocking failed for %s:%s";
-const char* const OPT_ERROR_MSG = "disable_sock_options failed for %s:%s";
-const char* const SETBUF_ERROR_MSG = "set_sock_buffers failed for server %s:%s";
+const char *const NONB_ERROR_MSG = "set_non_blocking failed for %s:%s";
+const char *const OPT_ERROR_MSG = "disable_sock_options failed for %s:%s";
+const char *const SETBUF_ERROR_MSG =
+ "set_sock_buffers failed for server %s:%s";
static const char *comm_err_str[] = { "Comm OK", "Error during bind()",
"Error during DNS lookup", "connect timeout", "Error during connect()",
- "Comm Error" };
+ "Comm Error"
+};
static void comm_connect_callback(int fd, int status);
static PF comm_connect_timeout;
-static void comm_connect_dns_callback(void *vptr, adns_answer *reply);
+static void comm_connect_dns_callback(void *vptr, adns_answer * reply);
static PF comm_connect_tryconnect;
/* close_all_connections() can be used *before* the system come up! */
-void close_all_connections(void)
+void
+close_all_connections(void)
{
int i;
#ifndef NDEBUG
#endif
#endif
- for (i = 4; i < MAXCONNECTIONS; ++i)
+ for (i = 4; i < MAXCONNECTIONS; ++i)
{
if (fd_table[i].flags.open)
fd_close(i);
#ifndef NDEBUG
/* fugly hack to reserve fd == 2 */
(void)close(2);
- fd = open("stderr.log",O_WRONLY|O_CREAT|O_APPEND,0644);
- if( fd >= 0 )
- {
- dup2(fd, 2);
- close(fd);
- }
+ fd = open("stderr.log", O_WRONLY | O_CREAT | O_APPEND, 0644);
+ if (fd >= 0)
+ {
+ dup2(fd, 2);
+ close(fd);
+ }
#endif
}
* This may only work when SO_DEBUG is enabled but its worth the
* gamble anyway.
*/
-int get_sockerr(int fd)
+int
+get_sockerr(int fd)
{
int errtmp = errno;
#ifdef SO_ERROR
int err = 0;
socklen_t len = sizeof(err);
- if (-1 < fd && !getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*) &err, (unsigned int *)&len)) {
+ if (-1 < fd
+ && !getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&err,
+ (unsigned int *)&len))
+ {
if (err)
errtmp = err;
}
* Actually stderr is still there IFF ircd was run with -s --Rodder
*/
-void report_error(int level, const char* text, const char* who, int error)
+void
+report_error(int level, const char *text, const char *who, int error)
{
who = (who) ? who : "";
* output - returns true (1) if successful, false (0) otherwise
* side effects -
*/
-int set_sock_buffers(int fd, int size)
+int
+set_sock_buffers(int fd, int size)
{
- if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*) &size, sizeof(size)) ||
- setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*) &size, sizeof(size)))
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size)) ||
+ setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size)))
return 0;
return 1;
}
* side effects - disable_sock_options - if remote has any socket options set,
* disable them
*/
-int disable_sock_options(int fd)
+int
+disable_sock_options(int fd)
{
#if defined(IP_OPTIONS) && defined(IPPROTO_IP)
if (setsockopt(fd, IPPROTO_IP, IP_OPTIONS, NULL, 0))
* side effects - use POSIX compliant non blocking and
* be done with it.
*/
-int set_non_blocking(int fd)
+int
+set_non_blocking(int fd)
{
#ifndef VMS
int nonb = 0;
* Close the physical connection. This function must make
* MyConnect(client_p) == FALSE, and set client_p->from == NULL.
*/
-void close_connection(struct Client *client_p)
+void
+close_connection(struct Client *client_p)
{
struct ConfItem *aconf;
assert(0 != client_p);
if (IsServer(client_p))
+ {
+ ServerStats->is_sv++;
+ ServerStats->is_sbs += client_p->localClient->sendB;
+ ServerStats->is_sbr += client_p->localClient->receiveB;
+ ServerStats->is_sks += client_p->localClient->sendK;
+ ServerStats->is_skr += client_p->localClient->receiveK;
+ ServerStats->is_sti += CurrentTime - client_p->firsttime;
+ if (ServerStats->is_sbs > 2047)
+ {
+ ServerStats->is_sks += (ServerStats->is_sbs >> 10);
+ ServerStats->is_sbs &= 0x3ff;
+ }
+ if (ServerStats->is_sbr > 2047)
+ {
+ ServerStats->is_skr += (ServerStats->is_sbr >> 10);
+ ServerStats->is_sbr &= 0x3ff;
+ }
+ /*
+ * If the connection has been up for a long amount of time, schedule
+ * a 'quick' reconnect, else reset the next-connect cycle.
+ */
+ if ((aconf = find_conf_exact(client_p->name, client_p->username,
+ client_p->host, CONF_SERVER)))
{
- ServerStats->is_sv++;
- ServerStats->is_sbs += client_p->localClient->sendB;
- ServerStats->is_sbr += client_p->localClient->receiveB;
- ServerStats->is_sks += client_p->localClient->sendK;
- ServerStats->is_skr += client_p->localClient->receiveK;
- ServerStats->is_sti += CurrentTime - client_p->firsttime;
- if (ServerStats->is_sbs > 2047)
- {
- ServerStats->is_sks += (ServerStats->is_sbs >> 10);
- ServerStats->is_sbs &= 0x3ff;
- }
- if (ServerStats->is_sbr > 2047)
- {
- ServerStats->is_skr += (ServerStats->is_sbr >> 10);
- ServerStats->is_sbr &= 0x3ff;
- }
/*
- * If the connection has been up for a long amount of time, schedule
- * a 'quick' reconnect, else reset the next-connect cycle.
+ * Reschedule a faster reconnect, if this was a automatically
+ * connected configuration entry. (Note that if we have had
+ * a rehash in between, the status has been changed to
+ * CONF_ILLEGAL). But only do this if it was a "good" link.
*/
- if ((aconf = find_conf_exact(client_p->name, client_p->username,
- client_p->host, CONF_SERVER)))
- {
- /*
- * Reschedule a faster reconnect, if this was a automatically
- * connected configuration entry. (Note that if we have had
- * a rehash in between, the status has been changed to
- * CONF_ILLEGAL). But only do this if it was a "good" link.
- */
- aconf->hold = time(NULL);
- aconf->hold += (aconf->hold - client_p->since > HANGONGOODLINK) ?
- HANGONRETRYDELAY : ConfConFreq(aconf);
- if (nextconnect > aconf->hold)
- nextconnect = aconf->hold;
- }
-
+ aconf->hold = time(NULL);
+ aconf->hold += (aconf->hold - client_p->since > HANGONGOODLINK) ?
+ HANGONRETRYDELAY : ConfConFreq(aconf);
+ if (nextconnect > aconf->hold)
+ nextconnect = aconf->hold;
}
+
+ }
else if (IsClient(client_p))
+ {
+ ServerStats->is_cl++;
+ ServerStats->is_cbs += client_p->localClient->sendB;
+ ServerStats->is_cbr += client_p->localClient->receiveB;
+ ServerStats->is_cks += client_p->localClient->sendK;
+ ServerStats->is_ckr += client_p->localClient->receiveK;
+ ServerStats->is_cti += CurrentTime - client_p->firsttime;
+ if (ServerStats->is_cbs > 2047)
+ {
+ ServerStats->is_cks += (ServerStats->is_cbs >> 10);
+ ServerStats->is_cbs &= 0x3ff;
+ }
+ if (ServerStats->is_cbr > 2047)
{
- ServerStats->is_cl++;
- ServerStats->is_cbs += client_p->localClient->sendB;
- ServerStats->is_cbr += client_p->localClient->receiveB;
- ServerStats->is_cks += client_p->localClient->sendK;
- ServerStats->is_ckr += client_p->localClient->receiveK;
- ServerStats->is_cti += CurrentTime - client_p->firsttime;
- if (ServerStats->is_cbs > 2047)
- {
- ServerStats->is_cks += (ServerStats->is_cbs >> 10);
- ServerStats->is_cbs &= 0x3ff;
- }
- if (ServerStats->is_cbr > 2047)
- {
- ServerStats->is_ckr += (ServerStats->is_cbr >> 10);
- ServerStats->is_cbr &= 0x3ff;
- }
+ ServerStats->is_ckr += (ServerStats->is_cbr >> 10);
+ ServerStats->is_cbr &= 0x3ff;
}
+ }
else
ServerStats->is_ni++;
-
+
#if 0
if (client_p->localClient->dns_reply)
- {
- --client_p->localClient->dns_reply->ref_count;
- client_p->localClient->dns_reply = 0;
- }
+ {
+ --client_p->localClient->dns_reply->ref_count;
+ client_p->localClient->dns_reply = 0;
+ }
#endif
if (-1 < client_p->fd)
- {
- /* attempt to flush any pending dbufs. Evil, but .. -- adrian */
- if (!IsDead(client_p))
- send_queued_write(client_p->fd, client_p);
- fd_close(client_p->fd);
- client_p->fd = -1;
- }
+ {
+ /* attempt to flush any pending dbufs. Evil, but .. -- adrian */
+ if (!IsDead(client_p))
+ send_queued_write(client_p->fd, client_p);
+ fd_close(client_p->fd);
+ client_p->fd = -1;
+ }
linebuf_donebuf(&client_p->localClient->buf_sendq);
linebuf_donebuf(&client_p->localClient->buf_recvq);
- memset(client_p->localClient->passwd, 0, sizeof(client_p->localClient->passwd));
+ memset(client_p->localClient->passwd, 0,
+ sizeof(client_p->localClient->passwd));
/*
* clean up extra sockets from P-lines which have been discarded.
*/
if (client_p->localClient->listener)
- {
- assert(0 < client_p->localClient->listener->ref_count);
- if (0 == --client_p->localClient->listener->ref_count &&
- !client_p->localClient->listener->active)
- free_listener(client_p->localClient->listener);
- client_p->localClient->listener = 0;
- }
+ {
+ assert(0 < client_p->localClient->listener->ref_count);
+ if (0 == --client_p->localClient->listener->ref_count &&
+ !client_p->localClient->listener->active)
+ free_listener(client_p->localClient->listener);
+ client_p->localClient->listener = 0;
+ }
det_confs_butmask(client_p, 0);
- client_p->from = NULL; /* ...this should catch them! >:) --msa */
+ client_p->from = NULL; /* ...this should catch them! >:) --msa */
}
/*
* The client is sent to the auth module for verification, and not put in
* any client list yet.
*/
-void add_connection(struct Listener* listener, int fd)
+void
+add_connection(struct Listener *listener, int fd)
{
- struct Client* new_client;
+ struct Client *new_client;
socklen_t len = sizeof(struct irc_sockaddr);
- struct irc_sockaddr irn;
+ struct irc_sockaddr irn;
assert(0 != listener);
#ifdef USE_IAUTH
if (iAuth.socket == NOSOCK)
{
send(fd,
- "NOTICE AUTH :*** Ircd Authentication Server is temporarily down, please connect later\r\n",
- 87,
- 0);
+ "NOTICE AUTH :*** Ircd Authentication Server is temporarily down, please connect later\r\n",
+ 87, 0);
fd_close(fd);
return;
}
* the client has already been checked out in accept_connection
*/
new_client = make_client(NULL);
- if (getpeername(fd, (struct sockaddr *)&SOCKADDR(irn), (unsigned int *)&len))
- {
- report_error(L_ALL, "Failed in adding new connection %s :%s",
- get_listener_name(listener), errno);
- ServerStats->is_ref++;
- fd_close(fd);
- return;
- }
+ if (getpeername
+ (fd, (struct sockaddr *)&SOCKADDR(irn), (unsigned int *)&len))
+ {
+ report_error(L_ALL, "Failed in adding new connection %s :%s",
+ get_listener_name(listener), errno);
+ ServerStats->is_ref++;
+ fd_close(fd);
+ return;
+ }
/*
* copy address to 'sockhost' as a string, copy it to host too
* so we have something valid to put into error messages...
*/
new_client->localClient->port = ntohs(S_PORT(irn));
- copy_s_addr(IN_ADDR(new_client->localClient->ip), S_ADDR(irn));
- inetntop(DEF_FAM, &IN_ADDR(new_client->localClient->ip), new_client->localClient->sockhost, HOSTIPLEN);
+ copy_s_addr(IN_ADDR(new_client->localClient->ip), S_ADDR(irn));
+ inetntop(DEF_FAM, &IN_ADDR(new_client->localClient->ip),
+ new_client->localClient->sockhost, HOSTIPLEN);
#ifdef IPV6
- if((!IN6_IS_ADDR_V4MAPPED(&IN_ADDR2(new_client->localClient->ip))) &&
- (!IN6_IS_ADDR_V4COMPAT(&IN_ADDR2(new_client->localClient->ip))))
- new_client->localClient->aftype = AF_INET6;
+ if ((!IN6_IS_ADDR_V4MAPPED(&IN_ADDR2(new_client->localClient->ip))) &&
+ (!IN6_IS_ADDR_V4COMPAT(&IN_ADDR2(new_client->localClient->ip))))
+ new_client->localClient->aftype = AF_INET6;
else
{
- memmove(&new_client->localClient->ip.sins.sin.s_addr,&IN_ADDR(new_client->localClient->ip)[12], sizeof(struct in_addr));
- new_client->localClient->aftype = AF_INET;
+ memmove(&new_client->localClient->ip.sins.sin.s_addr,
+ &IN_ADDR(new_client->localClient->ip)[12],
+ sizeof(struct in_addr));
+ new_client->localClient->aftype = AF_INET;
}
#else
new_client->localClient->aftype = AF_INET;
#endif
strcpy(new_client->host, new_client->localClient->sockhost);
- new_client->fd = fd;
+ new_client->fd = fd;
- new_client->localClient->listener = listener;
+ new_client->localClient->listener = listener;
++listener->ref_count;
if (!set_non_blocking(new_client->fd))
- report_error(L_ALL, NONB_ERROR_MSG, get_client_name(new_client, SHOW_IP), errno);
+ report_error(L_ALL, NONB_ERROR_MSG, get_client_name(new_client, SHOW_IP),
+ errno);
if (!disable_sock_options(new_client->fd))
- report_error(L_ALL, OPT_ERROR_MSG, get_client_name(new_client, SHOW_IP), errno);
+ report_error(L_ALL, OPT_ERROR_MSG, get_client_name(new_client, SHOW_IP),
+ errno);
start_auth(new_client);
}
-void error_exit_client(struct Client* client_p, int error)
+void
+error_exit_client(struct Client *client_p, int error)
{
/*
* ...hmm, with non-blocking sockets we might get
* for reading even though it ends up being an EOF. -avalon
*/
char errmsg[255];
- int current_error = get_sockerr(client_p->fd);
+ int current_error = get_sockerr(client_p->fd);
Debug((DEBUG_ERROR, "READ ERROR: fd = %d %d %d",
client_p->fd, current_error, error));
if (IsServer(client_p) || IsHandshake(client_p))
+ {
+ int connected = CurrentTime - client_p->firsttime;
+
+ if (error == 0)
{
- int connected = CurrentTime - client_p->firsttime;
-
- if (error == 0)
- {
- /* Admins get the real IP */
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Server %s closed the connection",
- get_client_name(client_p, SHOW_IP));
-
- /* Opers get a masked IP */
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Server %s closed the connection",
- get_client_name(client_p, MASK_IP));
-
- ilog(L_NOTICE, "Server %s closed the connection",
- get_client_name(client_p, SHOW_IP));
- }
- else
- {
- report_error(L_ADMIN, "Lost connection to %s: %d",
- get_client_name(client_p, SHOW_IP),
- current_error);
- report_error(L_OPER, "Lost connection to %s: %d",
- get_client_name(client_p, MASK_IP),
- current_error);
-
- }
-
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s had been connected for %d day%s, %2d:%02d:%02d",
- client_p->name, connected/86400,
- (connected/86400 == 1) ? "" : "s",
- (connected % 86400) / 3600, (connected % 3600) / 60,
- connected % 60);
+ /* Admins get the real IP */
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Server %s closed the connection",
+ get_client_name(client_p, SHOW_IP));
+
+ /* Opers get a masked IP */
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Server %s closed the connection",
+ get_client_name(client_p, MASK_IP));
+
+ ilog(L_NOTICE, "Server %s closed the connection",
+ get_client_name(client_p, SHOW_IP));
+ }
+ else
+ {
+ report_error(L_ADMIN, "Lost connection to %s: %d",
+ get_client_name(client_p, SHOW_IP), current_error);
+ report_error(L_OPER, "Lost connection to %s: %d",
+ get_client_name(client_p, MASK_IP), current_error);
+
}
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s had been connected for %d day%s, %2d:%02d:%02d",
+ client_p->name, connected / 86400,
+ (connected / 86400 == 1) ? "" : "s",
+ (connected % 86400) / 3600, (connected % 3600) / 60,
+ connected % 60);
+ }
if (error == 0)
{
strcpy(errmsg, "Remote host closed the connection");
}
else
{
- ircsprintf(errmsg, "Read error: %d (%s)",
+ ircsprintf(errmsg, "Read error: %d (%s)",
current_error, strerror(current_error));
}
fd_close(client_p->fd);
client_p->fd = -1;
-
+
exit_client(client_p, client_p, &me, errmsg);
}
int
ignoreErrno(int ierrno)
{
- switch (ierrno) {
+ switch (ierrno)
+ {
case EINPROGRESS:
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
#ifdef ERESTART
case ERESTART:
#endif
- return 1;
+ return 1;
default:
- return 0;
- }
- /* NOTREACHED */
- return 0;
+ return 0;
+ }
+ /* NOTREACHED */
+ return 0;
}
* Set the timeout for the fd
*/
void
-comm_settimeout(int fd, time_t timeout, PF *callback, void *cbdata)
+comm_settimeout(int fd, time_t timeout, PF * callback, void *cbdata)
{
- assert(fd > -1);
- assert(fd_table[fd].flags.open);
+ assert(fd > -1);
+ assert(fd_table[fd].flags.open);
- fd_table[fd].timeout = CurrentTime + (timeout / 1000);
- fd_table[fd].timeout_handler = callback;
- fd_table[fd].timeout_data = cbdata;
+ fd_table[fd].timeout = CurrentTime + (timeout / 1000);
+ fd_table[fd].timeout_handler = callback;
+ fd_table[fd].timeout_data = cbdata;
}
* with close functions, we _actually_ don't call comm_close() here ..
*/
void
-comm_setflush(int fd, time_t timeout, PF *callback, void *cbdata)
+comm_setflush(int fd, time_t timeout, PF * callback, void *cbdata)
{
- assert(fd > -1);
- assert(fd_table[fd].flags.open);
+ assert(fd > -1);
+ assert(fd_table[fd].flags.open);
- fd_table[fd].flush_timeout = CurrentTime + (timeout / 1000);
- fd_table[fd].flush_handler = callback;
- fd_table[fd].flush_data = cbdata;
+ fd_table[fd].flush_timeout = CurrentTime + (timeout / 1000);
+ fd_table[fd].flush_handler = callback;
+ fd_table[fd].flush_data = cbdata;
}
void
comm_checktimeouts(void *notused)
{
- int fd;
- PF *hdl;
- void *data;
-
- for (fd = 0; fd <= highest_fd; fd++)
- {
- if (!fd_table[fd].flags.open)
- continue;
- if (fd_table[fd].flags.closing)
- continue;
-
- /* check flush functions */
- if (fd_table[fd].flush_handler &&
- fd_table[fd].flush_timeout > 0 && fd_table[fd].flush_timeout
- < CurrentTime)
- {
- hdl = fd_table[fd].flush_handler;
- data = fd_table[fd].flush_data;
- comm_setflush(fd, 0, NULL, NULL);
- hdl(fd, data);
- }
-
- /* check timeouts */
- if (fd_table[fd].timeout_handler &&
- fd_table[fd].timeout > 0 && fd_table[fd].timeout < CurrentTime)
- {
- /* Call timeout handler */
- hdl = fd_table[fd].timeout_handler;
- data = fd_table[fd].timeout_data;
- comm_settimeout(fd, 0, NULL, NULL);
- hdl(fd, fd_table[fd].timeout_data);
- }
- }
+ int fd;
+ PF *hdl;
+ void *data;
+
+ for (fd = 0; fd <= highest_fd; fd++)
+ {
+ if (!fd_table[fd].flags.open)
+ continue;
+ if (fd_table[fd].flags.closing)
+ continue;
+
+ /* check flush functions */
+ if (fd_table[fd].flush_handler &&
+ fd_table[fd].flush_timeout > 0 && fd_table[fd].flush_timeout
+ < CurrentTime)
+ {
+ hdl = fd_table[fd].flush_handler;
+ data = fd_table[fd].flush_data;
+ comm_setflush(fd, 0, NULL, NULL);
+ hdl(fd, data);
+ }
+
+ /* check timeouts */
+ if (fd_table[fd].timeout_handler &&
+ fd_table[fd].timeout > 0 && fd_table[fd].timeout < CurrentTime)
+ {
+ /* Call timeout handler */
+ hdl = fd_table[fd].timeout_handler;
+ data = fd_table[fd].timeout_data;
+ comm_settimeout(fd, 0, NULL, NULL);
+ hdl(fd, fd_table[fd].timeout_data);
+ }
+ }
}
/*
*/
void
comm_connect_tcp(int fd, const char *host, u_short port,
- struct sockaddr *clocal, int socklen, CNCB *callback,
+ struct sockaddr *clocal, int socklen, CNCB * callback,
void *data, int aftype, int timeout)
{
- fd_table[fd].flags.called_connect = 1;
- assert(callback);
- fd_table[fd].connect.callback = callback;
- fd_table[fd].connect.data = data;
-
- S_FAM(fd_table[fd].connect.hostaddr) = DEF_FAM;
- S_PORT(fd_table[fd].connect.hostaddr) = htons(port);
- /* Note that we're using a passed sockaddr here. This is because
- * generally you'll be bind()ing to a sockaddr grabbed from
- * getsockname(), so this makes things easier.
- * XXX If NULL is passed as local, we should later on bind() to the
- * virtual host IP, for completeness.
- * -- adrian
- */
- if ((clocal != NULL) && (bind(fd, clocal, socklen) < 0))
- {
- /* Failure, call the callback with COMM_ERR_BIND */
- comm_connect_callback(fd, COMM_ERR_BIND);
- /* ... and quit */
- return;
- }
-
- /* Next, if we have been given an IP, get the addr and skip the
- * DNS check (and head direct to comm_connect_tryconnect().
- */
- if (inetpton(DEF_FAM, host, S_ADDR(&fd_table[fd].connect.hostaddr)) <=0)
- {
- /* Send the DNS request, for the next level */
- fd_table[fd].dns_query = MyMalloc(sizeof(struct DNSQuery));
- fd_table[fd].dns_query->ptr = &fd_table[fd];
- fd_table[fd].dns_query->callback = comm_connect_dns_callback;
- adns_gethost(host, aftype, fd_table[fd].dns_query);
- }
- else
- {
- /* We have a valid IP, so we just call tryconnect */
- /* Make sure we actually set the timeout here .. */
- comm_settimeout(fd, timeout*1000, comm_connect_timeout, NULL);
- comm_connect_tryconnect(fd, NULL);
- }
+ fd_table[fd].flags.called_connect = 1;
+ assert(callback);
+ fd_table[fd].connect.callback = callback;
+ fd_table[fd].connect.data = data;
+
+ S_FAM(fd_table[fd].connect.hostaddr) = DEF_FAM;
+ S_PORT(fd_table[fd].connect.hostaddr) = htons(port);
+ /* Note that we're using a passed sockaddr here. This is because
+ * generally you'll be bind()ing to a sockaddr grabbed from
+ * getsockname(), so this makes things easier.
+ * XXX If NULL is passed as local, we should later on bind() to the
+ * virtual host IP, for completeness.
+ * -- adrian
+ */
+ if ((clocal != NULL) && (bind(fd, clocal, socklen) < 0))
+ {
+ /* Failure, call the callback with COMM_ERR_BIND */
+ comm_connect_callback(fd, COMM_ERR_BIND);
+ /* ... and quit */
+ return;
+ }
+
+ /* Next, if we have been given an IP, get the addr and skip the
+ * DNS check (and head direct to comm_connect_tryconnect().
+ */
+ if (inetpton(DEF_FAM, host, S_ADDR(&fd_table[fd].connect.hostaddr)) <= 0)
+ {
+ /* Send the DNS request, for the next level */
+ fd_table[fd].dns_query = MyMalloc(sizeof(struct DNSQuery));
+ fd_table[fd].dns_query->ptr = &fd_table[fd];
+ fd_table[fd].dns_query->callback = comm_connect_dns_callback;
+ adns_gethost(host, aftype, fd_table[fd].dns_query);
+ }
+ else
+ {
+ /* We have a valid IP, so we just call tryconnect */
+ /* Make sure we actually set the timeout here .. */
+ comm_settimeout(fd, timeout * 1000, comm_connect_timeout, NULL);
+ comm_connect_tryconnect(fd, NULL);
+ }
}
/*
static void
comm_connect_callback(int fd, int status)
{
- CNCB *hdl;
- /* This check is gross..but probably necessary */
- if(fd_table[fd].connect.callback == NULL)
- return;
- /* Clear the connect flag + handler */
- hdl = fd_table[fd].connect.callback;
- fd_table[fd].connect.callback = NULL;
- fd_table[fd].flags.called_connect = 0;
-
- /* Clear the timeout handler */
- comm_settimeout(fd, 0, NULL, NULL);
-
- /* Call the handler */
- hdl(fd, status, fd_table[fd].connect.data);
+ CNCB *hdl;
+ /* This check is gross..but probably necessary */
+ if (fd_table[fd].connect.callback == NULL)
+ return;
+ /* Clear the connect flag + handler */
+ hdl = fd_table[fd].connect.callback;
+ fd_table[fd].connect.callback = NULL;
+ fd_table[fd].flags.called_connect = 0;
+
+ /* Clear the timeout handler */
+ comm_settimeout(fd, 0, NULL, NULL);
+
+ /* Call the handler */
+ hdl(fd, status, fd_table[fd].connect.data);
}
static void
comm_connect_timeout(int fd, void *notused)
{
- /* error! */
- comm_connect_callback(fd, COMM_ERR_TIMEOUT);
+ /* error! */
+ comm_connect_callback(fd, COMM_ERR_TIMEOUT);
}
* otherwise we initiate the connect()
*/
static void
-comm_connect_dns_callback(void *vptr, adns_answer *reply)
+comm_connect_dns_callback(void *vptr, adns_answer * reply)
{
- fde_t *F = vptr;
-
- if(!reply)
- {
- comm_connect_callback(F->fd, COMM_ERR_DNS);
- return;
- }
-
- if (reply->status != adns_s_ok)
- {
- /* Yes, callback + return */
- comm_connect_callback(F->fd, COMM_ERR_DNS);
- MyFree(reply);
- MyFree(F->dns_query);
- return;
- }
-
- /* No error, set a 10 second timeout */
- comm_settimeout(F->fd, 30*1000, comm_connect_timeout, NULL);
-
- /* Copy over the DNS reply info so we can use it in the connect() */
- /*
- * Note we don't fudge the refcount here, because we aren't keeping
- * the DNS record around, and the DNS cache is gone anyway..
- * -- adrian
- */
+ fde_t *F = vptr;
+
+ if (!reply)
+ {
+ comm_connect_callback(F->fd, COMM_ERR_DNS);
+ return;
+ }
+
+ if (reply->status != adns_s_ok)
+ {
+ /* Yes, callback + return */
+ comm_connect_callback(F->fd, COMM_ERR_DNS);
+ MyFree(reply);
+ MyFree(F->dns_query);
+ return;
+ }
+
+ /* No error, set a 10 second timeout */
+ comm_settimeout(F->fd, 30 * 1000, comm_connect_timeout, NULL);
+
+ /* Copy over the DNS reply info so we can use it in the connect() */
+ /*
+ * Note we don't fudge the refcount here, because we aren't keeping
+ * the DNS record around, and the DNS cache is gone anyway..
+ * -- adrian
+ */
#ifdef IPV6
- if(reply->rrs.addr->addr.sa.sa_family == AF_INET6)
- {
- copy_s_addr(S_ADDR(F->connect.hostaddr), reply->rrs.addr->addr.inet6.sin6_addr.s6_addr);
- }
- else
- {
- /* IPv4 mapped address */
- /* This is lazy... */
- memset(&F->connect.hostaddr.sins.sin6.sin6_addr.s6_addr, 0x0000, 10);
- memset(&F->connect.hostaddr.sins.sin6.sin6_addr.s6_addr[10], 0xffff, 2);
- memcpy(&F->connect.hostaddr.sins.sin6.sin6_addr.s6_addr[12], &reply->rrs.addr->addr.inet.sin_addr.s_addr, 4);
- }
+ if (reply->rrs.addr->addr.sa.sa_family == AF_INET6)
+ {
+ copy_s_addr(S_ADDR(F->connect.hostaddr),
+ reply->rrs.addr->addr.inet6.sin6_addr.s6_addr);
+ }
+ else
+ {
+ /* IPv4 mapped address */
+ /* This is lazy... */
+ memset(&F->connect.hostaddr.sins.sin6.sin6_addr.s6_addr, 0x0000, 10);
+ memset(&F->connect.hostaddr.sins.sin6.sin6_addr.s6_addr[10], 0xffff, 2);
+ memcpy(&F->connect.hostaddr.sins.sin6.sin6_addr.s6_addr[12],
+ &reply->rrs.addr->addr.inet.sin_addr.s_addr, 4);
+ }
#else
- F->connect.hostaddr.sins.sin.sin_addr.s_addr = reply->rrs.addr->addr.inet.sin_addr.s_addr;
+ F->connect.hostaddr.sins.sin.sin_addr.s_addr =
+ reply->rrs.addr->addr.inet.sin_addr.s_addr;
#endif
- /* Now, call the tryconnect() routine to try a connect() */
- MyFree(reply);
- comm_connect_tryconnect(F->fd, NULL);
+ /* Now, call the tryconnect() routine to try a connect() */
+ MyFree(reply);
+ comm_connect_tryconnect(F->fd, NULL);
}
static void
comm_connect_tryconnect(int fd, void *notused)
{
- int retval;
- /* This check is needed or re-entrant s_bsd_* like sigio break it. */
- if (fd_table[fd].connect.callback == NULL)
- return;
- /* Try the connect() */
- retval = connect(fd, (struct sockaddr *) &SOCKADDR(fd_table[fd].connect.hostaddr), sizeof(struct irc_sockaddr));
- /* Error? */
- if (retval < 0)
- {
- /*
- * If we get EISCONN, then we've already connect()ed the socket,
- * which is a good thing.
- * -- adrian
- */
- if (errno == EISCONN)
- comm_connect_callback(fd, COMM_OK);
- else if (ignoreErrno(errno))
- /* Ignore error? Reschedule */
- comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_WRITE,
- comm_connect_tryconnect, NULL, 0);
- else
- /* Error? Fail with COMM_ERR_CONNECT */
- comm_connect_callback(fd, COMM_ERR_CONNECT);
- return;
- }
- /* If we get here, we've suceeded, so call with COMM_OK */
- comm_connect_callback(fd, COMM_OK);
+ int retval;
+ /* This check is needed or re-entrant s_bsd_* like sigio break it. */
+ if (fd_table[fd].connect.callback == NULL)
+ return;
+ /* Try the connect() */
+ retval =
+ connect(fd, (struct sockaddr *)&SOCKADDR(fd_table[fd].connect.hostaddr),
+ sizeof(struct irc_sockaddr));
+ /* Error? */
+ if (retval < 0)
+ {
+ /*
+ * If we get EISCONN, then we've already connect()ed the socket,
+ * which is a good thing.
+ * -- adrian
+ */
+ if (errno == EISCONN)
+ comm_connect_callback(fd, COMM_OK);
+ else if (ignoreErrno(errno))
+ /* Ignore error? Reschedule */
+ comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_WRITE,
+ comm_connect_tryconnect, NULL, 0);
+ else
+ /* Error? Fail with COMM_ERR_CONNECT */
+ comm_connect_callback(fd, COMM_ERR_CONNECT);
+ return;
+ }
+ /* If we get here, we've suceeded, so call with COMM_OK */
+ comm_connect_callback(fd, COMM_OK);
}
/*
const char *
comm_errstr(int error)
{
- if (error < 0 || error >= COMM_ERR_MAX)
- return "Invalid error number!";
- return comm_err_str[error];
+ if (error < 0 || error >= COMM_ERR_MAX)
+ return "Invalid error number!";
+ return comm_err_str[error];
}
int fd;
/* First, make sure we aren't going to run out of file descriptors */
if (number_fd >= MASTER_MAX)
- {
- errno = ENFILE;
- return -1;
- }
+ {
+ errno = ENFILE;
+ return -1;
+ }
/*
* Next, we try to open the socket. We *should* drop the reserved FD
*/
fd = socket(family, sock_type, proto);
if (fd < 0)
- return -1; /* errno will be passed through, yay.. */
+ return -1; /* errno will be passed through, yay.. */
/* Set the socket non-blocking, and other wonderful bits */
if (!set_non_blocking(fd))
- {
- ilog(L_CRIT, "comm_open: Couldn't set FD %d non blocking: %s", fd, strerror(errno));
+ {
+ ilog(L_CRIT, "comm_open: Couldn't set FD %d non blocking: %s", fd,
+ strerror(errno));
/* if VMS, we might be opening a file (ircd.conf, resolv.conf).
VMS doesn't let us set non-blocking on a file, so it might fail. */
#ifndef VMS
- close(fd);
- return -1;
+ close(fd);
+ return -1;
#endif
- }
+ }
/* Next, update things in our fd tracking */
fd_open(fd, FD_SOCKET, note);
int newfd;
socklen_t addrlen = sizeof(struct irc_sockaddr);
if (number_fd >= MASTER_MAX)
- {
- errno = ENFILE;
- return -1;
- }
+ {
+ errno = ENFILE;
+ return -1;
+ }
/*
* Next, do the accept(). if we get an error, we should drop the
* reserved fd limit, but we can deal with that when comm_open()
* also does it. XXX -- adrian
*/
- newfd = accept(fd, (struct sockaddr *)&PSOCKADDR(pn), (unsigned int *)&addrlen);
+ newfd =
+ accept(fd, (struct sockaddr *)&PSOCKADDR(pn), (unsigned int *)&addrlen);
if (newfd < 0)
return -1;
/* Set the socket non-blocking, and other wonderful bits */
if (!set_non_blocking(newfd))
- {
- ilog(L_CRIT, "comm_accept: Couldn't set FD %d non blocking!", newfd);
- close(newfd);
- return -1;
- }
+ {
+ ilog(L_CRIT, "comm_accept: Couldn't set FD %d non blocking!", newfd);
+ close(newfd);
+ return -1;
+ }
/* Next, tag the FD as an incoming connection */
fd_open(newfd, FD_SOCKET, "Incoming connection");
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_bsd_devpoll.c,v 1.1 2002/01/04 09:14:30 a1kmm Exp $
+ * $Id: s_bsd_devpoll.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
#include "config.h"
#include "fdlist.h"
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
-#include <sys/param.h> /* NOFILE */
+#include <sys/param.h> /* NOFILE */
#include <arpa/inet.h>
#define POLL_LENGTH HARD_FDLIMIT
static void devpoll_update_events(int, short, PF *);
static int dpfd;
static short fdmask[POLL_LENGTH];
-static void devpoll_update_events(int, short, PF *);
+static void devpoll_update_events(int, short, PF *);
static void devpoll_write_update(int, int);
/* #define NOTYET 1 */
static void
devpoll_write_update(int fd, int events)
{
- struct pollfd pollfds[1]; /* Just to be careful */
- int retval;
+ struct pollfd pollfds[1]; /* Just to be careful */
+ int retval;
+
+ /* Build the pollfd entry */
+ pollfds[0].revents = 0;
+ pollfds[0].fd = fd;
+ pollfds[0].events = events;
- /* Build the pollfd entry */
- pollfds[0].revents = 0;
- pollfds[0].fd = fd;
- pollfds[0].events = events;
-
- /* Write the thing to our poll fd */
- retval = write(dpfd, &pollfds[0], sizeof(struct pollfd));
- if (retval != sizeof(struct pollfd))
- ilog(L_NOTICE, "devpoll_write_update: dpfd write failed %d: %s\n", errno, strerror(errno));
- /* Done! */
+ /* Write the thing to our poll fd */
+ retval = write(dpfd, &pollfds[0], sizeof(struct pollfd));
+ if (retval != sizeof(struct pollfd))
+ ilog(L_NOTICE, "devpoll_write_update: dpfd write failed %d: %s\n", errno,
+ strerror(errno));
+ /* Done! */
}
void
devpoll_update_events(int fd, short filter, PF * handler)
{
- int update_required = 0;
- int cur_mask = fdmask[fd];
- PF *cur_handler;
- fdmask[fd] = 0;
- switch (filter)
- {
- case COMM_SELECT_READ:
- cur_handler = fd_table[fd].read_handler;
- if (handler)
- fdmask[fd] |= POLLRDNORM;
- else
- fdmask[fd] &= ~POLLRDNORM;
- if (fd_table[fd].write_handler)
- fdmask[fd] |= POLLWRNORM;
- break;
- case COMM_SELECT_WRITE:
- cur_handler = fd_table[fd].write_handler;
- if (handler)
- fdmask[fd] |= POLLWRNORM;
- else
- fdmask[fd] &= ~POLLWRNORM;
- if(fd_table[fd].read_handler)
- fdmask[fd] |= POLLRDNORM;
- break;
- default:
+ int update_required = 0;
+ int cur_mask = fdmask[fd];
+ PF *cur_handler;
+ fdmask[fd] = 0;
+ switch (filter)
+ {
+ case COMM_SELECT_READ:
+ cur_handler = fd_table[fd].read_handler;
+ if (handler)
+ fdmask[fd] |= POLLRDNORM;
+ else
+ fdmask[fd] &= ~POLLRDNORM;
+ if (fd_table[fd].write_handler)
+ fdmask[fd] |= POLLWRNORM;
+ break;
+ case COMM_SELECT_WRITE:
+ cur_handler = fd_table[fd].write_handler;
+ if (handler)
+ fdmask[fd] |= POLLWRNORM;
+ else
+ fdmask[fd] &= ~POLLWRNORM;
+ if (fd_table[fd].read_handler)
+ fdmask[fd] |= POLLRDNORM;
+ break;
+ default:
#ifdef NOTYET
- ilog(L_NOTICE,"devpoll_update_events called with unknown filter: %hd\n", filter);
+ ilog(L_NOTICE,
+ "devpoll_update_events called with unknown filter: %hd\n", filter);
#endif
- return;
- break;
- }
+ return;
+ break;
+ }
- if (cur_handler == NULL && handler != NULL)
- update_required++;
- else
- if (cur_handler != NULL && handler == NULL)
- update_required++;
- if(cur_mask != fdmask[fd])
- update_required++;
- if (update_required)
- {
- /*
- * Ok, we can call devpoll_write_update() here now to re-build the
- * fd struct. If we end up with nothing on this fd, it won't write
- * anything.
- */
- if (fdmask[fd])
- {
- devpoll_write_update(fd, POLLREMOVE);
- devpoll_write_update(fd, fdmask[fd]);
- }
- else
- devpoll_write_update(fd, POLLREMOVE);
- }
+ if (cur_handler == NULL && handler != NULL)
+ update_required++;
+ else if (cur_handler != NULL && handler == NULL)
+ update_required++;
+ if (cur_mask != fdmask[fd])
+ update_required++;
+ if (update_required)
+ {
+ /*
+ * Ok, we can call devpoll_write_update() here now to re-build the
+ * fd struct. If we end up with nothing on this fd, it won't write
+ * anything.
+ */
+ if (fdmask[fd])
+ {
+ devpoll_write_update(fd, POLLREMOVE);
+ devpoll_write_update(fd, fdmask[fd]);
+ }
+ else
+ devpoll_write_update(fd, POLLREMOVE);
+ }
}
* This is a needed exported function which will be called to initialise
* the network loop code.
*/
-void init_netio(void)
+void
+init_netio(void)
{
- memset(&fdmask, 0, sizeof(fdmask));
- dpfd = open("/dev/poll", O_RDWR);
- if (dpfd < 0)
- {
- ilog(L_CRIT, "init_netio: Couldn't open /dev/poll - %d: %s\n", errno, strerror(errno));
- exit(115); /* Whee! */
- }
+ memset(&fdmask, 0, sizeof(fdmask));
+ dpfd = open("/dev/poll", O_RDWR);
+ if (dpfd < 0)
+ {
+ ilog(L_CRIT, "init_netio: Couldn't open /dev/poll - %d: %s\n", errno,
+ strerror(errno));
+ exit(115); /* Whee! */
+ }
}
/*
*/
void
comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
- void *client_data, time_t timeout)
-{
- fde_t *F = &fd_table[fd];
- assert(fd >= 0);
- assert(F->flags.open);
+ void *client_data, time_t timeout)
+{
+ fde_t *F = &fd_table[fd];
+ assert(fd >= 0);
+ assert(F->flags.open);
- /* Update the list, even though we're not using it .. */
- F->list = list;
-
- if (type & COMM_SELECT_READ)
- {
- devpoll_update_events(fd, COMM_SELECT_READ, handler);
- F->read_handler = handler;
- F->read_data = client_data;
- }
- if (type & COMM_SELECT_WRITE)
- {
- devpoll_update_events(fd, COMM_SELECT_WRITE, handler);
- F->write_handler = handler;
- F->write_data = client_data;
- }
- if (timeout)
- F->timeout = CurrentTime + (timeout / 1000);
+ /* Update the list, even though we're not using it .. */
+ F->list = list;
+
+ if (type & COMM_SELECT_READ)
+ {
+ devpoll_update_events(fd, COMM_SELECT_READ, handler);
+ F->read_handler = handler;
+ F->read_data = client_data;
+ }
+ if (type & COMM_SELECT_WRITE)
+ {
+ devpoll_update_events(fd, COMM_SELECT_WRITE, handler);
+ F->write_handler = handler;
+ F->write_data = client_data;
+ }
+ if (timeout)
+ F->timeout = CurrentTime + (timeout / 1000);
}
-
+
/*
* Check all connections for new connections and input data that is to be
* processed. Also check for connections with data queued and whether we can
int
comm_select(unsigned long delay)
{
- int num, i;
- struct pollfd pollfds[POLL_LENGTH];
- struct dvpoll dopoll;
+ int num, i;
+ struct pollfd pollfds[POLL_LENGTH];
+ struct dvpoll dopoll;
+
+ do
+ {
+ for (;;)
+ {
+ dopoll.dp_timeout = delay;
+ dopoll.dp_nfds = POLL_LENGTH;
+ dopoll.dp_fds = &pollfds[0];
+ num = ioctl(dpfd, DP_POLL, &dopoll);
+ if (num >= 0)
+ break;
+ if (ignoreErrno(errno))
+ break;
+ set_time();
+ return COMM_ERROR;
+ }
- do
- {
- for (;;)
- {
- dopoll.dp_timeout = delay;
- dopoll.dp_nfds = POLL_LENGTH;
- dopoll.dp_fds = &pollfds[0];
- num = ioctl(dpfd, DP_POLL, &dopoll);
- if (num >= 0)
- break;
- if (ignoreErrno(errno))
- break;
- set_time();
- return COMM_ERROR;
- }
+ set_time();
+ if (num == 0)
+ continue;
+ callbacks_called += num;
- set_time();
- if (num == 0)
- continue;
- callbacks_called += num;
+ for (i = 0; i < num; i++)
+ {
+ int fd = dopoll.dp_fds[i].fd;
+ PF *hdl = NULL;
+ fde_t *F = &fd_table[fd];
+ if ((dopoll.dp_fds[i].
+ revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR))
+ && (dopoll.dp_fds[i].events & (POLLRDNORM | POLLIN)))
+ {
+ if ((hdl = F->read_handler) != NULL)
+ {
+ F->read_handler = NULL;
+ hdl(fd, F->read_data);
+ /*
+ * this call used to be with a NULL pointer, BUT
+ * in the devpoll case we only want to update the
+ * poll set *if* the handler changes state (active ->
+ * NULL or vice versa.)
+ */
+ devpoll_update_events(fd, COMM_SELECT_READ, F->read_handler);
+ }
+ else
+ ilog(L_NOTICE, "comm_select: Unhandled read event: fdmask: %x\n",
+ fdmask[fd]);
+ }
+ if ((dopoll.dp_fds[i].
+ revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR))
+ && (dopoll.dp_fds[i].events & (POLLWRNORM | POLLOUT)))
+ {
+ if ((hdl = F->write_handler) != NULL)
+ {
+ F->write_handler = NULL;
+ hdl(fd, F->write_data);
+ /* See above similar code in the read case */
+ devpoll_update_events(fd, COMM_SELECT_WRITE, F->write_handler);
+ }
+ else
+ ilog(L_NOTICE, "comm_select: Unhandled write event: fdmask: %x\n",
+ fdmask[fd]);
- for (i = 0; i < num; i++)
- {
- int fd = dopoll.dp_fds[i].fd;
- PF *hdl = NULL;
- fde_t *F = &fd_table[fd];
- if ((dopoll.dp_fds[i].revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR)) && (dopoll.dp_fds[i].events & (POLLRDNORM|POLLIN)))
- {
- if ((hdl = F->read_handler) != NULL)
- {
- F->read_handler = NULL;
- hdl(fd, F->read_data);
- /*
- * this call used to be with a NULL pointer, BUT
- * in the devpoll case we only want to update the
- * poll set *if* the handler changes state (active ->
- * NULL or vice versa.)
- */
- devpoll_update_events(fd, COMM_SELECT_READ, F->read_handler);
- } else
- ilog(L_NOTICE, "comm_select: Unhandled read event: fdmask: %x\n", fdmask[fd]);
- }
- if ((dopoll.dp_fds[i].revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR)) && (dopoll.dp_fds[i].events & (POLLWRNORM|POLLOUT)))
- {
- if ((hdl = F->write_handler) != NULL)
- {
- F->write_handler = NULL;
- hdl(fd, F->write_data);
- /* See above similar code in the read case */
- devpoll_update_events(fd, COMM_SELECT_WRITE, F->write_handler);
- }
- else
- ilog(L_NOTICE, "comm_select: Unhandled write event: fdmask: %x\n", fdmask[fd]);
-
- }
- if(dopoll.dp_fds[i].revents & POLLNVAL)
- {
- ilog(L_NOTICE, "revents was Invalid for %d\n", fd);
- }
- }
- return COMM_OK;
- } while(0);
- /* XXX Get here, we broke! */
- return 0;
+ }
+ if (dopoll.dp_fds[i].revents & POLLNVAL)
+ {
+ ilog(L_NOTICE, "revents was Invalid for %d\n", fd);
+ }
+ }
+ return COMM_OK;
+ } while (0);
+ /* XXX Get here, we broke! */
+ return 0;
}
#endif /* USE_DEVPOLL */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_bsd_kqueue.c,v 1.1 2002/01/04 09:14:30 a1kmm Exp $
+ * $Id: s_bsd_kqueue.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
#include "config.h"
#include "fdlist.h"
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
-#include <sys/param.h> /* NOFILE */
+#include <sys/param.h> /* NOFILE */
#include <arpa/inet.h>
static int kq;
static struct timespec zero_timespec;
-static struct kevent *kqlst; /* kevent buffer */
-static int kqmax; /* max structs to buffer */
-static int kqoff; /* offset into the buffer */
+static struct kevent *kqlst; /* kevent buffer */
+static int kqmax; /* max structs to buffer */
+static int kqoff; /* offset into the buffer */
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
int kep_flags;
switch (filter)
- {
+ {
case EVFILT_READ:
cur_handler = fd_table[fd].read_handler;
break;
/* XXX bad! -- adrian */
return;
break;
- }
+ }
if ((cur_handler == NULL && handler != NULL)
- ||
- (cur_handler != NULL && handler == NULL))
+ || (cur_handler != NULL && handler == NULL))
+ {
+ struct kevent *kep;
+
+ kep = kqlst + kqoff;
+
+ if (handler != NULL)
{
- struct kevent *kep;
-
- kep = kqlst + kqoff;
-
- if (handler != NULL)
- {
- if (filter == EVFILT_WRITE)
- kep_flags = (EV_ADD | EV_ONESHOT);
- else
- kep_flags = EV_ADD;
- }
- else
- {
- kep_flags = EV_DELETE;
- }
-
- EV_SET(kep, (uintptr_t) fd, filter, kep_flags, 0, 0, 0);
-
- if (kqoff == kqmax)
- {
- int ret;
-
- ret = kevent(kq, kqlst, kqoff, NULL, 0, &zero_timespec);
- /* jdc -- someone needs to do error checking... */
- if (ret == -1)
- {
- perror("kq_update_events(): kevent()");
- return;
- }
- kqoff = 0;
- }
+ if (filter == EVFILT_WRITE)
+ kep_flags = (EV_ADD | EV_ONESHOT);
else
- {
- kqoff++;
- }
+ kep_flags = EV_ADD;
}
+ else
+ {
+ kep_flags = EV_DELETE;
+ }
+
+ EV_SET(kep, (uintptr_t) fd, filter, kep_flags, 0, 0, 0);
+
+ if (kqoff == kqmax)
+ {
+ int ret;
+
+ ret = kevent(kq, kqlst, kqoff, NULL, 0, &zero_timespec);
+ /* jdc -- someone needs to do error checking... */
+ if (ret == -1)
+ {
+ perror("kq_update_events(): kevent()");
+ return;
+ }
+ kqoff = 0;
+ }
+ else
+ {
+ kqoff++;
+ }
+ }
}
* This is a needed exported function which will be called to initialise
* the network loop code.
*/
-void init_netio(void)
+void
+init_netio(void)
{
kq = kqueue();
if (kq < 0)
- {
- ilog(L_CRIT, "init_netio: Couldn't open kqueue fd!\n");
- exit(115); /* Whee! */
- }
+ {
+ ilog(L_CRIT, "init_netio: Couldn't open kqueue fd!\n");
+ exit(115); /* Whee! */
+ }
kqmax = getdtablesize();
kqlst = MyMalloc(sizeof(*kqlst) * kqmax);
zero_timespec.tv_sec = 0;
*/
void
comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
- void *client_data, time_t timeout)
-{
+ void *client_data, time_t timeout)
+{
fde_t *F = &fd_table[fd];
assert(fd >= 0);
assert(F->flags.open);
F->list = list;
if (type & COMM_SELECT_READ)
- {
- kq_update_events(fd, EVFILT_READ, handler);
- F->read_handler = handler;
- F->read_data = client_data;
- }
+ {
+ kq_update_events(fd, EVFILT_READ, handler);
+ F->read_handler = handler;
+ F->read_data = client_data;
+ }
if (type & COMM_SELECT_WRITE)
- {
- kq_update_events(fd, EVFILT_WRITE, handler);
- F->write_handler = handler;
- F->write_data = client_data;
- }
+ {
+ kq_update_events(fd, EVFILT_WRITE, handler);
+ F->write_handler = handler;
+ F->write_data = client_data;
+ }
if (timeout)
F->timeout = CurrentTime + (timeout / 1000);
}
-
+
/*
* Check all connections for new connections and input data that is to be
* processed. Also check for connections with data queued and whether we can
int num, i;
static struct kevent ke[KE_LENGTH];
struct timespec poll_time;
-
- do {
+
+ do
+ {
/*
* remember we are doing NANOseconds here, not micro/milli. God knows
* why jlemon used a timespec, but hey, he wrote the interface, not I
poll_time.tv_sec = 0;
poll_time.tv_nsec = delay * 1000000;
for (;;)
- {
- num = kevent(kq, kqlst, kqoff, ke, KE_LENGTH, &poll_time);
- kqoff = 0;
- if (num >= 0)
- break;
- if (ignoreErrno(errno))
- break;
- set_time();
- return COMM_ERROR;
- /* NOTREACHED */
- }
+ {
+ num = kevent(kq, kqlst, kqoff, ke, KE_LENGTH, &poll_time);
+ kqoff = 0;
+ if (num >= 0)
+ break;
+ if (ignoreErrno(errno))
+ break;
+ set_time();
+ return COMM_ERROR;
+ /* NOTREACHED */
+ }
set_time();
if (num == 0)
continue;
callbacks_called += num;
-
+
for (i = 0; i < num; i++)
+ {
+ int fd = (int)ke[i].ident;
+ PF *hdl = NULL;
+ fde_t *F = &fd_table[fd];
+
+ if (ke[i].flags & EV_ERROR)
{
- int fd = (int) ke[i].ident;
- PF *hdl = NULL;
- fde_t *F = &fd_table[fd];
-
- if (ke[i].flags & EV_ERROR)
- {
- errno = ke[i].data;
- /* XXX error == bad! -- adrian */
- continue; /* XXX! */
- }
-
- switch (ke[i].filter)
- {
- case EVFILT_READ:
- if ((hdl = F->read_handler) != NULL) {
- F->read_handler = NULL;
- hdl(fd, F->read_data);
- }
- case EVFILT_WRITE:
- if ((hdl = F->write_handler) != NULL) {
- F->write_handler = NULL;
- hdl(fd, F->write_data);
- }
- default:
- /* Bad! -- adrian */
- break;
- }
+ errno = ke[i].data;
+ /* XXX error == bad! -- adrian */
+ continue; /* XXX! */
}
+
+ switch (ke[i].filter)
+ {
+ case EVFILT_READ:
+ if ((hdl = F->read_handler) != NULL)
+ {
+ F->read_handler = NULL;
+ hdl(fd, F->read_data);
+ }
+ case EVFILT_WRITE:
+ if ((hdl = F->write_handler) != NULL)
+ {
+ F->write_handler = NULL;
+ hdl(fd, F->write_data);
+ }
+ default:
+ /* Bad! -- adrian */
+ break;
+ }
+ }
return COMM_OK;
- } while (0); /* XXX should rip this out! -- adrian */
+ } while (0); /* XXX should rip this out! -- adrian */
/* XXX Get here, we broke! */
return 0;
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_bsd_poll.c,v 1.1 2002/01/04 09:14:30 a1kmm Exp $
+ * $Id: s_bsd_poll.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
#include "config.h"
#include "fdlist.h"
#include <sys/ioctl.h>
#include <sys/resource.h>
#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h> /* NOFILE */
+#include <sys/param.h> /* NOFILE */
#endif
#include <arpa/inet.h>
#define POLLWRNORM POLLOUT
#endif
-struct _pollfd_list {
- struct pollfd pollfds[MAXCONNECTIONS];
- int maxindex; /* highest FD number */
+struct _pollfd_list
+{
+ struct pollfd pollfds[MAXCONNECTIONS];
+ int maxindex; /* highest FD number */
};
-typedef struct _pollfd_list pollfd_list_t;
+typedef struct _pollfd_list pollfd_list_t;
pollfd_list_t pollfd_list;
static void poll_update_pollfds(int, short, PF *);
static inline int
poll_findslot(void)
{
- int i;
- for (i = 0; i < MAXCONNECTIONS; i++) {
- if (pollfd_list.pollfds[i].fd == -1) {
- /* MATCH!!#$*&$ */
- return i;
- }
+ int i;
+ for (i = 0; i < MAXCONNECTIONS; i++)
+ {
+ if (pollfd_list.pollfds[i].fd == -1)
+ {
+ /* MATCH!!#$*&$ */
+ return i;
}
- assert(1 == 0);
- /* NOTREACHED */
- return -1;
+ }
+ assert(1 == 0);
+ /* NOTREACHED */
+ return -1;
}
+
/*
* set and clear entries in the pollfds[] array.
- */
+ */
static void
poll_update_pollfds(int fd, short event, PF * handler)
-{
- fde_t *F = &fd_table[fd];
- int comm_index;
+{
+ fde_t *F = &fd_table[fd];
+ int comm_index;
- if(F->comm_index < 0)
- {
- F->comm_index = poll_findslot();
- }
- comm_index = F->comm_index;
+ if (F->comm_index < 0)
+ {
+ F->comm_index = poll_findslot();
+ }
+ comm_index = F->comm_index;
- /* Update the events */
- if (handler)
- {
- F->list = FDLIST_IDLECLIENT;
- pollfd_list.pollfds[comm_index].events |= event;
- pollfd_list.pollfds[comm_index].fd = fd;
- /* update maxindex here */
- if (comm_index > pollfd_list.maxindex)
- pollfd_list.maxindex = comm_index;
- }
- else
+ /* Update the events */
+ if (handler)
+ {
+ F->list = FDLIST_IDLECLIENT;
+ pollfd_list.pollfds[comm_index].events |= event;
+ pollfd_list.pollfds[comm_index].fd = fd;
+ /* update maxindex here */
+ if (comm_index > pollfd_list.maxindex)
+ pollfd_list.maxindex = comm_index;
+ }
+ else
+ {
+ if (comm_index >= 0)
+ {
+ pollfd_list.pollfds[comm_index].events &= ~event;
+ if (pollfd_list.pollfds[comm_index].events == 0)
{
- if (comm_index >= 0)
- {
- pollfd_list.pollfds[comm_index].events &= ~event;
- if (pollfd_list.pollfds[comm_index].events == 0)
- {
- pollfd_list.pollfds[comm_index].fd = -1;
- pollfd_list.pollfds[comm_index].revents = 0;
- F->comm_index = -1;
- F->list = FDLIST_NONE;
+ pollfd_list.pollfds[comm_index].fd = -1;
+ pollfd_list.pollfds[comm_index].revents = 0;
+ F->comm_index = -1;
+ F->list = FDLIST_NONE;
- /* update pollfd_list.maxindex here */
- if (comm_index == pollfd_list.maxindex)
- while (pollfd_list.maxindex >= 0 &&
- pollfd_list.pollfds[pollfd_list.maxindex].fd == -1)
- pollfd_list.maxindex--;
- }
- }
+ /* update pollfd_list.maxindex here */
+ if (comm_index == pollfd_list.maxindex)
+ while (pollfd_list.maxindex >= 0 &&
+ pollfd_list.pollfds[pollfd_list.maxindex].fd == -1)
+ pollfd_list.maxindex--;
}
+ }
+ }
}
* This is a needed exported function which will be called to initialise
* the network loop code.
*/
-void init_netio(void)
+void
+init_netio(void)
{
- int fd;
+ int fd;
- for (fd = 0; fd < MAXCONNECTIONS; fd++) {
- pollfd_list.pollfds[fd].fd = -1;
- }
- pollfd_list.maxindex = 0;
+ for (fd = 0; fd < MAXCONNECTIONS; fd++)
+ {
+ pollfd_list.pollfds[fd].fd = -1;
+ }
+ pollfd_list.maxindex = 0;
}
/*
*/
void
comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
- void *client_data, time_t timeout)
-{
- fde_t *F = &fd_table[fd];
- assert(fd >= 0);
- assert(F->flags.open);
+ void *client_data, time_t timeout)
+{
+ fde_t *F = &fd_table[fd];
+ assert(fd >= 0);
+ assert(F->flags.open);
- if (type & COMM_SELECT_READ) {
- F->read_handler = handler;
- F->read_data = client_data;
- poll_update_pollfds(fd, POLLRDNORM, handler);
- }
- if (type & COMM_SELECT_WRITE) {
- F->write_handler = handler;
- F->write_data = client_data;
- poll_update_pollfds(fd, POLLWRNORM, handler);
- }
- if (timeout)
- F->timeout = CurrentTime + (timeout / 1000);
+ if (type & COMM_SELECT_READ)
+ {
+ F->read_handler = handler;
+ F->read_data = client_data;
+ poll_update_pollfds(fd, POLLRDNORM, handler);
+ }
+ if (type & COMM_SELECT_WRITE)
+ {
+ F->write_handler = handler;
+ F->write_data = client_data;
+ poll_update_pollfds(fd, POLLWRNORM, handler);
+ }
+ if (timeout)
+ F->timeout = CurrentTime + (timeout / 1000);
}
-
+
/* int comm_select_fdlist(unsigned long delay)
* Input: The maximum time to delay.
* Output: Returns -1 on error, 0 on success.
int
comm_select(unsigned long delay)
{
- int num;
- int fd;
- int ci;
- PF *hdl;
-
- for (;;)
- {
- /* XXX kill that +1 later ! -- adrian */
- num = poll(pollfd_list.pollfds, pollfd_list.maxindex + 1, delay);
- if (num >= 0)
- break;
- if (ignoreErrno(errno))
- continue;
- /* error! */
- set_time();
- return -1;
- /* NOTREACHED */
- }
-
- /* update current time again, eww.. */
- set_time();
- callbacks_called += num;
-
- if (num == 0)
- return 0;
- /* XXX we *could* optimise by falling out after doing num fds ... */
- for (ci = 0; ci < pollfd_list.maxindex + 1; ci++)
- {
- fde_t *F;
- int revents;
- if (((revents = pollfd_list.pollfds[ci].revents) == 0) ||
- (pollfd_list.pollfds[ci].fd) == -1)
- continue;
- fd = pollfd_list.pollfds[ci].fd;
- F = &fd_table[fd];
- if (revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR))
+ int num;
+ int fd;
+ int ci;
+ PF *hdl;
+
+ for (;;)
{
- hdl = F->read_handler;
- F->read_handler = NULL;
- poll_update_pollfds(fd, POLLRDNORM, NULL);
- if (hdl)
- hdl(fd, F->read_data);
+ /* XXX kill that +1 later ! -- adrian */
+ num = poll(pollfd_list.pollfds, pollfd_list.maxindex + 1, delay);
+ if (num >= 0)
+ break;
+ if (ignoreErrno(errno))
+ continue;
+ /* error! */
+ set_time();
+ return -1;
+ /* NOTREACHED */
}
- if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR))
+
+ /* update current time again, eww.. */
+ set_time();
+ callbacks_called += num;
+
+ if (num == 0)
+ return 0;
+ /* XXX we *could* optimise by falling out after doing num fds ... */
+ for (ci = 0; ci < pollfd_list.maxindex + 1; ci++)
{
- hdl = F->write_handler;
- F->write_handler = NULL;
- poll_update_pollfds(fd, POLLWRNORM, NULL);
- if (hdl)
- hdl(fd, F->write_data);
+ fde_t *F;
+ int revents;
+ if (((revents = pollfd_list.pollfds[ci].revents) == 0) ||
+ (pollfd_list.pollfds[ci].fd) == -1)
+ continue;
+ fd = pollfd_list.pollfds[ci].fd;
+ F = &fd_table[fd];
+ if (revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR))
+ {
+ hdl = F->read_handler;
+ F->read_handler = NULL;
+ poll_update_pollfds(fd, POLLRDNORM, NULL);
+ if (hdl)
+ hdl(fd, F->read_data);
+ }
+ if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR))
+ {
+ hdl = F->write_handler;
+ F->write_handler = NULL;
+ poll_update_pollfds(fd, POLLWRNORM, NULL);
+ if (hdl)
+ hdl(fd, F->write_data);
+ }
}
- }
- return 0;
+ return 0;
}
#endif
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_bsd_select.c,v 1.1 2002/01/04 09:14:30 a1kmm Exp $
+ * $Id: s_bsd_select.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
#include "config.h"
#include "fdlist.h"
#include <sys/ioctl.h>
#include <sys/resource.h>
#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h> /* NOFILE */
+#include <sys/param.h> /* NOFILE */
#endif
#include <arpa/inet.h>
#include <assert.h>
fd_set tmpreadfds;
fd_set tmpwritefds;
-static void select_update_selectfds(int fd, short event, PF *handler);
+static void select_update_selectfds(int fd, short event, PF * handler);
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
/* Private functions */
/*
* set and clear entries in the select array ..
- */
+ */
static void
-select_update_selectfds(int fd, short event, PF *handler)
-{
- /* Update the read / write set */
- if (event & COMM_SELECT_READ) {
- if (handler)
- FD_SET(fd, &select_readfds);
- else
- FD_CLR(fd, &select_readfds);
- }
- if (event & COMM_SELECT_WRITE) {
- if (handler)
- FD_SET(fd, &select_writefds);
- else
- FD_CLR(fd, &select_writefds);
- }
+select_update_selectfds(int fd, short event, PF * handler)
+{
+ /* Update the read / write set */
+ if (event & COMM_SELECT_READ)
+ {
+ if (handler)
+ FD_SET(fd, &select_readfds);
+ else
+ FD_CLR(fd, &select_readfds);
+ }
+ if (event & COMM_SELECT_WRITE)
+ {
+ if (handler)
+ FD_SET(fd, &select_writefds);
+ else
+ FD_CLR(fd, &select_writefds);
+ }
}
* This is a needed exported function which will be called to initialise
* the network loop code.
*/
-void init_netio(void)
+void
+init_netio(void)
{
- FD_ZERO(&select_readfds);
- FD_ZERO(&select_writefds);
+ FD_ZERO(&select_readfds);
+ FD_ZERO(&select_writefds);
}
/*
*/
void
comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
- void *client_data, time_t timeout)
-{
- fde_t *F = &fd_table[fd];
- assert(fd >= 0);
- assert(F->flags.open);
+ void *client_data, time_t timeout)
+{
+ fde_t *F = &fd_table[fd];
+ assert(fd >= 0);
+ assert(F->flags.open);
#ifdef NOTYET
- debug(5, 5) ("commSetSelect: FD %d type %d, %s\n", fd, type, handler ? "SET"
- : "CLEAR");
+ debug(5, 5) ("commSetSelect: FD %d type %d, %s\n", fd, type, handler ? "SET"
+ : "CLEAR");
#endif
- if (type & COMM_SELECT_READ) {
- F->read_handler = handler;
- F->read_data = client_data;
- select_update_selectfds(fd, COMM_SELECT_READ, handler);
- }
- if (type & COMM_SELECT_WRITE) {
- F->write_handler = handler;
- F->write_data = client_data;
- select_update_selectfds(fd, COMM_SELECT_WRITE, handler);
- }
- if (timeout)
- F->timeout = CurrentTime + (timeout / 1000);
+ if (type & COMM_SELECT_READ)
+ {
+ F->read_handler = handler;
+ F->read_data = client_data;
+ select_update_selectfds(fd, COMM_SELECT_READ, handler);
+ }
+ if (type & COMM_SELECT_WRITE)
+ {
+ F->write_handler = handler;
+ F->write_data = client_data;
+ select_update_selectfds(fd, COMM_SELECT_WRITE, handler);
+ }
+ if (timeout)
+ F->timeout = CurrentTime + (timeout / 1000);
}
-
+
/*
* Check all connections for new connections and input data that is to be
* processed. Also check for connections with data queued and whether we can
int
comm_select(unsigned long delay)
{
- int num;
- int fd;
- PF *hdl;
- fde_t *F;
- struct timeval to;
-
- /* Copy over the read/write sets so we don't have to rebuild em */
- bcopy(&select_readfds, &tmpreadfds, sizeof(fd_set));
- bcopy(&select_writefds, &tmpwritefds, sizeof(fd_set));
-
- for (;;) {
- to.tv_sec = 0;
- to.tv_usec = delay * 1000;
- num = select(highest_fd + 1, &tmpreadfds, &tmpwritefds, NULL, &to);
- if (num >= 0)
- break;
- if (ignoreErrno(errno))
- continue;
- set_time();
- /* error! */
- return -1;
- /* NOTREACHED */
- }
- callbacks_called += num;
+ int num;
+ int fd;
+ PF *hdl;
+ fde_t *F;
+ struct timeval to;
+
+ /* Copy over the read/write sets so we don't have to rebuild em */
+ bcopy(&select_readfds, &tmpreadfds, sizeof(fd_set));
+ bcopy(&select_writefds, &tmpwritefds, sizeof(fd_set));
+
+ for (;;)
+ {
+ to.tv_sec = 0;
+ to.tv_usec = delay * 1000;
+ num = select(highest_fd + 1, &tmpreadfds, &tmpwritefds, NULL, &to);
+ if (num >= 0)
+ break;
+ if (ignoreErrno(errno))
+ continue;
set_time();
+ /* error! */
+ return -1;
+ /* NOTREACHED */
+ }
+ callbacks_called += num;
+ set_time();
+
+ if (num == 0)
+ return 0;
- if (num == 0)
- return 0;
-
- /* XXX we *could* optimise by falling out after doing num fds ... */
- for (fd = 0; fd < highest_fd + 1; fd++) {
- F = &fd_table[fd];
-
- if (FD_ISSET(fd, &tmpreadfds)) {
- hdl = F->read_handler;
- F->read_handler = NULL;
- select_update_selectfds(fd, COMM_SELECT_READ, NULL);
- if (!hdl) {
- /* XXX Eek! This is another bad place! */
- } else {
- hdl(fd, F->read_data);
- }
- }
- if (FD_ISSET(fd, &tmpwritefds)) {
- hdl = F->write_handler;
- F->write_handler = NULL;
- select_update_selectfds(fd, COMM_SELECT_WRITE, NULL);
- if (!hdl) {
- /* XXX Eek! This is another bad place! */
- } else {
- hdl(fd, F->write_data);
- }
- }
+ /* XXX we *could* optimise by falling out after doing num fds ... */
+ for (fd = 0; fd < highest_fd + 1; fd++)
+ {
+ F = &fd_table[fd];
+
+ if (FD_ISSET(fd, &tmpreadfds))
+ {
+ hdl = F->read_handler;
+ F->read_handler = NULL;
+ select_update_selectfds(fd, COMM_SELECT_READ, NULL);
+ if (!hdl)
+ {
+ /* XXX Eek! This is another bad place! */
+ }
+ else
+ {
+ hdl(fd, F->read_data);
+ }
}
- return 0;
+ if (FD_ISSET(fd, &tmpwritefds))
+ {
+ hdl = F->write_handler;
+ F->write_handler = NULL;
+ select_update_selectfds(fd, COMM_SELECT_WRITE, NULL);
+ if (!hdl)
+ {
+ /* XXX Eek! This is another bad place! */
+ }
+ else
+ {
+ hdl(fd, F->write_data);
+ }
+ }
+ }
+ return 0;
}
#endif /* USE_SELECT */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_bsd_sigio.c,v 1.1 2002/01/04 09:15:00 a1kmm Exp $
+ * $Id: s_bsd_sigio.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1 /* Needed for F_SETSIG */
static int sigio_signal;
static int sigio_is_screwed = 0; /* We overflowed our sigio queue */
static sigset_t our_sigset;
-struct _pollfd_list {
- struct pollfd pollfds[MAXCONNECTIONS];
- int maxindex; /* highest FD number */
+struct _pollfd_list
+{
+ struct pollfd pollfds[MAXCONNECTIONS];
+ int maxindex; /* highest FD number */
};
typedef struct _pollfd_list pollfd_list_t;
* Output: None
* Side Effects: Sets O_ASYNC on the said descriptor
*/
-static void set_sigio(int fd)
+static void
+set_sigio(int fd)
{
- int flags;
- fcntl(fd, F_GETFL, &flags);
- flags |= O_ASYNC | O_NONBLOCK;
- fcntl(fd, F_SETFL, flags);
+ int flags;
+ fcntl(fd, F_GETFL, &flags);
+ flags |= O_ASYNC | O_NONBLOCK;
+ fcntl(fd, F_SETFL, flags);
}
/*
* Output: None
* Side Effects: Removes O_ASYNC from the fd
*/
-static void clear_sigio(int fd)
+static void
+clear_sigio(int fd)
{
- int flags;
- fcntl(fd, F_GETFL, &flags);
- flags &= ~O_ASYNC;
- /* This _is_ needed... */
- flags |= O_NONBLOCK;
- fcntl(fd, F_SETFL, flags);
+ int flags;
+ fcntl(fd, F_GETFL, &flags);
+ flags &= ~O_ASYNC;
+ /* This _is_ needed... */
+ flags |= O_NONBLOCK;
+ fcntl(fd, F_SETFL, flags);
}
/*
* Output: None
* Side Effects: Block the said signal
*/
-static void mask_our_signal(int s)
+static void
+mask_our_signal(int s)
{
- sigemptyset(&our_sigset);
- sigaddset(&our_sigset, s);
- sigprocmask(SIG_BLOCK, &our_sigset, NULL);
+ sigemptyset(&our_sigset);
+ sigaddset(&our_sigset, s);
+ sigprocmask(SIG_BLOCK, &our_sigset, NULL);
}
/*
* find a spare slot in the fd list. We can optimise this out later!
* -- adrian
*/
-static inline int poll_findslot(void)
+static inline int
+poll_findslot(void)
{
- int i;
- for (i = 0; i < MAXCONNECTIONS; i++)
+ int i;
+ for (i = 0; i < MAXCONNECTIONS; i++)
+ {
+ if (pollfd_list.pollfds[i].fd == -1)
{
- if (pollfd_list.pollfds[i].fd == -1)
- {
- /* MATCH!!#$*&$ */
- return i;
- }
+ /* MATCH!!#$*&$ */
+ return i;
}
- assert(1 == 0);
- /* NOTREACHED */
- return -1;
+ }
+ assert(1 == 0);
+ /* NOTREACHED */
+ return -1;
}
/*
* set and clear entries in the pollfds[] array.
*/
-static void poll_update_pollfds(int fd, short event, PF * handler)
+static void
+poll_update_pollfds(int fd, short event, PF * handler)
{
- fde_t *F = &fd_table[fd];
- int comm_index;
+ fde_t *F = &fd_table[fd];
+ int comm_index;
- if (F->comm_index < 0)
- {
- set_sigio(fd);
- F->comm_index = poll_findslot();
- }
- comm_index = F->comm_index;
+ if (F->comm_index < 0)
+ {
+ set_sigio(fd);
+ F->comm_index = poll_findslot();
+ }
+ comm_index = F->comm_index;
- /* Update the events */
- if (handler)
- {
- F->list = FDLIST_IDLECLIENT;
- pollfd_list.pollfds[comm_index].events |= event;
- pollfd_list.pollfds[comm_index].fd = fd;
- /* update maxindex here */
- if (comm_index > pollfd_list.maxindex)
- pollfd_list.maxindex = comm_index;
- } else
+ /* Update the events */
+ if (handler)
+ {
+ F->list = FDLIST_IDLECLIENT;
+ pollfd_list.pollfds[comm_index].events |= event;
+ pollfd_list.pollfds[comm_index].fd = fd;
+ /* update maxindex here */
+ if (comm_index > pollfd_list.maxindex)
+ pollfd_list.maxindex = comm_index;
+ }
+ else
+ {
+ if (comm_index >= 0)
{
- if (comm_index >= 0)
- {
- pollfd_list.pollfds[comm_index].events &= ~event;
- if (pollfd_list.pollfds[comm_index].events == 0)
- {
- clear_sigio(fd);
- pollfd_list.pollfds[comm_index].fd = -1;
- pollfd_list.pollfds[comm_index].revents = 0;
- F->comm_index = -1;
- F->list = FDLIST_NONE;
+ pollfd_list.pollfds[comm_index].events &= ~event;
+ if (pollfd_list.pollfds[comm_index].events == 0)
+ {
+ clear_sigio(fd);
+ pollfd_list.pollfds[comm_index].fd = -1;
+ pollfd_list.pollfds[comm_index].revents = 0;
+ F->comm_index = -1;
+ F->list = FDLIST_NONE;
- /* update pollfd_list.maxindex here */
- if (comm_index == pollfd_list.maxindex)
- {
- while (pollfd_list.maxindex >= 0 &&
- pollfd_list.pollfds[pollfd_list.maxindex].fd == -1)
- pollfd_list.maxindex--;
- }
- }
+ /* update pollfd_list.maxindex here */
+ if (comm_index == pollfd_list.maxindex)
+ {
+ while (pollfd_list.maxindex >= 0 &&
+ pollfd_list.pollfds[pollfd_list.maxindex].fd == -1)
+ pollfd_list.maxindex--;
}
+ }
}
+ }
}
*
* Note: This signal handler indicates an error condition
*/
-void do_sigio(int s)
+void
+do_sigio(int s)
{
- sigio_is_screwed = 1;
+ sigio_is_screwed = 1;
}
/*
* Output: None
* Side Effect: Sets the FD up for SIGIO
*/
-void setup_sigio_fd(int fd)
+void
+setup_sigio_fd(int fd)
{
- int flags;
- fcntl(fd, F_SETOWN, getpid());
- fcntl(fd, F_SETSIG, sigio_signal);
- fcntl(fd, F_GETFL, &flags);
- flags |= O_ASYNC | O_NONBLOCK;
- fcntl(fd, F_SETFL, flags);
+ int flags;
+ fcntl(fd, F_SETOWN, getpid());
+ fcntl(fd, F_SETSIG, sigio_signal);
+ fcntl(fd, F_GETFL, &flags);
+ flags |= O_ASYNC | O_NONBLOCK;
+ fcntl(fd, F_SETFL, flags);
}
/*
* Side Effects: This is a needed exported function which will
* be called to initialise the network loop code.
*/
-void init_netio(void)
+void
+init_netio(void)
{
- int fd;
- sigio_signal = SIGRTMIN;
- for (fd = 0; fd < MAXCONNECTIONS; fd++)
- {
- pollfd_list.pollfds[fd].fd = -1;
- }
- pollfd_list.maxindex = 0;
- mask_our_signal(sigio_signal);
+ int fd;
+ sigio_signal = SIGRTMIN;
+ for (fd = 0; fd < MAXCONNECTIONS; fd++)
+ {
+ pollfd_list.pollfds[fd].fd = -1;
+ }
+ pollfd_list.maxindex = 0;
+ mask_our_signal(sigio_signal);
}
/*
comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
void *client_data, time_t timeout)
{
- int new_hdl;
- fde_t *F = &fd_table[fd];
- assert(fd >= 0);
- assert(F->flags.open);
- if (type & COMM_SELECT_READ)
- {
- new_hdl = (F->read_handler == NULL);
- F->read_handler = handler;
- F->read_data = client_data;
- poll_update_pollfds(fd, POLLIN, handler);
- if (new_hdl && handler != NULL)
- handler(fd, client_data);
- }
- if (type & COMM_SELECT_WRITE)
- {
- new_hdl = (F->write_handler == NULL);
- F->write_handler = handler;
- F->write_data = client_data;
- poll_update_pollfds(fd, POLLOUT, handler);
- if (new_hdl && handler != NULL)
- handler(fd, client_data);
- }
- if (timeout)
- F->timeout = CurrentTime + (timeout / 1000);
+ int new_hdl;
+ fde_t *F = &fd_table[fd];
+ assert(fd >= 0);
+ assert(F->flags.open);
+ if (type & COMM_SELECT_READ)
+ {
+ new_hdl = (F->read_handler == NULL);
+ F->read_handler = handler;
+ F->read_data = client_data;
+ poll_update_pollfds(fd, POLLIN, handler);
+ if (new_hdl && handler != NULL)
+ handler(fd, client_data);
+ }
+ if (type & COMM_SELECT_WRITE)
+ {
+ new_hdl = (F->write_handler == NULL);
+ F->write_handler = handler;
+ F->write_data = client_data;
+ poll_update_pollfds(fd, POLLOUT, handler);
+ if (new_hdl && handler != NULL)
+ handler(fd, client_data);
+ }
+ if (timeout)
+ F->timeout = CurrentTime + (timeout / 1000);
}
/* int comm_select(unsigned long delay)
* comm_setselect and fd_table[] and calls callbacks for IO ready
* events.
*/
-int comm_select(unsigned long delay)
+int
+comm_select(unsigned long delay)
{
- int num = 0;
- int revents = 0;
- int sig;
- int fd;
- int ci;
- PF *hdl;
- fde_t *F;
- struct siginfo si;
- struct timespec timeout;
- timeout.tv_sec = 0;
- timeout.tv_nsec = 1000000 * delay;
- for (;;)
+ int num = 0;
+ int revents = 0;
+ int sig;
+ int fd;
+ int ci;
+ PF *hdl;
+ fde_t *F;
+ struct siginfo si;
+ struct timespec timeout;
+ timeout.tv_sec = 0;
+ timeout.tv_nsec = 1000000 * delay;
+ for (;;)
+ {
+ if (!sigio_is_screwed)
{
- if (!sigio_is_screwed)
+ if ((sig = sigtimedwait(&our_sigset, &si, &timeout)) > 0)
+ {
+ if (sig == SIGIO)
{
- if ((sig = sigtimedwait(&our_sigset, &si, &timeout)) > 0)
- {
- if (sig == SIGIO)
- {
- sigio_is_screwed = 1;
- break;
- }
- fd = si.si_fd;
- pollfd_list.pollfds[fd].revents |= si.si_band;
- revents = pollfd_list.pollfds[fd].revents;
- num++;
- F = &fd_table[fd];
- set_time();
- if (revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR))
- {
- callbacks_called++;
- hdl = F->read_handler;
- F->read_handler = NULL;
- poll_update_pollfds(fd, POLLIN, NULL);
- if (hdl)
- hdl(fd, F->read_data);
- }
- if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR))
- {
- callbacks_called++;
- hdl = F->write_handler;
- F->write_handler = NULL;
- poll_update_pollfds(fd, POLLOUT, NULL);
- if (hdl)
- hdl(fd, F->write_data);
- }
- } else
- break;
-
- } else
- break;
- }
- if (!sigio_is_screwed) /* We don't need to proceed */
- {
- set_time();
- return 0;
- }
- for (;;)
- {
- if (sigio_is_screwed)
- {
- signal(sigio_signal, SIG_IGN);
- signal(sigio_signal, SIG_DFL);
- sigio_is_screwed = 0;
+ sigio_is_screwed = 1;
+ break;
}
- num = poll(pollfd_list.pollfds, pollfd_list.maxindex + 1, 0);
- if (num >= 0)
- break;
- if (ignoreErrno(errno))
- continue;
- /* error! */
- set_time();
- return -1;
- /* NOTREACHED */
- }
-
- /* update current time again, eww.. */
- set_time();
-
- if (num == 0)
- return 0;
- /* XXX we *could* optimise by falling out after doing num fds ... */
- for (ci = 0; ci < pollfd_list.maxindex + 1; ci++)
- {
- if (((revents = pollfd_list.pollfds[ci].revents) == 0) ||
- (pollfd_list.pollfds[ci].fd) == -1)
- continue;
- fd = pollfd_list.pollfds[ci].fd;
+ fd = si.si_fd;
+ pollfd_list.pollfds[fd].revents |= si.si_band;
+ revents = pollfd_list.pollfds[fd].revents;
+ num++;
F = &fd_table[fd];
+ set_time();
if (revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR))
{
- callbacks_called++;
- hdl = F->read_handler;
- F->read_handler = NULL;
- poll_update_pollfds(fd, POLLIN, NULL);
- if (hdl)
- hdl(fd, F->read_data);
+ callbacks_called++;
+ hdl = F->read_handler;
+ F->read_handler = NULL;
+ poll_update_pollfds(fd, POLLIN, NULL);
+ if (hdl)
+ hdl(fd, F->read_data);
}
if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR))
{
- callbacks_called++;
- hdl = F->write_handler;
- F->write_handler = NULL;
- poll_update_pollfds(fd, POLLOUT, NULL);
- if (hdl)
- hdl(fd, F->write_data);
+ callbacks_called++;
+ hdl = F->write_handler;
+ F->write_handler = NULL;
+ poll_update_pollfds(fd, POLLOUT, NULL);
+ if (hdl)
+ hdl(fd, F->write_data);
}
+ }
+ else
+ break;
+
}
+ else
+ break;
+ }
+ if (!sigio_is_screwed) /* We don't need to proceed */
+ {
+ set_time();
return 0;
+ }
+ for (;;)
+ {
+ if (sigio_is_screwed)
+ {
+ signal(sigio_signal, SIG_IGN);
+ signal(sigio_signal, SIG_DFL);
+ sigio_is_screwed = 0;
+ }
+ num = poll(pollfd_list.pollfds, pollfd_list.maxindex + 1, 0);
+ if (num >= 0)
+ break;
+ if (ignoreErrno(errno))
+ continue;
+ /* error! */
+ set_time();
+ return -1;
+ /* NOTREACHED */
+ }
+
+ /* update current time again, eww.. */
+ set_time();
+
+ if (num == 0)
+ return 0;
+ /* XXX we *could* optimise by falling out after doing num fds ... */
+ for (ci = 0; ci < pollfd_list.maxindex + 1; ci++)
+ {
+ if (((revents = pollfd_list.pollfds[ci].revents) == 0) ||
+ (pollfd_list.pollfds[ci].fd) == -1)
+ continue;
+ fd = pollfd_list.pollfds[ci].fd;
+ F = &fd_table[fd];
+ if (revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR))
+ {
+ callbacks_called++;
+ hdl = F->read_handler;
+ F->read_handler = NULL;
+ poll_update_pollfds(fd, POLLIN, NULL);
+ if (hdl)
+ hdl(fd, F->read_data);
+ }
+ if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR))
+ {
+ callbacks_called++;
+ hdl = F->write_handler;
+ F->write_handler = NULL;
+ poll_update_pollfds(fd, POLLOUT, NULL);
+ if (hdl)
+ hdl(fd, F->write_data);
+ }
+ }
+ return 0;
}
#endif
*
* (C) 1988 University of Oulu,Computing Center and Jarkko Oikarinen"
*
- * $Id: s_conf.c,v 1.1 2002/01/04 09:14:35 a1kmm Exp $
+ * $Id: s_conf.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
#include <sys/types.h>
struct config_server_hide ConfigServerHide;
-extern int yyparse(); /* defined in y.tab.c */
+extern int yyparse(); /* defined in y.tab.c */
extern int lineno;
extern char linebuf[];
-int scount = 0; /* used by yyparse(), etc */
+int scount = 0; /* used by yyparse(), etc */
#ifndef INADDR_NONE
#define INADDR_NONE ((unsigned int) 0xffffffff)
/* internally defined functions */
-static void lookup_confhost(struct ConfItem* aconf);
-static int SplitUserHost(struct ConfItem *aconf);
+static void lookup_confhost(struct ConfItem *aconf);
+static int SplitUserHost(struct ConfItem *aconf);
-static void set_default_conf(void);
-static void validate_conf(void);
-static void read_conf(FBFILE*);
-static void clear_out_old_conf(void);
-static void flush_deleted_I_P(void);
-static void expire_tklines(dlink_list *);
-static int is_attached(struct Client *client_p, struct ConfItem *aconf);
+static void set_default_conf(void);
+static void validate_conf(void);
+static void read_conf(FBFILE *);
+static void clear_out_old_conf(void);
+static void flush_deleted_I_P(void);
+static void expire_tklines(dlink_list *);
+static int is_attached(struct Client *client_p, struct ConfItem *aconf);
-FBFILE* conf_fbfile_in;
-char conf_line_in[256];
-struct ConfItem* yy_aconf;
+FBFILE *conf_fbfile_in;
+char conf_line_in[256];
+struct ConfItem *yy_aconf;
extern char yytext[];
/* address of class 0 conf */
-static struct Class* class0;
+static struct Class *class0;
-static int verify_access(struct Client *client_p, const char *username);
-static int attach_iline(struct Client *, struct ConfItem *);
+static int verify_access(struct Client *client_p, const char *username);
+static int attach_iline(struct Client *, struct ConfItem *);
static void clear_special_conf(struct ConfItem **);
#else
struct irc_inaddr ip;
#endif
- int count;
+ int count;
#ifdef PACE_CONNECT
time_t last_attempt;
#endif
struct ip_entry *next;
-} IP_ENTRY;
+}
+IP_ENTRY;
static IP_ENTRY *ip_hash_table[IP_HASH_SIZE];
static int hash_ip(struct irc_inaddr *);
-static IP_ENTRY *find_or_add_ip(struct irc_inaddr*);
+static IP_ENTRY *find_or_add_ip(struct irc_inaddr *);
/* general conf items link list root */
-struct ConfItem* ConfigItemList = NULL;
+struct ConfItem *ConfigItemList = NULL;
/* conf xline link list root */
-struct ConfItem *x_conf = ((struct ConfItem *)NULL);
+struct ConfItem *x_conf = ((struct ConfItem *)NULL);
/* conf uline link list root */
-struct ConfItem *u_conf = ((struct ConfItem *)NULL);
+struct ConfItem *u_conf = ((struct ConfItem *)NULL);
/*
* conf_dns_callback
* a non-null pointer, otherwise hp will be null.
* if successful save hp in the conf item it was called with
*/
-static void
-conf_dns_callback(void* vptr, adns_answer *reply)
+static void
+conf_dns_callback(void *vptr, adns_answer * reply)
{
- struct ConfItem *aconf = (struct ConfItem *) vptr;
+ struct ConfItem *aconf = (struct ConfItem *)vptr;
if (reply->status == adns_s_ok)
{
* allocate a dns_query and start ns lookup.
*/
void
-conf_dns_lookup(struct ConfItem* aconf)
+conf_dns_lookup(struct ConfItem *aconf)
{
if (aconf->dns_query == NULL)
- {
- aconf->dns_query = MyMalloc(sizeof(struct DNSQuery));
- aconf->dns_query->ptr = aconf;
- aconf->dns_query->callback = conf_dns_callback;
- adns_gethost(aconf->host, aconf->aftype, aconf->dns_query);
- }
+ {
+ aconf->dns_query = MyMalloc(sizeof(struct DNSQuery));
+ aconf->dns_query->ptr = aconf;
+ aconf->dns_query->callback = conf_dns_callback;
+ adns_gethost(aconf->host, aconf->aftype, aconf->dns_query);
+ }
}
/*
* output - pointer to new conf entry
* side effects - none
*/
-struct ConfItem*
+struct ConfItem *
make_conf()
{
- struct ConfItem* aconf;
+ struct ConfItem *aconf;
- aconf = (struct ConfItem*) MyMalloc(sizeof(struct ConfItem));
+ aconf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem));
memset(aconf, 0, sizeof(*aconf));
- aconf->status = CONF_ILLEGAL;
- aconf->aftype = AF_INET;
+ aconf->status = CONF_ILLEGAL;
+ aconf->aftype = AF_INET;
return (aconf);
}
* output - none
* side effects - remove conf item from ConfigItemList
*/
-static void
-delist_conf(struct ConfItem* aconf)
+static void
+delist_conf(struct ConfItem *aconf)
{
if (aconf == ConfigItemList)
{
ConfigItemList = ConfigItemList->next;
}
else
- {
- struct ConfItem* bconf;
+ {
+ struct ConfItem *bconf;
- /* jdc -- "for ();" is evil; Semicolon-o-Death. Use while(). */
- bconf = ConfigItemList;
- while (aconf != bconf->next)
- {
- bconf = bconf->next;
- }
- bconf->next = aconf->next;
+ /* jdc -- "for ();" is evil; Semicolon-o-Death. Use while(). */
+ bconf = ConfigItemList;
+ while (aconf != bconf->next)
+ {
+ bconf = bconf->next;
}
+ bconf->next = aconf->next;
+ }
aconf->next = NULL;
}
* output - none
* side effects - crucial password fields are zeroed, conf is freed
*/
-void
-free_conf(struct ConfItem* aconf)
+void
+free_conf(struct ConfItem *aconf)
{
assert(aconf != NULL);
assert(!(aconf->status & CONF_CLIENT) ||
MyFree(aconf->className);
MyFree(aconf->user);
#ifdef HAVE_LIBCRYPTO
- if (aconf->rsa_public_key) { RSA_free(aconf->rsa_public_key); }
- if (aconf->rsa_public_key_file) { MyFree(aconf->rsa_public_key_file); }
+ if (aconf->rsa_public_key)
+ {
+ RSA_free(aconf->rsa_public_key);
+ }
+ if (aconf->rsa_public_key_file)
+ {
+ MyFree(aconf->rsa_public_key_file);
+ }
#endif
- MyFree((char*) aconf);
+ MyFree((char *)aconf);
}
/*
}
}
-static struct LinkReport {
+static struct LinkReport
+{
int conf_type;
int rpl_stats;
int conf_char;
-} report_array[] = {
- { CONF_SERVER, RPL_STATSCLINE, 'C'},
- { CONF_LEAF, RPL_STATSLLINE, 'L'},
- { CONF_OPERATOR, RPL_STATSOLINE, 'O'},
- { CONF_HUB, RPL_STATSHLINE, 'H'},
- { 0, 0, '\0' }
+}
+report_array[] =
+{
+ {
+ CONF_SERVER, RPL_STATSCLINE, 'C'}
+ ,
+ {
+ CONF_LEAF, RPL_STATSLLINE, 'L'}
+ ,
+ {
+ CONF_OPERATOR, RPL_STATSOLINE, 'O'}
+ ,
+ {
+ CONF_HUB, RPL_STATSHLINE, 'H'}
+ ,
+ {
+ 0, 0, '\0'}
};
/*
* output - NONE
* side effects -
*/
-void
-report_configured_links(struct Client* source_p, int mask)
+void
+report_configured_links(struct Client *source_p, int mask)
{
- struct ConfItem* tmp;
- struct LinkReport* p;
- char* host;
- char* pass;
- char* user;
- char* name;
- char* classname;
- int port;
+ struct ConfItem *tmp;
+ struct LinkReport *p;
+ char *host;
+ char *pass;
+ char *user;
+ char *name;
+ char *classname;
+ int port;
- for (tmp = ConfigItemList; tmp; tmp = tmp->next) {
+ for (tmp = ConfigItemList; tmp; tmp = tmp->next)
+ {
if (tmp->status & mask)
- {
- for (p = &report_array[0]; p->conf_type; p++)
- if (p->conf_type == tmp->status)
- break;
-
- if(p->conf_type == 0)
- return;
+ {
+ for (p = &report_array[0]; p->conf_type; p++)
+ if (p->conf_type == tmp->status)
+ break;
- get_printable_conf(tmp, &name, &host, &pass, &user, &port,&classname);
+ if (p->conf_type == 0)
+ return;
- if(mask & CONF_SERVER)
- {
- char c;
- char buf[20];
- char *s = buf;
-
- buf[0] = '\0';
- c = p->conf_char;
-
- if (tmp->flags & CONF_FLAGS_ALLOW_AUTO_CONN)
- *s++ = 'A';
- if (tmp->flags & CONF_FLAGS_CRYPTLINK)
- *s++ = 'C';
- if (tmp->flags & CONF_FLAGS_LAZY_LINK)
- *s++ = 'L';
- if (tmp->flags & CONF_FLAGS_COMPRESSED)
- *s++ = 'Z';
- if (tmp->fakename)
- *s++ = 'M';
-
- if (!buf[0])
- *s++ = '*';
-
- *s++ = '\0';
- /* Allow admins to see actual ips */
- if(IsOperAdmin(source_p))
- sendto_one(source_p, form_str(p->rpl_stats), me.name,
- source_p->name, c,
- host,
- buf,
- name,
- port,
- classname,
- oper_flags_as_string((int)tmp->hold));
- else
- sendto_one(source_p, form_str(p->rpl_stats), me.name,
- source_p->name, c,
- "*@127.0.0.1",
- buf,
- name,
- port,
- classname);
+ get_printable_conf(tmp, &name, &host, &pass, &user, &port, &classname);
- }
- else if(mask & (CONF_OPERATOR))
- {
- /* Don't allow non opers to see oper privs */
- if(IsOper(source_p))
- sendto_one(source_p, form_str(p->rpl_stats), me.name,
- source_p->name,
- p->conf_char,
- user, host, name,
- oper_privs_as_string((struct Client *)NULL,port),
- classname,
- oper_flags_as_string((int)tmp->hold));
- else
- sendto_one(source_p, form_str(p->rpl_stats), me.name,
- source_p->name, p->conf_char,
- user, host, name,
- "0",
- classname,
- "");
- }
+ if (mask & CONF_SERVER)
+ {
+ char c;
+ char buf[20];
+ char *s = buf;
+
+ buf[0] = '\0';
+ c = p->conf_char;
+
+ if (tmp->flags & CONF_FLAGS_ALLOW_AUTO_CONN)
+ *s++ = 'A';
+ if (tmp->flags & CONF_FLAGS_CRYPTLINK)
+ *s++ = 'C';
+ if (tmp->flags & CONF_FLAGS_LAZY_LINK)
+ *s++ = 'L';
+ if (tmp->flags & CONF_FLAGS_COMPRESSED)
+ *s++ = 'Z';
+ if (tmp->fakename)
+ *s++ = 'M';
+
+ if (!buf[0])
+ *s++ = '*';
+
+ *s++ = '\0';
+ /* Allow admins to see actual ips */
+ if (IsOperAdmin(source_p))
+ sendto_one(source_p, form_str(p->rpl_stats), me.name,
+ source_p->name, c,
+ host,
+ buf,
+ name,
+ port, classname, oper_flags_as_string((int)tmp->hold));
+ else
+ sendto_one(source_p, form_str(p->rpl_stats), me.name,
+ source_p->name, c,
+ "*@127.0.0.1", buf, name, port, classname);
+
+ }
+ else if (mask & (CONF_OPERATOR))
+ {
+ /* Don't allow non opers to see oper privs */
+ if (IsOper(source_p))
+ sendto_one(source_p, form_str(p->rpl_stats), me.name,
+ source_p->name,
+ p->conf_char,
+ user, host, name,
+ oper_privs_as_string((struct Client *)NULL, port),
+ classname, oper_flags_as_string((int)tmp->hold));
else
sendto_one(source_p, form_str(p->rpl_stats), me.name,
source_p->name, p->conf_char,
- host, name, port,
- classname);
+ user, host, name, "0", classname, "");
}
+ else
+ sendto_one(source_p, form_str(p->rpl_stats), me.name,
+ source_p->name, p->conf_char, host, name, port, classname);
+ }
}
}
* output - none
* side effects -
*/
-void
-report_specials(struct Client* source_p, int flags, int numeric)
+void
+report_specials(struct Client *source_p, int flags, int numeric)
{
- struct ConfItem* this_conf;
- struct ConfItem* aconf;
- char* name;
- char* host;
- char* pass;
- char* user;
- char* classname;
- int port;
+ struct ConfItem *this_conf;
+ struct ConfItem *aconf;
+ char *name;
+ char *host;
+ char *pass;
+ char *user;
+ char *classname;
+ int port;
if (flags & CONF_XLINE)
this_conf = x_conf;
else if (flags & CONF_ULINE)
this_conf = u_conf;
- else return;
+ else
+ return;
for (aconf = this_conf; aconf; aconf = aconf->next)
if (aconf->status & flags)
- {
- get_printable_conf(aconf, &name, &host, &pass,
- &user, &port, &classname);
-
- sendto_one(source_p, form_str(numeric),
- me.name,
- source_p->name,
- name,
- pass);
- }
+ {
+ get_printable_conf(aconf, &name, &host, &pass,
+ &user, &port, &classname);
+
+ sendto_one(source_p, form_str(numeric),
+ me.name, source_p->name, name, pass);
+ }
}
/*
* Look for conf lines which have the same
* status as the flags passed.
*/
-int
+int
check_client(struct Client *client_p, struct Client *source_p, char *username)
{
- static char sockname[HOSTLEN + 1];
- int i;
-
+ static char sockname[HOSTLEN + 1];
+ int i;
+
ClearAccess(source_p);
if ((i = verify_access(source_p, username)))
- {
- ilog(L_INFO, "Access denied: %s[%s]", source_p->name, sockname);
- }
+ {
+ ilog(L_INFO, "Access denied: %s[%s]", source_p->name, sockname);
+ }
- switch( i )
- {
+ switch (i)
+ {
case SOCKET_ERROR:
(void)exit_client(client_p, source_p, &me, "Socket Error");
break;
case TOO_MANY:
- sendto_realops_flags(FLAGS_FULL, L_ALL,
+ sendto_realops_flags(FLAGS_FULL, L_ALL,
"Too many on IP for %s (%s).",
- get_client_name(source_p, SHOW_IP),
- source_p->localClient->sockhost);
-
- ilog(L_INFO,"Too many connections on IP from %s.",
- get_client_name(source_p, SHOW_IP));
-
+ get_client_name(source_p, SHOW_IP),
+ source_p->localClient->sockhost);
+
+ ilog(L_INFO, "Too many connections on IP from %s.",
+ get_client_name(source_p, SHOW_IP));
+
ServerStats->is_ref++;
- (void)exit_client(client_p, source_p, &me,
- "No more connections allowed on that IP" );
+ (void)exit_client(client_p, source_p, &me,
+ "No more connections allowed on that IP");
break;
case I_LINE_FULL:
sendto_realops_flags(FLAGS_FULL, L_ALL,
"I-line is full for %s (%s).",
- get_client_name(source_p, SHOW_IP),
- source_p->localClient->sockhost);
-
- ilog(L_INFO,"Too many connections from %s.",
- get_client_name(source_p, SHOW_IP));
-
+ get_client_name(source_p, SHOW_IP),
+ source_p->localClient->sockhost);
+
+ ilog(L_INFO, "Too many connections from %s.",
+ get_client_name(source_p, SHOW_IP));
+
ServerStats->is_ref++;
- (void)exit_client(client_p, source_p, &me,
- "No more connections allowed in your connection class" );
+ (void)exit_client(client_p, source_p, &me,
+ "No more connections allowed in your connection class");
break;
case NOT_AUTHORIZED:
ServerStats->is_ref++;
/* jdc - lists server name & port connections are on */
/* a purely cosmetical change */
- inetntop(source_p->localClient->aftype, &IN_ADDR(source_p->localClient->ip), ipaddr, HOSTIPLEN);
+ inetntop(source_p->localClient->aftype,
+ &IN_ADDR(source_p->localClient->ip), ipaddr, HOSTIPLEN);
sendto_realops_flags(FLAGS_UNAUTH, L_ALL,
- "Unauthorised client connection from %s [%s] on [%s/%u].",
- get_client_name(source_p, SHOW_IP),
- ipaddr,
- source_p->localClient->listener->name,
- source_p->localClient->listener->port);
-
+ "Unauthorised client connection from %s [%s] on [%s/%u].",
+ get_client_name(source_p, SHOW_IP), ipaddr,
+ source_p->localClient->listener->name,
+ source_p->localClient->listener->port);
+
ilog(L_INFO,
- "Unauthorized client connection from %s on [%s/%u].",
- get_client_name(source_p, SHOW_IP),
- source_p->localClient->listener->name,
- source_p->localClient->listener->port);
-
+ "Unauthorized client connection from %s on [%s/%u].",
+ get_client_name(source_p, SHOW_IP),
+ source_p->localClient->listener->name,
+ source_p->localClient->listener->port);
+
(void)exit_client(client_p, source_p, &me,
- "You are not authorized to use this server");
+ "You are not authorized to use this server");
break;
}
case BANNED_CLIENT:
- (void)exit_client(client_p,client_p, &me, "*** Banned ");
+ (void)exit_client(client_p, client_p, &me, "*** Banned ");
ServerStats->is_ref++;
break;
case 0:
default:
break;
- }
- return(i);
+ }
+ return (i);
}
/*
* output - 0 if success -'ve if not
* side effect - find the first (best) I line to attach.
*/
-static int
-verify_access(struct Client* client_p, const char* username)
+static int
+verify_access(struct Client *client_p, const char *username)
{
- struct ConfItem* aconf;
- struct ConfItem* gkill_conf;
- char non_ident[USERLEN + 1];
+ struct ConfItem *aconf;
+ struct ConfItem *gkill_conf;
+ char non_ident[USERLEN + 1];
if (IsGotId(client_p))
- {
- aconf = find_address_conf(client_p->host,client_p->username,
- &client_p->localClient->ip,
- client_p->localClient->aftype);
- }
+ {
+ aconf = find_address_conf(client_p->host, client_p->username,
+ &client_p->localClient->ip,
+ client_p->localClient->aftype);
+ }
else
- {
- non_ident[0] = '~';
- strncpy_irc(&non_ident[1],username, USERLEN - 1);
- non_ident[USERLEN] = '\0';
- aconf = find_address_conf(client_p->host,non_ident,
- &client_p->localClient->ip,
- client_p->localClient->aftype);
- }
+ {
+ non_ident[0] = '~';
+ strncpy_irc(&non_ident[1], username, USERLEN - 1);
+ non_ident[USERLEN] = '\0';
+ aconf = find_address_conf(client_p->host, non_ident,
+ &client_p->localClient->ip,
+ client_p->localClient->aftype);
+ }
if (aconf != NULL)
+ {
+ if (aconf->status & CONF_CLIENT)
+ {
+ if (aconf->flags & CONF_FLAGS_REDIR)
+ {
+ sendto_one(client_p, form_str(RPL_REDIR), me.name, client_p->name,
+ aconf->name ? aconf->name : "", aconf->port);
+ return (NOT_AUTHORIZED);
+ }
+ if (ConfigFileEntry.glines)
+ {
+ if (!IsConfExemptKline(aconf))
+ {
+ if (IsGotId(client_p))
+ gkill_conf = find_gkill(client_p, client_p->username);
+ else
+ gkill_conf = find_gkill(client_p, non_ident);
+
+ if (gkill_conf)
+ {
+ sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name,
+ client_p->name);
+ sendto_one(client_p, ":%s NOTICE %s :*** Banned %s",
+ me.name, client_p->name, gkill_conf->passwd);
+ return (BANNED_CLIENT);
+ }
+ }
+ }
+ if (IsConfDoIdentd(aconf))
+ SetNeedId(client_p);
+ if (IsConfRestricted(aconf))
+ SetRestricted(client_p);
+ /* Thanks for spoof idea amm */
+ if (IsConfDoSpoofIp(aconf))
+ {
+ if (IsConfSpoofNotice(aconf))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "%s spoofing: %s as %s", client_p->name,
+ client_p->host, aconf->name);
+ }
+ strncpy_irc(client_p->host, aconf->name, HOSTLEN);
+ SetIPSpoof(client_p);
+ }
+ return (attach_iline(client_p, aconf));
+ }
+ else if (aconf->status & CONF_KILL)
{
- if (aconf->status & CONF_CLIENT)
- {
- if (aconf->flags & CONF_FLAGS_REDIR)
- {
- sendto_one(client_p, form_str(RPL_REDIR), me.name, client_p->name,
- aconf->name ? aconf->name : "", aconf->port);
- return(NOT_AUTHORIZED);
- }
- if (ConfigFileEntry.glines)
- {
- if (!IsConfExemptKline(aconf))
- {
- if (IsGotId(client_p))
- gkill_conf = find_gkill(client_p, client_p->username);
- else
- gkill_conf = find_gkill(client_p, non_ident);
-
- if (gkill_conf)
- {
- sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name,
- client_p->name);
- sendto_one(client_p, ":%s NOTICE %s :*** Banned %s",
- me.name, client_p->name,
- gkill_conf->passwd);
- return(BANNED_CLIENT);
- }
- }
- }
- if (IsConfDoIdentd(aconf))
- SetNeedId(client_p);
- if (IsConfRestricted(aconf))
- SetRestricted(client_p);
- /* Thanks for spoof idea amm */
- if (IsConfDoSpoofIp(aconf))
- {
- if (IsConfSpoofNotice(aconf))
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "%s spoofing: %s as %s", client_p->name,
- client_p->host, aconf->name);
- }
- strncpy_irc(client_p->host, aconf->name, HOSTLEN);
- SetIPSpoof(client_p);
- }
- return(attach_iline(client_p, aconf));
- }
- else if (aconf->status & CONF_KILL)
- {
- if (ConfigFileEntry.kline_with_reason)
- {
- sendto_one(client_p, ":%s NOTICE %s :*** Banned %s",
- me.name,client_p->name,aconf->passwd);
- }
- return(BANNED_CLIENT);
- }
+ if (ConfigFileEntry.kline_with_reason)
+ {
+ sendto_one(client_p, ":%s NOTICE %s :*** Banned %s",
+ me.name, client_p->name, aconf->passwd);
+ }
+ return (BANNED_CLIENT);
}
- return(NOT_AUTHORIZED);
+ }
+ return (NOT_AUTHORIZED);
}
/*
* output -
* side effects - do actual attach
*/
-static
-int attach_iline(struct Client *client_p, struct ConfItem *aconf)
+static int
+attach_iline(struct Client *client_p, struct ConfItem *aconf)
{
IP_ENTRY *ip_found;
ip_found = find_or_add_ip(&client_p->localClient->ip);
ip_found->count++;
/* only check it if its non zero */
- if ( aconf->c_class /* This should never non NULL *grin* */ &&
- ConfConFreq(aconf) && ip_found->count > ConfConFreq(aconf))
+ if (aconf->c_class /* This should never non NULL *grin* */ &&
+ ConfConFreq(aconf) && ip_found->count > ConfConFreq(aconf))
+ {
+ if (!IsConfExemptLimits(aconf))
+ return TOO_MANY; /* Already at maximum allowed ip#'s */
+ else
{
- if(!IsConfExemptLimits(aconf))
- return TOO_MANY; /* Already at maximum allowed ip#'s */
- else
- {
- sendto_one(client_p,
- ":%s NOTICE %s :*** :I: line is full, but you have an >I: line!",
- me.name,client_p->name);
- }
+ sendto_one(client_p,
+ ":%s NOTICE %s :*** :I: line is full, but you have an >I: line!",
+ me.name, client_p->name);
}
+ }
- return (attach_conf(client_p, aconf) );
+ return (attach_conf(client_p, aconf));
}
/* link list of free IP_ENTRY's */
*
*/
-void
+void
clear_ip_hash_table()
{
- void *block_IP_ENTRIES; /* block of IP_ENTRY's */
- IP_ENTRY *new_IP_ENTRY; /* new IP_ENTRY being made */
- IP_ENTRY *last_IP_ENTRY; /* last IP_ENTRY in chain */
+ void *block_IP_ENTRIES; /* block of IP_ENTRY's */
+ IP_ENTRY *new_IP_ENTRY; /* new IP_ENTRY being made */
+ IP_ENTRY *last_IP_ENTRY; /* last IP_ENTRY in chain */
int size;
int n_left_to_allocate = MAXCONNECTIONS;
- size = sizeof(IP_ENTRY) + (sizeof(IP_ENTRY) & (sizeof(void*) - 1) );
+ size = sizeof(IP_ENTRY) + (sizeof(IP_ENTRY) & (sizeof(void *) - 1));
- block_IP_ENTRIES = (void *)MyMalloc((size * n_left_to_allocate));
+ block_IP_ENTRIES = (void *)MyMalloc((size * n_left_to_allocate));
- free_ip_entries = (IP_ENTRY *)block_IP_ENTRIES;
+ free_ip_entries = (IP_ENTRY *) block_IP_ENTRIES;
last_IP_ENTRY = free_ip_entries;
/* *shudder* pointer arithmetic */
- while(--n_left_to_allocate)
- {
- block_IP_ENTRIES = (void *)((unsigned long)block_IP_ENTRIES +
- (unsigned long) size);
- new_IP_ENTRY = (IP_ENTRY *)block_IP_ENTRIES;
- last_IP_ENTRY->next = new_IP_ENTRY;
- new_IP_ENTRY->next = (IP_ENTRY *)NULL;
- last_IP_ENTRY = new_IP_ENTRY;
- }
+ while (--n_left_to_allocate)
+ {
+ block_IP_ENTRIES = (void *)((unsigned long)block_IP_ENTRIES +
+ (unsigned long)size);
+ new_IP_ENTRY = (IP_ENTRY *) block_IP_ENTRIES;
+ last_IP_ENTRY->next = new_IP_ENTRY;
+ new_IP_ENTRY->next = (IP_ENTRY *) NULL;
+ last_IP_ENTRY = new_IP_ENTRY;
+ }
memset((void *)ip_hash_table, 0, sizeof(ip_hash_table));
}
int hash_index;
IP_ENTRY *ptr, *newptr;
- for(ptr = ip_hash_table[hash_index = hash_ip(ip_in)]; ptr;
- ptr = ptr->next)
+ for (ptr = ip_hash_table[hash_index = hash_ip(ip_in)]; ptr; ptr = ptr->next)
{
- if(!memcmp(&ptr->ip, ip_in, sizeof(*ip_in)))
- {
- return(ptr);
- }
- }
- if ( (ptr = ip_hash_table[hash_index]) != (IP_ENTRY *)NULL )
+ if (!memcmp(&ptr->ip, ip_in, sizeof(*ip_in)))
{
- if( free_ip_entries == (IP_ENTRY *)NULL)
- outofmemory();
+ return (ptr);
+ }
+ }
+ if ((ptr = ip_hash_table[hash_index]) != (IP_ENTRY *) NULL)
+ {
+ if (free_ip_entries == (IP_ENTRY *) NULL)
+ outofmemory();
- newptr = ip_hash_table[hash_index] = free_ip_entries;
- free_ip_entries = newptr->next;
+ newptr = ip_hash_table[hash_index] = free_ip_entries;
+ free_ip_entries = newptr->next;
- memcpy(&newptr->ip, ip_in, sizeof(*ip_in));
- newptr->count = 0;
+ memcpy(&newptr->ip, ip_in, sizeof(*ip_in));
+ newptr->count = 0;
#ifdef PACE_CONNECT
- newptr->last_attempt = 0;
-#endif
- newptr->next = ptr;
- return(newptr);
- }
+ newptr->last_attempt = 0;
+#endif
+ newptr->next = ptr;
+ return (newptr);
+ }
- if( free_ip_entries == (IP_ENTRY *)NULL)
+ if (free_ip_entries == (IP_ENTRY *) NULL)
outofmemory();
ptr = ip_hash_table[hash_index] = free_ip_entries;
free_ip_entries = ptr->next;
memcpy(&ptr->ip, ip_in, sizeof(*ip_in));
ptr->count = 0;
- ptr->next = (IP_ENTRY *)NULL;
+ ptr->next = (IP_ENTRY *) NULL;
return (ptr);
}
* XXX: Broken for IPV6
*/
-void
+void
remove_one_ip(struct irc_inaddr *ip_in)
{
IP_ENTRY *ptr, **lptr;
int hash_index = hash_ip(ip_in);
- for (lptr = ip_hash_table+hash_index, ptr = *lptr;
- ptr;
- lptr=&ptr->next, ptr=*lptr)
+ for (lptr = ip_hash_table + hash_index, ptr = *lptr;
+ ptr; lptr = &ptr->next, ptr = *lptr)
{
#ifndef IPV6
- if (ptr->ip != PIN_ADDR(ip_in))
- continue;
+ if (ptr->ip != PIN_ADDR(ip_in))
+ continue;
#else
- if (memcmp(&IN_ADDR(ptr->ip), &PIN_ADDR(ip_in),
- sizeof(struct irc_inaddr)))
- continue;
+ if (memcmp(&IN_ADDR(ptr->ip), &PIN_ADDR(ip_in),
+ sizeof(struct irc_inaddr)))
+ continue;
#endif
- if (ptr->count != 0)
- ptr->count--;
+ if (ptr->count != 0)
+ ptr->count--;
#ifndef PACE_CONNECT
- if (ptr->count != 0)
- continue;
+ if (ptr->count != 0)
+ continue;
#else
- if (ptr->count != 0 ||
- (CurrentTime-ptr->last_attempt)<=ConfigFileEntry.throttle_time)
- continue;
+ if (ptr->count != 0 ||
+ (CurrentTime - ptr->last_attempt) <= ConfigFileEntry.throttle_time)
+ continue;
#endif
- *lptr = ptr->next;
- ptr->next = free_ip_entries;
- free_ip_entries = ptr;
- return;
- }
+ *lptr = ptr->next;
+ ptr->next = free_ip_entries;
+ free_ip_entries = ptr;
+ return;
+ }
}
/*
* side effects - hopefully, none
*/
-static int
+static int
hash_ip(struct irc_inaddr *addr)
{
#ifndef IPV6
u_int32_t ip;
ip = ntohl(PIN_ADDR(addr));
- hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
- return(hash);
+ hash = ((ip >> 12) + ip) & (IP_HASH_SIZE - 1);
+ return (hash);
#else
unsigned int hash = 0;
- char *ip = (char *) &PIN_ADDR(addr);
+ char *ip = (char *)&PIN_ADDR(addr);
while (*ip)
- {
- hash = (hash << 4) - (hash + (unsigned char)*ip++);
- }
+ {
+ hash = (hash << 4) - (hash + (unsigned char)*ip++);
+ }
- return(hash & (IP_HASH_SIZE - 1));
+ return (hash & (IP_HASH_SIZE - 1));
#endif
}
* used in the hash.
*/
-void
-count_ip_hash(int *number_ips_stored,u_long *mem_ips_stored)
+void
+count_ip_hash(int *number_ips_stored, u_long * mem_ips_stored)
{
IP_ENTRY *ip_hash_ptr;
int i;
*number_ips_stored = 0;
*mem_ips_stored = 0;
- for(i = 0; i < IP_HASH_SIZE ;i++)
+ for (i = 0; i < IP_HASH_SIZE; i++)
+ {
+ ip_hash_ptr = ip_hash_table[i];
+ while (ip_hash_ptr)
{
- ip_hash_ptr = ip_hash_table[i];
- while(ip_hash_ptr)
- {
- *number_ips_stored = *number_ips_stored + 1;
- *mem_ips_stored = *mem_ips_stored +
- sizeof(IP_ENTRY);
+ *number_ips_stored = *number_ips_stored + 1;
+ *mem_ips_stored = *mem_ips_stored + sizeof(IP_ENTRY);
- ip_hash_ptr = ip_hash_ptr->next;
- }
+ ip_hash_ptr = ip_hash_ptr->next;
}
+ }
}
/*
* output -
* side effects -
*/
-void
+void
iphash_stats(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[],FBFILE* out)
+ int parc, char *parv[], FBFILE * out)
{
IP_ENTRY *ip_hash_ptr;
int i;
int collision_count;
char result_buf[256];
- if(out == NULL)
- sendto_one(source_p,":%s NOTICE %s :*** hash stats for iphash",
- me.name,client_p->name);
+ if (out == NULL)
+ sendto_one(source_p, ":%s NOTICE %s :*** hash stats for iphash",
+ me.name, client_p->name);
else
+ {
+ (void)sprintf(result_buf, "*** hash stats for iphash\n");
+ (void)fbputs(result_buf, out);
+ }
+
+ for (i = 0; i < IP_HASH_SIZE; i++)
+ {
+ ip_hash_ptr = ip_hash_table[i];
+
+ collision_count = 0;
+ while (ip_hash_ptr)
{
- (void)sprintf(result_buf,"*** hash stats for iphash\n");
- (void)fbputs(result_buf,out);
+ collision_count++;
+ ip_hash_ptr = ip_hash_ptr->next;
}
-
- for(i = 0; i < IP_HASH_SIZE ;i++)
+ if (collision_count)
{
- ip_hash_ptr = ip_hash_table[i];
-
- collision_count = 0;
- while(ip_hash_ptr)
- {
- collision_count++;
- ip_hash_ptr = ip_hash_ptr->next;
- }
- if(collision_count)
- {
- if(out == NULL)
- {
- sendto_one(source_p,":%s NOTICE %s :Entry %d (0x%X) Collisions %d",
- me.name,client_p->name,i,i,collision_count);
- }
- else
- {
- (void)sprintf(result_buf,"Entry %d (0x%X) Collisions %d\n",
- i,i,collision_count);
- (void)fbputs(result_buf,out);
- }
- }
+ if (out == NULL)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Entry %d (0x%X) Collisions %d",
+ me.name, client_p->name, i, i, collision_count);
+ }
+ else
+ {
+ (void)sprintf(result_buf, "Entry %d (0x%X) Collisions %d\n",
+ i, i, collision_count);
+ (void)fbputs(result_buf, out);
+ }
}
+ }
}
/*
* side effects - Disassociate configuration from the client.
* Also removes a class from the list if marked for deleting.
*/
-int
-detach_conf(struct Client* client_p,struct ConfItem* aconf)
+int
+detach_conf(struct Client *client_p, struct ConfItem *aconf)
{
dlink_node *ptr;
- if(aconf == NULL)
+ if (aconf == NULL)
return -1;
- for( ptr = client_p->localClient->confs.head; ptr; ptr = ptr->next )
+ for (ptr = client_p->localClient->confs.head; ptr; ptr = ptr->next)
+ {
+ if (ptr->data == aconf)
{
- if (ptr->data == aconf)
+ if ((aconf) && (ClassPtr(aconf)))
+ {
+ if (aconf->status & CONF_CLIENT_MASK)
{
- if ((aconf) && (ClassPtr(aconf)))
- {
- if (aconf->status & CONF_CLIENT_MASK)
- {
- if (ConfLinks(aconf) > 0)
- --ConfLinks(aconf);
- }
- if (ConfMaxLinks(aconf) == -1 && ConfLinks(aconf) == 0)
- {
- free_class(ClassPtr(aconf));
- ClassPtr(aconf) = NULL;
- }
- }
- if (aconf && !--aconf->clients && IsIllegal(aconf))
- {
- free_conf(aconf);
- }
- dlinkDelete(ptr, &client_p->localClient->confs);
- free_dlink_node(ptr);
- return 0;
+ if (ConfLinks(aconf) > 0)
+ --ConfLinks(aconf);
}
+ if (ConfMaxLinks(aconf) == -1 && ConfLinks(aconf) == 0)
+ {
+ free_class(ClassPtr(aconf));
+ ClassPtr(aconf) = NULL;
+ }
+ }
+ if (aconf && !--aconf->clients && IsIllegal(aconf))
+ {
+ free_conf(aconf);
+ }
+ dlinkDelete(ptr, &client_p->localClient->confs);
+ free_dlink_node(ptr);
+ return 0;
}
+ }
return -1;
}
* output - 1 if attached, 0 if not
* side effects -
*/
-static int
+static int
is_attached(struct Client *client_p, struct ConfItem *aconf)
{
- dlink_node *ptr=NULL;
+ dlink_node *ptr = NULL;
for (ptr = client_p->localClient->confs.head; ptr; ptr = ptr->next)
if (ptr->data == aconf)
break;
-
+
return (ptr) ? 1 : 0;
}
* connection). Note, that this automatically changes the
* attachment if there was an old one...
*/
-int
-attach_conf(struct Client *client_p,struct ConfItem *aconf)
+int
+attach_conf(struct Client *client_p, struct ConfItem *aconf)
{
dlink_node *lp;
if (is_attached(client_p, aconf))
- {
- return 1;
- }
+ {
+ return 1;
+ }
if (IsIllegal(aconf))
- {
- return(NOT_AUTHORIZED);
- }
+ {
+ return (NOT_AUTHORIZED);
+ }
- if ( (aconf->status & CONF_OPERATOR) == 0 )
+ if ((aconf->status & CONF_OPERATOR) == 0)
+ {
+ if ((aconf->status & CONF_CLIENT) &&
+ ConfLinks(aconf) >= ConfMaxLinks(aconf) && ConfMaxLinks(aconf) > 0)
{
- if ((aconf->status & CONF_CLIENT) &&
- ConfLinks(aconf) >= ConfMaxLinks(aconf) && ConfMaxLinks(aconf) > 0)
- {
- if (!IsConfExemptLimits(aconf))
- {
- return(I_LINE_FULL);
- }
- else
- {
- send(client_p->fd,
- "NOTICE FLINE :I: line is full, but you have an >I: line!\n",
- 56, 0);
- SetExemptLimits(client_p);
- }
+ if (!IsConfExemptLimits(aconf))
+ {
+ return (I_LINE_FULL);
+ }
+ else
+ {
+ send(client_p->fd,
+ "NOTICE FLINE :I: line is full, but you have an >I: line!\n",
+ 56, 0);
+ SetExemptLimits(client_p);
+ }
- }
}
+ }
lp = make_dlink_node();
* NOTE: this will allow C:::* and N:::* because the match mask is the
* conf line and not the name
*/
-int
-attach_confs(struct Client* client_p, const char* name, int statmask)
+int
+attach_confs(struct Client *client_p, const char *name, int statmask)
{
- struct ConfItem* tmp;
- int conf_counter = 0;
-
+ struct ConfItem *tmp;
+ int conf_counter = 0;
+
for (tmp = ConfigItemList; tmp; tmp = tmp->next)
+ {
+ if ((tmp->status & statmask) && !IsIllegal(tmp) &&
+ tmp->name && match(tmp->name, name))
{
- if ((tmp->status & statmask) && !IsIllegal(tmp) &&
- tmp->name && match(tmp->name, name))
- {
- if (-1 < attach_conf(client_p, tmp))
- ++conf_counter;
- }
- else if ((tmp->status & statmask) && !IsIllegal(tmp) &&
- tmp->name && !irccmp(tmp->name, name))
- {
- if (-1 < attach_conf(client_p, tmp))
- ++conf_counter;
- }
+ if (-1 < attach_conf(client_p, tmp))
+ ++conf_counter;
+ }
+ else if ((tmp->status & statmask) && !IsIllegal(tmp) &&
+ tmp->name && !irccmp(tmp->name, name))
+ {
+ if (-1 < attach_conf(client_p, tmp))
+ ++conf_counter;
}
+ }
return conf_counter;
}
* output - true (1) if both are found, otherwise return false (0)
* side effects - find connect block and attach them to connecting client
*/
-int
+int
attach_connect_block(struct Client *client_p,
- const char* name,
- const char* host)
+ const char *name, const char *host)
{
- struct ConfItem* ptr;
+ struct ConfItem *ptr;
assert(client_p != NULL);
assert(host != NULL);
for (ptr = ConfigItemList; ptr; ptr = ptr->next)
- {
- if (IsIllegal(ptr))
- continue;
- if (ptr->status != CONF_SERVER)
- continue;
- if ((match(name, ptr->name) == 0) || (match(ptr->host, host) == 0))
- continue;
- attach_conf(client_p, ptr);
- return -1;
- }
+ {
+ if (IsIllegal(ptr))
+ continue;
+ if (ptr->status != CONF_SERVER)
+ continue;
+ if ((match(name, ptr->name) == 0) || (match(ptr->host, host) == 0))
+ continue;
+ attach_conf(client_p, ptr);
+ return -1;
+ }
return 0;
}
* side effects - find a conf entry which matches the hostname
* and has the same name.
*/
-struct ConfItem*
-find_conf_exact(const char* name, const char* user,
- const char* host, int statmask)
+struct ConfItem *
+find_conf_exact(const char *name, const char *user,
+ const char *host, int statmask)
{
struct ConfItem *tmp;
for (tmp = ConfigItemList; tmp; tmp = tmp->next)
+ {
+ if (!(tmp->status & statmask) || !tmp->name || !tmp->host ||
+ irccmp(tmp->name, name))
+ continue;
+ /*
+ ** Accept if the *real* hostname (usually sockethost)
+ ** socket host) matches *either* host or name field
+ ** of the configuration.
+ */
+ if (!match(tmp->host, host) || !match(tmp->user, user)
+ || irccmp(tmp->name, name))
+ continue;
+ if (tmp->status & CONF_OPERATOR)
{
- if (!(tmp->status & statmask) || !tmp->name || !tmp->host ||
- irccmp(tmp->name, name))
- continue;
- /*
- ** Accept if the *real* hostname (usually sockethost)
- ** socket host) matches *either* host or name field
- ** of the configuration.
- */
- if (!match(tmp->host, host) || !match(tmp->user,user)
- || irccmp(tmp->name, name) )
- continue;
- if (tmp->status & CONF_OPERATOR)
- {
- if (tmp->clients < ConfMaxLinks(tmp))
- return tmp;
- else
- continue;
- }
- else
+ if (tmp->clients < ConfMaxLinks(tmp))
return tmp;
+ else
+ continue;
}
+ else
+ return tmp;
+ }
return NULL;
}
* side effects - find a conf entry which matches the name
* and has the given mask.
*/
-struct ConfItem*
-find_conf_name(dlink_list *list, const char* name, int statmask)
+struct ConfItem *
+find_conf_name(dlink_list * list, const char *name, int statmask)
{
dlink_node *ptr;
- struct ConfItem* aconf;
-
+ struct ConfItem *aconf;
+
for (ptr = list->head; ptr; ptr = ptr->next)
- {
- aconf = ptr->data;
- if ((aconf->status & statmask) && aconf->name &&
- (!irccmp(aconf->name, name) || match(aconf->name, name)))
- return aconf;
- }
+ {
+ aconf = ptr->data;
+ if ((aconf->status & statmask) && aconf->name &&
+ (!irccmp(aconf->name, name) || match(aconf->name, name)))
+ return aconf;
+ }
return NULL;
}
* side effects - find a conf entry which matches the name
* and has the given mask.
*/
-struct ConfItem*
-find_conf_host(dlink_list *list, const char* host, int statmask)
+struct ConfItem *
+find_conf_host(dlink_list * list, const char *host, int statmask)
{
dlink_node *ptr;
struct ConfItem *aconf;
-
+
for (ptr = list->head; ptr; ptr = ptr->next)
- {
- aconf = ptr->data;
- if (aconf->status & statmask && aconf->host && match(aconf->host, host))
- return aconf;
- }
+ {
+ aconf = ptr->data;
+ if (aconf->status & statmask && aconf->host && match(aconf->host, host))
+ return aconf;
+ }
return NULL;
}
*
*/
struct ConfItem *
-find_conf_ip(dlink_list *list, char *ip, char *user, int statmask)
+find_conf_ip(dlink_list * list, char *ip, char *user, int statmask)
{
dlink_node *ptr;
struct ConfItem *aconf;
-
+
for (ptr = list->head; ptr; ptr = ptr->next)
- {
- aconf = ptr->data;
+ {
+ aconf = ptr->data;
- if (!(aconf->status & statmask))
- continue;
+ if (!(aconf->status & statmask))
+ continue;
- if (!match(aconf->user, user))
- {
- continue;
- }
-/* XXX: broken for IPv6 */
- if (!memcmp((void *)&IN_ADDR(aconf->ipnum), (void *)ip, sizeof(struct in_addr)))
- return aconf;
+ if (!match(aconf->user, user))
+ {
+ continue;
}
+/* XXX: broken for IPv6 */
+ if (!memcmp
+ ((void *)&IN_ADDR(aconf->ipnum), (void *)ip, sizeof(struct in_addr)))
+ return aconf;
+ }
return ((struct ConfItem *)NULL);
}
* and has the given mask.
*
*/
-struct ConfItem*
-find_conf_by_name(const char* name, int status)
+struct ConfItem *
+find_conf_by_name(const char *name, int status)
{
- struct ConfItem* conf;
+ struct ConfItem *conf;
assert(name != NULL);
-
+
for (conf = ConfigItemList; conf; conf = conf->next)
- {
- if (conf->status == status && conf->name &&
- match(name, conf->name))
- return conf;
- }
+ {
+ if (conf->status == status && conf->name && match(name, conf->name))
+ return conf;
+ }
return NULL;
}
* and has the given mask.
*
*/
-struct ConfItem*
-find_conf_by_host(const char* host, int status)
+struct ConfItem *
+find_conf_by_host(const char *host, int status)
{
- struct ConfItem* conf;
+ struct ConfItem *conf;
assert(host != NULL);
-
+
for (conf = ConfigItemList; conf; conf = conf->next)
- {
- if (conf->status == status && conf->host &&
- match(host, conf->host))
- return conf;
- }
+ {
+ if (conf->status == status && conf->host && match(host, conf->host))
+ return conf;
+ }
return NULL;
}
{
struct ConfItem *bconf;
- for (bconf = ConfigItemList, mask &= ~CONF_ILLEGAL; bconf;
+ for (bconf = ConfigItemList, mask &= ~CONF_ILLEGAL; bconf;
bconf = bconf->next)
- {
- if (!(bconf->status & mask) || (bconf->port != aconf->port))
- continue;
-
- if ((BadPtr(bconf->host) && !BadPtr(aconf->host)) ||
- (BadPtr(aconf->host) && !BadPtr(bconf->host)))
- continue;
+ {
+ if (!(bconf->status & mask) || (bconf->port != aconf->port))
+ continue;
+
+ if ((BadPtr(bconf->host) && !BadPtr(aconf->host)) ||
+ (BadPtr(aconf->host) && !BadPtr(bconf->host)))
+ continue;
- if (!BadPtr(bconf->host) && irccmp(bconf->host, aconf->host))
- continue;
+ if (!BadPtr(bconf->host) && irccmp(bconf->host, aconf->host))
+ continue;
- if ((BadPtr(bconf->passwd) && !BadPtr(aconf->passwd)) ||
- (BadPtr(aconf->passwd) && !BadPtr(bconf->passwd)))
- continue;
+ if ((BadPtr(bconf->passwd) && !BadPtr(aconf->passwd)) ||
+ (BadPtr(aconf->passwd) && !BadPtr(bconf->passwd)))
+ continue;
- if (!BadPtr(bconf->passwd) &&
- irccmp(bconf->passwd, aconf->passwd))
+ if (!BadPtr(bconf->passwd) && irccmp(bconf->passwd, aconf->passwd))
continue;
- if ((BadPtr(bconf->name) && !BadPtr(aconf->name)) ||
- (BadPtr(aconf->name) && !BadPtr(bconf->name)))
- continue;
+ if ((BadPtr(bconf->name) && !BadPtr(aconf->name)) ||
+ (BadPtr(aconf->name) && !BadPtr(bconf->name)))
+ continue;
- if (!BadPtr(bconf->name) && irccmp(bconf->name, aconf->name))
- continue;
- break;
- }
+ if (!BadPtr(bconf->name) && irccmp(bconf->name, aconf->name))
+ continue;
+ break;
+ }
return bconf;
}
struct ConfItem *aconf;
for (aconf = x_conf; aconf; aconf = aconf->next)
- {
- if (BadPtr(aconf->name))
- continue;
+ {
+ if (BadPtr(aconf->name))
+ continue;
- if(match(aconf->name,to_find))
- return(aconf);
+ if (match(aconf->name, to_find))
+ return (aconf);
- }
- return(NULL);
+ }
+ return (NULL);
}
/*
* output - NULL or pointer to found struct ConfItem
* side effects - looks for a matches on all fields
*/
-int
-find_u_conf(char *server,char *user,char *host)
+int
+find_u_conf(char *server, char *user, char *host)
{
struct ConfItem *aconf;
for (aconf = u_conf; aconf; aconf = aconf->next)
- {
- if (BadPtr(aconf->name))
- continue;
+ {
+ if (BadPtr(aconf->name))
+ continue;
- if(match(aconf->name,server))
- {
- if (BadPtr(aconf->user) || BadPtr(aconf->host))
- return YES;
- if(match(aconf->user,user) && match(aconf->host,host))
- return YES;
+ if (match(aconf->name, server))
+ {
+ if (BadPtr(aconf->user) || BadPtr(aconf->host))
+ return YES;
+ if (match(aconf->user, user) && match(aconf->host, host))
+ return YES;
- }
}
+ }
return NO;
}
* output - none
* side effects - clears given special conf lines
*/
-static void
+static void
clear_special_conf(struct ConfItem **this_conf)
{
struct ConfItem *aconf;
struct ConfItem *next_aconf;
for (aconf = *this_conf; aconf; aconf = next_aconf)
- {
- next_aconf = aconf->next;
- free_conf(aconf);
- }
+ {
+ next_aconf = aconf->next;
+ free_conf(aconf);
+ }
*this_conf = (struct ConfItem *)NULL;
return;
}
* as a result of an operator issuing this command, else assume it has been
* called as a result of the server receiving a HUP signal.
*/
-int rehash(int sig)
+int
+rehash(int sig)
{
if (sig)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Got signal SIGHUP, reloading ircd conf. file");
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Got signal SIGHUP, reloading ircd conf. file");
+ }
restart_resolver();
/* don't close listeners until we know we can go ahead with the rehash */
read_conf_files(NO);
if (ServerInfo.description != NULL)
- {
- strncpy_irc(me.info, ServerInfo.description, REALLEN);
- }
+ {
+ strncpy_irc(me.info, ServerInfo.description, REALLEN);
+ }
flush_deleted_I_P();
check_klines();
#define NO 0
#define UNSET -1
-static void
+static void
set_default_conf(void)
{
class0 = find_class("default"); /* which one is the default class ? */
memset(&ServerInfo.ip6, 0, sizeof(ServerInfo.ip6));
ServerInfo.specific_ipv6_vhost = 0;
- ServerInfo.max_clients = MAX_CLIENTS; /* XXX - these don't seem to */
- ServerInfo.max_buffer = MAX_BUFFER; /* actually do anything! */
+ ServerInfo.max_clients = MAX_CLIENTS; /* XXX - these don't seem to */
+ ServerInfo.max_buffer = MAX_BUFFER; /* actually do anything! */
/* Don't reset hub, as that will break lazylinks */
/* ServerInfo.hub = NO; */
ServerInfo.dns_host.sin_addr.s_addr = 0;
ConfigFileEntry.warn_no_nline = YES;
ConfigFileEntry.non_redundant_klines = YES;
ConfigFileEntry.stats_o_oper_only = NO;
- ConfigFileEntry.stats_k_oper_only = 1; /* masked */
- ConfigFileEntry.stats_i_oper_only = 1; /* masked */
+ ConfigFileEntry.stats_k_oper_only = 1; /* masked */
+ ConfigFileEntry.stats_i_oper_only = 1; /* masked */
ConfigFileEntry.stats_P_oper_only = NO;
ConfigFileEntry.pace_wait = 10;
ConfigFileEntry.caller_id_wait = 60;
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
DupString(ConfigFileEntry.servlink_path, SLPATH);
ConfigFileEntry.egdpool_path = NULL;
-
+
#ifdef HAVE_LIBCRYPTO
/* jdc -- This is our default value for a cipher. According to the
* CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported
ConfigChannel.vchans_oper_only = NO;
- ConfigChannel.use_except = YES;
- /* ConfigChannel.use_halfops = YES; */ /* Don't set, as this can't
- be changed at runtime */
- ConfigChannel.use_invex = YES;
- ConfigChannel.use_knock = YES;
+ ConfigChannel.use_except = YES;
+/* ConfigChannel.use_halfops = YES; *//* Don't set, as this can't
+ be changed at runtime */
+ ConfigChannel.use_invex = YES;
+ ConfigChannel.use_knock = YES;
ConfigChannel.use_vchans = NO;
ConfigChannel.knock_delay = 300;
ConfigChannel.knock_delay_channel = 60;
ConfigFileEntry.default_floodcount = 8;
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
}
+
#undef YES
#undef NO
* output - None
* side effects - Read configuration file.
*/
-static void
-read_conf(FBFILE* file)
+static void
+read_conf(FBFILE * file)
{
scount = lineno = 0;
- set_default_conf(); /* Set default values prior to conf parsing */
- yyparse(); /* Load the values from the conf */
- validate_conf(); /* Check to make sure some values are still okay. */
- /* Some global values are also loaded here. */
- check_class(); /* Make sure classes are valid */
+ set_default_conf(); /* Set default values prior to conf parsing */
+ yyparse(); /* Load the values from the conf */
+ validate_conf(); /* Check to make sure some values are still okay. */
+ /* Some global values are also loaded here. */
+ check_class(); /* Make sure classes are valid */
}
-static void
+static void
validate_conf(void)
{
- if(ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
+ if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
- if(ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
+ if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
- if(ConfigFileEntry.servlink_path == NULL)
+ if (ConfigFileEntry.servlink_path == NULL)
DupString(ConfigFileEntry.servlink_path, SLPATH);
- if(ServerInfo.network_name == NULL)
- DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
+ if (ServerInfo.network_name == NULL)
+ DupString(ServerInfo.network_name, NETWORK_NAME_DEFAULT);
- if(ServerInfo.network_desc == NULL)
- DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
+ if (ServerInfo.network_desc == NULL)
+ DupString(ServerInfo.network_desc, NETWORK_DESC_DEFAULT);
if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
(ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
- ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
+ ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
/* Hasn't been set yet, so set it now */
- if(ConfigChannel.use_halfops == -1)
+ if (ConfigChannel.use_halfops == -1)
ConfigChannel.use_halfops = 1;
-
+
GlobalSetOptions.idletime = (ConfigFileEntry.idletime * 60);
}
* Output - none
* Side effects - add given conf to link list
*/
-void
+void
conf_add_conf(struct ConfItem *aconf)
{
(void)collapse(aconf->host);
(void)collapse(aconf->user);
Debug((DEBUG_NOTICE,
- "Read Init: (%d) (%s) (%s) (%s) (%d) (%d)",
- aconf->status,
- aconf->host ? aconf->host : "<NULL>",
- aconf->passwd ? aconf->passwd : "<NULL>",
- aconf->user ? aconf->user : "<NULL>",
- aconf->port,
- aconf->c_class ? ConfClassType(aconf): 0 ));
+ "Read Init: (%d) (%s) (%s) (%s) (%d) (%d)",
+ aconf->status,
+ aconf->host ? aconf->host : "<NULL>",
+ aconf->passwd ? aconf->passwd : "<NULL>",
+ aconf->user ? aconf->user : "<NULL>",
+ aconf->port, aconf->c_class ? ConfClassType(aconf) : 0));
aconf->next = ConfigItemList;
ConfigItemList = aconf;
* side effects - splits user@host found in a name field of conf given
* stuff the user into ->user and the host into ->host
*/
-static int
+static int
SplitUserHost(struct ConfItem *aconf)
{
char *p;
char *new_user;
char *new_host;
- if ( (p = strchr(aconf->host, '@')) )
- {
- *p = '\0';
- DupString(new_user, aconf->host);
- MyFree(aconf->user);
- aconf->user = new_user;
- p++;
- DupString(new_host,p);
- MyFree(aconf->host);
- aconf->host = new_host;
- }
+ if ((p = strchr(aconf->host, '@')))
+ {
+ *p = '\0';
+ DupString(new_user, aconf->host);
+ MyFree(aconf->user);
+ aconf->user = new_user;
+ p++;
+ DupString(new_host, p);
+ MyFree(aconf->host);
+ aconf->host = new_host;
+ }
else
- {
- DupString(aconf->user, "*");
- }
- return(1);
+ {
+ DupString(aconf->user, "*");
+ }
+ return (1);
}
/*
* line and convert an IP addresses in a.b.c.d number for to IP#s.
*
*/
-static void
-lookup_confhost(struct ConfItem* aconf)
+static void
+lookup_confhost(struct ConfItem *aconf)
{
if (BadPtr(aconf->host) || BadPtr(aconf->name))
- {
- ilog(L_ERROR, "Host/server name error: (%s) (%s)",
- aconf->host, aconf->name);
- return;
- }
+ {
+ ilog(L_ERROR, "Host/server name error: (%s) (%s)",
+ aconf->host, aconf->name);
+ return;
+ }
if (strchr(aconf->host, '*') || strchr(aconf->host, '?'))
return;
/*
- ** Do name lookup now on hostnames given and store the
- ** ip numbers in conf structure.
- */
+ ** Do name lookup now on hostnames given and store the
+ ** ip numbers in conf structure.
+ */
if (inetpton(DEF_FAM, aconf->host, &IN_ADDR(aconf->ipnum)) <= 0)
- {
- conf_dns_lookup(aconf);
- }
+ {
+ conf_dns_lookup(aconf);
+ }
}
/*
* conf_connect_allowed (untested)
*/
-int
+int
conf_connect_allowed(struct irc_inaddr *addr, int aftype)
{
#ifdef PACE_CONNECT
IP_ENTRY *ip_found;
#endif
struct ConfItem *aconf = find_dline(addr, aftype);
-
+
/* DLINE exempt also gets you out of static limits/pacing... */
if (aconf && (aconf->status & CONF_EXEMPTDLINE))
return 0;
-
+
if (aconf)
return BANNED_CLIENT;
#ifdef PACE_CONNECT
ip_found = find_or_add_ip(addr);
- if ((CurrentTime - ip_found->last_attempt) <
- ConfigFileEntry.throttle_time)
- {
- ip_found->last_attempt = CurrentTime;
- ip_found->count--;
- return TOO_FAST;
- }
+ if ((CurrentTime - ip_found->last_attempt) < ConfigFileEntry.throttle_time)
+ {
+ ip_found->last_attempt = CurrentTime;
+ ip_found->count--;
+ return TOO_FAST;
+ }
ip_found->last_attempt = CurrentTime;
#endif
return 0;
* and if so, return struct ConfItem pointer
*/
struct ConfItem *
-find_kill(struct Client* client_p)
+find_kill(struct Client *client_p)
{
struct ConfItem *aconf;
assert(client_p != NULL);
aconf = find_address_conf(client_p->host, client_p->username,
- &client_p->localClient->ip,
- client_p->localClient->aftype);
+ &client_p->localClient->ip,
+ client_p->localClient->aftype);
if (aconf == NULL)
return aconf;
- if(aconf->status & CONF_KILL)
+ if (aconf->status & CONF_KILL)
return aconf;
return NULL;
}
* side effects - expire tklines
*/
static void
-expire_tklines(dlink_list *tklist)
+expire_tklines(dlink_list * tklist)
{
dlink_node *kill_node;
dlink_node *next_node;
struct ConfItem *kill_ptr;
for (kill_node = tklist->head; kill_node; kill_node = next_node)
+ {
+ kill_ptr = kill_node->data;
+ next_node = kill_node->next;
+
+ if (kill_ptr->hold <= CurrentTime)
{
- kill_ptr = kill_node->data;
- next_node = kill_node->next;
-
- if (kill_ptr->hold <= CurrentTime)
- {
- /* Alert opers that a TKline expired - Hwy */
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Temporary K-line for [%s@%s] expired",
- (kill_ptr->user) ? kill_ptr->user : "*",
- (kill_ptr->host) ? kill_ptr->host : "*");
-
- delete_one_address_conf(kill_ptr->host, kill_ptr);
- dlinkDelete(kill_node, tklist);
- free_dlink_node(kill_node);
- }
+ /* Alert opers that a TKline expired - Hwy */
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Temporary K-line for [%s@%s] expired",
+ (kill_ptr->user) ? kill_ptr->user : "*",
+ (kill_ptr->host) ? kill_ptr->host : "*");
+
+ delete_one_address_conf(kill_ptr->host, kill_ptr);
+ dlinkDelete(kill_node, tklist);
+ free_dlink_node(kill_node);
}
+ }
}
/*
*/
char *
-oper_privs_as_string(struct Client *client_p,int port)
+oper_privs_as_string(struct Client *client_p, int port)
{
static char privs_out[16];
char *privs_ptr;
privs_ptr = privs_out;
*privs_ptr = '\0';
- if(port & CONF_OPER_GLINE)
- {
- if(client_p)
- SetOperGline(client_p);
- *privs_ptr++ = 'G';
- }
+ if (port & CONF_OPER_GLINE)
+ {
+ if (client_p)
+ SetOperGline(client_p);
+ *privs_ptr++ = 'G';
+ }
else
*privs_ptr++ = 'g';
- if(port & CONF_OPER_K)
- {
- if(client_p)
- SetOperK(client_p);
- *privs_ptr++ = 'K';
- }
+ if (port & CONF_OPER_K)
+ {
+ if (client_p)
+ SetOperK(client_p);
+ *privs_ptr++ = 'K';
+ }
else
*privs_ptr++ = 'k';
- if(port & CONF_OPER_N)
- {
- if(client_p)
- SetOperN(client_p);
- *privs_ptr++ = 'N';
- }
+ if (port & CONF_OPER_N)
+ {
+ if (client_p)
+ SetOperN(client_p);
+ *privs_ptr++ = 'N';
+ }
- if(port & CONF_OPER_GLOBAL_KILL)
- {
- if(client_p)
- SetOperGlobalKill(client_p);
- *privs_ptr++ = 'O';
- }
+ if (port & CONF_OPER_GLOBAL_KILL)
+ {
+ if (client_p)
+ SetOperGlobalKill(client_p);
+ *privs_ptr++ = 'O';
+ }
else
*privs_ptr++ = 'o';
- if(port & CONF_OPER_REMOTE)
- {
- if(client_p)
- SetOperRemote(client_p);
- *privs_ptr++ = 'R';
- }
+ if (port & CONF_OPER_REMOTE)
+ {
+ if (client_p)
+ SetOperRemote(client_p);
+ *privs_ptr++ = 'R';
+ }
else
*privs_ptr++ = 'r';
-
- if(port & CONF_OPER_UNKLINE)
- {
- if(client_p)
- SetOperUnkline(client_p);
- *privs_ptr++ = 'U';
- }
+
+ if (port & CONF_OPER_UNKLINE)
+ {
+ if (client_p)
+ SetOperUnkline(client_p);
+ *privs_ptr++ = 'U';
+ }
else
*privs_ptr++ = 'u';
- if(port & CONF_OPER_REHASH)
- {
- if(client_p)
- SetOperRehash(client_p);
- *privs_ptr++ = 'H';
- }
+ if (port & CONF_OPER_REHASH)
+ {
+ if (client_p)
+ SetOperRehash(client_p);
+ *privs_ptr++ = 'H';
+ }
else
*privs_ptr++ = 'h';
- if(port & CONF_OPER_DIE)
- {
- if(client_p)
- SetOperDie(client_p);
- *privs_ptr++ = 'D';
- }
+ if (port & CONF_OPER_DIE)
+ {
+ if (client_p)
+ SetOperDie(client_p);
+ *privs_ptr++ = 'D';
+ }
else
*privs_ptr++ = 'd';
if (port & CONF_OPER_ADMIN)
- {
- if (client_p)
- SetOperAdmin(client_p);
- *privs_ptr++ = 'A';
- }
+ {
+ if (client_p)
+ SetOperAdmin(client_p);
+ *privs_ptr++ = 'A';
+ }
else
*privs_ptr++ = 'a';
-
+
*privs_ptr = '\0';
- return(privs_out);
+ return (privs_out);
}
flags_ptr = flags_out;
*flags_ptr = '\0';
- if(flags & FLAGS_INVISIBLE)
+ if (flags & FLAGS_INVISIBLE)
*flags_ptr++ = 'i';
- if(flags & FLAGS_WALLOP)
+ if (flags & FLAGS_WALLOP)
*flags_ptr++ = 'w';
- if(flags & FLAGS_SERVNOTICE)
+ if (flags & FLAGS_SERVNOTICE)
*flags_ptr++ = 's';
- if(flags & FLAGS_CCONN)
+ if (flags & FLAGS_CCONN)
*flags_ptr++ = 'c';
- if(flags & FLAGS_REJ)
+ if (flags & FLAGS_REJ)
*flags_ptr++ = 'r';
- if(flags & FLAGS_SKILL)
+ if (flags & FLAGS_SKILL)
*flags_ptr++ = 'k';
- if(flags & FLAGS_FULL)
+ if (flags & FLAGS_FULL)
*flags_ptr++ = 'f';
- if(flags & FLAGS_SPY)
+ if (flags & FLAGS_SPY)
*flags_ptr++ = 'y';
- if(flags & FLAGS_DEBUG)
+ if (flags & FLAGS_DEBUG)
*flags_ptr++ = 'd';
- if(flags & FLAGS_NCHANGE)
+ if (flags & FLAGS_NCHANGE)
*flags_ptr++ = 'n';
- if(flags & FLAGS_ADMIN)
+ if (flags & FLAGS_ADMIN)
*flags_ptr++ = 'a';
- if(flags & FLAGS_EXTERNAL)
+ if (flags & FLAGS_EXTERNAL)
*flags_ptr++ = 'x';
- if(flags & FLAGS_UNAUTH)
+ if (flags & FLAGS_UNAUTH)
*flags_ptr++ = 'u';
- if(flags & FLAGS_BOTS)
+ if (flags & FLAGS_BOTS)
*flags_ptr++ = 'b';
- if(flags & FLAGS_LOCOPS)
+ if (flags & FLAGS_LOCOPS)
*flags_ptr++ = 'l';
- if(flags & FLAGS_CALLERID)
+ if (flags & FLAGS_CALLERID)
*flags_ptr++ = 'g';
*flags_ptr = '\0';
- return(flags_out);
+ return (flags_out);
}
* "oper" is server name for remote opers
* Side effects: None.
*/
-char*
+char *
get_oper_name(struct Client *client_p)
{
dlink_node *cnode;
/* +5 for !,@,{,} and null */
- static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5];
+ static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
if (MyConnect(client_p))
- {
- for (cnode=client_p->localClient->confs.head; cnode; cnode=cnode->next)
- if (((struct ConfItem*)cnode->data)->status & CONF_OPERATOR)
- {
- ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
- client_p->username, client_p->host,
- ((struct ConfItem*)cnode->data)->name);
- return buffer;
- }
- /* Probably should assert here for now. If there is an oper out there
- * with no oper{} conf attached, it would be good for us to know...
- */
- assert(0); /* Oper without oper conf! */
- }
+ {
+ for (cnode = client_p->localClient->confs.head; cnode;
+ cnode = cnode->next)
+ if (((struct ConfItem *)cnode->data)->status & CONF_OPERATOR)
+ {
+ ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
+ client_p->username, client_p->host,
+ ((struct ConfItem *)cnode->data)->name);
+ return buffer;
+ }
+ /* Probably should assert here for now. If there is an oper out there
+ * with no oper{} conf attached, it would be good for us to know...
+ */
+ assert(0); /* Oper without oper conf! */
+ }
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
- client_p->username, client_p->host, client_p->servptr->name);
+ client_p->username, client_p->host, client_p->servptr->name);
return buffer;
}
* in aconf, or "<NULL>" port is set to aconf->port in all cases.
*/
-void
+void
get_printable_conf(struct ConfItem *aconf, char **name, char **host,
- char **pass, char **user,int *port,char **classname)
+ char **pass, char **user, int *port, char **classname)
{
- static char null[] = "<NULL>";
- static char zero[] = "default";
+ static char null[] = "<NULL>";
+ static char zero[] = "default";
*name = BadPtr(aconf->name) ? null : aconf->name;
*host = BadPtr(aconf->host) ? null : aconf->host;
* output - none
* side effects - read all conf files needed, ircd.conf kline.conf etc.
*/
-void
+void
read_conf_files(int cold)
{
FBFILE *file;
filename = get_conf_name(CONF_TYPE);
- if ((conf_fbfile_in = fbopen(filename,"r")) == NULL)
+ if ((conf_fbfile_in = fbopen(filename, "r")) == NULL)
+ {
+ if (cold)
{
- if(cold)
- {
- ilog(L_CRIT, "Failed in reading configuration file %s", filename);
- exit(-1);
- }
- else
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Can't open file '%s' - aborting rehash!",
- filename );
- return;
- }
+ ilog(L_CRIT, "Failed in reading configuration file %s", filename);
+ exit(-1);
+ }
+ else
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Can't open file '%s' - aborting rehash!",
+ filename);
+ return;
}
+ }
if (cold)
{
kfilename = get_conf_name(KLINE_TYPE);
if (irccmp(filename, kfilename))
+ {
+ if ((file = fbopen(kfilename, "r")) == NULL)
{
- if((file = fbopen(kfilename,"r")) == NULL)
- {
- if (cold)
- ilog(L_ERROR, "Failed reading kline file %s", filename);
- else
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Can't open %s file klines could be missing!",
- kfilename);
- }
+ if (cold)
+ ilog(L_ERROR, "Failed reading kline file %s", filename);
else
- {
- parse_k_file(file);
- fbclose(file);
- }
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Can't open %s file klines could be missing!",
+ kfilename);
+ }
+ else
+ {
+ parse_k_file(file);
+ fbclose(file);
}
+ }
dfilename = get_conf_name(DLINE_TYPE);
if (irccmp(filename, dfilename) && irccmp(kfilename, dfilename))
+ {
+ if ((file = fbopen(dfilename, "r")) == NULL)
{
- if ((file = fbopen(dfilename,"r")) == NULL)
- {
- if(cold)
- ilog(L_ERROR, "Failed reading dline file %s", dfilename);
- else
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Can't open %s file dlines could be missing!",
- dfilename);
- }
+ if (cold)
+ ilog(L_ERROR, "Failed reading dline file %s", dfilename);
else
- {
- parse_d_file(file);
- fbclose(file);
- }
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Can't open %s file dlines could be missing!",
+ dfilename);
}
+ else
+ {
+ parse_d_file(file);
+ fbclose(file);
+ }
+ }
}
/*
* output - none
* side effects - Clear out the old configuration
*/
-static
-void clear_out_old_conf(void)
+static void
+clear_out_old_conf(void)
{
struct ConfItem **tmp = &ConfigItemList;
struct ConfItem *tmp2;
- struct Class *cltmp;
+ struct Class *cltmp;
/*
* We only need to free anything allocated by yyparse() here.
* side effects - This function removes I/P conf items
*/
-static
-void flush_deleted_I_P(void)
+static void
+flush_deleted_I_P(void)
{
struct ConfItem **tmp = &ConfigItemList;
struct ConfItem *tmp2;
/*
* flush out deleted I and P lines although still in use.
*/
- for (tmp = &ConfigItemList; (tmp2 = *tmp); )
+ for (tmp = &ConfigItemList; (tmp2 = *tmp);)
+ {
+ if (!(tmp2->status & CONF_ILLEGAL))
+ tmp = &tmp2->next;
+ else
{
- if (!(tmp2->status & CONF_ILLEGAL))
- tmp = &tmp2->next;
- else
- {
- *tmp = tmp2->next;
- tmp2->next = NULL;
- if (!tmp2->clients)
- free_conf(tmp2);
- }
+ *tmp = tmp2->next;
+ tmp2->next = NULL;
+ if (!tmp2->clients)
+ free_conf(tmp2);
}
+ }
}
/*
* forwarding the kline onto the next U lined server
*
*/
-void
-WriteKlineOrDline( KlineType type,
- struct Client *source_p,
- char *user,
- char *host,
- const char *reason,
- const char *oper_reason,
- const char *current_date,
- time_t cur_time)
+void
+WriteKlineOrDline(KlineType type,
+ struct Client *source_p,
+ char *user,
+ char *host,
+ const char *reason,
+ const char *oper_reason,
+ const char *current_date, time_t cur_time)
{
char buffer[1024];
FBFILE *out;
filename = get_conf_name(type);
- if(type == DLINE_TYPE)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s added D-Line for [%s] [%s]",
- get_oper_name(source_p), host, reason);
- sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s] to %s",
- me.name, source_p->name, host, filename);
+ if (type == DLINE_TYPE)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s added D-Line for [%s] [%s]",
+ get_oper_name(source_p), host, reason);
+ sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s] to %s",
+ me.name, source_p->name, host, filename);
- }
+ }
else
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s added K-Line for [%s@%s] [%s]",
- get_oper_name(source_p), user, host, reason);
- sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]",
- me.name, source_p->name, user, host);
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s added K-Line for [%s@%s] [%s]",
+ get_oper_name(source_p), user, host, reason);
+ sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]",
+ me.name, source_p->name, user, host);
+ }
- if ( (out = fbopen(filename, "a")) == NULL )
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** Problem opening %s ", filename);
- return;
- }
+ if ((out = fbopen(filename, "a")) == NULL)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** Problem opening %s ", filename);
+ return;
+ }
if (oper_reason == NULL)
oper_reason = "";
- if(type==KLINE_TYPE)
+ if (type == KLINE_TYPE)
ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
user,
- host,
+ host,
reason,
- oper_reason,
- current_date,
- get_oper_name(source_p),
- (long) cur_time);
+ oper_reason,
+ current_date, get_oper_name(source_p), (long)cur_time);
else
ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
host,
reason,
- oper_reason,
- current_date,
- get_oper_name(source_p),
- (long) cur_time);
+ oper_reason,
+ current_date, get_oper_name(source_p), (long)cur_time);
- if (fbputs(buffer,out) == -1)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "*** Problem writing to %s",filename);
- fbclose(out);
- return;
- }
-
+ if (fbputs(buffer, out) == -1)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** Problem writing to %s", filename);
+ fbclose(out);
+ return;
+ }
+
fbclose(out);
- if(type==KLINE_TYPE)
+ if (type == KLINE_TYPE)
ilog(L_TRACE, "%s added K-Line for [%s@%s] [%s]",
- source_p->name, user, host, reason);
+ source_p->name, user, host, reason);
else
ilog(L_TRACE, "%s added D-Line for [%s] [%s]",
- get_oper_name(source_p), host, reason);
+ get_oper_name(source_p), host, reason);
}
/* get_conf_name
const char *
get_conf_name(KlineType type)
{
- if(type == CONF_TYPE)
- {
- return(ConfigFileEntry.configfile);
- }
- else if(type == KLINE_TYPE)
- {
- return(ConfigFileEntry.klinefile);
- }
+ if (type == CONF_TYPE)
+ {
+ return (ConfigFileEntry.configfile);
+ }
+ else if (type == KLINE_TYPE)
+ {
+ return (ConfigFileEntry.klinefile);
+ }
- return(ConfigFileEntry.dlinefile);
+ return (ConfigFileEntry.dlinefile);
}
/*
*
*/
-void
-conf_add_class(struct ConfItem *aconf,int sendq)
+void
+conf_add_class(struct ConfItem *aconf, int sendq)
{
/*
- ** If conf line is a class definition, create a class entry
- */
- /*
- ** associate each conf line with a class by using a pointer
- ** to the correct class record. -avalon
- */
+ ** If conf line is a class definition, create a class entry
+ */
+ /*
+ ** associate each conf line with a class by using a pointer
+ ** to the correct class record. -avalon
+ */
if (aconf->host)
- {
- add_class(aconf->host, atoi(aconf->passwd),
- atoi(aconf->user), aconf->port,
- sendq);
- }
+ {
+ add_class(aconf->host, atoi(aconf->passwd),
+ atoi(aconf->user), aconf->port, sendq);
+ }
}
/*
* side effects - Add a class pointer to a conf
*/
-void
+void
conf_add_class_to_conf(struct ConfItem *aconf)
{
- if(aconf->className == NULL)
- {
- DupString(aconf->className,"default");
- ClassPtr(aconf) = class0;
- return;
- }
+ if (aconf->className == NULL)
+ {
+ DupString(aconf->className, "default");
+ ClassPtr(aconf) = class0;
+ return;
+ }
ClassPtr(aconf) = find_class(aconf->className);
- if(ClassPtr(aconf) == class0)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Warning *** Defaulting to default class for missing class \"%s\"",
- aconf->className);
- MyFree(aconf->className);
- DupString(aconf->className,"default");
- return;
- }
+ if (ClassPtr(aconf) == class0)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Warning *** Defaulting to default class for missing class \"%s\"",
+ aconf->className);
+ MyFree(aconf->className);
+ DupString(aconf->className, "default");
+ return;
+ }
if (ConfMaxLinks(aconf) < 0)
- {
- ClassPtr(aconf) = find_class(0);
- MyFree(aconf->className);
- DupString(aconf->className,"default");
- return;
- }
+ {
+ ClassPtr(aconf) = find_class(0);
+ MyFree(aconf->className);
+ DupString(aconf->className, "default");
+ return;
+ }
}
/*
* side effects - delist old conf (if present)
*/
-void
+void
conf_delist_old_conf(struct ConfItem *aconf)
{
struct ConfItem *bconf;
if ((bconf = find_conf_entry(aconf, aconf->status)))
- {
- delist_conf(bconf);
- bconf->status &= ~CONF_ILLEGAL;
- if (aconf->status == CONF_CLIENT)
- {
- ConfLinks(bconf) -= bconf->clients;
- ClassPtr(bconf) = ClassPtr(aconf);
- ConfLinks(bconf) += bconf->clients;
- bconf->flags = aconf->flags;
- if(bconf->flags & CONF_OPERATOR)
- bconf->port = aconf->port;
- }
- free_conf(aconf);
- aconf = bconf;
- }
+ {
+ delist_conf(bconf);
+ bconf->status &= ~CONF_ILLEGAL;
+ if (aconf->status == CONF_CLIENT)
+ {
+ ConfLinks(bconf) -= bconf->clients;
+ ClassPtr(bconf) = ClassPtr(aconf);
+ ConfLinks(bconf) += bconf->clients;
+ bconf->flags = aconf->flags;
+ if (bconf->flags & CONF_OPERATOR)
+ bconf->port = aconf->port;
+ }
+ free_conf(aconf);
+ aconf = bconf;
+ }
}
#define MAXCONFLINKS 150
* output - NONE
* side effects - Add a connect block
*/
-int
+int
conf_add_server(struct ConfItem *aconf, int lcount)
{
conf_add_class_to_conf(aconf);
if (lcount > MAXCONFLINKS || !aconf->host || !aconf->name)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"Bad connect block");
- ilog(L_WARN, "Bad connect block");
- return -1;
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Bad connect block");
+ ilog(L_WARN, "Bad connect block");
+ return -1;
+ }
if (BadPtr(aconf->passwd) && !(aconf->flags & CONF_FLAGS_CRYPTLINK))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"Bad connect block, name %s",
- aconf->name);
- ilog(L_WARN, "Bad connect block, host %s",aconf->name);
- return -1;
- }
-
- if( SplitUserHost(aconf) < 0 )
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"Bad connect block, name %s",
- aconf->name);
- ilog(L_WARN, "Bad connect block, name %s",aconf->name);
- return -1;
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Bad connect block, name %s",
+ aconf->name);
+ ilog(L_WARN, "Bad connect block, host %s", aconf->name);
+ return -1;
+ }
+
+ if (SplitUserHost(aconf) < 0)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Bad connect block, name %s",
+ aconf->name);
+ ilog(L_WARN, "Bad connect block, name %s", aconf->name);
+ return -1;
+ }
lookup_confhost(aconf);
return 0;
}
*/
if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST)
- {
- ilog(L_WARN,"Invalid Dline %s ignored",aconf->host);
- free_conf(aconf);
- }
+ {
+ ilog(L_WARN, "Invalid Dline %s ignored", aconf->host);
+ free_conf(aconf);
+ }
else
- {
- add_conf_by_address(aconf->host, CONF_DLINE, NULL, aconf);
- }
+ {
+ add_conf_by_address(aconf->host, CONF_DLINE, NULL, aconf);
+ }
}
/*
* side effects - Add a X line
*/
-void
+void
conf_add_x_conf(struct ConfItem *aconf)
{
MyFree(aconf->user);
* side effects - Add an U line
*/
-void
+void
conf_add_u_conf(struct ConfItem *aconf)
{
aconf->next = u_conf;
* side effects - update host/pass/user/port fields of given aconf
*/
-void
+void
conf_add_fields(struct ConfItem *aconf,
- char *host_field,
- char *pass_field,
- char *user_field,
- char *port_field,
- char *class_field)
+ char *host_field,
+ char *pass_field,
+ char *user_field, char *port_field, char *class_field)
{
- if(host_field)
+ if (host_field)
DupString(aconf->host, host_field);
- if(pass_field)
+ if (pass_field)
DupString(aconf->passwd, pass_field);
- if(user_field)
+ if (user_field)
DupString(aconf->user, user_field);
- if(port_field)
+ if (port_field)
aconf->port = atoi(port_field);
- if(class_field)
+ if (class_field)
DupString(aconf->className, class_field);
}
* output - none
* side effects - message to opers and log file entry is made
*/
-void
+void
yyerror(char *msg)
{
char newlinebuf[BUFSIZE];
strip_tabs(newlinebuf, (const unsigned char *)linebuf, strlen(linebuf));
- sendto_realops_flags(FLAGS_ALL, L_ALL,"%d: %s on line: %s",
- lineno + 1, msg, newlinebuf);
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%d: %s on line: %s",
+ lineno + 1, msg, newlinebuf);
- ilog(L_WARN, "%d: %s on line: %s",
- lineno + 1, msg, newlinebuf);
+ ilog(L_WARN, "%d: %s on line: %s", lineno + 1, msg, newlinebuf);
}
-int
-conf_fbgets(char *lbuf,int max_size, FBFILE *fb)
+int
+conf_fbgets(char *lbuf, int max_size, FBFILE * fb)
{
- char* buff;
+ char *buff;
- buff = fbgets(lbuf,max_size,fb);
+ buff = fbgets(lbuf, max_size, fb);
- if(!buff)
+ if (!buff)
return 0;
- return(strlen(lbuf));
+ return (strlen(lbuf));
}
-int
+int
conf_yy_fatal_error(char *msg)
{
return 0;
time_t expire_before = CurrentTime - ConfigFileEntry.throttle_time;
IP_ENTRY *ie, **iee;
- for (i=0; i<IP_HASH_SIZE; i++)
+ for (i = 0; i < IP_HASH_SIZE; i++)
+ {
+ for (iee = ip_hash_table + i, ie = *iee; ie; ie = *iee)
{
- for (iee=ip_hash_table+i, ie=*iee; ie; ie=*iee)
- {
- if (ie->count == 0 && ie->last_attempt <= expire_before)
- {
- *iee=ie->next;
- ie->next = free_ip_entries;
- free_ip_entries = ie;
- }
- else
- iee = &ie->next;
- }
- *iee = NULL;
+ if (ie->count == 0 && ie->last_attempt <= expire_before)
+ {
+ *iee = ie->next;
+ ie->next = free_ip_entries;
+ free_ip_entries = ie;
+ }
+ else
+ iee = &ie->next;
}
+ *iee = NULL;
+ }
}
#endif
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_debug.c,v 1.1 2002/01/04 09:14:40 a1kmm Exp $
+ * $Id: s_debug.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
-#include <sys/types.h>
+#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/file.h>
'\0'
};
-void debug(int level, char *format, ...)
+void
+debug(int level, char *format, ...)
{
static char debugbuf[1024];
va_list args;
int err = errno;
- if ((debuglevel >= 0) && (level <= debuglevel)) {
+ if ((debuglevel >= 0) && (level <= debuglevel))
+ {
va_start(args, format);
vsprintf(debugbuf, format, args);
ilog(L_DEBUG, "%s", debugbuf);
}
errno = err;
-} /* debug() */
+} /* debug() */
/*
* This is part of the STATS replies. There is no offical numeric for this
* different field names for "struct rusage".
* -avalon
*/
-void send_usage(struct Client *source_p)
+void
+send_usage(struct Client *source_p)
{
- struct rusage rus;
- time_t secs;
- time_t rup;
+ struct rusage rus;
+ time_t secs;
+ time_t rup;
#ifdef hz
# define hzz hz
#else
# ifdef HZ
# define hzz HZ
# else
- int hzz = 1;
+ int hzz = 1;
# endif
#endif
#ifdef VMS
- sendto_one(source_p, ":%s NOTICE %s :getrusage not supported on this system");
+ sendto_one(source_p,
+ ":%s NOTICE %s :getrusage not supported on this system");
return;
#else
if (getrusage(RUSAGE_SELF, &rus) == -1)
- {
- sendto_one(source_p,":%s NOTICE %s :Getruseage error: %s.",
- me.name, source_p->name, strerror(errno));
- return;
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Getruseage error: %s.",
+ me.name, source_p->name, strerror(errno));
+ return;
+ }
secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec;
if (0 == secs)
secs = 1;
sendto_one(source_p,
":%s %d %s :CPU Secs %d:%d User %d:%d System %d:%d",
- me.name, RPL_STATSDEBUG, source_p->name, (int)(secs/60), (int)(secs%60),
- (int)(rus.ru_utime.tv_sec/60), (int)(rus.ru_utime.tv_sec%60),
- (int)(rus.ru_stime.tv_sec/60), (int)(rus.ru_stime.tv_sec%60));
+ me.name, RPL_STATSDEBUG, source_p->name, (int)(secs / 60),
+ (int)(secs % 60), (int)(rus.ru_utime.tv_sec / 60),
+ (int)(rus.ru_utime.tv_sec % 60), (int)(rus.ru_stime.tv_sec / 60),
+ (int)(rus.ru_stime.tv_sec % 60));
sendto_one(source_p, ":%s %d %s :RSS %ld ShMem %ld Data %ld Stack %ld",
me.name, RPL_STATSDEBUG, source_p->name, rus.ru_maxrss,
(rus.ru_ixrss / rup), (rus.ru_idrss / rup),
(rus.ru_isrss / rup));
- sendto_one(source_p, ":%s %d %s :Swaps %d Reclaims %d Faults %d",
- me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nswap,
+ sendto_one(source_p, ":%s %d %s :Swaps %d Reclaims %d Faults %d", me.name,
+ RPL_STATSDEBUG, source_p->name, (int)rus.ru_nswap,
(int)rus.ru_minflt, (int)rus.ru_majflt);
- sendto_one(source_p, ":%s %d %s :Block in %d out %d",
- me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_inblock,
+ sendto_one(source_p, ":%s %d %s :Block in %d out %d", me.name,
+ RPL_STATSDEBUG, source_p->name, (int)rus.ru_inblock,
(int)rus.ru_oublock);
- sendto_one(source_p, ":%s %d %s :Msg Rcv %d Send %d",
- me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_msgrcv,
+ sendto_one(source_p, ":%s %d %s :Msg Rcv %d Send %d", me.name,
+ RPL_STATSDEBUG, source_p->name, (int)rus.ru_msgrcv,
(int)rus.ru_msgsnd);
sendto_one(source_p, ":%s %d %s :Signals %d Context Vol. %d Invol %d",
me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nsignals,
#endif /* VMS */
}
-void count_memory(struct Client *source_p)
+void
+count_memory(struct Client *source_p)
{
struct Client *target_p;
struct Channel *chptr;
struct Class *cltmp;
dlink_node *dlink;
- int channel_count = 0;
+ int channel_count = 0;
int local_client_conf_count = 0; /* local client conf links */
- int users_counted = 0; /* user structs */
+ int users_counted = 0; /* user structs */
int channel_users = 0;
int channel_invites = 0;
- int channel_bans = 0;
+ int channel_bans = 0;
int channel_except = 0;
int channel_invex = 0;
int conf_count = 0; /* conf lines */
int users_invited_count = 0; /* users invited */
int user_channels = 0; /* users in channels */
- int aways_counted = 0;
+ int aways_counted = 0;
int number_ips_stored; /* number of ip addresses hashed */
int number_servers_cached; /* number of servers cached by scache */
u_long mem_servers_cached; /* memory used by scache */
u_long mem_ips_stored; /* memory used by ip address hash */
- int linebuf_count =0;
+ int linebuf_count = 0;
u_long linebuf_memory_used = 0;
u_long client_hash_table_size = 0;
int remote_client_count = 0;
u_long remote_client_memory_used = 0;
- int user_count = 0;
+ int user_count = 0;
u_long user_memory_used = 0;
- int links_count = 0;
+ int links_count = 0;
u_long links_memory_used = 0;
u_long total_memory = 0;
count_whowas_memory(&wwu, &wwm);
for (target_p = GlobalClientList; target_p; target_p = target_p->next)
+ {
+ if (MyConnect(target_p))
+ {
+ for (dlink = target_p->localClient->confs.head;
+ dlink; dlink = dlink->next)
+ local_client_conf_count++;
+ }
+
+ if (target_p->user)
{
- if (MyConnect(target_p))
- {
- for (dlink = target_p->localClient->confs.head;
- dlink; dlink = dlink->next)
- local_client_conf_count++;
- }
-
- if (target_p->user)
- {
- users_counted++;
- for (dlink = target_p->user->invited.head; dlink;
- dlink = dlink->next)
- users_invited_count++;
- for (dlink = target_p->user->channel.head; dlink;
- dlink = dlink->next)
- user_channels++;
- if (target_p->user->away)
- {
- aways_counted++;
- away_memory += (strlen(target_p->user->away)+1);
- }
- }
+ users_counted++;
+ for (dlink = target_p->user->invited.head; dlink; dlink = dlink->next)
+ users_invited_count++;
+ for (dlink = target_p->user->channel.head; dlink; dlink = dlink->next)
+ user_channels++;
+ if (target_p->user->away)
+ {
+ aways_counted++;
+ away_memory += (strlen(target_p->user->away) + 1);
+ }
}
+ }
/* Count up all channels, ban lists, except lists, Invex lists */
for (chptr = GlobalChannelList; chptr; chptr = chptr->nextch)
- {
- channel_count++;
- channel_memory += (strlen(chptr->chname) + sizeof(struct Channel));
-
- for (dlink = chptr->peons.head; dlink; dlink = dlink->next)
- channel_users++;
- for (dlink = chptr->chanops.head; dlink; dlink = dlink->next)
- channel_users++;
+ {
+ channel_count++;
+ channel_memory += (strlen(chptr->chname) + sizeof(struct Channel));
+
+ for (dlink = chptr->peons.head; dlink; dlink = dlink->next)
+ channel_users++;
+ for (dlink = chptr->chanops.head; dlink; dlink = dlink->next)
+ channel_users++;
#ifdef REQUIRE_OANDV
- for (dlink = chptr->chanops_voiced.head; dlink; dlink = dlink->next)
- channel_users++;
+ for (dlink = chptr->chanops_voiced.head; dlink; dlink = dlink->next)
+ channel_users++;
#endif
- for (dlink = chptr->voiced.head; dlink; dlink = dlink->next)
- channel_users++;
- for (dlink = chptr->halfops.head; dlink; dlink = dlink->next)
- channel_users++;
-
- for (dlink = chptr->invites.head; dlink; dlink = dlink->next)
- channel_invites++;
-
- for (dlink = chptr->banlist.head; dlink; dlink = dlink->next)
- {
- actualBan = dlink->data;
- channel_bans++;
-
- channel_ban_memory += sizeof(dlink_node) +
- sizeof(struct Ban);
- if (actualBan->banstr)
- channel_ban_memory += strlen(actualBan->banstr);
- if (actualBan->who)
- channel_ban_memory += strlen(actualBan->who);
- }
-
- for (dlink = chptr->exceptlist.head; dlink; dlink = dlink->next)
- {
- actualBan = dlink->data;
- channel_except++;
-
- channel_except_memory += (sizeof(dlink_node) +
- sizeof(struct Ban));
- if (actualBan->banstr)
- channel_except_memory += strlen(actualBan->banstr);
- if (actualBan->who)
- channel_except_memory += strlen(actualBan->who);
- }
-
- for (dlink = chptr->invexlist.head; dlink; dlink = dlink->next)
- {
- actualBan = dlink->data;
- channel_invex++;
-
- channel_invex_memory += (sizeof(dlink_node) +
- sizeof(struct Ban));
- if (actualBan->banstr)
- channel_invex_memory += strlen(actualBan->banstr);
- if (actualBan->who)
- channel_invex_memory += strlen(actualBan->who);
- }
+ for (dlink = chptr->voiced.head; dlink; dlink = dlink->next)
+ channel_users++;
+ for (dlink = chptr->halfops.head; dlink; dlink = dlink->next)
+ channel_users++;
+
+ for (dlink = chptr->invites.head; dlink; dlink = dlink->next)
+ channel_invites++;
+
+ for (dlink = chptr->banlist.head; dlink; dlink = dlink->next)
+ {
+ actualBan = dlink->data;
+ channel_bans++;
+
+ channel_ban_memory += sizeof(dlink_node) + sizeof(struct Ban);
+ if (actualBan->banstr)
+ channel_ban_memory += strlen(actualBan->banstr);
+ if (actualBan->who)
+ channel_ban_memory += strlen(actualBan->who);
}
- /* count up all config items */
+ for (dlink = chptr->exceptlist.head; dlink; dlink = dlink->next)
+ {
+ actualBan = dlink->data;
+ channel_except++;
+
+ channel_except_memory += (sizeof(dlink_node) + sizeof(struct Ban));
+ if (actualBan->banstr)
+ channel_except_memory += strlen(actualBan->banstr);
+ if (actualBan->who)
+ channel_except_memory += strlen(actualBan->who);
+ }
- for (aconf = ConfigItemList; aconf; aconf = aconf->next)
+ for (dlink = chptr->invexlist.head; dlink; dlink = dlink->next)
{
- conf_count++;
- conf_memory += aconf->host ? strlen(aconf->host)+1 : 0;
- conf_memory += aconf->passwd ? strlen(aconf->passwd)+1 : 0;
- conf_memory += aconf->name ? strlen(aconf->name)+1 : 0;
- conf_memory += sizeof(struct ConfItem);
+ actualBan = dlink->data;
+ channel_invex++;
+
+ channel_invex_memory += (sizeof(dlink_node) + sizeof(struct Ban));
+ if (actualBan->banstr)
+ channel_invex_memory += strlen(actualBan->banstr);
+ if (actualBan->who)
+ channel_invex_memory += strlen(actualBan->who);
}
+ }
+
+ /* count up all config items */
+
+ for (aconf = ConfigItemList; aconf; aconf = aconf->next)
+ {
+ conf_count++;
+ conf_memory += aconf->host ? strlen(aconf->host) + 1 : 0;
+ conf_memory += aconf->passwd ? strlen(aconf->passwd) + 1 : 0;
+ conf_memory += aconf->name ? strlen(aconf->name) + 1 : 0;
+ conf_memory += sizeof(struct ConfItem);
+ }
/* count up all classes */
sendto_one(source_p, ":%s %d %s :Users %u(%lu) Invites %u(%lu)",
me.name, RPL_STATSDEBUG, source_p->name,
- users_counted, (unsigned long)users_counted * sizeof(struct User),
- users_invited_count, (unsigned long)users_invited_count * sizeof(dlink_node));
+ users_counted,
+ (unsigned long)users_counted * sizeof(struct User),
+ users_invited_count,
+ (unsigned long)users_invited_count * sizeof(dlink_node));
sendto_one(source_p, ":%s %d %s :User channels %u(%lu) Aways %u(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- user_channels, (unsigned long)user_channels*sizeof(dlink_node),
+ user_channels, (unsigned long)user_channels * sizeof(dlink_node),
aways_counted, (int)away_memory);
sendto_one(source_p, ":%s %d %s :Attached confs %u(%lu)",
me.name, RPL_STATSDEBUG, source_p->name,
- local_client_conf_count,
- (unsigned long)local_client_conf_count * sizeof(dlink_node));
+ local_client_conf_count,
+ (unsigned long)local_client_conf_count * sizeof(dlink_node));
sendto_one(source_p, ":%s %d %s :Conflines %u(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- conf_count, (int)conf_memory);
+ conf_count, (int)conf_memory);
sendto_one(source_p, ":%s %d %s :Classes %u(%lu)",
me.name, RPL_STATSDEBUG, source_p->name,
- class_count, (unsigned long)class_count*sizeof(struct Class));
+ class_count, (unsigned long)class_count * sizeof(struct Class));
sendto_one(source_p, ":%s %d %s :Channels %u(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- channel_count, (int)channel_memory);
+ channel_count, (int)channel_memory);
sendto_one(source_p, ":%s %d %s :Bans %u(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- channel_bans, (int)channel_ban_memory);
+ channel_bans, (int)channel_ban_memory);
sendto_one(source_p, ":%s %d %s :Exceptions %u(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- channel_except, (int)channel_except_memory);
+ channel_except, (int)channel_except_memory);
sendto_one(source_p, ":%s %d %s :Invex %u(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- channel_invex, (int)channel_invex_memory);
+ channel_invex, (int)channel_invex_memory);
sendto_one(source_p, ":%s %d %s :Channel members %u(%lu) invite %u(%lu)",
me.name, RPL_STATSDEBUG, source_p->name, channel_users,
- (unsigned long)channel_users*sizeof(dlink_node),
- channel_invites, (unsigned long)channel_invites*sizeof(dlink_node));
-
+ (unsigned long)channel_users * sizeof(dlink_node),
+ channel_invites,
+ (unsigned long)channel_invites * sizeof(dlink_node));
+
total_channel_memory = channel_memory +
channel_ban_memory +
- channel_users*sizeof(dlink_node) +
- channel_invites*sizeof(dlink_node);
+ channel_users * sizeof(dlink_node) + channel_invites * sizeof(dlink_node);
sendto_one(source_p, ":%s %d %s :Whowas users %u(%lu)",
me.name, RPL_STATSDEBUG, source_p->name,
- wwu, (unsigned long)wwu*sizeof(struct User));
+ wwu, (unsigned long)wwu * sizeof(struct User));
sendto_one(source_p, ":%s %d %s :Whowas array %u(%d)",
- me.name, RPL_STATSDEBUG, source_p->name, NICKNAMEHISTORYLENGTH, (int)wwm);
+ me.name, RPL_STATSDEBUG, source_p->name, NICKNAMEHISTORYLENGTH,
+ (int)wwm);
totww = wwu * sizeof(struct User) + wwm;
- client_hash_table_size = hash_get_client_table_size();
+ client_hash_table_size = hash_get_client_table_size();
channel_hash_table_size = hash_get_channel_table_size();
sendto_one(source_p, ":%s %d %s :Hash: client %u(%lu) chan %u(%lu)",
me.name, RPL_STATSDEBUG, source_p->name,
- U_MAX, client_hash_table_size,
- CH_MAX, channel_hash_table_size);
+ U_MAX, client_hash_table_size, CH_MAX, channel_hash_table_size);
sendto_one(source_p, ":%s %d %s :linebuf %d(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- linebuf_count, (int)linebuf_memory_used);
+ linebuf_count, (int)linebuf_memory_used);
- count_scache(&number_servers_cached,&mem_servers_cached);
+ count_scache(&number_servers_cached, &mem_servers_cached);
sendto_one(source_p, ":%s %d %s :scache %u(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- number_servers_cached,
- (int)mem_servers_cached);
+ number_servers_cached, (int)mem_servers_cached);
- count_ip_hash(&number_ips_stored,&mem_ips_stored);
+ count_ip_hash(&number_ips_stored, &mem_ips_stored);
sendto_one(source_p, ":%s %d %s :iphash %u(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- number_ips_stored,
- (int)mem_ips_stored);
+ number_ips_stored, (int)mem_ips_stored);
total_memory = totww + total_channel_memory + conf_memory +
class_count * sizeof(struct Class);
total_memory += mem_servers_cached;
sendto_one(source_p, ":%s %d %s :Total: whowas %d channel %d conf %d",
me.name, RPL_STATSDEBUG, source_p->name,
- (int)totww,
- (int)total_channel_memory,
- (int)conf_memory);
+ (int)totww, (int)total_channel_memory, (int)conf_memory);
- count_local_client_memory( &local_client_count,
- (int *)&local_client_memory_used );
+ count_local_client_memory(&local_client_count,
+ (int *)&local_client_memory_used);
total_memory += local_client_memory_used;
sendto_one(source_p, ":%s %d %s :Local client Memory in use: %d(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- local_client_count,
- (int)local_client_memory_used);
+ local_client_count, (int)local_client_memory_used);
- count_remote_client_memory( &remote_client_count,
- (int *)&remote_client_memory_used);
+ count_remote_client_memory(&remote_client_count,
+ (int *)&remote_client_memory_used);
total_memory += remote_client_memory_used;
sendto_one(source_p, ":%s %d %s :Remote client Memory in use: %d(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- remote_client_count,
- (int)remote_client_memory_used);
+ remote_client_count, (int)remote_client_memory_used);
- count_user_memory( &user_count, (int *)&user_memory_used );
+ count_user_memory(&user_count, (int *)&user_memory_used);
/* assert (users_counted == user_count); */
- if(users_counted != user_count)
- sendto_realops_flags(FLAGS_ALL, L_ALL, "*** WARNING: Users counted: %d != User count: %d",
- users_counted, user_count);
-
+ if (users_counted != user_count)
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "*** WARNING: Users counted: %d != User count: %d",
+ users_counted, user_count);
- count_links_memory( &links_count, (int *)&links_memory_used );
+
+ count_links_memory(&links_count, (int *)&links_memory_used);
total_memory += links_memory_used;
sendto_one(source_p, ":%s %d %s :Links Memory in use: %d(%d)",
me.name, RPL_STATSDEBUG, source_p->name,
- (int)links_count,
- (int)links_memory_used);
+ (int)links_count, (int)links_memory_used);
- sendto_one(source_p,
+ sendto_one(source_p,
":%s %d %s :TOTAL: %d Available: Current max RSS: %lu",
me.name, RPL_STATSDEBUG, source_p->name,
- (int)total_memory, get_maxrss());
+ (int)total_memory, get_maxrss());
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_gline.c,v 1.1 2002/01/04 09:14:40 a1kmm Exp $
+ * $Id: s_gline.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
#include "tools.h"
#include "handlers.h"
* output - struct ConfItem pointer if a gline was found for this client
* side effects - none
*/
-struct ConfItem*
-find_gkill(struct Client* client_p, char* username)
+struct ConfItem *
+find_gkill(struct Client *client_p, char *username)
{
assert(0 != client_p);
- return (IsExemptKline(client_p)) ? 0 : find_is_glined(client_p->host, username);
+ return (IsExemptKline(client_p)) ? 0 : find_is_glined(client_p->host,
+ username);
}
/*
* output - pointer to struct ConfItem if user@host glined
* side effects -
*/
-struct ConfItem*
-find_is_glined(const char* host, const char* name)
+struct ConfItem *
+find_is_glined(const char *host, const char *name)
{
dlink_node *gline_node;
- struct ConfItem *kill_ptr;
+ struct ConfItem *kill_ptr;
- for(gline_node = glines.head; gline_node; gline_node = gline_node->next)
+ for (gline_node = glines.head; gline_node; gline_node = gline_node->next)
+ {
+ kill_ptr = gline_node->data;
+ if ((kill_ptr->name && (!name || match(kill_ptr->name, name)))
+ && (kill_ptr->host && (!host || match(kill_ptr->host, host))))
{
- kill_ptr = gline_node->data;
- if( (kill_ptr->name && (!name || match(kill_ptr->name,name)))
- &&
- (kill_ptr->host && (!host || match(kill_ptr->host,host))))
- {
- return(kill_ptr);
- }
+ return (kill_ptr);
}
+ }
- return((struct ConfItem *)NULL);
+ return ((struct ConfItem *)NULL);
}
/*
* side effects -
*/
int
-remove_gline_match(const char* user, const char* host)
+remove_gline_match(const char *user, const char *host)
{
dlink_node *gline_node;
struct ConfItem *kill_ptr;
- for(gline_node = glines.head; gline_node; gline_node = gline_node->next)
+ for (gline_node = glines.head; gline_node; gline_node = gline_node->next)
+ {
+ kill_ptr = gline_node->data;
+ if (!irccmp(kill_ptr->host, host) && !irccmp(kill_ptr->name, user))
{
- kill_ptr = gline_node->data;
- if(!irccmp(kill_ptr->host,host) && !irccmp(kill_ptr->name,user))
- {
- free_conf(kill_ptr);
- dlinkDelete(gline_node, &glines);
- free_dlink_node(gline_node);
- return 1;
- }
+ free_conf(kill_ptr);
+ dlinkDelete(gline_node, &glines);
+ free_dlink_node(gline_node);
+ return 1;
}
+ }
return 0;
}
dlink_node *next_node;
struct ConfItem *kill_ptr;
- for(gline_node = glines.head; gline_node; gline_node = next_node)
+ for (gline_node = glines.head; gline_node; gline_node = next_node)
+ {
+ kill_ptr = gline_node->data;
+ next_node = gline_node->next;
+
+ if (kill_ptr->hold <= CurrentTime)
{
- kill_ptr = gline_node->data;
- next_node = gline_node->next;
-
- if(kill_ptr->hold <= CurrentTime)
- {
- free_conf(kill_ptr);
- dlinkDelete(gline_node, &glines);
- free_dlink_node(gline_node);
- }
+ free_conf(kill_ptr);
+ dlinkDelete(gline_node, &glines);
+ free_dlink_node(gline_node);
}
+ }
}
/*
dlink_node *next_node;
struct gline_pending *glp_ptr;
- for(pending_node = pending_glines.head; pending_node; pending_node = next_node)
- {
- glp_ptr = pending_node->data;
- next_node = pending_node->next;
+ for (pending_node = pending_glines.head; pending_node;
+ pending_node = next_node)
+ {
+ glp_ptr = pending_node->data;
+ next_node = pending_node->next;
- if(((glp_ptr->last_gline_time + GLINE_PENDING_EXPIRE) <= CurrentTime)
+ if (((glp_ptr->last_gline_time + GLINE_PENDING_EXPIRE) <= CurrentTime)
|| find_is_glined(glp_ptr->host, glp_ptr->user))
-
- {
- MyFree(glp_ptr->reason1);
- MyFree(glp_ptr->reason2);
- MyFree(glp_ptr);
- dlinkDelete(pending_node, &pending_glines);
- free_dlink_node(pending_node);
- }
+
+ {
+ MyFree(glp_ptr->reason1);
+ MyFree(glp_ptr->reason2);
+ MyFree(glp_ptr);
+ dlinkDelete(pending_node, &pending_glines);
+ free_dlink_node(pending_node);
}
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_log.c,v 1.1 2002/01/04 09:14:40 a1kmm Exp $
+ * $Id: s_log.c,v 1.2 2002/01/04 11:06:42 a1kmm Exp $
*/
-#include "client.h" /* Needed for struct Client */
+#include "client.h" /* Needed for struct Client */
#include "s_log.h"
#include "fileio.h"
#include "irc_string.h"
#include "ircd.h"
#include "s_misc.h"
-#include "event.h" /* Needed for EVH etc. */
+#include "event.h" /* Needed for EVH etc. */
#include "s_conf.h"
#include "memory.h"
#define LOG_BUFSIZE 2000
#ifdef USE_LOGFILE
-static FBFILE* logFile;
+static FBFILE *logFile;
#endif
static int logLevel = INIT_LOG_LEVEL;
-static FBFILE *user_log_fb=NULL;
+static FBFILE *user_log_fb = NULL;
#ifndef SYSLOG_USERS
static EVH user_log_resync;
};
#endif
-static const char *logLevelToString[] =
-{ "L_CRIT",
+static const char *logLevelToString[] = { "L_CRIT",
"L_ERROR",
"L_WARN",
"L_NOTICE",
* open_log - open ircd logging file
* returns true (1) if successful, false (0) otherwise
*/
-#if defined(USE_LOGFILE)
+#if defined(USE_LOGFILE)
-static int open_log(const char* filename)
+static int
+open_log(const char *filename)
{
logFile = fbopen(filename, "a");
- if (logFile == NULL) {
+ if (logFile == NULL)
+ {
#ifdef USE_SYSLOG
syslog(LOG_ERR, "Unable to open log file: %s: %s",
filename, strerror(errno));
}
#endif
-void close_log(void)
+void
+close_log(void)
{
-#if defined(USE_LOGFILE)
- if (logFile != NULL) {
+#if defined(USE_LOGFILE)
+ if (logFile != NULL)
+ {
fbclose(logFile);
logFile = NULL;
}
#endif
-#ifdef USE_SYSLOG
+#ifdef USE_SYSLOG
closelog();
#endif
}
-#if defined(USE_LOGFILE)
-static void write_log(const char* message)
+#if defined(USE_LOGFILE)
+static void
+write_log(const char *message)
{
char buf[LOG_BUFSIZE];
- if( !logFile )
+ if (!logFile)
return;
#ifdef HAVE_SNPRINTF
fbputs(buf, logFile);
}
#endif
-
-void ilog(int priority, const char* fmt, ...)
+
+void
+ilog(int priority, const char *fmt, ...)
{
- char buf[LOG_BUFSIZE];
+ char buf[LOG_BUFSIZE];
va_list args;
assert(-1 < priority);
assert(0 != fmt);
vsprintf(buf, fmt, args);
va_end(args);
-#ifdef USE_SYSLOG
+#ifdef USE_SYSLOG
if (priority <= L_DEBUG)
syslog(sysLogLevel[priority], "%s", buf);
#endif
-#if defined(USE_LOGFILE)
+#if defined(USE_LOGFILE)
write_log(buf);
#endif
}
-
-void init_log(const char* filename)
+
+void
+init_log(const char *filename)
{
-#if defined(USE_LOGFILE)
+#if defined(USE_LOGFILE)
open_log(filename);
#endif
#ifdef USE_SYSLOG
#endif
}
-void set_log_level(int level)
+void
+set_log_level(int level)
{
if (L_ERROR < level && level <= L_DEBUG)
logLevel = level;
}
-int get_log_level(void)
+int
+get_log_level(void)
{
- return( logLevel );
+ return (logLevel);
}
-const char *get_log_level_as_string(int level)
+const char *
+get_log_level_as_string(int level)
{
- if(level > L_DEBUG)
+ if (level > L_DEBUG)
level = L_DEBUG;
- else if(level < L_ERROR)
+ else if (level < L_ERROR)
level = L_ERROR;
- return(logLevelToString[level]);
+ return (logLevelToString[level]);
}
* side effects - Current exiting client is logged to
* either SYSLOG or to file.
*/
-void log_user_exit(struct Client *source_p)
+void
+log_user_exit(struct Client *source_p)
{
- time_t on_for;
+ time_t on_for;
on_for = CurrentTime - source_p->firsttime;
#ifdef SYSLOG_USERS
if (IsPerson(source_p))
- {
+ {
- ilog(L_INFO, "%s (%3ld:%02ld:%02ld): %s!%s@%s %ld/%ld\n",
- myctime(source_p->firsttime),
- (signed long) on_for / 3600,
- (signed long) (on_for % 3600)/60,
- (signed long) on_for % 60,
- source_p->name,
- source_p->username,
- source_p->host,
- source_p->localClient->sendK,
- source_p->localClient->receiveK);
- }
+ ilog(L_INFO, "%s (%3ld:%02ld:%02ld): %s!%s@%s %ld/%ld\n",
+ myctime(source_p->firsttime),
+ (signed long)on_for / 3600,
+ (signed long)(on_for % 3600) / 60,
+ (signed long)on_for % 60,
+ source_p->name,
+ source_p->username,
+ source_p->host,
+ source_p->localClient->sendK, source_p->localClient->receiveK);
+ }
#else
{
- char linebuf[BUFSIZ];
+ char linebuf[BUFSIZ];
/*
* This conditional makes the logfile active only after
* -Taner
*/
if (IsPerson(source_p))
+ {
+ if (user_log_fb == NULL)
{
- if (user_log_fb == NULL)
- {
- if( ConfigFileEntry.fname_userlog &&
- (user_log_fb = fbopen(ConfigFileEntry.fname_userlog, "r")) != NULL )
- {
- fbclose(user_log_fb);
- user_log_fb = fbopen(ConfigFileEntry.fname_userlog, "a");
- }
- }
-
- if( user_log_fb != NULL )
- {
- ircsprintf(linebuf,
- "%s (%3ld:%02ld:%02ld): %s!%s@%s %d/%d\n",
- myctime(source_p->firsttime),
- (signed long) on_for / 3600,
- (signed long) (on_for % 3600)/60,
- (signed long) on_for % 60,
- source_p->name,
- source_p->username,
- source_p->host,
- source_p->localClient->sendK,
- source_p->localClient->receiveK);
-
- fbputs(linebuf, user_log_fb);
- }
+ if (ConfigFileEntry.fname_userlog &&
+ (user_log_fb =
+ fbopen(ConfigFileEntry.fname_userlog, "r")) != NULL)
+ {
+ fbclose(user_log_fb);
+ user_log_fb = fbopen(ConfigFileEntry.fname_userlog, "a");
+ }
}
+
+ if (user_log_fb != NULL)
+ {
+ ircsprintf(linebuf,
+ "%s (%3ld:%02ld:%02ld): %s!%s@%s %d/%d\n",
+ myctime(source_p->firsttime),
+ (signed long)on_for / 3600,
+ (signed long)(on_for % 3600) / 60,
+ (signed long)on_for % 60,
+ source_p->name,
+ source_p->username,
+ source_p->host,
+ source_p->localClient->sendK,
+ source_p->localClient->receiveK);
+
+ fbputs(linebuf, user_log_fb);
+ }
+ }
}
#endif
}
user_log_resync(void *notused)
{
if (user_log_fb != NULL)
- {
- fbclose(user_log_fb);
- user_log_fb = NULL;
- }
+ {
+ fbclose(user_log_fb);
+ user_log_fb = NULL;
+ }
}
#endif
* side effects - FNAME_OPERLOG is written to, if its present
*/
-void log_oper( struct Client *source_p, char *name )
+void
+log_oper(struct Client *source_p, char *name)
{
FBFILE *oper_fb;
char linebuf[BUFSIZE];
if (!ConfigFileEntry.fname_operlog)
- return;
-
+ return;
+
if (IsPerson(source_p))
+ {
+ if ((oper_fb = fbopen(ConfigFileEntry.fname_operlog, "r")) != NULL)
{
- if( (oper_fb = fbopen(ConfigFileEntry.fname_operlog, "r")) != NULL )
- {
- fbclose(oper_fb);
- oper_fb = fbopen(ConfigFileEntry.fname_operlog, "a");
- }
-
- if(oper_fb != NULL)
- {
- ircsprintf(linebuf, "%s OPER (%s) by (%s!%s@%s)\n",
- myctime(CurrentTime), name,
- source_p->name, source_p->username,
- source_p->host);
-
- fbputs(linebuf,oper_fb);
- fbclose(oper_fb);
- }
+ fbclose(oper_fb);
+ oper_fb = fbopen(ConfigFileEntry.fname_operlog, "a");
}
+
+ if (oper_fb != NULL)
+ {
+ ircsprintf(linebuf, "%s OPER (%s) by (%s!%s@%s)\n",
+ myctime(CurrentTime), name,
+ source_p->name, source_p->username, source_p->host);
+
+ fbputs(linebuf, oper_fb);
+ fbclose(oper_fb);
+ }
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_misc.c,v 1.1 2002/01/04 09:14:40 a1kmm Exp $
+ * $Id: s_misc.c,v 1.2 2002/01/04 11:06:43 a1kmm Exp $
*/
#include "s_misc.h"
#include "client.h"
#include <unistd.h>
-static char* months[] = {
- "January", "February", "March", "April",
- "May", "June", "July", "August",
- "September", "October", "November","December"
+static char *months[] = {
+ "January", "February", "March", "April",
+ "May", "June", "July", "August",
+ "September", "October", "November", "December"
};
-static char* weekdays[] = {
- "Sunday", "Monday", "Tuesday", "Wednesday",
+static char *weekdays[] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
};
-char* date(time_t lclock)
+char *
+date(time_t lclock)
{
- static char buf[80], plus;
- struct tm *lt, *gm;
- struct tm gmbuf;
- int minswest;
+ static char buf[80], plus;
+ struct tm *lt, *gm;
+ struct tm gmbuf;
+ int minswest;
- if (!lclock)
+ if (!lclock)
lclock = CurrentTime;
gm = gmtime(&lclock);
memcpy((void *)&gmbuf, (void *)gm, sizeof(gmbuf));
lt = localtime(&lclock);
if (lt->tm_yday == gm->tm_yday)
- minswest = (gm->tm_hour - lt->tm_hour) * 60 +
- (gm->tm_min - lt->tm_min);
+ minswest = (gm->tm_hour - lt->tm_hour) * 60 + (gm->tm_min - lt->tm_min);
else if (lt->tm_yday > gm->tm_yday)
minswest = (gm->tm_hour - (lt->tm_hour + 24)) * 60;
else
plus = (minswest > 0) ? '-' : '+';
if (minswest < 0)
minswest = -minswest;
-
+
ircsprintf(buf, "%s %s %d %d -- %02u:%02u:%02u %c%02u:%02u",
- weekdays[lt->tm_wday], months[lt->tm_mon],lt->tm_mday,
- lt->tm_year + 1900, lt->tm_hour, lt->tm_min, lt->tm_sec,
- plus, minswest/60, minswest%60);
+ weekdays[lt->tm_wday], months[lt->tm_mon], lt->tm_mday,
+ lt->tm_year + 1900, lt->tm_hour, lt->tm_min, lt->tm_sec,
+ plus, minswest / 60, minswest % 60);
return buf;
}
-const char* smalldate(time_t lclock)
+const char *
+smalldate(time_t lclock)
{
- static char buf[MAX_DATE_STRING];
- struct tm *lt, *gm;
- struct tm gmbuf;
+ static char buf[MAX_DATE_STRING];
+ struct tm *lt, *gm;
+ struct tm gmbuf;
if (!lclock)
lclock = CurrentTime;
gm = gmtime(&lclock);
memcpy((void *)&gmbuf, (void *)gm, sizeof(gmbuf));
- gm = &gmbuf;
+ gm = &gmbuf;
lt = localtime(&lclock);
-
+
ircsprintf(buf, "%d/%d/%d %02d.%02d",
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
lt->tm_hour, lt->tm_min);
-
+
return buf;
}
* Make a small YYYYMMDD formatted string suitable for a
* dated file stamp.
*/
-char* small_file_date(time_t lclock)
+char *
+small_file_date(time_t lclock)
{
- static char timebuffer[MAX_DATE_STRING];
+ static char timebuffer[MAX_DATE_STRING];
struct tm *tmptr;
if (!lclock)
strftime(timebuffer, MAX_DATE_STRING, "%Y%m%d", tmptr);
return timebuffer;
}
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_serv.c,v 1.1 2002/01/04 09:14:43 a1kmm Exp $
+ * $Id: s_serv.c,v 1.2 2002/01/04 11:06:43 a1kmm Exp $
*/
#include <sys/types.h>
#include <errno.h>
#include <time.h>
#include <netdb.h>
-#include <fcntl.h>
+#include <fcntl.h>
#include "config.h"
#include "client.h"
#include "s_debug.h"
#include "memory.h"
-#include "channel.h" /* chcap_usage_counts stuff...*/
+#include "channel.h" /* chcap_usage_counts stuff... */
#include "hook.h"
extern char *crypt();
#endif
int MaxConnectionCount = 1;
-int MaxClientCount = 1;
+int MaxClientCount = 1;
int refresh_user_links = 0;
-struct Client *uplink=NULL;
+struct Client *uplink = NULL;
+
+static void start_io(struct Client *server);
+static void burst_members(struct Client *client_p, dlink_list * list);
+static void burst_ll_members(struct Client *client_p, dlink_list * list);
-static void start_io(struct Client *server);
-static void burst_members(struct Client *client_p, dlink_list *list);
-static void burst_ll_members(struct Client *client_p, dlink_list *list);
-
static SlinkRplHnd slink_error;
static SlinkRplHnd slink_zipstats;
/*
* extra argument to "PASS" takes care of checking that. -orabidoo
*/
struct Capability captab[] = {
-/* name cap */
- { "QS", CAP_QS },
- { "EX", CAP_EX },
- { "CHW", CAP_CHW },
- { "LL", CAP_LL },
- { "IE", CAP_IE },
- { "EOB", CAP_EOB },
- { "KLN", CAP_KLN },
- { "GLN", CAP_GLN },
- { "KNOCK", CAP_KNOCK },
- { "HOPS", CAP_HOPS },
- { "HUB", CAP_HUB },
- { "AOPS", CAP_AOPS },
- { "UID", CAP_UID },
- { "ZIP", CAP_ZIP },
- { "TBURST", CAP_TBURST },
- { 0, 0 }
+/* name cap */
+ {"QS", CAP_QS},
+ {"EX", CAP_EX},
+ {"CHW", CAP_CHW},
+ {"LL", CAP_LL},
+ {"IE", CAP_IE},
+ {"EOB", CAP_EOB},
+ {"KLN", CAP_KLN},
+ {"GLN", CAP_GLN},
+ {"KNOCK", CAP_KNOCK},
+ {"HOPS", CAP_HOPS},
+ {"HUB", CAP_HUB},
+ {"AOPS", CAP_AOPS},
+ {"UID", CAP_UID},
+ {"ZIP", CAP_ZIP},
+ {"TBURST", CAP_TBURST},
+ {0, 0}
};
#ifdef HAVE_LIBCRYPTO
-struct EncCapability CipherTable[] =
-{
+struct EncCapability CipherTable[] = {
#ifdef HAVE_EVP_BF_CFB
- { "BF/256", CAP_ENC_BF_256, 32, CIPHER_BF },
- { "BF/128", CAP_ENC_BF_128, 16, CIPHER_BF },
+ {"BF/256", CAP_ENC_BF_256, 32, CIPHER_BF},
+ {"BF/128", CAP_ENC_BF_128, 16, CIPHER_BF},
#endif
#ifdef HAVE_EVP_CAST5_CFB
- { "CAST/128", CAP_ENC_CAST_128, 16, CIPHER_CAST },
+ {"CAST/128", CAP_ENC_CAST_128, 16, CIPHER_CAST},
#endif
#ifdef HAVE_EVP_IDEA_CFB
- { "IDEA/128", CAP_ENC_IDEA_128, 16, CIPHER_IDEA },
+ {"IDEA/128", CAP_ENC_IDEA_128, 16, CIPHER_IDEA},
#endif
#ifdef HAVE_EVP_RC5_32_12_16_CFB
- { "RC5.16/128", CAP_ENC_RC5_16_128, 16, CIPHER_RC5_16 },
- { "RC5.12/128", CAP_ENC_RC5_12_128, 16, CIPHER_RC5_12 },
- { "RC5.8/128", CAP_ENC_RC5_8_128, 16, CIPHER_RC5_8 },
+ {"RC5.16/128", CAP_ENC_RC5_16_128, 16, CIPHER_RC5_16},
+ {"RC5.12/128", CAP_ENC_RC5_12_128, 16, CIPHER_RC5_12},
+ {"RC5.8/128", CAP_ENC_RC5_8_128, 16, CIPHER_RC5_8},
#endif
#ifdef HAVE_EVP_DES_EDE3_CFB
- { "3DES/168", CAP_ENC_3DES_168, 24, CIPHER_3DES },
+ {"3DES/168", CAP_ENC_3DES_168, 24, CIPHER_3DES},
#endif
#ifdef HAVE_EVP_DES_CFB
- { "DES/56", CAP_ENC_DES_56, 8, CIPHER_DES },
+ {"DES/56", CAP_ENC_DES_56, 8, CIPHER_DES},
#endif
- { 0, 0, 0, 0 }
+ {0, 0, 0, 0}
};
#endif
struct SlinkRplDef slinkrpltab[] = {
- { SLINKRPL_ERROR, slink_error, SLINKRPL_FLAG_DATA },
- { SLINKRPL_ZIPSTATS, slink_zipstats, SLINKRPL_FLAG_DATA },
- { 0, 0, 0 },
+ {SLINKRPL_ERROR, slink_error, SLINKRPL_FLAG_DATA},
+ {SLINKRPL_ZIPSTATS, slink_zipstats, SLINKRPL_FLAG_DATA},
+ {0, 0, 0},
};
unsigned long nextFreeMask();
static CNCB serv_connect_callback;
-void slink_error(unsigned int rpl, unsigned int len, unsigned char *data,
- struct Client *server_p)
+void
+slink_error(unsigned int rpl, unsigned int len, unsigned char *data,
+ struct Client *server_p)
{
assert(rpl == SLINKRPL_ERROR);
assert(len < 256);
- data[len-1] = '\0';
+ data[len - 1] = '\0';
sendto_realops_flags(FLAGS_ALL, L_ALL, "SlinkError for %s: %s",
server_p->name, data);
exit_client(server_p, server_p, &me, "servlink error -- terminating link");
}
-void slink_zipstats(unsigned int rpl, unsigned int len, unsigned char *data,
- struct Client *server_p)
+void
+slink_zipstats(unsigned int rpl, unsigned int len, unsigned char *data,
+ struct Client *server_p)
{
struct ZipStats *zipstats = &server_p->localClient->zipstats;
unsigned long in = 0, in_wire = 0, out = 0, out_wire = 0;
in |= (data[i++] << 24);
in |= (data[i++] << 16);
- in |= (data[i++] << 8);
- in |= (data[i++] );
+ in |= (data[i++] << 8);
+ in |= (data[i++]);
in_wire |= (data[i++] << 24);
in_wire |= (data[i++] << 16);
- in_wire |= (data[i++] << 8);
- in_wire |= (data[i++] );
+ in_wire |= (data[i++] << 8);
+ in_wire |= (data[i++]);
out |= (data[i++] << 24);
out |= (data[i++] << 16);
- out |= (data[i++] << 8);
- out |= (data[i++] );
+ out |= (data[i++] << 8);
+ out |= (data[i++]);
out_wire |= (data[i++] << 24);
out_wire |= (data[i++] << 16);
- out_wire |= (data[i++] << 8);
- out_wire |= (data[i++] );
+ out_wire |= (data[i++] << 8);
+ out_wire |= (data[i++]);
- if (!(((in + zipstats->in) >= zipstats->in) &&
- ((out + zipstats->out) >= zipstats->out) &&
- ((in_wire + zipstats->in_wire) >= zipstats->in_wire) &&
+ if (!(((in + zipstats->in) >= zipstats->in) &&
+ ((out + zipstats->out) >= zipstats->out) &&
+ ((in_wire + zipstats->in_wire) >= zipstats->in_wire) &&
((out_wire + zipstats->out_wire) >= zipstats->out_wire)))
- {
- /* overflow, so start again */
- zipstats->in = 0;
- zipstats->out = 0;
- zipstats->in_wire = 0;
- zipstats->out_wire = 0;
- }
+ {
+ /* overflow, so start again */
+ zipstats->in = 0;
+ zipstats->out = 0;
+ zipstats->in_wire = 0;
+ zipstats->out_wire = 0;
+ }
zipstats->in += in;
zipstats->out += out;
}
}
-void collect_zipstats(void *unused)
+void
+collect_zipstats(void *unused)
{
dlink_node *ptr;
struct Client *target_p;
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
+ if (IsCapable(target_p, CAP_ZIP))
{
- target_p = ptr->data;
- if (IsCapable(target_p, CAP_ZIP))
- {
- /* only bother if we haven't already got something queued... */
- if (!target_p->localClient->slinkq)
- {
- target_p->localClient->slinkq = MyMalloc(1); /* sigh.. */
- target_p->localClient->slinkq[0] = SLINKCMD_ZIPSTATS;
- target_p->localClient->slinkq_ofs = 0;
- target_p->localClient->slinkq_len = 1;
-
- /* schedule a write */
- comm_setselect(target_p->localClient->ctrlfd, FDLIST_IDLECLIENT,
- COMM_SELECT_WRITE, send_queued_slink_write,
- target_p, 0);
- }
- }
+ /* only bother if we haven't already got something queued... */
+ if (!target_p->localClient->slinkq)
+ {
+ target_p->localClient->slinkq = MyMalloc(1); /* sigh.. */
+ target_p->localClient->slinkq[0] = SLINKCMD_ZIPSTATS;
+ target_p->localClient->slinkq_ofs = 0;
+ target_p->localClient->slinkq_len = 1;
+
+ /* schedule a write */
+ comm_setselect(target_p->localClient->ctrlfd, FDLIST_IDLECLIENT,
+ COMM_SELECT_WRITE, send_queued_slink_write,
+ target_p, 0);
+ }
}
+ }
}
#ifdef HAVE_LIBCRYPTO
-struct EncCapability *check_cipher(struct Client *client_p,
- struct ConfItem *aconf)
+struct EncCapability *
+check_cipher(struct Client *client_p, struct ConfItem *aconf)
{
struct EncCapability *epref;
* conf struct. Otherwise, return NULL (an error).
*/
if (IsCapableEnc(client_p, epref->cap))
- return(epref);
+ return (epref);
- return(NULL);
+ return (NULL);
}
#endif /* HAVE_LIBCRYPTO */
* according to given config entry --Jto
* XXX - this is only called with me.name as name
*/
-const char* my_name_for_link(const char* name, struct ConfItem* aconf)
+const char *
+my_name_for_link(const char *name, struct ConfItem *aconf)
{
- if(aconf->fakename)
- return(aconf->fakename);
+ if (aconf->fakename)
+ return (aconf->fakename);
else
- return(name);
+ return (name);
}
/*
* output - none
* side effects - server is added to global_serv_list
*/
-void add_server_to_list(struct Client *client_p)
+void
+add_server_to_list(struct Client *client_p)
{
dlink_node *ptr;
-
+
ptr = make_dlink_node();
dlinkAdd(client_p, ptr, &global_serv_list);
* output - none
* side effects - server is removed from GlocalServerList
*/
-void remove_server_from_list(struct Client *client_p)
+void
+remove_server_from_list(struct Client *client_p)
{
dlink_node *ptr;
struct Client *target_p;
if (client_p == target_p)
{
- dlinkDelete(ptr,&global_serv_list);
+ dlinkDelete(ptr, &global_serv_list);
free_dlink_node(ptr);
break;
}
- }
- return;
+ }
+ return;
}
/*
* write_links_file
*/
-void write_links_file(void* notused)
+void
+write_links_file(void *notused)
{
MessageFileLine *next_mptr = 0;
MessageFileLine *mptr = 0;
MessageFile *MessageFileptr;
struct Client *target_p;
char *p;
- FBFILE* file;
+ FBFILE *file;
char buff[512];
dlink_node *ptr;
if ((file = fbopen(MessageFileptr->fileName, "w")) == 0)
return;
- for( mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr)
- {
- next_mptr = mptr->next;
- MyFree(mptr);
- }
+ for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr)
+ {
+ next_mptr = mptr->next;
+ MyFree(mptr);
+ }
MessageFileptr->contentsOfFile = NULL;
currentMessageLine = NULL;
target_p = ptr->data;
/* skip ourselves, we send ourselves in /links */
- if(IsMe(target_p))
+ if (IsMe(target_p))
continue;
/* skip hidden servers */
- if(target_p->hidden_server && ConfigServerHide.allow_hidden)
+ if (target_p->hidden_server && ConfigServerHide.allow_hidden)
continue;
- if(target_p->info[0])
+ if (target_p->info[0])
p = target_p->info;
else
p = "(Unknown Location)";
- newMessageLine = (MessageFileLine*) MyMalloc(sizeof(MessageFileLine));
+ newMessageLine = (MessageFileLine *) MyMalloc(sizeof(MessageFileLine));
/* Attempt to format the file in such a way it follows the usual links output
* ie "servername uplink :hops info"
* - madmax
*/
- ircsprintf(newMessageLine->line,"%s %s :1 %s",
+ ircsprintf(newMessageLine->line, "%s %s :1 %s",
target_p->name, me.name, p);
- newMessageLine->next = (MessageFileLine *)NULL;
+ newMessageLine->next = (MessageFileLine *) NULL;
if (MessageFileptr->contentsOfFile)
{
if (currentMessageLine)
currentMessageLine->next = newMessageLine;
- currentMessageLine = newMessageLine;
- }
- else
- {
- MessageFileptr->contentsOfFile = newMessageLine;
- currentMessageLine = newMessageLine;
- }
-
- ircsprintf(buff, "%s %s :1 %s\n", target_p->name, me.name, p);
- fbputs(buff, file);
+ currentMessageLine = newMessageLine;
}
+ else
+ {
+ MessageFileptr->contentsOfFile = newMessageLine;
+ currentMessageLine = newMessageLine;
+ }
+
+ ircsprintf(buff, "%s %s :1 %s\n", target_p->name, me.name, p);
+ fbputs(buff, file);
+ }
fbclose(file);
}
-
+
/*
* hunt_server - Do the basic thing in delivering the message (command)
* across the relays to the specific server (server) for
*
* returns: (see #defines)
*/
-int hunt_server(struct Client *client_p, struct Client *source_p, char *command,
- int server, int parc, char *parv[])
+int
+hunt_server(struct Client *client_p, struct Client *source_p, char *command,
+ int server, int parc, char *parv[])
{
struct Client *target_p;
int wilds;
* Assume it's me, if no server
*/
if (parc <= server || BadPtr(parv[server]) ||
- match(me.name, parv[server]) ||
- match(parv[server], me.name))
+ match(me.name, parv[server]) || match(parv[server], me.name))
return (HUNTED_ISME);
/*
* These are to pickup matches that would cause the following
* name, use the hash lookup
*/
if (!target_p)
+ {
+ if (!wilds)
{
- if (!wilds)
- {
- if (!(target_p = find_server(parv[server])))
- {
- sendto_one(source_p, form_str(ERR_NOSUCHSERVER), me.name,
- parv[0], parv[server]);
- return(HUNTED_NOSUCH);
- }
- }
- else
- {
- for (target_p = GlobalClientList;
- (target_p = next_client(target_p, parv[server]));
- target_p = target_p->next)
- {
- if (target_p->from == source_p->from && !MyConnect(target_p))
- continue;
- /*
- * Fix to prevent looping in case the parameter for
- * some reason happens to match someone from the from
- * link --jto
- */
- if (IsRegistered(target_p) && (target_p != client_p))
- break;
- }
- }
+ if (!(target_p = find_server(parv[server])))
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHSERVER), me.name,
+ parv[0], parv[server]);
+ return (HUNTED_NOSUCH);
+ }
+ }
+ else
+ {
+ for (target_p = GlobalClientList;
+ (target_p = next_client(target_p, parv[server]));
+ target_p = target_p->next)
+ {
+ if (target_p->from == source_p->from && !MyConnect(target_p))
+ continue;
+ /*
+ * Fix to prevent looping in case the parameter for
+ * some reason happens to match someone from the from
+ * link --jto
+ */
+ if (IsRegistered(target_p) && (target_p != client_p))
+ break;
+ }
}
+ }
if (target_p)
- {
- if (IsMe(target_p) || MyClient(target_p))
- return HUNTED_ISME;
-
- if (!match(target_p->name, parv[server]))
- parv[server] = target_p->name;
-
- /* Deal with lazylinks */
- client_burst_if_needed(target_p, source_p);
-
- /* This is a little kludgy but should work... */
- if (IsClient(source_p) &&
- ((MyConnect(target_p) && IsCapable(target_p, CAP_UID)) ||
- (!MyConnect(target_p) && IsCapable(target_p->from, CAP_UID))))
- parv[0] = ID(source_p);
-
- sendto_one(target_p, command, parv[0],
- parv[1], parv[2], parv[3], parv[4],
- parv[5], parv[6], parv[7], parv[8]);
- return(HUNTED_PASS);
- }
+ {
+ if (IsMe(target_p) || MyClient(target_p))
+ return HUNTED_ISME;
+
+ if (!match(target_p->name, parv[server]))
+ parv[server] = target_p->name;
+
+ /* Deal with lazylinks */
+ client_burst_if_needed(target_p, source_p);
+
+ /* This is a little kludgy but should work... */
+ if (IsClient(source_p) &&
+ ((MyConnect(target_p) && IsCapable(target_p, CAP_UID)) ||
+ (!MyConnect(target_p) && IsCapable(target_p->from, CAP_UID))))
+ parv[0] = ID(source_p);
+
+ sendto_one(target_p, command, parv[0],
+ parv[1], parv[2], parv[3], parv[4],
+ parv[5], parv[6], parv[7], parv[8]);
+ return (HUNTED_PASS);
+ }
sendto_one(source_p, form_str(ERR_NOSUCHSERVER), me.name,
parv[0], parv[server]);
- return(HUNTED_NOSUCH);
+ return (HUNTED_NOSUCH);
}
/*
void
try_connections(void *unused)
{
- struct ConfItem* aconf;
- struct Client* client_p;
- int connecting = FALSE;
- int confrq;
- time_t next = 0;
- struct Class* cltmp;
- struct ConfItem* con_conf = NULL;
- int con_class = 0;
-
- Debug((DEBUG_NOTICE,"Connection check at: %s", myctime(CurrentTime)));
-
- for (aconf = ConfigItemList; aconf; aconf = aconf->next )
- {
- /*
- * Also when already connecting! (update holdtimes) --SRB
- */
- if (!(aconf->status & CONF_SERVER) || aconf->port <= 0 ||
- !(aconf->flags & CONF_FLAGS_ALLOW_AUTO_CONN))
- continue;
- cltmp = ClassPtr(aconf);
- /*
- * Skip this entry if the use of it is still on hold until
- * future. Otherwise handle this entry (and set it on hold
- * until next time). Will reset only hold times, if already
- * made one successfull connection... [this algorithm is
- * a bit fuzzy... -- msa >;) ]
- */
- if (aconf->hold > CurrentTime)
- {
- if (next > aconf->hold || next == 0)
- next = aconf->hold;
- continue;
- }
+ struct ConfItem *aconf;
+ struct Client *client_p;
+ int connecting = FALSE;
+ int confrq;
+ time_t next = 0;
+ struct Class *cltmp;
+ struct ConfItem *con_conf = NULL;
+ int con_class = 0;
- if ((confrq = get_con_freq(cltmp)) < MIN_CONN_FREQ )
- confrq = MIN_CONN_FREQ;
+ Debug((DEBUG_NOTICE, "Connection check at: %s", myctime(CurrentTime)));
- aconf->hold = CurrentTime + confrq;
- /*
- * Found a CONNECT config with port specified, scan clients
- * and see if this server is already connected?
- */
- client_p = find_server(aconf->name);
-
- if (!client_p && (Links(cltmp) < MaxLinks(cltmp)) &&
- (!connecting || (ClassType(cltmp) > con_class)))
- {
- con_class = ClassType(cltmp);
- con_conf = aconf;
- /* We connect only one at time... */
- connecting = TRUE;
- }
- if ((next > aconf->hold) || (next == 0))
+ for (aconf = ConfigItemList; aconf; aconf = aconf->next)
+ {
+ /*
+ * Also when already connecting! (update holdtimes) --SRB
+ */
+ if (!(aconf->status & CONF_SERVER) || aconf->port <= 0 ||
+ !(aconf->flags & CONF_FLAGS_ALLOW_AUTO_CONN))
+ continue;
+ cltmp = ClassPtr(aconf);
+ /*
+ * Skip this entry if the use of it is still on hold until
+ * future. Otherwise handle this entry (and set it on hold
+ * until next time). Will reset only hold times, if already
+ * made one successfull connection... [this algorithm is
+ * a bit fuzzy... -- msa >;) ]
+ */
+ if (aconf->hold > CurrentTime)
+ {
+ if (next > aconf->hold || next == 0)
next = aconf->hold;
+ continue;
}
+ if ((confrq = get_con_freq(cltmp)) < MIN_CONN_FREQ)
+ confrq = MIN_CONN_FREQ;
- /* TODO: change this to set active flag to 0 when added to event! --Habeeb */
- if(GlobalSetOptions.autoconn==0)
- return;
-
- if (connecting)
+ aconf->hold = CurrentTime + confrq;
+ /*
+ * Found a CONNECT config with port specified, scan clients
+ * and see if this server is already connected?
+ */
+ client_p = find_server(aconf->name);
+
+ if (!client_p && (Links(cltmp) < MaxLinks(cltmp)) &&
+ (!connecting || (ClassType(cltmp) > con_class)))
{
- if (con_conf->next) /* are we already last? */
- {
- struct ConfItem** pconf;
- for (pconf = &ConfigItemList; (aconf = *pconf);
- pconf = &(aconf->next))
+ con_class = ClassType(cltmp);
+ con_conf = aconf;
+ /* We connect only one at time... */
+ connecting = TRUE;
+ }
+ if ((next > aconf->hold) || (next == 0))
+ next = aconf->hold;
+ }
+
+
+ /* TODO: change this to set active flag to 0 when added to event! --Habeeb */
+ if (GlobalSetOptions.autoconn == 0)
+ return;
+
+ if (connecting)
+ {
+ if (con_conf->next) /* are we already last? */
+ {
+ struct ConfItem **pconf;
+ for (pconf = &ConfigItemList; (aconf = *pconf); pconf = &(aconf->next))
/*
* put the current one at the end and
* make sure we try all connections
*/
if (aconf == con_conf)
*pconf = aconf->next;
- (*pconf = con_conf)->next = 0;
+ (*pconf = con_conf)->next = 0;
}
if (con_conf->flags & CONF_FLAGS_ALLOW_AUTO_CONN)
* error afterwards if it fails.
* -- adrian
*/
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Connection to %s[%s] activated.",
- con_conf->name, con_conf->host);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Connection to %s[%s] activated.",
+ con_conf->name, con_conf->host);
serv_connect(con_conf, 0);
}
}
- Debug((DEBUG_NOTICE,"Next connection check : %s", myctime(next)));
+ Debug((DEBUG_NOTICE, "Next connection check : %s", myctime(next)));
}
-int check_server(const char *name, struct Client* client_p, int cryptlink)
+int
+check_server(const char *name, struct Client *client_p, int cryptlink)
{
- struct ConfItem *aconf=NULL;
- struct ConfItem *server_aconf=NULL;
+ struct ConfItem *aconf = NULL;
+ struct ConfItem *server_aconf = NULL;
int error = -1;
assert(0 != client_p);
/* loop through looking for all possible connect items that might work */
for (aconf = ConfigItemList; aconf; aconf = aconf->next)
- {
- if ((aconf->status & CONF_SERVER) == 0)
- continue;
+ {
+ if ((aconf->status & CONF_SERVER) == 0)
+ continue;
- if (!match(name, aconf->name))
- continue;
+ if (!match(name, aconf->name))
+ continue;
- error = -3;
+ error = -3;
- /* XXX: Fix me for IPv6 */
- /* XXX sockhost is the IPv4 ip as a string */
+ /* XXX: Fix me for IPv6 */
+ /* XXX sockhost is the IPv4 ip as a string */
- if ( match(aconf->host, client_p->host) ||
- match(aconf->host, client_p->localClient->sockhost) )
- {
- error = -2;
+ if (match(aconf->host, client_p->host) ||
+ match(aconf->host, client_p->localClient->sockhost))
+ {
+ error = -2;
#ifdef HAVE_LIBCRYPTO
- if (cryptlink && IsConfCryptLink(aconf))
- {
- if (aconf->rsa_public_key)
- server_aconf = aconf;
- }
- else if (!(cryptlink || IsConfCryptLink(aconf)))
+ if (cryptlink && IsConfCryptLink(aconf))
+ {
+ if (aconf->rsa_public_key)
+ server_aconf = aconf;
+ }
+ else if (!(cryptlink || IsConfCryptLink(aconf)))
#endif /* HAVE_LIBCRYPTO */
- {
- if (IsConfEncrypted(aconf))
- {
- if (strcmp(aconf->passwd,
- crypt(client_p->localClient->passwd, aconf->passwd)) == 0)
- server_aconf = aconf;
- }
- else
- {
- if (strcmp(aconf->passwd, client_p->localClient->passwd) == 0)
- server_aconf = aconf;
- }
- }
- }
+ {
+ if (IsConfEncrypted(aconf))
+ {
+ if (strcmp(aconf->passwd,
+ crypt(client_p->localClient->passwd,
+ aconf->passwd)) == 0)
+ server_aconf = aconf;
+ }
+ else
+ {
+ if (strcmp(aconf->passwd, client_p->localClient->passwd) == 0)
+ server_aconf = aconf;
+ }
+ }
}
+ }
if (server_aconf == NULL)
return error;
/* Now find all leaf or hub config items for this server */
for (aconf = ConfigItemList; aconf; aconf = aconf->next)
- {
- if ((aconf->status & (CONF_HUB|CONF_LEAF)) == 0)
- continue;
+ {
+ if ((aconf->status & (CONF_HUB | CONF_LEAF)) == 0)
+ continue;
- if (!match(name, aconf->name))
- continue;
+ if (!match(name, aconf->name))
+ continue;
- attach_conf(client_p, aconf);
- }
+ attach_conf(client_p, aconf);
+ }
- if( !(server_aconf->flags & CONF_FLAGS_LAZY_LINK) )
- ClearCap(client_p,CAP_LL);
-#ifdef HAVE_LIBZ /* otherwise, cleait unconditionally */
- if( !(server_aconf->flags & CONF_FLAGS_COMPRESSED) )
+ if (!(server_aconf->flags & CONF_FLAGS_LAZY_LINK))
+ ClearCap(client_p, CAP_LL);
+#ifdef HAVE_LIBZ /* otherwise, cleait unconditionally */
+ if (!(server_aconf->flags & CONF_FLAGS_COMPRESSED))
#endif
- ClearCap(client_p,CAP_ZIP);
- if( !(server_aconf->flags & CONF_FLAGS_CRYPTLINK) )
- ClearCap(client_p,CAP_ENC);
+ ClearCap(client_p, CAP_ZIP);
+ if (!(server_aconf->flags & CONF_FLAGS_CRYPTLINK))
+ ClearCap(client_p, CAP_ENC);
/*
* Don't unset CAP_HUB here even if the server isn't a hub,
* it only indicates if the server thinks it's lazylinks are
* leafs or not.. if you unset it, bad things will happen
*/
- if(aconf != NULL)
+ if (aconf != NULL)
{
#ifdef IPV6
- if (IN6_IS_ADDR_UNSPECIFIED((struct in6_addr *)
- &IN_ADDR(aconf->ipnum)))
+ if (IN6_IS_ADDR_UNSPECIFIED((struct in6_addr *)&IN_ADDR(aconf->ipnum)))
#else
- if (IN_ADDR(aconf->ipnum) == INADDR_NONE)
+ if (IN_ADDR(aconf->ipnum) == INADDR_NONE)
#endif
- copy_s_addr(IN_ADDR(aconf->ipnum), IN_ADDR(client_p->localClient->ip));
+ copy_s_addr(IN_ADDR(aconf->ipnum), IN_ADDR(client_p->localClient->ip));
}
return 0;
}
* side effects - send the CAPAB line to a server -orabidoo
*
*/
-void send_capabilities(struct Client *client_p, struct ConfItem *aconf,
- int cap_can_send, int enc_can_send )
+void
+send_capabilities(struct Client *client_p, struct ConfItem *aconf,
+ int cap_can_send, int enc_can_send)
{
struct Capability *cap;
- char msgbuf[BUFSIZE];
- char *t;
- int tl;
+ char msgbuf[BUFSIZE];
+ char *t;
+ int tl;
#ifdef HAVE_LIBCRYPTO
struct EncCapability *epref;
- char *capend;
- int sent_cipher = 0;
+ char *capend;
+ int sent_cipher = 0;
#endif
t = msgbuf;
for (cap = captab; cap->name; ++cap)
+ {
+ if (cap->cap & cap_can_send)
{
- if (cap->cap & cap_can_send)
- {
- tl = ircsprintf(t, "%s ", cap->name);
- t += tl;
- }
+ tl = ircsprintf(t, "%s ", cap->name);
+ t += tl;
}
+ }
#ifdef HAVE_LIBCRYPTO
if (enc_can_send)
else
epref = ConfigFileEntry.default_cipher_preference;
- if ( (epref->cap & enc_can_send) )
+ if ((epref->cap & enc_can_send))
{
/* Leave the space -- it is removed later. */
tl = ircsprintf(t, "%s ", epref->name);
}
if (!sent_cipher)
- t = capend; /* truncate string before ENC:, below */
+ t = capend; /* truncate string before ENC:, below */
}
#endif
* output - NONE
* side effects - NICK message is sent towards given client_p
*/
-void sendnick_TS(struct Client *client_p, struct Client *target_p)
+void
+sendnick_TS(struct Client *client_p, struct Client *target_p)
{
static char ubuf[12];
if (!IsPerson(target_p))
- return;
-
+ return;
+
send_umode(NULL, target_p, 0, SEND_UMODES, ubuf);
if (!*ubuf)
{
- ubuf[0] = '+';
- ubuf[1] = '\0';
+ ubuf[0] = '+';
+ ubuf[1] = '\0';
}
-
+
if (HasID(target_p) && IsCapable(client_p, CAP_UID))
- sendto_one(client_p, "CLIENT %s %d %lu %s %s %s %s %s :%s",
- target_p->name,
- target_p->hopcount + 1,
- (unsigned long) target_p->tsinfo,
- ubuf,
- target_p->username, target_p->host,
- target_p->user->server, target_p->user->id, target_p->info);
+ sendto_one(client_p, "CLIENT %s %d %lu %s %s %s %s %s :%s",
+ target_p->name,
+ target_p->hopcount + 1,
+ (unsigned long)target_p->tsinfo,
+ ubuf,
+ target_p->username, target_p->host,
+ target_p->user->server, target_p->user->id, target_p->info);
else
- sendto_one(client_p, "NICK %s %d %lu %s %s %s %s :%s",
- target_p->name,
- target_p->hopcount + 1,
- (unsigned long) target_p->tsinfo,
- ubuf,
- target_p->username, target_p->host,
- target_p->user->server, target_p->info);
+ sendto_one(client_p, "NICK %s %d %lu %s %s %s %s :%s",
+ target_p->name,
+ target_p->hopcount + 1,
+ (unsigned long)target_p->tsinfo,
+ ubuf,
+ target_p->username, target_p->host,
+ target_p->user->server, target_p->info);
}
/*
* output - NONE
* side effects - If this client is not known by this lazyleaf, send it
*/
-void client_burst_if_needed(struct Client *client_p, struct Client *target_p)
+void
+client_burst_if_needed(struct Client *client_p, struct Client *target_p)
{
- if (!ServerInfo.hub) return;
- if (!MyConnect(client_p)) return;
- if (!IsCapable(client_p,CAP_LL)) return;
-
- if((target_p->lazyLinkClientExists & client_p->localClient->serverMask) == 0)
- {
- sendnick_TS(client_p, target_p);
- add_lazylinkclient(client_p,target_p);
- }
+ if (!ServerInfo.hub)
+ return;
+ if (!MyConnect(client_p))
+ return;
+ if (!IsCapable(client_p, CAP_LL))
+ return;
+
+ if ((target_p->lazyLinkClientExists & client_p->localClient->serverMask) ==
+ 0)
+ {
+ sendnick_TS(client_p, target_p);
+ add_lazylinkclient(client_p, target_p);
+ }
}
/*
* side effects - build up string representing capabilities of server listed
*/
-const char* show_capabilities(struct Client* target_p)
+const char *
+show_capabilities(struct Client *target_p)
{
- static char msgbuf[BUFSIZE];
- struct Capability* cap;
+ static char msgbuf[BUFSIZE];
+ struct Capability *cap;
char *t;
- int tl;
+ int tl;
t = msgbuf;
- tl = ircsprintf(msgbuf,"TS ");
+ tl = ircsprintf(msgbuf, "TS ");
t += tl;
- if (!target_p->localClient->caps) /* short circuit if no caps */
- {
- msgbuf[2] = '\0';
- return msgbuf;
- }
+ if (!target_p->localClient->caps) /* short circuit if no caps */
+ {
+ msgbuf[2] = '\0';
+ return msgbuf;
+ }
for (cap = captab; cap->cap; ++cap)
+ {
+ if (cap->cap & target_p->localClient->caps)
{
- if(cap->cap & target_p->localClient->caps)
- {
- tl = ircsprintf(t, "%s ", cap->name);
- t += tl;
- }
+ tl = ircsprintf(t, "%s ", cap->name);
+ t += tl;
}
+ }
#ifdef HAVE_LIBCRYPTO
if (IsCapable(target_p, CAP_ENC) &&
- target_p->localClient->in_cipher &&
- target_p->localClient->out_cipher)
+ target_p->localClient->in_cipher && target_p->localClient->out_cipher)
{
- tl = ircsprintf(t, "ENC:%s ",
- target_p->localClient->in_cipher->name);
+ tl = ircsprintf(t, "ENC:%s ", target_p->localClient->in_cipher->name);
t += tl;
}
#endif
* side effects -
*/
-int server_estab(struct Client *client_p)
+int
+server_estab(struct Client *client_p)
{
- struct Client* target_p;
- struct ConfItem* aconf;
- const char* inpath;
- static char inpath_ip[HOSTLEN * 2 + USERLEN + 5];
- char* host;
- dlink_node *m;
- dlink_node *ptr;
+ struct Client *target_p;
+ struct ConfItem *aconf;
+ const char *inpath;
+ static char inpath_ip[HOSTLEN * 2 + USERLEN + 5];
+ char *host;
+ dlink_node *m;
+ dlink_node *ptr;
assert(0 != client_p);
ClearAccess(client_p);
strcpy(inpath_ip, get_client_name(client_p, SHOW_IP));
- inpath = get_client_name(client_p, MASK_IP); /* "refresh" inpath with host */
+ inpath = get_client_name(client_p, MASK_IP); /* "refresh" inpath with host */
host = client_p->name;
if (!(aconf = find_conf_name(&client_p->localClient->confs, host,
CONF_SERVER)))
- {
- /* This shouldn't happen, better tell the ops... -A1kmm */
- sendto_realops_flags(FLAGS_ALL, L_ALL, "Warning: Lost connect{} block "
- "for server %s(this shouldn't happen)!", host);
- return exit_client(client_p, client_p, client_p, "Lost connect{} block!");
- }
+ {
+ /* This shouldn't happen, better tell the ops... -A1kmm */
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Warning: Lost connect{} block "
+ "for server %s(this shouldn't happen)!", host);
+ return exit_client(client_p, client_p, client_p, "Lost connect{} block!");
+ }
/* We shouldn't have to check this, it should already done before
* server_estab is called. -A1kmm
*/
- memset((void *)client_p->localClient->passwd, 0,sizeof(client_p->localClient->passwd));
+ memset((void *)client_p->localClient->passwd, 0,
+ sizeof(client_p->localClient->passwd));
/* Its got identd , since its a server */
SetGotId(client_p);
/* If there is something in the serv_list, it might be this
* connecting server..
*/
- if(!ServerInfo.hub && serv_list.head)
+ if (!ServerInfo.hub && serv_list.head)
+ {
+ if (client_p != serv_list.head->data || serv_list.head->next)
{
- if (client_p != serv_list.head->data || serv_list.head->next)
- {
- ServerStats->is_ref++;
- sendto_one(client_p, "ERROR :I'm a leaf not a hub");
- return exit_client(client_p, client_p, client_p, "I'm a leaf");
- }
+ ServerStats->is_ref++;
+ sendto_one(client_p, "ERROR :I'm a leaf not a hub");
+ return exit_client(client_p, client_p, client_p, "I'm a leaf");
}
+ }
if (IsUnknown(client_p) && !IsConfCryptLink(aconf))
+ {
+ /*
+ * jdc -- 1. Use EmptyString(), not [0] index reference.
+ * 2. Check aconf->spasswd, not aconf->passwd.
+ */
+ if (!EmptyString(aconf->spasswd))
{
- /*
- * jdc -- 1. Use EmptyString(), not [0] index reference.
- * 2. Check aconf->spasswd, not aconf->passwd.
- */
- if (!EmptyString(aconf->spasswd))
- {
- sendto_one(client_p,"PASS %s :TS", aconf->spasswd);
- }
+ sendto_one(client_p, "PASS %s :TS", aconf->spasswd);
+ }
- /*
- * Pass my info to the new server
- *
- * If trying to negotiate LazyLinks, pass on CAP_LL
- * If this is a HUB, pass on CAP_HUB
- */
+ /*
+ * Pass my info to the new server
+ *
+ * If trying to negotiate LazyLinks, pass on CAP_LL
+ * If this is a HUB, pass on CAP_HUB
+ */
- send_capabilities(client_p, aconf, default_server_capabs
- | ((aconf->flags & CONF_FLAGS_LAZY_LINK) ? CAP_LL : 0)
- | (ServerInfo.hub ? CAP_HUB : 0)
- | ((aconf->flags & CONF_FLAGS_COMPRESSED) ? CAP_ZIP_SUPPORTED : 0),
- 0);
+ send_capabilities(client_p, aconf, default_server_capabs
+ | ((aconf->flags & CONF_FLAGS_LAZY_LINK) ? CAP_LL : 0)
+ | (ServerInfo.hub ? CAP_HUB : 0)
+ | ((aconf->flags & CONF_FLAGS_COMPRESSED) ?
+ CAP_ZIP_SUPPORTED : 0), 0);
- sendto_one(client_p, "SERVER %s 1 :%s%s",
- my_name_for_link(me.name, aconf),
- ConfigServerHide.hidden ? "(H) " : "",
- (me.info[0]) ? (me.info) : "IRCers United");
- }
+ sendto_one(client_p, "SERVER %s 1 :%s%s",
+ my_name_for_link(me.name, aconf),
+ ConfigServerHide.hidden ? "(H) " : "",
+ (me.info[0]) ? (me.info) : "IRCers United");
+ }
/*
* XXX - this should be in s_bsd
*/
if (!set_sock_buffers(client_p->fd, READBUF_SIZE))
- report_error(L_ALL, SETBUF_ERROR_MSG, get_client_name(client_p, SHOW_IP), errno);
+ report_error(L_ALL, SETBUF_ERROR_MSG, get_client_name(client_p, SHOW_IP),
+ errno);
/* Hand the server off to servlink now */
#ifndef VMS
if (IsCapable(client_p, CAP_ENC) || IsCapable(client_p, CAP_ZIP))
+ {
+ if (fork_server(client_p) < 0)
{
- if (fork_server(client_p) < 0 )
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Warning: fork failed for server %s -- check servlink_path (%s)",
- get_client_name(client_p, HIDE_IP),
- ConfigFileEntry.servlink_path);
- sendto_realops_flags(FLAGS_ALL, L_OPER, "Warning: fork failed for server "
- "%s -- check servlink_path (%s)",
- get_client_name(client_p, MASK_IP),
- ConfigFileEntry.servlink_path);
- return exit_client(client_p, client_p, client_p, "Fork failed");
- }
- start_io(client_p);
- SetServlink(client_p);
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Warning: fork failed for server %s -- check servlink_path (%s)",
+ get_client_name(client_p, HIDE_IP),
+ ConfigFileEntry.servlink_path);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Warning: fork failed for server "
+ "%s -- check servlink_path (%s)",
+ get_client_name(client_p, MASK_IP),
+ ConfigFileEntry.servlink_path);
+ return exit_client(client_p, client_p, client_p, "Fork failed");
}
+ start_io(client_p);
+ SetServlink(client_p);
+ }
#endif
- sendto_one(client_p,"SVINFO %d %d 0 :%lu",
- TS_CURRENT,
- TS_MIN,
- (unsigned long) CurrentTime);
+ sendto_one(client_p, "SVINFO %d %d 0 :%lu",
+ TS_CURRENT, TS_MIN, (unsigned long)CurrentTime);
- det_confs_butmask(client_p, CONF_LEAF|CONF_HUB|CONF_SERVER);
+ det_confs_butmask(client_p, CONF_LEAF | CONF_HUB | CONF_SERVER);
/*
- ** *WARNING*
- ** In the following code in place of plain server's
- ** name we send what is returned by get_client_name
- ** which may add the "sockhost" after the name. It's
- ** *very* *important* that there is a SPACE between
- ** the name and sockhost (if present). The receiving
- ** server will start the information field from this
- ** first blank and thus puts the sockhost into info.
- ** ...a bit tricky, but you have been warned, besides
- ** code is more neat this way... --msa
- */
+ ** *WARNING*
+ ** In the following code in place of plain server's
+ ** name we send what is returned by get_client_name
+ ** which may add the "sockhost" after the name. It's
+ ** *very* *important* that there is a SPACE between
+ ** the name and sockhost (if present). The receiving
+ ** server will start the information field from this
+ ** first blank and thus puts the sockhost into info.
+ ** ...a bit tricky, but you have been warned, besides
+ ** code is more neat this way... --msa
+ */
SetServer(client_p);
client_p->servptr = &me;
- /* Update the capability combination usage counts. -A1kmm */
+ /* Update the capability combination usage counts. -A1kmm */
set_chcap_usage_counts(client_p);
/* Some day, all these lists will be consolidated *sigh* */
add_client_to_llist(&(me.serv->servers), client_p);
m = dlinkFind(&unknown_list, client_p);
- if(m != NULL)
- {
- dlinkDelete(m, &unknown_list);
- dlinkAdd(client_p, m, &serv_list);
- }
+ if (m != NULL)
+ {
+ dlinkDelete(m, &unknown_list);
+ dlinkAdd(client_p, m, &serv_list);
+ }
Count.server++;
Count.myserver++;
/* Show the real host/IP to admins */
sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Link with %s established: (%s) link",
- inpath_ip,show_capabilities(client_p));
+ "Link with %s established: (%s) link",
+ inpath_ip, show_capabilities(client_p));
/* Now show the masked hostname/IP to opers */
sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Link with %s established: (%s) link",
- inpath,show_capabilities(client_p));
+ "Link with %s established: (%s) link",
+ inpath, show_capabilities(client_p));
ilog(L_NOTICE, "Link with %s established: (%s) link",
- inpath_ip, show_capabilities(client_p));
+ inpath_ip, show_capabilities(client_p));
add_server_to_list(client_p);
add_to_client_hash_table(client_p->name, client_p);
client_p->flags2 |= FLAGS2_CBURST;
if (HasServlink(client_p))
- {
- /* we won't overflow FD_DESC_SZ here, as it can hold
- * client_p->name + 64
- */
+ {
+ /* we won't overflow FD_DESC_SZ here, as it can hold
+ * client_p->name + 64
+ */
#ifdef HAVE_SOCKETPAIR
- fd_note(client_p->fd, "slink data: %s", client_p->name);
- fd_note(client_p->localClient->ctrlfd, "slink ctrl: %s",
- client_p->name);
+ fd_note(client_p->fd, "slink data: %s", client_p->name);
+ fd_note(client_p->localClient->ctrlfd, "slink ctrl: %s", client_p->name);
#else
- fd_note(client_p->fd, "slink data (out): %s", client_p->name);
- fd_note(client_p->localClient->ctrlfd, "slink ctrl (out): %s",
- client_p->name);
- fd_note(client_p->fd_r, "slink data (in): %s", client_p->name);
- fd_note(client_p->localClient->ctrlfd_r, "slink ctrl (in): %s",
- client_p->name);
+ fd_note(client_p->fd, "slink data (out): %s", client_p->name);
+ fd_note(client_p->localClient->ctrlfd, "slink ctrl (out): %s",
+ client_p->name);
+ fd_note(client_p->fd_r, "slink data (in): %s", client_p->name);
+ fd_note(client_p->localClient->ctrlfd_r, "slink ctrl (in): %s",
+ client_p->name);
#endif
- } else
- fd_note(client_p->fd, "Server: %s", client_p->name);
+ }
+ else
+ fd_note(client_p->fd, "Server: %s", client_p->name);
/*
- ** Old sendto_serv_but_one() call removed because we now
- ** need to send different names to different servers
- ** (domain name matching) Send new server to other servers.
- */
- for(ptr=serv_list.head;ptr;ptr=ptr->next)
- {
- target_p = ptr->data;
+ ** Old sendto_serv_but_one() call removed because we now
+ ** need to send different names to different servers
+ ** (domain name matching) Send new server to other servers.
+ */
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
- if (target_p == client_p)
- continue;
+ if (target_p == client_p)
+ continue;
- if ((aconf = target_p->serv->sconf) &&
- match(my_name_for_link(me.name, aconf), client_p->name))
- continue;
- sendto_one(target_p,":%s SERVER %s 2 :%s%s",
- me.name, client_p->name,
- client_p->hidden_server ? "(H) " : "",
- client_p->info);
- }
+ if ((aconf = target_p->serv->sconf) &&
+ match(my_name_for_link(me.name, aconf), client_p->name))
+ continue;
+ sendto_one(target_p, ":%s SERVER %s 2 :%s%s",
+ me.name, client_p->name,
+ client_p->hidden_server ? "(H) " : "", client_p->info);
+ }
/*
- ** Pass on my client information to the new server
- **
- ** First, pass only servers (idea is that if the link gets
- ** cancelled beacause the server was already there,
- ** there are no NICK's to be cancelled...). Of course,
- ** if cancellation occurs, all this info is sent anyway,
- ** and I guess the link dies when a read is attempted...? --msa
- **
- ** Note: Link cancellation to occur at this point means
- ** that at least two servers from my fragment are building
- ** up connection this other fragment at the same time, it's
- ** a race condition, not the normal way of operation...
- **
- ** ALSO NOTE: using the get_client_name for server names--
- ** see previous *WARNING*!!! (Also, original inpath
- ** is destroyed...)
- */
+ ** Pass on my client information to the new server
+ **
+ ** First, pass only servers (idea is that if the link gets
+ ** cancelled beacause the server was already there,
+ ** there are no NICK's to be cancelled...). Of course,
+ ** if cancellation occurs, all this info is sent anyway,
+ ** and I guess the link dies when a read is attempted...? --msa
+ **
+ ** Note: Link cancellation to occur at this point means
+ ** that at least two servers from my fragment are building
+ ** up connection this other fragment at the same time, it's
+ ** a race condition, not the normal way of operation...
+ **
+ ** ALSO NOTE: using the get_client_name for server names--
+ ** see previous *WARNING*!!! (Also, original inpath
+ ** is destroyed...)
+ */
aconf = client_p->serv->sconf;
for (target_p = &me; target_p; target_p = target_p->prev)
+ {
+ /* target_p->from == target_p for target_p == client_p */
+ if (target_p->from == client_p)
+ continue;
+ if (IsServer(target_p))
{
- /* target_p->from == target_p for target_p == client_p */
- if (target_p->from == client_p)
+ if (match(my_name_for_link(me.name, aconf), target_p->name))
continue;
- if (IsServer(target_p))
- {
- if (match(my_name_for_link(me.name, aconf), target_p->name))
- continue;
- sendto_one(client_p, ":%s SERVER %s %d :%s%s",
- target_p->serv->up,
- target_p->name, target_p->hopcount+1,
- target_p->hidden_server ? "(H) " : "",
- target_p->info);
- }
- }
-
- if((ServerInfo.hub == 0) && MyConnect(client_p))
- {
- uplink = client_p;
+ sendto_one(client_p, ":%s SERVER %s %d :%s%s",
+ target_p->serv->up,
+ target_p->name, target_p->hopcount + 1,
+ target_p->hidden_server ? "(H) " : "", target_p->info);
}
+ }
+
+ if ((ServerInfo.hub == 0) && MyConnect(client_p))
+ {
+ uplink = client_p;
+ }
server_burst(client_p);
return 0;
}
-static void start_io(struct Client *server)
+static void
+start_io(struct Client *server)
{
unsigned char *buf;
int c = 0;
{
/* ziplink */
buf[c++] = SLINKCMD_SET_ZIP_OUT_LEVEL;
- buf[c++] = 0; /* | */
- buf[c++] = 1; /* \ len is 1 */
+ buf[c++] = 0; /* | */
+ buf[c++] = 1; /* \ len is 1 */
buf[c++] = ConfigFileEntry.compression_level;
buf[c++] = SLINKCMD_START_ZIP_IN;
buf[c++] = SLINKCMD_START_ZIP_OUT;
{
/* Decryption settings */
buf[c++] = SLINKCMD_SET_CRYPT_IN_CIPHER;
- buf[c++] = 0; /* / (upper 8-bits of len) */
- buf[c++] = 1; /* \ cipher id is 1 byte (lower 8-bits of len) */
+ buf[c++] = 0; /* / (upper 8-bits of len) */
+ buf[c++] = 1; /* \ cipher id is 1 byte (lower 8-bits of len) */
buf[c++] = server->localClient->in_cipher->cipherid;
buf[c++] = SLINKCMD_SET_CRYPT_IN_KEY;
- buf[c++] = 0; /* keylen < 256 */
+ buf[c++] = 0; /* keylen < 256 */
buf[c++] = server->localClient->in_cipher->keylen;
memcpy((buf + c), server->localClient->in_key,
- server->localClient->in_cipher->keylen);
+ server->localClient->in_cipher->keylen);
c += server->localClient->in_cipher->keylen;
/* Encryption settings */
buf[c++] = SLINKCMD_SET_CRYPT_OUT_CIPHER;
- buf[c++] = 0; /* / (upper 8-bits of len) */
- buf[c++] = 1; /* \ cipher id is 1 byte (lower 8-bits of len) */
+ buf[c++] = 0; /* / (upper 8-bits of len) */
+ buf[c++] = 1; /* \ cipher id is 1 byte (lower 8-bits of len) */
buf[c++] = server->localClient->out_cipher->cipherid;
buf[c++] = SLINKCMD_SET_CRYPT_OUT_KEY;
- buf[c++] = 0; /* keylen < 256 */
+ buf[c++] = 0; /* keylen < 256 */
buf[c++] = server->localClient->out_cipher->keylen;
memcpy((buf + c), server->localClient->out_key,
- server->localClient->out_cipher->keylen);
+ server->localClient->out_cipher->keylen);
c += server->localClient->out_cipher->keylen;
buf[c++] = SLINKCMD_START_CRYPT_IN;
buf[c++] = SLINKCMD_START_CRYPT_OUT;
}
#endif
- while(1)
+ while (1)
{
linecount++;
buf = MyRealloc(buf, (c + READBUF_SIZE + 64));
-
+
/* store data in c+3 to allow for SLINKCMD_INJECT_RECVQ and len u16 */
- linelen = linebuf_get(&server->localClient->buf_recvq,
- (char *)(buf + c + 3),
- READBUF_SIZE, LINEBUF_PARTIAL,
- LINEBUF_RAW); /* include partial lines & don't
- parse data */
+ linelen = linebuf_get(&server->localClient->buf_recvq, (char *)(buf + c + 3), READBUF_SIZE, LINEBUF_PARTIAL, LINEBUF_RAW); /* include partial lines & don't
+ parse data */
if (linelen)
{
break;
}
- while(1)
+ while (1)
{
linecount++;
buf = MyRealloc(buf, (c + BUF_DATA_SIZE + 64));
/* store data in c+3 to allow for SLINKCMD_INJECT_RECVQ and len u16 */
- linelen = linebuf_get(&server->localClient->buf_sendq,
- (char *)(buf + c + 3),
- READBUF_SIZE, LINEBUF_PARTIAL,
- LINEBUF_PARSED); /* include partial lines */
+ linelen = linebuf_get(&server->localClient->buf_sendq, (char *)(buf + c + 3), READBUF_SIZE, LINEBUF_PARTIAL, LINEBUF_PARSED); /* include partial lines */
if (linelen)
{
server->localClient->slinkq = buf;
server->localClient->slinkq_ofs = 0;
server->localClient->slinkq_len = c;
-
- /* schedule a write */
+
+ /* schedule a write */
send_queued_slink_write(server->localClient->ctrlfd, server);
}
* output - success: 0 / failure: -1
* side effect - fork, and exec SERVLINK to handle this connection
*/
-int fork_server(struct Client *server)
+int
+fork_server(struct Client *server)
{
- int ret;
- int i;
- int fd_temp[2];
- int slink_fds[2][2][2] = { { { 0, 0 }, { 0, 0 } },
- { { 0, 0 }, { 0, 0 } } };
- /* [0][y][z] - ctrl | [1][y][z] - data
- * [x][0][z] - child | [x][1][z] - parent
- * [x][y][0] - read | [x][y][1] - write
- */
- char fd_str[5][6]; /* store 5x '6' '5' '5' '3' '5' '\0' */
+ int ret;
+ int i;
+ int fd_temp[2];
+ int slink_fds[2][2][2] = { {{0, 0}, {0, 0}},
+ {{0, 0}, {0, 0}}
+ };
+ /* [0][y][z] - ctrl | [1][y][z] - data
+ * [x][0][z] - child | [x][1][z] - parent
+ * [x][y][0] - read | [x][y][1] - write
+ */
+ char fd_str[5][6]; /* store 5x '6' '5' '5' '3' '5' '\0' */
char *kid_argv[7];
-
+
#ifdef HAVE_SOCKETPAIR
/* ctrl */
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd_temp) < 0)
else if (ret == 0)
{
/* set our fds as non blocking and close everything else */
- for(i = 0; i < HARD_FDLIMIT; i++)
+ for (i = 0; i < HARD_FDLIMIT; i++)
{
if ((i == slink_fds[0][0][0]) || (i == slink_fds[0][0][1]) ||
(i == slink_fds[0][0][0]) || (i == slink_fds[1][0][1]) ||
- (i == server->fd)) {
+ (i == server->fd))
+ {
set_non_blocking(i);
-#ifdef USE_SIGIO /* the servlink process doesn't need O_ASYNC */
- {
- int flags = 0;
- fcntl(i, F_GETFL, &flags);
- flags |= ~O_ASYNC;
- fcntl(i, F_SETFL, flags);
- }
+#ifdef USE_SIGIO /* the servlink process doesn't need O_ASYNC */
+ {
+ int flags = 0;
+ fcntl(i, F_GETFL, &flags);
+ flags |= ~O_ASYNC;
+ fcntl(i, F_SETFL, flags);
+ }
#endif
}
else
{
#ifdef VMS
- if (i > 2) /* don't close std* */
+ if (i > 2) /* don't close std* */
#endif
close(i);
}
}
- sprintf(fd_str[0], "%d", slink_fds[0][0][0]); /* ctrl read */
- sprintf(fd_str[1], "%d", slink_fds[0][0][1]); /* ctrl write */
- sprintf(fd_str[2], "%d", slink_fds[1][0][0]); /* data read */
- sprintf(fd_str[3], "%d", slink_fds[1][0][1]); /* data write */
- sprintf(fd_str[4], "%d", server->fd); /* network read/write */
-
+ sprintf(fd_str[0], "%d", slink_fds[0][0][0]); /* ctrl read */
+ sprintf(fd_str[1], "%d", slink_fds[0][0][1]); /* ctrl write */
+ sprintf(fd_str[2], "%d", slink_fds[1][0][0]); /* data read */
+ sprintf(fd_str[3], "%d", slink_fds[1][0][1]); /* data write */
+ sprintf(fd_str[4], "%d", server->fd); /* network read/write */
+
kid_argv[0] = "-slink";
kid_argv[1] = fd_str[0];
kid_argv[2] = fd_str[1];
kid_argv[6] = NULL;
/* exec servlink program */
- execv( ConfigFileEntry.servlink_path, kid_argv );
+ execv(ConfigFileEntry.servlink_path, kid_argv);
/* We're still here, abort. */
_exit(1);
}
else
{
- fd_close( server->fd );
+ fd_close(server->fd);
/* close the childs end of the pipes */
close(slink_fds[0][0][0]);
if (!set_non_blocking(server->fd))
{
- report_error(L_ADMIN, NONB_ERROR_MSG, get_client_name(server, SHOW_IP), errno);
- report_error(L_OPER, NONB_ERROR_MSG, get_client_name(server, MASK_IP), errno);
+ report_error(L_ADMIN, NONB_ERROR_MSG, get_client_name(server, SHOW_IP),
+ errno);
+ report_error(L_OPER, NONB_ERROR_MSG, get_client_name(server, MASK_IP),
+ errno);
}
if (!set_non_blocking(server->localClient->ctrlfd))
{
- report_error(L_ADMIN, NONB_ERROR_MSG,
+ report_error(L_ADMIN, NONB_ERROR_MSG,
get_client_name(server, SHOW_IP), errno);
- report_error(L_OPER, NONB_ERROR_MSG,
+ report_error(L_OPER, NONB_ERROR_MSG,
get_client_name(server, MASK_IP), errno);
}
#ifndef HAVE_SOCKETPAIR
if (!set_non_blocking(server->fd_r))
{
- report_error(L_ADMIN, NONB_ERROR_MSG,
+ report_error(L_ADMIN, NONB_ERROR_MSG,
get_client_name(server, SHOW_IP), errno);
report_error(L_OPER, NONB_ERROR_MSG,
get_client_name(server, MASK_IP), errno);
}
if (!set_non_blocking(server->localClient->ctrlfd_r))
{
- report_error(L_ADMIN, NONB_ERROR_MSG,
+ report_error(L_ADMIN, NONB_ERROR_MSG,
get_client_name(server, SHOW_IP), errno);
report_error(L_OPER, NONB_ERROR_MSG,
get_client_name(server, MASK_IP), errno);
* side effects - send a server burst
* bugs - still too long
*/
-static void server_burst(struct Client *client_p)
+static void
+server_burst(struct Client *client_p)
{
/*
- ** Send it in the shortened format with the TS, if
- ** it's a TS server; walk the list of channels, sending
- ** all the nicks that haven't been sent yet for each
- ** channel, then send the channel itself -- it's less
- ** obvious than sending all nicks first, but on the
- ** receiving side memory will be allocated more nicely
- ** saving a few seconds in the handling of a split
- ** -orabidoo
- */
+ ** Send it in the shortened format with the TS, if
+ ** it's a TS server; walk the list of channels, sending
+ ** all the nicks that haven't been sent yet for each
+ ** channel, then send the channel itself -- it's less
+ ** obvious than sending all nicks first, but on the
+ ** receiving side memory will be allocated more nicely
+ ** saving a few seconds in the handling of a split
+ ** -orabidoo
+ */
/* On a "lazy link" hubs send nothing.
* Leafs always have to send nicks plus channels
*/
- if( IsCapable(client_p, CAP_LL) )
- {
- if(!ServerInfo.hub)
- {
- /* burst all our info */
- burst_all(client_p);
- /* Now, ask for channel info on all our current channels */
- cjoin_all(client_p);
- }
- }
- else
+ if (IsCapable(client_p, CAP_LL))
+ {
+ if (!ServerInfo.hub)
{
+ /* burst all our info */
burst_all(client_p);
+ /* Now, ask for channel info on all our current channels */
+ cjoin_all(client_p);
}
+ }
+ else
+ {
+ burst_all(client_p);
+ }
client_p->flags2 &= ~FLAGS2_CBURST;
/* EOB stuff is now in burst_all */
static void
burst_all(struct Client *client_p)
{
- struct Client* target_p;
- struct Channel* chptr;
- struct Channel* vchan;
- struct hook_burst_channel hinfo;
+ struct Client *target_p;
+ struct Channel *chptr;
+ struct Channel *vchan;
+ struct hook_burst_channel hinfo;
dlink_node *ptr;
/* serial counter borrowed from send.c */
current_serial++;
for (chptr = GlobalChannelList; chptr; chptr = chptr->nextch)
+ {
+ /* Don't send vchannels twice; vchannels will be
+ * sent along as subchannels of the top channel
+ */
+
+ if (IsVchan(chptr))
+ continue;
+
+ if (chptr->users != 0)
{
- /* Don't send vchannels twice; vchannels will be
- * sent along as subchannels of the top channel
- */
-
- if(IsVchan(chptr))
- continue;
-
- if(chptr->users != 0)
+ burst_members(client_p, &chptr->chanops);
+#ifdef REQUIRE_OANDV
+ burst_members(client_p, &chptr->chanops_voiced);
+#endif
+ burst_members(client_p, &chptr->voiced);
+ burst_members(client_p, &chptr->halfops);
+ burst_members(client_p, &chptr->peons);
+ send_channel_modes(client_p, chptr);
+ hinfo.chptr = chptr;
+ hinfo.client = client_p;
+ hook_call_event("burst_channel", &hinfo);
+ }
+
+ if (IsVchanTop(chptr))
+ {
+ for (ptr = chptr->vchan_list.head; ptr; ptr = ptr->next)
+ {
+ vchan = ptr->data;
+ if (vchan->users != 0)
{
- burst_members(client_p,&chptr->chanops);
+ burst_members(client_p, &vchan->chanops);
#ifdef REQUIRE_OANDV
- burst_members(client_p,&chptr->chanops_voiced);
+ burst_members(client_p, &vchan->chanops_voiced);
#endif
- burst_members(client_p,&chptr->voiced);
- burst_members(client_p,&chptr->halfops);
- burst_members(client_p,&chptr->peons);
- send_channel_modes(client_p, chptr);
+ burst_members(client_p, &vchan->voiced);
+ burst_members(client_p, &vchan->halfops);
+ burst_members(client_p, &vchan->peons);
+ send_channel_modes(client_p, vchan);
hinfo.chptr = chptr;
hinfo.client = client_p;
hook_call_event("burst_channel", &hinfo);
}
-
- if(IsVchanTop(chptr))
- {
- for ( ptr = chptr->vchan_list.head; ptr;
- ptr = ptr->next)
- {
- vchan = ptr->data;
- if(vchan->users != 0)
- {
- burst_members(client_p,&vchan->chanops);
-#ifdef REQUIRE_OANDV
- burst_members(client_p,&vchan->chanops_voiced);
-#endif
- burst_members(client_p,&vchan->voiced);
- burst_members(client_p,&vchan->halfops);
- burst_members(client_p,&vchan->peons);
- send_channel_modes(client_p, vchan);
- hinfo.chptr = chptr;
- hinfo.client = client_p;
- hook_call_event("burst_channel", &hinfo);
- }
- }
- }
+ }
}
+ }
/*
- ** also send out those that are not on any channel
- */
+ ** also send out those that are not on any channel
+ */
for (target_p = &me; target_p; target_p = target_p->prev)
+ {
+ if (target_p->serial != current_serial)
{
- if (target_p->serial != current_serial)
- {
- target_p->serial = current_serial;
- if (target_p->from != client_p)
- sendnick_TS(client_p, target_p);
- }
+ target_p->serial = current_serial;
+ if (target_p->from != client_p)
+ sendnick_TS(client_p, target_p);
}
+ }
/* We send the time we started the burst, and let the remote host determine an EOB time,
- ** as otherwise we end up sending a EOB of 0 Sending here means it gets sent last -- fl
- */
+ ** as otherwise we end up sending a EOB of 0 Sending here means it gets sent last -- fl
+ */
/* Its simpler to just send EOB and use the time its been connected.. --fl_ */
- if(IsCapable(client_p, CAP_EOB))
+ if (IsCapable(client_p, CAP_EOB))
sendto_one(client_p, ":%s EOB", me.name);
}
struct Channel *chptr;
for (chptr = GlobalChannelList; chptr; chptr = chptr->nextch)
- {
- sendto_one(client_p, ":%s CBURST %s",
- me.name, chptr->chname);
- }
+ {
+ sendto_one(client_p, ":%s CBURST %s", me.name, chptr->chname);
+ }
}
/*
void
burst_channel(struct Client *client_p, struct Channel *chptr)
{
- dlink_node *ptr;
- struct Channel* vchan;
+ dlink_node *ptr;
+ struct Channel *vchan;
- burst_ll_members(client_p,&chptr->chanops);
+ burst_ll_members(client_p, &chptr->chanops);
#ifdef REQUIRE_OANDV
burst_ll_members(client_p, &chptr->chanops_voiced);
#endif
- burst_ll_members(client_p,&chptr->voiced);
- burst_ll_members(client_p,&chptr->halfops);
- burst_ll_members(client_p,&chptr->peons);
+ burst_ll_members(client_p, &chptr->voiced);
+ burst_ll_members(client_p, &chptr->halfops);
+ burst_ll_members(client_p, &chptr->peons);
send_channel_modes(client_p, chptr);
- add_lazylinkchannel(client_p,chptr);
+ add_lazylinkchannel(client_p, chptr);
- if(chptr->topic[0])
- {
- sendto_one(client_p, ":%s TOPIC %s %s %lu :%s",
- me.name,
- chptr->chname,
- chptr->topic_info,
- (unsigned long) chptr->topic_time,
- chptr->topic);
- }
+ if (chptr->topic[0])
+ {
+ sendto_one(client_p, ":%s TOPIC %s %s %lu :%s",
+ me.name,
+ chptr->chname,
+ chptr->topic_info,
+ (unsigned long)chptr->topic_time, chptr->topic);
+ }
- if(IsVchanTop(chptr))
+ if (IsVchanTop(chptr))
+ {
+ for (ptr = chptr->vchan_list.head; ptr; ptr = ptr->next)
{
- for ( ptr = chptr->vchan_list.head; ptr; ptr = ptr->next)
- {
- vchan = ptr->data;
- burst_ll_members(client_p,&vchan->chanops);
+ vchan = ptr->data;
+ burst_ll_members(client_p, &vchan->chanops);
#ifdef REQUIRE_OANDV
- burst_ll_members(client_p,&vchan->chanops_voiced);
+ burst_ll_members(client_p, &vchan->chanops_voiced);
#endif
- burst_ll_members(client_p,&vchan->voiced);
- burst_ll_members(client_p,&vchan->halfops);
- burst_ll_members(client_p,&vchan->peons);
- send_channel_modes(client_p, vchan);
- add_lazylinkchannel(client_p,vchan);
-
- if(vchan->topic[0])
- {
- sendto_one(client_p, ":%s TOPIC %s %s %lu :%s",
- me.name,
- vchan->chname,
- vchan->topic_info,
- (unsigned long) vchan->topic_time,
- vchan->topic);
- }
- }
+ burst_ll_members(client_p, &vchan->voiced);
+ burst_ll_members(client_p, &vchan->halfops);
+ burst_ll_members(client_p, &vchan->peons);
+ send_channel_modes(client_p, vchan);
+ add_lazylinkchannel(client_p, vchan);
+
+ if (vchan->topic[0])
+ {
+ sendto_one(client_p, ":%s TOPIC %s %s %lu :%s",
+ me.name,
+ vchan->chname,
+ vchan->topic_info,
+ (unsigned long)vchan->topic_time, vchan->topic);
+ }
}
+ }
}
/*
void
add_lazylinkclient(struct Client *client_p, struct Client *source_p)
{
- assert(client_p->localClient != NULL);
- source_p->lazyLinkClientExists |= client_p->localClient->serverMask;
+ assert(client_p->localClient != NULL);
+ source_p->lazyLinkClientExists |= client_p->localClient->serverMask;
}
/*
struct Channel *chptr;
struct Client *target_p;
unsigned long clear_mask;
-
- if (!mask) /* On 0 mask, don't do anything */
- return;
-
+
+ if (!mask) /* On 0 mask, don't do anything */
+ return;
+
clear_mask = ~mask;
-
+
freeMask |= mask;
-
+
for (ptr = lazylink_channels.head; ptr; ptr = next_ptr)
{
- next_ptr = ptr->next;
- chptr = ptr->data;
- chptr->lazyLinkChannelExists &= clear_mask;
- if (chptr->lazyLinkChannelExists == 0)
- {
- dlinkDelete(ptr, &lazylink_channels);
- free_dlink_node(ptr);
- }
+ next_ptr = ptr->next;
+ chptr = ptr->data;
+ chptr->lazyLinkChannelExists &= clear_mask;
+ if (chptr->lazyLinkChannelExists == 0)
+ {
+ dlinkDelete(ptr, &lazylink_channels);
+ free_dlink_node(ptr);
+ }
}
for (target_p = GlobalClientList; target_p; target_p = target_p->next)
- target_p->lazyLinkClientExists &= clear_mask;
+ target_p->lazyLinkClientExists &= clear_mask;
}
/*
* output - NONE
* side effects -
*/
-void burst_members(struct Client *client_p, dlink_list *list)
+void
+burst_members(struct Client *client_p, dlink_list * list)
{
struct Client *target_p;
dlink_node *ptr;
for (ptr = list->head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
+ if (target_p->serial != current_serial)
{
- target_p = ptr->data;
- if (target_p->serial != current_serial)
- {
- target_p->serial = current_serial;
- if (target_p->from != client_p)
- sendnick_TS(client_p, target_p);
- }
+ target_p->serial = current_serial;
+ if (target_p->from != client_p)
+ sendnick_TS(client_p, target_p);
}
+ }
}
/*
* output - NONE
* side effects - This version also has to check the bitmap for lazylink
*/
-void burst_ll_members(struct Client *client_p, dlink_list *list)
+void
+burst_ll_members(struct Client *client_p, dlink_list * list)
{
struct Client *target_p;
dlink_node *ptr;
for (ptr = list->head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
+ if ((target_p->lazyLinkClientExists & client_p->localClient->
+ serverMask) == 0)
{
- target_p = ptr->data;
- if ((target_p->lazyLinkClientExists & client_p->localClient->serverMask) == 0)
- {
- if (target_p->from != client_p)
- {
- add_lazylinkclient(client_p,target_p);
- sendnick_TS(client_p, target_p);
- }
- }
+ if (target_p->from != client_p)
+ {
+ add_lazylinkclient(client_p, target_p);
+ sendnick_TS(client_p, target_p);
+ }
}
+ }
}
/*
* output - none
* side effects -
*/
-void set_autoconn(struct Client *source_p,char *parv0,char *name,int newval)
+void
+set_autoconn(struct Client *source_p, char *parv0, char *name, int newval)
{
struct ConfItem *aconf;
- if(name && (aconf= find_conf_by_name(name, CONF_SERVER)))
- {
- if (newval)
- aconf->flags |= CONF_FLAGS_ALLOW_AUTO_CONN;
- else
- aconf->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN;
-
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s has changed AUTOCONN for %s to %i",
- parv0, name, newval);
- sendto_one(source_p,
- ":%s NOTICE %s :AUTOCONN for %s is now set to %i",
- me.name, parv0, name, newval);
- }
+ if (name && (aconf = find_conf_by_name(name, CONF_SERVER)))
+ {
+ if (newval)
+ aconf->flags |= CONF_FLAGS_ALLOW_AUTO_CONN;
+ else
+ aconf->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN;
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s has changed AUTOCONN for %s to %i",
+ parv0, name, newval);
+ sendto_one(source_p,
+ ":%s NOTICE %s :AUTOCONN for %s is now set to %i",
+ me.name, parv0, name, newval);
+ }
else if (name)
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Can't find %s",
- me.name, parv0, name);
- }
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Can't find %s", me.name, parv0, name);
+ }
else
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Please specify a server name!",
- me.name, parv0);
- }
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :Please specify a server name!",
+ me.name, parv0);
+ }
}
-void initServerMask(void)
+void
+initServerMask(void)
{
freeMask = 0xFFFFFFFFL;
}
* output - unsigned long next unused mask for use in LL
* side effects -
*/
-unsigned long nextFreeMask()
+unsigned long
+nextFreeMask()
{
int i;
unsigned long mask;
mask = 1;
- for(i=0;i<32;i++)
+ for (i = 0; i < 32; i++)
+ {
+ if (mask & freeMask)
{
- if( mask & freeMask )
- {
- freeMask &= ~mask;
- return(mask);
- }
- mask <<= 1;
+ freeMask &= ~mask;
+ return (mask);
}
- return 0L; /* watch this special case ... */
+ mask <<= 1;
+ }
+ return 0L; /* watch this special case ... */
}
/*
int
serv_connect(struct ConfItem *aconf, struct Client *by)
{
- struct Client *client_p;
- int fd;
- char buf[HOSTIPLEN];
- /* Make sure aconf is useful */
- assert(aconf != NULL);
+ struct Client *client_p;
+ int fd;
+ char buf[HOSTIPLEN];
+ /* Make sure aconf is useful */
+ assert(aconf != NULL);
- /* log */
- inetntop(DEF_FAM, &IN_ADDR(aconf->ipnum), buf, HOSTIPLEN);
- ilog(L_NOTICE, "Connect to %s[%s] @%s", aconf->user, aconf->host,
- buf);
+ /* log */
+ inetntop(DEF_FAM, &IN_ADDR(aconf->ipnum), buf, HOSTIPLEN);
+ ilog(L_NOTICE, "Connect to %s[%s] @%s", aconf->user, aconf->host, buf);
- /*
- * Make sure this server isn't already connected
- * Note: aconf should ALWAYS be a valid C: line
- */
- if ((client_p = find_server(aconf->name)))
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Server %s already present from %s",
- aconf->name, get_client_name(client_p, SHOW_IP));
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Server %s already present from %s",
- aconf->name, get_client_name(client_p, MASK_IP));
- if (by && IsPerson(by) && !MyClient(by))
- sendto_one(by, ":%s NOTICE %s :Server %s already present from %s",
- me.name, by->name, aconf->name,
- get_client_name(client_p, MASK_IP));
- return 0;
- }
-
- /* create a socket for the server connection */
- if ((fd = comm_open(DEF_FAM, SOCK_STREAM, 0, NULL)) < 0)
- {
- /* Eek, failure to create the socket */
- report_error(L_ALL, "opening stream socket to %s: %s", aconf->name, errno);
- return 0;
- }
+ /*
+ * Make sure this server isn't already connected
+ * Note: aconf should ALWAYS be a valid C: line
+ */
+ if ((client_p = find_server(aconf->name)))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Server %s already present from %s",
+ aconf->name, get_client_name(client_p, SHOW_IP));
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Server %s already present from %s",
+ aconf->name, get_client_name(client_p, MASK_IP));
+ if (by && IsPerson(by) && !MyClient(by))
+ sendto_one(by, ":%s NOTICE %s :Server %s already present from %s",
+ me.name, by->name, aconf->name,
+ get_client_name(client_p, MASK_IP));
+ return 0;
+ }
- /* servernames are always guaranteed under HOSTLEN chars */
- fd_note(fd, "Server: %s", aconf->name);
+ /* create a socket for the server connection */
+ if ((fd = comm_open(DEF_FAM, SOCK_STREAM, 0, NULL)) < 0)
+ {
+ /* Eek, failure to create the socket */
+ report_error(L_ALL, "opening stream socket to %s: %s", aconf->name,
+ errno);
+ return 0;
+ }
- /* Create a local client */
- client_p = make_client(NULL);
+ /* servernames are always guaranteed under HOSTLEN chars */
+ fd_note(fd, "Server: %s", aconf->name);
- /* Copy in the server, hostname, fd */
- strncpy_irc(client_p->name, aconf->name, HOSTLEN);
- strncpy_irc(client_p->host, aconf->host, HOSTLEN);
- inetntop(DEF_FAM, &IN_ADDR(aconf->ipnum), client_p->localClient->sockhost, HOSTIPLEN);
- client_p->fd = fd;
+ /* Create a local client */
+ client_p = make_client(NULL);
- /*
- * Set up the initial server evilness, ripped straight from
- * connect_server(), so don't blame me for it being evil.
- * -- adrian
- */
+ /* Copy in the server, hostname, fd */
+ strncpy_irc(client_p->name, aconf->name, HOSTLEN);
+ strncpy_irc(client_p->host, aconf->host, HOSTLEN);
+ inetntop(DEF_FAM, &IN_ADDR(aconf->ipnum), client_p->localClient->sockhost,
+ HOSTIPLEN);
+ client_p->fd = fd;
- if (!set_non_blocking(client_p->fd))
- {
- report_error(L_ADMIN, NONB_ERROR_MSG, get_client_name(client_p, SHOW_IP), errno);
- report_error(L_OPER, NONB_ERROR_MSG, get_client_name(client_p, MASK_IP), errno);
- }
+ /*
+ * Set up the initial server evilness, ripped straight from
+ * connect_server(), so don't blame me for it being evil.
+ * -- adrian
+ */
- if (!set_sock_buffers(client_p->fd, READBUF_SIZE))
- {
- report_error(L_ADMIN, SETBUF_ERROR_MSG, get_client_name(client_p, SHOW_IP), errno);
- report_error(L_OPER, SETBUF_ERROR_MSG, get_client_name(client_p, MASK_IP), errno);
- }
+ if (!set_non_blocking(client_p->fd))
+ {
+ report_error(L_ADMIN, NONB_ERROR_MSG, get_client_name(client_p, SHOW_IP),
+ errno);
+ report_error(L_OPER, NONB_ERROR_MSG, get_client_name(client_p, MASK_IP),
+ errno);
+ }
- /*
- * Attach config entries to client here rather than in
- * serv_connect_callback(). This to avoid null pointer references.
- */
- if (!attach_connect_block(client_p, aconf->name, aconf->host))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Host %s is not enabled for connecting:no C/N-line",
- aconf->name);
- if (by && IsPerson(by) && !MyClient(by))
- sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.",
- me.name, by->name, client_p->name);
- det_confs_butmask(client_p, 0);
- free_client(client_p);
- return 0;
- }
- /*
- * at this point we have a connection in progress and C/N lines
- * attached to the client, the socket info should be saved in the
- * client and it should either be resolved or have a valid address.
- *
- * The socket has been connected or connect is in progress.
- */
- make_server(client_p);
- if (by && IsPerson(by))
- {
- strcpy(client_p->serv->by, by->name);
- if (client_p->serv->user)
- free_user(client_p->serv->user, NULL);
- client_p->serv->user = by->user;
- by->user->refcnt++;
- }
- else
- {
- strcpy(client_p->serv->by, "AutoConn.");
- if (client_p->serv->user)
- free_user(client_p->serv->user, NULL);
- client_p->serv->user = NULL;
- }
- client_p->serv->up = me.name;
- SetConnecting(client_p);
- add_client_to_list(client_p);
- /* from def_fam */
- client_p->localClient->aftype = aconf->aftype;
-
- /* Now, initiate the connection */
- /* XXX assume that a non 0 type means a specific bind address
- * for this connect.
- */
- if((aconf->aftype == AF_INET) && aconf->my_ipnum.sins.sin.s_addr)
- {
- struct irc_sockaddr ipn;
- memset(&ipn, 0, sizeof(struct irc_sockaddr));
- S_FAM(ipn) = DEF_FAM;
- S_PORT(ipn) = 0;
+ if (!set_sock_buffers(client_p->fd, READBUF_SIZE))
+ {
+ report_error(L_ADMIN, SETBUF_ERROR_MSG,
+ get_client_name(client_p, SHOW_IP), errno);
+ report_error(L_OPER, SETBUF_ERROR_MSG, get_client_name(client_p, MASK_IP),
+ errno);
+ }
+
+ /*
+ * Attach config entries to client here rather than in
+ * serv_connect_callback(). This to avoid null pointer references.
+ */
+ if (!attach_connect_block(client_p, aconf->name, aconf->host))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Host %s is not enabled for connecting:no C/N-line",
+ aconf->name);
+ if (by && IsPerson(by) && !MyClient(by))
+ sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.",
+ me.name, by->name, client_p->name);
+ det_confs_butmask(client_p, 0);
+ free_client(client_p);
+ return 0;
+ }
+ /*
+ * at this point we have a connection in progress and C/N lines
+ * attached to the client, the socket info should be saved in the
+ * client and it should either be resolved or have a valid address.
+ *
+ * The socket has been connected or connect is in progress.
+ */
+ make_server(client_p);
+ if (by && IsPerson(by))
+ {
+ strcpy(client_p->serv->by, by->name);
+ if (client_p->serv->user)
+ free_user(client_p->serv->user, NULL);
+ client_p->serv->user = by->user;
+ by->user->refcnt++;
+ }
+ else
+ {
+ strcpy(client_p->serv->by, "AutoConn.");
+ if (client_p->serv->user)
+ free_user(client_p->serv->user, NULL);
+ client_p->serv->user = NULL;
+ }
+ client_p->serv->up = me.name;
+ SetConnecting(client_p);
+ add_client_to_list(client_p);
+ /* from def_fam */
+ client_p->localClient->aftype = aconf->aftype;
+
+ /* Now, initiate the connection */
+ /* XXX assume that a non 0 type means a specific bind address
+ * for this connect.
+ */
+ if ((aconf->aftype == AF_INET) && aconf->my_ipnum.sins.sin.s_addr)
+ {
+ struct irc_sockaddr ipn;
+ memset(&ipn, 0, sizeof(struct irc_sockaddr));
+ S_FAM(ipn) = DEF_FAM;
+ S_PORT(ipn) = 0;
- copy_s_addr(S_ADDR(ipn), IN_ADDR(aconf->my_ipnum));
+ copy_s_addr(S_ADDR(ipn), IN_ADDR(aconf->my_ipnum));
- comm_connect_tcp(client_p->fd, aconf->host, aconf->port,
- (struct sockaddr *)&SOCKADDR(ipn), sizeof(struct irc_sockaddr),
- serv_connect_callback, client_p, aconf->aftype, 30);
- }
- else if((aconf->aftype == AF_INET) && ServerInfo.specific_ipv4_vhost)
- {
- struct irc_sockaddr ipn;
- memset(&ipn, 0, sizeof(struct irc_sockaddr));
- S_FAM(ipn) = DEF_FAM;
- S_PORT(ipn) = 0;
+ comm_connect_tcp(client_p->fd, aconf->host, aconf->port,
+ (struct sockaddr *)&SOCKADDR(ipn),
+ sizeof(struct irc_sockaddr), serv_connect_callback,
+ client_p, aconf->aftype, 30);
+ }
+ else if ((aconf->aftype == AF_INET) && ServerInfo.specific_ipv4_vhost)
+ {
+ struct irc_sockaddr ipn;
+ memset(&ipn, 0, sizeof(struct irc_sockaddr));
+ S_FAM(ipn) = DEF_FAM;
+ S_PORT(ipn) = 0;
- copy_s_addr(S_ADDR(ipn), IN_ADDR(ServerInfo.ip));
+ copy_s_addr(S_ADDR(ipn), IN_ADDR(ServerInfo.ip));
- comm_connect_tcp(client_p->fd, aconf->host, aconf->port,
- (struct sockaddr *)&SOCKADDR(ipn), sizeof(struct irc_sockaddr),
- serv_connect_callback, client_p, aconf->aftype, 30);
- }
+ comm_connect_tcp(client_p->fd, aconf->host, aconf->port,
+ (struct sockaddr *)&SOCKADDR(ipn),
+ sizeof(struct irc_sockaddr), serv_connect_callback,
+ client_p, aconf->aftype, 30);
+ }
#ifdef IPV6
- else if((aconf->aftype == AF_INET6) && ServerInfo.specific_ipv6_vhost)
- {
- struct irc_sockaddr ipn;
- memset(&ipn, 0, sizeof(struct irc_sockaddr));
- S_FAM(ipn) = AF_INET6;
- S_PORT(ipn) = 0;
-
- copy_s_addr(S_ADDR(ipn), IN_ADDR(ServerInfo.ip6));
-
- comm_connect_tcp(client_p->fd, aconf->host, aconf->port,
- (struct sockaddr *)&SOCKADDR(ipn), sizeof(struct irc_sockaddr),
- serv_connect_callback, client_p, aconf->aftype, 30);
- }
+ else if ((aconf->aftype == AF_INET6) && ServerInfo.specific_ipv6_vhost)
+ {
+ struct irc_sockaddr ipn;
+ memset(&ipn, 0, sizeof(struct irc_sockaddr));
+ S_FAM(ipn) = AF_INET6;
+ S_PORT(ipn) = 0;
+
+ copy_s_addr(S_ADDR(ipn), IN_ADDR(ServerInfo.ip6));
+
+ comm_connect_tcp(client_p->fd, aconf->host, aconf->port,
+ (struct sockaddr *)&SOCKADDR(ipn),
+ sizeof(struct irc_sockaddr), serv_connect_callback,
+ client_p, aconf->aftype, 30);
+ }
#endif
- else
- {
- comm_connect_tcp(client_p->fd, aconf->host, aconf->port, NULL, 0,
- serv_connect_callback, client_p, aconf->aftype, 30);
- }
+ else
+ {
+ comm_connect_tcp(client_p->fd, aconf->host, aconf->port, NULL, 0,
+ serv_connect_callback, client_p, aconf->aftype, 30);
+ }
- return 1;
+ return 1;
}
/*
static void
serv_connect_callback(int fd, int status, void *data)
{
- struct Client *client_p = data;
- struct ConfItem *aconf;
+ struct Client *client_p = data;
+ struct ConfItem *aconf;
- /* First, make sure its a real client! */
- assert(client_p != NULL);
- assert(client_p->fd == fd);
+ /* First, make sure its a real client! */
+ assert(client_p != NULL);
+ assert(client_p->fd == fd);
- /* Next, for backward purposes, record the ip of the server */
- copy_s_addr(IN_ADDR(client_p->localClient->ip), S_ADDR(fd_table[fd].connect.hostaddr));
- /* Check the status */
- if (status != COMM_OK)
- {
- /* We have an error, so report it and quit */
- /* Admins get to see any IP, mere opers don't *sigh*
- */
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Error connecting to %s[%s]: %s", client_p->name,
- client_p->host, comm_errstr(status));
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Error connecting to %s: %s",
- client_p->name, comm_errstr(status));
- client_p->flags |= FLAGS_DEADSOCKET;
- exit_client(client_p, client_p, &me, comm_errstr(status));
- return;
- }
+ /* Next, for backward purposes, record the ip of the server */
+ copy_s_addr(IN_ADDR(client_p->localClient->ip),
+ S_ADDR(fd_table[fd].connect.hostaddr));
+ /* Check the status */
+ if (status != COMM_OK)
+ {
+ /* We have an error, so report it and quit */
+ /* Admins get to see any IP, mere opers don't *sigh*
+ */
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Error connecting to %s[%s]: %s", client_p->name,
+ client_p->host, comm_errstr(status));
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "Error connecting to %s: %s",
+ client_p->name, comm_errstr(status));
+ client_p->flags |= FLAGS_DEADSOCKET;
+ exit_client(client_p, client_p, &me, comm_errstr(status));
+ return;
+ }
- /* COMM_OK, so continue the connection procedure */
- /* Get the C/N lines */
- aconf = find_conf_name(&client_p->localClient->confs,
- client_p->name, CONF_SERVER);
- if (!aconf)
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "Lost C-Line for %s", get_client_name(client_p, HIDE_IP));
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "Lost C-Line for %s", get_client_name(client_p, MASK_IP));
- exit_client(client_p, client_p, &me, "Lost C-line");
- return;
- }
- /* Next, send the initial handshake */
- SetHandshake(client_p);
+ /* COMM_OK, so continue the connection procedure */
+ /* Get the C/N lines */
+ aconf = find_conf_name(&client_p->localClient->confs,
+ client_p->name, CONF_SERVER);
+ if (!aconf)
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "Lost C-Line for %s", get_client_name(client_p,
+ HIDE_IP));
+ sendto_realops_flags(FLAGS_ALL, L_OPER, "Lost C-Line for %s",
+ get_client_name(client_p, MASK_IP));
+ exit_client(client_p, client_p, &me, "Lost C-line");
+ return;
+ }
+ /* Next, send the initial handshake */
+ SetHandshake(client_p);
#ifdef HAVE_LIBCRYPTO
- /* Handle all CRYPTLINK links in cryptlink_init */
- if (IsConfCryptLink(aconf))
- {
- cryptlink_init(client_p, aconf, fd);
- return;
- }
+ /* Handle all CRYPTLINK links in cryptlink_init */
+ if (IsConfCryptLink(aconf))
+ {
+ cryptlink_init(client_p, aconf, fd);
+ return;
+ }
#endif
-
- /*
- * jdc -- Check and send spasswd, not passwd.
- */
- if (!EmptyString(aconf->spasswd))
- {
- sendto_one(client_p, "PASS %s :TS", aconf->spasswd);
- }
-
- /*
- * Pass my info to the new server
- *
- * If trying to negotiate LazyLinks, pass on CAP_LL
- * If this is a HUB, pass on CAP_HUB
- */
- send_capabilities(client_p, aconf, default_server_capabs
- | ((aconf->flags & CONF_FLAGS_LAZY_LINK) ? CAP_LL : 0)
- | ((aconf->flags & CONF_FLAGS_COMPRESSED) ? CAP_ZIP_SUPPORTED : 0)
- | (ServerInfo.hub ? CAP_HUB : 0),
- 0);
+ /*
+ * jdc -- Check and send spasswd, not passwd.
+ */
+ if (!EmptyString(aconf->spasswd))
+ {
+ sendto_one(client_p, "PASS %s :TS", aconf->spasswd);
+ }
- sendto_one(client_p, "SERVER %s 1 :%s%s",
- my_name_for_link(me.name, aconf),
- ConfigServerHide.hidden ? "(H) " : "",
- me.info);
+ /*
+ * Pass my info to the new server
+ *
+ * If trying to negotiate LazyLinks, pass on CAP_LL
+ * If this is a HUB, pass on CAP_HUB
+ */
- /*
- * If we've been marked dead because a send failed, just exit
- * here now and save everyone the trouble of us ever existing.
- */
- if (IsDead(client_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN,
- "%s[%s] went dead during handshake",
- client_p->name,
- client_p->host);
- sendto_realops_flags(FLAGS_ALL, L_OPER,
- "%s went dead during handshake", client_p->name);
- exit_client(client_p, client_p, &me, "Went dead during handshake");
- return;
- }
+ send_capabilities(client_p, aconf, default_server_capabs
+ | ((aconf->flags & CONF_FLAGS_LAZY_LINK) ? CAP_LL : 0)
+ | ((aconf->flags & CONF_FLAGS_COMPRESSED) ?
+ CAP_ZIP_SUPPORTED : 0) | (ServerInfo.
+ hub ? CAP_HUB : 0), 0);
+
+ sendto_one(client_p, "SERVER %s 1 :%s%s",
+ my_name_for_link(me.name, aconf),
+ ConfigServerHide.hidden ? "(H) " : "", me.info);
+
+ /*
+ * If we've been marked dead because a send failed, just exit
+ * here now and save everyone the trouble of us ever existing.
+ */
+ if (IsDead(client_p))
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN,
+ "%s[%s] went dead during handshake",
+ client_p->name, client_p->host);
+ sendto_realops_flags(FLAGS_ALL, L_OPER,
+ "%s went dead during handshake", client_p->name);
+ exit_client(client_p, client_p, &me, "Went dead during handshake");
+ return;
+ }
- /* don't move to serv_list yet -- we haven't sent a burst! */
+ /* don't move to serv_list yet -- we haven't sent a burst! */
- /* If we get here, we're ok, so lets start reading some data */
- comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ, read_packet,
- client_p, 0);
+ /* If we get here, we're ok, so lets start reading some data */
+ comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ, read_packet,
+ client_p, 0);
}
#ifdef HAVE_LIBCRYPTO
/*
* sends a CRYPTLINK SERV command.
*/
-void cryptlink_init(struct Client *client_p,
- struct ConfItem *aconf,
- int fd)
+void
+cryptlink_init(struct Client *client_p, struct ConfItem *aconf, int fd)
{
char *encrypted;
char *key_to_send;
int enc_len;
/* get key */
- if ( (!ServerInfo.rsa_private_key) ||
- (!RSA_check_key(ServerInfo.rsa_private_key)) )
+ if ((!ServerInfo.rsa_private_key) ||
+ (!RSA_check_key(ServerInfo.rsa_private_key)))
{
cryptlink_error(client_p, "SERV", "Invalid RSA private key",
- "Invalid RSA private key");
+ "Invalid RSA private key");
return;
}
if (!aconf->rsa_public_key)
{
cryptlink_error(client_p, "SERV", "Invalid RSA public key",
- "Invalid RSA public key");
+ "Invalid RSA public key");
return;
}
if (get_randomness((unsigned char *)randkey, CIPHERKEYLEN) != 1)
{
cryptlink_error(client_p, "SERV", "Couldn't generate keyphrase",
- "Couldn't generate keyphrase");
+ "Couldn't generate keyphrase");
return;
}
enc_len = RSA_public_encrypt(CIPHERKEYLEN,
(unsigned char *)randkey,
(unsigned char *)encrypted,
- aconf->rsa_public_key,
- RSA_PKCS1_PADDING);
+ aconf->rsa_public_key, RSA_PKCS1_PADDING);
memcpy(client_p->localClient->in_key, randkey, CIPHERKEYLEN);
report_crypto_errors();
MyFree(encrypted);
cryptlink_error(client_p, "SERV", "Couldn't encrypt data",
- "Couldn't encrypt data");
+ "Couldn't encrypt data");
return;
}
{
MyFree(encrypted);
cryptlink_error(client_p, "SERV", "Couldn't base64 encode key",
- "Couldn't base64 encode key");
+ "Couldn't base64 encode key");
return;
}
send_capabilities(client_p, aconf, default_server_capabs
- | ((aconf->flags & CONF_FLAGS_LAZY_LINK) ? CAP_LL : 0)
- | ((aconf->flags & CONF_FLAGS_COMPRESSED) ? CAP_ZIP_SUPPORTED : 0)
- | (ServerInfo.hub ? CAP_HUB : 0),
- CAP_ENC_MASK);
+ | ((aconf->flags & CONF_FLAGS_LAZY_LINK) ? CAP_LL : 0)
+ | ((aconf->flags & CONF_FLAGS_COMPRESSED) ?
+ CAP_ZIP_SUPPORTED : 0) | (ServerInfo.
+ hub ? CAP_HUB : 0),
+ CAP_ENC_MASK);
sendto_one(client_p, "CRYPTLINK SERV %s %s :%s%s",
my_name_for_link(me.name, aconf), key_to_send,
if (IsDead(client_p))
{
cryptlink_error(client_p, "SERV", "Went dead during handshake",
- "Went dead during handshake");
+ "Went dead during handshake");
return;
}
}
}
-void cryptlink_error(struct Client *client_p, char *type,
- char *reason, char *client_reason)
+void
+cryptlink_error(struct Client *client_p, char *type,
+ char *reason, char *client_reason)
{
sendto_realops_flags(FLAGS_ALL, L_ADMIN, "%s: CRYPTLINK %s error - %s",
get_client_name(client_p, SHOW_IP), type, reason);
sendto_realops_flags(FLAGS_ALL, L_OPER, "%s: CRYPTLINK %s error - %s",
get_client_name(client_p, MASK_IP), type, reason);
ilog(L_ERROR, "%s: CRYPTLINK %s error - %s",
- get_client_name(client_p, SHOW_IP), type, reason);
+ get_client_name(client_p, SHOW_IP), type, reason);
/*
* If client_reason isn't NULL, then exit the client with the message
* defined in the call.
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_stats.c,v 1.1 2002/01/04 09:14:43 a1kmm Exp $
+ * $Id: s_stats.c,v 1.2 2002/01/04 11:06:43 a1kmm Exp $
*/
#include <sys/types.h>
/*
* stats stuff
*/
-static struct ServerStatistics ircst;
-struct ServerStatistics* ServerStats = &ircst;
+static struct ServerStatistics ircst;
+struct ServerStatistics *ServerStats = &ircst;
-void init_stats()
+void
+init_stats()
{
memset(&ircst, 0, sizeof(ircst));
}
* output - NONE
* side effects -
*/
-void tstats(struct Client *source_p)
+void
+tstats(struct Client *source_p)
{
- struct Client* target_p;
- struct ServerStatistics* sp;
- struct ServerStatistics tmp;
+ struct Client *target_p;
+ struct ServerStatistics *sp;
+ struct ServerStatistics tmp;
dlink_node *ptr;
sp = &tmp;
memcpy(sp, ServerStats, sizeof(struct ServerStatistics));
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
- {
- target_p = ptr->data;
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
- sp->is_sbs += target_p->localClient->sendB;
- sp->is_sbr += target_p->localClient->receiveB;
- sp->is_sks += target_p->localClient->sendK;
- sp->is_skr += target_p->localClient->receiveK;
- sp->is_sti += CurrentTime - target_p->firsttime;
- sp->is_sv++;
- if (sp->is_sbs > 1023)
- {
- sp->is_sks += (sp->is_sbs >> 10);
- sp->is_sbs &= 0x3ff;
- }
- if (sp->is_sbr > 1023)
- {
- sp->is_skr += (sp->is_sbr >> 10);
- sp->is_sbr &= 0x3ff;
- }
+ sp->is_sbs += target_p->localClient->sendB;
+ sp->is_sbr += target_p->localClient->receiveB;
+ sp->is_sks += target_p->localClient->sendK;
+ sp->is_skr += target_p->localClient->receiveK;
+ sp->is_sti += CurrentTime - target_p->firsttime;
+ sp->is_sv++;
+ if (sp->is_sbs > 1023)
+ {
+ sp->is_sks += (sp->is_sbs >> 10);
+ sp->is_sbs &= 0x3ff;
}
-
- for(ptr = lclient_list.head; ptr; ptr = ptr->next)
+ if (sp->is_sbr > 1023)
{
- target_p = ptr->data;
-
- sp->is_cbs += target_p->localClient->sendB;
- sp->is_cbr += target_p->localClient->receiveB;
- sp->is_cks += target_p->localClient->sendK;
- sp->is_ckr += target_p->localClient->receiveK;
- sp->is_cti += CurrentTime - target_p->firsttime;
- sp->is_cl++;
- if (sp->is_cbs > 1023)
- {
- sp->is_cks += (sp->is_cbs >> 10);
- sp->is_cbs &= 0x3ff;
- }
- if (sp->is_cbr > 1023)
- {
- sp->is_ckr += (sp->is_cbr >> 10);
- sp->is_cbr &= 0x3ff;
- }
-
+ sp->is_skr += (sp->is_sbr >> 10);
+ sp->is_sbr &= 0x3ff;
}
+ }
+
+ for (ptr = lclient_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
- for(ptr = unknown_list.head; ptr; ptr = ptr->next)
+ sp->is_cbs += target_p->localClient->sendB;
+ sp->is_cbr += target_p->localClient->receiveB;
+ sp->is_cks += target_p->localClient->sendK;
+ sp->is_ckr += target_p->localClient->receiveK;
+ sp->is_cti += CurrentTime - target_p->firsttime;
+ sp->is_cl++;
+ if (sp->is_cbs > 1023)
{
- sp->is_ni++;
+ sp->is_cks += (sp->is_cbs >> 10);
+ sp->is_cbs &= 0x3ff;
}
+ if (sp->is_cbr > 1023)
+ {
+ sp->is_ckr += (sp->is_cbr >> 10);
+ sp->is_cbr &= 0x3ff;
+ }
+
+ }
+
+ for (ptr = unknown_list.head; ptr; ptr = ptr->next)
+ {
+ sp->is_ni++;
+ }
sendto_one(source_p, ":%s %d %s :accepts %u refused %u",
me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref);
sendto_one(source_p, ":%s %d %s :unknown commands %u prefixes %u",
- me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco, sp->is_unpf);
+ me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco,
+ sp->is_unpf);
sendto_one(source_p, ":%s %d %s :nick collisions %u unknown closes %u",
me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni);
- sendto_one(source_p, ":%s %d %s :wrong direction %u empty %u",
- me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
- sendto_one(source_p, ":%s %d %s :numerics seen %u mode fakes %u",
- me.name, RPL_STATSDEBUG, source_p->name, sp->is_num, sp->is_fake);
- sendto_one(source_p, ":%s %d %s :auth successes %u fails %u",
- me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
+ sendto_one(source_p, ":%s %d %s :wrong direction %u empty %u", me.name,
+ RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
+ sendto_one(source_p, ":%s %d %s :numerics seen %u mode fakes %u", me.name,
+ RPL_STATSDEBUG, source_p->name, sp->is_num, sp->is_fake);
+ sendto_one(source_p, ":%s %d %s :auth successes %u fails %u", me.name,
+ RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
sendto_one(source_p, ":%s %d %s :local connections %u udp packets %u",
me.name, RPL_STATSDEBUG, source_p->name, sp->is_loc, sp->is_udp);
- sendto_one(source_p, ":%s %d %s :Client Server",
- me.name, RPL_STATSDEBUG, source_p->name);
- sendto_one(source_p, ":%s %d %s :connected %u %u",
- me.name, RPL_STATSDEBUG, source_p->name, sp->is_cl, sp->is_sv);
- sendto_one(source_p, ":%s %d %s :bytes sent %d.%uK %d.%uK",
- me.name, RPL_STATSDEBUG, source_p->name,
- (int)sp->is_cks, sp->is_cbs, (int)sp->is_sks, sp->is_sbs);
- sendto_one(source_p, ":%s %d %s :bytes recv %d.%uK %d.%uK",
- me.name, RPL_STATSDEBUG, source_p->name,
- (int)sp->is_ckr, sp->is_cbr, (int)sp->is_skr, sp->is_sbr);
- sendto_one(source_p, ":%s %d %s :time connected %d %d",
- me.name, RPL_STATSDEBUG, source_p->name, (int)sp->is_cti, (int)sp->is_sti);
+ sendto_one(source_p, ":%s %d %s :Client Server", me.name, RPL_STATSDEBUG,
+ source_p->name);
+ sendto_one(source_p, ":%s %d %s :connected %u %u", me.name, RPL_STATSDEBUG,
+ source_p->name, sp->is_cl, sp->is_sv);
+ sendto_one(source_p, ":%s %d %s :bytes sent %d.%uK %d.%uK", me.name,
+ RPL_STATSDEBUG, source_p->name, (int)sp->is_cks, sp->is_cbs,
+ (int)sp->is_sks, sp->is_sbs);
+ sendto_one(source_p, ":%s %d %s :bytes recv %d.%uK %d.%uK", me.name,
+ RPL_STATSDEBUG, source_p->name, (int)sp->is_ckr, sp->is_cbr,
+ (int)sp->is_skr, sp->is_sbr);
+ sendto_one(source_p, ":%s %d %s :time connected %d %d", me.name,
+ RPL_STATSDEBUG, source_p->name, (int)sp->is_cti,
+ (int)sp->is_sti);
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_user.c,v 1.1 2002/01/04 09:14:46 a1kmm Exp $
+ * $Id: s_user.c,v 1.2 2002/01/04 11:06:43 a1kmm Exp $
*/
#include <sys/types.h>
#include "memory.h"
#include "packet.h"
-static int valid_hostname(const char* hostname);
-static int valid_username(const char* username);
-static void report_and_set_user_flags( struct Client *, struct ConfItem * );
+static int valid_hostname(const char *hostname);
+static int valid_username(const char *username);
+static void report_and_set_user_flags(struct Client *, struct ConfItem *);
static int check_X_line(struct Client *client_p, struct Client *source_p);
void user_welcome(struct Client *source_p);
static int introduce_client(struct Client *client_p, struct Client *source_p,
- struct User *user, char *nick);
-int oper_up( struct Client *source_p, struct ConfItem *aconf );
+ struct User *user, char *nick);
+int oper_up(struct Client *source_p, struct ConfItem *aconf);
/* table of ascii char letters to corresponding bitmask */
char letter;
};
-static struct flag_item user_modes[] =
-{
+static struct flag_item user_modes[] = {
{FLAGS_ADMIN, 'a'},
- {FLAGS_BOTS, 'b'},
+ {FLAGS_BOTS, 'b'},
{FLAGS_CCONN, 'c'},
{FLAGS_DEBUG, 'd'},
- {FLAGS_FULL, 'f'},
+ {FLAGS_FULL, 'f'},
{FLAGS_CALLERID, 'g'},
{FLAGS_INVISIBLE, 'i'},
{FLAGS_SKILL, 'k'},
/* memory is cheap. map 0-255 to equivalent mode */
-int user_modes_from_c_to_bitmask[] =
-{
- /* 0x00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0F */
- /* 0x10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x1F */
- /* 0x20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x2F */
- /* 0x30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x3F */
- 0, /* @ */
- 0, /* A */
- 0, /* B */
- 0, /* C */
- 0, /* D */
- 0, /* E */
- 0, /* F */
- 0, /* G */
- 0, /* H */
- 0, /* I */
- 0, /* J */
- 0, /* K */
- 0, /* L */
- 0, /* M */
- 0, /* N */
- 0, /* O */
- 0, /* P */
- 0, /* Q */
- 0, /* R */
- 0, /* S */
- 0, /* T */
- 0, /* U */
- 0, /* V */
- 0, /* W */
- 0, /* X */
- 0, /* Y */
- 0, /* Z 0x5A */
- 0, 0, 0, 0, 0, /* 0x5F */
- /* 0x60 */ 0,
- FLAGS_ADMIN, /* a */
- FLAGS_BOTS, /* b */
- FLAGS_CCONN, /* c */
- FLAGS_DEBUG, /* d */
- 0, /* e */
- FLAGS_FULL, /* f */
- FLAGS_CALLERID, /* g */
- 0, /* h */
- FLAGS_INVISIBLE, /* i */
- 0, /* j */
- FLAGS_SKILL, /* k */
- FLAGS_LOCOPS, /* l */
- 0, /* m */
- FLAGS_NCHANGE, /* n */
- FLAGS_OPER, /* o */
- 0, /* p */
- 0, /* q */
- FLAGS_REJ, /* r */
- FLAGS_SERVNOTICE, /* s */
- 0, /* t */
- FLAGS_UNAUTH, /* u */
- 0, /* v */
- FLAGS_WALLOP, /* w */
- FLAGS_EXTERNAL, /* x */
- FLAGS_SPY, /* y */
- FLAGS_OPERWALL, /* z 0x7A */
- 0,0,0,0,0, /* 0x7B - 0x7F */
-
- /* 0x80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x9F */
- /* 0x90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x9F */
- /* 0xA0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xAF */
- /* 0xB0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xBF */
- /* 0xC0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xCF */
- /* 0xD0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xDF */
- /* 0xE0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xEF */
- /* 0xF0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xFF */
+int user_modes_from_c_to_bitmask[] = {
+ /* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0x0F */
+ /* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0x1F */
+ /* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0x2F */
+ /* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0x3F */
+ 0, /* @ */
+ 0, /* A */
+ 0, /* B */
+ 0, /* C */
+ 0, /* D */
+ 0, /* E */
+ 0, /* F */
+ 0, /* G */
+ 0, /* H */
+ 0, /* I */
+ 0, /* J */
+ 0, /* K */
+ 0, /* L */
+ 0, /* M */
+ 0, /* N */
+ 0, /* O */
+ 0, /* P */
+ 0, /* Q */
+ 0, /* R */
+ 0, /* S */
+ 0, /* T */
+ 0, /* U */
+ 0, /* V */
+ 0, /* W */
+ 0, /* X */
+ 0, /* Y */
+ 0, /* Z 0x5A */
+ 0, 0, 0, 0, 0, /* 0x5F */
+ /* 0x60 */ 0,
+ FLAGS_ADMIN, /* a */
+ FLAGS_BOTS, /* b */
+ FLAGS_CCONN, /* c */
+ FLAGS_DEBUG, /* d */
+ 0, /* e */
+ FLAGS_FULL, /* f */
+ FLAGS_CALLERID, /* g */
+ 0, /* h */
+ FLAGS_INVISIBLE, /* i */
+ 0, /* j */
+ FLAGS_SKILL, /* k */
+ FLAGS_LOCOPS, /* l */
+ 0, /* m */
+ FLAGS_NCHANGE, /* n */
+ FLAGS_OPER, /* o */
+ 0, /* p */
+ 0, /* q */
+ FLAGS_REJ, /* r */
+ FLAGS_SERVNOTICE, /* s */
+ 0, /* t */
+ FLAGS_UNAUTH, /* u */
+ 0, /* v */
+ FLAGS_WALLOP, /* w */
+ FLAGS_EXTERNAL, /* x */
+ FLAGS_SPY, /* y */
+ FLAGS_OPERWALL, /* z 0x7A */
+ 0, 0, 0, 0, 0, /* 0x7B - 0x7F */
+
+ /* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0x9F */
+ /* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0x9F */
+ /* 0xA0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0xAF */
+ /* 0xB0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0xBF */
+ /* 0xC0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0xCF */
+ /* 0xD0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0xDF */
+ /* 0xE0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0xEF */
+ /* 0xF0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ /* 0xFF */
};
/*
* output -
* side effects - display to client user counts etc.
*/
-int show_lusers(struct Client *source_p)
+int
+show_lusers(struct Client *source_p)
{
- if(!ConfigServerHide.hide_servers || IsOper(source_p))
+ if (!ConfigServerHide.hide_servers || IsOper(source_p))
sendto_one(source_p, form_str(RPL_LUSERCLIENT), me.name, source_p->name,
- (Count.total-Count.invisi), Count.invisi, Count.server);
+ (Count.total - Count.invisi), Count.invisi, Count.server);
else
sendto_one(source_p, form_str(RPL_LUSERCLIENT), me.name, source_p->name,
- (Count.total-Count.invisi), Count.invisi, 1);
+ (Count.total - Count.invisi), Count.invisi, 1);
if (Count.oper > 0)
sendto_one(source_p, form_str(RPL_LUSEROP), me.name, source_p->name,
Count.oper);
sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
me.name, source_p->name, Count.chan);
- if(!ConfigServerHide.hide_servers || IsOper(source_p))
- {
- sendto_one(source_p, form_str(RPL_LUSERME),
- me.name, source_p->name, Count.local, Count.myserver);
- sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name,
- Count.local, Count.max_loc);
- }
+ if (!ConfigServerHide.hide_servers || IsOper(source_p))
+ {
+ sendto_one(source_p, form_str(RPL_LUSERME),
+ me.name, source_p->name, Count.local, Count.myserver);
+ sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name,
+ Count.local, Count.max_loc);
+ }
else
- {
- sendto_one(source_p, form_str(RPL_LUSERME),
- me.name, source_p->name, Count.total, 0);
- sendto_one(source_p, form_str(RPL_LOCALUSERS),
- me.name, source_p->name, Count.total, Count.max_tot);
- }
+ {
+ sendto_one(source_p, form_str(RPL_LUSERME),
+ me.name, source_p->name, Count.total, 0);
+ sendto_one(source_p, form_str(RPL_LOCALUSERS),
+ me.name, source_p->name, Count.total, Count.max_tot);
+ }
sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, source_p->name,
Count.total, Count.max_tot);
- if(!ConfigServerHide.hide_servers || IsOper(source_p))
+ if (!ConfigServerHide.hide_servers || IsOper(source_p))
sendto_one(source_p, form_str(RPL_STATSCONN), me.name, source_p->name,
MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
MaxClientCount = Count.local;
if ((Count.local + Count.myserver) > MaxConnectionCount)
- MaxConnectionCount = Count.local + Count.myserver;
+ MaxConnectionCount = Count.local + Count.myserver;
return 0;
}
* output -
* side effects - display to client what we support (for them)
*/
-void show_isupport(struct Client *source_p)
+void
+show_isupport(struct Client *source_p)
{
char isupportbuffer[512];
- ircsprintf(isupportbuffer,FEATURES,FEATURESVALUES);
- sendto_one(source_p, form_str(RPL_ISUPPORT), me.name, source_p->name,
- isupportbuffer);
+ ircsprintf(isupportbuffer, FEATURES, FEATURESVALUES);
+ sendto_one(source_p, form_str(RPL_ISUPPORT), me.name, source_p->name,
+ isupportbuffer);
return;
}
** nick from local user or kill him/her...
*/
-int register_local_user(struct Client *client_p, struct Client *source_p,
- char *nick, char *username)
+int
+register_local_user(struct Client *client_p, struct Client *source_p,
+ char *nick, char *username)
{
- struct ConfItem* aconf;
- struct User* user = source_p->user;
- char tmpstr2[IRCD_BUFSIZE];
- char ipaddr[HOSTIPLEN];
- int status;
+ struct ConfItem *aconf;
+ struct User *user = source_p->user;
+ char tmpstr2[IRCD_BUFSIZE];
+ char ipaddr[HOSTIPLEN];
+ int status;
dlink_node *ptr;
dlink_node *m;
char *id;
/* If the user */
- if(ConfigFileEntry.ping_cookie && !(source_p->flags2 & FLAGS2_PING_COOKIE) && !source_p->random_ping)
+ if (ConfigFileEntry.ping_cookie && !(source_p->flags2 & FLAGS2_PING_COOKIE)
+ && !source_p->random_ping)
{
source_p->random_ping = (unsigned long)random();
sendto_one(source_p, "PING :%lu", (unsigned long)source_p->random_ping);
source_p->flags |= FLAGS_PINGSENT;
return 0;
- }
+ }
user->last = CurrentTime;
/* Straight up the maximum rate of flooding... */
source_p->localClient->allow_read = MAX_FLOOD_PER_SEC_I;
/* pointed out by Mortiis, never be too careful */
- if(strlen(username) > USERLEN)
+ if (strlen(username) > USERLEN)
username[USERLEN] = '\0';
- if( ( status = check_client(client_p, source_p, username )) < 0 )
- return(CLIENT_EXITED);
+ if ((status = check_client(client_p, source_p, username)) < 0)
+ return (CLIENT_EXITED);
- if(!valid_hostname(source_p->host))
- {
- sendto_one(source_p,":%s NOTICE %s :*** Notice -- You have an illegal character in your hostname",
- me.name, source_p->name );
+ if (!valid_hostname(source_p->host))
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :*** Notice -- You have an illegal character in your hostname",
+ me.name, source_p->name);
- strncpy(source_p->host,source_p->localClient->sockhost,HOSTIPLEN+1);
- }
+ strncpy(source_p->host, source_p->localClient->sockhost, HOSTIPLEN + 1);
+ }
ptr = source_p->localClient->confs.head;
aconf = ptr->data;
if (aconf == NULL)
- {
- (void)exit_client(client_p, source_p, &me, "*** Not Authorized");
- return(CLIENT_EXITED);
- }
+ {
+ (void)exit_client(client_p, source_p, &me, "*** Not Authorized");
+ return (CLIENT_EXITED);
+ }
if (!IsGotId(source_p))
+ {
+ if (IsNeedIdentd(aconf))
{
- if (IsNeedIdentd(aconf))
- {
- ServerStats->is_ref++;
- sendto_one(source_p,
- ":%s NOTICE %s :*** Notice -- You need to install identd to use this server",
- me.name, client_p->name);
- (void)exit_client(client_p, source_p, &me, "Install identd");
- return(CLIENT_EXITED);
- }
- else
- strncpy_irc(source_p->username, username, USERLEN);
+ ServerStats->is_ref++;
+ sendto_one(source_p,
+ ":%s NOTICE %s :*** Notice -- You need to install identd to use this server",
+ me.name, client_p->name);
+ (void)exit_client(client_p, source_p, &me, "Install identd");
+ return (CLIENT_EXITED);
+ }
+ else
+ strncpy_irc(source_p->username, username, USERLEN);
- if (IsNoTilde(aconf))
- {
- strncpy_irc(source_p->username, username, USERLEN);
- }
- else
- {
- *source_p->username = '~';
- strncpy_irc(&source_p->username[1], username, USERLEN - 1);
- }
- source_p->username[USERLEN] = '\0';
+ if (IsNoTilde(aconf))
+ {
+ strncpy_irc(source_p->username, username, USERLEN);
}
+ else
+ {
+ *source_p->username = '~';
+ strncpy_irc(&source_p->username[1], username, USERLEN - 1);
+ }
+ source_p->username[USERLEN] = '\0';
+ }
/* password check */
if (!BadPtr(aconf->passwd) &&
strcmp(source_p->localClient->passwd, aconf->passwd))
- {
- ServerStats->is_ref++;
- sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
- me.name, source_p->name);
- (void)exit_client(client_p, source_p, &me, "Bad Password");
- return(CLIENT_EXITED);
- }
- memset(source_p->localClient->passwd,0, sizeof(source_p->localClient->passwd));
+ {
+ ServerStats->is_ref++;
+ sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
+ me.name, source_p->name);
+ (void)exit_client(client_p, source_p, &me, "Bad Password");
+ return (CLIENT_EXITED);
+ }
+ memset(source_p->localClient->passwd, 0,
+ sizeof(source_p->localClient->passwd));
/* report if user has &^>= etc. and set flags as needed in source_p */
report_and_set_user_flags(source_p, aconf);
-
+
/* Limit clients */
/*
* We want to be able to have servers and F-line clients
* -Taner
*/
/* Except "F:" clients */
- if ( ( (Count.local + 1) >= (GlobalSetOptions.maxclients+MAX_BUFFER)
- ||
- (Count.local +1) >= (GlobalSetOptions.maxclients - 5) )
- &&
- !(IsExemptLimits(source_p)) )
- {
- sendto_realops_flags(FLAGS_FULL, L_ALL,
- "Too many clients, rejecting %s[%s].",
- nick, source_p->host);
-
- ServerStats->is_ref++;
- (void)exit_client(client_p, source_p, &me,
- "Sorry, server is full - try later");
- return(CLIENT_EXITED);
- }
+ if (((Count.local + 1) >= (GlobalSetOptions.maxclients + MAX_BUFFER)
+ ||
+ (Count.local + 1) >= (GlobalSetOptions.maxclients - 5))
+ && !(IsExemptLimits(source_p)))
+ {
+ sendto_realops_flags(FLAGS_FULL, L_ALL,
+ "Too many clients, rejecting %s[%s].",
+ nick, source_p->host);
+
+ ServerStats->is_ref++;
+ (void)exit_client(client_p, source_p, &me,
+ "Sorry, server is full - try later");
+ return (CLIENT_EXITED);
+ }
/* valid user name check */
if (!valid_username(source_p->username))
- {
- sendto_realops_flags(FLAGS_REJ, L_ALL,
- "Invalid username: %s (%s@%s)",
- nick, source_p->username, source_p->host);
- ServerStats->is_ref++;
- ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
- (void)exit_client(client_p, source_p, &me, tmpstr2);
- return(CLIENT_EXITED);
- }
+ {
+ sendto_realops_flags(FLAGS_REJ, L_ALL,
+ "Invalid username: %s (%s@%s)",
+ nick, source_p->username, source_p->host);
+ ServerStats->is_ref++;
+ ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
+ (void)exit_client(client_p, source_p, &me, tmpstr2);
+ return (CLIENT_EXITED);
+ }
/* end of valid user name check */
-
- if ((status = check_X_line(client_p,source_p)) < 0)
+
+ if ((status = check_X_line(client_p, source_p)) < 0)
return status;
- if (source_p->user->id[0] == '\0')
- {
- for (id = id_get(); find_id(id); id = id_get())
- ;
- strcpy(source_p->user->id, id);
- add_to_id_hash_table(id, source_p);
- id = id_get();
- strcpy(user->id_key, id);
- }
+ if (source_p->user->id[0] == '\0')
+ {
+ for (id = id_get(); find_id(id); id = id_get())
+ ;
+ strcpy(source_p->user->id, id);
+ add_to_id_hash_table(id, source_p);
+ id = id_get();
+ strcpy(user->id_key, id);
+ }
- inetntop(source_p->localClient->aftype, &IN_ADDR(source_p->localClient->ip),
- ipaddr, HOSTIPLEN);
+ inetntop(source_p->localClient->aftype, &IN_ADDR(source_p->localClient->ip),
+ ipaddr, HOSTIPLEN);
sendto_realops_flags(FLAGS_CCONN, L_ALL,
- "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
- nick, source_p->username, source_p->host,
- ipaddr,
- get_client_class(source_p), source_p->info);
-
+ "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
+ nick, source_p->username, source_p->host,
+ ipaddr, get_client_class(source_p), source_p->info);
+
if ((++Count.local) > Count.max_loc)
- {
- Count.max_loc = Count.local;
- if (!(Count.max_loc % 10))
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "New Max Local Clients: %d",
- Count.max_loc);
- }
+ {
+ Count.max_loc = Count.local;
+ if (!(Count.max_loc % 10))
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "New Max Local Clients: %d", Count.max_loc);
+ }
SetClient(source_p);
* side effects - This function is called when a remote client
* is introduced by a server.
*/
-int register_remote_user(struct Client *client_p, struct Client *source_p,
- char *nick, char *username)
+int
+register_remote_user(struct Client *client_p, struct Client *source_p,
+ char *nick, char *username)
{
- struct User* user = source_p->user;
+ struct User *user = source_p->user;
struct Client *target_p;
-
+
assert(0 != source_p);
assert(source_p->username != username);
user->last = CurrentTime;
/* pointed out by Mortiis, never be too careful */
- if(strlen(username) > USERLEN)
+ if (strlen(username) > USERLEN)
username[USERLEN] = '\0';
strncpy_irc(source_p->username, username, USERLEN);
source_p->servptr = find_server(user->server);
if (source_p->servptr == NULL)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,"Ghost killed: %s on invalid server %s",
- source_p->name, source_p->user->server);
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "Ghost killed: %s on invalid server %s",
+ source_p->name, source_p->user->server);
- kill_client(client_p, source_p, "%s (Server doesn't exist)",
- me.name);
+ kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name);
- source_p->flags |= FLAGS_KILLED;
- return exit_client(NULL, source_p, &me, "Ghost");
- }
+ source_p->flags |= FLAGS_KILLED;
+ return exit_client(NULL, source_p, &me, "Ghost");
+ }
add_client_to_llist(&(source_p->servptr->serv->users), source_p);
- if ((target_p = find_server(user->server)) && target_p->from != source_p->from)
- {
- sendto_realops_flags(FLAGS_DEBUG, L_ALL,
- "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
- client_p->name, nick, source_p->username,
- source_p->host, user->server,
- target_p->name, target_p->from->name);
- kill_client(client_p, source_p,
- "%s (NICK from wrong direction (%s != %s))",
- me.name,
- user->server,
- target_p->from->name);
-
- source_p->flags |= FLAGS_KILLED;
- return exit_client(source_p, source_p, &me,
- "USER server wrong direction");
-
- }
+ if ((target_p = find_server(user->server))
+ && target_p->from != source_p->from)
+ {
+ sendto_realops_flags(FLAGS_DEBUG, L_ALL,
+ "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
+ client_p->name, nick, source_p->username,
+ source_p->host, user->server,
+ target_p->name, target_p->from->name);
+ kill_client(client_p, source_p,
+ "%s (NICK from wrong direction (%s != %s))",
+ me.name, user->server, target_p->from->name);
+
+ source_p->flags |= FLAGS_KILLED;
+ return exit_client(source_p, source_p, &me,
+ "USER server wrong direction");
+
+ }
/*
* Super GhostDetect:
* If we can't find the server the user is supposed to be on,
* then simply blow the user away. -Taner
*/
if (!target_p)
- {
- kill_client(client_p, source_p, "%s GHOST (no server found)",
- me.name);
- sendto_realops_flags(FLAGS_ALL, L_ALL, "No server %s for user %s[%s@%s] from %s",
- user->server, source_p->name, source_p->username,
- source_p->host, source_p->from->name);
- source_p->flags |= FLAGS_KILLED;
- return exit_client(source_p, source_p, &me, "Ghosted Client");
- }
+ {
+ kill_client(client_p, source_p, "%s GHOST (no server found)", me.name);
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "No server %s for user %s[%s@%s] from %s",
+ user->server, source_p->name, source_p->username,
+ source_p->host, source_p->from->name);
+ source_p->flags |= FLAGS_KILLED;
+ return exit_client(source_p, source_p, &me, "Ghosted Client");
+ }
return (introduce_client(client_p, source_p, user, nick));
}
*/
static int
introduce_client(struct Client *client_p, struct Client *source_p,
- struct User *user, char *nick)
+ struct User *user, char *nick)
{
dlink_node *server_node;
struct Client *server;
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
if (!*ubuf)
- {
- ubuf[0] = '+';
- ubuf[1] = '\0';
- }
+ {
+ ubuf[0] = '+';
+ ubuf[1] = '\0';
+ }
/* arghhh one could try not introducing new nicks to ll leafs
* -davidt
* rewritten to cope with UIDs .. eww eww eww --is
*/
-
- if (!ServerInfo.hub && uplink && IsCapable(uplink,CAP_LL)
- && client_p != uplink)
+
+ if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL)
+ && client_p != uplink)
+ {
+ if (IsCapable(uplink, CAP_UID) && HasID(source_p))
{
- if (IsCapable(uplink, CAP_UID) && HasID(source_p))
- {
- sendto_one(uplink, "CLIENT %s %d %lu %s %s %s %s %s :%s",
- nick,
- source_p->hopcount+1,
- (unsigned long) source_p->tsinfo,
- ubuf,
- source_p->username, source_p->host, user->server,
- user->id, source_p->info);
- }
- else
- {
- sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
- nick,
- source_p->hopcount+1,
- (unsigned long) source_p->tsinfo,
- ubuf,
- source_p->username, source_p->host, user->server,
- source_p->info);
- }
+ sendto_one(uplink, "CLIENT %s %d %lu %s %s %s %s %s :%s",
+ nick,
+ source_p->hopcount + 1,
+ (unsigned long)source_p->tsinfo,
+ ubuf,
+ source_p->username, source_p->host, user->server,
+ user->id, source_p->info);
+ }
+ else
+ {
+ sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
+ nick,
+ source_p->hopcount + 1,
+ (unsigned long)source_p->tsinfo,
+ ubuf,
+ source_p->username, source_p->host, user->server,
+ source_p->info);
}
+ }
else
+ {
+ for (server_node = serv_list.head; server_node;
+ server_node = server_node->next)
{
- for (server_node = serv_list.head; server_node; server_node = server_node->next)
- {
- server = (struct Client *) server_node->data;
-
- if (IsCapable(server, CAP_LL) || server == client_p)
- continue;
-
- if (IsCapable(server, CAP_UID) && HasID(source_p))
- sendto_one(server, "CLIENT %s %d %lu %s %s %s %s %s :%s",
- nick,
- source_p->hopcount+1,
- (unsigned long) source_p->tsinfo,
- ubuf,
- source_p->username, source_p->host, user->server,
- user->id, source_p->info);
- else
- sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
- nick,
- source_p->hopcount+1,
- (unsigned long) source_p->tsinfo,
- ubuf,
- source_p->username, source_p->host, user->server,
- source_p->info);
- }
+ server = (struct Client *)server_node->data;
+
+ if (IsCapable(server, CAP_LL) || server == client_p)
+ continue;
+
+ if (IsCapable(server, CAP_UID) && HasID(source_p))
+ sendto_one(server, "CLIENT %s %d %lu %s %s %s %s %s :%s",
+ nick,
+ source_p->hopcount + 1,
+ (unsigned long)source_p->tsinfo,
+ ubuf,
+ source_p->username, source_p->host, user->server,
+ user->id, source_p->info);
+ else
+ sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
+ nick,
+ source_p->hopcount + 1,
+ (unsigned long)source_p->tsinfo,
+ ubuf,
+ source_p->username, source_p->host, user->server,
+ source_p->info);
}
-
+ }
+
if (ubuf[1])
send_umode_out(client_p, source_p, 0);
return 0;
* NOTE: this doesn't allow a hostname to begin with a dot and
* will not allow more dots than chars.
*/
-static int valid_hostname(const char* hostname)
+static int
+valid_hostname(const char *hostname)
{
- const char* p = hostname;
+ const char *p = hostname;
assert(0 != p);
return NO;
while (*p)
- {
- if (!IsHostChar(*p))
- return NO;
- p++;
- }
+ {
+ if (!IsHostChar(*p))
+ return NO;
+ p++;
+ }
return (YES);
}
* Allow '.' in username to allow for "first.last"
* style of username
*/
-static int valid_username(const char* username)
+static int
+valid_username(const char *username)
{
int dots = 0;
const char *p = username;
return NO;
while (*++p)
+ {
+ if ((*p == '.') && ConfigFileEntry.dots_in_ident)
{
- if((*p == '.') && ConfigFileEntry.dots_in_ident)
- {
- dots++;
- if(dots > ConfigFileEntry.dots_in_ident)
- return NO;
- if(!IsUserChar(p[1]))
- return NO;
- }
- else if (!IsUserChar(*p))
+ dots++;
+ if (dots > ConfigFileEntry.dots_in_ident)
+ return NO;
+ if (!IsUserChar(p[1]))
return NO;
}
+ else if (!IsUserChar(*p))
+ return NO;
+ }
return YES;
}
* Report to user any special flags they are getting, and set them.
*/
-static void
-report_and_set_user_flags(struct Client *source_p,struct ConfItem *aconf)
+static void
+report_and_set_user_flags(struct Client *source_p, struct ConfItem *aconf)
{
/* If this user is being spoofed, tell them so */
- if(IsConfDoSpoofIp(aconf))
- {
- sendto_one(source_p,
- ":%s NOTICE %s :*** Spoofing your IP. congrats.",
- me.name,source_p->name);
- }
+ if (IsConfDoSpoofIp(aconf))
+ {
+ sendto_one(source_p,
+ ":%s NOTICE %s :*** Spoofing your IP. congrats.",
+ me.name, source_p->name);
+ }
/* If this user is in the exception class, Set it "E lined" */
- if(IsConfExemptKline(aconf))
- {
- SetExemptKline(source_p);
- sendto_one(source_p,
- ":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.",
- me.name,source_p->name);
- }
+ if (IsConfExemptKline(aconf))
+ {
+ SetExemptKline(source_p);
+ sendto_one(source_p,
+ ":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.",
+ me.name, source_p->name);
+ }
/* If this user is exempt from user limits set it F lined" */
- if(IsConfExemptLimits(aconf))
- {
- SetExemptLimits(source_p);
- sendto_one(source_p,
- ":%s NOTICE %s :*** You are exempt from user limits. congrats.",
- me.name,source_p->name);
- }
+ if (IsConfExemptLimits(aconf))
+ {
+ SetExemptLimits(source_p);
+ sendto_one(source_p,
+ ":%s NOTICE %s :*** You are exempt from user limits. congrats.",
+ me.name, source_p->name);
+ }
/* If this user is exempt from idle time outs */
- if(IsConfIdlelined(aconf))
- {
- SetIdlelined(source_p);
- sendto_one(source_p,
- ":%s NOTICE %s :*** You are exempt from idle limits. congrats.",
- me.name,source_p->name);
- }
+ if (IsConfIdlelined(aconf))
+ {
+ SetIdlelined(source_p);
+ sendto_one(source_p,
+ ":%s NOTICE %s :*** You are exempt from idle limits. congrats.",
+ me.name, source_p->name);
+ }
}
* output -
* side effects -
*/
-int do_local_user(char* nick, struct Client* client_p, struct Client* source_p,
- char* username, char *host, char *server, char *realname)
+int
+do_local_user(char *nick, struct Client *client_p, struct Client *source_p,
+ char *username, char *host, char *server, char *realname)
{
unsigned int oflags;
- struct User* user;
+ struct User *user;
assert(0 != source_p);
assert(source_p->username != username);
oflags = source_p->flags;
if (!IsUnknown(source_p))
- {
- sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), me.name, nick);
- return 0;
- }
+ {
+ sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), me.name, nick);
+ return 0;
+ }
source_p->flags |= FLAGS_INVISIBLE;
if (!(oflags & FLAGS_INVISIBLE) && IsInvisible(source_p))
user->server = me.name;
strncpy_irc(source_p->info, realname, REALLEN);
-
+
if (source_p->name[0])
- {
+ {
/* NICK already received, now I have USER... */
- return register_local_user(client_p, source_p, source_p->name, username);
+ return register_local_user(client_p, source_p, source_p->name, username);
}
else
+ {
+ if (!IsGotId(source_p))
{
- if (!IsGotId(source_p))
- {
- /*
- * save the username in the client
- */
- strncpy_irc(source_p->username, username, USERLEN);
- }
+ /*
+ * save the username in the client
+ */
+ strncpy_irc(source_p->username, username, USERLEN);
}
+ }
return 0;
}
* output -
* side effects -
*/
-int do_remote_user(char* nick, struct Client* client_p, struct Client* source_p,
- char* username, char *host, char *server, char *realname,
- char *id)
+int
+do_remote_user(char *nick, struct Client *client_p, struct Client *source_p,
+ char *username, char *host, char *server, char *realname,
+ char *id)
{
unsigned int oflags;
- struct User* user;
+ struct User *user;
assert(0 != source_p);
assert(source_p->username != username);
* coming from another server, take the servers word for it
*/
user->server = find_or_add(server);
- strncpy_irc(source_p->host, host, HOSTLEN);
+ strncpy_irc(source_p->host, host, HOSTLEN);
strncpy_irc(source_p->info, realname, REALLEN);
if (id)
- strcpy(source_p->user->id, id);
-
+ strcpy(source_p->user->id, id);
+
return register_remote_user(client_p, source_p, source_p->name, username);
}
* parv[1] - username to change mode for
* parv[2] - modes to change
*/
-int user_mode(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
+int
+user_mode(struct Client *client_p, struct Client *source_p, int parc,
+ char *parv[])
{
- int flag;
- int i;
- char **p, *m;
+ int flag;
+ int i;
+ char **p, *m;
struct Client *target_p;
- int what, setflags;
- int badflag = NO; /* Only send one bad flag notice */
- char buf[BUFSIZE];
+ int what, setflags;
+ int badflag = NO; /* Only send one bad flag notice */
+ char buf[BUFSIZE];
dlink_node *ptr;
struct ConfItem *aconf;
what = MODE_ADD;
if (parc < 2)
- {
- sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
- me.name, parv[0], "MODE");
- return 0;
- }
+ {
+ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
+ me.name, parv[0], "MODE");
+ return 0;
+ }
if ((target_p = find_person(parv[1])) == NULL)
- {
- if (MyConnect(source_p))
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, parv[0], parv[1]);
- return 0;
- }
+ {
+ if (MyConnect(source_p))
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, parv[0], parv[1]);
+ return 0;
+ }
/* Dont know why these were commented out..
* put them back using new sendto() funcs
*/
if (IsServer(source_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ADMIN, "*** Mode for User %s from %s",
- parv[1], source_p->name);
- return 0;
- }
+ {
+ sendto_realops_flags(FLAGS_ALL, L_ADMIN, "*** Mode for User %s from %s",
+ parv[1], source_p->name);
+ return 0;
+ }
if (source_p != target_p || target_p->from != source_p->from)
- {
- sendto_one(source_p, form_str(ERR_USERSDONTMATCH), me.name, parv[0]);
- return 0;
- }
+ {
+ sendto_one(source_p, form_str(ERR_USERSDONTMATCH), me.name, parv[0]);
+ return 0;
+ }
if (parc < 3)
- {
- m = buf;
- *m++ = '+';
-
- for (i = 0; user_modes[i].letter && (m - buf < BUFSIZE - 4);i++)
- if (source_p->umodes & user_modes[i].mode)
- *m++ = user_modes[i].letter;
- *m = '\0';
- sendto_one(source_p, form_str(RPL_UMODEIS), me.name, parv[0], buf);
- return 0;
- }
+ {
+ m = buf;
+ *m++ = '+';
+
+ for (i = 0; user_modes[i].letter && (m - buf < BUFSIZE - 4); i++)
+ if (source_p->umodes & user_modes[i].mode)
+ *m++ = user_modes[i].letter;
+ *m = '\0';
+ sendto_one(source_p, form_str(RPL_UMODEIS), me.name, parv[0], buf);
+ return 0;
+ }
/* find flags already set for user */
setflags = source_p->umodes;
-
+
/*
* parse mode change string(s)
*/
- for (p = &parv[2]; p && *p; p++ )
+ for (p = &parv[2]; p && *p; p++)
for (m = *p; *m; m++)
- switch(*m)
- {
- case '+' :
+ switch (*m)
+ {
+ case '+':
what = MODE_ADD;
break;
- case '-' :
+ case '-':
what = MODE_DEL;
- break;
+ break;
- case 'o' :
- if(what == MODE_ADD)
+ case 'o':
+ if (what == MODE_ADD)
+ {
+ if (IsServer(client_p) && !IsOper(source_p))
{
- if(IsServer(client_p) && !IsOper(source_p))
- {
- ++Count.oper;
- SetOper(source_p);
- }
+ ++Count.oper;
+ SetOper(source_p);
}
+ }
else
+ {
+ /* Only decrement the oper counts if an oper to begin with
+ * found by Pat Szuta, Perly , perly@xnet.com
+ */
+
+ if (!IsOper(source_p))
+ break;
+
+ ClearOper(source_p);
+ source_p->umodes &= ~ConfigFileEntry.oper_only_umodes;
+
+ Count.oper--;
+
+ if (MyConnect(source_p))
{
- /* Only decrement the oper counts if an oper to begin with
- * found by Pat Szuta, Perly , perly@xnet.com
+ dlink_node *dm;
+
+ ptr = source_p->localClient->confs.head;
+ aconf = ptr->data;
+ detach_conf(source_p, aconf);
+
+ source_p->flags2 &= ~(FLAGS2_OPER_GLOBAL_KILL |
+ FLAGS2_OPER_REMOTE |
+ FLAGS2_OPER_UNKLINE |
+ FLAGS2_OPER_GLINE |
+ FLAGS2_OPER_N |
+ FLAGS2_OPER_K | FLAGS2_OPER_ADMIN);
+
+ dm = dlinkFind(&oper_list, source_p);
+ if (dm != NULL)
+ {
+ dlinkDelete(dm, &oper_list);
+ free_dlink_node(dm);
+ }
+
+ /*
+ 20001216:
+ reattach to "old" iline
+ - einride
*/
-
- if(!IsOper(source_p))
- break;
-
- ClearOper(source_p);
- source_p->umodes &= ~ConfigFileEntry.oper_only_umodes;
-
- Count.oper--;
-
- if (MyConnect(source_p))
- {
- dlink_node *dm;
-
- ptr = source_p->localClient->confs.head;
- aconf = ptr->data;
- detach_conf(source_p,aconf);
-
- source_p->flags2 &= ~(FLAGS2_OPER_GLOBAL_KILL|
- FLAGS2_OPER_REMOTE|
- FLAGS2_OPER_UNKLINE|
- FLAGS2_OPER_GLINE|
- FLAGS2_OPER_N|
- FLAGS2_OPER_K|
- FLAGS2_OPER_ADMIN);
-
- dm = dlinkFind(&oper_list,source_p);
- if(dm != NULL)
- {
- dlinkDelete(dm,&oper_list);
- free_dlink_node(dm);
- }
-
- /*
- 20001216:
- reattach to "old" iline
- - einride
- */
- remove_one_ip(&source_p->localClient->ip);
- check_client(source_p->servptr, source_p, source_p->username);
- }
+ remove_one_ip(&source_p->localClient->ip);
+ check_client(source_p->servptr, source_p, source_p->username);
}
+ }
break;
/* we may not get these,
* but they shouldnt be in default
*/
- case ' ' :
- case '\n' :
- case '\r' :
- case '\t' :
+ case ' ':
+ case '\n':
+ case '\r':
+ case '\t':
break;
- default :
- if( (flag = user_modes_from_c_to_bitmask[(unsigned char)*m]))
+ default:
+ if ((flag = user_modes_from_c_to_bitmask[(unsigned char)*m]))
+ {
+ if (MyConnect(source_p) && !IsOper(source_p) &&
+ (ConfigFileEntry.oper_only_umodes & flag))
{
- if (MyConnect(source_p) && !IsOper(source_p) &&
- (ConfigFileEntry.oper_only_umodes & flag))
- {
- badflag = YES;
- }
- else
- {
- if (what == MODE_ADD)
- source_p->umodes |= flag;
- else
- source_p->umodes &= ~flag;
- }
+ badflag = YES;
}
- else
+ else
{
- if (MyConnect(source_p))
- badflag = YES;
+ if (what == MODE_ADD)
+ source_p->umodes |= flag;
+ else
+ source_p->umodes &= ~flag;
}
+ }
+ else
+ {
+ if (MyConnect(source_p))
+ badflag = YES;
+ }
break;
- }
+ }
- if(badflag)
+ if (badflag)
sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG), me.name, parv[0]);
if ((source_p->umodes & FLAGS_NCHANGE) && !IsOperN(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :*** You need oper and N flag for +n",
- me.name,parv[0]);
- source_p->umodes &= ~FLAGS_NCHANGE; /* only tcm's really need this */
- }
+ {
+ sendto_one(source_p, ":%s NOTICE %s :*** You need oper and N flag for +n",
+ me.name, parv[0]);
+ source_p->umodes &= ~FLAGS_NCHANGE; /* only tcm's really need this */
+ }
- if (MyConnect(source_p) && (source_p->umodes & FLAGS_ADMIN) && !IsOperAdmin(source_p))
- {
- sendto_one(source_p,":%s NOTICE %s :*** You need oper and A flag for +a",
- me.name, parv[0]);
- source_p->umodes &= ~FLAGS_ADMIN;
- }
+ if (MyConnect(source_p) && (source_p->umodes & FLAGS_ADMIN)
+ && !IsOperAdmin(source_p))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :*** You need oper and A flag for +a",
+ me.name, parv[0]);
+ source_p->umodes &= ~FLAGS_ADMIN;
+ }
if (!(setflags & FLAGS_INVISIBLE) && IsInvisible(source_p))
return 0;
}
-
+
/*
* send the MODE string for user (user) to connection client_p
* -avalon
*/
-void send_umode(struct Client *client_p, struct Client *source_p, int old,
- int sendmask, char *umode_buf)
+void
+send_umode(struct Client *client_p, struct Client *source_p, int old,
+ int sendmask, char *umode_buf)
{
- int i;
+ int i;
int flag;
- char *m;
- int what = 0;
+ char *m;
+ int what = 0;
/*
* build a string in umode_buf to represent the change in the user's
m = umode_buf;
*m = '\0';
- for (i = 0; user_modes[i].letter; i++ )
- {
- flag = user_modes[i].mode;
+ for (i = 0; user_modes[i].letter; i++)
+ {
+ flag = user_modes[i].mode;
- if (MyClient(source_p) && !(flag & sendmask))
- continue;
- if ((flag & old) && !(source_p->umodes & flag))
- {
- if (what == MODE_DEL)
- *m++ = user_modes[i].letter;
- else
- {
- what = MODE_DEL;
- *m++ = '-';
- *m++ = user_modes[i].letter;
- }
- }
- else if (!(flag & old) && (source_p->umodes & flag))
- {
- if (what == MODE_ADD)
- *m++ = user_modes[i].letter;
- else
- {
- what = MODE_ADD;
- *m++ = '+';
- *m++ = user_modes[i].letter;
- }
- }
+ if (MyClient(source_p) && !(flag & sendmask))
+ continue;
+ if ((flag & old) && !(source_p->umodes & flag))
+ {
+ if (what == MODE_DEL)
+ *m++ = user_modes[i].letter;
+ else
+ {
+ what = MODE_DEL;
+ *m++ = '-';
+ *m++ = user_modes[i].letter;
+ }
}
+ else if (!(flag & old) && (source_p->umodes & flag))
+ {
+ if (what == MODE_ADD)
+ *m++ = user_modes[i].letter;
+ else
+ {
+ what = MODE_ADD;
+ *m++ = '+';
+ *m++ = user_modes[i].letter;
+ }
+ }
+ }
*m = '\0';
if (*umode_buf && client_p)
sendto_one(client_p, ":%s MODE %s :%s",
* output - NONE
* side effects - Only send ubuf out to servers that know about this client
*/
-void send_umode_out(struct Client *client_p,
- struct Client *source_p,
- int old)
+void
+send_umode_out(struct Client *client_p, struct Client *source_p, int old)
{
struct Client *target_p;
char buf[BUFSIZE];
send_umode(NULL, source_p, old, SEND_UMODES, buf);
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
+ {
+ target_p = ptr->data;
+
+ if ((target_p != client_p) && (target_p != source_p) && (*buf))
{
- target_p = ptr->data;
-
- if((target_p != client_p) && (target_p != source_p) && (*buf))
- {
- if((!(ServerInfo.hub && IsCapable(target_p, CAP_LL)))
- || (target_p->localClient->serverMask &
- source_p->lazyLinkClientExists))
- sendto_one(target_p, ":%s MODE %s :%s",
- source_p->name, source_p->name, buf);
- }
+ if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL)))
+ || (target_p->localClient->serverMask &
+ source_p->lazyLinkClientExists))
+ sendto_one(target_p, ":%s MODE %s :%s",
+ source_p->name, source_p->name, buf);
}
+ }
if (client_p && MyClient(client_p))
send_umode(client_p, source_p, old, ALL_UMODES, buf);
* output - NONE
* side effects -
*/
-void user_welcome(struct Client *source_p)
+void
+user_welcome(struct Client *source_p)
{
- sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
- ServerInfo.network_name, source_p->name );
- /* This is a duplicate of the NOTICE but see below...*/
+ sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
+ ServerInfo.network_name, source_p->name);
+ /* This is a duplicate of the NOTICE but see below... */
sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
- get_listener_name(source_p->localClient->listener), ircd_version);
-
+ get_listener_name(source_p->localClient->listener),
+ ircd_version);
+
/*
- ** Don't mess with this one - IRCII needs it! -Avalon
- */
+ ** Don't mess with this one - IRCII needs it! -Avalon
+ */
sendto_one(source_p,
- "NOTICE %s :*** Your host is %s, running version %s",
- source_p->name, get_listener_name(source_p->localClient->listener),
- ircd_version);
-
- sendto_one(source_p, form_str(RPL_CREATED),me.name,source_p->name,creation);
- sendto_one(source_p, form_str(RPL_MYINFO), me.name, source_p->name,
- me.name, ircd_version);
-
+ "NOTICE %s :*** Your host is %s, running version %s",
+ source_p->name,
+ get_listener_name(source_p->localClient->listener),
+ ircd_version);
+
+ sendto_one(source_p, form_str(RPL_CREATED), me.name, source_p->name,
+ creation);
+ sendto_one(source_p, form_str(RPL_MYINFO), me.name, source_p->name, me.name,
+ ircd_version);
+
show_isupport(source_p);
-
+
show_lusers(source_p);
if (ConfigFileEntry.short_motd)
- {
- sendto_one(source_p,"NOTICE %s :*** Notice -- motd was last changed at %s",
- source_p->name,
- ConfigFileEntry.motd.lastChangedDate);
-
- sendto_one(source_p,
- "NOTICE %s :*** Notice -- Please read the motd if you haven't read it",
- source_p->name);
-
- sendto_one(source_p, form_str(RPL_MOTDSTART),
- me.name, source_p->name, me.name);
-
- sendto_one(source_p,
- form_str(RPL_MOTD),
- me.name, source_p->name,
- "*** This is the short motd ***"
- );
+ {
+ sendto_one(source_p,
+ "NOTICE %s :*** Notice -- motd was last changed at %s",
+ source_p->name, ConfigFileEntry.motd.lastChangedDate);
- sendto_one(source_p, form_str(RPL_ENDOFMOTD),
- me.name, source_p->name);
- }
- else
+ sendto_one(source_p,
+ "NOTICE %s :*** Notice -- Please read the motd if you haven't read it",
+ source_p->name);
+
+ sendto_one(source_p, form_str(RPL_MOTDSTART),
+ me.name, source_p->name, me.name);
+
+ sendto_one(source_p,
+ form_str(RPL_MOTD),
+ me.name, source_p->name, "*** This is the short motd ***");
+
+ sendto_one(source_p, form_str(RPL_ENDOFMOTD), me.name, source_p->name);
+ }
+ else
SendMessageFile(source_p, &ConfigFileEntry.motd);
if (IsRestricted(source_p))
- {
- sendto_one(source_p,form_str(ERR_RESTRICTED),
- me.name, source_p->name);
- }
+ {
+ sendto_one(source_p, form_str(ERR_RESTRICTED), me.name, source_p->name);
+ }
}
/*
* outupt - -1 if exiting 0 if ok
* side effects -
*/
-static int check_X_line(struct Client *client_p, struct Client *source_p)
+static int
+check_X_line(struct Client *client_p, struct Client *source_p)
{
struct ConfItem *aconf;
char *reason;
- if(IsOper(source_p))
+ if (IsOper(source_p))
return 0;
if ((aconf = find_x_conf(source_p->info)))
+ {
+ if (aconf->passwd)
+ reason = aconf->passwd;
+ else
+ reason = "NONE";
+
+ if (aconf->port)
{
- if(aconf->passwd)
- reason = aconf->passwd;
- else
- reason = "NONE";
-
- if(aconf->port)
- {
- if (aconf->port == 1)
- {
- sendto_realops_flags(FLAGS_REJ, L_ALL,
- "X-line Rejecting [%s] [%s], user %s",
- source_p->info,
- reason,
- get_client_name(client_p, HIDE_IP));
- }
- ServerStats->is_ref++;
- (void)exit_client(client_p, source_p, &me, "Bad user info");
- return (CLIENT_EXITED);
- }
- else
- sendto_realops_flags(FLAGS_REJ, L_ALL,
- "X-line Warning [%s] [%s], user %s",
- source_p->info,
- reason,
- get_client_name(client_p, HIDE_IP));
+ if (aconf->port == 1)
+ {
+ sendto_realops_flags(FLAGS_REJ, L_ALL,
+ "X-line Rejecting [%s] [%s], user %s",
+ source_p->info,
+ reason, get_client_name(client_p, HIDE_IP));
+ }
+ ServerStats->is_ref++;
+ (void)exit_client(client_p, source_p, &me, "Bad user info");
+ return (CLIENT_EXITED);
}
+ else
+ sendto_realops_flags(FLAGS_REJ, L_ALL,
+ "X-line Warning [%s] [%s], user %s",
+ source_p->info,
+ reason, get_client_name(client_p, HIDE_IP));
+ }
return 0;
}
* This could also be used by rsa oper routines.
*/
-int oper_up( struct Client *source_p,
- struct ConfItem *aconf )
+int
+oper_up(struct Client *source_p, struct ConfItem *aconf)
{
int old = (source_p->umodes & ALL_UMODES);
- char *operprivs=NULL;
+ char *operprivs = NULL;
dlink_node *ptr;
struct ConfItem *found_aconf;
dlink_node *m;
SetOper(source_p);
- if((int)aconf->hold)
+ if ((int)aconf->hold)
+ {
+ source_p->umodes |= ((int)aconf->hold & ALL_UMODES);
+ if (!IsOperN(source_p))
+ source_p->umodes &= ~FLAGS_NCHANGE;
+
+ sendto_one(source_p, ":%s NOTICE %s :*** Oper flags set from conf",
+ me.name, source_p->name);
+ }
+ else
+ {
+ if (ConfigFileEntry.oper_umodes)
{
- source_p->umodes |= ((int)aconf->hold & ALL_UMODES);
- if( !IsOperN(source_p) )
- source_p->umodes &= ~FLAGS_NCHANGE;
-
- sendto_one(source_p, ":%s NOTICE %s :*** Oper flags set from conf",
- me.name,source_p->name);
+ source_p->umodes |= ConfigFileEntry.oper_umodes & ALL_UMODES;
}
- else
+ else
{
- if(ConfigFileEntry.oper_umodes)
- {
- source_p->umodes |= ConfigFileEntry.oper_umodes & ALL_UMODES;
- }
- else
- {
- source_p->umodes |= (FLAGS_SERVNOTICE|FLAGS_OPERWALL|FLAGS_WALLOP|FLAGS_LOCOPS) & ALL_UMODES;
- }
+ source_p->umodes |=
+ (FLAGS_SERVNOTICE | FLAGS_OPERWALL | FLAGS_WALLOP | FLAGS_LOCOPS) &
+ ALL_UMODES;
}
-
+ }
+
Count.oper++;
SetExemptKline(source_p);
-
+
m = make_dlink_node();
- dlinkAdd(source_p,m,&oper_list);
+ dlinkAdd(source_p, m, &oper_list);
- if(source_p->localClient->confs.head)
+ if (source_p->localClient->confs.head)
+ {
+ ptr = source_p->localClient->confs.head;
+ if (ptr)
{
- ptr = source_p->localClient->confs.head;
- if(ptr)
- {
- found_aconf = ptr->data;
- if(found_aconf)
- operprivs = oper_privs_as_string(source_p,found_aconf->port);
- }
+ found_aconf = ptr->data;
+ if (found_aconf)
+ operprivs = oper_privs_as_string(source_p, found_aconf->port);
}
+ }
else
operprivs = "";
source_p->umodes |= FLAGS_ADMIN;
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s (%s@%s) is now an operator", source_p->name,
- source_p->username, source_p->host);
+ "%s (%s@%s) is now an operator", source_p->name,
+ source_p->username, source_p->host);
send_umode_out(source_p, source_p, old);
sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
sendto_one(source_p, ":%s NOTICE %s :*** Oper privs are %s", me.name,
source_p->name, operprivs);
SendMessageFile(source_p, &ConfigFileEntry.opermotd);
-
+
return 1;
}
/*
* scache.c
*
- * $Id: scache.c,v 1.1 2002/01/04 09:14:48 a1kmm Exp $
+ * $Id: scache.c,v 1.2 2002/01/04 11:06:43 a1kmm Exp $
*/
#include "client.h"
typedef struct scache_entry
{
- char name[HOSTLEN+1];
+ char name[HOSTLEN + 1];
struct scache_entry *next;
-} SCACHE;
+}
+SCACHE;
static SCACHE *scache_hash[SCACHE_HASH_SIZE];
-void clear_scache_hash_table(void)
+void
+clear_scache_hash_table(void)
{
memset(scache_hash, 0, sizeof(scache_hash));
}
-static int hash(const char* string)
+static int
+hash(const char *string)
{
int hash_value;
hash_value = 0;
while (*string)
- {
- hash_value += ToLower(*string);
- /* I don't like auto increments inside macro calls... -db */
- string++;
- }
+ {
+ hash_value += ToLower(*string);
+ /* I don't like auto increments inside macro calls... -db */
+ string++;
+ }
return hash_value % SCACHE_HASH_SIZE;
}
* existing, servername. use the hash in list.c for those. -orabidoo
*/
-const char* find_or_add(const char* name)
+const char *
+find_or_add(const char *name)
{
- int hash_index;
- SCACHE* ptr;
+ int hash_index;
+ SCACHE *ptr;
ptr = scache_hash[hash_index = hash(name)];
- for ( ; ptr; ptr = ptr->next)
- {
- if (!irccmp(ptr->name, name))
- return(ptr->name);
- }
+ for (; ptr; ptr = ptr->next)
+ {
+ if (!irccmp(ptr->name, name))
+ return (ptr->name);
+ }
- ptr = (SCACHE*) MyMalloc(sizeof(SCACHE));
+ ptr = (SCACHE *) MyMalloc(sizeof(SCACHE));
assert(0 != ptr);
strncpy_irc(ptr->name, name, HOSTLEN);
ptr->next = scache_hash[hash_index];
scache_hash[hash_index] = ptr;
- return ptr->name;
+ return ptr->name;
}
/*
* output - NONE
* side effects -
*/
-void count_scache(int *number_servers_cached,u_long *mem_servers_cached)
+void
+count_scache(int *number_servers_cached, u_long * mem_servers_cached)
{
SCACHE *scache_ptr;
int i;
*number_servers_cached = 0;
*mem_servers_cached = 0;
- for(i = 0; i < SCACHE_HASH_SIZE ;i++)
+ for (i = 0; i < SCACHE_HASH_SIZE; i++)
+ {
+ scache_ptr = scache_hash[i];
+ while (scache_ptr)
{
- scache_ptr = scache_hash[i];
- while(scache_ptr)
- {
- *number_servers_cached = *number_servers_cached + 1;
- *mem_servers_cached = *mem_servers_cached +
- (strlen(scache_ptr->name) +
- sizeof(SCACHE *));
-
- scache_ptr = scache_ptr->next;
- }
+ *number_servers_cached = *number_servers_cached + 1;
+ *mem_servers_cached = *mem_servers_cached +
+ (strlen(scache_ptr->name) + sizeof(SCACHE *));
+
+ scache_ptr = scache_ptr->next;
}
+ }
}
/* list all server names in scache very verbose */
-
-void list_scache(struct Client *source_p)
+
+void
+list_scache(struct Client *source_p)
{
int hash_index;
SCACHE *ptr;
- for (hash_index = 0; hash_index < SCACHE_HASH_SIZE ;hash_index++)
+ for (hash_index = 0; hash_index < SCACHE_HASH_SIZE; hash_index++)
+ {
+ ptr = scache_hash[hash_index];
+ while (ptr)
{
- ptr = scache_hash[hash_index];
- while(ptr)
- {
- if(ptr->name)
- sendto_one(source_p,":%s NOTICE %s :%s",
- me.name, source_p->name, ptr->name);
- ptr = ptr->next;
- }
+ if (ptr->name)
+ sendto_one(source_p, ":%s NOTICE %s :%s",
+ me.name, source_p->name, ptr->name);
+ ptr = ptr->next;
}
+ }
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: send.c,v 1.1 2002/01/04 09:14:55 a1kmm Exp $
+ * $Id: send.c,v 1.2 2002/01/04 11:06:43 a1kmm Exp $
*/
#include <sys/types.h>
#define LOG_BUFSIZE 2048
-static int
-_send_linebuf(struct Client *, buf_head_t *);
+static int _send_linebuf(struct Client *, buf_head_t *);
static void
send_linebuf_remote(struct Client *, struct Client *, buf_head_t *);
#define send_linebuf(a,b) _send_linebuf((a->from?a->from:a),b)
/* global for now *sigh* */
-unsigned long current_serial=0L;
+unsigned long current_serial = 0L;
-static void
-sendto_list_local(dlink_list *list, buf_head_t *linebuf);
+static void sendto_list_local(dlink_list * list, buf_head_t * linebuf);
static void
sendto_list_remote(struct Client *one,
- struct Client *from, dlink_list *list, int caps,
- int nocaps, buf_head_t *linebuf);
+ struct Client *from, dlink_list * list, int caps,
+ int nocaps, buf_head_t * linebuf);
static void
sendto_list_anywhere(struct Client *one, struct Client *from,
- dlink_list *list, buf_head_t *local_linebuf,
- buf_head_t *remote_linebuf);
+ dlink_list * list, buf_head_t * local_linebuf,
+ buf_head_t * remote_linebuf);
static inline int
send_format(char *lsendbuf, const char *pattern, va_list args);
-static inline int
-send_trim(char *lsendbuf, int len );
+static inline int send_trim(char *lsendbuf, int len);
/*
** dead_link
}
Debug((DEBUG_ERROR, notice, get_client_name(to, HIDE_IP)));
return (-1);
-} /* dead_link() */
+} /* dead_link() */
/*
** sendq.
*/
static int
-_send_linebuf(struct Client *to, buf_head_t *linebuf)
+_send_linebuf(struct Client *to, buf_head_t * linebuf)
{
#ifdef INVARIANTS
if (IsMe(to))
}
#endif
if (to->fd < 0)
- return 0; /* Thou shalt not write to closed descriptors */
+ return 0; /* Thou shalt not write to closed descriptors */
if (IsDead(to))
- return 0; /* This socket has already been marked as dead */
+ return 0; /* This socket has already been marked as dead */
if (linebuf_len(&to->localClient->buf_sendq) > get_sendq(to))
{
to->localClient->sendM += 1;
me.localClient->sendM += 1;
- send_queued_write(to->fd, to);
+ send_queued_write(to->fd, to);
return 0;
-} /* send_linebuf() */
+} /* send_linebuf() */
/*
* send_linebuf_remote
*/
static void
send_linebuf_remote(struct Client *to, struct Client *from,
- buf_head_t *linebuf)
+ buf_head_t * linebuf)
{
- if(to->from)
+ if (to->from)
to = to->from;
- if(ServerInfo.hub && IsCapable(to, CAP_LL))
+ if (ServerInfo.hub && IsCapable(to, CAP_LL))
{
- if(((from->lazyLinkClientExists &
- to->localClient->serverMask) == 0))
+ if (((from->lazyLinkClientExists & to->localClient->serverMask) == 0))
client_burst_if_needed(to, from);
}
exit_client(NULL, to, &me, "Ghosted client");
return;
- }
+ }
_send_linebuf(to, linebuf);
return;
-} /* send_linebuf_remote() */
+} /* send_linebuf_remote() */
/*
** send_queued_write
#ifndef NDEBUG
struct hook_io_data hdata;
#endif
-
+
/*
** Once socket is marked dead, we cannot start writing to it,
** even if the error is removed...
* dead socket... --msa
*/
return;
- } /* if (IsDead(to)) */
+ } /* if (IsDead(to)) */
#endif
/* Next, lets try to write some data */
hdata.connection = to;
if (to->localClient->buf_sendq.list.head)
hdata.data =
- ((buf_line_t *)to->localClient->buf_sendq.list.head->data)->buf +
+ ((buf_line_t *) to->localClient->buf_sendq.list.head->data)->buf +
to->localClient->buf_sendq.writeofs;
#endif
-
- if (linebuf_len(&to->localClient->buf_sendq)) {
- while((retlen = linebuf_flush(to->fd, &to->localClient->buf_sendq)) > 0)
+
+ if (linebuf_len(&to->localClient->buf_sendq))
+ {
+ while ((retlen = linebuf_flush(to->fd, &to->localClient->buf_sendq)) > 0)
{
/* We have some data written .. update counters */
#ifndef NDEBUG
hdata.len = retlen;
hook_call_event("iosend", &hdata);
if (to->localClient->buf_sendq.list.head)
- hdata.data =
- ((buf_line_t *)to->localClient->buf_sendq.list.head->data)->buf +
+ hdata.data =
+ ((buf_line_t *) to->localClient->buf_sendq.list.head->data)->buf +
to->localClient->buf_sendq.writeofs;
#endif
to->localClient->sendB += retlen;
me.localClient->sendB += retlen;
if (to->localClient->sendB > 1023)
- {
+ {
to->localClient->sendK += (to->localClient->sendB >> 10);
- to->localClient->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
- } else if (me.localClient->sendB > 1023)
- {
+ to->localClient->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
+ }
+ else if (me.localClient->sendB > 1023)
+ {
me.localClient->sendK += (me.localClient->sendB >> 10);
me.localClient->sendB &= 0x03ff;
}
}
- if ((retlen < 0) && (ignoreErrno(errno))) {
+ if ((retlen < 0) && (ignoreErrno(errno)))
+ {
/* we have a non-fatal error, so just continue */
- } else if (retlen < 0) {
+ }
+ else if (retlen < 0)
+ {
/* We have a fatal error */
dead_link(to, "Write error to %s, closing link");
return;
- } else if (retlen == 0) {
+ }
+ else if (retlen == 0)
+ {
/* 0 bytes is an EOF .. */
dead_link(to, "EOF during write to %s, closing link");
return;
if (linebuf_len(&to->localClient->buf_sendq))
comm_setselect(fd, FDLIST_IDLECLIENT, COMM_SELECT_WRITE,
send_queued_write, to, 0);
-} /* send_queued_write() */
+} /* send_queued_write() */
/*
** send_queued_slink_write
** even if the error is removed...
*/
#ifdef INVARIANTS
- if (IsDead(to)) {
+ if (IsDead(to))
+ {
/*
* Actually, we should *NEVER* get here--something is
* not working correct if send_queued is called for a
* dead socket... --msa
*/
return;
- } /* if (IsDead(to)) */
+ } /* if (IsDead(to)) */
#endif
/* Next, lets try to write some data */
- if (to->localClient->slinkq) {
+ if (to->localClient->slinkq)
+ {
retlen = write(to->localClient->ctrlfd,
to->localClient->slinkq + to->localClient->slinkq_ofs,
to->localClient->slinkq_len);
- if ((retlen < 0) && (ignoreErrno(errno))) {
+ if ((retlen < 0) && (ignoreErrno(errno)))
+ {
/* we have a non-fatal error, so just continue */
- } else if (retlen < 0) {
+ }
+ else if (retlen < 0)
+ {
/* We have a fatal error */
dead_link(to, "Write error to %s, closing link");
return;
- } else if (retlen == 0) {
+ }
+ else if (retlen == 0)
+ {
/* 0 bytes is an EOF .. */
dead_link(to, "EOF during write to %s, closing link");
return;
- } else {
+ }
+ else
+ {
to->localClient->slinkq_len -= retlen;
assert(to->localClient->slinkq_len >= 0);
/* Finally, if we have any more data, reschedule a write */
if (to->localClient->slinkq_len)
comm_setselect(to->localClient->ctrlfd, FDLIST_IDLECLIENT,
- COMM_SELECT_WRITE, send_queued_slink_write,
- to, 0);
-} /* send_queued_slink_write() */
+ COMM_SELECT_WRITE, send_queued_slink_write, to, 0);
+} /* send_queued_slink_write() */
/*
* sendto_one
if (to->fd < 0)
{
Debug((DEBUG_ERROR,
- "Local socket %s with negative fd... AARGH!",
- to->name));
+ "Local socket %s with negative fd... AARGH!", to->name));
}
else if (IsMe(to))
{
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Trying to send to myself!");
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Trying to send to myself!");
return;
}
#endif
linebuf_donebuf(&linebuf);
deprintf("send", "Sending to %s", to->name);
-} /* sendto_one() */
+} /* sendto_one() */
/*
* sendto_one_prefix
if (to->fd < 0)
{
Debug((DEBUG_ERROR,
- "Local socket %s with negative fd... AARGH!",
- to->name));
+ "Local socket %s with negative fd... AARGH!", to->name));
return;
}
else if (IsMe(to))
{
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Trying to send to myself!");
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "Trying to send to myself!");
return;
}
#endif
va_end(args);
send_linebuf(to_sendto, &linebuf);
linebuf_donebuf(&linebuf);
-} /* sendto_one() */
+} /* sendto_one() */
/*
* sendto_channel_butone
struct Channel *chptr, char *command,
const char *pattern, ...)
{
- va_list args;
+ va_list args;
buf_head_t local_linebuf;
buf_head_t remote_linebuf;
linebuf_newbuf(&remote_linebuf);
va_start(args, pattern);
- if(IsServer(from))
+ if (IsServer(from))
linebuf_putmsg(&local_linebuf, pattern, args, ":%s %s %s ",
from->name, command, RootChan(chptr)->chname);
else
linebuf_donebuf(&local_linebuf);
linebuf_donebuf(&remote_linebuf);
-} /* sendto_channel_butone() */
+} /* sendto_channel_butone() */
/*
* sendto_list_anywhere
*/
void
sendto_list_anywhere(struct Client *one, struct Client *from,
- dlink_list *list, buf_head_t *local_linebuf,
- buf_head_t *remote_linebuf)
+ dlink_list * list, buf_head_t * local_linebuf,
+ buf_head_t * remote_linebuf)
{
dlink_node *ptr;
struct Client *target_p;
if (MyConnect(target_p) && IsRegisteredUser(target_p))
{
- if(target_p->serial != current_serial)
+ if (target_p->serial != current_serial)
{
send_linebuf(target_p, local_linebuf);
target_p->serial = current_serial;
* Now check whether a message has been sent to this
* remote link already
*/
- if(target_p->from->serial != current_serial)
+ if (target_p->from->serial != current_serial)
{
send_linebuf_remote(target_p, from, remote_linebuf);
target_p->from->serial = current_serial;
* lazylinks, uids, etc.
* -davidt
*/
-void sendto_server(struct Client *one, struct Client *source_p,
- struct Channel *chptr, unsigned long caps,
- unsigned long nocaps, unsigned long llflags,
- char *format, ...)
+void
+sendto_server(struct Client *one, struct Client *source_p,
+ struct Channel *chptr, unsigned long caps,
+ unsigned long nocaps, unsigned long llflags, char *format, ...)
{
va_list args;
struct Client *client_p;
linebuf_putmsg(&linebuf, format, args, NULL);
va_end(args);
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
{
client_p = ptr->data;
if (!(llflags & LL_ICLIENT) && source_p &&
((source_p->lazyLinkClientExists &
client_p->localClient->serverMask) == 0))
- continue; /* we can't introduce the unknown source_p, skip */
+ continue; /* we can't introduce the unknown source_p, skip */
if (llflags & LL_ICHAN)
burst_channel(client_p, chptr);
else
- continue; /* we can't introduce the unknown chptr, skip */
+ continue; /* we can't introduce the unknown chptr, skip */
}
/* check LL client */
if (source_p &&
client_p->localClient->serverMask) == 0))
{
if (llflags & LL_ICLIENT)
- client_burst_if_needed(client_p,source_p);
+ client_burst_if_needed(client_p, source_p);
else
- continue; /* we can't introduce the unknown source_p, skip */
+ continue; /* we can't introduce the unknown source_p, skip */
}
}
send_linebuf(client_p, &linebuf);
}
linebuf_donebuf(&linebuf);
-} /* sendto_common_channels() */
+} /* sendto_common_channels() */
/*
* sendto_channel_local
*/
void
sendto_channel_local(int type,
- struct Channel *chptr,
- const char *pattern, ...)
+ struct Channel *chptr, const char *pattern, ...)
{
va_list args;
buf_head_t linebuf;
/* Serial number checking isn't strictly necessary, but won't hurt */
++current_serial;
- switch(type)
+ switch (type)
{
case NON_CHANOPS:
sendto_list_local(&chptr->locvoiced, &linebuf);
#endif
}
linebuf_donebuf(&linebuf);
-} /* sendto_channel_local() */
+} /* sendto_channel_local() */
/*
* sendto_channel_remote
*/
void
sendto_channel_remote(struct Client *one,
- struct Client *from, int type, int caps,
- int nocaps, struct Channel *chptr, char *pattern,
- ...)
+ struct Client *from, int type, int caps,
+ int nocaps, struct Channel *chptr, char *pattern, ...)
{
va_list args;
buf_head_t linebuf;
/* Serial number checking isn't strictly necessary, but won't hurt */
++current_serial;
- switch(type)
+ switch (type)
{
case NON_CHANOPS:
sendto_list_remote(one, from, &chptr->voiced, caps, nocaps, &linebuf);
sendto_list_remote(one, from, &chptr->peons, caps, nocaps, &linebuf);
break;
- /* Fall through to accumulate lists... */
+ /* Fall through to accumulate lists... */
default:
case ALL_MEMBERS:
sendto_list_remote(one, from, &chptr->peons, caps, nocaps, &linebuf);
#endif
}
linebuf_donebuf(&linebuf);
-} /* sendto_channel_remote() */
+} /* sendto_channel_remote() */
/*
* sendto_list_local
* list to send a message to a group of people.
*/
static void
-sendto_list_local(dlink_list *list, buf_head_t *linebuf_ptr)
+sendto_list_local(dlink_list * list, buf_head_t * linebuf_ptr)
{
dlink_node *ptr;
struct Client *target_p;
target_p->serial = current_serial;
send_linebuf(target_p, linebuf_ptr);
- }
-} /* sendto_list_local() */
+ }
+} /* sendto_list_local() */
/*
* sendto_list_remote(struct Client *one,
*/
static void
sendto_list_remote(struct Client *one,
- struct Client *from, dlink_list *list, int caps,
- int nocaps, buf_head_t *linebuf)
+ struct Client *from, dlink_list * list, int caps,
+ int nocaps, buf_head_t * linebuf)
{
dlink_node *ptr;
struct Client *target_p;
if (MyConnect(target_p))
continue;
- if (target_p == one) /* must skip the origin! */
+ if (target_p == one) /* must skip the origin! */
continue;
if (((target_p->from->localClient->caps & caps) != caps) ||
target_p->from->serial = current_serial;
send_linebuf(target_p, linebuf);
- }
-} /* sendto_list_remote() */
+ }
+} /* sendto_list_remote() */
/*
** match_it() and sendto_match_butone() ARE only used
*/
static int
match_it(const struct Client *one, const char *mask, int what)
-
{
- if(what == MATCH_HOST)
+ if (what == MATCH_HOST)
return match(mask, one->host);
return match(mask, one->user->server);
-} /* match_it() */
+} /* match_it() */
/*
* sendto_match_butone
*/
void
sendto_match_butone(struct Client *one, struct Client *from,
- char *mask, int what,
- const char *pattern, ...)
+ char *mask, int what, const char *pattern, ...)
{
va_list args;
struct Client *client_p;
linebuf_putmsg(&remote_linebuf, pattern, args, ":%s ", from->name);
linebuf_putmsg(&local_linebuf, pattern, args, ":%s!%s@%s ", from->name,
- from->username, from->host);
+ from->username, from->host);
va_end(args);
/* scan the local clients */
- for(ptr = lclient_list.head; ptr; ptr = ptr->next)
+ for (ptr = lclient_list.head; ptr; ptr = ptr->next)
{
client_p = ptr->data;
- if (client_p == one) /* must skip the origin !! */
+ if (client_p == one) /* must skip the origin !! */
continue;
if (match_it(client_p, mask, what))
{
client_p = ptr->data;
- if (client_p == one) /* must skip the origin !! */
+ if (client_p == one) /* must skip the origin !! */
continue;
/*
linebuf_donebuf(&local_linebuf);
linebuf_donebuf(&remote_linebuf);
-} /* sendto_match_butone() */
+} /* sendto_match_butone() */
/*
linebuf_newbuf(&linebuf);
va_start(args, pattern);
- if(MyClient(to))
+ if (MyClient(to))
{
- if(IsServer(from))
+ if (IsServer(from))
linebuf_putmsg(&linebuf, pattern, args, ":%s ", from->name);
else
linebuf_putmsg(&linebuf, pattern, args, ":%s!%s@%s ", from->name,
va_end(args);
- if(MyClient(to))
+ if (MyClient(to))
send_linebuf(to, &linebuf);
else
send_linebuf_remote(to, from, &linebuf);
void
sendto_realops_flags(int flags, int level, const char *pattern, ...)
-
{
struct Client *client_p;
- char nbuf[IRCD_BUFSIZE*2];
+ char nbuf[IRCD_BUFSIZE * 2];
dlink_node *ptr;
va_list args;
buf_head_t linebuf;
/* If we're sending it to opers and theyre an admin, skip.
* If we're sending it to admins, and theyre not, skip.
*/
- if(((level == L_ADMIN) && !IsAdmin(client_p)) ||
- ((level == L_OPER) && IsAdmin(client_p)))
+ if (((level == L_ADMIN) && !IsAdmin(client_p)) ||
+ ((level == L_OPER) && IsAdmin(client_p)))
continue;
- if(client_p->umodes & flags)
+ if (client_p->umodes & flags)
{
linebuf_newbuf(&linebuf);
linebuf_putmsg(&linebuf, NULL, NULL,
linebuf_donebuf(&linebuf);
}
}
-} /* sendto_realops_flags() */
+} /* sendto_realops_flags() */
/*
* sendto_wallops_flags
buf_head_t linebuf;
linebuf_newbuf(&linebuf);
-
+
va_start(args, pattern);
- if(IsPerson(source_p))
+ if (IsPerson(source_p))
linebuf_putmsg(&linebuf, pattern, args, ":%s!%s@%s WALLOPS :",
source_p->name, source_p->username, source_p->host);
else
{
client_p = ptr->data;
- if(client_p->umodes & flags)
+ if (client_p->umodes & flags)
send_linebuf(client_p, &linebuf);
}
linebuf_donebuf(&linebuf);
(void)send_format(lbuf, pattern, args);
va_end(args);
- sendto_realops_flags(FLAGS_ALL, L_ALL,"%s",lbuf);
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%s", lbuf);
ilog(L_CRIT, "%s", lbuf);
-} /* ts_warn() */
+} /* ts_warn() */
/*
static inline int
send_format(char *lsendbuf, const char *pattern, va_list args)
{
- int len; /* used for the length of the current message */
+ int len; /* used for the length of the current message */
len = vsprintf_irc(lsendbuf, pattern, args);
- return (send_trim(lsendbuf,len));
+ return (send_trim(lsendbuf, len));
}
/*
* side effects - input buffer is trimmed if needed
*/
static inline int
-send_trim(char *lsendbuf,int len)
+send_trim(char *lsendbuf, int len)
{
/*
* from rfc1459
* -wnder
*/
- if(len > 510)
+ if (len > 510)
{
- lsendbuf[IRCD_BUFSIZE-2] = '\r';
- lsendbuf[IRCD_BUFSIZE-1] = '\n';
+ lsendbuf[IRCD_BUFSIZE - 2] = '\r';
+ lsendbuf[IRCD_BUFSIZE - 1] = '\n';
lsendbuf[IRCD_BUFSIZE] = '\0';
- return(IRCD_BUFSIZE);
+ return (IRCD_BUFSIZE);
}
return len;
}
buf_head_t linebuf;
linebuf_newbuf(&linebuf);
-
+
va_start(args, pattern);
- if(HasID(diedie) && IsCapable(client_p, CAP_UID))
+ if (HasID(diedie) && IsCapable(client_p, CAP_UID))
linebuf_putmsg(&linebuf, pattern, args, ":%s KILL %s :",
me.name, ID(diedie));
else
va_start(args, pattern);
- if(HasID(source_p))
+ if (HasID(source_p))
{
have_uid = 1;
linebuf_newbuf(&linebuf_uid);
va_end(args);
- for(ptr = serv_list.head; ptr; ptr = ptr->next)
+ for (ptr = serv_list.head; ptr; ptr = ptr->next)
{
client_p = ptr->data;
if (one && (client_p == one->from))
continue;
- if (IsCapable(client_p,CAP_LL) && ServerInfo.hub)
+ if (IsCapable(client_p, CAP_LL) && ServerInfo.hub)
{
- if((source_p->lazyLinkClientExists &
- client_p->localClient->serverMask) != 0)
+ if ((source_p->lazyLinkClientExists &
+ client_p->localClient->serverMask) != 0)
{
if (have_uid && IsCapable(client_p, CAP_UID))
send_linebuf(client_p, &linebuf_uid);
if (have_uid)
linebuf_donebuf(&linebuf_uid);
linebuf_donebuf(&linebuf_nick);
-}
+}
* Ungraciously stolen from mutt, by Aaron Sethman, for the very sad machine that
* does not have vsnprintf or snprintf
*
- * $Id: snprintf.c,v 1.1 2002/01/04 09:14:55 a1kmm Exp $
- */
+ * $Id: snprintf.c,v 1.2 2002/01/04 11:06:43 a1kmm Exp $
+ */
/**************************************************************
/* varargs declarations: */
# include <stdarg.h>
-# define HAVE_STDARGS /* let's hope that works everywhere (mj) */
+# define HAVE_STDARGS /* let's hope that works everywhere (mj) */
# define VA_LOCAL_DECL va_list ap
# define VA_START(f) va_start(ap, f)
-# define VA_SHIFT(v,t) ; /* no-op for ANSI */
+# define VA_SHIFT(v,t) ; /* no-op for ANSI */
# define VA_END va_end(ap)
/*int snprintf (char *str, size_t count, const char *fmt, ...);*/
/*int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);*/
-static void dopr (char *buffer, size_t maxlen, const char *format,
- va_list args);
-static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
- char *value, int flags, int min, int max);
-static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
- long value, int base, int min, int max, int flags);
-static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- long double fvalue, int min, int max, int flags);
-static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
+static void dopr(char *buffer, size_t maxlen, const char *format,
+ va_list args);
+static void fmtstr(char *buffer, size_t * currlen, size_t maxlen,
+ char *value, int flags, int min, int max);
+static void fmtint(char *buffer, size_t * currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags);
+static void fmtfp(char *buffer, size_t * currlen, size_t maxlen,
+ long double fvalue, int min, int max, int flags);
+static void dopr_outch(char *buffer, size_t * currlen, size_t maxlen, char c);
/*
* dopr(): poor man's version of doprintf
#undef MAX
#define MAX(p,q) ((p >= q) ? p : q)
-static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
+static void
+dopr(char *buffer, size_t maxlen, const char *format, va_list args)
{
char ch;
long value;
int flags;
int cflags;
size_t currlen;
-
+
state = DP_S_DEFAULT;
currlen = flags = cflags = min = 0;
max = -1;
while (state != DP_S_DONE)
{
- if ((ch == '\0') || (currlen >= maxlen))
+ if ((ch == '\0') || (currlen >= maxlen))
state = DP_S_DONE;
- switch(state)
+ switch (state)
{
- case DP_S_DEFAULT:
- if (ch == '%')
- state = DP_S_FLAGS;
- else
- dopr_outch (buffer, &currlen, maxlen, ch);
- ch = *format++;
- break;
- case DP_S_FLAGS:
- switch (ch)
- {
- case '-':
- flags |= DP_F_MINUS;
- ch = *format++;
- break;
- case '+':
- flags |= DP_F_PLUS;
- ch = *format++;
- break;
- case ' ':
- flags |= DP_F_SPACE;
- ch = *format++;
- break;
- case '#':
- flags |= DP_F_NUM;
+ case DP_S_DEFAULT:
+ if (ch == '%')
+ state = DP_S_FLAGS;
+ else
+ dopr_outch(buffer, &currlen, maxlen, ch);
ch = *format++;
- break;
- case '0':
- flags |= DP_F_ZERO;
- ch = *format++;
- break;
- default:
- state = DP_S_MIN;
- break;
- }
- break;
- case DP_S_MIN:
- if (isdigit((unsigned char)ch))
- {
- min = 10*min + char_to_int (ch);
- ch = *format++;
- }
- else if (ch == '*')
- {
- min = va_arg (args, int);
- ch = *format++;
- state = DP_S_DOT;
- }
- else
- state = DP_S_DOT;
- break;
- case DP_S_DOT:
- if (ch == '.')
- {
- state = DP_S_MAX;
- ch = *format++;
- }
- else
- state = DP_S_MOD;
- break;
- case DP_S_MAX:
- if (isdigit((unsigned char)ch))
- {
- if (max < 0)
- max = 0;
- max = 10*max + char_to_int (ch);
- ch = *format++;
- }
- else if (ch == '*')
- {
- max = va_arg (args, int);
- ch = *format++;
- state = DP_S_MOD;
- }
- else
- state = DP_S_MOD;
- break;
- case DP_S_MOD:
- /* Currently, we don't support Long Long, bummer */
- switch (ch)
- {
- case 'h':
- cflags = DP_C_SHORT;
- ch = *format++;
- break;
- case 'l':
- cflags = DP_C_LONG;
- ch = *format++;
- break;
- case 'L':
- cflags = DP_C_LDOUBLE;
- ch = *format++;
- break;
- default:
- break;
- }
- state = DP_S_CONV;
- break;
- case DP_S_CONV:
- switch (ch)
- {
- case 'd':
- case 'i':
- if (cflags == DP_C_SHORT)
- value = va_arg (args, short int);
- else if (cflags == DP_C_LONG)
- value = va_arg (args, long int);
- else
- value = va_arg (args, int);
- fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
- break;
- case 'o':
- flags |= DP_F_UNSIGNED;
- if (cflags == DP_C_SHORT)
- value = va_arg (args, unsigned short int);
- else if (cflags == DP_C_LONG)
- value = va_arg (args, unsigned long int);
- else
- value = va_arg (args, unsigned int);
- fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
- break;
- case 'u':
- flags |= DP_F_UNSIGNED;
- if (cflags == DP_C_SHORT)
- value = va_arg (args, unsigned short int);
- else if (cflags == DP_C_LONG)
- value = va_arg (args, unsigned long int);
- else
- value = va_arg (args, unsigned int);
- fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
- break;
- case 'X':
- flags |= DP_F_UP;
- case 'x':
- flags |= DP_F_UNSIGNED;
- if (cflags == DP_C_SHORT)
- value = va_arg (args, unsigned short int);
- else if (cflags == DP_C_LONG)
- value = va_arg (args, unsigned long int);
- else
- value = va_arg (args, unsigned int);
- fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
- break;
- case 'f':
- if (cflags == DP_C_LDOUBLE)
- fvalue = va_arg (args, long double);
- else
- fvalue = va_arg (args, double);
- /* um, floating point? */
- fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
- break;
- case 'E':
- flags |= DP_F_UP;
- case 'e':
- if (cflags == DP_C_LDOUBLE)
- fvalue = va_arg (args, long double);
- else
- fvalue = va_arg (args, double);
- break;
- case 'G':
- flags |= DP_F_UP;
- case 'g':
- if (cflags == DP_C_LDOUBLE)
- fvalue = va_arg (args, long double);
- else
- fvalue = va_arg (args, double);
- break;
- case 'c':
- dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
- break;
- case 's':
- strvalue = va_arg (args, char *);
- if (max < 0)
- max = maxlen; /* ie, no max */
- fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
- break;
- case 'p':
- strvalue = va_arg (args, void *);
- fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
- break;
- case 'n':
- if (cflags == DP_C_SHORT)
- {
- short int *num;
- num = va_arg (args, short int *);
- *num = currlen;
- }
- else if (cflags == DP_C_LONG)
- {
- long int *num;
- num = va_arg (args, long int *);
- *num = currlen;
- }
- else
- {
- int *num;
- num = va_arg (args, int *);
- *num = currlen;
+ break;
+ case DP_S_FLAGS:
+ switch (ch)
+ {
+ case '-':
+ flags |= DP_F_MINUS;
+ ch = *format++;
+ break;
+ case '+':
+ flags |= DP_F_PLUS;
+ ch = *format++;
+ break;
+ case ' ':
+ flags |= DP_F_SPACE;
+ ch = *format++;
+ break;
+ case '#':
+ flags |= DP_F_NUM;
+ ch = *format++;
+ break;
+ case '0':
+ flags |= DP_F_ZERO;
+ ch = *format++;
+ break;
+ default:
+ state = DP_S_MIN;
+ break;
+ }
+ break;
+ case DP_S_MIN:
+ if (isdigit((unsigned char)ch))
+ {
+ min = 10 * min + char_to_int(ch);
+ ch = *format++;
+ }
+ else if (ch == '*')
+ {
+ min = va_arg(args, int);
+ ch = *format++;
+ state = DP_S_DOT;
+ }
+ else
+ state = DP_S_DOT;
+ break;
+ case DP_S_DOT:
+ if (ch == '.')
+ {
+ state = DP_S_MAX;
+ ch = *format++;
+ }
+ else
+ state = DP_S_MOD;
+ break;
+ case DP_S_MAX:
+ if (isdigit((unsigned char)ch))
+ {
+ if (max < 0)
+ max = 0;
+ max = 10 * max + char_to_int(ch);
+ ch = *format++;
+ }
+ else if (ch == '*')
+ {
+ max = va_arg(args, int);
+ ch = *format++;
+ state = DP_S_MOD;
+ }
+ else
+ state = DP_S_MOD;
+ break;
+ case DP_S_MOD:
+ /* Currently, we don't support Long Long, bummer */
+ switch (ch)
+ {
+ case 'h':
+ cflags = DP_C_SHORT;
+ ch = *format++;
+ break;
+ case 'l':
+ cflags = DP_C_LONG;
+ ch = *format++;
+ break;
+ case 'L':
+ cflags = DP_C_LDOUBLE;
+ ch = *format++;
+ break;
+ default:
+ break;
}
- break;
- case '%':
- dopr_outch (buffer, &currlen, maxlen, ch);
- break;
- case 'w':
- /* not supported yet, treat as next char */
- ch = *format++;
- break;
+ state = DP_S_CONV;
+ break;
+ case DP_S_CONV:
+ switch (ch)
+ {
+ case 'd':
+ case 'i':
+ if (cflags == DP_C_SHORT)
+ value = va_arg(args, short int);
+ else if (cflags == DP_C_LONG)
+ value = va_arg(args, long int);
+ else
+ value = va_arg(args, int);
+ fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags);
+ break;
+ case 'o':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg(args, unsigned short int);
+ else if (cflags == DP_C_LONG)
+ value = va_arg(args, unsigned long int);
+ else
+ value = va_arg(args, unsigned int);
+ fmtint(buffer, &currlen, maxlen, value, 8, min, max, flags);
+ break;
+ case 'u':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg(args, unsigned short int);
+ else if (cflags == DP_C_LONG)
+ value = va_arg(args, unsigned long int);
+ else
+ value = va_arg(args, unsigned int);
+ fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags);
+ break;
+ case 'X':
+ flags |= DP_F_UP;
+ case 'x':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg(args, unsigned short int);
+ else if (cflags == DP_C_LONG)
+ value = va_arg(args, unsigned long int);
+ else
+ value = va_arg(args, unsigned int);
+ fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags);
+ break;
+ case 'f':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg(args, long double);
+ else
+ fvalue = va_arg(args, double);
+ /* um, floating point? */
+ fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags);
+ break;
+ case 'E':
+ flags |= DP_F_UP;
+ case 'e':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg(args, long double);
+ else
+ fvalue = va_arg(args, double);
+ break;
+ case 'G':
+ flags |= DP_F_UP;
+ case 'g':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg(args, long double);
+ else
+ fvalue = va_arg(args, double);
+ break;
+ case 'c':
+ dopr_outch(buffer, &currlen, maxlen, va_arg(args, int));
+ break;
+ case 's':
+ strvalue = va_arg(args, char *);
+ if (max < 0)
+ max = maxlen; /* ie, no max */
+ fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max);
+ break;
+ case 'p':
+ strvalue = va_arg(args, void *);
+ fmtint(buffer, &currlen, maxlen, (long)strvalue, 16, min, max,
+ flags);
+ break;
+ case 'n':
+ if (cflags == DP_C_SHORT)
+ {
+ short int *num;
+ num = va_arg(args, short int *);
+ *num = currlen;
+ }
+ else if (cflags == DP_C_LONG)
+ {
+ long int *num;
+ num = va_arg(args, long int *);
+ *num = currlen;
+ }
+ else
+ {
+ int *num;
+ num = va_arg(args, int *);
+ *num = currlen;
+ }
+ break;
+ case '%':
+ dopr_outch(buffer, &currlen, maxlen, ch);
+ break;
+ case 'w':
+ /* not supported yet, treat as next char */
+ ch = *format++;
+ break;
+ default:
+ /* Unknown, skip */
+ break;
+ }
+ ch = *format++;
+ state = DP_S_DEFAULT;
+ flags = cflags = min = 0;
+ max = -1;
+ break;
+ case DP_S_DONE:
+ break;
default:
- /* Unknown, skip */
- break;
- }
- ch = *format++;
- state = DP_S_DEFAULT;
- flags = cflags = min = 0;
- max = -1;
- break;
- case DP_S_DONE:
- break;
- default:
- /* hmm? */
- break; /* some picky compilers need this */
+ /* hmm? */
+ break; /* some picky compilers need this */
}
}
- if (currlen < maxlen - 1)
+ if (currlen < maxlen - 1)
buffer[currlen] = '\0';
- else
+ else
buffer[maxlen - 1] = '\0';
}
-static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
- char *value, int flags, int min, int max)
+static void
+fmtstr(char *buffer, size_t * currlen, size_t maxlen,
+ char *value, int flags, int min, int max)
{
- int padlen, strln; /* amount to pad */
+ int padlen, strln; /* amount to pad */
int cnt = 0;
-
+
if (value == 0)
{
value = "<NULL>";
}
- for (strln = 0; value[strln]; ++strln); /* strlen */
+ for (strln = 0; value[strln]; ++strln); /* strlen */
padlen = min - strln;
- if (padlen < 0)
+ if (padlen < 0)
padlen = 0;
- if (flags & DP_F_MINUS)
- padlen = -padlen; /* Left Justify */
+ if (flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justify */
- while ((padlen > 0) && (cnt < max))
+ while ((padlen > 0) && (cnt < max))
{
- dopr_outch (buffer, currlen, maxlen, ' ');
+ dopr_outch(buffer, currlen, maxlen, ' ');
--padlen;
++cnt;
}
- while (*value && (cnt < max))
+ while (*value && (cnt < max))
{
- dopr_outch (buffer, currlen, maxlen, *value++);
+ dopr_outch(buffer, currlen, maxlen, *value++);
++cnt;
}
- while ((padlen < 0) && (cnt < max))
+ while ((padlen < 0) && (cnt < max))
{
- dopr_outch (buffer, currlen, maxlen, ' ');
+ dopr_outch(buffer, currlen, maxlen, ' ');
++padlen;
++cnt;
}
/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
-static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
- long value, int base, int min, int max, int flags)
+static void
+fmtint(char *buffer, size_t * currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags)
{
int signvalue = 0;
unsigned long uvalue;
char convert[20];
int place = 0;
- int spadlen = 0; /* amount to space pad */
- int zpadlen = 0; /* amount to zero pad */
+ int spadlen = 0; /* amount to space pad */
+ int zpadlen = 0; /* amount to zero pad */
int caps = 0;
-
+
if (max < 0)
max = 0;
uvalue = value;
- if(!(flags & DP_F_UNSIGNED))
+ if (!(flags & DP_F_UNSIGNED))
{
- if( value < 0 ) {
+ if (value < 0)
+ {
signvalue = '-';
uvalue = -value;
}
- else
- if (flags & DP_F_PLUS) /* Do a sign (+/i) */
- signvalue = '+';
- else
- if (flags & DP_F_SPACE)
- signvalue = ' ';
+ else if (flags & DP_F_PLUS) /* Do a sign (+/i) */
+ signvalue = '+';
+ else if (flags & DP_F_SPACE)
+ signvalue = ' ';
}
-
- if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
- do {
+ if (flags & DP_F_UP)
+ caps = 1; /* Should characters be upper case? */
+
+ do
+ {
convert[place++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")
- [uvalue % (unsigned)base ];
- uvalue = (uvalue / (unsigned)base );
- } while(uvalue && (place < 20));
- if (place == 20) place--;
+ (caps ? "0123456789ABCDEF" : "0123456789abcdef")
+ [uvalue % (unsigned)base];
+ uvalue = (uvalue / (unsigned)base);
+ } while (uvalue && (place < 20));
+ if (place == 20)
+ place--;
convert[place] = 0;
zpadlen = max - place;
- spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
- if (zpadlen < 0) zpadlen = 0;
- if (spadlen < 0) spadlen = 0;
+ spadlen = min - MAX(max, place) - (signvalue ? 1 : 0);
+ if (zpadlen < 0)
+ zpadlen = 0;
+ if (spadlen < 0)
+ spadlen = 0;
if (flags & DP_F_ZERO)
{
zpadlen = MAX(zpadlen, spadlen);
spadlen = 0;
}
- if (flags & DP_F_MINUS)
- spadlen = -spadlen; /* Left Justifty */
+ if (flags & DP_F_MINUS)
+ spadlen = -spadlen; /* Left Justifty */
#ifdef DEBUG_SNPRINTF
- dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
- zpadlen, spadlen, min, max, place));
+ dprint(1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
+ zpadlen, spadlen, min, max, place));
#endif
/* Spaces */
- while (spadlen > 0)
+ while (spadlen > 0)
{
- dopr_outch (buffer, currlen, maxlen, ' ');
+ dopr_outch(buffer, currlen, maxlen, ' ');
--spadlen;
}
/* Sign */
- if (signvalue)
- dopr_outch (buffer, currlen, maxlen, signvalue);
+ if (signvalue)
+ dopr_outch(buffer, currlen, maxlen, signvalue);
/* Zeros */
- if (zpadlen > 0)
+ if (zpadlen > 0)
{
while (zpadlen > 0)
{
- dopr_outch (buffer, currlen, maxlen, '0');
+ dopr_outch(buffer, currlen, maxlen, '0');
--zpadlen;
}
}
/* Digits */
- while (place > 0)
- dopr_outch (buffer, currlen, maxlen, convert[--place]);
-
+ while (place > 0)
+ dopr_outch(buffer, currlen, maxlen, convert[--place]);
+
/* Left Justified spaces */
- while (spadlen < 0) {
- dopr_outch (buffer, currlen, maxlen, ' ');
+ while (spadlen < 0)
+ {
+ dopr_outch(buffer, currlen, maxlen, ' ');
++spadlen;
}
}
-static long double abs_val (long double value)
+static long double
+abs_val(long double value)
{
long double result = value;
return result;
}
-static long double pow10 (int exp)
+static long double
+pow10(int exp)
{
long double result = 1;
result *= 10;
exp--;
}
-
+
return result;
}
-static long round (long double value)
+static long
+round(long double value)
{
long intpart;
return intpart;
}
-static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- long double fvalue, int min, int max, int flags)
+static void
+fmtfp(char *buffer, size_t * currlen, size_t maxlen,
+ long double fvalue, int min, int max, int flags)
{
int signvalue = 0;
long double ufvalue;
char fconvert[20];
int iplace = 0;
int fplace = 0;
- int padlen = 0; /* amount to pad */
- int zpadlen = 0;
+ int padlen = 0; /* amount to pad */
+ int zpadlen = 0;
int caps = 0;
long intpart;
long fracpart;
-
+
/*
* AIX manpage says the default is 0, but Solaris says the default
* is 6, and sprintf on AIX defaults to 6
if (max < 0)
max = 6;
- ufvalue = abs_val (fvalue);
+ ufvalue = abs_val(fvalue);
if (fvalue < 0)
signvalue = '-';
- else
- if (flags & DP_F_PLUS) /* Do a sign (+/i) */
- signvalue = '+';
- else
- if (flags & DP_F_SPACE)
- signvalue = ' ';
+ else if (flags & DP_F_PLUS) /* Do a sign (+/i) */
+ signvalue = '+';
+ else if (flags & DP_F_SPACE)
+ signvalue = ' ';
intpart = ufvalue;
/* We "cheat" by converting the fractional part to integer by
* multiplying by a factor of 10
*/
- fracpart = round ((pow10 (max)) * (ufvalue - intpart));
+ fracpart = round((pow10(max)) * (ufvalue - intpart));
- if (fracpart >= pow10 (max))
+ if (fracpart >= pow10(max))
{
intpart++;
- fracpart -= pow10 (max);
+ fracpart -= pow10(max);
}
#ifdef DEBUG_SNPRINTF
- dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
+ dprint(1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
#endif
/* Convert integer part */
- do {
+ do
+ {
iconvert[iplace++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10];
+ (caps ? "0123456789ABCDEF" : "0123456789abcdef")[intpart % 10];
intpart = (intpart / 10);
- } while(intpart && (iplace < 20));
- if (iplace == 20) iplace--;
+ } while (intpart && (iplace < 20));
+ if (iplace == 20)
+ iplace--;
iconvert[iplace] = 0;
/* Convert fractional part */
- do {
+ do
+ {
fconvert[fplace++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
+ (caps ? "0123456789ABCDEF" : "0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
- } while(fracpart && (fplace < 20));
- if (fplace == 20) fplace--;
+ } while (fracpart && (fplace < 20));
+ if (fplace == 20)
+ fplace--;
fconvert[fplace] = 0;
/* -1 for decimal point, another -1 if we are printing a sign */
- padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
+ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
zpadlen = max - fplace;
if (zpadlen < 0)
zpadlen = 0;
- if (padlen < 0)
+ if (padlen < 0)
padlen = 0;
- if (flags & DP_F_MINUS)
- padlen = -padlen; /* Left Justifty */
+ if (flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justifty */
- if ((flags & DP_F_ZERO) && (padlen > 0))
+ if ((flags & DP_F_ZERO) && (padlen > 0))
{
- if (signvalue)
+ if (signvalue)
{
- dopr_outch (buffer, currlen, maxlen, signvalue);
+ dopr_outch(buffer, currlen, maxlen, signvalue);
--padlen;
signvalue = 0;
}
while (padlen > 0)
{
- dopr_outch (buffer, currlen, maxlen, '0');
+ dopr_outch(buffer, currlen, maxlen, '0');
--padlen;
}
}
while (padlen > 0)
{
- dopr_outch (buffer, currlen, maxlen, ' ');
+ dopr_outch(buffer, currlen, maxlen, ' ');
--padlen;
}
- if (signvalue)
- dopr_outch (buffer, currlen, maxlen, signvalue);
+ if (signvalue)
+ dopr_outch(buffer, currlen, maxlen, signvalue);
- while (iplace > 0)
- dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
+ while (iplace > 0)
+ dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]);
/*
* Decimal point. This should probably use locale to find the correct
* char to print out.
*/
- dopr_outch (buffer, currlen, maxlen, '.');
+ dopr_outch(buffer, currlen, maxlen, '.');
- while (fplace > 0)
- dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
+ while (fplace > 0)
+ dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]);
while (zpadlen > 0)
{
- dopr_outch (buffer, currlen, maxlen, '0');
+ dopr_outch(buffer, currlen, maxlen, '0');
--zpadlen;
}
- while (padlen < 0)
+ while (padlen < 0)
{
- dopr_outch (buffer, currlen, maxlen, ' ');
+ dopr_outch(buffer, currlen, maxlen, ' ');
++padlen;
}
}
-static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
+static void
+dopr_outch(char *buffer, size_t * currlen, size_t maxlen, char c)
{
if (*currlen < maxlen)
buffer[(*currlen)++] = c;
#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_VSNPRINTF
-int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
+int
+vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{
str[0] = 0;
dopr(str, count, fmt, args);
- return(strlen(str));
+ return (strlen(str));
}
#endif /* !HAVE_VSNPRINTF */
#ifndef HAVE_SNPRINTF
/* VARARGS3 */
#ifdef HAVE_STDARGS
-int snprintf (char *str,size_t count,const char *fmt,...)
+int
+snprintf(char *str, size_t count, const char *fmt, ...)
#else
-int snprintf (va_alist) va_dcl
+int
+snprintf(va_alist)
+ va_dcl
#endif
{
#ifndef HAVE_STDARGS
char *fmt;
#endif
VA_LOCAL_DECL;
-
- VA_START (fmt);
- VA_SHIFT (str, char *);
- VA_SHIFT (count, size_t );
- VA_SHIFT (fmt, char *);
- (void) vsnprintf(str, count, fmt, ap);
+
+ VA_START(fmt);
+ VA_SHIFT(str, char *);
+ VA_SHIFT(count, size_t);
+ VA_SHIFT(fmt, char *);
+ (void)vsnprintf(str, count, fmt, ap);
VA_END;
- return(strlen(str));
+ return (strlen(str));
}
#ifdef TEST_SNPRINTF
#ifndef LONG_STRING
#define LONG_STRING 1024
#endif
-int main (void)
+int
+main(void)
{
char buf1[LONG_STRING];
char buf2[LONG_STRING];
"%3.2f",
NULL
};
- double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
- 0.9996, 1.996, 4.136, 0};
+ double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
+ 0.9996, 1.996, 4.136, 0
+ };
char *int_fmt[] = {
"%-1.5d",
"%1.5d",
"%4d",
NULL
};
- long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
+ long int_nums[] = { -1, 134, 91340, 341, 0203, 0 };
int x, y;
int fail = 0;
int num = 0;
- printf ("Testing snprintf format codes against system sprintf...\n");
+ printf("Testing snprintf format codes against system sprintf...\n");
- for (x = 0; fp_fmt[x] != NULL ; x++)
- for (y = 0; fp_nums[y] != 0 ; y++)
+ for (x = 0; fp_fmt[x] != NULL; x++)
+ for (y = 0; fp_nums[y] != 0; y++)
{
- snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]);
- sprintf (buf2, fp_fmt[x], fp_nums[y]);
- if (strcmp (buf1, buf2))
+ snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
+ sprintf(buf2, fp_fmt[x], fp_nums[y]);
+ if (strcmp(buf1, buf2))
{
- printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", /* __SPRINTF_CHECKED__ */
- fp_fmt[x], buf1, buf2);
- fail++;
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", /* __SPRINTF_CHECKED__ */
+ fp_fmt[x], buf1, buf2);
+ fail++;
}
num++;
}
- for (x = 0; int_fmt[x] != NULL ; x++)
- for (y = 0; int_nums[y] != 0 ; y++)
+ for (x = 0; int_fmt[x] != NULL; x++)
+ for (y = 0; int_nums[y] != 0; y++)
{
- snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]);
- sprintf (buf2, int_fmt[x], int_nums[y]);
- if (strcmp (buf1, buf2))
+ snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
+ sprintf(buf2, int_fmt[x], int_nums[y]);
+ if (strcmp(buf1, buf2))
{
- printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", /* __SPRINTF_CHECKED__ */
- int_fmt[x], buf1, buf2);
- fail++;
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", /* __SPRINTF_CHECKED__ */
+ int_fmt[x], buf1, buf2);
+ fail++;
}
num++;
}
- printf ("%d tests failed out of %d.\n", fail, num);
+ printf("%d tests failed out of %d.\n", fail, num);
}
#endif /* SNPRINTF_TEST */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: sprintf_irc.c,v 1.1 2002/01/04 09:14:55 a1kmm Exp $
+ * $Id: sprintf_irc.c,v 1.2 2002/01/04 11:06:44 a1kmm Exp $
*/
#include "sprintf_irc.h"
#include "irc_string.h"
#include <stdio.h>
const char atoi_tab[4000] = {
- '0','0','0',0, '0','0','1',0, '0','0','2',0, '0','0','3',0, '0','0','4',0,
- '0','0','5',0, '0','0','6',0, '0','0','7',0, '0','0','8',0, '0','0','9',0,
- '0','1','0',0, '0','1','1',0, '0','1','2',0, '0','1','3',0, '0','1','4',0,
- '0','1','5',0, '0','1','6',0, '0','1','7',0, '0','1','8',0, '0','1','9',0,
- '0','2','0',0, '0','2','1',0, '0','2','2',0, '0','2','3',0, '0','2','4',0,
- '0','2','5',0, '0','2','6',0, '0','2','7',0, '0','2','8',0, '0','2','9',0,
- '0','3','0',0, '0','3','1',0, '0','3','2',0, '0','3','3',0, '0','3','4',0,
- '0','3','5',0, '0','3','6',0, '0','3','7',0, '0','3','8',0, '0','3','9',0,
- '0','4','0',0, '0','4','1',0, '0','4','2',0, '0','4','3',0, '0','4','4',0,
- '0','4','5',0, '0','4','6',0, '0','4','7',0, '0','4','8',0, '0','4','9',0,
- '0','5','0',0, '0','5','1',0, '0','5','2',0, '0','5','3',0, '0','5','4',0,
- '0','5','5',0, '0','5','6',0, '0','5','7',0, '0','5','8',0, '0','5','9',0,
- '0','6','0',0, '0','6','1',0, '0','6','2',0, '0','6','3',0, '0','6','4',0,
- '0','6','5',0, '0','6','6',0, '0','6','7',0, '0','6','8',0, '0','6','9',0,
- '0','7','0',0, '0','7','1',0, '0','7','2',0, '0','7','3',0, '0','7','4',0,
- '0','7','5',0, '0','7','6',0, '0','7','7',0, '0','7','8',0, '0','7','9',0,
- '0','8','0',0, '0','8','1',0, '0','8','2',0, '0','8','3',0, '0','8','4',0,
- '0','8','5',0, '0','8','6',0, '0','8','7',0, '0','8','8',0, '0','8','9',0,
- '0','9','0',0, '0','9','1',0, '0','9','2',0, '0','9','3',0, '0','9','4',0,
- '0','9','5',0, '0','9','6',0, '0','9','7',0, '0','9','8',0, '0','9','9',0,
- '1','0','0',0, '1','0','1',0, '1','0','2',0, '1','0','3',0, '1','0','4',0,
- '1','0','5',0, '1','0','6',0, '1','0','7',0, '1','0','8',0, '1','0','9',0,
- '1','1','0',0, '1','1','1',0, '1','1','2',0, '1','1','3',0, '1','1','4',0,
- '1','1','5',0, '1','1','6',0, '1','1','7',0, '1','1','8',0, '1','1','9',0,
- '1','2','0',0, '1','2','1',0, '1','2','2',0, '1','2','3',0, '1','2','4',0,
- '1','2','5',0, '1','2','6',0, '1','2','7',0, '1','2','8',0, '1','2','9',0,
- '1','3','0',0, '1','3','1',0, '1','3','2',0, '1','3','3',0, '1','3','4',0,
- '1','3','5',0, '1','3','6',0, '1','3','7',0, '1','3','8',0, '1','3','9',0,
- '1','4','0',0, '1','4','1',0, '1','4','2',0, '1','4','3',0, '1','4','4',0,
- '1','4','5',0, '1','4','6',0, '1','4','7',0, '1','4','8',0, '1','4','9',0,
- '1','5','0',0, '1','5','1',0, '1','5','2',0, '1','5','3',0, '1','5','4',0,
- '1','5','5',0, '1','5','6',0, '1','5','7',0, '1','5','8',0, '1','5','9',0,
- '1','6','0',0, '1','6','1',0, '1','6','2',0, '1','6','3',0, '1','6','4',0,
- '1','6','5',0, '1','6','6',0, '1','6','7',0, '1','6','8',0, '1','6','9',0,
- '1','7','0',0, '1','7','1',0, '1','7','2',0, '1','7','3',0, '1','7','4',0,
- '1','7','5',0, '1','7','6',0, '1','7','7',0, '1','7','8',0, '1','7','9',0,
- '1','8','0',0, '1','8','1',0, '1','8','2',0, '1','8','3',0, '1','8','4',0,
- '1','8','5',0, '1','8','6',0, '1','8','7',0, '1','8','8',0, '1','8','9',0,
- '1','9','0',0, '1','9','1',0, '1','9','2',0, '1','9','3',0, '1','9','4',0,
- '1','9','5',0, '1','9','6',0, '1','9','7',0, '1','9','8',0, '1','9','9',0,
- '2','0','0',0, '2','0','1',0, '2','0','2',0, '2','0','3',0, '2','0','4',0,
- '2','0','5',0, '2','0','6',0, '2','0','7',0, '2','0','8',0, '2','0','9',0,
- '2','1','0',0, '2','1','1',0, '2','1','2',0, '2','1','3',0, '2','1','4',0,
- '2','1','5',0, '2','1','6',0, '2','1','7',0, '2','1','8',0, '2','1','9',0,
- '2','2','0',0, '2','2','1',0, '2','2','2',0, '2','2','3',0, '2','2','4',0,
- '2','2','5',0, '2','2','6',0, '2','2','7',0, '2','2','8',0, '2','2','9',0,
- '2','3','0',0, '2','3','1',0, '2','3','2',0, '2','3','3',0, '2','3','4',0,
- '2','3','5',0, '2','3','6',0, '2','3','7',0, '2','3','8',0, '2','3','9',0,
- '2','4','0',0, '2','4','1',0, '2','4','2',0, '2','4','3',0, '2','4','4',0,
- '2','4','5',0, '2','4','6',0, '2','4','7',0, '2','4','8',0, '2','4','9',0,
- '2','5','0',0, '2','5','1',0, '2','5','2',0, '2','5','3',0, '2','5','4',0,
- '2','5','5',0, '2','5','6',0, '2','5','7',0, '2','5','8',0, '2','5','9',0,
- '2','6','0',0, '2','6','1',0, '2','6','2',0, '2','6','3',0, '2','6','4',0,
- '2','6','5',0, '2','6','6',0, '2','6','7',0, '2','6','8',0, '2','6','9',0,
- '2','7','0',0, '2','7','1',0, '2','7','2',0, '2','7','3',0, '2','7','4',0,
- '2','7','5',0, '2','7','6',0, '2','7','7',0, '2','7','8',0, '2','7','9',0,
- '2','8','0',0, '2','8','1',0, '2','8','2',0, '2','8','3',0, '2','8','4',0,
- '2','8','5',0, '2','8','6',0, '2','8','7',0, '2','8','8',0, '2','8','9',0,
- '2','9','0',0, '2','9','1',0, '2','9','2',0, '2','9','3',0, '2','9','4',0,
- '2','9','5',0, '2','9','6',0, '2','9','7',0, '2','9','8',0, '2','9','9',0,
- '3','0','0',0, '3','0','1',0, '3','0','2',0, '3','0','3',0, '3','0','4',0,
- '3','0','5',0, '3','0','6',0, '3','0','7',0, '3','0','8',0, '3','0','9',0,
- '3','1','0',0, '3','1','1',0, '3','1','2',0, '3','1','3',0, '3','1','4',0,
- '3','1','5',0, '3','1','6',0, '3','1','7',0, '3','1','8',0, '3','1','9',0,
- '3','2','0',0, '3','2','1',0, '3','2','2',0, '3','2','3',0, '3','2','4',0,
- '3','2','5',0, '3','2','6',0, '3','2','7',0, '3','2','8',0, '3','2','9',0,
- '3','3','0',0, '3','3','1',0, '3','3','2',0, '3','3','3',0, '3','3','4',0,
- '3','3','5',0, '3','3','6',0, '3','3','7',0, '3','3','8',0, '3','3','9',0,
- '3','4','0',0, '3','4','1',0, '3','4','2',0, '3','4','3',0, '3','4','4',0,
- '3','4','5',0, '3','4','6',0, '3','4','7',0, '3','4','8',0, '3','4','9',0,
- '3','5','0',0, '3','5','1',0, '3','5','2',0, '3','5','3',0, '3','5','4',0,
- '3','5','5',0, '3','5','6',0, '3','5','7',0, '3','5','8',0, '3','5','9',0,
- '3','6','0',0, '3','6','1',0, '3','6','2',0, '3','6','3',0, '3','6','4',0,
- '3','6','5',0, '3','6','6',0, '3','6','7',0, '3','6','8',0, '3','6','9',0,
- '3','7','0',0, '3','7','1',0, '3','7','2',0, '3','7','3',0, '3','7','4',0,
- '3','7','5',0, '3','7','6',0, '3','7','7',0, '3','7','8',0, '3','7','9',0,
- '3','8','0',0, '3','8','1',0, '3','8','2',0, '3','8','3',0, '3','8','4',0,
- '3','8','5',0, '3','8','6',0, '3','8','7',0, '3','8','8',0, '3','8','9',0,
- '3','9','0',0, '3','9','1',0, '3','9','2',0, '3','9','3',0, '3','9','4',0,
- '3','9','5',0, '3','9','6',0, '3','9','7',0, '3','9','8',0, '3','9','9',0,
- '4','0','0',0, '4','0','1',0, '4','0','2',0, '4','0','3',0, '4','0','4',0,
- '4','0','5',0, '4','0','6',0, '4','0','7',0, '4','0','8',0, '4','0','9',0,
- '4','1','0',0, '4','1','1',0, '4','1','2',0, '4','1','3',0, '4','1','4',0,
- '4','1','5',0, '4','1','6',0, '4','1','7',0, '4','1','8',0, '4','1','9',0,
- '4','2','0',0, '4','2','1',0, '4','2','2',0, '4','2','3',0, '4','2','4',0,
- '4','2','5',0, '4','2','6',0, '4','2','7',0, '4','2','8',0, '4','2','9',0,
- '4','3','0',0, '4','3','1',0, '4','3','2',0, '4','3','3',0, '4','3','4',0,
- '4','3','5',0, '4','3','6',0, '4','3','7',0, '4','3','8',0, '4','3','9',0,
- '4','4','0',0, '4','4','1',0, '4','4','2',0, '4','4','3',0, '4','4','4',0,
- '4','4','5',0, '4','4','6',0, '4','4','7',0, '4','4','8',0, '4','4','9',0,
- '4','5','0',0, '4','5','1',0, '4','5','2',0, '4','5','3',0, '4','5','4',0,
- '4','5','5',0, '4','5','6',0, '4','5','7',0, '4','5','8',0, '4','5','9',0,
- '4','6','0',0, '4','6','1',0, '4','6','2',0, '4','6','3',0, '4','6','4',0,
- '4','6','5',0, '4','6','6',0, '4','6','7',0, '4','6','8',0, '4','6','9',0,
- '4','7','0',0, '4','7','1',0, '4','7','2',0, '4','7','3',0, '4','7','4',0,
- '4','7','5',0, '4','7','6',0, '4','7','7',0, '4','7','8',0, '4','7','9',0,
- '4','8','0',0, '4','8','1',0, '4','8','2',0, '4','8','3',0, '4','8','4',0,
- '4','8','5',0, '4','8','6',0, '4','8','7',0, '4','8','8',0, '4','8','9',0,
- '4','9','0',0, '4','9','1',0, '4','9','2',0, '4','9','3',0, '4','9','4',0,
- '4','9','5',0, '4','9','6',0, '4','9','7',0, '4','9','8',0, '4','9','9',0,
- '5','0','0',0, '5','0','1',0, '5','0','2',0, '5','0','3',0, '5','0','4',0,
- '5','0','5',0, '5','0','6',0, '5','0','7',0, '5','0','8',0, '5','0','9',0,
- '5','1','0',0, '5','1','1',0, '5','1','2',0, '5','1','3',0, '5','1','4',0,
- '5','1','5',0, '5','1','6',0, '5','1','7',0, '5','1','8',0, '5','1','9',0,
- '5','2','0',0, '5','2','1',0, '5','2','2',0, '5','2','3',0, '5','2','4',0,
- '5','2','5',0, '5','2','6',0, '5','2','7',0, '5','2','8',0, '5','2','9',0,
- '5','3','0',0, '5','3','1',0, '5','3','2',0, '5','3','3',0, '5','3','4',0,
- '5','3','5',0, '5','3','6',0, '5','3','7',0, '5','3','8',0, '5','3','9',0,
- '5','4','0',0, '5','4','1',0, '5','4','2',0, '5','4','3',0, '5','4','4',0,
- '5','4','5',0, '5','4','6',0, '5','4','7',0, '5','4','8',0, '5','4','9',0,
- '5','5','0',0, '5','5','1',0, '5','5','2',0, '5','5','3',0, '5','5','4',0,
- '5','5','5',0, '5','5','6',0, '5','5','7',0, '5','5','8',0, '5','5','9',0,
- '5','6','0',0, '5','6','1',0, '5','6','2',0, '5','6','3',0, '5','6','4',0,
- '5','6','5',0, '5','6','6',0, '5','6','7',0, '5','6','8',0, '5','6','9',0,
- '5','7','0',0, '5','7','1',0, '5','7','2',0, '5','7','3',0, '5','7','4',0,
- '5','7','5',0, '5','7','6',0, '5','7','7',0, '5','7','8',0, '5','7','9',0,
- '5','8','0',0, '5','8','1',0, '5','8','2',0, '5','8','3',0, '5','8','4',0,
- '5','8','5',0, '5','8','6',0, '5','8','7',0, '5','8','8',0, '5','8','9',0,
- '5','9','0',0, '5','9','1',0, '5','9','2',0, '5','9','3',0, '5','9','4',0,
- '5','9','5',0, '5','9','6',0, '5','9','7',0, '5','9','8',0, '5','9','9',0,
- '6','0','0',0, '6','0','1',0, '6','0','2',0, '6','0','3',0, '6','0','4',0,
- '6','0','5',0, '6','0','6',0, '6','0','7',0, '6','0','8',0, '6','0','9',0,
- '6','1','0',0, '6','1','1',0, '6','1','2',0, '6','1','3',0, '6','1','4',0,
- '6','1','5',0, '6','1','6',0, '6','1','7',0, '6','1','8',0, '6','1','9',0,
- '6','2','0',0, '6','2','1',0, '6','2','2',0, '6','2','3',0, '6','2','4',0,
- '6','2','5',0, '6','2','6',0, '6','2','7',0, '6','2','8',0, '6','2','9',0,
- '6','3','0',0, '6','3','1',0, '6','3','2',0, '6','3','3',0, '6','3','4',0,
- '6','3','5',0, '6','3','6',0, '6','3','7',0, '6','3','8',0, '6','3','9',0,
- '6','4','0',0, '6','4','1',0, '6','4','2',0, '6','4','3',0, '6','4','4',0,
- '6','4','5',0, '6','4','6',0, '6','4','7',0, '6','4','8',0, '6','4','9',0,
- '6','5','0',0, '6','5','1',0, '6','5','2',0, '6','5','3',0, '6','5','4',0,
- '6','5','5',0, '6','5','6',0, '6','5','7',0, '6','5','8',0, '6','5','9',0,
- '6','6','0',0, '6','6','1',0, '6','6','2',0, '6','6','3',0, '6','6','4',0,
- '6','6','5',0, '6','6','6',0, '6','6','7',0, '6','6','8',0, '6','6','9',0,
- '6','7','0',0, '6','7','1',0, '6','7','2',0, '6','7','3',0, '6','7','4',0,
- '6','7','5',0, '6','7','6',0, '6','7','7',0, '6','7','8',0, '6','7','9',0,
- '6','8','0',0, '6','8','1',0, '6','8','2',0, '6','8','3',0, '6','8','4',0,
- '6','8','5',0, '6','8','6',0, '6','8','7',0, '6','8','8',0, '6','8','9',0,
- '6','9','0',0, '6','9','1',0, '6','9','2',0, '6','9','3',0, '6','9','4',0,
- '6','9','5',0, '6','9','6',0, '6','9','7',0, '6','9','8',0, '6','9','9',0,
- '7','0','0',0, '7','0','1',0, '7','0','2',0, '7','0','3',0, '7','0','4',0,
- '7','0','5',0, '7','0','6',0, '7','0','7',0, '7','0','8',0, '7','0','9',0,
- '7','1','0',0, '7','1','1',0, '7','1','2',0, '7','1','3',0, '7','1','4',0,
- '7','1','5',0, '7','1','6',0, '7','1','7',0, '7','1','8',0, '7','1','9',0,
- '7','2','0',0, '7','2','1',0, '7','2','2',0, '7','2','3',0, '7','2','4',0,
- '7','2','5',0, '7','2','6',0, '7','2','7',0, '7','2','8',0, '7','2','9',0,
- '7','3','0',0, '7','3','1',0, '7','3','2',0, '7','3','3',0, '7','3','4',0,
- '7','3','5',0, '7','3','6',0, '7','3','7',0, '7','3','8',0, '7','3','9',0,
- '7','4','0',0, '7','4','1',0, '7','4','2',0, '7','4','3',0, '7','4','4',0,
- '7','4','5',0, '7','4','6',0, '7','4','7',0, '7','4','8',0, '7','4','9',0,
- '7','5','0',0, '7','5','1',0, '7','5','2',0, '7','5','3',0, '7','5','4',0,
- '7','5','5',0, '7','5','6',0, '7','5','7',0, '7','5','8',0, '7','5','9',0,
- '7','6','0',0, '7','6','1',0, '7','6','2',0, '7','6','3',0, '7','6','4',0,
- '7','6','5',0, '7','6','6',0, '7','6','7',0, '7','6','8',0, '7','6','9',0,
- '7','7','0',0, '7','7','1',0, '7','7','2',0, '7','7','3',0, '7','7','4',0,
- '7','7','5',0, '7','7','6',0, '7','7','7',0, '7','7','8',0, '7','7','9',0,
- '7','8','0',0, '7','8','1',0, '7','8','2',0, '7','8','3',0, '7','8','4',0,
- '7','8','5',0, '7','8','6',0, '7','8','7',0, '7','8','8',0, '7','8','9',0,
- '7','9','0',0, '7','9','1',0, '7','9','2',0, '7','9','3',0, '7','9','4',0,
- '7','9','5',0, '7','9','6',0, '7','9','7',0, '7','9','8',0, '7','9','9',0,
- '8','0','0',0, '8','0','1',0, '8','0','2',0, '8','0','3',0, '8','0','4',0,
- '8','0','5',0, '8','0','6',0, '8','0','7',0, '8','0','8',0, '8','0','9',0,
- '8','1','0',0, '8','1','1',0, '8','1','2',0, '8','1','3',0, '8','1','4',0,
- '8','1','5',0, '8','1','6',0, '8','1','7',0, '8','1','8',0, '8','1','9',0,
- '8','2','0',0, '8','2','1',0, '8','2','2',0, '8','2','3',0, '8','2','4',0,
- '8','2','5',0, '8','2','6',0, '8','2','7',0, '8','2','8',0, '8','2','9',0,
- '8','3','0',0, '8','3','1',0, '8','3','2',0, '8','3','3',0, '8','3','4',0,
- '8','3','5',0, '8','3','6',0, '8','3','7',0, '8','3','8',0, '8','3','9',0,
- '8','4','0',0, '8','4','1',0, '8','4','2',0, '8','4','3',0, '8','4','4',0,
- '8','4','5',0, '8','4','6',0, '8','4','7',0, '8','4','8',0, '8','4','9',0,
- '8','5','0',0, '8','5','1',0, '8','5','2',0, '8','5','3',0, '8','5','4',0,
- '8','5','5',0, '8','5','6',0, '8','5','7',0, '8','5','8',0, '8','5','9',0,
- '8','6','0',0, '8','6','1',0, '8','6','2',0, '8','6','3',0, '8','6','4',0,
- '8','6','5',0, '8','6','6',0, '8','6','7',0, '8','6','8',0, '8','6','9',0,
- '8','7','0',0, '8','7','1',0, '8','7','2',0, '8','7','3',0, '8','7','4',0,
- '8','7','5',0, '8','7','6',0, '8','7','7',0, '8','7','8',0, '8','7','9',0,
- '8','8','0',0, '8','8','1',0, '8','8','2',0, '8','8','3',0, '8','8','4',0,
- '8','8','5',0, '8','8','6',0, '8','8','7',0, '8','8','8',0, '8','8','9',0,
- '8','9','0',0, '8','9','1',0, '8','9','2',0, '8','9','3',0, '8','9','4',0,
- '8','9','5',0, '8','9','6',0, '8','9','7',0, '8','9','8',0, '8','9','9',0,
- '9','0','0',0, '9','0','1',0, '9','0','2',0, '9','0','3',0, '9','0','4',0,
- '9','0','5',0, '9','0','6',0, '9','0','7',0, '9','0','8',0, '9','0','9',0,
- '9','1','0',0, '9','1','1',0, '9','1','2',0, '9','1','3',0, '9','1','4',0,
- '9','1','5',0, '9','1','6',0, '9','1','7',0, '9','1','8',0, '9','1','9',0,
- '9','2','0',0, '9','2','1',0, '9','2','2',0, '9','2','3',0, '9','2','4',0,
- '9','2','5',0, '9','2','6',0, '9','2','7',0, '9','2','8',0, '9','2','9',0,
- '9','3','0',0, '9','3','1',0, '9','3','2',0, '9','3','3',0, '9','3','4',0,
- '9','3','5',0, '9','3','6',0, '9','3','7',0, '9','3','8',0, '9','3','9',0,
- '9','4','0',0, '9','4','1',0, '9','4','2',0, '9','4','3',0, '9','4','4',0,
- '9','4','5',0, '9','4','6',0, '9','4','7',0, '9','4','8',0, '9','4','9',0,
- '9','5','0',0, '9','5','1',0, '9','5','2',0, '9','5','3',0, '9','5','4',0,
- '9','5','5',0, '9','5','6',0, '9','5','7',0, '9','5','8',0, '9','5','9',0,
- '9','6','0',0, '9','6','1',0, '9','6','2',0, '9','6','3',0, '9','6','4',0,
- '9','6','5',0, '9','6','6',0, '9','6','7',0, '9','6','8',0, '9','6','9',0,
- '9','7','0',0, '9','7','1',0, '9','7','2',0, '9','7','3',0, '9','7','4',0,
- '9','7','5',0, '9','7','6',0, '9','7','7',0, '9','7','8',0, '9','7','9',0,
- '9','8','0',0, '9','8','1',0, '9','8','2',0, '9','8','3',0, '9','8','4',0,
- '9','8','5',0, '9','8','6',0, '9','8','7',0, '9','8','8',0, '9','8','9',0,
- '9','9','0',0, '9','9','1',0, '9','9','2',0, '9','9','3',0, '9','9','4',0,
- '9','9','5',0, '9','9','6',0, '9','9','7',0, '9','9','8',0, '9','9','9',0 };
+ '0', '0', '0', 0, '0', '0', '1', 0, '0', '0', '2', 0, '0', '0', '3', 0, '0',
+ '0', '4', 0,
+ '0', '0', '5', 0, '0', '0', '6', 0, '0', '0', '7', 0, '0', '0', '8', 0, '0',
+ '0', '9', 0,
+ '0', '1', '0', 0, '0', '1', '1', 0, '0', '1', '2', 0, '0', '1', '3', 0, '0',
+ '1', '4', 0,
+ '0', '1', '5', 0, '0', '1', '6', 0, '0', '1', '7', 0, '0', '1', '8', 0, '0',
+ '1', '9', 0,
+ '0', '2', '0', 0, '0', '2', '1', 0, '0', '2', '2', 0, '0', '2', '3', 0, '0',
+ '2', '4', 0,
+ '0', '2', '5', 0, '0', '2', '6', 0, '0', '2', '7', 0, '0', '2', '8', 0, '0',
+ '2', '9', 0,
+ '0', '3', '0', 0, '0', '3', '1', 0, '0', '3', '2', 0, '0', '3', '3', 0, '0',
+ '3', '4', 0,
+ '0', '3', '5', 0, '0', '3', '6', 0, '0', '3', '7', 0, '0', '3', '8', 0, '0',
+ '3', '9', 0,
+ '0', '4', '0', 0, '0', '4', '1', 0, '0', '4', '2', 0, '0', '4', '3', 0, '0',
+ '4', '4', 0,
+ '0', '4', '5', 0, '0', '4', '6', 0, '0', '4', '7', 0, '0', '4', '8', 0, '0',
+ '4', '9', 0,
+ '0', '5', '0', 0, '0', '5', '1', 0, '0', '5', '2', 0, '0', '5', '3', 0, '0',
+ '5', '4', 0,
+ '0', '5', '5', 0, '0', '5', '6', 0, '0', '5', '7', 0, '0', '5', '8', 0, '0',
+ '5', '9', 0,
+ '0', '6', '0', 0, '0', '6', '1', 0, '0', '6', '2', 0, '0', '6', '3', 0, '0',
+ '6', '4', 0,
+ '0', '6', '5', 0, '0', '6', '6', 0, '0', '6', '7', 0, '0', '6', '8', 0, '0',
+ '6', '9', 0,
+ '0', '7', '0', 0, '0', '7', '1', 0, '0', '7', '2', 0, '0', '7', '3', 0, '0',
+ '7', '4', 0,
+ '0', '7', '5', 0, '0', '7', '6', 0, '0', '7', '7', 0, '0', '7', '8', 0, '0',
+ '7', '9', 0,
+ '0', '8', '0', 0, '0', '8', '1', 0, '0', '8', '2', 0, '0', '8', '3', 0, '0',
+ '8', '4', 0,
+ '0', '8', '5', 0, '0', '8', '6', 0, '0', '8', '7', 0, '0', '8', '8', 0, '0',
+ '8', '9', 0,
+ '0', '9', '0', 0, '0', '9', '1', 0, '0', '9', '2', 0, '0', '9', '3', 0, '0',
+ '9', '4', 0,
+ '0', '9', '5', 0, '0', '9', '6', 0, '0', '9', '7', 0, '0', '9', '8', 0, '0',
+ '9', '9', 0,
+ '1', '0', '0', 0, '1', '0', '1', 0, '1', '0', '2', 0, '1', '0', '3', 0, '1',
+ '0', '4', 0,
+ '1', '0', '5', 0, '1', '0', '6', 0, '1', '0', '7', 0, '1', '0', '8', 0, '1',
+ '0', '9', 0,
+ '1', '1', '0', 0, '1', '1', '1', 0, '1', '1', '2', 0, '1', '1', '3', 0, '1',
+ '1', '4', 0,
+ '1', '1', '5', 0, '1', '1', '6', 0, '1', '1', '7', 0, '1', '1', '8', 0, '1',
+ '1', '9', 0,
+ '1', '2', '0', 0, '1', '2', '1', 0, '1', '2', '2', 0, '1', '2', '3', 0, '1',
+ '2', '4', 0,
+ '1', '2', '5', 0, '1', '2', '6', 0, '1', '2', '7', 0, '1', '2', '8', 0, '1',
+ '2', '9', 0,
+ '1', '3', '0', 0, '1', '3', '1', 0, '1', '3', '2', 0, '1', '3', '3', 0, '1',
+ '3', '4', 0,
+ '1', '3', '5', 0, '1', '3', '6', 0, '1', '3', '7', 0, '1', '3', '8', 0, '1',
+ '3', '9', 0,
+ '1', '4', '0', 0, '1', '4', '1', 0, '1', '4', '2', 0, '1', '4', '3', 0, '1',
+ '4', '4', 0,
+ '1', '4', '5', 0, '1', '4', '6', 0, '1', '4', '7', 0, '1', '4', '8', 0, '1',
+ '4', '9', 0,
+ '1', '5', '0', 0, '1', '5', '1', 0, '1', '5', '2', 0, '1', '5', '3', 0, '1',
+ '5', '4', 0,
+ '1', '5', '5', 0, '1', '5', '6', 0, '1', '5', '7', 0, '1', '5', '8', 0, '1',
+ '5', '9', 0,
+ '1', '6', '0', 0, '1', '6', '1', 0, '1', '6', '2', 0, '1', '6', '3', 0, '1',
+ '6', '4', 0,
+ '1', '6', '5', 0, '1', '6', '6', 0, '1', '6', '7', 0, '1', '6', '8', 0, '1',
+ '6', '9', 0,
+ '1', '7', '0', 0, '1', '7', '1', 0, '1', '7', '2', 0, '1', '7', '3', 0, '1',
+ '7', '4', 0,
+ '1', '7', '5', 0, '1', '7', '6', 0, '1', '7', '7', 0, '1', '7', '8', 0, '1',
+ '7', '9', 0,
+ '1', '8', '0', 0, '1', '8', '1', 0, '1', '8', '2', 0, '1', '8', '3', 0, '1',
+ '8', '4', 0,
+ '1', '8', '5', 0, '1', '8', '6', 0, '1', '8', '7', 0, '1', '8', '8', 0, '1',
+ '8', '9', 0,
+ '1', '9', '0', 0, '1', '9', '1', 0, '1', '9', '2', 0, '1', '9', '3', 0, '1',
+ '9', '4', 0,
+ '1', '9', '5', 0, '1', '9', '6', 0, '1', '9', '7', 0, '1', '9', '8', 0, '1',
+ '9', '9', 0,
+ '2', '0', '0', 0, '2', '0', '1', 0, '2', '0', '2', 0, '2', '0', '3', 0, '2',
+ '0', '4', 0,
+ '2', '0', '5', 0, '2', '0', '6', 0, '2', '0', '7', 0, '2', '0', '8', 0, '2',
+ '0', '9', 0,
+ '2', '1', '0', 0, '2', '1', '1', 0, '2', '1', '2', 0, '2', '1', '3', 0, '2',
+ '1', '4', 0,
+ '2', '1', '5', 0, '2', '1', '6', 0, '2', '1', '7', 0, '2', '1', '8', 0, '2',
+ '1', '9', 0,
+ '2', '2', '0', 0, '2', '2', '1', 0, '2', '2', '2', 0, '2', '2', '3', 0, '2',
+ '2', '4', 0,
+ '2', '2', '5', 0, '2', '2', '6', 0, '2', '2', '7', 0, '2', '2', '8', 0, '2',
+ '2', '9', 0,
+ '2', '3', '0', 0, '2', '3', '1', 0, '2', '3', '2', 0, '2', '3', '3', 0, '2',
+ '3', '4', 0,
+ '2', '3', '5', 0, '2', '3', '6', 0, '2', '3', '7', 0, '2', '3', '8', 0, '2',
+ '3', '9', 0,
+ '2', '4', '0', 0, '2', '4', '1', 0, '2', '4', '2', 0, '2', '4', '3', 0, '2',
+ '4', '4', 0,
+ '2', '4', '5', 0, '2', '4', '6', 0, '2', '4', '7', 0, '2', '4', '8', 0, '2',
+ '4', '9', 0,
+ '2', '5', '0', 0, '2', '5', '1', 0, '2', '5', '2', 0, '2', '5', '3', 0, '2',
+ '5', '4', 0,
+ '2', '5', '5', 0, '2', '5', '6', 0, '2', '5', '7', 0, '2', '5', '8', 0, '2',
+ '5', '9', 0,
+ '2', '6', '0', 0, '2', '6', '1', 0, '2', '6', '2', 0, '2', '6', '3', 0, '2',
+ '6', '4', 0,
+ '2', '6', '5', 0, '2', '6', '6', 0, '2', '6', '7', 0, '2', '6', '8', 0, '2',
+ '6', '9', 0,
+ '2', '7', '0', 0, '2', '7', '1', 0, '2', '7', '2', 0, '2', '7', '3', 0, '2',
+ '7', '4', 0,
+ '2', '7', '5', 0, '2', '7', '6', 0, '2', '7', '7', 0, '2', '7', '8', 0, '2',
+ '7', '9', 0,
+ '2', '8', '0', 0, '2', '8', '1', 0, '2', '8', '2', 0, '2', '8', '3', 0, '2',
+ '8', '4', 0,
+ '2', '8', '5', 0, '2', '8', '6', 0, '2', '8', '7', 0, '2', '8', '8', 0, '2',
+ '8', '9', 0,
+ '2', '9', '0', 0, '2', '9', '1', 0, '2', '9', '2', 0, '2', '9', '3', 0, '2',
+ '9', '4', 0,
+ '2', '9', '5', 0, '2', '9', '6', 0, '2', '9', '7', 0, '2', '9', '8', 0, '2',
+ '9', '9', 0,
+ '3', '0', '0', 0, '3', '0', '1', 0, '3', '0', '2', 0, '3', '0', '3', 0, '3',
+ '0', '4', 0,
+ '3', '0', '5', 0, '3', '0', '6', 0, '3', '0', '7', 0, '3', '0', '8', 0, '3',
+ '0', '9', 0,
+ '3', '1', '0', 0, '3', '1', '1', 0, '3', '1', '2', 0, '3', '1', '3', 0, '3',
+ '1', '4', 0,
+ '3', '1', '5', 0, '3', '1', '6', 0, '3', '1', '7', 0, '3', '1', '8', 0, '3',
+ '1', '9', 0,
+ '3', '2', '0', 0, '3', '2', '1', 0, '3', '2', '2', 0, '3', '2', '3', 0, '3',
+ '2', '4', 0,
+ '3', '2', '5', 0, '3', '2', '6', 0, '3', '2', '7', 0, '3', '2', '8', 0, '3',
+ '2', '9', 0,
+ '3', '3', '0', 0, '3', '3', '1', 0, '3', '3', '2', 0, '3', '3', '3', 0, '3',
+ '3', '4', 0,
+ '3', '3', '5', 0, '3', '3', '6', 0, '3', '3', '7', 0, '3', '3', '8', 0, '3',
+ '3', '9', 0,
+ '3', '4', '0', 0, '3', '4', '1', 0, '3', '4', '2', 0, '3', '4', '3', 0, '3',
+ '4', '4', 0,
+ '3', '4', '5', 0, '3', '4', '6', 0, '3', '4', '7', 0, '3', '4', '8', 0, '3',
+ '4', '9', 0,
+ '3', '5', '0', 0, '3', '5', '1', 0, '3', '5', '2', 0, '3', '5', '3', 0, '3',
+ '5', '4', 0,
+ '3', '5', '5', 0, '3', '5', '6', 0, '3', '5', '7', 0, '3', '5', '8', 0, '3',
+ '5', '9', 0,
+ '3', '6', '0', 0, '3', '6', '1', 0, '3', '6', '2', 0, '3', '6', '3', 0, '3',
+ '6', '4', 0,
+ '3', '6', '5', 0, '3', '6', '6', 0, '3', '6', '7', 0, '3', '6', '8', 0, '3',
+ '6', '9', 0,
+ '3', '7', '0', 0, '3', '7', '1', 0, '3', '7', '2', 0, '3', '7', '3', 0, '3',
+ '7', '4', 0,
+ '3', '7', '5', 0, '3', '7', '6', 0, '3', '7', '7', 0, '3', '7', '8', 0, '3',
+ '7', '9', 0,
+ '3', '8', '0', 0, '3', '8', '1', 0, '3', '8', '2', 0, '3', '8', '3', 0, '3',
+ '8', '4', 0,
+ '3', '8', '5', 0, '3', '8', '6', 0, '3', '8', '7', 0, '3', '8', '8', 0, '3',
+ '8', '9', 0,
+ '3', '9', '0', 0, '3', '9', '1', 0, '3', '9', '2', 0, '3', '9', '3', 0, '3',
+ '9', '4', 0,
+ '3', '9', '5', 0, '3', '9', '6', 0, '3', '9', '7', 0, '3', '9', '8', 0, '3',
+ '9', '9', 0,
+ '4', '0', '0', 0, '4', '0', '1', 0, '4', '0', '2', 0, '4', '0', '3', 0, '4',
+ '0', '4', 0,
+ '4', '0', '5', 0, '4', '0', '6', 0, '4', '0', '7', 0, '4', '0', '8', 0, '4',
+ '0', '9', 0,
+ '4', '1', '0', 0, '4', '1', '1', 0, '4', '1', '2', 0, '4', '1', '3', 0, '4',
+ '1', '4', 0,
+ '4', '1', '5', 0, '4', '1', '6', 0, '4', '1', '7', 0, '4', '1', '8', 0, '4',
+ '1', '9', 0,
+ '4', '2', '0', 0, '4', '2', '1', 0, '4', '2', '2', 0, '4', '2', '3', 0, '4',
+ '2', '4', 0,
+ '4', '2', '5', 0, '4', '2', '6', 0, '4', '2', '7', 0, '4', '2', '8', 0, '4',
+ '2', '9', 0,
+ '4', '3', '0', 0, '4', '3', '1', 0, '4', '3', '2', 0, '4', '3', '3', 0, '4',
+ '3', '4', 0,
+ '4', '3', '5', 0, '4', '3', '6', 0, '4', '3', '7', 0, '4', '3', '8', 0, '4',
+ '3', '9', 0,
+ '4', '4', '0', 0, '4', '4', '1', 0, '4', '4', '2', 0, '4', '4', '3', 0, '4',
+ '4', '4', 0,
+ '4', '4', '5', 0, '4', '4', '6', 0, '4', '4', '7', 0, '4', '4', '8', 0, '4',
+ '4', '9', 0,
+ '4', '5', '0', 0, '4', '5', '1', 0, '4', '5', '2', 0, '4', '5', '3', 0, '4',
+ '5', '4', 0,
+ '4', '5', '5', 0, '4', '5', '6', 0, '4', '5', '7', 0, '4', '5', '8', 0, '4',
+ '5', '9', 0,
+ '4', '6', '0', 0, '4', '6', '1', 0, '4', '6', '2', 0, '4', '6', '3', 0, '4',
+ '6', '4', 0,
+ '4', '6', '5', 0, '4', '6', '6', 0, '4', '6', '7', 0, '4', '6', '8', 0, '4',
+ '6', '9', 0,
+ '4', '7', '0', 0, '4', '7', '1', 0, '4', '7', '2', 0, '4', '7', '3', 0, '4',
+ '7', '4', 0,
+ '4', '7', '5', 0, '4', '7', '6', 0, '4', '7', '7', 0, '4', '7', '8', 0, '4',
+ '7', '9', 0,
+ '4', '8', '0', 0, '4', '8', '1', 0, '4', '8', '2', 0, '4', '8', '3', 0, '4',
+ '8', '4', 0,
+ '4', '8', '5', 0, '4', '8', '6', 0, '4', '8', '7', 0, '4', '8', '8', 0, '4',
+ '8', '9', 0,
+ '4', '9', '0', 0, '4', '9', '1', 0, '4', '9', '2', 0, '4', '9', '3', 0, '4',
+ '9', '4', 0,
+ '4', '9', '5', 0, '4', '9', '6', 0, '4', '9', '7', 0, '4', '9', '8', 0, '4',
+ '9', '9', 0,
+ '5', '0', '0', 0, '5', '0', '1', 0, '5', '0', '2', 0, '5', '0', '3', 0, '5',
+ '0', '4', 0,
+ '5', '0', '5', 0, '5', '0', '6', 0, '5', '0', '7', 0, '5', '0', '8', 0, '5',
+ '0', '9', 0,
+ '5', '1', '0', 0, '5', '1', '1', 0, '5', '1', '2', 0, '5', '1', '3', 0, '5',
+ '1', '4', 0,
+ '5', '1', '5', 0, '5', '1', '6', 0, '5', '1', '7', 0, '5', '1', '8', 0, '5',
+ '1', '9', 0,
+ '5', '2', '0', 0, '5', '2', '1', 0, '5', '2', '2', 0, '5', '2', '3', 0, '5',
+ '2', '4', 0,
+ '5', '2', '5', 0, '5', '2', '6', 0, '5', '2', '7', 0, '5', '2', '8', 0, '5',
+ '2', '9', 0,
+ '5', '3', '0', 0, '5', '3', '1', 0, '5', '3', '2', 0, '5', '3', '3', 0, '5',
+ '3', '4', 0,
+ '5', '3', '5', 0, '5', '3', '6', 0, '5', '3', '7', 0, '5', '3', '8', 0, '5',
+ '3', '9', 0,
+ '5', '4', '0', 0, '5', '4', '1', 0, '5', '4', '2', 0, '5', '4', '3', 0, '5',
+ '4', '4', 0,
+ '5', '4', '5', 0, '5', '4', '6', 0, '5', '4', '7', 0, '5', '4', '8', 0, '5',
+ '4', '9', 0,
+ '5', '5', '0', 0, '5', '5', '1', 0, '5', '5', '2', 0, '5', '5', '3', 0, '5',
+ '5', '4', 0,
+ '5', '5', '5', 0, '5', '5', '6', 0, '5', '5', '7', 0, '5', '5', '8', 0, '5',
+ '5', '9', 0,
+ '5', '6', '0', 0, '5', '6', '1', 0, '5', '6', '2', 0, '5', '6', '3', 0, '5',
+ '6', '4', 0,
+ '5', '6', '5', 0, '5', '6', '6', 0, '5', '6', '7', 0, '5', '6', '8', 0, '5',
+ '6', '9', 0,
+ '5', '7', '0', 0, '5', '7', '1', 0, '5', '7', '2', 0, '5', '7', '3', 0, '5',
+ '7', '4', 0,
+ '5', '7', '5', 0, '5', '7', '6', 0, '5', '7', '7', 0, '5', '7', '8', 0, '5',
+ '7', '9', 0,
+ '5', '8', '0', 0, '5', '8', '1', 0, '5', '8', '2', 0, '5', '8', '3', 0, '5',
+ '8', '4', 0,
+ '5', '8', '5', 0, '5', '8', '6', 0, '5', '8', '7', 0, '5', '8', '8', 0, '5',
+ '8', '9', 0,
+ '5', '9', '0', 0, '5', '9', '1', 0, '5', '9', '2', 0, '5', '9', '3', 0, '5',
+ '9', '4', 0,
+ '5', '9', '5', 0, '5', '9', '6', 0, '5', '9', '7', 0, '5', '9', '8', 0, '5',
+ '9', '9', 0,
+ '6', '0', '0', 0, '6', '0', '1', 0, '6', '0', '2', 0, '6', '0', '3', 0, '6',
+ '0', '4', 0,
+ '6', '0', '5', 0, '6', '0', '6', 0, '6', '0', '7', 0, '6', '0', '8', 0, '6',
+ '0', '9', 0,
+ '6', '1', '0', 0, '6', '1', '1', 0, '6', '1', '2', 0, '6', '1', '3', 0, '6',
+ '1', '4', 0,
+ '6', '1', '5', 0, '6', '1', '6', 0, '6', '1', '7', 0, '6', '1', '8', 0, '6',
+ '1', '9', 0,
+ '6', '2', '0', 0, '6', '2', '1', 0, '6', '2', '2', 0, '6', '2', '3', 0, '6',
+ '2', '4', 0,
+ '6', '2', '5', 0, '6', '2', '6', 0, '6', '2', '7', 0, '6', '2', '8', 0, '6',
+ '2', '9', 0,
+ '6', '3', '0', 0, '6', '3', '1', 0, '6', '3', '2', 0, '6', '3', '3', 0, '6',
+ '3', '4', 0,
+ '6', '3', '5', 0, '6', '3', '6', 0, '6', '3', '7', 0, '6', '3', '8', 0, '6',
+ '3', '9', 0,
+ '6', '4', '0', 0, '6', '4', '1', 0, '6', '4', '2', 0, '6', '4', '3', 0, '6',
+ '4', '4', 0,
+ '6', '4', '5', 0, '6', '4', '6', 0, '6', '4', '7', 0, '6', '4', '8', 0, '6',
+ '4', '9', 0,
+ '6', '5', '0', 0, '6', '5', '1', 0, '6', '5', '2', 0, '6', '5', '3', 0, '6',
+ '5', '4', 0,
+ '6', '5', '5', 0, '6', '5', '6', 0, '6', '5', '7', 0, '6', '5', '8', 0, '6',
+ '5', '9', 0,
+ '6', '6', '0', 0, '6', '6', '1', 0, '6', '6', '2', 0, '6', '6', '3', 0, '6',
+ '6', '4', 0,
+ '6', '6', '5', 0, '6', '6', '6', 0, '6', '6', '7', 0, '6', '6', '8', 0, '6',
+ '6', '9', 0,
+ '6', '7', '0', 0, '6', '7', '1', 0, '6', '7', '2', 0, '6', '7', '3', 0, '6',
+ '7', '4', 0,
+ '6', '7', '5', 0, '6', '7', '6', 0, '6', '7', '7', 0, '6', '7', '8', 0, '6',
+ '7', '9', 0,
+ '6', '8', '0', 0, '6', '8', '1', 0, '6', '8', '2', 0, '6', '8', '3', 0, '6',
+ '8', '4', 0,
+ '6', '8', '5', 0, '6', '8', '6', 0, '6', '8', '7', 0, '6', '8', '8', 0, '6',
+ '8', '9', 0,
+ '6', '9', '0', 0, '6', '9', '1', 0, '6', '9', '2', 0, '6', '9', '3', 0, '6',
+ '9', '4', 0,
+ '6', '9', '5', 0, '6', '9', '6', 0, '6', '9', '7', 0, '6', '9', '8', 0, '6',
+ '9', '9', 0,
+ '7', '0', '0', 0, '7', '0', '1', 0, '7', '0', '2', 0, '7', '0', '3', 0, '7',
+ '0', '4', 0,
+ '7', '0', '5', 0, '7', '0', '6', 0, '7', '0', '7', 0, '7', '0', '8', 0, '7',
+ '0', '9', 0,
+ '7', '1', '0', 0, '7', '1', '1', 0, '7', '1', '2', 0, '7', '1', '3', 0, '7',
+ '1', '4', 0,
+ '7', '1', '5', 0, '7', '1', '6', 0, '7', '1', '7', 0, '7', '1', '8', 0, '7',
+ '1', '9', 0,
+ '7', '2', '0', 0, '7', '2', '1', 0, '7', '2', '2', 0, '7', '2', '3', 0, '7',
+ '2', '4', 0,
+ '7', '2', '5', 0, '7', '2', '6', 0, '7', '2', '7', 0, '7', '2', '8', 0, '7',
+ '2', '9', 0,
+ '7', '3', '0', 0, '7', '3', '1', 0, '7', '3', '2', 0, '7', '3', '3', 0, '7',
+ '3', '4', 0,
+ '7', '3', '5', 0, '7', '3', '6', 0, '7', '3', '7', 0, '7', '3', '8', 0, '7',
+ '3', '9', 0,
+ '7', '4', '0', 0, '7', '4', '1', 0, '7', '4', '2', 0, '7', '4', '3', 0, '7',
+ '4', '4', 0,
+ '7', '4', '5', 0, '7', '4', '6', 0, '7', '4', '7', 0, '7', '4', '8', 0, '7',
+ '4', '9', 0,
+ '7', '5', '0', 0, '7', '5', '1', 0, '7', '5', '2', 0, '7', '5', '3', 0, '7',
+ '5', '4', 0,
+ '7', '5', '5', 0, '7', '5', '6', 0, '7', '5', '7', 0, '7', '5', '8', 0, '7',
+ '5', '9', 0,
+ '7', '6', '0', 0, '7', '6', '1', 0, '7', '6', '2', 0, '7', '6', '3', 0, '7',
+ '6', '4', 0,
+ '7', '6', '5', 0, '7', '6', '6', 0, '7', '6', '7', 0, '7', '6', '8', 0, '7',
+ '6', '9', 0,
+ '7', '7', '0', 0, '7', '7', '1', 0, '7', '7', '2', 0, '7', '7', '3', 0, '7',
+ '7', '4', 0,
+ '7', '7', '5', 0, '7', '7', '6', 0, '7', '7', '7', 0, '7', '7', '8', 0, '7',
+ '7', '9', 0,
+ '7', '8', '0', 0, '7', '8', '1', 0, '7', '8', '2', 0, '7', '8', '3', 0, '7',
+ '8', '4', 0,
+ '7', '8', '5', 0, '7', '8', '6', 0, '7', '8', '7', 0, '7', '8', '8', 0, '7',
+ '8', '9', 0,
+ '7', '9', '0', 0, '7', '9', '1', 0, '7', '9', '2', 0, '7', '9', '3', 0, '7',
+ '9', '4', 0,
+ '7', '9', '5', 0, '7', '9', '6', 0, '7', '9', '7', 0, '7', '9', '8', 0, '7',
+ '9', '9', 0,
+ '8', '0', '0', 0, '8', '0', '1', 0, '8', '0', '2', 0, '8', '0', '3', 0, '8',
+ '0', '4', 0,
+ '8', '0', '5', 0, '8', '0', '6', 0, '8', '0', '7', 0, '8', '0', '8', 0, '8',
+ '0', '9', 0,
+ '8', '1', '0', 0, '8', '1', '1', 0, '8', '1', '2', 0, '8', '1', '3', 0, '8',
+ '1', '4', 0,
+ '8', '1', '5', 0, '8', '1', '6', 0, '8', '1', '7', 0, '8', '1', '8', 0, '8',
+ '1', '9', 0,
+ '8', '2', '0', 0, '8', '2', '1', 0, '8', '2', '2', 0, '8', '2', '3', 0, '8',
+ '2', '4', 0,
+ '8', '2', '5', 0, '8', '2', '6', 0, '8', '2', '7', 0, '8', '2', '8', 0, '8',
+ '2', '9', 0,
+ '8', '3', '0', 0, '8', '3', '1', 0, '8', '3', '2', 0, '8', '3', '3', 0, '8',
+ '3', '4', 0,
+ '8', '3', '5', 0, '8', '3', '6', 0, '8', '3', '7', 0, '8', '3', '8', 0, '8',
+ '3', '9', 0,
+ '8', '4', '0', 0, '8', '4', '1', 0, '8', '4', '2', 0, '8', '4', '3', 0, '8',
+ '4', '4', 0,
+ '8', '4', '5', 0, '8', '4', '6', 0, '8', '4', '7', 0, '8', '4', '8', 0, '8',
+ '4', '9', 0,
+ '8', '5', '0', 0, '8', '5', '1', 0, '8', '5', '2', 0, '8', '5', '3', 0, '8',
+ '5', '4', 0,
+ '8', '5', '5', 0, '8', '5', '6', 0, '8', '5', '7', 0, '8', '5', '8', 0, '8',
+ '5', '9', 0,
+ '8', '6', '0', 0, '8', '6', '1', 0, '8', '6', '2', 0, '8', '6', '3', 0, '8',
+ '6', '4', 0,
+ '8', '6', '5', 0, '8', '6', '6', 0, '8', '6', '7', 0, '8', '6', '8', 0, '8',
+ '6', '9', 0,
+ '8', '7', '0', 0, '8', '7', '1', 0, '8', '7', '2', 0, '8', '7', '3', 0, '8',
+ '7', '4', 0,
+ '8', '7', '5', 0, '8', '7', '6', 0, '8', '7', '7', 0, '8', '7', '8', 0, '8',
+ '7', '9', 0,
+ '8', '8', '0', 0, '8', '8', '1', 0, '8', '8', '2', 0, '8', '8', '3', 0, '8',
+ '8', '4', 0,
+ '8', '8', '5', 0, '8', '8', '6', 0, '8', '8', '7', 0, '8', '8', '8', 0, '8',
+ '8', '9', 0,
+ '8', '9', '0', 0, '8', '9', '1', 0, '8', '9', '2', 0, '8', '9', '3', 0, '8',
+ '9', '4', 0,
+ '8', '9', '5', 0, '8', '9', '6', 0, '8', '9', '7', 0, '8', '9', '8', 0, '8',
+ '9', '9', 0,
+ '9', '0', '0', 0, '9', '0', '1', 0, '9', '0', '2', 0, '9', '0', '3', 0, '9',
+ '0', '4', 0,
+ '9', '0', '5', 0, '9', '0', '6', 0, '9', '0', '7', 0, '9', '0', '8', 0, '9',
+ '0', '9', 0,
+ '9', '1', '0', 0, '9', '1', '1', 0, '9', '1', '2', 0, '9', '1', '3', 0, '9',
+ '1', '4', 0,
+ '9', '1', '5', 0, '9', '1', '6', 0, '9', '1', '7', 0, '9', '1', '8', 0, '9',
+ '1', '9', 0,
+ '9', '2', '0', 0, '9', '2', '1', 0, '9', '2', '2', 0, '9', '2', '3', 0, '9',
+ '2', '4', 0,
+ '9', '2', '5', 0, '9', '2', '6', 0, '9', '2', '7', 0, '9', '2', '8', 0, '9',
+ '2', '9', 0,
+ '9', '3', '0', 0, '9', '3', '1', 0, '9', '3', '2', 0, '9', '3', '3', 0, '9',
+ '3', '4', 0,
+ '9', '3', '5', 0, '9', '3', '6', 0, '9', '3', '7', 0, '9', '3', '8', 0, '9',
+ '3', '9', 0,
+ '9', '4', '0', 0, '9', '4', '1', 0, '9', '4', '2', 0, '9', '4', '3', 0, '9',
+ '4', '4', 0,
+ '9', '4', '5', 0, '9', '4', '6', 0, '9', '4', '7', 0, '9', '4', '8', 0, '9',
+ '4', '9', 0,
+ '9', '5', '0', 0, '9', '5', '1', 0, '9', '5', '2', 0, '9', '5', '3', 0, '9',
+ '5', '4', 0,
+ '9', '5', '5', 0, '9', '5', '6', 0, '9', '5', '7', 0, '9', '5', '8', 0, '9',
+ '5', '9', 0,
+ '9', '6', '0', 0, '9', '6', '1', 0, '9', '6', '2', 0, '9', '6', '3', 0, '9',
+ '6', '4', 0,
+ '9', '6', '5', 0, '9', '6', '6', 0, '9', '6', '7', 0, '9', '6', '8', 0, '9',
+ '6', '9', 0,
+ '9', '7', '0', 0, '9', '7', '1', 0, '9', '7', '2', 0, '9', '7', '3', 0, '9',
+ '7', '4', 0,
+ '9', '7', '5', 0, '9', '7', '6', 0, '9', '7', '7', 0, '9', '7', '8', 0, '9',
+ '7', '9', 0,
+ '9', '8', '0', 0, '9', '8', '1', 0, '9', '8', '2', 0, '9', '8', '3', 0, '9',
+ '8', '4', 0,
+ '9', '8', '5', 0, '9', '8', '6', 0, '9', '8', '7', 0, '9', '8', '8', 0, '9',
+ '8', '9', 0,
+ '9', '9', '0', 0, '9', '9', '1', 0, '9', '9', '2', 0, '9', '9', '3', 0, '9',
+ '9', '4', 0,
+ '9', '9', '5', 0, '9', '9', '6', 0, '9', '9', '7', 0, '9', '9', '8', 0, '9',
+ '9', '9', 0
+};
static char scratch_buffer[32];
int
vsprintf_irc(char *str, const char *format, va_list args)
-
{
char c;
int bytes = 0;
while ((c = *format++))
+ {
+ if (c == '%')
{
- if (c == '%')
- {
- c = *format++; /* May never be '\0' ! */
-
- if (c == 's')
- {
- const char *p1 = va_arg(args, const char *);
- if ((*str = *p1))
- {
- ++bytes;
- while ((*++str = *++p1))
- ++bytes;
- }
-
- continue;
- }
-
- if (c == 'c')
- {
- *str++ = (char) va_arg(args, int);
- ++bytes;
-
- continue;
- }
-
- /*
- * Prints time_t value in interval
- * [ 100000000 , 4294967295 ]
- * Actually prints like "%09lu"
- */
- if (c == 'l' && *format == 'u')
- {
- unsigned long v1, v2;
- const char *ap;
-
- ++format;
- v1 = va_arg(args, unsigned long);
- if (v1 > 999999999L)
- {
- v2 = v1 / 1000000000;
- v1 -= v2 * 1000000000;
- *str++ = '0' + v2;
- ++bytes;
- }
-
- v2 = v1 / 1000000;
- v1 -= v2 * 1000000;
- ap = atoi_tab + (v2 << 2);
- *str++ = *ap++;
- *str++ = *ap++;
- *str++ = *ap;
- v2 = v1 / 1000;
- v1 -= v2 * 1000;
- ap = atoi_tab + (v2 << 2);
- *str++ = *ap++;
- *str++ = *ap++;
- *str++ = *ap;
- ap = atoi_tab + (v1 << 2);
- *str++ = *ap++;
- *str++ = *ap++;
- *str++ = *ap;
-
- bytes += 9;
-
- continue;
- }
- if (c == 't')
- {
- unsigned int v1;
-
- v1 = va_arg(args,int);
-
- *str++ = (v1/10) + '0';
- *str++ = v1%10 + '0';
-
- bytes += 2;
-
- continue;
- }
-
- if (c == 'd')
- {
- unsigned int v1, v2;
- const char *ap;
- char *s = &scratch_buffer[sizeof(scratch_buffer) - 2];
-
- v1 = va_arg(args, int);
- if ((int)v1 <= 0)
- {
- if (v1 == 0)
- {
- *str++ = '0';
- ++bytes;
- continue;
- }
- *str++ = '-';
- ++bytes;
- v1 = -v1;
- }
-
- do
- {
- v2 = v1 / 1000;
- ap = atoi_tab + 2 + ((v1 - 1000 * v2) << 2);
- *s-- = *ap--;
- *s-- = *ap--;
- *s-- = *ap;
- }
- while ((v1 = v2) > 0);
-
- while ('0' == *++s);
-
- *str = *s;
- ++bytes;
-
- while ((*++str = *++s))
- ++bytes;
-
- continue;
- }
-
- if (c == 'u')
- {
- unsigned int v1, v2;
- const char *ap;
- char *s = &scratch_buffer[sizeof(scratch_buffer) - 2];
-
- v1 = va_arg(args, unsigned int);
- if (v1 == 0)
- {
- *str++ = '0';
- ++bytes;
- continue;
- }
-
- do
- {
- v2 = v1 / 1000;
- ap = atoi_tab + 2 + ((v1 - 1000 * v2) << 2);
- *s-- = *ap--;
- *s-- = *ap--;
- *s-- = *ap;
- }
- while ((v1 = v2) > 0);
-
- while ('0' == *++s);
-
- *str = *s;
- ++bytes;
-
- while ((*++str = *++s))
- ++bytes;
-
- continue;
- }
-
- if (c != '%')
- {
- int ret;
-
- format -= 2;
- ret = vsprintf(str, format, args);
- str += ret;
- bytes += ret;
-
- break;
- }
- }
-
- *str++ = c;
- ++bytes;
+ c = *format++; /* May never be '\0' ! */
+
+ if (c == 's')
+ {
+ const char *p1 = va_arg(args, const char *);
+ if ((*str = *p1))
+ {
+ ++bytes;
+ while ((*++str = *++p1))
+ ++bytes;
+ }
+
+ continue;
+ }
+
+ if (c == 'c')
+ {
+ *str++ = (char)va_arg(args, int);
+ ++bytes;
+
+ continue;
+ }
+
+ /*
+ * Prints time_t value in interval
+ * [ 100000000 , 4294967295 ]
+ * Actually prints like "%09lu"
+ */
+ if (c == 'l' && *format == 'u')
+ {
+ unsigned long v1, v2;
+ const char *ap;
+
+ ++format;
+ v1 = va_arg(args, unsigned long);
+ if (v1 > 999999999L)
+ {
+ v2 = v1 / 1000000000;
+ v1 -= v2 * 1000000000;
+ *str++ = '0' + v2;
+ ++bytes;
+ }
+
+ v2 = v1 / 1000000;
+ v1 -= v2 * 1000000;
+ ap = atoi_tab + (v2 << 2);
+ *str++ = *ap++;
+ *str++ = *ap++;
+ *str++ = *ap;
+ v2 = v1 / 1000;
+ v1 -= v2 * 1000;
+ ap = atoi_tab + (v2 << 2);
+ *str++ = *ap++;
+ *str++ = *ap++;
+ *str++ = *ap;
+ ap = atoi_tab + (v1 << 2);
+ *str++ = *ap++;
+ *str++ = *ap++;
+ *str++ = *ap;
+
+ bytes += 9;
+
+ continue;
+ }
+ if (c == 't')
+ {
+ unsigned int v1;
+
+ v1 = va_arg(args, int);
+
+ *str++ = (v1 / 10) + '0';
+ *str++ = v1 % 10 + '0';
+
+ bytes += 2;
+
+ continue;
+ }
+
+ if (c == 'd')
+ {
+ unsigned int v1, v2;
+ const char *ap;
+ char *s = &scratch_buffer[sizeof(scratch_buffer) - 2];
+
+ v1 = va_arg(args, int);
+ if ((int)v1 <= 0)
+ {
+ if (v1 == 0)
+ {
+ *str++ = '0';
+ ++bytes;
+ continue;
+ }
+ *str++ = '-';
+ ++bytes;
+ v1 = -v1;
+ }
+
+ do
+ {
+ v2 = v1 / 1000;
+ ap = atoi_tab + 2 + ((v1 - 1000 * v2) << 2);
+ *s-- = *ap--;
+ *s-- = *ap--;
+ *s-- = *ap;
+ }
+ while ((v1 = v2) > 0);
+
+ while ('0' == *++s);
+
+ *str = *s;
+ ++bytes;
+
+ while ((*++str = *++s))
+ ++bytes;
+
+ continue;
+ }
+
+ if (c == 'u')
+ {
+ unsigned int v1, v2;
+ const char *ap;
+ char *s = &scratch_buffer[sizeof(scratch_buffer) - 2];
+
+ v1 = va_arg(args, unsigned int);
+ if (v1 == 0)
+ {
+ *str++ = '0';
+ ++bytes;
+ continue;
+ }
+
+ do
+ {
+ v2 = v1 / 1000;
+ ap = atoi_tab + 2 + ((v1 - 1000 * v2) << 2);
+ *s-- = *ap--;
+ *s-- = *ap--;
+ *s-- = *ap;
+ }
+ while ((v1 = v2) > 0);
+
+ while ('0' == *++s);
+
+ *str = *s;
+ ++bytes;
+
+ while ((*++str = *++s))
+ ++bytes;
+
+ continue;
+ }
+
+ if (c != '%')
+ {
+ int ret;
+
+ format -= 2;
+ ret = vsprintf(str, format, args);
+ str += ret;
+ bytes += ret;
+
+ break;
+ }
}
+ *str++ = c;
+ ++bytes;
+ }
+
*str = '\0';
return (bytes);
-} /* vsprintf_irc() */
+} /* vsprintf_irc() */
int
ircsprintf(char *str, const char *format, ...)
va_end(args);
return (bytes);
-} /* ircsprintf() */
-
+} /* ircsprintf() */
*
* adrian chadd <adrian@creative.net.au>
*
- * $Id: tools.c,v 1.1 2002/01/04 09:14:55 a1kmm Exp $
+ * $Id: tools.c,v 1.2 2002/01/04 11:06:44 a1kmm Exp $
*/
#include <assert.h>
mem_frob(void *data, int len)
{
/* correct for Intel only! little endian */
- unsigned char b[4] = { 0xef, 0xbe, 0xad, 0xde };
- int i;
- char *cdata = data;
- for (i = 0; i < len; i++) {
- *cdata = b[i % 4];
- cdata++;
- }
+ unsigned char b[4] = { 0xef, 0xbe, 0xad, 0xde };
+ int i;
+ char *cdata = data;
+ for (i = 0; i < len; i++)
+ {
+ *cdata = b[i % 4];
+ cdata++;
+ }
}
#endif
void
dlinkAdd(void *data, dlink_node * m, dlink_list * list)
{
- m->data = data;
- m->next = NULL;
- m->next = list->head;
- /* Assumption: If list->tail != NULL, list->head != NULL */
- if (list->head != NULL)
- list->head->prev = m;
- else if (list->tail == NULL)
- list->tail = m;
- list->head = m;
+ m->data = data;
+ m->next = NULL;
+ m->next = list->head;
+ /* Assumption: If list->tail != NULL, list->head != NULL */
+ if (list->head != NULL)
+ list->head->prev = m;
+ else if (list->tail == NULL)
+ list->tail = m;
+ list->head = m;
}
void
-dlinkAddBefore(dlink_node *b, void *data, dlink_node *m, dlink_list *list)
+dlinkAddBefore(dlink_node * b, void *data, dlink_node * m, dlink_list * list)
{
- /* Shortcut - if its the first one, call dlinkAdd only */
- if (b == list->head)
- dlinkAdd(data, m, list);
- else {
- m->data = data;
- b->prev->next = m;
- m->prev = b->prev;
- b->prev = m;
- m->next = b;
- }
+ /* Shortcut - if its the first one, call dlinkAdd only */
+ if (b == list->head)
+ dlinkAdd(data, m, list);
+ else
+ {
+ m->data = data;
+ b->prev->next = m;
+ m->prev = b->prev;
+ b->prev = m;
+ m->next = b;
+ }
}
void
-dlinkAddTail(void *data, dlink_node *m, dlink_list *list)
+dlinkAddTail(void *data, dlink_node * m, dlink_list * list)
{
- m->data = data;
- m->next = NULL;
- m->prev = list->tail;
- /* Assumption: If list->tail != NULL, list->head != NULL */
- if (list->tail != NULL)
- list->tail->next = m;
- else if (list->head == NULL)
- list->head = m;
- list->tail = m;
+ m->data = data;
+ m->next = NULL;
+ m->prev = list->tail;
+ /* Assumption: If list->tail != NULL, list->head != NULL */
+ if (list->tail != NULL)
+ list->tail->next = m;
+ else if (list->head == NULL)
+ list->head = m;
+ list->tail = m;
}
/* Execution profiles show that this function is called the most
* often of all non-spontaneous functions. So it had better be
* efficient. */
void
-dlinkDelete(dlink_node *m, dlink_list *list)
+dlinkDelete(dlink_node * m, dlink_list * list)
{
- /* Assumption: If m->next == NULL, then list->tail == m
- * and: If m->prev == NULL, then list->head == m
- */
- if (m->next)
- m->next->prev = m->prev;
- else
- list->tail = m->prev;
- if (m->prev)
- m->prev->next = m->next;
- else
- list->head = m->next;
- /* XXX - does this ever matter? */
- m->next = m->prev = NULL;
+ /* Assumption: If m->next == NULL, then list->tail == m
+ * and: If m->prev == NULL, then list->head == m
+ */
+ if (m->next)
+ m->next->prev = m->prev;
+ else
+ list->tail = m->prev;
+ if (m->prev)
+ m->prev->next = m->next;
+ else
+ list->head = m->next;
+ /* XXX - does this ever matter? */
+ m->next = m->prev = NULL;
}
* output - return the length (>=0) of a chain of links.
* side effects -
*/
-extern int dlink_list_length(dlink_list *list)
+extern int
+dlink_list_length(dlink_list * list)
{
dlink_node *ptr;
- int count = 0;
+ int count = 0;
for (ptr = list->head; ptr; ptr = ptr->next)
count++;
* output - pointer to link or NULL if not found
* side effects - Look for ptr in the linked listed pointed to by link.
*/
-dlink_node *dlinkFind(dlink_list *list, void * data )
+dlink_node *
+dlinkFind(dlink_list * list, void *data)
{
dlink_node *ptr;
for (ptr = list->head; ptr; ptr = ptr->next)
- {
- if (ptr->data == data)
- return (ptr);
- }
+ {
+ if (ptr->data == data)
+ return (ptr);
+ }
return (NULL);
}
void
-dlinkMoveList(dlink_list *from, dlink_list *to)
+dlinkMoveList(dlink_list * from, dlink_list * to)
{
/* There are three cases */
/* case one, nothing in from list */
- if(from->head == NULL)
- return;
+ if (from->head == NULL)
+ return;
/* case two, nothing in to list */
/* actually if to->head is NULL and to->tail isn't, thats a bug */
- if(to->head == NULL) {
- to->head = from->head;
- to->tail = from->tail;
- from->head = from->tail = NULL;
- return;
- }
+ if (to->head == NULL)
+ {
+ to->head = from->head;
+ to->tail = from->tail;
+ from->head = from->tail = NULL;
+ return;
+ }
/* third case play with the links */
- from->tail->next = to->head;
- from->head->prev = to->head->prev;
- to->head->prev = from->tail;
- to->head = from->head;
- from->head = from->tail = NULL;
+ from->tail->next = to->head;
+ from->head->prev = to->head->prev;
+ to->head->prev = from->tail;
+ to->head = from->head;
+ from->head = from->tail = NULL;
/* I think I got that right */
}
-
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vchannel.c,v 1.1 2002/01/04 09:14:55 a1kmm Exp $
+ * $Id: vchannel.c,v 1.2 2002/01/04 11:06:44 a1kmm Exp $
*/
#include "tools.h"
/* don't cjoin a vchan, only the top is allowed */
if (IsVchan(root))
- {
- /* could send a notice here, but on a vchan aware server
- * they shouldn't see the sub chans anyway
- */
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, source_p->name, name);
- return NULL;
- }
+ {
+ /* could send a notice here, but on a vchan aware server
+ * they shouldn't see the sub chans anyway
+ */
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, source_p->name, name);
+ return NULL;
+ }
if (on_sub_vchan(root, source_p))
- {
- sendto_one(source_p, form_str(ERR_ALREADYONVCHAN),
- me.name, source_p->name, name);
- return NULL;
- }
+ {
+ sendto_one(source_p, form_str(ERR_ALREADYONVCHAN),
+ me.name, source_p->name, name);
+ return NULL;
+ }
/* "root" channel name exists, now create a new copy of it */
if (strlen(name) > CHANNELLEN - 15)
- {
- sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name, source_p->name,
- name);
- return NULL;
- }
+ {
+ sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name, source_p->name,
+ name);
+ return NULL;
+ }
if ((source_p->user->joined >= ConfigChannel.max_chans_per_user) &&
(!IsOper(source_p) || (source_p->user->joined >=
ConfigChannel.max_chans_per_user * 3)))
- {
- sendto_one(source_p, form_str(ERR_TOOMANYCHANNELS),
- me.name, source_p->name, name);
- return NULL;
- }
+ {
+ sendto_one(source_p, form_str(ERR_TOOMANYCHANNELS),
+ me.name, source_p->name, name);
+ return NULL;
+ }
/* Find an unused vchan name (##<chan>_<ts> format) */
vchan_ts = CurrentTime - 1;
do
+ {
+ vchan_ts++;
+
+ /*
+ * We have to give up eventually, so only allow the TS
+ * to be up to MAX_TS_DELTA seconds out.
+ */
+ if (vchan_ts > (CurrentTime + ConfigFileEntry.ts_max_delta))
{
- vchan_ts++;
-
- /*
- * We have to give up eventually, so only allow the TS
- * to be up to MAX_TS_DELTA seconds out.
- */
- if (vchan_ts > (CurrentTime + ConfigFileEntry.ts_max_delta))
- {
- sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
- me.name, source_p->name, name);
- return NULL;
- }
-
- ircsprintf(vchan_name, "##%s_%u", name + 1, vchan_ts);
- vchan_chptr = hash_find_channel(vchan_name);
+ sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
+ me.name, source_p->name, name);
+ return NULL;
+ }
+
+ ircsprintf(vchan_name, "##%s_%u", name + 1, vchan_ts);
+ vchan_chptr = hash_find_channel(vchan_name);
} while (vchan_chptr);
vchan_chptr = get_or_create_channel(source_p, vchan_name, NULL);
if (vchan_chptr == NULL)
- {
- sendto_one(source_p, form_str(ERR_BADCHANNAME),
- me.name, source_p->name, (unsigned char *)name);
- return NULL;
- }
+ {
+ sendto_one(source_p, form_str(ERR_BADCHANNAME),
+ me.name, source_p->name, (unsigned char *)name);
+ return NULL;
+ }
m = make_dlink_node();
dlinkAdd(vchan_chptr, m, &root->vchan_list);
struct Channel *chptr;
if (IsVchanTop(root))
+ {
+ if (on_sub_vchan(root, source_p))
+ return NULL;
+ if (vkey && vkey[0] == '!')
{
- if (on_sub_vchan(root, source_p))
+ /* user joined with key "!". force listing.
+ (this prevents join-invited-chan voodoo) */
+ if (!vkey[1])
+ {
+ show_vchans(source_p, root, "join");
return NULL;
- if (vkey && vkey[0] == '!')
- {
- /* user joined with key "!". force listing.
- (this prevents join-invited-chan voodoo) */
- if (!vkey[1])
- {
- show_vchans(source_p, root, "join");
- return NULL;
- }
-
- /* found a matching vchan? let them join it */
- if ((chptr = find_vchan(root, vkey)))
- return chptr;
- else
- {
- sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
- me.name, source_p->name, name);
- return NULL;
- }
- }
+ }
+
+ /* found a matching vchan? let them join it */
+ if ((chptr = find_vchan(root, vkey)))
+ return chptr;
else
- {
- /* voodoo to auto-join channel invited to */
- if ((chptr = vchan_invites(root, source_p)))
- return chptr;
- /* otherwise, they get a list of channels */
- else
- {
- show_vchans(source_p, root, "join");
- return NULL;
- }
- }
+ {
+ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
+ me.name, source_p->name, name);
+ return NULL;
+ }
}
+ else
+ {
+ /* voodoo to auto-join channel invited to */
+ if ((chptr = vchan_invites(root, source_p)))
+ return chptr;
+ /* otherwise, they get a list of channels */
+ else
+ {
+ show_vchans(source_p, root, "join");
+ return NULL;
+ }
+ }
+ }
/* trying to join a sub chans 'real' name
* don't allow that
*/
else if (IsVchan(root))
- {
- sendto_one(source_p, form_str(ERR_BADCHANNAME),
- me.name, source_p->name, name);
- return NULL;
- }
+ {
+ sendto_one(source_p, form_str(ERR_BADCHANNAME),
+ me.name, source_p->name, name);
+ return NULL;
+ }
return root;
}
for (vchanmap_node = source_p->vchan_map.head; vchanmap_node;
vchanmap_node = vchanmap_node->next)
+ {
+ vchan_info = vchanmap_node->data;
+ if (vchan_info->vchan == vchan)
{
- vchan_info = vchanmap_node->data;
- if (vchan_info->vchan == vchan)
- {
- MyFree(vchan_info);
- dlinkDelete(vchanmap_node, &source_p->vchan_map);
- free_dlink_node(vchanmap_node);
- return;
- }
+ MyFree(vchan_info);
+ dlinkDelete(vchanmap_node, &source_p->vchan_map);
+ free_dlink_node(vchanmap_node);
+ return;
}
+ }
}
/*
/* check to see if this chptr maps to a sub vchan */
for (vchanmap_node = source_p->vchan_map.head; vchanmap_node;
vchanmap_node = vchanmap_node->next)
- {
- vchan_info = vchanmap_node->data;
- if (vchan_info->base_chan == chptr)
- return YES;
- }
+ {
+ vchan_info = vchanmap_node->data;
+ if (vchan_info->base_chan == chptr)
+ return YES;
+ }
return NO;
}
/* check to see if this chptr maps to a sub vchan */
for (vchanmap_node = source_p->vchan_map.head; vchanmap_node;
vchanmap_node = vchanmap_node->next)
- {
- vchan_info = vchanmap_node->data;
- if (vchan_info->base_chan == chptr)
- return (vchan_info->vchan);
- }
+ {
+ vchan_info = vchanmap_node->data;
+ if (vchan_info->base_chan == chptr)
+ return (vchan_info->vchan);
+ }
return NULL;
}
t = buf + mlen;
if (!SecretChannel(chptr))
- {
- ircsprintf(t, "!%s ", pick_vchan_id(chptr));
- tlen = strlen(t);
- cur_len += tlen;
- t += tlen;
- }
+ {
+ ircsprintf(t, "!%s ", pick_vchan_id(chptr));
+ tlen = strlen(t);
+ cur_len += tlen;
+ t += tlen;
+ }
else
- {
- strcpy(t, "<secret> ");
- tlen = 9;
- cur_len += tlen;
- t += tlen;
- done_secret = 1;
- }
+ {
+ strcpy(t, "<secret> ");
+ tlen = 9;
+ cur_len += tlen;
+ t += tlen;
+ done_secret = 1;
+ }
for (ptr = chptr->vchan_list.head; ptr; ptr = ptr->next)
+ {
+ chtmp = ptr->data;
+
+ if (cur_len > (BUFSIZE - (NICKLEN * 2 + 5)))
{
- chtmp = ptr->data;
+ sendto_one(source_p, "%s", buf);
+ cur_len = mlen;
+ t = buf + mlen;
+ }
- if (cur_len > (BUFSIZE - (NICKLEN * 2 + 5)))
- {
- sendto_one(source_p, "%s", buf);
- cur_len = mlen;
- t = buf + mlen;
- }
-
- /* Obey the rules of /list */
- if (SecretChannel(chtmp))
- {
- if (!done_secret)
- {
- strcpy(t, "<secret> ");
- tlen = 9;
- cur_len += tlen;
- t += tlen;
- done_secret = 1;
- }
- }
- else
- {
- ircsprintf(t, "!%s ", pick_vchan_id(chtmp));
- tlen = strlen(t);
- cur_len += tlen;
- t += tlen;
- }
+ /* Obey the rules of /list */
+ if (SecretChannel(chtmp))
+ {
+ if (!done_secret)
+ {
+ strcpy(t, "<secret> ");
+ tlen = 9;
+ cur_len += tlen;
+ t += tlen;
+ done_secret = 1;
+ }
}
+ else
+ {
+ ircsprintf(t, "!%s ", pick_vchan_id(chtmp));
+ tlen = strlen(t);
+ cur_len += tlen;
+ t += tlen;
+ }
+ }
sendto_one(source_p, "%s", buf);
}
for (lp = chptr->chanops.head; lp; lp = lp->next)
if (!lp->next)
- {
- target_p = lp->data;
- return target_p->name;
- }
+ {
+ target_p = lp->data;
+ return target_p->name;
+ }
#ifdef REQUIRE_OANDV
for (lp = chptr->chanops_voiced.head; lp; lp = lp->next)
if (!lp->next)
- {
- target_p = lp->data;
- return target_p->name;
- }
+ {
+ target_p = lp->data;
+ return target_p->name;
+ }
#endif
for (lp = chptr->halfops.head; lp; lp = lp->next)
if (!lp->next)
- {
- target_p = lp->data;
- return target_p->name;
- }
+ {
+ target_p = lp->data;
+ return target_p->name;
+ }
for (lp = chptr->voiced.head; lp; lp = lp->next)
if (!lp->next)
- {
- target_p = lp->data;
- return target_p->name;
- }
+ {
+ target_p = lp->data;
+ return target_p->name;
+ }
for (lp = chptr->peons.head; lp; lp = lp->next)
if (!lp->next)
- {
- target_p = lp->data;
- return target_p->name;
- }
+ {
+ target_p = lp->data;
+ return target_p->name;
+ }
return chptr->vchan_id;
}
/* try and match vchan_id */
if (*key == '!')
- {
- /* first the root */
- if (chptr->vchan_id && (irccmp(chptr->vchan_id, key) == 0))
- return chptr;
+ {
+ /* first the root */
+ if (chptr->vchan_id && (irccmp(chptr->vchan_id, key) == 0))
+ return chptr;
- /* then it's vchans */
- for (ptr = chptr->vchan_list.head; ptr; ptr = ptr->next)
- {
- chtmp = ptr->data;
- if (chtmp->vchan_id && (irccmp(chtmp->vchan_id, key) == 0))
- return chtmp;
- }
+ /* then it's vchans */
+ for (ptr = chptr->vchan_list.head; ptr; ptr = ptr->next)
+ {
+ chtmp = ptr->data;
+ if (chtmp->vchan_id && (irccmp(chtmp->vchan_id, key) == 0))
+ return chtmp;
}
+ }
return NULL;
}
*/
for (lp = source_p->user->invited.head; lp; lp = lp->next)
- {
- /* check root first */
- if (lp->data == chptr)
- return chptr;
+ {
+ /* check root first */
+ if (lp->data == chptr)
+ return chptr;
- /* then vchan list */
- for (vptr = chptr->vchan_list.head; vptr; vptr = vptr->next)
- {
- cp = vptr->data;
+ /* then vchan list */
+ for (vptr = chptr->vchan_list.head; vptr; vptr = vptr->next)
+ {
+ cp = vptr->data;
- if (lp->data == cp)
- return cp;
- }
+ if (lp->data == cp)
+ return cp;
}
+ }
return NULL;
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
-* $Id: whowas.c,v 1.1 2002/01/04 09:14:59 a1kmm Exp $
+* $Id: whowas.c,v 1.2 2002/01/04 11:06:44 a1kmm Exp $
*/
#include <sys/types.h>
/* internally defined function */
static void add_whowas_to_clist(struct Whowas **, struct Whowas *);
-static void del_whowas_from_clist(struct Whowas **,struct Whowas *);
+static void del_whowas_from_clist(struct Whowas **, struct Whowas *);
static void add_whowas_to_list(struct Whowas **, struct Whowas *);
-static void del_whowas_from_list(struct Whowas **,struct Whowas *);
+static void del_whowas_from_list(struct Whowas **, struct Whowas *);
struct Whowas WHOWAS[NICKNAMEHISTORYLENGTH];
struct Whowas *WHOWASHASH[WW_MAX];
static int whowas_next = 0;
-unsigned int hash_whowas_name(const char* name)
+unsigned int
+hash_whowas_name(const char *name)
{
unsigned int h = 0;
while (*name)
- {
- h = (h << 4) - (h + (unsigned char)ToLower(*name++));
- }
- return(h & (WW_MAX - 1));
+ {
+ h = (h << 4) - (h + (unsigned char)ToLower(*name++));
+ }
+ return (h & (WW_MAX - 1));
}
-void add_history(struct Client* client_p, int online)
+void
+add_history(struct Client *client_p, int online)
{
- struct Whowas* who = &WHOWAS[whowas_next];
+ struct Whowas *who = &WHOWAS[whowas_next];
assert(0 != client_p);
if (who->hashv != -1)
- {
- if (who->online)
- del_whowas_from_clist(&(who->online->whowas),who);
- del_whowas_from_list(&WHOWASHASH[who->hashv], who);
- }
+ {
+ if (who->online)
+ del_whowas_from_clist(&(who->online->whowas), who);
+ del_whowas_from_list(&WHOWASHASH[who->hashv], who);
+ }
who->hashv = hash_whowas_name(client_p->name);
who->logoff = CurrentTime;
/*
who->servername = client_p->user->server;
if (online)
- {
- who->online = client_p;
- add_whowas_to_clist(&(client_p->whowas), who);
- }
+ {
+ who->online = client_p;
+ add_whowas_to_clist(&(client_p->whowas), who);
+ }
else
who->online = NULL;
add_whowas_to_list(&WHOWASHASH[who->hashv], who);
whowas_next = 0;
}
-void off_history(struct Client *client_p)
+void
+off_history(struct Client *client_p)
{
struct Whowas *temp, *next;
- for(temp=client_p->whowas;temp;temp=next)
- {
- next = temp->cnext;
- temp->online = NULL;
- del_whowas_from_clist(&(client_p->whowas), temp);
- }
+ for (temp = client_p->whowas; temp; temp = next)
+ {
+ next = temp->cnext;
+ temp->online = NULL;
+ del_whowas_from_clist(&(client_p->whowas), temp);
+ }
}
-struct Client *get_history(char *nick,time_t timelimit)
+struct Client *
+get_history(char *nick, time_t timelimit)
{
struct Whowas *temp;
int blah;
timelimit = CurrentTime - timelimit;
blah = hash_whowas_name(nick);
temp = WHOWASHASH[blah];
- for(;temp;temp=temp->next)
- {
- if (irccmp(nick, temp->name))
- continue;
- if (temp->logoff < timelimit)
- continue;
- return temp->online;
- }
+ for (; temp; temp = temp->next)
+ {
+ if (irccmp(nick, temp->name))
+ continue;
+ if (temp->logoff < timelimit)
+ continue;
+ return temp->online;
+ }
return NULL;
}
-void count_whowas_memory(int *wwu,
- u_long *wwum)
+void
+count_whowas_memory(int *wwu, u_long * wwum)
{
struct Whowas *tmp;
int i;
- int u = 0;
- u_long um = 0;
+ int u = 0;
+ u_long um = 0;
/* count the number of used whowas structs in 'u' */
/* count up the memory used of whowas structs in um */
for (i = 0, tmp = &WHOWAS[0]; i < NICKNAMEHISTORYLENGTH; i++, tmp++)
if (tmp->hashv != -1)
- {
- u++;
- um += sizeof(struct Whowas);
- }
+ {
+ u++;
+ um += sizeof(struct Whowas);
+ }
*wwu = u;
*wwum = um;
return;
}
-void initwhowas()
+void
+initwhowas()
{
int i;
- for (i=0;i<NICKNAMEHISTORYLENGTH;i++)
- {
- memset((void *)&WHOWAS[i], 0, sizeof(struct Whowas));
- WHOWAS[i].hashv = -1;
- }
- for (i=0;i<WW_MAX;i++)
- WHOWASHASH[i] = NULL;
+ for (i = 0; i < NICKNAMEHISTORYLENGTH; i++)
+ {
+ memset((void *)&WHOWAS[i], 0, sizeof(struct Whowas));
+ WHOWAS[i].hashv = -1;
+ }
+ for (i = 0; i < WW_MAX; i++)
+ WHOWASHASH[i] = NULL;
}
-static void add_whowas_to_clist(struct Whowas **bucket,struct Whowas *whowas)
+static void
+add_whowas_to_clist(struct Whowas **bucket, struct Whowas *whowas)
{
whowas->cprev = NULL;
if ((whowas->cnext = *bucket) != NULL)
whowas->cnext->cprev = whowas;
*bucket = whowas;
}
-
-static void del_whowas_from_clist(struct Whowas **bucket,
- struct Whowas *whowas)
+
+static void
+del_whowas_from_clist(struct Whowas **bucket, struct Whowas *whowas)
{
if (whowas->cprev)
whowas->cprev->cnext = whowas->cnext;
whowas->cnext->cprev = whowas->cprev;
}
-static void add_whowas_to_list(struct Whowas **bucket, struct Whowas *whowas)
+static void
+add_whowas_to_list(struct Whowas **bucket, struct Whowas *whowas)
{
whowas->prev = NULL;
if ((whowas->next = *bucket) != NULL)
whowas->next->prev = whowas;
*bucket = whowas;
}
-
-static void del_whowas_from_list(struct Whowas **bucket,
- struct Whowas *whowas)
+
+static void
+del_whowas_from_list(struct Whowas **bucket, struct Whowas *whowas)
{
if (whowas->prev)
whowas->prev->next = whowas->next;