lcrzo_time(3)

NAME
lcrzo_time - lcrzo library : time

CONTENTS
/*    Laurent Constantin's network library (lcrzo)
                 lcrzo_time module
  Functions herein allow to measure time.
*/
/*-------------------------------------------------------------*/
/* definition of a lcrzo_time. You should not use its
   fields directly. */
typedef struct
{ lcrzo_uint32 sec;
  lcrzo_uint32 usec;  /* cannot be over 999999 */
} lcrzo_time;
typedef const lcrzo_time lcrzo_consttime;
/*-------------------------------------------------------------*/
/* Name : lcrzo_time_sleep_xsec
   Description :
     Wait for a number of seconds, milliseconds or microseconds.
     The waited time might be greater than user value.
   Input parameter(s) :
     sec : number of seconds to wait
     msec : number of milliseconds to wait
     usec : number of microseconds to wait
   Input/output parameter(s) :
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_sleep_sec(lcrzo_uint32 sec);
int lcrzo_time_sleep_msec(lcrzo_uint32 msec);
int lcrzo_time_sleep_usec(lcrzo_uint32 usec);
/*-------------------------------------------------------------*/
/* Name : lcrzo_time_pause_xsec
   Description :
     Wait for a number of seconds, milliseconds or microseconds.
     The waited time is wanted to be as precise as possible.
   Input parameter(s) :
     sec : number of seconds to wait
     msec : number of milliseconds to wait
     usec : number of microseconds to wait
   Input/output parameter(s) :
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_pause_sec(lcrzo_uint32 sec);
int lcrzo_time_pause_msec(lcrzo_uint32 msec);
int lcrzo_time_pause_usec(lcrzo_uint32 usec);
/*-------------------------------------------------------------*/
/* Name : lcrzo_time_fprint
   Description :
     Print a lcrzo_time.
   Input parameter(s) :
     *pf : FILE where the function prints
     startstring : string to print before the lcrzo_time
     *ptime : lcrzo_time to print
     endstring : string to print after the lcrzo_time
   Input/output parameter(s) :
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_fprint(LCRZOFILE *pf,
		      lcrzo_conststring startstring,
		      lcrzo_consttime *ptime,
		      lcrzo_conststring endstring);
/* idem, but on stdout */
#define lcrzo_time_print(s,t,e) lcrzo_time_fprint(stdout, s,t,e)
/*-------------------------------------------------------------*/
/* Name : lcrzo_time_init_currenttime
   Description :
     Initialize a lcrzo_time with the current time.
   Input parameter(s) :
   Input/output parameter(s) :
   Output parameter(s) :
     *ptime : lcrzo_time set to the current time
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_init_currenttime(lcrzo_time *ptime);
/* Name : lcrzo_time_init_sec
   Description :
     Initialize a lcrzo_time with a number of seconds.
   Input parameter(s) :
     sec : number of seconds
   Input/output parameter(s) :
   Output parameter(s) :
     *ptime : lcrzo_time set
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_init_sec(lcrzo_uint32 sec,
			lcrzo_time *ptime);
/* Name : lcrzo_time_init_msec
   Description :
     Initialize a lcrzo_time with a number of milliseconds.
   Input parameter(s) :
     usec : number of milliseconds
   Input/output parameter(s) :
   Output parameter(s) :
     *ptime : lcrzo_time set
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_init_msec(lcrzo_uint32 msec,
			 lcrzo_time *ptime);
/* Name : lcrzo_time_init_usec
   Description :
     Initialize a lcrzo_time with a number of micro-seconds.
   Input parameter(s) :
     usec : number of micro-seconds
   Input/output parameter(s) :
   Output parameter(s) :
     *ptime : lcrzo_time set
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_init_usec(lcrzo_uint32 usec,
			 lcrzo_time *ptime);
/* Name : lcrzo_time_init_secmsecusec
   Description :
     Initialize a lcrzo_time.
   Input parameter(s) :
     sec : number of seconds
     msec : number of milli-seconds
     usec : number of micro-seconds
   Input/output parameter(s) :
   Output parameter(s) :
     *ptime : lcrzo_time set
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_init_secusec(lcrzo_uint32 sec,
			    lcrzo_uint32 usec,
			    lcrzo_time *ptime);
int lcrzo_time_init_msecusec(lcrzo_uint32 msec,
			     lcrzo_uint32 usec,
			     lcrzo_time *ptime);
int lcrzo_time_init_secmsec(lcrzo_uint32 sec,
			    lcrzo_uint32 msec,
			    lcrzo_time *ptime);
int lcrzo_time_init_secmsecusec(lcrzo_uint32 sec,
				lcrzo_uint32 msec,
				lcrzo_uint32 usec,
				lcrzo_time *ptime);
/* initialize another lcrzo_time */
int lcrzo_time_init_time(lcrzo_consttime *ptimein,
			 lcrzo_time *ptimeout);
/* get seconds, milliseconds and microseconds stored in a lcrzo_time */
/*  function              obtained ranges */
/*
    lcrzo_time_get_sec          [0..2^32]
    lcrzo_time_get_msec         [0..2^32]
    lcrzo_time_get_usec         [0..2^32]
    lcrzo_time_get_secusec      [0..2^32], [0-999999]
    lcrzo_time_get_secmsec      [0..2^32], [0-999]
    lcrzo_time_get_msecusec     [0..2^32], [0-999]
    lcrzo_time_get_secmsecusec  [0..2^32], [0-999], [0-999]
*/
int lcrzo_time_get_sec(lcrzo_consttime *ptime,
		       lcrzo_uint32 *psec);
