Example #1
0
bool OGRDXFWriterDS::WriteNewLayerDefinitions( VSILFILE * fpOut )

{
    const int nNewLayers = CSLCount(papszLayersToCreate);

    for( int iLayer = 0; iLayer < nNewLayers; iLayer++ )
    {
        for( unsigned i = 0; i < aosDefaultLayerText.size(); i++ )
        {
            if( anDefaultLayerCode[i] == 2 )
            {
                if( !WriteValue( fpOut, 2, papszLayersToCreate[iLayer] ) )
                    return false;
            }
            else if( anDefaultLayerCode[i] == 5 )
            {
                WriteEntityID( fpOut );
            }
            else
            {
                if( !WriteValue( fpOut,
                                 anDefaultLayerCode[i],
                                 aosDefaultLayerText[i] ) )
                    return false;
            }
        }
    }

    return true;
}
Example #2
0
long OGRDXFWriterDS::WriteEntityID( VSILFILE *fpIn, long nPreferredFID )

{
    CPLString osEntityID;

    if( nPreferredFID != OGRNullFID )
    {

        osEntityID.Printf( "%X", (unsigned int) nPreferredFID );
        if( !CheckEntityID( osEntityID ) )
        {
            aosUsedEntities.insert( osEntityID );
            WriteValue( fpIn, 5, osEntityID );
            return nPreferredFID;
        }
    }

    do
    {
        osEntityID.Printf( "%X", nNextFID++ );
    }
    while( CheckEntityID( osEntityID ) );

    aosUsedEntities.insert( osEntityID );
    WriteValue( fpIn, 5, osEntityID );

    return nNextFID - 1;
}
Example #3
0
void JsonExpressFormater::WriteExpression(stringx name, ref<JsonNode> node, ref<StringBuilder> sb, int level)
{
	switch (node->GetType())
	{
	case JSN_String:
		WriteValue(name, '\"' + node->TextValue() + '\"', sb, level);
		break;
	case JSN_Integer:
		WriteValue(name, Converter::ToString(node->IntValue()), sb, level);
		break;
	case JSN_Boolean:
		WriteValue(name, node->BoolValue() ? __X("true") : __X("false"), sb, level);
		break;
	case JSN_None:
		WriteValue(name, __X("null"), sb, level);
		break;
	case JSN_Dictionary:
		WriteSubDictionary(name, node, sb, level);
		break;
	case JSN_NodeList:
		WriteSubList(name, node, sb, level);
		break;
	default:
		cdec_throw(JsonException(EC_JSON_NotImplemented, 0));
	}
}
    void AnalyzeData(std::istream& in, std::ostream& out, uint32_t current_time)
    {
        TypeStatistic stat(c_max_message_type+1);
        Data message;
        while (in >> message)
        {
            DataStatistic& act = stat[message.type];

            if ((act.message_count) &&(act.current_time != message.time))
                act.current_buff_size = 0;

            if (act.current_buff_size + message.size <= c_max_message_size)
            {
                act.current_time = message.time;
                if (act.current_buff_size == 0) // first message in this time
                {
                    ++act.time_count;
                }

                act.current_buff_size += message.size;
                ++act.message_count;
            }
        }

        for(uint32_t i = 0; i <= c_max_message_type; ++i)
            if (stat[i].time_count)
            {
                WriteValue(out, i);
                WriteValue(out, stat[i].message_count*1.0/stat[i].time_count);
            }
    };
