Пример #1
0
/***********************************************************************
 *  init()
 ***********************************************************************/
int crypt0_init(void **pptr, int init, void *data, size_t size)
{
	crypt0_t *c;
	FUN("crypt0_init");

	if (NULL == pptr) {
		LOGS(L_CRYPTO,L_ERROR,("pptr is NULL\n"));
		errno = EINVAL;
		return -1;
	}
	if (0 != init) {
		LOGS(L_CRYPTO,L_ERROR,("init is not 0\n"));
		errno = EINVAL;
		return -1;
	}
	c = (crypt0_t *)xcalloc(sizeof(crypt0_t), 1);
	*pptr = c;

	c->magic = CRYPT0_MAGIC;

	(void)data;
	(void)size;

	return 0;
}
// -----------------------------------------------------------------------------
// CUpnpCpbSimpleDeviceDescription::DiscoverDeviceL
// Start processing device.
// -----------------------------------------------------------------------------
//
TInt CUpnpCpbSimpleDeviceDescription::DiscoverDeviceL(CUpnpDevice* aDevice)
    {
    LOG_FUNC_NAME;
    iIsNull = EFalse;
    iRootDevice = aDevice;
    // check if device match the type
    if(!iRepository.MatchTargetDevice(aDevice->DeviceType()))
        {
        iResult = KDisscoveryFinished;
        return iResult;
        }

    iResult = KDisscoveryInProgress;
    TPtrC8 buffer(GetNextServiceType(iRootDevice));

    if (buffer.Length())
        {
        LOGS("CUpnpCpbSimpleDeviceDescription::DiscoverDeviceL - Discovering services");

        //ask for 1st service description
        iResult = KDisscoveryInProgress;
        TInt sessionId = iMessanger.GetServiceDescriptionL (aDevice, buffer);
        // put SessionID to memory per pending Service Description request
        aDevice->WaitServiceDescriptionL( sessionId );
        }
    else
        {
        LOGS("CUpnpCpbSimpleDeviceDescription::DiscoverDeviceL - "
             "No service info for the device");
        LOGS("CUpnpCpbSimpleDeviceDescription::DiscoverDeviceL - "
             "All device info brought - device officially discovered");
        iResult = KDisscoveryFinished;
        }
    return iResult;
    }
// -----------------------------------------------------------------------------
// CUpnpSymbianServerBase::RunError
// RunError is called when RunL leaves.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt CUpnpSymbianServerBase::RunError( TInt aError )
    {
    LOG_FUNC_NAME;
    if ( aError == KErrBadDescriptor )
        {
        // A bad descriptor error implies a badly programmed client, so panic it;
        // otherwise report the error to the client
        LOGS( "RunError - BadClient" );
        PanicClient( Message(), EBadDescriptor );
        }
    else if ( aError != KErrCorrupt )
        {
        LOGS( "RunError - Faulty Message" );
        if ( !Message().IsNull() )
            {
            Message().Complete( aError );
            }
        }

    // The leave will result in an early return from CServer::RunL(), skipping
    // the call to request another message. So do that now in order to keep the
    // server running.
    ReStart();

    // Handled the error fully
    return KErrNone;
    }
