#include < tcfslib.h> typedef struct tcfspwdb_r { char user[UserLen]; char upw[UUSIZE]; } tcfspwdb;In order to manage the database, the library provide the following set of procedures. These procedures return 0 if an error occurs, else the return value is non zero.
int tcfspwdbr_new(tcfspwdb **p)
Allocates a record and store its pointer in *p.
int tcfspwdbr_edit(tcfspwdb *record, int flags, ...)
Fills the fields of the strucutre pointed to by record with
the strings passed to the procedure after the flags parameter. flags
specifies the fields to be filled according to the following rules.
int tcfspwdbr_read(tcfspwdb *record, int flags, ...)
Copies the content of the fields specified by flags following
the convention adopted for tcfspwdbr_edit of the structure pointed
to by record into the strings passed after flags.
int tcfspwdbr_dispose(tcfspwdb *record)
Frees the memory pointed to by record;
tcfspwdb *tcfs_getpwnam(char *name, tcfspwdb *dest)
Searches the database for a record with field user equal
to the string pointed to by name and store the result in the structure
pointed to by dest. If dest is NULL, the procedure allocates
a record and returns it. In case of success returns a pointer to the record.
int tcfs_putpwnam(char *user, tcfspwdb *src, int flags)
Stores the record pointed to by src in the database using the
key specified by user. The procedure assumes src is a new
entry if flags ==U_NEW, and overwrites if flags ==U_CHG.
If a record with a key specified by user and flags==U_NEW, or if
no such record exists and flags==U_CHG, tcfs_putpwnam returns
an error. If flags==U_DEL, the content of src is ignored,
and the record with key (if exists) will be erased from the database.
int tcfs_decrypt_key(char *user, char *key, char *uuk, char **res)
Decrypts the string uuk using as key the string key and
stores the pointer to the result in res. Argument user is
ignored. No allocation is done.
int tcfs_encrypt_key(char *user, char *passwd, char *k, char
**uuk)
As tcfs_decrypt_key but it performs encryption instead of
decryption.
int tcfs_enable_default(char *u, char *pass)
Enables the cryptographic filesystem for the user u, using the
the default key. User must provide his UNIX password in pass in
order to decrypt the key.
int tcfs_disable(char *u, int flags)
Disables the tcfs features for the user u.
int tcfs_permanent(char *u, int flags)
Sets or removes the permanent flag for the user u. If flags
equals to SET, the permanent flag is set, else it is removed.
int tcfs_getcount(char *user)
Returns the counter associated to the user's key.
int tcfs_getpermanent (char *user)
Returns the status of the permenent flag.