Example #1
0
ChEXPORT void WrdStringTable::appendString (const ChCHAR2* in_pData, ChUINT2 in_unNumberOfCharacters, ChWriter* pOverwriteInfo)
{
    ChAutoPtr<CsString> pString(ChNEW CsString);
	pString->append(in_pData, in_unNumberOfCharacters);
	pString->SetOverwriteInfo(pOverwriteInfo);
    m_strings.push_back(pString.get());
    pString.giveUpOwnership();
}
Example #2
0
pString Result::get_summary() const
{
	io::pNode opt_summary = _data->find_node("summary");
	if (!opt_summary) {
		return pString();
	}
	else {
		return opt_summary->to_string();
	}
}
Example #3
0
ChEXPORT WrdStringTable& WrdStringTable::operator= (const WrdStringTable& rhs)
{
    cleanup();
    for (ChUINT4 i = 0; i < rhs.m_strings.size(); ++i)
    {
        ChAutoPtr<CsString> pString(ChNEW CsString);
		*pString = *rhs.m_strings[i];
        m_strings.push_back(pString.get());
        pString.giveUpOwnership();
    }
    return *this;
}
int WPSRegistrar::ProcessDone()
{
	uint32 err;

	err = g_regProtocol.ProcessMessageDone(&m_regInfo, m_msgBuffer );
    if(WSC_SUCCESS != err)
    {
		return err_process_Done;
    }
	printf("\n*****  Successfully processed Message Done\n");
	if (m_regInfo.p_enrolleeInfo) {
		WPSDeviceWasAuthenticated(* ((GUID*) & (m_regInfo.p_enrolleeInfo->uuid)));
	}

	//****** Derivation of UPnP Protected Setup AuthKey and KeyWrapKey ******
    //1. declare and initialize the appropriate buffer objects
	BufferObj kdkBuf(m_regInfo.emsk.GetBuf(), SIZE_256_BITS);
    BufferObj pString((uint8 *)UPNP_PERSONALIZATION_STRING, 
                        strlen(UPNP_PERSONALIZATION_STRING));
    BufferObj keys;

    //2. call the key derivation function
    g_regProtocol.DeriveKey(kdkBuf, pString, 256 + 128, keys);

    //3. split the key into the component keys and store them
    keys.Rewind(keys.Length());
    m_regInfo.UPnPPSauthKey.Reset();
	m_regInfo.UPnPPSkeyWrapKey.Reset();

	m_regInfo.UPnPPSauthKey.Append(SIZE_256_BITS, keys.Pos());
    keys.Advance(SIZE_256_BITS);

    m_regInfo.UPnPPSkeyWrapKey.Append(SIZE_128_BITS, keys.Pos());
	// **** End of key derivation code

	return init;
}
Example #5
0
/**
 * Adds a std::string value to the parameter map.
 * @param comp :: Component to which the new parameter is related
 * @param name :: Name for the new parameter
 * @param value :: Parameter value
 * @param pDescription :: a pointer (may be NULL) to a string, containing
 * parameter's
 * description. If provided, the contents of the string is copied to the
 * parameter's
 * memory
*/
void ParameterMap::addString(const IComponent *comp, const std::string &name,
                             const std::string &value,
                             const std::string *const pDescription) {
  add<std::string>(pString(), comp, name, value, pDescription);
}
BOOL CSocketThreadManager::SpawnThreads(LPCSTR lpClassName)
{
	try
	{
		//Add to this class our thread ID, and a random number
		if (!lpClassName)
		{
			//Calculate our string
			int iStringLength;
			iStringLength=strlen(CSocketThreadManager_Class);

			//Add some size to it
			iStringLength+=50;

			//Allocate the string
			std::auto_ptr<char> pString(new char[iStringLength]);

			//Get our thread ID
			DWORD dwThreadID;
			dwThreadID=GetCurrentThreadId();

			//Get the tick of the system
			DWORD dwProcessID;
			dwProcessID=GetTickCount();
			
			//Create the string
			sprintf(pString.get(),"%s_%lu_%lu",CSocketThreadManager_Class,
											   GetCurrentThreadId(),
											   GetTickCount());

			//And register the window
			//Check if we need to register the class
			if (!m_bRegisteredWindow)
				if (!RegisterClass(pString.get()))
				{
					//Report it
					ReportError("SpawnThreads","Failed to register window!");

					//And quit
					return FALSE;
				}
		
			//Save the class name
			m_sClassName=pString.get();
		}
		else
			m_sClassName=lpClassName;

		//Start creating threads
		//Allocate the thread structure
		m_pThreadData=new ThreadData[m_ulThreadCount];

		//Initialize the data
		for (int iCount=0;iCount<m_ulThreadCount;++iCount)
		{
			m_pThreadData[iCount].bFreeze=FALSE;
			m_pThreadData[iCount].pEvent=NULL;
			m_pThreadData[iCount].hInstance=NULL;
			m_pThreadData[iCount].hWindowHandle=NULL;
			m_pThreadData[iCount].iSocketCount=0;
			m_pThreadData[iCount].iTimeoutCount=0;
			m_pThreadData[iCount].pThread=NULL;
			m_pThreadData[iCount].pCSection=COSManager::CreateCriticalSection();
			m_pThreadData[iCount].pClass=this;
		}

		//Did we have an error?
		BOOL bError;
		bError=FALSE;

		//Our waiting list
		CWaitList aList;

		//Start spawning
		for (int iCounter=0;
			 iCounter<m_ulThreadCount;
			 ++iCounter)
		{
			//Copy the class name
			m_pThreadData[iCounter].sClassName=m_sClassName;

			//Create an event
			m_pThreadData[iCounter].pEvent=COSManager::CreateEvent();

			//Add it to the list
			aList.AddObject(m_pThreadData[iCounter].pEvent,
							TRUE);

			//Set our instance
			m_pThreadData[iCounter].hInstance=m_hInstance;

			//Create extended data
			CreateExtendedData(m_pThreadData[iCounter].aExtension);

			//And create it
			m_pThreadData[iCounter].pThread=COSManager::CreateThread(SocketThread);
			
			//Check the thread has been created
			if (!m_pThreadData[iCounter].pThread->GetThreadID())
			{
				//Report the error
				ReportError("SpawnThreads","Failed to create thread!");

				//We have an error
				bError=TRUE;

				//Exit the loop
				break;
			}
			else
				//Start the thread
				m_pThreadData[iCounter].pThread->Start((LPVOID)&m_pThreadData[iCounter]);
		}

		//Tmp position
		DWORD dwTmp;

		if (aList.Wait(TRUE,
					   dwTmp,
					   THREADS_TIMEOUT))
		{
			//Report the error
			ReportError("SpawnThreads","Timeout waiting for threads!");

			//Close the threads
			CleanThreads(TRUE);

			//Exit
			return FALSE;
		}
		else if (bError)
		{
			//Close the threads
			CleanThreads(FALSE);

			//Exit
			return FALSE;
		}
		else
		{
			//We are OK
			m_bInitialized=TRUE;

			//Done
			return TRUE;
		}
	}
	ERROR_HANDLER_RETURN("SpawnThreads",FALSE)
}