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
RevLine 
[cf550bc6]1/*-
[a569125]2 * Copyright (c) 2007, 2009
3 * Thorsten Glaser <tg@mirbsd.org>
[cf550bc6]4 *
[a6ce807]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.
[cf550bc6]10 *
[a6ce807]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 *-
[08c8e8e]20 * fgetln() wrapper for operating systems with getline() – glibc
[cf550bc6]21 */
22
[a6ce807]23#define _GNU_SOURCE /* for getline() */
[2c03383]24#include <sys/types.h>
[9e17a74]25#include <stdio.h>
[2c03383]26#include <string.h>
27
[a569125]28__RCSID("$MirOS: contrib/code/mirmake/dist/contrib/fgetln.c,v 1.6 2009/11/21 14:50:27 tg Exp $");
[08c8e8e]29
30#if defined(__GLIBC__)
31
32#if !defined(_MIRMAKE_H) || !defined(_MIRMAKE_DEFNS)
[a6ce807]33char *fgetln(FILE *, size_t *);
[08c8e8e]34#endif
[4e20789]35
[2c03383]36char *
[a6ce807]37fgetln(FILE *stream, size_t *len)
[2c03383]38{
[08c8e8e]39 static char *lb = NULL;
40 static size_t lbsz = 0;
41
42 if ((*len = getline(&lb, &lbsz, stream)) != (size_t)-1)
[a569125]43 /* getdelim ensures *len is not 0 here */
[08c8e8e]44 return (lb);
45
46 /* not required by manpage, but reference implementation does this */
47 *len = 0;
[2c03383]48
[08c8e8e]49 /* not required to zero lb or lbsz: getdelim manages it */
50 return (NULL);
[2c03383]51}
52#endif
Note: See TracBrowser for help on using the repository browser.