Annotation of 43BSDReno/contrib/isode-beta/acsap/acsaptest.c, revision 1.1

1.1     ! root        1: /* acsaptest.c - test out -lacsap */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/acsap/RCS/acsaptest.c,v 7.3 90/07/27 08:41:44 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/acsap/RCS/acsaptest.c,v 7.3 90/07/27 08:41:44 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       acsaptest.c,v $
        !            12:  * Revision 7.3  90/07/27  08:41:44  mrose
        !            13:  * update
        !            14:  * 
        !            15:  * Revision 7.2  90/07/09  14:30:43  mrose
        !            16:  * sync
        !            17:  * 
        !            18:  * Revision 7.1  90/07/01  21:02:11  mrose
        !            19:  * pepsy
        !            20:  * 
        !            21:  * Revision 7.0  89/11/23  21:22:01  mrose
        !            22:  * Release 6.0
        !            23:  * 
        !            24:  */
        !            25: 
        !            26: /*
        !            27:  *                               NOTICE
        !            28:  *
        !            29:  *    Acquisition, use, and distribution of this module and related
        !            30:  *    materials are subject to the restrictions of a license agreement.
        !            31:  *    Consult the Preface in the User's Manual for the full terms of
        !            32:  *    this agreement.
        !            33:  *
        !            34:  */
        !            35: 
        !            36: 
        !            37: #include <stdio.h>
        !            38: #define        ACSE
        !            39: #include "acpkt.h"
        !            40: #include "isoservent.h"
        !            41: #include "tailor.h"
        !            42: #include "psap.h"
        !            43: #include "DSE-types.h"
        !            44: #include "UNIV-types.h"
        !            45: 
        !            46: 
        !            47: #define        NULLIE  ((struct isoentity *) 0)
        !            48: 
        !            49: 
        !            50: char   *macro2str ();
        !            51: struct TSAPaddr *ta2norm ();
        !            52: 
        !            53: /*  */
        !            54: 
        !            55: /* ARGSUSED */
        !            56: 
        !            57: main (argc, argv, envp)
        !            58: int    argc;
        !            59: char  **argv,
        !            60:       **envp;
        !            61: {
        !            62:     AEI            aei;
        !            63:     register struct PSAPaddr *pa;
        !            64:     register struct isoentity  *ie;
        !            65:     register struct isobject  *io;
        !            66:     register struct isoservent  *is;
        !            67: 
        !            68:     isodetailor (argv[0], 1);
        !            69:     
        !            70:     argc--, argv++;
        !            71:     switch (argc) {
        !            72:        case 1:
        !            73:            if (strcmp (*argv, "-version") == 0) {
        !            74:                printf ("%s\n", acsapversion);
        !            75:                break;
        !            76:            }
        !            77:            if (!(pa = str2paddr (*argv)))
        !            78:                goto you_lose;
        !            79:            printent (NULLIE, NULLAEI, pa);
        !            80:            break;
        !            81: 
        !            82:        case 2:
        !            83:        case 3:
        !            84:            if (strcmp (argv[0], "-macro") == 0) {
        !            85:                char   *cp;
        !            86: 
        !            87:                if ((cp  = macro2str (argv[1])) == NULL)
        !            88:                    goto you_lose;
        !            89:                printf ("%s\n", cp);
        !            90:                break;
        !            91:            }
        !            92: 
        !            93:            if (!(aei = _str2aei (argv[0], *argv[1] ? argv[1] : NULLCP,
        !            94:                                  argv[2], isatty (fileno (stdin))))) {
        !            95:                fprintf (stderr, "name translation failed: %s\n", PY_pepy);
        !            96:                goto you_lose;
        !            97:            }
        !            98:            printent (NULLIE, aei, NULLPA);
        !            99: 
        !           100:            if (!(pa = aei2addr (aei))) {
        !           101:                fprintf (stderr, "address translation failed\n");
        !           102:                goto you_lose;
        !           103:            }
        !           104:            printent (NULLIE, NULLAEI, pa);
        !           105:            break;
        !           106: 
        !           107:        default:
        !           108:            printf ("ISO Entities Database\n");
        !           109:            while (ie = getisoentity ())
        !           110:                printent (ie, oid2aei (&ie -> ie_identifier), &ie -> ie_addr);
        !           111: 
        !           112:            printf ("\nISO Objects Database\n");
        !           113:            while (io = getisobject ())
        !           114:                printobj (io);
        !           115: 
        !           116:            printf ("\nISO Services Database\n");
        !           117:            while (is = getisoservent ())
        !           118:                printsrv (is);
        !           119:            break;
        !           120:     }
        !           121: 
        !           122:     exit (0);                  /* NOTREACHED */
        !           123: 
        !           124: you_lose: ;
        !           125:     fprintf (stderr, "no such luck\n");
        !           126:     exit (1);                  /* NOTREACHED */
        !           127: }
        !           128: 
        !           129: /*  */
        !           130: 
        !           131: static printent (ie, aei, pa)
        !           132: register struct isoentity  *ie;
        !           133: AEI    aei;
        !           134: register struct PSAPaddr *pa;
        !           135: {
        !           136:     if (ie)
        !           137:        printf ("Entity:  %s (%s)\n", ie -> ie_descriptor,
        !           138:                oid2ode (&ie -> ie_identifier));
        !           139: 
        !           140:     if (aei)
        !           141:        printf ("AE info: %s\n", sprintaei (aei));
        !           142: 
        !           143:     if (pa) {
        !           144:        struct PSAPaddr pas;
        !           145:        register struct TSAPaddr *ta = &pa -> pa_addr.sa_addr;
        !           146:        PE          pe;
        !           147: 
        !           148:        printf ("Address: %s\n", paddr2str (pa, NULLNA));
        !           149: 
        !           150:        pe = NULLPE;
        !           151:        if (build_DSE_PSAPaddr (&pe, 1, NULL, NULLCP, (char *) pa) == NOTOK) {
        !           152:            printf ("build of PSAPaddr failed: %s\n", PY_pepy);
        !           153:            goto dont_touch;
        !           154:        }
        !           155: 
        !           156:        bzero ((char *) &pas, sizeof pas);
        !           157:        if (parse_DSE_PSAPaddr (pe, 1, NULLIP, NULLVP, (char *) &pas) ==NOTOK){
        !           158:            printf ("parse of PSAPaddr failed: %s\n", PY_pepy);
        !           159:            goto dont_touch;
        !           160:        }
        !           161: 
        !           162:        (void) print_DSE_PSAPaddr (pe, 1, NULLIP, NULLVP, NULLCP);
        !           163: 
        !           164:        if (bcmp ((char *) pa, (char *) &pas, sizeof pas)) {
        !           165:            printf ("*** NOT EQUAL ***\n");
        !           166:            printf ("\told %s\n", paddr2str (pa, NULLNA));
        !           167:            printf ("\tnew %s\n", paddr2str (&pas, NULLNA));
        !           168:        }
        !           169: 
        !           170: dont_touch: ;
        !           171:        if (pe)
        !           172:            pe_free (pe);
        !           173: 
        !           174:        {
        !           175:            struct TSAPaddr *tz = ta2norm (ta);
        !           176: 
        !           177:            if (tz) {
        !           178:                if (bcmp ((char *) ta, (char *) tz, sizeof *tz))
        !           179:                    printf ("NORM:    %s\n", taddr2str (tz));
        !           180:            }
        !           181:            else
        !           182:                printf ("*** ta2norm FAILED ***\n");
        !           183:        }
        !           184: 
        !           185:     }
        !           186: 
        !           187:     if (ie || aei || pa)
        !           188:        printf ("\n");
        !           189: }
        !           190: 
        !           191: /*  */
        !           192: 
        !           193: static printobj (io)
        !           194: register struct isobject *io;
        !           195: {
        !           196:     printf ("ODE: \"%s\"\nOID: %s\n\n", io -> io_descriptor,
        !           197:            sprintoid (&io -> io_identity));
        !           198: }
        !           199: 
        !           200: /*  */
        !           201: 
        !           202: static printsrv (is)
        !           203: register struct isoservent *is;
        !           204: {
        !           205:     register int    n = is -> is_tail - is -> is_vec - 1;
        !           206:     register char **ap = is -> is_vec;
        !           207: 
        !           208:     printf ("ENT: \"%s\" PRV: \"%s\" SEL: %s\n",
        !           209:            is -> is_entity, is -> is_provider,
        !           210:            sel2str (is -> is_selector, is -> is_selectlen, 1));
        !           211: 
        !           212:     for (; n >= 0; ap++, n--)
        !           213:        printf ("\t%d: \"%s\"\n", ap - is -> is_vec, *ap);
        !           214:     printf ("\n");
        !           215: }

unix.superglobalmegacorp.com

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