diff options
author | Simon Rettberg | 2014-03-15 01:49:50 +0100 |
---|---|---|
committer | Simon Rettberg | 2014-03-15 01:49:50 +0100 |
commit | bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad (patch) | |
tree | c7d1995a09f6ed0c4e6873252e957d72f5d07d07 /fmt_asn1tag.c | |
download | ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.tar.gz ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.tar.xz ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.zip |
Lean and mean initial commit
Not much functionality yet
Diffstat (limited to 'fmt_asn1tag.c')
-rw-r--r-- | fmt_asn1tag.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fmt_asn1tag.c b/fmt_asn1tag.c new file mode 100644 index 0000000..b2bd1a0 --- /dev/null +++ b/fmt_asn1tag.c @@ -0,0 +1,15 @@ +#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; +} |