Example #5
0
/////////////////////////////////////////////////////////////////////
/// Partitions a rectangular region of a given subband.
/// Partitioning scheme: The plane is partitioned in squares of side length LinBlockSize.
/// Write wavelet coefficients from subband into the input buffer of a macro block.
/// It might throw an IOException.
/// @param band A subband
/// @param width The width of the rectangle
/// @param height The height of the rectangle
/// @param startPos The absolute subband position of the top left corner of the rectangular region
/// @param pitch The number of bytes in row of the subband
void CEncoder::Partition(CSubband* band, int width, int height, int startPos, int pitch) {
	ASSERT(band);

	const div_t hh = div(height, LinBlockSize);
	const div_t ww = div(width, LinBlockSize);
	const int ws = pitch - LinBlockSize;
	const int wr = pitch - ww.rem;
	int pos, base = startPos, base2;

	// main height
	for (int i=0; i < hh.quot; i++) {
		// main width
		base2 = base;
		for (int j=0; j < ww.quot; j++) {
			pos = base2;
			for (int y=0; y < LinBlockSize; y++) {
				for (int x=0; x < LinBlockSize; x++) {
					WriteValue(band, pos);
					pos++;
				}
				pos += ws;
			}
			base2 += LinBlockSize;
		}
		// rest of width
		pos = base2;
		for (int y=0; y < LinBlockSize; y++) {
			for (int x=0; x < ww.rem; x++) {
				WriteValue(band, pos);
				pos++;
			}
			pos += wr;
			base += pitch;
		}
	}
	// main width
	base2 = base;
	for (int j=0; j < ww.quot; j++) {
		// rest of height
		pos = base2;
		for (int y=0; y < hh.rem; y++) {
			for (int x=0; x < LinBlockSize; x++) {
				WriteValue(band, pos);
				pos++;
			}
			pos += ws;
		}
		base2 += LinBlockSize;
	}
	// rest of height
	pos = base2;
	for (int y=0; y < hh.rem; y++) {
		// rest of width
		for (int x=0; x < ww.rem; x++) {
			WriteValue(band, pos);
			pos++;
		}
		pos += wr;
	}
}
Example #6
0
bool CBratSettings::SaveConfigSelectionCriteria()
{
	CMapProduct& mapProductInstance = CMapProduct::GetInstance();
	for ( CObMap::iterator it = mapProductInstance.begin(); it != mapProductInstance.end(); it++ )
	{
		CProduct* product = dynamic_cast<CProduct*>( it->second );
		if ( product == nullptr || !product->HasCriteriaInfo() )
			continue;

		std::string config_path = BuildComposedKey( { GROUP_SEL_CRITERIA, product->GetLabel() } );		
		{
			CSection section( mSettings, config_path );
			if ( product->IsSetLatLonCriteria() )
				WriteValue( section, ENTRY_LAT_LON, product->GetLatLonCriteria()->GetAsText() );

			if ( product->IsSetDatetimeCriteria() )
				WriteValue( section, ENTRY_DATETIME, product->GetDatetimeCriteria()->GetAsText() );

			if ( product->IsSetCycleCriteria() )
				WriteValue( section, ENTRY_CYCLE, product->GetCycleCriteria()->GetAsText() );

			if ( product->IsSetPassIntCriteria() )
				WriteValue( section, ENTRY_PASS_NUMBER, product->GetPassIntCriteria()->GetAsText() );

			if ( product->IsSetPassStringCriteria() )
				WriteValue( section, ENTRY_PASS_STRING, product->GetPassStringCriteria()->GetAsText() );
		}

		Sync();
	}

	return mSettings.status() == QSettings::NoError;
}
Example #7
0
int CGXCommunication::ReadScalerAndUnits()
{
    int ret = 0;
    std::string str;
    std::string ln;
    std::vector<std::pair<CGXDLMSObject*, unsigned char> > list;
    if ((m_Parser->GetNegotiatedConformance() & DLMS_CONFORMANCE_MULTIPLE_REFERENCES) != 0)
    {
        // Read scalers and units from the device.
        for (std::vector<CGXDLMSObject*>::iterator it = m_Parser->GetObjects().begin(); it != m_Parser->GetObjects().end(); ++it)
        {
            if ((*it)->GetObjectType() == DLMS_OBJECT_TYPE_REGISTER ||
                (*it)->GetObjectType() == DLMS_OBJECT_TYPE_EXTENDED_REGISTER)
            {
                list.push_back(std::make_pair(*it, 3));
            }
            else if ((*it)->GetObjectType() == DLMS_OBJECT_TYPE_DEMAND_REGISTER)
            {
                list.push_back(std::make_pair(*it, 4));
            }
        }
        if ((ret = ReadList(list)) != 0)
        {
            printf("Err! Failed to read register: %s", CGXDLMSConverter::GetErrorMessage(ret));
            m_Parser->SetNegotiatedConformance((DLMS_CONFORMANCE)(m_Parser->GetNegotiatedConformance() & ~DLMS_CONFORMANCE_MULTIPLE_REFERENCES));
        }
    }
    if ((m_Parser->GetNegotiatedConformance() & DLMS_CONFORMANCE_MULTIPLE_REFERENCES) == 0)
    {
        //If readlist is not supported read one value at the time.
        for (std::vector<CGXDLMSObject*>::iterator it = m_Parser->GetObjects().begin(); it != m_Parser->GetObjects().end(); ++it)
        {
            if ((*it)->GetObjectType() == DLMS_OBJECT_TYPE_REGISTER ||
                (*it)->GetObjectType() == DLMS_OBJECT_TYPE_EXTENDED_REGISTER)
            {
                (*it)->GetLogicalName(ln);
                WriteValue(m_Trace, ln.c_str());
                if ((ret = Read(*it, 3, str)) != 0)
                {
                    printf("Err! Failed to read register: %s %s", ln.c_str(), CGXDLMSConverter::GetErrorMessage(ret));
                    //Continue reading.
                    continue;
                }
            }
            else if ((*it)->GetObjectType() == DLMS_OBJECT_TYPE_DEMAND_REGISTER)
            {
                (*it)->GetLogicalName(ln);
                WriteValue(m_Trace, ln.c_str());
                if ((ret = Read(*it, 4, str)) != 0)
                {
                    printf("Err! Failed to read register: %s %s", ln.c_str(), CGXDLMSConverter::GetErrorMessage(ret));
                    //Continue reading.
                    continue;
                }
            }
        }
    }
    return ret;
}
Example #8
0
SQLRETURN SQL_API
SQLExtendedFetch(SQLHSTMT StatementHandle,
		 SQLUSMALLINT FetchOrientation,
		 SQLLEN FetchOffset,
#ifdef BUILD_REAL_64_BIT_MODE	/* note: only defined on Debian Lenny */
		 SQLUINTEGER  *RowCountPtr,
#else
		 SQLULEN *RowCountPtr,
#endif
		 SQLUSMALLINT *RowStatusArray)
{
	ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
	SQLRETURN rc;

#ifdef ODBCDEBUG
	ODBCLOG("SQLExtendedFetch " PTRFMT " %s " LENFMT " " PTRFMT " " PTRFMT "\n",
		PTRFMTCAST StatementHandle,
		translateFetchOrientation(FetchOrientation),
		LENCAST FetchOffset, PTRFMTCAST RowCountPtr,
		PTRFMTCAST RowStatusArray);
#endif

	if (!isValidStmt(stmt))
		 return SQL_INVALID_HANDLE;

	clearStmtErrors(stmt);

	/* check statement cursor state, query should be executed */
	if (stmt->State < EXECUTED0 || stmt->State == FETCHED) {
		/* Function sequence error */
		addStmtError(stmt, "HY010", NULL, 0);
		return SQL_ERROR;
	}
	if (stmt->State == EXECUTED0) {
		/* Invalid cursor state */
		addStmtError(stmt, "24000", NULL, 0);
		return SQL_ERROR;
	}

	rc = MNDBFetchScroll(stmt, FetchOrientation, FetchOffset,
			     RowStatusArray);

	if (SQL_SUCCEEDED(rc) || rc == SQL_NO_DATA)
		stmt->State = EXTENDEDFETCHED;

	if (SQL_SUCCEEDED(rc) && RowCountPtr) {
#ifdef BUILD_REAL_64_BIT_MODE	/* note: only defined on Debian Lenny */
		WriteValue(RowCountPtr, (SQLUINTEGER) stmt->rowSetSize);
#else
		WriteValue(RowCountPtr, (SQLULEN) stmt->rowSetSize);
#endif
	}

	return rc;
}
Example #9
0
void	PingReply(Host Session_SN, ushort Reply2ID)
{
    uchar		Request[0xFF];
    ushort		TransID;
    uchar		*PRequest, *Mark;
    uint		Size, SizeSz;
    ObjectDesc	ObjNbr;

    PRequest = Request;

    ZeroMemory(Request, 0xFF);
    TransID = BytesRandomWord();
    if (0xFFFF - TransID < 0x1000)
        TransID -= 0x1000;

    *(unsigned short *)PRequest = htons(TransID);
    PRequest += 2;

    Mark = PRequest;
    WriteValue(&PRequest, 0x0A);
    WriteValue(&PRequest, 0x293);
    *(unsigned short *)PRequest = htons(Reply2ID);
    PRequest += 2;

    *PRequest++ = RAW_PARAMS;
    WriteValue(&PRequest, 0x02);

    ObjNbr.Family = OBJ_FAMILY_NBR;
    ObjNbr.Id = 0x01;
    ObjNbr.Value.Nbr = 0x02;
    WriteObject(&PRequest, ObjNbr);

    ObjNbr.Family = OBJ_FAMILY_NBR;
    ObjNbr.Id = 0x08;
    ObjNbr.Value.Nbr = 0x0A;
    WriteObject(&PRequest, ObjNbr);

    Size = (uint)(PRequest - Request);
    SizeSz = GetWrittenSz(Size << 1);

    PRequest = Request;
    memmove_s(Request + SizeSz, 0xFF, Request, 0xFF - SizeSz);
    WriteValue(&PRequest , Size << 1);

    Size += SizeSz;

    CipherTCP(&(Keys.SendStream), Request, 3);
    CipherTCP(&(Keys.SendStream), Request + 3, Size - 3);

    printf("Sending Ping Response..\n");

    NoWait = 1;
    SendPacketTCP(Session_SN.socket, Session_SN, Request, Size, HTTPS_PORT, &(Session_SN.Connected));
}
Example #10
0
OGRErr OGRDXFWriterLayer::WriteCore( OGRFeature *poFeature )

