Merge commit '180c6d0b440961cbc873c4d045eb8b2daa1364e9'
[sliver-openvswitch.git] / lib / dirs.c.in
index a174ab3..658a74b 100644 (file)
@@ -1,6 +1,6 @@
 #line 2 "@srcdir@/lib/dirs.c.in"
 /*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 #include <config.h>
 #include "dirs.h"
 #include <stdlib.h>
+#include "util.h"
 
 struct directory {
     const char *value;          /* Actual value; NULL if not yet determined. */
@@ -37,6 +38,13 @@ get_dir(struct directory *d)
     return d->value;
 }
 
+const char *
+ovs_sysconfdir(void)
+{
+    static struct directory d = { NULL, @sysconfdir@, "OVS_SYSCONFDIR" };
+    return get_dir(&d);
+}
+
 const char *
 ovs_pkgdatadir(void)
 {
@@ -58,6 +66,23 @@ ovs_logdir(void)
     return get_dir(&d);
 }
 
+const char *
+ovs_dbdir(void)
+{
+    static const char *dbdir;
+    if (!dbdir) {
+        dbdir = getenv("OVS_DBDIR");
+        if (!dbdir || !dbdir[0]) {
+            char *sysconfdir = getenv("OVS_SYSCONFDIR");
+
+            dbdir = (sysconfdir
+                     ? xasprintf("%s/openvswitch", sysconfdir)
+                     : @DBDIR@);
+        }
+    }
+    return dbdir;
+}
+
 const char *
 ovs_bindir(void)
 {