ING_DB
This commit is contained in:
parent
c2a6413e11
commit
7503654ab7
|
|
@ -0,0 +1,68 @@
|
||||||
|
# include <stdio.h>
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/symbol.h"
|
||||||
|
# include "../h/pipes.h"
|
||||||
|
# include "IIglobals.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Exit DBS --
|
||||||
|
** waits for the parser to return,
|
||||||
|
** catching all children's death till then
|
||||||
|
** or till an error return.
|
||||||
|
** In case wait(II) is interrupted while waiting,
|
||||||
|
** as evidenced by errno == 4, waiting will resume.
|
||||||
|
*/
|
||||||
|
IIexit()
|
||||||
|
{
|
||||||
|
register int ndx;
|
||||||
|
register int pidptr;
|
||||||
|
register int err;
|
||||||
|
int status;
|
||||||
|
int pidlist[10];
|
||||||
|
extern errno; /* perror(III) */
|
||||||
|
|
||||||
|
# ifdef xETR1
|
||||||
|
if (IIdebug)
|
||||||
|
printf("EXIT\n");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
close(IIw_down);
|
||||||
|
close(IIr_down);
|
||||||
|
close(IIr_front);
|
||||||
|
pidptr = 0;
|
||||||
|
err = 0;
|
||||||
|
errno = 0;
|
||||||
|
while ((ndx = wait(&status)) != IIqlpid && (ndx != -1 || errno == 4))
|
||||||
|
{
|
||||||
|
if (ndx == -1)
|
||||||
|
{
|
||||||
|
errno = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
# ifdef xETR1
|
||||||
|
if (IIdebug)
|
||||||
|
printf("\tpid %u stat 0%o sig %d\n", ndx, status >> 8, status & 0177);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
pidlist[pidptr++] = ndx;
|
||||||
|
if (status & 0177)
|
||||||
|
{
|
||||||
|
printf("PID %u Status 0%o -- ", ndx, status & 0177);
|
||||||
|
if (status & 0200)
|
||||||
|
printf("Core Dumped");
|
||||||
|
else
|
||||||
|
printf("Abnormal beendet");
|
||||||
|
err++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
printf("\nPID Liste:");
|
||||||
|
for (ndx = 0; ndx < pidptr; ndx++)
|
||||||
|
printf(" %u", pidlist[ndx]);
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
sync();
|
||||||
|
IIqlpid = 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
# include <stdio.h>
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/pipes.h"
|
||||||
|
# include "IIglobals.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** SYSERR -- SYStem ERRor message print and abort
|
||||||
|
**
|
||||||
|
** Syserr acts like a printf with up to five arguments.
|
||||||
|
**
|
||||||
|
** If the first argument to syserr is not zero,
|
||||||
|
** the message "SYSERR:" is prepended.
|
||||||
|
**
|
||||||
|
** If the extern variable `IIproc_name' is assigned to a
|
||||||
|
** string, that string is prepended to the message.
|
||||||
|
**
|
||||||
|
** All arguments must be null-terminated.
|
||||||
|
**
|
||||||
|
** The function pointed to by `AAexitfn' is then called.
|
||||||
|
** It is initialized to be `exit'.
|
||||||
|
*/
|
||||||
|
# ifdef P8000
|
||||||
|
IIsyserr(p0, p1, p2, p3)
|
||||||
|
register char *p0;
|
||||||
|
register int p1;
|
||||||
|
register int p2;
|
||||||
|
register int p3;
|
||||||
|
{
|
||||||
|
# else
|
||||||
|
IIsyserr(pv)
|
||||||
|
char *pv;
|
||||||
|
{
|
||||||
|
register char **p;
|
||||||
|
# endif
|
||||||
|
extern int errno;
|
||||||
|
|
||||||
|
# ifndef P8000
|
||||||
|
p = &pv;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
putchar('\n');
|
||||||
|
if (IIproc_name)
|
||||||
|
printf("%s ", IIproc_name);
|
||||||
|
printf("SYSERR: ");
|
||||||
|
|
||||||
|
# ifdef P8000
|
||||||
|
printf(p0, p1, p2, p3);
|
||||||
|
# else
|
||||||
|
printf(p[0], p[1], p[2], p[3]);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
if (errno)
|
||||||
|
printf("\tBS error %d\n", errno);
|
||||||
|
fflush(stdout);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
# include <stdio.h>
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/symbol.h"
|
||||||
|
# include "../h/pipes.h"
|
||||||
|
# include "IIglobals.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** IIwrite is used to write a string to the
|
||||||
|
** QL parser
|
||||||
|
*/
|
||||||
|
IIwrite(str)
|
||||||
|
register char *str;
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
|
||||||
|
# ifdef xETR1
|
||||||
|
if (IIdebug)
|
||||||
|
printf("WRITE: string \"%s\"\n", str);
|
||||||
|
# endif
|
||||||
|
if (!IIqlpid)
|
||||||
|
IIsyserr("Es ist noch kein ## DBS-statement aktiv");
|
||||||
|
if (IIin_retrieve)
|
||||||
|
IIsyserr("QL-Statement innerhalb ## RETRIEVE");
|
||||||
|
|
||||||
|
if (i = IIlength(str))
|
||||||
|
if (IIwrpipe(P_NORM, &IIoutpipe, IIw_down, str, i) != i)
|
||||||
|
IIsyserr("WRITE - VALUE len=%d", i);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
# include <stdio.h>
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/symbol.h"
|
||||||
|
# include "../h/pipes.h"
|
||||||
|
# include "IIglobals.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Buffered Write on Pipe
|
||||||
|
**
|
||||||
|
** The message `msg' of length `n' is buffered and written onto
|
||||||
|
** the pipe with file descriptor `des'. `Buf' is the addr
|
||||||
|
** of the buffer in which buffering is to take place. If `n' is
|
||||||
|
** zero, `msg' is taken to be a null-terminated string of char-
|
||||||
|
** acters. `Mode' gives the operations mode of IIwrpipe().
|
||||||
|
**
|
||||||
|
** Buffers written with IIwrpipe() should be read with rdpipe().
|
||||||
|
**
|
||||||
|
** Modes:
|
||||||
|
**
|
||||||
|
** P_PRIME -- Prime the pipe for writing. This involves clearing
|
||||||
|
** out the error field, setting normal status, etc. In
|
||||||
|
** general, it should always be done when you want to
|
||||||
|
** start writing. It need not be done after writing an
|
||||||
|
** end-of-pipe (EOP), as this operation automatically
|
||||||
|
** resets the pipe. The "exec_id" field (read by
|
||||||
|
** rdpipe(P_EXECID)) is set to `des', and the "func_id"
|
||||||
|
** field is set to `n'.
|
||||||
|
**
|
||||||
|
** P_NORM -- Normal mode. `Msg' is buffered into `buf' and
|
||||||
|
** physically written into the pipe as necessary.
|
||||||
|
**
|
||||||
|
** P_END -- Writes an EOP. Only the first three parameters need
|
||||||
|
** be specified.
|
||||||
|
**
|
||||||
|
** P_FLUSH -- Flushes the buffer into the pipe, but does not write
|
||||||
|
** an EOP. In fact, a non-EOP is guaranteed to be
|
||||||
|
** written.
|
||||||
|
**
|
||||||
|
** P_WRITE -- Same as P_FLUSH, but the mode is unchanged. This
|
||||||
|
** mode is pretty obscure, and you probably need not use
|
||||||
|
** it.
|
||||||
|
**
|
||||||
|
** P_INT -- Writes an interrupt synchronization block into the
|
||||||
|
** pipe. This mode need only be called by resyncpipes()
|
||||||
|
** and need not normally concern the user. It is critical
|
||||||
|
** that this mode be called by all processes so that dead-
|
||||||
|
** lock or AAsyserrs do not occur.
|
||||||
|
*/
|
||||||
|
IIwrpipe(mode, buf, des, msg, n)
|
||||||
|
int mode;
|
||||||
|
register struct pipfrmt *buf;
|
||||||
|
int des;
|
||||||
|
char *msg;
|
||||||
|
int n;
|
||||||
|
{
|
||||||
|
register int nn;
|
||||||
|
register int msgl;
|
||||||
|
register int flushflg;
|
||||||
|
|
||||||
|
# ifdef xETR1
|
||||||
|
if (IIdebug > 1)
|
||||||
|
printf("WRPIPE(%d): mode %d buf 0%o msg 0%o n %d\n", des, mode, buf, msg, n);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
nn = msgl = 0;
|
||||||
|
flushflg = 0;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case P_PRIME:
|
||||||
|
buf->buf_len = buf->pbuf_pt = buf->err_id = 0;
|
||||||
|
buf->hdrstat = NORM_STAT;
|
||||||
|
buf->exec_id = des;
|
||||||
|
buf->func_id = n;
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
case P_NORM:
|
||||||
|
msgl = nn = !n? IIlength(msg) + 1: n;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case P_END:
|
||||||
|
buf->hdrstat = LAST_STAT;
|
||||||
|
flushflg++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case P_FLUSH:
|
||||||
|
buf->hdrstat = NORM_STAT;
|
||||||
|
|
||||||
|
case P_WRITE:
|
||||||
|
flushflg++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case P_INT:
|
||||||
|
buf->hdrstat = SYNC_STAT;
|
||||||
|
flushflg++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
IIsyserr("WRPIPE(%d): Unbekannter Mode %d", des, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (nn > 0 || flushflg)
|
||||||
|
{
|
||||||
|
/* BUFFER OUT DATA */
|
||||||
|
while (nn > 0 && buf->pbuf_pt < PBUFSIZ)
|
||||||
|
buf->pbuf[buf->pbuf_pt++] = msg[msgl - (nn--)];
|
||||||
|
/* WRITE PIPE? */
|
||||||
|
if (buf->pbuf_pt >= PBUFSIZ || flushflg)
|
||||||
|
{
|
||||||
|
buf->buf_len = buf->pbuf_pt;
|
||||||
|
# ifdef xETR2
|
||||||
|
if (IIdebug > 1)
|
||||||
|
IIprpipe(buf);
|
||||||
|
# endif
|
||||||
|
if (write(des, buf, HDRSIZ + PBUFSIZ) < HDRSIZ + PBUFSIZ)
|
||||||
|
IIsyserr("WRPIPE(%d): WRITE ERROR", des);
|
||||||
|
buf->pbuf_pt = 0;
|
||||||
|
buf->err_id = 0;
|
||||||
|
flushflg = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# ifdef xETR3
|
||||||
|
if (IIdebug > 1)
|
||||||
|
printf("WRPIPE(%d): return (%d)\n", des, msgl);
|
||||||
|
# endif
|
||||||
|
return (msgl);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue