CGI_LIBDIRS = $(CGI_UTIL_LIBDIR) $(YAJL_LIBDIR)
targets = blerg.a blerg_auth.a blergtool blerglatest blerg.cgi www/build/enyo-blerg.js
-blerg_a_objects = database/database.o database/tags.o database/util.o database/subscription.o common/stringbucket.o
+blerg_a_objects = database/database.o database/tags.o database/util.o database/configuration.o database/subscription.o common/stringbucket.o
blerg_auth_a_objects = common/auth.o common/md5.o
blergtool_objects = tools/blergtool.o blerg.a
blerglatest_objects = tools/blerglatest.o blerg.a common/json.o
#ifndef _CONFIG_H
#define _CONFIG_H
+#define BLERG_PATH "/var/lib/blerg"
#define DATA_PATH "data"
#define HASH_TAGS_PATH "hash_tags"
#define REF_TAGS_PATH "ref_tags"
AC_CHECK_FUNCS([ftruncate memset mkdir munmap select strchr strtoull])
# Needed variables for programs to function...
+AC_ARG_WITH([blerg-path],
+AC_HELP_STRING([--with-blerg-path=@<:@DIR@:>@],
+[Base directory for database default=/var/lib/blerg]
+),
+[
+if test "$withval" != "no"; then
+ AC_DEFINE_UNQUOTED([DATA_PATH], ["$withval"], [Base data directory])
+else
+ AC_MSG_ERROR(blerg-path MUST be defined)
+fi
+],
+[AC_DEFINE([BLERG_PATH], ["/var/lib/blerg"], [Base data directory])]
+)
+
AC_ARG_WITH([blerg-data-path],
AC_HELP_STRING([--with-blerg-data-path=@<:@DIR@:>@],
-[Where database files will be stored default=data]
+[Where account data will be stored default=data]
),
[
if test "$withval" != "no"; then
- AC_DEFINE_UNQUOTED([DATA_PATH], ["$withval"], [Where data is located])
+ AC_DEFINE_UNQUOTED([DATA_PATH], ["$withval"], [Where account data is located])
else
AC_MSG_ERROR(blerg-data-path MUST be defined)
fi
+/* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
+ * BSD-style license. Please see the COPYING file for details.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "configuration.h"
+#include "config.h"
+
+struct blerg_configuration blergconf;
+
+int blerg_configuration_init() {
+ char *a;
+
+ a = getenv("BLERG_PATH");
+ if (a == NULL) {
+ strncpy(blergconf.base_path, BLERG_PATH, FILENAME_MAX);
+ } else {
+ strncpy(blergconf.base_path, a, FILENAME_MAX);
+ }
+ return 1;
+}
+/* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
+ * BSD-style license. Please see the COPYING file for details.
+ */
+#ifndef _CONFIGURATION_H
+#define _CONFIGURATION_H
+
+#include <stdio.h>
+
+struct blerg_configuration {
+ char base_path[FILENAME_MAX];
+};
+
+int blerg_configuration_init();
+
+extern struct blerg_configuration blergconf;
+
+#endif //_CONFIGURATION_H
#include <sys/file.h>
#include <fcntl.h>
#include "database.h"
+#include "configuration.h"
#include "subscription.h"
#include "util.h"
#include "config.h"
return r; \
}
+int blerg_init() {
+ if (!blerg_configuration_init()) {
+ return 0;
+ }
+ return 1;
+}
+
uint64_t blerg_get_record_count(struct blerg *blerg) {
uint64_t count;
flock(blerg->meta_fd, LOCK_SH);
#define BLERG_INVALID_RECORD 0xFFFFFFFFFFFFFFFF
+int blerg_init();
int blerg_exists(const char *name);
struct blerg *blerg_open(const char *name);
int blerg_close(struct blerg *blerg);