Update tinySIP:

Begin adding support for SIP timers.
This commit is contained in:
bossiel 2009-12-14 03:20:49 +00:00
parent dc9dc49083
commit 3da5926e38
34 changed files with 554 additions and 88 deletions

View File

@ -34,10 +34,22 @@
#ifndef _TINYSAK_H_
#define _TINYSAK_H_
#if HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef __SYMBIAN32__
#undef _WIN32 /* Because of WINSCW */
#endif
#if defined(WIN32)|| defined(_WIN32) || defined(_WIN32_WCE)
# define TSK_UNDER_WINDOWS 1
#endif
/**@def TINYSAK_API
* Used on Windows and Sysbian systems to export public functions.
*/
#if (defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) || defined(__SYMBIAN32__)) && defined(TINYSAK_EXPORTS)
#if (TSK_UNDER_WINDOWS || defined(__SYMBIAN32__)) && defined(TINYSAK_EXPORTS)
# define TINYSAK_API __declspec(dllexport)
#elif (defined(WIN32) || defined(_WIN32_WCE) || defined(__SYMBIAN32__)) && defined(TINYSAK_IMPORTS)
# define TINYSAK_API __declspec(dllimport)
@ -56,20 +68,15 @@
//
// Features
//
#if HAVE_CONFIG
#include "config.h"
#else
#if defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE)
# define HAVE_GETTIMEOFDAY 0
#else
# define HAVE_GETTIMEOFDAY 1
#endif
#endif /* HAVE_CONFIG */
#if TSK_UNDER_WINDOWS
# define HAVE_GETTIMEOFDAY 0
#else if(!HAVE_CONFIG_H)
# define HAVE_GETTIMEOFDAY 1
#endif
#include <stdint.h>
#ifdef __SYMBIAN32__
#undef _WIN32 /* Because of WINSCW */
#endif
#endif /* _TINYSAK_H_ */

View File

@ -39,6 +39,7 @@
#include "tsk_url.h"
#include "tsk_params.h"
#include "tsk_timer.h"
#include "tsk_condwait.h"
#include "tsk_mutex.h"
#include "tsk_semaphore.h"

View File

@ -32,7 +32,6 @@
#include "tinySAK_config.h"
#include <stdint.h>
#include <stdio.h>
#define TSK_BINARY_REVERSE_2BYTE(value) ((Tsk_BitReverseTable256[value & 0xff] << 8) | (Tsk_BitReverseTable256[(value >> 8)]))

View File

