+ return size > strlcpy(dest, name, size);
+}
+
+
+static void
+Handle_CHANNEL( int Line, char *Var, char *Arg )
+{
+ size_t len;
+ size_t chancount = 0;
+
+ assert( Line > 0 );
+ assert( Var != NULL );
+ assert( Arg != NULL );
+ if (Conf_Channel_Count > 0)
+ chancount = Conf_Channel_Count - 1;
+
+ if( strcasecmp( Var, "Name" ) == 0 ) {
+ if (!Handle_Channelname(chancount, Arg))
+ Config_Error_TooLong( Line, Var );
+ return;
+ }
+ if( strcasecmp( Var, "Modes" ) == 0 ) {
+ /* Initial modes */
+ len = strlcpy( Conf_Channel[chancount].modes, Arg, sizeof( Conf_Channel[chancount].modes ));
+ if (len >= sizeof( Conf_Channel[chancount].modes ))
+ Config_Error_TooLong( Line, Var );
+ return;
+ }
+ if( strcasecmp( Var, "Topic" ) == 0 ) {
+ /* Initial topic */
+ if (!array_copys( &Conf_Channel[chancount].topic, Arg))
+ Config_Error_TooLong( Line, Var );
+ return;
+ }
+
+ if( strcasecmp( Var, "Key" ) == 0 ) {
+ /* Initial Channel Key (mode k) */
+ len = strlcpy(Conf_Channel[chancount].key, Arg, sizeof(Conf_Channel[chancount].key));
+ if (len >= sizeof( Conf_Channel[chancount].key ))
+ Config_Error_TooLong(Line, Var);
+ return;
+ }
+
+ if( strcasecmp( Var, "MaxUsers" ) == 0 ) {
+ /* maximum user limit, mode l */
+ Conf_Channel[chancount].maxusers = (unsigned long) atol(Arg);
+ if (Conf_Channel[chancount].maxusers == 0)
+ Config_Error_NaN(Line, Var);
+ return;
+ }
+
+ Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!",
+ NGIRCd_ConfFile, Line, Var );
+} /* Handle_CHANNEL */
+
+
+static void
+Validate_Config(bool Configtest, bool Rehash)
+{
+ /* Validate configuration settings. */
+
+#ifdef DEBUG
+ int i, servers, servers_once;
+#endif
+ char *ptr;
+
+ /* Validate configured server name, see RFC 2812 section 2.3.1 */
+ ptr = Conf_ServerName;
+ do {
+ if (*ptr >= 'a' && *ptr <= 'z') continue;
+ if (*ptr >= 'A' && *ptr <= 'Z') continue;
+ if (*ptr >= '0' && *ptr <= '9') continue;
+ if (ptr > Conf_ServerName) {
+ if (*ptr == '.' || *ptr == '-')
+ continue;
+ }
+ Conf_ServerName[0] = '\0';
+ break;
+ } while (*(++ptr));
+
+ if (!Conf_ServerName[0]) {
+ /* No server name configured! */
+ Config_Error(LOG_ALERT,
+ "No (valid) server name configured in \"%s\" (section 'Global': 'Name')!",
+ NGIRCd_ConfFile);
+ if (!Configtest && !Rehash) {
+ Config_Error(LOG_ALERT,
+ "%s exiting due to fatal errors!",
+ PACKAGE_NAME);
+ exit(1);
+ }
+ }
+
+ if (Conf_ServerName[0] && !strchr(Conf_ServerName, '.')) {
+ /* No dot in server name! */
+ Config_Error(LOG_ALERT,
+ "Invalid server name configured in \"%s\" (section 'Global': 'Name'): Dot missing!",
+ NGIRCd_ConfFile);
+ if (!Configtest) {
+ Config_Error(LOG_ALERT,
+ "%s exiting due to fatal errors!",
+ PACKAGE_NAME);
+ exit(1);
+ }
+ }
+
+#ifdef STRICT_RFC
+ if (!Conf_ServerAdminMail[0]) {
+ /* No administrative contact configured! */
+ Config_Error(LOG_ALERT,
+ "No administrator email address configured in \"%s\" ('AdminEMail')!",
+ NGIRCd_ConfFile);
+ if (!Configtest) {
+ Config_Error(LOG_ALERT,
+ "%s exiting due to fatal errors!",
+ PACKAGE_NAME);
+ exit(1);
+ }
+ }
+#endif
+
+ if (!Conf_ServerAdmin1[0] && !Conf_ServerAdmin2[0]
+ && !Conf_ServerAdminMail[0]) {
+ /* No administrative information configured! */
+ Config_Error(LOG_WARNING,
+ "No administrative information configured but required by RFC!");
+ }
+
+#ifdef DEBUG
+ servers = servers_once = 0;
+ for (i = 0; i < MAX_SERVERS; i++) {
+ if (Conf_Server[i].name[0]) {
+ servers++;
+ 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);
+#endif