xref: /netbsd-src/lib/libc/compat/stdio/compat_fgetpos.c (revision 1897181a7231d5fc7ab48994d1447fcbc4e13a49)
1*1897181aSchristos /* $NetBSD: compat_fgetpos.c,v 1.1 2012/01/22 18:36:18 christos Exp $ */
2*1897181aSchristos 
3*1897181aSchristos /*-
4*1897181aSchristos  * Copyright (c) 1990, 1993
5*1897181aSchristos  *	The Regents of the University of California.  All rights reserved.
6*1897181aSchristos  *
7*1897181aSchristos  * This code is derived from software contributed to Berkeley by
8*1897181aSchristos  * Chris Torek.
9*1897181aSchristos  *
10*1897181aSchristos  * Redistribution and use in source and binary forms, with or without
11*1897181aSchristos  * modification, are permitted provided that the following conditions
12*1897181aSchristos  * are met:
13*1897181aSchristos  * 1. Redistributions of source code must retain the above copyright
14*1897181aSchristos  *    notice, this list of conditions and the following disclaimer.
15*1897181aSchristos  * 2. Redistributions in binary form must reproduce the above copyright
16*1897181aSchristos  *    notice, this list of conditions and the following disclaimer in the
17*1897181aSchristos  *    documentation and/or other materials provided with the distribution.
18*1897181aSchristos  * 3. Neither the name of the University nor the names of its contributors
19*1897181aSchristos  *    may be used to endorse or promote products derived from this software
20*1897181aSchristos  *    without specific prior written permission.
21*1897181aSchristos  *
22*1897181aSchristos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*1897181aSchristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*1897181aSchristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*1897181aSchristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*1897181aSchristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*1897181aSchristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*1897181aSchristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*1897181aSchristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*1897181aSchristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*1897181aSchristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*1897181aSchristos  * SUCH DAMAGE.
33*1897181aSchristos  *
34*1897181aSchristos  * Original version ID:
35*1897181aSchristos  * NetBSD: fgetpos.c,v 1.11 2003/08/07 16:43:23 agc Exp
36*1897181aSchristos  */
37*1897181aSchristos 
38*1897181aSchristos #include <sys/cdefs.h>
39*1897181aSchristos #if defined(LIBC_SCCS) && !defined(lint)
40*1897181aSchristos __RCSID("$NetBSD: compat_fgetpos.c,v 1.1 2012/01/22 18:36:18 christos Exp $");
41*1897181aSchristos #endif /* LIBC_SCCS and not lint */
42*1897181aSchristos 
43*1897181aSchristos #define __LIBC12_SOURCE__
44*1897181aSchristos 
45*1897181aSchristos #include "namespace.h"
46*1897181aSchristos #include <sys/types.h>
47*1897181aSchristos 
48*1897181aSchristos #include <assert.h>
49*1897181aSchristos #include <stdio.h>
50*1897181aSchristos #include <compat/include/stdio.h>
51*1897181aSchristos 
52*1897181aSchristos #ifdef __warn_references
53*1897181aSchristos __warn_references(fgetpos,
54*1897181aSchristos     "warning: reference to compatibility fgetpos(); include <stdio.h> for correct reference")
55*1897181aSchristos #endif
56*1897181aSchristos 
57*1897181aSchristos int
fgetpos(FILE * __restrict fp,off_t * __restrict pos)58*1897181aSchristos fgetpos(FILE * __restrict fp, off_t * __restrict pos)
59*1897181aSchristos {
60*1897181aSchristos 	_DIAGASSERT(fp != NULL);
61*1897181aSchristos 	_DIAGASSERT(pos != NULL);
62*1897181aSchristos 
63*1897181aSchristos 	return (*pos = ftello(fp)) == (off_t)-1;
64*1897181aSchristos }
65