+GLOBAL void
+Conf_UnsetServer( CONN_ID Idx )
+{
+ /* Set next time for next connection attempt, if this is a server
+ * link that is (still) configured here. If the server is set as
+ * "once", delete it from our configuration.
+ * Non-Server-Connections will be silently ignored. */
+
+ int i;
+ time_t t;
+
+ /* Check all our configured servers */
+ for( i = 0; i < MAX_SERVERS; i++ ) {
+ if( Conf_Server[i].conn_id != Idx ) continue;
+
+ /* Gotcha! Mark server configuration as "unused": */
+ Conf_Server[i].conn_id = NONE;
+
+ if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) {
+ /* Delete configuration here */
+ 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;
+ }
+ }
+} /* Conf_UnsetServer */
+
+
+GLOBAL void
+Conf_SetServer( int ConfServer, CONN_ID Idx )
+{
+ /* Set connection for specified configured server */
+
+ assert( ConfServer > NONE );
+ assert( Idx > NONE );
+
+ Conf_Server[ConfServer].conn_id = Idx;
+} /* Conf_SetServer */
+
+
+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++ ) {
+ if( Conf_Server[i].conn_id == Idx ) return i;
+ }
+ return NONE;
+} /* Conf_GetServer */
+
+
+GLOBAL bool
+Conf_EnableServer( const char *Name, UINT16 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 (Conf_Server[i].port && Conf_Server[i].host[0]);
+ }
+ }
+ return false;
+} /* Conf_EnableServer */
+
+
+GLOBAL bool
+Conf_EnablePassiveServer(const char *Name)
+{
+ /* Enable specified server */
+ int i;
+
+ assert( Name != NULL );
+ for (i = 0; i < MAX_SERVERS; i++) {
+ if ((strcasecmp( Conf_Server[i].name, Name ) == 0) && (Conf_Server[i].port > 0)) {
+ /* BINGO! Enable server */
+ Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
+ return true;
+ }
+ }
+ return false;
+} /* Conf_EnablePassiveServer */
+
+
+GLOBAL bool
+Conf_DisableServer( const 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 bool
+Conf_AddServer( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const 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 */
+
+
+/**
+ * Check if the given nick name is an service
+ */
+GLOBAL bool
+Conf_IsService(int ConfServer, const char *Nick)
+{
+ return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
+} /* Conf_IsService */
+
+
+static void
+Set_Defaults( bool InitServers )