+GLOBAL VOID
+Conn_ResetPenalty( CONN_ID Idx )
+{
+ assert( Idx > NONE );
+ My_Connections[Idx].delaytime = 0;
+} /* Conn_ResetPenalty */
+
+
+GLOBAL VOID
+Conn_ClearFlags( VOID )
+{
+ /* Alle Connection auf "nicht-markiert" setzen */
+
+ LONG i;
+
+ for( i = 0; i < Pool_Size; i++ ) My_Connections[i].flag = 0;
+} /* Conn_ClearFlags */
+
+
+GLOBAL INT
+Conn_Flag( CONN_ID Idx )
+{
+ /* Ist eine Connection markiert (TRUE) oder nicht? */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].flag;
+} /* Conn_Flag */
+
+
+GLOBAL VOID
+Conn_SetFlag( CONN_ID Idx, INT Flag )
+{
+ /* Connection markieren */
+
+ assert( Idx > NONE );
+ My_Connections[Idx].flag = Flag;
+} /* Conn_SetFlag */
+
+
+GLOBAL CONN_ID
+Conn_First( VOID )
+{
+ /* Connection-Struktur der ersten Verbindung liefern;
+ * Ist keine Verbindung vorhanden, wird NONE geliefert. */
+
+ LONG i;
+
+ for( i = 0; i < Pool_Size; i++ )
+ {
+ if( My_Connections[i].sock != NONE ) return i;
+ }
+ return NONE;
+} /* Conn_First */
+
+
+GLOBAL CONN_ID
+Conn_Next( CONN_ID Idx )
+{
+ /* Naechste Verbindungs-Struktur liefern; existiert keine
+ * weitere, so wird NONE geliefert. */
+
+ LONG i = NONE;
+
+ assert( Idx > NONE );
+
+ for( i = Idx + 1; i < Pool_Size; i++ )
+ {
+ if( My_Connections[i].sock != NONE ) return i;
+ }
+ return NONE;
+} /* Conn_Next */
+
+
+GLOBAL VOID
+Conn_SetServer( CONN_ID Idx, INT ConfServer )
+{
+ /* Connection als Server markieren: Index des konfigurierten
+ * Servers speichern. Verbindung muss bereits bestehen! */
+
+ assert( Idx > NONE );
+ assert( My_Connections[Idx].sock > NONE );
+
+ My_Connections[Idx].our_server = ConfServer;
+} /* Conn_SetServer */
+
+
+GLOBAL VOID
+Conn_SetOption( CONN_ID Idx, INT Option )
+{
+ /* Option fuer Verbindung setzen.
+ * Initial sind alle Optionen _nicht_ gesetzt. */
+
+ assert( Idx > NONE );
+ assert( Option != 0 );
+
+ My_Connections[Idx].options |= Option;
+} /* Conn_SetOption */
+
+
+GLOBAL VOID
+Conn_UnsetOption( CONN_ID Idx, INT Option )
+{
+ /* Option fuer Verbindung loeschen */
+
+ assert( Idx > NONE );
+ assert( Option != 0 );
+
+ My_Connections[Idx].options &= ~Option;
+} /* Conn_UnsetOption */
+
+
+GLOBAL INT
+Conn_Options( CONN_ID Idx )
+{
+ assert( Idx > NONE );
+ return My_Connections[Idx].options;
+} /* Conn_Options */
+
+
+#ifdef USE_ZLIB
+
+GLOBAL BOOLEAN
+Conn_InitZip( CONN_ID Idx )
+{
+ /* Kompression fuer Link initialisieren */
+
+ assert( Idx > NONE );
+
+ My_Connections[Idx].zip.in.avail_in = 0;
+ My_Connections[Idx].zip.in.total_in = 0;
+ My_Connections[Idx].zip.in.total_out = 0;
+ My_Connections[Idx].zip.in.zalloc = NULL;
+ My_Connections[Idx].zip.in.zfree = NULL;
+ My_Connections[Idx].zip.in.data_type = Z_ASCII;
+
+ if( inflateInit( &My_Connections[Idx].zip.in ) != Z_OK )
+ {
+ /* Fehler! */
+ Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib inflate)!", Idx );
+ return FALSE;
+ }
+
+ My_Connections[Idx].zip.out.total_in = 0;
+ My_Connections[Idx].zip.out.total_in = 0;
+ My_Connections[Idx].zip.out.zalloc = NULL;
+ My_Connections[Idx].zip.out.zfree = NULL;
+ My_Connections[Idx].zip.out.data_type = Z_ASCII;
+
+ if( deflateInit( &My_Connections[Idx].zip.out, Z_DEFAULT_COMPRESSION ) != Z_OK )
+ {
+ /* Fehler! */
+ Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib deflate)!", Idx );
+ return FALSE;
+ }
+
+ My_Connections[Idx].zip.bytes_in = My_Connections[Idx].bytes_in;
+ My_Connections[Idx].zip.bytes_out = My_Connections[Idx].bytes_out;
+
+ Log( LOG_INFO, "Enabled link compression (zlib) on connection %d.", Idx );
+ Conn_SetOption( Idx, CONN_ZIP );
+
+ return TRUE;
+} /* Conn_InitZip */
+
+
+GLOBAL LONG
+Conn_SendBytesZip( CONN_ID Idx )
+{
+ /* Anzahl gesendeter Bytes (komprimiert!) liefern */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].zip.bytes_out;
+} /* Conn_SendBytesZip */
+
+
+GLOBAL LONG
+Conn_RecvBytesZip( CONN_ID Idx )
+{
+ /* Anzahl gesendeter Bytes (komprimiert!) liefern */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].zip.bytes_in;
+} /* Conn_RecvBytesZip */
+
+#endif
+
+
+GLOBAL time_t
+Conn_StartTime( CONN_ID Idx )
+{
+ /* Zeitpunkt des Link-Starts liefern (in Sekunden) */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].starttime;
+} /* Conn_Uptime */
+
+
+GLOBAL INT
+Conn_SendQ( CONN_ID Idx )
+{
+ /* Laenge der Daten im Schreibbuffer liefern */
+
+ assert( Idx > NONE );
+#ifdef USE_ZLIB
+ if( My_Connections[Idx].options & CONN_ZIP ) return My_Connections[Idx].zip.wdatalen;
+ else
+#endif
+ return My_Connections[Idx].wdatalen;
+} /* Conn_SendQ */
+
+
+GLOBAL LONG
+Conn_SendMsg( CONN_ID Idx )
+{
+ /* Anzahl gesendeter Nachrichten liefern */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].msg_out;
+} /* Conn_SendMsg */
+
+
+GLOBAL LONG
+Conn_SendBytes( CONN_ID Idx )
+{
+ /* Anzahl gesendeter Bytes (unkomprimiert) liefern */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].bytes_out;
+} /* Conn_SendBytes */
+
+
+GLOBAL INT
+Conn_RecvQ( CONN_ID Idx )
+{
+ /* Laenge der Daten im Lesebuffer liefern */
+
+ assert( Idx > NONE );
+#ifdef USE_ZLIB
+ if( My_Connections[Idx].options & CONN_ZIP ) return My_Connections[Idx].zip.rdatalen;
+ else
+#endif
+ return My_Connections[Idx].rdatalen;
+} /* Conn_RecvQ */
+
+
+GLOBAL LONG
+Conn_RecvMsg( CONN_ID Idx )
+{
+ /* Anzahl empfangener Nachrichten liefern */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].msg_in;
+} /* Conn_RecvMsg */
+
+
+GLOBAL LONG
+Conn_RecvBytes( CONN_ID Idx )
+{
+ /* Anzahl empfangener Bytes (unkomprimiert) liefern */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].bytes_in;
+} /* Conn_RecvBytes */
+
+
+GLOBAL VOID
+Conn_ResetWCounter( VOID )
+{
+ WCounter = 0;
+} /* Conn_ResetWCounter */
+
+
+GLOBAL LONG
+Conn_WCounter( VOID )
+{
+ return WCounter;
+} /* Conn_WCounter */
+
+