Annotation of 43BSDReno/contrib/isode-beta/others/quipu/uips/dish/socket.c, revision 1.1.1.1

1.1       root        1: /* socket.c - dish -pipe support */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/others/quipu/uips/dish/RCS/socket.c,v 7.0 89/11/23 22:36:06 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/others/quipu/uips/dish/RCS/socket.c,v 7.0 89/11/23 22:36:06 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       socket.c,v $
                     12:  * Revision 7.0  89/11/23  22:36:06  mrose
                     13:  * Release 6.0
                     14:  * 
                     15:  */
                     16: 
                     17: /*
                     18:  *                               NOTICE
                     19:  *
                     20:  *    Acquisition, use, and distribution of this module and related
                     21:  *    materials are subject to the restrictions of a license agreement.
                     22:  *    Consult the Preface in the User's Manual for the full terms of
                     23:  *    this agreement.
                     24:  *
                     25:  */
                     26: 
                     27: 
                     28: #include <stdio.h>
                     29: #include "quipu/util.h"
                     30: #include "tailor.h"
                     31: #include "general.h"
                     32: 
                     33: #ifdef SOCKETS         /* USE INTERNET SOCKETS */
                     34: 
                     35: #include "internet.h"
                     36: 
                     37: get_dish_sock (isock, pid)
                     38: struct sockaddr_in *isock;
                     39: int    pid;
                     40: {
                     41:     int    myppid;
                     42: char * getenv ();
                     43: char * ptr, * prnt;
                     44: static char buffer [BUFSIZ];
                     45: static char parent [BUFSIZ];
                     46: int     portno;
                     47: char   *dp;
                     48: register struct hostent *hp;
                     49: 
                     50:        if ((myppid = pid) == 0)
                     51:            myppid = getppid ();
                     52: 
                     53:         if (pid != 0 || (ptr = getenv ("DISHPROC")) == NULLCP) {
                     54: #ifdef notanymore
                     55:                char    *cp;
                     56: #endif
                     57: 
                     58:                portno = (myppid & 0xffff) | 0x8000;
                     59: #ifdef notanymore
                     60:                if ((hp = gethostbystring (cp = getlocalhost ())) == NULL) {
                     61:                        (void) fprintf (stderr,"%s: unknown host", cp);
                     62:                        return (-1);
                     63:                }
                     64:                (void) sprintf (buffer, "%s %d",
                     65:                                inet_ntoa (*(struct in_addr *) hp -> h_addr),
                     66:                                portno);
                     67: #else
                     68:                (void) sprintf (buffer, "127.0.0.1 %d", portno);
                     69: #endif
                     70:                (void) setenv ("DISHPROC", ptr = buffer);
                     71:         } 
                     72: 
                     73:         if (pid !=0 || (prnt = getenv ("DISHPARENT")) == NULLCP) {
                     74:                (void) sprintf (parent, "%d", myppid);
                     75:                (void) setenv ("DISHPARENT", prnt = parent);
                     76:        }
                     77: 
                     78: 
                     79:        if (sscanf (prnt, "%d", &pid) != 1) {
                     80:                (void) fprintf (stderr,"DISHPARENT malformed");
                     81:                return (-1);
                     82:        }
                     83: 
                     84:        if ((dp = index (ptr, ' ')) == NULLCP || sscanf (dp + 1, "%d", &portno) != 1) {
                     85:                (void) fprintf (stderr,"DISHPROC malformed");
                     86:                return (-1);
                     87:        }
                     88:        *dp = NULL;
                     89: 
                     90:        if ((hp = gethostbystring (ptr)) == NULL) {
                     91:                (void) fprintf (stderr,"%s: unknown host in DISHPROC", ptr);
                     92:                return (-1);
                     93:        }
                     94:        *dp = ' ';
                     95: 
                     96:        bzero ((char *) isock, sizeof *isock);
                     97:        isock -> sin_family = hp -> h_addrtype;
                     98:        isock -> sin_port = htons ((u_short) portno);
                     99:        inaddr_copy (hp, isock);
                    100: 
                    101:        return (0);
                    102: 
                    103: }
                    104: 
                    105: #else  /* USE UNIX NAMED PIPES */
                    106: 
                    107: 
                    108: void dummy ()
                    109: {
                    110: ;
                    111: }
                    112: 
                    113: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.