/***********************************************************************
* *
* 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"
/* Put out a null-terminated string
**
** Written by Kiem-Phong Vo.
*/
#if __STD_C
#else
Sfio_t* f; /* write to this stream */
char* s; /* string to write */
int rc; /* record separator. */
#endif
{
char *ss;
SFMTXDECL(f);
SFMTXENTER(f,-1);
SFMTXRETURN(f, -1);
SFLOCK(f,0);
for(w = 0; (*s || rc >= 0); )
{ /* need to communicate string size to exception handler */
ss = (char*)s; /* save current checkpoint */
}
if(p < 0 ) /* something not right about buffering */
break;
if(p >= (n + (rc < 0 ? 0 : 1)) )
{ /* buffer can hold everything */
if(n > 0)
ps += n;
w += n;
}
if(rc >= 0)
w += 1;
}
}
else
{ /* create a reserve buffer to hold data */
p = n + (rc >= 0 ? 1 : 0);
n = 0;
else
{ if(n > 0)
if(rc >= 0)
n = 0;
}
w += n;
}
break;
}
if(*s == 0)
w += 1;
break;
}
ps -= 1;
#else
for(; p > 0; --p, ++ps, ++s)
if((*ps = *s) == 0)
break;
#endif
}
/* sync unseekable shared streams */
(void)SFFLSBUF(f,-1);
/* check for line buffering */
{ if(n > w)
n = w;
f->next -= n;
}
SFOPEN(f,0);
SFMTXRETURN(f, w);
}