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

16 lines
426 B
C

#include "asn1.h"
/* write int in least amount of bytes, return number of bytes */
/* as used in ASN.1 tags */
size_t fmt_asn1tag(char* dest,enum asn1_tagclass tc,enum asn1_tagtype tt,unsigned long l) {
/* encoding is either l%128 or (0x1f,...) */
if (l<0x1f) {
if (dest) *dest=(int)tc+(int)tt+(l&0x1f);
return 1;
}
if (dest) {
*dest=(int)tc+(int)tt+0x1f; ++dest;
}
return fmt_asn1tagint(dest,l)+1;
}