Files
mars-tinyldap/fmt_asn1OID.c
leitner e04ca78ff8 add "generic" format string based encoder and decoder (scan_asn1generic,
fmt_asn1generic, see t10.c for example usage)
add "generic" asn.1 dumper (in t10.c)
fix some read off-by-one errors, minor cleanups
add real OID support
add bitstring support
2011-04-28 19:50:11 +00:00

17 lines
436 B
C

#include "asn1.h"
size_t fmt_asn1OID(char* dest,const unsigned long* array,unsigned long len) {
size_t i,l,l2;
if (len<2) return 0;
for (l=1,i=2; i<len; ++i) {
l+=fmt_asn1tagint(dest,array[i]);
}
l2=fmt_asn1transparent(dest,UNIVERSAL,PRIMITIVE,OBJECT_IDENTIFIER,l);
if (!dest) return l+l2;
dest[l2]=array[0]*40+array[1];
dest+=l2+1;
for (i=2; i<len; ++i)
dest+=fmt_asn1tagint(dest,array[i]);
return l+l2;
}