home *** CD-ROM | disk | FTP | other *** search
- /*
- (C) 1995-96 AROS - The Amiga Replacement OS
- $Id: fgets.c,v 1.3 1997/01/27 00:36:19 ldp Exp $
-
- Desc:
- Lang: english
- */
- #include "dos_intern.h"
-
- /*****************************************************************************
-
- NAME */
- #include <proto/dos.h>
-
- AROS_LH3(STRPTR, FGets,
-
- /* SYNOPSIS */
- AROS_LHA(BPTR , fh, D1),
- AROS_LHA(STRPTR, buf, D2),
- AROS_LHA(ULONG , buflen, D3),
-
- /* LOCATION */
- struct DosLibrary *, DOSBase, 56, Dos)
-
- /* FUNCTION
- Read until NEWLINE (\n), EOF is encountered or buflen-1
- characters have been read. If a NEWLINE is read, it will
- be the last character in the buffer. The buffer will always
- be \0-terminated.
-
- INPUTS
- fh - Read buffered from this filehandle
- buf - Put read chars in this buffer
- buflen - The size of the buffer
-
- RESULT
- buf or NULL if the first thing read is EOF.
-
- NOTES
-
- EXAMPLE
-
- BUGS
-
- SEE ALSO
-
- INTERNALS
-
- HISTORY
- 27-11-96 digulla automatically created from
- dos_lib.fd and clib/dos_protos.h
-
- *****************************************************************************/
- {
- AROS_LIBFUNC_INIT
- AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
- ULONG len;
- LONG c;
-
- buflen --;
-
- for (len=0; len<buflen; len++)
- {
- c = FGetC (fh);
-
- if (c == EOF)
- {
- if (len == 0)
- return NULL;
- else
- break;
- }
-
- buf[len++] = c;
-
- if (c == '\n')
- break;
- }
-
- buf[len] = 0;
-
- return buf;
- AROS_LIBFUNC_EXIT
- } /* FGets */
-