int lcrzo_time_get_msec(lcrzo_consttime *ptime,
			lcrzo_uint32 *pmsec);
int lcrzo_time_get_usec(lcrzo_consttime *ptime,
			lcrzo_uint32 *pusec);
int lcrzo_time_get_secusec(lcrzo_consttime *ptime,
			   lcrzo_uint32 *psec,
			   lcrzo_uint32 *pusec);
int lcrzo_time_get_secmsec(lcrzo_consttime *ptime,
			   lcrzo_uint32 *psec,
			   lcrzo_uint32 *pmsec);
int lcrzo_time_get_msecusec(lcrzo_consttime *ptime,
			    lcrzo_uint32 *pmsec,
			    lcrzo_uint32 *pusec);
int lcrzo_time_get_secmsecusec(lcrzo_consttime *ptime,
			       lcrzo_uint32 *psec,
			       lcrzo_uint32 *pmsec,
			       lcrzo_uint32 *pusec);
/* add seconds/milliseconds/microseconds/time to a lcrzo_time */
int lcrzo_time_plus_sec(lcrzo_consttime *ptime,
			lcrzo_uint32 sec,
			lcrzo_time *presulttime);
int lcrzo_time_plus_msec(lcrzo_consttime *ptime,
			 lcrzo_uint32 msec,
			 lcrzo_time *presulttime);
int lcrzo_time_plus_usec(lcrzo_consttime *ptime,
			 lcrzo_uint32 usec,
			 lcrzo_time *presulttime);
/* *ppresulttime = *ptime1 + *ptime2 */
int lcrzo_time_plus_time(lcrzo_consttime *ptime1,
			 lcrzo_consttime *ptime2,
			 lcrzo_time *presulttime);
/* substract seconds/milliseconds/microseconds/time to a lcrzo_time */
int lcrzo_time_minus_sec(lcrzo_consttime *ptime,
			 lcrzo_uint32 sec,
			 lcrzo_time *presulttime);
int lcrzo_time_minus_msec(lcrzo_consttime *ptime,
			  lcrzo_uint32 msec,
			  lcrzo_time *presulttime);
int lcrzo_time_minus_usec(lcrzo_consttime *ptime,
			  lcrzo_uint32 usec,
			  lcrzo_time *presulttime);
/* *ppresulttime = *ptime1 - *ptime2 */
int lcrzo_time_minus_time(lcrzo_consttime *ptime1,
			  lcrzo_consttime *ptime2,
			  lcrzo_time *presulttime);
/*-------------------------------------------------------------*/
/* Name : lcrzo_time_diffcurrent_sec
   Description :
     Compare a lcrzo_time to the current time.
   Input parameter(s) :
     *ptime : lcrzo_time to compare to the current time
   Input/output parameter(s) :
   Output parameter(s) :
     *psec : number of seconds between the two times
   Normal return values :
     LCRZO_ERR_OK : ok
*/
/*  function              obtained ranges */
/*
lcrzo_time_get_sec          [0..2^32]
lcrzo_time_get_msec         [0..2^32]
lcrzo_time_get_usec         [0..2^32]
lcrzo_time_get_secusec      [0..2^32], [0-999999]
lcrzo_time_get_secmsec      [0..2^32], [0-999]
lcrzo_time_get_msecusec     [0..2^32], [0-999]
lcrzo_time_get_secmsecusec  [0..2^32], [0-999], [0-999]
*/
int lcrzo_time_diffcurrent_sec(lcrzo_consttime *ptime,
			       lcrzo_uint32 *psec);
int lcrzo_time_diffcurrent_msec(lcrzo_consttime *ptime,
				lcrzo_uint32 *pmsec);
int lcrzo_time_diffcurrent_usec(lcrzo_consttime *ptime,
				lcrzo_uint32 *pusec);
int lcrzo_time_diffcurrent_secusec(lcrzo_consttime *ptime,
				   lcrzo_uint32 *psec,
				   lcrzo_uint32 *pusec);
int lcrzo_time_diffcurrent_secmsec(lcrzo_consttime *ptime,
				   lcrzo_uint32 *psec,
				   lcrzo_uint32 *pmsec);
int lcrzo_time_diffcurrent_msecusec(lcrzo_consttime *ptime,
				    lcrzo_uint32 *pmsec,
				    lcrzo_uint32 *pusec);
int lcrzo_time_diffcurrent_secmsecusec(lcrzo_consttime *ptime,
				       lcrzo_uint32 *psec,
				       lcrzo_uint32 *pmsec,
				       lcrzo_uint32 *pusec);
/* Name : lcrzo_time_diffcurrent_time
   Description :
     Compare a lcrzo_time to the current time.
   Input parameter(s) :
     *ptime : lcrzo_time to compare to the current time
   Input/output parameter(s) :
   Output parameter(s) :
     *pdifftime : lcrzo_time containing the difference
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_time_diffcurrent_time(lcrzo_consttime *ptime,
				lcrzo_time *pdifftime);

SEE ALSO
lcrzo(3), lcrzo_types(3), lcrzo_data(3), lcrzo_string(3), lcrzo_time(3), lcrzo_file(3), lcrzo_address(3), lcrzo_device(3), lcrzo_list(3), lcrzo_process(3), lcrzo_ipc(3), lcrzo_header(3), lcrzo_ipopt(3), lcrzo_tcpopt(3), lcrzo_packet(3), lcrzo_icmp(3), lcrzo_print(3), lcrzo_record(3), lcrzo_conf(3), lcrzo_spoof(3), lcrzo_sniff(3), lcrzo_sock(3), lcrzo_wait(3), lcrzo_global(3), lcrzo_error(3) lcrzo_misc(3), lcrzo_obso(3),