4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1986 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */
34 * Seek for standard library. Coordinates with buffering.
42 fseek(iop
, offset
, ptrname
)
47 register int resync
, c
;
48 long p
= -1; /* can't happen? */
50 iop
->_flag
&= ~_IOEOF
;
51 if(iop
->_flag
& _IOREAD
) {
52 if(ptrname
< 2 && iop
->_base
&& !(iop
->_flag
&_IONBF
)) {
56 long curpos
= lseek(fileno(iop
), 0L, 1);
65 if(!(iop
->_flag
&_IORW
) && c
> 0 && p
<= c
&&
66 p
>= iop
->_base
- iop
->_ptr
) {
73 if(iop
->_flag
& _IORW
) {
74 iop
->_ptr
= iop
->_base
;
75 iop
->_flag
&= ~_IOREAD
;
78 p
= lseek(fileno(iop
), offset
-resync
, ptrname
);
80 if (resync
&& p
!= -1)
83 } else if(iop
->_flag
& (_IOWRT
| _IORW
)) {
86 if(iop
->_flag
& _IORW
) {
87 iop
->_flag
&= ~_IOWRT
;
88 iop
->_ptr
= iop
->_base
;
90 return(lseek(fileno(iop
), offset
, ptrname
) == -1 || p
== EOF
?
93 return((p
== -1)? -1: 0);