]> git.sur5r.net Git - openldap/blobdiff - libraries/liblmdb/mdb_dump.c
Happy New Year
[openldap] / libraries / liblmdb / mdb_dump.c
index 925532593b442f217ef1df1b53b3a0594a02bd2a..9df5dc0b161f3baaf663416f59da474d3abc443e 100644 (file)
@@ -1,6 +1,6 @@
 /* mdb_dump.c - memory-mapped database dump tool */
 /*
- * Copyright 2011-2014 Howard Chu, Symas Corp.
+ * Copyright 2011-2018 Howard Chu, Symas Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include <signal.h>
 #include "lmdb.h"
 
+#ifdef _WIN32
+#define Z      "I"
+#else
+#define Z      "z"
+#endif
+
 #define PRINT  1
 static int mode;
 
@@ -109,7 +115,7 @@ static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name)
        if (name)
                printf("database=%s\n", name);
        printf("type=btree\n");
-       printf("mapsize=%zu\n", info.me_mapsize);
+       printf("mapsize=%" Z "u\n", info.me_mapsize);
        if (info.me_mapaddr)
                printf("mapaddr=%p\n", info.me_mapaddr);
        printf("maxreaders=%u\n", info.me_maxreaders);
@@ -149,7 +155,7 @@ static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name)
 
 static void usage(char *prog)
 {
-       fprintf(stderr, "usage: %s dbpath [-V] [-f output] [-l] [-n] [-p] [-a|-s subdb]\n", prog);
+       fprintf(stderr, "usage: %s [-V] [-f output] [-l] [-n] [-p] [-a|-s subdb] dbpath\n", prog);
        exit(EXIT_FAILURE);
 }
 
@@ -227,6 +233,10 @@ int main(int argc, char *argv[])
 
        envname = argv[optind];
        rc = mdb_env_create(&env);
+       if (rc) {
+               fprintf(stderr, "mdb_env_create failed, error %d %s\n", rc, mdb_strerror(rc));
+               return EXIT_FAILURE;
+       }
 
        if (alldbs || subname) {
                mdb_env_set_maxdbs(env, 2);