Cleanup and rename a lot of stringring stuff to make more sense
[blerg.git] / database / configuration.c
1 /* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
2  * BSD-style license.  Please see the COPYING file for details.
3  */
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include "configuration.h"
8 #include "config.h"
9
10 struct blerg_configuration blergconf;
11
12 int blerg_configuration_init() {
13         char *a;
14
15         a = getenv("BLERG_PATH");
16         if (a == NULL) {
17                 strncpy(blergconf.base_path, BLERG_PATH, FILENAME_MAX);
18         } else {
19                 strncpy(blergconf.base_path, a, FILENAME_MAX);
20         }
21
22         snprintf(blergconf.data_path, FILENAME_MAX, "%s/%s", blergconf.base_path, DATA_PATH);
23         snprintf(blergconf.hash_tags_path, FILENAME_MAX, "%s/%s", blergconf.base_path, HASH_TAGS_PATH);
24         snprintf(blergconf.ref_tags_path, FILENAME_MAX, "%s/%s", blergconf.base_path, REF_TAGS_PATH);
25
26         return 1;
27 }