Annotation of 43BSDTahoe/new/xns/morexnslib/xnsbfs/bfsgetdoms.c, revision 1.1.1.1

1.1       root        1: /* $Header: bfsgetdoms.c,v 1.1 86/06/27 13:14:35 jqj Exp $ */
                      2: /* $Log:       bfsgetdoms.c,v $
                      3:  * Revision 1.1  86/06/27  13:14:35  jqj
                      4:  * Initial revision
                      5:  * 
                      6:  */
                      7:  
                      8: /* get domains served by a CHS server */
                      9: 
                     10: #include <stdio.h>
                     11: #include <sys/types.h>
                     12: #include <netns/ns.h>
                     13: #include <xnscourier/Clearinghouse2.h>
                     14: #include <xnscourier/except.h>
                     15: 
                     16: static Cardinal nullhash = 0;
                     17: static Clearinghouse2_Authenticator nullagent = {{0,{0,(Unspecified*)0}},
                     18:                                                 {1,&nullhash}};
                     19: FILE *outfile;
                     20: 
                     21: #define MAXPACKS 20
                     22: static
                     23: listproc(conn)
                     24:        CourierConnection *conn;
                     25: {
                     26:        int count, i;
                     27:        Unspecified buffer[MAXWORDS*MAXPACKS], *bp, *bufend;
                     28:        Clearinghouse2_StreamOfDomainName names;
                     29: 
                     30:        bufend = buffer;
                     31:        bp = buffer+((MAXWORDS-1)*MAXPACKS);    /* end of avail. space */
                     32:        while ((count = BDTread(conn, (char*)bufend,
                     33:                                MAXWORDS*sizeof(Unspecified))) > 0) {
                     34:                bufend += count/sizeof(Unspecified);
                     35:                if (bufend > bp) {
                     36:                        fprintf(stderr,"BDT read too big to fit\n");
                     37:                        BDTabort(conn);
                     38:                }
                     39:        }
                     40:        bp = buffer;
                     41:        while (bp < bufend) {
                     42:                bp += internalize_Clearinghouse2_StreamOfDomainName(&names,bp);
                     43:                if (0 == (int) names.designator) {
                     44:                    for (i=0; i < names.nextSegment_case.segment.length; i++) {
                     45:                        printout(names.nextSegment_case.segment.sequence[i]);
                     46:                    }
                     47:                    free(names.nextSegment_case.segment.sequence);
                     48:                } else {
                     49:                    for (i=0; i < names.lastSegment_case.length; i++) {
                     50:                        printout(names.lastSegment_case.sequence[i]);
                     51:                    }
                     52:                    free(names.lastSegment_case.sequence);
                     53:                    return;
                     54:                }
                     55:        }
                     56: }
                     57: 
                     58: static
                     59: printout(dname)
                     60:        Clearinghouse2_DomainName dname;
                     61: {
                     62:        /* print out a 2-part domain name */
                     63:        if (strcmp(dname.domain,"...") == 0 &&
                     64:            strcmp(dname.organization,"...") == 0)
                     65:                return;
                     66:        fprintf(outfile," \":%s:%s\"",dname.domain,dname.organization);
                     67: }
                     68: 
                     69: printdomains(sns)
                     70:        struct ns_addr sns;
                     71: {
                     72:        CourierConnection *ccon;
                     73:        extern char *ns_ntoa();
                     74: 
                     75:        sns.x_port = 0;
                     76:        ccon = CourierOpen(&sns);
                     77:        if (ccon == (CourierConnection *)NULL) return;
                     78:        fprintf(outfile,"%s", ns_ntoa(sns));
                     79:        DURING
                     80:                Clearinghouse2_ListDomainServed(ccon, listproc,
                     81:                                BulkData1_immediateSink, nullagent);
                     82:        HANDLER {
                     83:        } END_HANDLER;
                     84:        CourierClose(ccon);
                     85:        fprintf(outfile,"\n");
                     86: }

unix.superglobalmegacorp.com

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