@ -33,11 +33,10 @@
#include "tsk_debug.h"
#include "tsk_macros.h"
#include "tsk_time.h"
#include "tsk_mutex.h"
#include <pthread.h>
#include <time.h>
#if defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE)
#if TSK_UNDER_WINDOWS
#include <windows.h>
#else
#include <sys/time.h>
@ -116,7 +115,7 @@ int tsk_condwait_wait(tsk_condwait_handle_t* handle)
* @retval Zero if succeed or @ref ETIMEDOUT if timedout and non-zero otherwise.
* @sa @ref tsk_condwait_wait.
*/
int tsk_condwait_timedwait(tsk_condwait_handle_t* handle, unsigned int ms)
int tsk_condwait_timedwait(tsk_condwait_handle_t* handle, uint64_t ms)
{
int ret = EINVAL;
tsk_condwait_t *condwait = (tsk_condwait_t*)handle;
@ -127,8 +126,8 @@ int tsk_condwait_timedwait(tsk_condwait_handle_t* handle, unsigned int ms)
struct timeval tv = {0, 0};
/*int rc =*/ tsk_gettimeofday(&tv, 0);
ts.tv_sec = ( tv.tv_sec + (ms/1000) );
ts.tv_nsec += ( (tv.tv_usec * 1000) + (ms % 1000 * 1000000) );
ts.tv_sec = ( tv.tv_sec + ((long)ms/1000) );
ts.tv_nsec += ( (tv.tv_usec * 1000) + ((long)ms % 1000 * 1000000) );
if(ts.tv_nsec > 999999999) ts.tv_sec+=1, ts.tv_nsec = ts.tv_nsec % 1000000000;
tsk_mutex_lock(condwait->mutex);
@ -173,6 +172,21 @@ int tsk_condwait_signal(tsk_condwait_handle_t* handle)
return ret;
}
/**@ingroup tsk_condwait_group
* Gets the internal mutex used by the CondWait object.
* @param handle The CondWait object holding the mutex.
* @retval The internal mutex.
*/
tsk_mutex_handle_t* tsk_condwait_get_mutex(tsk_condwait_handle_t* handle)
{
tsk_condwait_t *condwait = (tsk_condwait_t*)handle;
if(condwait)
{
return condwait->mutex;
}
return 0;
}
/**@ingroup tsk_condwait_group
* Wakes up all threads that are currently waiting on @ref condwait variable.
* @param handle CondWait handle created using @ref tsk_condwait_create.

View File

@ -31,6 +31,7 @@
#define _TINYSAK_CONDWAIT_H_
#include "tinySAK_config.h"
#include "tsk_mutex.h"
/**
* Pthread condwait handle.
@ -39,9 +40,10 @@ typedef void tsk_condwait_handle_t;
TINYSAK_API tsk_condwait_handle_t* tsk_condwait_create();
TINYSAK_API int tsk_condwait_wait(tsk_condwait_handle_t* handle);
TINYSAK_API int tsk_condwait_timedwait(tsk_condwait_handle_t* handle, unsigned int ms);
TINYSAK_API int tsk_condwait_timedwait(tsk_condwait_handle_t* handle, uint64_t ms);
TINYSAK_API int tsk_condwait_signal(tsk_condwait_handle_t* handle);
TINYSAK_API int tsk_condwait_broadcast(tsk_condwait_handle_t* handle);
TINYSAK_API tsk_mutex_handle_t* tsk_condwait_get_mutex(tsk_condwait_handle_t* handle);
TINYSAK_API void tsk_condwait_destroy(tsk_condwait_handle_t** handle);
#endif /* _TINYSAK_CONDWAIT_H_ */

View File