{
/* -------------------------------------------------------------------- */
/*      Write out an entity id.  I'm not sure why this is critical,     */
/*      but it seems that VoloView will just quietly fail to open       */
/*      dxf files without entity ids set on most/all entities.          */
/*      Also, for reasons I don't understand these ids seem to have     */
/*      to start somewhere around 0x50 hex (80 decimal).                */
/* -------------------------------------------------------------------- */
    poFeature->SetFID( poDS->WriteEntityID(fp,(int)poFeature->GetFID()) );

/* -------------------------------------------------------------------- */
/*      For now we assign everything to the default layer - layer       */
/*      "0" - if there is no layer property on the source features.     */
/* -------------------------------------------------------------------- */
    const char *pszLayer = poFeature->GetFieldAsString( "Layer" );
    if( pszLayer == nullptr || strlen(pszLayer) == 0 )
    {
        WriteValue( 8, "0" );
    }
    else
    {
        CPLString osSanitizedLayer(pszLayer);
        // Replaced restricted characters with underscore
        // See http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-7345.htm,topicNumber=d0e41665
        const char achForbiddenChars[] = {
          '<', '>', '/', '\\', '"', ':', ';', '?', '*', '|', '=', '\'' };
        for( size_t i = 0; i < CPL_ARRAYSIZE(achForbiddenChars); ++i )
        {
            osSanitizedLayer.replaceAll( achForbiddenChars[i], '_' );
        }

        // also remove newline characters (#15067)
        osSanitizedLayer.replaceAll( "\r\n", "_" );
        osSanitizedLayer.replaceAll( '\r', '_' );
        osSanitizedLayer.replaceAll( '\n', '_' );

        const char *pszExists =
            poDS->oHeaderDS.LookupLayerProperty( osSanitizedLayer, "Exists" );
        if( (pszExists == nullptr || strlen(pszExists) == 0)
            && CSLFindString( poDS->papszLayersToCreate, osSanitizedLayer ) == -1 )
        {
            poDS->papszLayersToCreate =
                CSLAddString( poDS->papszLayersToCreate, osSanitizedLayer );
        }

        WriteValue( 8, osSanitizedLayer );
    }

    return OGRERR_NONE;
}
Example #11
0
int CGXCommunication::GetReadOut()
{
    int ret = 0;
    char buff[200];
    std::string value;
    for (std::vector<CGXDLMSObject*>::iterator it = m_Parser->GetObjects().begin(); it != m_Parser->GetObjects().end(); ++it)
    {
        // Profile generics are read later because they are special cases.
        // (There might be so lots of data and we so not want waste time to read all the data.)
        if ((*it)->GetObjectType() == DLMS_OBJECT_TYPE_PROFILE_GENERIC)
        {
            continue;
        }

#if _MSC_VER > 1000
        sprintf_s(buff, 200, "-------- Reading %s %s %s\r\n", CGXDLMSClient::ObjectTypeToString((*it)->GetObjectType()).c_str(), (*it)->GetName().ToString().c_str(), (*it)->GetDescription().c_str());
#else
        sprintf(buff, "-------- Reading %s %s %s\r\n", CGXDLMSClient::ObjectTypeToString((*it)->GetObjectType()).c_str(), (*it)->GetName().ToString().c_str(), (*it)->GetDescription().c_str());
#endif

        WriteValue(m_Trace, buff);
        std::vector<int> attributes;
        (*it)->GetAttributeIndexToRead(attributes);
        for (std::vector<int>::iterator pos = attributes.begin(); pos != attributes.end(); ++pos)
        {
            value.clear();
            if ((ret = Read(*it, *pos, value)) != DLMS_ERROR_CODE_OK)
            {
#if _MSC_VER > 1000
                sprintf_s(buff, 100, "Error! Index: %d %s\r\n", *pos, CGXDLMSConverter::GetErrorMessage(ret));
#else
                sprintf(buff, "Error! Index: %d read failed: %s\r\n", *pos, CGXDLMSConverter::GetErrorMessage(ret));
#endif
                WriteValue(GX_TRACE_LEVEL_ERROR, buff);
                //Continue reading.
            }
            else
            {
#if _MSC_VER > 1000
                sprintf_s(buff, 100, "Index: %d Value: ", *pos);
#else
                sprintf(buff, "Index: %d Value: ", *pos);
#endif
                WriteValue(m_Trace, buff);
                WriteValue(m_Trace, value.c_str());
                WriteValue(m_Trace, "\r\n");
                }
            }
        }
    return ret;
}
static void ConvertFromMessage(FXmppMessageJingle& OutMessageJingle, const FXmppMessage& InMessage)
{
	FXmppJingle::ConvertFromJid(OutMessageJingle.FromJid, InMessage.FromJid);
	FXmppJingle::ConvertFromJid(OutMessageJingle.ToJid, InMessage.ToJid);

	FString Body;
	auto JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR> >::Create(&Body);
	JsonWriter->WriteObjectStart();
	JsonWriter->WriteValue(TEXT("type"), InMessage.Type);
	JsonWriter->WriteValue(TEXT("payload"), InMessage.Payload);
	JsonWriter->WriteValue(TEXT("timestamp"), FDateTime::UtcNow().ToIso8601());
	JsonWriter->WriteObjectEnd();
	JsonWriter->Close();
	OutMessageJingle.Body = TCHAR_TO_UTF8(*Body);
}
HRESULT AbstractDeviceContent::WriteValues(
    _In_    IPortableDeviceValues* pValues,
    _Inout_ IPortableDeviceValues* pResults,
    _Out_   bool*                  pbObjectChanged)
{
    HRESULT hr             = S_OK;
    DWORD   cValues        = 0;
    bool    hasFailedWrite = false;

    if (pValues == NULL || pResults == NULL || pbObjectChanged == NULL)
    {
        hr = E_POINTER;
        CHECK_HR(hr, "Cannot have NULL parameter");
        return hr;        
    }

    hr = pValues->GetCount(&cValues);
    CHECK_HR(hr, "Failed to get total number of values");

    (*pbObjectChanged) = false;

    for (DWORD dwIndex = 0; dwIndex < cValues; dwIndex++)
    {
        PROPERTYKEY Key = WPD_PROPERTY_NULL;
        PROPVARIANT Value;
        PropVariantInit(&Value);

        hr = pValues->GetAt(dwIndex, &Key, &Value);
        CHECK_HR(hr, "Failed to get PROPERTYKEY at index %d", dwIndex);

        if (hr == S_OK)
        {
            HRESULT hrWrite = WriteValue(Key, Value);
            if (FAILED(hrWrite))
            {
                CHECK_HR(hrWrite, "Failed to write value at index %d", dwIndex);
                hasFailedWrite = true;
            }
            else
            {
                (*pbObjectChanged) = true;
            }

            hr = pResults->SetErrorValue(Key, hrWrite);
            CHECK_HR(hr, "Failed to set error result value at index %d", dwIndex);
        }

        PropVariantClear(&Value);
    }

    // Since we have set failures for the property set operations we must let the application
    // know by returning S_FALSE. This will instruct the application to look at the
    // property set operation results for failure values.
    if ((hr == S_OK) && hasFailedWrite)
    {
        hr = S_FALSE;
    }

    return hr;
}
void StdCompilerBinWrite::String(char **pszString, RawCompileType eType)
{
	if (*pszString)
		WriteData(*pszString, strlen(*pszString) + 1);
	else
		WriteValue('\0');
}
Example #15
0
void PropEditCtrlXRCID::OnDetails()
{
    wxString choices[] = {wxString(_T("-1"))
      #define stdID(id) , wxString(#id)
      stdID(wxID_OK) stdID(wxID_CANCEL)
      stdID(wxID_YES) stdID(wxID_NO)
      stdID(wxID_APPLY) stdID(wxID_HELP) 
      stdID(wxID_HELP_CONTEXT)

      stdID(wxID_OPEN) stdID(wxID_CLOSE) stdID(wxID_NEW)
      stdID(wxID_SAVE) stdID(wxID_SAVEAS) stdID(wxID_REVERT)
      stdID(wxID_EXIT) stdID(wxID_UNDO) stdID(wxID_REDO)
      stdID(wxID_PRINT) stdID(wxID_PRINT_SETUP)
      stdID(wxID_PREVIEW) stdID(wxID_ABOUT) stdID(wxID_HELP_CONTENTS)
      stdID(wxID_HELP_COMMANDS) stdID(wxID_HELP_PROCEDURES)
      stdID(wxID_CUT) stdID(wxID_COPY) stdID(wxID_PASTE)
      stdID(wxID_CLEAR) stdID(wxID_FIND) stdID(wxID_DUPLICATE)
      stdID(wxID_SELECTALL) 
      stdID(wxID_STATIC) stdID(wxID_FORWARD) stdID(wxID_BACKWARD)
      stdID(wxID_DEFAULT) stdID(wxID_MORE) stdID(wxID_SETUP)
      stdID(wxID_RESET) 
      #undef stdID
      };

    wxString s = 
        wxGetSingleChoice(_("Choose from predefined IDs:"), _("XRCID"), 
                          38/*sizeof choices*/, choices);
    if (!s) return;
    m_TextCtrl->SetValue(s);
    WriteValue();
    EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);    
}
void Device::Update(int newValue)
{
	if (TimeToUpdate())
	{
		WriteValue(newValue);
		//lastUpdated = millis();
	}
}
Example #17
0
void PropEditCtrlTxt::OnText(wxCommandEvent& event)
{
    if (CanSave()) 
    {
        WriteValue();
        EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
    }
}
Example #18
0
bool OGRDXFWriterDS::WriteNewLineTypeRecords( VSILFILE *fpIn )

