mirror of
https://github.com/osmarks/ngircd.git
synced 2025-01-26 15:26:51 +00:00
Code cleanups from Florian Westphal, <westphal@foo.fh-furtwangen.de>:
wrote functions for common error messages.
This commit is contained in:
parent
d16ce5a735
commit
a6d7fb8739
@ -14,7 +14,7 @@
|
||||
|
||||
#include "portab.h"
|
||||
|
||||
static char UNUSED id[] = "$Id: conf.c,v 1.66 2004/10/20 13:47:32 alex Exp $";
|
||||
static char UNUSED id[] = "$Id: conf.c,v 1.67 2005/01/20 00:13:08 alex Exp $";
|
||||
|
||||
#include "imp.h"
|
||||
#include <assert.h>
|
||||
@ -66,6 +66,9 @@ LOCAL VOID Handle_CHANNEL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
|
||||
|
||||
LOCAL VOID Config_Error PARAMS(( CONST INT Level, CONST CHAR *Format, ... ));
|
||||
|
||||
LOCAL VOID Config_Error_NaN PARAMS(( INT LINE, CONST CHAR *Value ));
|
||||
LOCAL VOID Config_Error_TooLong PARAMS(( INT LINE, CONST CHAR *Value ));
|
||||
|
||||
LOCAL VOID Init_Server_Struct PARAMS(( CONF_SERVER *Server ));
|
||||
|
||||
|
||||
@ -565,37 +568,43 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
if( strcasecmp( Var, "Name" ) == 0 )
|
||||
{
|
||||
/* Server name */
|
||||
if( strlcpy( Conf_ServerName, Arg, sizeof( Conf_ServerName )) >= sizeof( Conf_ServerName )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_ServerName, Arg, sizeof( Conf_ServerName )) >= sizeof( Conf_ServerName ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Info" ) == 0 )
|
||||
{
|
||||
/* Info text of server */
|
||||
if( strlcpy( Conf_ServerInfo, Arg, sizeof( Conf_ServerInfo )) >= sizeof( Conf_ServerInfo )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Info\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_ServerInfo, Arg, sizeof( Conf_ServerInfo )) >= sizeof( Conf_ServerInfo ))
|
||||
Config_Error_TooLong ( Line, Var );
|
||||
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Password" ) == 0 )
|
||||
{
|
||||
/* Global server password */
|
||||
if( strlcpy( Conf_ServerPwd, Arg, sizeof( Conf_ServerPwd )) >= sizeof( Conf_ServerPwd )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Password\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_ServerPwd, Arg, sizeof( Conf_ServerPwd )) >= sizeof( Conf_ServerPwd ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "AdminInfo1" ) == 0 )
|
||||
{
|
||||
/* Administrative info #1 */
|
||||
if( strlcpy( Conf_ServerAdmin1, Arg, sizeof( Conf_ServerAdmin1 )) >= sizeof( Conf_ServerAdmin1 )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminInfo1\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_ServerAdmin1, Arg, sizeof( Conf_ServerAdmin1 )) >= sizeof( Conf_ServerAdmin1 )) Config_Error_TooLong ( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "AdminInfo2" ) == 0 )
|
||||
{
|
||||
/* Administrative info #2 */
|
||||
if( strlcpy( Conf_ServerAdmin2, Arg, sizeof( Conf_ServerAdmin2 )) >= sizeof( Conf_ServerAdmin2 )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminInfo2\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_ServerAdmin2, Arg, sizeof( Conf_ServerAdmin2 )) >= sizeof( Conf_ServerAdmin2 )) Config_Error_TooLong ( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "AdminEMail" ) == 0 )
|
||||
{
|
||||
/* Administrative email contact */
|
||||
if( strlcpy( Conf_ServerAdminMail, Arg, sizeof( Conf_ServerAdminMail )) >= sizeof( Conf_ServerAdminMail )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminEMail\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_ServerAdminMail, Arg, sizeof( Conf_ServerAdminMail )) >= sizeof( Conf_ServerAdminMail )) Config_Error_TooLong( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Ports" ) == 0 )
|
||||
@ -620,19 +629,25 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
if( strcasecmp( Var, "MotdFile" ) == 0 )
|
||||
{
|
||||
/* "Message of the day" (MOTD) file */
|
||||
if( strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile )) >= sizeof( Conf_MotdFile )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MotdFile\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile )) >= sizeof( Conf_MotdFile ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "MotdPhrase" ) == 0 )
|
||||
{
|
||||
/* "Message of the day" phrase (instead of file) */
|
||||
if( strlcpy( Conf_MotdPhrase, Arg, sizeof( Conf_MotdPhrase )) >= sizeof( Conf_MotdPhrase )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MotdPhrase\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_MotdPhrase, Arg, sizeof( Conf_MotdPhrase )) >= sizeof( Conf_MotdPhrase ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "ChrootDir" ) == 0 )
|
||||
{
|
||||
/* directory for chroot() */
|
||||
if( strlcpy( Conf_Chroot, Arg, sizeof( Conf_Chroot )) >= sizeof( Conf_Chroot )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ChrootDir\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_Chroot, Arg, sizeof( Conf_Chroot )) >= sizeof( Conf_Chroot ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "ServerUID" ) == 0 )
|
||||
@ -643,7 +658,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_ISDIGIT
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ServerUID\" is not a number!", NGIRCd_ConfFile, Line );
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error_NaN( Line, Var );
|
||||
else
|
||||
#endif
|
||||
Conf_UID = (UINT)atoi( Arg );
|
||||
@ -658,7 +673,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_ISDIGIT
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ServerGID\" is not a number!", NGIRCd_ConfFile, Line );
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error_NaN( Line, Var );
|
||||
else
|
||||
#endif
|
||||
Conf_GID = (UINT)atoi( Arg );
|
||||
@ -711,7 +726,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
{
|
||||
/* Maximum number of connections. Values <= 0 are equal to "no limit". */
|
||||
#ifdef HAVE_ISDIGIT
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnections\" is not a number!", NGIRCd_ConfFile, Line );
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error_NaN( Line, Var);
|
||||
else
|
||||
#endif
|
||||
Conf_MaxConnections = atol( Arg );
|
||||
@ -721,7 +736,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
{
|
||||
/* Maximum number of simoultanous connections from one IP. Values <= 0 are equal to "no limit". */
|
||||
#ifdef HAVE_ISDIGIT
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnectionsIP\" is not a number!", NGIRCd_ConfFile, Line );
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error_NaN( Line, Var );
|
||||
else
|
||||
#endif
|
||||
Conf_MaxConnectionsIP = atoi( Arg );
|
||||
@ -731,7 +746,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
{
|
||||
/* Maximum number of channels a user can join. Values <= 0 are equal to "no limit". */
|
||||
#ifdef HAVE_ISDIGIT
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxJoins\" is not a number!", NGIRCd_ConfFile, Line );
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error_NaN( Line, Var );
|
||||
else
|
||||
#endif
|
||||
Conf_MaxJoins = atoi( Arg );
|
||||
@ -742,7 +757,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
/* IP-Address to bind sockets */
|
||||
if( strlcpy( Conf_ListenAddress, Arg, sizeof( Conf_ListenAddress )) >= sizeof( Conf_ListenAddress ))
|
||||
{
|
||||
Config_Error( LOG_WARNING, "%s, line %d: Value of \"Listen\" too long!", NGIRCd_ConfFile, Line );
|
||||
Config_Error_TooLong( Line, Var );
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -762,13 +777,13 @@ Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
|
||||
if( strcasecmp( Var, "Name" ) == 0 )
|
||||
{
|
||||
/* Name of IRC operator */
|
||||
if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) Config_Error_TooLong( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Password" ) == 0 )
|
||||
{
|
||||
/* Password of IRC operator */
|
||||
if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Password\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) Config_Error_TooLong( Line, Var );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -791,25 +806,28 @@ Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
|
||||
if( strcasecmp( Var, "Host" ) == 0 )
|
||||
{
|
||||
/* Hostname of the server */
|
||||
if( strlcpy( New_Server.host, Arg, sizeof( New_Server.host )) >= sizeof( New_Server.host )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Host\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( New_Server.host, Arg, sizeof( New_Server.host )) >= sizeof( New_Server.host ))
|
||||
Config_Error_TooLong ( Line, Var );
|
||||
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Name" ) == 0 )
|
||||
{
|
||||
/* Name of the server ("Nick"/"ID") */
|
||||
if( strlcpy( New_Server.name, Arg, sizeof( New_Server.name )) >= sizeof( New_Server.name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( New_Server.name, Arg, sizeof( New_Server.name )) >= sizeof( New_Server.name ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "MyPassword" ) == 0 )
|
||||
{
|
||||
/* Password of this server which is sent to the peer */
|
||||
if( strlcpy( New_Server.pwd_in, Arg, sizeof( New_Server.pwd_in )) >= sizeof( New_Server.pwd_in )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MyPassword\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( New_Server.pwd_in, Arg, sizeof( New_Server.pwd_in )) >= sizeof( New_Server.pwd_in )) Config_Error_TooLong( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "PeerPassword" ) == 0 )
|
||||
{
|
||||
/* Passwort of the peer which must be received */
|
||||
if( strlcpy( New_Server.pwd_out, Arg, sizeof( New_Server.pwd_out )) >= sizeof( New_Server.pwd_out )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"PeerPassword\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( New_Server.pwd_out, Arg, sizeof( New_Server.pwd_out )) >= sizeof( New_Server.pwd_out )) Config_Error_TooLong( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Port" ) == 0 )
|
||||
@ -824,7 +842,7 @@ Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
|
||||
{
|
||||
/* Server group */
|
||||
#ifdef HAVE_ISDIGIT
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Group\" is not a number!", NGIRCd_ConfFile, Line );
|
||||
if( ! isdigit( (INT)*Arg )) Config_Error_NaN( Line, Var );
|
||||
else
|
||||
#endif
|
||||
New_Server.group = atoi( Arg );
|
||||
@ -845,19 +863,23 @@ Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
|
||||
if( strcasecmp( Var, "Name" ) == 0 )
|
||||
{
|
||||
/* Name of the channel */
|
||||
if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].name )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].name )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].name ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Modes" ) == 0 )
|
||||
{
|
||||
/* Initial modes */
|
||||
if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].modes )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].modes )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Modes\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].modes )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].modes ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
return;
|
||||
}
|
||||
if( strcasecmp( Var, "Topic" ) == 0 )
|
||||
{
|
||||
/* Initial topic */
|
||||
if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Topic\" too long!", NGIRCd_ConfFile, Line );
|
||||
if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].topic ))
|
||||
Config_Error_TooLong( Line, Var );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -939,6 +961,18 @@ Validate_Config( BOOLEAN Configtest )
|
||||
} /* Validate_Config */
|
||||
|
||||
|
||||
LOCAL VOID
|
||||
Config_Error_TooLong ( CONST INT Line, CONST CHAR *Item )
|
||||
{
|
||||
Config_Error( LOG_WARNING, "%s, line %d: Value of \"%s\" too long!", NGIRCd_ConfFile, Line, Item );
|
||||
}
|
||||
|
||||
LOCAL VOID
|
||||
Config_Error_NaN( CONST INT Line, CONST CHAR *Item )
|
||||
{
|
||||
Config_Error( LOG_WARNING, "%s, line %d: Value of \"%s\" is not a number!", NGIRCd_ConfFile, Line, Item );
|
||||
}
|
||||
|
||||
#ifdef PROTOTYPES
|
||||
LOCAL VOID Config_Error( CONST INT Level, CONST CHAR *Format, ... )
|
||||
#else
|
||||
@ -978,17 +1012,13 @@ Init_Server_Struct( CONF_SERVER *Server )
|
||||
|
||||
assert( Server != NULL );
|
||||
|
||||
strcpy( Server->host, "" );
|
||||
strcpy( Server->ip, "" );
|
||||
strcpy( Server->name, "" );
|
||||
strcpy( Server->pwd_in, "" );
|
||||
strcpy( Server->pwd_out, "" );
|
||||
Server->port = 0;
|
||||
memset( Server, 0, sizeof (CONF_SERVER) );
|
||||
|
||||
Server->group = NONE;
|
||||
Server->lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
|
||||
Server->res_stat = NULL;
|
||||
|
||||
if( NGIRCd_Passive ) Server->flags = CONF_SFLAG_DISABLED;
|
||||
else Server->flags = 0;
|
||||
|
||||
Server->conn_id = NONE;
|
||||
} /* Init_Server_Struct */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user