LegacySymmetricProvider::Mode LegacySymmetricProvider::StringToMode(
    const String& Mode)
{
    if (Mode.Compare("aes-128-cbc"))
        return LegacySymmetricProvider::AES_128_CBC;
    if (Mode.Compare("aes-256-cbc"))
        return LegacySymmetricProvider::AES_256_CBC;
    if (Mode.Compare("aes-256-ecb"))
        return LegacySymmetricProvider::AES_256_ECB;
    if (Mode.Compare("aes-128-gcm"))
        return LegacySymmetricProvider::AES_128_GCM;
    if (Mode.Compare("aes-256-gcm"))
        return LegacySymmetricProvider::AES_256_GCM;
    return LegacySymmetricProvider::ERROR_MODE;
}
originType OTTransactionType::GetOriginTypeFromString(const String& strType)
{
    originType theType = originType::origin_error_state;

    if (strType.Compare("not_applicable"))
        theType = originType::not_applicable;
    else if (strType.Compare("origin_market_offer"))
        theType = originType::origin_market_offer;
    else if (strType.Compare("origin_payment_plan"))
        theType = originType::origin_payment_plan;
    else if (strType.Compare("origin_smart_contract"))
        theType = originType::origin_smart_contract;
    else if (strType.Compare("origin_pay_dividend"))
        theType = originType::origin_pay_dividend;
    else
        theType = originType::origin_error_state;

    return theType;
}
Example #3
0
CryptoHash::HashType CryptoHash::StringToHashType(const String& inputString)
{
    if (inputString.Compare("null"))
        return CryptoHash::NONE;
    else if (inputString.Compare("HASH256"))
        return CryptoHash::HASH256;
    else if (inputString.Compare("HASH160"))
        return CryptoHash::HASH160;
    else if (inputString.Compare("SHA224"))
        return CryptoHash::SHA224;
    else if (inputString.Compare("SHA256"))
        return CryptoHash::SHA256;
    else if (inputString.Compare("SHA384"))
        return CryptoHash::SHA384;
    else if (inputString.Compare("SHA512"))
        return CryptoHash::SHA512;
    return CryptoHash::ERROR;
}
Example #4
0
ECode CContentService::ObserverNode::AddObserverLocked(
    /* [in] */ ObserverNode* node,
    /* [in] */ IUri* uri,
    /* [in] */ Int32 index,
    /* [in] */ IContentObserver* observer,
    /* [in] */ Boolean notifyForDescendents)
{
    // If this is the leaf node add the observer
    if (index == CountUriSegments(uri)) {
        AutoPtr<ObserverEntry> oberverEntry = new ObserverEntry(node, observer, notifyForDescendents);
        mObservers->PushBack(oberverEntry);
        return NOERROR;
    }

    // Look to see if the proper child already exists
    String segment = GetUriSegment(uri, index);

    if (segment.IsNull()) {
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }

    List<AutoPtr<ObserverNode> >::Iterator it;

    for (it = mChildren->Begin(); it != mChildren->End(); it++) {
        AutoPtr<ObserverNode> pNode = *it;
        if (!segment.Compare(pNode->mName)) {
            FAIL_RETURN(pNode->AddObserverLocked(node, uri, index+1 , observer, notifyForDescendents));
            return NOERROR;
        }
    }

    // No child found, create one
    AutoPtr<ObserverNode> newNode = new ObserverNode(segment);
    mChildren->PushBack(newNode);
    FAIL_RETURN(newNode->AddObserverLocked(newNode, uri, index+1 , observer, notifyForDescendents));
    return NOERROR;
}
Example #5
0
ECode CContentService::ObserverNode::CollectObserversLocked(
    /* [in] */ ObserverNode* node,
    /* [in] */ IUri* uri,
    /* [in] */ Int32 index,
    /* [in] */ IContentObserver* observer,
    /* [in] */ Boolean selfNotify,
    /* [in] */ List<AutoPtr<ObserverCall> >* calls)
{
    VALIDATE_NOT_NULL(node);
    VALIDATE_NOT_NULL(observer);
    VALIDATE_NOT_NULL(calls);
    String segment;
    Int32 segmentCount = CountUriSegments(uri);
    List<AutoPtr<ObserverNode> >::Iterator it;

    if (index >= segmentCount) {
        // This is the leaf node, notify all observers
        CollectMyObserversLocked(node, TRUE, observer, selfNotify, calls);
    } 
    else if (index < segmentCount){
        segment = GetUriSegment(uri, index);
        // Notify any observers at this level who are interested in descendents
        CollectMyObserversLocked(node, FALSE, observer, selfNotify, calls);
    }

    for (it = mChildren->Begin(); it != mChildren->End(); it++) {
        AutoPtr<ObserverNode> pNode = *it;
        if (segment.IsNull() || !segment.Compare(pNode->mName)) {
            FAIL_RETURN(pNode->CollectObserversLocked(pNode, uri, index+1, observer, selfNotify, calls));
            if (!segment.IsNull()) {
                break;
            }
        }
    }

    return NOERROR;
}
void PipeAudioSource::OnAudioDeviceChanged(const String &MonitorDevices, const String &SecMonitor)
{
	if (this->MonitorDevices.Compare(MonitorDevices.Array()) && this->SecMonitor.Compare(SecMonitor.Array()))
	{
		return;
	}

	Log::writeMessage(LOG_RTSPSERV, 1, "%s invoke begin!", __FUNCTION__);
	OSEnterMutex(hAudioMutex);

	bSameDevice = false;

	if (m_pAudioWaveOut)
	{
		m_pAudioWaveOut->Uninitialize();
	}

	if (NULL == m_pAudioWaveOut)
	{
		if (!MonitorDevices.Compare(TEXT("停用")) && !m_pAudioWaveOut)
		{
			m_pAudioWaveOut = new AudioWaveOut;
		}
	}
	else
	{
		if ((MonitorDevices.Compare(TEXT("Disable")) || MonitorDevices.Compare(TEXT("停用"))))
		{
			delete m_pAudioWaveOut;
			m_pAudioWaveOut = NULL;
		}
	}
	if (NULL != m_pAudioWaveOut)
	{
		m_pAudioWaveOut->Initialize(MonitorDevices.Array(), 2, Param.samplesPerSec, Param.bitsPerSample);
	}

	if (m_pSecWaveOut)
	{
		m_pSecWaveOut->Uninitialize();
	}

	if (SecMonitor.CompareI(MonitorDevices.Array()) && (!SecMonitor.Compare(TEXT("Disable")) || !SecMonitor.Compare(TEXT("停用"))))
	{
		bSameDevice = true;
	}
	else if (!SecMonitor.Compare(TEXT("停用")) && !m_pSecWaveOut)
	{
		m_pSecWaveOut = new AudioWaveOut;
	}
	else if (m_pSecWaveOut)
	{
		if ((SecMonitor.Compare(TEXT("Disable")) || SecMonitor.Compare(TEXT("停用"))))
		{
			delete m_pSecWaveOut;
			m_pSecWaveOut = NULL;
		}
	}

	if (m_pSecWaveOut)
	{
		m_pSecWaveOut->Initialize(SecMonitor.Array(), 2, Param.samplesPerSec, Param.bitsPerSample);
	}

	OSLeaveMutex(hAudioMutex);

	this->MonitorDevices = MonitorDevices;
	this->SecMonitor = SecMonitor;

	Log::writeMessage(LOG_RTSPSERV, 1, "%s invoke end!", __FUNCTION__);
}
bool PipeAudioSource::Initialize(PipeVideo *parent, const AudioParam& param)
{
	m_iLastPts = 0;
	m_iBlockSize = 0;
	Times = 0;
	LimitGetData = 0;
	m_PipeVideo = parent;

	if (!hAudioMutex)
	{
		hAudioMutex = OSCreateMutex();
	}

    bool bFloat = false;
    UINT  inputChannels;
    UINT  inputSamplesPerSec;
    UINT  inputBitsPerSample;
    DWORD inputChannelMask;

	inputBitsPerSample = param.bitsPerSample; // 16;
    inputChannelMask   = 0;
	inputChannels = param.channels; // 1;
	inputSamplesPerSec = param.samplesPerSec; // 8000;

	m_iBlockSize = inputChannels * inputBitsPerSample / 8;

    sampleFrameCount   = inputSamplesPerSec / 100;
	sampleSegmentSize = m_iBlockSize * sampleFrameCount;

	Param = param;
	m_isFirstDiffTimeWithAPI = true;
	m_lTimeDiffWithAPI = 0;
	m_iLastTimeStamp = 0;
    outputBuffer.SetSize(sampleSegmentSize);
	InitAudioData(bFloat, inputChannels, inputSamplesPerSec, inputBitsPerSample, m_iBlockSize, inputChannelMask);

	if (m_pAudioWaveOut)
	{
		m_pAudioWaveOut->Uninitialize();
	}

	String strReanderName = GetDirectorMonitorDevices();
	if (NULL == m_pAudioWaveOut)
	{
		if (!strReanderName.Compare(TEXT("停用")) && !m_pAudioWaveOut)
		{
			m_pAudioWaveOut = new AudioWaveOut;
		}
	}
	else
	{
		if ((strReanderName.Compare(TEXT("Disable")) || strReanderName.Compare(TEXT("停用"))))
		{
			delete m_pAudioWaveOut;
			m_pAudioWaveOut = NULL;
		}
	}

	if (NULL != m_pAudioWaveOut)
	{
		m_pAudioWaveOut->Initialize(strReanderName.Array(), 2, inputSamplesPerSec, inputBitsPerSample);
	}

	String SecRenderName = GetSecMonitorDevices();


	if (m_pSecWaveOut)
	{
		m_pSecWaveOut->Uninitialize();
	}

	if (SecRenderName.CompareI(strReanderName.Array()) && (!SecRenderName.Compare(TEXT("Disable")) || !SecRenderName.Compare(TEXT("停用"))))
	{
		bSameDevice = true;
	}
	else if (!SecRenderName.Compare(TEXT("停用")) && !m_pSecWaveOut)
	{
		m_pSecWaveOut = new AudioWaveOut;
	}
	else if (m_pSecWaveOut)
	{
		if ((SecRenderName.Compare(TEXT("Disable")) || SecRenderName.Compare(TEXT("停用"))))
		{
			delete m_pSecWaveOut;
			m_pSecWaveOut = NULL;
		}
	}

	if (m_pSecWaveOut)
	{
		m_pSecWaveOut->Initialize(SecRenderName.Array(), 2, inputSamplesPerSec, inputBitsPerSample);
	}

    return true;
}
Example #8
0
//-----------------------------------------------------------------------------------------------------------------------------------------------------
VOID Configuration::LoadCommandLine(String CmdLineString)
{
  Array<String> Tokens;
  String CurrentToken;

  SIZE_T i = 0;
  enum { WHITESPACE, TEXT, QUOTEDTEXT } State = WHITESPACE;

  while (i < CmdLineString.Length())
  {
    switch(State)
    {
    case WHITESPACE:
      if (CmdLineString(i) == '\"')
      {
        State = QUOTEDTEXT;
        break;
      }
      else if (!String::IsWhitespace(CmdLineString(i)))
      {
        State = TEXT;
        CurrentToken += CmdLineString(i);
        break;
      }
      break;
    case QUOTEDTEXT:
      if (CmdLineString(i) == '\\' && CmdLineString(i+1) == '\"')
      {
        CurrentToken += '\"';
        i++;
        break;
      }
      else if (CmdLineString(i) == '\"')
      {
        if (String::IsWhitespace(CmdLineString(i+1)))
        {
          State = WHITESPACE;
          Tokens.Add(CurrentToken);
          CurrentToken = String::Empty;
          break;
        }
        else
          State = TEXT;
      }
      CurrentToken += CmdLineString(i);
      break;
    case TEXT:
      if (String::IsWhitespace(CmdLineString(i)))
      {
        State = WHITESPACE;
        Tokens.Add(CurrentToken);
        CurrentToken = String::Empty;
        break;
      }
      else if (CmdLineString(i) == '\"')
      {
        State = QUOTEDTEXT;
        break;
      }
      CurrentToken += CmdLineString(i);
      break;
      
    };

    i++;
  };

  if (State == TEXT || State == QUOTEDTEXT)
    Tokens.Add(CurrentToken);

  SIZE_T ValueIndex = 0;
  SIZE_T ValueItemIndex = 0;

  for (SIZE_T i=1; i<Tokens.Length(); i++)
  {
    if (Tokens(i)(0) == '/')
    {
      ValueItemIndex = 0;
      ValueIndex++;
      
      String::Iterator Colon = Tokens(i).Find(TEXT(":"));
      if (Colon == Tokens(i).End())
      {
        String FlagName = Tokens(i).Substr(1);
        if (FlagName.Compare( TEXT("?"), FALSE) == 0 || FlagName.Compare( TEXT("Help"), FALSE) == 0 )
          return;

        if (m_NameMapping.Contains(FlagName))
          FlagName = m_NameMapping[FlagName];
        
        if (m_Schema.Contains(FlagName))
        {
          Item& I = m_Schema[FlagName];
          I.m_Count = 1;
          I.m_Present = TRUE;
          SetValue<String>(FlagName, "1");
        }

      }
      else
      {
        String Key = Tokens(i).Substr( Tokens(i).Begin()+1, Colon );
        String Value = Tokens(i).Substr( Colon+1 );

        if (m_NameMapping.Contains(Key))
          Key = m_NameMapping[Key];
        
        if (m_Schema.Contains(Key))
        {
          Item& I = m_Schema[Key];
          I.m_Count = 1;
          I.m_Present = TRUE;
          SetValue<String>(Key, Value);
        }
      }
    }
    else
    {
      if (ValueIndex < m_CommandLineBindings.Length())
      {
        String Name = m_CommandLineBindings[ValueIndex];
        Item& I = m_Schema[Name];

        if (I.m_IsList)
        {
          if (!m_ConfigListValues.Contains(Name))
            m_ConfigListValues.Add(Name, StringArray());
          m_ConfigListValues[Name].Add(Tokens(i));
        }
        else
        {
          SetValue<String>(Name, Tokens(i));
        }
        
        ValueItemIndex++;
        if (ValueItemIndex >= I.m_MaximumCount)
        {
          ValueItemIndex = 0;
          ValueIndex++;
        }
      }
    }

	}

}
Example #9
0
void HttpRequest::ThreadFunction()
{
#ifndef UWP //TODO: fix UWP
    String protocol = "http";
    String host;
    String path = "/";
    int port = 80;

    unsigned protocolEnd = url_.Find("://");
    if (protocolEnd != String::NPOS)
    {
        protocol = url_.Substring(0, protocolEnd);
        host = url_.Substring(protocolEnd + 3);
    }
    else
        host = url_;

    unsigned pathStart = host.Find('/');
    if (pathStart != String::NPOS)
    {
        path = host.Substring(pathStart);
        host = host.Substring(0, pathStart);
    }

    unsigned portStart = host.Find(':');
    if (portStart != String::NPOS)
    {
        port = ToInt(host.Substring(portStart + 1));
        host = host.Substring(0, portStart);
    }

    char errorBuffer[ERROR_BUFFER_SIZE];
    memset(errorBuffer, 0, sizeof(errorBuffer));

    String headersStr;
    for (unsigned i = 0; i < headers_.Size(); ++i)
    {
        // Trim and only add non-empty header strings
        String header = headers_[i].Trimmed();
        if (header.Length())
            headersStr += header + "\r\n";
    }

    // Initiate the connection. This may block due to DNS query
    /// \todo SSL mode will not actually work unless Civetweb's SSL mode is initialized with an external SSL DLL
    mg_connection* connection = 0;
    if (postData_.Empty())
    {
        connection = mg_download(host.CString(), port, protocol.Compare("https", false) ? 0 : 1, errorBuffer, sizeof(errorBuffer),
            "%s %s HTTP/1.0\r\n"
            "Host: %s\r\n"
            "%s"
            "\r\n", verb_.CString(), path.CString(), host.CString(), headersStr.CString());
    }
    else
    {
        connection = mg_download(host.CString(), port, protocol.Compare("https", false) ? 0 : 1, errorBuffer, sizeof(errorBuffer),
            "%s %s HTTP/1.0\r\n"
            "Host: %s\r\n"
            "%s"
            "Content-Length: %d\r\n"
            "\r\n"
            "%s", verb_.CString(), path.CString(), host.CString(), headersStr.CString(), postData_.Length(), postData_.CString());
    }

    {
        MutexLock lock(mutex_);
        state_ = connection ? HTTP_OPEN : HTTP_ERROR;

        // If no connection could be made, store the error and exit
        if (state_ == HTTP_ERROR)
        {
            error_ = String(&errorBuffer[0]);
            return;
        }
    }

    // Loop while should run, read data from the connection, copy to the main thread buffer if there is space
    while (shouldRun_)
    {
        // Read less than full buffer to be able to distinguish between full and empty ring buffer. Reading may block
        int bytesRead = mg_read(connection, httpReadBuffer_.Get(), READ_BUFFER_SIZE / 4);
        if (bytesRead <= 0)
            break;

        mutex_.Acquire();

        // Wait until enough space in the main thread's ring buffer
        for (;;)
        {
            unsigned spaceInBuffer = READ_BUFFER_SIZE - ((writePosition_ - readPosition_) & (READ_BUFFER_SIZE - 1));
            if ((int)spaceInBuffer > bytesRead || !shouldRun_)
                break;

            mutex_.Release();
            Time::Sleep(5);
            mutex_.Acquire();
        }

        if (!shouldRun_)
        {
            mutex_.Release();
            break;
        }

        if (writePosition_ + bytesRead <= READ_BUFFER_SIZE)
            memcpy(readBuffer_.Get() + writePosition_, httpReadBuffer_.Get(), (size_t)bytesRead);
        else
        {
            // Handle ring buffer wrap
            unsigned part1 = READ_BUFFER_SIZE - writePosition_;
            unsigned part2 = bytesRead - part1;
            memcpy(readBuffer_.Get() + writePosition_, httpReadBuffer_.Get(), part1);
            memcpy(readBuffer_.Get(), httpReadBuffer_.Get() + part1, part2);
        }

        writePosition_ += bytesRead;
        writePosition_ &= READ_BUFFER_SIZE - 1;

        mutex_.Release();
    }

    // Close the connection
    mg_close_connection(connection);

    {
        MutexLock lock(mutex_);
        state_ = HTTP_CLOSED;
    }
#endif
}
bool MapperTestDAImpl::Exec( Context &context, ParameterMapper *input, ResultMapper *output)
{
	StartTrace1(MapperTestDAImpl.Exec, fName);
	Anything config, anyDataType;
	TraceAny(fConfig, "fConfig: ");
	String strMode;
	if ( input->Get("DataType", anyDataType, context) ) {
		strMode = anyDataType.AsString();
	} else {
		strMode = "String";
	}
	Trace("DataType is [" << strMode << "]");

	if ( input->Get("transfer", config, context) ) {
		TraceAny(config, "Config: ");
		for (long i = 0, sz=config.GetSize(); i < sz; i++) {
			String strGetKey, strPutKey;
			Anything anyEntry = config[i];
			strGetKey = config.SlotName(i);
			if ( anyEntry.GetType() == AnyArrayType ) { //<! assume unnamed configuration entries { /getKey putKey }
				strGetKey = anyEntry.SlotName(0L);
				anyEntry = anyEntry[0L];
			}
			strPutKey = anyEntry.AsString();
			Trace("get key [" << strGetKey << "] put key [" << strPutKey << "]");
			if (strGetKey.Length()) {
				String inputStr(128L);
				bool bGetCode, bPutCode = false;
				if (strMode.Compare("int") == 0) {
					int iTestVal = 0;
					bGetCode = input->Get(strGetKey, iTestVal, context);
					if (bGetCode) {
						bPutCode = output->Put(strPutKey, iTestVal, context);
						Trace("From [" << strGetKey << "] to [" << strPutKey << "]: [" << (long)iTestVal << "]");
					}
				} else if (strMode.Compare("long") == 0) {
					long lTestVal = 0L;
					bGetCode = input->Get(strGetKey, lTestVal, context);
					if (bGetCode) {
						bPutCode = output->Put(strPutKey, lTestVal, context);
						Trace("From [" << strGetKey << "] to [" << strPutKey << "]: [" << lTestVal << "]");
					}
				} else if (strMode.Compare("bool") == 0) {
					bool bTestVal = false;
					bGetCode = input->Get(strGetKey, bTestVal, context);
					if (bGetCode) {
						bPutCode = output->Put(strPutKey, bTestVal, context);
						Trace("From [" << strGetKey << "] to [" << strPutKey << "]: [" << (bTestVal ? "true" : "false") << "]");
					}
				} else if (strMode.Compare("float") == 0) {
					float fTestVal = 0.0F;
					bGetCode = input->Get(strGetKey, fTestVal, context);
					if (bGetCode) {
						bPutCode = output->Put(strPutKey, fTestVal, context);
						Trace("From [" << strGetKey << "] to [" << strPutKey << "]: [" << fTestVal << "]");
					}
				} else if (strMode.Compare("double") == 0) {
					double dTestVal = 0.0;
					bGetCode = input->Get(strGetKey, dTestVal, context);
					if (bGetCode) {
						bPutCode = output->Put(strPutKey, dTestVal, context);
						Trace("From [" << strGetKey << "] to [" << strPutKey << "]: [" << dTestVal << "]");
					}
				} else if (strMode.Compare("Anything") == 0) {
					Anything aTestVal;
					bGetCode = input->Get(strGetKey, aTestVal, context);
					if (bGetCode) {
						bPutCode = output->Put(strPutKey, aTestVal, context);
						StringStream Ios(inputStr);
						aTestVal.PrintOn(Ios);
						Ios << std::flush;
						Trace("From [" << strGetKey << "] to [" << strPutKey << "]: [" << inputStr << "]");
					}
				} else if (strMode.Compare("StringStream") == 0) {
					StringStream Ios(inputStr);
					bGetCode = input->Get(strGetKey, Ios, context);
					Ios << std::flush;
					if (bGetCode) {
						bPutCode = output->Put(strPutKey, Ios, context);
						Trace("From [" << strGetKey << "] to [" << strPutKey << "]: [" << inputStr << "]");
					}
				} else {
					// default is String mode
					String sTestVal = "";
					bGetCode = input->Get(strGetKey, sTestVal, context);
					if (bGetCode) {
						bPutCode = output->Put(strPutKey, sTestVal, context);
						Trace("From [" << strGetKey << "] to [" << strPutKey << "]: [" << sTestVal << "]");
					}
				}
				Trace("GetCode: " << (bGetCode ? "true" : "false") << " PutCode: " << (bPutCode ? "true" : "false"));
			}
		}
		Trace("ret: true");
		return true;
	}
	Trace("ret: false");
	return false;
}
Example #11
0
// return -1 if error, 0 if nothing, and 1 if the node was processed.
int32_t OTOffer::ProcessXMLNode(irr::io::IrrXMLReader*& xml)
{
    int32_t nReturnVal = 0;

    // Here we call the parent class first.
    // If the node is found there, or there is some error,
    // then we just return either way.  But if it comes back
    // as '0', then nothing happened, and we'll continue executing.
    //
    // -- Note you can choose not to call the parent if
    // you don't want to use any of those xml tags.
    // As I do below, in the case of OTAccount.
    // if (nReturnVal = Contract::ProcessXMLNode(xml))
    //    return nReturnVal;

    if (!strcmp("marketOffer", xml->getNodeName())) {
        m_strVersion = xml->getAttributeValue("version");

        String strIsSelling;
        strIsSelling = xml->getAttributeValue("isSelling");
        if (strIsSelling.Compare("true"))
            m_bSelling = true;
        else
            m_bSelling = false;

        m_strContractType.Set((m_bSelling ? "ASK" : "BID"));

        const String strNotaryID(xml->getAttributeValue("notaryID")),
            strInstrumentDefinitionID(
                xml->getAttributeValue("instrumentDefinitionID")),
            strCurrencyTypeID(xml->getAttributeValue("currencyTypeID"));

        const Identifier NOTARY_ID(strNotaryID),
            INSTRUMENT_DEFINITION_ID(strInstrumentDefinitionID),
            CURRENCY_TYPE_ID(strCurrencyTypeID);

        SetNotaryID(NOTARY_ID);
        SetInstrumentDefinitionID(INSTRUMENT_DEFINITION_ID);
        SetCurrencyID(CURRENCY_TYPE_ID);

        const String strScale = xml->getAttributeValue("marketScale");
        const int64_t lScale =
            strScale.Exists() ? strScale.ToLong() : 0; // if it doesn't exist,
                                                       // the 0 here causes the
                                                       // below error to fire.

        if (!isPowerOfTen(lScale)) {
            otOut << "OTOffer::ProcessXMLNode: Failure: marketScale *must* be "
                     "1, or a power of 10. Instead I got: " << lScale << ".\n";
            return (-1);
        }
        else
            SetScale(lScale);

        const String strPriceLimit = xml->getAttributeValue("priceLimit");
        const int64_t lPriceLimit = strPriceLimit.Exists()
                                        ? strPriceLimit.ToLong()
                                        : 0; // if it doesn't exist, the 0 here
                                             // causes the below error to fire.

        // NOTE: Market Orders (new) have a 0 price, so this error condition was
        // changed.
        if (!strPriceLimit.Exists())
        //      if (lPriceLimit < 1)
        {
            otOut << "OTOffer::ProcessXMLNode: Failure: priceLimit *must* be "
                     "provided(" << lPriceLimit << ").\n";
            return (-1);
        }
        else
            SetPriceLimit(lPriceLimit);

        const String strTotal = xml->getAttributeValue("totalAssetsOnOffer");
        const int64_t lTotal =
            strTotal.Exists() ? strTotal.ToLong() : 0; // if it doesn't exist,
                                                       // the 0 here causes the
                                                       // below error to fire.
        if (lTotal < 1) {
            otOut << "OTOffer::ProcessXMLNode: Failure: totalAssetsOnOffer "
                     "*must* be larger than 0. Instead I got: " << lTotal
                  << ".\n";
            return (-1);
        }
        else
            SetTotalAssetsOnOffer(lTotal);

        const String strFinished = xml->getAttributeValue("finishedSoFar");
        const int64_t lFinished = strFinished.Exists()
                                      ? strFinished.ToLong()
                                      : 0; // if it doesn't exist, the 0 here
                                           // causes the below error to fire.
        if (lFinished < 0) {
            otOut << "OTOffer::ProcessXMLNode: Failure: finishedSoFar *must* "
                     "be 0 or larger. Instead I got: " << lFinished << ".\n";
            return (-1);
        }
        else
            SetFinishedSoFar(lFinished);

        const String strMinInc = xml->getAttributeValue("minimumIncrement");
        // if it doesn't exist, the 0 here causes the below error to fire.
        const int64_t lMinInc = strMinInc.Exists() ? strMinInc.ToLong() : 0;

        if ((lMinInc < 1) || (lMinInc > lTotal)) // Minimum increment cannot
                                                 // logically be higher than the
                                                 // total assets on offer...
        {
            otOut << "OTOffer::ProcessXMLNode: Failure: minimumIncrement "
                     "*must* be 1 or larger, \n"
                     "and must also be less than the total assets on offer. "
                     "Instead I got: " << lMinInc << ".\n";
            return (-1);
        }
        else
            SetMinimumIncrement(lMinInc);

        const String strTransNum = xml->getAttributeValue("transactionNum");
        const int64_t lTransNum =
            strTransNum.Exists() ? strTransNum.ToLong() : 0;

        SetTransactionNum(lTransNum);

        const String str_valid_from = xml->getAttributeValue("validFrom");
        const String str_valid_to = xml->getAttributeValue("validTo");

        int64_t tValidFrom =
            str_valid_from.Exists() ? parseTimestamp(str_valid_from.Get()) : 0;
        int64_t tValidTo =
            str_valid_to.Exists() ? parseTimestamp(str_valid_to.Get()) : 0;

        if ((tValidTo < tValidFrom) && (tValidTo != 0)) {
            otOut << "OTOffer::" << __FUNCTION__ << ": Failure: validTo date ("
                  << tValidFrom << ") cannot be earlier than "
                                   "validFrom date (" << tValidTo << ").\n";
            return (-1);
        }

        SetValidFrom(OTTimeGetTimeFromSeconds(tValidFrom));
        SetValidTo(OTTimeGetTimeFromSeconds(tValidTo));

        otLog4 << "\n\nOffer. Transaction Number: " << m_lTransactionNum
               << "\n Valid From: " << tValidFrom << "\n Valid To: " << tValidTo
               << "\n"
                  " InstrumentDefinitionID: " << strInstrumentDefinitionID
               << "\n  CurrencyTypeID: " << strCurrencyTypeID
               << "\n NotaryID: " << strNotaryID
               << "\n"
                  " Price Limit: " << GetPriceLimit()
               << ",  Total Assets on Offer: " << GetTotalAssetsOnOffer()
               << ",  " << (m_bSelling ? "sold" : "bought")
               << " so far: " << GetFinishedSoFar() << "\n "
                                                       " Scale: " << GetScale()
               << ".   Minimum Increment: " << GetMinimumIncrement()
               << ".  This offer is a" << (m_bSelling ? "n ASK" : " BID")
               << ".\n";

        nReturnVal = 1;
    }

    return nReturnVal;
}