Let the olsrd find the olsrd.conf in the PREFIXed directory
authorBernd Petrovitsch <bernd@firmix.at>
Sun, 23 Nov 2008 21:21:52 +0000 (22:21 +0100)
committerBernd Petrovitsch <bernd@firmix.at>
Sun, 23 Nov 2008 21:21:52 +0000 (22:21 +0100)
Makefile.inc
src/defs.h
src/main.c

index 036d82b..191a0c0 100644 (file)
@@ -49,6 +49,7 @@ CFGNAME ?= $(EXENAME).conf
 CFGFILE ?= $(ETCDIR)/$(CFGNAME)
 
 CPPFLAGS =     $(filter-out -I./src,-Isrc -I$(TOPDIR)/src)
+CPPFLAGS +=    -DETCDIR='"$(ETCDIR)"'
 
 # add gcc warnings and optimizations if CFLAGS not set
 ifndef CFLAGS
index 3e44b4b..df095c8 100644 (file)
@@ -51,7 +51,7 @@ extern const char build_host[];
 
 #ifndef OLSRD_GLOBAL_CONF_FILE
 #define OLSRD_CONF_FILE_NAME   "olsrd.conf"
-#define OLSRD_GLOBAL_CONF_FILE "/etc/" OLSRD_CONF_FILE_NAME
+#define OLSRD_GLOBAL_CONF_FILE ETCDIR "/" OLSRD_CONF_FILE_NAME
 #endif
 
 #define        MAXMESSAGESIZE          1500    /* max broadcast size */
index fc9d89d..5826fe4 100644 (file)
@@ -162,7 +162,7 @@ main(int argc, char *argv[])
    */
 #ifdef WIN32
 #ifndef WINCE
-  GetWindowsDirectory(conf_file_name, FILENAME_MAX - 11);
+  GetWindowsDirectory(conf_file_name, sizeof(conf_file_name) - 1 - strlen(OLSRD_CONF_FILE_NAME));
 #else
   conf_file_name[0] = 0;
 #endif
@@ -173,7 +173,7 @@ main(int argc, char *argv[])
     conf_file_name[len++] = '\\';
   }
 
-  strscpy(conf_file_name + len, "olsrd.conf", sizeof(conf_file_name) - len);
+  strscpy(conf_file_name + len, OLSRD_CONF_FILE_NAME, sizeof(conf_file_name) - len);
 #else
   strscpy(conf_file_name, OLSRD_GLOBAL_CONF_FILE, sizeof(conf_file_name));
 #endif