Пример #4
0
bool ZFile::open(const char* pMode)
{
	
    //LOGS("Begin Open File:");
    //LOGS(m_strFileName.c_str());
    try
    {
        clear();

        m_pFile = fopen(m_strFileName.c_str(),pMode);
        if (NULL == m_pFile)
        {
            LOGS("fopen file failed");
            return false;
        }

        //LOGS("open file success");
        return true;

    }
    catch (...)
    {
        LOGS("fopen file failed");
        m_pFile = NULL;
        return false;
    }


    return false;
}
// -----------------------------------------------------------------------------
// CUpnpSymbianServerBase::StartServerL
// Create and start the server.
// -----------------------------------------------------------------------------
//
void CUpnpSymbianServerBase::StartServerL( const TDesC& aThreadName,
    TServerFactoryMethodLC aServerFactoryMethodLC )
    {
    User::LeaveIfError( User::RenameThread( aThreadName ) );
    // Construct active scheduler
    CActiveScheduler* activeScheduler = new( ELeave ) CActiveScheduler;
    CleanupStack::PushL( activeScheduler );

    // Install active scheduler
    // We don't need to check whether an active scheduler is already installed
    // as this is a new thread, so there won't be one
    CActiveScheduler::Install( activeScheduler );

    // Construct our server
    CUpnpSymbianServerBase* serverObject = aServerFactoryMethodLC();
    LOGS( "UpnpSymbianServer *** Ready to accept connections" );

    RProcess::Rendezvous( KErrNone );

    // Start handling requests
    CActiveScheduler::Start();

    LOGS( "UpnpSymbianServer *** Active scheduler stopped" );
    LOGS( "UpnpSymbianServer *** Prepared for shutdown" );

    CleanupStack::PopAndDestroy( serverObject );
    REComSession::FinalClose();
    CleanupStack::PopAndDestroy( activeScheduler );
    LOGS( "UpnpSymbianServer *** Shutdown complete" );
    }
Пример #6
0
//* 
//* Init All Resources
//* 
void a_init_all(){
  //-- Init Input Event Handler
  ui_init();
  LOGS("Input Initialized\n");
  
  //-- Init Graphic Framebuffer
  ag_init();
  LOGS("Graph Initialized\n");
}
Пример #7
0
//* 
//* Release All Resources
//* 
void a_release_all(){
  //-- Release All
  ag_closefonts();  //-- Release Fonts
  LOGS("Font Released\n");
  ev_exit();        //-- Release Input Engine
  LOGS("Input Released\n");
  az_close();       //-- Release Zip Handler
  LOGS("Archive Released\n");
  ag_close();       //-- Release Graph Engine
  LOGS("Graph Released\n");
}
Пример #8
0
/**
 * Issues simulations till a stop condition is fulfilled.
 *
 * @param rCond The stop condition.
 */
void UpdateController::runSubphase(StopCondition &rCond) {
	LOGS(Priority::INFO)<<"(re)started subphase";
	fireInitializePhase();
	lNIterations = 0;
	while (!rCond.fulfilled(lNIterations)) {
		if (lNIterations % 50 == 0) {
			LOGS(Priority::VERBOSE)<<"iteration: "<<lNIterations;
			R_CheckUserInterrupt();
		}
		lrSimulation.simulate();
		++lNIterations;
	}
	fireFinalizePhase(lNIterations * lrSimulation.nSimulations());
}
Пример #9
0
BBSoundSet *BBSoundSetPool::getSet(){
  BBSoundSet *set = _sets[_currentIndex];
  set->reset();

  _currentIndex ++;
  LOGS("BBSoundSetPool::getSet()");
  LOG(_currentIndex);
  LOG(_numSets);
  if( _currentIndex == _numSets){
    LOGS("-------------- RESET SET POOL --------------");
    shuffle();
    _currentIndex = 0;
  }
  return set;
}
// -----------------------------------------------------------------------------
// CUpnpDeviceImplementation::NewL
// -----------------------------------------------------------------------------
//
EXPORT_C CUpnpDeviceImplementation* CUpnpDeviceImplementation::NewL( 
        const TDesC8& aUri, 
        CUpnpDeviceDescriptionStore& aDescriptionStore,
        MUpnpDeviceDescriptionProvider& aProvider )
    {
    LOGS("CUpnpDevice:: CUpnpDevice::NewL( const TDesC& aFilename, TInt aIapId, TInt aHandle )" );

    HBufC8* descr = UpnpFileUtil::ReadFileL( aDescriptionStore.DescriptionFile() );
    if ( descr->Length()> KMaxDeviceDescriptionLenght )
        {
        delete descr;
        User::Leave( KErrTooBig );
        }
    CleanupStack::PushL( descr );

    CUpnpContentHandlersController* controller = CUpnpContentHandlersController::NewLC();

    CUpnpDeviceImplementation* deviceImpl = controller->ParseDeviceImplL( *descr );
    CleanupStack::PushL( deviceImpl );
    deviceImpl->ConstructL( aUri, aDescriptionStore, aProvider );
    CleanupStack::Pop( deviceImpl );

    CleanupStack::PopAndDestroy( controller );
    CleanupStack::PopAndDestroy( descr );

    return deviceImpl;
    }
