|
|
1.1 ! root 1: /* isoservent.c - look-up ISODE services */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/compat/RCS/isoservent.c,v 7.0 89/11/23 21:23:11 mrose Rel $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/compat/RCS/isoservent.c,v 7.0 89/11/23 21:23:11 mrose Rel $ ! 9: * ! 10: * ! 11: * $Log: isoservent.c,v $ ! 12: * Revision 7.0 89/11/23 21:23:11 mrose ! 13: * Release 6.0 ! 14: * ! 15: */ ! 16: ! 17: /* ! 18: * NOTICE ! 19: * ! 20: * Acquisition, use, and distribution of this module and related ! 21: * materials are subject to the restrictions of a license agreement. ! 22: * Consult the Preface in the User's Manual for the full terms of ! 23: * this agreement. ! 24: * ! 25: */ ! 26: ! 27: ! 28: /* LINTLIBRARY */ ! 29: ! 30: #include <ctype.h> ! 31: #include <stdio.h> ! 32: #include "general.h" ! 33: #include "manifest.h" ! 34: #include "isoservent.h" ! 35: #include "tailor.h" ! 36: ! 37: /* DATA */ ! 38: ! 39: static char *isoservices = "isoservices"; ! 40: ! 41: static FILE *servf = NULL; ! 42: static int stayopen = 0; ! 43: ! 44: static struct isoservent iss; ! 45: ! 46: /* */ ! 47: ! 48: int setisoservent (f) ! 49: int f; ! 50: { ! 51: if (servf == NULL) ! 52: servf = fopen (isodefile (isoservices, 0), "r"); ! 53: else ! 54: rewind (servf); ! 55: stayopen |= f; ! 56: ! 57: return (servf != NULL); ! 58: } ! 59: ! 60: ! 61: int endisoservent () { ! 62: if (servf && !stayopen) { ! 63: (void) fclose (servf); ! 64: servf = NULL; ! 65: } ! 66: ! 67: return 1; ! 68: } ! 69: ! 70: /* */ ! 71: ! 72: struct isoservent *getisoservent () { ! 73: int mask, ! 74: vecp; ! 75: register char *cp; ! 76: register struct isoservent *is = &iss; ! 77: static char buffer[BUFSIZ + 1], ! 78: file[BUFSIZ]; ! 79: static char *vec[NVEC + NSLACK + 1]; ! 80: ! 81: if (servf == NULL ! 82: && (servf = fopen (isodefile (isoservices, 0), "r")) == NULL) ! 83: return NULL; ! 84: ! 85: bzero ((char *) is, sizeof *is); ! 86: ! 87: while (fgets (buffer, sizeof buffer, servf) != NULL) { ! 88: if (*buffer == '#') ! 89: continue; ! 90: if (cp = index (buffer, '\n')) ! 91: *cp = NULL; ! 92: if ((vecp = str2vecX (buffer, vec, 1 + 1, &mask, NULL)) < 3) ! 93: continue; ! 94: ! 95: if ((cp = index (vec[0], '/')) == NULL) ! 96: continue; ! 97: *cp++ = NULL; ! 98: ! 99: is -> is_provider = vec[0]; ! 100: is -> is_entity = cp; ! 101: is -> is_selectlen = str2sel (vec[1], (mask & (1 << 1)) ? 1 : 0, ! 102: is -> is_selector, ISSIZE); ! 103: ! 104: is -> is_vec = vec + 2; ! 105: is -> is_tail = vec + vecp; ! 106: ! 107: if (strcmp (cp = is -> is_vec[0], "tsapd-bootstrap")) ! 108: (void) strcpy (is -> is_vec[0] = file, isodefile (cp, 1)); ! 109: ! 110: return is; ! 111: } ! 112: ! 113: return NULL; ! 114: } ! 115: ! 116: /* */ ! 117: ! 118: #ifdef DEBUG ! 119: _printsrv (is) ! 120: register struct isoservent *is; ! 121: { ! 122: register int n = is -> is_tail - is -> is_vec - 1; ! 123: register char **ap = is -> is_vec; ! 124: ! 125: LLOG (addr_log, LLOG_DEBUG, ! 126: ("\tENT: \"%s\" PRV: \"%s\" SEL: %s", ! 127: is -> is_entity, is -> is_provider, ! 128: sel2str (is -> is_selector, is -> is_selectlen, 1))); ! 129: ! 130: for (; n >= 0; ap++, n--) ! 131: LLOG (addr_log, LLOG_DEBUG, ! 132: ("\t\t%d: \"%s\"\n", ap - is -> is_vec, *ap)); ! 133: } ! 134: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.