[Olsr-dev] [PATCH v1 09/43] conf: fix determining the lock file, mirror what main does
Ferry Huberts
(spam-protected)
Wed Nov 11 17:21:42 CET 2015
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
src/cfgparser/olsrd_conf.c | 9 +++++----
src/cfgparser/olsrd_conf.h | 10 ++++++++++
src/main.c | 10 ----------
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/cfgparser/olsrd_conf.c b/src/cfgparser/olsrd_conf.c
index 634439e..c9b01d5 100644
--- a/src/cfgparser/olsrd_conf.c
+++ b/src/cfgparser/olsrd_conf.c
@@ -1379,11 +1379,12 @@ void set_derived_cnf(struct olsrd_config * cnf) {
char * olsrd_get_default_lockfile(struct olsrd_config *cnf) {
char buf[FILENAME_MAX];
int ipv = (cnf->ip_version == AF_INET) ? 4 : 6;
-#ifdef _WIN32
- snprintf(buf, sizeof(buf), "%s-ipv%d.lock", cnf->configuration_file ? cnf->configuration_file : "olsrd" , ipv);
+
+#ifndef DEFAULT_LOCKFILE_PREFIX
+ snprintf(buf, sizeof(buf), "%s-ipv%d.lock", cnf->configuration_file ? cnf->configuration_file : "olsrd", ipv);
#else
- snprintf(buf, sizeof(buf), "/var/run/olsrd-ipv%d.lock", ipv);
-#endif
+ snprintf(buf, sizeof(buf), "%s-ipv%d.lock", DEFAULT_LOCKFILE_PREFIX, ipv);
+#endif /* DEFAULT_LOCKFILE_PREFIX */
return strdup(buf);
}
diff --git a/src/cfgparser/olsrd_conf.h b/src/cfgparser/olsrd_conf.h
index c1b6de5..0b5d17b 100644
--- a/src/cfgparser/olsrd_conf.h
+++ b/src/cfgparser/olsrd_conf.h
@@ -47,6 +47,16 @@
#define PARSER_VERSION "0.1.2"
+#if defined __ANDROID__
+#define DEFAULT_LOCKFILE_PREFIX "/data/local/olsrd"
+#elif defined linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
+#define DEFAULT_LOCKFILE_PREFIX "/var/run/olsrd"
+#elif defined _WIN32
+#define DEFAULT_LOCKFILE_PREFIX "C:\\olsrd"
+#else /* defined _WIN32 */
+#define DEFAULT_LOCKFILE_PREFIX "olsrd"
+#endif /* defined _WIN32 */
+
extern int current_line;
struct conf_token {
diff --git a/src/main.c b/src/main.c
index eb632b2..d264a63 100644
--- a/src/main.c
+++ b/src/main.c
@@ -86,16 +86,6 @@ bool olsr_win32_end_flag = false;
static void olsr_shutdown(int) __attribute__ ((noreturn));
#endif /* _WIN32 */
-#if defined __ANDROID__
-#define DEFAULT_LOCKFILE_PREFIX "/data/local/olsrd"
-#elif defined linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
-#define DEFAULT_LOCKFILE_PREFIX "/var/run/olsrd"
-#elif defined _WIN32
-#define DEFAULT_LOCKFILE_PREFIX "C:\\olsrd"
-#else /* defined _WIN32 */
-#define DEFAULT_LOCKFILE_PREFIX "olsrd"
-#endif /* defined _WIN32 */
-
/*
* Local function prototypes
*/
--
2.5.0
More information about the Olsr-dev
mailing list