1
0
mirror of https://github.com/osmarks/ngircd.git synced 2026-01-08 13:19:04 +00:00

Compare commits

...

21 Commits

Author SHA1 Message Date
Alexander Barton
52512462a2 ngIRCd 0.10.1. 2006-12-17 14:06:19 +00:00
Alexander Barton
d9323ada46 Updated documentation for release 0.10.1. 2006-12-17 13:55:29 +00:00
Alexander Barton
ec1847f018 Added support for Solaris 11. [from HEAD] 2006-12-17 13:49:49 +00:00
Florian Westphal
0af8fafdfb add PredefChannelsOnly to manpage [from HEAD] 2006-12-11 22:08:14 +00:00
Florian Westphal
c9e26562ce Changed Numerics 265 and 266 to follow ircd 2.11.x "standards". [from HEAD]
Allow PASS syntax defined in RFC 1459 for server links, too. [from HEAD]
Enhanced ISUPPORT message (005 numeric). [from HEAD]
2006-12-02 14:26:52 +00:00
Florian Westphal
a64e33b317 cleanups [from HEAD] 2006-12-02 14:21:26 +00:00
Florian Westphal
7e2e23d12f make several counters unsigned, char *s -> const char *s [from HEAD] 2006-12-02 14:00:00 +00:00
Florian Westphal
ab7bb74581 cleanups [from HEAD] 2006-12-02 13:54:10 +00:00
Florian Westphal
254bf129dc merge Conf_PredefChannelsOnly [from HEAD] 2006-12-02 13:33:52 +00:00
Florian Westphal
14cdb7fdd0 char* -> const char* [from HEAD] 2006-12-02 13:18:22 +00:00
Florian Westphal
740d876c44 backport checks for inline keyword and strcspn() [from HEAD] 2006-12-02 13:13:53 +00:00
Florian Westphal
de9a130bd9 merge Conf_PredefChannelsOnly Config Option [from HEAD] 2006-12-02 13:10:43 +00:00
Florian Westphal
a0e0da74f8 make several counters unsigned [from HEAD] 2006-12-02 13:08:02 +00:00
Florian Westphal
83c14a6383 - whitespace damage [from HEAD] 2006-12-02 13:06:50 +00:00
Florian Westphal
6c12659bcf #define MASK_LEN should use parentheses [from HEAD] 2006-12-02 13:05:38 +00:00
Florian Westphal
83d4d66818 make LogDebug() 'static inline' if DEBUG is not defined [from HEAD] 2006-12-02 13:02:07 +00:00
Florian Westphal
2434e86e14 char *foo -> const char *foo [from HEAD] 2006-12-02 13:01:11 +00:00
Florian Westphal
2b4b416d2f cleanups [from HEAD] 2006-12-02 13:00:25 +00:00
Alexander Barton
62f74db6f6 Fixed validation of server names containing digits. [from HEAD] 2006-11-10 10:06:14 +00:00
Florian Westphal
cf4ae77991 fix Channel_Join() [from HEAD] 2006-10-05 18:30:47 +00:00
Alexander Barton
1f652554dd Update info text of local server after re-reading configuration. [from HEAD] 2006-10-03 11:01:05 +00:00
31 changed files with 431 additions and 346 deletions

View File

@@ -10,6 +10,18 @@
-- ChangeLog --
ngIRCd 0.10.1 (2006-12-17)
- Fixed validation of server names containing digits.
- Update the "info text" of the local server after re-reading configuration.
- Changed Numerics 265 and 266 to follow ircd 2.11.x "standards".
- Allow PASS syntax defined in RFC 1459 for server links, too.
- Enhanced ISUPPORT message (005 numeric).
- New configuration option "PredefChannelsOnly": if set, clients can only
join predefined channels.
- Code cleanups: use "LogDebug(...)" instead of "Log(LOG_DEBUG, ...)", use
"strcspn()", unsigned vs. signed, use "const", fix whitespaces, ...
ngIRCd 0.10.0 (2006-10-01)
- Fixed file handle leak when daemon is not able to send MOTD to a client.
@@ -661,4 +673,4 @@ ngIRCd 0.0.1, 31.12.2001
--
$Id: ChangeLog,v 1.302.2.4 2006/10/01 16:21:55 alex Exp $
$Id: ChangeLog,v 1.302.2.9 2006/12/17 13:55:29 alex Exp $

8
NEWS
View File

@@ -10,6 +10,12 @@
-- NEWS --
ngIRCd 0.10.1 (2006-12-17)
- Allow PASS syntax defined in RFC 1459 for server links, too.
- New configuration option "PredefChannelsOnly": if set, clients can only
join predefined channels.
ngIRCd 0.10.0 (2006-10-01)
ngIRCd 0.10.0-pre1 (2006-08-02)
@@ -223,4 +229,4 @@ ngIRCd 0.0.1, 31.12.2001
--
$Id: NEWS,v 1.75.2.3 2006/10/01 16:21:55 alex Exp $
$Id: NEWS,v 1.75.2.4 2006/12/17 13:55:29 alex Exp $

View File

