mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 18:04:13 +08:00
mdbx-tools: print git-tree while show version info.
This commit is contained in:
parent
7c17e314aa
commit
b8ac1daae0
@ -930,17 +930,23 @@ int main(int argc, char *argv[]) {
|
|||||||
dbi_main.name = "@MAIN";
|
dbi_main.name = "@MAIN";
|
||||||
atexit(pagemap_cleanup);
|
atexit(pagemap_cleanup);
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2)
|
||||||
usage(prog);
|
usage(prog);
|
||||||
}
|
|
||||||
|
|
||||||
for (int i; (i = getopt(argc, argv, "Vvqnwcdsi:")) != EOF;) {
|
for (int i; (i = getopt(argc, argv, "Vvqnwcdsi:")) != EOF;) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
printf("mdbx_chk version %d.%d.%d.%d\n"
|
||||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
" - source: %s %s, commit %s, tree %s\n"
|
||||||
exit(EXIT_SUCCESS);
|
" - build: %s for %s by %s\n"
|
||||||
break;
|
" - flags: %s\n"
|
||||||
|
" - options: %s\n",
|
||||||
|
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||||
|
mdbx_version.revision, mdbx_version.git.describe,
|
||||||
|
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||||
|
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target,
|
||||||
|
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
@ -989,7 +995,9 @@ int main(int argc, char *argv[]) {
|
|||||||
#endif /* !WINDOWS */
|
#endif /* !WINDOWS */
|
||||||
|
|
||||||
envname = argv[optind];
|
envname = argv[optind];
|
||||||
print("Running mdbx_chk for %s in 'read-%s' mode...\n", envname,
|
print("mdbx_chk %s (%s, T-%s)\nRunning for %s in 'read-%s' mode...\n",
|
||||||
|
mdbx_version.git.describe, mdbx_version.git.datetime,
|
||||||
|
mdbx_version.git.tree, envname,
|
||||||
(envflags & MDBX_RDONLY) ? "only" : "write");
|
(envflags & MDBX_RDONLY) ? "only" : "write");
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
|
|
||||||
|
@ -56,9 +56,17 @@ int main(int argc, char *argv[]) {
|
|||||||
else if (argv[1][1] == 'c' && argv[1][2] == '\0')
|
else if (argv[1][1] == 'c' && argv[1][2] == '\0')
|
||||||
cpflags |= MDBX_CP_COMPACT;
|
cpflags |= MDBX_CP_COMPACT;
|
||||||
else if (argv[1][1] == 'V' && argv[1][2] == '\0') {
|
else if (argv[1][1] == 'V' && argv[1][2] == '\0') {
|
||||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
printf("mdbx_copy version %d.%d.%d.%d\n"
|
||||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
" - source: %s %s, commit %s, tree %s\n"
|
||||||
exit(EXIT_SUCCESS);
|
" - build: %s for %s by %s\n"
|
||||||
|
" - flags: %s\n"
|
||||||
|
" - options: %s\n",
|
||||||
|
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||||
|
mdbx_version.revision, mdbx_version.git.describe,
|
||||||
|
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||||
|
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target,
|
||||||
|
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
} else
|
} else
|
||||||
argc = 0;
|
argc = 0;
|
||||||
}
|
}
|
||||||
@ -81,6 +89,11 @@ int main(int argc, char *argv[]) {
|
|||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
#endif /* !WINDOWS */
|
#endif /* !WINDOWS */
|
||||||
|
|
||||||
|
printf("mdbx_copy %s (%s, T-%s)\nRunning for copy %s to %s...\n",
|
||||||
|
mdbx_version.git.describe, mdbx_version.git.datetime,
|
||||||
|
mdbx_version.git.tree, argv[1], (argc == 2) ? "stdout" : argv[2]);
|
||||||
|
fflush(NULL);
|
||||||
|
|
||||||
act = "opening environment";
|
act = "opening environment";
|
||||||
rc = mdbx_env_create(&env);
|
rc = mdbx_env_create(&env);
|
||||||
if (rc == MDBX_SUCCESS) {
|
if (rc == MDBX_SUCCESS) {
|
||||||
|
@ -175,9 +175,8 @@ int main(int argc, char *argv[]) {
|
|||||||
char *subname = NULL;
|
char *subname = NULL;
|
||||||
int alldbs = 0, envflags = 0, list = 0;
|
int alldbs = 0, envflags = 0, list = 0;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2)
|
||||||
usage(prog);
|
usage(prog);
|
||||||
}
|
|
||||||
|
|
||||||
/* -a: dump main DB and all subDBs
|
/* -a: dump main DB and all subDBs
|
||||||
* -s: dump only the named subDB
|
* -s: dump only the named subDB
|
||||||
@ -190,10 +189,17 @@ int main(int argc, char *argv[]) {
|
|||||||
while ((i = getopt(argc, argv, "af:lnps:V")) != EOF) {
|
while ((i = getopt(argc, argv, "af:lnps:V")) != EOF) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
printf("mdbx_dump version %d.%d.%d.%d\n"
|
||||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
" - source: %s %s, commit %s, tree %s\n"
|
||||||
exit(EXIT_SUCCESS);
|
" - build: %s for %s by %s\n"
|
||||||
break;
|
" - flags: %s\n"
|
||||||
|
" - options: %s\n",
|
||||||
|
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||||
|
mdbx_version.revision, mdbx_version.git.describe,
|
||||||
|
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||||
|
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target,
|
||||||
|
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
case 'l':
|
case 'l':
|
||||||
list = 1;
|
list = 1;
|
||||||
/*FALLTHROUGH*/;
|
/*FALLTHROUGH*/;
|
||||||
@ -243,6 +249,11 @@ int main(int argc, char *argv[]) {
|
|||||||
#endif /* !WINDOWS */
|
#endif /* !WINDOWS */
|
||||||
|
|
||||||
envname = argv[optind];
|
envname = argv[optind];
|
||||||
|
printf("mdbx_dump %s (%s, T-%s)\nRunning for %s...\n",
|
||||||
|
mdbx_version.git.describe, mdbx_version.git.datetime,
|
||||||
|
mdbx_version.git.tree, envname);
|
||||||
|
fflush(NULL);
|
||||||
|
|
||||||
rc = mdbx_env_create(&env);
|
rc = mdbx_env_create(&env);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr, "mdbx_env_create failed, error %d %s\n", rc,
|
fprintf(stderr, "mdbx_env_create failed, error %d %s\n", rc,
|
||||||
|
@ -344,10 +344,17 @@ int main(int argc, char *argv[]) {
|
|||||||
while ((i = getopt(argc, argv, "af:ns:NTV")) != EOF) {
|
while ((i = getopt(argc, argv, "af:ns:NTV")) != EOF) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
printf("mdbx_load version %d.%d.%d.%d\n"
|
||||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
" - source: %s %s, commit %s, tree %s\n"
|
||||||
exit(EXIT_SUCCESS);
|
" - build: %s for %s by %s\n"
|
||||||
break;
|
" - flags: %s\n"
|
||||||
|
" - options: %s\n",
|
||||||
|
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||||
|
mdbx_version.revision, mdbx_version.git.describe,
|
||||||
|
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||||
|
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target,
|
||||||
|
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
case 'a':
|
case 'a':
|
||||||
append = 1;
|
append = 1;
|
||||||
break;
|
break;
|
||||||
@ -391,6 +398,12 @@ int main(int argc, char *argv[]) {
|
|||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
#endif /* !WINDOWS */
|
#endif /* !WINDOWS */
|
||||||
|
|
||||||
|
envname = argv[optind];
|
||||||
|
printf("mdbx_load %s (%s, T-%s)\nRunning for %s...\n",
|
||||||
|
mdbx_version.git.describe, mdbx_version.git.datetime,
|
||||||
|
mdbx_version.git.tree, envname);
|
||||||
|
fflush(NULL);
|
||||||
|
|
||||||
dbuf.iov_len = 4096;
|
dbuf.iov_len = 4096;
|
||||||
dbuf.iov_base = mdbx_malloc(dbuf.iov_len);
|
dbuf.iov_base = mdbx_malloc(dbuf.iov_len);
|
||||||
|
|
||||||
@ -398,7 +411,6 @@ int main(int argc, char *argv[]) {
|
|||||||
if (!(mode & NOHDR))
|
if (!(mode & NOHDR))
|
||||||
readhdr();
|
readhdr();
|
||||||
|
|
||||||
envname = argv[optind];
|
|
||||||
rc = mdbx_env_create(&env);
|
rc = mdbx_env_create(&env);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr, "mdbx_env_create failed, error %d %s\n", rc,
|
fprintf(stderr, "mdbx_env_create failed, error %d %s\n", rc,
|
||||||
|
@ -71,9 +71,8 @@ int main(int argc, char *argv[]) {
|
|||||||
char *subname = NULL;
|
char *subname = NULL;
|
||||||
int alldbs = 0, envinfo = 0, envflags = 0, freinfo = 0, rdrinfo = 0;
|
int alldbs = 0, envinfo = 0, envflags = 0, freinfo = 0, rdrinfo = 0;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2)
|
||||||
usage(prog);
|
usage(prog);
|
||||||
}
|
|
||||||
|
|
||||||
/* -a: print stat of main DB and all subDBs
|
/* -a: print stat of main DB and all subDBs
|
||||||
* -s: print stat of only the named subDB
|
* -s: print stat of only the named subDB
|
||||||
@ -87,10 +86,17 @@ int main(int argc, char *argv[]) {
|
|||||||
while ((o = getopt(argc, argv, "Vaefnrs:")) != EOF) {
|
while ((o = getopt(argc, argv, "Vaefnrs:")) != EOF) {
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
printf("mdbx_stat version %d.%d.%d.%d\n"
|
||||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
" - source: %s %s, commit %s, tree %s\n"
|
||||||
exit(EXIT_SUCCESS);
|
" - build: %s for %s by %s\n"
|
||||||
break;
|
" - flags: %s\n"
|
||||||
|
" - options: %s\n",
|
||||||
|
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||||
|
mdbx_version.revision, mdbx_version.git.describe,
|
||||||
|
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||||
|
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target,
|
||||||
|
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
case 'a':
|
case 'a':
|
||||||
if (subname)
|
if (subname)
|
||||||
usage(prog);
|
usage(prog);
|
||||||
@ -135,6 +141,12 @@ int main(int argc, char *argv[]) {
|
|||||||
#endif /* !WINDOWS */
|
#endif /* !WINDOWS */
|
||||||
|
|
||||||
envname = argv[optind];
|
envname = argv[optind];
|
||||||
|
envname = argv[optind];
|
||||||
|
printf("mdbx_stat %s (%s, T-%s)\nRunning for %s...\n",
|
||||||
|
mdbx_version.git.describe, mdbx_version.git.datetime,
|
||||||
|
mdbx_version.git.tree, envname);
|
||||||
|
fflush(NULL);
|
||||||
|
|
||||||
rc = mdbx_env_create(&env);
|
rc = mdbx_env_create(&env);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr, "mdbx_env_create failed, error %d %s\n", rc,
|
fprintf(stderr, "mdbx_env_create failed, error %d %s\n", rc,
|
||||||
@ -142,9 +154,8 @@ int main(int argc, char *argv[]) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alldbs || subname) {
|
if (alldbs || subname)
|
||||||
mdbx_env_set_maxdbs(env, 4);
|
mdbx_env_set_maxdbs(env, 4);
|
||||||
}
|
|
||||||
|
|
||||||
rc = mdbx_env_open(env, envname, envflags | MDBX_RDONLY, 0664);
|
rc = mdbx_env_open(env, envname, envflags | MDBX_RDONLY, 0664);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user