+
+ Read_Config_File(NGIRCd_ConfFile, fd);
+ fclose(fd);
+
+ if (Conf_IncludeDir[0]) {
+ dh = opendir(Conf_IncludeDir);
+ if (!dh)
+ Config_Error(LOG_ALERT,
+ "Can't open include directory \"%s\": %s",
+ Conf_IncludeDir, strerror(errno));
+ } else {
+ strlcpy(Conf_IncludeDir, SYSCONFDIR, sizeof(Conf_IncludeDir));
+ strlcat(Conf_IncludeDir, CONFIG_DIR, sizeof(Conf_IncludeDir));
+ dh = opendir(Conf_IncludeDir);
+ }
+
+ /* Include further configuration files, if IncludeDir is available */
+ if (dh) {
+ while ((entry = readdir(dh)) != NULL) {
+ ptr = strrchr(entry->d_name, '.');
+ if (!ptr || strcasecmp(ptr, ".conf") != 0)
+ continue;
+ snprintf(file, sizeof(file), "%s/%s",
+ Conf_IncludeDir, entry->d_name);
+ if (TestOnly)
+ Config_Error(LOG_INFO,
+ "Reading configuration from \"%s\" ...",
+ file);
+ fd = fopen(file, "r");
+ if (fd) {
+ Read_Config_File(file, fd);
+ fclose(fd);
+ } else
+ Config_Error(LOG_ALERT,
+ "Can't read configuration \"%s\": %s",
+ file, strerror(errno));
+ }
+ closedir(dh);
+ }
+
+ /* Check if there is still a server to add */
+ if( New_Server.name[0] ) {
+ /* Copy data to "real" server structure */
+ assert( New_Server_Idx > NONE );
+ Conf_Server[New_Server_Idx] = New_Server;
+ }
+
+ /* not a single listening port? Add default. */
+ if (no_listenports() &&
+ !array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport))
+ {
+ Config_Error(LOG_ALERT, "Could not add default listening Port %u: %s",
+ (unsigned int) defaultport, strerror(errno));
+
+ exit(1);
+ }
+
+ if (!Conf_ListenAddress)
+ Conf_ListenAddress = strdup_warn(DEFAULT_LISTEN_ADDRSTR);
+
+ if (!Conf_ListenAddress) {
+ Config_Error(LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME);
+ exit(1);
+ }
+
+ /* No MOTD phrase configured? (re)try motd file. */
+ if (array_bytes(&Conf_Motd) == 0) {
+ if (Read_TextFile(Conf_MotdFile, "MOTD", &Conf_Motd))
+ Using_MotdFile = true;
+ }
+
+ /* Try to read ngIRCd help text file. */
+ (void)Read_TextFile(Conf_HelpFile, "help text", &Conf_Helptext);
+ if (!array_bytes(&Conf_Helptext))
+ Config_Error(LOG_WARNING,
+ "No help text available, HELP command will be of limited use.");
+
+#ifdef SSL_SUPPORT
+ /* Make sure that all SSL-related files are readable */
+ CheckFileReadable("CertFile", Conf_SSLOptions.CertFile);
+ CheckFileReadable("DHFile", Conf_SSLOptions.DHFile);
+ CheckFileReadable("KeyFile", Conf_SSLOptions.KeyFile);
+
+ /* Set the default ciphers if none were configured */
+ if (!Conf_SSLOptions.CipherList)
+ Conf_SSLOptions.CipherList = strdup_warn(DEFAULT_CIPHERS);
+#endif
+
+ return true;
+}
+
+/**
+ * ...
+ */
+static void Read_Config_File(const char *File, FILE *fd)
+{
+ char section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
+ int i, line = 0;
+ size_t count;
+