@ -318,6 +318,45 @@ void tsk_list_push_item(tsk_list_t* list, tsk_list_item_t** item, int back)
(*item) = 0;
}
/**@ingroup tsk_list_group
* Add an item to the list in ascending or descending order.
* @param list
* @param item
* @param predicate
*/
void tsk_list_push_filtered_item(tsk_list_t* list, tsk_list_item_t** item, int ascending)
{
if(list)
{
tsk_list_item_t *prev = 0;
tsk_list_item_t *curr = prev = list->head;
while(curr)
{
int diff = tsk_object_cmp((*item), curr);
if((diff <= 0 && ascending) || (diff >=0 && !ascending))
{
if(curr == list->head)
{
tsk_list_push_front_item(list, item);
}
else
{
(*item)->next = curr;
prev->next = (*item);
}
return;
}
prev = curr;
curr = curr->next;
}
tsk_list_push_back_item(list, item);
}
}
/**@ingroup tsk_list_group
* Add all items in @a source into @a destination
* @param dest destination list
@ -349,8 +388,7 @@ void tsk_list_push_data(tsk_list_t* list, void** data, int back)
{
if(data)
{
tsk_list_item_t *item = 0;
item = TSK_LIST_ITEM_CREATE();
tsk_list_item_t *item = TSK_LIST_ITEM_CREATE();
item->data = *data;
tsk_list_push_item(list, &item, back);
@ -362,6 +400,25 @@ void tsk_list_push_data(tsk_list_t* list, void** data, int back)
}
}
/**@ingroup tsk_list_group
* Add an opaque data to the list in ascending or descending order.
*/
void tsk_list_push_filtered_data(tsk_list_t* list, void** data, int ascending)
{
if(data)
{
tsk_list_item_t *item = TSK_LIST_ITEM_CREATE();
item->data = *data;
tsk_list_push_filtered_item(list, &item, ascending);
(*data) = 0;
}
else
{
TSK_DEBUG_WARN("Cannot add an uninitialized data to the list");
}
}
/**@ingroup tsk_list_group
* Find an item from a list.
* @param list The list from which to search an item.
@ -445,13 +502,21 @@ static void* tsk_list_item_destroy(void *self)
return item;
}
static int tsk_list_item_cmp(const void *self, const void *object)
{
const tsk_list_item_t* item1 = self;
const tsk_list_item_t* item2 = object;
return tsk_object_cmp(item1->data, item2->data);
}
//TSK_DECLARE_DEF(tsk, list_item);
static const tsk_object_def_t tsk_list_item_def_s =
{
sizeof(tsk_list_item_t),
tsk_list_item_create,
tsk_list_item_destroy,
0,
tsk_list_item_cmp,
};
const void *tsk_list_item_def_t = &tsk_list_item_def_s;

View File

@ -108,16 +108,22 @@ TINYSAK_API void tsk_list_remove_item_by_pred(tsk_list_t* list, tsk_list_func_pr
TINYSAK_API void tsk_list_clear_items(tsk_list_t* list);
TINYSAK_API void tsk_list_push_item(tsk_list_t* list, tsk_list_item_t** item, int back);
#define tsk_list_pushback_item(list, item) tsk_list_push_item(list, item, 1)
#define tsk_list_pushfront_item(list, item) tsk_list_push_item(list, item, 0)
#define tsk_list_push_back_item(list, item) tsk_list_push_item(list, item, 1)
#define tsk_list_push_front_item(list, item) tsk_list_push_item(list, item, 0)
TINYSAK_API void tsk_list_push_filtered_item(tsk_list_t* list, tsk_list_item_t** item, int ascending);
#define tsk_list_push_ascending_item(list, item) tsk_list_pushfiltered_item(list, item, 1)
#define tsk_list_push_descending_item(list, item) tsk_list_pushfiltered_item(list, item, 0)
TINYSAK_API void tsk_list_push_list(tsk_list_t* destination, tsk_list_t** source, int back);
#define tsk_list_pushback_list(destination, source) tsk_list_push_list(destination, source, 1)
#define tsk_list_pushfront_list(destination, source) tsk_list_push_list(destination, source, 0)
TINYSAK_API void tsk_list_push_data(tsk_list_t* list, void** data, int back);
#define tsk_list_pushback_data(list, data) tsk_list_push_data(list, data, 1)
#define tsk_list_pushfront_data(list, data) tsk_list_push_data(list, data, 0)
#define tsk_list_push_back_data(list, data) tsk_list_push_data(list, data, 1)
#define tsk_list_push_front_data(list, data) tsk_list_push_data(list, data, 0)
TINYSAK_API void tsk_list_push_filtered_data(tsk_list_t* list, void** data, int ascending);
#define tsk_list_push_ascending_data(list, data) tsk_list_push_filtered_data(list, data, 1)
#define tsk_list_push_descending_data(list, data) tsk_list_push_filtered_data(list, data, 0)
TINYSAK_API const tsk_list_item_t* tsk_list_find_item_by_data(const tsk_list_t* list, const void * tskobj);
TINYSAK_API const tsk_list_item_t* tsk_list_find_item_by_pred(const tsk_list_t* list, tsk_list_func_predicate predicate, const void * data);

View File

@ -31,7 +31,6 @@
#define _TINYSAK_PPFCS16_H_
#include "tinySAK_config.h"
#include <stdint.h>
#define TSK_PPPINITFCS16 0xffff /* Initial FCS value */
#define TSK_PPPGOODFCS16 0xf0b8 /* Good final FCS value */

View File

@ -31,7 +31,6 @@
#define _TINYSAK_SHA1_H_
#include "tinySAK_config.h"
#include <stdint.h>
#ifndef _TSK_SHA_enum_

View File

@ -37,7 +37,7 @@
#include <stdlib.h>
#include <string.h>
#if defined(_MSC_VER) || defined(WIN32)
#if defined(_MSC_VER) || TSK_UNDER_WINDOWS
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# define strdup _strdup
@ -267,6 +267,22 @@ void tsk_strunquote(char **str)
}
}
/**@ingroup tsk_string_group
* Conversts an integer to string.
* @param i The integer number to convert to a string.
* @param result Pointer to the string where to copy the result.
*/
void tsk_itoa(int64_t i, tsk_istr_t *result)
{
memset(result, 0, sizeof(*result));
sprintf(*result,"%lld",i);
}

View File

