Files
sics/site_ansto/hardsup/Digital/utility.h
Douglas Clowes 4623b25ccd Progressive refinement
r1199 | dcl | 2006-10-26 18:38:34 +1000 (Thu, 26 Oct 2006) | 2 lines
2012-11-15 12:49:46 +11:00

56 lines
1.4 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>
#ifdef __cplusplus
#else
#include <stdbool.h>
#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