|
|
1.1 ! root 1: /* sel2str.c - selector to string */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/compat/RCS/sel2str.c,v 7.0 89/11/23 21:23:23 mrose Rel $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/compat/RCS/sel2str.c,v 7.0 89/11/23 21:23:23 mrose Rel $ ! 9: * ! 10: * ! 11: * $Log: sel2str.c,v $ ! 12: * Revision 7.0 89/11/23 21:23:23 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 "isoaddrs.h" ! 35: ! 36: /* */ ! 37: ! 38: char *sel2str (sel, len, quoted) ! 39: char *sel; ! 40: int len, ! 41: quoted; ! 42: { ! 43: register char *cp, ! 44: *dp, ! 45: *ep; ! 46: static int i = 0; ! 47: static char buf1[NASIZE * 2 + 1], ! 48: buf2[NASIZE * 2 + 1], ! 49: buf3[NASIZE * 2 + 1], ! 50: buf4[NASIZE * 2 + 1]; ! 51: static char *bufs[] = { buf1, buf2, buf3, buf4 }; ! 52: ! 53: cp = bufs[i++]; ! 54: i = i % 4; ! 55: ! 56: if (quoted) { ! 57: #ifndef NOGOSIP ! 58: if (len == 2) { ! 59: if (quoted < 0) ! 60: goto ugly; ! 61: (void) sprintf (cp, "#%d", ! 62: (sel[0] & 0xff) << 8 | (sel[1] & 0xff)); ! 63: goto out; ! 64: } ! 65: #endif ! 66: ! 67: for (ep = (dp = sel) + len; dp < ep; dp++) ! 68: if (!isprint (*dp)) ! 69: goto ugly; ! 70: ! 71: if (len > NASIZE * 2) ! 72: len = NASIZE * 2; ! 73: ! 74: (void) sprintf (cp, len ? "\"%*.*s\"" : "\"\"", len, len, sel); ! 75: } ! 76: else { ! 77: ugly: ; ! 78: if (len > NASIZE) /* XXX */ ! 79: len = NASIZE; ! 80: ! 81: cp[explode (cp, (u_char *) sel, len)] = NULL; ! 82: } ! 83: #ifndef NOGOSIP ! 84: out: ; ! 85: #endif ! 86: ! 87: return cp; ! 88: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.