ING_DB
This commit is contained in:
parent
937df898e0
commit
22dba5398b
|
|
@ -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)));
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# include <stdio.h>
|
||||
# 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
|
||||
}
|
||||
Loading…
Reference in New Issue