/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "sfhdr.h"
/* Reserve a segment of data or buffer.
**
** Written by Kiem-Phong Vo.
*/
#if __STD_C
#else
Sfio_t* f; /* file to peek */
int type; /* LOCKR: lock stream, LASTR: last record */
#endif
{
SFMTXDECL(f);
/* see if we need to bias toward SF_WRITE instead of the default SF_READ */
if(type < 0)
mode = 0;
/* return the last record */
f->next += n;
}
}
else
}
SFMTXRETURN(f, data);
}
if(type > 0)
}
SFLOCK(f,0);
n = 0;
goto done;
}
/* iterate until get to a stream that has data or buffer space */
{ SFOPEN(f,0);
}
n = 0;
if(n > 0 && n >= sz) /* all done */
break;
/* set amount to perform IO */
iosz = -1;
}
else
if(iosz <= 0) /* nothing to do */
break;
}
/* do a buffer refill or flush */
now = n;
{ if(n == 0) /* peek-read only if there is no buffered data */
}
}
break;
}
}
else
{ /* sfreserve(f,0,0) == sfread(f, sfreserve(f,-1,SF_LOCKR), 0) */
}
n = 0;
if(n >= sz) /* got it */
break;
break;
/* request was only to assess data availability */
break;
}
done: /* compute the buffer to be returned */
if(size == 0 || n == 0)
{ if(n > 0) /* got data */
}
else if(n >= sz) /* got data */
}
}
}
}
SFOPEN(f,0);
if(data)
}
else
}
}
SFMTXRETURN(f, data);
}