Debian Codegraph @

check.cc

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /* This is free and unencumbered software released into the public domain. */
2
3 #include <cstdio> /* for std::*printf() */
4 #include <cstdlib> /* for EXIT_FAILURE, EXIT_SUCCESS */
•5 #include <cerrno> /* for std::errno */
6 #include <cstring> /* for std::error */
7 #include <unistd.h> /* for unlink and rmdir */
8 #include <lmdb++.h>
9
10 int main() {
11 try {
12 /* Create the LMDB environment: */
13 auto env = lmdb::env::create();
14
•15 char tmpdir[] = "/tmp/check.XXXXXX";
16 if (!mkdtemp(tmpdir)) {
17 std::fprintf(stderr, "Unable to create temporary directory: %s\n", std::strerror(errno));
18 return EXIT_FAILURE;
19 }
20 /* Open the LMDB environment: */
•21 env.open(tmpdir);
22
23 /* Begin the LMDB transaction: */
24 auto txn = lmdb::txn::begin(env);
25
26 // TODO
27
•28 /* clean up */
29 char filename[30]; // enough room for tmpdir + filename
30 std::sprintf(filename, "%s/data.mdb", tmpdir);
31 unlink(filename);
32 std::sprintf(filename, "%s/lock.mdb", tmpdir);
33 unlink(filename);
34 rmdir(tmpdir);
35
36 return EXIT_SUCCESS;
37 }
38 catch (const lmdb::error& error) {
39 std::fprintf(stderr, "Failed with error: %s\n", error.what());
40 return EXIT_FAILURE;
41 }
42 }