src/utils.h

00001 /***************************************************************************
00002  *            utils.h
00003  *
00004  *  Wed Feb 23 14:15:36 2005
00005  *  Copyright  2005  Simon Morlat
00006  *  Email simon.morlat@linphone.org
00007  ****************************************************************************/
00008 /*
00009   The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
00010   Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
00011 
00012   This library is free software; you can redistribute it and/or
00013   modify it under the terms of the GNU Lesser General Public
00014   License as published by the Free Software Foundation; either
00015   version 2.1 of the License, or (at your option) any later version.
00016 
00017   This library is distributed in the hope that it will be useful,
00018   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020   Lesser General Public License for more details.
00021 
00022   You should have received a copy of the GNU Lesser General Public
00023   License along with this library; if not, write to the Free Software
00024   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 */
00026 
00027 #ifndef UTILS_H
00028 #define UTILS_H
00029 
00030 #include "ortp/event.h"
00031 
00032 struct _OList {
00033         struct _OList *next;
00034         struct _OList *prev;
00035         void *data;
00036 };
00037 
00038 typedef struct _OList OList;
00039 
00040 
00041 #define o_list_next(elem) ((elem)->next)
00042 
00043 OList * o_list_append(OList *elem, void * data);
00044 OList * o_list_remove(OList *list, void *data);
00045 OList * o_list_free(OList *elem);
00046 
00047 #ifndef MIN
00048 #define MIN(a,b) (((a)>(b)) ? (b) : (a))
00049 #endif
00050 #ifndef MAX
00051 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
00052 #endif
00053 
00054 #define return_if_fail(expr) if (!(expr)) {printf("%s:%i- assertion"#expr "failed\n",__FILE__,__LINE__); return;}
00055 #define return_val_if_fail(expr,ret) if (!(expr)) {printf("%s:%i- assertion" #expr "failed\n",__FILE__,__LINE__); return (ret);}
00056 
00057 
00058 #define INT_TO_POINTER(truc)    ((long)(long)(truc))
00059 #define POINTER_TO_INT(truc)    ((int)(long)(truc))
00060 
00061 typedef struct _dwsplit_t{
00062 #ifdef ORTP_BIGENDIAN
00063         uint16_t hi;
00064         uint16_t lo;
00065 #else
00066         uint16_t lo;
00067         uint16_t hi;
00068 #endif
00069 } dwsplit_t;
00070 
00071 typedef union{
00072         dwsplit_t split;
00073         uint32_t one;
00074 } poly32_t;
00075 
00076 #ifdef ORTP_BIGENDIAN
00077 #define hton24(x) (x)
00078 #else
00079 #define hton24(x) ((( (x) & 0x00ff0000) >>16) | (( (x) & 0x000000ff) <<16) | ( (x) & 0x0000ff00) )
00080 #endif
00081 #define ntoh24(x) hton24(x)
00082 
00083 #if defined(WIN32) || defined(_WIN32_WCE)
00084 #define is_would_block_error(errnum)    (errnum==WSAEWOULDBLOCK)
00085 #else
00086 #define is_would_block_error(errnum)    (errnum==EWOULDBLOCK || errnum==EAGAIN)
00087 #endif
00088 
00089 void ortp_ev_queue_put(OrtpEvQueue *q, OrtpEvent *ev);
00090 
00091 #endif

Generated on Tue Feb 5 21:35:36 2008 for oRTP by  doxygen 1.5.4