]> code.citadel.org Git - citadel.git/blobdiff - citadel/config.c
- port to Cygwin (DLL support, etc.)
[citadel.git] / citadel / config.c
index ed8fe1dc0d40475ef8f1622f45aba7de444048ce..534eb58d94f85fc786b8189926d649807a980747 100644 (file)
@@ -1,10 +1,15 @@
 /*
+ * $Id$
+ *
  * This function reads the citadel.config file.  It should be called at
  * the beginning of EVERY Citadel program.
  *
- * $Id$
  */
 
+#ifdef DLL_EXPORT
+#define IN_LIBCIT
+#endif
+
 #include "sysdep.h"
 #include <stdlib.h>
 #include <sys/stat.h>
@@ -14,6 +19,8 @@
 #include <string.h>
 #include <limits.h>
 #include "citadel.h"
+#include "server.h"
+#include "dynloader.h"
 #include "config.h"
 
 struct config config;
@@ -31,15 +38,18 @@ void get_config(void) {
 
        if (chdir(home_specified ? bbs_home_directory : BBSDIR) != 0) {
                fprintf(stderr,
-                "Cannot start.\nThere is no Citadel installation in %s\n%s\n",
+                       "This program could not be started.\n"
+                       "Unable to change directory to %s\n"
+                       "Error: %s\n",
                        (home_specified ? bbs_home_directory : BBSDIR),
                        strerror(errno));
                exit(1);
        }
        cfp = fopen("citadel.config", "rb");
        if (cfp == NULL) {
-               fprintf(stderr, "Cannot start.\n");
-               fprintf(stderr, "There is no citadel.config in %s\n%s\n",
+               fprintf(stderr, "This program could not be started.\n"
+                       "Unable to open %s/citadel.config\n"
+                       "Error: %s\n",
                        (home_specified ? bbs_home_directory : BBSDIR),
                        strerror(errno));
                exit(1);
@@ -49,13 +59,15 @@ void get_config(void) {
                perror("citadel.config");
                exit(1);
        }
+#ifndef __CYGWIN__
        if (st.st_uid != BBSUID || st.st_mode != (S_IFREG | S_IRUSR | S_IWUSR)) {
                fprintf(stderr, "check the permissions on citadel.config\n");
                exit(1);
        }
+#endif
        fclose(cfp);
 
-       if (config.c_setup_level != REV_LEVEL) {
+       if (config.c_setup_level < REV_MIN) {
                fprintf(stderr, "config: Your data files are out of date.  ");
                fprintf(stderr, "Run setup to update them.\n");
                fprintf(stderr,
@@ -75,7 +87,17 @@ void get_config(void) {
                 config.c_maxmsglen = INT_MAX;
         if (config.c_maxmsglen < 8192)
                 config.c_maxmsglen = 8192;
-               
+
+        /* Default lower and upper limits on number of worker threads */
+
+       if (config.c_min_workers < 3)           /* no less than 3 */
+               config.c_min_workers = 5;
+
+       if (config.c_max_workers == 0)                  /* default maximum */
+               config.c_max_workers = 256;
+
+       if (config.c_max_workers < config.c_min_workers)   /* max >= min */
+               config.c_max_workers = config.c_min_workers;
 }