add functions to encode and decode variable length integers in binary
This commit is contained in:
parent
662cf55fc9
commit
ad6c2d9ce7
8
fmt.h
8
fmt.h
@ -4,6 +4,8 @@
|
||||
|
||||
/* for size_t: */
|
||||
#include <stddef.h>
|
||||
/* for uint32_t */
|
||||
#include <stdint.h>
|
||||
/* for time_t: */
|
||||
#include <sys/types.h>
|
||||
|
||||
@ -88,6 +90,12 @@ size_t fmt_humank(char* dest,unsigned long long l);
|
||||
/* "Sun, 06 Nov 1994 08:49:37 GMT" */
|
||||
size_t fmt_httpdate(char* dest,time_t t);
|
||||
|
||||
#define FMT_UTF8 5
|
||||
#define FMT_ASN1LENGTH 17 /* enough space to hold 2^128-1 */
|
||||
/* some variable length encodings for integers */
|
||||
size_t fmt_utf8(char* dest,uint32_t n); /* can store 0-0x7fffffff */
|
||||
size_t fmt_asn1derlength(char* dest,unsigned long long l);
|
||||
|
||||
/* internal functions, may be independently useful */
|
||||
char fmt_tohex(char c);
|
||||
|
||||
|
4
scan.h
4
scan.h
@ -73,6 +73,10 @@ size_t scan_noncharsetnskip(const char *in,const char *charset,size_t limit) __p
|
||||
*/
|
||||
size_t scan_httpdate(const char *in,time_t *t) __pure__;
|
||||
|
||||
/* some variable length encodings for integers */
|
||||
size_t scan_utf8(const char* in,size_t len,uint32_t* n) __pure__;
|
||||
size_t scan_asn1derlength(const char* in,size_t len,unsigned long long* n) __pure__;
|
||||
|
||||
/* a few internal function that might be useful independently */
|
||||
/* convert from hex ASCII, return 0 to 15 for success or -1 for failure */
|
||||
int scan_fromhex(unsigned char c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user