@ -39,6 +39,8 @@
#define TSK_STRING_SAFE_FREE(self) tsk_object_unref(self), self = 0
#define TSK_STRING_STR(self) ((tsk_string_t*)self)->value
typedef char tsk_istr_t[20]; /**< Integer number as string value. */
TINYSAK_API char tsk_b10tob16(char c);
TINYSAK_API char tsk_b16tob10(char c);
@ -52,6 +54,7 @@ TINYSAK_API void tsk_strtrim_left(char **str);
TINYSAK_API void tsk_strtrim_right(char **str);
TINYSAK_API void tsk_strquote(char **str);
TINYSAK_API void tsk_strunquote(char **str);
TINYSAK_API void tsk_itoa(int64_t i, tsk_istr_t *result);
#define tsk_strtrim_both(str) tsk_strtrim_left(str), tsk_strtrim_right(str);

View File

@ -32,9 +32,27 @@
#include <pthread.h>
#if TSK_UNDER_WINDOWS
# include <windows.h>
#endif
/**@defgroup tsk_thread_group Useful functions for threading.
*/
void tsk_thread_sleep(uint64_t ms)
{
#if TSK_UNDER_WINDOWS
Sleep((DWORD)ms);
#else
struct timespec interval;
interval.tv_sec = (long)(ms/1000);
interval.tv_nsec = (long)(ms%1000) * 1000000;
nanosleep(&interval, 0);
#endif
}
/**@ingroup tsk_thread_group
* Creates a new thread.
* @param tid Pthread handle id to the created thread.

View File

@ -32,7 +32,8 @@
#include "tinySAK_config.h"
int TINYSAK_API tsk_thread_create(void** tid, void *(*start) (void *), void *arg);
int TINYSAK_API tsk_thread_join(void** tid);
TINYSAK_API void tsk_thread_sleep(uint64_t ms);
TINYSAK_API int tsk_thread_create(void** tid, void *(*start) (void *), void *arg);
TINYSAK_API int tsk_thread_join(void** tid);
#endif

View File

@ -29,7 +29,7 @@
*/
#include "tsk_time.h"
#include <time.h>
#if defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE)
#if TSK_UNDER_WINDOWS
#include <windows.h>
#endif
@ -37,7 +37,7 @@
*/
#if !HAVE_GETTIMEOFDAY
#if defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE)
#if TSK_UNDER_WINDOWS
/* Thanks to "http://www.cpp-programming.net/c-tidbits/gettimeofday-function-for-windows" */
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
@ -110,3 +110,16 @@ int tsk_gettimeofday(struct timeval *tv, struct timezone *tz)
{
return gettimeofday(tv, tz);
}
/**
* Gets the number of milliseconds since the EPOCH.
* @retval The number of milliseconds since EPOCH.
*/
uint64_t tsk_time_epoch()
{
struct timeval tv;
static const uint64_t thousand = 1000;
gettimeofday(&tv, 0);
return (((uint64_t)tv.tv_sec)*thousand) + (((uint64_t)tv.tv_usec)/thousand);
}

View File

@ -38,7 +38,12 @@ struct timezone;
#endif
int tsk_gettimeofday(struct timeval *tv, struct timezone *tz);
uint64_t tsk_time_epoch();
/**
* Gets the number of milliseconds since the EPOCH.
*/
#define tsk_time_epoch tsk_time_now
#ifdef _WIN32_WCE

View File

