sfreserve.c revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Knowledge Ventures *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* 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
int type; /* LOCKR: lock stream, LASTR: last record */
#endif
{
/* 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;
/* amount to perform IO */
iosz = -1;
else
if(iosz <= 0)
break;
}
/* do a buffer refill or flush */
now = n;
{ if(n == 0) /* peek-read only if there is no buffered data */
}
}
break;
}
}
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);
}