/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* 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"
/* Read a record delineated by a character.
** The record length can be accessed via sfvalue(f).
**
** Written by Kiem-Phong Vo
*/
#if __STD_C
#else
Sfio_t* f; /* stream to read from */
int rc; /* record separator */
int type;
#endif
{
int found;
SFMTXDECL(f);
SFMTXENTER(f, NIL(char*));
SFMTXRETURN(f, NIL(char*));
SFLOCK(f,0);
/* buffer to be returned */
un = 0;
found = 0;
/* compatibility mode */
found = 1;
}
found = 1;
}
goto done;
}
while(!found)
{ /* fill buffer if necessary */
{ /* for unseekable devices, peek-read 1 record */
/* fill buffer the conventional way */
if(SFRPEEK(f,s,n) <= 0)
goto done;
}
else
{ ends = s+n;
goto do_copy;
}
}
}
#if _lib_memchr
s = ends;
#else
while(*s != rc)
if((s += 1) == ends)
break;
#endif
if(s < ends) /* found separator */
{ s += 1; /* include the separator */
found = 1;
if(!us &&
{ /* returning data in buffer */
f->next = s;
goto done;
}
}
/* amount to be read */
n = s - f->next;
goto done;
}
/* get internal buffer */
{ if(rsrv)
else
goto done;
}
}
/* now copy data */
un += n;
f->next += n;
}
done:
f->getr = 0;
}
}
/* prepare for a call to get the broken record */
if(rsrv)
SFOPEN(f,0);
}
SFMTXRETURN(f, (char*)us);
}