Each module must provide 7 functions to the generic pwdb interface. They are registered with the generic interface via a structure of the following form:
struct _pwdb_module {
pwdb_type type; /* type of database (code) */
const char *name; /* type of database (text) */
const char *class; /* class of database (user/group) */
/* FUNCTIONS: used to access the relevant database */
int (*locate)(const char *name, const int id, const struct pwdb **p);
int (*request)(const char *entry_name, const struct pwdb **p);
int (*replace)(const char *name, const int id, const struct pwdb **p);
int (*delete)(const char *name, const int id, const struct pwdb **p);
int (*support)(const char *entry_name);
int (*flags)(pwdb_flag *flags);
int (*cleanup)(int code);
};
For the functions above taking a name and an id entry, the
application may choose to leave one unspecified with the following
defaults:
PWDB_NAME_UNKNOWNjust look at the id field
PWDB_ID_UNKNOWNjust look at the name field
In the case that the application supplies neither the name or the
id, the module functions will try to obtain the relevant
information from the argument pwdb structure.
It is legal for both the name and id to be specified. In
this case they must both match an entry in the database to satisfy one
of the above function calls. If both values are supplied and there is
no entry in the database which matches them, PWDB_BAD_REQUEST
is returned.
The structure is registered via an entry in the modules list (see pwdb_module.c).