2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
17 #include <sys/types.h>
26 #include <afs/afsutil.h>
33 cmdproc(register struct cmd_syndesc *as, afs_int32 arock)
38 register afs_int32 code = 0, cnt = 0;
39 register struct cmd_item *ti;
41 if (as->parms[0].items) {
42 dbmfile = as->parms[0].items->data;
44 kdb = dbm_open(dbmfile, O_RDONLY, KALOG_DB_MODE);
49 if (!(ti = as->parms[1].items)) {
50 printf("Printing all entries found in %s\n", dbmfile);
51 for (key = dbm_firstkey(kdb); key.dptr;
52 key = afs_dbm_nextkey(kdb, key), cnt++) {
53 printf("\t%s\n", key.dptr);
55 printf("%d entries were found\n", cnt);
57 for (; ti; ti = ti->next) {
58 key.dsize = strlen(ti->data) + 1;
60 data = dbm_fetch(kdb, key);
62 fprintf(stderr, "%s: no entry exists\n", ti->data);
65 if (data.dsize != sizeof(kalog_elt)) {
66 fprintf(stderr, "%s: data came out corrupt\n", ti->data);
69 memcpy(&rdata, data.dptr, sizeof(kalog_elt));
70 printf("%s: last operation from host %x at %s", ti->data,
71 rdata.host, ctime(&rdata.last_use));
78 #include "AFS_component_version_number.c"
81 main(int argc, char **argv)
83 register struct cmd_syndesc *ts;
84 register afs_int32 code;
85 char dbmfile_help[AFSDIR_PATH_MAX];
87 sprintf(dbmfile_help, "dbmfile to use (default %s)",
88 AFSDIR_SERVER_KALOGDB_FILEPATH);
89 dbmfile = AFSDIR_SERVER_KALOGDB_FILEPATH;
90 ts = cmd_CreateSyntax(NULL, cmdproc, 0, "Dump contents of dbm database");
91 cmd_AddParm(ts, "-dbmfile", CMD_SINGLE, CMD_OPTIONAL, dbmfile_help);
92 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL,
93 "extract entries that match specified key");
94 code = cmd_Dispatch(argc, argv);
99 #include "AFS_component_version_number.c"
104 printf("kdb not supported\n");