summaryrefslogtreecommitdiffabout
path: root/src/gdbmtool.c
Unidiff
Diffstat (limited to 'src/gdbmtool.c') (more/less context) (show whitespace changes)
-rw-r--r--src/gdbmtool.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 33bdf93..9c6eebe 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -549,30 +549,35 @@ err_printer (void *data GDBM_ARG_UNUSED, char const *fmt, ...)
549 va_start (ap, fmt); 549 va_start (ap, fmt);
550 vfprintf (stderr, fmt, ap); 550 vfprintf (stderr, fmt, ap);
551 va_end (ap); 551 va_end (ap);
552 fprintf (stderr, "\n"); 552 fprintf (stderr, "\n");
553} 553}
554 554
555/* recover verbose backup max-failed-keys=N max-failed-buckets=N max-failures=N */ 555/* recover sumamry verbose backup max-failed-keys=N max-failed-buckets=N max-failures=N */
556void 556void
557recover_handler (struct handler_param *param) 557recover_handler (struct handler_param *param)
558{ 558{
559 gdbm_recovery rcvr; 559 gdbm_recovery rcvr;
560 int flags = 0; 560 int flags = 0;
561 int rc; 561 int rc;
562 int i; 562 int i;
563 char *p; 563 char *p;
564 int summary = 0;
564 565
565 for (i = 1; i < param->argc; i++) 566 for (i = 0; i < param->argc; i++)
566 { 567 {
567 char *arg = PARAM_STRING (param, i); 568 char *arg = PARAM_STRING (param, i);
568 if (strcmp (arg, "verbose") == 0) 569 if (strcmp (arg, "verbose") == 0)
569 { 570 {
570 rcvr.errfun = err_printer; 571 rcvr.errfun = err_printer;
571 flags |= GDBM_RCVR_ERRFUN; 572 flags |= GDBM_RCVR_ERRFUN;
572 } 573 }
574 else if (strcmp (arg, "summary") == 0)
575 {
576 summary = 1;
577 }
573 else if (strcmp (arg, "backup") == 0) 578 else if (strcmp (arg, "backup") == 0)
574 { 579 {
575 rcvr.errfun = err_printer; 580 rcvr.errfun = err_printer;
576 flags |= GDBM_RCVR_BACKUP; 581 flags |= GDBM_RCVR_BACKUP;
577 } 582 }
578 else if (strncmp (arg, "max-failures=", 13) == 0) 583 else if (strncmp (arg, "max-failures=", 13) == 0)
@@ -614,12 +619,25 @@ recover_handler (struct handler_param *param)
614 619
615 rc = gdbm_recover (gdbm_file, &rcvr, flags); 620 rc = gdbm_recover (gdbm_file, &rcvr, flags);
616 621
617 if (rc == 0) 622 if (rc == 0)
618 { 623 {
619 fprintf (param->fp, _("Recovery succeeded.\n")); 624 fprintf (param->fp, _("Recovery succeeded.\n"));
625 if (summary)
626 {
627 fprintf (param->fp,
628 _("Keys recovered: %lu, failed: %lu, duplicate: %lu\n"),
629 (unsigned long) rcvr.recovered_keys,
630 (unsigned long) rcvr.failed_keys,
631 (unsigned long) rcvr.duplicate_keys);
632 fprintf (param->fp,
633 _("Buckets recovered: %lu, failed: %lu\n"),
634 (unsigned long) rcvr.recovered_buckets,
635 (unsigned long) rcvr.failed_buckets);
636 }
637
620 if (rcvr.backup_name) 638 if (rcvr.backup_name)
621 { 639 {
622 fprintf (param->fp, 640 fprintf (param->fp,
623 _("Original database preserved in file %s"), 641 _("Original database preserved in file %s"),
624 rcvr.backup_name); 642 rcvr.backup_name);
625 free (rcvr.backup_name); 643 free (rcvr.backup_name);
@@ -922,13 +940,13 @@ export_handler (struct handler_param *param)
922{ 940{
923 int format = GDBM_DUMP_FMT_ASCII; 941 int format = GDBM_DUMP_FMT_ASCII;
924 int flags = GDBM_WRCREAT; 942 int flags = GDBM_WRCREAT;
925 int i; 943 int i;
926 int filemode; 944 int filemode;
927 945
928 for (i = 1; i < param->argc; i++) 946 for (i = 0; i < param->argc; i++)
929 { 947 {
930 if (strcmp (PARAM_STRING (param, i), "truncate") == 0) 948 if (strcmp (PARAM_STRING (param, i), "truncate") == 0)
931 flags = GDBM_NEWDB; 949 flags = GDBM_NEWDB;
932 else if (strcmp (PARAM_STRING (param, i), "binary") == 0) 950 else if (strcmp (PARAM_STRING (param, i), "binary") == 0)
933 format = GDBM_DUMP_FMT_BINARY; 951 format = GDBM_DUMP_FMT_BINARY;
934 else if (strcmp (PARAM_STRING (param, i), "ascii") == 0) 952 else if (strcmp (PARAM_STRING (param, i), "ascii") == 0)
@@ -956,13 +974,13 @@ import_handler (struct handler_param *param)
956 int flag = GDBM_INSERT; 974 int flag = GDBM_INSERT;
957 unsigned long err_line; 975 unsigned long err_line;
958 int meta_mask = 0; 976 int meta_mask = 0;
959 int i; 977 int i;
960 int rc; 978 int rc;
961 979
962 for (i = 1; i < param->argc; i++) 980 for (i = 0; i < param->argc; i++)
963 { 981 {
964 if (strcmp (PARAM_STRING (param, i), "replace") == 0) 982 if (strcmp (PARAM_STRING (param, i), "replace") == 0)
965 flag = GDBM_REPLACE; 983 flag = GDBM_REPLACE;
966 else if (strcmp (PARAM_STRING (param, i), "nometa") == 0) 984 else if (strcmp (PARAM_STRING (param, i), "nometa") == 0)
967 meta_mask = GDBM_META_MASK_MODE | GDBM_META_MASK_OWNER; 985 meta_mask = GDBM_META_MASK_MODE | GDBM_META_MASK_OWNER;
968 else 986 else
@@ -1217,12 +1235,13 @@ struct command command_tab[] = {
1217 FALSE, 1235 FALSE,
1218 REPEAT_NEVER, 1236 REPEAT_NEVER,
1219 N_("reorganize") }, 1237 N_("reorganize") },
1220 { S(recover), T_CMD, 1238 { S(recover), T_CMD,
1221 checkdb, recover_handler, NULL, 1239 checkdb, recover_handler, NULL,
1222 { { "[verbose]", GDBM_ARG_STRING }, 1240 { { "[verbose]", GDBM_ARG_STRING },
1241 { "[summary]", GDBM_ARG_STRING },
1223 { "[backup]", GDBM_ARG_STRING }, 1242 { "[backup]", GDBM_ARG_STRING },
1224 { "[max-failed-keys=N]", GDBM_ARG_STRING }, 1243 { "[max-failed-keys=N]", GDBM_ARG_STRING },
1225 { "[max-failed-buckets=N]", GDBM_ARG_STRING }, 1244 { "[max-failed-buckets=N]", GDBM_ARG_STRING },
1226 { "[max-failures=N]", GDBM_ARG_STRING }, 1245 { "[max-failures=N]", GDBM_ARG_STRING },
1227 { NULL } }, 1246 { NULL } },
1228 FALSE, 1247 FALSE,

Return to:

Send suggestions and report system problems to the System administrator.