xref: /netbsd-src/lib/libc/stdio/getline.c (revision 142091db360ab583ce70ce17da0eef01a0d70dea)
1*142091dbSroy /* $NetBSD: getline.c,v 1.3 2009/12/02 08:46:33 roy Exp $ */
2d4a3cf6aSroy 
3d4a3cf6aSroy /*
4d4a3cf6aSroy  * Copyright (c) 2009 The NetBSD Foundation, Inc.
5d4a3cf6aSroy  *
6d4a3cf6aSroy  * This code is derived from software contributed to The NetBSD Foundation
7d4a3cf6aSroy  * by Roy Marples.
8d4a3cf6aSroy  *
9d4a3cf6aSroy  * Redistribution and use in source and binary forms, with or without
10d4a3cf6aSroy  * modification, are permitted provided that the following conditions
11d4a3cf6aSroy  * are met:
12d4a3cf6aSroy  * 1. Redistributions of source code must retain the above copyright
13d4a3cf6aSroy  *    notice, this list of conditions and the following disclaimer.
14d4a3cf6aSroy  * 2. Redistributions in binary form must reproduce the above copyright
15d4a3cf6aSroy  *    notice, this list of conditions and the following disclaimer in the
16d4a3cf6aSroy  *    documentation and/or other materials provided with the distribution.
17d4a3cf6aSroy  *
18d4a3cf6aSroy  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19d4a3cf6aSroy  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20d4a3cf6aSroy  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21d4a3cf6aSroy  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22d4a3cf6aSroy  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23d4a3cf6aSroy  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24d4a3cf6aSroy  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25d4a3cf6aSroy  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26d4a3cf6aSroy  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27d4a3cf6aSroy  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28d4a3cf6aSroy  */
29d4a3cf6aSroy 
30d4a3cf6aSroy #include <sys/cdefs.h>
31*142091dbSroy __RCSID("$NetBSD: getline.c,v 1.3 2009/12/02 08:46:33 roy Exp $");
323490b83aSroy 
333490b83aSroy #include "namespace.h"
34d4a3cf6aSroy 
35d4a3cf6aSroy #include <stdio.h>
36d4a3cf6aSroy 
37*142091dbSroy #ifdef __weak_alias
__weak_alias(getline,_getline)38*142091dbSroy __weak_alias(getline, _getline)
39*142091dbSroy #endif
40*142091dbSroy 
41d4a3cf6aSroy ssize_t
42d4a3cf6aSroy getline(char **__restrict buf, size_t *__restrict buflen, FILE *__restrict fp)
43d4a3cf6aSroy {
44d4a3cf6aSroy 	return getdelim(buf, buflen, '\n', fp);
45d4a3cf6aSroy }
46