|
|
BSD 4.3reno
/* pe.c - General PE utility routines */
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/dsap/common/pe.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif
/*
* $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/dsap/common/pe.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*
*
* $Log: pe.c,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.0 89/11/23 21:44:20 mrose
* Release 6.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
/* LINTLIBRARY */
#include "quipu/util.h"
#include "psap.h"
#include "quipu/attr.h" /* for defn of READOUT */
pe_print (ps, pe, format)
register PS ps;
register PE pe;
int format;
{
char * ptr;
register int i;
PS sps;
char * fmt;
if ( format == FILEOUT) {
(void) pe2ps (ps,pe);
return;
}
if ((sps = ps_alloc (str_open)) == NULLPS)
return;
if (str_setup (sps,NULLCP,LINESIZE,0) == NOTOK)
return;
if (format == READOUT)
fmt = "%02x ";
else {
ps_print (ps,"{ASN} ");
fmt = "%02x";
}
(void) pe2ps (sps,pe);
ptr = sps->ps_base;
for (i=0; i<sps->ps_byteno; i++)
ps_printf (ps,fmt,*ptr++ & 255);
ps_print (ps,"00");
ps_free (sps);
}
PE asn2pe (str)
char * str;
{
char * ptr;
char * pe_ptr;
register int i,j;
PS sps;
void StripSpace ();
int val;
PE pe;
StripSpace (str);
j = strlen (str);
pe_ptr = (char *) smalloc (j+10);
ptr = pe_ptr;
for ( i=0 ; i<j; i++) {
(void) sscanf (str,"%2x",&val);
*ptr++ = val & 0xff;
str++; str++;
}
if ((sps = ps_alloc (str_open)) == NULLPS)
return(NULLPE);
if (str_setup (sps,pe_ptr,j,1) == NOTOK)
return(NULLPE);
pe = ps2pe (sps);
ps_free (sps);
return (pe);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.