Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / fgets.c
blobfd1c994061f1849a38f32d0b85516467968d03a2
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include "dos_intern.h"
9 #include <aros/debug.h>
11 /*****************************************************************************
13 NAME */
14 #include <proto/dos.h>
16 AROS_LH3(STRPTR, FGets,
18 /* SYNOPSIS */
19 AROS_LHA(BPTR , fh, D1),
20 AROS_LHA(STRPTR, buf, D2),
21 AROS_LHA(ULONG , buflen, D3),
23 /* LOCATION */
24 struct DosLibrary *, DOSBase, 56, Dos)
26 /* FUNCTION
27 Read until NEWLINE (\n), EOF is encountered or buflen-1
28 characters have been read. If a NEWLINE is read, it will
29 be the last character in the buffer. The buffer will always
30 be \0-terminated.
32 INPUTS
33 fh - Read buffered from this filehandle
34 buf - Put read chars in this buffer
35 buflen - The size of the buffer
37 RESULT
38 buf or NULL if the first thing read is EOF.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
48 INTERNALS
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
53 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
55 ULONG len = 0;
56 LONG c;
58 buflen--;
62 c = FGetC (fh);
64 if (c == EOF)
66 if (len == 0)
67 return NULL;
68 else
69 break;
72 buf[len++] = c;
74 while ((len<buflen) && (c != '\n'));
76 buf[len] = 0;
78 return buf;
80 AROS_LIBFUNC_EXIT
81 } /* FGets */