commit - a7956f334e5db679d4def573360ac9a03afd6836
commit + 281f7583f558f32bc55c98a0beb1de576719a80f
blob - c12658d9e17329a8c3cfe9408cced78b9b938cac
blob + 011dffec691d3f3ce287305f7d4a1bd157c09a47
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
#include "portab.h"
-static char UNUSED id[] = "$Id: conf.c,v 1.52 2002/12/30 00:01:45 alex Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.53 2002/12/31 16:12:50 alex Exp $";
#include "imp.h"
#include <assert.h>
/* Gotcha! Mark server configuration as "unused": */
Conf_Server[i].conn_id = NONE;
- if( Conf_Server[i].once )
+ if( Conf_Server[i].flags & CONF_SFLAG_ONCE )
{
/* Delete configuration here */
Init_Server_Struct( &Conf_Server[i] );
}
return NONE;
} /* Conf_GetServer */
+
+
+GLOBAL BOOLEAN
+Conf_EnableServer( CHAR *Name, INT Port )
+{
+ /* Enable specified server and adjust port */
+
+ INT i;
+
+ assert( Name != NULL );
+
+ for( i = 0; i < MAX_SERVERS; i++ )
+ {
+ if( strcasecmp( Conf_Server[i].name, Name ) == 0 )
+ {
+ /* Gotcha! Set port and enable server: */
+ Conf_Server[i].port = Port;
+ Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
+ return TRUE;
+ }
+ }
+ return FALSE;
+} /* Conf_EnableServer */
+GLOBAL BOOLEAN
+Conf_DisableServer( CHAR *Name )
+{
+ /* Enable specified server and adjust port */
+
+ INT i;
+
+ assert( Name != NULL );
+
+ for( i = 0; i < MAX_SERVERS; i++ )
+ {
+ if( strcasecmp( Conf_Server[i].name, Name ) == 0 )
+ {
+ /* Gotcha! Disable and disconnect server: */
+ Conf_Server[i].flags |= CONF_SFLAG_DISABLED;
+ if( Conf_Server[i].conn_id > NONE ) Conn_Close( Conf_Server[i].conn_id, NULL, "Server link terminated on operator request", TRUE );
+ return TRUE;
+ }
+ }
+ return FALSE;
+} /* Conf_DisableServer */
+
+
+GLOBAL BOOLEAN
+Conf_AddServer( CHAR *Name, INT Port, CHAR *Host, CHAR *MyPwd, CHAR *PeerPwd )
+{
+ /* Add new server to configuration */
+
+ INT i;
+
+ assert( Name != NULL );
+ assert( Host != NULL );
+ assert( MyPwd != NULL );
+ assert( PeerPwd != NULL );
+
+ /* Search unused item in server configuration structure */
+ for( i = 0; i < MAX_SERVERS; i++ )
+ {
+ /* Is this item used? */
+ if( ! Conf_Server[i].name[0] ) break;
+ }
+ if( i >= MAX_SERVERS ) return FALSE;
+
+ Init_Server_Struct( &Conf_Server[i] );
+ strlcpy( Conf_Server[i].name, Name, sizeof( Conf_Server[i].name ));
+ strlcpy( Conf_Server[i].host, Host, sizeof( Conf_Server[i].host ));
+ strlcpy( Conf_Server[i].pwd_out, MyPwd, sizeof( Conf_Server[i].pwd_out ));
+ 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 */
+
+
LOCAL VOID
Set_Defaults( BOOLEAN InitServers )
{
for( i = 0; i < MAX_SERVERS; i++ )
{
if( Conf_Server[i].conn_id == NONE ) Init_Server_Struct( &Conf_Server[i] );
- else Conf_Server[i].once = TRUE;
+ else Conf_Server[i].flags |= CONF_SFLAG_ONCE;
}
/* Initialize variables */
if( Conf_Server[i].name[0] )
{
servers++;
- if( Conf_Server[i].once ) servers_once++;
+ if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) servers_once++;
}
}
Log( LOG_DEBUG, "Configuration: Operators=%d, Servers=%d[%d], Channels=%d", Conf_Oper_Count, servers, servers_once, Conf_Channel_Count );
Server->group = NONE;
Server->lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
Server->res_stat = NULL;
- Server->once = FALSE;
+ if( NGIRCd_Passive ) Server->flags = CONF_SFLAG_DISABLED;
+ else Server->flags = 0;
Server->conn_id = NONE;
} /* Init_Server_Struct */
blob - dce12fbac4349857b41a4e898a0f7ca7800e6dcc
blob + 47784ba40d94c942a8634cc26cdb8c16c9679617
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
- * $Id: conf.h,v 1.25 2002/12/30 00:01:45 alex Exp $
+ * $Id: conf.h,v 1.26 2002/12/31 16:12:50 alex Exp $
*
* Configuration management (header)
*/
INT group; /* Group of server */
time_t lasttry; /* Last connect attempt */
RES_STAT *res_stat; /* Status of the resolver */
- BOOLEAN once; /* This server is valid only once */
+ INT flags; /* Flags */
CONN_ID conn_id; /* ID of server connection or NONE */
} CONF_SERVER;
} CONF_CHANNEL;
+#define CONF_SFLAG_ONCE 1 /* Delete this entry after next disconnect */
+#define CONF_SFLAG_DISABLED 2 /* This server configuration entry is disabled */
+
+
/* Name ("Nick") of the servers */
GLOBAL CHAR Conf_ServerName[CLIENT_ID_LEN];
GLOBAL VOID Conf_SetServer PARAMS(( INT ConfServer, CONN_ID Idx ));
GLOBAL INT Conf_GetServer PARAMS(( CONN_ID Idx ));
+GLOBAL BOOLEAN Conf_EnableServer PARAMS(( CHAR *Name, INT Port ));
+GLOBAL BOOLEAN Conf_DisableServer PARAMS(( CHAR *Name ));
+GLOBAL BOOLEAN Conf_AddServer PARAMS(( CHAR *Name, INT Port, CHAR *Host, CHAR *MyPwd, CHAR *PeerPwd ));
+
#endif