Пример #11
0
void MeetingSetting::initPermittedSteps(const bool* const permitted) {
	// THIS WORKS CAUSE WE KNOW THAT PERMITTED STEPS CONTAINS EGO!
	if (lpPermittedSteps == 0) {
	lpSetting->initPermittedSteps(permitted);
		if (lpSetting->getPermittedSize() > 1) {
		ITieIterator* iter = lpSetting->getPermittedSteps();
		if(iter->actor() == ego()) {
			iter->next();
		}
			int pos = nextInt(lpSetting->getPermittedSize() - 1);
		while (pos != 0) {
			iter->next();
			if (iter->actor() != ego()) {
				--pos;
			}
		}
			SingleIterator iter1(ego());
			SingleIterator iter2(iter->actor());
			lpPermittedSteps = new UnionTieIterator(iter1, iter2);
		delete iter;
	} else {
		lpPermittedSteps = new SingleIterator(ego());
	}
	} else {
		LOGS(Priority::ERROR)<<"setting has not been terminated\n";
		throw "setting has not been terminated";
	}
}
Пример #12
0
/* Our own IRQs are disabled as we're being called from our IRQ handler */
static void rds_processpacket(struct rds_dev *dev)
{
	int a,last_used=dev->rx_used;
	char buffer[64];
	
	/* Got a whole packet, log it and buffer */
	sprintf(buffer,"pkt %02x/%02x/%02x/%02x %02x/%02x/%02x/%02x\n",
		dev->buffer[0],dev->buffer[1],dev->buffer[2],dev->buffer[3],
		dev->buffer[4],dev->buffer[5],dev->buffer[6],dev->buffer[7]);
	LOGS(buffer);

	/* Put it into the buffer */
	if (dev->rx_free<8) {
		/* No room! */
		return;
	}

	dev->rx_free-=8;
	dev->rx_used+=8;
	dev->rx_count+=8;
	for(a=0;a<8;a++) {
		dev->rx_buffer[dev->rx_head++]=dev->buffer[a];
		if (dev->rx_head==RDS_RX_BUFFER_SIZE) dev->rx_head=0;
	}

	/* If we've filled an empty buffer, wake up readers */
	if (!last_used) wake_up_interruptible(&dev->rx_wq);
}
Пример #13
0
// -----------------------------------------------------------------------------
// CUpnpHttpServer::ConnectionAcceptedL
//
// -----------------------------------------------------------------------------
//
CUpnpTcpSession* CUpnpHttpServer::ConnectionAcceptedL( RSocket aSocket )
    {
    LOG_FUNC_NAME;

    #ifdef _DEBUG
    TInetAddr tempAddr;
    aSocket.RemoteName( tempAddr );
    tempAddr.ConvertToV4();

    const TInt KMaxAdressLength = 20;
    TBuf<KMaxAdressLength> addrBuf;
    tempAddr.Output( addrBuf );

    HBufC8* addrBuf8 = UpnpString::FromUnicodeL( addrBuf );
    CleanupStack::PushL( addrBuf8 );

    LOGS( "CUpnpHttpServer::ConnectionAcceptedL - Remote socket connected" );
    LOGT( addrBuf8->Des() );

    LOGS1("CUpnpHttpServer::ConnectionAcceptedL - Creating a new Http session. Session count: %i", iSessionList.Count());

    CleanupStack::PopAndDestroy(addrBuf8);
    #endif //_DEBUG
    CUpnpHttpSession* sess = CUpnpHttpSession::NewL( aSocket, this,
        CUpnpHttpMessage::NewSessionIdL(), EPriorityNormal );

    return sess;
    }
