summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fs.c24
-rw-r--r--src/rccdb4.c29
-rw-r--r--src/rccdb4.h9
-rw-r--r--src/rccxml.c26
4 files changed, 71 insertions, 17 deletions
diff --git a/src/fs.c b/src/fs.c
index ba3ce34..abf45b0 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -1,10 +1,24 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <mntent.h>
+
+#include "../config.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif /* HAVE_SYS_TYPES_H */
+
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif /* HAVE_SYS_STAT_H */
+
+#ifdef HAVE_MNTENT_H
+# include <mntent.h>
+#endif /* HAVE_MNTENT_H */
#include "internal.h"
#include "rcciconv.h"
@@ -75,6 +89,7 @@ int rccFS0(rcc_language_config config, const char *fspath, const char *filename,
if (!len) return 1;
if (!strncmp(filename, fspath, len)) tmp = filename + strlen(fspath);
+#ifdef HAVE_MNTENT_H
} else {
lastprefix = config->ctx->lastprefix;
@@ -102,6 +117,7 @@ int rccFS0(rcc_language_config config, const char *fspath, const char *filename,
}
endmntent(mtab);
}
+#endif /* HAVE_MNTENT_H */
}
if (!tmp) return 1;
diff --git a/src/rccdb4.c b/src/rccdb4.c
index fc821a8..60c9606 100644
--- a/src/rccdb4.c
+++ b/src/rccdb4.c
@@ -37,6 +37,7 @@ int rccInitDb4(rcc_context ctx, const char *name, rcc_db4_flags flags) {
db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) {
int err;
db4_context ctx;
+#ifdef HAVE_DB_H
DB_ENV *dbe;
DB *db;
@@ -61,34 +62,43 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) {
dbe->close(dbe, 0);
return NULL;
}
+#endif /* HAVE_DB_H */
ctx = (db4_context)malloc(sizeof(db4_context_s));
if (!ctx) {
+#ifdef HAVE_DB_H
db->close(db, 0);
dbe->close(dbe, 0);
+#endif /* HAVE_DB_H */
return NULL;
}
+#ifdef HAVE_DB_H
ctx->db = db;
ctx->dbe = dbe;
+#endif /* HAVE_DB_H */
ctx->flags = flags;
return ctx;
}
void rccDb4FreeContext(db4_context ctx) {
if (ctx) {
+#ifdef HAVE_DB_H
ctx->db->close(ctx->db, 0);
ctx->dbe->close(ctx->dbe, 0);
+#endif /* HAVE_DB_H */
free(ctx);
}
}
int rccDb4SetKey(db4_context ctx, const char *orig, size_t olen, const rcc_string string) {
- int err;
+#ifdef HAVE_DB_H
DBT key, data;
+#endif /* HAVE_DB_H */
if ((!ctx)||(!orig)||(!string)) return -1;
+#ifdef HAVE_DB_H
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
@@ -99,16 +109,20 @@ int rccDb4SetKey(db4_context ctx, const char *orig, size_t olen, const rcc_strin
if (key.size < RCC_MIN_DB4_CHARS) return -1;
- err = ctx->db->put(ctx->db, NULL, &key, &data, 0);
- return err;
+ if (!ctx->db->put(ctx->db, NULL, &key, &data, 0)) return 0;
+#endif /* HAVE_DB_H */
+
+ return 1;
}
rcc_string rccDb4GetKey(db4_context ctx, const char *orig, size_t olen) {
- int err;
+#ifdef HAVE_DB_H
DBT key, data;
+#endif /* HAVE_DB_H */
if ((!ctx)||(!orig)) return NULL;
+#ifdef HAVE_DB_H
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
@@ -119,7 +133,8 @@ rcc_string rccDb4GetKey(db4_context ctx, const char *orig, size_t olen) {
if (key.size < RCC_MIN_DB4_CHARS) return NULL;
- err = ctx->db->get(ctx->db, NULL, &key, &data, 0);
- if (err) return NULL;
- return data.data;
+ if (!ctx->db->get(ctx->db, NULL, &key, &data, 0)) return data.data;
+#endif /* HAVE_DB_H */
+
+ return NULL;
}
diff --git a/src/rccdb4.h b/src/rccdb4.h
index 33457ef..1d5072b 100644
--- a/src/rccdb4.h
+++ b/src/rccdb4.h
@@ -1,12 +1,19 @@
#ifndef _RCC_DB4_H
#define _RCC_DB4_H
-#include <db.h>
+#include "../config.h"
+
+#ifdef HAVE_DB_H
+# include <db.h>
+#endif /* HAVE_DB_H */
+
#include "rccstring.h"
struct db4_context_t {
+#ifdef HAVE_DB_H
DB_ENV *dbe;
DB *db;
+#endif /* HAVE_DB_H */
rcc_db4_flags flags;
};
diff --git a/src/rccxml.c b/src/rccxml.c
index b7cc1d8..c7ee405 100644
--- a/src/rccxml.c
+++ b/src/rccxml.c
@@ -1,11 +1,27 @@
#include <stdio.h>
#include <stdarg.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
+#include "../config.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif /* HAVE_SYS_TYPES_H */
+
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif /* HAVE_SYS_STAT_H */
+
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+#endif /* HAVE_SYS_FILE_H */
#include <libxml/parser.h>
#include <libxml/tree.h>