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 o

⟦5c7388d4f⟧ TextFile

    Length: 2541 (0x9ed)
    Types: TextFile
    Names: »osilookup.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« 
        └─⟦de7628f85⟧ 
            └─⟦this⟧ »isode-6.0/others/osilookup/osilookup.c« 

TextFile

/* osilookup.c - convert entry in /etc/osi.hosts to isoentities format */

#ifndef	lint
static char *rcsid = "$Header: /f/osi/others/osilookup/RCS/osilookup.c,v 7.0 89/11/23 22:01:00 mrose Rel $";
#endif

/* 
 * $Header: /f/osi/others/osilookup/RCS/osilookup.c,v 7.0 89/11/23 22:01:00 mrose Rel $
 *
 * Contributed by John A. Scott, the MITRE Corporation
 *
 * N.B.:	I whipped up this code quickly to fill a need I had.  I
 *		do not, it any way, shape, or form, warrant its output.
 *
 *
 * $Log:	osilookup.c,v $
 * Revision 7.0  89/11/23  22:01:00  mrose
 * Release 6.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 "config.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#ifndef	SUNLINK_6_0
#include <sys/ieee802.h>
#else
#include <net/if_ieee802.h>
#endif
#include <netosi/osi.h>
#include <netosi/osi_addr.h>
#include <sunosi/mapds_user.h>

/* \f

 */

/* ARGSUSED */

main (argc, argv, envp)
int	argc;
char  **argv,
      **envp;
{
    int	    len,
	    paddr_type;
    char   *prefix,
	   *service,
	    buf[BUFSIZ],
	    buf2[BUFSIZ];
    OSI_ADDR p_addr;

    if (argc < 2) {
	fprintf (stderr,"usage: %s host [service]\n", argv[0]);
	exit (0);
    }
    service = (argc > 2) ? argv[2] : "FTAM";

    /* SUNLink OSI directory lookup */
    mds_lookup (argv[1], service, &p_addr);

    /* SUNLink function to slice out SAP bytes from full address */
    paddr_type = 0;
    if ((len = osi_get_sap (&p_addr, buf, sizeof buf, OSI_NSAP, &paddr_type))
	    <= 0) {
	fprintf (stderr, "no entry for %s %s\n", argv[1], service);
	exit (1);
    }

    buf2[explode (buf2, (u_char *) buf, len)]= NULL;
    switch (paddr_type) {
	case AF_NBS:
	    prefix = "49";
	    break;

	case AF_OSINET:
	    prefix = "470004";
	    break;

	default:
	    prefix = "";
	    break;
    }
    printf ("\t\t\t\tNS+%s%s\n\n", prefix, buf2);

    exit (0);
}

/* so we don't have to load libisode.a */

static char nib2hex[0x10] = {
    '0', '1', '2', '3', '4', '5', '6', '7',
    '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};


static int  explode (a, b, n)
register char  *a;
register u_char *b;
register int    n;
{
    register int    i;
    register u_char c;

    for (i = 0; i < n; i++) {
	c = *b++;
	*a++ = nib2hex[(c & 0xf0) >> 4];
	*a++ = nib2hex[(c & 0x0f)];
    }
    *a = NULL;

    return (n * 2);
}