Objective Systems, Inc.  

ooCommon.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2009 by Objective Systems, Inc.
00003  *
00004  * This software is furnished under an open source license and may be
00005  * used and copied only in accordance with the terms of this license.
00006  * The text of the license may generally be found in the root
00007  * directory of this installation in the LICENSE.txt file.  It
00008  * can also be viewed online at the following URL:
00009  *
00010  *   http://www.obj-sys.com/open/license.html
00011  *
00012  * Any redistributions of this file including modified versions must
00013  * maintain this copyright notice.
00014  *
00015  *****************************************************************************/
00020 #ifndef _OOCOMMON_H_
00021 #define _OOCOMMON_H_
00022 
00023 #include <limits.h>
00024 #include <stdio.h>
00025 #include <string.h>
00026 #include <stdlib.h>
00027 
00028 #ifdef _WIN32_WCE
00029 #include <winsock.h>
00030 #elif defined(_WIN32) || defined(_WIN64)
00031 #include <sys/types.h>
00032 #define INCL_WINSOCK_API_TYPEDEFS   1
00033 #define INCL_WINSOCK_API_PROTOTYPES 0
00034 #include <winsock2.h>
00035 #else
00036 #include <sys/types.h>
00037 #include <sys/time.h>
00038 #include <sys/socket.h>
00039 #include <netinet/in.h>
00040 #include <netdb.h>
00041 #include <unistd.h>
00042 #include <arpa/inet.h>
00043 #endif
00044 
00050 /* Basic type definitions */
00051 
00052 typedef char            OOCHAR;
00053 typedef unsigned char   OOUCHAR;
00054 typedef signed char     OOINT8;
00055 typedef unsigned char   OOUINT8;
00056 typedef short           OOINT16;
00057 typedef unsigned short  OOUINT16;
00058 typedef int             OOINT32;
00059 typedef unsigned int    OOUINT32;
00060 typedef OOUINT8         OOBOOL;
00061 
00062 #define OOUINT32_MAX    4294967295U
00063 #define OOINT32_MAX     ((OOINT32)2147483647L)
00064 #define OOINT32_MIN     ((OOINT32)(-OOINT32_MAX-1))
00065 
00066 #ifndef FALSE
00067 #define FALSE           0
00068 #define TRUE            1
00069 #endif
00070 
00071 /* Common error codes */
00072 
00073 #define OOERRINVPARAM   (-50)   /* Invalid parameter    */
00074 #define OOERRBUFOVFLW   (-51)   /* Buffer overflow      */
00075 #define OOERRNOMEM      (-52)   /* No dynamic memory available */
00076 
00077 /* Message buffer: this is used for asynchronous transfers */
00078 
00079 typedef struct _OOMsgBuf {
00080    OOUINT8* pdata;      /* Pointer to binary or text data               */
00081    OOUINT32 bufsiz;     /* Size of the buffer in bytes                  */
00082    OOUINT32 length;     /* # bytes to send (write) or # received (read) */
00083    OOUINT32 offset;     /* Offset into buffer of first byte to send     */
00084    OOBOOL   dynamic;    /* pdata is dynamic (allocated with OOMEMALLOC) */
00085 } OOMsgBuf;
00086 
00087 /* Enumerated item descriptor */
00088 
00089 typedef struct OOEnumItem {
00090    const char* name;
00091    OOINT32     value;
00092    OOUINT16    namelen;
00093    OOUINT16    transidx;
00094 } OOEnumItem;
00095 
00096 /* Memory allocation and free function definitions.  These definitions  */
00097 /* can be changed if a non-standard allocation/free function is to be   */
00098 /* used..                                                               */
00099 
00100 #define OOMEMALLOC  malloc
00101 #define OOMEMFREE   free
00102 
00103 /* Min/max macros */
00104 
00105 #ifndef OOMAX
00106 #define OOMAX(a,b)  (((a)>(b))?(a):(b))
00107 #endif
00108 
00109 #ifndef OOMIN
00110 #define OOMIN(a,b)  (((a)<(b))?(a):(b))
00111 #endif
00112 
00113 /* Get count of number of items in an array */
00114 
00115 #define OONUMBEROF(items) (sizeof(items)/sizeof(items[0]))
00116 
00117 /* This is used for creating a Windows DLL.  Specify -DMAKE_DLL to      */
00118 /* compile code for inclusion in a DLL.                                 */
00119 
00120 #ifndef EXTERN
00121 #if defined (MAKE_DLL)
00122 #define EXTERN __declspec(dllexport)
00123 #elif defined (USE_DLL)
00124 #define EXTERN __declspec(dllimport)
00125 #else
00126 #define EXTERN
00127 #endif /* _DLL */
00128 #endif /* EXTERN */
00129 
00130 EXTERN OOINT32 lookupEnum
00131 (const char* strValue, size_t strValueSize, const OOEnumItem enumTable[], 
00132  OOUINT16 enumTableSize);
00133 
00134 #if defined(_WIN32) || defined(_WIN64)
00135 #define strcasecmp _stricmp
00136 #endif
00137 
00141 #endif /* _OOCOMMON_H_ */

This file was last modified on 28 May 2010.
Objective Open H.323 Stack, 0.9.1