home *** CD-ROM | disk | FTP | other *** search
- /* user.h
- * Users header file
- * (c) Chris Rutter 1997
- */
-
- #ifndef __user_H
- #define __user_H
-
- #include <stdio.h>
- #include <stdlib.h>
-
- /* this structure defines every user as listed in the password database */
- typedef struct
- {
- char username[32];
- char password[32];
- char realName[128];
- int uid, gid;
- char homeDir[256];
- } user;
-
- /* user_enumerate() opens the password file the first time it is called,
- * continues to return |user *| to every user in the database, and then
- * closes the file and returns a NULL pointer when it reaches the end.
- * typically it would be called in a while loop.
- */
- extern user *user_enumerate (void);
-
- /* user_get_info() searches the password database for the user, and returns
- * either a NULL pointer if the user wasn't found, or a |user *| if the user
- * was.
- */
- extern user *user_get_info (char *username);
-
- /* user_read_line() reads one line from the open password file pointed to be
- * the |FILE *|, and populates the |user *| with that information. it
- * returns a flag indicating whether the |user *| was successfully populated.
- * if the flag is FALSE, the end of the file was probably reached.
- */
- extern int user_read_line (FILE *, user *);
-
- /* user_write_line() adds a line to the end of the password database to
- * represent the |user *| passed. it returns a flag indicating success (TRUE)
- * or failure (FALSE).
- */
- extern int user_write_line (user *);
-
- /* user_verify() will verify a username and password pair, and return either
- * a populated |user *| if the pair verified, or a NULL pointer if they
- * didn't.
- */
- extern user *user_verify (char *uid, char *pass);
-
- /* user_crypt() will apply the internal one-way lossy crypt routine to a
- * string of text, and return a pointer to the crypted equivalent.
- */
- extern char *user_crypt (char *);
-
- /* user_scanf() will read an entire line of text into the space pointed to
- * by |char *|, up to the number of characters specified in |max|. if |echo|
- * is TRUE, then characters will be echoed to the screen.
- */
- extern void user_scanf (char *, size_t max, int echo);
-
- /* user_log() will log the string |s| to the end of the file |f|. it writes
- * it in a syslog-ish format.
- */
- extern void user_log (char *f, char *s);
-
- #endif /* __user_H */
-