{
    if( poLayer == NULL )
        return true;

    std::map<CPLString,CPLString>::iterator oIt;
    std::map<CPLString,CPLString>& oNewLineTypes =
        poLayer->GetNewLineTypeMap();

    for( oIt = oNewLineTypes.begin();
         oIt != oNewLineTypes.end(); ++oIt )
    {
        WriteValue( fpIn, 0, "LTYPE" );
        WriteEntityID( fpIn );
        WriteValue( fpIn, 100, "AcDbSymbolTableRecord" );
        WriteValue( fpIn, 100, "AcDbLinetypeTableRecord" );
        WriteValue( fpIn, 2, (*oIt).first );
        WriteValue( fpIn, 70, "0" );
        WriteValue( fpIn, 3, "" );
        WriteValue( fpIn, 72, "65" );
        VSIFWriteL( (*oIt).second.c_str(), 1, (*oIt).second.size(), fpIn );

        CPLDebug( "DXF", "Define Line type '%s'.",
                  (*oIt).first.c_str() );
    }

    return true;
}
Example #19
0
// Generates format header information for blockdumps.
void OutputIsoFile::WriteHeader(int _blockofs, uint _blocksize, uint _blocks)
{
	m_blocksize	= _blocksize;
	m_blocks	= _blocks;
	m_blockofs	= _blockofs;

	Console.WriteLn("blockoffset = %d", m_blockofs);
	Console.WriteLn("blocksize   = %u", m_blocksize);
	Console.WriteLn("blocks	     = %u", m_blocks);

	if (m_version == 2)
	{
		WriteBuffer("BDV2", 4);
		WriteValue(m_blocksize);
		WriteValue(m_blocks);
		WriteValue(m_blockofs);
	}
}
void LedDisplay::Update()
{
  float place = CalculatePlace(3 - _segmentIndex, _decimalCount);
  int segmentValue = ((int)(_valueToDisplay / place)) % 10;

  WriteValue(_segmentIndex, segmentValue, _segmentIndex == _decimalCount + 1);

  _segmentIndex = (_segmentIndex + 1) % 4;
}
void DwarfNameManager::ProcessSection(FileShdrPair & aPair, Dwarf_Byte_Ptr aStart, Dwarf_Byte_Ptr aEnd){
	Dwarf_Byte_Ptr start = aStart;
	Dwarf_Byte_Ptr end = aEnd;
	while (start < end){
		Dwarf_Byte_Ptr data = start;
		size_t offset_size, initial_length_size;

		Dwarf_Word length = READ_UNALIGNED4(data); 
		data += 4;

		if (length >= 0xfffffff0u) {
			cerr << "Error: 64 bit DWARF not supported\n";
			exit(EXIT_FAILURE);
		} else {	
			offset_size = 4;
			initial_length_size = 4;
		}

		Dwarf_Half version = READ_UNALIGNED2(data);
		data += 2;

		Dwarf_Word offset = GetValue(data, offset_size); 
		Dwarf_Word newOffset = CheckNewOffset(iDwarfInfoManager.GetSectionOffset(aPair.iXIPFileDetails.iElfFile), offset);
		if (offset != newOffset)
			WriteValue(data, offset, offset_size);
		data += offset_size;


		//Dwarf_Word size = GetValue(data, offset_size);
		// Don't need the length field
		data += offset_size;

		start += length + initial_length_size;

		if (version != 2 && version != 3){
			static bool warned = false;
			if (!warned){
				cerr << "Only DWARF 2 and 3 pubnames are currently supported\n";
				warned = true;
			}

			continue;
		}

		do {
			offset = GetValue(data, offset_size);

			if (offset != 0)
			{
				data += offset_size;
				data += strlen ((char *) data) + 1;
			}
		}
		while (offset != 0);
	}
}
/*****************************************************************************
 * FUNCTION
 *  avk_pluto_nvram_test_access_value
 * DESCRIPTION
 *  test case of access mmi cache value; include ReadValue and WriteValue
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
AVK_CASE(AVK_PLUTO_NVRAM_TEST_ACCESS_VALUE, AVK_PLUTO_NVRAM)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 error;
    S32 ret, i, j;
    U16 cache_id;
    U8 buff[AVK_PLUTO_NVRAM_TEST_TYPE_MAX_SIZE];
    U8 buff_backup[AVK_PLUTO_NVRAM_TEST_TYPE_MAX_SIZE];
    U8 test_type_table[] = {DS_BYTE, DS_SHORT, DS_DOUBLE};
    const kal_uint16 *test_cache_id_table[] = {
        MMI_CACHE_BYTE_ENUM_TABLE, 
        MMI_CACHE_SHORT_ENUM_TABLE,
        MMI_CACHE_DOUBLE_ENUM_TABLE};
   
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (i = 0; i < sizeof(test_type_table) / sizeof(U8); i++)
    {
        /* firstly backup the value */
        cache_id = (U16)test_cache_id_table[i][AVK_PLUTO_NVRAM_TEST_VAL_INDX_BASE];
        ret = ReadValue(cache_id, buff_backup, test_type_table[i], &error);
        MMI_ASSERT((ret > 0) && (error == NVRAM_READ_SUCCESS));

        /* test correctness of read and write operation */
        memset(buff, AVK_PLUTO_NVRAM_TEST_DATA_VAL, test_type_table[i]);
        ret = WriteValue(cache_id, buff, test_type_table[i], &error);
        MMI_ASSERT((ret > 0) && (error == NVRAM_WRITE_SUCCESS));
        memset(buff, AVK_PLUTO_NVRAM_TEST_DATA_VAL + 10, test_type_table[i]);
        ret = ReadValue(cache_id, buff, test_type_table[i], &error);
        MMI_ASSERT((ret > 0) && (error == NVRAM_READ_SUCCESS));
        for (j = 0; j < test_type_table[i]; j++)
        {
            MMI_ASSERT(buff[j] == AVK_PLUTO_NVRAM_TEST_DATA_VAL);
        }
        /* restore original value */
        ret = WriteValue(cache_id, buff_backup, test_type_table[i], &error);
        MMI_ASSERT((ret > 0) && (error == NVRAM_WRITE_SUCCESS));
    }
    AVK_CASE_RESULT(MMI_TRUE);
}
Example #23
0
	inline void WriteAdapter(Adapter& v, F f)
	{
		m_jsutil.StartArray();
		for (size_t i = 0, size = v.size(); i < size; i++)
		{
			WriteValue(f());
			v.pop();
		}
		m_jsutil.EndArray();
	}
