source: freewrt/tools/paxmirabilis/fgetln.c@ a569125

freewrt_1_0 freewrt_2_0
Last change on this file since a569125 was a569125, checked in by Thorsten Glaser <tg@…>, 14 years ago

even FreeWRT 1.0-stable deserves paxmirabilis-20120216 compiled with LTO ☺

git-svn-id: svn://www.freewrt.org/branches/freewrt_1_0@3981 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*-
2 * Copyright (c) 2007, 2009
3 * Thorsten Glaser <tg@mirbsd.org>
4 *
5 * Provided that these terms and disclaimer and all copyright notices
6 * are retained or reproduced in an accompanying document, permission
7 * is granted to deal in this work without restriction, including un-
8 * limited rights to use, publicly perform, distribute, sell, modify,
9 * merge, give away, or sublicence.
10 *
11 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
12 * the utmost extent permitted by applicable law, neither express nor
13 * implied; without malicious intent or gross negligence. In no event
14 * may a licensor, author or contributor be held liable for indirect,
15 * direct, other damage, loss, or other issues arising in any way out
16 * of dealing in the work, even if advised of the possibility of such
17 * damage or existence of a defect, except proven that it results out
18 * of said person's immediate fault when using the work as intended.
19 *-
20 * fgetln() wrapper for operating systems with getline() – glibc
21 */
22
23#define _GNU_SOURCE /* for getline() */
24#include <sys/types.h>
25#include <stdio.h>
26#include <string.h>
27
28__RCSID("$MirOS: contrib/code/mirmake/dist/contrib/fgetln.c,v 1.6 2009/11/21 14:50:27 tg Exp $");
29
30#if defined(__GLIBC__)
31
32#if !defined(_MIRMAKE_H) || !defined(_MIRMAKE_DEFNS)
33char *fgetln(FILE *, size_t *);
34#endif
35
36char *
37fgetln(FILE *stream, size_t *len)
38{
39 static char *lb = NULL;
40 static size_t lbsz = 0;
41
42 if ((*len = getline(&lb, &lbsz, stream)) != (size_t)-1)
43 /* getdelim ensures *len is not 0 here */
44 return (lb);
45
46 /* not required by manpage, but reference implementation does this */
47 *len = 0;
48
49 /* not required to zero lb or lbsz: getdelim manages it */
50 return (NULL);
51}
52#endif
Note: See TracBrowser for help on using the repository browser.