1 $NetBSD: patch-ab,v 1.1 2000/01/15 17:44:20 hubertf Exp $
3 diff -x *.orig -urN ./WWW/Library/Implementation/HTAAFile.c /usr/pkgsrc/www/lynx/work.unpatched/lynx2-8-2/WWW/Library/Implementation/HTAAFile.c
4 --- ./WWW/Library/Implementation/HTAAFile.c Thu Jan 1 01:00:00 1970
5 +++ /usr/pkgsrc/www/lynx/work.unpatched/lynx2-8-2/WWW/Library/Implementation/HTAAFile.c Sat Jan 15 07:57:17 2000
8 +** FILE ROUTINES FOR AUTHENTICATION
9 +** (PASSWD AND GROUP FILES) AND
10 +** ACCESS CONTROL LIST (.www_acl)
12 +** AL Ari Luotonen luotonen@dxcern.cern.ch
24 +#include <HTAAUtil.h> /* Common utilities used in AA */
25 +#include <HTAAFile.h> /* Implemented here */
34 +/* PUBLIC HTAAFile_nextRec()
35 +** GO TO THE BEGINNING OF THE NEXT RECORD
37 +** fp is the file from which records are read from.
40 +** returns nothing. File read pointer is located at the beginning
41 +** of the next record. Handles continuation lines
42 +** (lines ending in comma indicate a following
43 +** continuation line).
46 +PUBLIC void HTAAFile_nextRec ARGS1(FILE *, fp)
52 + while (ch != EOF && ch != CR && ch != LF) {
53 + if (ch != ' ' && ch != '\t')
54 + last = ch; /* Last non-whitespace */
55 + ch = getc(fp); /* Skip until end-of-line */
58 + (ch == CR || ch == LF))/*Skip carriage returns and linefeeds*/
62 + } while (last == ',' && ch != EOF); /* Skip also continuation lines */
66 +/* PRIVATE read_item()
67 +** READ AN ITEM FROM A PASSWORD, GROUP
68 +** OR ACCESS CONTROL LIST FILE
69 +** i.e. either a field, or a list item.
71 +** fp is the file to read the characters from
72 +** contents is the character array to put the characters
73 +** reading_list if TRUE, read a list item (ends either in
74 +** acomma or acolon),
75 +** if FALSE, read a field (ends in acolon).
76 +** max_len is the maximum number of characters that may
77 +** be read (i.e. the size of dest minus one for
78 +** terminating null).
80 +** returns the terminating character
81 +** (i.e. either separator or CR or LF or EOF).
82 +** contents contains a null-terminated string representing
85 +** Ignores leading and trailing blanks and tabs.
87 +** If the item is more than max_len characters
88 +** long, the rest of the characters in that item
89 +** are ignored. However, contents is always
92 +PRIVATE int read_item ARGS4(FILE *, fp,
97 + char * dest = contents;
98 + char * end = contents;
102 + while (SPACE == ch || TAB == ch) /* Skip spaces and tabs */
105 + while (ch != FIELD_SEPARATOR &&
106 + (!reading_list || ch != LIST_SEPARATOR) &&
107 + ch != CR && ch != LF && ch != EOF && cnt < max_len) {
110 + if (ch != SPACE && ch != TAB)
113 + } /* while not eol or eof or too many read */
115 + if (cnt == max_len) {
116 + /* If the field was too long (or exactly maximum) ignore the rest */
117 + while (ch != FIELD_SEPARATOR &&
118 + (!reading_list || ch != LIST_SEPARATOR) &&
119 + ch != CR && ch != LF && ch != EOF)
123 + if (ch == CR || ch == LF)
124 + ungetc(ch, fp); /* Push back the record separator (NL or LF) */
126 + /* Terminate the string, truncating trailing whitespace off.
127 + ** Otherwise (if whitespace would be included), here would
128 + ** be *dest='\0'; and cnt -= ... would be left out.
133 + return ch; /* Return the terminating character */
138 +/* PUBLIC HTAAFile_readField()
139 +** READ A FIELD FROM A PASSWORD, GROUP
140 +** OR ACCESS CONTROL LIST FILE
141 +** i.e. an item terminated by colon,
142 +** end-of-line, or end-of-file.
144 +** fp is the file to read the characters from
145 +** contents is the character array to put the characters
146 +** max_len is the maximum number of characters that may
147 +** be read (i.e. the size of dest minus one for
148 +** terminating null).
150 +** returns the terminating character
151 +** (i.e. either separator or CR or LF or EOF).
152 +** contents contains a null-terminated string representing
155 +** Ignores leading and trailing blanks and tabs.
157 +** If the field is more than max_len characters
158 +** long, the rest of the characters in that item
159 +** are ignored. However, contents is always
162 +PUBLIC int HTAAFile_readField ARGS3(FILE *, fp,
166 + return read_item(fp, contents, NO, max_len);
172 +/* PUBLIC HTAAFile_readList()
174 +** READ A LIST OF STRINGS SEPARATED BY COMMAS
175 +** (FROM A GROUP OR ACCESS CONTROL LIST FILE)
177 +** fp is a pointer to the input file.
178 +** result is the list to which append the read items.
179 +** max_len is the maximum number of characters in each
180 +** list entry (extra characters are ignored).
182 +** returns the number of items read.
185 +PUBLIC int HTAAFile_readList ARGS3(FILE *, fp,
194 + if (!item && !(item = (char*)malloc(max_len+1)))
195 + outofmem(__FILE__, "HTAAFile_readList");
196 + terminator = read_item(fp, item, YES, max_len);
197 + if (strlen(item) > 0) {
199 + HTList_addObject(result, (void*)item);
202 + } while (terminator != FIELD_SEPARATOR &&
203 + terminator != CR && terminator != LF &&
204 + terminator != EOF);
206 + FREE(item); /* This was not needed */