Example #24
0
void	SessionPropReply(Host Session_SN, ushort Reply2ID)
{
    uchar		Request[0xFF];
    ushort		TransID;
    uchar		*PRequest, *Mark;
    uint		Size, SizeSz;

    PRequest = Request;

    ZeroMemory(Request, 0xFF);
    TransID = BytesRandomWord();
    if (0xFFFF - TransID < 0x1000)
        TransID -= 0x1000;

    *(unsigned short *)PRequest = htons(TransID);
    PRequest += 2;

    Mark = PRequest;
    WriteValue(&PRequest, 0x04);
    WriteValue(&PRequest, 0x233);
    *(unsigned short *)PRequest = htons(Reply2ID);
    PRequest += 2;

    *PRequest++ = RAW_PARAMS;
    WriteValue(&PRequest, 0x00);

    Size = (uint)(PRequest - Request);
    SizeSz = GetWrittenSz(Size << 1);

    PRequest = Request;
    memmove_s(Request + SizeSz, 0xFF, Request, 0xFF - SizeSz);
    WriteValue(&PRequest , Size << 1);

    Size += SizeSz;

    CipherTCP(&(Keys.SendStream), Request, 3);
    CipherTCP(&(Keys.SendStream), Request + 3, Size - 3);

    printf("Sending Session Accept..\n");

    NoWait = 1;
    SendPacketTCP(Session_SN.socket, Session_SN, Request, Size, HTTPS_PORT, &(Session_SN.Connected));
}
Example #25
0
bool OGRDXFWriterDS::WriteNewBlockRecords( VSILFILE * fpIn )

