1 .\" Generated from openpam_readword.c by gendoc.pl
2 .\" $Id: openpam_readword.c 916 2017-02-07 12:25:58Z des $
8 .Nd read a word from a file, respecting shell quoting rules
12 .In security/pam_appl.h
13 .In security/openpam.h
15 .Fn openpam_readword "FILE *f" "int *lineno" "size_t *lenp"
19 function reads the next word from a file, and
20 returns it in a NUL-terminated buffer allocated with
23 A word is a sequence of non-whitespace characters.
24 However, whitespace characters can be included in a word if quoted or
25 escaped according to the following rules:
28 An unescaped single or double quote introduces a quoted string,
29 which ends when the same quote character is encountered a second
31 The quotes themselves are stripped.
33 Within a single- or double-quoted string, all whitespace characters,
34 including the newline character, are preserved as-is.
36 Outside a quoted string, a backslash escapes the next character,
37 which is preserved as-is, unless that character is a newline, in
38 which case it is discarded and reading continues at the beginning of
39 the next line as if the backslash and newline had not been there.
40 In all cases, the backslash itself is discarded.
42 Within a single-quoted string, double quotes and backslashes are
45 Within a double-quoted string, a single quote is preserved as-is,
46 and a backslash is preserved as-is unless used to escape a double
50 In addition, if the first non-whitespace character on the line is a
51 hash character (#), the rest of the line is discarded.
52 If a hash character occurs within a word, however, it is preserved
54 A backslash at the end of a comment does cause line continuation.
60 the integer variable it points to is
61 incremented every time a quoted or escaped newline character is read.
67 the length of the word (after quotes and
68 backslashes have been removed) is stored in the variable it points to.
72 function returns a pointer to a
73 dynamically allocated NUL-terminated string containing the first word
74 encountered on the line.
76 The caller is responsible for releasing the returned buffer by passing
82 reaches the end of the line or file before any
83 characters are copied to the word, it returns
86 case, the newline is pushed back to the file.
90 reaches the end of the file while a quote or
91 backslash escape is in effect, it sets
97 .Sh IMPLEMENTATION NOTES
98 The parsing rules are intended to be equivalent to the normal POSIX
100 Any discrepancy is a bug and should be reported to the author along
101 with sample input that can be used to reproduce the error.
104 .Xr openpam_readline 3 ,
105 .Xr openpam_readlinev 3 ,
110 function is an OpenPAM extension.
114 function and this manual page were
116 .An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .