resetting manifest requested domain to floor
[platform/upstream/db4.git] / os_brew / fgets.c
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2006-2009 Oracle.  All rights reserved.
5  *
6  * $Id$
7  */
8
9 #include "db_config.h"
10
11 #include "db_int.h"
12
13 /*
14  * fgets --
15  *
16  * PUBLIC: #ifndef HAVE_FGETS
17  * PUBLIC: char *fgets __P((char *, int, FILE *));
18  * PUBLIC: #endif
19  */
20 char *
21 fgets(s, n, fp)
22         char *s;
23         int n;
24         FILE *fp;
25 {
26         int c;
27         char *cs;
28
29         c = 0;
30         cs = s;
31
32         while (--n > 0 && (c = fgetc(fp)) != EOF) {
33                 *cs++ = c;
34                 if (c == '\n')
35                         break;
36         }
37         if (c == EOF && cs == s)
38                 return (NULL);
39
40         *cs++ = '\0';
41         return (s);
42 }