home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htaafile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  4.4 KB  |  125 lines

  1. /*                       FILE ROUTINES FOR ACCESS AUTHORIZATION PACKAGE
  2.                                              
  3.    This module implements the routines used for accessing (and parsing) the files used in
  4.    the access authorization:
  5.    
  6.       password file
  7.       
  8.       group file
  9.       
  10.       access control list (ACL) file
  11.       
  12.  */
  13.  
  14.  
  15. #ifndef HTAAFILE_H
  16. #define HTAAFILE_H
  17.  
  18. #include <stdio.h>      /* FILE */
  19. #include "HTUtils.h"            /* BOOL, PARAMS, ARGS */
  20. #include "HTList.h"             /* HTList */
  21.  
  22. #ifdef SHORT_NAMES
  23. #define HTAAFnRe        HTAAFile_nextRec
  24. #define HTAAFrFi        HTAAFile_readField
  25. #define HTAAFrLi        HTAAFile_readList
  26. #endif /*SHORT_NAMES*/
  27.  
  28.  
  29. /* Used field separators */
  30.  
  31. #define FIELD_SEPARATOR ':'     /* Used to separate fields              */
  32. #define LIST_SEPARATOR  ','     /* Used to separate items in a list     */
  33.                                 /* in group and ALC files.              */
  34.  
  35. /*
  36.  
  37. Naming conventions
  38.  
  39.   Record                 is an entire line in file.
  40.                          
  41.   Field                  is an entity separated by colons and/or by end-of-line.
  42.                          
  43.   List                   is a field in which there are items separated by commas.
  44.                          
  45. Record-oriented Read Routines
  46.  
  47.    Password, group and ACL are internally read in by the following functions:
  48.    
  49.   HTAAFile_nextRec()      skips to the beginning of the next record (must be called even
  50.                          after the last field of a record is read to proceed to the next
  51.                          record).
  52.                          
  53.   HTAAFile_readField()    reads a field (separated by colons).
  54.                          
  55.   HTAAFile_readList()     reads a field containing a comma-separated list of items.
  56.                          
  57.  */
  58.  
  59. /* PUBLIC                                               HTAAFile_nextRec()
  60. **                      GO TO THE BEGINNING OF THE NEXT RECORD
  61. ** ON ENTRY:
  62. **      fp      is the file from which records are read from.
  63. **
  64. ** ON EXIT:
  65. **      returns nothing. File read pointer is located at the beginning
  66. **              of the next record.
  67. **
  68. */
  69. PUBLIC void HTAAFile_nextRec PARAMS((FILE * fp));
  70.  
  71.  
  72. /* PUBLIC                                               HTAAFile_readField()
  73. **              READ A FIELD FROM A PASSWORD, GROUP
  74. **              OR ACCESS CONTROL LIST FILE
  75. **              i.e. an item terminated by colon,
  76. **              end-of-line, or end-of-file.
  77. ** ON ENTRY:
  78. **      fp              is the file to read the characters from
  79. **      contents        is the character array to put the characters
  80. **      max_len         is the maximum number of characters that may
  81. **                      be read (i.e. the size of dest minus one for
  82. **                      terminating null).
  83. ** ON EXIT:
  84. **      returns         the terminating character
  85. **                      (i.e. either separator or CR or LF or EOF).
  86. **      contents        contains a null-terminated string representing
  87. **                      the read field.
  88. ** NOTE 1:
  89. **                      Ignores leading and trailing blanks and tabs.
  90. ** NOTE 2:
  91. **                      If the field is more than max_len characters
  92. **                      long, the rest of the characters in that item
  93. **                      are ignored.  However, contents is always
  94. **                      null-terminated!
  95. */
  96. PUBLIC int HTAAFile_readField PARAMS((FILE * fp,
  97.                                       char * contents,
  98.                                       int    max_len));
  99.  
  100.  
  101. /* PUBLIC                                               HTAAFile_readList()
  102. **
  103. **                      READ A LIST OF STRINGS SEPARATED BY COMMAS
  104. **                      (FROM A GROUP OR ACCESS CONTROL LIST FILE)
  105. ** ON ENTRY:
  106. **      fp              is a pointer to the input file.
  107. **      result          is the list to which append the read items.
  108. **      max_len         is the maximum number of characters in each
  109. **                      list entry (extra characters are ignored).
  110. ** ON EXIT:
  111. **      returns         the number of items read.
  112. **
  113. */
  114. PUBLIC int HTAAFile_readList PARAMS((FILE *     fp,
  115.                                      HTList *   result,
  116.                                      int        max_len));
  117. /*
  118.  
  119.  */
  120.  
  121. #endif /* not HTAAFILE_H */
  122. /*
  123.  
  124.    End of file HTAAFile.h.  */
  125.