summaryrefslogtreecommitdiffstats
path: root/fmt_asn1tagint.c
diff options
context:
space:
mode:
authorSimon Rettberg2014-03-15 01:49:50 +0100
committerSimon Rettberg2014-03-15 01:49:50 +0100
commitbedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad (patch)
treec7d1995a09f6ed0c4e6873252e957d72f5d07d07 /fmt_asn1tagint.c
downloadldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.tar.gz
ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.tar.xz
ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.zip
Lean and mean initial commit
Not much functionality yet
Diffstat (limited to 'fmt_asn1tagint.c')
-rw-r--r--fmt_asn1tagint.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/fmt_asn1tagint.c b/fmt_asn1tagint.c
new file mode 100644
index 0000000..338d7bf
--- /dev/null
+++ b/fmt_asn1tagint.c
@@ -0,0 +1,17 @@
+#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;
+}