Revision 8180,
1.2 KB
checked in by epeisach, 29 years ago
(diff) |
Include sys/types.h before sys/stat.h
|
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/types.h> |
---|
9 | #include <sys/stat.h> |
---|
10 | #include <fcntl.h> |
---|
11 | #include <ndbm.h> |
---|
12 | #include <sys/file.h> |
---|
13 | |
---|
14 | #include "lert.h" |
---|
15 | |
---|
16 | main(argc, argv) |
---|
17 | int argc; |
---|
18 | char ** argv; |
---|
19 | { |
---|
20 | char buffer[512]; |
---|
21 | DBM *db; |
---|
22 | datum key; |
---|
23 | datum new; |
---|
24 | datum data; |
---|
25 | register char *cp; |
---|
26 | register char *nd_p; |
---|
27 | int nd_c; |
---|
28 | int count = 0; |
---|
29 | int changed; |
---|
30 | int new_char; |
---|
31 | char * name_p; |
---|
32 | int name_c; |
---|
33 | char categ[128]; |
---|
34 | |
---|
35 | if (argc != 2) { |
---|
36 | fprintf(stderr, "usage: %s name\n", argv[0]); |
---|
37 | fprintf(stderr, " lertused is a user name\n"); |
---|
38 | fprintf(stderr, " to be removed from the lertdata database\n"); |
---|
39 | exit(1); |
---|
40 | } |
---|
41 | |
---|
42 | db = dbm_open(LERTS_DATA, O_RDWR, 0600); |
---|
43 | if (db == NULL) { |
---|
44 | fprintf(stderr, "Unable to open database file %s.\n", LERTS_DATA); |
---|
45 | exit (1); |
---|
46 | } |
---|
47 | for (key = dbm_firstkey(db); key.dptr != NULL; key = dbm_nextkey(db)) { |
---|
48 | if (!dbm_error(db)) { |
---|
49 | if (strncmp(argv[1], key.dptr, key.dsize) == 0) { |
---|
50 | if (dbm_delete(db, key) < 0) { |
---|
51 | fprintf(stderr, "dbm_delete() failed\n"); |
---|
52 | (void) dbm_clearerr(db); |
---|
53 | } |
---|
54 | } |
---|
55 | } |
---|
56 | } |
---|
57 | return (0); |
---|
58 | } |
---|
59 | |
---|
Note: See
TracBrowser
for help on using the repository browser.