فهرست منبع

Added ability to load an alternate config file

Thomas Davis 12 سال پیش
والد
کامیت
ed1eddef54
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      main.c

+ 15 - 0
main.c

@@ -76,6 +76,11 @@ static struct mg_context *ctx;      // Set by start_civetweb()
 #define CONFIG_FILE "civetweb.conf"
 #endif /* !CONFIG_FILE */
 
+// backup config file
+#if !defined(CONFIG_FILE2) && defined(LINUX)
+#define CONFIG_FILE2 "/etc/civetweb/civetweb.conf"
+#endif
+
 static void WINCDECL signal_handler(int sig_num) {
   exit_flag = sig_num;
 }
@@ -217,6 +222,16 @@ static void process_command_line_arguments(char *argv[], char **options) {
     die("Cannot open config file %s: %s", config_file, strerror(errno));
   }
 
+#ifdef CONFIG_FILE2
+  // try alternate config file
+  if (fp == NULL) {
+    fp = fopen(CONFIG_FILE2, "r");
+    if (fp != NULL) {
+	strcpy(config_file, CONFIG_FILE2);
+    }
+  }
+#endif
+
   // Load config file settings first
   if (fp != NULL) {
     fprintf(stderr, "Loading config file %s\n", config_file);