| 1 |
/* sprt.c: */ |
| 2 |
#include <stdio.h> |
| 3 |
#include "xtdio.h" |
| 4 |
|
| 5 |
/* ------------------------------------------------------------------------- |
| 6 |
* Local Definitions: |
| 7 |
*/ |
| 8 |
#define BUFSIZE 261 |
| 9 |
#define SFTY 5 |
| 10 |
|
| 11 |
/* sprt: this routine makes string characters all visible */ |
| 12 |
#ifdef __PROTOTYPE__ |
| 13 |
char *sprt(const char *s) |
| 14 |
#else /* __PROTOTYPE__ */ |
| 15 |
char *sprt(s) |
| 16 |
char *s; |
| 17 |
#endif /* __PROTOTYPE__ */ |
| 18 |
{ |
| 19 |
static char buf1[BUFSIZE]; |
| 20 |
static char buf2[BUFSIZE]; |
| 21 |
static char buf3[BUFSIZE]; |
| 22 |
static char buf4[BUFSIZE]; |
| 23 |
char *b; |
| 24 |
char *bend; |
| 25 |
static char *buf = buf3; |
| 26 |
int ic; |
| 27 |
|
| 28 |
/* allows up to three sprt()s in one function call */ |
| 29 |
if(buf == buf1) buf= buf2; |
| 30 |
else if(buf == buf2) buf= buf3; |
| 31 |
else if(buf == buf3) buf= buf4; |
| 32 |
else buf= buf1; |
| 33 |
|
| 34 |
buf[0]= '\0'; |
| 35 |
bend = buf + BUFSIZE - SFTY; |
| 36 |
if(s) for(b= buf; *s && b < bend; ++s, b+= strlen(b)) { |
| 37 |
ic= (int) *s; |
| 38 |
if(ic < 31) sprintf(b,"^%c",(char) (ic + 64)); |
| 39 |
else if(ic >= 128) sprintf(b,"~%3d",ic); |
| 40 |
else { |
| 41 |
*b = *s; |
| 42 |
*(b+1)= '\0'; |
| 43 |
} |
| 44 |
b+= strlen(b); |
| 45 |
} |
| 46 |
return buf; |
| 47 |
} |
| 48 |
|
| 49 |
/* --------------------------------------------------------------------- */ |