Пример #14
0
static void pnode(shm_node_t *n)
{
	FUN("pnode");
#if	SHM_DEBUG
	LOGS(L_SHM,L_ERROR,
		("%#x: rsize=%#x usize=%#x addr=%#x pid=%u file=%s:%u next=0x%x\n",
		(unsigned)n, (unsigned)n->x.rsize, (unsigned)n->x.usize,
		(unsigned)ADDR(n), (unsigned)n->x.pid, (unsigned)n->x.next,
		(char *)((NULL != n->x.file) ? n->x.file : "unknown"),
		(unsigned)n->x.line));
#else
	LOGS(L_SHM,L_ERROR,
		("%#x: rsize=%#x usize=%#x addr=%#x pid=%u next=0x%x\n",
		(unsigned)n, (unsigned)n->x.rsize, (unsigned)n->x.usize,
		(unsigned)ADDR(n), (unsigned)n->x.pid, (unsigned)n->x.next));
#endif
}
Пример #15
0
SYSCALL(void, maHttpSetRequestHeader(MAHandle conn, const char* key, const char* value)) {
	LOGS("HttpSetRequestHeader %i %s: %s\n", conn, key, value);
	MAStreamConn& mac = getStreamConn(conn);
	HttpConnection* http = mac.conn->http();
	MYASSERT(http != NULL, ERR_CONN_NOT_HTTP);
	MYASSERT(http->mState == HttpConnection::SETUP, ERR_HTTP_NOT_SETUP);
	http->SetRequestHeader(key, value);
}
Пример #16
0
/**
 * Runs the epoch simulation for the period and updates the variables.
 *
 * Similar to: siena07models.cpp mlPeriod()
 *
 * @param m Period.
 */
