#ifndef BLOB_H #define BLOB_H #include typedef struct blob { char *ptr; unsigned int len; } blob_t; #define blob_dyn(ptr,len) (blob_t){(void*)(ptr), (len)} #define blob_buf(buf) (blob_t){(void*)(buf), sizeof(buf)} #define blob_str(str) (blob_t){(char*)(str), strlen(str)} extern const blob_t BLOB_NULL;; static inline int blob_is_null(blob_t b) { return b.ptr == NULL; } char *blob_cstr_dup(blob_t b); blob_t blob_dup(blob_t b); int blob_cmp(blob_t a, blob_t b); blob_t blob_pushed(blob_t buffer, blob_t left); void blob_push(blob_t *b, blob_t d); void blob_push_int_str(blob_t *b, int val); void blob_push_hexdump(blob_t *to, blob_t binary); blob_t blob_pull(blob_t *b, int len); void blob_pull_skip(blob_t *b, int len); int blob_pull_matching(blob_t *b, blob_t e); #endif