Revision 13853,
1.2 KB
checked in by tb, 25 years ago
(diff) |
Check for <db.h> and <nbdm.h> in configure.in; use lert.h to select the right
db header file. Change .c files not to include <ndbm.h> anymore.
|
Line | |
---|
1 | /* |
---|
2 | file: lertsaid.c |
---|
3 | dump the dbm data file where I'm keeping records |
---|
4 | |
---|
5 | */ |
---|
6 | |
---|
7 | #include <stdio.h> |
---|
8 | #include <sys/types.h> |
---|
9 | #include <sys/stat.h> |
---|
10 | #include <fcntl.h> |
---|
11 | #include <sys/file.h> |
---|
12 | |
---|
13 | #include "lert.h" |
---|
14 | |
---|
15 | main(argc, argv) |
---|
16 | int argc; |
---|
17 | char ** argv; |
---|
18 | { |
---|
19 | char buffer[512]; |
---|
20 | DBM *db; |
---|
21 | datum key; |
---|
22 | datum old; |
---|
23 | datum data; |
---|
24 | register char *cp; |
---|
25 | register char *name_p; |
---|
26 | int name_c; |
---|
27 | char name[128]; |
---|
28 | char categ[128]; |
---|
29 | |
---|
30 | if (argc != 1) { |
---|
31 | fprintf(stderr, "usage: %s\n", argv[0]); |
---|
32 | fprintf(stderr, " dumps the file of people who have responded -n\n"); |
---|
33 | exit(1); |
---|
34 | } |
---|
35 | |
---|
36 | db = dbm_open(LERTS_LOG, O_RDONLY, 0600); |
---|
37 | if (db == NULL) { |
---|
38 | fprintf(stderr, "Unable to open database file %s.\n", LERTS_LOG); |
---|
39 | exit (1); |
---|
40 | } |
---|
41 | |
---|
42 | for (key = dbm_firstkey(db); key.dptr != NULL; key = dbm_nextkey(db)) { |
---|
43 | data = dbm_fetch(db, key); |
---|
44 | if (!dbm_error(db)) { |
---|
45 | cp = name; |
---|
46 | for(name_c = key.dsize, name_p = key.dptr; name_c > 0; name_c--) { |
---|
47 | *cp = *name_p; |
---|
48 | cp++; |
---|
49 | name_p++; |
---|
50 | } |
---|
51 | cp = categ; |
---|
52 | for(name_c = data.dsize, name_p = data.dptr; name_c > 0; name_c--) { |
---|
53 | *cp = *name_p; |
---|
54 | cp++; |
---|
55 | name_p++; |
---|
56 | } |
---|
57 | *cp = '\0'; |
---|
58 | printf("name: %s categories: %s\n", name, categ); |
---|
59 | } |
---|
60 | } |
---|
61 | return (0); |
---|
62 | } |
---|
63 | |
---|
Note: See
TracBrowser
for help on using the repository browser.