void MetropolisHastingsSimulation::simulatePeriod(const int m) {
	MLSimulation* pSim = new MLSimulation(lpData, lpModel);

	// Update simulations
	pSim->simpleRates(lpModel->simpleRates());
	pSim->currentPermutationLength(lpModel->currentPermutationLength(m));

	pSim->missingNetworkProbability(
			static_cast<const Model*>(lpModel)->missingNetworkProbability(m));

	pSim->missingBehaviorProbability(
			static_cast<const Model*>(lpModel)->missingBehaviorProbability(m));

	LOGS(Priority::VERBOSE)<<"\nSimple rates: "<<pSim->simpleRates()
	<<"\nCurrent permutation length: "<<pSim->currentPermutationLength()
	<<"\nMissing network probability: "<<pSim->missingNetworkProbability()
	<<"\nMissing behavior probability: "<<pSim->missingBehaviorProbability();

	pSim->pChain(lpModel->rChainStore(m).back()->copyChain());
	lpModel->needScores(false);
	lpModel->needDerivatives(false);
	lpModel->numberMLSteps(lNRunMH[m]);

	LOGS(Priority::VERBOSE)<<"\nNum steps: "<<lpModel->numberMLSteps();

	pSim->runEpoch(m);
	// Run through current state of chain and calculate scores and derivatives.
	lpModel->needScores(true); // !onlyLoglik (bayes)
	lpModel->needDerivatives(lNeedsDerivative);

	pSim->updateProbabilities(pSim->pChain(), pSim->pChain()->pFirst()->pNext(),
			pSim->pChain()->pLast()->pPrevious());
	// Store chain on Model.
	Chain* pChain = pSim->pChain();
	pChain->createInitialStateDifferences();
	pSim->createEndStateDifferences();
	lpModel->chainStore(*pChain, m);
	lpModel->currentPermutationLength(m, pSim->currentPermutationLength());

	// Add up period results.
	addSingleScores(lScores[0], m, *pSim);
	addSingleDerivatives(lDerivative[0], m, *pSim);

	LOGS(Priority::DEBUG)<<"Scores: "<<lScores[0].transpose();
}
Пример #17
0
void BBSoundSetPool::setPool(BBSoundSet *(sets[]), int count){
  _sets = sets;
  _numSets = count;
  srand(analogRead(0) * analogRead(1) - analogRead(2));
  shuffle();
  LOGS("BBSoundSetPool::setPool()");
  // LOG(_numSets);

}
Пример #18
0
bool ZFile::GetLineInfo(char* pBuf, int iBufSize)
{
    if(NULL == m_pFile)
    {
        LOGS("file not open");
        return false;
    }

    return (NULL != fgets(pBuf,iBufSize,m_pFile))?true:false;
}
Пример #19
0
int ZFile::write(const char* pBuf,int iBufSize)
{
    if(NULL == m_pFile)
    {
        LOGS("file not open");
        return (-1);
    }

    return fwrite(pBuf,1,iBufSize,m_pFile);
}
Пример #20
0
int ZFile::fprintf( const char* format,...)
{
    if(NULL == m_pFile)
    {
        LOGS("file not open");
        return (-1);
    }

    return ::fprintf(m_pFile,format);
}
Пример #21
0
void ISubject::detatch(IObserver *observer){

  ObserverVector::iterator position = std::find(_observers.begin(), _observers.end(), observer);
  if (position != _observers.end()) {// == vector.end() means the element was not found
    _observers.erase(position);
    LOGS("remove observer: ");
    LOG(_observers.size());
  }

}
Пример #22
0
void MeetingSetting::terminateSetting() {
	lpSetting->terminateSetting(ego());
	if (lpPermittedSteps != 0) {
		delete lpPermittedSteps;
		lpPermittedSteps = 0;
	} else {
		LOGS(Priority::ERROR)<< "setting has not been initialized\n";
		throw "setting has not been initialized";

	}
}
// -----------------------------------------------------------------------------
// CUpnpCpbSimpleDeviceDescription::ServiceDescription
// Parse service description
// -----------------------------------------------------------------------------
//
TInt CUpnpCpbSimpleDeviceDescription::ProcessServiceDescriptionL(CUpnpHttpMessage* aMsg)
    {
    LOG_FUNC_NAME;
    CUpnpDevice::TServiceAdd result;

    // Parsing service desription
    CUpnpService* service = NULL;
    service = iSaxController->ParseServiceL(aMsg->Body(), iRootDevice);

    CleanupStack::PushL(service);
    result = iRootDevice->AddServiceL(aMsg->SessionId(), service);
    CleanupStack::Pop(service);

    if ( result == CUpnpDevice::EAllServicesAdded )
        { // device has received all service descriptions
        LOGS("CUpnpCpbSimpleDeviceDescription::ProcessServiceDescriptionL  - "
             "All service info added to the parent device");
        iResult = 	KDisscoveryFinished;
        }
    else if ( result == CUpnpDevice::EServiceAdded )
        {
        LOGS("CUpnpCpbSimpleDeviceDescription::ProcessServiceDescriptionL - "
             "Service added");
        // Waiting for next desciptions.
        iResult = 	KDisscoveryInProgress;

        TPtrC8 buffer(GetNextServiceType(iRootDevice));
        TInt sessionId = iMessanger.GetServiceDescriptionL (iRootDevice,
                                  buffer);
        // put SessionID to memory per pending Service Description request
        iRootDevice->WaitServiceDescriptionL( sessionId );
        }
    else
        {
        delete service;
        iResult = KDisscoveryInProgress;
        }

    LOGS1("CUpnpCpbSimpleDeviceDescription::ProcessServiceDescriptionL -res=%d", iResult);
    return iResult;
    }
Пример #24
0
/**
 * \copydoc Simulation::needsChanged()
 */