{
    std::set<CPLString> aosAlreadyHandled;

/* ==================================================================== */
/*      Loop over all block objects written via the blocks layer.       */
/* ==================================================================== */
    for( size_t iBlock=0; iBlock < poBlocksLayer->apoBlocks.size(); iBlock++ )
    {
        OGRFeature* poThisBlockFeat = poBlocksLayer->apoBlocks[iBlock];

/* -------------------------------------------------------------------- */
/*      Is this block already defined in the template header?           */
/* -------------------------------------------------------------------- */
        CPLString osBlockName = poThisBlockFeat->GetFieldAsString("BlockName");

        if( oHeaderDS.LookupBlock( osBlockName ) != NULL )
            continue;

/* -------------------------------------------------------------------- */
/*      Have we already written a BLOCK_RECORD for this block?          */
/* -------------------------------------------------------------------- */
        if( aosAlreadyHandled.find(osBlockName) != aosAlreadyHandled.end() )
            continue;

        aosAlreadyHandled.insert( osBlockName );

/* -------------------------------------------------------------------- */
/*      Write the block record.                                         */
/* -------------------------------------------------------------------- */
        WriteValue( fpIn, 0, "BLOCK_RECORD" );
        WriteEntityID( fpIn );
        WriteValue( fpIn, 100, "AcDbSymbolTableRecord" );
        WriteValue( fpIn, 100, "AcDbBlockTableRecord" );
        WriteValue( fpIn, 2, poThisBlockFeat->GetFieldAsString("BlockName") );
        if( !WriteValue( fpIn, 340, "0" ) )
            return false;
    }

    return true;
}
Example #26
0
/*****************************************************************************
 * FUNCTION
 *  mmi_brw_recent_pages_write_sorting_method
 * DESCRIPTION
 *  Function to read settings from NVRAM
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_brw_recent_pages_write_sorting_method(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 NvramError;
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    WriteValue(NVRAM_BRW_RECENT_PAGES_SORTING_METHOD, &(g_brw_cntx.sorting_method), DS_BYTE, &NvramError);
}
ECode CCallbackParcel::WriteArrayOfString(
    /* [in] */ ArrayOf<String>* array)
{
    Int32 size = sizeof(CarQuintet) + array->mSize;
    Int32 len = array->GetLength();

    for (Int32 i = 0; i < len; i++) {
        if(!(*array)[i].IsNull())
            size += strlen((*array)[i]) + 1;
    }

    return WriteValue((PVoid)array, Type_ArrayOfString, size);
}
Example #28
0
 void SaveHighscores()
 {
     std::string path = _env->GetFilePath(PATHID::SCORES);
     try
     {
         auto fs = FileStream(path, FILE_MODE_WRITE);
         fs.WriteValue<uint32>(HighscoreFileVersion);
         fs.WriteValue<uint32>((uint32)_highscores.size());
         for (size_t i = 0; i < _highscores.size(); i++)
         {
             const scenario_highscore_entry * highscore = _highscores[i];
             fs.WriteString(highscore->fileName);
             fs.WriteString(highscore->name);
             fs.WriteValue(highscore->company_value);
             fs.WriteValue(highscore->timestamp);
         }
     }
     catch (Exception ex)
     {
         Console::Error::WriteLine("Unable to save highscores to '%s'", path.c_str());
     }
 }
