2 .TH %PAGEREF% MinGW "Programmer's Reference Manual"
5 .BR getline ,\0 getdelim
6 \- read a delimited record from a stream
13 .B ssize_t getdelim( char
23 .B ssize_t getline( char
33 Feature Test Macro Requirements for libmingwex:
35 .BR getdelim (),\~ getline ():
37 Available since libmingwex version 3.22:
38 .BR _POSIX_C_SOURCE\0 >=\0 200809L\0 ||\0 _XOPEN_SOURCE\0 >=\0 700
45 function reads data from
47 until either a character entity matching
56 is stored into the buffer referenced by the pointer at
65 function is a special case of
69 argument implicitly specified as the POSIX newline character,
75 argument must be a reference to a pointer which is safe to pass to
80 or a pointer to a buffer of size as indicated by
90 with a value of zero in
94 and recommended as a mechanism for requesting allocation
100 argument is specified as an
102 it must be passed a value which is representable as an
103 .BR "unsigned char" ,
104 otherwise the behaviour is undefined.
110 is initially passed as a
119 in an attempt to allocate
122 or an arbitrarily sized smaller default buffer,
123 if such an allocation is not achievable.
128 will be updated to reflect the allocated buffer location,
129 and the actual size allocated.
133 at any time during collection of the input record,
134 the buffer referenced by
136 becomes too small to store the record,
137 it will be expanded as necessary,
142 will be adjusted to reflect the change in allocation.
147 On successful completion,
151 return the number of characters stored into the buffer at
156 character if this was encountered before
158 but excluding the terminating
163 If no characters were read,
171 and the end-of-file indicator is set for
181 as indicated under the heading
192 may fail for any of the reasons described as failure conditions for
194 when any such error occurs,
212 returning \(mi1 after setting
214 to indicate occurrence of any of the following errors:
231 or otherwise is not a valid stream opened for reading,
237 An attempt to allocate a buffer,
238 or to expand the buffer referenced by
247 characters were read,
250 (Note that POSIX specifies that
254 for this error condition;
258 for the rationale for the use of
260 in this implementation).
266 Originally implemented as GNU extension functions,
271 were adopted into POSIX.1-2008;
272 implementations conforming to this POSIX standard have been
273 integrated into libmingwex from version 3.22 onwards.
288 if ((fp = fopen ("/etc/motd", "r")) == NULL)
291 while ((count = getline (&line, &len, fp)) != -1)
292 printf ("Retrieved line of length %zu:\en> %s\en", count, line);
294 if (ferror (fp)) { /* handle error */ }
305 A return value of \(mi1 may indicate that
307 is already at end-of-file when
312 or it may indicate an error condition;
317 to distinguish error and end-of-file conditions.
322 can accommodate a maximum character count of
325 the return value will overflow if
331 characters without encountering a line delimiter;
332 for this overflow condition,
333 POSIX.1-2008 stipulates an
338 MSVCRT.DLL provides no significant interpretation for
339 an arbitrarily assigned
344 this implementation of
348 substitutes the semantically similar,
349 (but not semantically identical),
354 to ensure that MSVCRT.DLL's
356 can return an acceptable description for this error condition.
361 Please refer to Microsoft's documentation,
363 for standard I/O streams,
376 This manpage was written by \%Keith\ Marshall,
377 \%<keithmarshall@users.sourceforge.net>, to document the
381 functions as they have been implemented for the MinGW.org Project.
382 It may be copied, modified and redistributed,
383 without restriction of copyright,
384 provided this acknowledgement of contribution by
385 the original author remains unchanged.