diff --git a/WEGA/contrib/ingres/dbs/src/gutil/errfilen.c b/WEGA/contrib/ingres/dbs/src/gutil/errfilen.c new file mode 100644 index 0000000..d2823cc --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/gutil/errfilen.c @@ -0,0 +1,32 @@ +# include "gen.h" +# include "../h/dbs.h" +# include "../h/aux.h" + +static char AA_ERRFN[] ="/sys/etc/error"; + +/* +** Errfn() -- Returns the pathname where the error file can be found +** +** It is assumed that the error errnum cannot be more than 999 +*/ +char *AAerrfn(errnum) +register int errnum; +{ + register char *cp; + char ver[12]; + extern char AAversion[]; + extern char *AAbmove(); + extern char *AAztack(); + extern char *AA_iocv(); + + AAbmove(AAversion, cp = ver, sizeof ver); + /* make sure any mod number is removed */ + for ( ; *cp; cp++) + if (*cp == '/') + break; + + /* now insert the "_X" */ + *cp++ = '_'; + *cp++ = 0; + return (AAztack(AAztack(AAztack(AApath, AA_ERRFN), ver), AA_iocv(errnum))); +} diff --git a/WEGA/contrib/ingres/dbs/src/gutil/need.c b/WEGA/contrib/ingres/dbs/src/gutil/need.c new file mode 100644 index 0000000..7254d8e --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/gutil/need.c @@ -0,0 +1,83 @@ +# include "gen.h" +# include "../h/dbs.h" +# include "../h/aux.h" +# include "need.h" + +/* +** NEED.C -- general buffer allocation routines +** +** allow buffers with LIFO de-allocation +** +** Defines: +** need() +** initbuf() +** +** +** +** NEED -- allocate space from a buffer +** +** On buffer overflow, calls err_func from that field +** in the buffer with the error code err_code from that field +** in the buffer, then returns 0. +** need() guarantees an even adress on return. +** +** Parameters: +** bf -- buffer +** nbytes -- number of bytes desired +** +** Returns: +** pointer to allocated area +** on buffer overflow returns 0. +** +** Side Effects: +** adjusts buffer structure to reflect allocation. +*/ +char *need(buf, nbytes) +register struct nodbuffer *buf; +register int nbytes; +{ + register char *x; + + nbytes = ALIGNMENT(nbytes); + if (nbytes > buf->nleft) + { + (*buf->err_func)(buf->err_num); + return (0); + } + x = buf->xfree; + buf->xfree += nbytes; + buf->nleft -= nbytes; + return (x); +} + + +/* +** INITBUF -- initialize a buffer +** +** Must be called before the first need() call on the buffer. +** +** Parameters: +** bf -- buffer +** size -- size fo buffer area +** err_num -- error code for overflow +** err_func -- function to call with err_code on error +** +** Returns: +** none +** +** Side Effects: +** initializes buffer structure +*/ +initbuf(buf, size, err_num, err_func) +register struct nodbuffer *buf; +register int size; +register int err_num; +int (*err_func)(); +{ + if (((int) buf) & 01) + AAsyserr(14008, buf); + buf->nleft = size - sizeof *buf; + buf->xfree = buf->buffer; + buf->err_num = err_num; + buf->err_func = err_func; +} diff --git a/WEGA/contrib/ingres/dbs/src/gutil/set_so_buf.c b/WEGA/contrib/ingres/dbs/src/gutil/set_so_buf.c new file mode 100644 index 0000000..13c0a24 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/gutil/set_so_buf.c @@ -0,0 +1,27 @@ +# include +# include "gen.h" +# include "../h/dbs.h" + +extern int AAtTany; + +/* +** SET_SO_BUF -- set standard output buffer conditionally +** +** This routine sets the standard output buffer conditionally, +** based on whether trace flags are set or not. +*/ +set_so_buf() +{ +# ifdef SETBUF + extern int errno; + static char buffer[BUFSIZ]; + +# ifdef xATR1 + if (AAtTany) + return; +# endif + + errno = 0; + setbuf(stdout, buffer); +# endif +}