ba.h (550B)
1 #ifndef BA_H 2 #define BA_H 3 4 #include <stdlib.h> 5 #include <string.h> 6 #include <stdio.h> 7 #include <stdint.h> 8 #include <ctype.h> 9 10 /* primitive variable length byte array to simplify working with hex strings */ 11 12 typedef struct { 13 size_t len; 14 uint8_t *val; 15 } ba; 16 17 ba* ba_from_hex(char *hex); 18 ba* ba_from_hex_n(char *hex, unsigned int n); 19 ba* ba_from_string(char *s); 20 void ba_fprint(ba *b, FILE *stream, int prec); 21 void ba_fprint_ascii(ba *b, FILE *stream, int prec); 22 void ba_xor(ba *a, ba *b); 23 int ba_copy(ba *dst, ba *src); 24 void ba_free(ba *b); 25 26 #endif