libosip
5.3.0
include
osip2
osip_time.h
1
/*
2
The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3
Copyright (C) 2001-2020 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
/* Operations on struct timeval */
47
#if !defined(timerisset)
48
#define osip_timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
49
#else
50
#define osip_timerisset(tvp) timerisset(tvp)
51
#endif
52
53
#if !defined(timercmp)
54
#define osip_timercmp(a, b, CMP) (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_usec CMP(b)->tv_usec) : ((a)->tv_sec CMP(b)->tv_sec))
55
#else
56
#define osip_timercmp(tvp, uvp, cmp) timercmp(tvp, uvp, cmp)
57
#endif
58
59
#if !defined(timerclear)
60
#define osip_timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
61
#else
62
#define osip_timerclear(tvp) timerclear(tvp)
63
#endif
64
65
#if !defined(timersub)
66
#define osip_timersub(a, b, result) \
67
do { \
68
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
69
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
70
if ((result)->tv_usec < 0) { \
71
--(result)->tv_sec; \
72
(result)->tv_usec += 1000000; \
73
} \
74
} while (0)
75
#else
76
#define osip_timersub(a, b, result) timersub(a, b, result)
77
#endif
78
79
int
osip_gettimeofday(
struct
timeval *tp,
void
*tz);
80
time_t osip_getsystemtime(time_t *t);
81
void
osip_compensatetime(
void
);
82
83
#ifdef __cplusplus
84
}
85
#endif
86
#endif
Generated on Sun Feb 27 2022 11:19:30 for libosip by
1.9.1