home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / comms_networking / users / Users / h / user
Encoding:
Text File  |  1998-01-01  |  2.2 KB  |  71 lines

  1. /* user.h
  2.  * Users header file
  3.  * (c) Chris Rutter 1997
  4.  */
  5.  
  6. #ifndef __user_H
  7. #define __user_H
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. /* this structure defines every user as listed in the password database */
  13. typedef struct
  14. {
  15.     char username[32];
  16.     char password[32];
  17.     char realName[128];
  18.     int  uid, gid;
  19.     char homeDir[256];
  20. } user;
  21.  
  22. /* user_enumerate() opens the password file the first time it is called,
  23.  * continues to return |user *| to every user in the database, and then
  24.  * closes the file and returns a NULL pointer when it reaches the end.
  25.  * typically it would be called in a while loop.
  26.  */
  27. extern user *user_enumerate (void);
  28.  
  29. /* user_get_info() searches the password database for the user, and returns
  30.  * either a NULL pointer if the user wasn't found, or a |user *| if the user
  31.  * was.
  32.  */
  33. extern user *user_get_info (char *username);
  34.  
  35. /* user_read_line() reads one line from the open password file pointed to be
  36.  * the |FILE *|, and populates the |user *| with that information. it
  37.  * returns a flag indicating whether the |user *| was successfully populated.
  38.  * if the flag is FALSE, the end of the file was probably reached.
  39.  */
  40. extern int user_read_line (FILE *, user *);
  41.  
  42. /* user_write_line() adds a line to the end of the password database to
  43.  * represent the |user *| passed. it returns a flag indicating success (TRUE)
  44.  * or failure (FALSE).
  45.  */
  46. extern int user_write_line (user *);
  47.  
  48. /* user_verify() will verify a username and password pair, and return either
  49.  * a populated |user *| if the pair verified, or a NULL pointer if they
  50.  * didn't.
  51.  */
  52. extern user *user_verify (char *uid, char *pass);
  53.  
  54. /* user_crypt() will apply the internal one-way lossy crypt routine to a
  55.  * string of text, and return a pointer to the crypted equivalent.
  56.  */
  57. extern char *user_crypt (char *);
  58.  
  59. /* user_scanf() will read an entire line of text into the space pointed to
  60.  * by |char *|, up to the number of characters specified in |max|. if |echo|
  61.  * is TRUE, then characters will be echoed to the screen.
  62.  */
  63. extern void user_scanf (char *, size_t max, int echo);
  64.  
  65. /* user_log() will log the string |s| to the end of the file |f|. it writes
  66.  * it in a syslog-ish format.
  67.  */
  68. extern void user_log (char *f, char *s);
  69.  
  70. #endif /* __user_H */
  71.