]> git.sur5r.net Git - openldap/blob - libraries/liblmdb/mdb_copy.c
Rename libmdb to liblmdb
[openldap] / libraries / liblmdb / mdb_copy.c
1 /* mdb_copy.c - memory-mapped database backup tool */
2 /*
3  * Copyright 2012 Howard Chu, Symas Corp.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted only as authorized by the OpenLDAP
8  * Public License.
9  *
10  * A copy of this license is available in the file LICENSE in the
11  * top-level directory of the distribution or, alternatively, at
12  * <http://www.OpenLDAP.org/license.html>.
13  */
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include "lmdb.h"
17
18 int main(int argc,char * argv[])
19 {
20         int rc;
21         MDB_env *env;
22         char *envname = argv[1];
23
24         if (argc != 3) {
25                 fprintf(stderr, "usage: %s srcpath dstpath\n", argv[0]);
26                 exit(EXIT_FAILURE);
27         }
28
29         rc = mdb_env_create(&env);
30
31         rc = mdb_env_open(env, envname, MDB_RDONLY, 0);
32         if (rc) {
33                 printf("mdb_env_open failed, error %d %s\n", rc, mdb_strerror(rc));
34         } else {
35                 rc = mdb_env_copy(env, argv[2]);
36                 if (rc)
37                         printf("mdb_env_copy failed, error %d %s\n", rc, mdb_strerror(rc));
38         }
39         mdb_env_close(env);
40
41         return rc ? EXIT_FAILURE : EXIT_SUCCESS;
42 }