@ -0,0 +1,123 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file tsk_timer.c
* @brief Timers Mangement.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tsk_timer.h"
#include "tsk_debug.h"
#include "tsk_list.h"
#include "tsk_thread.h"
#include "tsk_condwait.h"
/**@defgroup tsk_timer_group Timers Management
*/
typedef struct tsk_timer_s
{
TSK_DECLARE_OBJECT;
const void *arg; /**< Opaque data to return to the callback function. */
uint64_t timeout; /**< Number of milliseconds after which the callback function is called. */
tsk_timer_callback callback; /**< The callback function to after @ref timeout milliseconds. */
}
tsk_timer_t;
typedef tsk_list_t tsk_timers_L_t;
/*== Global variables. */
static tsk_condwait_handle_t *tsk_manager_condwait = 0;
static tsk_mutex_handle_t *tsk_manager_mutex = 0;
static int tsk_manager_running = 0;
static int tsk_manager_break = 0;
static tsk_timers_L_t *tsk_manager_timers = 0;
static void *tsk_manager_thread_id = 0;
/*== Definitions */
static void *tsk_timer_manager_loop(void *param);
/**@ingroup tsk_timer_group
* Start the timer manager.
*/
int tsk_timer_manager_start()
{
if(!tsk_manager_running && !tsk_manager_condwait)
{
tsk_manager_condwait = tsk_condwait_create();
tsk_manager_mutex = tsk_condwait_get_mutex(tsk_manager_condwait);
//tsk_mutex_lock(tsk_manager_mutex); /* First lock. */
tsk_manager_break = 0;
tsk_thread_create(&tsk_manager_thread_id, tsk_timer_manager_loop, 0);
}
return 0;
}
int tsk_timer_manager_stop()
{
if(tsk_manager_running && tsk_manager_condwait)
{
tsk_manager_break = 1;
tsk_condwait_broadcast(tsk_manager_condwait);
//tsk_mutex_unlock(tsk_manager_mutex);
tsk_thread_join(&tsk_manager_thread_id);
tsk_condwait_destroy(&tsk_manager_condwait);
tsk_manager_running = 0;
}
return 0;
}
tsk_timer_id_t tsk_timer_manager_schedule(uint64_t timeout, tsk_timer_callback callback, const void *arg)
{
return 0;
}
void tsk_timer_manager_cancel(tsk_timer_id_t id)
{
}
static void *tsk_timer_manager_loop(void *param)
{
TSK_DEBUG_INFO("TIMER MANAGER -- START");
tsk_manager_running = 1;
for(;;)
{
//tsk_mutex_lock(tsk_manager_mutex);
//tsk_condwait_wait(tsk_manager_condwait);
if(tsk_manager_break)
{
break;
}
}
TSK_DEBUG_INFO("TIMER MANAGER -- STOP");
return 0;
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file tsk_timers.h
* @brief Timer Management.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TINYSAK_TIMER_H_
#define _TINYSAK_TIMER_H_
#include "tinySAK_config.h"
typedef enum tsk_timer_retcode_e
{
tsk_error,
tsk_canceled,
tsk_timedout,
}
tsk_timer_retcode_t;
typedef uint64_t tsk_timer_id_t;
typedef void (*tsk_timer_callback)(const void* arg, tsk_timer_retcode_t code);
TINYSAK_API int tsk_timer_manager_start();
TINYSAK_API int tsk_timer_manager_stop();
TINYSAK_API tsk_timer_id_t tsk_timer_manager_schedule(uint64_t timeout, tsk_timer_callback callback, const void *arg);
TINYSAK_API void tsk_timer_manager_cancel(tsk_timer_id_t id);
TINYSAK_API const void *tsk_timer_def_t;
#endif /* _TINYSAK_TIMER_H_ */

View File

@ -43,7 +43,8 @@
#define RUN_TEST_SEMAPHORE 0
#define RUN_TEST_SAFEOBJECT 0
#define RUN_TEST_OBJECT 0
#define RUN_TEST_PARAMS 1
#define RUN_TEST_PARAMS 0
#define RUN_TEST_TIMER 1
#if RUN_TEST_LISTS || RUN_TEST_ALL
#include "test_lists.h"
@ -85,6 +86,11 @@
#include "test_params.h"
#endif
#if RUN_TEST_TIMER || RUN_TEST_ALL
#include "test_timer.h"
#endif
#ifdef _WIN32_WCE
@ -102,9 +108,11 @@ int main()
#if RUN_TEST_LISTS || RUN_TEST_ALL
/* linked lists */
test_basic_list();
//test_basic_list();
printf("\n\n");
test_complex_list();
//test_complex_list();
printf("\n\n");
test_filtered_list();
printf("\n\n");
#endif
@ -161,6 +169,12 @@ int main()
test_params();
printf("\n\n");
#endif
#if RUN_TEST_TIMER || RUN_TEST_ALL
/* timer */
test_timer();
printf("\n\n");
#endif
}

View File

@ -237,6 +237,10 @@
RelativePath=".\test_strings.h"
>
</File>
<File
RelativePath=".\test_timer.h"
>
</File>
<File
RelativePath=".\test_url.h"
>

View File

