commit - c3aac8ddb4d78601fe55633be5f846317ecb5608
commit + 040f5422f2c8262ab19832f1e9d0e269afad8ec1
blob - 31e568ca2b1f41946a25fcdaadc6627f72b4e002
blob + c4231dc9ebf70cb31840cde0b87adb82357e1452
--- src/ngircd/channel.c
+++ src/ngircd/channel.c
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: channel.c,v 1.21 2002/04/23 19:51:31 alex Exp $
+ * $Id: channel.c,v 1.22 2002/05/21 00:10:16 alex Exp $
*
* channel.c: Management der Channels
*/
#include <string.h>
#include "client.h"
+#include "conf.h"
#include "hash.h"
#include "irc-write.h"
#include "log.h"
GLOBAL VOID Channel_Init( VOID )
{
+ CHANNEL *chan;
+ CHAR *c;
+ INT i;
+
My_Channels = NULL;
My_Cl2Chan = NULL;
+
+ /* Vordefinierte persistente Channels erzeugen */
+ for( i = 0; i < Conf_Channel_Count; i++ )
+ {
+ /* Ist ein Name konfiguriert? */
+ if( ! Conf_Channel[i].name ) continue;
+
+ /* Gueltiger Channel-Name? */
+ if( ! Channel_IsValidName( Conf_Channel[i].name ))
+ {
+ Log( LOG_ERR, "Can't create pre-defined channel: invalid name: \"%s\"!", Conf_Channel[i].name );
+ continue;
+ }
+
+ /* Channel anlegen */
+ chan = New_Chan( Conf_Channel[i].name );
+ if( chan )
+ {
+ /* Verketten */
+ chan->next = My_Channels;
+ My_Channels = chan;
+ Channel_ModeAdd( chan, 'P' );
+ Channel_SetTopic( chan, Conf_Channel[i].topic );
+ c = Conf_Channel[i].modes;
+ while( *c ) Channel_ModeAdd( chan, *c++ );
+ Log( LOG_INFO, "Created pre-defined channel \"%s\".", Conf_Channel[i].name );
+ }
+ else Log( LOG_ERR, "Can't create pre-defined channel \"%s\"!", Conf_Channel[i].name );
+ }
} /* Channel_Init */
Log( LOG_DEBUG, "User \"%s\" left channel \"%s\" (%s).", Client_Mask( Client ), c->name, Reason );
- /* Wenn Channel nun leer: loeschen */
- if( ! Get_First_Cl2Chan( NULL, Chan )) Delete_Channel( Chan );
+ /* Wenn Channel nun leer und nicht pre-defined: loeschen */
+ if( ! strchr( Channel_Modes( Chan ), 'P' ))
+ {
+ if( ! Get_First_Cl2Chan( NULL, Chan )) Delete_Channel( Chan );
+ }
return TRUE;
} /* Remove_Client */
blob - f558d1a55c9334c52ad0b9570f5219fd31e4a0a6
blob + 73d1cf49519a183070882b299edfc8c40097948b
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: conf.c,v 1.23 2002/03/30 13:08:10 alex Exp $
+ * $Id: conf.c,v 1.24 2002/05/21 00:10:16 alex Exp $
*
* conf.h: Konfiguration des ngircd
*/
GLOBAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg );
GLOBAL VOID Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg );
GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg );
+GLOBAL VOID Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg );
LOCAL VOID Config_Error( CONST INT Level, CONST CHAR *Format, ... );
printf( " Group = %d\n", Conf_Server[i].group );
puts( "" );
}
+
+ for( i = 0; i < Conf_Channel_Count; i++ )
+ {
+ puts( "[CHANNEL]" );
+ printf( " Name = %s\n", Conf_Channel[i].name );
+ printf( " Modes = %s\n", Conf_Channel[i].modes );
+ printf( " Topic = %s\n", Conf_Channel[i].topic );
+ puts( "" );
+ }
return 0;
} /* Conf_Test */
Conf_ConnectRetry = 60;
Conf_Oper_Count = 0;
-
Conf_Server_Count = 0;
+ Conf_Channel_Count = 0;
} /* Set_Defaults */
Conf_Server[Conf_Server_Count].lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
Conf_Server[Conf_Server_Count].res_stat = NULL;
Conf_Server_Count++;
+ }
+ continue;
+ }
+ if( strcasecmp( section, "[CHANNEL]" ) == 0 )
+ {
+ if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
+ else
+ {
+ /* neuen vordefinierten Channel initialisieren */
+ strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
+ strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
+ strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
+ Conf_Channel_Count++;
}
continue;
}
if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
+ else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
}
Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
} /* Handle_SERVER */
+
+
+GLOBAL VOID Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
+{
+ assert( Line > 0 );
+ assert( Var != NULL );
+ assert( Arg != NULL );
+ if( strcasecmp( Var, "Name" ) == 0 )
+ {
+ /* Hostname des Servers */
+ strncpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, CHANNEL_NAME_LEN - 1 );
+ Conf_Channel[Conf_Channel_Count - 1].name[CHANNEL_NAME_LEN - 1] = '\0';
+ return;
+ }
+ if( strcasecmp( Var, "Modes" ) == 0 )
+ {
+ /* Name des Servers ("Nick") */
+ strncpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, CHANNEL_MODE_LEN - 1 );
+ Conf_Channel[Conf_Channel_Count - 1].modes[CHANNEL_MODE_LEN - 1] = '\0';
+ return;
+ }
+ if( strcasecmp( Var, "Topic" ) == 0 )
+ {
+ /* Passwort des Servers */
+ strncpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, CHANNEL_TOPIC_LEN - 1 );
+ Conf_Channel[Conf_Channel_Count - 1].topic[CHANNEL_TOPIC_LEN - 1] = '\0';
+ return;
+ }
+ Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
+} /* Handle_CHANNEL */
+
+
LOCAL VOID Validate_Config( VOID )
{
/* Konfiguration ueberpruefen */
blob - 2aefbcd44f962ba05700001d2c4ef24785af3a40
blob + 74a249937605be43d69fd468ddc09d61db2069b5
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: conf.h,v 1.15 2002/03/29 22:53:59 alex Exp $
+ * $Id: conf.h,v 1.16 2002/05/21 00:10:16 alex Exp $
*
* conf.h: Konfiguration des ngircd (Header)
*/
RES_STAT *res_stat; /* Status des Resolver */
} CONF_SERVER;
+typedef struct _Conf_Channel
+{
+ CHAR name[CHANNEL_NAME_LEN]; /* Name des Channel */
+ CHAR modes[CHANNEL_MODE_LEN]; /* Channel-Modes */
+ CHAR topic[CHANNEL_TOPIC_LEN]; /* Topic des Channels */
+} CONF_CHANNEL;
+
/* Name ("Nick") des Servers */
GLOBAL CHAR Conf_ServerName[CLIENT_ID_LEN];
GLOBAL CONF_SERVER Conf_Server[MAX_SERVERS];
GLOBAL INT Conf_Server_Count;
+/* Vorkonfigurierte Channels */
+GLOBAL CONF_CHANNEL Conf_Channel[MAX_DEFCHANNELS];
+GLOBAL INT Conf_Channel_Count;
+
GLOBAL VOID Conf_Init( VOID );
GLOBAL INT Conf_Test( VOID );
GLOBAL VOID Conf_Exit( VOID );
blob - a81a899d4f657e1f921612b3332994975a921dfb
blob + aa7d1228a25e57d961c5b29419758eced9961450
--- src/ngircd/defines.h
+++ src/ngircd/defines.h
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: defines.h,v 1.23 2002/04/08 01:18:14 alex Exp $
+ * $Id: defines.h,v 1.24 2002/05/21 00:10:16 alex Exp $
*
* defines.h: (globale) Konstanten
*/
#define MAX_SERVERS 16 /* max. Anzahl konfigurierbarer Server ("Peers") */
+#define MAX_DEFCHANNELS 16 /* max. Anzahl vorkonfigurierbarerr Channels */
+
#define MAX_CONNECTIONS 100 /* max. Anzahl von Verbindungen an diesem Server */
#define CLIENT_ID_LEN 64 /* max. ID-Laenge; vgl. RFC 2812, 1.1 und 1.2.1 */
#define RECONNECT_DELAY 3 /* Server-Links erst nach 3 Sekunden versuchen, wieder aufzubauen */
#define USERMODES "aios" /* unterstuetzte User-Modes */
-#define CHANMODES "amnopqstv" /* unterstuetzte Channel-Modes */
+#define CHANMODES "amnopPqstv" /* unterstuetzte Channel-Modes */
#define CONNECTED TRUE /* fuer die irc-xxx-Module */
#define DISCONNECTED FALSE
blob - 79ccdd9adeaf299e3d0d073f60b08e100125d339
blob + 551c74bd5aa2ca6bd49003de3509bbd521d003dc
--- src/ngircd/irc-channel.c
+++ src/ngircd/irc-channel.c
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: irc-channel.c,v 1.4 2002/04/23 19:51:14 alex Exp $
+ * $Id: irc-channel.c,v 1.5 2002/05/21 00:10:16 alex Exp $
*
* irc-channel.c: IRC-Channel-Befehle
*/
flags++;
}
+ /* Wenn persistenter Channel und IRC-Operator: zum Channel-OP machen */
+ if(( strchr( Channel_Modes( chan ), 'P' )) && ( strchr( Client_Modes( target ), 'o' ))) Channel_UserModeAdd( chan, target, 'o' );
+
/* Muessen Modes an andere Server gemeldet werden? */
strcpy( &modes[1], Channel_UserModes( chan, target ));
if( modes[1] ) modes[0] = 0x7;
blob - 5b086c73817bf07726af3aa4dc013ca99b84bb32
blob + ca638fb41768690d01267af487fa0c1ce453c69b
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: irc-mode.c,v 1.4 2002/03/25 17:11:45 alex Exp $
+ * $Id: irc-mode.c,v 1.5 2002/05/21 00:10:16 alex Exp $
*
* irc-mode.c: IRC-Befehle zur Mode-Aenderung (MODE, AWAY, ...)
*/
case 't':
/* Topic Lock */
x[0] = 't';
+ break;
+ case 'P':
+ /* Persistent */
+ x[0] = 'P';
break;
default:
Log( LOG_DEBUG, "Unknown channel-mode \"%c%c\" from \"%s\" at %s!?", set ? '+' : '-', *mode_ptr, Client_ID( Client ), Channel_Name( chan ));