1 /* $Id: commonio.h,v 1.6 2000/09/02 18:40:43 marekm Exp $ */
6 struct commonio_entry {
8 void *eptr; /* struct passwd, struct spwd, ... */
9 struct commonio_entry *prev, *next;
14 * Operations depending on database type: passwd, group, shadow etc.
18 * Make a copy of the object (for example, struct passwd)
19 * and all strings pointed by it, in malloced memory.
21 void *(*dup)(const void *);
24 * free() the object including any strings pointed by it.
29 * Return the name of the object (for example, pw_name
32 const char *(*getname)(const void *);
35 * Parse a string, return object (in static area -
36 * should be copied using the dup operation above).
38 void *(*parse)(const char *);
41 * Write the object to the file (this calls putpwent()
42 * for struct passwd, for example).
44 int (*put)(const void *, FILE *);
47 * fgets and fputs (can be replaced by versions that
48 * understand line continuation conventions).
50 char *(*fgets)(char *, int, FILE *);
51 int (*fputs)(const char *, FILE *);
59 * Name of the data file.
64 * Operations from above.
66 struct commonio_ops *ops;
69 * Currently open file stream.
74 * Head, tail, current position in linked list.
76 struct commonio_entry *head, *tail, *cursor;
87 extern int commonio_setname(struct commonio_db *, const char *);
88 extern int commonio_present(const struct commonio_db *);
89 extern int commonio_lock(struct commonio_db *);
90 extern int commonio_lock_nowait(struct commonio_db *);
91 extern int commonio_open(struct commonio_db *, int);
92 extern const void *commonio_locate(struct commonio_db *, const char *);
93 extern int commonio_update(struct commonio_db *, const void *);
94 extern int commonio_remove(struct commonio_db *, const char *);
95 extern int commonio_rewind(struct commonio_db *);
96 extern const void *commonio_next(struct commonio_db *);
97 extern int commonio_close(struct commonio_db *);
98 extern int commonio_unlock(struct commonio_db *);
99 extern void commonio_del_entry(struct commonio_db *, const struct commonio_entry *);