sfstr.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* 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 <ast.h>
#include <stdarg.h>
static int
{
int o;
if (n < STR)
n = STR;
return -1;
return 0;
}
int
{
Sfstr_t* p;
int r;
if (VALID(p, f))
{
p->nxt = 0;
r = 0;
}
else
r = fclose(f);
return r;
}
int
{
Sfstr_t* p;
char* s;
int r;
if (!VALID(p, f))
return r;
}
char*
{
int r;
return r > 0 ? buf : (char*)0;
}
int
{
Sfstr_t* p;
int r;
if (VALID(p, f))
{
return -1;
*p->nxt++ = c;
r = 1;
}
else
r = fputc(c, f);
return r;
}
int
{
Sfstr_t* p;
int r;
int n;
if (VALID(p, f))
{
r = n + (sep >= 0);
return -1;
p->nxt += n;
if (sep >= 0)
}
else
{
r++;
}
return r;
}
char*
{
Sfstr_t* p;
if (VALID(p, f))
return p->beg;
return 0;
}
sfstropen(void)
{
Sfstr_t* p;
if (!p->nxt)
{
if (!p->beg)
{
break;
}
return (Sfio_t*)p;
}
return 0;
}
#define _sf_strseek(f,p,m) \
( (m) == SEEK_SET ? \
: (m) == SEEK_CUR ? \
((f)->nxt += (p), \
: (m) == SEEK_END ? \
: (char*)0 \
)
char*
{
Sfstr_t* p;
if (VALID(p, f))
return _sf_strseek(p, n, w);
return 0;
}
char*
{
Sfstr_t* p;
return 0;
}
int
{
Sfstr_t* p;
int r;
else
r = -1;
return r;
}
char*
{
Sfstr_t* p;
{
*p->nxt = 0;
}
return 0;
}
int
{
Sfstr_t* p;
if (VALID(p, f))
{
return -1;
p->nxt += n;
}
else
return n;
}