Files
mars-tinyldap/fmt_asn1tagint.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

18 lines
307 B
C

#include "asn1.h"
size_t fmt_asn1tagint(char* dest,unsigned long l) {
size_t needed=((sizeof l)*7)/8,i;
for (i=1; i<needed; ++i)
if (!(l>>(i*7)))
break;
if (dest) {
size_t j=i;
while (j) {
--j;
*dest=((l>>(j*7))&0x7f) + (j?0x80:0);
++dest;
}
}
return i;
}