lsquic_util.h revision 7d09751d
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_util.h -- Utility functions 4 */ 5 6#ifndef LSQUIC_UTIL_H 7#define LSQUIC_UTIL_H 1 8 9#ifdef __cplusplus 10extern "C" { 11#endif 12 13lsquic_time_t 14lsquic_time_now (void); 15 16void 17lsquic_init_timers (void); 18 19/* Returns 1 if `buf' contains only zero bytes, 0 otherwise. 20 */ 21int 22lsquic_is_zero (const void *buf, size_t bufsz); 23 24 25 26char * get_bin_str(const void *s, size_t len, size_t max_display_len); 27 28size_t 29lsquic_hex_encode (const void *src, size_t src_sz, void *dst, size_t dst_sz); 30 31/* `out_sz' is assumed to be at least 1. `out' is always NUL-terminated. */ 32size_t 33lsquic_hexdump (const void *src, size_t src_sz, char *out, size_t out_sz); 34 35void 36lsquic_hexstr (const unsigned char *buf, size_t bufsz, char *out, size_t outsz); 37 38#define HEXSTR(buf, bufsz, out) \ 39 (lsquic_hexstr(buf, bufsz, out, sizeof(out)), out) 40 41#ifdef __cplusplus 42} 43#endif 44 45 46#endif 47