27 #if defined(HAVE_STDARG_H)
30 #if defined(HAVE_VARARGS_H)
37 #if defined(__VXWORKS_OS__)
39 int osip_vsnprintf(
char *buf,
int max,
const char *fmt, va_list ap);
40 int osip_snprintf(
char *buf,
int max,
const char *fmt, ...);
42 #define snprintf osip_snprintf
43 #define vsnprintf osip_vsnprintf
46 #include <osipparser2/osip_const.h>
50 #define SIP_SYNTAX_ERROR (-1)
51 #define SIP_NETWORK_ERROR (-2)
52 #define SIP_ECONNREFUSED (-3)
53 #define SIP_RESSOURCE_ERROR (-4)
54 #define SIP_GLOBAL_ERROR (-5)
64 #if !defined(WIN32) && !defined(_WIN32_WCE)
67 typedef void *osip_malloc_func_t(
size_t size);
68 typedef void osip_free_func_t(
void *ptr);
69 typedef void *osip_realloc_func_t(
void *ptr,
size_t size);
71 extern osip_malloc_func_t *osip_malloc_func;
72 extern osip_realloc_func_t *osip_realloc_func;
73 extern osip_free_func_t *osip_free_func;
75 void osip_set_allocators(osip_malloc_func_t *malloc_func, osip_realloc_func_t *realloc_func, osip_free_func_t *free_func);
80 void *_osip_malloc(
size_t size,
char *file,
unsigned short line);
81 void _osip_free(
void *ptr);
82 void *_osip_realloc(
void *ptr,
size_t size,
char *file,
unsigned short line);
85 #define osip_malloc(S) _osip_malloc(S, __FILE__, __LINE__)
88 #define osip_realloc(P, S) _osip_realloc(P, S, __FILE__, __LINE__)
91 #define osip_free(P) \
103 #define osip_malloc(S) (osip_malloc_func ? osip_malloc_func(S) : malloc(S))
106 #define osip_realloc(P, S) (osip_realloc_func ? osip_realloc_func(P, S) : realloc(P, S))
109 #define osip_free(P) \
112 if (osip_free_func) \
123 #define osip_malloc(S) malloc(S)
126 #define osip_realloc(P, S) realloc(P, S)
129 #define osip_free(P) \
144 #if defined(_DEBUG) && defined(WIN32)
145 #define OSIP_MEMORY_DEBUG
148 #ifdef OSIP_MEMORY_DEBUG
151 #define osip_malloc(S) _osip_malloc(S, __FILE__, __LINE__)
154 #define osip_realloc(P, S) _osip_realloc(P, S, __FILE__, __LINE__)
157 #define osip_free(P) \
165 void *_osip_malloc(
size_t size,
char *file,
unsigned short line);
166 void _osip_free(
void *ptr);
167 void *_osip_realloc(
void *ptr,
size_t size,
char *file,
unsigned short line);
169 void *osip_malloc(
size_t size);
170 void *osip_realloc(
void *,
size_t size);
171 void osip_free(
void *);
176 #if defined(WIN32) && !defined(__GNUC__)
177 #define alloca _alloca
184 unsigned int osip_build_random_number(
void);
192 void osip_usleep(
int useconds);
195 int osip_atoi(
const char *number);
196 int osip_strcasecmp(
const char *s1,
const char *s2);
197 int osip_strncasecmp(
const char *s1,
const char *s2,
size_t len);
200 #define osip_atoi atoi
201 #define osip_strcasecmp strcasecmp
202 #define osip_strncasecmp strncasecmp
205 char *osip_strcasestr(
const char *haystack,
const char *needle);
211 char *osip_strncpy(
char *dest,
const char *src,
size_t length);
212 char *osip_strdup(
const char *ch);
213 char *osip_strdup_without_quote(
const char *ch);
214 int osip_tolower(
char *word);
215 int osip_clrspace(
char *word);
216 int __osip_set_next_token(
char **dest,
char *buf,
int end_separator,
char **next);
218 const char *__osip_quote_find(
const char *qstring);
219 char *osip_enquote(
const char *s);
220 void osip_dequote(
char *s);
222 unsigned long osip_hash(
const char *str);
223 char *osip_str_append(
char *dst,
const char *src);
224 char *osip_strn_append(
char *dst,
const char *src,
size_t len);
225 char *osip_clrncpy(
char *dst,
const char *src,
size_t len);
234 typedef enum _trace_level {
236 #define OSIP_FATAL TRACE_LEVEL0
238 #define OSIP_BUG TRACE_LEVEL1
240 #define OSIP_ERROR TRACE_LEVEL2
242 #define OSIP_WARNING TRACE_LEVEL3
244 #define OSIP_INFO1 TRACE_LEVEL4
246 #define OSIP_INFO2 TRACE_LEVEL5
248 #define OSIP_INFO3 TRACE_LEVEL6
250 #define OSIP_INFO4 TRACE_LEVEL7
252 } osip_trace_level_t;
254 typedef void osip_trace_func_t(
const char *fi,
int li, osip_trace_level_t level,
const char *chfr, va_list ap);
258 void osip_trace_initialize_func(osip_trace_level_t level, osip_trace_func_t *func);
259 void osip_trace_initialize_syslog(osip_trace_level_t level,
char *ident);
260 int osip_trace_initialize(osip_trace_level_t level, FILE *file);
261 void osip_trace_enable_until_level(osip_trace_level_t level);
262 void osip_trace_enable_level(osip_trace_level_t level);
263 void osip_trace_disable_level(osip_trace_level_t level);
264 int osip_is_trace_level_activate(osip_trace_level_t level);
268 #define TRACE_INITIALIZE(level, file) \
271 #define TRACE_ENABLE_LEVEL(level) \
274 #define TRACE_DISABLE_LEVEL(level) \
277 #define IS_TRACE_LEVEL_ACTIVATE(level) (-1)
281 #define TRACE_INITIALIZE(level, file) osip_trace_initialize(level, file)
282 #define TRACE_ENABLE_LEVEL(level) osip_trace_enable_level(level)
283 #define TRACE_DISABLE_LEVEL(level) osip_trace_disable_level(level)
284 #define IS_TRACE_LEVEL_ACTIVATE(level) osip_is_trace_level_activate(level)
293 int osip_trace(
const char *fi,
int li, osip_trace_level_t level, FILE *f,
const char *chfr, ...);
296 #define OSIP_TRACE(P) P
298 #define OSIP_TRACE(P) \
303 #define REMOVE_ELEMENT(first_element, element) \
304 if (element->parent == NULL) { \
305 first_element = element->next; \
306 if (first_element != NULL) \
307 first_element->parent = NULL; \
309 element->parent->next = element->next; \
310 if (element->next != NULL) \
311 element->next->parent = element->parent; \
312 element->next = NULL; \
313 element->parent = NULL; \
316 #define ADD_ELEMENT(first_element, element) \
317 if (first_element == NULL) { \
318 first_element = element; \
319 element->next = NULL; \
320 element->parent = NULL; \
322 element->next = first_element; \
323 element->parent = NULL; \
324 element->next->parent = element; \
325 first_element = element; \
328 #define APPEND_ELEMENT(type_of_element_t, first_element, element) \
329 if (first_element == NULL) { \
330 first_element = element; \
331 element->next = NULL; \
332 element->parent = NULL; \
334 type_of_element_t *f; \
335 for (f = first_element; f->next != NULL; f = f->next) { \
338 element->parent = f; \
339 element->next = NULL; \
342 const char *osip_strerror(
int err);
347 #define OSIP_SUCCESS 0
348 #define OSIP_UNDEFINED_ERROR -1
349 #define OSIP_BADPARAMETER -2
350 #define OSIP_WRONG_STATE -3
351 #define OSIP_NOMEM -4
352 #define OSIP_SYNTAXERROR -5
353 #define OSIP_NOTFOUND -6
354 #define OSIP_API_NOT_INITIALIZED -7
355 #define OSIP_NO_NETWORK -10
356 #define OSIP_PORT_BUSY -11
357 #define OSIP_UNKNOWN_HOST -12
358 #define OSIP_DISK_FULL -30
359 #define OSIP_NO_RIGHTS -31
360 #define OSIP_FILE_NOT_EXIST -32
361 #define OSIP_TIMEOUT -50
362 #define OSIP_TOOMUCHCALL -51
363 #define OSIP_WRONG_FORMAT -52
364 #define OSIP_NOCOMMONCODEC -53
365 #define OSIP_RETRY_LIMIT -60