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

⟦fa3679a5a⟧ TextFile

    Length: 1931 (0x78b)
    Types: TextFile
    Names: »or_ps2asc.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« 
        └─⟦e5a54fb17⟧ 
            └─⟦this⟧ »pp-5.0/Lib/or/or_ps2asc.c« 

TextFile

/* or_ps2asc.c: convert printable string to ascii */

# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/or/RCS/or_ps2asc.c,v 5.0 90/09/20 16:08:33 pp Exp Locker: pp $";
# endif

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Lib/or/RCS/or_ps2asc.c,v 5.0 90/09/20 16:08:33 pp Exp Locker: pp $
 *
 * $Log:	or_ps2asc.c,v $
 * Revision 5.0  90/09/20  16:08:33  pp
 * rcsforce : 5.0 public release
 * 
 */



#include "util.h"


/*
Map printable string to ASCII
*/

void or_ps2asc (ps, ascii)
char    *ps;
char    *ascii;
{
    register char       *p, *q;
    int                 i;

    PP_DBG (("Lib/or_ps2asc('%s')", ps));

    p = ps;
    q = ascii;
    for (;*p != '\0';) {

	if (*p != '(')
		*q++ = *p++;
	else {
		if (*(p + 2) == ')') {
			switch (*(p + 1)) {
			    case 'a':
			    case 'A':
				*q++ = '@';
				break;
			    case 'p':
			    case 'P':
				*q++ = '%';
				break;
			    case 'b':
			    case 'B':
				*q++ = '!';
				break;
			    case 'q':
			    case 'Q':
				*q++ = '"';
				break;
			    case 'u':
			    case 'U':
				*q++ = '_';
				break;
			    case 'l':
			    case 'L':
				*q++ = '(';
				break;
			    case 'r':
			    case 'R':
				*q++ = ')';
				break;

			    default:
				PP_LOG (LLOG_EXCEPTIONS, 
					("Unknown Printable Char '%s'", ps));
				(void) strcpy (ascii, ps);
				return;
			}
			p = p + 3;
		}

		else {

			if (isdigit (*(p + 1)) && isdigit (*(p + 2))
			    && (*(p + 3)) && *(p + 4) == ')')
			{
				(void) sscanf (p + 1, "%3d", &i);
				p = p + 5;
			}
			else
			{
				PP_LOG (LLOG_EXCEPTIONS, 
					("Unkown digit '%s'", ps)); 
				(void) strcpy (ascii, ps);
				return;
			}


			if (i <= 0 || i >= 127) {
				PP_LOG (LLOG_EXCEPTIONS, 
					("Digit '%d' out of range '%s'", i, ps)); 
				(void) strcpy (ascii, ps);
				return;
			}

			*q++ = (char) i;

		}  /* end of if */

	}  /* end of if */

    }  /* end of for */

    *q = '\0';
}