Annotation of researchv9/X11/src/X.V11R1/lib/X/XLiHosts.c, revision 1.1

1.1     ! root        1: #include "copyright.h"
        !             2: 
        !             3: /* $Header: XLiHosts.c,v 11.12 87/08/06 16:45:02 newman Exp $ */
        !             4: /* Copyright    Massachusetts Institute of Technology    1986  */
        !             5: /* This can really be considered an os dependent routine */
        !             6: 
        !             7: #define NEED_REPLIES
        !             8: #include "Xlibint.h"
        !             9: /*
        !            10:  * can be freed using XFree.
        !            11:  */
        !            12: 
        !            13: XHostAddress *XListHosts (dpy, nhosts, enabled)
        !            14:     register Display *dpy;
        !            15:     int *nhosts;
        !            16:     Bool *enabled;
        !            17:     {
        !            18:     register XHostAddress *outbuf, *op;
        !            19:     xListHostsReply reply;
        !            20:     long nbytes;
        !            21:     unsigned char *buf, *bp;
        !            22:     register int i;
        !            23:     register xListHostsReq *req;
        !            24: 
        !            25:     LockDisplay(dpy);
        !            26:     GetReq (ListHosts, req);
        !            27:     
        !            28:     if (!_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
        !            29:        UnlockDisplay(dpy);
        !            30:        SyncHandle();
        !            31:        return (NULL);
        !            32:        }
        !            33: 
        !            34:     *enabled = reply.enabled;
        !            35:     *nhosts = reply.nHosts;
        !            36:     if (*nhosts == 0) {
        !            37:        UnlockDisplay(dpy);
        !            38:         SyncHandle();
        !            39:        return (NULL);
        !            40:        }
        !            41: 
        !            42:     nbytes = reply.length << 2;        /* compute number of bytes in reply */
        !            43:     op = outbuf = 
        !            44:        (XHostAddress *) Xmalloc (nbytes + *nhosts * sizeof (XHostAddress));
        !            45:     bp = buf = ((unsigned char  *)outbuf) + *nhosts * sizeof (XHostAddress);
        !            46: 
        !            47:     _XRead (dpy, buf, nbytes);
        !            48: 
        !            49:     for (i = 0; i < *nhosts; i++) {
        !            50:        op->family = ((xHostEntry *) bp)->family;
        !            51:        op->length =((xHostEntry *) bp)->length; 
        !            52:        op->address = (char *) (((xHostEntry *) bp) + 1);
        !            53:        bp += sizeof(xHostEntry) + (((op->length + 3) >> 2) << 2);
        !            54:        op++;
        !            55:        }
        !            56:        
        !            57: 
        !            58:     UnlockDisplay(dpy);
        !            59:     SyncHandle();
        !            60: 
        !            61:     return (outbuf);
        !            62:     }
        !            63: 
        !            64:     
        !            65: 
        !            66: 

unix.superglobalmegacorp.com

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