/***********************************************************************
* *
* 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 "sfdchdr.h"
/*
* a discipline that prepends a prefix string to each output line
*
* Glenn Fowler
* AT&T Research
*
* @(#)$Id: sfdcprefix (AT&T Research) 1998-06-25 $
*/
typedef struct
{
} Prefix_t;
/*
* prefix write
*/
#if __STD_C
#else
Sfio_t* f;
register size_t n;
#endif
{
register char* b;
register char* s;
register char* e;
register char* t;
register ssize_t w;
int skip;
skip = 0;
w = 0;
b = (char*)buf;
s = b;
e = s + n;
do
{
if (!(t = memchr(s, '\n', e - s)))
{
skip = 1;
t = e - 1;
}
n = t - s + 1;
else
if ((s = t + 1) >= e)
return w;
} while ((s = t + 1) < e);
return w;
}
/*
* remove the discipline on close
*/
#if __STD_C
#else
Sfio_t* f;
int type;
#endif
{
return 0;
}
/*
* push the prefix discipline on f
*/
#if __STD_C
#else
int sfdcprefix(f, prefix)
Sfio_t* f;
char* prefix;
#endif
{
register char* s;
size_t n;
/*
* this is a writeonly discipline
*/
return -1;
return -1;
s = (char*)prefix + n;
n = s - (char*)prefix;
if (*s != ' ' || *s != '\t')
n++;
{
return -1;
}
return 0;
}