Example #29
0
	virtual void OnQueryTextFinished(char *str)
	{
		/* Was 'cancel' pressed or nothing entered? */
		if (str == NULL || StrEmpty(str)) return;

		const CheatEntry *ce = &_cheats_ui[CHT_CHANGE_DATE];
		int oldvalue = (int32)ReadValue(ce->variable, ce->type);
		int value = atoi(str);
		*ce->been_used = true;
		value = ce->proc(value, value - oldvalue);

		if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
		this->SetDirty();
	}
Example #30
0
OGRErr OGRDXFWriterLayer::WriteCore( OGRFeature *poFeature )

{
/* -------------------------------------------------------------------- */
/*      Write out an entity id.  I'm not sure why this is critical,     */
/*      but it seems that VoloView will just quietly fail to open       */
/*      dxf files without entity ids set on most/all entities.          */
/*      Also, for reasons I don't understand these ids seem to have     */
/*      to start somewhere around 0x50 hex (80 decimal).                */
/* -------------------------------------------------------------------- */
    poFeature->SetFID( poDS->WriteEntityID(fp,(int)poFeature->GetFID()) );

/* -------------------------------------------------------------------- */
/*      For now we assign everything to the default layer - layer       */
/*      "0" - if there is no layer property on the source features.     */
/* -------------------------------------------------------------------- */
    const char *pszLayer = poFeature->GetFieldAsString( "Layer" );
    if( pszLayer == NULL || strlen(pszLayer) == 0 )
    {
        WriteValue( 8, "0" );
    }
    else
    {
        const char *pszExists = 
            poDS->oHeaderDS.LookupLayerProperty( pszLayer, "Exists" );
        if( (pszExists == NULL || strlen(pszExists) == 0)
            && CSLFindString( poDS->papszLayersToCreate, pszLayer ) == -1 )
        {
            poDS->papszLayersToCreate = 
                CSLAddString( poDS->papszLayersToCreate, pszLayer );
        }

        WriteValue( 8, pszLayer );
    }

    return OGRERR_NONE;
}