Update contrib.
3 * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
8 /* No user fns here. Pesch 15apr92. */
11 * Copyright (c) 1990 The Regents of the University of California.
12 * All rights reserved.
14 * Redistribution and use in source and binary forms are permitted
15 * provided that the above copyright notice and this paragraph are
16 * duplicated in all such forms and that any documentation,
17 * advertising materials, and other materials related to such
18 * distribution and use acknowledge that the software was developed
19 * by the University of California, Berkeley. The name of the
20 * University may not be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28 #include <sys/types.h>
30 #include <sys/unistd.h>
34 * Small standard I/O/seek/close functions.
35 * These maintain the `known seek offset' for seek optimisation.
39 __sread (void* cookie,char *buf,int n)
41 register FILE *fp = (FILE *) cookie;
44 ret = _read_r(fp->_data, fp->_file, buf, n);
46 /* If the read succeeded, update the current offset. */
51 fp->_flags &= ~__SOFF; /* paranoia */
56 __swrite (void* cookie,char const *buf,int n)
58 register FILE *fp = (FILE *) cookie;
60 if (fp->_flags & __SAPP)
61 (void) _lseek_r (fp->_data, fp->_file, (off_t) 0, SEEK_END);
62 fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */
63 return _write_r (fp->_data, fp->_file, buf, n);
67 __sseek (void* cookie,fpos_t offset,int whence)
69 register FILE *fp = (FILE *) cookie;
72 ret = _lseek_r (fp->_data, fp->_file, (off_t) offset, whence);
74 fp->_flags &= ~__SOFF;
84 __sclose (void* cookie)
86 FILE *fp = (FILE *) cookie;
88 return _close_r (fp->_data, fp->_file);