@ -92,19 +92,19 @@ void test_basic_list()
/* add items to the list */
item->data = TSK_STRING_CREATE("First item");
tsk_list_pushfront_item(list, &item);
tsk_list_push_front_item(list, &item);
item = TSK_LIST_ITEM_CREATE();
item->data = TSK_STRING_CREATE("Second item");
tsk_list_pushback_item(list, &item);
tsk_list_push_back_item(list, &item);
item = TSK_LIST_ITEM_CREATE();
item->data = TSK_STRING_CREATE("Third item");
tsk_list_pushfront_item(list, &item);
tsk_list_push_front_item(list, &item);
item = TSK_LIST_ITEM_CREATE();
item->data = TSK_STRING_CREATE("Fourth item");
tsk_list_pushback_item(list, &item);
tsk_list_push_back_item(list, &item);
/* dump all items */
tsk_list_foreach(item, list)
@ -117,6 +117,92 @@ void test_basic_list()
TSK_LIST_SAFE_FREE(list);
}
void test_filtered_list()
{
#define PUSH_FILTERED(list, data) tsk_list_push_ascending_data(list, data);
tsk_list_t *list = TSK_LIST_CREATE();
tsk_list_item_t *item = 0;
/* add items to the list */
{
person_t *person2 = PERSON_CREATE("2", "person2");
PUSH_FILTERED(list, ((void**) &person2));
}
{
person_t *person6 = PERSON_CREATE("6", "person6");
PUSH_FILTERED(list, ((void**) &person6));
}
{
person_t *person1 = PERSON_CREATE("1", "person1");
PUSH_FILTERED(list, ((void**) &person1));
}
{
person_t *person6 = PERSON_CREATE("6", "person6");
PUSH_FILTERED(list, ((void**) &person6));
}
{
person_t *person6 = PERSON_CREATE("6", "person6");
PUSH_FILTERED(list, ((void**) &person6));
}
{
person_t *person2 = PERSON_CREATE("2", "person2");
PUSH_FILTERED(list, ((void**) &person2));
}
{
person_t *person2 = PERSON_CREATE("2", "person2");
PUSH_FILTERED(list, ((void**) &person2));
}
{
person_t *person5 = PERSON_CREATE("5", "person5");
PUSH_FILTERED(list, ((void**) &person5));
}
{
person_t *person4 = PERSON_CREATE("4", "person4");
PUSH_FILTERED(list, ((void**) &person4));
}
{
person_t *person1 = PERSON_CREATE("1", "person1");
PUSH_FILTERED(list, ((void**) &person1));
}
{
person_t *person1 = PERSON_CREATE("1", "person1");
PUSH_FILTERED(list, ((void**) &person1));
}
{
person_t *person3 = PERSON_CREATE("3", "person3");
PUSH_FILTERED(list, ((void**) &person3));
}
{
person_t *person6 = PERSON_CREATE("6", "person6");
PUSH_FILTERED(list, ((void**) &person6));
}
{
person_t *person1 = PERSON_CREATE("1", "person1");
PUSH_FILTERED(list, ((void**) &person1));
}
{
person_t *person3 = PERSON_CREATE("3", "person3");
PUSH_FILTERED(list, ((void**) &person3));
}
{
person_t *person6 = PERSON_CREATE("6", "person6");
PUSH_FILTERED(list, ((void**) &person6));
}
/* dump all items */
tsk_list_foreach(item, list)
{
person_t* item_data = item->data;
printf("test_filtered_list/// --> [id=%s and name=%s]\n", item_data->id, item_data->name);
}
/* delete all items in the list */
TSK_LIST_SAFE_FREE(list);
#undef PUSH_FILTERED
}
void test_complex_list()
{
tsk_list_t *list = TSK_LIST_CREATE();
@ -125,15 +211,15 @@ void test_complex_list()
/* add items to the list */
{
person_t *person1 = PERSON_CREATE("1", "person1");
tsk_list_pushback_data(list, ((void**) &person1));
tsk_list_push_back_data(list, ((void**) &person1));
}
{
person_t *person2 = PERSON_CREATE("2", "person2");
tsk_list_pushfront_data(list, ((void**) &person2));
tsk_list_push_front_data(list, ((void**) &person2));
}
{
person_t *person3 = PERSON_CREATE("3", "person3");
tsk_list_pushfront_data(list, ((void**) &person3));
tsk_list_push_front_data(list, ((void**) &person3));
}
/* dump all items */

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
#ifndef _TEST_TIMER_H_
#define _TEST_TIMER_H_
void test_timer()
{
printf("test_timer//\n");
tsk_timer_manager_start();
tsk_timer_manager_schedule(100000, 0, 0);
//tsk_timer_manager_stop();
}
#endif /* _TEST_TIMER_H_ */

View File

@ -422,6 +422,10 @@
RelativePath=".\src\tsk_time.h"
>
</File>
<File
RelativePath=".\src\tsk_timer.h"
>
</File>
<File
RelativePath=".\src\tsk_url.h"
>
@ -504,6 +508,10 @@
RelativePath=".\src\tsk_time.c"
>
</File>
<File
RelativePath=".\src\tsk_timer.c"
>
</File>
<File
RelativePath=".\src\tsk_url.c"
>

View File

@ -35,8 +35,6 @@
#include "tsk_object.h"
#include <stdint.h>
/**@def TSIP_HEADER_VIA_CREATE
* Creates new sip via header. You must call @ref TSIP_HEADER_VIA_SAFE_FREE to free the header.
* @sa TSIP_HEADER_VIA_SAFE_FREE.

View File

@ -35,8 +35,6 @@
#include "tinysip/parsers/tsip_ragel_state.h"
#include <stdint.h>
TINYSIP_API tsip_uri_t *tsip_uri_parse(const char *data, size_t size);
#endif /* TINYSIP_PARSER_URI_H */

View File

@ -32,8 +32,6 @@
#include "tinysip_config.h"
#include <stdint.h>
#define PARSER_SET_STRING(string) \
if(!string) \
@ -59,7 +57,7 @@
if(param) \
{ \
if(!dest) dest = TSK_LIST_CREATE(); \
tsk_list_pushback_data(dest, ((void**) &param)); \
tsk_list_push_back_data(dest, ((void**) &param)); \
}
#define PARSER_ADD_STRING(dest) \
@ -70,7 +68,7 @@
{ \
dest = TSK_LIST_CREATE(); \
} \
tsk_list_pushback_data(dest, ((void**) &string));
tsk_list_push_back_data(dest, ((void**) &string));
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct tsip_parser_s

View File

@ -35,8 +35,6 @@
#include "tsk_object.h"
#include "tsk_params.h"
#include <stdint.h>
/**@def TSIP_URI_CREATE
* Creates new sip/sips/tel uri. You must call @ref TSIP_URI_SAFE_FREE to free the uri.
* @sa TSIP_HEADER_VIA_SAFE_FREE.

View File

@ -43,6 +43,7 @@
#undef _WIN32 /* Because of WINSCW */
#endif
#include <stdint.h>
/* Tiny SAK */
#define TINYSAK_IMPORTS

View File

@ -97,7 +97,7 @@
tsip_header_Allow_t *header = tsip_header_Allow_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -107,7 +107,7 @@
tsip_header_Allow_Events_t *header = tsip_header_Allow_Events_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -261,7 +261,7 @@
tsip_header_Max_Forwards_t *header = tsip_header_Max_Forwards_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -295,7 +295,7 @@
tsip_header_P_Access_Network_Info_t *header = tsip_header_P_Access_Network_Info_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -383,7 +383,7 @@
tsip_header_P_Preferred_Identity_t *header = tsip_header_P_Preferred_Identity_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -423,7 +423,7 @@
tsip_header_Privacy_t *header = tsip_header_Privacy_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -511,7 +511,7 @@
tsip_header_Require_t *header = tsip_header_Require_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -605,7 +605,7 @@
tsip_header_Supported_t *header = tsip_header_Supported_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -642,7 +642,7 @@
tsip_header_User_Agent_t *header = tsip_header_User_Agent_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
@ -658,7 +658,7 @@
tsip_header_Via_t *header = tsip_header_Via_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
}

