|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T a
Length: 2245 (0x8c5)
Types: TextFile
Names: »asx.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
└─⟦697af93db⟧ »EurOpenD3/network/snmp/mit-snmp.tar.Z«
└─⟦57bbcbe75⟧
└─⟦this⟧ »./snmp/asx.c«
/*
* $Header: asx.c,v 1.1 89/01/11 22:09:11 jrd Exp $
* Author: J. Davin
* Copyright 1988, 1989, Massachusetts Institute of Technology
* See permission and disclaimer notice in file "notice.h"
*/
#include <notice.h>
#include <ctypes.h>
#include <debug.h>
#include <asn.h>
#include <asx.h>
#define asxBufSize (512)
CVoidType asxInit ()
{
}
static CUnsfType asxTab (level)
CUnsfType level;
{
while (level-- != 0) {
printf ("\t");
}
return (level);
}
CBytePtrType asxTypeToLabel (type)
AsnTypeType type;
{
char *result;
switch (type) {
case asnTypeInteger:
result = "INTEGER";
break;
case asnTypeOctetString:
result = "OCTETSTRING";
break;
case asnTypeObjectId:
result = "OBJECTIDENTIFIER";
break;
case asnTypeNull:
result = "NULL";
break;
case asnTypeSequence:
result = "SEQUENCE";
break;
case asnTypeSequenceOf:
result = "SEQUENCE OF";
break;
default:
result = "??";
break;
}
return ((CBytePtrType) result);
}
AsxStatusType asxPrint (asn, level)
AsnIdType asn;
CUnsfType level;
{
if (asn == (AsnIdType) 0) {
return (errOk);
}
(void) asxTab (level);
printf ("[ ");
switch (asnClass (asn)) {
case asnClassUniversal:
printf ("U");
break;
case asnClassContext:
printf ("C");
break;
case asnClassApplication:
printf ("A");
break;
case asnClassPrivate:
printf ("P");
break;
default:
printf ("?");
break;
}
printf (" %d ] %s {\n", asnTag (asn),
asxTypeToLabel (asnType (asn)));
switch (asnType (asn)) {
case asnTypeInteger:
case asnTypeOctetString:
case asnTypeObjectId:
{
CByteType buf [ asxBufSize ];
CBytePtrType cp;
AsnLengthType n;
cp = buf;
(void) asxTab (level + 1);
for (n = asnContents (asn, buf, asxBufSize); n > 0;
n--) {
printf (" %02.02X", *cp++);
}
printf ("\n");
}
break;
case asnTypeSequence:
case asnTypeSequenceOf:
{
AsnIndexType i;
AsnIdType item;
item = (AsnIdType) 0;
for (i = 1; i <= asnSons (asn);
i += (asnSons (item) + 1)) {
item = asnFree (item);
item = asnComponent (asn, i);
(void) asxPrint (item, level + 1);
}
}
break;
default:
break;
}
(void) asxTab (level);
printf ("}\n");
return (errOk);
}