2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
11 #include <dos/dosextens.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
17 /*****************************************************************************
30 Read one line of characters from the stream into the buffer.
31 Reading will stop, when a newline ('\n') is encountered, EOF
32 or when the buffer is full. If a newline is read, then it is
33 put into the buffer. The last character in the buffer is always
34 '\0' (Therefore at most size-1 characters can be read in one go).
37 buffer - Write characters into this buffer
38 size - This is the size of the buffer in characters.
39 stream - Read from this stream
42 buffer or NULL in case of an error or EOF.
47 // Read a file line by line
51 while (fgets (line, sizeof (line), fh))
59 fopen(), gets(), fputs()
63 ******************************************************************************/
65 fdesc
*fdesc
= __getfdesc(stream
->fd
);
70 stream
->flags
|= __POSIXC_STDIO_ERROR
;
77 buffer
= FGets (fdesc
->fcb
->handle
, buffer
, size
);
83 errno
= __stdc_ioerr2errno(IoErr());
84 stream
->flags
|= __POSIXC_STDIO_ERROR
;
88 stream
->flags
|= __POSIXC_STDIO_EOF
;
93 int bsize
= strlen(buffer
);
94 if ((bsize
+ 1 < size
) && (buffer
[bsize
- 1] != '\n'))
95 stream
->flags
|= __POSIXC_STDIO_EOF
;