View File

@ -98,7 +98,7 @@
{
if(curr_contact)
{
tsk_list_pushback_data(hdr_contact->contacts, ((void**) &curr_contact));
tsk_list_push_back_data(hdr_contact->contacts, ((void**) &curr_contact));
TSK_DEBUG_INFO("CONTACT:ADD_CONTACT");
}
}
@ -146,7 +146,7 @@ tsip_header_Contact_t *tsip_header_Contact_parse(const char *data, size_t size)
{
if(curr_contact)
{
tsk_list_pushback_data(hdr_contact->contacts, ((void**) &curr_contact));
tsk_list_push_back_data(hdr_contact->contacts, ((void**) &curr_contact));
}
}

View File

@ -156,6 +156,6 @@ void tsip_header_add_param(tsip_header_t *header, const char *name, const char *
param->name = tsk_strdup(name);
param->value = tsk_strdup(value);
tsk_list_pushback_data(header->params, ((void**) &param));
tsk_list_push_back_data(header->params, ((void**) &param));
}
}

View File

@ -20818,7 +20818,7 @@ _match:
{
if(curr_contact)
{
tsk_list_pushback_data(hdr_contact->contacts, ((void**) &curr_contact));
tsk_list_push_back_data(hdr_contact->contacts, ((void**) &curr_contact));
TSK_DEBUG_INFO("CONTACT:ADD_CONTACT");
}
}
@ -20856,7 +20856,7 @@ _again:
{
if(curr_contact)
{
tsk_list_pushback_data(hdr_contact->contacts, ((void**) &curr_contact));
tsk_list_push_back_data(hdr_contact->contacts, ((void**) &curr_contact));
}
}

