51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
/* vim: ts=8 sts=2 tw=60
|
|
*
|
|
* General utility structure and function definitions
|
|
*/
|
|
#ifndef _UTILITY_H_
|
|
#define _UTILITY_H_
|
|
|
|
#include <sys/time.h>
|
|
#include <stdbool.h>
|
|
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 dprintf(int level, const char* format, ...);
|
|
#else
|
|
#define dprintf fprintf
|
|
#endif
|
|
#endif
|