1 /* $NetBSD: mkmap_lmdb.c,v 1.2 2023/12/23 20:30:46 christos Exp $ */ 2 3 /*++ 4 /* NAME 5 /* mkmap_lmdb 3 6 /* SUMMARY 7 /* create or open database, LMDB style 8 /* SYNOPSIS 9 /* #include <dict_lmdb.h> 10 /* 11 /* MKMAP *mkmap_lmdb_open(path) 12 /* const char *path; 13 /* 14 /* DESCRIPTION 15 /* This module implements support for creating LMDB databases. 16 /* 17 /* mkmap_lmdb_open() takes a file name, appends the ".lmdb" 18 /* suffix, and does whatever initialization is required 19 /* before the OpenLDAP LMDB open routine is called. 20 /* 21 /* All errors are fatal. 22 /* SEE ALSO 23 /* dict_lmdb(3), LMDB dictionary interface. 24 /* LICENSE 25 /* .ad 26 /* .fi 27 /* The Secure Mailer license must be distributed with this software. 28 /* AUTHOR(S) 29 /* Howard Chu 30 /* Symas Corporation 31 /* 32 /* Wietse Venema 33 /* Google, Inc. 34 /* 111 8th Avenue 35 /* New York, NY 10011, USA 36 /*--*/ 37 38 /* System library. */ 39 40 #include <sys_defs.h> 41 #include <sys/stat.h> 42 #include <unistd.h> 43 #include <errno.h> 44 45 /* Utility library. */ 46 47 #include <mymalloc.h> 48 #include <dict_lmdb.h> 49 #include <mkmap.h> 50 51 #ifdef HAS_LMDB 52 #ifdef PATH_LMDB_H 53 #include PATH_LMDB_H 54 #else 55 #include <lmdb.h> 56 #endif 57 58 /* mkmap_lmdb_open */ 59 mkmap_lmdb_open(const char * path)60MKMAP *mkmap_lmdb_open(const char *path) 61 { 62 MKMAP *mkmap = (MKMAP *) mymalloc(sizeof(*mkmap)); 63 64 /* 65 * Fill in the generic members. 66 */ 67 mkmap->open = dict_lmdb_open; 68 mkmap->after_open = 0; 69 mkmap->after_close = 0; 70 71 /* 72 * LMDB uses MVCC so it needs no special lock management here. 73 */ 74 75 return (mkmap); 76 } 77 78 #endif 79