/* vim: ts=8 sts=2 tw=60 * * General utility structure and function definitions */ #ifndef _UTILITY_H_ #define _UTILITY_H_ #include #ifdef __cplusplus #else #include #endif typedef unsigned long long uint64; /** * Text Buffer for accumulating text for input or output */ typedef struct buffer_t { /** length of text in the body of this buffer */ int length; /** the body of the text, null terminated string */ char body[65536]; } BUFFER, *pBUFFER; /** * Convert a time value to a string * * Makes a string version of the time for printing. Uses * only the time of day to produce a string in the format * HH:MM:SS.UUUUUU at microsecond resolution. * * Uses a circular set of internal static buffers allowing * several calls without overwriting - useful for * formatting multiple times in one print function call. * * \param tv pointer to a timeval structure or NULL for * current time * * \return address of the string given by str */ char* make_timestamp(const struct timeval* tv); double time_diff(struct timeval* later, struct timeval* earlier); int time_sub(struct timeval* later, struct timeval* earlier); int time_cmp(struct timeval* later, struct timeval* earlier); void time_adv(struct timeval* tmr, int msec); #if 1 int set_debug_level(int new_level); int dbg_printf(int level, const char* format, ...); #else #define dbg_printf fprintf #endif #endif