00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _OSIP_PORT_H_
00022 #define _OSIP_PORT_H_
00023
00024
00025
00026 #include <stdio.h>
00027 #ifdef WIN32
00028
00029 #define STDC_HEADERS 1
00030 #define HAVE_CTYPE_H 1
00031 #define HAVE_STRING_H 1
00032 #define HAVE_SYS_TYPES_H 1
00033 #define HAVE_TIME_H 1
00034 #define HAVE_STDARG_H 1
00035
00036
00037
00038 #if _MSC_VER >= 1300
00039 #define WIN32_USE_CRYPTO 1
00040 #endif
00041
00042 #elif defined _WIN32_WCE
00043
00044 #define STDC_HEADERS 1
00045 #define HAVE_CTYPE_H 1
00046 #define HAVE_STRING_H 1
00047 #define HAVE_TIME_H 1
00048 #define HAVE_STDARG_H 1
00049
00050 #define strnicmp _strnicmp
00051 #define stricmp _stricmp
00052 #define EBUSY 16
00053
00054 #endif
00055
00056 #ifdef __VXWORKS_OS__
00057 #include <string.h>
00058 #include <time.h>
00059 #include <sys/times.h>
00060 #include <stdarg.h>
00061 #include <sys/types.h>
00062 #include <stdlib.h>
00063 #define VA_START(a, f) va_start(a, f)
00064
00065
00066 int osip_vsnprintf( char* buf, int max, const char *fmt, va_list ap);
00067 int osip_snprintf( char *buf, int max, const char *fmt, ...);
00068
00069 #define snprintf osip_snprintf
00070 #define vsnprintf osip_vsnprintf
00071
00072
00073 #else
00074
00075 #if defined (HAVE_CONFIG_H)
00076 #include <config.h>
00077 # if defined (HAVE_STRING_H)
00078 # include <string.h>
00079 # else
00080 # include <strings.h>
00081 # endif
00082 #else
00083 # include <string.h>
00084 #endif
00085
00086 #if defined (HAVE_SYS_TYPES_H)
00087 # include <sys/types.h>
00088 #endif
00089
00090 #if STDC_HEADERS
00091 # include <stdlib.h>
00092 #endif
00093
00094 #if defined(HAVE_STDARG_H) || defined(WIN32)
00095 # include <stdarg.h>
00096 # define VA_START(a, f) va_start(a, f)
00097 #else
00098 # if defined(HAVE_VARARGS_H)
00099 # include <varargs.h>
00100 # define VA_START(a, f) va_start(a)
00101 # else
00102 # include <stdarg.h>
00103 # define VA_START(a, f) va_start(a, f)
00104 # endif
00105 #endif
00106
00107 #ifdef HAVE_TIME_H
00108 # include <time.h>
00109 #endif
00110
00111 #if defined (HAVE_SYS_TIME_H)
00112 # include <sys/time.h>
00113 #endif
00114
00115 #endif
00116
00117 #ifdef _WIN32_WCE
00118 #define VA_START(a, f) va_start(a, f)
00119 #endif
00120
00121 #ifdef WIN32
00122 #define VA_START(a, f) va_start(a, f)
00123 #endif
00124
00125 #ifdef __PSOS__
00126 #define VA_START(a, f) va_start(a, f)
00127 #endif
00128
00129 #if __STDC__
00130 # ifndef NOPROTOS
00131 # define PARAMS(args) args
00132 # endif
00133 #endif
00134
00135 #ifndef PARAMS
00136 # define PARAMS(args) ()
00137 #endif
00138
00139 #include <osipparser2/osip_const.h>
00140
00141 #include <osipparser2/osip_list.h>
00142
00143 #define SIP_SYNTAX_ERROR (-1)
00144 #define SIP_NETWORK_ERROR (-2)
00145 #define SIP_ECONNREFUSED (-3)
00146 #define SIP_RESSOURCE_ERROR (-4)
00147 #define SIP_GLOBAL_ERROR (-5)
00148
00149 #ifdef __cplusplus
00150 extern "C"
00151 {
00152 #endif
00153
00154
00155
00156
00157
00158 #ifndef WIN32
00159
00160 typedef void *osip_malloc_func_t(size_t size);
00161 typedef void osip_free_func_t(void *ptr);
00162 typedef void *osip_realloc_func_t(void *ptr, size_t size);
00163
00164 extern osip_malloc_func_t *osip_malloc_func;
00165 extern osip_realloc_func_t *osip_realloc_func;
00166 extern osip_free_func_t *osip_free_func;
00167
00168 void osip_set_allocators(osip_malloc_func_t *malloc_func,
00169 osip_realloc_func_t *realloc_func,
00170 osip_free_func_t *free_func);
00171
00172 #ifndef osip_malloc
00173 #define osip_malloc(S) (osip_malloc_func?osip_malloc_func(S):malloc(S))
00174 #endif
00175 #ifndef osip_realloc
00176 #define osip_realloc(P,S) (osip_realloc_func?osip_realloc_func(P,S):realloc(P,S))
00177 #endif
00178 #ifndef osip_free
00179 #define osip_free(P) { if (P!=NULL) { if (osip_free_func) osip_free_func(P); else free(P);} }
00180 #endif
00181
00182 #else
00183 void *osip_malloc(size_t size);
00184 void *osip_realloc(void *, size_t size);
00185 void osip_free(void *);
00186 #endif
00187
00188 #ifdef WIN32
00189 #define alloca _alloca
00190 #endif
00191
00192
00193
00194
00195
00196 unsigned int osip_build_random_number (void);
00197
00198
00199
00200
00201
00202 #define SP " \0"
00203
00204 void osip_usleep (int useconds);
00205
00206
00207
00208
00209
00210 int osip_atoi (const char *number);
00211 char *osip_strncpy (char *dest, const char *src, size_t length);
00212 char *osip_strdup (const char *ch);
00213 char *osip_strdup_without_quote (const char *ch);
00214 int osip_tolower (char *word);
00215 int osip_clrspace (char *word);
00216 char *__osip_sdp_append_string (char *string, size_t size,
00217 char *cur, char *string_osip_to_append);
00218 int __osip_set_next_token (char **dest, char *buf, int end_separator,
00219 char **next);
00220
00221 char *__osip_quote_find (const char *qstring);
00222 char *osip_enquote (const char *s);
00223 void osip_dequote (char *s);
00224
00225 int osip_strcasecmp (const char *s1, const char *s2);
00226 int osip_strncasecmp (const char *s1, const char *s2, size_t len);
00227
00228
00229
00230
00231
00232 #define LOG_TRUE 1
00233 #define LOG_FALSE 0
00234
00235 typedef enum _trace_level
00236 {
00237 TRACE_LEVEL0 = 0,
00238 #define OSIP_FATAL 0
00239 TRACE_LEVEL1 = 1,
00240 #define OSIP_BUG 1
00241 TRACE_LEVEL2 = 2,
00242 #define OSIP_ERROR 2
00243 TRACE_LEVEL3 = 3,
00244 #define OSIP_WARNING 3
00245 TRACE_LEVEL4 = 4,
00246 #define OSIP_INFO1 4
00247 TRACE_LEVEL5 = 5,
00248 #define OSIP_INFO2 5
00249 TRACE_LEVEL6 = 6,
00250 #define OSIP_INFO3 6
00251 TRACE_LEVEL7 = 7,
00252 #define OSIP_INFO4 7
00253 END_TRACE_LEVEL = 8
00254 }
00255 osip_trace_level_t;
00256
00257
00258 typedef void osip_trace_func_t(char *fi, int li, osip_trace_level_t level, char *chfr, va_list ap);
00259
00260
00261
00262 void osip_trace_initialize_func (osip_trace_level_t level, osip_trace_func_t *func);
00263 void osip_trace_initialize_syslog (osip_trace_level_t level, char *ident);
00264 void osip_trace_initialize (osip_trace_level_t level, FILE * file);
00265 void osip_trace_enable_until_level (osip_trace_level_t level);
00266 void osip_trace_enable_level (osip_trace_level_t level);
00267 void osip_trace_disable_level (osip_trace_level_t level);
00268 int osip_is_trace_level_activate (osip_trace_level_t level);
00269
00270 #ifndef ENABLE_TRACE
00271
00272 #define TRACE_INITIALIZE(level, file) do { } while (0)
00273 #define TRACE_ENABLE_LEVEL(level) do { } while (0)
00274 #define TRACE_DISABLE_LEVEL(level) do { } while (0)
00275 #define IS_TRACE_LEVEL_ACTIVATE(level) (-1)
00276
00277 #else
00278
00279 #define TRACE_INITIALIZE(level, file) osip_trace_initialize(level, file)
00280 #define TRACE_ENABLE_LEVEL(level) osip_trace_enable_level ( level )
00281 #define TRACE_DISABLE_LEVEL(level) osip_trace_disable_level ( level )
00282 #define IS_TRACE_LEVEL_ACTIVATE(level) osip_is_trace_level_activate( level )
00283
00284 #endif
00285
00286
00287
00288
00289
00290
00291 int osip_trace (char *fi, int li, osip_trace_level_t level, FILE * f,
00292 char *chfr, ...);
00293
00294 #ifdef ENABLE_TRACE
00295 #define OSIP_TRACE(P) P
00296 #else
00297 #define OSIP_TRACE(P) do {} while (0)
00298 #endif
00299
00300 #ifdef __cplusplus
00301 }
00302 #endif
00303
00304 #endif