Annotation of 43BSDReno/contrib/isode-beta/others/osilookup/osilookup.c, revision 1.1.1.1

1.1       root        1: /* osilookup.c - convert entry in /etc/osi.hosts to isoentities format */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/others/osilookup/RCS/osilookup.c,v 7.0 89/11/23 22:01:00 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/others/osilookup/RCS/osilookup.c,v 7.0 89/11/23 22:01:00 mrose Rel $
                      9:  *
                     10:  * Contributed by John A. Scott, the MITRE Corporation
                     11:  *
                     12:  * N.B.:       I whipped up this code quickly to fill a need I had.  I
                     13:  *             do not, it any way, shape, or form, warrant its output.
                     14:  *
                     15:  *
                     16:  * $Log:       osilookup.c,v $
                     17:  * Revision 7.0  89/11/23  22:01:00  mrose
                     18:  * Release 6.0
                     19:  * 
                     20:  */
                     21: 
                     22: /*
                     23:  *                               NOTICE
                     24:  *
                     25:  *    Acquisition, use, and distribution of this module and related
                     26:  *    materials are subject to the restrictions of a license agreement.
                     27:  *    Consult the Preface in the User's Manual for the full terms of
                     28:  *    this agreement.
                     29:  *
                     30:  */
                     31: 
                     32: 
                     33: #include "config.h"
                     34: #include <stdio.h>
                     35: #include <sys/types.h>
                     36: #include <sys/socket.h>
                     37: #ifndef        SUNLINK_6_0
                     38: #include <sys/ieee802.h>
                     39: #else
                     40: #include <net/if_ieee802.h>
                     41: #endif
                     42: #include <netosi/osi.h>
                     43: #include <netosi/osi_addr.h>
                     44: #include <sunosi/mapds_user.h>
                     45: 
                     46: /*  */
                     47: 
                     48: /* ARGSUSED */
                     49: 
                     50: main (argc, argv, envp)
                     51: int    argc;
                     52: char  **argv,
                     53:       **envp;
                     54: {
                     55:     int            len,
                     56:            paddr_type;
                     57:     char   *prefix,
                     58:           *service,
                     59:            buf[BUFSIZ],
                     60:            buf2[BUFSIZ];
                     61:     OSI_ADDR p_addr;
                     62: 
                     63:     if (argc < 2) {
                     64:        fprintf (stderr,"usage: %s host [service]\n", argv[0]);
                     65:        exit (0);
                     66:     }
                     67:     service = (argc > 2) ? argv[2] : "FTAM";
                     68: 
                     69:     /* SUNLink OSI directory lookup */
                     70:     mds_lookup (argv[1], service, &p_addr);
                     71: 
                     72:     /* SUNLink function to slice out SAP bytes from full address */
                     73:     paddr_type = 0;
                     74:     if ((len = osi_get_sap (&p_addr, buf, sizeof buf, OSI_NSAP, &paddr_type))
                     75:            <= 0) {
                     76:        fprintf (stderr, "no entry for %s %s\n", argv[1], service);
                     77:        exit (1);
                     78:     }
                     79: 
                     80:     buf2[explode (buf2, (u_char *) buf, len)]= NULL;
                     81:     switch (paddr_type) {
                     82:        case AF_NBS:
                     83:            prefix = "49";
                     84:            break;
                     85: 
                     86:        case AF_OSINET:
                     87:            prefix = "470004";
                     88:            break;
                     89: 
                     90:        default:
                     91:            prefix = "";
                     92:            break;
                     93:     }
                     94:     printf ("\t\t\t\tNS+%s%s\n\n", prefix, buf2);
                     95: 
                     96:     exit (0);
                     97: }
                     98: 
                     99: /* so we don't have to load libisode.a */
                    100: 
                    101: static char nib2hex[0x10] = {
                    102:     '0', '1', '2', '3', '4', '5', '6', '7',
                    103:     '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
                    104: };
                    105: 
                    106: 
                    107: static int  explode (a, b, n)
                    108: register char  *a;
                    109: register u_char *b;
                    110: register int    n;
                    111: {
                    112:     register int    i;
                    113:     register u_char c;
                    114: 
                    115:     for (i = 0; i < n; i++) {
                    116:        c = *b++;
                    117:        *a++ = nib2hex[(c & 0xf0) >> 4];
                    118:        *a++ = nib2hex[(c & 0x0f)];
                    119:     }
                    120:     *a = NULL;
                    121: 
                    122:     return (n * 2);
                    123: }

unix.superglobalmegacorp.com

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