DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T a

⟦c7dc7877e⟧ TextFile

    Length: 4512 (0x11a0)
    Types: TextFile
    Names: »acsaptest.c«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/acsap/acsaptest.c« 

TextFile

/* acsaptest.c - test out -lacsap */

#ifndef	lint
static char *rcsid = "$Header: /f/osi/acsap/RCS/acsaptest.c,v 6.0 89/03/18 23:24:28 mrose Rel $";
#endif

/* 
 * $Header: /f/osi/acsap/RCS/acsaptest.c,v 6.0 89/03/18 23:24:28 mrose Rel $
 *
 *
 * $Log:	acsaptest.c,v $
 * Revision 6.0  89/03/18  23:24:28  mrose
 * Release 5.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>
#define	ACSE
#include "acpkt.h"
#include "isoservent.h"
#include "tailor.h"


#define	NULLIE	((struct isoentity *) 0)


struct TSAPaddr *ta2norm ();

/* \f

 */

/* ARGSUSED */

main (argc, argv, envp)
int	argc;
char  **argv,
      **envp;
{
    register struct isoentity  *ie;
    register struct isobject  *io;
    register struct isoservent  *is;

    isodetailor (argv[0], 1);
    
    argc--, argv++;
    if (argc == 1) {
	if (strcmp (*argv, "version") == 0)
	    printf ("%s\n", acsapversion);
	else {
	    register struct PSAPaddr *pa;

	    if (!(pa = str2paddr (*argv)))
		goto you_lose;
	    printent (NULLIE, NULLAEI, pa);
	}

	exit (0);
    }

    if (argc == 2) {
	AEI	aei;
	struct PSAPaddr *pa;

	if (!(aei = str2aei (argv[0], argv[1])))
	    goto you_lose;
	printent (NULLIE, aei, NULLPA);

	if (!(pa = aei2addr (aei))) {
	    fprintf (stderr, "address translation failed\n");
	    exit (1);
	}

	printent (NULLIE, NULLAEI, pa);
    }
    else {
	printf ("ISO Entities Database\n");
	while (ie = getisoentity ())
	    printent (ie, oid2aei (&ie -> ie_identifier), &ie -> ie_addr);

	printf ("\nISO Objects Database\n");
	while (io = getisobject ())
	    printobj (io);

	printf ("\nISO Services Database\n");
	while (is = getisoservent ())
	    printsrv (is);
    }

    exit (0);			/* NOTREACHED */

you_lose: ;
    fprintf (stderr, "no such luck\n");
    exit (1);			/* NOTREACHED */
}

/* \f

 */

static	printent (ie, aei, pa)
register struct isoentity  *ie;
AEI	aei;
register struct PSAPaddr *pa;
{
    if (ie)
	printf ("Entity:  %s (%s)\n", ie -> ie_descriptor,
		oid2ode (&ie -> ie_identifier));

    if (aei)
	printf ("AE info: %s\n", sprintaei (aei));

    if (pa) {
	register int n;
	struct PSAPaddr pas;
	register struct TSAPaddr *ta = &pa -> pa_addr.sa_addr;
	register struct NSAPaddr *na;
	PE	    pe;

	printf ("Address: %s\n", paddr2str (pa, NULLNA));

	pe = NULLPE;
	for (na = ta -> ta_addrs, n = ta -> ta_naddr - 1; n >= 0; na++, n--)
	    if (na -> na_type == NA_TCP) {
#include "internet.h"

		register struct hostent *hp;

		if ((hp = gethostbystring (na -> na_domain)) == NULL)
		    goto dont_touch;

#define	s2a(b)	(((int) (b)) & 0xff)
		bzero (na -> na_domain, sizeof na -> na_domain);
		(void) sprintf (na -> na_domain, "%d.%d.%d.%d",
				s2a (hp -> h_addr[0]),
				s2a (hp -> h_addr[1]),
				s2a (hp -> h_addr[2]),
				s2a (hp -> h_addr[3]));
#undef	s2a
	    }

	if (build_DSE_PSAPaddr (&pe, 1, NULL, NULLCP, (char *) pa) == NOTOK) {
	    printf ("build of PSAPaddr failed: %s\n", PY_pepy);
	    goto dont_touch;
	}

	bzero ((char *) &pas, sizeof pas);
	if (parse_DSE_PSAPaddr (pe, 1, NULLIP, NULLVP, (char *) &pas) ==NOTOK){
	    printf ("parse of PSAPaddr failed: %s\n", PY_pepy);
	    goto dont_touch;
	}

	(void) print_DSE_PSAPaddr (pe, 1, NULLIP, NULLVP, NULLCP);

	if (bcmp ((char *) pa, (char *) &pas, sizeof pas)) {
	    printf ("*** NOT EQUAL ***\n");
	    printf ("\told %s\n", paddr2str (pa, NULLNA));
	    printf ("\tnew %s\n", paddr2str (&pas, NULLNA));
	}

dont_touch: ;
	if (pe)
	    pe_free (pe);

	{
	    struct TSAPaddr *tz = ta2norm (ta);

	    if (ta) {
		if (bcmp ((char *) ta, (char *) tz, sizeof *tz))
		    printf ("NORM:    %s\n", taddr2str (tz));
	    }
	    else
		printf ("*** ta2norm FAILED ***\n");
	}

    }

    if (ie || aei || pa)
	printf ("\n");
}

/* \f

 */

static	printobj (io)
register struct isobject *io;
{
    printf ("ODE: \"%s\"\nOID: %s\n\n", io -> io_descriptor,
	    sprintoid (&io -> io_identity));
}

/* \f

 */

static	printsrv (is)
register struct isoservent *is;
{
    register int    n = is -> is_tail - is -> is_vec - 1;
    register char **ap = is -> is_vec;

    printf ("ENT: \"%s\" PRV: \"%s\" SEL: %s\n",
	    is -> is_entity, is -> is_provider,
	    sel2str (is -> is_selector, is -> is_selectlen, 1));

    for (; n >= 0; ap++, n--)
	printf ("\t%d: \"%s\"\n", ap - is -> is_vec, *ap);
    printf ("\n");
}