Fix line endings per .gitattributes

This commit is contained in:
Travis Cross committed 2014-08-08 15:24:42 +00:00
1 parent 1e9505d853
commit 8414c498cf
199 files changed
+28770 -28770

No files matched your search

+74 -74
View File
@@ -1,74 +1,74 @@
/*
* libZRTP SDK library, implements the ZRTP secure VoIP protocol.
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*
* Viktor Krykun <v.krikun at zfoneproject.com>
*/
#ifndef ZRTP_WIN_CONFIG_H__
#define ZRTP_WIN_CONFIG_H__
#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable: 4068)
#if !(defined(__BUILDMACHINE__) && __BUILDMACHINE__ == WinDDK)
#include <Windows.h>
#endif
/*
* Used to map system integer types to zrtp integer definitions.
* Define to 1 if you have the <inttypes.h> header file.
*/
#undef ZRTP_HAVE_INTTYPES_H
#define ZRTP_HAVE_STRING_H 1
/*
* This header is needed for operations with binary file in deefault realization
* of the secrets' cache. Can be eliminated if default cache isn't used.
* Define to 1 if you have the <stdio.h> header file.
*/
#ifndef ZRTP_HAVE_STDIO_H
# define ZRTP_HAVE_STDIO_H 1
#endif
#ifndef ZRTP_HAVE_STDARG_H
# define ZRTP_HAVE_STDARG_H 1
#endif
/*
* Used by bnlib, but we don't need this on Windows platform.
*/
#ifndef NO_ASSERT_H
#define NO_ASSERT_H 1
#endif
/*
* Used by bnlib. We have stdlib in any Windows platform - set it to 1.
*/
#ifndef NO_STDLIB_H
#define NO_STDLIB_H 0
#endif
#define ZRTP_HAVE_INT64_T 0
#define ZRTP_HAVE_INT32_T 0
#define ZRTP_HAVE_INT16_T 0
#define ZRTP_HAVE_INT8_T 0
#define ZRTP_HAVE_UINT64_T 0
#define ZRTP_HAVE_UINT32_T 0
#define ZRTP_HAVE_UINT16_T 0
#define ZRTP_HAVE_UINT8_T 0
#define SIZEOF_UNSIGNED_LONG 4
#define SIZEOF_UNSIGNED_LONG_LONG 8
#define ZRTP_INLINE static __inline
#define ZRTP_VERSION "0.90"
#endif /* ZRTP_WIN_CONFIG_H__ */
/*
* libZRTP SDK library, implements the ZRTP secure VoIP protocol.
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*
* Viktor Krykun <v.krikun at zfoneproject.com>
*/
#ifndef ZRTP_WIN_CONFIG_H__
#define ZRTP_WIN_CONFIG_H__
#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable: 4068)
#if !(defined(__BUILDMACHINE__) && __BUILDMACHINE__ == WinDDK)
#include <Windows.h>
#endif
/*
* Used to map system integer types to zrtp integer definitions.
* Define to 1 if you have the <inttypes.h> header file.
*/
#undef ZRTP_HAVE_INTTYPES_H
#define ZRTP_HAVE_STRING_H 1
/*
* This header is needed for operations with binary file in deefault realization
* of the secrets' cache. Can be eliminated if default cache isn't used.
* Define to 1 if you have the <stdio.h> header file.
*/
#ifndef ZRTP_HAVE_STDIO_H
# define ZRTP_HAVE_STDIO_H 1
#endif
#ifndef ZRTP_HAVE_STDARG_H
# define ZRTP_HAVE_STDARG_H 1
#endif
/*
* Used by bnlib, but we don't need this on Windows platform.
*/
#ifndef NO_ASSERT_H
#define NO_ASSERT_H 1
#endif
/*
* Used by bnlib. We have stdlib in any Windows platform - set it to 1.
*/
#ifndef NO_STDLIB_H
#define NO_STDLIB_H 0
#endif
#define ZRTP_HAVE_INT64_T 0
#define ZRTP_HAVE_INT32_T 0
#define ZRTP_HAVE_INT16_T 0
#define ZRTP_HAVE_INT8_T 0
#define ZRTP_HAVE_UINT64_T 0
#define ZRTP_HAVE_UINT32_T 0
#define ZRTP_HAVE_UINT16_T 0
#define ZRTP_HAVE_UINT8_T 0
#define SIZEOF_UNSIGNED_LONG 4
#define SIZEOF_UNSIGNED_LONG_LONG 8
#define ZRTP_INLINE static __inline
#define ZRTP_VERSION "0.90"
#endif /* ZRTP_WIN_CONFIG_H__ */
+79 -79
View File
@@ -1,79 +1,79 @@
/*
============================================================================
Name : CDelayRuner.cpp
Author : R. Drutsky
Version : 1.0
Copyright : Copyright (c) 2010 Soft Industry
Description : CCDelayRuner implementation
============================================================================
*/
#include "DelayRuner.h"
#include "zrtp_iface_system.h"
void zrtp_internal_delete_task_from_list(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask);
CDelayRuner::CDelayRuner() :
CActive(EPriorityLow) // Standard priority
{
}
CDelayRuner* CDelayRuner::NewLC()
{
CDelayRuner* self = new (ELeave) CDelayRuner();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CDelayRuner* CDelayRuner::NewL()
{
CDelayRuner* self = CDelayRuner::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CDelayRuner::ConstructL()
{
User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
CActiveScheduler::Add(this); // Add to scheduler
}
CDelayRuner::~CDelayRuner()
{
Cancel(); // Cancel any request, if outstanding
iTimer.Close(); // Destroy the RTimer object
// Delete instance variables if any
}
void CDelayRuner::DoCancel()
{
iTimer.Cancel();
}
void CDelayRuner::StartL(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask)
{
Cancel(); // Cancel any request, just to be sure
//iState = EUninitialized;
iCtx = ctx;
iZTask = ztask;
iTimer.After(iStatus, ztask->timeout * 1000); // Set for later
SetActive(); // Tell scheduler a request is active
}
void CDelayRuner::RunL()
{
if (iStatus == KErrNone)
{
// Do something useful
iZTask->_is_busy = 1 ; // may be we don't need this
(iZTask->callback)(iCtx,iZTask);
iZTask->_is_busy = 0 ; // may be we don't need this
}
zrtp_internal_delete_task_from_list(iCtx,iZTask);
}
TInt CDelayRuner::RunError(TInt aError)
{
return aError;
}
/*
============================================================================
Name : CDelayRuner.cpp
Author : R. Drutsky
Version : 1.0
Copyright : Copyright (c) 2010 Soft Industry
Description : CCDelayRuner implementation
============================================================================
*/
#include "DelayRuner.h"
#include "zrtp_iface_system.h"
void zrtp_internal_delete_task_from_list(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask);
CDelayRuner::CDelayRuner() :
CActive(EPriorityLow) // Standard priority
{
}
CDelayRuner* CDelayRuner::NewLC()
{
CDelayRuner* self = new (ELeave) CDelayRuner();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CDelayRuner* CDelayRuner::NewL()
{
CDelayRuner* self = CDelayRuner::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CDelayRuner::ConstructL()
{
User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
CActiveScheduler::Add(this); // Add to scheduler
}
CDelayRuner::~CDelayRuner()
{
Cancel(); // Cancel any request, if outstanding
iTimer.Close(); // Destroy the RTimer object
// Delete instance variables if any
}
void CDelayRuner::DoCancel()
{
iTimer.Cancel();
}
void CDelayRuner::StartL(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask)
{
Cancel(); // Cancel any request, just to be sure
//iState = EUninitialized;
iCtx = ctx;
iZTask = ztask;
iTimer.After(iStatus, ztask->timeout * 1000); // Set for later
SetActive(); // Tell scheduler a request is active
}
void CDelayRuner::RunL()
{
if (iStatus == KErrNone)
{
// Do something useful
iZTask->_is_busy = 1 ; // may be we don't need this
(iZTask->callback)(iCtx,iZTask);
iZTask->_is_busy = 0 ; // may be we don't need this
}
zrtp_internal_delete_task_from_list(iCtx,iZTask);
}
TInt CDelayRuner::RunError(TInt aError)
{
return aError;
}
+72 -72
View File
@@ -1,72 +1,72 @@
/*
============================================================================
Name : CDelayRuner.h
Author : R. Drutsky
Version : 1.0
Copyright : Copyright (c) 2010 Soft Industry
Description : CDelayRuner declaration
============================================================================
*/
#ifndef DELAYRUNER_H
#define DELAYRUNER_H
#include <e32base.h> // For CActive, link against: euser.lib
#include <e32std.h> // For RTimer, link against: euser.lib
#include <zrtp.h>
class CDelayRuner : public CActive
{
public:
// Cancel and destroy
~CDelayRuner();
// Two-phased constructor.
static CDelayRuner* NewL();
// Two-phased constructor.
static CDelayRuner* NewLC();
public:
// New functions
// Function for making the initial request
void StartL(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask);
private:
// C++ constructor
CDelayRuner();
// Second-phase constructor
void ConstructL();
private:
// From CActive
// Handle completion
void RunL();
// How to cancel me
void DoCancel();
// Override to handle leaves from RunL(). Default implementation causes
// the active scheduler to panic.
TInt RunError(TInt aError);
private:
enum TCDelayRunerState
{
EUninitialized, // Uninitialized
EInitialized, // Initalized
EError
// Error condition
};
private:
TInt iState; // State of the active object
RTimer iTimer; // Provides async timing service
zrtp_stream_t *iCtx;
zrtp_retry_task_t * iZTask;
};
#endif // CDELAYRUNER_H
/*
============================================================================
Name : CDelayRuner.h
Author : R. Drutsky
Version : 1.0
Copyright : Copyright (c) 2010 Soft Industry
Description : CDelayRuner declaration
============================================================================
*/
#ifndef DELAYRUNER_H
#define DELAYRUNER_H
#include <e32base.h> // For CActive, link against: euser.lib
#include <e32std.h> // For RTimer, link against: euser.lib
#include <zrtp.h>
class CDelayRuner : public CActive
{
public:
// Cancel and destroy
~CDelayRuner();
// Two-phased constructor.
static CDelayRuner* NewL();
// Two-phased constructor.
static CDelayRuner* NewLC();
public:
// New functions
// Function for making the initial request
void StartL(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask);
private:
// C++ constructor
CDelayRuner();
// Second-phase constructor
void ConstructL();
private:
// From CActive
// Handle completion
void RunL();
// How to cancel me
void DoCancel();
// Override to handle leaves from RunL(). Default implementation causes
// the active scheduler to panic.
TInt RunError(TInt aError);
private:
enum TCDelayRunerState
{
EUninitialized, // Uninitialized
EInitialized, // Initalized
EError
// Error condition
};
private:
TInt iState; // State of the active object
RTimer iTimer; // Provides async timing service
zrtp_stream_t *iCtx;
zrtp_retry_task_t * iZTask;
};
#endif // CDELAYRUNER_H
+336 -336
View File
@@ -1,336 +1,336 @@
/*
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*/
#include <charconv.h>
#include <stdarg.h>
#include <sys/time.h>
#include <e32msgqueue.h>
#include <UNISTD.H>
#include <e32base.h>
#include <e32math.h>
#include <zrtp.h>
extern "C"
{
/**
* @brief Get kernel-generated random number
* @bug seems not work
* @return 32 random bits
*/
uint32_t zrtp_symbian_kernel_random();
/**
* @brief Pseudo random number: sum of pid's shifted and xored by number of precceses
* @return
*/
uint32_t zrtp_sum_of_pid_and_number_of_poccesses();
/**
* @brief Number of milisecond past from particular date and time
* @return
*/
uint64_t zrtp_get_system_time_crazy();
/**
* @brief Current procces PID
* @return PID
*/
unsigned int zrtp_get_pid();
/**
* @brief Availible memory
* @return memory availible on heap
*/
uint32_t zrtp_get_availible_heap();
}
//-----------------------------------------------------------------------------
zrtp_status_t zrtp_mutex_init(zrtp_mutex_t **mutex) {
RMutex *rmutex = new RMutex();
//rmutex->CreateLocal(); was before
rmutex->CreateGlobal(KNullDesC);
*mutex = (zrtp_mutex_t*) rmutex;
return zrtp_status_ok;
}
zrtp_status_t zrtp_mutex_lock(zrtp_mutex_t* mutex) {
RMutex *rmutex = (RMutex *) mutex;
rmutex->Wait();
return zrtp_status_ok;
}
zrtp_status_t zrtp_mutex_unlock(zrtp_mutex_t* mutex) {
RMutex *rmutex = (RMutex *) mutex;
rmutex->Signal();
return zrtp_status_ok;
}
zrtp_status_t zrtp_mutex_destroy(zrtp_mutex_t* mutex) {
RMutex *rmutex = (RMutex *) mutex;
if (rmutex) {
rmutex->Close();
delete rmutex;
}
return zrtp_status_ok;
}
//-----------------------------------------------------------------------------
zrtp_status_t zrtp_sem_init(zrtp_sem_t** sem, uint32_t value, uint32_t limit) {
RSemaphore *rsem = new RSemaphore();
//rsem->CreateLocal(value);
rsem->CreateGlobal(KNullDesC,value);
*sem = (zrtp_sem_t*) rsem;
return zrtp_status_ok;
}
zrtp_status_t zrtp_sem_destroy(zrtp_sem_t* sem) {
RSemaphore *rsem = (RSemaphore *) sem;
if (rsem) {
rsem->Close();
delete rsem;
}
return zrtp_status_ok;
}
zrtp_status_t zrtp_sem_wait(zrtp_sem_t* sem) {
RSemaphore *rsem = (RSemaphore *) sem;
rsem->Wait();
return zrtp_status_ok;
}
zrtp_status_t zrtp_sem_trtwait(zrtp_sem_t* sem) {
RSemaphore *rsem = (RSemaphore *) sem;
rsem->Wait(1000);
return zrtp_status_ok;
}
zrtp_status_t zrtp_sem_post(zrtp_sem_t* sem) {
RSemaphore *rsem = (RSemaphore *) sem;
rsem->Signal();
return zrtp_status_ok;
}
//-----------------------------------------------------------------------------
int zrtp_sleep(unsigned int msec) {
TTimeIntervalMicroSeconds32 i(msec *1000);
User::After(i);
return 0;
}
int zrtp_thread_create(zrtp_thread_routine_t start_routine, void *arg) {
RThread h;
TBuf<64> thName=_L("zrtp_thread");
h.Create(thName, start_routine, KDefaultStackSize*2, NULL, arg) ;
h.Resume();
h.Close();
return NULL;
}
//-----------------------------------------------------------------------------
// For Scheduler
#if (defined(ZRTP_USE_BUILTIN_SCEHDULER) && (ZRTP_USE_BUILTIN_SCEHDULER ==1))
#include "DelayRuner.h"
#include "zrtp_error.h"
mlist_t tasks_head_s;
static uint8_t inited = 0 ;
static uint8_t is_running = 0;
typedef struct {
zrtp_stream_t *ctx; /** ZRTP stream context associated with the task */
zrtp_retry_task_t *ztask; /** ZRTP stream associated with the task */
mlist_t _mlist;
CDelayRuner* ao; // Active object
} zrtp_sched_task_s_t;
zrtp_status_t zrtp_def_scheduler_init(zrtp_global_t* zrtp)
{
zrtp_status_t status = zrtp_status_ok;
ZRTP_LOG(3,("symbian","Init start"));
if (inited) {
return zrtp_status_ok;
}
do {
init_mlist(&tasks_head_s);
is_running = 1;
inited = 1;
} while (0);
ZRTP_LOG(3,("symbian","Init end"));
return status;
}
void zrtp_def_scheduler_down()
{
ZRTP_LOG(3,("symbian","Down start"));
mlist_t *node = 0, *tmp = 0;
if (!inited) {
return;
}
/* Stop main thread */
is_running = 0;
// zrtp_sem_post(count);
/* Then destroy tasks queue and realease all other resources */
//zrtp_mutex_lock(protector);
mlist_for_each_safe(node, tmp, &tasks_head_s) {
zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node);
if (task->ao!=NULL)
{
delete task->ao;
}
zrtp_sys_free(task);
}
init_mlist(&tasks_head_s);
// zrtp_mutex_unlock(protector);
// zrtp_mutex_destroy(protector);
// zrtp_sem_destroy(count);
ZRTP_LOG(3,("symbian","Down end"));
inited = 0;
}
void zrtp_def_scheduler_call_later(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask)
{
// ZRTP_LOG(3,("symbian","CallLater start"));
//mlist_t *node=0, *tmp=0;
mlist_t* last = &tasks_head_s;
//zrtp_mutex_lock(protector);
if (!ztask->_is_enabled) {
//zrtp_mutex_unlock(protector);
return;
}
do {
zrtp_sched_task_s_t* new_task = (zrtp_sched_task_s_t*)zrtp_sys_alloc(sizeof(zrtp_sched_task_s_t));
if (!new_task) {
break;
}
new_task->ctx = ctx;
new_task->ztask = ztask;
new_task->ao = CDelayRuner::NewL();
mlist_insert(last, &new_task->_mlist);
new_task->ao->StartL(ctx,ztask);
//zrtp_sem_post(count);
} while (0);
//ZRTP_LOG(3,("symbian","CallLater end"));
//zrtp_mutex_unlock(protector);
}
void zrtp_def_scheduler_cancel_call_later(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask)
{
mlist_t *node=0, *tmp=0;
ZRTP_LOG(3,("symbian","CancelcallLater start"));
// zrtp_mutex_lock(protector);
mlist_for_each_safe(node, tmp, &tasks_head_s) {
zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node);
if ((task->ctx == ctx) && ((task->ztask == ztask) || !ztask)) {
task->ao->Cancel();
delete task->ao; // Cancel and delete task
mlist_del(&task->_mlist);
zrtp_sys_free(task);
//zrtp_sem_trtwait(count);
if (ztask) {
break;
}
}
}
ZRTP_LOG(3,("symbian","CancelCallLater done"));
// zrtp_mutex_unlock(protector);
}
void zrtp_internal_delete_task_from_list(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask)
{
mlist_t *node=0, *tmp=0;
ZRTP_LOG(3,("symbian","DelTask begin"));
mlist_for_each_safe(node, tmp, &tasks_head_s)
{
zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node);
if ((task->ctx == ctx) && ((task->ztask == ztask) || !ztask))
{
delete task->ao; // Cancel and delete task
mlist_del(&task->_mlist);
zrtp_sys_free(task);
ZRTP_LOG(3,("symbian","DelTask Del"));
//zrtp_sem_trtwait(count);
if (ztask)
{
break;
}
}
}
ZRTP_LOG(3,("symbian","DelTask end"));
}
void zrtp_def_scheduler_wait_call_later(zrtp_stream_t* ctx)
{
}
#endif // ZRTP_USE_BUILTIN_SCEHDULER
//-----------------------------------------------------------------------------
unsigned int zrtp_get_pid()
{
return getpid();
}
uint64_t zrtp_get_system_time_crazy()
{
TTime time;
return time.MicroSecondsFrom(TTime(TDateTime (491,EAugust,7,3,37,17,347))).Int64();
}
uint32_t zrtp_sum_of_pid_and_number_of_poccesses()
{
TFindProcess fp;
RProcess procces;
TFullName proccesName;
uint_32t idsum=1;
uint_32t proccesCount=0;
fp.Find(KNullDesC);
while (fp.Next(proccesName)==KErrNone)
{
if (procces.Open(proccesName,EOwnerProcess)==KErrNone)
{
idsum+=procces.Id();
proccesCount++;
procces.Close();
}
}
idsum = (idsum << 3) xor proccesCount;
return idsum;
}
uint32_t zrtp_get_availible_heap()
{
return User::Heap().MaxLength();
}
uint32_t zrtp_symbian_kernel_random()
{
return Math::Random();
}
/*
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*/
#include <charconv.h>
#include <stdarg.h>
#include <sys/time.h>
#include <e32msgqueue.h>
#include <UNISTD.H>
#include <e32base.h>
#include <e32math.h>
#include <zrtp.h>
extern "C"
{
/**
* @brief Get kernel-generated random number
* @bug seems not work
* @return 32 random bits
*/
uint32_t zrtp_symbian_kernel_random();
/**
* @brief Pseudo random number: sum of pid's shifted and xored by number of precceses
* @return
*/
uint32_t zrtp_sum_of_pid_and_number_of_poccesses();
/**
* @brief Number of milisecond past from particular date and time
* @return
*/
uint64_t zrtp_get_system_time_crazy();
/**
* @brief Current procces PID
* @return PID
*/
unsigned int zrtp_get_pid();
/**
* @brief Availible memory
* @return memory availible on heap
*/
uint32_t zrtp_get_availible_heap();
}
//-----------------------------------------------------------------------------
zrtp_status_t zrtp_mutex_init(zrtp_mutex_t **mutex) {
RMutex *rmutex = new RMutex();
//rmutex->CreateLocal(); was before
rmutex->CreateGlobal(KNullDesC);
*mutex = (zrtp_mutex_t*) rmutex;
return zrtp_status_ok;
}
zrtp_status_t zrtp_mutex_lock(zrtp_mutex_t* mutex) {
RMutex *rmutex = (RMutex *) mutex;
rmutex->Wait();
return zrtp_status_ok;
}
zrtp_status_t zrtp_mutex_unlock(zrtp_mutex_t* mutex) {
RMutex *rmutex = (RMutex *) mutex;
rmutex->Signal();
return zrtp_status_ok;
}
zrtp_status_t zrtp_mutex_destroy(zrtp_mutex_t* mutex) {
RMutex *rmutex = (RMutex *) mutex;
if (rmutex) {
rmutex->Close();
delete rmutex;
}
return zrtp_status_ok;
}
//-----------------------------------------------------------------------------
zrtp_status_t zrtp_sem_init(zrtp_sem_t** sem, uint32_t value, uint32_t limit) {
RSemaphore *rsem = new RSemaphore();
//rsem->CreateLocal(value);
rsem->CreateGlobal(KNullDesC,value);
*sem = (zrtp_sem_t*) rsem;
return zrtp_status_ok;
}
zrtp_status_t zrtp_sem_destroy(zrtp_sem_t* sem) {
RSemaphore *rsem = (RSemaphore *) sem;
if (rsem) {
rsem->Close();
delete rsem;
}
return zrtp_status_ok;
}
zrtp_status_t zrtp_sem_wait(zrtp_sem_t* sem) {
RSemaphore *rsem = (RSemaphore *) sem;
rsem->Wait();
return zrtp_status_ok;
}
zrtp_status_t zrtp_sem_trtwait(zrtp_sem_t* sem) {
RSemaphore *rsem = (RSemaphore *) sem;
rsem->Wait(1000);
return zrtp_status_ok;
}
zrtp_status_t zrtp_sem_post(zrtp_sem_t* sem) {
RSemaphore *rsem = (RSemaphore *) sem;
rsem->Signal();
return zrtp_status_ok;
}
//-----------------------------------------------------------------------------
int zrtp_sleep(unsigned int msec) {
TTimeIntervalMicroSeconds32 i(msec *1000);
User::After(i);
return 0;
}
int zrtp_thread_create(zrtp_thread_routine_t start_routine, void *arg) {
RThread h;
TBuf<64> thName=_L("zrtp_thread");
h.Create(thName, start_routine, KDefaultStackSize*2, NULL, arg) ;
h.Resume();
h.Close();
return NULL;
}
//-----------------------------------------------------------------------------
// For Scheduler
#if (defined(ZRTP_USE_BUILTIN_SCEHDULER) && (ZRTP_USE_BUILTIN_SCEHDULER ==1))
#include "DelayRuner.h"
#include "zrtp_error.h"
mlist_t tasks_head_s;
static uint8_t inited = 0 ;
static uint8_t is_running = 0;
typedef struct {
zrtp_stream_t *ctx; /** ZRTP stream context associated with the task */
zrtp_retry_task_t *ztask; /** ZRTP stream associated with the task */
mlist_t _mlist;
CDelayRuner* ao; // Active object
} zrtp_sched_task_s_t;
zrtp_status_t zrtp_def_scheduler_init(zrtp_global_t* zrtp)
{
zrtp_status_t status = zrtp_status_ok;
ZRTP_LOG(3,("symbian","Init start"));
if (inited) {
return zrtp_status_ok;
}
do {
init_mlist(&tasks_head_s);
is_running = 1;
inited = 1;
} while (0);
ZRTP_LOG(3,("symbian","Init end"));
return status;
}
void zrtp_def_scheduler_down()
{
ZRTP_LOG(3,("symbian","Down start"));
mlist_t *node = 0, *tmp = 0;
if (!inited) {
return;
}
/* Stop main thread */
is_running = 0;
// zrtp_sem_post(count);
/* Then destroy tasks queue and realease all other resources */
//zrtp_mutex_lock(protector);
mlist_for_each_safe(node, tmp, &tasks_head_s) {
zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node);
if (task->ao!=NULL)
{
delete task->ao;
}
zrtp_sys_free(task);
}
init_mlist(&tasks_head_s);
// zrtp_mutex_unlock(protector);
// zrtp_mutex_destroy(protector);
// zrtp_sem_destroy(count);
ZRTP_LOG(3,("symbian","Down end"));
inited = 0;
}
void zrtp_def_scheduler_call_later(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask)
{
// ZRTP_LOG(3,("symbian","CallLater start"));
//mlist_t *node=0, *tmp=0;
mlist_t* last = &tasks_head_s;
//zrtp_mutex_lock(protector);
if (!ztask->_is_enabled) {
//zrtp_mutex_unlock(protector);
return;
}
do {
zrtp_sched_task_s_t* new_task = (zrtp_sched_task_s_t*)zrtp_sys_alloc(sizeof(zrtp_sched_task_s_t));
if (!new_task) {
break;
}
new_task->ctx = ctx;
new_task->ztask = ztask;
new_task->ao = CDelayRuner::NewL();
mlist_insert(last, &new_task->_mlist);
new_task->ao->StartL(ctx,ztask);
//zrtp_sem_post(count);
} while (0);
//ZRTP_LOG(3,("symbian","CallLater end"));
//zrtp_mutex_unlock(protector);
}
void zrtp_def_scheduler_cancel_call_later(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask)
{
mlist_t *node=0, *tmp=0;
ZRTP_LOG(3,("symbian","CancelcallLater start"));
// zrtp_mutex_lock(protector);
mlist_for_each_safe(node, tmp, &tasks_head_s) {
zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node);
if ((task->ctx == ctx) && ((task->ztask == ztask) || !ztask)) {
task->ao->Cancel();
delete task->ao; // Cancel and delete task
mlist_del(&task->_mlist);
zrtp_sys_free(task);
//zrtp_sem_trtwait(count);
if (ztask) {
break;
}
}
}
ZRTP_LOG(3,("symbian","CancelCallLater done"));
// zrtp_mutex_unlock(protector);
}
void zrtp_internal_delete_task_from_list(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask)
{
mlist_t *node=0, *tmp=0;
ZRTP_LOG(3,("symbian","DelTask begin"));
mlist_for_each_safe(node, tmp, &tasks_head_s)
{
zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node);
if ((task->ctx == ctx) && ((task->ztask == ztask) || !ztask))
{
delete task->ao; // Cancel and delete task
mlist_del(&task->_mlist);
zrtp_sys_free(task);
ZRTP_LOG(3,("symbian","DelTask Del"));
//zrtp_sem_trtwait(count);
if (ztask)
{
break;
}
}
}
ZRTP_LOG(3,("symbian","DelTask end"));
}
void zrtp_def_scheduler_wait_call_later(zrtp_stream_t* ctx)
{
}
#endif // ZRTP_USE_BUILTIN_SCEHDULER
//-----------------------------------------------------------------------------
unsigned int zrtp_get_pid()
{
return getpid();
}
uint64_t zrtp_get_system_time_crazy()
{
TTime time;
return time.MicroSecondsFrom(TTime(TDateTime (491,EAugust,7,3,37,17,347))).Int64();
}
uint32_t zrtp_sum_of_pid_and_number_of_poccesses()
{
TFindProcess fp;
RProcess procces;
TFullName proccesName;
uint_32t idsum=1;
uint_32t proccesCount=0;
fp.Find(KNullDesC);
while (fp.Next(proccesName)==KErrNone)
{
if (procces.Open(proccesName,EOwnerProcess)==KErrNone)
{
idsum+=procces.Id();
proccesCount++;
procces.Close();
}
}
idsum = (idsum << 3) xor proccesCount;
return idsum;
}
uint32_t zrtp_get_availible_heap()
{
return User::Heap().MaxLength();
}
uint32_t zrtp_symbian_kernel_random()
{
return Math::Random();
}
+21 -21
View File
@@ -14,7 +14,7 @@
* code omits one level of interface glue has no perceptible effect on
* the results.
*/
#include "zrtp.h"
#include "zrtp.h"
#ifndef HAVE_CONFIG_H
#define HAVE_CONFIG_H 0
@@ -289,14 +289,14 @@ bntest_main(int argc, char **argv)
/* Timing test code - only if requested on the command line */
if (modbits) {
#if CLOCK_AVAIL
#if CLOCK_AVAIL
timetype start, stop;
unsigned long cursec, expsec, twoexpsec, dblexpsec;
unsigned curms, expms, twoexpms, dblexpms;
expsec = twoexpsec = dblexpsec = 0;
expms = twoexpms = dblexpms = 0;
#endif
#endif
lbnCopy_16(C,B,i);
lbnSub1_16(C,i,1); /* C is exponent: p-1 */
@@ -407,31 +407,31 @@ bntest_main(int argc, char **argv)
bnput16("e = ", e, i);
ZRTP_LOG(3, (_ZTU_, "%u bits, should be %d", m, (int)expbits2));
}
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&start);
#endif
#endif
z = lbnTwoExpMod_16(A, B, k, C, i);
if (z < 0)
goto nomem;
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&stop);
subtime(stop, start);
twoexpsec += cursec = sec(stop);
twoexpms += curms = msec(stop);
ZRTP_LOG(3, (_ZTU_, "2^<%d>:%4lu.%03u ", (int)expbits, cursec, curms));
#else
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d> ", (int)modbits, (int)expbits));
#endif
#endif
fflush(stdout);
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&start);
#endif
#endif
z = lbnExpMod_16(A, A, i, B, k, C, i);
if (z < 0)
goto nomem;
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&stop);
subtime(stop, start);
expsec += cursec = sec(stop);
@@ -451,13 +451,13 @@ bntest_main(int argc, char **argv)
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2,
cursec, curms));
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d>*<%d>^<%d>",
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2));
#endif
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d>*<%d>^<%d>",
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2));
#endif
}
#if CLOCK_AVAIL
#if CLOCK_AVAIL
twoexpms += (twoexpsec % j) * 1000;
ZRTP_LOG(3, (_ZTU_, "2^<%d> mod <%d> bits AVERAGE: %4lu.%03u s",
(int)expbits, (int)modbits, twoexpsec/j, twoexpms/j));
@@ -472,7 +472,7 @@ bntest_main(int argc, char **argv)
(int)modbits, dblexpsec/j, dblexpms/j));
putchar('\n');
#endif
#endif
}
puts("Beginning 1000 interations of sanity checking.\n"
@@ -486,9 +486,9 @@ bntest_main(int argc, char **argv)
* on in case of major wierdness, but it produces a *lot* of
* output.
*/
#if (ZRTP_PLATFORM == ZP_WINCE) || (ZRTP_PLATFORM == ZP_SYMBIAN)
for (j = 1; j <= 20; j++) {
#else
#if (ZRTP_PLATFORM == ZP_WINCE) || (ZRTP_PLATFORM == ZP_SYMBIAN)
for (j = 1; j <= 20; j++) {
#else
for (j = 1; j <= 1000; j++) {
#endif
/* Do the tests for lots of different number sizes. */
+21 -21
View File
@@ -14,7 +14,7 @@
* code omits one level of interface glue has no perceptible effect on
* the results.
*/
#include "zrtp.h"
#include "zrtp.h"
#ifndef HAVE_CONFIG_H
#define HAVE_CONFIG_H 0
@@ -289,14 +289,14 @@ bntest_main(int argc, char **argv)
/* Timing test code - only if requested on the command line */
if (modbits) {
#if CLOCK_AVAIL
#if CLOCK_AVAIL
timetype start, stop;
unsigned long cursec, expsec, twoexpsec, dblexpsec;
unsigned curms, expms, twoexpms, dblexpms;
expsec = twoexpsec = dblexpsec = 0;
expms = twoexpms = dblexpms = 0;
#endif
#endif
lbnCopy_32(C,B,i);
lbnSub1_32(C,i,1); /* C is exponent: p-1 */
@@ -407,31 +407,31 @@ bntest_main(int argc, char **argv)
bnput32("e = ", e, i);
ZRTP_LOG(3, (_ZTU_, "%u bits, should be %d", m, (int)expbits2));
}
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&start);
#endif
#endif
z = lbnTwoExpMod_32(A, B, k, C, i);
if (z < 0)
goto nomem;
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&stop);
subtime(stop, start);
twoexpsec += cursec = sec(stop);
twoexpms += curms = msec(stop);
ZRTP_LOG(3, (_ZTU_, "2^<%d>:%4lu.%03u ", (int)expbits, cursec, curms));
#else
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d> ", (int)modbits, (int)expbits));
#endif
#endif
fflush(stdout);
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&start);
#endif
#endif
z = lbnExpMod_32(A, A, i, B, k, C, i);
if (z < 0)
goto nomem;
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&stop);
subtime(stop, start);
expsec += cursec = sec(stop);
@@ -451,13 +451,13 @@ bntest_main(int argc, char **argv)
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2,
cursec, curms));
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d>*<%d>^<%d>",
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2));
#endif
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d>*<%d>^<%d>",
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2));
#endif
}
#if CLOCK_AVAIL
#if CLOCK_AVAIL
twoexpms += (twoexpsec % j) * 1000;
ZRTP_LOG(3, (_ZTU_, "2^<%d> mod <%d> bits AVERAGE: %4lu.%03u s",
(int)expbits, (int)modbits, twoexpsec/j, twoexpms/j));
@@ -472,7 +472,7 @@ bntest_main(int argc, char **argv)
(int)modbits, dblexpsec/j, dblexpms/j));
putchar('\n');
#endif
#endif
}
puts("Beginning 1000 interations of sanity checking.\n"
@@ -486,9 +486,9 @@ bntest_main(int argc, char **argv)
* on in case of major wierdness, but it produces a *lot* of
* output.
*/
#if (ZRTP_PLATFORM == ZP_WINCE) || (ZRTP_PLATFORM == ZP_SYMBIAN)
for (j = 1; j <= 20; j++) {
#else
#if (ZRTP_PLATFORM == ZP_WINCE) || (ZRTP_PLATFORM == ZP_SYMBIAN)
for (j = 1; j <= 20; j++) {
#else
for (j = 1; j <= 1000; j++) {
#endif
/* Do the tests for lots of different number sizes. */
+21 -21
View File
@@ -14,7 +14,7 @@
* code omits one level of interface glue has no perceptible effect on
* the results.
*/
#include "zrtp.h"
#include "zrtp.h"
#ifndef HAVE_CONFIG_H
#define HAVE_CONFIG_H 0
@@ -289,14 +289,14 @@ bntest_main(int argc, char **argv)
/* Timing test code - only if requested on the command line */
if (modbits) {
#if CLOCK_AVAIL
#if CLOCK_AVAIL
timetype start, stop;
unsigned long cursec, expsec, twoexpsec, dblexpsec;
unsigned curms, expms, twoexpms, dblexpms;
expsec = twoexpsec = dblexpsec = 0;
expms = twoexpms = dblexpms = 0;
#endif
#endif
lbnCopy_64(C,B,i);
lbnSub1_64(C,i,1); /* C is exponent: p-1 */
@@ -407,31 +407,31 @@ bntest_main(int argc, char **argv)
bnput64("e = ", e, i);
ZRTP_LOG(3, (_ZTU_, "%u bits, should be %d", m, (int)expbits2));
}
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&start);
#endif
#endif
z = lbnTwoExpMod_64(A, B, k, C, i);
if (z < 0)
goto nomem;
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&stop);
subtime(stop, start);
twoexpsec += cursec = sec(stop);
twoexpms += curms = msec(stop);
ZRTP_LOG(3, (_ZTU_, "2^<%d>:%4lu.%03u ", (int)expbits, cursec, curms));
#else
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d> ", (int)modbits, (int)expbits));
#endif
#endif
fflush(stdout);
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&start);
#endif
#endif
z = lbnExpMod_64(A, A, i, B, k, C, i);
if (z < 0)
goto nomem;
#if CLOCK_AVAIL
#if CLOCK_AVAIL
gettime(&stop);
subtime(stop, start);
expsec += cursec = sec(stop);
@@ -451,13 +451,13 @@ bntest_main(int argc, char **argv)
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2,
cursec, curms));
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d>*<%d>^<%d>",
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2));
#endif
#else
ZRTP_LOG(3, (_ZTU_, "<%d>^<%d>*<%d>^<%d>",
(int)modbits, (int)expbits,
(int)modbits, (int)expbits2));
#endif
}
#if CLOCK_AVAIL
#if CLOCK_AVAIL
twoexpms += (twoexpsec % j) * 1000;
ZRTP_LOG(3, (_ZTU_, "2^<%d> mod <%d> bits AVERAGE: %4lu.%03u s",
(int)expbits, (int)modbits, twoexpsec/j, twoexpms/j));
@@ -472,7 +472,7 @@ bntest_main(int argc, char **argv)
(int)modbits, dblexpsec/j, dblexpms/j));
putchar('\n');
#endif
#endif
}
puts("Beginning 1000 interations of sanity checking.\n"
@@ -486,9 +486,9 @@ bntest_main(int argc, char **argv)
* on in case of major wierdness, but it produces a *lot* of
* output.
*/
#if (ZRTP_PLATFORM == ZP_WINCE) || (ZRTP_PLATFORM == ZP_SYMBIAN)
for (j = 1; j <= 20; j++) {
#else
#if (ZRTP_PLATFORM == ZP_WINCE) || (ZRTP_PLATFORM == ZP_SYMBIAN)
for (j = 1; j <= 20; j++) {
#else
for (j = 1; j <= 1000; j++) {
#endif
/* Do the tests for lots of different number sizes. */