+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;
+
+ /* 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 */
+ if( Conf_Server[i].lasttry < time( NULL ) - Conf_ConnectRetry )
+ {
+ /* Okay, the connection was established "long enough": */
+ Conf_Server[i].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
+ }
+ }
+ }
+} /* 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;
+
+ assert( Idx > NONE );
+
+ for( i = 0; i < MAX_SERVERS; i++ )
+ {
+ if( Conf_Server[i].conn_id == Idx ) return 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 */
+
+