void StatisticsSimulation::needsChanged() {
	set<ResultType>::iterator it = find(lNeeds.begin(), lNeeds.end(),
			PERIOD_SCORES);
	lpModel->needScores(it != lNeeds.end());
	if (lpModel->needScores()) {
		LOGS(Priority::DEBUG)<<"simulation collects scores";
		// Create stores only the first time.
		if (lScores.empty()) {
			setupMaps(lScores, lScoresData, lNThreads, nPeriods(), nParameters());
		}
	}
}
Пример #25
0
void ISubject::attach(IObserver *observer){
  // LOG((int)this);

  // don't add if already subscribed
  if (std::find(_observers.begin(), _observers.end(), observer) == _observers.end())
  {
    LOGS("attatching Observer: ");
    _observers.push_back(observer);
    LOG(_observers.size());
  }

}
Пример #26
0
void resize(int _newWidth, int _newHeight) {

    LOGS("resize: %d x %d", _newWidth, _newHeight);
    LOG("resize: %d x %d", _newWidth, _newHeight);

    glViewport(0, 0, _newWidth, _newHeight);

    if (m_view) {
        m_view->setSize(_newWidth, _newHeight);
    }

    Primitives::setResolution(_newWidth, _newHeight);
}
Пример #27
0
static void plist(shm_node_t *head)
{
	shm_node_t *c;
	FUN("plist");

	LOGS(L_SHM,L_ERROR,("=== list starts at 0x%x ===\n",
		(uint32_t)head));
	c = head;
	while (NULL != c) {
		pnode(c);
		c = c->x.next;
	}
}
// -----------------------------------------------------------------------------
// CUpnpHttpFileAccess::SaveL
//
// -----------------------------------------------------------------------------
//
TInt CUpnpHttpFileAccess::SaveL( TDesC8& aBuffer )
{
    LOGS1( "%i, CUpnpHttpFileAccess::SaveL()", this );
    if ( iIsDeleted )
    {
        LOGS( "file closed" );
        return KErrGeneral;
    }
    LOGS( "file not closed" );
    TInt toWrite = (EncodingMode( )|| (TransferTotal( ) == KErrNotFound ) )
                   ? aBuffer.Length( ) : (TransferTotal( )- iBytesWritten);

    if ( aBuffer.Size( ) < toWrite )
    {
        toWrite = aBuffer.Size( );
    }

    if ( UpnpFileUtil::CheckDiskSpaceShortL( iFileToServe->Des( ), toWrite,
            iFsSession ) )
    {
        DeleteFile( );
        return EHttpInsufficientStorage;
    }

    TInt error = KErrNone;

    // At first time iPosInFile == 0 or range offset, see ConstructL, and the next time
    // saving will continue at stopped point.

    error = iFile.Write( iPosInFile, aBuffer.Right( toWrite ) );
    if ( error != KErrNone )
    {
        return error;
    }
    iPosInFile += toWrite;
    iBytesWritten += toWrite;
    return KErrNone;

}
Пример #29
0
/***********************************************************************
 *  exit()
 ***********************************************************************/
int crypt0_exit(void *ptr)
{
	crypt0_t *c = ptr;
	FUN("crypt0_exit");

	if (NULL == ptr) {
		LOGS(L_CRYPTO,L_ERROR,("pptr is NULL\n"));
		errno = EINVAL;
		return -1;
	}
	if (CRYPT0_MAGIC != c->magic) {
		LOGS(L_CRYPTO,L_ERROR,("magic is %x (!= %x)\n",
			c->magic, CRYPT0_MAGIC));
		errno = EINVAL;
		return -1;
	}

	memset(c, 0, sizeof(*c));
	xfree(ptr);

	return 0;
}
Пример #30
0
/**
 * \copydoc Controller::run()
 */
bool UpdateController::run() {
	addListener(lpStep);
	addListener(&lAutoCorrelator);
	addListener(&lParameterSum);
	// Run lPhase2N2subphases sub phases
	lpStep->setGain(lGainInitial);
	for (int subphase = 0; subphase < lNSubphases; ++subphase) {
		const pair<int, int> n = calculateNIterations(subphase);
		LOGS(Priority::INFO)<<"\n\n=== start subphase ==========="
		<<"\nSubphase: "<<subphase
		<<"\nIterations: ["<<n.first<<".."<<n.second<<"]"
		<<"\n==============================\n";
		retryPhase(n);
		// Reduce gain
		lpStep->setGain(lpStep->getGain() * lGainDecay);
		LOGS(Priority::VERBOSE)<<"reduced gain to: "<<lpStep->getGain();
	}
	removeListener(&lParameterSum);
	removeListener(&lAutoCorrelator);
	removeListener(lpStep);
	return true;
}