Commit final version of tinySIGCOMP.
This commit is contained in:
parent
62f66aecec
commit
6ec47a3d5d
|
@ -210,7 +210,7 @@ void tsk_condwait_destroy(tsk_condwait_handle_t** handle)
|
|||
tsk_mutex_destroy(&((*condwait)->mutex));
|
||||
pthread_cond_destroy((*condwait)->pcond);
|
||||
TSK_FREE((*condwait)->pcond);
|
||||
tsk_free(condwait);
|
||||
tsk_free((void**)condwait);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -182,7 +182,7 @@ int find_person_by_name(const tsk_list_item_t* item, const void* name)
|
|||
*/
|
||||
static int tsk_list_find_by_item(const tsk_list_item_t* item, const void* _item)
|
||||
{
|
||||
return (item == (const tsk_list_item_t*)_item) ? 1 : 0;
|
||||
return (item == (const tsk_list_item_t*)_item) ? 0 : -1;
|
||||
}
|
||||
|
||||
/**@ingroup tsk_list_group
|
||||
|
@ -218,7 +218,7 @@ void tsk_list_remove_item_by_data(tsk_list_t* list, const void * tskobj)
|
|||
|
||||
while(curr)
|
||||
{
|
||||
if(tsk_object_icmp(curr->data, tskobj))
|
||||
if(!tsk_object_cmp(curr->data, tskobj))
|
||||
{
|
||||
if(prev == curr)
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ void tsk_list_remove_item_by_pred(tsk_list_t* list, tsk_list_func_predicate pred
|
|||
|
||||
while(curr)
|
||||
{
|
||||
if(predicate(curr, data))
|
||||
if(!predicate(curr, data))
|
||||
{
|
||||
if(prev == curr && curr->next == NULL)
|
||||
{ /* There was only one item */
|
||||
|
@ -270,6 +270,32 @@ void tsk_list_remove_item_by_pred(tsk_list_t* list, tsk_list_func_predicate pred
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn void tsk_list_clear_items(tsk_list_t* list)
|
||||
///
|
||||
/// @brief Clear lsit by removing and deleting all items.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 11/28/2009
|
||||
///
|
||||
/// @param [in,out] list The list to clear.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void tsk_list_clear_items(tsk_list_t* list)
|
||||
{
|
||||
if(list)
|
||||
{
|
||||
tsk_list_item_t* next = 0;
|
||||
tsk_list_item_t* curr = list->head;
|
||||
|
||||
while(curr)
|
||||
{
|
||||
next = curr->next;
|
||||
tsk_object_unref(curr);
|
||||
curr = next;
|
||||
}
|
||||
list->head = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**@ingroup tsk_list_group
|
||||
* Add an item to the list
|
||||
|
@ -339,7 +365,7 @@ const tsk_list_item_t* tsk_list_find_item_by_data(const tsk_list_t* list, const
|
|||
tsk_list_item_t *item;
|
||||
tsk_list_foreach(item, list)
|
||||
{
|
||||
if(tsk_object_icmp(item->data, tskobj))
|
||||
if(!tsk_object_cmp(item->data, tskobj))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
@ -363,7 +389,7 @@ const tsk_list_item_t* tsk_list_find_item_by_pred(const tsk_list_t* list, tsk_li
|
|||
tsk_list_item_t *item;
|
||||
tsk_list_foreach(item, list)
|
||||
{
|
||||
if(predicate(item, data))
|
||||
if(!predicate(item, data))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
@ -416,7 +442,6 @@ static const tsk_object_def_t tsk_list_item_def_s =
|
|||
tsk_list_item_create,
|
||||
tsk_list_item_destroy,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tsk_list_item_def_t = &tsk_list_item_def_s;
|
||||
|
||||
|
@ -441,7 +466,7 @@ static void* tsk_list_destroy(void *self)
|
|||
while(curr)
|
||||
{
|
||||
next = curr->next;
|
||||
curr = tsk_object_unref(curr);
|
||||
/*curr =*/ tsk_object_unref(curr);
|
||||
curr = next;
|
||||
}
|
||||
}
|
||||
|
@ -459,6 +484,5 @@ static const tsk_object_def_t tsk_list_def_s =
|
|||
tsk_list_create,
|
||||
tsk_list_destroy,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tsk_list_def_t = &tsk_list_def_s;
|
|
@ -43,7 +43,7 @@
|
|||
* Safely free a linked list previously created using @ref TSK_LIST_CREATE.
|
||||
* @sa @ref TSK_LIST_CREATE.
|
||||
*/
|
||||
#define TSK_LIST_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TSK_LIST_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@def TSK_LIST_ITEM_CREATE
|
||||
* Create and initialize an item.
|
||||
|
@ -55,7 +55,7 @@
|
|||
* Safely free an item previously created using @ref TSK_LIST_ITEM_CREATE.
|
||||
* @sa @ref TSK_LIST_ITEM_CREATE.
|
||||
*/
|
||||
#define TSK_LIST_ITEM_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TSK_LIST_ITEM_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@typedef tsk_list_item_func_free
|
||||
* Used to define the function to call to free an @b item.
|
||||
|
@ -85,7 +85,7 @@ tsk_list_t;
|
|||
|
||||
/**@typedef tsk_list_func_predicate
|
||||
* Function predicate used to match an item.
|
||||
* @retval 1 if match and 0 otherwise
|
||||
* @retval 0 if match and <0 if first<second and >0 otherwise
|
||||
*/
|
||||
typedef int (*tsk_list_func_predicate)(const tsk_list_item_t* item, const void* data);
|
||||
|
||||
|
@ -104,6 +104,7 @@ typedef int (*tsk_list_func_predicate)(const tsk_list_item_t* item, const void*
|
|||
TINYSAK_API void tsk_list_remove_item(tsk_list_t* list, tsk_list_item_t* item);
|
||||
TINYSAK_API void tsk_list_remove_item_by_data(tsk_list_t* list, const void * tskobj);
|
||||
TINYSAK_API void tsk_list_remove_item_by_pred(tsk_list_t* list, tsk_list_func_predicate predicate, const void * data);
|
||||
TINYSAK_API void tsk_list_clear_items(tsk_list_t* list);
|
||||
TINYSAK_API void tsk_list_add_item(tsk_list_t* list, tsk_list_item_t** item);
|
||||
TINYSAK_API void tsk_list_add_list(tsk_list_t* destination, tsk_list_t** source);
|
||||
TINYSAK_API void tsk_list_add_data(tsk_list_t* destination, void** data);
|
||||
|
|
|
@ -90,7 +90,7 @@ int tsk_object_cmp(const void *self, const void *object)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tsk_object_icmp(const void *self, const void *object)
|
||||
/*int tsk_object_icmp(const void *self, const void *object)
|
||||
{
|
||||
const tsk_object_def_t **objdef = self;
|
||||
if(objdef && *objdef && (*objdef)->objicmp)
|
||||
|
@ -98,7 +98,7 @@ int tsk_object_icmp(const void *self, const void *object)
|
|||
return (*objdef)->objicmp(self, object);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
void* tsk_object_ref(void *self)
|
||||
{
|
||||
|
|
|
@ -61,16 +61,14 @@ typedef struct tsk_object_def_s
|
|||
size_t size; /**< The size of an tsk object. */
|
||||
void* (* constructor) (void *self, va_list *app); /**< The constructor. */
|
||||
void* (* destructor) (void *); /**< The destructor. */
|
||||
void* (* cloner) (const void *self); /**< The object cloner. */
|
||||
int (* objcmp) ( const char *self, const char *object ); /**< Compare two object */
|
||||
int (* objicmp) ( const char *self, const char *object ); /**< Compare two object (Ignore case) */
|
||||
int (* objcmp) (const void *object1, const void *object2); /**< Compare two object */
|
||||
}
|
||||
tsk_object_def_t;
|
||||
|
||||
TINYSAK_API void* tsk_object_new(const tsk_object_def_t *objdef, ...);
|
||||
TINYSAK_API size_t tsk_object_sizeof(const void *self);
|
||||
TINYSAK_API int tsk_object_cmp(const void *self, const void *object);
|
||||
TINYSAK_API int tsk_object_icmp(const void *self, const void *object);
|
||||
//TINYSAK_API int tsk_object_icmp(const void *self, const void *object);
|
||||
TINYSAK_API void* tsk_object_ref(void *self);
|
||||
TINYSAK_API void* tsk_object_unref(void *self);
|
||||
TINYSAK_API void tsk_object_delete(void *self);
|
||||
|
|
|
@ -167,7 +167,7 @@ int tsk_sprintf(char** str, const char* format, ...)
|
|||
{
|
||||
int n;
|
||||
len = (strlen(format)*2);
|
||||
*str = (char*)tsk_calloc(heap, 1, len+1);
|
||||
*str = (char*)tsk_calloc(1, len+1);
|
||||
for(;;)
|
||||
{
|
||||
if( (n = vsnprintf(*str, len, format, list)) >= 0 && (n<len) )
|
||||
|
@ -178,7 +178,7 @@ int tsk_sprintf(char** str, const char* format, ...)
|
|||
else
|
||||
{
|
||||
len += 5;
|
||||
*str = tsk_realloc(heap, *str, len+1);
|
||||
*str = tsk_realloc(*str, len+1);
|
||||
}
|
||||
}
|
||||
done:
|
||||
|
@ -235,9 +235,8 @@ static void* tsk_string_destroy(void * self)
|
|||
static const tsk_object_def_t tsk_string_def_s =
|
||||
{
|
||||
sizeof(tsk_string_t),
|
||||
tsk_string_create, tsk_string_destroy,
|
||||
tsk_string_create,
|
||||
tsk_string_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tsk_string_def_t = &tsk_string_def_s;
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
#include "tsk_object.h"
|
||||
|
||||
#define TSK_STRING_CREATE(str) tsk_object_new(tsk_string_def_t, str)
|
||||
#define TSK_STRING_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TSK_STRING_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
#define TSK_STRING_STR(self) ((tsk_string_t*)self)->value
|
||||
|
||||
TINYSAK_API char tsk_b10tob16(char c);
|
||||
TINYSAK_API char tsk_b16tob10(char c);
|
||||
|
|
|
@ -47,17 +47,17 @@
|
|||
#define TSK_XML_NODE_SELECT_END() nst_end
|
||||
|
||||
#define TSK_XML_NAMESPACE_CREATE() tsk_object_new(tsk_xml_namespace_def_t)
|
||||
#define TSK_XML_NAMESPACE_FREE(self) tsk_object_unref(self)
|
||||
#define TSK_XML_NAMESPACE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
#define TSK_XML_ELEMENT_CREATE(element) tsk_object_new(tsk_xml_element_def_t)
|
||||
#define TSK_XML_ELEMENT_FREE(self) tsk_object_unref(self)
|
||||
#define TSK_XML_ELEMENT_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
#define TSK_XML_ATTRIBUTE_CREATE(attribute) tsk_object_new(tsk_xml_attribute_def_t)
|
||||
#define TSK_XML_ATTRIBUTE_FREE(self) tsk_object_unref(self)
|
||||
#define TSK_XML_ATTRIBUTE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
#define TSK_XML_SERIALIZE(result, element, strValue)\
|
||||
if(strValue) tsk_sprintf(0, &result, "<"##element##">%s</"##element##">", strValue); \
|
||||
else tsk_strupdate2(&result, "");
|
||||
if(strValue) tsk_sprintf(&result, "<"##element##">%s</"##element##">", strValue); \
|
||||
else tsk_strupdate(&result, "");
|
||||
|
||||
/** C and XML Schema mapping */
|
||||
typedef enum tsk_xml_type_e
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
AdditionalDependencies="ws2.lib "$(DOUBANGO_HOME)\thirdparties\wince\lib\libxml\libxml2.lib" "$(DOUBANGO_HOME)\thirdparties\wince\lib\pthread\pthread.lib" "$(DOUBANGO_HOME)\thirdparties\wince\lib\wcecompat\wcecompat.lib""
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="8"
|
||||
TargetMachine="0"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -202,6 +203,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories=""$(DOUBANGO_HOME)\thirdparties\win32\include";"$(DOUBANGO_HOME)\thirdparties\win32\include\pthread""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TINYSAK_EXPORTS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
|
@ -222,6 +224,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies=""$(DOUBANGO_HOME)\thirdparties\win32\lib\libxml\vs_libxml2.dll.a" "$(DOUBANGO_HOME)\thirdparties\win32\lib\pthread\pthread.lib" $(NOINHERIT)"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
|
|
|
@ -327,7 +327,7 @@ void tcomp_buffer_allocBuff(tcomp_buffer_handle_t* handle, size_t size)
|
|||
TSK_DEBUG_WARN("Cannot allocate zero bytes.");
|
||||
return;
|
||||
}
|
||||
tsk_free(&(buffer->lpbuffer));
|
||||
tsk_free((void**)&(buffer->lpbuffer));
|
||||
|
||||
buffer->index_bits = buffer->index_bytes = 0;
|
||||
buffer->lpbuffer = (uint8_t*) tsk_calloc(1, size );
|
||||
|
@ -457,7 +457,7 @@ void tcomp_buffer_freeBuff(tcomp_buffer_handle_t* handle)
|
|||
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
|
||||
if(buffer->lpbuffer && buffer->size && buffer->owner)
|
||||
{
|
||||
tsk_free(&(buffer->lpbuffer));
|
||||
tsk_free((void**)&(buffer->lpbuffer));
|
||||
}
|
||||
buffer->size = buffer->index_bytes = buffer->index_bits = 0;
|
||||
}
|
||||
|
@ -515,6 +515,38 @@ uint8_t* tcomp_buffer_getP_BIT(const tcomp_buffer_handle_t* handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_buffer_group
|
||||
*/
|
||||
uint64_t tcomp_buffer_createHash(const void *data, size_t len)
|
||||
{
|
||||
if(!data || !len)
|
||||
{
|
||||
TSK_DEBUG_ERROR("Null data.");
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
#define PRIME_1 500237
|
||||
#define PRIME_2 700241
|
||||
uint64_t hash = 0;
|
||||
uint8_t* strid = (uint8_t*)data;
|
||||
|
||||
/* Generate Hash code from id */
|
||||
{
|
||||
uint64_t b = PRIME_1, a = PRIME_2;
|
||||
size_t i;
|
||||
for(i = 0; i < len; strid++, i++)
|
||||
{
|
||||
hash = hash * a + (*strid);
|
||||
a = a * b;
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
|
||||
#undef PRIME_1
|
||||
#undef PRIME_2
|
||||
}
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_buffer_group
|
||||
* Print the internal buffer.
|
||||
* @param handle SigComp handle holding the internal buffer to print.
|
||||
|
@ -653,8 +685,6 @@ static const tsk_object_def_t tcomp_buffer_def_s =
|
|||
sizeof(tcomp_buffer_t),
|
||||
_tcomp_buffer_create,
|
||||
tcomp_buffer_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_buffer_def_t = &tcomp_buffer_def_s;
|
||||
const void *tcomp_buffer_def_t = &tcomp_buffer_def_s;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#define _TCOMP_BUFFER_CREATE(data, len) tsk_object_new(tcomp_buffer_def_t, data, len)
|
||||
#define TCOMP_BUFFER_CREATE() _TCOMP_BUFFER_CREATE(0, 0)
|
||||
|
||||
#define TCOMP_BUFFER_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_BUFFER_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**
|
||||
* Sigcomp Buffer handle
|
||||
|
@ -77,6 +77,8 @@ size_t* tcomp_buffer_getIndexBits(const tcomp_buffer_handle_t* handle);
|
|||
|
||||
uint8_t* tcomp_buffer_getP_BIT(const tcomp_buffer_handle_t* handle);
|
||||
|
||||
uint64_t tcomp_buffer_createHash(const void *data, size_t len);
|
||||
|
||||
void tcomp_buffer_nprint(tcomp_buffer_handle_t* handle, size_t size);
|
||||
#define tcomp_buffer_print(handle) tcomp_buffer_nprint(handle, -1)
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ void tcomp_compartment_setRemoteParams(tcomp_compartment_t *compartment, tcomp_p
|
|||
if(tcomp_params_hasCpbDmsSms(lpParams))
|
||||
{
|
||||
tcomp_params_setCpbCode(compartment->remote_parameters, lpParams->cpbCode);
|
||||
tcomp_params_setCpbCode(compartment->remote_parameters, lpParams->dmsCode);
|
||||
tcomp_params_setCpbCode(compartment->remote_parameters, lpParams->smsCode);
|
||||
tcomp_params_setDmsCode(compartment->remote_parameters, lpParams->dmsCode);
|
||||
tcomp_params_setSmsCode(compartment->remote_parameters, lpParams->smsCode);
|
||||
}
|
||||
|
||||
/* SigComp version */
|
||||
|
@ -116,13 +116,13 @@ void tcomp_compartment_setRetFeedback(tcomp_compartment_t *compartment, tcomp_bu
|
|||
compartment->lpRetFeedback = _TCOMP_BUFFER_CREATE(tcomp_buffer_getBuffer(feedback), tcomp_buffer_getSize(feedback));
|
||||
|
||||
#if USE_ONLY_ACKED_STATES
|
||||
//
|
||||
// ACK STATE ==> Returned feedback contains the partial state-id.
|
||||
//
|
||||
if(compartment->compressorData && !compartment->compressorData->isStream)
|
||||
/*
|
||||
* ACK STATE ==> Returned feedback contains the partial state-id.
|
||||
*/
|
||||
if(compartment->compressorData && !compartment->compressorData_isStream)
|
||||
{
|
||||
tcomp_buffer_handle_t *stateid = _TCOMP_BUFFER_CREATE(tcomp_buffer_getBufferAtPos(feedback, 1), tcomp_buffer_getSize(feedback)-1);
|
||||
tcomp_compressordata_ackGhost(compartment->compressorData, stateid);
|
||||
compartment->ackGhost(compartment->compressorData, stateid);
|
||||
TCOMP_BUFFER_SAFE_FREE(stateid);
|
||||
}
|
||||
#endif
|
||||
|
@ -142,7 +142,7 @@ void tcomp_compartment_clearStates(tcomp_compartment_t *compartment)
|
|||
|
||||
tsk_safeobj_lock(compartment);
|
||||
|
||||
TSK_LIST_SAFE_FREE(compartment->local_states);
|
||||
tsk_list_clear_items(compartment->local_states);
|
||||
compartment->total_memory_left = compartment->total_memory_size;
|
||||
|
||||
tsk_safeobj_unlock(compartment);
|
||||
|
@ -224,6 +224,7 @@ void tcomp_compartment_freeState(tcomp_compartment_t *compartment, tcomp_state_t
|
|||
compartment->total_memory_left += TCOMP_GET_STATE_SIZE(*lpState);
|
||||
tsk_list_remove_item_by_data(compartment->local_states, *lpState);
|
||||
*lpState = 0;
|
||||
TSK_DEBUG_INFO("SigComp - Free state.");
|
||||
|
||||
tsk_safeobj_unlock(compartment);
|
||||
}
|
||||
|
@ -301,10 +302,10 @@ void tcomp_compartment_addState(tcomp_compartment_t *compartment, tcomp_state_t
|
|||
tsk_safeobj_lock(compartment);
|
||||
|
||||
tcomp_state_makeValid(*lpState);
|
||||
tcomp_buffer_nprint((*lpState)->identifier, 6);
|
||||
tsk_list_add_data(compartment->local_states, ((void**) lpState));
|
||||
compartment->total_memory_left -= TCOMP_GET_STATE_SIZE(*lpState);
|
||||
tsk_list_add_data(compartment->local_states, ((void**) lpState));
|
||||
|
||||
TSK_DEBUG_INFO("SigComp - Add new state.");
|
||||
*lpState = 0;
|
||||
|
||||
tsk_safeobj_unlock(compartment);
|
||||
|
@ -357,7 +358,7 @@ void tcomp_compartment_freeGhostState(tcomp_compartment_t *compartment)
|
|||
|
||||
if(compartment->compressorData)
|
||||
{
|
||||
tcomp_compressordata_freeGhostState(compartment->compressorData);
|
||||
compartment->freeGhostState(compartment->compressorData);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -382,18 +383,23 @@ void tcomp_compartment_addNack(tcomp_compartment_t *compartment, const uint8_t n
|
|||
tsk_safeobj_lock(compartment);
|
||||
|
||||
// FIXME: very bad
|
||||
if(tcomp_buffer_getSize(compartment->nacks) >= NACK_MAX_HISTORY_SIZE)
|
||||
if(compartment->nacks_history_count >= NACK_MAX_HISTORY_SIZE)
|
||||
{
|
||||
assert(0);
|
||||
/*std::list<SigCompBuffer*>::iterator it = this->nacks.end(); it--;
|
||||
SigCompBuffer* lpBuffer = *it;
|
||||
this->nacks.erase(it);
|
||||
SAFE_DELETE_PTR(lpBuffer);*/
|
||||
tsk_list_item_t *item;
|
||||
tsk_list_item_t *item2delete = 0;
|
||||
|
||||
tsk_list_foreach(item, compartment->nacks)
|
||||
{
|
||||
item2delete = item;
|
||||
}
|
||||
tsk_list_remove_item(compartment->nacks, item2delete);
|
||||
compartment->nacks_history_count--;
|
||||
}
|
||||
|
||||
|
||||
id = _TCOMP_BUFFER_CREATE(nackId, TSK_SHA1HashSize);
|
||||
tsk_list_add_data(compartment->nacks, ((void**) &id));
|
||||
compartment->nacks_history_count++;
|
||||
|
||||
tsk_safeobj_unlock(compartment);
|
||||
}
|
||||
|
@ -421,6 +427,7 @@ int tcomp_compartment_hasNack(tcomp_compartment_t *compartment, const tcomp_buff
|
|||
|
||||
if(tcomp_buffer_equals(curr, nackId))
|
||||
{
|
||||
TSK_DEBUG_INFO("SigComp - Nack found.");
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -467,6 +474,9 @@ static void* tcomp_compartment_create(void * self, va_list * app)
|
|||
|
||||
// I always assume that remote params are equal to local params
|
||||
|
||||
/* Identifier */
|
||||
compartment->identifier = id;
|
||||
|
||||
/* Remote parameters */
|
||||
compartment->remote_parameters = TCOMP_PARAMS_CREATE();
|
||||
tcomp_params_setParameters(compartment->remote_parameters, sigCompParameters);
|
||||
|
@ -509,7 +519,9 @@ static void* tcomp_compartment_destroy(void *self)
|
|||
TSK_LIST_SAFE_FREE(compartment->nacks);
|
||||
|
||||
/* Delete Compressor data */
|
||||
TCOMP_COMPRESSORDATA_SAFE_FREE(compartment->compressorData);
|
||||
tsk_object_unref(compartment->compressorData);
|
||||
compartment->ackGhost = 0;
|
||||
compartment->freeGhostState = 0;
|
||||
|
||||
/* Delete params */
|
||||
TCOMP_PARAMS_SAFE_FREE(compartment->local_parameters);
|
||||
|
@ -525,13 +537,19 @@ static void* tcomp_compartment_destroy(void *self)
|
|||
return self;
|
||||
}
|
||||
|
||||
static int tcomp_compartment_cmp(const void *obj1, const void *obj2)
|
||||
{
|
||||
const tcomp_compartment_t *compartment1 = obj1;
|
||||
const tcomp_compartment_t *compartment2 = obj2;
|
||||
uint64_t res = (compartment1->identifier - compartment2->identifier);
|
||||
return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tsk_compartment_def_s =
|
||||
{
|
||||
sizeof(tcomp_compartment_t),
|
||||
tcomp_compartment_create,
|
||||
tcomp_compartment_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
tcomp_compartment_cmp
|
||||
};
|
||||
const void *tcomp_compartment_def_t = &tsk_compartment_def_s;
|
|
@ -43,7 +43,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#define TCOMP_COMPARTMENT_CREATE(id, sigCompParameters) tsk_object_new(tcomp_compartment_def_t, (uint64_t)id, (uint16_t)sigCompParameters)
|
||||
#define TCOMP_COMPARTMENT_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_COMPARTMENT_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
typedef struct tcomp_compartment_s
|
||||
{
|
||||
|
@ -63,9 +63,10 @@ typedef struct tcomp_compartment_s
|
|||
tcomp_buffer_handle_t *lpReqFeedback;
|
||||
tcomp_buffer_handle_t *lpRetFeedback;
|
||||
|
||||
tcomp_compressordata_t* compressorData;
|
||||
TCOMP_DECLARE_COMPRESSORDATA;
|
||||
|
||||
tcomp_buffers_L_t* nacks;
|
||||
uint8_t nacks_history_count;
|
||||
|
||||
TSK_DECLARE_SAFEOBJ;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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 tcomp_compressor.h
|
||||
* @brief Compression function definition.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TCOMP_COMPRESSOR_H
|
||||
#define TCOMP_COMPRESSOR_H
|
||||
|
||||
#include "tinysigcomp_config.h"
|
||||
#include "tcomp_compartment.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @typedef int (*tcomp_compressor_compress)(tcomp_compartment_t *lpCompartment,
|
||||
/// const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size,
|
||||
/// int stream)
|
||||
///
|
||||
/// @brief Function pointer definition for compression method.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef int (*tcomp_compressor_compress)(tcomp_compartment_t *lpCompartment, const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size, int stream);
|
||||
|
||||
#endif /* TCOMP_COMPRESSOR_H */
|
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* 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 tcomp_compressor.h
|
||||
* @brief Deflate compressor.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tcomp_compressor_deflate.h"
|
||||
#include "tcomp_deflatedata.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
|
||||
#define TCOMP_MIN(a, b) (a < b ? a : b)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn int tcomp_compressor_deflate_compress(tcomp_compartment_t *lpCompartment,
|
||||
/// const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size,
|
||||
/// int stream)
|
||||
///
|
||||
/// @brief Compress SIgComp message using deflate algorithm.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 11/29/2009
|
||||
///
|
||||
/// @param [in,out] lpCompartment If non-null, the pointer to a compartment.
|
||||
/// @param [in,out] input_ptr If non-null, the input pointer.
|
||||
/// @param input_size Size of the input.
|
||||
/// @param [in,out] output_ptr If non-null, the output pointer.
|
||||
/// @param [in,out] output_size If non-null, size of the output.
|
||||
/// @param stream The stream.
|
||||
///
|
||||
/// @return .
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int tcomp_compressor_deflate_compress(tcomp_compartment_t *lpCompartment, const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size, int stream)
|
||||
{
|
||||
#define GET_OUTPUT_BUFFER_AT(position) (((uint8_t*)output_ptr) + position)
|
||||
|
||||
int result = 1, stateChanged, stateful, windowBits, zret;
|
||||
tcomp_deflatedata_t *deflatedata = 0;
|
||||
size_t pointer = 0, state_len_index = 0, compressedDataLen;
|
||||
uint8_t smsCode, *header;
|
||||
|
||||
tsk_safeobj_lock(lpCompartment);
|
||||
|
||||
/* Compression Data */
|
||||
if(!lpCompartment->compressorData)
|
||||
{
|
||||
lpCompartment->compressorData = TCOMP_DEFLATEDATA_CREATE(stream);
|
||||
if(!lpCompartment->compressorData)
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create deflate compressor data.");
|
||||
result = 0;
|
||||
goto bail;
|
||||
}
|
||||
else
|
||||
{
|
||||
lpCompartment->ackGhost = tcomp_deflatedata_ackGhost;
|
||||
lpCompartment->freeGhostState = tcomp_deflatedata_freeGhostState;
|
||||
lpCompartment->compressorData_isStream = stream;
|
||||
}
|
||||
}
|
||||
|
||||
deflatedata = lpCompartment->compressorData;
|
||||
|
||||
/* State memory size code */
|
||||
smsCode = TCOMP_MIN(lpCompartment->remote_parameters->smsCode, lpCompartment->remote_parameters->dmsCode);
|
||||
#if USE_ONLY_ACKED_STATES
|
||||
stateful = (deflatedata->ghostState && tcomp_deflatedata_isStateful(deflatedata));
|
||||
#else
|
||||
stateful = (deflatedata->ghostState != 0);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Init zLIB
|
||||
*/
|
||||
windowBits = ( smsCode - (stream?2:1) ) + 10;
|
||||
windowBits = (windowBits < 8) ? 8 : ( (windowBits > 15 ? 15 : windowBits) ); /* Because of zlib limitation (windowsize MUST be between 8 and 15) */
|
||||
if(windowBits != deflatedata->zWindowBits)
|
||||
{
|
||||
/* Window size changed */
|
||||
tcomp_deflatedata_freeGhostState(deflatedata);
|
||||
tcomp_deflatedata_zSetWindowBits(deflatedata, windowBits);
|
||||
|
||||
if( !(result = tcomp_deflatedata_zReset(deflatedata)) )
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
else if(!deflatedata->ghostState)
|
||||
{
|
||||
/* No ghost --> reset zlib */
|
||||
deflatedata->ghost_copy_offset = 0;
|
||||
if( !(result = tcomp_deflatedata_zReset(deflatedata)) )
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* SigComp headers
|
||||
*/
|
||||
header = GET_OUTPUT_BUFFER_AT(pointer++);
|
||||
|
||||
|
||||
/* SigComp Header */
|
||||
if(lpCompartment->lpReqFeedback && tcomp_buffer_getSize(lpCompartment->lpReqFeedback))
|
||||
{
|
||||
/* Return the requested feedback */
|
||||
*header = 0xfc; /* T=1 */
|
||||
memcpy(GET_OUTPUT_BUFFER_AT(pointer), tcomp_buffer_getBuffer(lpCompartment->lpReqFeedback), tcomp_buffer_getSize(lpCompartment->lpReqFeedback));
|
||||
pointer += tcomp_buffer_getSize(lpCompartment->lpReqFeedback);
|
||||
}
|
||||
else
|
||||
{
|
||||
*header = 0xf8;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stateless or stateful?
|
||||
*/
|
||||
if(stateful)
|
||||
{
|
||||
memcpy(GET_OUTPUT_BUFFER_AT(pointer), tcomp_buffer_getBuffer(deflatedata->ghostState->identifier), TCOMP_PARTIAL_ID_LEN_VALUE);
|
||||
|
||||
pointer += TCOMP_PARTIAL_ID_LEN_VALUE;
|
||||
*header |= TCOMP_PARTIAL_ID_LEN_CODE;
|
||||
|
||||
TSK_DEBUG_INFO("Compressing stateful message.");
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t codeLen = DEFLATE_BYTECODE_LEN;
|
||||
/* first byte for codelen */
|
||||
*GET_OUTPUT_BUFFER_AT(pointer++) = ((codeLen>>4)& 0x00ff);
|
||||
/* last 4 bits for codelen */
|
||||
*GET_OUTPUT_BUFFER_AT(pointer) = ((codeLen & 0x000f)<<4);
|
||||
/* first and last 4 bits for destination */
|
||||
*GET_OUTPUT_BUFFER_AT(pointer++) |= DEFLATE_BYTECODE_DESTINATION_CODE;
|
||||
|
||||
/*
|
||||
* Upload UDVM bytecode
|
||||
*/
|
||||
memcpy(GET_OUTPUT_BUFFER_AT(pointer), (const uint8_t*)DEFLATEDATA_DEFLATE_BYTECODE, codeLen);
|
||||
pointer += codeLen;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// FIXME: check for overflow and >=320
|
||||
//
|
||||
// [DMS]+[Req. Fed. Loc.]+[state_len]+[cpb||dms||sms]+[Sigcomp_version]+[states]
|
||||
//*output_buffer.getBuffer(pointer++) = 0x04; //reserved=0, Q=1, S=0, I=0
|
||||
//*output_buffer.getBuffer(pointer++) = (this->req_feedback_item++); //requested feedback item
|
||||
|
||||
state_len_index = pointer;
|
||||
*GET_OUTPUT_BUFFER_AT(pointer) = 0x00, pointer += 4; /* [hash_len]+[state_len] */
|
||||
*GET_OUTPUT_BUFFER_AT(pointer++) = (tcomp_params_getParameters(lpCompartment->local_parameters)>>8); // [cpb||dms||sms]
|
||||
*GET_OUTPUT_BUFFER_AT(pointer++) = (tcomp_params_getParameters(lpCompartment->local_parameters)&0x00ff); // [Sigcomp_version]
|
||||
#if USE_DICTS_FOR_COMPRESSION
|
||||
*output_buffer.getBuffer(pointer++) = 0x00; // First dict byte // FIXME
|
||||
*output_buffer.getBuffer(pointer++) = DEFLATE_FIXME_DICT; // FIXME: also change ghost
|
||||
#endif
|
||||
TSK_DEBUG_INFO("Compressing stateless message.");
|
||||
}
|
||||
|
||||
/*
|
||||
* Compress data using ZLIB
|
||||
*/
|
||||
compressedDataLen = (*output_size - pointer);
|
||||
zret = tcomp_deflatedata_zCompress(deflatedata, input_ptr, input_size, GET_OUTPUT_BUFFER_AT(pointer), &compressedDataLen, &stateChanged);
|
||||
if(!zret)
|
||||
{
|
||||
result = 0;
|
||||
goto bail;
|
||||
}
|
||||
pointer += compressedDataLen;
|
||||
*output_size = (pointer);
|
||||
|
||||
/*
|
||||
* Update state length
|
||||
*/
|
||||
if(!stateful)
|
||||
{
|
||||
uint16_t state_len = ( (1<<(deflatedata->zWindowBits)) + DEFLATE_UDVM_CIRCULAR_START_INDEX - 64 );
|
||||
uint32_t hash_len = (state_len + 8);
|
||||
|
||||
// FIXME: 131072 could not go in 2-bytes
|
||||
*GET_OUTPUT_BUFFER_AT(state_len_index) = (hash_len >> 8);
|
||||
*GET_OUTPUT_BUFFER_AT(state_len_index+1) = (hash_len & 0x00ff);
|
||||
*GET_OUTPUT_BUFFER_AT(state_len_index+2) = (state_len >> 8);
|
||||
*GET_OUTPUT_BUFFER_AT(state_len_index+3) = (state_len & 0x00ff);
|
||||
|
||||
/* First time or synchronize failure (NACK reason=STATE_NOT_FOUND) */
|
||||
if(!deflatedata->ghostState)
|
||||
{
|
||||
tcomp_deflatedata_createGhost(deflatedata, state_len, lpCompartment->local_parameters);
|
||||
}
|
||||
}
|
||||
#if USE_ONLY_ACKED_STATES
|
||||
if(stateChanged)
|
||||
#endif
|
||||
{
|
||||
tcomp_deflatedata_updateGhost(deflatedata, (const uint8_t*)input_ptr, input_size);
|
||||
}
|
||||
|
||||
//output_buffer.print(2000);
|
||||
|
||||
bail:
|
||||
tsk_safeobj_unlock(lpCompartment);
|
||||
|
||||
return result;
|
||||
|
||||
#undef GET_OUTPUT_BUFFER_AT
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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 tcomp_compressor.h
|
||||
* @brief Deflate compressor.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TCOMP_COMPRESSORDEFLATE_H
|
||||
#define TCOMP_COMPRESSORDEFLATE_H
|
||||
|
||||
#include "tinysigcomp_config.h"
|
||||
#include "tcomp_compartment.h"
|
||||
|
||||
int tcomp_compressor_deflate_compress(tcomp_compartment_t *lpCompartment, const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size, int stream);
|
||||
|
||||
#endif /* TCOMP_COMPRESSORDEFLATE_H */
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* 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 tcomp_compressor_dummy.h
|
||||
* @brief SigComp dummy compresor. Used if none match. See RFC 4896 subclause 11.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
|
||||
#include "tcomp_compressor_dummy.h"
|
||||
#include "tcomp_buffer.h"
|
||||
|
||||
#define UNCOMPRESSED_BYTECODE_LENGTH 13
|
||||
#define UNCOMPRESSED_BYTECODE_DESTINATION_CODE 0x01 /* 128 */
|
||||
#define DUMMYCOMPRESSOR_UNCOMPRESSED_BYTECODE \
|
||||
"\xf8\x00\xa1\x1c\x01\x86\x09\x22\x86\x01\x16\xf9\x23"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn static int tcomp_compressor_dummy_compress(tcomp_compartment_t *lpCompartment,
|
||||
/// const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size,
|
||||
/// int stream)
|
||||
///
|
||||
/// @brief Dummy compressor as per RFC 4896 subclause 11. This function is used to create uncompressed sigcomp message.
|
||||
/// Used if none match.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 11/28/2009
|
||||
///
|
||||
/// @param [in,out] lpCompartment The compartment to use.
|
||||
/// @param [in,out] input_ptr The input buffer containing the message to compress.
|
||||
/// @param input_size The size of the input buffer.
|
||||
/// @param [in,out] output_ptr The output buffer where to copy the compressed message.
|
||||
/// @param [in,out] output_size The size of the output buffer.
|
||||
/// @param stream Indicates whether it's a stream buffer or not.
|
||||
///
|
||||
/// @return 1 if succedd and 0 otherwise.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int tcomp_compressor_dummy_compress(tcomp_compartment_t *lpCompartment, const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size, int stream)
|
||||
{
|
||||
tcomp_buffer_handle_t *output_buffer = TCOMP_BUFFER_CREATE();
|
||||
size_t pointer = 0;
|
||||
uint8_t *header;
|
||||
uint16_t codeLen;
|
||||
|
||||
tcomp_buffer_referenceBuff(output_buffer, (uint8_t*)output_ptr, *output_size);
|
||||
header = tcomp_buffer_getBufferAtPos(output_buffer, pointer++);
|
||||
|
||||
/* SigComp Header */
|
||||
if(lpCompartment->lpReqFeedback && tcomp_buffer_getSize(lpCompartment->lpReqFeedback))
|
||||
{
|
||||
/* Return the requested feedback */
|
||||
*header = 0xfc; /* T=1 */
|
||||
memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), tcomp_buffer_getBuffer(lpCompartment->lpReqFeedback), tcomp_buffer_getSize(lpCompartment->lpReqFeedback));
|
||||
pointer += tcomp_buffer_getSize(lpCompartment->lpReqFeedback);
|
||||
}
|
||||
else
|
||||
{
|
||||
*header = 0xf8;
|
||||
}
|
||||
|
||||
codeLen = UNCOMPRESSED_BYTECODE_LENGTH;
|
||||
/* first byte for codelen */
|
||||
*tcomp_buffer_getBufferAtPos(output_buffer, pointer++) = ((codeLen>>4)& 0x00ff);
|
||||
|
||||
/* last 4 bits for codelen */
|
||||
*tcomp_buffer_getBufferAtPos(output_buffer, pointer) = ((codeLen & 0x000f)<<4);
|
||||
|
||||
/* first and last 4 bits for destination */
|
||||
*tcomp_buffer_getBufferAtPos(output_buffer, pointer++) |= UNCOMPRESSED_BYTECODE_DESTINATION_CODE;
|
||||
|
||||
/*
|
||||
* Upload UDVM bytecode
|
||||
*/
|
||||
memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), (uint8_t*)DUMMYCOMPRESSOR_UNCOMPRESSED_BYTECODE, codeLen);
|
||||
pointer += codeLen;
|
||||
|
||||
/*
|
||||
* Copy data uncompressed
|
||||
*/
|
||||
memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), input_ptr, input_size);
|
||||
pointer += input_size;
|
||||
*output_size = (pointer);
|
||||
|
||||
TCOMP_BUFFER_SAFE_FREE(output_buffer);
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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 tcomp_compressor_dummy.h
|
||||
* @brief SigComp dummy compresor. Used if none match. See RFC 4896 subclause 11.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TCOMP_COMPRESSOR_DUMMY_H
|
||||
#define TCOMP_COMPRESSOR_DUMMY_H
|
||||
|
||||
#include "tinysigcomp_config.h"
|
||||
#include "tcomp_compartment.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int tcomp_compressor_dummy_compress(tcomp_compartment_t *lpCompartment, const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size, int stream);
|
||||
|
||||
#endif /* TCOMP_COMPRESSOR_DUMMY_H */
|
|
@ -1,119 +1,117 @@
|
|||
/*
|
||||
* 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 tcomp_compressordata.c
|
||||
* @brief SigComp compressor data.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tcomp_compressordata.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/**@defgroup tcomp_compressordata_group SigComp NACK information.
|
||||
*/
|
||||
|
||||
/**@ingroup tcomp_compressordata_group
|
||||
*/
|
||||
void tcomp_compressordata_ackGhost(tcomp_compressordata_t *compdata, const tcomp_buffer_handle_t *stateid)
|
||||
{
|
||||
if(compdata)
|
||||
{
|
||||
tsk_safeobj_lock(compdata);
|
||||
assert(0);
|
||||
tsk_safeobj_unlock(compdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL compressor data.");
|
||||
}
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_compressordata_group
|
||||
*/
|
||||
void tcomp_compressordata_freeGhostState(tcomp_compressordata_t *compdata)
|
||||
{
|
||||
if(compdata)
|
||||
{
|
||||
tsk_safeobj_lock(compdata);
|
||||
assert(0);
|
||||
tsk_safeobj_unlock(compdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL compressor data.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// SigComp compressor data object definition
|
||||
///*
|
||||
//* 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.
|
||||
//*
|
||||
//*/
|
||||
//
|
||||
static void* tcomp_compressordata_create(void * self, va_list * app)
|
||||
{
|
||||
tcomp_compressordata_t *compdata = self;
|
||||
if(compdata)
|
||||
{
|
||||
/* Initialize safeobject */
|
||||
tsk_safeobj_init(compdata);
|
||||
|
||||
compdata->isStream = va_arg(*app, int);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void* tcomp_compressordata_destroy(void *self)
|
||||
{
|
||||
tcomp_compressordata_t *compdata = self;
|
||||
if(compdata)
|
||||
{
|
||||
/* Deinitialize safeobject */
|
||||
tsk_safeobj_deinit(compdata);
|
||||
|
||||
TCOMP_STATE_SAFE_FREE(compdata->ghostState);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tsk_compressordata_def_s =
|
||||
{
|
||||
sizeof(tcomp_compressordata_t),
|
||||
tcomp_compressordata_create,
|
||||
tcomp_compressordata_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_compressordata_def_t = &tsk_compressordata_def_s;
|
||||
///**@file tcomp_compressordata.c
|
||||
// * @brief SigComp compressor data.
|
||||
// *
|
||||
// * @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
// *
|
||||
// * @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
// */
|
||||
//#include "tcomp_compressordata.h"
|
||||
//
|
||||
//#include "tsk_debug.h"
|
||||
//
|
||||
//#include <assert.h>
|
||||
//
|
||||
///**@defgroup tcomp_compressordata_group SigComp NACK information.
|
||||
//*/
|
||||
//
|
||||
///**@ingroup tcomp_compressordata_group
|
||||
//*/
|
||||
//void tcomp_compressordata_ackGhost(tcomp_compressordata_t *compdata, const tcomp_buffer_handle_t *stateid)
|
||||
//{
|
||||
// if(compdata)
|
||||
// {
|
||||
// tsk_safeobj_lock(compdata);
|
||||
// assert(0);
|
||||
// tsk_safeobj_unlock(compdata);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TSK_DEBUG_ERROR("NULL compressor data.");
|
||||
// }
|
||||
//}
|
||||
//
|
||||
///**@ingroup tcomp_compressordata_group
|
||||
//*/
|
||||
//void tcomp_compressordata_freeGhostState(tcomp_compressordata_t *compdata)
|
||||
//{
|
||||
// if(compdata)
|
||||
// {
|
||||
// tsk_safeobj_lock(compdata);
|
||||
// assert(0);
|
||||
// tsk_safeobj_unlock(compdata);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TSK_DEBUG_ERROR("NULL compressor data.");
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
////========================================================
|
||||
//// SigComp compressor data object definition
|
||||
////
|
||||
//static void* tcomp_compressordata_create(void * self, va_list * app)
|
||||
//{
|
||||
// tcomp_compressordata_t *compdata = self;
|
||||
// if(compdata)
|
||||
// {
|
||||
// /* Initialize safeobject */
|
||||
// tsk_safeobj_init(compdata);
|
||||
//
|
||||
// compdata->isStream = va_arg(*app, int);
|
||||
// }
|
||||
//
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
//static void* tcomp_compressordata_destroy(void *self)
|
||||
//{
|
||||
// tcomp_compressordata_t *compdata = self;
|
||||
// if(compdata)
|
||||
// {
|
||||
// /* Deinitialize safeobject */
|
||||
// tsk_safeobj_deinit(compdata);
|
||||
//
|
||||
// TCOMP_STATE_SAFE_FREE(compdata->ghostState);
|
||||
// }
|
||||
//
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
//static const tsk_object_def_t tsk_compressordata_def_s =
|
||||
//{
|
||||
// sizeof(tcomp_compressordata_t),
|
||||
// tcomp_compressordata_create,
|
||||
// tcomp_compressordata_destroy,
|
||||
// 0
|
||||
//};
|
||||
//const void *tcomp_compressordata_def_t = &tsk_compressordata_def_s;
|
|
@ -31,29 +31,42 @@
|
|||
#define TCOMP_COMPRESSOR_DATA_H
|
||||
|
||||
#include "tinysigcomp_config.h"
|
||||
#include "tcomp_state.h"
|
||||
#include "tcomp_buffer.h"
|
||||
|
||||
#include "tsk_object.h"
|
||||
#include "tsk_safeobj.h"
|
||||
typedef void tcomp_compressordata_t;
|
||||
|
||||
#define TCOMP_COMPRESSORDATA_CREATE(isStream) tsk_object_new(tsk_compressordata_def_t, isStream)
|
||||
#define TCOMP_COMPRESSORDATA_SAFE_FREE(self) tsk_object_unref(self)
|
||||
typedef void (*tcomp_xxx_freeGhostState)(tcomp_compressordata_t *data);
|
||||
typedef void (*tcomp_xxx_ackGhost)(tcomp_compressordata_t *data, const tcomp_buffer_handle_t *stateid);
|
||||
|
||||
typedef struct tcomp_compressordata_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
#define TCOMP_DECLARE_COMPRESSORDATA \
|
||||
void *compressorData; \
|
||||
unsigned compressorData_isStream; \
|
||||
tcomp_xxx_freeGhostState freeGhostState; \
|
||||
tcomp_xxx_ackGhost ackGhost
|
||||
|
||||
tcomp_state_t *ghostState;
|
||||
unsigned isStream:1;
|
||||
|
||||
TSK_DECLARE_SAFEOBJ;
|
||||
}
|
||||
tcomp_compressordata_t;
|
||||
|
||||
void tcomp_compressordata_ackGhost(tcomp_compressordata_t *compdata, const tcomp_buffer_handle_t *stateid);
|
||||
void tcomp_compressordata_freeGhostState(tcomp_compressordata_t *compdata);
|
||||
|
||||
TINYSIGCOMP_API const void *tcomp_compressordata_def_t;
|
||||
//#include "tcomp_state.h"
|
||||
//#include "tcomp_buffer.h"
|
||||
//
|
||||
//#include "tsk_object.h"
|
||||
//#include "tsk_safeobj.h"
|
||||
//
|
||||
//#define TCOMP_COMPRESSORDATA_CREATE(isStream) tsk_object_new(tsk_compressordata_def_t, isStream)
|
||||
//#define TCOMP_COMPRESSORDATA_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
//
|
||||
//typedef struct tcomp_compressordata_s
|
||||
//{
|
||||
// TSK_DECLARE_OBJECT;
|
||||
//
|
||||
// tcomp_state_t *ghostState;
|
||||
// unsigned isStream:1;
|
||||
//
|
||||
// TSK_DECLARE_SAFEOBJ;
|
||||
//}
|
||||
//tcomp_compressordata_t;
|
||||
//
|
||||
//void tcomp_compressordata_ackGhost(tcomp_compressordata_t *compdata, const tcomp_buffer_handle_t *stateid);
|
||||
//void tcomp_compressordata_freeGhostState(tcomp_compressordata_t *compdata);
|
||||
//
|
||||
//TINYSIGCOMP_API const void *tcomp_compressordata_def_t;
|
||||
|
||||
#endif /* TCOMP_COMPRESSOR_DATA_H */
|
|
@ -29,6 +29,10 @@
|
|||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tcomp_compressordisp.h"
|
||||
#include "tcomp_compressor_dummy.h"
|
||||
#include "tcomp_compressor_deflate.h"
|
||||
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
/**@defgroup tcomp_compressordisp_group SIGCOMP decompressor dispatcher.
|
||||
|
@ -36,9 +40,133 @@
|
|||
* endpoint.
|
||||
*/
|
||||
|
||||
#define TCOMP_NACK_SUPPORTED (dispatcher->stateHandler->sigcomp_parameters->SigComp_version >= 0x02)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn int tcomp_compressordisp_compress(tcomp_compressordisp_t *dispatcher,
|
||||
/// uint64_t compartmentId, const void *input_ptr, size_t input_size, void *output_ptr,
|
||||
/// size_t *output_size, int stream)
|
||||
///
|
||||
/// @brief Tcomp compressordisp compress.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 11/29/2009
|
||||
///
|
||||
/// @param [in,out] dispatcher The compressor dispatcher.
|
||||
/// @param compartmentId The compartment to use to compress the message.
|
||||
/// @param [in,out] input_ptr The message to compress.
|
||||
/// @param input_size The size of the input buffer.
|
||||
/// @param [in,out] output_ptr The output buffer to copy the compressed data.
|
||||
/// @param [in,out] output_size The size of the output buffer.
|
||||
/// @param stream Indicates whether it's a stream buffer ot not.
|
||||
///
|
||||
/// @return 1 if succeed and 0 otherwize.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int tcomp_compressordisp_compress(tcomp_compressordisp_t *dispatcher, uint64_t compartmentId, const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size, int stream)
|
||||
{
|
||||
int ret = 1;
|
||||
int i = 0;
|
||||
|
||||
/* For each compartment id create/retrieve one compressor instance */
|
||||
tcomp_compartment_t *lpCompartment = tcomp_statehandler_getCompartment(dispatcher->stateHandler, compartmentId);
|
||||
|
||||
if(!lpCompartment)
|
||||
{
|
||||
TSK_DEBUG_ERROR("You must provide a valid compartment to perform compression.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Performs compression.
|
||||
*/
|
||||
tsk_safeobj_lock(dispatcher);
|
||||
|
||||
for( i = 0; (i < TCOMP_MAX_COMPRESSORS && dispatcher->compressors[i]); i++ )
|
||||
{
|
||||
if((ret = dispatcher->compressors[i](lpCompartment, input_ptr, input_size, output_ptr, output_size, stream)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tsk_safeobj_unlock(dispatcher);
|
||||
|
||||
/*
|
||||
* STREAM case. FIXME:Because I'm a lazy man I only support 0xFF00 case
|
||||
*/
|
||||
if(stream)
|
||||
{
|
||||
uint8_t* escapedBuffer;
|
||||
size_t i, j;
|
||||
size_t escapedBufferSize = (*output_size + 2); /* 2 = strlen(0xffff) */
|
||||
|
||||
for(i = 0; i < *output_size ; i++)
|
||||
{
|
||||
escapedBufferSize += ((uint8_t*)output_ptr)[i] == 0xff ? 1 : 0;
|
||||
}
|
||||
escapedBuffer = (uint8_t*)tsk_calloc(escapedBufferSize, sizeof(uint8_t));
|
||||
|
||||
for(i = 0, j = 0; i < *output_size; i++, j++)
|
||||
{
|
||||
escapedBuffer[j] = ((uint8_t*)output_ptr)[i];
|
||||
if(escapedBuffer[j] == 0xff)
|
||||
{
|
||||
escapedBuffer[++j] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
/* End stream */
|
||||
escapedBuffer[escapedBufferSize-1] = escapedBuffer[escapedBufferSize-2] = 0xff;
|
||||
memcpy(output_ptr, escapedBuffer, escapedBufferSize);
|
||||
|
||||
*output_size = escapedBufferSize; /* Update size */
|
||||
TSK_FREE(escapedBuffer); /* free */
|
||||
}
|
||||
|
||||
/*
|
||||
* NACK
|
||||
*/
|
||||
if(ret && TCOMP_NACK_SUPPORTED)
|
||||
{
|
||||
/* store nack for later retrieval in case of errors */
|
||||
uint8_t nackId[TSK_SHA1HashSize];
|
||||
tsk_sha1context_t sha;
|
||||
|
||||
tsk_sha1reset(&sha);
|
||||
tsk_sha1input(&sha, (const uint8_t*)output_ptr, *output_size);
|
||||
tsk_sha1result(&sha, nackId);
|
||||
tcomp_compartment_addNack(lpCompartment, nackId);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn void tcomp_compressordisp_addCompressor(tcomp_compressordisp_t *dispatcher,
|
||||
/// tcomp_compressor_compress compressor)
|
||||
///
|
||||
/// @brief Add new compressor the list of the compressors.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 11/29/2009
|
||||
///
|
||||
/// @param [in,out] dispatcher The compressor dispatcher.
|
||||
/// @param compressor A function pointer to the new compressor.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void tcomp_compressordisp_addCompressor(tcomp_compressordisp_t *dispatcher, tcomp_compressor_compress compressor)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < TCOMP_MAX_COMPRESSORS; i++)
|
||||
{
|
||||
if(!dispatcher->compressors[i])
|
||||
{
|
||||
dispatcher->compressors[i] = compressor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -59,8 +187,17 @@ static void* tcomp_compressordisp_create(void * self, va_list * app)
|
|||
tcomp_compressordisp_t *compressordisp = self;
|
||||
if(compressordisp)
|
||||
{
|
||||
int i = 0;
|
||||
compressordisp->stateHandler = va_arg(*app, const tcomp_statehandler_t*);
|
||||
|
||||
compressordisp->compressors[0] = tcomp_compressor_deflate_compress; /* If you don't want deflate compressor then remove this line. */
|
||||
compressordisp->compressors[1] = tcomp_compressor_dummy_compress; /* RFC 4896 [11. Uncompressed Bytecode]. */
|
||||
|
||||
for(i = 2; i < TCOMP_MAX_COMPRESSORS; i++)
|
||||
{
|
||||
compressordisp->compressors[i] = 0;
|
||||
}
|
||||
|
||||
/* Initialize safeobject */
|
||||
tsk_safeobj_init(compressordisp);
|
||||
}
|
||||
|
@ -94,8 +231,6 @@ static const tsk_object_def_t tcomp_compressordisp_def_s =
|
|||
sizeof(tcomp_compressordisp_t),
|
||||
tcomp_compressordisp_create,
|
||||
tcomp_compressordisp_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_compressordisp_def_t = &tcomp_compressordisp_def_s;
|
|
@ -36,19 +36,24 @@
|
|||
#include "tcomp_buffer.h"
|
||||
#include "tcomp_types.h"
|
||||
#include "tcomp_result.h"
|
||||
#include "tcomp_compressor.h"
|
||||
|
||||
#include "tsk_list.h"
|
||||
#include "tsk_object.h"
|
||||
#include "tsk_safeobj.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define TCOMP_MAX_COMPRESSORS 5
|
||||
|
||||
#define TCOMP_COMPRESSORDISP_CREATE(statehandler) tsk_object_new(tcomp_compressordisp_def_t, (const tcomp_statehandler_t*)statehandler)
|
||||
#define TCOMP_COMPRESSORDISP_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_COMPRESSORDISP_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
typedef struct tcomp_compressordisp_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
tcomp_compressor_compress compressors[TCOMP_MAX_COMPRESSORS];
|
||||
const tcomp_statehandler_t* stateHandler;
|
||||
|
||||
TSK_DECLARE_SAFEOBJ;
|
||||
|
@ -56,6 +61,10 @@ typedef struct tcomp_compressordisp_s
|
|||
tcomp_compressordisp_t;
|
||||
|
||||
|
||||
int tcomp_compressordisp_compress(tcomp_compressordisp_t *dispatcher, uint64_t compartmentId, const void *input_ptr, size_t input_size, void *output_ptr, size_t *output_size, int stream);
|
||||
|
||||
void tcomp_compressordisp_addCompressor(tcomp_compressordisp_t *dispatcher, tcomp_compressor_compress compressor);
|
||||
|
||||
TINYSIGCOMP_API const void *tcomp_compressordisp_def_t;
|
||||
|
||||
#endif /* TCOMP_COMPRESSORDISP_H */
|
|
@ -50,9 +50,10 @@ static int pred_find_streambuffer_by_id(const tsk_list_item_t *item, const void
|
|||
if(item && item->data)
|
||||
{
|
||||
tcomp_stream_buffer_t *streambuffer = item->data;
|
||||
return (streambuffer->id == *((uint64_t*)id));
|
||||
uint64_t res = (streambuffer->id - *((uint64_t*)id));
|
||||
return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,21 +175,21 @@ int tcomp_decompressordisp_getNextMessage(tcomp_decompressordisp_t *dispatcher,
|
|||
*/
|
||||
int tcomp_decompressordisp_internalDecompress(tcomp_decompressordisp_t *dispatcher, const void* input_ptr, const size_t input_size, tcomp_result_t **lpResult)
|
||||
{
|
||||
tcomp_message_t *sigCompMessage;
|
||||
tcomp_udvm_t *sigCompUDVM;
|
||||
int ret;
|
||||
tcomp_message_t *sigCompMessage = 0;
|
||||
tcomp_udvm_t *sigCompUDVM = 0;
|
||||
int ret = 0;
|
||||
|
||||
if(!dispatcher)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL sigcomp decompressor dispatcher.");
|
||||
return 0;
|
||||
}
|
||||
goto bail;
|
||||
}
|
||||
|
||||
sigCompMessage = TCOMP_MESSAGE_CREATE(input_ptr, input_size, (*lpResult)->isStreamBased);
|
||||
if(!sigCompMessage || !sigCompMessage->isOK)
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new sigcomp message.");
|
||||
return 0;
|
||||
goto bail;
|
||||
}
|
||||
else if(sigCompMessage->isNack && TCOMP_NACK_SUPPORTED(dispatcher))
|
||||
{
|
||||
|
@ -196,7 +197,7 @@ int tcomp_decompressordisp_internalDecompress(tcomp_decompressordisp_t *dispatch
|
|||
tcomp_statehandler_handleNack((tcomp_statehandler_t*)dispatcher->stateHandler, (const tcomp_nackinfo_t*)sigCompMessage->nack_info);
|
||||
(*lpResult)->isNack = 1;
|
||||
|
||||
return 0;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
/* Create new UDVM entity for each SigComp message */
|
||||
|
@ -212,6 +213,10 @@ int tcomp_decompressordisp_internalDecompress(tcomp_decompressordisp_t *dispatch
|
|||
(*lpResult)->isNack = TCOMP_NACK_SUPPORTED(dispatcher);
|
||||
}
|
||||
|
||||
bail:
|
||||
/* Delete Message */
|
||||
TCOMP_MESSAGE_SAFE_FREE(sigCompMessage);
|
||||
|
||||
/* Delete UDVM entity */
|
||||
TCOMP_UDVM_SAFE_FREE(sigCompUDVM);
|
||||
|
||||
|
@ -385,8 +390,6 @@ static const tsk_object_def_t tcomp_decompressordisp_def_s =
|
|||
sizeof(tcomp_decompressordisp_t),
|
||||
tcomp_decompressordisp_create,
|
||||
tcomp_decompressordisp_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_decompressordisp_def_t = &tcomp_decompressordisp_def_s;
|
||||
|
@ -434,8 +437,6 @@ static const tsk_object_def_t tcomp_stream_buffer_def_s =
|
|||
sizeof(tcomp_stream_buffer_t),
|
||||
tcomp_stream_buffer_create,
|
||||
tcomp_stream_buffer_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_stream_buffer_def_t = &tcomp_stream_buffer_def_s;
|
|
@ -36,16 +36,17 @@
|
|||
#include "tcomp_types.h"
|
||||
#include "tcomp_result.h"
|
||||
|
||||
|
||||
#include "tsk_object.h"
|
||||
#include "tsk_safeobj.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define TCOMP_STREAM_BUFFER_CREATE(id) tsk_object_new(tcomp_stream_buffer_def_t, (uint64_t)id)
|
||||
#define TCOMP_STREAM_BUFFER_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_STREAM_BUFFER_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
#define TCOMP_DECOMPRESSORDISP_CREATE(statehandler) tsk_object_new(tcomp_decompressordisp_def_t, (const tcomp_statehandler_t*)statehandler)
|
||||
#define TCOMP_DECOMPRESSORDISP_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_DECOMPRESSORDISP_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
typedef struct tcomp_stream_buffer_s
|
||||
{
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* 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 tcomp_compressor.h
|
||||
* @brief Deflate compressor data.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tcomp_deflatedata.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
|
||||
/**@defgroup tcomp_deflatedata_group Deflate compressor data.
|
||||
*/
|
||||
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
int tcomp_deflatedata_isStateful(tcomp_deflatedata_t *deflatedata)
|
||||
{
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return deflatedata->stream_acked.stateful;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Deflate compressor data object definition
|
||||
//
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
static void* tcomp_deflatedata_create(void * self, va_list * app)
|
||||
{
|
||||
tcomp_deflatedata_t *deflatedata = self;
|
||||
if(deflatedata)
|
||||
{
|
||||
/* Initialize safeobject */
|
||||
tsk_safeobj_init(deflatedata);
|
||||
|
||||
deflatedata->stream = va_arg(*app, int);
|
||||
deflatedata->zLevel = va_arg(*app, int);
|
||||
deflatedata->zWindowBits = va_arg(*app, int);;
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null SigComp defalte data.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
static void* tcomp_deflatedata_destroy(void *self)
|
||||
{
|
||||
tcomp_deflatedata_t *deflatedata = self;
|
||||
if(deflatedata)
|
||||
{
|
||||
/* Deinitialize safeobject */
|
||||
tsk_safeobj_deinit(deflatedata);
|
||||
|
||||
tcomp_deflatedata_zUnInit(deflatedata);
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null SigComp defalte data.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tsk_deflatedata_def_s =
|
||||
{
|
||||
sizeof(tcomp_deflatedata_t),
|
||||
tcomp_deflatedata_create,
|
||||
tcomp_deflatedata_destroy,
|
||||
0,
|
||||
};
|
||||
const void *tcomp_deflatedata_def_t = &tsk_deflatedata_def_s;
|
|
@ -0,0 +1,277 @@
|
|||
/*
|
||||
* 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 tcomp_compressor.h
|
||||
* @brief Deflate compressor data.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tcomp_deflatedata.h"
|
||||
|
||||
#include "tsk_binaryutils.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
|
||||
/*
|
||||
|<----------------------------DMS--------------------------------->|
|
||||
|<-----SigComp message---->|<------------UDVM memory size--------->|
|
||||
+-+----------+-------------+-----+----------+----------------------+
|
||||
| | bytecode | comp msg | | bytecode | circular buffer |
|
||||
+-+----------+-------------+-----+----------+----------------------+
|
||||
^ ^
|
||||
| |
|
||||
SigComp header Low bytes of UDVM
|
||||
|
||||
I suppose we would like to compress this message "libsigcomp":
|
||||
GHOST STRUCTURE:
|
||||
0x02bb --> Circular Buffer size (DEFLATE_UDVM_CIRCULAR_START_INDEX = 699)
|
||||
0x2000 --> DMS (8192)
|
||||
0x0005 --> See 'libsigcomp/asm/deflate.asm' (MULTILOAD param number five)
|
||||
0x02c5 --> 709 (DEFLATE_UDVM_CIRCULAR_START_INDEX + strlen("libsigcomp"))
|
||||
...... --> Remaining MULTILOAD words
|
||||
0x0682 --> 1666 (HASH_LEN = SMS+8)
|
||||
0x067a --> 1658 (SMS)
|
||||
0x1902 --> [CPB+DMS+SMS]+[SigComp version]
|
||||
------------------------------------------------------------
|
||||
0x0003 --> DEFLATE_NO_DICT
|
||||
...... --> Dictionnary words
|
||||
0x0000 --> FIXME
|
||||
0x0000 --> FIXME
|
||||
...... --> Deflate byte code (DeflateCompressor::deflate_bytecode)
|
||||
...... --> no compressed message
|
||||
*/
|
||||
|
||||
#define GHOST_CB_START_INDEX (0)
|
||||
#define GHOST_DMS_INDEX (GHOST_CB_START_INDEX + 2)
|
||||
#define GHOST_0x0005_INDEX (GHOST_DMS_INDEX + 2)
|
||||
#define GHOST_CB_END_INDEX (GHOST_0x0005_INDEX + 2)
|
||||
#define GHOST_HASH_LEN_INDEX (GHOST_CB_END_INDEX + 2 + 236)
|
||||
#define GHOST_SMS_INDEX (GHOST_HASH_LEN_INDEX + 2)
|
||||
#define GHOST_CPB_DMS_SMS_INDEX (GHOST_SMS_INDEX + 2)
|
||||
#define GHOST_VERSION_INDEX (GHOST_CPB_DMS_SMS_INDEX + 1)
|
||||
|
||||
#define GHOST_BYTECODE1_SIZE (GHOST_VERSION_INDEX + 1)
|
||||
|
||||
static const char* DeflateData_deflate_bytecode1_ghost =
|
||||
{
|
||||
"\xff\xff" // Circular buffer Size (CBS)
|
||||
"\xff\xff" // State Memory Size (DMS)
|
||||
"\x00\x05" // See 'libsigcomp/asm/deflate.asm'
|
||||
"\xff\xff" // (CBS + strlen(input))
|
||||
|
||||
"\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\x09\x00\x00"
|
||||
"\x00\x0a\x00\x01\x00\x0b\x00\x01\x00\x0d\x00\x01\x00\x0f\x00\x01\x00\x11\x00\x02\x00\x13\x00\x02\x00\x17\x00\x02\x00\x1b"
|
||||
"\x00\x02\x00\x1f\x00\x03\x00\x23\x00\x03\x00\x2b\x00\x03\x00\x33\x00\x03\x00\x3b\x00\x04\x00\x43\x00\x04\x00\x53\x00\x04"
|
||||
"\x00\x63\x00\x04\x00\x73\x00\x05\x00\x83\x00\x05\x00\xa3\x00\x05\x00\xc3\x00\x05\x00\xe3\x00\x00\x01\x02\x00\x00\x00\x01"
|
||||
"\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x01\x00\x05\x00\x01\x00\x07\x00\x02\x00\x09\x00\x02\x00\x0d\x00\x03"
|
||||
"\x00\x11\x00\x03\x00\x19\x00\x04\x00\x21\x00\x04\x00\x31\x00\x05\x00\x41\x00\x05\x00\x61\x00\x06\x00\x81\x00\x06\x00\xc1"
|
||||
"\x00\x07\x01\x01\x00\x07\x01\x81\x00\x08\x02\x01\x00\x08\x03\x01\x00\x09\x04\x01\x00\x09\x06\x01\x00\x0a\x08\x01\x00\x0a"
|
||||
"\x0c\x01\x00\x0b\x10\x01\x00\x0b\x18\x01\x00\x0c\x20\x01\x00\x0c\x30\x01\x00\x0d\x40\x01\x00\x0d\x60\x01"
|
||||
|
||||
"\xff\xff" // HASH_LEN
|
||||
"\xff\xff" // SMS
|
||||
"\xff" // [CPB+DMS+SMS]
|
||||
"\xff" // SigComp Version
|
||||
};
|
||||
|
||||
|
||||
#define GHOST_STATE_ADDRESS 64
|
||||
#define GHOST_STATE_INSTRUCTION 492
|
||||
#define GHOST_STATE_MIN_ACCESS_LEN 6
|
||||
#define GHOST_STATE_RETENTION_PRIORITY 0
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
void tcomp_deflatedata_createGhost(tcomp_deflatedata_t *deflatedata, uint16_t state_length, tcomp_params_t *params)
|
||||
{
|
||||
uint8_t *ghostvalue_ptr = 0;
|
||||
#define GHOSTVALUE_AT(position) (ghostvalue_ptr + position)
|
||||
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(deflatedata->ghostState)
|
||||
{
|
||||
TSK_DEBUG_ERROR("The defalte data already have a ghost state. This MUST never happen.");
|
||||
return;
|
||||
}
|
||||
|
||||
tsk_safeobj_lock(deflatedata);
|
||||
|
||||
deflatedata->ghostState = TCOMP_STATE_CREATE(state_length, GHOST_STATE_ADDRESS, GHOST_STATE_INSTRUCTION, GHOST_STATE_MIN_ACCESS_LEN, GHOST_STATE_RETENTION_PRIORITY);
|
||||
tcomp_buffer_allocBuff(deflatedata->ghostState->value, state_length);
|
||||
ghostvalue_ptr = tcomp_buffer_getBuffer(deflatedata->ghostState->value);
|
||||
|
||||
memcpy(ghostvalue_ptr, DeflateData_deflate_bytecode1_ghost, GHOST_BYTECODE1_SIZE);
|
||||
|
||||
TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_START_INDEX), DEFLATE_UDVM_CIRCULAR_START_INDEX );
|
||||
TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_DMS_INDEX), state_length+GHOST_STATE_ADDRESS );
|
||||
TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_END_INDEX), (DEFLATE_UDVM_CIRCULAR_START_INDEX + 0/*input_size*/) );
|
||||
// ......
|
||||
TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_HASH_LEN_INDEX), (state_length+8) );
|
||||
TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_SMS_INDEX), state_length );
|
||||
TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CPB_DMS_SMS_INDEX), tcomp_params_getParameters(params) ); // [cpb+dms+sms]+[version]
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#define GHOST_DICT_CODE_INDEX (GHOST_BYTECODE1_SIZE)
|
||||
#define GHOST_DICT_WORDS_INDEX (GHOST_DICT_CODE_INDEX + 2)
|
||||
#if USE_DICTS_FOR_COMPRESSION
|
||||
# define GHOST_FIXME2_INDEX (GHOST_DICT_WORDS_INDEX + 4/*Sip dict id len*/)
|
||||
#else
|
||||
# define GHOST_FIXME2_INDEX (GHOST_DICT_WORDS_INDEX + 0)
|
||||
#endif
|
||||
#define GHOST_DEFLATE_BYTECODE_INDEX (GHOST_FIXME2_INDEX + 4)
|
||||
#define GHOST_INPUT_INDEX (GHOST_DEFLATE_BYTECODE_INDEX + DEFLATE_BYTECODE_LEN)
|
||||
|
||||
#if USE_DICTS_FOR_COMPRESSION
|
||||
BINARY_SET_2BYTES( ghostState->getStateValue()->getBuffer(GHOST_DICT_CODE_INDEX), DEFLATE_FIXME_DICT );
|
||||
if( DEFLATE_FIXME_DICT == DEFLATE_NO_DICT ){
|
||||
// Nothing to append
|
||||
}else{
|
||||
if(DEFLATE_FIXME_DICT == DEFLATE_SIP_DICT_ONLY){
|
||||
::memmove( ghostState->getStateValue()->getBuffer(GHOST_DICT_WORDS_INDEX), RFC3485_DICTIONARY_SIP_IDENTIFIER, 4 );
|
||||
}else{
|
||||
assert(1==0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
memcpy( GHOSTVALUE_AT(GHOST_DEFLATE_BYTECODE_INDEX), (const char*)DEFLATEDATA_DEFLATE_BYTECODE, DEFLATE_BYTECODE_LEN );
|
||||
|
||||
tsk_safeobj_unlock(deflatedata);
|
||||
|
||||
#undef GHOSTVALUE_AT
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
void tcomp_deflatedata_ackGhost(tcomp_compressordata_t *data, const tcomp_buffer_handle_t *stateid)
|
||||
{
|
||||
tcomp_deflatedata_t *deflatedata = data;
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return;
|
||||
}
|
||||
|
||||
tsk_safeobj_lock(deflatedata);
|
||||
|
||||
#if USE_ONLY_ACKED_STATES
|
||||
if(deflatedata->ghostState)
|
||||
{
|
||||
/* Update ghost */
|
||||
if(tcomp_buffer_startsWith(deflatedata->ghostState->identifier, stateid))
|
||||
{
|
||||
/* END() + COPY() */
|
||||
tcomp_deflateStream_end(&(deflatedata->stream_acked));
|
||||
tcomp_deflateStream_copy(&(deflatedata->stream_acked), &(deflatedata->stream_1));
|
||||
deflatedata->stream_acked.stateful = 1;
|
||||
deflatedata->stream_acked.dataWaitingAck = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
tsk_safeobj_unlock(deflatedata);
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
void tcomp_deflatedata_updateGhost(tcomp_deflatedata_t *deflatedata, const uint8_t *input_ptr, size_t input_size)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t *ghostvalue_ptr = 0;
|
||||
|
||||
#define GHOSTVALUE_AT(position) (ghostvalue_ptr + position)
|
||||
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!deflatedata->ghostState)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL ghost state.");
|
||||
return;
|
||||
}
|
||||
|
||||
tsk_safeobj_lock(deflatedata);
|
||||
|
||||
ghostvalue_ptr = tcomp_buffer_getBuffer(deflatedata->ghostState->value);
|
||||
|
||||
#define ZBUFF_LEN (0x0001 << deflatedata->zWindowBits)
|
||||
for(i = 0; i < input_size; i++)
|
||||
{
|
||||
#if 0
|
||||
*GHOSTVALUE_AT(GHOST_INPUT_INDEX + ghost_copy_offset) = 0x00;
|
||||
#else
|
||||
*GHOSTVALUE_AT(GHOST_INPUT_INDEX + deflatedata->ghost_copy_offset) = input_ptr[i];
|
||||
#endif
|
||||
deflatedata->ghost_copy_offset = (deflatedata->ghost_copy_offset + 1) % ZBUFF_LEN;
|
||||
}
|
||||
|
||||
/* Update Circular Buffer Index */
|
||||
TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_END_INDEX), (DEFLATE_UDVM_CIRCULAR_START_INDEX + deflatedata->ghost_copy_offset) );
|
||||
|
||||
/* Compute State Identifier (20 bytes) */
|
||||
tcomp_state_makeValid(deflatedata->ghostState);
|
||||
|
||||
/*printf("GHOST\n");
|
||||
tcomp_buffer_nprint(deflatedata->ghostState->value);
|
||||
tcomp_buffer_nprint(deflatedata->ghostState->identifier);*/
|
||||
|
||||
tsk_safeobj_unlock(deflatedata);
|
||||
|
||||
#undef GHOSTVALUE_AT
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
uint32_t* tcomp_deflatedata_getGhostCopyOffset(tcomp_deflatedata_t *deflatedata)
|
||||
{
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return &(deflatedata->ghost_copy_offset);
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
void tcomp_deflatedata_freeGhostState(tcomp_compressordata_t *data)
|
||||
{
|
||||
tcomp_deflatedata_t *deflatedata = data;
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return;
|
||||
}
|
||||
|
||||
TCOMP_STATE_SAFE_FREE(deflatedata->ghostState);
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* 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 tcomp_compressor.h
|
||||
* @brief Deflate compressor data.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TCOMP_COMPRESSORDEFLATE_DATA_H
|
||||
#define TCOMP_COMPRESSORDEFLATE_DATA_H
|
||||
|
||||
#include "tinysigcomp_config.h"
|
||||
#include "tcomp_params.h"
|
||||
#include "tcomp_state.h"
|
||||
#include "tcomp_compressordata.h"
|
||||
|
||||
#if HAS_ZLIB
|
||||
# include <zlib.h>
|
||||
#else
|
||||
# include "zlib.h"
|
||||
#endif
|
||||
|
||||
#define _TCOMP_DEFLATEDATA_CREATE(isStream, z_level, z_windowBits) tsk_object_new(tcomp_deflatedata_def_t, (int)isStream, (int)z_level,(int) z_windowBits)
|
||||
#define TCOMP_DEFLATEDATA_CREATE(isStream) tsk_object_new(tcomp_deflatedata_def_t, (int)isStream, Z_BEST_COMPRESSION, Z_DEFAULT_WINDOW_BITS)
|
||||
#define TCOMP_DEFLATEDATA_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/** [[[[[[[[[[[[[[[[[ **/
|
||||
#define USE_DICTS_FOR_COMPRESSION 0
|
||||
|
||||
#define Z_DEFAULT_WINDOW_BITS 10 /* 1024*/
|
||||
|
||||
#define DEFLATE_DECOMPRESSION_PTR_INDEX 70
|
||||
#if USE_DICTS_FOR_COMPRESSION
|
||||
# define DEFLATE_UDVM_CIRCULAR_START_INDEX 701
|
||||
#else
|
||||
# define DEFLATE_UDVM_CIRCULAR_START_INDEX 630
|
||||
#endif
|
||||
|
||||
#define DEFLATE_SIP_DICT_ONLY 0x00
|
||||
#define DEFLATE_PRES_DICT_ONLY 0x01
|
||||
#define DEFLATE_SIP_PRES_DICTS 0x02
|
||||
#define DEFLATE_NO_DICT 0x03
|
||||
#define DEFLATE_FIXME_DICT DEFLATE_NO_DICT
|
||||
|
||||
#define DEFLATE_BYTECODE_DESTINATION_START 320
|
||||
#define DEFLATE_BYTECODE_DESTINATION_CODE 0x04 // 320
|
||||
#if USE_DICTS_FOR_COMPRESSION
|
||||
# define DEFLATE_BYTECODE_LEN 381
|
||||
#else
|
||||
# define DEFLATE_BYTECODE_LEN 310
|
||||
#endif
|
||||
/** ]]]]]]]]]]]]]] **/
|
||||
|
||||
|
||||
#if USE_DICTS_FOR_COMPRESSION
|
||||
#define DEFLATEDATA_DEFLATE_BYTECODE \
|
||||
"\x0f\x86\x7a\xa2\xbd\x8d\x05\xa2\xbd\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00" \
|
||||
"\x09\x00\x0a\x01\x0b\x01\x0d\x01\x0f\x01\x11\x02\x13\x02\x17\x02\x1b\x02\x1f\x03\x23\x03" \
|
||||
"\x2b\x03\x33\x03\x3b\x04\xa0\x43\x04\xa0\x53\x04\xa0\x63\x04\xa0\x73\x05\xa0\x83\x05\xa0" \
|
||||
"\xa3\x05\xa0\xc3\x05\xa0\xe3\x00\xa1\x02\x00\x01\x00\x02\x00\x03\x00\x04\x01\x05\x01\x07" \
|
||||
"\x02\x09\x02\x0d\x03\x11\x03\x19\x04\x21\x04\x31\x05\xa0\x41\x05\xa0\x61\x06\xa0\x81\x06" \
|
||||
"\xa0\xc1\x07\xa1\x01\x07\xa1\x81\x08\xa2\x01\x08\xa3\x01\x09\xa4\x01\x09\xa6\x01\x0a\xa8" \
|
||||
"\x01\x0a\xac\x01\x0b\xb0\x01\x0b\xb8\x01\x0c\x80\x20\x01\x0c\x80\x30\x01\x0d\x80\x40\x01" \
|
||||
"\x0d\x80\x60\x01\x1c\x08\xa1\x34\xa0\xde\x0e\xa0\x42\xc1\x36\x06\x21\x86\x1a\x04\xc1\x3a" \
|
||||
"\xa0\x0c\xa0\x1e\xa0\x30\xa0\x47\x0f\xa1\x3a\x04\xa6\xfb\x80\xe5\x07\x80\xdf\xe5\x80\xe6" \
|
||||
"\x00\x16\xa0\x2c\x0f\xa1\x3a\x04\xa6\xd9\x80\x42\x29\x80\x7d\x0b\x80\xb3\x00\x16\xa0\x1a" \
|
||||
"\x0f\xa1\x3a\x07\xa6\xfb\x80\xe5\x07\x80\xdf\xe5\x80\xe6\x06\x80\xd9\x42\x80\x29\x7d\xab" \
|
||||
"\xb3\x1d\x03\x22\xa0\x89\x1e\x20\xa0\x68\x04\x07\x00\x17\x80\x40\x11\x01\x30\xa0\xbf\x00" \
|
||||
"\x00\xa0\xc0\xa0\xc7\x80\x40\x29\x01\xa1\x90\xa1\xff\xa0\x90\x17\x50\x80\x40\x11\xa0\x0b" \
|
||||
"\xa0\x49\xa0\x15\x22\x21\x01\x13\x21\x01\x23\x16\x9f\xcf\x08\x10\x04\x12\x50\x04\x22\x1d" \
|
||||
"\x51\x22\xa0\x49\x06\x12\x51\x1e\x20\xa0\x41\x01\x05\x00\x1f\x2f\x08\x10\x04\x12\x50\x04" \
|
||||
"\x26\x1d\x53\x26\xa0\x31\x06\x14\x53\x0e\x20\x63\x14\x54\x52\x23\x22\x50\x52\x16\x9f\x9b" \
|
||||
"\x0e\x2a\xa4\x86\x0f\x38\x04\xc1\x36\x86\xa1\xec\x06\x0d\x38\xc1\x34\x2c\x23\x2a\xa1\x38" \
|
||||
"\xc1\x36\x86\xa1\xec\x06\x00"
|
||||
#else
|
||||
#define DEFLATEDATA_DEFLATE_BYTECODE \
|
||||
"\x0f\x86\x7a\xa2\x76\x8d\x05\xa2\x76\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00" \
|
||||
"\x09\x00\x0a\x01\x0b\x01\x0d\x01\x0f\x01\x11\x02\x13\x02\x17\x02\x1b\x02\x1f\x03\x23\x03" \
|
||||
"\x2b\x03\x33\x03\x3b\x04\xa0\x43\x04\xa0\x53\x04\xa0\x63\x04\xa0\x73\x05\xa0\x83\x05\xa0" \
|
||||
"\xa3\x05\xa0\xc3\x05\xa0\xe3\x00\xa1\x02\x00\x01\x00\x02\x00\x03\x00\x04\x01\x05\x01\x07" \
|
||||
"\x02\x09\x02\x0d\x03\x11\x03\x19\x04\x21\x04\x31\x05\xa0\x41\x05\xa0\x61\x06\xa0\x81\x06" \
|
||||
"\xa0\xc1\x07\xa1\x01\x07\xa1\x81\x08\xa2\x01\x08\xa3\x01\x09\xa4\x01\x09\xa6\x01\x0a\xa8" \
|
||||
"\x01\x0a\xac\x01\x0b\xb0\x01\x0b\xb8\x01\x0c\x80\x20\x01\x0c\x80\x30\x01\x0d\x80\x40\x01" \
|
||||
"\x0d\x80\x60\x01\x1c\x06\xa1\x34\xa0\x97\x0e\xa0\x42\xc1\x36\x06\x21\x86\x1d\x03\x22\xa0" \
|
||||
"\x89\x1e\x20\xa0\x68\x04\x07\x00\x17\x80\x40\x11\x01\x30\xa0\xbf\x00\x00\xa0\xc0\xa0\xc7" \
|
||||
"\x80\x40\x29\x01\xa1\x90\xa1\xff\xa0\x90\x17\x50\x80\x40\x11\xa0\x0b\xa0\x49\xa0\x15\x22" \
|
||||
"\x21\x01\x13\x21\x01\x23\x16\x9f\xcf\x08\x10\x04\x12\x50\x04\x22\x1d\x51\x22\xa0\x49\x06" \
|
||||
"\x12\x51\x1e\x20\xa0\x41\x01\x05\x00\x1f\x2f\x08\x10\x04\x12\x50\x04\x26\x1d\x53\x26\xa0" \
|
||||
"\x31\x06\x14\x53\x0e\x20\x63\x14\x54\x52\x23\x22\x50\x52\x16\x9f\x9b\x0e\x2a\xa4\x86\x0f" \
|
||||
"\x38\x04\xc1\x36\x86\xa1\xec\x06\x0d\x38\xc1\x34\x2c\x23\x2a\xa1\x38\xc1\x36\x86\xa1\xec" \
|
||||
"\x06\x00"
|
||||
|
||||
#endif /* USE_DICTS_FOR_COMPRESSION */
|
||||
|
||||
typedef struct tcomp_deflateStream_s
|
||||
{
|
||||
z_stream zs;
|
||||
unsigned dataWaitingAck:1;
|
||||
unsigned stateful:1;
|
||||
}
|
||||
tcomp_deflateStream_t;
|
||||
|
||||
int tcomp_deflateStream_end(tcomp_deflateStream_t *stream);
|
||||
int tcomp_deflateStream_copy(tcomp_deflateStream_t *stream, tcomp_deflateStream_t *source);
|
||||
|
||||
typedef struct tcomp_deflatedata_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
tcomp_deflateStream_t stream_1;
|
||||
tcomp_deflateStream_t stream_acked;
|
||||
int zLevel;
|
||||
int zWindowBits;
|
||||
|
||||
unsigned initialized:1;
|
||||
|
||||
uint32_t ghost_copy_offset;
|
||||
tcomp_state_t *ghostState;
|
||||
unsigned stream:1;
|
||||
|
||||
TSK_DECLARE_SAFEOBJ;
|
||||
}
|
||||
tcomp_deflatedata_t;
|
||||
|
||||
void tcomp_deflatedata_freeGhostState(tcomp_compressordata_t *deflatedata);
|
||||
void tcomp_deflatedata_ackGhost(tcomp_compressordata_t *deflatedata, const tcomp_buffer_handle_t *stateid);
|
||||
void tcomp_deflatedata_createGhost(tcomp_deflatedata_t *deflatedata, uint16_t state_len, tcomp_params_t *params);
|
||||
void tcomp_deflatedata_updateGhost(tcomp_deflatedata_t *deflatedata, const uint8_t *input_ptr, size_t input_size);
|
||||
uint32_t* tcomp_deflatedata_getGhostCopyOffset(tcomp_deflatedata_t *deflatedata);
|
||||
|
||||
int tcomp_deflatedata_zReset(tcomp_deflatedata_t *deflatedata);
|
||||
int tcomp_deflatedata_zCompress(tcomp_deflatedata_t *deflatedata, const void* in, size_t inLen, void* out, size_t* outLen, int *stateChanged);
|
||||
|
||||
int tcomp_deflatedata_zGetWindowBits(tcomp_deflatedata_t *deflatedata);
|
||||
void tcomp_deflatedata_zSetWindowBits(tcomp_deflatedata_t *deflatedata, int windowSize);
|
||||
|
||||
int tcomp_deflatedata_isStateful(tcomp_deflatedata_t *deflatedata);
|
||||
int tcomp_deflatedata_zInit(tcomp_deflatedata_t *deflatedata);
|
||||
int tcomp_deflatedata_zUnInit(tcomp_deflatedata_t *deflatedata);
|
||||
|
||||
TINYSIGCOMP_API const void *tcomp_deflatedata_def_t;
|
||||
|
||||
#endif /* TCOMP_COMPRESSORDEFLATE_DATA_H */
|
|
@ -0,0 +1,245 @@
|
|||
/*
|
||||
* 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 tcomp_compressor.h
|
||||
* @brief Deflate compressor data.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tcomp_deflatedata.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
int tcomp_deflateStream_end(tcomp_deflateStream_t *stream)
|
||||
{
|
||||
if(!stream)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte stream.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return deflateEnd(&(stream->zs));
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
int tcomp_deflateStream_copy(tcomp_deflateStream_t *stream, tcomp_deflateStream_t *source)
|
||||
{
|
||||
if(!stream)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte stream.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return deflateCopy(&(stream->zs), &(source->zs));
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
int tcomp_deflatedata_zInit(tcomp_deflatedata_t *deflatedata)
|
||||
{
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Already initialized? */
|
||||
if(deflatedata->initialized)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* allocate deflate state */
|
||||
deflatedata->stream_1.zs.zalloc = deflatedata->stream_acked.zs.zalloc = Z_NULL;
|
||||
deflatedata->stream_1.zs.zfree = deflatedata->stream_acked.zs.zfree = Z_NULL;
|
||||
deflatedata->stream_1.zs.opaque = deflatedata->stream_acked.zs.opaque = Z_NULL;
|
||||
#ifndef __SYMBIAN32__
|
||||
deflatedata->stream_1.zs.data_type = deflatedata->stream_acked.zs.data_type = Z_TEXT;
|
||||
#endif
|
||||
|
||||
//bool ret = (deflateInit(&this->zStream, this->zLevel) == Z_OK);
|
||||
if( deflateInit2(&deflatedata->stream_1.zs, deflatedata->zLevel, Z_DEFLATED, -deflatedata->zWindowBits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK
|
||||
|| deflateInit2(&deflatedata->stream_acked.zs, deflatedata->zLevel, Z_DEFLATED, -deflatedata->zWindowBits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#if USE_DICTS_FOR_COMPRESSION
|
||||
if( deflateSetDictionary(this->stream_1.zs, (const Bytef*)RFC3485_DICTIONARY_SIP_VALUE, RFC3485_DICTIONARY_SIP_VALUE_LENGTH) != Z_OK
|
||||
|| deflateSetDictionary(this->stream_acked.zs, (const Bytef*)RFC3485_DICTIONARY_SIP_VALUE, RFC3485_DICTIONARY_SIP_VALUE_LENGTH) != Z_OK )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
deflatedata->stream_1.stateful = deflatedata->stream_acked.stateful = 0;
|
||||
deflatedata->stream_1.dataWaitingAck = deflatedata->stream_acked.dataWaitingAck = 0;
|
||||
deflatedata->initialized = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
int tcomp_deflatedata_zUnInit(tcomp_deflatedata_t *deflatedata)
|
||||
{
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(deflatedata->initialized)
|
||||
{
|
||||
deflatedata->initialized = 0;
|
||||
|
||||
deflatedata->stream_1.dataWaitingAck = deflatedata->stream_acked.dataWaitingAck = 0;
|
||||
deflatedata->stream_1.stateful = deflatedata->stream_acked.stateful = 0;
|
||||
|
||||
return (tcomp_deflateStream_end(&deflatedata->stream_1) != Z_STREAM_ERROR) && (tcomp_deflateStream_end(&deflatedata->stream_acked) != Z_STREAM_ERROR);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
int tcomp_deflatedata_zReset(tcomp_deflatedata_t *deflatedata)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = deflatedata->initialized ? tcomp_deflatedata_zUnInit(deflatedata) : 1;
|
||||
ret &= tcomp_deflatedata_zInit(deflatedata);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
int tcomp_deflatedata_zCompress(tcomp_deflatedata_t *deflatedata, const void* in, size_t inLen, void* out, size_t* outLen, int *stateChanged)
|
||||
{
|
||||
int ret = 0;
|
||||
/*
|
||||
Two streams [1] and [2]
|
||||
|
||||
* ZINIT/ZUNINIT/ZRESET
|
||||
XXX([1])
|
||||
XXX([2])
|
||||
|
||||
* COMPRESSION
|
||||
[1]->END()
|
||||
[1]<-COPY-[2]
|
||||
[1]->COMPRESS()
|
||||
|
||||
* ACK
|
||||
[2]->END()
|
||||
[2]<-COPY-[1]
|
||||
updateGhost([1])
|
||||
*/
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
tsk_safeobj_lock(deflatedata);
|
||||
|
||||
/* Initialized? */
|
||||
if(!deflatedata->initialized)
|
||||
{
|
||||
if(!tcomp_deflatedata_zInit(deflatedata))
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to initialize zlib resources..");
|
||||
tsk_safeobj_unlock(deflatedata);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_ONLY_ACKED_STATES
|
||||
if(!deflatedata->stream_acked.dataWaitingAck)
|
||||
{
|
||||
deflatedata->stream_acked.dataWaitingAck = 1;
|
||||
*stateChanged = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*stateChanged = 0;
|
||||
}
|
||||
|
||||
/* END() + COPY() ==> use acked state */
|
||||
tcomp_deflateStream_end(&(deflatedata->stream_1));
|
||||
tcomp_deflateStream_copy(&(deflatedata->stream_1), &(deflatedata->stream_acked));
|
||||
|
||||
#else
|
||||
*stateChanged = 1;
|
||||
#endif
|
||||
|
||||
// IN
|
||||
deflatedata->stream_1.zs.next_in = (Bytef*)in;
|
||||
deflatedata->stream_1.zs.avail_in = (uInt)inLen;
|
||||
|
||||
// OUT
|
||||
deflatedata->stream_1.zs.next_out = (Bytef*)out;
|
||||
deflatedata->stream_1.zs.avail_out = (uInt)*outLen;
|
||||
|
||||
ret = deflate(&(deflatedata->stream_1.zs), Z_SYNC_FLUSH);
|
||||
|
||||
*outLen -= deflatedata->stream_1.zs.avail_out;
|
||||
|
||||
tsk_safeobj_unlock(deflatedata);
|
||||
|
||||
return (ret == Z_OK);
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
int tcomp_deflatedata_zGetWindowBits(tcomp_deflatedata_t *deflatedata)
|
||||
{
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return deflatedata->zWindowBits;
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_deflatedata_group
|
||||
*/
|
||||
void tcomp_deflatedata_zSetWindowBits(tcomp_deflatedata_t *deflatedata, int windowSize)
|
||||
{
|
||||
if(!deflatedata)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL defalte data.");
|
||||
return;
|
||||
}
|
||||
|
||||
deflatedata->zWindowBits = windowSize;
|
||||
}
|
|
@ -56,7 +56,7 @@ tcomp_dictionary_t* tcomp_dicts_create_presence_dict()
|
|||
|
||||
if(pres_dict)
|
||||
{
|
||||
tcomp_buffer_referenceBuff(pres_dict->value, (char*)pres_dict_data, RFC5112_DICTIONARY_PRESENCE_VALUE_LENGTH);
|
||||
tcomp_buffer_referenceBuff(pres_dict->value, (uint8_t*)pres_dict_data, RFC5112_DICTIONARY_PRESENCE_VALUE_LENGTH);
|
||||
tcomp_state_makeValid(pres_dict);
|
||||
}
|
||||
else
|
||||
|
@ -87,7 +87,7 @@ tcomp_dictionary_t* tcomp_dicts_create_sip_dict()
|
|||
|
||||
if(sip_dict)
|
||||
{
|
||||
tcomp_buffer_referenceBuff(sip_dict->value, (char*)sip_dict_data, RFC3485_DICTIONARY_SIP_VALUE_LENGTH);
|
||||
tcomp_buffer_referenceBuff(sip_dict->value, (uint8_t*)sip_dict_data, RFC3485_DICTIONARY_SIP_VALUE_LENGTH);
|
||||
tcomp_state_makeValid(sip_dict);
|
||||
}
|
||||
else
|
||||
|
@ -97,4 +97,4 @@ tcomp_dictionary_t* tcomp_dicts_create_sip_dict()
|
|||
}
|
||||
|
||||
return sip_dict;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,14 +59,22 @@ tcomp_manager_t;
|
|||
|
||||
/**@ingroup tcomp_manager_group
|
||||
*/
|
||||
size_t tcomp_manager_compress(tcomp_manager_handle_t *handle, uint64_t compartmentId, const void* input_ptr, size_t input_size, void* output_ptr, size_t output_size, int stream)
|
||||
size_t tcomp_manager_compress(tcomp_manager_handle_t *handle, const void* compartmentId, size_t compartmentIdSize, const void* input_ptr, size_t input_size, void* output_ptr, size_t output_size, int stream)
|
||||
{
|
||||
tcomp_manager_t *manager = handle;
|
||||
size_t ret_size = output_size;
|
||||
|
||||
if(!manager)
|
||||
{
|
||||
TSK_DEBUG_ERROR("NULL sigcomp manager.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(tcomp_compressordisp_compress(manager->dispatcher_compressor, tcomp_buffer_createHash(compartmentId, compartmentIdSize),
|
||||
input_ptr, input_size, output_ptr, &ret_size, stream))
|
||||
{
|
||||
return ret_size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -148,7 +156,7 @@ void tcomp_manager_provideCompartmentId(tcomp_manager_handle_t *handle, tcomp_re
|
|||
|
||||
/**@ingroup tcomp_manager_group
|
||||
*/
|
||||
void tcomp_manager_closeCompartment(tcomp_manager_handle_t *handle, uint64_t compartmentId)
|
||||
void tcomp_manager_closeCompartment(tcomp_manager_handle_t *handle, const void *compartmentId, size_t compartmentIdSize)
|
||||
{
|
||||
tcomp_manager_t *manager = handle;
|
||||
if(!manager)
|
||||
|
@ -157,7 +165,7 @@ void tcomp_manager_closeCompartment(tcomp_manager_handle_t *handle, uint64_t com
|
|||
return;
|
||||
}
|
||||
|
||||
tcomp_statehandler_deleteCompartment(manager->stateHandler, compartmentId);
|
||||
tcomp_statehandler_deleteCompartment(manager->stateHandler, tcomp_buffer_createHash(compartmentId, compartmentIdSize));
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_manager_group
|
||||
|
@ -218,7 +226,7 @@ void tcomp_manager_setSigComp_Version(tcomp_manager_handle_t *handle, uint8_t ve
|
|||
|
||||
/**@ingroup tcomp_manager_group
|
||||
*/
|
||||
void tcomp_manager_addCompressor(tcomp_manager_handle_t *handle/*, SigCompCompressor* compressor*/)
|
||||
void tcomp_manager_addCompressor(tcomp_manager_handle_t *handle, tcomp_compressor_compress compressor)
|
||||
{
|
||||
tcomp_manager_t *manager = handle;
|
||||
if(!manager)
|
||||
|
@ -227,7 +235,7 @@ void tcomp_manager_addCompressor(tcomp_manager_handle_t *handle/*, SigCompCompre
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
tcomp_compressordisp_addCompressor(manager->dispatcher_compressor, compressor);
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_manager_group
|
||||
|
@ -268,9 +276,6 @@ void tcomp_manager_addPresenceDictionary(tcomp_manager_handle_t *handle)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// SigComp manager object definition
|
||||
//
|
||||
|
@ -321,8 +326,6 @@ static const tsk_object_def_t tcomp_manager_def_s =
|
|||
sizeof(tcomp_manager_t),
|
||||
tcomp_manager_create,
|
||||
tcomp_manager_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_manager_def_t = &tcomp_manager_def_s;
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "tinysigcomp_config.h"
|
||||
#include "tcomp_result.h"
|
||||
#include "tcomp_compressor.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -39,14 +40,14 @@ typedef void tcomp_manager_handle_t;
|
|||
|
||||
|
||||
#define TCOMP_MANAGER_CREATE() (tcomp_manager_handle_t*)tsk_object_new(tcomp_manager_def_t)
|
||||
#define TCOMP_MANAGER_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_MANAGER_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
//
|
||||
// Compression / Decompression
|
||||
//
|
||||
TINYSIGCOMP_API size_t tcomp_manager_compress(tcomp_manager_handle_t *handle, uint64_t compartmentId, const void* input_ptr, size_t input_size, void* output_ptr, size_t output_size, int stream);
|
||||
#define tcomp_manager_compressUDP(handle, compartmentId, input_ptr, input_size, output_ptr, output_size) tcomp_manager_compress((tcomp_manager_handle_t *)handle, (uint64_t) compartmentId, (const void*) input_ptr, (size_t) input_size, (void*) output_ptr, (size_t) output_size, 0)
|
||||
#define tcomp_manager_compressTCP(handle, compartmentId, input_ptr, input_size, output_ptr, output_size) tcomp_manager_compress((tcomp_manager_handle_t *)handle, (uint64_t) compartmentId, (const void*) input_ptr, (size_t) input_size, (void*) output_ptr, (size_t) output_size, 1)
|
||||
TINYSIGCOMP_API size_t tcomp_manager_compress(tcomp_manager_handle_t *handle, const void* compartmentId, size_t compartmentIdSize, const void* input_ptr, size_t input_size, void* output_ptr, size_t output_size, int stream);
|
||||
#define tcomp_manager_compressUDP(handle, compartmentId, compartmentIdSize, input_ptr, input_size, output_ptr, output_size) tcomp_manager_compress((tcomp_manager_handle_t *)handle, (const void*) compartmentId, (size_t) compartmentIdSize, (const void*) input_ptr, (size_t) input_size, (void*) output_ptr, (size_t) output_size, 0)
|
||||
#define tcomp_manager_compressTCP(handle, compartmentId, compartmentIdSize, input_ptr, input_size, output_ptr, output_size) tcomp_manager_compress((tcomp_manager_handle_t *)handle, (const void*) compartmentId, (size_t) compartmentIdSize, (const void*) input_ptr, (size_t) input_size, (void*) output_ptr, (size_t) output_size, 1)
|
||||
#define tcomp_manager_compressSCTP compressTCP
|
||||
|
||||
TINYSIGCOMP_API size_t tcomp_manager_decompress(tcomp_manager_handle_t *handle, const void* input_ptr, size_t input_size, tcomp_result_t *lpResult);
|
||||
|
@ -56,7 +57,7 @@ TINYSIGCOMP_API size_t tcomp_manager_getNextStreamMessage(tcomp_manager_handle_t
|
|||
* Compartment management
|
||||
*/
|
||||
TINYSIGCOMP_API void tcomp_manager_provideCompartmentId(tcomp_manager_handle_t *handle, tcomp_result_t *lpResult);
|
||||
TINYSIGCOMP_API void tcomp_manager_closeCompartment(tcomp_manager_handle_t *handle, uint64_t compartmentId);
|
||||
TINYSIGCOMP_API void tcomp_manager_closeCompartment(tcomp_manager_handle_t *handle, const void *compartmentId, size_t compartmentIdSize);
|
||||
|
||||
/*
|
||||
* SigComp Parameters
|
||||
|
@ -69,7 +70,7 @@ TINYSIGCOMP_API void tcomp_manager_setSigComp_Version(tcomp_manager_handle_t *ha
|
|||
/*
|
||||
* Compressors
|
||||
*/
|
||||
TINYSIGCOMP_API void tcomp_manager_addCompressor(tcomp_manager_handle_t *handle/*, SigCompCompressor* compressor*/);
|
||||
TINYSIGCOMP_API void tcomp_manager_addCompressor(tcomp_manager_handle_t *handle, tcomp_compressor_compress compressor);
|
||||
|
||||
/*
|
||||
* Dictionnaries
|
||||
|
|
|
@ -73,6 +73,8 @@ void initFeedbackItem(tcomp_message_t *message, uint8_t** start_ptr)
|
|||
tcomp_buffer_referenceBuff(message->ret_feedback_buffer, *start_ptr, 1+(**start_ptr&0x7f));
|
||||
*start_ptr += tcomp_buffer_getSize(message->ret_feedback_buffer);
|
||||
}
|
||||
|
||||
TSK_DEBUG_INFO("SigComp - Create feedback item.");
|
||||
}
|
||||
|
||||
/*== initStateId
|
||||
|
@ -99,10 +101,12 @@ void initStateful(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end_pt
|
|||
+---+---+---+---+---+---+---+---+
|
||||
*/
|
||||
message->isOK &= (*start_ptr<=end_ptr);
|
||||
if(message->isOK){
|
||||
if(message->isOK)
|
||||
{
|
||||
tcomp_buffer_referenceBuff(message->remaining_sigcomp_buffer, *start_ptr,
|
||||
((end_ptr-*start_ptr)));
|
||||
}
|
||||
TSK_DEBUG_INFO("SigComp - Creating stateful message.");
|
||||
}
|
||||
|
||||
/*== initStateless
|
||||
|
@ -172,6 +176,8 @@ void initStateless(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end_p
|
|||
tcomp_buffer_referenceBuff(message->uploaded_UDVM_buffer, bytecodes_uploaded_udvm, bytecodes_len);
|
||||
tcomp_buffer_referenceBuff(message->remaining_sigcomp_buffer, remaining_SigComp_message, ((end_ptr-remaining_SigComp_message)));
|
||||
}
|
||||
|
||||
TSK_DEBUG_INFO("SigComp - Creating stateless message.");
|
||||
}
|
||||
|
||||
/*== initNack
|
||||
|
@ -224,6 +230,8 @@ void initNack(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end_ptr)
|
|||
/* Has error details */
|
||||
tcomp_buffer_appendBuff(message->nack_info->details, dummy_ptr, (end_ptr-dummy_ptr));
|
||||
}
|
||||
|
||||
TSK_DEBUG_INFO("SigComp - Initializing NACK message.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -364,8 +372,6 @@ static const tsk_object_def_t tcomp_message_def_s =
|
|||
sizeof(tcomp_message_t),
|
||||
tcomp_message_create,
|
||||
tcomp_message_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_message_def_t = &tcomp_message_def_s;
|
|
@ -38,7 +38,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#define TCOMP_MESSAGE_CREATE(input_ptr, input_size, stream) tsk_object_new(tcomp_message_def_t, input_ptr, input_size, stream)
|
||||
#define TCOMP_MESSAGE_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_MESSAGE_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**
|
||||
* SigComp Message Format as per RFC 3320 subclause 7.
|
||||
|
|
|
@ -80,8 +80,6 @@ static const tsk_object_def_t tcomp_nackinfo_def_s =
|
|||
sizeof(tcomp_nackinfo_t),
|
||||
tcomp_nackinfo_create,
|
||||
tcomp_nackinfo_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_nackinfo_def_t = &tcomp_nackinfo_def_s;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#define TCOMP_NACKINFO_CREATE() tsk_object_new(tsk_nackinfo_def_t)
|
||||
#define TCOMP_NACKINFO_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_NACKINFO_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/*
|
||||
+---+---+---+---+---+---+---+---+
|
||||
|
@ -64,6 +64,7 @@
|
|||
*/
|
||||
/**@typedef tcomp_nackinfo_t
|
||||
* NACK info as per rfc 4077 subclause 3.1.
|
||||
* You MUST use @ref TCOMP_NACKINFO_CREATE to create new nackinfo object.
|
||||
*/
|
||||
typedef struct tcomp_nackinfo_s
|
||||
{
|
||||
|
|
|
@ -233,7 +233,7 @@ void tcomp_params_reset(tcomp_params_t* params)
|
|||
params->cpbCode = params->dmsCode = params->smsCode = params->SigComp_version = 0;
|
||||
params->cpbValue = params->dmsValue = params->smsValue = 0;
|
||||
|
||||
TSK_LIST_SAFE_FREE(params->returnedStates);
|
||||
tsk_list_clear_items(params->returnedStates);
|
||||
}
|
||||
else TSK_DEBUG_WARN("NULL sigcomp parameters.");
|
||||
}
|
||||
|
@ -259,7 +259,8 @@ static void* tcomp_params_create(void *self, va_list * app)
|
|||
tcomp_params_t *params = self;
|
||||
if(params)
|
||||
{
|
||||
tcomp_params_reset(params);
|
||||
//tcomp_params_reset(params);
|
||||
params->returnedStates = TSK_LIST_CREATE();
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Failed to create new sigcomp params.");
|
||||
|
||||
|
@ -288,8 +289,6 @@ static const tsk_object_def_t tcomp_params_def_s =
|
|||
sizeof(tcomp_params_t),
|
||||
tcomp_params_create,
|
||||
tcomp_params_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_params_def_t = &tcomp_params_def_s;
|
|
@ -35,7 +35,7 @@
|
|||
#include "tsk_object.h"
|
||||
|
||||
#define TCOMP_PARAMS_CREATE() tsk_object_new(tcomp_params_def_t)
|
||||
#define TCOMP_PARAMS_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_PARAMS_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@typedef tcomp_params_t
|
||||
* SIGCOMP parameters as per rfc 3320 subclause 3.3.
|
||||
|
|
|
@ -100,8 +100,6 @@ static const tsk_object_def_t tcomp_reqfeed_def_s =
|
|||
sizeof(tcomp_reqfeed_t),
|
||||
tcomp_reqfeed_create,
|
||||
tcomp_reqfeed_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_reqfeed_def_t = &tcomp_reqfeed_def_s;
|
|
@ -35,7 +35,7 @@
|
|||
#include "tsk_object.h"
|
||||
|
||||
#define TCOMP_REQFEED_CREATE() tsk_object_new(tcomp_reqfeed_def_t)
|
||||
#define TCOMP_REQFEED_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_REQFEED_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/*
|
||||
0 1 2 3 4 5 6 7
|
||||
|
|
|
@ -99,25 +99,7 @@ void tcomp_result_setCompartmentId(tcomp_result_t *result, const void *id, size_
|
|||
{
|
||||
if(result)
|
||||
{
|
||||
#define PRIME_1 500237
|
||||
#define PRIME_2 700241
|
||||
uint64_t hash = 0;
|
||||
uint8_t* strid = (uint8_t*)id;
|
||||
|
||||
/* Generate Hash code from id */
|
||||
{
|
||||
uint64_t b = PRIME_1, a = PRIME_2;
|
||||
size_t i;
|
||||
for(i = 0; i < len; strid++, i++)
|
||||
{
|
||||
hash = hash * a + (*strid);
|
||||
a = a * b;
|
||||
}
|
||||
}
|
||||
result->compartmentId = hash;
|
||||
|
||||
#undef PRIME_1
|
||||
#undef PRIME_2
|
||||
result->compartmentId = tcomp_buffer_createHash(id, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -253,8 +235,6 @@ static const tsk_object_def_t tcomp_result_def_s =
|
|||
sizeof(tcomp_result_t),
|
||||
tcomp_result_create,
|
||||
tcomp_result_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_result_def_t = &tcomp_result_def_s;
|
||||
|
@ -296,8 +276,6 @@ static const tsk_object_def_t tcomp_tempstate_to_free_def_s =
|
|||
sizeof(tcomp_tempstate_to_free_t),
|
||||
tcomp_tempstate_to_free_create,
|
||||
tcomp_tempstate_to_free_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_tempstate_to_free_def_t = &tcomp_tempstate_to_free_def_s;
|
|
@ -41,10 +41,10 @@
|
|||
#define MAX_TEMP_SATES 4
|
||||
|
||||
#define TCOMP_RESULT_CREATE() tsk_object_new(tcomp_result_def_t)
|
||||
#define TCOMP_RESULT_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_RESULT_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
#define TCOMP_TEMPSTATE_TO_FREE_CREATE() tsk_object_new(tcomp_tempstate_to_free_def_t)
|
||||
#define TCOMP_TEMPSTATE_TO_FREE_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_TEMPSTATE_TO_FREE_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
typedef struct tcomp_tempstate_to_free_s
|
||||
{
|
||||
|
|
|
@ -79,16 +79,19 @@ void tcomp_state_makeValid(tcomp_state_t* state)
|
|||
*/
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t values[4] =
|
||||
{
|
||||
state->length,
|
||||
state->address,
|
||||
state->instruction,
|
||||
state->minimum_access_length
|
||||
};
|
||||
|
||||
int32_t err = tsk_sha1reset(&sha);
|
||||
uint8_t firstPart[8];
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
uint16_t values[4];
|
||||
values[0] = state->length,
|
||||
values[1] = state->address,
|
||||
values[2] = state->instruction,
|
||||
values[3] = state->minimum_access_length;
|
||||
|
||||
#else
|
||||
uint16_t values[4] = { state->length, state->address, state->instruction, state->minimum_access_length };
|
||||
#endif
|
||||
|
||||
for(i=0; i<4; i++)
|
||||
{
|
||||
|
@ -175,10 +178,10 @@ static int tcomp_state_cmp(const void *obj1, const void *obj2)
|
|||
|
||||
if(state1 && state2)
|
||||
{
|
||||
return tcomp_buffer_equals(state1->identifier, state2->identifier);
|
||||
return tcomp_buffer_equals(state1->identifier, state2->identifier) ? 0 : -1;
|
||||
}
|
||||
else if(!state1 && !state2) return 1;
|
||||
else return 0;
|
||||
else if(!state1 && !state2) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tcomp_state_def_s =
|
||||
|
@ -186,8 +189,6 @@ static const tsk_object_def_t tcomp_state_def_s =
|
|||
sizeof(tcomp_state_t),
|
||||
tcomp_state_create,
|
||||
tcomp_state_destroy,
|
||||
0,
|
||||
tcomp_state_cmp,
|
||||
tcomp_state_cmp
|
||||
};
|
||||
const void *tcomp_state_def_t = &tcomp_state_def_s;
|
||||
const void *tcomp_state_def_t = &tcomp_state_def_s;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#define TCOMP_STATE_CREATE(length, address, instruction, minimum_access_length, retention_priority) \
|
||||
tsk_object_new(tcomp_state_def_t, length, address, instruction, minimum_access_length, retention_priority)
|
||||
|
||||
#define TCOMP_STATE_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_STATE_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
|
||||
// FIXME:
|
||||
|
|
|
@ -46,17 +46,18 @@ static int pred_find_compartment_by_id(const tsk_list_item_t *item, const void *
|
|||
if(item && item->data)
|
||||
{
|
||||
tcomp_compartment_t *compartment = item->data;
|
||||
return (compartment->identifier == *((uint64_t*)id));
|
||||
uint64_t res = (compartment->identifier - *((uint64_t*)id));
|
||||
return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**@ingroup tcomp_statehandler_group
|
||||
*/
|
||||
tcomp_compartment_t *tcomp_statehandler_getCompartment(tcomp_statehandler_t *statehandler, uint64_t id)
|
||||
tcomp_compartment_t *tcomp_statehandler_getCompartment(const tcomp_statehandler_t *statehandler, uint64_t id)
|
||||
{
|
||||
tcomp_compartment_t *result;
|
||||
tcomp_compartment_t* newcomp;
|
||||
tcomp_compartment_t *result = 0;
|
||||
tcomp_compartment_t* newcomp = 0;
|
||||
const tsk_list_item_t *item_const;
|
||||
|
||||
if(!statehandler)
|
||||
|
@ -98,6 +99,7 @@ void tcomp_statehandler_deleteCompartment(tcomp_statehandler_t *statehandler, ui
|
|||
item_const = tsk_list_find_item_by_pred(statehandler->compartments, pred_find_compartment_by_id, &id);
|
||||
if(item_const && (compartment = item_const->data))
|
||||
{
|
||||
TSK_DEBUG_INFO("SigComp - Delete compartment %lld", id);
|
||||
tsk_list_remove_item_by_data(statehandler->compartments, compartment);
|
||||
}
|
||||
|
||||
|
@ -263,7 +265,7 @@ compartment_free_states:
|
|||
/*
|
||||
* Request state free now we have the correponding comprtement
|
||||
*/
|
||||
if(tcomp_result_getTempStatesToFreeSize((const tcomp_result_t*)lpResult))
|
||||
if(tcomp_result_getTempStatesToFreeSize((const tcomp_result_t*)*lpResult))
|
||||
{
|
||||
tcomp_compartment_freeStates(lpCompartment, (*lpResult)->statesToFree, tcomp_result_getTempStatesToFreeSize((const tcomp_result_t*)*lpResult));
|
||||
}
|
||||
|
@ -446,8 +448,6 @@ static const tsk_object_def_t tsk_statehandler_def_s =
|
|||
sizeof(tcomp_statehandler_t),
|
||||
tcomp_statehandler_create,
|
||||
tcomp_statehandler_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_statehandler_def_t = &tsk_statehandler_def_s;
|
|
@ -45,7 +45,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#define TCOMP_STATEHANDLER_CREATE() tsk_object_new(tcomp_statehandler_def_t)
|
||||
#define TCOMP_STATEHANDLER_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_STATEHANDLER_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
typedef struct tcomp_statehandler_s
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ typedef struct tcomp_statehandler_s
|
|||
}
|
||||
tcomp_statehandler_t;
|
||||
|
||||
tcomp_compartment_t *tcomp_statehandler_getCompartment(tcomp_statehandler_t *statehandler, uint64_t id);
|
||||
tcomp_compartment_t *tcomp_statehandler_getCompartment(const tcomp_statehandler_t *statehandler, uint64_t id);
|
||||
void tcomp_statehandler_deleteCompartment(tcomp_statehandler_t *statehandler, uint64_t id);
|
||||
int tcomp_statehandler_compartmentExist(tcomp_statehandler_t *statehandler, uint64_t id);
|
||||
uint16_t tcomp_statehandler_findState(tcomp_statehandler_t *statehandler, const tcomp_buffer_handle_t *partial_identifier, tcomp_state_t** lpState);
|
||||
|
|
|
@ -557,8 +557,6 @@ static const tsk_object_def_t tcomp_udvm_def_s =
|
|||
sizeof(tcomp_udvm_t),
|
||||
tcomp_udvm_create,
|
||||
tcomp_udvm_destroy,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
const void *tcomp_udvm_def_t = &tcomp_udvm_def_s;
|
|
@ -47,7 +47,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#define TCOMP_UDVM_CREATE(_sigCompMessage, stateHandler, lpResult) tsk_object_new(tcomp_udvm_def_t, (tcomp_message_t*)_sigCompMessage, (tcomp_statehandler_t*)stateHandler, (tcomp_result_t*)lpResult)
|
||||
#define TCOMP_UDVM_SAFE_FREE(self) tsk_object_unref(self)
|
||||
#define TCOMP_UDVM_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
#define TCOMP_UDVM_SET_2BYTES_VAL(position, value) TSK_BINARY_SET_2BYTES(tcomp_buffer_getBufferAtPos(udvm->memory, position), value)
|
||||
#define TCOMP_UDVM_GET_2BYTES_VAL(position) TSK_BINARY_GET_2BYTES(tcomp_buffer_getBufferAtPos(udvm->memory, position))
|
||||
|
|
|
@ -1912,7 +1912,7 @@ int TCOMP_UDVM_EXEC_INST__OUTPUT(tcomp_udvm_t *udvm, uint16_t output_start, uint
|
|||
*outputbuffer_size += output_length;
|
||||
|
||||
#if DEBUG || _DEBUG
|
||||
tcomp_buffer_nprint(udvm->lpResult->output_buffer, *outputbuffer_size);
|
||||
//tcomp_buffer_nprint(udvm->lpResult->output_buffer, *outputbuffer_size);
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
@ -2087,6 +2087,10 @@ int TCOMP_UDVM_EXEC_INST__END_MESSAGE(tcomp_udvm_t *udvm, uint16_t requested_fee
|
|||
partial_id = TCOMP_BUFFER_CREATE();
|
||||
tcomp_buffer_allocBuff(partial_id, length);
|
||||
tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(partial_id), index, length);
|
||||
if(!udvm->lpResult->remote_parameters->returnedStates)
|
||||
{
|
||||
udvm->lpResult->remote_parameters->returnedStates = TSK_LIST_CREATE();
|
||||
}
|
||||
tsk_list_add_data(udvm->lpResult->remote_parameters->returnedStates, (void**)&partial_id);
|
||||
index += length;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
// Nack - RFC 4077
|
||||
//
|
||||
#define NACK_VERSION 0x01
|
||||
#define NACK_MAX_HISTORY_SIZE 0x0a
|
||||
#define NACK_MAX_HISTORY_SIZE 0x0A
|
||||
|
||||
//
|
||||
// Feedbacks
|
||||
|
|
|
@ -21,11 +21,21 @@
|
|||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "tcomp_manager.h" /* TinySIGCOMP API functions. */
|
||||
|
||||
#define LOOP 0
|
||||
#define TORTURES 0
|
||||
|
||||
#define RUN_TEST_ALL 0
|
||||
#define RUN_TEST_TORTURES 1
|
||||
#if TORTURES
|
||||
|
||||
#define STREAM_ID 1983
|
||||
#define COMPARTMENT_ID "urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a473"
|
||||
#define OUTPUT_BUFFER_SIZE 2000
|
||||
#define DECOMPRESSION_MEMORY_SIZE 65530
|
||||
|
||||
#define RUN_TEST_LOOP 1
|
||||
|
||||
#define RUN_TEST_ALL 1
|
||||
#define RUN_TEST_NO 68
|
||||
|
||||
#include "rfc4465_torture_tests.h"
|
||||
|
||||
|
@ -669,7 +679,7 @@ struct_torture_test tests[] =
|
|||
"A.3.4. Accessing RFC 3485 State",
|
||||
RFC4465_A_3_4__Accessing_RFC_3485_State,
|
||||
61,
|
||||
"0x5349 50",
|
||||
"\x53\x49\x50",
|
||||
11
|
||||
}
|
||||
,
|
||||
|
@ -678,7 +688,7 @@ struct_torture_test tests[] =
|
|||
"A.3.5. Bytecode State Creation_1",
|
||||
RFC4465_A_3_5__Bytecode_State_Creation_1,
|
||||
74,
|
||||
"0x4f4b",
|
||||
"\x4f\x4b",
|
||||
66
|
||||
}
|
||||
,
|
||||
|
@ -687,7 +697,7 @@ struct_torture_test tests[] =
|
|||
"A.3.5. Bytecode State Creation_2",
|
||||
RFC4465_A_3_5__Bytecode_State_Creation_2,
|
||||
8,
|
||||
"0x4f4b 31",
|
||||
"\x4f\x4b\x31",
|
||||
7
|
||||
}
|
||||
,
|
||||
|
@ -696,7 +706,7 @@ struct_torture_test tests[] =
|
|||
"A.3.5. Bytecode State Creation_3",
|
||||
RFC4465_A_3_5__Bytecode_State_Creation_3,
|
||||
13,
|
||||
"0x4f4b 32",
|
||||
"\x4f\x4b\x32",
|
||||
5
|
||||
}
|
||||
,
|
||||
|
@ -705,7 +715,7 @@ struct_torture_test tests[] =
|
|||
"A.3.5. Bytecode State Creation_4",
|
||||
RFC4465_A_3_5__Bytecode_State_Creation_4,
|
||||
7,
|
||||
"0x0000 32",
|
||||
"\x00\x00\x32",
|
||||
5
|
||||
}
|
||||
,
|
||||
|
@ -715,24 +725,13 @@ struct_torture_test tests[] =
|
|||
RFC4465_A_3_5__Bytecode_State_Creation_5,
|
||||
7,
|
||||
"STATE_NOT_FOUND",
|
||||
0
|
||||
0,
|
||||
0,
|
||||
1
|
||||
}
|
||||
};
|
||||
|
||||
#include "tcomp_manager.h"
|
||||
|
||||
#define STREAM_ID 1983
|
||||
#define COMPARTMENT_ID "urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a473"
|
||||
#define OUTPUT_BUFFER_SIZE 2000
|
||||
#define DECOMPRESSION_MEMORY_SIZE 65530
|
||||
|
||||
#define RUN_TEST_LOOP 0
|
||||
|
||||
#define RUN_TEST_ALL 0
|
||||
#define RUN_TEST_NO 48
|
||||
|
||||
|
||||
int startsWith(const char* buffer1, size_t size1, const char* buffer2, size_t size2) /*const*/
|
||||
int startsWith(const char* buffer1, size_t size1, const char* buffer2, size_t size2)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
@ -748,10 +747,14 @@ int startsWith(const char* buffer1, size_t size1, const char* buffer2, size_t si
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
#else
|
||||
int main()
|
||||
#endif
|
||||
{
|
||||
size_t i, start, end;
|
||||
size_t res_size;
|
||||
size_t res_size = 0;
|
||||
char buffer[OUTPUT_BUFFER_SIZE];
|
||||
tcomp_manager_handle_t *manager = TCOMP_MANAGER_CREATE();
|
||||
tcomp_result_t *result = TCOMP_RESULT_CREATE();
|
||||
|
@ -838,3 +841,319 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#else /* !TORTURES */
|
||||
|
||||
#define COMPARTMENT_ID1 "urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a474" // My first compartment id
|
||||
#define COMPARTMENT_ID2 "urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a475" // My second compartment id
|
||||
|
||||
#define IS_STREAM 0 // Using reliable transport
|
||||
#define STREAM_ID 678 // stream identifier
|
||||
|
||||
#define MAX_BUFFER_SIZE 0xfff0
|
||||
|
||||
#define LOOP_COUNT 100
|
||||
|
||||
#define DECOMP_NACK_4_TEST 0
|
||||
|
||||
#define PRINTLN printf("\r\n");
|
||||
|
||||
// messages to use for tests
|
||||
const char* messages[] =
|
||||
{
|
||||
//{
|
||||
"REGISTER sip:ims-network.com SIP/2.0\r\n"
|
||||
"Via: SIP/2.0/UDP [::]:1988;comp=sigcomp;rport;branch=z9hG4bK1245420841406\r\n"
|
||||
"From: <sip:mamadou@ims-network.com>;tag=29358\r\n"
|
||||
"To: <sip:mamadou@ims-network.com>\r\n"
|
||||
"Call-ID: M-fa53180346f7f55ceb8d8670f9223dbb\r\n"
|
||||
"CSeq: 201 REGISTER\r\n"
|
||||
"Max-Forwards: 70\r\n"
|
||||
"Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
|
||||
"Contact: <sip:mamadou@[::]:1988;comp=sigcomp;transport=udp>;expires=600000;+deviceID=\"3ca50bcb-7a67-44f1-afd0-994a55f930f4\";mobility=\"fixed\";+g.3gpp.cs-voice;+g.3gpp.app%5fref=\"urn%3Aurnxxx%3A3gpp-application.ims.iari.gsmais\";+g.oma.sip-im.large-message;+g.oma.sip-im\r\n"
|
||||
"User-Agent: IM-client/OMA1.0 doubango/v4.0.1390.0\r\n"
|
||||
"Require: pref\r\n"
|
||||
"P-Preferred-Identity: <sip:mamadou@ims-network.com>\r\n"
|
||||
"Supported: path\r\n"
|
||||
"P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n"
|
||||
"Privacy: none\r\n"
|
||||
"Supported: timer\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n"
|
||||
//}
|
||||
,
|
||||
//{
|
||||
"SIP/2.0 401 Unauthorized - Challenging the UE\r\n"
|
||||
"Via: SIP/2.0/UDP [::]:1988;comp=sigcomp;received=2001:5C0:1502:1800:1D41:BF77:F1BF:BB49;rport=1988;branch=z9hG4bK1245420841406\r\n"
|
||||
"From: <sip:mamadou@ims-network.com>;tag=29358\r\n"
|
||||
"To: <sip:mamadou@ims-network.com>;tag=3241f316c9eb68efd2c34668c4fbf834-eaa0\r\n"
|
||||
"Call-ID: M-fa53180346f7f55ceb8d8670f9223dbb\r\n"
|
||||
"CSeq: 201 REGISTER\r\n"
|
||||
"Path: <sip:term@pcscf.ims-network.com:4060;lr>\r\n"
|
||||
"Service-Route: <sip:orig@scscf.ims-network.com:6060;lr>"
|
||||
"Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, INFO\r\n"
|
||||
"Server: Sip EXpress router (2.1.0-dev1 OpenIMSCore (i386/linux))\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"Warning: 392 2001:5C0:1502:1800:0:0:0:226:6060 \"Noisy feedback tells: pid=24454 req_src_ip=2001:5C0:1502:1800:0:0:0:226 req_src_port=5060 in_uri=sip:scscf.ims-network.com:6060 out_uri=sip:scscf.ims-network.com:6060 via_cnt==3\"\r\n"
|
||||
"WWW-Authenticate: Digest realm=\"ims-network.com\", nonce=\"xFBhTyFaQ0/lBgboH2ZqDe3BDmFXDwAA2Peq/bxtLQs=\", algorithm=AKAv1-MD5, qop=\"auth,auth-int\"\r\n"
|
||||
"\r\n"
|
||||
|
||||
//}
|
||||
,
|
||||
//{
|
||||
"REGISTER sip:ims-network.com SIP/2.0\r\n"
|
||||
"Via: SIP/2.0/UDP [::]:1988;comp=sigcomp;rport;branch=z9hG4bK1245420841407\r\n"
|
||||
"From: <sip:mamadou@ims-network.com>;tag=29358\r\n"
|
||||
"To: <sip:mamadou@ims-network.com>\r\n"
|
||||
"Call-ID: M-fa53180346f7f55ceb8d8670f9223dbb\r\n"
|
||||
"CSeq: 202 REGISTER\r\n"
|
||||
"Max-Forwards: 70\r\n"
|
||||
"Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
|
||||
"Contact: <sip:mamadou@[::]:1988;comp=sigcomp;transport=udp>;expires=600000;+deviceID=\"3ca50bcb-7a67-44f1-afd0-994a55f930f4\";mobility=\"fixed\";+g.3gpp.cs-voice;+g.3gpp.app%5fref=\"urn%3Aurnxxx%3A3gpp-application.ims.iari.gsmais\";+g.oma.sip-im.large-message;+g.oma.sip-im\r\n"
|
||||
"User-Agent: IM-client/OMA1.0 doubango/v4.0.1390.0\r\n"
|
||||
"Authorization: Digest algorithm=AKAv1-MD5,username=\"mamadou@ims-network.com\",realm=\"ims-network.com\",nonce=\"xFBhTyFaQ0/lBgboH2ZqDe3BDmFXDwAA2Peq/bxtLQs=\",uri=\"sip:ims-network.com\",response=\"c499a6b49693d5b29c431786cff32ca4\",qop=auth-int,cnonce=\"9fcc19edace2d1beaa6122b86dd11256\",nc=00000001\r\n"
|
||||
"Require: pref\r\n"
|
||||
"P-Preferred-Identity: <sip:mamadou@ims-network.com>\r\n"
|
||||
"Supported: path\r\n"
|
||||
"P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n"
|
||||
"Privacy: none\r\n"
|
||||
"Supported: timer\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n"
|
||||
//}
|
||||
,
|
||||
//{
|
||||
"SIP/2.0 200 OK - SAR succesful and registrar saved\r\n"
|
||||
"Via: SIP/2.0/UDP [::]:1988;comp=sigcomp;received=2001:5C0:1502:1800:1D41:BF77:F1BF:BB49;rport=1988;branch=z9hG4bK1245420841407\r\n"
|
||||
"From: <sip:mamadou@ims-network.com>;tag=29358\r\n"
|
||||
"To: <sip:mamadou@ims-network.com>;tag=3241f316c9eb68efd2c34668c4fbf834-1b36\r\n"
|
||||
"Call-ID: M-fa53180346f7f55ceb8d8670f9223dbb\r\n"
|
||||
"CSeq: 202 REGISTER\r\n"
|
||||
"P-Associated-URI: <sip:mamadou@ims-network.com>\r\n"
|
||||
"Contact: <sip:mamadou@[::]:1988;comp=sigcomp;transport=udp>;expires=600000\r\n"
|
||||
"Path: <sip:term@pcscf.ims-network.com:4060;lr>\r\n"
|
||||
"Service-Route: <sip:orig@scscf.ims-network.com:6060;lr>"
|
||||
"Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, INFO\r\n"
|
||||
"P-Charging-Function-Addresses: ccf=pri_ccf_address\r\n"
|
||||
"Server: Sip EXpress router (2.1.0-dev1 OpenIMSCore (i386/linux))\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"Warning: 392 2001:5C0:1502:1800:0:0:0:226:6060 \"Noisy feedback tells: pid=24452 req_src_ip=2001:5C0:1502:1800:0:0:0:226 req_src_port=5060 in_uri=sip:scscf.ims-network.com:6060 out_uri=sip:scscf.ims-network.com:6060 via_cnt==3\"\r\n"
|
||||
"\r\n"
|
||||
//}
|
||||
,
|
||||
//{
|
||||
"SUBSCRIBE sip:mamadou@ims-network.com SIP/2.0\r\n"
|
||||
"Via: SIP/2.0/UDP [::]:1988;comp=sigcomp;rport;branch=z9hG4bK1245420841408\r\n"
|
||||
"From: <sip:mamadou@ims-network.com>;tag=5705\r\n"
|
||||
"To: <sip:mamadou@ims-network.com>\r\n"
|
||||
"Call-ID: M-dd6e227ce416f853ca7bca49ad5b676d\r\n"
|
||||
"CSeq: 301 SUBSCRIBE\r\n"
|
||||
"Max-Forwards: 70\r\n"
|
||||
"Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
|
||||
"Contact: <sip:mamadou@[::]:1988;comp=sigcomp;transport=udp>;+g.oma.sip-im\r\n"
|
||||
"User-Agent: IM-client/OMA1.0 doubango/v4.0.1390.0\r\n"
|
||||
"Expires: 600000\r\n"
|
||||
"Event: reg\r\n"
|
||||
"Accept: application/reginfo+xml\r\n"
|
||||
"Route: <sip:[2001:5c0:1502:1800::226]:4060;lr=true;transport=udp>,<sip:orig@scscf.ims-network.com:6060;lr>\r\n"
|
||||
"P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n"
|
||||
"Privacy: none\r\n"
|
||||
"Supported: timer\r\n"
|
||||
"Allow-Events: presence, presence.winfo, conference\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n"
|
||||
//}
|
||||
,
|
||||
//{
|
||||
"SIP/2.0 200 Subscription to REG saved\r\n"
|
||||
"Record-Route: <sip:mo@pcscf.ims-network.com:4060;lr>\r\n"
|
||||
"Via: SIP/2.0/UDP [::]:1988;comp=sigcomp;received=2001:5C0:1502:1800:1D41:BF77:F1BF:BB49;rport=1988;branch=z9hG4bK1245420841408\r\n"
|
||||
"From: <sip:mamadou@ims-network.com>;tag=5705\r\n"
|
||||
"To: <sip:mamadou@ims-network.com>;tag=3241f316c9eb68efd2c34668c4fbf834-5cce\r\n"
|
||||
"Call-ID: M-dd6e227ce416f853ca7bca49ad5b676d\r\n"
|
||||
"CSeq: 301 SUBSCRIBE\r\n"
|
||||
"Expires: 600000\r\n"
|
||||
"Contact: <sip:mamadou@ims-network.com;comp=sigcomp;>\r\n"
|
||||
"Server: Sip EXpress router (2.1.0-dev1 OpenIMSCore (i386/linux))\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"Warning: 392 2001:5C0:1502:1800:0:0:0:226:6060 \"Noisy feedback tells: pid=24454 req_src_ip=2001:5C0:1502:1800:0:0:0:226 req_src_port=4060 in_uri=sip:mamadou@ims-network.com out_uri=sip:mamadou@ims-network.com via_cnt==2\"\r\n"
|
||||
"\r\n"
|
||||
//}
|
||||
,
|
||||
//{
|
||||
"NOTIFY sip:mamadou@[::]:1988;transport=udp SIP/2.0\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:5C0:1502:1800:0:0:0:226]:4060;comp=sigcomp;branch=z9hG4bK2b3f.38818b91.0\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:5C0:1502:1800:0:0:0:226]:6060;received=2001:5C0:1502:1800:0:0:0:226;rport=6060;branch=z9hG4bK2b3f.6db77cf1.0\r\n"
|
||||
"To: <sip:mamadou@ims-network.com>;tag=5705\r\n"
|
||||
"From: <sip:mamadou@ims-network.com>;tag=3241f316c9eb68efd2c34668c4fbf834-5cce\r\n"
|
||||
"CSeq: 10 NOTIFY\r\n"
|
||||
"Call-ID: M-dd6e227ce416f853ca7bca49ad5b676d\r\n"
|
||||
"Content-Length: 379\r\n"
|
||||
"User-Agent: Sip EXpress router(2.1.0-dev1 OpenIMSCore (i386/linux))\r\n"
|
||||
"Contact: <sip:mamadou@ims-network.com; comp=sigcomp;>\r\n"
|
||||
"Event: reg\r\n"
|
||||
"Max-Forwards: 16\r\n"
|
||||
"Subscription-State: active;expires=600030\r\n"
|
||||
"Content-Type: application/reginfo+xml\r\n"
|
||||
"\r\n"
|
||||
"<?xml version=\"1.0\"?>\r\n"
|
||||
"<reginfo xmlns=\"urn:ietf:params:xml:ns:reginfo\" version=\"0\" state=\"full\">\r\n"
|
||||
"<registration aor=\"sip:mamadou@ims-network.com\" id=\"0xb5d91fcc\" state=\"active\">\r\n"
|
||||
"<contact id=\"0xb5d8fb98\" state=\"active\" event=\"registered\" expires=\"600000\">\r\n"
|
||||
"<uri>sip:mamadou@[::]:1988;transport=udp</uri>\r\n"
|
||||
"</contact>\r\n"
|
||||
"</registration>\r\n"
|
||||
"</reginfo>\r\n"
|
||||
//}
|
||||
,
|
||||
//{
|
||||
"SIP/2.0 200 OK\r\n"
|
||||
"Max-Forwards: 70\r\n"
|
||||
"User-Agent: IM-client/OMA1.0 doubango/v4.0.1390.0\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:5C0:1502:1800:0:0:0:226]:4060;comp=sigcomp;branch=z9hG4bK2b3f.38818b91.0;received=2001:5c0:1502:1800::226\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:5C0:1502:1800:0:0:0:226]:6060;received=2001:5C0:1502:1800:0:0:0:226;rport=6060;branch=z9hG4bK2b3f.6db77cf1.0\r\n"
|
||||
"To: <sip:mamadou@ims-network.com>;tag=5705\r\n"
|
||||
"From: <sip:mamadou@ims-network.com>;tag=3241f316c9eb68efd2c34668c4fbf834-5cce\r\n"
|
||||
"CSeq: 10 NOTIFY\r\n"
|
||||
"Call-ID: M-dd6e227ce416f853ca7bca49ad5b676d\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n"
|
||||
//}
|
||||
};
|
||||
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
#else
|
||||
int main()
|
||||
#endif
|
||||
{
|
||||
int i = 0;
|
||||
size_t outLen = 0;
|
||||
|
||||
tcomp_manager_handle_t *manager1 = 0, *manager2 = 0;
|
||||
tcomp_result_t *result1 = 0, *result2 = 0;
|
||||
|
||||
/* temporary buffers --> will hold compression/decompression results */
|
||||
char buff1[MAX_BUFFER_SIZE];
|
||||
char buff2[MAX_BUFFER_SIZE];
|
||||
|
||||
/* Managers */
|
||||
manager1 = TCOMP_MANAGER_CREATE();
|
||||
manager2 = TCOMP_MANAGER_CREATE();
|
||||
|
||||
/* Add SIP/Presence dictionnaries */
|
||||
tcomp_manager_addSipSdpDictionary(manager1);
|
||||
tcomp_manager_addPresenceDictionary(manager1);
|
||||
tcomp_manager_addSipSdpDictionary(manager2);
|
||||
tcomp_manager_addPresenceDictionary(manager2);
|
||||
|
||||
/* Results --> it is recomanded to use one result struct for each manager */
|
||||
result1 = TCOMP_RESULT_CREATE();
|
||||
result2 = TCOMP_RESULT_CREATE();
|
||||
|
||||
/* Sets compartment Ids */
|
||||
tcomp_result_setCompartmentId(result1, COMPARTMENT_ID1, strlen(COMPARTMENT_ID1));
|
||||
tcomp_result_setCompartmentId(result2, COMPARTMENT_ID2, strlen(COMPARTMENT_ID2));
|
||||
|
||||
/* Set DMS and SMS */
|
||||
tcomp_manager_setDecompression_Memory_Size(manager1, 8192);
|
||||
tcomp_manager_setDecompression_Memory_Size(manager2, 8192);
|
||||
tcomp_manager_setCycles_Per_Bit(manager1, 64);
|
||||
tcomp_manager_setCycles_Per_Bit(manager2, 64);
|
||||
tcomp_manager_setState_Memory_Size(manager1, 8192);
|
||||
tcomp_manager_setState_Memory_Size(manager2, 8192);
|
||||
|
||||
for(i = 0; i< (8*LOOP_COUNT); i++)
|
||||
{
|
||||
memset(buff1, '\0', MAX_BUFFER_SIZE);
|
||||
memset(buff2, '\0', MAX_BUFFER_SIZE);
|
||||
|
||||
//
|
||||
// Compression using manager I
|
||||
//
|
||||
outLen = tcomp_manager_compress(manager1, COMPARTMENT_ID1, strlen(COMPARTMENT_ID1), messages[i%8], strlen(messages[i%8]), buff1, MAX_BUFFER_SIZE, IS_STREAM);
|
||||
if(outLen)
|
||||
{
|
||||
//* TODO: sendto(SendSocket, buff1, outLen, 0, (SOCKADDR *) &SenderAddr, sizeof(SenderAddr));
|
||||
|
||||
/*
|
||||
* Decompress the compressed message using manager II
|
||||
*/
|
||||
tcomp_result_setOutputBuffer(result2, buff2, MAX_BUFFER_SIZE, IS_STREAM, STREAM_ID); // set the output buffer where to copy decompressed message
|
||||
outLen = tcomp_manager_decompress(manager2, buff1, outLen, result2);
|
||||
if(outLen) // OK
|
||||
{
|
||||
// buff2 contains the result and outLen is result length
|
||||
printf("%s\n\n", buff2);
|
||||
PRINTLN;
|
||||
|
||||
// provide the compartment id --> save temp states
|
||||
tcomp_manager_provideCompartmentId(manager2, result2);
|
||||
}
|
||||
else // NOK
|
||||
{
|
||||
printf("ERROR (1)");
|
||||
PRINTLN;
|
||||
//--assert(tcomp_result_getIsNack(result2));
|
||||
#if DECOMP_NACK_4_TEST
|
||||
manager1->decompress(result2.getNackInfo()->getBuffer(), result2.getNackInfo()->getSize(), &result1);
|
||||
#endif
|
||||
// Decompression failed --> handle NACK (done by remote party)
|
||||
// NACK will be retourned only if SigCompVersion >= 2
|
||||
// NACK must be sent to the remote party (SIP/IMS use-case) over the network
|
||||
//* TODO: sendto(SendSocket, result2.getNackInfo()->getBuffer(), result2.getNackInfo()->getSize(), 0, (SOCKADDR *) &SenderAddr, sizeof(SenderAddr));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout<< "ERROR (2)" << std::endl;
|
||||
//--assert(0); // MUST never happen
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Compression using manager II
|
||||
//
|
||||
outLen = tcomp_manager_compress(manager2, COMPARTMENT_ID2, strlen(COMPARTMENT_ID2), messages[i%8], strlen(messages[i%8]), buff2, MAX_BUFFER_SIZE, IS_STREAM);
|
||||
if(outLen)
|
||||
{
|
||||
tcomp_result_setOutputBuffer(result1, buff1, MAX_BUFFER_SIZE, IS_STREAM, STREAM_ID); // set the output buffer where to copy decompressed message
|
||||
outLen = tcomp_manager_decompress(manager1, buff2, outLen, result1);
|
||||
if(outLen)
|
||||
{
|
||||
printf(buff1);
|
||||
PRINTLN;
|
||||
tcomp_manager_provideCompartmentId(manager1, result1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ERROR (3)");
|
||||
//--assert(tcomp_result_getIsNack(result2));
|
||||
#if DECOMP_NACK_4_TEST
|
||||
manager2->decompress(result1.getNackInfo()->getBuffer(), result1.getNackInfo()->getSize(), &result2);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ERROR (4)");
|
||||
//--assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Close compartments
|
||||
tcomp_manager_closeCompartment(manager1, COMPARTMENT_ID1, strlen(COMPARTMENT_ID1));
|
||||
tcomp_manager_closeCompartment(manager2, COMPARTMENT_ID2, strlen(COMPARTMENT_ID2));
|
||||
|
||||
// Delete Results
|
||||
TCOMP_RESULT_SAFE_FREE(result1);
|
||||
TCOMP_RESULT_SAFE_FREE(result2);
|
||||
|
||||
// Delete managers
|
||||
TCOMP_MANAGER_SAFE_FREE(manager1);
|
||||
TCOMP_MANAGER_SAFE_FREE(manager2);
|
||||
}
|
||||
|
||||
|
||||
#endif /* TORTURES */
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
|
@ -118,6 +121,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)\src";"$(DOUBANGO_HOME)\thirdparties\win32\include";"$(DOUBANGO_HOME)\tinySAK\src""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
|
@ -137,6 +141,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinySIGCOMP.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
|
@ -166,6 +171,170 @@
|
|||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
|
||||
OutputDirectory=""$(SolutionDir)$(ConfigurationName)\wce""
|
||||
IntermediateDirectory=""$(SolutionDir)$(ConfigurationName)""
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ExecutionBucket="7"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)\src";"$(DOUBANGO_HOME)\thirdparties\wince\include";"$(DOUBANGO_HOME)\tinySAK\src""
|
||||
PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
WarnAsError="true"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinySIGCOMP.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="8"
|
||||
EntryPointSymbol="mainWCRTStartup"
|
||||
ResourceOnlyDLL="false"
|
||||
TargetMachine="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCodeSignTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
<DeploymentTool
|
||||
ForceDirty="-1"
|
||||
RemoteDirectory=""
|
||||
RegisterOutput="0"
|
||||
AdditionalFiles=""
|
||||
/>
|
||||
<DebuggerTool
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
|
||||
OutputDirectory=""$(SolutionDir)$(ConfigurationName)\wce""
|
||||
IntermediateDirectory=""$(SolutionDir)$(ConfigurationName)""
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ExecutionBucket="7"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="8"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCodeSignTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
<DeploymentTool
|
||||
ForceDirty="-1"
|
||||
RemoteDirectory=""
|
||||
RegisterOutput="0"
|
||||
AdditionalFiles=""
|
||||
/>
|
||||
<DebuggerTool
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
|
|
|
@ -17,21 +17,21 @@ Global
|
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Win32.Build.0 = Release|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Release|Win32.Build.0 = Release|Win32
|
||||
{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
|
||||
{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}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = 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
|
||||
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
|
@ -42,7 +45,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(DOUBANGO_HOME)\thirdparties\win32\include";"$(DOUBANGO_HOME)\tinySAK\src""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TINYSIGCOMP_EXPORTS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TINYSIGCOMP_EXPORTS;DEBUG_LEVEL=DEBUG_LEVEL_INFO"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
@ -50,6 +53,7 @@
|
|||
WarningLevel="3"
|
||||
WarnAsError="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
|
@ -90,6 +94,86 @@
|
|||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
|
||||
OutputDirectory=""$(SolutionDir)$(ConfigurationName)\wce""
|
||||
IntermediateDirectory=""$(SolutionDir)$(ConfigurationName)""
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ExecutionBucket="7"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(DOUBANGO_HOME)\thirdparties\win32\include";"$(DOUBANGO_HOME)\tinySAK\src""
|
||||
PreprocessorDefinitions="TINYSIGCOMP_EXPORTS;DEBUG_LEVEL=DEBUG_LEVEL_INFO;_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_WINDOWS;_USRDLL;$(ARCHFAM);$(_ARCHFAM_)"
|
||||
MinimalRebuild="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
WarnAsError="true"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="$(OutDir)\tinySAK.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="8"
|
||||
TargetMachine="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCodeSignTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
<DeploymentTool
|
||||
ForceDirty="-1"
|
||||
RemoteDirectory="%CSIDL_PROGRAM_FILES%\test"
|
||||
RegisterOutput="0"
|
||||
AdditionalFiles=""
|
||||
/>
|
||||
<DebuggerTool
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
|
@ -117,12 +201,14 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories=""$(DOUBANGO_HOME)\thirdparties\win32\include";"$(DOUBANGO_HOME)\tinySAK\src""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TINYSIGCOMP_EXPORTS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
|
@ -135,6 +221,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="$(OutDir)\tinySAK.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
|
@ -164,6 +251,87 @@
|
|||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
|
||||
OutputDirectory=""$(SolutionDir)$(ConfigurationName)\wce""
|
||||
IntermediateDirectory=""$(SolutionDir)$(ConfigurationName)""
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ExecutionBucket="7"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TINYSIGCOMP_EXPORTS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="8"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCodeSignTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
<DeploymentTool
|
||||
ForceDirty="-1"
|
||||
RemoteDirectory=""
|
||||
RegisterOutput="0"
|
||||
AdditionalFiles=""
|
||||
/>
|
||||
<DebuggerTool
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
|
@ -292,6 +460,26 @@
|
|||
<Filter
|
||||
Name="Compressors"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_compressor_deflate.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_compressor_dummy.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_deflatedata.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_deflatedata.ghost.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_deflatedata.zlib.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -387,7 +575,7 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_nakinfo.h"
|
||||
RelativePath=".\src\tcomp_nackinfo.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
@ -434,6 +622,22 @@
|
|||
<Filter
|
||||
Name="Compressors"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_compressor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_compressor_deflate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_compressor_dummy.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tcomp_deflatedata.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
|
|
@ -42,4 +42,7 @@
|
|||
#undef _WIN32 /* Because of WINSCW */
|
||||
#endif
|
||||
|
||||
/* Tiny SAK */
|
||||
#define TINYSAK_IMPORTS
|
||||
|
||||
#endif // TINYXCAP_CONFIG_H
|
||||
|
|
|
@ -254,8 +254,8 @@ void txc_content_set(txc_content_t* content, const char *data, size_t size, cons
|
|||
{
|
||||
if(content)
|
||||
{
|
||||
tsk_strupdate2(&(content->data), data);
|
||||
tsk_strupdate2(&(content->type), type);
|
||||
tsk_strupdate(&(content->data), data);
|
||||
tsk_strupdate(&(content->type), type);
|
||||
content->size = size;
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ const txc_auid_t* txc_auid_findby_name(const AUIDS_T auids, const char* name)
|
|||
int i;
|
||||
for(i=0; i< sizeof(AUIDS_T)/sizeof(txc_auid_t); i++)
|
||||
{
|
||||
if(tsk_equals(auids[i].name, name))
|
||||
if(tsk_strequals(auids[i].name, name))
|
||||
{
|
||||
return &auids[i];
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ void txc_auid_update(txc_context_t* context, xcap_auid_type_t type, const char*
|
|||
const txc_auid_t* auid = txc_auid_findby_type(context->auids, type);
|
||||
if(auid)
|
||||
{
|
||||
tsk_strupdate(&context->heap, &(((txc_auid_t*)auid)->document), document);
|
||||
tsk_strupdate(&(((txc_auid_t*)auid)->document), document);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ void txc_auid_free(void **_auid)
|
|||
TSK_FREE((*auid)->content_type);
|
||||
TSK_FREE((*auid)->document);
|
||||
|
||||
tsk_free2(_auid);
|
||||
tsk_free(_auid);
|
||||
}
|
||||
|
||||
/**@ingroup txc_group
|
||||
|
@ -397,17 +397,14 @@ void txc_context_init(txc_context_t* context)
|
|||
{
|
||||
int i;
|
||||
|
||||
/* initialize the context's memory heap */
|
||||
tsk_heap_init(&context->heap);
|
||||
|
||||
/* copy all default auids */
|
||||
for(i = 0; i< (sizeof(AUIDS_T)/sizeof(txc_auid_t)); i++)
|
||||
{
|
||||
context->auids[i].type = txc_auids[i].type;
|
||||
context->auids[i].available = txc_auids[i].available;
|
||||
context->auids[i].content_type = tsk_strdup(&context->heap, txc_auids[i].content_type);
|
||||
context->auids[i].document = tsk_strdup(&context->heap, txc_auids[i].document);
|
||||
context->auids[i].name = tsk_strdup(&context->heap, txc_auids[i].name);
|
||||
context->auids[i].content_type = tsk_strdup(txc_auids[i].content_type);
|
||||
context->auids[i].document = tsk_strdup(txc_auids[i].document);
|
||||
context->auids[i].name = tsk_strdup(txc_auids[i].name);
|
||||
}
|
||||
|
||||
/* initialize libcurl */
|
||||
|
@ -421,7 +418,7 @@ void txc_context_init(txc_context_t* context)
|
|||
context->multihandle = curl_multi_init();
|
||||
|
||||
/* Pthread semaphore + thread */
|
||||
TSK_SEMAPHORE_CREATE(context->semaphore);
|
||||
context->semaphore = tsk_semaphore_create();
|
||||
context->running = 1;
|
||||
tsk_thread_create(&(context->tid), curl_async_process, context);
|
||||
}
|
||||
|
@ -454,6 +451,8 @@ void txc_context_update_available_auids(txc_context_t *context, const tsk_list_t
|
|||
*/
|
||||
void txc_context_free(txc_context_t** context)
|
||||
{
|
||||
int i;
|
||||
|
||||
TSK_FREE((*context)->txc_root);
|
||||
TSK_FREE((*context)->xui);
|
||||
TSK_FREE((*context)->password);
|
||||
|
@ -464,20 +463,24 @@ void txc_context_free(txc_context_t** context)
|
|||
TSK_FREE((*context)->pragma);
|
||||
TXC_EASYHANDLE_SAFE_FREE((*context)->easyhandle);
|
||||
|
||||
for(i = 0; i< (sizeof(AUIDS_T)/sizeof(txc_auid_t)); i++)
|
||||
{
|
||||
TSK_FREE((*context)->auids[i].content_type);
|
||||
TSK_FREE((*context)->auids[i].document);
|
||||
TSK_FREE((*context)->auids[i].name);
|
||||
}
|
||||
|
||||
/* Pthread semaphore + static thread */
|
||||
(*context)->running = 0;
|
||||
tsk_semaphore_increment((*context)->semaphore);
|
||||
tsk_thread_join(&((*context)->tid));
|
||||
TSK_SEMAPHORE_SAFE_FREE((*context)->semaphore);
|
||||
|
||||
/* cleanup the heap */
|
||||
tsk_heap_cleanup(&((*context)->heap));
|
||||
tsk_semaphore_destroy(&(*context)->semaphore);
|
||||
|
||||
/* cleanup multihandle*/
|
||||
curl_multi_cleanup((*context)->multihandle);
|
||||
|
||||
/* free the context */
|
||||
tsk_free2(context);
|
||||
tsk_free(context);
|
||||
|
||||
/* cleanup libcurl */
|
||||
curl_global_cleanup();
|
||||
|
@ -517,7 +520,7 @@ void txc_request_free(txc_request_t** request)
|
|||
/* Curl easyhandle cleanup */
|
||||
curl_easy_cleanup((*request)->easyhandle);
|
||||
|
||||
tsk_free2(request);
|
||||
tsk_free(request);
|
||||
}
|
||||
|
||||
/*== libcurl write callback */
|
||||
|
@ -570,12 +573,10 @@ CURLcode txc_easyhandle_init(txc_context_t* context, txc_request_t* request, txc
|
|||
{
|
||||
CURLcode code = CURLE_OK;
|
||||
char* temp_str = 0;
|
||||
tsk_heap_t heap;
|
||||
|
||||
if(request->easyhandle) curl_easy_cleanup(request->easyhandle);
|
||||
|
||||
request->easyhandle = curl_easy_init();
|
||||
tsk_heap_init(&heap);
|
||||
|
||||
#if (DEBUG || _DEBUG) && 0
|
||||
curl_easy_setopt(request->easyhandle, CURLOPT_VERBOSE, 1);
|
||||
|
@ -629,14 +630,16 @@ CURLcode txc_easyhandle_init(txc_context_t* context, txc_request_t* request, txc
|
|||
}
|
||||
|
||||
/* X-3GPP-Intended-Identity */
|
||||
tsk_sprintf(&heap, &temp_str, "X-3GPP-Intended-Identity: \"%s\"", context->xui);
|
||||
tsk_sprintf(&temp_str, "X-3GPP-Intended-Identity: \"%s\"", context->xui);
|
||||
request->headers = curl_slist_append(request->headers, temp_str);
|
||||
TSK_FREE(temp_str);
|
||||
|
||||
/* Content-Type */
|
||||
if(request->content && request->content->type)
|
||||
{
|
||||
tsk_sprintf(&heap, &temp_str, "Content-Type: %s", request->content->type);
|
||||
tsk_sprintf(&temp_str, "Content-Type: %s", request->content->type);
|
||||
request->headers = curl_slist_append(request->headers, temp_str);
|
||||
TSK_FREE(temp_str);
|
||||
}
|
||||
|
||||
/* set proxy host */
|
||||
|
@ -678,15 +681,17 @@ CURLcode txc_easyhandle_init(txc_context_t* context, txc_request_t* request, txc
|
|||
/* Pragma */
|
||||
if(context->pragma)
|
||||
{
|
||||
tsk_sprintf(&heap, &temp_str, "Pragma: %s", context->pragma);
|
||||
tsk_sprintf(&temp_str, "Pragma: %s", context->pragma);
|
||||
request->headers = curl_slist_append(request->headers, temp_str);
|
||||
TSK_FREE(temp_str);
|
||||
}
|
||||
|
||||
/* Accept */
|
||||
if(request->http_accept)
|
||||
{
|
||||
tsk_sprintf(&heap, &temp_str, "Accept: \"%s\"", request->http_accept);
|
||||
tsk_sprintf(&temp_str, "Accept: \"%s\"", request->http_accept);
|
||||
request->headers = curl_slist_append(request->headers, temp_str);
|
||||
TSK_FREE(temp_str);
|
||||
}
|
||||
else request->headers = curl_slist_append(request->headers, "Accept:");
|
||||
|
||||
|
@ -694,8 +699,9 @@ CURLcode txc_easyhandle_init(txc_context_t* context, txc_request_t* request, txc
|
|||
/* Expect */
|
||||
if(request->http_expect)
|
||||
{
|
||||
tsk_sprintf(&heap, &temp_str, "Expect: %s", request->http_expect);
|
||||
tsk_sprintf(&temp_str, "Expect: %s", request->http_expect);
|
||||
request->headers = curl_slist_append(request->headers, temp_str);
|
||||
TSK_FREE(temp_str);
|
||||
}
|
||||
|
||||
/* pass our list of custom made headers */
|
||||
|
@ -751,8 +757,9 @@ CURLcode txc_easyhandle_init(txc_context_t* context, txc_request_t* request, txc
|
|||
}
|
||||
|
||||
/* content length */
|
||||
tsk_sprintf(&heap, &temp_str, "Content-Length: %u", request->content->size);
|
||||
tsk_sprintf(&temp_str, "Content-Length: %u", request->content->size);
|
||||
request->headers = curl_slist_append(request->headers, temp_str);
|
||||
TSK_FREE(temp_str);
|
||||
|
||||
/* ioctl function callback */
|
||||
if(code=curl_easy_setopt(request->easyhandle, CURLOPT_IOCTLFUNCTION , ioctl_callback))
|
||||
|
@ -778,9 +785,6 @@ CURLcode txc_easyhandle_init(txc_context_t* context, txc_request_t* request, txc
|
|||
|
||||
bail:
|
||||
|
||||
/* free the header list */
|
||||
tsk_heap_cleanup(&heap);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -861,7 +865,7 @@ static void* curl_async_process(void* arg)
|
|||
{
|
||||
char* contentType = 0;
|
||||
curl_easy_getinfo(easyhandle, CURLINFO_CONTENT_TYPE, &contentType);
|
||||
tsk_strupdate2(&(request->content->type), contentType);
|
||||
tsk_strupdate(&(request->content->type), contentType);
|
||||
}
|
||||
TSK_DEBUG_INFO("New XCAP response received from the XDMS");
|
||||
context->http_callback(request);
|
||||
|
@ -1120,7 +1124,7 @@ bail:
|
|||
// /* get response content-type */
|
||||
// if(code=curl_easy_getinfo(context->easyhandle, CURLINFO_CONTENT_TYPE, (&temp_str)))
|
||||
// PANIC_AND_JUMP(xpa_libcurl_error, request)
|
||||
// else if(request->content) request->content->type = tsk_strdup2((const char*)temp_str);
|
||||
// else if(request->content) request->content->type = tsk_strdup((const char*)temp_str);
|
||||
//
|
||||
//bail:
|
||||
//
|
||||
|
|
|
@ -299,10 +299,9 @@ typedef struct txc_context_s
|
|||
char* pragma; /**< HTTP pragma */
|
||||
char* user_agent; /**< The user agent. */
|
||||
AUIDS_T auids; /**< Contains list of all default auids. */
|
||||
tsk_heap_t heap; /**< Internal heap*/
|
||||
|
||||
|
||||
void* tid; /**< Thread id */
|
||||
tsk_semaphore_t *semaphore; /**< Pthread semaphore */
|
||||
tsk_semaphore_handle_t *semaphore; /**< Pthread semaphore */
|
||||
|
||||
CURLM *multihandle; /**< Curl multi-handle */
|
||||
CURL* easyhandle; /**< Curl handle. */
|
||||
|
|
|
@ -122,13 +122,13 @@ char* txc_doc_get_cust_sel(const char *xcaproot, const char *auid, const char *x
|
|||
|
||||
if(!xcaproot || !auid || !name) return 0;
|
||||
|
||||
if(!xui || tsk_equals("global", xui))
|
||||
if(!xui || tsk_striequals("global", xui))
|
||||
{ /* xdm-root/auid-name/global/doc-name */
|
||||
tsk_sprintf(0, &selector, "%s/%s/global/%s", xcaproot, auid, name);
|
||||
tsk_sprintf(&selector, "%s/%s/global/%s", xcaproot, auid, name);
|
||||
}
|
||||
else
|
||||
{ /* xdm-root/auid-name/users/xui/doc-name */
|
||||
tsk_sprintf(0, &selector, "%s/%s/users/%s/%s", xcaproot, auid, xui, name);
|
||||
tsk_sprintf(&selector, "%s/%s/users/%s/%s", xcaproot, auid, xui, name);
|
||||
}
|
||||
|
||||
return selector;
|
||||
|
|
|
@ -58,10 +58,10 @@ char *rlist2_str = 0, *rls_str = 0, *oma_presrules_str = 0;
|
|||
TXC_CONTEXT_CREATE(context);
|
||||
|
||||
// Initialize the context
|
||||
context->user_agent = tsk_strdup2("XDM-client/OMA1.1");
|
||||
context->xdm_root = tsk_strdup2("http://xcap.example.com/services");
|
||||
context->password = tsk_strdup2("mysecret");
|
||||
context->xui = tsk_strdup2("sip:doubango@example.com");
|
||||
context->user_agent = tsk_strdup("XDM-client/OMA1.1");
|
||||
context->xdm_root = tsk_strdup("http://xcap.example.com/services");
|
||||
context->password = tsk_strdup("mysecret");
|
||||
context->xui = tsk_strdup("sip:doubango@example.com");
|
||||
|
||||
// Create an GSMA RCS2 resource-lists document object and serialize the document for test
|
||||
rlist2 = txc_gsmarcs_create_rlist2(context);
|
||||
|
@ -88,21 +88,21 @@ TXC_CONTEXT_SAFE_FREE(context);
|
|||
*/
|
||||
|
||||
#define GSME_RCS_RLIST_ADD_ANCHOR(lname)\
|
||||
tsk_sprintf(0, &anchor, \
|
||||
tsk_sprintf(&anchor, \
|
||||
"%s/~~/resource-lists/list%%5B@name=%%22%s%%22%%5D", \
|
||||
doc_sel, lname); \
|
||||
txc_rlist_list2_add_external(list2, anchor); \
|
||||
TSK_FREE(anchor);
|
||||
|
||||
#define GSMA_RCS_ADD_SERVICE(lname, package)\
|
||||
tsk_sprintf(0, &uri, "%s;pres-list=%s", \
|
||||
tsk_sprintf(&uri, "%s;pres-list=%s", \
|
||||
context->xui, lname);\
|
||||
tsk_sprintf(0, &resource_list, \
|
||||
tsk_sprintf(&resource_list, \
|
||||
"%s/~~/resource-lists/list%%5B@name=%%22%s%%22%%5D", \
|
||||
doc_sel, lname); \
|
||||
txc_rls_service_set(service, uri, resource_list); \
|
||||
txc_rls_service_add_package(service, package); \
|
||||
tsk_list_add_data(services, ((void**) &service), txc_rls_service_free); \
|
||||
tsk_list_add_data(services, ((void**) &service)); \
|
||||
TSK_FREE(resource_list); \
|
||||
TSK_FREE(uri);
|
||||
|
||||
|
@ -127,49 +127,49 @@ txc_rlist_list2_L_t* txc_gsmarcs_create_rlist2(const txc_context_t* context)
|
|||
}
|
||||
|
||||
/* create list to be returned */
|
||||
TSK_LIST_CREATE(rlist);
|
||||
rlist = TSK_LIST_CREATE();
|
||||
|
||||
/* list containing all contacts and named 'all' */
|
||||
TXC_RLIST_LIST2_CREATE(list2);
|
||||
list2 = TXC_RLIST_LIST2_CREATE();
|
||||
txc_rlist_list2_set(list2, "all", "all contacts");
|
||||
tsk_list_add_data(rlist, ((void**) &list2), txc_rlist_list2_free);
|
||||
tsk_list_add_data(rlist, ((void**) &list2));
|
||||
|
||||
/* rcs */
|
||||
TXC_RLIST_LIST2_CREATE(list2);
|
||||
list2 = TXC_RLIST_LIST2_CREATE();
|
||||
txc_rlist_list2_set(list2, TXC_RNAME_GSMA_RCS_RCS, TXC_RNAME_GSMA_RCS_RCS);
|
||||
txc_rlist_list2_add_entry(list2, context->xui, "own"); /* RCS 2 */
|
||||
GSME_RCS_RLIST_ADD_ANCHOR("all");
|
||||
tsk_list_add_data(rlist, ((void**) &list2), txc_rlist_list2_free);
|
||||
tsk_list_add_data(rlist, ((void**) &list2));
|
||||
|
||||
/* rcs_blockedcontacts */
|
||||
TXC_RLIST_LIST2_CREATE(list2);
|
||||
list2 = TXC_RLIST_LIST2_CREATE();
|
||||
txc_rlist_list2_set(list2, TXC_RNAME_GSMA_RCS_BLOCKEDCONTACTS, TXC_RNAME_GSMA_RCS_BLOCKEDCONTACTS);
|
||||
tsk_list_add_data(rlist, ((void**) &list2), txc_rlist_list2_free);
|
||||
tsk_list_add_data(rlist, ((void**) &list2));
|
||||
|
||||
/* rcs_revokedcontacts” */
|
||||
TXC_RLIST_LIST2_CREATE(list2);
|
||||
list2 = TXC_RLIST_LIST2_CREATE();
|
||||
txc_rlist_list2_set(list2, TXC_RNAME_GSMA_RCS_REVOKEDCONTACTS, TXC_RNAME_GSMA_RCS_REVOKEDCONTACTS);
|
||||
tsk_list_add_data(rlist, ((void**) &list2), txc_rlist_list2_free);
|
||||
tsk_list_add_data(rlist, ((void**) &list2));
|
||||
|
||||
/* oma_buddylist */
|
||||
TXC_RLIST_LIST2_CREATE(list2);
|
||||
list2 = TXC_RLIST_LIST2_CREATE();
|
||||
txc_rlist_list2_set(list2, TXC_RNAME_OMA_BUDDYLIST, TXC_RNAME_OMA_BUDDYLIST);
|
||||
GSME_RCS_RLIST_ADD_ANCHOR(TXC_RNAME_GSMA_RCS_RCS);
|
||||
tsk_list_add_data(rlist, ((void**) &list2), txc_rlist_list2_free);
|
||||
tsk_list_add_data(rlist, ((void**) &list2));
|
||||
|
||||
/* oma_grantedcontacts */
|
||||
TXC_RLIST_LIST2_CREATE(list2);
|
||||
list2 = TXC_RLIST_LIST2_CREATE();
|
||||
txc_rlist_list2_set(list2, TXC_RNAME_OMA_GRANTEDCONTACTS, TXC_RNAME_OMA_GRANTEDCONTACTS);
|
||||
GSME_RCS_RLIST_ADD_ANCHOR(TXC_RNAME_GSMA_RCS_RCS);
|
||||
GSME_RCS_RLIST_ADD_ANCHOR(TXC_RNAME_OMA_BUDDYLIST);
|
||||
tsk_list_add_data(rlist, ((void**) &list2), txc_rlist_list2_free);
|
||||
tsk_list_add_data(rlist, ((void**) &list2));
|
||||
|
||||
/* oma_blockedcontacts */
|
||||
TXC_RLIST_LIST2_CREATE(list2);
|
||||
list2 = TXC_RLIST_LIST2_CREATE();
|
||||
txc_rlist_list2_set(list2, TXC_RNAME_OMA_BLOCKEDCONTACTS, TXC_RNAME_OMA_BLOCKEDCONTACTS);
|
||||
GSME_RCS_RLIST_ADD_ANCHOR(TXC_RNAME_GSMA_RCS_BLOCKEDCONTACTS);
|
||||
GSME_RCS_RLIST_ADD_ANCHOR(TXC_RNAME_GSMA_RCS_REVOKEDCONTACTS);
|
||||
tsk_list_add_data(rlist, ((void**) &list2), txc_rlist_list2_free);
|
||||
tsk_list_add_data(rlist, ((void**) &list2));
|
||||
|
||||
bail:
|
||||
/* free doc sel */
|
||||
|
@ -198,14 +198,14 @@ txc_rls_service_L_t* txc_gsmarcs_create_rls(const txc_context_t* context)
|
|||
}
|
||||
|
||||
/* create list to be returned */
|
||||
TSK_LIST_CREATE(services);
|
||||
services = TSK_LIST_CREATE();
|
||||
|
||||
/* rcs */
|
||||
TXC_RLS_SERVICE_CREATE(service);
|
||||
service = TXC_RLS_SERVICE_CREATE();
|
||||
GSMA_RCS_ADD_SERVICE(TXC_RNAME_GSMA_RCS_RCS, "presence");
|
||||
|
||||
/* oma buddy list */
|
||||
TXC_RLS_SERVICE_CREATE(service);
|
||||
service = TXC_RLS_SERVICE_CREATE();
|
||||
GSMA_RCS_ADD_SERVICE(TXC_RNAME_OMA_BUDDYLIST, "presence");
|
||||
|
||||
bail:
|
||||
|
|
|
@ -154,17 +154,17 @@ char* txc_ietf_presrules_serialize(const txc_context_t *context)
|
|||
}
|
||||
|
||||
/* oma granted contacts */
|
||||
tsk_sprintf(0, &oma_grantedcontacts,
|
||||
tsk_sprintf(&oma_grantedcontacts,
|
||||
"%s/~~/resource-lists/list%%5B@name=%%22%s%%22%%5D",
|
||||
doc_sel, TXC_RNAME_OMA_GRANTEDCONTACTS);
|
||||
|
||||
/* oma blocked contacts */
|
||||
tsk_sprintf(0, &oma_blockedcontacts,
|
||||
tsk_sprintf(&oma_blockedcontacts,
|
||||
"%s/~~/resource-lists/list%%5B@name=%%22%s%%22%%5D",
|
||||
doc_sel, TXC_RNAME_OMA_BLOCKEDCONTACTS);
|
||||
|
||||
/* append all */
|
||||
tsk_sprintf(0, &ietf_presrules_str, TXC_IETF_PRESRULES_TEMPLATE,
|
||||
tsk_sprintf(&ietf_presrules_str, TXC_IETF_PRESRULES_TEMPLATE,
|
||||
context->xui, oma_grantedcontacts, oma_blockedcontacts);
|
||||
|
||||
bail:
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
* @param prefix the prefix of the object to create
|
||||
*/
|
||||
#define TXC_XXX_CREATE2(xxx, prefix)\
|
||||
xxx = (txc_##prefix##_t*)tsk_calloc2(1, sizeof(txc_##prefix##_t)); \
|
||||
xxx = (txc_##prefix##_t*)tsk_calloc(1, sizeof(txc_##prefix##_t)); \
|
||||
txc_##prefix##_init(xxx);
|
||||
|
||||
/**@def TXC_XXX_SAFE_FREE2
|
||||
|
|
|
@ -187,20 +187,17 @@ static char* __internal_txc_node_get_cust_sel(const char* doc_selector, const ch
|
|||
|
||||
int step;
|
||||
char *result=0, *node_root = 0, *_namespace=0, *step_str = 0;
|
||||
tsk_heap_t heap;
|
||||
|
||||
/* check parameters validity */
|
||||
if(!doc_selector || !auid) return 0;
|
||||
|
||||
/* initialize memory heap */
|
||||
tsk_heap_init(&heap);
|
||||
|
||||
/* set base uri*/
|
||||
uri = tsk_strdup2(doc_selector);
|
||||
uri = tsk_strdup(doc_selector);
|
||||
|
||||
/* append node root*/
|
||||
tsk_sprintf(&heap, &node_root, "/~~/%s", auid);
|
||||
tsk_strcat2(&uri, node_root);
|
||||
tsk_sprintf(&node_root, "/~~/%s", auid);
|
||||
tsk_strcat(&uri, node_root);
|
||||
TSK_FREE(node_root);
|
||||
|
||||
while( (step=va_arg(steps, txc_node_step_t)) != 0xFF)
|
||||
{
|
||||
|
@ -211,8 +208,9 @@ static char* __internal_txc_node_get_cust_sel(const char* doc_selector, const ch
|
|||
case by_name:
|
||||
{ /* qname */
|
||||
const char* qname = va_arg(steps, const char*);
|
||||
tsk_sprintf(&heap, &step_str, "/%s", qname);
|
||||
tsk_strcat2(&uri, (const char*)step_str);
|
||||
tsk_sprintf(&step_str, "/%s", qname);
|
||||
tsk_strcat(&uri, (const char*)step_str);
|
||||
TSK_FREE(step_str);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -220,18 +218,20 @@ static char* __internal_txc_node_get_cust_sel(const char* doc_selector, const ch
|
|||
{ /* qname, position */
|
||||
const char* qname = va_arg(steps, const char*);
|
||||
int position = va_arg(steps, int);
|
||||
tsk_sprintf(&heap, &step_str, "/%s%%5B%d%%5D", qname, position);
|
||||
tsk_strcat2(&uri, (const char*)step_str);
|
||||
tsk_sprintf(&step_str, "/%s%%5B%d%%5D", qname, position);
|
||||
tsk_strcat(&uri, (const char*)step_str);
|
||||
TSK_FREE(step_str);
|
||||
break;
|
||||
}
|
||||
|
||||
case by_attr:
|
||||
{ /* qname, att_name, att_value */
|
||||
const char* qname = va_arg(steps, const char*);
|
||||
char* att_name = tsk_url_encode(&heap, va_arg(steps, const char*));
|
||||
char* att_value = tsk_url_encode(&heap, va_arg(steps, const char*));
|
||||
tsk_sprintf(&heap, &step_str, "/%s%%5B@%s=%%22%s%%22%%5D", qname, att_name, att_value);
|
||||
tsk_strcat2(&uri, (const char*)step_str);
|
||||
char* att_name = tsk_url_encode(va_arg(steps, const char*));
|
||||
char* att_value = tsk_url_encode(va_arg(steps, const char*));
|
||||
tsk_sprintf(&step_str, "/%s%%5B@%s=%%22%s%%22%%5D", qname, att_name, att_value);
|
||||
tsk_strcat(&uri, (const char*)step_str);
|
||||
TSK_FREE(step_str); TSK_FREE(att_name); TSK_FREE(att_value);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -239,10 +239,11 @@ static char* __internal_txc_node_get_cust_sel(const char* doc_selector, const ch
|
|||
{ /* qname, position, att_name, att_value */
|
||||
const char* qname = va_arg(steps, const char*);
|
||||
int position = va_arg(steps, int);
|
||||
char* att_name = tsk_url_encode(&heap, va_arg(steps, const char*));
|
||||
char* att_value = tsk_url_encode(&heap, va_arg(steps, const char*));
|
||||
tsk_sprintf(&heap, &step_str, "/%s%%5B%d%%5D%%5B@%s=%%22%s%%22%%5D", qname, position, att_name, att_value);
|
||||
tsk_strcat2(&uri, (const char*)step_str);
|
||||
char* att_name = tsk_url_encode(va_arg(steps, const char*));
|
||||
char* att_value = tsk_url_encode(va_arg(steps, const char*));
|
||||
tsk_sprintf(&step_str, "/%s%%5B%d%%5D%%5B@%s=%%22%s%%22%%5D", qname, position, att_name, att_value);
|
||||
tsk_strcat(&uri, (const char*)step_str);
|
||||
TSK_FREE(step_str); TSK_FREE(att_name); TSK_FREE(att_value);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -250,8 +251,9 @@ static char* __internal_txc_node_get_cust_sel(const char* doc_selector, const ch
|
|||
{ /* prefix ns */
|
||||
const char* prefix = va_arg(steps, const char*);
|
||||
const char* ns = va_arg(steps, const char*);
|
||||
tsk_sprintf(&heap, &step_str, "%sxmlns(%s=%%22%s%%22)", _namespace?"":"%3F",prefix, ns);
|
||||
tsk_strcat(&heap, &_namespace, (const char*)step_str);
|
||||
tsk_sprintf(&step_str, "%sxmlns(%s=%%22%s%%22)", _namespace?"":"%3F",prefix, ns);
|
||||
tsk_strcat(&_namespace, (const char*)step_str);
|
||||
TSK_FREE(step_str);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
|
@ -260,10 +262,8 @@ static char* __internal_txc_node_get_cust_sel(const char* doc_selector, const ch
|
|||
}
|
||||
|
||||
/* add namespace and free it*/
|
||||
tsk_strcat2(&uri, (const char*)_namespace);
|
||||
|
||||
/* Free heap */
|
||||
tsk_heap_cleanup(&heap);
|
||||
tsk_strcat(&uri, (const char*)_namespace);
|
||||
TSK_FREE(_namespace);
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
|
|
@ -104,30 +104,30 @@ printf("\n---\nTEST OMA XCAP-DIRECTORY\n---\n");
|
|||
TSK_XML_NODE_SELECT_END())
|
||||
|
||||
|
||||
/**@ingroup txc_oma_directory_group
|
||||
* Internal function to initialize an OMA XCAP directory folder.
|
||||
* You must never call this method. You shall use @ref TXC_OMADIR_FOLDER_CREATE to create a folder.
|
||||
* @param folder The folder to initialize
|
||||
*/
|
||||
void txc_omadir_folder_init(txc_omadir_folder_t *folder)
|
||||
{
|
||||
}
|
||||
///**@ingroup txc_oma_directory_group
|
||||
//* Internal function to initialize an OMA XCAP directory folder.
|
||||
//* You must never call this method. You shall use @ref TXC_OMADIR_FOLDER_CREATE to create a folder.
|
||||
//* @param folder The folder to initialize
|
||||
//*/
|
||||
//void txc_omadir_folder_init(txc_omadir_folder_t *folder)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**@ingroup txc_oma_directory_group
|
||||
* Internal function to free an OMA XCAP directory folder.
|
||||
* You must never call this method. You shall use @ref TXC_OMADIR_FOLDER_SAFE_FREE to safely free a folder.
|
||||
* @param _folder The folder to free
|
||||
* @sa @ref TXC_OMADIR_FOLDER_SAFE_FREE
|
||||
*/
|
||||
void txc_omadir_folder_free(void **_folder)
|
||||
{
|
||||
txc_omadir_folder_t **folder = ((txc_omadir_folder_t**)_folder);
|
||||
|
||||
TSK_FREE((*folder)->auid);
|
||||
|
||||
free(*_folder);
|
||||
(*_folder) = 0;
|
||||
}
|
||||
///**@ingroup txc_oma_directory_group
|
||||
//* Internal function to free an OMA XCAP directory folder.
|
||||
//* You must never call this method. You shall use @ref TXC_OMADIR_FOLDER_SAFE_FREE to safely free a folder.
|
||||
//* @param _folder The folder to free
|
||||
//* @sa @ref TXC_OMADIR_FOLDER_SAFE_FREE
|
||||
//*/
|
||||
//void txc_omadir_folder_free(void **_folder)
|
||||
//{
|
||||
// txc_omadir_folder_t **folder = ((txc_omadir_folder_t**)_folder);
|
||||
//
|
||||
// TSK_FREE((*folder)->auid);
|
||||
//
|
||||
// free(*_folder);
|
||||
// (*_folder) = 0;
|
||||
//}
|
||||
|
||||
/**@ingroup txc_oma_directory_group
|
||||
* Deserialize an OMA XCAP folder directory from an XML node pointer.
|
||||
|
@ -141,37 +141,37 @@ txc_omadir_folder_t* txc_omadir_folder_from_xml(xmlNodePtr node)
|
|||
|
||||
if(node = tsk_xml_find_node(node, "folder", nft_none))
|
||||
{
|
||||
TXC_OMADIR_FOLDER_CREATE(folder);
|
||||
folder = TXC_OMADIR_FOLDER_CREATE();
|
||||
|
||||
/* auid */
|
||||
node2 = tsk_xml_select_node(node,
|
||||
TSK_XML_NODE_SELECT_ATT_VALUE("folder", "auid"), TSK_XML_NODE_SELECT_END());
|
||||
folder->auid = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
folder->auid = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
}
|
||||
else return 0;
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
/**@ingroup txc_oma_directory_group
|
||||
* Used to create an OMA XCAP directory context
|
||||
* @param buffer The XML buffer from which to create the context
|
||||
* @param size The size of the XML buffer
|
||||
* @retval An OMA XCAP directory context. You MUST use @ref txc_omadir_free to free the returned object.
|
||||
* @sa @ref txc_omadir_free
|
||||
*/
|
||||
txc_omadir_t* txc_omadir_create(const char* buffer, size_t size)
|
||||
{
|
||||
if(buffer && size)
|
||||
{
|
||||
txc_omadir_t* omadir = (txc_omadir_t*)tsk_calloc2(1, sizeof(txc_omadir_t));
|
||||
omadir->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
|
||||
return omadir;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
///**@ingroup txc_oma_directory_group
|
||||
//* Used to create an OMA XCAP directory context
|
||||
//* @param buffer The XML buffer from which to create the context
|
||||
//* @param size The size of the XML buffer
|
||||
//* @retval An OMA XCAP directory context. You MUST use @ref txc_omadir_free to free the returned object.
|
||||
//* @sa @ref txc_omadir_free
|
||||
//*/
|
||||
//txc_omadir_t* txc_omadir_create(const char* buffer, size_t size)
|
||||
//{
|
||||
// if(buffer && size)
|
||||
// {
|
||||
// txc_omadir_t* omadir = (txc_omadir_t*)tsk_calloc2(1, sizeof(txc_omadir_t));
|
||||
// omadir->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
//
|
||||
// return omadir;
|
||||
// }
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
/**@ingroup txc_oma_directory_group
|
||||
* Returns all folders from an OMA XCAP directory context.
|
||||
|
@ -196,11 +196,11 @@ txc_omadir_folder_L_t* txc_omadir_get_all_folders(const txc_omadir_t* omadir)
|
|||
if(!tsk_xml_find_node(node, "folder", nft_none)) node = tsk_xml_find_node(node, "folder", nft_next);
|
||||
if(node)
|
||||
{
|
||||
TSK_LIST_CREATE(list);
|
||||
list = TSK_LIST_CREATE();
|
||||
do
|
||||
{
|
||||
folder = txc_omadir_folder_from_xml(node);
|
||||
tsk_list_add_data(list, ((void**) &folder), txc_omadir_folder_free);
|
||||
tsk_list_add_data(list, ((void**) &folder));
|
||||
}
|
||||
while(node = tsk_xml_find_node(node, "folder", nft_next));
|
||||
}
|
||||
|
@ -229,11 +229,11 @@ txc_rlist_entry_L_t* txc_omadir_get_entries_by_folder(const txc_omadir_t* omadir
|
|||
if(!tsk_xml_find_node(node, "entry", nft_none)) node = tsk_xml_find_node(node, "entry", nft_next);
|
||||
if(node)
|
||||
{
|
||||
TSK_LIST_CREATE(list);
|
||||
list = TSK_LIST_CREATE();
|
||||
do
|
||||
{
|
||||
rlist_entry = txc_rlist_entry_from_xml(node, fo_auid);
|
||||
tsk_list_add_data(list, ((void**) &rlist_entry), txc_rlist_entry_free);
|
||||
tsk_list_add_data(list, ((void**) &rlist_entry));
|
||||
}
|
||||
while(node = tsk_xml_find_node(node, "entry", nft_next));
|
||||
}
|
||||
|
@ -241,20 +241,144 @@ txc_rlist_entry_L_t* txc_omadir_get_entries_by_folder(const txc_omadir_t* omadir
|
|||
return list;
|
||||
}
|
||||
|
||||
/**@ingroup txc_oma_directory_group
|
||||
* Free an OMA XCAP directory context previously created using @ref txc_omadir_create.
|
||||
* @param omadir The context to free.
|
||||
* @sa @ref txc_omadir_create
|
||||
///**@ingroup txc_oma_directory_group
|
||||
//* Free an OMA XCAP directory context previously created using @ref txc_omadir_create.
|
||||
//* @param omadir The context to free.
|
||||
//* @sa @ref txc_omadir_create
|
||||
//*/
|
||||
//void txc_omadir_free(txc_omadir_t **omadir)
|
||||
//{
|
||||
// if(*omadir)
|
||||
// {
|
||||
// xmlFreeDoc((*omadir)->docPtr);
|
||||
//
|
||||
// free(*omadir);
|
||||
// (*omadir)=0;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// OMA directory object definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_omadir_group
|
||||
*/
|
||||
void txc_omadir_free(txc_omadir_t **omadir)
|
||||
static void* txc_omadir_create(void *self, va_list * app)
|
||||
{
|
||||
if(*omadir)
|
||||
{
|
||||
xmlFreeDoc((*omadir)->docPtr);
|
||||
|
||||
free(*omadir);
|
||||
(*omadir)=0;
|
||||
txc_omadir_t *omadir = self;
|
||||
if(omadir)
|
||||
{
|
||||
const char* buffer = va_arg(*app, const char*);
|
||||
size_t size = va_arg(*app, size_t);
|
||||
if(buffer && size)
|
||||
{
|
||||
omadir->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new omadir object.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_omadir_group
|
||||
*/
|
||||
static void* txc_omadir_destroy(void * self)
|
||||
{
|
||||
txc_omadir_t *omadir = self;
|
||||
if(omadir)
|
||||
{
|
||||
xmlFreeDoc(omadir->docPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL omadir object.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_omadir_def_s =
|
||||
{
|
||||
sizeof(txc_omadir_t),
|
||||
txc_omadir_create,
|
||||
txc_omadir_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_omadir_def_t = &txc_omadir_def_s;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// OMA directory folder object definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_omadir_group
|
||||
*/
|
||||
static void* txc_omadir_folder_create(void *self, va_list * app)
|
||||
{
|
||||
txc_omadir_folder_t *folder = self;
|
||||
if(folder)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new omadir folder object.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_omadir_group
|
||||
*/
|
||||
static void* txc_omadir_folder_destroy(void * self)
|
||||
{
|
||||
txc_omadir_folder_t *folder = self;
|
||||
if(folder)
|
||||
{
|
||||
TSK_FREE(folder->auid);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL omadir folderobject.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_omadir_folder_def_s =
|
||||
{
|
||||
sizeof(txc_omadir_folder_t),
|
||||
txc_omadir_folder_create,
|
||||
txc_omadir_folder_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_omadir_folder_def_t = &txc_omadir_folder_def_s;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#undef OMADIR_RETURN_IF_INVALID
|
|
@ -35,6 +35,9 @@
|
|||
#include "txc.h"
|
||||
#include "txc_rlist.h"
|
||||
|
||||
#define TXC_OMADIR_CREATE(buffer, size) tsk_object_new(txc_omadir_def_t, (const char*)buffer, (size_t)size)
|
||||
#define TXC_OMADIR_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@def TXC_OMADIR_FOLDER_CREATE
|
||||
* Create an OMA XCAP directory folder
|
||||
* You MUST @ref TXC_OMADIR_FOLDER_SAFE_FREE to free the objet.
|
||||
|
@ -44,13 +47,15 @@
|
|||
* Safely free an OMA XCAP directory previously created using @ref TXC_OMADIR_FOLDER_CREATE.
|
||||
* @sa @ref TXC_OMADIR_FOLDER_CREATE
|
||||
*/
|
||||
#define TXC_OMADIR_FOLDER_CREATE(this) TXC_XXX_CREATE2(this, omadir_folder)
|
||||
#define TXC_OMADIR_FOLDER_SAFE_FREE(this) TXC_XXX_SAFE_FREE2(this, omadir_folder)
|
||||
#define TXC_OMADIR_FOLDER_CREATE() tsk_object_new(txc_omadir_folder_def_t)
|
||||
#define TXC_OMADIR_FOLDER_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/** OMA XCAP directory folder .
|
||||
*/
|
||||
typedef struct txc_omadir_folder_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
char* auid; /**< The auid of the folder */
|
||||
}
|
||||
txc_omadir_folder_t;
|
||||
|
@ -59,18 +64,25 @@ typedef tsk_list_t txc_omadir_folder_L_t; /* List of @ref txc_omadir_folder_t el
|
|||
/**OMA XCAP directory context. */
|
||||
typedef struct txc_omadir_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
xmlDocPtr docPtr; /**< Pointer to the XML document*/
|
||||
}
|
||||
txc_omadir_t;
|
||||
|
||||
void txc_omadir_folder_init(txc_omadir_folder_t *folder);
|
||||
void txc_omadir_folder_free(void **folder);
|
||||
//void txc_omadir_folder_init(txc_omadir_folder_t *folder);
|
||||
//void txc_omadir_folder_free(void **folder);
|
||||
|
||||
txc_omadir_folder_t* txc_omadir_folder_from_xml(xmlNodePtr node);
|
||||
|
||||
TINYXCAP_API txc_omadir_t* txc_omadir_create(const char* buffer, size_t size);
|
||||
//TINYXCAP_API txc_omadir_t* txc_omadir_create(const char* buffer, size_t size);
|
||||
TINYXCAP_API txc_omadir_folder_L_t* txc_omadir_get_all_folders(const txc_omadir_t* omadir);
|
||||
TINYXCAP_API txc_rlist_entry_L_t* txc_omadir_get_entries_by_folder(const txc_omadir_t* omadir, const char* fo_auid);
|
||||
TINYXCAP_API void txc_omadir_free(txc_omadir_t **omadir);
|
||||
//TINYXCAP_API void txc_omadir_free(txc_omadir_t **omadir);
|
||||
|
||||
|
||||
TINYXCAP_API const void *txc_omadir_def_t;
|
||||
TINYXCAP_API const void *txc_omadir_folder_def_t;
|
||||
|
||||
|
||||
#endif /* _TINYXCAP_TXC_OMA_DIRECTORY_H_ */
|
|
@ -94,24 +94,24 @@ txc_oma_prescont_t* txc_oma_prescont_create(const char* buffer, size_t size)
|
|||
if(node)
|
||||
{
|
||||
/* init pres-cont object */
|
||||
pres_cont = (txc_oma_prescont_t*)tsk_calloc2(1, sizeof(txc_oma_prescont_t));
|
||||
pres_cont = (txc_oma_prescont_t*)tsk_calloc(1, sizeof(txc_oma_prescont_t));
|
||||
do
|
||||
{
|
||||
if( tsk_equals(node->name, "mime-Type") )
|
||||
if( tsk_strequals(node->name, "mime-Type") )
|
||||
{
|
||||
pres_cont->mime_type = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node->children));
|
||||
pres_cont->mime_type = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node->children));
|
||||
}
|
||||
else if( tsk_equals(node->name, "encoding") )
|
||||
else if( tsk_strequals(node->name, "encoding") )
|
||||
{
|
||||
pres_cont->encoding = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node->children));
|
||||
pres_cont->encoding = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node->children));
|
||||
}
|
||||
else if( tsk_equals(node->name, "description") )
|
||||
else if( tsk_strequals(node->name, "description") )
|
||||
{
|
||||
pres_cont->description = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node->children));
|
||||
pres_cont->description = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node->children));
|
||||
}
|
||||
else if( tsk_equals(node->name, "data") )
|
||||
else if( tsk_strequals(node->name, "data") )
|
||||
{
|
||||
pres_cont->data = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node->children));
|
||||
pres_cont->data = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node->children));
|
||||
}
|
||||
}
|
||||
while(node = tsk_xml_find_node(node, 0, nft_next));
|
||||
|
|
|
@ -157,17 +157,17 @@ char* txc_oma_presrules_serialize(const txc_context_t *context)
|
|||
}
|
||||
|
||||
/* oma granted contacts */
|
||||
tsk_sprintf(0, &oma_grantedcontacts,
|
||||
tsk_sprintf(&oma_grantedcontacts,
|
||||
"%s/~~/resource-lists/list%%5B@name=%%22%s%%22%%5D",
|
||||
doc_sel, TXC_RNAME_OMA_GRANTEDCONTACTS);
|
||||
|
||||
/* oma blocked contacts */
|
||||
tsk_sprintf(0, &oma_blockedcontacts,
|
||||
tsk_sprintf(&oma_blockedcontacts,
|
||||
"%s/~~/resource-lists/list%%5B@name=%%22%s%%22%%5D",
|
||||
doc_sel, TXC_RNAME_OMA_BLOCKEDCONTACTS);
|
||||
|
||||
/* append all */
|
||||
tsk_sprintf(0, &oma_presrules_str, TXC_OMA_PRESRULES_TEMPLATE,
|
||||
tsk_sprintf(&oma_presrules_str, TXC_OMA_PRESRULES_TEMPLATE,
|
||||
context->xui, oma_grantedcontacts, oma_blockedcontacts);
|
||||
|
||||
bail:
|
||||
|
|
|
@ -149,14 +149,14 @@ printf("\nget all entries in the list named 'rcs_revokedcontacts'\n");
|
|||
|
||||
#define RLIST_RETURN_IF_INVALID(rlist) if(!rlist || !(rlist->docPtr)) return 0;
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to initialize a previously created entry
|
||||
* @param entry The entry to initilialize
|
||||
* @sa TXC_RLIST_ENTRY_CREATE
|
||||
*/
|
||||
void txc_rlist_entry_init(txc_rlist_entry_t *entry)
|
||||
{
|
||||
}
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Internal function to initialize a previously created entry
|
||||
//* @param entry The entry to initilialize
|
||||
//* @sa TXC_RLIST_ENTRY_CREATE
|
||||
//*/
|
||||
//void txc_rlist_entry_init(txc_rlist_entry_t *entry)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Set the entry's uri and display-name
|
||||
|
@ -168,38 +168,38 @@ void txc_rlist_entry_set(txc_rlist_entry_t *entry, const char* uri, const char*
|
|||
{
|
||||
if(entry)
|
||||
{
|
||||
tsk_strupdate2(&(entry->uri), uri);
|
||||
tsk_strupdate2(&(entry->display_name), display_name);
|
||||
tsk_strupdate(&(entry->uri), uri);
|
||||
tsk_strupdate(&(entry->display_name), display_name);
|
||||
}
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to free an entry previously created using @ref TXC_RLIST_ENTRY_SAFE_FREE.
|
||||
* You MUST call @ref TXC_RLIST_ENTRY_SAFE_FREE to safely free your entry.
|
||||
* @sa @ref TXC_RLIST_ENTRY_SAFE_FREE
|
||||
*/
|
||||
void txc_rlist_entry_free(void **_entry)
|
||||
{
|
||||
txc_rlist_entry_t **entry = ((txc_rlist_entry_t**)_entry);
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Internal function to free an entry previously created using @ref TXC_RLIST_ENTRY_SAFE_FREE.
|
||||
//* You MUST call @ref TXC_RLIST_ENTRY_SAFE_FREE to safely free your entry.
|
||||
//* @sa @ref TXC_RLIST_ENTRY_SAFE_FREE
|
||||
//*/
|
||||
//void txc_rlist_entry_free(void **_entry)
|
||||
//{
|
||||
// txc_rlist_entry_t **entry = ((txc_rlist_entry_t**)_entry);
|
||||
//
|
||||
// TSK_FREE((*entry)->uri);
|
||||
// TSK_FREE((*entry)->display_name);
|
||||
// TSK_FREE((*entry)->list);
|
||||
// TSK_FREE((*entry)->last_modified);
|
||||
// TSK_FREE((*entry)->etag);
|
||||
//
|
||||
// tsk_free2(_entry);
|
||||
//}
|
||||
|
||||
TSK_FREE((*entry)->uri);
|
||||
TSK_FREE((*entry)->display_name);
|
||||
TSK_FREE((*entry)->list);
|
||||
TSK_FREE((*entry)->last_modified);
|
||||
TSK_FREE((*entry)->etag);
|
||||
|
||||
tsk_free2(_entry);
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to initialize a previously created @ref txc_rlist_list_t object.
|
||||
* You MUST use @ref TXC_RLIST_LIST_CREATE to create and intialize your simple list.
|
||||
* @param list The list to initialize
|
||||
* @sa @ref TXC_RLIST_LIST_CREATE
|
||||
*/
|
||||
void txc_rlist_list_init(txc_rlist_list_t *list)
|
||||
{
|
||||
}
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Internal function to initialize a previously created @ref txc_rlist_list_t object.
|
||||
//* You MUST use @ref TXC_RLIST_LIST_CREATE to create and intialize your simple list.
|
||||
//* @param list The list to initialize
|
||||
//* @sa @ref TXC_RLIST_LIST_CREATE
|
||||
//*/
|
||||
//void txc_rlist_list_init(txc_rlist_list_t *list)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Update the list's name and display-name
|
||||
|
@ -211,36 +211,36 @@ void txc_rlist_list_set(txc_rlist_list_t *list, const char* name, const char* di
|
|||
{
|
||||
if(list)
|
||||
{
|
||||
tsk_strupdate2(&(list->name), name);
|
||||
tsk_strupdate2(&(list->display_name), display_name);
|
||||
tsk_strupdate(&(list->name), name);
|
||||
tsk_strupdate(&(list->display_name), display_name);
|
||||
}
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to free a previously created @ref txc_rlist_list_t object.
|
||||
* You MUST use @ref TXC_RLIST_LIST_SAFE_FREE to free your simple list.
|
||||
* @param _list The simple list to free
|
||||
* @sa @ref TXC_RLIST_LIST_SAFE_FREE
|
||||
*/
|
||||
void txc_rlist_list_free(void **_list)
|
||||
{
|
||||
txc_rlist_list_t **list = ((txc_rlist_list_t**)_list);
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Internal function to free a previously created @ref txc_rlist_list_t object.
|
||||
//* You MUST use @ref TXC_RLIST_LIST_SAFE_FREE to free your simple list.
|
||||
//* @param _list The simple list to free
|
||||
//* @sa @ref TXC_RLIST_LIST_SAFE_FREE
|
||||
//*/
|
||||
//void txc_rlist_list_free(void **_list)
|
||||
//{
|
||||
// txc_rlist_list_t **list = ((txc_rlist_list_t**)_list);
|
||||
//
|
||||
// TSK_FREE((*list)->display_name);
|
||||
// TSK_FREE((*list)->name);
|
||||
//
|
||||
// tsk_free2(_list);
|
||||
//}
|
||||
|
||||
TSK_FREE((*list)->display_name);
|
||||
TSK_FREE((*list)->name);
|
||||
|
||||
tsk_free2(_list);
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to initialize a newly created @ref txc_rlist_list2_t object.
|
||||
* You MUST use @ref TXC_RLIST_LIST2_CREATE to create and initialize your complex list.
|
||||
* @param list2 The complex list to initialize
|
||||
* @sa @ref TXC_RLIST_LIST2_CREATE
|
||||
*/
|
||||
void txc_rlist_list2_init(txc_rlist_list2_t *list2)
|
||||
{
|
||||
}
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Internal function to initialize a newly created @ref txc_rlist_list2_t object.
|
||||
//* You MUST use @ref TXC_RLIST_LIST2_CREATE to create and initialize your complex list.
|
||||
//* @param list2 The complex list to initialize
|
||||
//* @sa @ref TXC_RLIST_LIST2_CREATE
|
||||
//*/
|
||||
//void txc_rlist_list2_init(txc_rlist_list2_t *list2)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Set list2's name and display-name
|
||||
|
@ -252,8 +252,8 @@ void txc_rlist_list2_set(txc_rlist_list2_t *list2, const char* name, const char*
|
|||
{
|
||||
if(list2)
|
||||
{
|
||||
tsk_strupdate2(&(list2->name), name);
|
||||
tsk_strupdate2(&(list2->display_name),display_name);
|
||||
tsk_strupdate(&(list2->name), name);
|
||||
tsk_strupdate(&(list2->display_name),display_name);
|
||||
}
|
||||
}
|
||||
/**@ingroup txc_rlist_group
|
||||
|
@ -268,12 +268,12 @@ void txc_rlist_list2_add_external(txc_rlist_list2_t *list2, const char* anchor)
|
|||
txc_rlist_external_t *external = 0;
|
||||
if(!(list2->externals))
|
||||
{
|
||||
TSK_LIST_CREATE(list2->externals);
|
||||
list2->externals = TSK_LIST_CREATE();
|
||||
}
|
||||
|
||||
TXC_RLIST_EXTERNAL_CREATE(external);
|
||||
external = TXC_RLIST_EXTERNAL_CREATE();
|
||||
txc_rlist_external_set(external, anchor);
|
||||
tsk_list_add_data(list2->externals, ((void**)&external), txc_rlist_external_free);
|
||||
tsk_list_add_data(list2->externals, ((void**)&external));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,44 +288,44 @@ void txc_rlist_list2_add_entry(txc_rlist_list2_t *list2, const char* uri, const
|
|||
if(list2)
|
||||
{
|
||||
txc_rlist_entry_t *entry = 0;
|
||||
TXC_RLIST_ENTRY_CREATE(entry);
|
||||
entry = TXC_RLIST_ENTRY_CREATE();
|
||||
txc_rlist_entry_set(entry, uri, display_name);
|
||||
|
||||
if(!(list2->entries))
|
||||
{
|
||||
TSK_LIST_CREATE(list2->entries);
|
||||
list2->entries = TSK_LIST_CREATE();
|
||||
}
|
||||
tsk_list_add_data(list2->entries, ((void**)&entry), txc_rlist_entry_free);
|
||||
tsk_list_add_data(list2->entries, ((void**)&entry));
|
||||
}
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to free a previously created @ref txc_rlist_list2_t object using @ref TXC_RLIST_LIST2_CREATE.
|
||||
* You MUST use @ref TXC_RLIST_LIST2_SAFE_FREE to safely free your complex list.
|
||||
* @param _list2 The complex list to free
|
||||
* @sa @ref TXC_RLIST_LIST2_SAFE_FREE
|
||||
*/
|
||||
void txc_rlist_list2_free(void **_list2)
|
||||
{
|
||||
txc_rlist_list2_t **list2 = ((txc_rlist_list2_t**)_list2);
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Internal function to free a previously created @ref txc_rlist_list2_t object using @ref TXC_RLIST_LIST2_CREATE.
|
||||
//* You MUST use @ref TXC_RLIST_LIST2_SAFE_FREE to safely free your complex list.
|
||||
//* @param _list2 The complex list to free
|
||||
//* @sa @ref TXC_RLIST_LIST2_SAFE_FREE
|
||||
//*/
|
||||
//void txc_rlist_list2_free(void **_list2)
|
||||
//{
|
||||
// txc_rlist_list2_t **list2 = ((txc_rlist_list2_t**)_list2);
|
||||
//
|
||||
// TSK_FREE((*list2)->display_name);
|
||||
// TSK_FREE((*list2)->name);
|
||||
// TSK_LIST_SAFE_FREE((*list2)->externals);
|
||||
// TSK_LIST_SAFE_FREE((*list2)->entries);
|
||||
//
|
||||
// tsk_free2(_list2);
|
||||
//}
|
||||
|
||||
TSK_FREE((*list2)->display_name);
|
||||
TSK_FREE((*list2)->name);
|
||||
TSK_LIST_SAFE_FREE((*list2)->externals);
|
||||
TSK_LIST_SAFE_FREE((*list2)->entries);
|
||||
|
||||
tsk_free2(_list2);
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to initialize an external element.
|
||||
* You MUST call @ref TXC_RLIST_EXTERNAL_CREATE to create and initialize your element.
|
||||
* @param external The external element to initialize.
|
||||
* @sa @ref TXC_RLIST_EXTERNAL_CREATE.
|
||||
*/
|
||||
void txc_rlist_external_init(txc_rlist_external_t *external)
|
||||
{
|
||||
}
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Internal function to initialize an external element.
|
||||
//* You MUST call @ref TXC_RLIST_EXTERNAL_CREATE to create and initialize your element.
|
||||
//* @param external The external element to initialize.
|
||||
//* @sa @ref TXC_RLIST_EXTERNAL_CREATE.
|
||||
//*/
|
||||
//void txc_rlist_external_init(txc_rlist_external_t *external)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Sets the external's anchor value
|
||||
|
@ -336,25 +336,25 @@ void txc_rlist_external_set(txc_rlist_external_t *external, const char* anchor)
|
|||
{
|
||||
if(external)
|
||||
{
|
||||
tsk_strupdate2(&(external->anchor), anchor);
|
||||
tsk_strupdate(&(external->anchor), anchor);
|
||||
}
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to free a previously created @ref txc_rlist_external_t object.
|
||||
* You must call @ref TXC_RLIST_EXTERNAL_SAFE_FREE to free your object.
|
||||
* @param _external The external element to free
|
||||
* @sa @ref TXC_RLIST_EXTERNAL_SAFE_FREE
|
||||
*/
|
||||
void txc_rlist_external_free(void **_external)
|
||||
{
|
||||
txc_rlist_external_t **external = ((txc_rlist_external_t**)_external);
|
||||
|
||||
TSK_FREE((*external)->anchor);
|
||||
TSK_FREE((*external)->list);
|
||||
|
||||
tsk_free2(_external);
|
||||
}
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Internal function to free a previously created @ref txc_rlist_external_t object.
|
||||
//* You must call @ref TXC_RLIST_EXTERNAL_SAFE_FREE to free your object.
|
||||
//* @param _external The external element to free
|
||||
//* @sa @ref TXC_RLIST_EXTERNAL_SAFE_FREE
|
||||
//*/
|
||||
//void txc_rlist_external_free(void **_external)
|
||||
//{
|
||||
// txc_rlist_external_t **external = ((txc_rlist_external_t**)_external);
|
||||
//
|
||||
// TSK_FREE((*external)->anchor);
|
||||
// TSK_FREE((*external)->list);
|
||||
//
|
||||
// tsk_free2(_external);
|
||||
//}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Internal function to deserialize an entry element from an XML node pointer.
|
||||
|
@ -370,28 +370,28 @@ txc_rlist_entry_t* txc_rlist_entry_from_xml(const xmlNodePtr node, const char* l
|
|||
|
||||
if(tsk_xml_find_node(node, "entry", nft_none))
|
||||
{
|
||||
TXC_RLIST_ENTRY_CREATE(rlist_entry);
|
||||
rlist_entry->list = tsk_strdup2(lname);
|
||||
rlist_entry = TXC_RLIST_ENTRY_CREATE();
|
||||
rlist_entry->list = tsk_strdup(lname);
|
||||
|
||||
/* display-name */
|
||||
node2 = tsk_xml_select_node(node, TSK_XML_NODE_SELECT_BY_NAME("entry"),
|
||||
TSK_XML_NODE_SELECT_BY_NAME("display-name"), TSK_XML_NODE_SELECT_END());
|
||||
rlist_entry->display_name = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_entry->display_name = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
/* uri */
|
||||
node2 = tsk_xml_select_node(node,
|
||||
TSK_XML_NODE_SELECT_ATT_VALUE("entry", "uri"), TSK_XML_NODE_SELECT_END());
|
||||
rlist_entry->uri = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_entry->uri = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
/* last-modified */
|
||||
node2 = tsk_xml_select_node(node,
|
||||
TSK_XML_NODE_SELECT_ATT_VALUE("entry", "last-modified"), TSK_XML_NODE_SELECT_END());
|
||||
rlist_entry->last_modified = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_entry->last_modified = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
/* etag */
|
||||
node2 = tsk_xml_select_node(node,
|
||||
TSK_XML_NODE_SELECT_ATT_VALUE("entry", "etag"), TSK_XML_NODE_SELECT_END());
|
||||
rlist_entry->etag = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_entry->etag = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
}
|
||||
else return 0;
|
||||
|
@ -413,14 +413,14 @@ txc_rlist_external_t* txc_rlist_external_from_xml(const xmlNodePtr node, const c
|
|||
|
||||
if(tsk_xml_find_node(node, "external", nft_none))
|
||||
{
|
||||
TXC_RLIST_EXTERNAL_CREATE(rlist_external);
|
||||
rlist_external->list = tsk_strdup2(lname);
|
||||
rlist_external = TXC_RLIST_EXTERNAL_CREATE();
|
||||
rlist_external->list = tsk_strdup(lname);
|
||||
|
||||
/* anchor */
|
||||
node2 = tsk_xml_select_node(node,
|
||||
TSK_XML_NODE_SELECT_ATT_VALUE("external", "anchor"),
|
||||
TSK_XML_NODE_SELECT_END());
|
||||
rlist_external->anchor = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_external->anchor = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
}else return 0;
|
||||
|
||||
|
@ -440,19 +440,19 @@ txc_rlist_list_t* txc_rlist_list_from_xml(const xmlNodePtr node)
|
|||
|
||||
if(tsk_xml_find_node(node, "list", nft_none))
|
||||
{
|
||||
TXC_RLIST_LIST_CREATE(rlist_list);
|
||||
rlist_list = TXC_RLIST_LIST_CREATE();
|
||||
|
||||
/* name */
|
||||
node2 = tsk_xml_select_node(node,
|
||||
TSK_XML_NODE_SELECT_ATT_VALUE("list", "name"),
|
||||
TSK_XML_NODE_SELECT_END());
|
||||
rlist_list->name = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_list->name = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
/* display-name */
|
||||
node2 = tsk_xml_select_node(node, TSK_XML_NODE_SELECT_BY_NAME("list"),
|
||||
TSK_XML_NODE_SELECT_BY_NAME("display-name"),
|
||||
TSK_XML_NODE_SELECT_END());
|
||||
rlist_list->display_name = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_list->display_name = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
}else return 0;
|
||||
|
||||
|
@ -472,19 +472,19 @@ txc_rlist_list2_t* txc_rlist_list2_from_xml(const xmlNodePtr node)
|
|||
|
||||
if(tsk_xml_find_node(node, "list", nft_none))
|
||||
{
|
||||
TXC_RLIST_LIST2_CREATE(rlist_list2);
|
||||
rlist_list2 = TXC_RLIST_LIST2_CREATE();
|
||||
|
||||
/** name **/
|
||||
node2 = tsk_xml_select_node(node,
|
||||
TSK_XML_NODE_SELECT_ATT_VALUE("list", "name"),
|
||||
TSK_XML_NODE_SELECT_END());
|
||||
rlist_list2->name = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_list2->name = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
/** display-name **/
|
||||
node2 = tsk_xml_select_node(node, TSK_XML_NODE_SELECT_BY_NAME("list"),
|
||||
TSK_XML_NODE_SELECT_BY_NAME("display-name"),
|
||||
TSK_XML_NODE_SELECT_END());
|
||||
rlist_list2->display_name = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rlist_list2->display_name = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
/*== externals ==*/
|
||||
/* select first external */
|
||||
|
@ -492,11 +492,11 @@ txc_rlist_list2_t* txc_rlist_list2_from_xml(const xmlNodePtr node)
|
|||
if(node2)
|
||||
{
|
||||
txc_rlist_external_t *rlist_external = 0;
|
||||
TSK_LIST_CREATE(rlist_list2->externals);
|
||||
rlist_list2->externals = TSK_LIST_CREATE();
|
||||
do
|
||||
{
|
||||
rlist_external = txc_rlist_external_from_xml(node2, rlist_list2->name);
|
||||
tsk_list_add_data(rlist_list2->externals, ((void**) &rlist_external), txc_rlist_external_free);
|
||||
tsk_list_add_data(rlist_list2->externals, ((void**) &rlist_external));
|
||||
}
|
||||
while(node2 = tsk_xml_find_node(node2, "external", nft_next));
|
||||
}
|
||||
|
@ -507,11 +507,11 @@ txc_rlist_list2_t* txc_rlist_list2_from_xml(const xmlNodePtr node)
|
|||
if(node2)
|
||||
{
|
||||
txc_rlist_entry_t *rlist_entry = 0;
|
||||
TSK_LIST_CREATE(rlist_list2->entries);
|
||||
rlist_list2->entries = TSK_LIST_CREATE();
|
||||
do
|
||||
{
|
||||
rlist_entry = txc_rlist_entry_from_xml(node2, rlist_list2->name);
|
||||
tsk_list_add_data(rlist_list2->entries, ((void**) &rlist_entry), txc_rlist_entry_free);
|
||||
tsk_list_add_data(rlist_list2->entries, ((void**) &rlist_entry));
|
||||
}
|
||||
while(node2 = tsk_xml_find_node(node2, "entry", nft_next));
|
||||
}
|
||||
|
@ -520,26 +520,26 @@ txc_rlist_list2_t* txc_rlist_list2_from_xml(const xmlNodePtr node)
|
|||
return rlist_list2;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Create a resource-lists context.
|
||||
* @param buffer The XML buffer from wich to create the context
|
||||
* @param size The size of the XML buffer
|
||||
* @retval @ref txc_rlist_t object holding a pointer to the XML buffer.
|
||||
* You must call @ref txc_rlist_free to free the returned object.
|
||||
* @sa @ref txc_rlist_free
|
||||
*/
|
||||
txc_rlist_t* txc_rlist_create(const char* buffer, size_t size)
|
||||
{
|
||||
if(buffer && size)
|
||||
{
|
||||
txc_rlist_t* rlist = (txc_rlist_t*)tsk_calloc2(1, sizeof(txc_rlist_t));
|
||||
rlist->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
|
||||
return rlist;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Create a resource-lists context.
|
||||
//* @param buffer The XML buffer from wich to create the context
|
||||
//* @param size The size of the XML buffer
|
||||
//* @retval @ref txc_rlist_t object holding a pointer to the XML buffer.
|
||||
//* You must call @ref txc_rlist_free to free the returned object.
|
||||
//* @sa @ref txc_rlist_free
|
||||
//*/
|
||||
//txc_rlist_t* txc_rlist_create(const char* buffer, size_t size)
|
||||
//{
|
||||
// if(buffer && size)
|
||||
// {
|
||||
// txc_rlist_t* rlist = (txc_rlist_t*)tsk_calloc(1, sizeof(txc_rlist_t));
|
||||
// rlist->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
//
|
||||
// return rlist;
|
||||
// }
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Returns all lists holded by this context
|
||||
|
@ -564,18 +564,18 @@ txc_rlist_listx_L_t* txc_rlist_get_all_lists(const txc_rlist_t* rlist, int type2
|
|||
if(!tsk_xml_find_node(node, "list", nft_none)) node = tsk_xml_find_node(node, "list", nft_next);
|
||||
if(node)
|
||||
{
|
||||
TSK_LIST_CREATE(list);
|
||||
list = TSK_LIST_CREATE();
|
||||
do
|
||||
{
|
||||
if(type2)
|
||||
{
|
||||
txc_rlist_list2_t* rlist_list2 = txc_rlist_list2_from_xml(node);
|
||||
tsk_list_add_data(list, ((void**) &rlist_list2), txc_rlist_list2_free);
|
||||
tsk_list_add_data(list, ((void**) &rlist_list2));
|
||||
}
|
||||
else
|
||||
{
|
||||
txc_rlist_list_t* rlist_list = txc_rlist_list_from_xml(node);
|
||||
tsk_list_add_data(list, ((void**) &rlist_list), txc_rlist_list_free);
|
||||
tsk_list_add_data(list, ((void**) &rlist_list));
|
||||
}
|
||||
}
|
||||
while(node = tsk_xml_find_node(node, "list", nft_next));
|
||||
|
@ -602,7 +602,7 @@ txc_rlist_entry_L_t* txc_rlist_get_entries_by_list(const txc_rlist_t* rlist, con
|
|||
node = RLIST_SELECT_LIST_BY_NAME(lname);
|
||||
if(!node) return 0;
|
||||
|
||||
TSK_LIST_CREATE(list);
|
||||
list = TSK_LIST_CREATE();
|
||||
|
||||
/* select first entry */
|
||||
if(!tsk_xml_find_node(node, "entry", nft_none)) node = tsk_xml_find_node(node, "entry", nft_next);
|
||||
|
@ -611,7 +611,7 @@ txc_rlist_entry_L_t* txc_rlist_get_entries_by_list(const txc_rlist_t* rlist, con
|
|||
do
|
||||
{
|
||||
rlist_entry = txc_rlist_entry_from_xml(node, lname);
|
||||
tsk_list_add_data(list, ((void**) &rlist_entry), txc_rlist_entry_free);
|
||||
tsk_list_add_data(list, ((void**) &rlist_entry));
|
||||
}
|
||||
while(node = tsk_xml_find_node(node, "entry", nft_next));
|
||||
}
|
||||
|
@ -641,11 +641,11 @@ txc_rlist_external_L_t* txc_rlist_get_externals_by_list(const txc_rlist_t* rlist
|
|||
if(!tsk_xml_find_node(node, "external", nft_none)) node = tsk_xml_find_node(node, "external", nft_next);
|
||||
if(node)
|
||||
{
|
||||
TSK_LIST_CREATE(list);
|
||||
list = TSK_LIST_CREATE();
|
||||
do
|
||||
{
|
||||
rlist_external = txc_rlist_external_from_xml(node, lname);
|
||||
tsk_list_add_data(list, ((void**) &rlist_external), txc_rlist_external_free);
|
||||
tsk_list_add_data(list, ((void**) &rlist_external));
|
||||
}
|
||||
while(node = tsk_xml_find_node(node, "external", nft_next));
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ char* txc_rlist_external_serialize(const txc_rlist_external_t *external)
|
|||
char* external_str = 0;
|
||||
if(!external || !external->anchor) return 0;
|
||||
|
||||
tsk_sprintf(0, &external_str, "<external anchor=\"%s\" />", external->anchor);
|
||||
tsk_sprintf(&external_str, "<external anchor=\"%s\" />", external->anchor);
|
||||
return external_str;
|
||||
}
|
||||
|
||||
|
@ -693,7 +693,7 @@ char* txc_rlist_entry_serialize2(const char* uri, const char* displayname)
|
|||
char* entry_str = 0;
|
||||
if(!uri || !displayname) return 0;
|
||||
|
||||
tsk_sprintf(0, &entry_str,
|
||||
tsk_sprintf(&entry_str,
|
||||
"<entry uri=\"%s\" xmlns=\""TXC_NS_RLIST"\">"
|
||||
"<display-name>%s</display-name>"
|
||||
"</entry>",
|
||||
|
@ -730,12 +730,12 @@ char* txc_rlist_list_serialize2(const char* name, const char* displayname, const
|
|||
|
||||
if(!name) return 0;
|
||||
|
||||
if(anchor) tsk_sprintf(0, &anchor_str, "<external anchor=\"%s\"/>", anchor);
|
||||
else anchor_str = tsk_strdup2("");
|
||||
if(anchor) tsk_sprintf(&anchor_str, "<external anchor=\"%s\"/>", anchor);
|
||||
else anchor_str = tsk_strdup("");
|
||||
TSK_XML_SERIALIZE(displayname_str, "display-name", displayname);
|
||||
|
||||
/* serialize */
|
||||
tsk_sprintf(0, &list_str,
|
||||
tsk_sprintf(&list_str,
|
||||
"<list name=\"%s\" xmlns=\""TXC_NS_RLIST"\">"
|
||||
"%s"
|
||||
"%s"
|
||||
|
@ -764,7 +764,7 @@ char* txc_rlist_list2_serialize(const txc_rlist_list2_t *list2)
|
|||
if(!list2) return 0;
|
||||
|
||||
/* name and display-name */
|
||||
tsk_sprintf(0, &list2_str,
|
||||
tsk_sprintf(&list2_str,
|
||||
"<list name=\"%s\" xmlns=\""TXC_NS_RLIST"\">"
|
||||
"<display-name>%s</display-name>",
|
||||
list2->name, list2->display_name);
|
||||
|
@ -774,7 +774,7 @@ char* txc_rlist_list2_serialize(const txc_rlist_list2_t *list2)
|
|||
{
|
||||
txc_rlist_entry_t *entry = ((txc_rlist_entry_t*)item->data);
|
||||
char* entry_str = txc_rlist_entry_serialize(entry);
|
||||
tsk_strcat2(&list2_str, (const char*)entry_str);
|
||||
tsk_strcat(&list2_str, (const char*)entry_str);
|
||||
TSK_FREE(entry_str);
|
||||
}
|
||||
|
||||
|
@ -783,12 +783,12 @@ char* txc_rlist_list2_serialize(const txc_rlist_list2_t *list2)
|
|||
{
|
||||
txc_rlist_external_t *external = ((txc_rlist_external_t*)item->data);
|
||||
char* external_str = txc_rlist_external_serialize(external);
|
||||
tsk_strcat2(&list2_str, (const char*)external_str);
|
||||
tsk_strcat(&list2_str, (const char*)external_str);
|
||||
TSK_FREE(external_str);
|
||||
}
|
||||
|
||||
/* close list */
|
||||
tsk_strcat2(&list2_str, "</list>");
|
||||
tsk_strcat(&list2_str, "</list>");
|
||||
|
||||
return list2_str;
|
||||
}
|
||||
|
@ -808,19 +808,19 @@ char* txc_rlist_list2_L_serialize(const txc_rlist_list2_L_t *list22)
|
|||
if(!list22) return 0;
|
||||
|
||||
/* xml header */
|
||||
tsk_strcat2(&rlist2_str, RLIST_XML_HEADER);
|
||||
tsk_strcat(&rlist2_str, RLIST_XML_HEADER);
|
||||
|
||||
tsk_list_foreach(item, list22)
|
||||
{
|
||||
/* get list2 */
|
||||
txc_rlist_list2_t *list2 = ((txc_rlist_list2_t*)item->data);
|
||||
char* list2_str = txc_rlist_list2_serialize(list2);
|
||||
tsk_strcat2(&rlist2_str, list2_str);
|
||||
tsk_strcat(&rlist2_str, list2_str);
|
||||
TSK_FREE(list2_str);
|
||||
}
|
||||
|
||||
/* xml footer */
|
||||
tsk_strcat2(&rlist2_str, RLIST_XML_FOOTER);
|
||||
tsk_strcat(&rlist2_str, RLIST_XML_FOOTER);
|
||||
|
||||
return rlist2_str;
|
||||
}
|
||||
|
@ -836,28 +836,286 @@ char* txc_rlist_add_xml_header(const char* xml_content)
|
|||
char* xml = 0;
|
||||
|
||||
/* append xml header */
|
||||
tsk_sprintf(0, &xml,
|
||||
tsk_sprintf(&xml,
|
||||
"%s%s%s",
|
||||
RLIST_XML_HEADER, xml_content, RLIST_XML_FOOTER);
|
||||
return xml;
|
||||
}
|
||||
|
||||
///**@ingroup txc_rlist_group
|
||||
//* Function to free a previously created context using @ref txc_rlist_create.
|
||||
//* @param rlist The context the free.
|
||||
//* @sa @ref txc_rlist_create
|
||||
//*/
|
||||
//void txc_rlist_free(txc_rlist_t **rlist )
|
||||
//{
|
||||
// if(*rlist)
|
||||
// {
|
||||
// xmlFreeDoc((*rlist)->docPtr);
|
||||
//
|
||||
// free(*rlist);
|
||||
// (*rlist)=0;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Rlist entry object definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
* Function to free a previously created context using @ref txc_rlist_create.
|
||||
* @param rlist The context the free.
|
||||
* @sa @ref txc_rlist_create
|
||||
*/
|
||||
void txc_rlist_free(txc_rlist_t **rlist )
|
||||
static void* txc_rlist_create(void *self, va_list * app)
|
||||
{
|
||||
if(*rlist)
|
||||
{
|
||||
xmlFreeDoc((*rlist)->docPtr);
|
||||
|
||||
free(*rlist);
|
||||
(*rlist)=0;
|
||||
txc_rlist_t *rlist = self;
|
||||
if(rlist)
|
||||
{
|
||||
const char* buffer = va_arg(*app, const char*);
|
||||
size_t size = va_arg(*app, size_t);
|
||||
if(buffer && size)
|
||||
{
|
||||
rlist->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new rlist.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_destroy(void * self)
|
||||
{
|
||||
txc_rlist_t *rlist= self;
|
||||
if(rlist)
|
||||
{
|
||||
xmlFreeDoc(rlist->docPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL rlist.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_rlist_def_s =
|
||||
{
|
||||
sizeof(txc_rlist_t),
|
||||
txc_rlist_create,
|
||||
txc_rlist_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_rlist_def_t = &txc_rlist_def_s;
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Rlist entry object definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_entry_create(void *self, va_list * app)
|
||||
{
|
||||
txc_rlist_entry_t *rlist_entry = self;
|
||||
if(rlist_entry)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new rlist_entry.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_entry_destroy(void * self)
|
||||
{
|
||||
txc_rlist_entry_t *rlist_entry = self;
|
||||
if(rlist_entry)
|
||||
{
|
||||
TSK_FREE(rlist_entry->uri);
|
||||
TSK_FREE(rlist_entry->display_name);
|
||||
TSK_FREE(rlist_entry->list);
|
||||
TSK_FREE(rlist_entry->last_modified);
|
||||
TSK_FREE(rlist_entry->etag);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL entry.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_rlist_entry_def_s =
|
||||
{
|
||||
sizeof(txc_rlist_entry_t),
|
||||
txc_rlist_entry_create,
|
||||
txc_rlist_entry_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_rlist_entry_def_t = &txc_rlist_entry_def_s;
|
||||
|
||||
|
||||
//========================================================
|
||||
// Rlist list object definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_list_create(void *self, va_list * app)
|
||||
{
|
||||
txc_rlist_list_t *rlist_list = self;
|
||||
if(rlist_list)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new rlist_list.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_list_destroy(void * self)
|
||||
{
|
||||
txc_rlist_list_t *rlist_list = self;
|
||||
if(rlist_list)
|
||||
{
|
||||
TSK_FREE(rlist_list->display_name);
|
||||
TSK_FREE(rlist_list->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL list.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_rlist_list_def_s =
|
||||
{
|
||||
sizeof(txc_rlist_list_t),
|
||||
txc_rlist_list_create,
|
||||
txc_rlist_list_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_rlist_list_def_t = &txc_rlist_list_def_s;
|
||||
|
||||
|
||||
//========================================================
|
||||
// Rlist list2 object definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_list2_create(void *self, va_list * app)
|
||||
{
|
||||
txc_rlist_list2_t *rlist_list2 = self;
|
||||
if(rlist_list2)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new rlist_list2.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_list2_destroy(void * self)
|
||||
{
|
||||
txc_rlist_list2_t *rlist_list2 = self;
|
||||
if(rlist_list2)
|
||||
{
|
||||
TSK_FREE(rlist_list2->display_name);
|
||||
TSK_FREE(rlist_list2->name);
|
||||
TSK_LIST_SAFE_FREE(rlist_list2->externals);
|
||||
TSK_LIST_SAFE_FREE(rlist_list2->entries);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL list2.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_rlist_list2_def_s =
|
||||
{
|
||||
sizeof(txc_rlist_list2_t),
|
||||
txc_rlist_list2_create,
|
||||
txc_rlist_list2_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_rlist_list2_def_t = &txc_rlist_list2_def_s;
|
||||
|
||||
//========================================================
|
||||
// Rlist external object definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_external_create(void *self, va_list * app)
|
||||
{
|
||||
txc_rlist_external_t *rlist_external = self;
|
||||
if(rlist_external)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new rlist_external.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rlist_group
|
||||
*/
|
||||
static void* txc_rlist_external_destroy(void * self)
|
||||
{
|
||||
txc_rlist_external_t *rlist_external = self;
|
||||
if(rlist_external)
|
||||
{
|
||||
TSK_FREE(rlist_external->anchor);
|
||||
TSK_FREE(rlist_external->list);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL external.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_rlist_external_def_s =
|
||||
{
|
||||
sizeof(txc_rlist_external_t),
|
||||
txc_rlist_external_create,
|
||||
txc_rlist_external_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_rlist_external_def_t = &txc_rlist_external_def_s;
|
||||
|
||||
|
||||
#undef RLIST_SELECT_LIST_BY_NAME
|
||||
#undef RLIST_RETURN_IF_INVALID
|
||||
|
||||
|
|
|
@ -33,6 +33,11 @@
|
|||
#include "tinyxcap_config.h"
|
||||
#include "tsk_xml.h"
|
||||
|
||||
#include "tsk_object.h"
|
||||
|
||||
#define TXC_RLIST_CREATE(buffer, size) tsk_object_new(txc_rlist_def_t, (const char*)buffer, (size_t)size)
|
||||
#define TXC_RLIST_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@def TXC_RLIST_ENTRY_CREATE
|
||||
* Create a new @ref txc_rlist_entry_t object. You must call @ref TXC_RLIST_ENTRY_SAFE_FREE to free the newly created object.
|
||||
* @sa @ref TXC_RLIST_ENTRY_SAFE_FREE
|
||||
|
@ -42,8 +47,8 @@
|
|||
* @sa @ref TXC_RLIST_ENTRY_CREATE
|
||||
*/
|
||||
|
||||
#define TXC_RLIST_ENTRY_CREATE(this) TXC_XXX_CREATE2(this, rlist_entry)
|
||||
#define TXC_RLIST_ENTRY_SAFE_FREE(this) TXC_XXX_SAFE_FREE2(this, rlist_entry)
|
||||
#define TXC_RLIST_ENTRY_CREATE() tsk_object_new(txc_rlist_entry_def_t)
|
||||
#define TXC_RLIST_ENTRY_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@def TXC_RLIST_LIST_CREATE
|
||||
* Create a new @ref txc_rlist_list_t object. You must call @ref TXC_RLIST_LIST_SAFE_FREE to free the newly created object.
|
||||
|
@ -53,8 +58,8 @@
|
|||
* Safely free @ref txc_rlist_list_t object previously created using @ref TXC_RLIST_LIST_CREATE.
|
||||
* @sa @ref TXC_RLIST_LIST_CREATE
|
||||
*/
|
||||
#define TXC_RLIST_LIST_CREATE(this) TXC_XXX_CREATE2(this, rlist_list)
|
||||
#define TXC_RLIST_LIST_SAFE_FREE(this) TXC_XXX_SAFE_FREE2(this, rlist_list)
|
||||
#define TXC_RLIST_LIST_CREATE() tsk_object_new(txc_rlist_list_def_t)
|
||||
#define TXC_RLIST_LIST_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@def TXC_RLIST_LIST2_CREATE
|
||||
* Create a new @ref txc_rlist_list2_t object. You must call @ref TXC_RLIST_LIST2_SAFE_FREE to free the newly created object.
|
||||
|
@ -64,8 +69,8 @@
|
|||
* Safely free @ref txc_rlist_list2_t object previously created using @ref TXC_RLIST_LIST2_CREATE.
|
||||
* @sa @ref TXC_RLIST_LIST2_CREATE
|
||||
*/
|
||||
#define TXC_RLIST_LIST2_CREATE(this) TXC_XXX_CREATE2(this, rlist_list2)
|
||||
#define TXC_RLIST_LIST2_SAFE_FREE(this) TXC_XXX_SAFE_FREE2(this, rlist_list2)
|
||||
#define TXC_RLIST_LIST2_CREATE() tsk_object_new(txc_rlist_list2_def_t)
|
||||
#define TXC_RLIST_LIST2_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@def TXC_RLIST_EXTERNAL_CREATE
|
||||
* Create a new @ref txc_rlist_external_t object. You must call @ref TXC_RLIST_EXTERNAL_SAFE_FREE to free the newly created object.
|
||||
|
@ -75,13 +80,15 @@
|
|||
* Safely free @ref txc_rlist_external_t object previously created using @ref TXC_RLIST_EXTERNAL_CREATE.
|
||||
* @sa @ref TXC_RLIST_EXTERNAL_CREATE
|
||||
*/
|
||||
#define TXC_RLIST_EXTERNAL_CREATE(this) TXC_XXX_CREATE2(this, rlist_external)
|
||||
#define TXC_RLIST_EXTERNAL_SAFE_FREE(this) TXC_XXX_SAFE_FREE2(this, rlist_external)
|
||||
#define TXC_RLIST_EXTERNAL_CREATE() tsk_object_new(txc_rlist_external_def_t)
|
||||
#define TXC_RLIST_EXTERNAL_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/** Resource-list entry element
|
||||
*/
|
||||
typedef struct txc_rlist_entry_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
char* uri; /**< The uri*/
|
||||
char* display_name; /**< The display-name*/
|
||||
char* last_modified; /**< Last modified datetime */
|
||||
|
@ -95,6 +102,8 @@ typedef tsk_list_t txc_rlist_entry_L_t; /**< List of @ref txc_rlist_entry_t elem
|
|||
*/
|
||||
typedef struct txc_rlist_list_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
char* display_name; /**< The display-name*/
|
||||
char* name; /**< The name*/
|
||||
}
|
||||
|
@ -106,6 +115,8 @@ typedef tsk_list_t txc_rlist_listx_L_t; /**< List of @ref txc_rlist_list_t or @r
|
|||
*/
|
||||
typedef struct txc_rlist_external_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
char* anchor; /**< The anchor*/
|
||||
char* list; /**< The parent lis*/
|
||||
}
|
||||
|
@ -116,6 +127,8 @@ typedef tsk_list_t txc_rlist_external_L_t; /**< List of @ref txc_rlist_external_
|
|||
*/
|
||||
typedef struct txc_rlist_list2_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
char* display_name; /**< The list display-name*/
|
||||
char* name; /**< The list name */
|
||||
txc_rlist_entry_L_t* entries; /**< All entries */
|
||||
|
@ -129,34 +142,36 @@ typedef tsk_list_t txc_rlist_list2_L_t; /**< List of @ref txc_rlist_list2_t elem
|
|||
*/
|
||||
typedef struct txc_rlist_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
xmlDocPtr docPtr; /**< Pointer to the XML document */
|
||||
}
|
||||
txc_rlist_t;
|
||||
|
||||
void txc_rlist_list_init(txc_rlist_list_t *list);
|
||||
//void txc_rlist_list_init(txc_rlist_list_t *list);
|
||||
void txc_rlist_list_set(txc_rlist_list_t *list, const char* name, const char* display_name);
|
||||
void txc_rlist_list_free(void **list);
|
||||
//void txc_rlist_list_free(void **list);
|
||||
|
||||
void txc_rlist_list2_init(txc_rlist_list2_t *list2);
|
||||
//void txc_rlist_list2_init(txc_rlist_list2_t *list2);
|
||||
void txc_rlist_list2_set(txc_rlist_list2_t *list2, const char* name, const char* display_name);
|
||||
void txc_rlist_list2_add_external(txc_rlist_list2_t *list2, const char* anchor);
|
||||
void txc_rlist_list2_add_entry(txc_rlist_list2_t *list2, const char* uri, const char* display_name);
|
||||
void txc_rlist_list2_free(void **list2);
|
||||
//void txc_rlist_list2_free(void **list2);
|
||||
|
||||
void txc_rlist_entry_init(txc_rlist_entry_t *entry);
|
||||
//void txc_rlist_entry_init(txc_rlist_entry_t *entry);
|
||||
void txc_rlist_entry_set(txc_rlist_entry_t *entry, const char* uri, const char* display_name);
|
||||
void txc_rlist_entry_free(void **entry);
|
||||
//void txc_rlist_entry_free(void **entry);
|
||||
|
||||
void txc_rlist_external_init(txc_rlist_external_t *external);
|
||||
//void txc_rlist_external_init(txc_rlist_external_t *external);
|
||||
void txc_rlist_external_set(txc_rlist_external_t *external, const char* anchor);
|
||||
void txc_rlist_external_free(void **external);
|
||||
//void txc_rlist_external_free(void **external);
|
||||
|
||||
txc_rlist_entry_t* txc_rlist_entry_from_xml(const xmlNodePtr node, const char* lname);
|
||||
txc_rlist_external_t* txc_rlist_external_from_xml(const xmlNodePtr node, const char* lname);
|
||||
txc_rlist_list_t* txc_rlist_list_from_xml(const xmlNodePtr node);
|
||||
txc_rlist_list2_t* txc_rlist_list2_from_xml(const xmlNodePtr node);
|
||||
|
||||
TINYXCAP_API txc_rlist_t* txc_rlist_create(const char* buffer, size_t size);
|
||||
//TINYXCAP_API txc_rlist_t* txc_rlist_create(const char* buffer, size_t size);
|
||||
TINYXCAP_API txc_rlist_listx_L_t* txc_rlist_get_all_lists(const txc_rlist_t* rlist, int type2);
|
||||
TINYXCAP_API txc_rlist_entry_L_t* txc_rlist_get_entries_by_list(const txc_rlist_t* rlist, const char* lname);
|
||||
TINYXCAP_API txc_rlist_external_L_t* txc_rlist_get_externals_by_list(const txc_rlist_t* rlist, const char* lname);
|
||||
|
@ -168,6 +183,13 @@ TINYXCAP_API char* txc_rlist_list_serialize2(const char* name, const char* displ
|
|||
TINYXCAP_API char* txc_rlist_list2_serialize(const txc_rlist_list2_t *list2);
|
||||
TINYXCAP_API char* txc_rlist_list2_L_serialize(const txc_rlist_list2_L_t *list22);
|
||||
TINYXCAP_API char* txc_rlist_add_xml_header(const char* xml_content);
|
||||
TINYXCAP_API void txc_rlist_free(txc_rlist_t **rlist);
|
||||
//TINYXCAP_API void txc_rlist_free(txc_rlist_t **rlist);
|
||||
|
||||
TINYXCAP_API const void *txc_rlist_def_t;
|
||||
TINYXCAP_API const void *txc_rlist_entry_def_t;
|
||||
TINYXCAP_API const void *txc_rlist_list_def_t;
|
||||
TINYXCAP_API const void *txc_rlist_list2_def_t;
|
||||
TINYXCAP_API const void *txc_rlist_external_def_t;
|
||||
|
||||
|
||||
#endif /* _TINYXCAP_TXC_RLIST_H_ */
|
|
@ -91,14 +91,14 @@ printf("\n---\nTEST RLS-SERVICES\n---\n");
|
|||
"<rls-services xmlns=\""TXC_NS_RLS"\">"
|
||||
#define RLS_XML_FOOTER "</rls-services>"
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
* Internal function to initialize a service .
|
||||
* You MUST call @ref TXC_RLS_SERVICE_CREATE to create and initialize your object.
|
||||
* @param service The service element to initialize
|
||||
*/
|
||||
void txc_rls_service_init(txc_rls_service_t *service)
|
||||
{
|
||||
}
|
||||
///**@ingroup txc_rls_group
|
||||
//* Internal function to initialize a service .
|
||||
//* You MUST call @ref TXC_RLS_SERVICE_CREATE to create and initialize your object.
|
||||
//* @param service The service element to initialize
|
||||
//*/
|
||||
//void txc_rls_service_init(txc_rls_service_t *service)
|
||||
//{
|
||||
//}
|
||||
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
|
@ -111,8 +111,8 @@ void txc_rls_service_set(txc_rls_service_t *service, const char* uri, const char
|
|||
{
|
||||
if(service)
|
||||
{
|
||||
tsk_strupdate2(&(service->uri), uri);
|
||||
tsk_strupdate2(&(service->resource_list), resource_list);
|
||||
tsk_strupdate(&(service->uri), uri);
|
||||
tsk_strupdate(&(service->resource_list), resource_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,31 +128,31 @@ void txc_rls_service_add_package(txc_rls_service_t *service, const char* package
|
|||
{
|
||||
if(!(service->packages))
|
||||
{
|
||||
TSK_LIST_CREATE(service->packages);
|
||||
service->packages = TSK_LIST_CREATE();
|
||||
}
|
||||
|
||||
TSK_LIST_ITEM_CREATE(item);
|
||||
item->data = (void*)tsk_strdup2(package);
|
||||
item = TSK_LIST_ITEM_CREATE();
|
||||
item->data = TSK_STRING_CREATE(package);
|
||||
tsk_list_add_item(service->packages, &item);
|
||||
}
|
||||
}
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
* Internal function to free an rls service previously created using @ref TXC_RLS_SERVICE_CREATE.
|
||||
* You MUST call @ref TXC_RLS_SERVICE_SAFE_FREE to free a service.
|
||||
* @param _service The service to free.
|
||||
* @sa @ref TXC_RLS_SERVICE_SAFE_FREE
|
||||
*/
|
||||
void txc_rls_service_free(void **_service)
|
||||
{
|
||||
txc_rls_service_t **service = ((txc_rls_service_t**)_service);
|
||||
|
||||
TSK_FREE((*service)->uri);
|
||||
TSK_FREE((*service)->resource_list);
|
||||
TSK_LIST_SAFE_FREE((*service)->packages);
|
||||
|
||||
tsk_free2(_service);
|
||||
}
|
||||
///**@ingroup txc_rls_group
|
||||
//* Internal function to free an rls service previously created using @ref TXC_RLS_SERVICE_CREATE.
|
||||
//* You MUST call @ref TXC_RLS_SERVICE_SAFE_FREE to free a service.
|
||||
//* @param _service The service to free.
|
||||
//* @sa @ref TXC_RLS_SERVICE_SAFE_FREE
|
||||
//*/
|
||||
//void txc_rls_service_free(void **_service)
|
||||
//{
|
||||
// txc_rls_service_t **service = ((txc_rls_service_t**)_service);
|
||||
//
|
||||
// TSK_FREE((*service)->uri);
|
||||
// TSK_FREE((*service)->resource_list);
|
||||
// TSK_LIST_SAFE_FREE((*service)->packages);
|
||||
//
|
||||
// tsk_free2(_service);
|
||||
//}
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
* Internal function to deserialize an rls service from an XML document.
|
||||
|
@ -168,19 +168,19 @@ txc_rls_service_t* txc_rls_service_from_xml(const xmlNodePtr node)
|
|||
|
||||
if(tsk_xml_find_node(node, "service", nft_none))
|
||||
{
|
||||
TXC_RLS_SERVICE_CREATE(rls_service);
|
||||
rls_service = TXC_RLS_SERVICE_CREATE();
|
||||
|
||||
/* uri */
|
||||
node2 = tsk_xml_select_node(node,
|
||||
TSK_XML_NODE_SELECT_ATT_VALUE("service", "uri"),
|
||||
TSK_XML_NODE_SELECT_END());
|
||||
rls_service->uri = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rls_service->uri = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
/* resource-list */
|
||||
node2 = tsk_xml_select_node(node, TSK_XML_NODE_SELECT_BY_NAME("service"),
|
||||
TSK_XML_NODE_SELECT_BY_NAME("resource-list"),
|
||||
TSK_XML_NODE_SELECT_END());
|
||||
rls_service->resource_list = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
rls_service->resource_list = tsk_strdup(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2));
|
||||
|
||||
/* packages */
|
||||
node2 = tsk_xml_select_node(node, TSK_XML_NODE_SELECT_BY_NAME("service"),
|
||||
|
@ -191,11 +191,11 @@ txc_rls_service_t* txc_rls_service_from_xml(const xmlNodePtr node)
|
|||
if(!tsk_xml_find_node(node2, "package", nft_none)) node2 = tsk_xml_find_node(node2, "package", nft_next);
|
||||
if(node2)
|
||||
{
|
||||
TSK_LIST_CREATE(rls_service->packages);
|
||||
rls_service->packages = TSK_LIST_CREATE();
|
||||
do
|
||||
{
|
||||
TSK_LIST_ITEM_CREATE(item);
|
||||
item->data = tsk_strdup2(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2->children));
|
||||
item = TSK_LIST_ITEM_CREATE();
|
||||
item->data = TSK_STRING_CREATE(TSK_XML_NODE_SAFE_GET_TEXTVALUE(node2->children));
|
||||
tsk_list_add_item(rls_service->packages, &item);
|
||||
}
|
||||
while(node2 = tsk_xml_find_node(node2, "service", nft_next));
|
||||
|
@ -205,25 +205,25 @@ txc_rls_service_t* txc_rls_service_from_xml(const xmlNodePtr node)
|
|||
return rls_service;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
* Create a rls context from an XML buffer.
|
||||
* @param buffer The XML buffer from which to create the rls context
|
||||
* @param size The size of the XML buffer
|
||||
* @retval Pointer to a @ref txc_rls_t object or NULL. You MUST call @ref txc_rls_free to free the returned object.
|
||||
* @sa @ref txc_rls_free
|
||||
*/
|
||||
txc_rls_t* txc_rls_create(const char* buffer, size_t size)
|
||||
{
|
||||
if(buffer && size)
|
||||
{
|
||||
txc_rls_t* rls = (txc_rls_t*)tsk_calloc2(1, sizeof(txc_rls_t));
|
||||
rls->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
|
||||
return rls;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
///**@ingroup txc_rls_group
|
||||
//* Create a rls context from an XML buffer.
|
||||
//* @param buffer The XML buffer from which to create the rls context
|
||||
//* @param size The size of the XML buffer
|
||||
//* @retval Pointer to a @ref txc_rls_t object or NULL. You MUST call @ref txc_rls_free to free the returned object.
|
||||
//* @sa @ref txc_rls_free
|
||||
//*/
|
||||
//txc_rls_t* txc_rls_create(const char* buffer, size_t size)
|
||||
//{
|
||||
// if(buffer && size)
|
||||
// {
|
||||
// txc_rls_t* rls = (txc_rls_t*)tsk_calloc2(1, sizeof(txc_rls_t));
|
||||
// rls->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
//
|
||||
// return rls;
|
||||
// }
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
* Get all rls services
|
||||
|
@ -247,11 +247,11 @@ txc_rls_service_L_t* txc_rls_get_all_services(const txc_rls_t* rls)
|
|||
if(!tsk_xml_find_node(node, "service", nft_none)) node = tsk_xml_find_node(node, "service", nft_next);
|
||||
if(node)
|
||||
{
|
||||
TSK_LIST_CREATE(list);
|
||||
list = TSK_LIST_CREATE();
|
||||
do
|
||||
{
|
||||
rls_service = txc_rls_service_from_xml(node);
|
||||
tsk_list_add_data(list, ((void**) &rls_service), txc_rls_service_free);
|
||||
tsk_list_add_data(list, ((void**) &rls_service));
|
||||
}
|
||||
while(node = tsk_xml_find_node(node, "service", nft_next));
|
||||
}
|
||||
|
@ -275,12 +275,12 @@ char* txc_rls_service_serialize(const txc_rls_service_t *service)
|
|||
tsk_list_foreach(item, service->packages)
|
||||
{
|
||||
char* curr = 0;
|
||||
tsk_sprintf(0, &curr, "<package>%s</package>", ((char*)item->data));
|
||||
tsk_strcat2(&package_str, curr);
|
||||
tsk_sprintf(&curr, "<package>%s</package>", TSK_STRING_STR(item->data));
|
||||
tsk_strcat(&package_str, curr);
|
||||
TSK_FREE(curr);
|
||||
}
|
||||
/* service */
|
||||
tsk_sprintf(0, &service_str,
|
||||
tsk_sprintf(&service_str,
|
||||
"<service uri=\"%s\">"
|
||||
"<resource-list>%s</resource-list>"
|
||||
"<packages>"
|
||||
|
@ -305,38 +305,164 @@ char* txc_rls_services_serialize(const tsk_list_t *services)
|
|||
if(!services) return 0;
|
||||
|
||||
/* xml header */
|
||||
tsk_strcat2(&services_str, RLS_XML_HEADER);
|
||||
tsk_strcat(&services_str, RLS_XML_HEADER);
|
||||
|
||||
tsk_list_foreach(item, services)
|
||||
{
|
||||
/* get service */
|
||||
txc_rls_service_t *service = ((txc_rls_service_t*)item->data);
|
||||
char* service_str = txc_rls_service_serialize(service);
|
||||
tsk_strcat2(&services_str, service_str);
|
||||
tsk_strcat(&services_str, service_str);
|
||||
TSK_FREE(service_str);
|
||||
}
|
||||
|
||||
/* xml footer */
|
||||
tsk_strcat2(&services_str, RLS_XML_FOOTER);
|
||||
tsk_strcat(&services_str, RLS_XML_FOOTER);
|
||||
|
||||
return services_str;
|
||||
}
|
||||
|
||||
///**@ingroup txc_rls_group
|
||||
//* Internal function to free an rls context previously created using @ref txc_rls_create.
|
||||
//* @param rls The context to free
|
||||
//* @sa @ref txc_rls_create
|
||||
//*/
|
||||
//void txc_rls_free(txc_rls_t **rls)
|
||||
//{
|
||||
// if(*rls)
|
||||
// {
|
||||
// xmlFreeDoc((*rls)->docPtr);
|
||||
//
|
||||
// tsk_free2(rls);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// RLS object definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
* Internal function to free an rls context previously created using @ref txc_rls_create.
|
||||
* @param rls The context to free
|
||||
* @sa @ref txc_rls_create
|
||||
*/
|
||||
void txc_rls_free(txc_rls_t **rls)
|
||||
static void* txc_rls_create(void *self, va_list * app)
|
||||
{
|
||||
if(*rls)
|
||||
{
|
||||
xmlFreeDoc((*rls)->docPtr);
|
||||
|
||||
tsk_free2(rls);
|
||||
txc_rls_t *rls = self;
|
||||
if(rls)
|
||||
{
|
||||
const char* buffer = va_arg(*app, const char*);
|
||||
size_t size = va_arg(*app, size_t);
|
||||
if(buffer && size)
|
||||
{
|
||||
rls->docPtr = xmlParseMemory(buffer, (int)size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new rls object.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
*/
|
||||
static void* txc_rls_destroy(void * self)
|
||||
{
|
||||
txc_rls_t *rls = self;
|
||||
if(rls)
|
||||
{
|
||||
xmlFreeDoc(rls->docPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL rls object.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_rls_def_s =
|
||||
{
|
||||
sizeof(txc_rls_t),
|
||||
txc_rls_create,
|
||||
txc_rls_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_rls_def_t = &txc_rls_def_s;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// RLS service definition
|
||||
//
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
*/
|
||||
static void* txc_rls_service_create(void *self, va_list * app)
|
||||
{
|
||||
txc_rls_service_t *rls_service = self;
|
||||
if(!rls_service)
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new rls service object.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup txc_rls_group
|
||||
*/
|
||||
static void* txc_rls_service_destroy(void * self)
|
||||
{
|
||||
txc_rls_service_t *rls_service = self;
|
||||
if(rls_service)
|
||||
{
|
||||
TSK_FREE(rls_service->uri);
|
||||
TSK_FREE(rls_service->resource_list);
|
||||
TSK_LIST_SAFE_FREE(rls_service->packages);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_WARN("Cannot destroy NULL rls service object.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
static const tsk_object_def_t txc_rls_service_def_s =
|
||||
{
|
||||
sizeof(txc_rls_service_t),
|
||||
txc_rls_service_create,
|
||||
txc_rls_service_destroy,
|
||||
0
|
||||
};
|
||||
const void *txc_rls_service_def_t = &txc_rls_service_def_s;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#undef RLS_RETURN_IF_INVALID
|
||||
|
||||
#undef RLS_XML_HEADER
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include "tinyxcap_config.h"
|
||||
#include "tsk_xml.h"
|
||||
|
||||
#define TXC_RLS_CREATE(buffer, size) tsk_object_new(txc_rls_def_t, (const char*)buffer, (size_t)size)
|
||||
#define TXC_RLS_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**@def TXC_RLS_SERVICE_CREATE
|
||||
* Create an initialize an rls service. You MUST use @ref TXC_RLS_SERVICE_SAFE_FREE to free the object.
|
||||
* @sa @ref TXC_RLS_SERVICE_SAFE_FREE
|
||||
|
@ -43,14 +46,16 @@
|
|||
* Safely free an rls service previously created using @ref TXC_RLS_SERVICE_CREATE.
|
||||
* @sa @ref TXC_RLS_SERVICE_CREATE
|
||||
*/
|
||||
#define TXC_RLS_SERVICE_CREATE(this) TXC_XXX_CREATE2(this, rls_service)
|
||||
#define TXC_RLS_SERVICE_SAFE_FREE(this) TXC_XXX_SAFE_FREE2(this, rls_service)
|
||||
#define TXC_RLS_SERVICE_CREATE() tsk_object_new(txc_rls_service_def_t)
|
||||
#define TXC_RLS_SERVICE_SAFE_FREE(self) tsk_object_unref(self), self = 0
|
||||
|
||||
/**
|
||||
* RLS-SERVICE
|
||||
*/
|
||||
typedef struct txc_rls_service_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
char* uri; /**< The uri of the service*/
|
||||
char* resource_list; /**< The resource-lists associated to this rls-service */
|
||||
tsk_list_t* packages; /**< The list of available packages */
|
||||
|
@ -63,21 +68,26 @@ typedef tsk_list_t txc_rls_service_L_t; /**< List of @ref txc_rls_service_t elem
|
|||
*/
|
||||
typedef struct txc_rls_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
xmlDocPtr docPtr; /**< Pointer to the XML document */
|
||||
}
|
||||
txc_rls_t;
|
||||
|
||||
void txc_rls_service_init(txc_rls_service_t *service);
|
||||
//void txc_rls_service_init(txc_rls_service_t *service);
|
||||
void txc_rls_service_set(txc_rls_service_t *service, const char* uri, const char* resource_list);
|
||||
void txc_rls_service_add_package(txc_rls_service_t *service, const char* package);
|
||||
void txc_rls_service_free(void **service);
|
||||
//void txc_rls_service_free(void **service);
|
||||
|
||||
txc_rls_service_t* txc_rls_service_from_xml(const xmlNodePtr node);
|
||||
|
||||
TINYXCAP_API txc_rls_t* txc_rls_create(const char* buffer, size_t size);
|
||||
//TINYXCAP_API txc_rls_t* txc_rls_create(const char* buffer, size_t size);
|
||||
TINYXCAP_API txc_rls_service_L_t* txc_rls_get_all_services(const txc_rls_t* rls);
|
||||
TINYXCAP_API char* txc_rls_service_serialize(const txc_rls_service_t *service);
|
||||
TINYXCAP_API char* txc_rls_services_serialize(const tsk_list_t *services);
|
||||
TINYXCAP_API void txc_rls_free(txc_rls_t **rls);
|
||||
//TINYXCAP_API void txc_rls_free(txc_rls_t **rls);
|
||||
|
||||
TINYXCAP_API const void *txc_rls_def_t;
|
||||
TINYXCAP_API const void *txc_rls_service_def_t;
|
||||
|
||||
#endif /* _TINYXCAP_TXC_RLS_H_ */
|
|
@ -112,7 +112,7 @@ static tsk_list_t* txc_xcap_caps_xxx(xmlNodePtr rootNode, const char* root, cons
|
|||
tsk_list_item_t* item = 0;
|
||||
xmlNodePtr node = 0;
|
||||
|
||||
TSK_LIST_CREATE(xxx);
|
||||
xxx = TSK_LIST_CREATE();
|
||||
|
||||
node = tsk_xml_select_node(rootNode,
|
||||
TSK_XML_NODE_SELECT_BY_NAME(root),
|
||||
|
@ -124,8 +124,8 @@ static tsk_list_t* txc_xcap_caps_xxx(xmlNodePtr rootNode, const char* root, cons
|
|||
{
|
||||
if(node->children && node->children->type == XML_TEXT_NODE)
|
||||
{
|
||||
TSK_LIST_ITEM_CREATE(item);
|
||||
item->data = tsk_strdup2((const char*)node->children->content);
|
||||
item = TSK_LIST_ITEM_CREATE();
|
||||
item->data = TSK_STRING_CREATE((const char*)node->children->content);
|
||||
tsk_list_add_item(xxx, &item);
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ xcap_caps_t* txc_xcap_caps_create(const char* buffer, size_t size)
|
|||
{
|
||||
xmlNodePtr root = 0;
|
||||
xmlDocPtr docPtr = 0;
|
||||
xcap_caps_t* caps = (xcap_caps_t*)tsk_calloc2(1, sizeof(xcap_caps_t));
|
||||
xcap_caps_t* caps = (xcap_caps_t*)tsk_calloc(1, sizeof(xcap_caps_t));
|
||||
|
||||
docPtr = xmlParseMemory(buffer, (int)size);
|
||||
if(docPtr) root = docPtr->children;
|
||||
|
@ -171,8 +171,7 @@ void txc_xcap_caps_free(xcap_caps_t** caps)
|
|||
TSK_LIST_SAFE_FREE((*caps)->namespaces);
|
||||
TSK_LIST_SAFE_FREE((*caps)->extensions);
|
||||
|
||||
free(*caps);
|
||||
(*caps)=0;
|
||||
tsk_free(caps);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,12 @@
|
|||
#include "targetver.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__)
|
||||
//#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__)
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
|
||||
//#endif
|
||||
|
||||
#define TINYSAK_IMPORTS
|
||||
#define TINYXCAP_IMPORTS
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#define TEST_XXXX_CONTEXT_INIT(context) \
|
||||
context->user_agent = tsk_strdup2("XDM-client/OMA1.1"); \
|
||||
context->txc_root = tsk_strdup2("http://192.168.0.15:8080/services"); \
|
||||
context->password = tsk_strdup2("doubango"); \
|
||||
context->xui = tsk_strdup2("sip:doubango@micromethod.com"); \
|
||||
context->pragma = tsk_strdup2("keep-alive"); \
|
||||
context->user_agent = tsk_strdup("XDM-client/OMA1.1"); \
|
||||
context->txc_root = tsk_strdup("http://192.168.0.15:8080/services"); \
|
||||
context->password = tsk_strdup("doubango"); \
|
||||
context->xui = tsk_strdup("sip:doubango@micromethod.com"); \
|
||||
context->pragma = tsk_strdup("keep-alive"); \
|
||||
context->reuse_http_connection = 0;
|
||||
|
||||
#define LOOP 0
|
||||
#define LOOP 1
|
||||
|
||||
#define RUN_TEST_ALL 0
|
||||
#define RUN_TEST_SELECTOR 0
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
WarnAsError="true"
|
||||
|
|
|
@ -43,12 +43,12 @@ int test_async()
|
|||
txc_request_t* request = 0;
|
||||
int ret = 0, error = 0, i;
|
||||
txc_context_t* context = 0;
|
||||
tsk_condwait_t *condwait;
|
||||
tsk_condwait_handle_t *condwait;
|
||||
|
||||
printf("---\nTEST_ASYNC\n---\n");
|
||||
|
||||
TXC_CONTEXT_CREATE(context);
|
||||
TSK_CONDWAIT_CREATE(condwait);
|
||||
condwait = tsk_condwait_create();
|
||||
|
||||
TEST_XXXX_CONTEXT_INIT(context);
|
||||
context->http_callback = http_callback;
|
||||
|
@ -74,7 +74,7 @@ int test_async()
|
|||
tsk_condwait_timedwait(condwait, 20000);
|
||||
#endif
|
||||
|
||||
TSK_CONDWAIT_SAFE_FREE(condwait);
|
||||
tsk_condwait_destroy(&condwait);
|
||||
TXC_CONTEXT_SAFE_FREE(context);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -49,7 +49,7 @@ void test_oma_directory(const char* buffer, size_t size)
|
|||
printf("\n---\nTEST OMA XCAP-DIRECTORY\n---\n");
|
||||
{
|
||||
/* create oma xcap directory context */
|
||||
omadir = txc_omadir_create(buffer, size);
|
||||
omadir = TXC_OMADIR_CREATE(buffer, size);
|
||||
|
||||
/* get all folders */
|
||||
printf("\nget all folders\n");
|
||||
|
@ -79,7 +79,7 @@ void test_oma_directory(const char* buffer, size_t size)
|
|||
}
|
||||
|
||||
/* free the context */
|
||||
txc_omadir_free(&omadir);
|
||||
TXC_OMADIR_SAFE_FREE(omadir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void test_rlist(const char* rlist_str, size_t size)
|
|||
printf("\n---\nTEST RESOURCE-LISTS\n---\n");
|
||||
{
|
||||
/* create rlist context */
|
||||
rlist = txc_rlist_create(rlist_str, size);
|
||||
rlist = TXC_RLIST_CREATE(rlist_str, size);
|
||||
|
||||
/* get all lists */
|
||||
printf("\nget all lists\n");
|
||||
|
@ -114,7 +114,7 @@ void test_rlist(const char* rlist_str, size_t size)
|
|||
}
|
||||
|
||||
/* free rlist */
|
||||
txc_rlist_free(&rlist);
|
||||
TXC_RLIST_SAFE_FREE(rlist);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ void test_rlist2(const char* rlist_str, size_t size)
|
|||
printf("\n---\nTEST RESOURCE-LISTS-2\n---\n");
|
||||
{
|
||||
/* create rlist context */
|
||||
rlist = txc_rlist_create(rlist_str, size);
|
||||
rlist = TXC_RLIST_CREATE(rlist_str, size);
|
||||
|
||||
/* get all lists */
|
||||
printf("\nget all lists\n");
|
||||
|
@ -164,7 +164,7 @@ void test_rlist2(const char* rlist_str, size_t size)
|
|||
}
|
||||
|
||||
/* free rlist */
|
||||
txc_rlist_free(&rlist);
|
||||
TXC_RLIST_SAFE_FREE(rlist);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ void test_rls_services(const char* buffer, size_t size)
|
|||
printf("\n---\nTEST RLS-SERVICES\n---\n");
|
||||
{
|
||||
/* create rls context */
|
||||
rls = txc_rls_create(buffer, size);
|
||||
rls = TXC_RLS_CREATE(buffer, size);
|
||||
|
||||
/* get all services */
|
||||
list = txc_rls_get_all_services(rls);
|
||||
|
@ -67,7 +67,7 @@ void test_rls_services(const char* buffer, size_t size)
|
|||
TSK_LIST_SAFE_FREE(list);
|
||||
|
||||
/* free rls context */
|
||||
txc_rls_free(&rls);
|
||||
TXC_RLS_SAFE_FREE(rls);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "txc_api.h"
|
||||
|
||||
#ifndef TEST_XCAP_CAPS
|
||||
|
@ -54,16 +53,16 @@ void test_xcap_caps(const char* buffer, size_t size)
|
|||
printf("\n---\nTEST XCAP-CAPS\n---\n");
|
||||
{
|
||||
xcap_caps = txc_xcap_caps_create(buffer, size);
|
||||
|
||||
|
||||
/* dump namespaces */
|
||||
tsk_list_foreach(item, xcap_caps->namespaces)
|
||||
printf("namespace: %s\n", ((char*)item->data));
|
||||
printf("namespace: %s\n", TSK_STRING_STR(item->data));
|
||||
/* dump extensions */
|
||||
tsk_list_foreach(item, xcap_caps->extensions)
|
||||
printf("extension: %s\n", ((char*)item->data));
|
||||
printf("extension: %s\n", TSK_STRING_STR(item->data));
|
||||
/* dump auids */
|
||||
tsk_list_foreach(item, xcap_caps->auids)
|
||||
printf("auid: %s\n", ((char*)item->data));
|
||||
printf("auid: %s\n", TSK_STRING_STR(item->data));
|
||||
|
||||
txc_xcap_caps_free(&xcap_caps);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue