ftell.c (249808) | ftell.c (249810) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#if defined(LIBC_SCCS) && !defined(lint) 34static char sccsid[] = "@(#)ftell.c 8.2 (Berkeley) 5/4/95"; 35#endif /* LIBC_SCCS and not lint */ 36#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#if defined(LIBC_SCCS) && !defined(lint) 34static char sccsid[] = "@(#)ftell.c 8.2 (Berkeley) 5/4/95"; 35#endif /* LIBC_SCCS and not lint */ 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/lib/libc/stdio/ftell.c 249808 2013-04-23 13:33:13Z emaste $"); | 37__FBSDID("$FreeBSD: head/lib/libc/stdio/ftell.c 249810 2013-04-23 14:36:44Z emaste $"); |
38 39#include "namespace.h" 40#include <sys/types.h> 41#include <errno.h> 42#include <limits.h> 43#include <stdio.h> 44#include "un-namespace.h" 45#include "local.h" 46#include "libc_private.h" 47 48/* 49 * standard ftell function. 50 */ 51long | 38 39#include "namespace.h" 40#include <sys/types.h> 41#include <errno.h> 42#include <limits.h> 43#include <stdio.h> 44#include "un-namespace.h" 45#include "local.h" 46#include "libc_private.h" 47 48/* 49 * standard ftell function. 50 */ 51long |
52ftell(fp) 53 FILE *fp; | 52ftell(FILE *fp) |
54{ 55 off_t rv; 56 57 rv = ftello(fp); 58 if (rv > LONG_MAX) { 59 errno = EOVERFLOW; 60 return (-1); 61 } 62 return (rv); 63} 64 65/* 66 * ftello: return current offset. 67 */ 68off_t | 53{ 54 off_t rv; 55 56 rv = ftello(fp); 57 if (rv > LONG_MAX) { 58 errno = EOVERFLOW; 59 return (-1); 60 } 61 return (rv); 62} 63 64/* 65 * ftello: return current offset. 66 */ 67off_t |
69ftello(fp) 70 FILE *fp; | 68ftello(FILE *fp) |
71{ 72 fpos_t rv; 73 int ret; 74 75 FLOCKFILE(fp); 76 ret = _ftello(fp, &rv); 77 FUNLOCKFILE(fp); 78 if (ret) 79 return (-1); 80 if (rv < 0) { /* Unspecified value because of ungetc() at 0 */ 81 errno = ESPIPE; 82 return (-1); 83 } 84 return (rv); 85} 86 87int | 69{ 70 fpos_t rv; 71 int ret; 72 73 FLOCKFILE(fp); 74 ret = _ftello(fp, &rv); 75 FUNLOCKFILE(fp); 76 if (ret) 77 return (-1); 78 if (rv < 0) { /* Unspecified value because of ungetc() at 0 */ 79 errno = ESPIPE; 80 return (-1); 81 } 82 return (rv); 83} 84 85int |
88_ftello(fp, offset) 89 FILE *fp; 90 fpos_t *offset; | 86_ftello(FILE *fp, fpos_t *offset) |
91{ 92 fpos_t pos; 93 size_t n; 94 95 if (fp->_seek == NULL) { 96 errno = ESPIPE; /* historic practice */ 97 return (1); 98 } --- 41 unchanged lines hidden --- | 87{ 88 fpos_t pos; 89 size_t n; 90 91 if (fp->_seek == NULL) { 92 errno = ESPIPE; /* historic practice */ 93 return (1); 94 } --- 41 unchanged lines hidden --- |