Revision 7779,
1.1 KB
checked in by cfields, 30 years ago
(diff) |
Initial revision
|
Line | |
---|
1 | /* |
---|
2 | file: lertused.c |
---|
3 | basic use: lertused name |
---|
4 | removes a user from lert db |
---|
5 | */ |
---|
6 | |
---|
7 | #include <stdio.h> |
---|
8 | #include <sys/stat.h> |
---|
9 | #include <fcntl.h> |
---|
10 | #include <ndbm.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 new; |
---|
23 | datum data; |
---|
24 | register char *cp; |
---|
25 | register char *nd_p; |
---|
26 | int nd_c; |
---|
27 | int count = 0; |
---|
28 | int changed; |
---|
29 | int new_char; |
---|
30 | char * name_p; |
---|
31 | int name_c; |
---|
32 | char categ[128]; |
---|
33 | |
---|
34 | if (argc != 2) { |
---|
35 | fprintf(stderr, "usage: %s name\n", argv[0]); |
---|
36 | fprintf(stderr, " lertused is a user name\n"); |
---|
37 | fprintf(stderr, " to be removed from the lertdata database\n"); |
---|
38 | exit(1); |
---|
39 | } |
---|
40 | |
---|
41 | db = dbm_open(LERTS_DATA, O_RDWR, 0600); |
---|
42 | if (db == NULL) { |
---|
43 | fprintf(stderr, "Unable to open database file %s.\n", LERTS_DATA); |
---|
44 | exit (1); |
---|
45 | } |
---|
46 | for (key = dbm_firstkey(db); key.dptr != NULL; key = dbm_nextkey(db)) { |
---|
47 | if (!dbm_error(db)) { |
---|
48 | if (strncmp(argv[1], key.dptr, key.dsize) == 0) { |
---|
49 | if (dbm_delete(db, key) < 0) { |
---|
50 | fprintf(stderr, "dbm_delete() failed\n"); |
---|
51 | (void) dbm_clearerr(db); |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | } |
---|
56 | return (0); |
---|
57 | } |
---|
58 | |
---|
Note: See
TracBrowser
for help on using the repository browser.