- Add TinySigComp project.

- Add Binary utils.
- Add support for thread-safe objects.
- Add support for sha1 and ppfcs16.
This commit is contained in:
bossiel 2009-11-21 05:43:13 +00:00
parent 8c499b7270
commit 5a3075df3c
55 changed files with 10697 additions and 171 deletions

View File

@ -42,8 +42,12 @@
#include "tsk_mutex.h"
#include "tsk_semaphore.h"
#include "tsk_thread.h"
#include "tsk_safeobj.h"
#include "tsk_macros.h"
#include "tsk_debug.h"
#include "tsk_ppfcs16.h"
#include "tsk_sha1.h"
#endif /* _TINYSAK_SAK_H_ */

View File

@ -33,7 +33,7 @@
#include "tsk_debug.h"
#include "tsk_macros.h"
#include "tsk_time.h"
#include "tsk_mutex.h"
#include <pthread.h>
#include <time.h>
@ -47,32 +47,60 @@
/**@defgroup tsk_condwait_group Pthread CondWait
*/
/**@ingroup tsk_condwait_group
* Internal function to initialize a condwait. You MUST use @ref TSK_CONDWAIT_CREATE to create and initialize a condwait.
* @param condwait The condwait to initialize.
* @sa @ref TSK_CONDWAIT_CREATE
/** Pthread CondWait.
*/
void tsk_condwait_init(tsk_condwait_t* condwait)
typedef struct tsk_condwait_s
{
condwait->handle = tsk_calloc2(1, sizeof(pthread_cond_t));
pthread_cond_init((pthread_cond_t*)condwait->handle, 0);
TSK_MUTEX_CREATE(condwait->mutex);
pthread_cond_t* pcond; /**< Handle pointing to the condwait */
tsk_mutex_handle_t* mutex; /**< Locker*/
}
tsk_condwait_t;
/**@ingroup tsk_condwait_group
* Creates new Pthread conwait handle. You MUST call @ref tsk_condwait_destroy to free the handle.
* @retval New condwait handle.
* @sa @ref tsk_condwait_destroy.
*/
tsk_condwait_handle_t* tsk_condwait_create()
{
tsk_condwait_t *condwait = tsk_calloc2(1, sizeof(tsk_condwait_t));
if(condwait)
{
condwait->pcond = (pthread_cond_t*)tsk_calloc2(1, sizeof(pthread_cond_t));
if(pthread_cond_init(condwait->pcond, 0))
{
TSK_DEBUG_ERROR("Failed to initialize the new conwait.");
}
if(!(condwait->mutex = tsk_mutex_create()))
{
if(!pthread_mutex_init((pthread_mutex_t*)condwait->mutex, 0))
{
TSK_DEBUG_ERROR("Failed to initialize the new mutex.");
}
}
}
else
{
TSK_DEBUG_ERROR("Failed to create new conwait.");
}
return condwait;
}
/**@ingroup tsk_condwait_group
* Wait for a condition indefinitely.
* @param condwait CondWait context created using @ref TSK_CONDWAIT_CREATE.
* @param handle CondWait handle created using @ref tsk_condwait_create.
* @retval Zero if succeed and non-zero otherwise.
* @sa @ref tsk_condwait_timedwait.
*/
int tsk_condwait_wait(tsk_condwait_t* condwait)
int tsk_condwait_wait(tsk_condwait_handle_t* handle)
{
int ret = EINVAL;
tsk_condwait_t *condwait = (tsk_condwait_t*)handle;
if(condwait && condwait->mutex)
{
tsk_mutex_lock(condwait->mutex);
if(ret = pthread_cond_wait((pthread_cond_t*)condwait->handle, (pthread_mutex_t*)condwait->mutex->handle))
if(ret = pthread_cond_wait(condwait->pcond, (pthread_mutex_t*)condwait->mutex))
{
TSK_DEBUG_ERROR("pthread_cond_wait function failed: %d", ret);
}
@ -83,14 +111,15 @@ int tsk_condwait_wait(tsk_condwait_t* condwait)
/**@ingroup tsk_condwait_group
* Wait for a condition @ref ms milliseconds.
* @param condwait CondWait context created using @ref TSK_CONDWAIT_CREATE.
* @param handle CondWait context created using @ref tsk_condwait_create.
* @param ms The number of milliseconds to wait for a given condition.
* @retval Zero if succeed or @ref ETIMEDOUT if timedout and non-zero otherwise.
* @sa @ref tsk_condwait_wait.
*/
int tsk_condwait_timedwait(tsk_condwait_t* condwait, unsigned int ms)
int tsk_condwait_timedwait(tsk_condwait_handle_t* handle, unsigned int ms)
{
int ret = EINVAL;
tsk_condwait_t *condwait = (tsk_condwait_t*)handle;
if(condwait && condwait->mutex)
{
@ -103,9 +132,16 @@ int tsk_condwait_timedwait(tsk_condwait_t* condwait, unsigned int ms)
if(ts.tv_nsec > 999999999) ts.tv_sec+=1, ts.tv_nsec = ts.tv_nsec % 1000000000;
tsk_mutex_lock(condwait->mutex);
if(ret = pthread_cond_timedwait((pthread_cond_t*)condwait->handle, (pthread_mutex_t*)condwait->mutex->handle, &ts))
if(ret = pthread_cond_timedwait(condwait->pcond, (pthread_mutex_t*)condwait->mutex, &ts))
{
TSK_DEBUG_ERROR("pthread_cond_timedwait function failed: %d", ret);
if(ret == ETIMEDOUT)
{
TSK_DEBUG_INFO("pthread_cond_timedwait function timedout: %d", ret);
}
else
{
TSK_DEBUG_ERROR("pthread_cond_timedwait function failed: %d", ret);
}
}
tsk_mutex_unlock(condwait->mutex);
@ -116,18 +152,19 @@ int tsk_condwait_timedwait(tsk_condwait_t* condwait, unsigned int ms)
/**@ingroup tsk_condwait_group
* Wakes up at least one thread that is currently waiting on @ref condwait variable.
* @param condwait CondWait context created using @ref TSK_CONDWAIT_CREATE.
* @param handle CondWait handle created using @ref tsk_condwait_create.
* @retval Zero if succeed and non-zero otherwise.
* @sa @ref tsk_condwait_broadcast.
*/
int tsk_condwait_signal(tsk_condwait_t* condwait)
int tsk_condwait_signal(tsk_condwait_handle_t* handle)
{
int ret = EINVAL;
tsk_condwait_t *condwait = (tsk_condwait_t*)handle;
if(condwait && condwait->mutex)
{
tsk_mutex_lock(condwait->mutex);
if(ret = pthread_cond_signal((pthread_cond_t*)condwait->handle))
if(ret = pthread_cond_signal(condwait->pcond))
{
TSK_DEBUG_ERROR("pthread_cond_signal function failed: %d", ret);
}
@ -138,18 +175,19 @@ int tsk_condwait_signal(tsk_condwait_t* condwait)
/**@ingroup tsk_condwait_group
* Wakes up all threads that are currently waiting on @ref condwait variable.
* @param condwait CondWait context created using @ref TSK_CONDWAIT_CREATE.
* @param handle CondWait handle created using @ref tsk_condwait_create.
* @retval Zero if succeed and non-zero otherwise.
* @sa @ref tsk_condwait_signal.
*/
int tsk_condwait_broadcast(tsk_condwait_t* condwait)
int tsk_condwait_broadcast(tsk_condwait_handle_t* handle)
{
int ret = EINVAL;
tsk_condwait_t *condwait = (tsk_condwait_t*)handle;
if(condwait && condwait->mutex)
{
tsk_mutex_lock(condwait->mutex);
if(ret = pthread_cond_broadcast((pthread_cond_t*)condwait->handle))
if(ret = pthread_cond_broadcast(condwait->pcond))
{
TSK_DEBUG_ERROR("pthread_cond_broadcast function failed: %d", ret);
}
@ -159,17 +197,19 @@ int tsk_condwait_broadcast(tsk_condwait_t* condwait)
}
/**@ingroup tsk_condwait_group
* Internal function to free a condwait previously created using @ref TSK_CONDWAIT_CREATE. You MUST use @ref TSK_CONDWAIT_SAFE_FREE to safely free a condwait.
* @param condwait The condwait to free.
* @sa @ref TSK_CONDWAIT_SAFE_FREE
* Destroy/Free a condwait variable previously created using @ref tsk_condwait_create.
* @param handle The condwait handle to free.
* @sa @ref tsk_condwait_create
*/
void tsk_condwait_free(tsk_condwait_t** condwait)
void tsk_condwait_destroy(tsk_condwait_handle_t** handle)
{
tsk_condwait_t **condwait = (tsk_condwait_t**)handle;
if(condwait && *condwait)
{
TSK_MUTEX_SAFE_FREE((*condwait)->mutex);
pthread_cond_destroy((pthread_cond_t*)(*condwait)->handle);
TSK_FREE((*condwait)->handle);
tsk_mutex_destroy(&((*condwait)->mutex));
pthread_cond_destroy((*condwait)->pcond);
TSK_FREE((*condwait)->pcond);
tsk_free2((void**)condwait);
}
else

View File

@ -31,36 +31,17 @@
#define _TINYSAK_CONDWAIT_H_
#include "tinySAK_config.h"
#include "tsk_mutex.h"
/**@def TSK_CONDWAIT_CREATE
* Create and initialize a condwait.
* You MUST use @ref TSK_CONDWAIT_SAFE_FREE to free a condwait.
* @param this The @ref tsk_condwait_t object to create.
* @sa @ref TSK_CONDWAIT_SAFE_FREE.
/**
* Pthread condwait handle.
*/
#define TSK_CONDWAIT_CREATE(this) TSK_XXX_CREATE2(this, condwait)
/**@def TSK_CONDWAIT_SAFE_FREE
* Safely free a condwait previously created using @ref TSK_CONDWAIT_CREATE.
* @param this The @ref tsk_condwait_t object to free.
* @sa @ref TSK_CONDWAIT_CREATE.
*/
#define TSK_CONDWAIT_SAFE_FREE(this) TSK_XXX_SAFE_FREE2(this, condwait)
typedef void tsk_condwait_handle_t;
/** Pthread CondWait.
*/
typedef struct tsk_condwait_s
{
void* handle; /**< Handle pointing to the condwait */
tsk_mutex_t* mutex; /**< Locker*/
}
tsk_condwait_t;
TINYSAK_API void tsk_condwait_init(tsk_condwait_t* condwait);
TINYSAK_API int tsk_condwait_wait(tsk_condwait_t* condwait);
TINYSAK_API int tsk_condwait_timedwait(tsk_condwait_t* condwait, unsigned int ms);
TINYSAK_API int tsk_condwait_signal(tsk_condwait_t* condwait);
TINYSAK_API int tsk_condwait_broadcast(tsk_condwait_t* condwait);
TINYSAK_API void tsk_condwait_free(tsk_condwait_t** condwait);
TINYSAK_API tsk_condwait_handle_t* tsk_condwait_create();
TINYSAK_API int tsk_condwait_wait(tsk_condwait_handle_t* handle);
TINYSAK_API int tsk_condwait_timedwait(tsk_condwait_handle_t* handle, unsigned int ms);
TINYSAK_API int tsk_condwait_signal(tsk_condwait_handle_t* handle);
TINYSAK_API int tsk_condwait_broadcast(tsk_condwait_handle_t* handle);
TINYSAK_API void tsk_condwait_destroy(tsk_condwait_handle_t** handle);
#endif /* _TINYSAK_CONDWAIT_H_ */

View File

@ -38,6 +38,7 @@
*/
#define TSK_SAFE_FREE(heap, ptr) (void)tsk_free(heap, (void**)(&ptr));
#define TSK_FREE(ptr) TSK_SAFE_FREE(0, (void**)(ptr))
#define TSK_SAFE_DELETE_ARRAY(ptr) { if(ptr){ delete []ptr; ptr=NULL; } }
/** Safely free a pointer
*/

View File

@ -37,28 +37,39 @@
*/
/**@ingroup tsk_mutex_group
* Internal function to initialize a mutex. You MUST use @ref TSK_MUTEX_CREATE to create and initialize a mutex.
* @param mutex The mutex to initialize.
* @sa @ref TSK_MUTEX_CREATE
* Creates new mutex handle. You MUST use @ref tsk_mutex_destroy to free the mutex handle.
* @retval New mutex handle.
* @sa @ref tsk_mutex_destroy
*/
void tsk_mutex_init(tsk_mutex_t* mutex)
tsk_mutex_handle_t* tsk_mutex_create()
{
mutex->handle = tsk_calloc2(1, sizeof(pthread_mutex_t));
pthread_mutex_init((pthread_mutex_t*)mutex->handle, 0);
tsk_mutex_handle_t *handle = tsk_calloc2(1, sizeof(pthread_mutex_t));
if(handle)
{
if(pthread_mutex_init((pthread_mutex_t*)handle, 0))
{
TSK_DEBUG_ERROR("Failed to initialize the new mutex.");
}
}
else
{
TSK_DEBUG_ERROR("Failed to create new mutex.");
}
return handle;
}
/**@ingroup tsk_mutex_group
* Lock a mutex. You must use @ref tsk_mutex_unlock to unlock the mutex.
* @param mutex The mutex to lock.
* @param handle The handle of the mutex to lock.
* @retval Zero if succeed and non-zero otherwise.
* @sa @ref tsk_mutex_unlock.
*/
int tsk_mutex_lock(tsk_mutex_t* mutex)
int tsk_mutex_lock(tsk_mutex_handle_t* handle)
{
int ret = EINVAL;
if(mutex)
if(handle)
{
if(ret = pthread_mutex_lock((pthread_mutex_t*)mutex->handle))
if(ret = pthread_mutex_lock((pthread_mutex_t*)handle))
{
TSK_DEBUG_ERROR("Failed to lock the mutex: %d", ret);
}
@ -68,18 +79,25 @@ int tsk_mutex_lock(tsk_mutex_t* mutex)
/**@ingroup tsk_mutex_group
* Unlock a mutex previously locked using @ref tsk_mutex_lock.
* @param mutex The mutex to unlock.
* @param handle The handle of the mutex to unlock.
* @retval Zero if succeed and non-zero otherwise.
* @sa @ref tsk_mutex_lock.
*/
int tsk_mutex_unlock(tsk_mutex_t* mutex)
int tsk_mutex_unlock(tsk_mutex_handle_t* handle)
{
int ret = EINVAL;
if(mutex)
if(handle)
{
if(ret= pthread_mutex_unlock((pthread_mutex_t*)mutex->handle))
if(ret = pthread_mutex_unlock((pthread_mutex_t*)handle))
{
TSK_DEBUG_ERROR("Failed to unlock the mutex: %d", ret);
if(ret == EPERM)
{
TSK_DEBUG_INFO("The calling thread does not own the mutex: %d", ret);
}
else
{
TSK_DEBUG_ERROR("Failed to unlock the mutex: %d", ret);
}
}
}
return ret;
@ -90,13 +108,12 @@ int tsk_mutex_unlock(tsk_mutex_t* mutex)
* @param mutex The mutex to free.
* @sa @ref TSK_MUTEX_SAFE_FREE
*/
void tsk_mutex_free(tsk_mutex_t** mutex)
void tsk_mutex_destroy(tsk_mutex_handle_t** handle)
{
if(mutex && *mutex)
if(handle && *handle)
{
pthread_mutex_destroy((pthread_mutex_t*)(*mutex)->handle);
TSK_FREE((*mutex)->handle);
tsk_free2((void**)mutex);
pthread_mutex_destroy((pthread_mutex_t*)*handle);
tsk_free2((void**)handle);
}
else
{

View File

@ -32,31 +32,14 @@
#include "tinySAK_config.h"
/**@def TSK_MUTEX_CREATE
* Create and initialize a mutex.
* You MUST use @ref TSK_MUTEX_SAFE_FREE to free a mutex.
* @param this The @ref tsk_mutex_t object to create.
* @sa @ref TSK_MUTEX_SAFE_FREE.
/**
* Pthread Mutex handle.
*/
#define TSK_MUTEX_CREATE(this) TSK_XXX_CREATE2(this, mutex)
/**@def TSK_MUTEX_SAFE_FREE
* Safely free a mutex previously created using @ref TSK_MUTEX_CREATE.
* @param this The @ref tsk_mutex_t object to free.
* @sa @ref TSK_MUTEX_CREATE.
*/
#define TSK_MUTEX_SAFE_FREE(this) TSK_XXX_SAFE_FREE2(this, mutex)
typedef void tsk_mutex_handle_t;
/** Pthread Mutex.
*/
typedef struct tsk_mutex_s
{
void* handle; /**< Handle pointing to the mutex */
}
tsk_mutex_t;
TINYSAK_API void tsk_mutex_init(tsk_mutex_t* mutex);
TINYSAK_API int tsk_mutex_lock(tsk_mutex_t* mutex);
TINYSAK_API int tsk_mutex_unlock(tsk_mutex_t* mutex);
TINYSAK_API void tsk_mutex_free(tsk_mutex_t** mutex);
TINYSAK_API tsk_mutex_handle_t* tsk_mutex_create();
TINYSAK_API int tsk_mutex_lock(tsk_mutex_handle_t* handle);
TINYSAK_API int tsk_mutex_unlock(tsk_mutex_handle_t* handle);
TINYSAK_API void tsk_mutex_destroy(tsk_mutex_handle_t** handle);
#endif /* _TINYSAK_MUTEX_H_ */

View File

@ -38,28 +38,39 @@
*/
/**@ingroup tsk_semaphore_group
* Internal function to initialize a semaphore. You MUST use @ref TSK_SEMAPHORE_CREATE to create and initialize a semaphore.
* @param semaphore The semaphore to initialize.
* @sa @ref TSK_SEMAPHORE_CREATE
* Creates new Pthread semaphore. You MUST use @ref tsk_semaphore_free to free the handle.
* @retval The New semaphore handle.
* @sa @ref tsk_semaphore_free
*/
void tsk_semaphore_init(tsk_semaphore_t* semaphore)
tsk_semaphore_handle_t* tsk_semaphore_create()
{
semaphore->handle = tsk_calloc2(1, sizeof(sem_t));
sem_init((sem_t*)semaphore->handle, PTHREAD_PROCESS_PRIVATE, 0);
tsk_semaphore_handle_t *handle = tsk_calloc2(1, sizeof(sem_t));
if(handle)
{
if(sem_init((sem_t*)handle, PTHREAD_PROCESS_PRIVATE, 0))
{
TSK_DEBUG_ERROR("Failed to initialize the new semaphore.");
}
}
else
{
TSK_DEBUG_ERROR("Failed to create new mutex.");
}
return handle;
}
/**@ingroup tsk_semaphore_group
* Increment a semaphore. You should use @ref tsk_semaphore_decrement to decrement the semaphore.
* @param semaphore The semaphore to increment.
* @param handle The semaphore to increment.
* @retval Zero if succeed and otherwise the function returns -1 and sets errno to indicate the error.
* @sa @ref tsk_semaphore_decrement.
*/
int tsk_semaphore_increment(tsk_semaphore_t* semaphore)
int tsk_semaphore_increment(tsk_semaphore_handle_t* handle)
{
int ret = EINVAL;
if(semaphore)
if(handle)
{
if(ret = sem_post((sem_t*)semaphore->handle))
if(ret = sem_post((sem_t*)handle))
{
TSK_DEBUG_ERROR("sem_post function failed: %d", ret);
}
@ -69,18 +80,18 @@ int tsk_semaphore_increment(tsk_semaphore_t* semaphore)
/**@ingroup tsk_semaphore_group
* Decrement a semaphore. You should use @ref tsk_semaphore_increment to increment a semaphore.
* @param semaphore The semaphore to decrement.
* @param handle The semaphore to decrement.
* @retval Zero if succeed and otherwise the function returns -1 and sets errno to indicate the error.
* @sa @ref tsk_semaphore_increment.
*/
int tsk_semaphore_decrement(tsk_semaphore_t* semaphore)
int tsk_semaphore_decrement(tsk_semaphore_handle_t* handle)
{
int ret = EINVAL;
if(semaphore)
if(handle)
{
do
{
ret = sem_wait((sem_t*)semaphore->handle);
ret = sem_wait((sem_t*)handle);
}
while ( errno == EINTR );
}
@ -91,17 +102,16 @@ int tsk_semaphore_decrement(tsk_semaphore_t* semaphore)
}
/**@ingroup tsk_semaphore_group
* Internal function to free a semaphore previously created using @ref TSK_SEMAPHORE_CREATE. You MUST use @ref TSK_SEMAPHORE_SAFE_FREE to safely free a semaphore.
* @param semaphore The semaphore to free.
* @sa @ref TSK_SEMAPHORE_SAFE_FREE
* Destroy a semaphore previously created using @ref tsk_semaphore_create.
* @param handle The semaphore to free.
* @sa @ref tsk_semaphore_create
*/
void tsk_semaphore_free(tsk_semaphore_t** semaphore)
void tsk_semaphore_destroy(tsk_semaphore_handle_t** handle)
{
if(semaphore && *semaphore)
if(handle && *handle)
{
sem_destroy((sem_t*)(*semaphore)->handle);
TSK_FREE((*semaphore)->handle);
tsk_free2((void**)semaphore);
sem_destroy((sem_t*)*handle);
tsk_free2((void**)handle);
}
else
{

View File

@ -32,31 +32,11 @@
#include "tinySAK_config.h"
/**@def TSK_SEMAPHORE_CREATE
* Create and initialize a semaphore.
* You MUST use @ref TSK_SEMAPHORE_SAFE_FREE to free a semaphore.
* @param this The @ref tsk_semaphore_t object to create.
* @sa @ref TSK_SEMAPHORE_SAFE_FREE.
*/
#define TSK_SEMAPHORE_CREATE(this) TSK_XXX_CREATE2(this, semaphore)
/**@def TSK_SEMAPHORE_SAFE_FREE
* Safely free a semaphore previously created using @ref TSK_SEMAPHORE_CREATE.
* @param this The @ref tsk_semaphore_t object to free.
* @sa @ref TSK_SEMAPHORE_CREATE.
*/
#define TSK_SEMAPHORE_SAFE_FREE(this) TSK_XXX_SAFE_FREE2(this, semaphore)
typedef void tsk_semaphore_handle_t;
/** Pthread Semaphore.
*/
typedef struct tsk_semaphore_s
{
void* handle; /**< Handle pointing to the semaphore */
}
tsk_semaphore_t;
TINYSAK_API void tsk_semaphore_init(tsk_semaphore_t* semaphore);
TINYSAK_API int tsk_semaphore_increment(tsk_semaphore_t* semaphore);
TINYSAK_API int tsk_semaphore_decrement(tsk_semaphore_t* semaphore);
TINYSAK_API void tsk_semaphore_free(tsk_semaphore_t** semaphore);
TINYSAK_API tsk_semaphore_handle_t* tsk_semaphore_create();
TINYSAK_API int tsk_semaphore_increment(tsk_semaphore_handle_t* handle);
TINYSAK_API int tsk_semaphore_decrement(tsk_semaphore_handle_t* handle);
TINYSAK_API void tsk_semaphore_destroy(tsk_semaphore_handle_t** handle);
#endif /* _TINYSAK_SEMAPHORE_H_ */

View File

@ -33,7 +33,7 @@
#define LOOP 1
#define RUN_TEST_ALL 1
#define RUN_TEST_ALL 0
#define RUN_TEST_LISTS 0
#define RUN_TEST_HEAP 0
#define RUN_TEST_STRINGS 0
@ -41,6 +41,7 @@
#define RUN_TEST_MUTEX 0
#define RUN_TEST_CONDWAIT 0
#define RUN_TEST_SEMAPHORE 0
#define RUN_TEST_SAFEOBJECT 1
#if RUN_TEST_LISTS || RUN_TEST_ALL
#include "test_lists.h"
@ -70,6 +71,10 @@
#include "test_semaphore.h"
#endif
#if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL
#include "test_safeobject.h"
#endif
#ifdef _WIN32_WCE
int _tmain(int argc, _TCHAR* argv[])
#else
@ -127,6 +132,12 @@ int main()
printf("\n\n");
#endif
#if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL
/* safe object */
test_safeobject();
printf("\n\n");
#endif
}
getchar();

View File

@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\include\win32\pthread&quot;;&quot;$(DOUBANGO_HOME)\thirdparties\include\win32&quot;;&quot;$(SolutionDir)src&quot;"
AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\win32\include\pthread&quot;;&quot;$(DOUBANGO_HOME)\thirdparties\win32\include&quot;;&quot;$(SolutionDir)src&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -63,7 +63,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(OutDir)\tinySAK.lib &quot;$(DOUBANGO_HOME)\thirdparties\lib\win32\pthread\pthread.lib&quot;"
AdditionalDependencies="$(OutDir)\tinySAK.lib &quot;$(DOUBANGO_HOME)\thirdparties\win32\lib\pthread\pthread.lib&quot;"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
@ -217,6 +217,10 @@
RelativePath=".\test_mutex.h"
>
</File>
<File
RelativePath=".\test_safeobject.h"
>
</File>
<File
RelativePath=".\test_semaphore.h"
>

View File

@ -24,7 +24,7 @@
void *threadfunc_timed(void *parm)
{
tsk_condwait_t *condwait = (tsk_condwait_t *)parm;
tsk_condwait_handle_t *condwait = (tsk_condwait_handle_t *)parm;
int ret = 0;
ret = tsk_condwait_timedwait(condwait, 10);
@ -35,7 +35,7 @@ void *threadfunc_timed(void *parm)
void *threadfunc_infinite(void *parm)
{
tsk_condwait_t *condwait = (tsk_condwait_t *)parm;
tsk_condwait_handle_t *condwait = (tsk_condwait_handle_t *)parm;
int ret = 0;
ret = tsk_condwait_wait(condwait);
@ -46,7 +46,7 @@ void *threadfunc_infinite(void *parm)
void *threadfunc_onemore(void *parm)
{
tsk_condwait_t *condwait = (tsk_condwait_t *)parm;
tsk_condwait_handle_t *condwait = (tsk_condwait_handle_t *)parm;
int ret = 0;
ret = tsk_condwait_wait(condwait);
@ -60,14 +60,12 @@ void *threadfunc_onemore(void *parm)
/* Pthread condwait */
void test_condwait()
{
tsk_condwait_t *condwait;
tsk_condwait_handle_t *condwait = tsk_condwait_create();
int ret;
void* tid[3] = {0,0,0};
printf("test_condwait//\n");
TSK_CONDWAIT_CREATE(condwait);
tsk_thread_create(&tid[0], threadfunc_timed, condwait);
tsk_thread_create(&tid[1], threadfunc_infinite, condwait);
tsk_thread_create(&tid[2], threadfunc_onemore, condwait);
@ -82,7 +80,7 @@ void test_condwait()
tsk_thread_join(&tid[1]);
tsk_thread_join(&tid[2]);
TSK_CONDWAIT_SAFE_FREE(condwait);
tsk_condwait_destroy(&condwait);
}
#endif /* _TEST_CONDWAIT_H_ */

View File

@ -26,7 +26,7 @@ int mutex_count = 0;
void *threadfunc_mutex1(void *parm)
{
tsk_mutex_t *mutex = (tsk_mutex_t *)parm;
tsk_mutex_handle_t *mutex = (tsk_mutex_handle_t *)parm;
int ret = 0;
mutex_count++;
@ -38,7 +38,7 @@ void *threadfunc_mutex1(void *parm)
void *threadfunc_mutex2(void *parm)
{
tsk_mutex_t *mutex = (tsk_mutex_t *)parm;
tsk_mutex_handle_t *mutex = (tsk_mutex_handle_t *)parm;
int ret = 0;
mutex_count++;
@ -51,27 +51,28 @@ void *threadfunc_mutex2(void *parm)
/* Pthread mutex */
void test_mutex()
{
tsk_mutex_t *mutex = 0;
tsk_mutex_handle_t *mutex = tsk_mutex_create();
void* tid[2] = {0, 0};
int i;
printf("test_mutex//\n");
TSK_MUTEX_CREATE(mutex);
//assert(!tsk_mutex_lock(mutex));
tsk_thread_create(&tid[0], threadfunc_mutex1, mutex);
tsk_thread_create(&tid[1], threadfunc_mutex2, mutex);
/* VERY BAD */
while(mutex_count<2);
for(i=0;i<10000000;i++);
for(i=0;i<10000000000;i++);
assert(!tsk_mutex_unlock(mutex));
assert(!tsk_mutex_unlock(mutex));
tsk_thread_join(&tid[0]);
tsk_thread_join(&tid[1]);
TSK_MUTEX_SAFE_FREE(mutex);
tsk_mutex_destroy(&mutex);
}
#endif /* _TEST_MUTEX_H_ */

View File

@ -26,7 +26,7 @@ int sema_count = 0;
void *threadfunc_semaphore1(void *parm)
{
tsk_semaphore_t *semaphore = (tsk_semaphore_t *)parm;
tsk_semaphore_handle_t *semaphore = (tsk_semaphore_handle_t *)parm;
int ret = 0;
sema_count++;
@ -38,7 +38,7 @@ void *threadfunc_semaphore1(void *parm)
void *threadfunc_semaphore2(void *parm)
{
tsk_semaphore_t *semaphore = (tsk_semaphore_t *)parm;
tsk_semaphore_handle_t *semaphore = (tsk_semaphore_handle_t *)parm;
int ret = 0;
sema_count++;
@ -51,14 +51,12 @@ void *threadfunc_semaphore2(void *parm)
/* Pthread semaphore */
void test_semaphore()
{
tsk_semaphore_t *semaphore = 0;
tsk_semaphore_handle_t *semaphore = tsk_semaphore_create();
void* tid[2] = {0,0};
int i;
printf("test_semaphore//\n");
TSK_SEMAPHORE_CREATE(semaphore);
tsk_thread_create(&tid[0], threadfunc_semaphore1, semaphore);
tsk_thread_create(&tid[1], threadfunc_semaphore2, semaphore);
@ -72,7 +70,7 @@ void test_semaphore()
tsk_thread_join(&tid[0]);
tsk_thread_join(&tid[1]);
TSK_SEMAPHORE_SAFE_FREE(semaphore);
tsk_semaphore_destroy(&semaphore);
}
#endif /* _TEST_SEMAPHORE_H_ */

View File

@ -351,6 +351,10 @@
RelativePath=".\src\tsk.h"
>
</File>
<File
RelativePath=".\src\tsk_binaryutils.h"
>
</File>
<File
RelativePath=".\src\tsk_condwait.h"
>
@ -379,10 +383,22 @@
RelativePath=".\src\tsk_mutex.h"
>
</File>
<File
RelativePath=".\src\tsk_ppfcs16.h"
>
</File>
<File
RelativePath=".\src\tsk_safeobj.h"
>
</File>
<File
RelativePath=".\src\tsk_semaphore.h"
>
</File>
<File
RelativePath=".\src\tsk_sha1.h"
>
</File>
<File
RelativePath=".\src\tsk_string.h"
>
@ -413,6 +429,10 @@
RelativePath=".\src\tsk.c"
>
</File>
<File
RelativePath=".\src\tsk_binaryutils.c"
>
</File>
<File
RelativePath=".\src\tsk_condwait.c"
>
@ -437,10 +457,22 @@
RelativePath=".\src\tsk_mutex.c"
>
</File>
<File
RelativePath=".\src\tsk_ppfcs16.c"
>
</File>
<File
RelativePath=".\src\tsk_safeobj.c"
>
</File>
<File
RelativePath=".\src\tsk_semaphore.c"
>
</File>
<File
RelativePath=".\src\tsk_sha1.c"
>
</File>
<File
RelativePath=".\src\tsk_string.c"
>

1558
trunk/tinySIGCOMP/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,131 @@
at (32)
readonly (0)
:index pad (2)
:extra_length_bits pad (2)
:len_value pad (2)
:extra_dist_bits pad (2)
:dist_value pad (2)
at (42)
:req_feed_loc pad (1)
:req_feed_len pad (1)
:req_feed_field pad (12)
:hash_start pad (8)
at (64)
:byte_copy_left pad (2)
:byte_copy_right pad (2)
:input_bit_order pad (2)
:decompressed_ptr pad (2)
:length_table pad (116)
:distance_table pad (120)
:hash_len_loc pad (2)
:state_len_loc pad (2)
:ret_params_loc pad (1)
:sigcomp_version pad (1)
align (64)
readonly (1)
:initialize_memory
set (udvm_memory_size, 8192)
set (length_table_start, (((length_table - 4) / 4) + 16384))
set (length_table_mid, (length_table_start + 24))
set (dist_table_start, (distance_table / 4))
MULTILOAD (64, 122, circular_buffer, udvm_memory_size, 5,
circular_buffer,
0, 3, 0, 4, 0, 5,
0, 6, 0, 7, 0, 8,
0, 9, 0, 10, 1, 11,
1, 13, 1, 15, 1, 17,
2, 19, 2, 23, 2, 27,
2, 31, 3, 35, 3, 43,
3, 51, 3, 59, 4, 67,
4, 83, 4, 99, 4, 115,
5, 131, 5, 163, 5, 195,
5, 227, 0, 258,
0, 1, 0, 2, 0, 3,
0, 4, 1, 5, 1, 7,
2, 9, 2, 13, 3, 17,
3, 25, 4, 33, 4, 49,
5, 65, 5, 97, 6, 129,
6, 193, 7, 257, 7, 385,
8, 513, 8, 769, 9, 1025,
9, 1537, 10, 2049, 10, 3073,
11, 4097, 11, 6145, 12, 8193,
12, 12289, 13, 16385, 13, 24577)
; -- hash_len, state_len, params, version, dicts
INPUT-BYTES (6, hash_len_loc, !)
LOAD (66, $state_len_loc)
ADD(66, 64)
:decompress_sigcomp_msg
:start_decomp
INPUT-BITS (3, extra_length_bits, !)
:next_char
INPUT-HUFFMAN (index, end_of_msg, 4,
7, 0, 23, length_table_start,
1, 48, 191, 0,
0, 192, 199, length_table_mid,
1, 400, 511, 144)
COMPARE ($index, length_table_start, literal, end_of_msg,
length_distance)
:literal
set (index_lsb, (index + 1))
OUTPUT (index_lsb, 1)
COPY-LITERAL (index_lsb, 1, $decompressed_ptr)
JUMP (next_char)
:length_distance
; this is the length part
MULTIPLY ($index, 4)
COPY ($index, 4, extra_length_bits)
INPUT-BITS ($extra_length_bits, extra_length_bits, !)
ADD ($len_value, $extra_length_bits)
; this is the distance part
INPUT-HUFFMAN (index, !, 1, 5, 0, 31, dist_table_start)
MULTIPLY ($index, 4)
COPY ($index, 4, extra_dist_bits)
INPUT-BITS ($extra_dist_bits, extra_dist_bits, !)
ADD ($dist_value, $extra_dist_bits)
LOAD (index, $decompressed_ptr)
COPY-OFFSET ($dist_value, $len_value, $decompressed_ptr)
OUTPUT ($index, $len_value)
JUMP (next_char)
:end_of_msg
LOAD (req_feed_loc, 1158)
MULTILOAD (hash_start, 4, $state_len_loc, 64, decompress_sigcomp_msg, 6)
SHA-1 (hash_start, $hash_len_loc, req_feed_field)
END-MESSAGE (req_feed_loc, ret_params_loc, $state_len_loc, 64, decompress_sigcomp_msg, 6, 0)
readonly (0)
:circular_buffer

View File

@ -0,0 +1,144 @@
at (32)
readonly (0)
:index pad (2)
:extra_length_bits pad (2)
:len_value pad (2)
:extra_dist_bits pad (2)
:dist_value pad (2)
at (42)
:req_feed_loc pad (1)
:req_feed_len pad (1)
:req_feed_field pad (12)
:hash_start pad (8)
at (64)
:byte_copy_left pad (2)
:byte_copy_right pad (2)
:input_bit_order pad (2)
:decompressed_ptr pad (2)
:length_table pad (116)
:distance_table pad (120)
:hash_len_loc pad (2)
:state_len_loc pad (2)
:ret_params_loc pad (1)
:sigcomp_version pad (1)
:dicts pad (2)
align (64)
readonly (1)
:initialize_memory
set (udvm_memory_size, 8192)
set (length_table_start, (((length_table - 4) / 4) + 16384))
set (length_table_mid, (length_table_start + 24))
set (dist_table_start, (distance_table / 4))
MULTILOAD (64, 122, circular_buffer, udvm_memory_size, 5,
circular_buffer,
0, 3, 0, 4, 0, 5,
0, 6, 0, 7, 0, 8,
0, 9, 0, 10, 1, 11,
1, 13, 1, 15, 1, 17,
2, 19, 2, 23, 2, 27,
2, 31, 3, 35, 3, 43,
3, 51, 3, 59, 4, 67,
4, 83, 4, 99, 4, 115,
5, 131, 5, 163, 5, 195,
5, 227, 0, 258,
0, 1, 0, 2, 0, 3,
0, 4, 1, 5, 1, 7,
2, 9, 2, 13, 3, 17,
3, 25, 4, 33, 4, 49,
5, 65, 5, 97, 6, 129,
6, 193, 7, 257, 7, 385,
8, 513, 8, 769, 9, 1025,
9, 1537, 10, 2049, 10, 3073,
11, 4097, 11, 6145, 12, 8193,
12, 12289, 13, 16385, 13, 24577)
; -- hash_len, state_len, params, version, dicts
INPUT-BYTES (8, hash_len_loc, !)
LOAD (66, $state_len_loc)
ADD(66, 64)
:decompress_sigcomp_msg
; -- DICTIONARIES
SWITCH (4, $dicts, sip, pres, sip_pres, start_decomp)
:sip
MULTILOAD (dicts, 4, 1787, 58631, 57317, 58880)
JUMP (start_decomp)
:pres
MULTILOAD (dicts, 4, 1753, 16937, 32011, 45824)
JUMP (start_decomp)
:sip_pres
MULTILOAD (dicts, 7, 1787, 58631, 57317, 58886, 55618, 10621, 2995)
:start_decomp
INPUT-BITS (3, extra_length_bits, !)
:next_char
INPUT-HUFFMAN (index, end_of_msg, 4,
7, 0, 23, length_table_start,
1, 48, 191, 0,
0, 192, 199, length_table_mid,
1, 400, 511, 144)
COMPARE ($index, length_table_start, literal, end_of_msg,
length_distance)
:literal
set (index_lsb, (index + 1))
OUTPUT (index_lsb, 1)
COPY-LITERAL (index_lsb, 1, $decompressed_ptr)
JUMP (next_char)
:length_distance
; this is the length part
MULTIPLY ($index, 4)
COPY ($index, 4, extra_length_bits)
INPUT-BITS ($extra_length_bits, extra_length_bits, !)
ADD ($len_value, $extra_length_bits)
; this is the distance part
INPUT-HUFFMAN (index, !, 1, 5, 0, 31, dist_table_start)
MULTIPLY ($index, 4)
COPY ($index, 4, extra_dist_bits)
INPUT-BITS ($extra_dist_bits, extra_dist_bits, !)
ADD ($dist_value, $extra_dist_bits)
LOAD (index, $decompressed_ptr)
COPY-OFFSET ($dist_value, $len_value, $decompressed_ptr)
OUTPUT ($index, $len_value)
JUMP (next_char)
:end_of_msg
LOAD (req_feed_loc, 1158)
MULTILOAD (hash_start, 4, $state_len_loc, 64, decompress_sigcomp_msg, 6)
SHA-1 (hash_start, $hash_len_loc, req_feed_field)
END-MESSAGE (req_feed_loc, ret_params_loc, $state_len_loc, 64, decompress_sigcomp_msg, 6, 0)
readonly (0)
:circular_buffer

View File

@ -0,0 +1,27 @@
; RFC 4896
at (0)
:udvm_memory_size pad (2)
:cycles_per_bit pad (2)
:sigcomp_version pad (2)
:partial_state_id_length pad (2)
:state_length pad (2)
:reserved pad (2)
at (64)
:byte_copy_left pad (2)
:byte_copy_right pad (2)
:input_bit_order pad (2)
:stack_location pad (2)
; Simple loop
; Read a byte
; Output a byte
; Until there are no more bytes!
at (128)
:start
INPUT-BYTES (1, byte_copy_left, end)
OUTPUT (byte_copy_left, 1)
JUMP (start)
:end
END-MESSAGE (0,0,0,0,0,0,0)

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

View File

@ -0,0 +1,151 @@
#if !HAS_ZLIB
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
#define BASE 65521UL /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
/* use NO_DIVIDE if your processor does not do division in hardware */
#ifdef NO_DIVIDE
# define MOD(a) \
do { \
if (a >= (BASE << 16)) a -= (BASE << 16); \
if (a >= (BASE << 15)) a -= (BASE << 15); \
if (a >= (BASE << 14)) a -= (BASE << 14); \
if (a >= (BASE << 13)) a -= (BASE << 13); \
if (a >= (BASE << 12)) a -= (BASE << 12); \
if (a >= (BASE << 11)) a -= (BASE << 11); \
if (a >= (BASE << 10)) a -= (BASE << 10); \
if (a >= (BASE << 9)) a -= (BASE << 9); \
if (a >= (BASE << 8)) a -= (BASE << 8); \
if (a >= (BASE << 7)) a -= (BASE << 7); \
if (a >= (BASE << 6)) a -= (BASE << 6); \
if (a >= (BASE << 5)) a -= (BASE << 5); \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
# define MOD4(a) \
do { \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
#else
# define MOD(a) a %= BASE
# define MOD4(a) a %= BASE
#endif
/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
uLong adler;
const Bytef *buf;
uInt len;
{
unsigned long sum2;
unsigned n;
/* split Adler-32 into component sums */
sum2 = (adler >> 16) & 0xffff;
adler &= 0xffff;
/* in case user likes doing a byte at a time, keep it fast */
if (len == 1) {
adler += buf[0];
if (adler >= BASE)
adler -= BASE;
sum2 += adler;
if (sum2 >= BASE)
sum2 -= BASE;
return adler | (sum2 << 16);
}
/* initial Adler-32 value (deferred check for len == 1 speed) */
if (buf == Z_NULL)
return 1L;
/* in case short lengths are provided, keep it somewhat fast */
if (len < 16) {
while (len--) {
adler += *buf++;
sum2 += adler;
}
if (adler >= BASE)
adler -= BASE;
MOD4(sum2); /* only added so many BASE's */
return adler | (sum2 << 16);
}
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
n = NMAX / 16; /* NMAX is divisible by 16 */
do {
DO16(buf); /* 16 sums unrolled */
buf += 16;
} while (--n);
MOD(adler);
MOD(sum2);
}
/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
}
while (len--) {
adler += *buf++;
sum2 += adler;
}
MOD(adler);
MOD(sum2);
}
/* return recombined sums */
return adler | (sum2 << 16);
}
/* ========================================================================= */
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off_t len2;
{
unsigned long sum1;
unsigned long sum2;
unsigned rem;
/* the derivation of this formula is left as an exercise for the reader */
rem = (unsigned)(len2 % BASE);
sum1 = adler1 & 0xffff;
sum2 = rem * sum1;
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 > BASE) sum1 -= BASE;
if (sum1 > BASE) sum1 -= BASE;
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
if (sum2 > BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
#endif // HAS_ZLIB

View File

@ -0,0 +1,81 @@
#if !HAS_ZLIB
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
/* ===========================================================================
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least 0.1% larger than sourceLen plus
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
#endif
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
deflateEnd(&stream);
return err == Z_OK ? Z_BUF_ERROR : err;
}
*destLen = stream.total_out;
err = deflateEnd(&stream);
return err;
}
/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_BEST_SPEED);
}
/* ===========================================================================
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
uLong ZEXPORT compressBound (sourceLen)
uLong sourceLen;
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
}
#endif // HAS_ZLIB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,334 @@
#if !HAS_ZLIB
/* deflate.h -- internal compression state
* Copyright (C) 1995-2004 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id$ */
#ifndef DEFLATE_H
#define DEFLATE_H
#include "zutil.h"
/* define NO_GZIP when compiling if you want to disable gzip header and
trailer creation by deflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip encoding
should be left enabled. */
#ifndef NO_GZIP
# define GZIP
#endif
/* ===========================================================================
* Internal compression state.
*/
#define LENGTH_CODES 29
/* number of length codes, not counting the special END_BLOCK code */
#define LITERALS 256
/* number of literal bytes 0..255 */
#define L_CODES (LITERALS+1+LENGTH_CODES)
/* number of Literal or Length codes, including the END_BLOCK code */
#define D_CODES 30
/* number of distance codes */
#define BL_CODES 19
/* number of codes used to transfer the bit lengths */
#define HEAP_SIZE (2*L_CODES+1)
/* maximum heap size */
#define MAX_BITS 15
/* All codes must not exceed MAX_BITS bits */
#define INIT_STATE 42
#define EXTRA_STATE 69
#define NAME_STATE 73
#define COMMENT_STATE 91
#define HCRC_STATE 103
#define BUSY_STATE 113
#define FINISH_STATE 666
/* Stream status */
/* Data structure describing a single value and its code string. */
typedef struct ct_data_s {
union {
ush freq; /* frequency count */
ush code; /* bit string */
} fc;
union {
ush dad; /* father node in Huffman tree */
ush len; /* length of bit string */
} dl;
} FAR ct_data;
#define Freq fc.freq
#define Code fc.code
#define Dad dl.dad
#define Len dl.len
typedef struct static_tree_desc_s static_tree_desc;
typedef struct tree_desc_s {
ct_data *dyn_tree; /* the dynamic tree */
int max_code; /* largest code with non zero frequency */
static_tree_desc *stat_desc; /* the corresponding static tree */
} FAR tree_desc;
typedef ush Pos;
typedef Pos FAR Posf;
typedef unsigned IPos;
/* A Pos is an index in the character window. We use short instead of int to
* save space in the various tables. IPos is used only for parameter passing.
*/
typedef struct internal_state {
z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */
Bytef *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */
uInt pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp gzhead; /* gzip header information to write */
uInt gzindex; /* where in extra, name, or comment */
Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
/* used by deflate.c: */
uInt w_size; /* LZ77 window size (32K by default) */
uInt w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */
Bytef *window;
/* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize
* bytes. With this organization, matches are limited to a distance of
* wSize-MAX_MATCH bytes, but this ensures that IO is always
* performed with a length multiple of the block size. Also, it limits
* the window size to 64K, which is quite useful on MSDOS.
* To do: use the user input buffer as sliding window.
*/
ulg window_size;
/* Actual size of window: 2*wSize, except when the user input buffer
* is directly used as sliding window.
*/
Posf *prev;
/* Link to older string with same hash index. To limit the size of this
* array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K.
*/
Posf *head; /* Heads of the hash chains or NIL. */
uInt ins_h; /* hash index of string to be inserted */
uInt hash_size; /* number of elements in hash table */
uInt hash_bits; /* log2(hash_size) */
uInt hash_mask; /* hash_size-1 */
uInt hash_shift;
/* Number of bits by which ins_h must be shifted at each input
* step. It must be such that after MIN_MATCH steps, the oldest
* byte no longer takes part in the hash key, that is:
* hash_shift * MIN_MATCH >= hash_bits
*/
long block_start;
/* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards.
*/
uInt match_length; /* length of best match */
IPos prev_match; /* previous match */
int match_available; /* set if previous match exists */
uInt strstart; /* start of string to insert */
uInt match_start; /* start of matching string */
uInt lookahead; /* number of valid bytes ahead in window */
uInt prev_length;
/* Length of the best match at previous step. Matches not greater than this
* are discarded. This is used in the lazy match evaluation.
*/
uInt max_chain_length;
/* To speed up deflation, hash chains are never searched beyond this
* length. A higher limit improves compression ratio but degrades the
* speed.
*/
uInt max_lazy_match;
/* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression
* levels >= 4.
*/
# define max_insert_length max_lazy_match
/* Insert new strings in the hash table only if the match length is not
* greater than this length. This saves time but degrades compression.
* max_insert_length is used only for compression levels <= 3.
*/
int level; /* compression level (1..9) */
int strategy; /* favor or force Huffman coding*/
uInt good_match;
/* Use a faster search when the previous match is longer than this */
int nice_match; /* Stop searching when current match exceeds this */
/* used by trees.c: */
/* Didn't use ct_data typedef below to supress compiler warning */
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
struct tree_desc_s l_desc; /* desc. for literal tree */
struct tree_desc_s d_desc; /* desc. for distance tree */
struct tree_desc_s bl_desc; /* desc. for bit length tree */
ush bl_count[MAX_BITS+1];
/* number of codes at each bit length for an optimal tree */
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
int heap_len; /* number of elements in the heap */
int heap_max; /* element of largest frequency */
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
* The same heap array is used to build all trees.
*/
uch depth[2*L_CODES+1];
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
uchf *l_buf; /* buffer for literals or lengths */
uInt lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for
* limiting lit_bufsize to 64K:
* - frequencies can be kept in 16 bit counters
* - if compression is not successful for the first block, all input
* data is still in the window so we can still emit a stored block even
* when input comes from standard input. (This can also be done for
* all blocks if lit_bufsize is not greater than 32K.)
* - if compression is not successful for a file smaller than 64K, we can
* even emit a stored file instead of a stored block (saving 5 bytes).
* This is applicable only for zip (not gzip or zlib).
* - creating new Huffman trees less frequently may not provide fast
* adaptation to changes in the input data statistics. (Take for
* example a binary file with poorly compressible code followed by
* a highly compressible string table.) Smaller buffer sizes give
* fast adaptation but have of course the overhead of transmitting
* trees more frequently.
* - I can't count above 4
*/
uInt last_lit; /* running index in l_buf */
ushf *d_buf;
/* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag
* array would be necessary.
*/
ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */
uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif
ush bi_buf;
/* Output buffer. bits are inserted starting at the bottom (least
* significant bits).
*/
int bi_valid;
/* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero.
*/
} FAR deflate_state;
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
/* Minimum amount of lookahead, except at the end of the input file.
* See deflate.c for comments about the MIN_MATCH+1.
*/
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
/* In order to simplify the code, particularly on 16 bit machines, match
* distances are limited to MAX_DIST instead of WSIZE.
*/
/* in trees.c */
void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
#define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
/* Mapping from a distance to a distance code. dist is the distance - 1 and
* must not have side effects. _dist_code[256] and _dist_code[257] are never
* used.
*/
#ifndef DEBUG
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
extern uch _length_code[];
extern uch _dist_code[];
#else
extern const uch _length_code[];
extern const uch _dist_code[];
#endif
# define _tr_tally_lit(s, c, flush) \
{ uch cc = (c); \
s->d_buf[s->last_lit] = 0; \
s->l_buf[s->last_lit++] = cc; \
s->dyn_ltree[cc].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
# define _tr_tally_dist(s, distance, length, flush) \
{ uch len = (length); \
ush dist = (distance); \
s->d_buf[s->last_lit] = dist; \
s->l_buf[s->last_lit++] = len; \
dist--; \
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
s->dyn_dtree[d_code(dist)].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
#else
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
# define _tr_tally_dist(s, distance, length, flush) \
flush = _tr_tally(s, distance, length)
#endif
#endif /* DEFLATE_H */
#endif // HAS_ZLIB

View File

@ -0,0 +1,103 @@
/*
* 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.c
* @brief SIGCOMP (RFC 3320) Implementation for 2.5G and 3G cellular networks.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tcomp.h"
/** @mainpage TinySIGCOMP API Overview
*
* This file is an overview of TinySIGCOMP API.
*
* TinySIGCOMP is a tiny but fully featured SIGCOMP implementation for 2.5G, 3G and 4G cellular networks. This library is also used in Doubango project to provide SIGCOMP
* support for 3GPP IMS and OMA networks.
* This API is designed to efficiently work on embedded systems whith limited memory and low computing power.
*
* As many operators have begun to commercially deploy IMS, the relevance of using SigComp to lower bandwidth usage will come quickly.
* In my own opinion I think that most operators (especially those using RCS) will question how to reduce SIP signaling (registration, billing, presence, messaging )
* bandwidth usage (who will pay bits?).
* These questions will especially concern using SIP (or all other text-based protocols) in wireless handsets as part of 2.5G, 3G and 4G cellular networks.
*
* SigComp stands for Signaling Compression and has been defined in <a href="http://www.ietf.org/rfc/rfc3320.txt">RFC 3320</a> by the Internet Engineering Task Force (IETF) ROHC working group.
*
* @image html SigComp_Architecture.png "SigComp Architecture (From wikimedia)"
*
* Many application protocols used for multimedia communications are text-based and engineered for bandwidth rich links. As a result the messages have not been optimized in
* terms of size. For example, typical IMS/SIP messages range from a few hundred bytes up to two thousand bytes or more. For this reason, SIGCOMP is mandatory for
* 3GPP IMS netwoks and <a href="http://en.wikipedia.org/wiki/Push_to_Talk_over_Cellular">PoC systems</a>.
*
* SIGCOMP could also be useful for RCS (Rich Communication Suite) networks because of the size of the SIP packets (more than three thousand bytes for presence publication).
* Using SIGCOMP in IMS/RCS context will reduce the round-trip over slow radio links.
*
* @par Supported OS
*
* Windows Xp/Vista (Visual Studio 2005 or Mingw32)
* Windows Mobile 5 and later (Visual Studio 2005 or Mingw32ce/cegcc toolchain)
* Symbian S60 (Carbide.c++ v2.0 with S60_3rd_FP2_SDK_v1.1)
* Google Android
* All Linux, FreeBSD, ... (GCC 4.x)
*
*
* @par FEATURES
*
* The goal of this project is to provide a SigComp framework which:
*
* - Could be used as an external API or Framework
* - Highly portable (Coded in C/C++ without any external dependencies)
* - Easily configurable (memory usage, priorities in static dictionaries, stateful/stateless modes, dynamic/static/shared compression types )
* - Easy to integrate with any existing SIP/IMS stack, Proxy-CSCF, PoC client
* - Allow to easily plug your own compressor (DEFLATE RFC 1951- will be the default)
* -
* - Robust
* - Efficiently run on mobile handsets (small footprint)
* - Use small memory (UDVM decompression)
* - Run fast without high CPU usage
* - Supports both TCP and UDP compression modes
* - Thread-safe
*
* @par COMPLIANCE
*
* - <a href="http://www.ietf.org/rfc/rfc3320.txt">RFC 3320</a>: Signaling Compression (SigComp)
* - <a href="http://www.ietf.org/rfc/rfc3321.txt">RFC 3321</a>: Signaling Compression (SigComp) - Extended Operations
* - <a href="http://www.ietf.org/rfc/rfc3485.txt">RFC 3485</a>: The Session Initiation Protocol (SIP) and Session Description Protocol (SDP) Static Dictionary for Signaling Compression (SigComp)
* - <a href="http://www.ietf.org/rfc/rfc4077.txt">RFC 4077</a>: A Negative Acknowledgement Mechanism for Signaling Compression
* - <a href="http://www.ietf.org/rfc/rfc4464.txt">RFC 4464</a>: Signaling Compression (SigComp) Users' Guide
* - <a href="http://www.ietf.org/rfc/rfc4465.txt">RFC 4465</a>: Signaling Compression (SigComp) Torture Tests
* - <a href="http://www.ietf.org/rfc/rfc4896.txt">RFC 4896</a>: Signaling Compression (SigComp) Corrections and Clarifications
* - <a href="http://www.ietf.org/rfc/rfc5049.txt">RFC 5049</a>: Applying Signaling Compression (SigComp) to the Session Initiation Protocol (SIP)
* - <a href="http://www.ietf.org/rfc/rfc5112.txt">RFC 5112</a>: The Presence-Specific Static Dictionary for Signaling Compression (Sigcomp)
* - <a href="http://www.ietf.org/rfc/rfc1662.txt">RFC 1662</a>: PPP in HDLC-like Framing
* - <a href="http://www.ietf.org/rfc/rfc1951.txt">RFC 1951</a>: DEFLATE Compressed Data Format Specification version
* - <a href="http://www.ietf.org/rfc/rfc3174.txt">RFC 3174</a>: US Secure Hash Algorithm 1 (SHA1)
* - 3GPP TR23.979 Annex C: Required SigComp performance
*
* @par Getting Started
*
*/
/**@defgroup tcomp_group SIGCOMP
*/

View File

@ -0,0 +1,37 @@
/*
* 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.h
* @brief SIGCOMP (RFC 3320) Implementation for 2.5G, 3G and 4G cellular networks.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TINYSIGCOMPP_TCOMP_H_
#define _TINYSIGCOMPP_TCOMP_H_
#include "tinysigcomp_config.h"
#endif /* _TINYSIGCOMPP_TCOMP_H_ */

View File

@ -0,0 +1,625 @@
/*
* 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_buffer.c
* @brief SigComp Buffer
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tcomp_buffer.h"
#include "tsk_binaryutils.h"
#include "tsk_memory.h"
#include "tsk_debug.h"
#include <string.h>
/**@defgroup tcomp_buffer_group SigComp Buffer
*/
/**@typedef tcomp_buffer_t
* SigComp buffer.
*/
typedef struct tcomp_buffer_s
{
size_t size; /**< The size of the buffer */
uint8_t* lpbuffer; /**< Pointer to the buffer */
size_t index_bytes; /**< Bytes (8bit size) cursor */
size_t index_bits; /**< Bits (1bit size) cursor */
unsigned owner:1; /**< If we are the owner of the buffer or not (external buffer) */
uint8_t P_BIT; /**< P-BIT controller. */
}
tcomp_buffer_t;
/**@ingroup tcomp_buffer_group
* Create SigComp buffer handle. You MUST use @ref tcomp_buffer_destroy to free the handle.
* @param data Reference to an external buffer
* @param len The length of the external buffer
* @retval Returns a new buffer handle.
* @sa @ref tcomp_buffer_destroy.
*/
tcomp_buffer_handle_t* _tcomp_buffer_create(const void* data, size_t len)
{
tcomp_buffer_t* buffer = tsk_calloc2(1, sizeof(tcomp_buffer_t));
if(buffer)
{
buffer->owner = 1;
/*The P-bit controls the order in which bits are passed from the
dispatcher to the INPUT instructions*/
buffer->P_BIT = TCOMP_P_BIT_MSB_TO_LSB;
if(data && len)
{
tcomp_buffer_appendBuff(buffer, data, len);
}
}
else TSK_DEBUG_ERROR("Cannot create new SigComp handle");
return ((tcomp_buffer_handle_t*)buffer);
}
/**@ingroup tcomp_buffer_group
* Compare two sigomp buffers.
* @param handle1 First handle to compare.
* @param handle2 Second handle to compare.
* @retval 1 if the two handles are equals and 0 otherwise.
*/
int tcomp_buffer_equals(const tcomp_buffer_handle_t* handle1, const tcomp_buffer_handle_t* handle2)
{
if( tcomp_buffer_getSize(handle1) == tcomp_buffer_getSize(handle2) )
{
return tcomp_buffer_startsWith(handle1, handle2);
}
return 0;
}
/**@ingroup tcomp_buffer_group
* Checks if the first internal buffer starts with the second handle internal buffer.
* @param handle1 First handle
* @param handle2 Second handle
* @retval Returns 1 if the first internal buffer starts with the second handle internal buffer and 0 otherwise.
*/
int tcomp_buffer_startsWith(const tcomp_buffer_handle_t* handle1, const tcomp_buffer_handle_t* handle2) /*const*/
{
size_t i;
tcomp_buffer_t* buffer1 = (tcomp_buffer_t*)handle1;
tcomp_buffer_t* buffer2 = (tcomp_buffer_t*)handle2;
if(buffer1->size < buffer2->size) return 0;
for(i = 0; i< buffer2->size; i++)
{
if(buffer1->lpbuffer[i] != buffer2->lpbuffer[i])
{
return 0;
}
}
return 1;
}
/**@ingroup tcomp_buffer_group
* Get a readonly pointer to the internal buffer.
* @param handle The handle for which to get the internal buffer.
* @param position Position pointer
* @retval Pointer to the internal buffer.
*/
const uint8_t* tcomp_buffer_getReadOnlyBufferAtPos(const tcomp_buffer_handle_t* handle, size_t position)/*const*/
{
if(handle)
{
return (((tcomp_buffer_t*)handle)->lpbuffer + position);
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Get a read/write pointer to the internal buffer.
* @param handle The handle for which to get the internal buffer.
* @param position Position pointer
* @retval Pointer to the internal buffer.
*/
uint8_t* tcomp_buffer_getBufferAtPos(const tcomp_buffer_handle_t* handle, size_t position)
{
if(handle)
{
return (((tcomp_buffer_t*)handle)->lpbuffer + position);
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Gets the internal buffer size
* @retval The size of the internal buffer
*/
const size_t tcomp_buffer_getSize(const tcomp_buffer_handle_t* handle) /*const*/
{
if(handle)
{
return ((tcomp_buffer_t*)handle)->size;
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Gets the remainning bits.
* @param handle The handle for which to get the remaining bits.
*/
const size_t tcomp_buffer_getRemainingBits(const tcomp_buffer_handle_t* handle) /*const*/
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
size_t result = ((buffer->size * 8) - ((buffer->index_bytes * 8) + buffer->index_bits));
return (result < 0) ? 0: result;
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Read @a size bytes.
* @param handle The handle for which to read bytes.
* @param length Number of bytes to read.
* @retval Pointer to the resulting buffer.
*/
uint8_t* tcomp_buffer_readBytes(tcomp_buffer_handle_t* handle, size_t length)
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
size_t old_index;
if((buffer->index_bytes + length) > (buffer->size))
{
return 0;
}
old_index = buffer->index_bytes;
buffer->index_bytes += length;
return tcomp_buffer_getBufferAtPos(handle, old_index);
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Read the internal buffer from LSB to MSB as per RFC 3320 subclause 8.2.
* @param handle The SigComp handle holding the internal buffer to read.
* @param length The length of the buffer to read.
* @retval All bits as a 2-bytes integer value
*/
uint16_t tcomp_buffer_readLsbToMsb(tcomp_buffer_handle_t* handle, size_t length)
{
// UDV Memory is always MSB first
// MSB <-- LSB
// FIXME: use mask
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
uint8_t pos = 0;
char* end;
uint16_t result_val = 0;
char result_str[16]; memset(result_str, 0, 16);
while(pos < length)
{
result_str[pos++] = (buffer->lpbuffer[buffer->index_bytes]
&(1 << (buffer->index_bits))) ? '1' : '0';
if(++buffer->index_bits == 8)
{
buffer->index_bytes++;
buffer->index_bits = 0;
}
}
end = (result_str+length);
result_val = (uint16_t)strtol(result_str, &end, 2);
return result_val;
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Read the internal buffer from MSB to LSB as per RFC 3320 subclause 8.2.
* @param handle The SigComp handle holding the internal buffer to read.
* @param length The length of the buffer to read.
* @retval All bits as a 2-bytes integer value
*/
uint16_t tcomp_buffer_readMsbToLsb(tcomp_buffer_handle_t* handle, size_t length)
{
// UDV Memory is always MSB first
// MSB --> LSB
// FIXME: use mask
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
uint8_t pos = 0;
char* end;
uint16_t result_val = 0;
char result_str[16]; memset(result_str, 0, 16);
while(pos < length)
{
result_str[pos++] = (buffer->lpbuffer[buffer->index_bytes]
&(128 >> (buffer->index_bits))) ? '1' : '0';
if(++buffer->index_bits == 8)
{
buffer->index_bytes++;
buffer->index_bits = 0;
}
}
end = (result_str + length);
result_val = (uint16_t)strtol(result_str, &end, 2);
return result_val;
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Discards bits as per RFC 3320 subclause 8.2.
* @param handle SigComp handle holding the internal buffer.
*/
void tcomp_buffer_discardBits(tcomp_buffer_handle_t* handle)
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
if(buffer->index_bits)
{
buffer->index_bits=0;
buffer->index_bytes++;
}
}
else TSK_DEBUG_ERROR("Null SigComp handle");
}
/**@ingroup tcomp_buffer_group
* Discards last bytes as per RFC 3320 subclause 8.2.
* @param handle SigComp handle holding the internal buffer.
* @param count The number of bytes to discard.
*/
void tcomp_buffer_discardLastBytes(tcomp_buffer_handle_t* handle, uint16_t count)
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
if(buffer->size > count)
{
buffer->size -= count;
}
else
{
tcomp_buffer_freeBuff(handle);
}
}
else TSK_DEBUG_ERROR("Null SigComp handle");
}
/**@ingroup tcomp_buffer_group
* Alloc the internal buffer.
* @param handle SigComp handle holding the internal buffer to alloc.
* @param size Number of bytes to allocate.
*/
void tcomp_buffer_allocBuff(tcomp_buffer_handle_t* handle, size_t size)
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
if(!buffer->owner)
{
TSK_DEBUG_ERROR("The SigComp is not the owner of the internal buffer to alloc.");
return;
}
if(!size)
{
TSK_DEBUG_WARN("Cannot allocate zero bytes.");
return;
}
tsk_free2(&(buffer->lpbuffer));
buffer->index_bits = buffer->index_bytes = 0;
buffer->lpbuffer = (uint8_t*) tsk_calloc2(1, size );
buffer->size = size;
}
else TSK_DEBUG_ERROR("Null SigComp handle");
}
/**@ingroup tcomp_buffer_group
* Add a buffer as a reference (not owned).
* @param handle SigComp handle holding the internal buffer.
* @param externalBuff THe external buffer to reference.
* @param size The size of the external buffer.
*/
void tcomp_buffer_referenceBuff(tcomp_buffer_handle_t* handle, uint8_t* externalBuff, size_t size)
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
if(buffer->size && buffer->owner)
{
TSK_DEBUG_ERROR("The SigComp handle already hold an internal buffer.");
return;
}
buffer->size = size;
buffer->lpbuffer = externalBuff;
buffer->index_bytes = 0;
buffer->index_bits = 0;
buffer->owner = 0;
}
else TSK_DEBUG_ERROR("Null SigComp handle");
}
/**@ingroup tcomp_buffer_group
* Append data to our internal buffer.
* @param handle The handle to the SigComp buffer.
* @param data Data to append to our internal buffer.
* @param size The size of the data
* @retval 1 if succeed and 0 otherwise.
*/
int tcomp_buffer_appendBuff(tcomp_buffer_handle_t* handle, const void* data, size_t size)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
size_t oldSize = buffer->size;
size_t newSize = (oldSize + size);
{
// realloc buffer
if(!buffer->size){
buffer->lpbuffer = (uint8_t*)tsk_malloc2(newSize);
}
else{
buffer->lpbuffer = (uint8_t*)tsk_realloc2(buffer->lpbuffer, newSize);
}
}
if(!buffer->lpbuffer) return 0;
if(data)
{
memmove((buffer->lpbuffer+oldSize), data, size);
}
else
{
memset((buffer->lpbuffer+oldSize), 0, size);
}
buffer->size = newSize;
return 1;
}
/**@ingroup tcomp_buffer_group
* Remove bytes from the internal buffer.
* @param handle SigComp handle holding the internal buffer from which to remove bytes.
* @param pos The starting position from which to start removing bytes
* @param size The number of bytes to remove
* @retval 1 if succeed an zero otherwise.
*/
int tcomp_buffer_removeBuff(tcomp_buffer_handle_t* handle, size_t pos, size_t size)
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
size_t oldSize, newSize;
if(((pos + size) > buffer->size)) size = (buffer->size - pos);
memmove((buffer->lpbuffer + pos), (buffer->lpbuffer + pos + size), (buffer->size - (pos + size)));
oldSize = buffer->size;
newSize = (oldSize - size);
{
if(!(buffer->size))
{
buffer->lpbuffer = (uint8_t*)tsk_calloc2(1, newSize);
}
else
{
buffer->lpbuffer = (uint8_t*)tsk_realloc2(buffer->lpbuffer, newSize);
}
}
if(buffer->lpbuffer)
{
buffer->size = newSize;
return 1;
}
return 0;
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Free the internal buffer.
* @param handle SigComp handle holding the internal buffer to free.
*/
void tcomp_buffer_freeBuff(tcomp_buffer_handle_t* handle)
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
if(buffer->lpbuffer && buffer->size && buffer->owner)
{
tsk_free2(&(buffer->lpbuffer));
}
buffer->size = buffer->index_bytes = buffer->index_bits = 0;
}
else TSK_DEBUG_ERROR("Null SigComp handle");
}
/**@ingroup tcomp_buffer_group
* Gets the bytes cursor position.
* @param handle SigComp handle holding the internal buffer.
* @retval The cursor position.
*/
size_t* tcomp_buffer_getIndexBytes(const tcomp_buffer_handle_t* handle)
{
if(handle)
{
return &(((tcomp_buffer_t*)handle)->index_bytes);
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Gets the bits cursor position.
* @param handle SigComp handle holding the internal buffer.
* @retval The cursor position.
*/
size_t* tcomp_buffer_getIndexBits(const tcomp_buffer_handle_t* handle)
{
if(handle)
{
return &(((tcomp_buffer_t*)handle)->index_bits);
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Gets the P-bit controller value.
* The P-bit controls the order in which bits are passed from the dispatcher to the INPUT instructions. If set to 0, it indicates that
* the bits within an individual byte are passed to the INPUT instructions in MSB to LSB order. If it is set to 1, the bits are
* passed in LSB to MSB order.
* @param handle SigComp handle holding the internal buffer.
* @retval The P-Bit value.
*/
uint8_t* tcomp_buffer_getP_BIT(const tcomp_buffer_handle_t* handle)
{
if(handle)
{
return &(((tcomp_buffer_t*)handle)->P_BIT);
}
else TSK_DEBUG_ERROR("Null SigComp handle");
return 0;
}
/**@ingroup tcomp_buffer_group
* Print the internal buffer.
* @param handle SigComp handle holding the internal buffer to print.
* @param size The number of bytes to print.
*/
void tcomp_buffer_nprint(tcomp_buffer_handle_t* handle, size_t size)
{
#if defined(_DEBUG) || defined(DEBUG)
if(handle)
{
size_t i, size_to_print;
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
size_to_print = (size<0) ? buffer->size : size;
if( !size_to_print || !buffer->lpbuffer) return;
for(i = 0; i < size_to_print; i+=2)
{
char s[10];
uint16_t value;
memset(s, 0, 10);
if((i+1) == size_to_print)
{
// last 2-byte lay in 1byte
value = buffer->lpbuffer[i];
#if 0
sprintf_s(s, 10, i?"%0.2x":"0x%0.2x", value);
#else
sprintf(s, i ? "%0.2x" : "0x%0.2x", value);
#endif
}
else
{
uint8_t *b_ptr = tcomp_buffer_getBufferAtPos(handle, i);
value = TSK_BINARY_GET_2BYTES(b_ptr);
#if 0
sprintf_s(s, 10, i?"%0.4x":"0x%0.4x", value);
#else
sprintf(s, i?"%0.4x":"0x%0.4x", value);
#endif
}
printf("%s ", s);
}
printf("\n\n");
}
else TSK_DEBUG_ERROR("Null SigComp handle");
#endif
}
/**@ingroup tcomp_buffer_group
* Resets a sigcomp buffer.
* @param handle Handle holding the internal buffer to reset.
*/
void tcomp_buffer_reset(tcomp_buffer_handle_t* handle)
{
if(handle)
{
tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
buffer->index_bytes = 0;
buffer->index_bits = 0;
if(buffer->lpbuffer)
{
memset(buffer->lpbuffer, 0, buffer->size);
}
}
else TSK_DEBUG_ERROR("Null SigComp handle");
}
/**@ingroup tcomp_buffer_group
* Destroy a SigComp buffer handle previously allocated using @ref _tcomp_buffer_create or @a tcomp_buffer_create.
* @param handle The SigComp buffer handle to free.
* @sa @a tcomp_buffer_create @ref _tcomp_buffer_create.
*/
void tcomp_buffer_destroy(tcomp_buffer_handle_t** handle)
{
if(handle || !*handle)
{
tcomp_buffer_t** buffer = (tcomp_buffer_t**)handle;
tsk_free2(&((*buffer)->lpbuffer));
tsk_free2(buffer);
}
else TSK_DEBUG_ERROR("Null SigComp handle.");
}

View File

@ -0,0 +1,82 @@
/*
* 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_buffer.h
* @brief SigComp Buffer
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TCOMP_BUFFER_H
#define TCOMP_BUFFER_H
#include "tinysigcomp_config.h"
#include <stdint.h>
#define TCOMP_P_BIT_MSB_TO_LSB 0
#define TCOMP_P_BIT_LSB_TO_MSB 1
/**
* Sigcomp Buffer handle
*/
typedef void tcomp_buffer_handle_t;
tcomp_buffer_handle_t* _tcomp_buffer_create(const void* data, size_t len);
#define tcomp_buffer_create() _tcomp_buffer_create(0, 0)
int tcomp_buffer_equals(const tcomp_buffer_handle_t* handle1, const tcomp_buffer_handle_t* handle2);
int tcomp_buffer_startsWith(const tcomp_buffer_handle_t* handle1, const tcomp_buffer_handle_t* handle2) /*const*/;
const uint8_t* tcomp_buffer_getReadOnlyBufferAtPos(const tcomp_buffer_handle_t* handle, size_t position) /*const*/;
#define tcomp_buffer_getReadOnlyBuffer(buffer) tcomp_buffer_getReadOnlyBufferAtPos(buffer, 0)
uint8_t* tcomp_buffer_getBufferAtPos(const tcomp_buffer_handle_t* handle, size_t position);
#define tcomp_buffer_getBuffer(handle) tcomp_buffer_getBufferAtPos(handle, 0)
const size_t tcomp_buffer_getSize(const tcomp_buffer_handle_t* handle) /*const*/;
const size_t tcomp_buffer_getRemainingBits(const tcomp_buffer_handle_t* handle) /*const*/;
uint8_t* tcomp_buffer_readBytes(tcomp_buffer_handle_t* handle, size_t size);
uint16_t tcomp_buffer_readLsbToMsb(tcomp_buffer_handle_t* handle, size_t length);
uint16_t tcomp_buffer_readMsbToLsb(tcomp_buffer_handle_t* handle, size_t length);
void tcomp_buffer_discardBits(tcomp_buffer_handle_t* handle);
void tcomp_buffer_discardLastBytes(tcomp_buffer_handle_t* handle, uint16_t count);
void tcomp_buffer_allocBuff(tcomp_buffer_handle_t* handle, size_t size);
void tcomp_buffer_referenceBuff(tcomp_buffer_handle_t* handle, uint8_t* externalBuff, size_t size);
int tcomp_buffer_appendBuff(tcomp_buffer_handle_t* handle, const void* data, size_t size);
int tcomp_buffer_removeBuff(tcomp_buffer_handle_t* handle, size_t pos, size_t size);
void tcomp_buffer_freeBuff(tcomp_buffer_handle_t* handle);
size_t* tcomp_buffer_getIndexBytes(const tcomp_buffer_handle_t* handle);
size_t* tcomp_buffer_getIndexBits(const tcomp_buffer_handle_t* handle);
uint8_t* tcomp_buffer_getP_BIT(const tcomp_buffer_handle_t* handle);
void tcomp_buffer_nprint(tcomp_buffer_handle_t* handle, size_t size);
#define tcomp_buffer_print(handle) tcomp_buffer_nprint(handle, -1)
void tcomp_buffer_reset(tcomp_buffer_handle_t* handle);
void tcomp_buffer_destroy(tcomp_buffer_handle_t** handle);
#endif /* TCOMP_BUFFER_H */

View File

@ -0,0 +1,69 @@
/*
* 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_nakinfo.c
* @brief RFC 4077 - A Negative Acknowledgement Mechanism for Signaling Compression (NACK)
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tcomp_nakinfo.h"
#include "tsk_memory.h"
#include "tsk_debug.h"
/**@defgroup tcomp_nackinfo_group SigComp NACK information.
*/
/**@ingroup tcomp_nackinfo_group
* Creates a nack info message. You MUST use @ref tcomp_nackinfo_destroy to free the nackinfo.
* @retval The NACK info message.
* @sa @ref tcomp_nackinfo_destroy.
*/
tcomp_nackinfo_t* tcomp_nackinfo_create()
{
tcomp_nackinfo_t *nackinfo = (tcomp_nackinfo_t *)tsk_calloc2(1, sizeof(tcomp_nackinfo_t));
if(nackinfo)
{
nackinfo->version = NACK_VERSION;
nackinfo->details = tcomp_buffer_create();
}
else
{
TSK_DEBUG_ERROR("Failed to create new nackinfo.");
}
return nackinfo;
}
/**@ingroup tcomp_nackinfo_group
* Destroy a nackinfo message previously created using @ref tcomp_nackinfo_create.
* @param nackinfo The NACK info message to free.
* @sa @ref tcomp_nackinfo_create.
*/
void tcomp_nackinfo_destroy(tcomp_nackinfo_t **nackinfo)
{
if(nackinfo && *nackinfo)
{
tcomp_buffer_destroy(&((*nackinfo)->details));
tsk_free2(nackinfo);
}
}

View File

@ -0,0 +1,76 @@
/*
* 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_nakinfo.h
* @brief RFC 4077 - A Negative Acknowledgement Mechanism for Signaling Compression (NACK)
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TCOMP_NAKINFO_H
#define TCOMP_NAKINFO_H
#include "tinysigcomp_config.h"
#include "tcomp_buffer.h"
#include "tsk_sha1.h"
#include <stdint.h>
/*
+---+---+---+---+---+---+---+---+
| code_len = 0 |
+---+---+---+---+---+---+---+---+
| code_len = 0 | version = 1 |
+---+---+---+---+---+---+---+---+
| Reason Code |
+---+---+---+---+---+---+---+---+
| OPCODE of failed instruction |
+---+---+---+---+---+---+---+---+
| PC of failed instruction |
| |
+---+---+---+---+---+---+---+---+
| |
: SHA-1 Hash of failed message :
| |
+---+---+---+---+---+---+---+---+
| |
: Error Details :
| |
+---+---+---+---+---+---+---+---+
*/
/**@typedef tcomp_nackinfo_t
* NACK info as per rfc 4077 subclause 3.1.
*/
typedef struct tcomp_nackinfo_s
{
uint8_t version; /**< Gives the version of the NACK mechanism being employed. */
uint8_t reasonCode; /**< The Reason Code is a one-byte value that indicates the nature of the decompression failure. */
uint8_t opcode; /**< The "OPCODE of failed instruction" is a one-byte field that includes the opcode to which the PC was pointing when the failure occurred */
uint16_t pc; /**< "PC of failed instruction" is a two-byte field containing the value of the program counter when failure occurred (i.e., the memory address of the failed UDVM instruction) */
uint8_t sha1[TSK_SHA1HashSize]; /**<"SHA-1 Hash of failed message" contains the full 20-byte SHA-1 hash of the SigComp message that could not be decompressed */
tcomp_buffer_handle_t *details; /**< "Error Details" provides additional information that might be useful in correcting the problem that caused decompression failure.*/
}
tcomp_nackinfo_t;
tcomp_nackinfo_t* tcomp_nackinfo_create();
void tcomp_nackinfo_destroy(tcomp_nackinfo_t **nackinfo);
#endif /* TCOMP_NAKINFO_H */

View File

@ -0,0 +1,271 @@
/*
* 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_params.c
* @brief SIGCOMP parameters as per rfc 3320 subclause 3.3.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tcomp_params.h"
#include "tsk_binaryutils.h"
#include "tsk_memory.h"
#include "tsk_debug.h"
/**@defgroup tcomp_params_group SIGCOMP parameters as per rfc 3320 subclause 3.3.
*/
/**@ingroup tcomp_params_group
* Creates new sigcomp params. You MUST use @ref tcomp_params_destroy to free the params.
* @retval New sigcomp params.
* @sa @ref tcomp_params_destroy.
*/
tcomp_params_t* tcomp_params_create()
{
tcomp_params_t *params = (tcomp_params_t *)tsk_calloc2(1, sizeof(tcomp_params_t));
if(params)
{
tcomp_params_reset(params);
}
else TSK_DEBUG_ERROR("Failed to create new sigcomp params.");
return params;
}
/**@ingroup tcomp_params_group
* Checks if CPB, DMS and SMS values have been initialized.
* @param params The sigcomp parameters containing the values to check.
* @retval 1 if values have been set and zero otherwise.
*/
int tcomp_params_hasCpbDmsSms(tcomp_params_t* params)
{
if(params)
{
return (params->cpbCode || params->dmsCode || params->smsCode) ? 1 : 0;
}
else TSK_DEBUG_WARN("NULL sigcomp parameters.");
return 0;
}
/**@ingroup tcomp_params_group
* Sets CPB bits.
* @param params The sigcomp parameters containing cpb bits to set.
* @param cpbCode The new CPB code.
* @sa @ref tcomp_params_setCpbValue.
*/
void tcomp_params_setCpbCode(tcomp_params_t* params, uint8_t cpbCode)
{
if(params)
{
params->cpbCode = cpbCode;
params->cpbValue = sigcomp_encoding_cpb[cpbCode];
}
else TSK_DEBUG_ERROR("NULL sigcomp parameters.");
}
/**@ingroup tcomp_params_group
* Sets CPB bits.
* @param params The sigcomp parameters containing cpb bits to set.
* @param cpbValue The new CPB value.
* @sa @ref tcomp_params_setCpbCode.
*/
void tcomp_params_setCpbValue(tcomp_params_t* params, uint8_t cpbValue)
{
if(params)
{
uint8_t code;
for(code=0; code<4; code++)
{
if( cpbValue <= sigcomp_encoding_cpb[code])
{
params->cpbCode = code;
break;
}
}
params->cpbValue = cpbValue;
}
else TSK_DEBUG_ERROR("NULL sigcomp parameters.");
}
/**@ingroup tcomp_params_group
* Sets DMS bits.
* @param params The sigcomp parameters containing dms bits to set.
* @param dmsCode The new DMS code.
* @sa @ref tcomp_params_setDmsValue.
*/
void tcomp_params_setDmsCode(tcomp_params_t* params, uint8_t dmsCode)
{
if(params)
{
params->dmsCode = dmsCode;
params->dmsValue = sigcomp_encoding_dms[dmsCode];
}
else TSK_DEBUG_ERROR("NULL sigcomp parameters.");
}
/**@ingroup tcomp_params_group
* Sets DMS bits.
* @param params The sigcomp parameters containing dms bits to set.
* @param dmsValue The new DMS value.
* @sa @ref tcomp_params_setDmsCode.
*/
void tcomp_params_setDmsValue(tcomp_params_t* params, uint32_t dmsValue)
{
if(params)
{
uint8_t code;
for(code=1; code<8; code++)
{
if(dmsValue <= sigcomp_encoding_dms[code])
{
params->dmsCode = code;
break;
}
}
params->dmsValue = dmsValue;
}
else TSK_DEBUG_ERROR("NULL sigcomp parameters.");
}
/**@ingroup tcomp_params_group
* Sets SMS bits.
* @param params The sigcomp parameters containing sms bits to set.
* @param smsCode The new SMS code.
* @sa @ref tcomp_params_setSmsValue.
*/
void tcomp_params_setSmsCode(tcomp_params_t* params, uint8_t smsCode)
{
if(params)
{
params->smsCode = smsCode;
params->smsValue = sigcomp_encoding_sms[smsCode];
}
else TSK_DEBUG_ERROR("NULL sigcomp parameters.");
}
/**@ingroup tcomp_params_group
* Sets SMS bits.
* @param params The sigcomp parameters containing sms bits to set.
* @param smsValue The new SMS value.
* @sa @ref tcomp_params_setSmsCode.
*/
void tcomp_params_setSmsValue(tcomp_params_t* params, uint32_t smsValue)
{
if(params)
{
uint8_t code;
for(code=0; code<8; code++)
{
if(smsValue <= sigcomp_encoding_sms[code])
{
params->smsCode = code;
break;
}
}
params->smsValue = smsValue;
}
else TSK_DEBUG_ERROR("NULL sigcomp parameters.");
}
/**@ingroup tcomp_params_group
* Gets CPB, DMS and SMS values as a single 2-bytes value.
* @param params The sigcomp parameters containing the values.
* @retval CPB||DMS||SMS as 2-bytes value.
* @sa @ref tcomp_params_setParameters.
*/
uint16_t tcomp_params_getParameters(tcomp_params_t* params)
{
if(params)
{
/*
+---+---+---+---+---+---+---+---+
| cpb | dms | sms |
+---+---+---+---+---+---+---+---+
| SigComp_version |
+---+---+---+---+---+---+---+---+
*/
uint16_t result = ((params->cpbCode<<6)|(params->dmsCode<<3)|params->smsCode);
result <<=8;
return (result | params->SigComp_version);
}
else TSK_DEBUG_ERROR("NULL sigcomp parameters.");
return 0;
}
/**@ingroup tcomp_params_group
* Sets CPB, DMS and SMS values.
* @param params The sigcomp parameters containing the values to set.
* @param sigCompParameters New values as 2-bytes value.
* @sa @ref tcomp_params_getParameters.
*/
void tcomp_params_setParameters(tcomp_params_t* params, uint16_t sigCompParameters)
{
if(params)
{
/*
+---+---+---+---+---+---+---+---+
| cpb | dms | sms |
+---+---+---+---+---+---+---+---+
| SigComp_version |
+---+---+---+---+---+---+---+---+
*/
tcomp_params_setCpbCode( params, (sigCompParameters>>14) );
tcomp_params_setDmsCode( params, ((sigCompParameters>>11) & 0x07) );
tcomp_params_setSmsCode( params, ((sigCompParameters>>8) & 0x07) );
params->SigComp_version = ( (sigCompParameters & 0x00ff) );
}
else TSK_DEBUG_ERROR("NULL sigcomp parameters.");
}
/**@ingroup tcomp_params_group
* Reset all parameters.
* @param params The params to reset.
*/
void tcomp_params_reset(tcomp_params_t* params)
{
if(params)
{
params->cpbCode = params->dmsCode = params->smsCode = params->SigComp_version = 0;
params->cpbValue = params->dmsValue = params->smsValue = 0;
tsk_list_free(&(params->returnedStates));
}
else TSK_DEBUG_WARN("NULL sigcomp parameters.");
}
/**@ingroup tcomp_nackinfo_group
* Destroy SigComp parameters previously created using @ref tcomp_params_create.
* @param params The SigComp params to free.
* @sa @ref tcomp_params_create.
*/
void tcomp_params_destroy(tcomp_params_t** params)
{
if(params && *params)
{
tsk_free2(params);
tsk_list_free(&((*params)->returnedStates));
}
else TSK_DEBUG_WARN("NULL sigcomp parameters.");
}

View File

@ -0,0 +1,74 @@
/*
* 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_params.h
* @brief SIGCOMP parameters as per rfc 3320 subclause 3.3.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TCOMP_PARAMS_H
#define TCOMP_PARAMS_H
#include "tinysigcomp_config.h"
#include "tcomp_types.h"
/**@typedef tcomp_params_t
* SIGCOMP parameters as per rfc 3320 subclause 3.3.
*/
typedef struct tcomp_params_s
{
uint8_t cpbCode; /**< 'Cycles Per Bit' binary code. You MUST use @ref tcomp_params_setCpbCode to set this value. */
uint8_t dmsCode; /**< 'Decompression Memory' Size binary code. You MUST use @ref tcomp_params_setDmsCode to set this value. */
uint8_t smsCode; /**< 'State Memory Size' binary code. You MUST use @ref tcomp_params_setSmsCode to set this value. */
uint8_t cpbValue; /**< 'Cycles Per Bit' value. You MUST use @ref tcomp_params_setCpbValue to set this value. */
uint32_t dmsValue; /**< 'Decompression Memory Size' value. You MUST use @ref tcomp_params_setDmsValue to set this value. */
uint32_t smsValue; /**< 'State Memory Size' value You MUST use @ref tcomp_params_setSmsValue to set this value. */
uint8_t SigComp_version; /**< SigComp version. */
tcomp_buffers_L_t* returnedStates; /**< List of the returned states. */
}
tcomp_params_t;
tcomp_params_t* tcomp_params_create();
int tcomp_params_hasCpbDmsSms(tcomp_params_t*);
void tcomp_params_setCpbCode(tcomp_params_t*, uint8_t _cpbCode);
void tcomp_params_setCpbValue(tcomp_params_t*, uint8_t _cpbValue);
void tcomp_params_setDmsCode(tcomp_params_t*, uint8_t _dmsCode);
void tcomp_params_setDmsValue(tcomp_params_t*, uint32_t _dmsValue);
void tcomp_params_setSmsCode(tcomp_params_t*, uint8_t _smsCode);
void tcomp_params_setSmsValue(tcomp_params_t*, uint32_t _smsValue);
uint16_t tcomp_params_getParameters(tcomp_params_t*);
void tcomp_params_setParameters(tcomp_params_t*, uint16_t sigCompParameters);
void tcomp_params_reset(tcomp_params_t*);
void tcomp_params_destroy(tcomp_params_t**);
#endif /* TCOMP_PARAMS_H */

View File

@ -0,0 +1,84 @@
/*
* 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_reqfeed.c
* @brief SIGCOMP requested feedback item as per rfc 3320 subclause 9.4.9.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tcomp_reqfeed.h"
#include "tcomp_buffer.h"
#include "tsk_memory.h"
#include "tsk_debug.h"
/**@defgroup tcomp_reqfeed_group SigComp requested feedback item.
*/
/**@ingroup tcomp_reqfeed_group
* Create new feedback item. You MUST use @ref tcomp_reqfeed_destroy to free the feedback.
* @retval The new feedback item.
* @sa @ref tcomp_reqfeed_destroy.
*/
tcomp_reqfeed_t* tcomp_reqfeed_create()
{
tcomp_reqfeed_t *feedback = (tcomp_reqfeed_t *)tsk_calloc2(1, sizeof(tcomp_reqfeed_t));
if(feedback)
{
feedback->item = tcomp_buffer_create();
}
else TSK_DEBUG_ERROR("Failed to create new feedback.");
return feedback;
}
/**@ingroup tcomp_reqfeed_group
* Reset the feedback.
* @param feedback The feedback to reset.
*/
void tcomp_reqfeed_reset(tcomp_reqfeed_t* feedback)
{
if(feedback)
{
tcomp_buffer_freeBuff(feedback->item);
tcomp_buffer_reset(feedback->item);
feedback->Q = feedback->S = feedback->I = 0;
}
else TSK_DEBUG_ERROR("NULL feedback.");
}
/**@ingroup tcomp_reqfeed_group
* Free a feedback item previously created using @ref tcomp_reqfeed_create.
* @param feedback The feedback to free.
* @sa @ref tcomp_reqfeed_create.
*/
void tcomp_reqfeed_destroy(tcomp_reqfeed_t** feedback)
{
if(feedback && *feedback)
{
tcomp_buffer_destroy(&((*feedback)->item));
tsk_free2(feedback);
}
}

View File

@ -0,0 +1,67 @@
/*
* 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_reqfeed.h
* @brief SIGCOMP requested feedback item as per rfc 3320 subclause 9.4.9.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TCOMP_REQ_FEEDBACK_H
#define TCOMP_REQ_FEEDBACK_H
#include "tinysigcomp_config.h"
#include "tcomp_buffer.h"
/*
0 1 2 3 4 5 6 7
+---+---+---+---+---+---+---+---+
| reserved | Q | S | I | requested_feedback_location
+---+---+---+---+---+---+---+---+
| |
: requested feedback item : if Q = 1
| |
+---+---+---+---+---+---+---+---+
*/
/**@typedef tcomp_reqfeed_t
* SigComp Requested feedback item as per RFC 3320 subclause 9.4.9.
*/
typedef struct tcomp_reqfeed_s
{
uint8_t Q; /**< The Q-bit indicates whether a requested feedback item is present or not.*/
uint8_t S; /**< The compressor sets the S-bit to 1 if it does not wish (or no longer
wishes) to save state information at the receiving endpoint and also
does not wish to access state information that it has previously saved.*/
uint8_t I; /**< Similarly the compressor sets the I-bit to 1 if it does not wish (or
no longer wishes) to access any of the locally available state items
offered by the receiving endpoint.*/
tcomp_buffer_handle_t *item; /**< The requested item feedback data */
}
tcomp_reqfeed_t;
tcomp_reqfeed_t* tcomp_reqfeed_create();
void tcomp_reqfeed_reset(tcomp_reqfeed_t*);
void tcomp_reqfeed_destroy(tcomp_reqfeed_t**);
#endif /* TCOMP_REQ_FEEDBACK_H */

View File

@ -0,0 +1,35 @@
/*
* 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_result.c
* @brief SIGCOMP decompresion result.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tcomp_result.h"
#include "tsk_memory.h"
#include "tsk_debug.h"
/**@defgroup tcomp_result_group SIGCOMP decompresion result.
*/

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file tcomp_result.h
* @brief SIGCOMP decompresion result.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TCOMP_RESULT_H
#define TCOMP_RESULT_H
#include "tinysigcomp_config.h"
#endif /* TCOMP_RESULT_H */

View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file tcomp_rfc5049_sip.h
* @brief RFC 5049 - Applying Signaling Compression (SigComp) to the Session Initiation Protocol (SIP)
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TINYSIGCOMPP_RFC5049_H_
#define _TINYSIGCOMPP_RFC5049_H_
/*****
Applying Signaling Compression (SigComp)
to the Session Initiation Protocol (SIP)
*****/
// 4.1. decompression_memory_size (DMS) for SIP/SigComp
#define SIP_RFC5049_DECOMPRESSION_MEMORY_SIZE 8192
// 4.2. state_memory_size (SMS) for SIP/SigComp (per compartment)
#define SIP_RFC5049_STATE_MEMORY_SIZE 2048
// 4.3. cycles_per_bit (CPB) for SIP/SigComp
#define SIP_RFC5049_CYCLES_PER_BIT 16
// 4.4. SigComp_version (SV) for SIP/SigComp
#define SIP_RFC5049_SIGCOMP_VERSION 0x02 // (at least SigComp + NACK)
// 4.5. locally available state (LAS) for SIP/SigComp
// Minimum LAS for SIP/SigComp: the SIP/SDP static dictionary as defined
//in [RFC3485].
#endif /* _TINYSIGCOMPP_RFC5049_H_ */

View File

@ -0,0 +1,154 @@
/*
* 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_state.c
* @brief SIGCOMP state.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tcomp_state.h"
#include "tsk_memory.h"
#include "tsk_debug.h"
#include "tsk_sha1.h"
/**@defgroup tcomp_state_group SIGCOMP decompresion result.
*/
/**@ingroup tcomp_state_group
* Creates new SigComp state. You MUST use @ref tcomp_state_destroy to free the state.
* @retval New SigComp state.
* @sa @ref tcomp_state_destroy.
*/
tcomp_state_t* tcomp_state_create(uint16_t length, uint16_t address, uint16_t instruction, uint16_t minimum_access_length, uint16_t retention_priority)
{
tcomp_state_t *state = (tcomp_state_t *)tsk_calloc2(1, sizeof(tcomp_state_t));
if(state)
{
state->length = length;
state->address = address;
state->instruction = instruction;
state->minimum_access_length = minimum_access_length;
state->retention_priority = retention_priority;
/* Initialize safeobject */
tsk_safeobj_init(state);
}
else
{
TSK_DEBUG_ERROR("Failed to create new state.");
}
return state;
}
/**@ingroup tcomp_state_group
* Compare two sigomp states.
* @param state1 First state to compare.
* @param state2 Second state to compare.
* @retval 1 if the two handles are equals and 0 otherwise.
*/
int tcomp_state_equals(const tcomp_state_t *state1, const tcomp_state_t *state2)
{
if(state1 && state2)
{
return tcomp_buffer_equals(state1->identifier, state2->identifier);
}
else if(!state1 && !state2) return 1;
else return 0;
}
/**@ingroup tcomp_state_group
* Compute the state identifier by calculating a 20-byte SHA-1 hash [RFC-3174] over the
* byte string formed by concatenating the state_length, state_address,
* state_instruction, minimum_access_length and state_value (in the order given).
* @param state The state to make valid.
*/
void tcomp_state_makeValid(tcomp_state_t* state)
{
tsk_sha1context_t sha;
if(!state)
{
TSK_DEBUG_ERROR("NULL sigcomp state.");
return;
}
/* Lock */
tsk_safeobj_lock(state);
tcomp_buffer_allocBuff(state->identifier, TSK_SHA1HashSize);
/*=============
* Calculates a 20-byte SHA-1 hash [RFC-3174] over the byte string formed by concatenating the state_length, state_address,
* state_instruction, minimum_access_length and state_value (in the order given). This is the state_identifier.
*/
{
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];
for(i=0; i<4; i++)
{
#if 0 /*BIG_ENDIAN*/// Do not change this (it's for my own tests)
firstPart[i] = (values[i] & 0xff);
firstPart[i+1] = (values[i] >> 8);
#else
firstPart[2*i] = (values[i] >> 8);
firstPart[2*i+1] = (values[i]& 0xff);
#endif
}
tsk_sha1input(&sha, firstPart, 8);
tsk_sha1input(&sha, tcomp_buffer_getBuffer(state->value), tcomp_buffer_getSize(state->value));
err = tsk_sha1result(&sha, tcomp_buffer_getBuffer(state->identifier));
}
/* unlock */
tsk_safeobj_unlock(state);
}
/**@ingroup tcomp_state_group
* Destroy a SigComp state previously created using @ref tcomp_state_create.
* @param state The SigComp state to destroy.
* @sa @a tcomp_state_create.
*/
void tcomp_state_destroy(tcomp_state_t** state)
{
if(state || !*state)
{
tsk_safeobj_deinit(*state);
tcomp_buffer_destroy(&((*state)->identifier));
tcomp_buffer_destroy(&((*state)->value));
tsk_free2(state);
}
else TSK_DEBUG_ERROR("Null SigComp state.");
}

View File

@ -0,0 +1,61 @@
/*
* 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_state.h
* @brief SIGCOMP state.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TCOMP_STATE_H
#define TCOMP_STATE_H
#include "tinysigcomp_config.h"
#include "tcomp_buffer.h"
#include "tsk_safeobj.h"
typedef struct tcomp_state_s
{
tcomp_buffer_handle_t *value; /**< State's value. */
tcomp_buffer_handle_t *identifier; /**< State's identifier. */
uint16_t length; /**< State's length. */
uint16_t address; /**< State's address. */
uint16_t instruction; /**< State's instruction. */
uint16_t minimum_access_length; /**< State's minimum access length. */
uint16_t retention_priority; /**< State's retention priority. */
TSK_SAFEOBJ_DECLARE;
}
tcomp_state_t;
tcomp_state_t* tcomp_state_create(uint16_t length, uint16_t address, uint16_t instruction, uint16_t minimum_access_length, uint16_t retention_priority);
int tcomp_state_equals(const tcomp_state_t *state1, const tcomp_state_t *state2);
void tcomp_state_makeValid(tcomp_state_t*);
void tcomp_state_destroy(tcomp_state_t**);
#endif /* TCOMP_STATE_H */

View File

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

View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
#ifndef TINYSIGCOMP_CONFIG_H
#define TINYSIGCOMP_CONFIG_H
#if (defined(WIN32) || defined(_WIN32_WCE) || defined(__SYMBIAN32__)) && defined(TINYSIGCOMP_EXPORTS)
# define TINYSIGCOMP_API __declspec(dllexport)
#elif (defined(WIN32) || defined(_WIN32_WCE) || defined(__SYMBIAN32__)) && defined(TINYSIGCOMP_IMPORTS)
# define TINYSIGCOMP_API __declspec(dllimport)
#else
# define TINYSIGCOMP_API
#endif
//
//DEFLATE block type 01 (data compressed with fixed Huffman codes)*/
//
#ifndef FORCE_STATIC
# define FORCE_STATIC /*zlib*/
#endif
// avoid linking in the crc code
#define NO_GZIP
//
// Nack - RFC 4077
//
#define NACK_VERSION 0x01
#define NACK_MAX_HISTORY_SIZE 0x0a
//
// Feedbacks
//
#define USE_ONLY_ACKED_STATES 1
//
// Disable some well-known warnings
//
#ifdef _MSC_VER
# define _CRT_SECURE_NO_WARNINGS
#endif
#ifdef __SYMBIAN32__
#undef _WIN32 /* Because of WINSCW */
#endif
#endif // TINYSIGCOMP_CONFIG_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,130 @@
#if !HAS_ZLIB
/* header created automatically with -DGEN_TREES_H */
local const ct_data static_ltree[L_CODES+2] = {
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
};
local const ct_data static_dtree[D_CODES] = {
{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
};
const uch _dist_code[DIST_CODE_LEN] = {
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
};
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
};
local const int base_length[LENGTH_CODES] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
64, 80, 96, 112, 128, 160, 192, 224, 0
};
local const int base_dist[D_CODES] = {
0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
};
#endif // HAS_ZLIB

View File

@ -0,0 +1,336 @@
#if !HAS_ZLIB
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2005 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#ifndef ZCONF_H
#define ZCONF_H
#include "tinysigcomp_config.h"
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
# define deflateInit_ z_deflateInit_
# define deflate z_deflate
# define deflateEnd z_deflateEnd
# define inflateInit_ z_inflateInit_
# define inflate z_inflate
# define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary
# define deflateCopy z_deflateCopy
# define deflateReset z_deflateReset
# define deflateParams z_deflateParams
# define deflateBound z_deflateBound
# define deflatePrime z_deflatePrime
# define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateCopy z_inflateCopy
# define inflateReset z_inflateReset
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# define uncompress z_uncompress
# define adler32 z_adler32
# define crc32 z_crc32
# define get_crc_table z_get_crc_table
# define zError z_zError
# define alloc_func z_alloc_func
# define free_func z_free_func
# define in_func z_in_func
# define out_func z_out_func
# define Byte z_Byte
# define uInt z_uInt
# define uLong z_uLong
# define Bytef z_Bytef
# define charf z_charf
# define intf z_intf
# define uIntf z_uIntf
# define uLongf z_uLongf
# define voidpf z_voidpf
# define voidp z_voidp
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
# define OS2
#endif
#if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
#endif
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
# ifndef WIN32
# define WIN32
# endif
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
# ifndef SYS16BIT
# define SYS16BIT
# endif
# endif
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#ifdef SYS16BIT
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#ifdef __STDC_VERSION__
# ifndef STDC
# define STDC
# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
# define STDC
#endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
# define STDC
#endif
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define STDC
#endif
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# define STDC
#endif
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
# define STDC
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
# define NO_DUMMY_DECL
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
# else
# define FAR far
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# define FAR _far
# else
# define FAR far
# endif
# endif
#endif
#if defined(WINDOWS) || defined(WIN32) || defined(__SYMBIAN32__)
/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
# ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
# define ZEXTERN extern __declspec(dllexport)
# else
# define ZEXTERN extern __declspec(dllimport)
# endif
# endif
# endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
# ifdef ZLIB_WINAPI
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
# else
# define ZEXPORTVA FAR CDECL
# endif
# endif
#endif
#if defined (__BEOS__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport)
# else
# define ZEXPORT __declspec(dllimport)
# define ZEXPORTVA __declspec(dllimport)
# endif
# endif
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(__MACTYPES__)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void const *voidpc;
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte const *voidpc;
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
# include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# define z_off_t off_t
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if defined(__OS400__)
# define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
# ifdef FAR
# undef FAR
# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
# pragma map(deflateInit_,"DEIN")
# pragma map(deflateInit2_,"DEIN2")
# pragma map(deflateEnd,"DEEND")
# pragma map(deflateBound,"DEBND")
# pragma map(inflateInit_,"ININ")
# pragma map(inflateInit2_,"ININ2")
# pragma map(inflateEnd,"INEND")
# pragma map(inflateSync,"INSY")
# pragma map(inflateSetDictionary,"INSEDI")
# pragma map(compressBound,"CMBND")
# pragma map(inflate_table,"INTABL")
# pragma map(inflate_fast,"INFA")
# pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */
#endif // HAS_ZLIB

1359
trunk/tinySIGCOMP/src/zlib.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,321 @@
#if !HAS_ZLIB
/* zutil.c -- target dependent utility functions for the compression library
* Copyright (C) 1995-2005 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#include "zutil.h"
#ifndef NO_DUMMY_DECL
struct internal_state {int dummy;}; /* for buggy compilers */
#endif
const char * const z_errmsg[10] = {
"need dictionary", /* Z_NEED_DICT 2 */
"stream end", /* Z_STREAM_END 1 */
"", /* Z_OK 0 */
"file error", /* Z_ERRNO (-1) */
"stream error", /* Z_STREAM_ERROR (-2) */
"data error", /* Z_DATA_ERROR (-3) */
"insufficient memory", /* Z_MEM_ERROR (-4) */
"buffer error", /* Z_BUF_ERROR (-5) */
"incompatible version",/* Z_VERSION_ERROR (-6) */
""};
const char * ZEXPORT zlibVersion()
{
return ZLIB_VERSION;
}
uLong ZEXPORT zlibCompileFlags()
{
uLong flags;
flags = 0;
switch (sizeof(uInt)) {
case 2: break;
case 4: flags += 1; break;
case 8: flags += 2; break;
default: flags += 3;
}
switch (sizeof(uLong)) {
case 2: break;
case 4: flags += 1 << 2; break;
case 8: flags += 2 << 2; break;
default: flags += 3 << 2;
}
switch (sizeof(voidpf)) {
case 2: break;
case 4: flags += 1 << 4; break;
case 8: flags += 2 << 4; break;
default: flags += 3 << 4;
}
switch (sizeof(z_off_t)) {
case 2: break;
case 4: flags += 1 << 6; break;
case 8: flags += 2 << 6; break;
default: flags += 3 << 6;
}
#ifdef DEBUG
flags += 1 << 8;
#endif
#if defined(ASMV) || defined(ASMINF)
flags += 1 << 9;
#endif
#ifdef ZLIB_WINAPI
flags += 1 << 10;
#endif
#ifdef BUILDFIXED
flags += 1 << 12;
#endif
#ifdef DYNAMIC_CRC_TABLE
flags += 1 << 13;
#endif
#ifdef NO_GZCOMPRESS
flags += 1L << 16;
#endif
#ifdef NO_GZIP
flags += 1L << 17;
#endif
#ifdef PKZIP_BUG_WORKAROUND
flags += 1L << 20;
#endif
#ifdef FASTEST
flags += 1L << 21;
#endif
#ifdef STDC
# ifdef NO_vsnprintf
flags += 1L << 25;
# ifdef HAS_vsprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_vsnprintf_void
flags += 1L << 26;
# endif
# endif
#else
flags += 1L << 24;
# ifdef NO_snprintf
flags += 1L << 25;
# ifdef HAS_sprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_snprintf_void
flags += 1L << 26;
# endif
# endif
#endif
return flags;
}
#ifdef DEBUG
# ifndef verbose
# define verbose 0
# endif
int z_verbose = verbose;
void z_error (m)
char *m;
{
fprintf(stderr, "%s\n", m);
exit(1);
}
#endif
/* exported to allow conversion of error code to string for compress() and
* uncompress()
*/
const char * ZEXPORT zError(err)
int err;
{
return ERR_MSG(err);
}
#if defined(_WIN32_WCE)
/* The Microsoft C Run-Time Library for Windows CE doesn't have
* errno. We define it as a global variable to simplify porting.
* Its value is always 0 and should not be used.
*/
int errno = 0;
#endif
#ifndef HAVE_MEMCPY
void zmemcpy(dest, source, len)
Bytef* dest;
const Bytef* source;
uInt len;
{
if (len == 0) return;
do {
*dest++ = *source++; /* ??? to be unrolled */
} while (--len != 0);
}
int zmemcmp(s1, s2, len)
const Bytef* s1;
const Bytef* s2;
uInt len;
{
uInt j;
for (j = 0; j < len; j++) {
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
}
return 0;
}
void zmemzero(dest, len)
Bytef* dest;
uInt len;
{
if (len == 0) return;
do {
*dest++ = 0; /* ??? to be unrolled */
} while (--len != 0);
}
#endif
#ifdef SYS16BIT
#ifdef __TURBOC__
/* Turbo C in 16-bit mode */
# define MY_ZCALLOC
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
* and farmalloc(64K) returns a pointer with an offset of 8, so we
* must fix the pointer. Warning: the pointer must be put back to its
* original form in order to free it, use zcfree().
*/
#define MAX_PTR 10
/* 10*64K = 640K */
local int next_ptr = 0;
typedef struct ptr_table_s {
voidpf org_ptr;
voidpf new_ptr;
} ptr_table;
local ptr_table table[MAX_PTR];
/* This table is used to remember the original form of pointers
* to large buffers (64K). Such pointers are normalized with a zero offset.
* Since MSDOS is not a preemptive multitasking OS, this table is not
* protected from concurrent access. This hack doesn't work anyway on
* a protected system like OS/2. Use Microsoft C instead.
*/
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
{
voidpf buf = opaque; /* just to make some compilers happy */
ulg bsize = (ulg)items*size;
/* If we allocate less than 65520 bytes, we assume that farmalloc
* will return a usable pointer which doesn't have to be normalized.
*/
if (bsize < 65520L) {
buf = farmalloc(bsize);
if (*(ush*)&buf != 0) return buf;
} else {
buf = farmalloc(bsize + 16L);
}
if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
table[next_ptr].org_ptr = buf;
/* Normalize the pointer to seg:0 */
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
*(ush*)&buf = 0;
table[next_ptr++].new_ptr = buf;
return buf;
}
void zcfree (voidpf opaque, voidpf ptr)
{
int n;
if (*(ush*)&ptr != 0) { /* object < 64K */
farfree(ptr);
return;
}
/* Find the original pointer */
for (n = 0; n < next_ptr; n++) {
if (ptr != table[n].new_ptr) continue;
farfree(table[n].org_ptr);
while (++n < next_ptr) {
table[n-1] = table[n];
}
next_ptr--;
return;
}
ptr = opaque; /* just to make some compilers happy */
Assert(0, "zcfree: ptr not found");
}
#endif /* __TURBOC__ */
#ifdef M_I86
/* Microsoft C in 16-bit mode */
# define MY_ZCALLOC
#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
# define _halloc halloc
# define _hfree hfree
#endif
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
{
if (opaque) opaque = 0; /* to make compiler happy */
return _halloc((long)items, size);
}
void zcfree (voidpf opaque, voidpf ptr)
{
if (opaque) opaque = 0; /* to make compiler happy */
_hfree(ptr);
}
#endif /* M_I86 */
#endif /* SYS16BIT */
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
#ifndef STDC
extern voidp malloc OF((uInt size));
extern voidp calloc OF((uInt items, uInt size));
extern void free OF((voidpf ptr));
#endif
voidpf zcalloc (opaque, items, size)
voidpf opaque;
unsigned items;
unsigned size;
{
if (opaque) items += size - size; /* make compiler happy */
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
(voidpf)calloc(items, size);
}
void zcfree (opaque, ptr)
voidpf opaque;
voidpf ptr;
{
free(ptr);
if (opaque) return; /* make compiler happy */
}
#endif /* MY_ZCALLOC */
#endif // HAS_ZLIB

View File

@ -0,0 +1,271 @@
#if !HAS_ZLIB
/* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2005 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id$ */
#ifndef ZUTIL_H
#define ZUTIL_H
#define ZLIB_INTERNAL
#include "zlib.h"
#if defined(STDC) && !defined(__SYMBIAN32__)
# ifndef _WIN32_WCE
# include <stddef.h>
# endif
# include <string.h>
# include <stdlib.h>
#endif
#ifdef NO_ERRNO_H
# ifdef _WIN32_WCE
/* The Microsoft C Run-Time Library for Windows CE doesn't have
* errno. We define it as a global variable to simplify porting.
* Its value is always 0 and should not be used. We rename it to
* avoid conflict with other libraries that use the same workaround.
*/
# define errno z_errno
# endif
extern int errno;
#else
# ifndef _WIN32_WCE
# include <errno.h>
# endif
#endif
#ifndef local
# define local static
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
typedef unsigned char uch;
typedef uch FAR uchf;
typedef unsigned short ush;
typedef ush FAR ushf;
typedef unsigned long ulg;
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = (char*)ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
#ifndef DEF_WBITS
# define DEF_WBITS MAX_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
#if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
#else
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
#endif
/* default memLevel */
#define STORED_BLOCK 0
#define STATIC_TREES 1
#define DYN_TREES 2
/* The three kinds of block type */
#define MIN_MATCH 3
#define MAX_MATCH 258
/* The minimum and maximum match lengths */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
/* target dependencies */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# define OS_CODE 0x00
# if defined(__TURBOC__) || defined(__BORLANDC__)
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
# else
# include <alloc.h>
# endif
# else /* MSC or DJGPP */
# include <malloc.h>
# endif
#endif
#ifdef AMIGA
# define OS_CODE 0x01
#endif
#if defined(VAXC) || defined(VMS)
# define OS_CODE 0x02
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif
#if defined(ATARI) || defined(atarist)
# define OS_CODE 0x05
#endif
#ifdef OS2
# define OS_CODE 0x06
# ifdef M_I86
#include <malloc.h>
# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif
#endif
#ifdef TOPS20
# define OS_CODE 0x0a
#endif
#ifdef WIN32
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
# define OS_CODE 0x0b
# endif
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
# define OS_CODE 0x0f
#endif
#if defined(_BEOS_) || defined(RISCOS)
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
#if (defined(_MSC_VER) && (_MSC_VER > 600))
# if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED
# endif
# else
# define fdopen(fd,type) _fdopen(fd,type)
# endif
#endif
/* common defaults */
#ifndef OS_CODE
# define OS_CODE 0x03 /* assume Unix */
#endif
#ifndef F_OPEN
# define F_OPEN(name, mode) fopen((name), (mode))
#endif
/* functions */
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#if defined(__CYGWIN__)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#ifndef HAVE_VSNPRINTF
# ifdef MSDOS
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef __TURBOC__
# define NO_vsnprintf
# endif
# ifdef WIN32
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
# define vsnprintf _vsnprintf
# endif
# endif
# ifdef __SASC
# define NO_vsnprintf
# endif
#endif
#ifdef VMS
# define NO_vsnprintf
#endif
#if defined(pyr)
# define NO_MEMCPY
#endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
/* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested).
* The __SC__ check is for Symantec.
*/
# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
# define zmemcpy _fmemcpy
# define zmemcmp _fmemcmp
# define zmemzero(dest, len) _fmemset(dest, 0, len)
# else
# define zmemcpy memcpy
# define zmemcmp memcmp
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
#ifdef DEBUG
# include <stdio.h>
extern int z_verbose;
extern void z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else
# define Assert(cond,msg)
# define Trace(x)
# define Tracev(x)
# define Tracevv(x)
# define Tracec(c,x)
# define Tracecv(c,x)
#endif
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
void zcfree OF((voidpf opaque, voidpf ptr));
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
#endif /* ZUTIL_H */
#endif // HAS_ZLIB

View File

@ -0,0 +1,33 @@
========================================================================
CONSOLE APPLICATION : test Project Overview
========================================================================
AppWizard has created this test application for you.
This file contains a summary of what you will find in each of the files that
make up your test application.
test.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
test.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named test.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,26 @@
/*
* 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.
*
*/
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

View File

@ -0,0 +1,34 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
#ifndef TEST_TINYSIGCOMP_STDAFX_H
#define TEST_TINYSIGCOMP_STDAFX_H
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#endif /* TEST_TINYSIGCOMP_STDAFX_H */

View File

@ -0,0 +1,18 @@
#ifndef _TEST_TINYSIGCOMP_VER
#define _TEST_TINYSIGCOMP_VER
#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__)
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
#endif
#endif /*_TEST_TINYSIGCOMP_VER*/

View File

@ -0,0 +1,30 @@
/*
* 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.
*
*/
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}

View File

@ -0,0 +1,212 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="test"
ProjectGUID="{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}"
RootNamespace="test"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
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="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\stdafx.c"
>
</File>
<File
RelativePath=".\test.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\targetver.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,44 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySIGCOMP", "tinySIGCOMP.vcproj", "{76261DC8-25B3-43F4-9FB5-112C4AC0880E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{0FC0B98C-E5BE-4AB4-A382-CBBEA5F09AFE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySAK", "..\tinySAK\tinySAK.vcproj", "{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
Release|Win32 = Release|Win32
Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
EndGlobalSection
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}.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}.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)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,342 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="tinySIGCOMP"
ProjectGUID="{76261DC8-25B3-43F4-9FB5-112C4AC0880E}"
RootNamespace="tinySIGCOMP"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\win32\include&quot;;&quot;$(DOUBANGO_HOME)\tinySAK\src&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TINYSIGCOMP_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(OutDir)\tinySAK.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
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="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="source"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\tcomp.c"
>
</File>
<File
RelativePath=".\src\tcomp_buffer.c"
>
</File>
<Filter
Name="zlib"
>
<File
RelativePath=".\src\adler32.c"
>
</File>
<File
RelativePath=".\src\compress.c"
>
</File>
<File
RelativePath=".\src\deflate.c"
>
</File>
<File
RelativePath=".\src\trees.c"
>
</File>
<File
RelativePath=".\src\zutil.c"
>
</File>
</Filter>
<Filter
Name="SigCompLayer"
>
<File
RelativePath=".\src\tcomp_nakinfo.c"
>
</File>
<File
RelativePath=".\src\tcomp_params.c"
>
</File>
<File
RelativePath=".\src\tcomp_reqfeed.c"
>
</File>
<File
RelativePath=".\src\tcomp_result.c"
>
</File>
<File
RelativePath=".\src\tcomp_state.c"
>
</File>
</Filter>
<Filter
Name="Dictionaries"
>
</Filter>
<Filter
Name="Compressors"
>
</Filter>
</Filter>
<Filter
Name="include"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\src\tcomp.h"
>
</File>
<File
RelativePath=".\src\tcomp_buffer.h"
>
</File>
<File
RelativePath=".\src\tcomp_rfc5049_sip.h"
>
</File>
<File
RelativePath=".\src\tcomp_types.h"
>
</File>
<File
RelativePath=".\src\tinysigcomp_config.h"
>
</File>
<Filter
Name="zlib"
>
<File
RelativePath=".\src\deflate.h"
>
</File>
<File
RelativePath=".\src\trees.h"
>
</File>
<File
RelativePath=".\src\zconf.h"
>
</File>
<File
RelativePath=".\src\zlib.h"
>
</File>
<File
RelativePath=".\src\zutil.h"
>
</File>
</Filter>
<Filter
Name="SigCompLayer"
>
<File
RelativePath=".\src\tcomp_nakinfo.h"
>
</File>
<File
RelativePath=".\src\tcomp_params.h"
>
</File>
<File
RelativePath=".\src\tcomp_reqfeed.h"
>
</File>
<File
RelativePath=".\src\tcomp_result.h"
>
</File>
<File
RelativePath=".\src\tcomp_state.h"
>
</File>
</Filter>
<Filter
Name="Dictionaries"
>
</Filter>
<Filter
Name="Compressors"
>
</Filter>
</Filter>
<Filter
Name="asm"
>
<File
RelativePath=".\asm\deflate.asm"
>
</File>
<File
RelativePath=".\asm\deflate.asm.back"
>
</File>
<File
RelativePath=".\asm\dummy.asm"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -253,7 +253,7 @@ typedef struct txc_auid_s
unsigned available:1; /**< The auid availability. */
}
txc_auid_t;
typedef tsk_list_t txc_auid_L_t; /* contains 'txc_auid_t' elements */
typedef tsk_list_t txc_auid_L_t; /**< Contains @ref txc_auid_t elements */
typedef txc_auid_t AUIDS_T[TXC_AUIDS_COUNT];
/**@typedef txc_request_t