@@ -8,13 +8,13 @@
# (at your option) any later version.
# Please read the file COPYING, README and AUTHORS for more information.
#
# $Id: configure.in,v 1.118.2.6 2006/10/01 16:21:56 alex Exp $
# $Id: configure.in,v 1.118.2.8 2006/12/17 14:06:19 alex Exp $
#
# -- Initialisation --
AC_PREREQ(2.50)
AC_INIT(ngircd, 0.10.0)
AC_INIT(ngircd, 0.10.1)
AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(1.6)
@@ -53,6 +53,7 @@ AC_PROG_RANLIB
AM_C_PROTOTYPES
AC_C_CONST
AC_C_INLINE
# -- Hard coded system and compiler dependencies/features/options ... --
@@ -137,7 +138,7 @@ AC_FUNC_STRFTIME
AC_CHECK_FUNCS([ \
bind gethostbyaddr gethostbyname gethostname inet_ntoa malloc memmove \
memset realloc setsid setsockopt socket strcasecmp strchr strerror \
memset realloc setsid setsockopt socket strcasecmp strchr strcspn strerror \
strstr waitpid],,AC_MSG_ERROR([required function missing!]))
AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat)
@@ -198,7 +199,7 @@ if test "$x_zlib_on" = "yes"; then
fi
x_io_backend=select
x_io_backend=select\(\)
AC_ARG_WITH(epoll,
[ --without-epoll disable epoll support (autodetected by default)],
[ if test "$withval" != "no"; then
@@ -207,16 +208,17 @@ AC_ARG_WITH(epoll,
CPPFLAGS="-I$withval/include $CPPFLAGS"
LDFLAGS="-L$withval/lib $LDFLAGS"
fi
AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll,
AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll\(\),
AC_MSG_ERROR([Can't enable epoll support!])
)
fi
],
[
AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll)
AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll\(\))
]
)
AC_ARG_WITH(kqueue,
[ --without-kqueue disable kqueue support (autodetected by default)],
[ if test "$withval" != "no"; then
@@ -225,13 +227,13 @@ AC_ARG_WITH(kqueue,
CPPFLAGS="-I$withval/include $CPPFLAGS"
LDFLAGS="-L$withval/lib $LDFLAGS"
fi
AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue,
AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
AC_MSG_ERROR([Can't enable kqueue support!])
)
fi
],
[
AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue)
AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
]
)
@@ -481,7 +483,7 @@ test "$x_identauth_on" = "yes" \
&& echo $ECHO_N "yes $ECHO_C" \
|| echo $ECHO_N "no $ECHO_C"
echo $ECHO_N " I/O backend: $ECHO_C"
echo "\"$x_io_backend()\""
echo "\"$x_io_backend\""
echo

View File

@@ -1,3 +1,9 @@
ngircd (0.10.1-0ab1) unstable; urgency=low
* New "upstream" release: 0.10.1
-- Alexander Barton <alex@barton.de> Sun, 17 Dec 2006 14:52:06 +0100
ngircd (0.10.0-0ab1) unstable; urgency=low
* New "upstream" release: 0.10.0

View File

@@ -1,5 +1,5 @@
%define name ngircd
%define version 0.10.0
%define version 0.10.1
%define release 1
%define prefix %{_prefix}

View File

@@ -1,4 +1,4 @@
# $Id: sample-ngircd.conf,v 1.37 2006/04/09 12:27:23 alex Exp $
# $Id: sample-ngircd.conf,v 1.37.2.1 2006/12/02 13:10:43 fw Exp $
#
# This is a sample configuration file for the ngIRCd, which must be adepted
@@ -93,6 +93,9 @@
# server? (This is a compatibility hack for ircd-irc2 servers)
;OperServerMode = no
# Allow Pre-Defined Channels only (see Section [Channels])
;PredefChannelsOnly = no
# Maximum number of simultaneous connection the server is allowed
# to accept (<=0: unlimited):
;MaxConnections = -1

View File

@@ -1,5 +1,5 @@
.\"
.\" $Id: ngircd.conf.5,v 1.20 2005/09/02 14:39:00 fw Exp $
.\" $Id: ngircd.conf.5,v 1.20.2.1 2006/12/11 22:08:14 fw Exp $
.\"
.TH ngircd.conf 5 "August 2005" ngircd "ngIRCd Manual"
.SH NAME
@@ -146,6 +146,11 @@ If OperCanUseMode is enabled, this may lead the compatibility problems with
Servers that run the ircd-irc2 Software. This Option "masks" mode requests
by non-chanops as if they were coming from the server. Default: no.
.TP
\fBPredefChannelsOnly\fR
If enabled, no new channels can be created. Useful if
you do not want to have channels other than those defined in
the config file.
.TP
\fBMaxConnections\fR
Maximum number of simultaneous connection the server is allowed to accept
(<=0: unlimited). Default: -1.

View File

@@ -12,7 +12,7 @@
#include "array.h"
static char UNUSED id[] = "$Id: array.c,v 1.11 2006/07/01 22:11:48 fw Exp $";
static char UNUSED id[] = "$Id: array.c,v 1.11.2.1 2006/12/02 13:00:25 fw Exp $";
#include <assert.h>
@@ -66,10 +66,7 @@ array_alloc(array * a, size_t size, size_t pos)
assert(size > 0);
if (pos_plus1 < pos)
return NULL;
if (!safemult_sizet(size, pos_plus1, &alloc))
if (pos_plus1 == 0 || !safemult_sizet(size, pos_plus1, &alloc))
return NULL;
if (a->allocated < alloc) {
@@ -263,7 +260,7 @@ array_get(array * a, size_t membersize, size_t pos)
if (a->allocated < totalsize)
return NULL;
return a->mem + pos * membersize;
return a->mem + totalsize;
}
@@ -283,16 +280,6 @@ array_free(array * a)
}
void
array_free_wipe(array * a)
{
if (!array_UNUSABLE(a))
memset(a->mem, 0, a->allocated);
array_free(a);
}
void *
array_start(const array * const a)
{
@@ -331,9 +318,6 @@ array_moveleft(array * a, size_t membersize, size_t pos)
assert(a != NULL);
assert(membersize > 0);
if (!pos)
return;
if (!safemult_sizet(membersize, pos, &bytepos)) {
a->used = 0;
return;

View File

@@ -17,7 +17,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: channel.c,v 1.56 2006/07/24 22:54:09 alex Exp $";
static char UNUSED id[] = "$Id: channel.c,v 1.56.2.1 2006/12/02 13:08:02 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -114,7 +114,7 @@ Channel_InitPredefined( void )
c = Conf_Channel[i].modes;
while (*c)
Channel_ModeAdd(chan, *c++);
Log(LOG_INFO, "Created pre-defined channel \"%s\".",
Conf_Channel[i].name );
}
@@ -173,7 +173,7 @@ Channel_Join( CLIENT *Client, char *Name )
{
/* Gibt es noch nicht? Dann neu anlegen: */
chan = Channel_Create( Name );
if( ! chan ) return false;
if (!chan) return false;
}
/* User dem Channel hinzufuegen */
@@ -214,7 +214,6 @@ Channel_Kick( CLIENT *Client, CLIENT *Origin, char *Name, char *Reason )
assert( Name != NULL );
assert( Reason != NULL );
/* Channel suchen */
chan = Channel_Search( Name );
if( ! chan )
{
@@ -266,11 +265,11 @@ Channel_Quit( CLIENT *Client, char *Reason )
} /* Channel_Quit */
GLOBAL long
GLOBAL unsigned long
Channel_Count( void )
{
CHANNEL *c;
long count = 0;
unsigned long count = 0;
c = My_Channels;
while( c )
@@ -282,11 +281,11 @@ Channel_Count( void )
} /* Channel_Count */
GLOBAL long
GLOBAL unsigned long
Channel_MemberCount( CHANNEL *Chan )
{
CL2CHAN *cl2chan;
long count = 0;
unsigned long count = 0;
assert( Chan != NULL );
@@ -340,8 +339,8 @@ Channel_PCount( void )
} /* Channel_PCount */
GLOBAL char *
Channel_Name( CHANNEL *Chan )
GLOBAL const char *
Channel_Name( const CHANNEL *Chan )
{
assert( Chan != NULL );
return Chan->name;
@@ -364,7 +363,7 @@ Channel_Key( CHANNEL *Chan )
} /* Channel_Key */
GLOBAL long
GLOBAL unsigned long
Channel_MaxUsers( CHANNEL *Chan )
{
assert( Chan != NULL );
@@ -463,25 +462,13 @@ Channel_GetChannel( CL2CHAN *Cl2Chan )
GLOBAL bool
Channel_IsValidName( char *Name )
Channel_IsValidName( const char *Name )
{
/* Pruefen, ob Name als Channelname gueltig */
char *ptr, badchars[10];
assert( Name != NULL );
if(( Name[0] != '#' ) || ( strlen( Name ) >= CHANNEL_NAME_LEN )) return false;
ptr = Name;
strcpy( badchars, " ,:\007" );
while( *ptr )
{
if( strchr( badchars, *ptr )) return false;
ptr++;
}
return true;
return Name[strcspn(Name, " ,:\007")] == 0;
} /* Channel_IsValidName */
@@ -548,7 +535,7 @@ Channel_UserModeAdd( CHANNEL *Chan, CLIENT *Client, char Mode )
cl2chan = Get_Cl2Chan( Chan, Client );
assert( cl2chan != NULL );
x[0] = Mode; x[1] = '\0';
if( ! strchr( cl2chan->modes, x[0] ))
{
@@ -594,7 +581,7 @@ GLOBAL char *
Channel_UserModes( CHANNEL *Chan, CLIENT *Client )
{
/* return Users' Channel-Modes */
CL2CHAN *cl2chan;
assert( Chan != NULL );
@@ -661,12 +648,9 @@ Channel_SetTopic(CHANNEL *Chan, CLIENT *Client, char *Topic)
if (len < array_bytes(&Chan->topic))
array_free(&Chan->topic);
if (!array_copyb(&Chan->topic, Topic, len))
if (len >= COMMAND_LEN || !array_copyb(&Chan->topic, Topic, len+1))
Log(LOG_WARNING, "could not set new Topic \"%s\" on %s: %s",
Topic, Chan->name, strerror(errno));
array_cat0(&Chan->topic);
#ifndef STRICT_RFC
Chan->topic_time = time(NULL);
if (Client != NULL && Client_Type(Client) != CLIENT_SERVER)
@@ -698,17 +682,17 @@ Channel_SetKey( CHANNEL *Chan, char *Key )
assert( Key != NULL );
strlcpy( Chan->key, Key, sizeof( Chan->key ));
Log( LOG_DEBUG, "Channel %s: Key is now \"%s\".", Chan->name, Chan->key );
LogDebug("Channel %s: Key is now \"%s\".", Chan->name, Chan->key );
} /* Channel_SetKey */
GLOBAL void
Channel_SetMaxUsers( CHANNEL *Chan, long Count )
Channel_SetMaxUsers(CHANNEL *Chan, unsigned long Count)
{
assert( Chan != NULL );
Chan->maxusers = Count;
Log( LOG_DEBUG, "Channel %s: Member limit is now %ld.", Chan->name, Chan->maxusers );
LogDebug("Channel %s: Member limit is now %lu.", Chan->name, Chan->maxusers );
} /* Channel_SetMaxUsers */
@@ -730,7 +714,7 @@ Channel_Write( CHANNEL *Chan, CLIENT *From, CLIENT *Client, char *Text )
ok = true;
if( strchr( Channel_Modes( Chan ), 'n' ) && ( ! is_member )) ok = false;
if( strchr( Channel_Modes( Chan ), 'm' ) && ( ! is_op ) && ( ! has_voice )) ok = false;
/* Is the client banned? */
if( Lists_CheckBanned( From, Chan ))
{
@@ -753,7 +737,7 @@ Channel_Create( char *Name )
CHANNEL *c;
assert( Name != NULL );
c = (CHANNEL *)malloc( sizeof( CHANNEL ));
if( ! c )
{
@@ -765,9 +749,7 @@ Channel_Create( char *Name )
c->hash = Hash( c->name );
c->next = My_Channels;
My_Channels = c;
#ifdef DEBUG
Log( LOG_DEBUG, "Created new channel structure for \"%s\".", Name );
#endif
LogDebug("Created new channel structure for \"%s\".", Name);
return c;
} /* Channel_Create */
@@ -851,25 +833,42 @@ Remove_Client( int Type, CHANNEL *Chan, CLIENT *Client, CLIENT *Origin, char *Re
switch( Type )
{
case REMOVE_QUIT:
/* QUIT: andere Server wurden bereits informiert, vgl. Client_Destroy();
* hier also "nur" noch alle User in betroffenen Channeln infomieren */
/* QUIT: other servers have already been notified, see Client_Destroy();
* so only inform other clients in same channel. */
assert( InformServer == false );
Log( LOG_DEBUG, "User \"%s\" left channel \"%s\" (%s).", Client_Mask( Client ), c->name, Reason );
LogDebug("User \"%s\" left channel \"%s\" (%s).",
Client_Mask( Client ), c->name, Reason );
break;
case REMOVE_KICK:
/* User wurde geKICKed: ggf. andere Server sowie alle betroffenen User
* im entsprechenden Channel informieren */
if( InformServer ) IRC_WriteStrServersPrefix( Client_NextHop( Origin ), Origin, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason );
IRC_WriteStrChannelPrefix( Client, c, Origin, false, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason );
if(( Client_Conn( Client ) > NONE ) && ( Client_Type( Client ) == CLIENT_USER )) IRC_WriteStrClientPrefix( Client, Origin, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason );
Log( LOG_DEBUG, "User \"%s\" has been kicked of \"%s\" by \"%s\": %s.", Client_Mask( Client ), c->name, Client_ID( Origin ), Reason );
/* User was KICKed: inform other servers and all users in channel */
if( InformServer )
IRC_WriteStrServersPrefix( Client_NextHop( Origin ),
Origin, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason);
IRC_WriteStrChannelPrefix(Client, c, Origin, false, "KICK %s %s :%s",
c->name, Client_ID( Client ), Reason );
if ((Client_Conn(Client) > NONE) &&
(Client_Type(Client) == CLIENT_USER))
{
IRC_WriteStrClientPrefix(Client, Origin, "KICK %s %s :%s",
c->name, Client_ID( Client ), Reason);
}
LogDebug("User \"%s\" has been kicked of \"%s\" by \"%s\": %s.",
Client_Mask( Client ), c->name, Client_ID(Origin), Reason);
break;
default:
/* PART */
if( InformServer ) IRC_WriteStrServersPrefix( Origin, Client, "PART %s :%s", c->name, Reason );
IRC_WriteStrChannelPrefix( Origin, c, Client, false, "PART %s :%s", c->name, Reason );
if(( Client_Conn( Origin ) > NONE ) && ( Client_Type( Origin ) == CLIENT_USER )) IRC_WriteStrClientPrefix( Origin, Client, "PART %s :%s", c->name, Reason );
Log( LOG_DEBUG, "User \"%s\" left channel \"%s\" (%s).", Client_Mask( Client ), c->name, Reason );
default: /* PART */
if (InformServer)
IRC_WriteStrServersPrefix(Origin, Client, "PART %s :%s", c->name, Reason);
IRC_WriteStrChannelPrefix(Origin, c, Client, false, "PART %s :%s",
c->name, Reason);
if ((Client_Conn(Origin) > NONE) &&
(Client_Type(Origin) == CLIENT_USER))
{
IRC_WriteStrClientPrefix( Origin, Client, "PART %s :%s", c->name, Reason);
LogDebug("User \"%s\" left channel \"%s\" (%s).",
Client_Mask(Client), c->name, Reason);
}
}
/* Wenn Channel nun leer und nicht pre-defined: loeschen */

View File

@@ -8,7 +8,7 @@
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: channel.h,v 1.29 2005/09/02 12:50:25 alex Exp $
* $Id: channel.h,v 1.29.2.1 2006/12/02 13:08:02 fw Exp $
*
* Channel management (header)
*/
@@ -35,7 +35,7 @@ typedef struct _CHANNEL
char topic_who[CLIENT_NICK_LEN];/* Nickname of user that set topic */
#endif
char key[CLIENT_PASS_LEN]; /* Channel key ("password", mode "k" ) */
long maxusers; /* Maximum number of members (mode "l") */
unsigned long maxusers; /* Maximum number of members (mode "l") */
} CHANNEL;
typedef struct _CLIENT2CHAN
@@ -65,21 +65,21 @@ GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, char *Reason ));
GLOBAL void Channel_Kick PARAMS(( CLIENT *Client, CLIENT *Origin, char *Name, char *Reason ));
GLOBAL long Channel_Count PARAMS(( void ));
GLOBAL long Channel_MemberCount PARAMS(( CHANNEL *Chan ));
GLOBAL unsigned long Channel_Count PARAMS(( void ));
GLOBAL unsigned long Channel_MemberCount PARAMS(( CHANNEL *Chan ));
GLOBAL int Channel_CountForUser PARAMS(( CLIENT *Client ));
GLOBAL int Channel_PCount PARAMS(( void ));
GLOBAL char *Channel_Name PARAMS(( CHANNEL *Chan ));
GLOBAL const char *Channel_Name PARAMS(( const CHANNEL *Chan ));
GLOBAL char *Channel_Modes PARAMS(( CHANNEL *Chan ));
GLOBAL char *Channel_Topic PARAMS(( CHANNEL *Chan ));
GLOBAL char *Channel_Key PARAMS(( CHANNEL *Chan ));
GLOBAL long Channel_MaxUsers PARAMS(( CHANNEL *Chan ));
GLOBAL unsigned long Channel_MaxUsers PARAMS(( CHANNEL *Chan ));
GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, CLIENT *Client, char *Topic ));
GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, char *Modes ));
GLOBAL void Channel_SetKey PARAMS(( CHANNEL *Chan, char *Key ));
GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, long Count ));
GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, unsigned long Count ));
GLOBAL CHANNEL *Channel_Search PARAMS(( char *Name ));
@@ -94,7 +94,7 @@ GLOBAL CL2CHAN *Channel_NextChannelOf PARAMS(( CLIENT *Client, CL2CHAN *Cl2Chan
GLOBAL CLIENT *Channel_GetClient PARAMS(( CL2CHAN *Cl2Chan ));
GLOBAL CHANNEL *Channel_GetChannel PARAMS(( CL2CHAN *Cl2Chan ));
GLOBAL bool Channel_IsValidName PARAMS(( char *Name ));
GLOBAL bool Channel_IsValidName PARAMS(( const char *Name ));
GLOBAL bool Channel_ModeAdd PARAMS(( CHANNEL *Chan, char Mode ));
GLOBAL bool Channel_ModeDel PARAMS(( CHANNEL *Chan, char Mode ));

View File

@@ -17,7 +17,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: client.c,v 1.91 2006/04/23 10:37:27 fw Exp $";
static char UNUSED id[] = "$Id: client.c,v 1.91.2.1 2006/12/02 14:00:00 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -57,8 +57,8 @@ static WHOWAS My_Whowas[MAX_WHOWAS];
static int Last_Whowas = -1;
static long Count PARAMS(( CLIENT_TYPE Type ));
static long MyCount PARAMS(( CLIENT_TYPE Type ));
static unsigned long Count PARAMS(( CLIENT_TYPE Type ));
static unsigned long MyCount PARAMS(( CLIENT_TYPE Type ));
static CLIENT *New_Client_Struct PARAMS(( void ));
static void Generate_MyToken PARAMS(( CLIENT *Client ));
@@ -211,8 +211,8 @@ Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
if( Modes ) Client_SetModes( client, Modes );
if( Type == CLIENT_SERVER ) Generate_MyToken( client );
/* ist der User away? */
if( strchr( client->modes, 'a' )) strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away ));
if( strchr( client->modes, 'a' ))
strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away ));
/* Verketten */
client->next = (POINTER *)My_Clients;
@@ -399,7 +399,7 @@ Client_SetUser( CLIENT *Client, char *User, bool Idented )
assert( Client != NULL );
assert( User != NULL );
if( Idented ) strlcpy( Client->user, User, sizeof( Client->user ));
else
{
@@ -416,7 +416,7 @@ Client_SetInfo( CLIENT *Client, char *Info )
assert( Client != NULL );
assert( Info != NULL );
strlcpy( Client->info, Info, sizeof( Client->info ));
} /* Client_SetInfo */
@@ -452,7 +452,7 @@ Client_SetPassword( CLIENT *Client, char *Pwd )
assert( Client != NULL );
assert( Pwd != NULL );
strlcpy( Client->pwd, Pwd, sizeof( Client->pwd ));
} /* Client_SetPassword */
@@ -522,7 +522,7 @@ Client_ModeAdd( CLIENT *Client, char Mode )
*/
char x[2];
assert( Client != NULL );
x[0] = Mode; x[1] = '\0';
@@ -734,11 +734,13 @@ GLOBAL CLIENT *
Client_NextHop( CLIENT *Client )
{
CLIENT *c;
assert( Client != NULL );
c = Client;
while( c->introducer && ( c->introducer != c ) && ( c->introducer != This_Server )) c = c->introducer;
while( c->introducer && ( c->introducer != c ) && ( c->introducer != This_Server ))
c = c->introducer;
return c;
} /* Client_NextHop */
@@ -750,7 +752,7 @@ Client_Mask( CLIENT *Client )
* Prefixe benoetigt wird. */
assert( Client != NULL );
if( Client->type == CLIENT_SERVER ) return Client->id;
snprintf( GetID_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, Client->host );
@@ -795,12 +797,9 @@ Client_Away( CLIENT *Client )
GLOBAL bool
Client_CheckNick( CLIENT *Client, char *Nick )
{
/* Nick ueberpruefen */
assert( Client != NULL );
assert( Nick != NULL );
/* Nick ungueltig? */
if( ! Client_IsValidNick( Nick ))
{
IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick );
@@ -913,11 +912,11 @@ Client_MyServiceCount( void )
} /* Client_MyServiceCount */
GLOBAL long
GLOBAL unsigned long
Client_MyServerCount( void )
{
CLIENT *c;
long cnt;
unsigned long cnt;
cnt = 0;
c = My_Clients;
@@ -930,11 +929,11 @@ Client_MyServerCount( void )
} /* Client_MyServerCount */
GLOBAL long
GLOBAL unsigned long
Client_OperCount( void )
{
CLIENT *c;
long cnt;
unsigned long cnt;
cnt = 0;
c = My_Clients;
@@ -947,19 +946,19 @@ Client_OperCount( void )
} /* Client_OperCount */
GLOBAL long
GLOBAL unsigned long
Client_UnknownCount( void )
{
CLIENT *c;
long cnt;
unsigned long cnt = 0;
cnt = 0;
c = My_Clients;
while( c )
{
if( c && ( c->type != CLIENT_USER ) && ( c->type != CLIENT_SERVICE ) && ( c->type != CLIENT_SERVER )) cnt++;
c = (CLIENT *)c->next;
}
return cnt;
} /* Client_UnknownCount */
@@ -979,16 +978,13 @@ Client_MyMaxUserCount( void )
GLOBAL bool
Client_IsValidNick( char *Nick )
Client_IsValidNick( const char *Nick )
{
/* Ist der Nick gueltig? */
const char *ptr;
static const char goodchars[] = ";0123456789-";
char *ptr, goodchars[20];
assert( Nick != NULL );
strcpy( goodchars, ";0123456789-" );
if( Nick[0] == '#' ) return false;
if( strchr( goodchars, Nick[0] )) return false;
if( strlen( Nick ) >= CLIENT_NICK_LEN ) return false;
@@ -996,11 +992,11 @@ Client_IsValidNick( char *Nick )
ptr = Nick;
while( *ptr )
{
if(( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return false;
if(( *ptr > '}' ) && ( ! strchr( goodchars, *ptr ))) return false;
if (( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return false;
if ( *ptr > '}' ) return false;
ptr++;
}
return true;
} /* Client_IsValidNick */
@@ -1037,13 +1033,12 @@ Client_StartTime(CLIENT *Client)
} /* Client_Uptime */
static long
static unsigned long
Count( CLIENT_TYPE Type )
{
CLIENT *c;
long cnt;
unsigned long cnt = 0;
cnt = 0;
c = My_Clients;
while( c )
{
@@ -1054,13 +1049,12 @@ Count( CLIENT_TYPE Type )
} /* Count */
static long
static unsigned long
MyCount( CLIENT_TYPE Type )
{
CLIENT *c;
long cnt;
unsigned long cnt = 0;
cnt = 0;
c = My_Clients;
while( c )
{
@@ -1075,9 +1069,9 @@ static CLIENT *
New_Client_Struct( void )
{
/* Neue CLIENT-Struktur pre-initialisieren */
CLIENT *c;
c = (CLIENT *)malloc( sizeof( CLIENT ));
if( ! c )
{
@@ -1130,7 +1124,7 @@ Adjust_Counters( CLIENT *Client )
assert( Client != NULL );
if( Client->type != CLIENT_USER ) return;
if( Client->conn_id != NONE )
{
/* Local connection */
@@ -1153,7 +1147,7 @@ Client_RegisterWhowas( CLIENT *Client )
{
int slot;
time_t now;
assert( Client != NULL );
now = time(NULL);
@@ -1167,7 +1161,7 @@ Client_RegisterWhowas( CLIENT *Client )
#ifdef DEBUG
Log( LOG_DEBUG, "Saving WHOWAS information to slot %d ...", slot );
#endif
My_Whowas[slot].time = now;
strlcpy( My_Whowas[slot].id, Client_ID( Client ),
sizeof( My_Whowas[slot].id ));
@@ -1179,7 +1173,7 @@ Client_RegisterWhowas( CLIENT *Client )
sizeof( My_Whowas[slot].info ));
strlcpy( My_Whowas[slot].server, Client_ID( Client_Introducer( Client )),
sizeof( My_Whowas[slot].server ));
Last_Whowas = slot;
} /* Client_RegisterWhowas */

View File

@@ -8,7 +8,7 @@
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: client.h,v 1.42 2006/04/23 10:37:27 fw Exp $
* $Id: client.h,v 1.42.2.2 2006/12/02 14:26:53 fw Exp $
*
* Client management (header)
*/
@@ -23,10 +23,9 @@
#define CLIENT_GOTNICK 4 /* client did send NICK */
#define CLIENT_GOTUSER 8 /* client did send USER */
#define CLIENT_USER 16 /* client is an IRC user */
#define CLIENT_UNKNOWNSERVER 32 /* unregistered server connection */
#define CLIENT_GOTPASSSERVER 64 /* client did send PASS in "server style" */
#define CLIENT_SERVER 128 /* client is a server */
#define CLIENT_SERVICE 256 /* client is a service */
#define CLIENT_SERVER 32 /* client is a server */
#define CLIENT_SERVICE 64 /* client is a service */
#define CLIENT_UNKNOWNSERVER 128 /* unregistered server connection */
#define CLIENT_TYPE int
@@ -138,15 +137,15 @@ GLOBAL bool Client_CheckID PARAMS(( CLIENT *Client, char *ID ));
GLOBAL long Client_UserCount PARAMS(( void ));
GLOBAL long Client_ServiceCount PARAMS(( void ));
GLOBAL long Client_ServerCount PARAMS(( void ));
GLOBAL long Client_OperCount PARAMS(( void ));
GLOBAL long Client_UnknownCount PARAMS(( void ));
GLOBAL unsigned long Client_OperCount PARAMS(( void ));
GLOBAL unsigned long Client_UnknownCount PARAMS(( void ));
GLOBAL long Client_MyUserCount PARAMS(( void ));
GLOBAL long Client_MyServiceCount PARAMS(( void ));
GLOBAL long Client_MyServerCount PARAMS(( void ));
GLOBAL unsigned long Client_MyServerCount PARAMS(( void ));
GLOBAL long Client_MaxUserCount PARAMS(( void ));
GLOBAL long Client_MyMaxUserCount PARAMS(( void ));
GLOBAL bool Client_IsValidNick PARAMS(( char *Nick ));
GLOBAL bool Client_IsValidNick PARAMS(( const char *Nick ));
GLOBAL WHOWAS *Client_GetWhowas PARAMS(( void ));
GLOBAL int Client_GetLastWhowasIndex PARAMS(( void ));

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: conf.c,v 1.92 2006/07/23 16:42:45 alex Exp $";
static char UNUSED id[] = "$Id: conf.c,v 1.92.2.3 2006/12/02 13:10:43 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -146,6 +146,9 @@ Conf_Rehash( void )
Set_Defaults( false );
Read_Config( );
Validate_Config(false, true);
/* Update CLIENT structure of local server */
Client_SetInfo(Client_ThisServer(), Conf_ServerInfo);
} /* Config_Rehash */
@@ -199,15 +202,16 @@ Conf_Test( void )
printf( " PingTimeout = %d\n", Conf_PingTimeout );
printf( " PongTimeout = %d\n", Conf_PongTimeout );
printf( " ConnectRetry = %d\n", Conf_ConnectRetry );
printf( " OperCanUseMode = %s\n", Conf_OperCanMode == true? "yes" : "no" );
printf( " OperCanUseMode = %s\n", Conf_OperCanMode == true ? "yes" : "no" );
printf( " OperServerMode = %s\n", Conf_OperServerMode == true? "yes" : "no" );
printf( " PredefChannelsOnly = %s\n", Conf_PredefChannelsOnly == true ? "yes" : "no" );
printf( " MaxConnections = %ld\n", Conf_MaxConnections>0 ? Conf_MaxConnections : -1);
printf( " MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP>0 ? Conf_MaxConnectionsIP : -1);
printf( " MaxJoins = %d\n\n", Conf_MaxJoins>0 ? Conf_MaxJoins : -1);
for( i = 0; i < Conf_Oper_Count; i++ ) {
if( ! Conf_Oper[i].name[0] ) continue;
/* Valid "Operator" section */
puts( "[OPERATOR]" );
printf( " Name = %s\n", Conf_Oper[i].name );
@@ -218,7 +222,7 @@ Conf_Test( void )
for( i = 0; i < MAX_SERVERS; i++ ) {
if( ! Conf_Server[i].name[0] ) continue;
/* Valid "Server" section */
puts( "[SERVER]" );
printf( " Name = %s\n", Conf_Server[i].name );
@@ -231,7 +235,7 @@ Conf_Test( void )
for( i = 0; i < Conf_Channel_Count; i++ ) {
if( ! Conf_Channel[i].name[0] ) continue;
/* Valid "Channel" section */
puts( "[CHANNEL]" );
printf( " Name = %s\n", Conf_Channel[i].name );
@@ -240,7 +244,7 @@ Conf_Test( void )
topic = (char*)array_start(&Conf_Channel[i].topic);
printf( " Topic = %s\n\n", topic ? topic : "");
}
return 0;
} /* Conf_Test */
@@ -268,14 +272,14 @@ Conf_UnsetServer( CONN_ID Idx )
Init_Server_Struct( &Conf_Server[i] );
} else {
/* Set time for next connect attempt */
t = time(NULL);
if (Conf_Server[i].lasttry < t - Conf_ConnectRetry) {
/* The connection has been "long", so we don't
* require the next attempt to be delayed. */
Conf_Server[i].lasttry =
t - Conf_ConnectRetry + RECONNECT_DELAY;
} else
Conf_Server[i].lasttry = t;
t = time(NULL);
if (Conf_Server[i].lasttry < t - Conf_ConnectRetry) {
/* The connection has been "long", so we don't
* require the next attempt to be delayed. */
Conf_Server[i].lasttry =
t - Conf_ConnectRetry + RECONNECT_DELAY;
} else
Conf_Server[i].lasttry = t;
}
}
} /* Conf_UnsetServer */
@@ -297,9 +301,9 @@ GLOBAL int
Conf_GetServer( CONN_ID Idx )
{
/* Get index of server in configuration structure */
int i = 0;
assert( Idx > NONE );
for( i = 0; i < MAX_SERVERS; i++ ) {
@@ -377,7 +381,7 @@ Conf_AddServer( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd
strlcpy( Conf_Server[i].pwd_in, PeerPwd, sizeof( Conf_Server[i].pwd_in ));
Conf_Server[i].port = Port;
Conf_Server[i].flags = CONF_SFLAG_ONCE;
return true;
} /* Conf_AddServer */
@@ -409,7 +413,7 @@ Set_Defaults( bool InitServers )
strcpy( Conf_ListenAddress, "" );
Conf_UID = Conf_GID = 0;
Conf_PingTimeout = 120;
Conf_PongTimeout = 20;
@@ -419,8 +423,9 @@ Set_Defaults( bool InitServers )
Conf_Channel_Count = 0;
Conf_OperCanMode = false;
Conf_PredefChannelsOnly = false;
Conf_OperServerMode = false;
Conf_MaxConnections = -1;
Conf_MaxConnectionsIP = 5;
Conf_MaxJoins = 10;
@@ -750,6 +755,11 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
}
return;
}
if( strcasecmp( Var, "PredefChannelsOnly" ) == 0 ) {
/* Should we only allow pre-defined-channels? (i.e. users cannot create their own channels) */
Conf_PredefChannelsOnly = Check_ArgIsTrue( Arg );
return;
}
if( strcasecmp( Var, "OperCanUseMode" ) == 0 ) {
/* Are IRC operators allowed to use MODE in channels they aren't Op in? */
Conf_OperCanMode = Check_ArgIsTrue( Arg );
@@ -912,6 +922,21 @@ Handle_SERVER( int Line, char *Var, char *Arg )
} /* Handle_SERVER */
static bool
Handle_Channelname(size_t chancount, const char *name)
{
size_t size = sizeof( Conf_Channel[chancount].name );
char *dest = Conf_Channel[chancount].name;
if (*name && *name != '#') {
*dest = '#';
--size;
++dest;
}
return size > strlcpy(dest, name, size);
}
static void
Handle_CHANNEL( int Line, char *Var, char *Arg )
{
@@ -925,9 +950,7 @@ Handle_CHANNEL( int Line, char *Var, char *Arg )
chancount = Conf_Channel_Count - 1;
if( strcasecmp( Var, "Name" ) == 0 ) {
/* Name of the channel */
len = strlcpy( Conf_Channel[chancount].name, Arg, sizeof( Conf_Channel[chancount].name ));
if (len >= sizeof( Conf_Channel[chancount].name ))
if (!Handle_Channelname(chancount, Arg))
Config_Error_TooLong( Line, Var );
return;
}
@@ -965,7 +988,7 @@ Validate_Config(bool Configtest, bool Rehash)
do {
if (*ptr >= 'a' && *ptr <= 'z') continue;
if (*ptr >= 'A' && *ptr <= 'Z') continue;
if (*ptr >= '1' && *ptr <= '0') continue;
if (*ptr >= '0' && *ptr <= '9') continue;
if (ptr > Conf_ServerName) {
if (*ptr == '.' || *ptr == '-')
continue;

View File

@@ -8,7 +8,7 @@
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: conf.h,v 1.40 2006/05/10 21:24:01 alex Exp $
* $Id: conf.h,v 1.40.2.1 2006/12/02 13:10:43 fw Exp $
*
* Configuration management (header)
*/
@@ -110,6 +110,8 @@ GLOBAL CONF_SERVER Conf_Server[MAX_SERVERS];
/* Pre-defined channels */
GLOBAL CONF_CHANNEL Conf_Channel[MAX_DEFCHANNELS];
GLOBAL unsigned int Conf_Channel_Count;
/* Pre-defined channels only */
GLOBAL bool Conf_PredefChannelsOnly;
/* Are IRC operators allowed to always use MODE? */
GLOBAL bool Conf_OperCanMode;

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: hash.c,v 1.12 2005/07/31 20:13:08 alex Exp $";
static char UNUSED id[] = "$Id: hash.c,v 1.12.2.1 2006/12/02 13:18:22 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -31,7 +31,7 @@ static UINT32 jenkins_hash PARAMS(( register UINT8 *k, register UINT32 length, r
GLOBAL UINT32
Hash( char *String )
Hash( const char *String )
{
/* Hash-Wert ueber String berechnen */

View File

@@ -8,7 +8,7 @@
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: hash.h,v 1.5 2005/03/19 18:43:48 fw Exp $
* $Id: hash.h,v 1.5.4.1 2006/12/02 13:18:22 fw Exp $
*
* Hash calculation (header)
*/
@@ -17,8 +17,7 @@
#ifndef __hash_h__
#define __hash_h__
GLOBAL UINT32 Hash PARAMS((char *String ));
GLOBAL UINT32 Hash PARAMS((const char *String ));
#endif

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-channel.c,v 1.35 2006/03/16 20:14:16 fw Exp $";
static char UNUSED id[] = "$Id: irc-channel.c,v 1.35.2.2 2006/12/02 13:33:52 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -78,8 +78,17 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
chan = NULL; flags = NULL;
/* wird der Channel neu angelegt? */
if( Channel_Search( channame )) is_new_chan = false;
else is_new_chan = true;
if( Channel_Search( channame )) {
is_new_chan = false;
} else {
if (Conf_PredefChannelsOnly) { /* this server does not allow creation of channels */
IRC_WriteStrClient( Client, ERR_BANNEDFROMCHAN_MSG, Client_ID( Client ), channame );
/* Try next name, if any */
channame = strchr(channame, ',');
continue;
}
is_new_chan = true;
}
/* Hat ein Server Channel-User-Modes uebergeben? */
if( Client_Type( Client ) == CLIENT_SERVER )
@@ -123,7 +132,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
IRC_WriteStrClient( Client, ERR_BANNEDFROMCHAN_MSG, Client_ID( Client ), channame );
/* Try next name, if any */
channame = strtok( NULL, "," );
channame = strchr(channame, ',');
continue;
}
@@ -134,7 +143,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
IRC_WriteStrClient( Client, ERR_INVITEONLYCHAN_MSG, Client_ID( Client ), channame );
/* Try next name, if any */
channame = strtok( NULL, "," );
channame = strchr(channame, ',');
continue;
}
@@ -145,7 +154,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
IRC_WriteStrClient( Client, ERR_BADCHANNELKEY_MSG, Client_ID( Client ), channame );
/* Try next name, if any */
channame = strtok( NULL, "," );
channame = strchr(channame, ',');
continue;
}
@@ -156,7 +165,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
IRC_WriteStrClient( Client, ERR_CHANNELISFULL_MSG, Client_ID( Client ), channame );
/* Try next name, if any */
channame = strtok( NULL, "," );
channame = strchr(channame, ',');
continue;
}
}
@@ -176,7 +185,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
if( ! Channel_Join( target, channame ))
{
/* naechsten Namen ermitteln */
channame = strtok( NULL, "," );
channame = strchr(channame, ',');
continue;
}
if( ! chan ) chan = Channel_Search( channame );
@@ -491,7 +500,7 @@ IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
{
if( *ptr == 'l' )
{
snprintf( l, sizeof( l ), " %ld", Channel_MaxUsers( chan ));
snprintf( l, sizeof( l ), " %lu", Channel_MaxUsers( chan ));
strlcat( modes_add, l, sizeof( modes_add ));
}
if( *ptr == 'k' )

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-info.c,v 1.33.2.1 2006/09/16 13:49:15 alex Exp $";
static char UNUSED id[] = "$Id: irc-info.c,v 1.33.2.2 2006/12/02 14:26:53 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -542,7 +542,8 @@ GLOBAL bool
IRC_WHO( CLIENT *Client, REQUEST *Req )
{
bool ok, only_ops;
char flags[8], *ptr;
char flags[8];
const char *ptr;
CL2CHAN *cl2chan;
CHANNEL *chan, *cn;
CLIENT *c;
@@ -832,7 +833,10 @@ IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
GLOBAL bool
IRC_Send_LUSERS( CLIENT *Client )
{
long cnt;
unsigned long cnt;
#ifndef STRICT_RFC
unsigned long max;
#endif
assert( Client != NULL );
@@ -861,9 +865,17 @@ IRC_Send_LUSERS( CLIENT *Client )
#ifndef STRICT_RFC
/* Maximum number of local users */
if( ! IRC_WriteStrClient( Client, RPL_LOCALUSERS_MSG, Client_ID( Client ), Client_MyUserCount( ), Client_MyMaxUserCount( ))) return DISCONNECTED;
cnt = Client_MyUserCount();
max = Client_MyMaxUserCount();
if (! IRC_WriteStrClient(Client, RPL_LOCALUSERS_MSG, Client_ID(Client),
cnt, max, cnt, max))
return DISCONNECTED;
/* Maximum number of users in the network */
if( ! IRC_WriteStrClient( Client, RPL_NETUSERS_MSG, Client_ID( Client ), Client_UserCount( ), Client_MaxUserCount( ))) return DISCONNECTED;
cnt = Client_UserCount();
max = Client_MaxUserCount();
if(! IRC_WriteStrClient(Client, RPL_NETUSERS_MSG, Client_ID(Client),
cnt, max, cnt, max))
return DISCONNECTED;
#endif
return CONNECTED;

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-login.c,v 1.49 2005/09/01 10:51:24 alex Exp $";
static char UNUSED id[] = "$Id: irc-login.c,v 1.49.2.2 2006/12/02 14:26:53 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -45,101 +45,119 @@ static bool Hello_User PARAMS(( CLIENT *Client ));
static void Kill_Nick PARAMS(( char *Nick, char *Reason ));
/**
* Handler for the IRC command "PASS".
* See RFC 2813 section 4.1.1, and RFC 2812 section 3.1.1.
*/
GLOBAL bool
IRC_PASS( CLIENT *Client, REQUEST *Req )
{
char *type, *orig_flags;
int protohigh, protolow;
assert( Client != NULL );
assert( Req != NULL );
/* Fehler liefern, wenn kein lokaler Client */
if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command );
/* Return an error if this is not a local client */
if (Client_Conn(Client) <= NONE)
return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(Client), Req->command);
if(( Client_Type( Client ) == CLIENT_UNKNOWN ) && ( Req->argc == 1))
{
/* noch nicht registrierte unbekannte Verbindung */
Log( LOG_DEBUG, "Connection %d: got PASS command ...", Client_Conn( Client ));
/* Passwort speichern */
Client_SetPassword( Client, Req->argv[0] );
Client_SetType( Client, CLIENT_GOTPASS );
return CONNECTED;
if (Client_Type(Client) == CLIENT_UNKNOWN && Req->argc == 1) {
/* Not yet registered "unknown" connection, PASS with one
* argument: either a regular client, service, or server
* using the old RFC 1459 section 4.1.1 syntax. */
LogDebug("Connection %d: got PASS command ...",
Client_Conn(Client));
} else if ((Client_Type(Client) == CLIENT_UNKNOWN ||
Client_Type(Client) == CLIENT_UNKNOWNSERVER) &&
(Req->argc == 3 || Req->argc == 4)) {
/* Not yet registered "unknown" connection or outgoing server
* link, PASS with three or four argument: server using the
* RFC 2813 section 4.1.1 syntax. */
LogDebug("Connection %d: got PASS command (new server link) ...",
Client_Conn(Client));
} else if (Client_Type(Client) == CLIENT_UNKNOWN ||
Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
/* Unregistered connection, but wrong number of arguments: */
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
} else {
/* Registered connection, PASS command is not allowed! */
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client));
}
else if((( Client_Type( Client ) == CLIENT_UNKNOWN ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER )) && (( Req->argc == 3 ) || ( Req->argc == 4 )))
{
char c2, c4, *type, *impl, *serverver, *flags, *ptr, *ircflags;
int protohigh, protolow;
/* noch nicht registrierte Server-Verbindung */
Log( LOG_DEBUG, "Connection %d: got PASS command (new server link) ...", Client_Conn( Client ));
Client_SetPassword(Client, Req->argv[0]);
Client_SetType(Client, CLIENT_GOTPASS);
/* Passwort speichern */
Client_SetPassword( Client, Req->argv[0] );
/* Protocol version */
if (Req->argc >= 2 && strlen(Req->argv[1]) >= 4) {
int c2, c4;
/* Protokollversion ermitteln */
if( strlen( Req->argv[1] ) >= 4 )
{
c2 = Req->argv[1][2];
c4 = Req->argv[1][4];
c2 = Req->argv[1][2];
c4 = Req->argv[1][4];
Req->argv[1][4] = '\0';
protolow = atoi( &Req->argv[1][2] );
Req->argv[1][2] = '\0';
protohigh = atoi( Req->argv[1] );
Req->argv[1][4] = '\0';
protolow = atoi(&Req->argv[1][2]);
Req->argv[1][2] = '\0';
protohigh = atoi(Req->argv[1]);
Req->argv[1][2] = c2;
Req->argv[1][4] = c4;
}
else protohigh = protolow = 0;
Req->argv[1][2] = c2;
Req->argv[1][4] = c4;
} else
protohigh = protolow = 0;
/* Protokoll-Typ */
if( strlen( Req->argv[1] ) > 4 ) type = &Req->argv[1][4];
else type = NULL;
/* Protocol type, see doc/Protocol.txt */
if (Req->argc >= 2 && strlen(Req->argv[1]) > 4)
type = &Req->argv[1][4];
else
type = NULL;
/* Protocol flags/options */
if (Req->argc >= 4)
orig_flags = Req->argv[3];
else
orig_flags = "";
/* IRC-Flags (nach RFC 2813) */
if( Req->argc >= 4 ) ircflags = Req->argv[3];
else ircflags = "";
/* Implementation, version and IRC+ flags */
if (Req->argc >= 3) {
char *impl, *ptr, *serverver, *flags;
/* Implementation, Version und ngIRCd-Flags */
impl = Req->argv[2];
ptr = strchr( impl, '|' );
if( ptr ) *ptr = '\0';
ptr = strchr(impl, '|');
if (ptr)
*ptr = '\0';
if( type && ( strcmp( type, PROTOIRCPLUS ) == 0 ))
{
/* auf der anderen Seite laeuft ein Server, der
* ebenfalls das IRC+-Protokoll versteht */
if (type && strcmp(type, PROTOIRCPLUS) == 0) {
/* The peer seems to be a server which supports the
* IRC+ protocol (see doc/Protocol.txt). */
serverver = ptr + 1;
flags = strchr( serverver, ':' );
if( flags )
{
flags = strchr(serverver, ':');
if (flags) {
*flags = '\0';
flags++;
}
else flags = "";
Log( LOG_INFO, "Peer announces itself as %s-%s using protocol %d.%d/IRC+ (flags: \"%s\").", impl, serverver, protohigh, protolow, flags );
}
else
{
/* auf der anderen Seite laeuft ein Server, der
* nur das Originalprotokoll unterstuetzt */
} else
flags = "";
Log(LOG_INFO,
"Peer announces itself as %s-%s using protocol %d.%d/IRC+ (flags: \"%s\").",
impl, serverver, protohigh, protolow, flags);
} else {
/* The peer seems to be a server supporting the
* "original" IRC protocol (RFC 2813). */
serverver = "";
if( strchr( ircflags, 'Z' )) flags = "Z";
else flags = "";
Log( LOG_INFO, "Peer announces itself as \"%s\" using protocol %d.%d (flags: \"%s\").", impl, protohigh, protolow, flags );
if (strchr(orig_flags, 'Z'))
flags = "Z";
else
flags = "";
Log(LOG_INFO,
"Peer announces itself as \"%s\" using protocol %d.%d (flags: \"%s\").",
impl, protohigh, protolow, flags);
}
Client_SetType( Client, CLIENT_GOTPASSSERVER );
Client_SetFlags( Client, flags );
return CONNECTED;
Client_SetFlags(Client, flags);
}
else if(( Client_Type( Client ) == CLIENT_UNKNOWN ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER ))
{
/* Falsche Anzahl Parameter? */
return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
}
else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
return CONNECTED;
} /* IRC_PASS */
@@ -268,13 +286,13 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
"NICK :%s", Req->argv[0] );
IRC_WriteStrRelatedPrefix( target, target, false,
"NICK :%s", Req->argv[0] );
/* Register old nickname for WHOWAS queries */
Client_RegisterWhowas( target );
/* Save new nickname */
Client_SetID( target, Req->argv[0] );
IRC_SetPenalty( target, 2 );
}
@@ -598,9 +616,15 @@ Hello_User( CLIENT *Client )
if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, USERMODES, CHANMODES )) return false;
#endif
/* Features */
if( ! IRC_WriteStrClient( Client, RPL_ISUPPORT_MSG, Client_ID( Client ), CLIENT_NICK_LEN - 1,
COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1, Conf_MaxJoins )) return DISCONNECTED;
/* Features supported by this server (005 numeric, ISUPPORT),
* see <http://www.irc.org/tech_docs/005.html> for details. */
if (! IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
Conf_MaxJoins))
return DISCONNECTED;
if (! IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
CHANNEL_NAME_LEN-1, CLIENT_NICK_LEN-1, COMMAND_LEN-23,
CLIENT_AWAY_LEN-1, COMMAND_LEN-113))
return DISCONNECTED;
Client_SetType( Client, CLIENT_USER );

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-mode.c,v 1.45 2006/05/10 21:24:01 alex Exp $";
static char UNUSED id[] = "$Id: irc-mode.c,v 1.45.2.1 2006/12/02 14:21:26 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -69,7 +69,7 @@ IRC_MODE( CLIENT *Client, REQUEST *Req )
if( ! origin ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
}
else origin = Client;
/* Channel or user mode? */
cl = NULL; chan = NULL;
if (Client_IsValidNick(Req->argv[0]))
@@ -268,7 +268,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
switch( *mode_ptr )
{
case 'l':
snprintf( argadd, sizeof( argadd ), " %ld", Channel_MaxUsers( Channel ));
snprintf( argadd, sizeof( argadd ), " %lu", Channel_MaxUsers( Channel ));
strlcat( the_args, argadd, sizeof( the_args ));
break;
case 'k':

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-op.c,v 1.15 2005/04/27 07:39:18 alex Exp $";
static char UNUSED id[] = "$Id: irc-op.c,v 1.15.4.1 2006/12/02 14:21:26 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -101,15 +101,14 @@ IRC_INVITE( CLIENT *Client, REQUEST *Req )
/* If the target user is banned on that channel: remember invite */
if( Lists_CheckBanned( target, chan )) remember = true;
if( remember )
{
/* We must memember this invite */
if (remember) {
/* We must remember this invite */
if( ! Lists_AddInvited( Client_Mask( target ), chan, true)) return CONNECTED;
}
}
Log( LOG_DEBUG, "User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask( from ), Req->argv[0], Req->argv[1] );
LogDebug("User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask(from), Req->argv[0], Req->argv[1]);
/* Inform target client */
IRC_WriteStrClientPrefix( target, from, "INVITE %s %s", Req->argv[0], Req->argv[1] );

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-server.c,v 1.39 2006/04/30 21:31:43 alex Exp $";
static char UNUSED id[] = "$Id: irc-server.c,v 1.39.2.2 2006/12/02 14:26:53 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -41,6 +41,10 @@ static char UNUSED id[] = "$Id: irc-server.c,v 1.39 2006/04/30 21:31:43 alex Exp
#include "irc-server.h"
/**
* Handler for the IRC command "SERVER".
* See RFC 2813 section 4.1.2.
*/
GLOBAL bool
IRC_SERVER( CLIENT *Client, REQUEST *Req )
{
@@ -55,13 +59,16 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Fehler liefern, wenn kein lokaler Client */
if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command );
/* Return an error if this is not a local client */
if (Client_Conn(Client) <= NONE)
return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(Client), Req->command);
if( Client_Type( Client ) == CLIENT_GOTPASSSERVER )
{
/* Verbindung soll als Server-Server-Verbindung registriert werden */
Log( LOG_DEBUG, "Connection %d: got SERVER command (new server link) ...", Client_Conn( Client ));
if (Client_Type(Client) == CLIENT_GOTPASS) {
/* We got a PASS command from the peer, and now a SERVER
* command: the peer tries to register itself as a server. */
LogDebug("Connection %d: got SERVER command (new server link) ...",
Client_Conn(Client));
/* Falsche Anzahl Parameter? */
if(( Req->argc != 2 ) && ( Req->argc != 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
@@ -207,7 +214,13 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
else
{
/* "CHANINFO <chan> +<modes> <key> <limit> :<topic>" */
if( ! IRC_WriteStrClient( Client, "CHANINFO %s +%s %s %ld :%s", Channel_Name( chan ), modes, strchr( Channel_Modes( chan ), 'k' ) ? Channel_Key( chan ) : "*", strchr( Channel_Modes( chan ), 'l' ) ? Channel_MaxUsers( chan ) : 0L, topic )) return DISCONNECTED;
if( ! IRC_WriteStrClient( Client, "CHANINFO %s +%s %s %lu :%s",
Channel_Name( chan ), modes,
strchr( Channel_Modes( chan ), 'k' ) ? Channel_Key( chan ) : "*",
strchr( Channel_Modes( chan ), 'l' ) ? Channel_MaxUsers( chan ) : 0UL, topic ))
{
return DISCONNECTED;
}
}
}
}

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-write.c,v 1.20 2006/05/10 21:24:01 alex Exp $";
static char UNUSED id[] = "$Id: irc-write.c,v 1.20.2.1 2006/12/02 13:06:50 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -378,7 +378,7 @@ va_dcl
}
cl2chan = Channel_NextMember( chan, cl2chan );
}
/* naechsten Channel */
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
}
@@ -403,12 +403,12 @@ GLOBAL void
IRC_SetPenalty( CLIENT *Client, time_t Seconds )
{
CONN_ID c;
assert( Client != NULL );
assert( Seconds > 0 );
if( Client_Type( Client ) == CLIENT_SERVER ) return;
c = Client_Conn( Client );
if (c > NONE)
Conn_SetPenalty(c, Seconds);

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: lists.c,v 1.18 2005/07/31 20:13:08 alex Exp $";
static char UNUSED id[] = "$Id: lists.c,v 1.18.2.1 2006/12/02 13:05:38 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -36,7 +36,7 @@ static char UNUSED id[] = "$Id: lists.c,v 1.18 2005/07/31 20:13:08 alex Exp $";
#include "lists.h"
#define MASK_LEN 2*CLIENT_HOST_LEN
#define MASK_LEN (2*CLIENT_HOST_LEN)
typedef struct _C2C
@@ -106,7 +106,7 @@ Lists_IsInviteEntry( char *Mask, CHANNEL *Chan )
{
assert( Mask != NULL );
assert( Chan != NULL );
return Already_Registered( My_Invites, Mask, Chan );
} /* Lists_IsInviteEntry */

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: log.c,v 1.61 2006/07/23 23:23:45 alex Exp $";
static char UNUSED id[] = "$Id: log.c,v 1.61.2.1 2006/12/02 13:02:07 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -166,25 +166,21 @@ Log_Exit( void )
* Log function for debug messages.
* This function is only functional when the program is compiled with debug
* code enabled; otherwise it is an empty function which the compiler will
* hopefully mangle down to "nothing". Therefore you should use LogDebug(...)
* in favor to Log(LOG_DEBUG, ...).
* hopefully mangle down to "nothing" (see log.h). Therefore you should use
* LogDebug(...) in favor to Log(LOG_DEBUG, ...).
* @param Format Format string like printf().
* @param ... Further arguments.
*/
#ifdef DEBUG
# ifdef PROTOTYPES
GLOBAL void
#ifdef DEBUG
LogDebug( const char *Format, ... )
#else
LogDebug( UNUSED const char *Format, ... )
#endif /* DEBUG */
# else
GLOBAL void
LogDebug( Format, va_alist )
const char *Format;
va_dcl
# endif /* PROTOTYPES */
#ifdef DEBUG
{
char msg[MAX_LOG_MSG_LEN];
va_list ap;
@@ -199,14 +195,9 @@ va_dcl
va_end( ap );
Log(LOG_DEBUG, "%s", msg);
}
#else
{
/* Do nothing.
* The compiler should optimize this out, please ;-) */
}
#endif /* DEBUG */
/**
* Logging function of ngIRCd.
* This function logs messages to the console and/or syslog, whichever is

View File

@@ -8,7 +8,7 @@
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: log.h,v 1.19 2006/02/08 17:33:28 fw Exp $
* $Id: log.h,v 1.19.2.1 2006/12/02 13:02:07 fw Exp $
*
* Logging functions (header)
*/
@@ -39,7 +39,13 @@ GLOBAL void Log_Init PARAMS(( bool Daemon_Mode ));
GLOBAL void Log_Exit PARAMS(( void ));
GLOBAL void Log PARAMS(( int Level, const char *Format, ... ));
#ifdef DEBUG
GLOBAL void LogDebug PARAMS(( const char *Format, ... ));
#else
static inline void LogDebug PARAMS(( UNUSED const char *Format, ... )){/* Do nothing. The compiler should optimize this out, please ;-) */}
#endif
GLOBAL void Log_Init_Resolver PARAMS(( void ));
GLOBAL void Log_Exit_Resolver PARAMS(( void ));

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: match.c,v 1.4 2005/07/31 20:13:08 alex Exp $";
static char UNUSED id[] = "$Id: match.c,v 1.4.2.1 2006/12/02 13:01:11 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -32,8 +32,8 @@ static char UNUSED id[] = "$Id: match.c,v 1.4 2005/07/31 20:13:08 alex Exp $";
*/
static int Matche PARAMS(( char *p, char *t ));
static int Matche_After_Star PARAMS(( char *p, char *t ));
static int Matche PARAMS(( const char *p, const char *t ));
static int Matche_After_Star PARAMS(( const char *p, const char *t ));
#define MATCH_PATTERN 6 /* bad pattern */
@@ -45,7 +45,7 @@ static int Matche_After_Star PARAMS(( char *p, char *t ));
GLOBAL bool
Match( char *Pattern, char *String )
Match( const char *Pattern, const char *String )
{
/* Pattern mit String vergleichen */
if( Matche( Pattern, String ) == MATCH_VALID ) return true;
@@ -54,7 +54,7 @@ Match( char *Pattern, char *String )
static int
Matche( char *p, char *t )
Matche( const char *p, const char *t )
{
register char range_start, range_end;
bool invert;
@@ -201,7 +201,7 @@ Matche( char *p, char *t )
static int
Matche_After_Star( char *p, char *t )
Matche_After_Star( const char *p, const char *t )
{
register int nextp, match = 0;

View File

@@ -8,7 +8,7 @@
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: match.h,v 1.3 2005/03/19 18:43:49 fw Exp $
* $Id: match.h,v 1.3.4.1 2006/12/02 13:01:11 fw Exp $
*
* Wildcard pattern matching (header)
*/
@@ -18,7 +18,7 @@
#define __match_h__
GLOBAL bool Match PARAMS(( char *Pattern, char *String ));
GLOBAL bool Match PARAMS(( const char *Pattern, const char *String ));
#endif

View File

@@ -8,7 +8,7 @@
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: messages.h,v 1.67 2005/09/02 12:50:25 alex Exp $
* $Id: messages.h,v 1.67.2.2 2006/12/02 14:26:53 fw Exp $
*
* IRC numerics (Header)
*/
@@ -22,7 +22,8 @@
#define RPL_YOURHOST_MSG "002 %s :Your host is %s, running version ngircd-%s (%s/%s/%s)"
#define RPL_CREATED_MSG "003 %s :This server has been started %s"
#define RPL_MYINFO_MSG "004 %s %s ngircd-%s %s %s"
#define RPL_ISUPPORT_MSG "005 %s NICKLEN=%d TOPICLEN=%d AWAYLEN=%d MAXCHANNELS=%d :are supported on this server"
#define RPL_ISUPPORT1_MSG "005 %s RFC2812 CASEMAPPING=ascii PREFIX=(ov)@+ CHANTYPES=# CHANMODES=bI,k,l,imnPst CHANLIMIT=#:%d :are supported on this server"
#define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d PENALTY :are supported on this server"
#define RPL_TRACELINK_MSG "200 %s Link %s-%s %s %s V%s %ld %d %d"
#define RPL_TRACEOPERATOR_MSG "204 %s Oper 2 :%s"
@@ -32,17 +33,17 @@
#define RPL_ENDOFSTATS_MSG "219 %s %c :End of STATS report"
#define RPL_UMODEIS_MSG "221 %s +%s"
#define RPL_LUSERCLIENT_MSG "251 %s :There are %ld users and %ld services on %ld servers"
#define RPL_LUSEROP_MSG "252 %s %ld :operator(s) online"
#define RPL_LUSERUNKNOWN_MSG "253 %s %ld :unknown connection(s)"
#define RPL_LUSERCHANNELS_MSG "254 %s %ld :channels formed"
#define RPL_LUSERME_MSG "255 %s :I have %ld users, %ld services and %ld servers"
#define RPL_LUSEROP_MSG "252 %s %lu :operator(s) online"
#define RPL_LUSERUNKNOWN_MSG "253 %s %lu :unknown connection(s)"
#define RPL_LUSERCHANNELS_MSG "254 %s %lu :channels formed"
#define RPL_LUSERME_MSG "255 %s :I have %lu users, %lu services and %lu servers"
#define RPL_ADMINME_MSG "256 %s %s :Administrative info"
#define RPL_ADMINLOC1_MSG "257 %s :%s"
#define RPL_ADMINLOC2_MSG "258 %s :%s"
#define RPL_ADMINEMAIL_MSG "259 %s :%s"
#define RPL_TRACEEND_MSG "262 %s %s %s-%s.%s :End of TRACE"
#define RPL_LOCALUSERS_MSG "265 %s :Current local users: %ld, Max: %ld"
#define RPL_NETUSERS_MSG "266 %s :Current global users: %ld, Max: %ld"
#define RPL_LOCALUSERS_MSG "265 %s %lu %lu :Current local users: %lu, Max: %lu"
#define RPL_NETUSERS_MSG "266 %s %lu %lu :Current global users: %lu, Max: %lu"
#define RPL_AWAY_MSG "301 %s %s :%s"
#define RPL_USERHOST_MSG "302 %s :"

View File

@@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: resolve.c,v 1.24 2006/05/10 21:24:01 alex Exp $";
static char UNUSED id[] = "$Id: resolve.c,v 1.24.2.1 2006/12/02 13:00:25 fw Exp $";
#include "imp.h"
#include <assert.h>
@@ -340,33 +340,24 @@ Resolve_Shutdown( RES_STAT *s)
GLOBAL size_t
Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
{
int err;
ssize_t bytes_read;
assert(buflen > 0);
/* Read result from pipe */
errno = 0;
bytes_read = read(s->resolver_fd, readbuf, buflen);
if (bytes_read < 0) {
if (errno != EAGAIN) {
err = errno;
Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(err));
Resolve_Shutdown(s);
errno = err;
if (errno == EAGAIN)
return 0;
}
return 0;
}
Resolve_Shutdown(s);
if (bytes_read == 0) { /* EOF: lookup failed */
Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(errno));
bytes_read = 0;
}
#ifdef DEBUG
else if (bytes_read == 0)
Log( LOG_DEBUG, "Resolver: Can't read result: EOF");
#endif
return 0;
}
Resolve_Shutdown(s);
return (size_t)bytes_read;
}
/* -eof- */

View File

@@ -1,16 +1,17 @@
#!/bin/sh
# ngIRCd Test Suite
# $Id: getpid.sh,v 1.4 2003/08/22 11:31:18 alex Exp $
# $Id: getpid.sh,v 1.4.6.1 2006/12/17 13:49:49 alex Exp $
# did we get a name?
[ $# -ne 1 ] && exit 1
# detect flags for "ps" and "head"
if [ `uname` = "FreeBSD" ]; then
UNAME=`uname`
if [ $UNAME = "FreeBSD" -o $UNAME = "SunOS" ]; then
PS_FLAGS="-a"; PS_PIDCOL="1"; HEAD_FLAGS="-n 1"
elif [ `uname` = "A/UX" ]; then
elif [ $UNAME = "A/UX" ]; then
PS_FLAGS="-ae"; PS_PIDCOL="1"; HEAD_FLAGS="-1"
elif [ `uname` = "GNU" ]; then
elif [ $UNAME = "GNU" ]; then
PS_FLAGS="-ax"; PS_PIDCOL="2"; HEAD_FLAGS="-n 1"
else
PS_FLAGS="-f"; PS_PIDCOL="2"; HEAD_FLAGS="-n 1"
@@ -19,13 +20,17 @@ else
fi
# debug output
#echo "$0: UNAME=$UNAME"
#echo "$0: PS_FLAGS=$PS_FLAGS"
#echo "$0: PS_PIDCOL=$PS_PIDCOL"
#echo "$0: HEAD_FLAGS=$HEAD_FLAGS"
# search PID
ps $PS_FLAGS > procs.tmp
cat procs.tmp | grep -v "$0" | grep "$1" | awk "{print \$$PS_PIDCOL}" | sort -n > pids.tmp
cat procs.tmp | \
grep -v "$0" | grep "$1" | \
awk "{print \$$PS_PIDCOL}" | \
sort -n > pids.tmp
pid=`head $HEAD_FLAGS pids.tmp`
rm -rf procs.tmp pids.tmp