summaryrefslogtreecommitdiff
path: root/src/libstddjb/cdb_init_at.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/cdb_init_at.c')
-rw-r--r--src/libstddjb/cdb_init_at.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libstddjb/cdb_init_at.c b/src/libstddjb/cdb_init_at.c
new file mode 100644
index 0000000..faea790
--- /dev/null
+++ b/src/libstddjb/cdb_init_at.c
@@ -0,0 +1,18 @@
+/* ISC license. */
+
+#include <skalibs/djbunix.h>
+#include <skalibs/cdb.h>
+#include <skalibs/unix-transactional.h>
+
+int cdb_init_at (cdb *c, int dirfd, char const *file)
+{
+ int fd = open_readat(dirfd, file) ;
+ if (fd < 0) return 0 ;
+ if (!cdb_init_fromfd(c, fd))
+ {
+ fd_close(fd) ;
+ return 0 ;
+ }
+ fd_close(fd) ;
+ return 1 ;
+}