- strncpy() und vsnprintf() kopieren nun etwas "optimierter" (1 Byte weniger) :-)
This commit is contained in:
parent
2ee05c9a68
commit
10363b398e
|
@ -9,11 +9,14 @@
|
|||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||
*
|
||||
* $Id: channel.c,v 1.17 2002/03/02 01:35:50 alex Exp $
|
||||
* $Id: channel.c,v 1.18 2002/03/03 17:17:01 alex Exp $
|
||||
*
|
||||
* channel.c: Management der Channels
|
||||
*
|
||||
* $Log: channel.c,v $
|
||||
* Revision 1.18 2002/03/03 17:17:01 alex
|
||||
* - strncpy() und vsnprintf() kopieren nun etwas "optimierter" (1 Byte weniger) :-)
|
||||
*
|
||||
* Revision 1.17 2002/03/02 01:35:50 alex
|
||||
* - Channel- und Nicknames werden nun ordentlich validiert.
|
||||
*
|
||||
|
@ -480,7 +483,7 @@ GLOBAL VOID Channel_SetTopic( CHANNEL *Chan, CHAR *Topic )
|
|||
assert( Chan != NULL );
|
||||
assert( Topic != NULL );
|
||||
|
||||
strncpy( Chan->topic, Topic, CHANNEL_TOPIC_LEN );
|
||||
strncpy( Chan->topic, Topic, CHANNEL_TOPIC_LEN - 1 );
|
||||
Chan->topic[CHANNEL_TOPIC_LEN - 1] = '\0';
|
||||
} /* Channel_SetTopic */
|
||||
|
||||
|
@ -500,7 +503,7 @@ LOCAL CHANNEL *New_Chan( CHAR *Name )
|
|||
return NULL;
|
||||
}
|
||||
c->next = NULL;
|
||||
strncpy( c->name, Name, CHANNEL_NAME_LEN );
|
||||
strncpy( c->name, Name, CHANNEL_NAME_LEN - 1 );
|
||||
c->name[CHANNEL_NAME_LEN - 1] = '\0';
|
||||
strcpy( c->modes, "" );
|
||||
strcpy( c->topic, "" );
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||
*
|
||||
* $Id: client.c,v 1.41 2002/03/02 01:35:50 alex Exp $
|
||||
* $Id: client.c,v 1.42 2002/03/03 17:17:01 alex Exp $
|
||||
*
|
||||
* client.c: Management aller Clients
|
||||
*
|
||||
|
@ -21,6 +21,9 @@
|
|||
* Server gewesen, so existiert eine entsprechende CONNECTION-Struktur.
|
||||
*
|
||||
* $Log: client.c,v $
|
||||
* Revision 1.42 2002/03/03 17:17:01 alex
|
||||
* - strncpy() und vsnprintf() kopieren nun etwas "optimierter" (1 Byte weniger) :-)
|
||||
*
|
||||
* Revision 1.41 2002/03/02 01:35:50 alex
|
||||
* - Channel- und Nicknames werden nun ordentlich validiert.
|
||||
*
|
||||
|
@ -398,7 +401,7 @@ GLOBAL VOID Client_SetHostname( CLIENT *Client, CHAR *Hostname )
|
|||
/* Hostname eines Clients setzen */
|
||||
|
||||
assert( Client != NULL );
|
||||
strncpy( Client->host, Hostname, CLIENT_HOST_LEN );
|
||||
strncpy( Client->host, Hostname, CLIENT_HOST_LEN - 1 );
|
||||
Client->host[CLIENT_HOST_LEN - 1] = '\0';
|
||||
} /* Client_SetHostname */
|
||||
|
||||
|
@ -408,7 +411,7 @@ GLOBAL VOID Client_SetID( CLIENT *Client, CHAR *ID )
|
|||
/* Hostname eines Clients setzen */
|
||||
|
||||
assert( Client != NULL );
|
||||
strncpy( Client->id, ID, CLIENT_ID_LEN );
|
||||
strncpy( Client->id, ID, CLIENT_ID_LEN - 1 );
|
||||
Client->id[CLIENT_ID_LEN - 1] = '\0';
|
||||
} /* Client_SetID */
|
||||
|
||||
|
@ -418,11 +421,11 @@ GLOBAL VOID Client_SetUser( CLIENT *Client, CHAR *User, BOOLEAN Idented )
|
|||
/* Username eines Clients setzen */
|
||||
|
||||
assert( Client != NULL );
|
||||
if( Idented ) strncpy( Client->user, User, CLIENT_USER_LEN );
|
||||
if( Idented ) strncpy( Client->user, User, CLIENT_USER_LEN - 1 );
|
||||
else
|
||||
{
|
||||
Client->user[0] = '~';
|
||||
strncpy( Client->user + 1, User, CLIENT_USER_LEN - 1 );
|
||||
strncpy( Client->user + 1, User, CLIENT_USER_LEN - 2 );
|
||||
}
|
||||
Client->user[CLIENT_USER_LEN - 1] = '\0';
|
||||
} /* Client_SetUser */
|
||||
|
@ -433,7 +436,7 @@ GLOBAL VOID Client_SetInfo( CLIENT *Client, CHAR *Info )
|
|||
/* Hostname eines Clients setzen */
|
||||
|
||||
assert( Client != NULL );
|
||||
strncpy( Client->info, Info, CLIENT_INFO_LEN );
|
||||
strncpy( Client->info, Info, CLIENT_INFO_LEN - 1 );
|
||||
Client->info[CLIENT_INFO_LEN - 1] = '\0';
|
||||
} /* Client_SetInfo */
|
||||
|
||||
|
@ -443,7 +446,7 @@ GLOBAL VOID Client_SetModes( CLIENT *Client, CHAR *Modes )
|
|||
/* Hostname eines Clients setzen */
|
||||
|
||||
assert( Client != NULL );
|
||||
strncpy( Client->modes, Modes, CLIENT_MODE_LEN );
|
||||
strncpy( Client->modes, Modes, CLIENT_MODE_LEN - 1 );
|
||||
Client->modes[CLIENT_MODE_LEN - 1] = '\0';
|
||||
} /* Client_SetModes */
|
||||
|
||||
|
@ -453,7 +456,7 @@ GLOBAL VOID Client_SetPassword( CLIENT *Client, CHAR *Pwd )
|
|||
/* Von einem Client geliefertes Passwort */
|
||||
|
||||
assert( Client != NULL );
|
||||
strncpy( Client->pwd, Pwd, CLIENT_PASS_LEN );
|
||||
strncpy( Client->pwd, Pwd, CLIENT_PASS_LEN - 1 );
|
||||
Client->pwd[CLIENT_PASS_LEN - 1] = '\0';
|
||||
} /* Client_SetPassword */
|
||||
|
||||
|
@ -467,7 +470,7 @@ GLOBAL VOID Client_SetAway( CLIENT *Client, CHAR *Txt )
|
|||
if( Txt )
|
||||
{
|
||||
/* Client AWAY setzen */
|
||||
strncpy( Client->away, Txt, CLIENT_AWAY_LEN );
|
||||
strncpy( Client->away, Txt, CLIENT_AWAY_LEN - 1 );
|
||||
Client->away[CLIENT_AWAY_LEN - 1] = '\0';
|
||||
Client_ModeAdd( Client, 'a' );
|
||||
Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt );
|
||||
|
@ -584,17 +587,17 @@ GLOBAL CLIENT *Client_GetFromConn( CONN_ID Idx )
|
|||
|
||||
GLOBAL CLIENT *Client_GetFromID( CHAR *Nick )
|
||||
{
|
||||
/* Client-Struktur, die den entsprechenden Nick hat,
|
||||
* liefern. Wird keine gefunden, so wird NULL geliefert. */
|
||||
/* Client-Struktur, die den entsprechenden Nick hat, liefern.
|
||||
* Wird keine gefunden, so wird NULL geliefert. */
|
||||
|
||||
CHAR n[CLIENT_ID_LEN + 1], *ptr;
|
||||
CHAR n[CLIENT_ID_LEN], *ptr;
|
||||
CLIENT *c = NULL;
|
||||
|
||||
assert( Nick != NULL );
|
||||
|
||||
/* Nick kopieren und ggf. Host-Mask abschneiden */
|
||||
strncpy( n, Nick, CLIENT_ID_LEN );
|
||||
n[CLIENT_ID_LEN] = '\0';
|
||||
strncpy( n, Nick, CLIENT_ID_LEN - 1 );
|
||||
n[CLIENT_ID_LEN - 1] = '\0';
|
||||
ptr = strchr( n, '!' );
|
||||
if( ptr ) *ptr = '\0';
|
||||
|
||||
|
|
|
@ -9,11 +9,14 @@
|
|||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||
*
|
||||
* $Id: conf.c,v 1.13 2002/01/18 15:51:44 alex Exp $
|
||||
* $Id: conf.c,v 1.14 2002/03/03 17:17:01 alex Exp $
|
||||
*
|
||||
* conf.h: Konfiguration des ngircd
|
||||
*
|
||||
* $Log: conf.c,v $
|
||||
* Revision 1.14 2002/03/03 17:17:01 alex
|
||||
* - strncpy() und vsnprintf() kopieren nun etwas "optimierter" (1 Byte weniger) :-)
|
||||
*
|
||||
* Revision 1.13 2002/01/18 15:51:44 alex
|
||||
* - Server-Verbinungen werden beim Start erst nach kurzer Pause aufgebaut.
|
||||
*
|
||||
|
@ -218,21 +221,21 @@ GLOBAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
|||
if( strcasecmp( Var, "Name" ) == 0 )
|
||||
{
|
||||
/* Der Server-Name */
|
||||
strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN );
|
||||
strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN - 1 );
|
||||
Conf_ServerName[CLIENT_ID_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Info" ) == 0 )
|
||||
{
|
||||
/* Server-Info-Text */
|
||||
strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN );
|
||||
strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN - 1 );
|
||||
Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Password" ) == 0 )
|
||||
{
|
||||
/* Der Server-Name */
|
||||
strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN );
|
||||
/* Server-Passwort */
|
||||
strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN - 1 );
|
||||
Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
|
@ -258,7 +261,7 @@ GLOBAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
|||
if( strcasecmp( Var, "MotdFile" ) == 0 )
|
||||
{
|
||||
/* Datei mit der "message of the day" (MOTD) */
|
||||
strncpy( Conf_MotdFile, Arg, FNAME_LEN );
|
||||
strncpy( Conf_MotdFile, Arg, FNAME_LEN - 1 );
|
||||
Conf_MotdFile[FNAME_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
|
@ -298,14 +301,14 @@ GLOBAL VOID Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
|
|||
if( strcasecmp( Var, "Name" ) == 0 )
|
||||
{
|
||||
/* Name des IRC Operator */
|
||||
strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_ID_LEN );
|
||||
strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_ID_LEN - 1 );
|
||||
Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Password" ) == 0 )
|
||||
{
|
||||
/* Passwort des IRC Operator */
|
||||
strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN );
|
||||
strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
|
||||
Conf_Oper[Conf_Oper_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
|
@ -325,21 +328,21 @@ GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
|
|||
if( strcasecmp( Var, "Host" ) == 0 )
|
||||
{
|
||||
/* Hostname des Servers */
|
||||
strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN );
|
||||
strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN - 1 );
|
||||
Conf_Server[Conf_Server_Count - 1].host[HOST_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Name" ) == 0 )
|
||||
{
|
||||
/* Name des Servers ("Nick") */
|
||||
strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN );
|
||||
strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN - 1 );
|
||||
Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Password" ) == 0 )
|
||||
{
|
||||
/* Passwort des Servers */
|
||||
strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN );
|
||||
strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
|
||||
Conf_Server[Conf_Server_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -9,11 +9,14 @@
|
|||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||
*
|
||||
* $Id: log.c,v 1.18 2002/02/19 20:07:13 alex Exp $
|
||||
* $Id: log.c,v 1.19 2002/03/03 17:17:01 alex Exp $
|
||||
*
|
||||
* log.c: Logging-Funktionen
|
||||
*
|
||||
* $Log: log.c,v $
|
||||
* Revision 1.19 2002/03/03 17:17:01 alex
|
||||
* - strncpy() und vsnprintf() kopieren nun etwas "optimierter" (1 Byte weniger) :-)
|
||||
*
|
||||
* Revision 1.18 2002/02/19 20:07:13 alex
|
||||
* - direkt nach dem Start werden die aktiven "Modes" ins Log geschrieben.
|
||||
*
|
||||
|
@ -166,16 +169,14 @@ GLOBAL VOID Log( CONST INT Level, CONST CHAR *Format, ... )
|
|||
|
||||
/* String mit variablen Argumenten zusammenbauen ... */
|
||||
va_start( ap, Format );
|
||||
vsnprintf( msg, MAX_LOG_MSG_LEN - 1, Format, ap );
|
||||
msg[MAX_LOG_MSG_LEN - 1] = '\0';
|
||||
vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
|
||||
va_end( ap );
|
||||
|
||||
/* ... und ausgeben */
|
||||
if( NGIRCd_NoDaemon ) printf( "[%d] %s\n", Level, msg );
|
||||
#ifdef USE_SYSLOG
|
||||
syslog( Level, msg );
|
||||
#endif
|
||||
|
||||
va_end( ap );
|
||||
} /* Log */
|
||||
|
||||
|
||||
|
@ -216,13 +217,12 @@ GLOBAL VOID Log_Resolver( CONST INT Level, CONST CHAR *Format, ... )
|
|||
|
||||
/* String mit variablen Argumenten zusammenbauen ... */
|
||||
va_start( ap, Format );
|
||||
vsnprintf( msg, MAX_LOG_MSG_LEN - 1, Format, ap );
|
||||
msg[MAX_LOG_MSG_LEN - 1] = '\0';
|
||||
vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
|
||||
va_end( ap );
|
||||
|
||||
/* ... und ausgeben */
|
||||
syslog( Level, msg );
|
||||
|
||||
va_end( ap );
|
||||
#endif
|
||||
} /* Log_Resolver */
|
||||
|
||||
|
|
Loading…
Reference in New Issue