migrate substitution keywords to SVN
[reactos.git] / reactos / lib / crtdll / stdio / fgets.c
1 /* $Id$
2 *
3 * ReactOS msvcrt library
4 *
5 * fgets.c
6 *
7 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 *
9 * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
10 * 28/12/1998: Appropriated for Reactos
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
27
28 #include <msvcrt/stdio.h>
29 #include <msvcrt/internal/file.h>
30
31
32 char* fgets(char* s, int n, FILE* f)
33 {
34 int c=0;
35 char *cs;
36
37 cs = s;
38 while (--n>0 && (c = getc(f)) != EOF) {
39 *cs++ = c;
40 if (c == '\n')
41 break;
42 }
43 if (c == EOF && cs == s)
44 return NULL;
45 *cs++ = '\0';
46 return s;
47 }