sfdcseekable.c revision 3e14f97f673e8a630f076077de35afdd43dc1587
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1985-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Glenn Fowler <gsf@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Phong Vo <kpv@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* Discipline to make an unseekable read stream seekable
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin** sfraise(f,SFSK_DISCARD,0) discards previous seek data
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin** but seeks from current offset on still allowed
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin** Written by Kiem-Phong Vo, kpv@research.att.com, 03/18/1998.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef struct _skable_s
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Sfoff_t discard;/* sfseek(f,-1,SEEK_SET) discarded data */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic ssize_t skwrite(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic ssize_t skread(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* do a raw read */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return r+w;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic Sfoff_t skseek(Sfio_t* f, Sfoff_t addr, int type, Sfdisc_t* disc)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return -1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* read enough to reach the seek point */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin w = sizeof(buf);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(w != r)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* on close, remove the discipline */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic int skexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* see if already seekable */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return -1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return -1;