osip_time.h

00001 /*
00002   The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
00003   Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Aymeric MOIZARD jack@atosc.org
00004   
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _OSIP_TIME_H_
00021 #define _OSIP_TIME_H_
00022 
00023 #ifdef __cplusplus
00024 extern "C"
00025 {
00026 #endif
00027 
00028 /* Common time-related functions and data types */
00029 
00030 #if defined(_WIN32_WCE)
00031 struct _timeb {
00032   time_t time;
00033   unsigned short millitm;
00034   short timezone;
00035   short dstflag;
00036 };
00037 
00038 #endif
00039 
00040 /* struct timeval, as defined in <sys/time.h>, <winsock.h> or <winsock2.h> */
00041   struct timeval;
00042 
00043 /* Time manipulation functions */
00044   void add_gettimeofday (struct timeval *atv, int ms);
00045   void min_timercmp (struct timeval *tv1, struct timeval *tv2);
00046 
00047 /* OS-dependent */
00048 #if defined(WIN32) || defined(_WIN32_WCE) || defined (__VXWORKS_OS__) || defined(__arc__)
00049 /* Operations on struct timeval */
00050 #define osip_timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
00051 # define osip_timercmp(a, b, CMP)                          \
00052   (((a)->tv_sec == (b)->tv_sec) ?                          \
00053    ((a)->tv_usec CMP (b)->tv_usec) :                       \
00054    ((a)->tv_sec CMP (b)->tv_sec))
00055 #define osip_timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
00056 
00057 /* osip_gettimeofday() for Windows */
00058 #if defined(__arc__)
00059 #define osip_gettimeofday gettimeofday
00060 #else
00061   int osip_gettimeofday (struct timeval *tp, void *tz);
00062 #endif
00063 
00064 #else
00065 /* Operations on struct timeval */
00066 #define osip_timerisset(tvp)            timerisset(tvp)
00067 #define osip_timercmp(tvp, uvp, cmp)    timercmp(tvp,uvp,cmp)
00068 #define osip_timerclear(tvp)            timerclear(tvp)
00069 
00070 /* osip_gettimeofday() == gettimeofday() */
00071 #define osip_gettimeofday gettimeofday
00072 
00073 #endif
00074 
00075 #ifdef __cplusplus
00076 }
00077 #endif
00078 
00079 #endif

Generated on Wed Feb 13 01:03:29 2008 for libosip by  doxygen 1.5.4