xref: /netbsd-src/lib/libc/compat/stdio/compat_fsetpos.c (revision e61202360d5611414dd6f6115934a96aa1f50b1a)
1*e6120236Sdrochner /* $NetBSD: compat_fsetpos.c,v 1.2 2012/10/17 16:09:03 drochner Exp $ */
21897181aSchristos 
31897181aSchristos /*-
41897181aSchristos  * Copyright (c) 1990, 1993
51897181aSchristos  *	The Regents of the University of California.  All rights reserved.
61897181aSchristos  *
71897181aSchristos  * This code is derived from software contributed to Berkeley by
81897181aSchristos  * Chris Torek.
91897181aSchristos  *
101897181aSchristos  * Redistribution and use in source and binary forms, with or without
111897181aSchristos  * modification, are permitted provided that the following conditions
121897181aSchristos  * are met:
131897181aSchristos  * 1. Redistributions of source code must retain the above copyright
141897181aSchristos  *    notice, this list of conditions and the following disclaimer.
151897181aSchristos  * 2. Redistributions in binary form must reproduce the above copyright
161897181aSchristos  *    notice, this list of conditions and the following disclaimer in the
171897181aSchristos  *    documentation and/or other materials provided with the distribution.
181897181aSchristos  * 3. Neither the name of the University nor the names of its contributors
191897181aSchristos  *    may be used to endorse or promote products derived from this software
201897181aSchristos  *    without specific prior written permission.
211897181aSchristos  *
221897181aSchristos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231897181aSchristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241897181aSchristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251897181aSchristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261897181aSchristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271897181aSchristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281897181aSchristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291897181aSchristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301897181aSchristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311897181aSchristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321897181aSchristos  * SUCH DAMAGE.
331897181aSchristos  *
341897181aSchristos  * Original version ID:
351897181aSchristos  * NetBSD: fsetpos.c,v 1.10 2003/08/07 16:43:25 agc Exp
361897181aSchristos  */
371897181aSchristos 
381897181aSchristos #include <sys/cdefs.h>
391897181aSchristos #if defined(LIBC_SCCS) && !defined(lint)
40*e6120236Sdrochner __RCSID("$NetBSD: compat_fsetpos.c,v 1.2 2012/10/17 16:09:03 drochner Exp $");
411897181aSchristos #endif /* LIBC_SCCS and not lint */
421897181aSchristos 
431897181aSchristos #define __LIBC12_SOURCE__
441897181aSchristos 
451897181aSchristos #include "namespace.h"
461897181aSchristos #include <sys/types.h>
471897181aSchristos 
481897181aSchristos #include <assert.h>
491897181aSchristos #include <stdio.h>
501897181aSchristos #include <compat/include/stdio.h>
511897181aSchristos 
521897181aSchristos #ifdef __warn_references
531897181aSchristos __warn_references(fsetpos,
541897181aSchristos     "warning: reference to compatibility fsetpos(); include <stdio.h> for correct reference")
551897181aSchristos #endif
561897181aSchristos 
571897181aSchristos 
581897181aSchristos /*
591897181aSchristos  * fsetpos: like fseek.
601897181aSchristos  */
611897181aSchristos int
fsetpos(FILE * __restrict iop,const off_t * __restrict pos)621897181aSchristos fsetpos(FILE * __restrict iop, const off_t * __restrict pos)
631897181aSchristos {
641897181aSchristos 	_DIAGASSERT(iop != NULL);
651897181aSchristos 	_DIAGASSERT(pos != NULL);
661897181aSchristos 
671897181aSchristos 	return fseeko(iop, *pos, SEEK_SET) == (off_t)-1;
681897181aSchristos }
69