2 .TH %PAGEREF% MinGW "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
32 Feature Test Macro Requirements for libmingwex:
34 .BR getdelim (),\~ getline ():
36 Available since libmingwex version 3.22:
37 .BR _POSIX_C_SOURCE\0 >=\0 200809L\0 ||\0 _XOPEN_SOURCE\0 >=\0 700
44 function reads data from
46 until either a character entity matching
55 is stored into the buffer referenced by the pointer at
64 function is a special case of
68 argument implicitly specified as the POSIX newline character,
74 argument must be a reference to a pointer which is safe to pass to
79 or a pointer to a buffer of size as indicated by
89 with a value of zero in
93 and recommended as a mechanism for requesting allocation
99 argument is specified as an
101 it must be passed a value which is representable as an
102 .BR "unsigned char" ,
103 otherwise the behaviour is undefined.
109 is initially passed as a
118 in an attempt to allocate
121 or an arbitrarily sized smaller default buffer,
122 if such an allocation is not achievable.
127 will be updated to reflect the allocated buffer location,
128 and the actual size allocated.
132 at any time during collection of the input record,
133 the buffer referenced by
135 becomes too small to store the record,
136 it will be expanded as necessary,
141 will be adjusted to reflect the change in allocation.
146 On successful completion,
150 return the number of characters stored into the buffer at
155 character if this was encountered before
157 but excluding the terminating
162 If no characters were read,
170 and the end-of-file indicator is set for
180 as indicated under the heading
191 may fail for any of the reasons described as failure conditions for
193 when any such error occurs,
211 returning \(mi1 after setting
213 to indicate occurrence of any of the following errors:
230 or otherwise is not a valid stream opened for reading,
236 An attempt to allocate a buffer,
237 or to expand the buffer referenced by
246 characters were read,
255 for this error condition;
259 for the rationale for the use of
261 in this implementation).
265 .SH STANDARDS CONFORMANCE
267 Originally implemented as GNU extension functions,
273 .BR \%POSIX.1\(hy2008 ;
274 implementations conforming to this
276 standard have been integrated into libmingwex
277 from version 3.22 onwards.
292 if ((fp = fopen ("/etc/motd", "r")) == NULL)
295 while ((count = getline (&line, &len, fp)) != -1)
296 printf ("Retrieved line of length %zu:\en> %s\en", count, line);
298 if (ferror (fp)) { /* handle error */ }
309 A return value of \(mi1 may indicate that
311 is already at end-of-file when
316 or it may indicate an error condition;
321 to distinguish error and end-of-file conditions.
326 can accommodate a maximum character count of
329 the return value will overflow if
335 characters without encountering a line delimiter;
336 for this overflow condition,
343 MSVCRT.DLL provides no significant interpretation for
344 an arbitrarily assigned
349 this implementation of
353 substitutes the semantically similar,
354 (but not semantically identical),
359 to ensure that MSVCRT.DLL's
361 can return an acceptable description for this error condition.
366 Please refer to Microsoft's documentation,
368 for standard I/O streams,
381 This manpage was written by \%Keith\ Marshall,
382 \%<keith@users.osdn.me>,
387 functions as they have been implemented for the MinGW.org Project.
388 It may be copied, modified and redistributed,
389 without restriction of copyright,
390 provided this acknowledgement of contribution by
391 the original author remains in place.