|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T a
Length: 3031 (0xbd7)
Types: TextFile
Names: »acserver1.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z«
└─⟦de7628f85⟧
└─⟦this⟧ »isode-6.0/acsap/acserver1.c«
/* acserver1.c - generic server dispatch */
#ifndef lint
static char *rcsid = "$Header: /f/osi/acsap/RCS/acserver1.c,v 7.0 89/11/23 21:22:02 mrose Rel $";
#endif
/*
* $Header: /f/osi/acsap/RCS/acserver1.c,v 7.0 89/11/23 21:22:02 mrose Rel $
*
*
* $Log: acserver1.c,v $
* Revision 7.0 89/11/23 21:22:02 mrose
* Release 6.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
/* LINTLIBRARY */
#include <signal.h>
#include "psap.h"
#include "tsap.h"
#include "tailor.h"
#include <sys/ioctl.h>
#ifdef BSD42
#include <sys/file.h>
#endif
#ifdef SYS5
#include <fcntl.h>
#endif
/* \f
*/
int isodeserver (argc, argv, aei, initfnx, workfnx, losefnx, td)
int argc;
char **argv;
AEI aei;
IFP initfnx,
workfnx,
losefnx;
struct TSAPdisconnect *td;
{
int fd,
nfds,
vecp;
fd_set ifds,
mask;
char *vec[4];
isodetailor (NULLCP, 0);
nfds = 0;
FD_ZERO (&mask);
if (argc > 1) {
if ((fd = (*initfnx) (argc, argv)) == NOTOK)
return tsaplose (td, DR_NETWORK, NULLCP, "initialization failed");
nfds = fd + 1;
FD_SET (fd, &mask);
}
else {
struct PSAPaddr *pa;
if ((pa = aei2addr (aei)) == NULLPA)
return tsaplose (td, DR_ADDRESS, NULLCP,
"address translation failed");
if (TNetListen (&pa -> pa_addr.sa_addr, td) == NOTOK)
return NOTOK;
if (!isatty (2)) {
int i;
for (i = 0; i < 5; i++) {
switch (fork ()) {
case NOTOK:
sleep (5);
continue;
case OK:
break;
default:
_exit (0);
}
break;
}
(void) chdir ("/");
if ((fd = open ("/dev/null", O_RDWR)) != NOTOK) {
if (fd != 0)
(void) dup2 (fd, 0), (void) close (fd);
(void) dup2 (0, 1);
(void) dup2 (0, 2);
}
#ifdef TIOCNOTTY
if ((fd = open ("/dev/tty", O_RDWR)) != NOTOK) {
(void) ioctl (fd, TIOCNOTTY, NULLCP);
(void) close (fd);
}
#else
#ifdef SYS5
(void) setpgrp ();
(void) signal (SIGINT, SIG_IGN);
(void) signal (SIGQUIT, SIG_IGN);
#endif
#endif
}
}
for (;;) {
ifds = mask;
if (TNetAccept (&vecp, vec, nfds, &ifds, NULLFD, NULLFD, NOTOK, td)
== NOTOK) {
(void) (*losefnx) (td);
continue;
}
if (vecp > 0 && (fd = (*initfnx) (vecp, vec)) != NOTOK) {
if (fd >= nfds)
nfds = fd + 1;
FD_SET (fd, &mask);
}
for (fd = 0; fd < nfds; fd++)
if (FD_ISSET (fd, &ifds)) {
if (workfnx == NULLIFP) {
(void) TNetClose (NULLTA, td);
return tsaplose (td, DR_OPERATION, NULLCP,
"no worker routine for connected fd");
}
if ((*workfnx) (fd) == NOTOK) {
if (nfds == fd + 1)
nfds--;
FD_CLR (fd, &mask);
if (argc > 1) {
int xd;
for (xd = 0; xd < nfds; xd++)
if (FD_ISSET (xd, &mask))
break;
if (xd >= nfds)
return OK;
}
}
}
}
}