1 .\" Generated from openpam_readword.c by gendoc.pl
2 .\" $Id: openpam_readword.c 648 2013-03-05 17:54:27Z des $
8 .Nd read a word from a file, respecting shell quoting rules
14 .In security/pam_appl.h
15 .In security/openpam.h
17 .Fn openpam_readword "FILE *f" "int *lineno" "size_t *lenp"
21 function reads the next word from a file, and
22 returns it in a NUL-terminated buffer allocated with
25 A word is a sequence of non-whitespace characters.
26 However, whitespace characters can be included in a word if quoted or
27 escaped according to the following rules:
30 An unescaped single or double quote introduces a quoted string,
31 which ends when the same quote character is encountered a second
33 The quotes themselves are stripped.
35 Within a single- or double-quoted string, all whitespace characters,
36 including the newline character, are preserved as-is.
38 Outside a quoted string, a backslash escapes the next character,
39 which is preserved as-is, unless that character is a newline, in
40 which case it is discarded and reading continues at the beginning of
41 the next line as if the backslash and newline had not been there.
42 In all cases, the backslash itself is discarded.
44 Within a single-quoted string, double quotes and backslashes are
47 Within a double-quoted string, a single quote is preserved as-is,
48 and a backslash is preserved as-is unless used to escape a double
52 In addition, if the first non-whitespace character on the line is a
53 hash character (#), the rest of the line is discarded.
54 If a hash character occurs within a word, however, it is preserved
56 A backslash at the end of a comment does cause line continuation.
62 the integer variable it points to is
63 incremented every time a quoted or escaped newline character is read.
69 the length of the word (after quotes and
70 backslashes have been removed) is stored in the variable it points to.
74 function returns a pointer to a
75 dynamically allocated NUL-terminated string containing the first word
76 encountered on the line.
78 The caller is responsible for releasing the returned buffer by passing
84 reaches the end of the line or file before any
85 characters are copied to the word, it returns
88 case, the newline is pushed back to the file.
92 reaches the end of the file while a quote or
93 backslash escape is in effect, it sets
99 .Sh IMPLEMENTATION NOTES
100 The parsing rules are intended to be equivalent to the normal POSIX
102 Any discrepancy is a bug and should be reported to the author along
103 with sample input that can be used to reproduce the error.
106 .Xr openpam_readline 3 ,
107 .Xr openpam_readlinev 3 ,
112 function is an OpenPAM extension.
116 function and this manual page were
118 .An Dag-Erling Sm\(/orgrav Aq des@des.no .