timeutil.c File Reference

Utility functions for time calculations. More...

#include <stdio.h>
#include "timeutil.h"

Include dependency graph for timeutil.c:


Functions

int timeutil_get_timeval_from_msec (int msec, struct timeval *tv)
int timeutil_interval_exceeded (struct timeval *start, struct timeval *interval)
int timeutil_intervals_runtime (struct timeval *start1, struct timeval *interval1, struct timeval *start2, struct timeval *interval2, struct timeval *diff)

Detailed Description


Function Documentation

int timeutil_get_timeval_from_msec ( int  msec,
struct timeval *  tv 
)

Fills a timeval structure for the given milliseconds value.

Parameters:
msec milliseconds
tv timeval structure
Returns:
0 on success or -1 if an error occured

int timeutil_interval_exceeded ( struct timeval *  start,
struct timeval *  interval 
)

Checks if a time interval is exceeded according to a given start time.

Parameters:
start start time
interval interval time
Returns:
1 if time interval is exceeded, else 0

int timeutil_intervals_runtime ( struct timeval *  start1,
struct timeval *  interval1,
struct timeval *  start2,
struct timeval *  interval2,
struct timeval *  diff 
)

Calculates the length of time until the first of two given intervals gets exceeded.

If both intervals are exceeded a time value of 0 is returned.

 Example:
                interval1
 start1 |------------------------|
                    interval2
     start2 |-----------------------|
                           diff
                    now |--------|
Parameters:
start1 start time 1
interval1 interval time 1
start2 start time 2
interval2 interval time 2
diff time until the first of two given intervals gets exceeded (return value)
Returns:
0 on success or -1 if an error occured


Generated on Mon Mar 29 01:39:32 2010 for Veronica by  doxygen 1.5.8