some fixes to accented characters
[tangerine.git] / rom / dos / fgets.c
blobafba1fbe8bac9ffd73da89d89b8007e52bbcfdbe
1 /*
2 Copyright © 1995-2007, 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
54 ULONG len = 0;
55 LONG c;
57 buflen--;
61 c = FGetC (fh);
63 if (c == EOF)
65 if (len == 0)
66 return NULL;
67 else
68 break;
71 buf[len++] = c;
73 while ((len<buflen) && (c != '\n'));
75 buf[len] = 0;
77 return buf;
79 AROS_LIBFUNC_EXIT
80 } /* FGets */