libosip  4.1.0
osip_time.h
1 /*
2  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3  Copyright (C) 2001-2012 Aymeric MOIZARD amoizard@antisip.com
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 #ifndef _OSIP_TIME_H_
21 #define _OSIP_TIME_H_
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Common time-related functions and data types */
28 
29 #if defined(_WIN32_WCE)
30  struct _timeb {
31  time_t time;
32  unsigned short millitm;
33  short timezone;
34  short dstflag;
35  };
36 
37 #endif
38 
39 /* struct timeval, as defined in <sys/time.h>, <winsock.h> or <winsock2.h> */
40  struct timeval;
41 
42 /* Time manipulation functions */
43  void add_gettimeofday (struct timeval *atv, int ms);
44  void min_timercmp (struct timeval *tv1, struct timeval *tv2);
45 
46 /* OS-dependent */
47 #if defined(WIN32) || defined(_WIN32_WCE) || defined (__VXWORKS_OS__) || defined(__arc__)
48 /* Operations on struct timeval */
49 #define osip_timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
50 #define osip_timercmp(a, b, CMP) \
51  (((a)->tv_sec == (b)->tv_sec) ? \
52  ((a)->tv_usec CMP (b)->tv_usec) : \
53  ((a)->tv_sec CMP (b)->tv_sec))
54 #define osip_timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
55 
56 #else
57 /* Operations on struct timeval */
58 #define osip_timerisset(tvp) timerisset(tvp)
59 #define osip_timercmp(tvp, uvp, cmp) timercmp(tvp,uvp,cmp)
60 #define osip_timerclear(tvp) timerclear(tvp)
61 
62 #endif
63 
64  int osip_gettimeofday (struct timeval *tp, void *tz);
65  time_t osip_getsystemtime (time_t * t);
66  void osip_compensatetime (void);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 #endif