|
|
BSD 4.3reno
/* socket.c - dish -pipe support */
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/dish/socket.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif
/*
* $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/dish/socket.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*
*
* $Log: socket.c,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.0 89/11/23 22:36:06 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.
*
*/
#include <stdio.h>
#include "quipu/util.h"
#include "tailor.h"
#include "general.h"
#ifdef SOCKETS /* USE INTERNET SOCKETS */
#include "internet.h"
get_dish_sock (isock, pid)
struct sockaddr_in *isock;
int pid;
{
int myppid;
char * getenv ();
char * ptr, * prnt;
static char buffer [BUFSIZ];
static char parent [BUFSIZ];
int portno;
char *dp;
register struct hostent *hp;
if ((myppid = pid) == 0)
myppid = getppid ();
if (pid != 0 || (ptr = getenv ("DISHPROC")) == NULLCP) {
#ifdef notanymore
char *cp;
#endif
portno = (myppid & 0xffff) | 0x8000;
#ifdef notanymore
if ((hp = gethostbystring (cp = getlocalhost ())) == NULL) {
(void) fprintf (stderr,"%s: unknown host", cp);
return (-1);
}
(void) sprintf (buffer, "%s %d",
inet_ntoa (*(struct in_addr *) hp -> h_addr),
portno);
#else
(void) sprintf (buffer, "127.0.0.1 %d", portno);
#endif
(void) setenv ("DISHPROC", ptr = buffer);
}
if (pid !=0 || (prnt = getenv ("DISHPARENT")) == NULLCP) {
(void) sprintf (parent, "%d", myppid);
(void) setenv ("DISHPARENT", prnt = parent);
}
if (sscanf (prnt, "%d", &pid) != 1) {
(void) fprintf (stderr,"DISHPARENT malformed");
return (-1);
}
if ((dp = index (ptr, ' ')) == NULLCP || sscanf (dp + 1, "%d", &portno) != 1) {
(void) fprintf (stderr,"DISHPROC malformed");
return (-1);
}
*dp = NULL;
if ((hp = gethostbystring (ptr)) == NULL) {
(void) fprintf (stderr,"%s: unknown host in DISHPROC", ptr);
return (-1);
}
*dp = ' ';
bzero ((char *) isock, sizeof *isock);
isock -> sin_family = hp -> h_addrtype;
isock -> sin_port = htons ((u_short) portno);
inaddr_copy (hp, isock);
return (0);
}
#else /* USE UNIX NAMED PIPES */
void dummy ()
{
;
}
#endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.