View File

@ -2231,7 +2231,7 @@ _match:
tsip_header_Allow_t *header = tsip_header_Allow_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2241,7 +2241,7 @@ _match:
tsip_header_Allow_Events_t *header = tsip_header_Allow_Events_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2395,7 +2395,7 @@ _match:
tsip_header_Max_Forwards_t *header = tsip_header_Max_Forwards_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2429,7 +2429,7 @@ _match:
tsip_header_P_Access_Network_Info_t *header = tsip_header_P_Access_Network_Info_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2517,7 +2517,7 @@ _match:
tsip_header_P_Preferred_Identity_t *header = tsip_header_P_Preferred_Identity_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2557,7 +2557,7 @@ _match:
tsip_header_Privacy_t *header = tsip_header_Privacy_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2645,7 +2645,7 @@ _match:
tsip_header_Require_t *header = tsip_header_Require_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2739,7 +2739,7 @@ _match:
tsip_header_Supported_t *header = tsip_header_Supported_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2776,7 +2776,7 @@ _match:
tsip_header_User_Agent_t *header = tsip_header_User_Agent_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
break;
@ -2792,7 +2792,7 @@ _match:
tsip_header_Via_t *header = tsip_header_Via_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_pushback_data(message->headers, ((void**) &header));
tsk_list_push_back_data(message->headers, ((void**) &header));
}
}
}

View File

@ -20,8 +20,8 @@
*
*/
#ifndef TEST_SIPMESSAGE_H
#define TEST_SIPMESSAGE_H
#ifndef TEST_TSIP_STDAFX_H
#define TEST_TSIP_STDAFX_H
#ifdef WIN32
#include "targetver.h"
@ -38,4 +38,4 @@
#define TINYSAK_IMPORTS
#define TINYSIP_IMPORTS
#endif /* TEST_SIPMESSAGE_H */
#endif /* TEST_TSIP_STDAFX_H */

View File

@ -15,22 +15,22 @@ Global
Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4CE20732-9978-4A88-B586-CFEFCB63E82D}.Debug|Win32.ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{4CE20732-9978-4A88-B586-CFEFCB63E82D}.Debug|Win32.Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{4CE20732-9978-4A88-B586-CFEFCB63E82D}.Debug|Win32.ActiveCfg = Debug|Win32
{4CE20732-9978-4A88-B586-CFEFCB63E82D}.Debug|Win32.Build.0 = Debug|Win32
{4CE20732-9978-4A88-B586-CFEFCB63E82D}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{4CE20732-9978-4A88-B586-CFEFCB63E82D}.Release|Win32.ActiveCfg = Release|Win32
{4CE20732-9978-4A88-B586-CFEFCB63E82D}.Release|Win32.Build.0 = Release|Win32
{4CE20732-9978-4A88-B586-CFEFCB63E82D}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Win32.ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Win32.Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Win32.ActiveCfg = Debug|Win32
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Win32.Build.0 = Debug|Win32
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Release|Win32.ActiveCfg = Release|Win32
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Release|Win32.Build.0 = Release|Win32
{353640F9-25C2-4850-BCF8-07A07D8E46AE}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.ActiveCfg = Debug|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.Build.0 = Debug|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.ActiveCfg = Release|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.Build.0 = Release|Win32