Exemplo n.º 1
0
// Image definition
bool CLwoWriter::WriteImageDefinitions()
{
	CLwoFile::CLayer::ImageVector& images = m_curLayer.GetImageVector();
	CLwoFile::CLayer::ImageVector::iterator imageBegin, imageIt, imageEnd;
	imageBegin = images.begin();
	imageEnd = images.end();

	for(imageIt = imageBegin; imageIt != imageEnd; ++imageIt) // For each LWO face
	{
		std::string imagePath(*imageIt);
		ushort still_size = (ushort)GetStringSize(imagePath);

		MSG_DEBUG("CLIP | STIL: '" << imagePath << "'");

		// "CLIP" + size
		WriteTag(CLwoFile::CHUNK_CLIP);
		WriteLong(4 + 4 + 2 + still_size); // imageIndex + "STIL" + stilSize + pathString 

		ulong imageIndex = (imageIt - imageBegin);
		WriteLong(imageIndex); // image index : 0-based index

		WriteTag(CLwoFile::CHUNK_STIL); // STIL
		WriteShort(still_size);

		// Write the image path
		WriteString(imagePath);
	}

	return true;
}
void WireFormatLite::WriteGroup(int field_number,
                                const MessageLite& value,
                                io::CodedOutputStream* output) {
  WriteTag(field_number, WIRETYPE_START_GROUP, output);
  value.SerializeWithCachedSizes(output);
  WriteTag(field_number, WIRETYPE_END_GROUP, output);
}
CString CBCGPTagManager::WriteBrush (const CString& strTag, const CBCGPBrush& value)
{
	CString strValue;

	WriteTag (strValue, WriteInt (s_BrushType, value.GetGradientType(), CBCGPBrush::BCGP_NO_GRADIENT));

	if (value.GetGradientType() == CBCGPBrush::BCGP_NO_GRADIENT)
	{
		WriteTag (strValue, WriteColor (s_BrushColor, value.GetColor()));
	}
	else
	{
		CString strColors;
		WriteTag (strColors, WriteColor (s_BrushColor, value.GetColor()));
		WriteTag (strColors, WriteColor (s_BrushColor, value.GetGradientColor()));
		WriteItem (strValue, s_BrushColors, strColors);
	}

	WriteTag (strValue, WriteInt (s_Opacity, bcg_clamp(bcg_round(value.GetOpacity() * 255.0), 0, 255), 255));

	CString str;
	WriteItem (str, strTag, strValue);

	return str;
}
Exemplo n.º 4
0
bool SQClosure::Save( SQVM *v, SQUserPointer up, SQWRITEFUNC write ) {
	_CHECK_IO( WriteTag( v, write, up, SQ_CLOSURESTREAM_HEAD ) );
	_CHECK_IO( WriteTag( v, write, up, sizeof( SQChar ) ) );
	_CHECK_IO( _funcproto( _function )->Save( v, up, write ) );
	_CHECK_IO( WriteTag( v, write, up, SQ_CLOSURESTREAM_TAIL ) );
	return true;
}
Exemplo n.º 5
0
static int HashTag(struct SectorTag* tag)
{
   struct SectorTag tag1, tag2;
   SECTOR sector = tag->sectornumber;
   unsigned long hashkey = (unsigned long) sector % TotalSectorCount;
   unsigned long index;

   /* See wether the tag is free. */
   if (!GetTag(hashkey, &tag1)) return 0;
   
   if (tag1.ThisTag == 0xFFFFFFFFL)
   {
      /* If so, write the tag. */
      tag->ThisTag = hashkey;

      tag->NextTag  = 0xFFFFFFFFL;
      tag->FreeNext = tag1.FreeNext;
      TagIsUsed(hashkey);
      return WriteTag(hashkey, tag);
   }
   else
   {
      /* Find a free slot in the hash table. */
      for (;;)
      {
	   /* Start looking at the head. */
	   index = FreeIndexListHead;

	   /* See wether it is free */
	   if (!GetTag(index, &tag2)) return 0;
	   if (tag2.ThisTag == 0xFFFFFFFFL)
	   {
	      /* This index will be filled in momentarily. */
              FreeIndexListHead = tag2.FreeNext;
	      break;
	   }
	   /* If it is not, remove the tag from the free list. */
	   FreeIndexListHead = tag2.FreeNext;
      }
      
      /* Add it to the linked list */
      tag->NextTag  = tag1.NextTag;
      tag1.NextTag  = index;
      tag->ThisTag  = index;
      tag->FreeNext = tag2.FreeNext;

      TagIsUsed(index);
      if (!WriteTag(index,   tag))  return 0;
      if (!WriteTag(hashkey, &tag1)) return 0;
   }
           
   return 1;
}
void WireFormatLite::WriteGroupMaybeToArray(int field_number,
                                            const MessageLite& value,
                                            io::CodedOutputStream* output) {
  WriteTag(field_number, WIRETYPE_START_GROUP, output);
  const int size = value.GetCachedSize();
  uint8* target = output->GetDirectBufferForNBytesAndAdvance(size);
  if (target != NULL) {
    uint8* end = value.SerializeWithCachedSizesToArray(target);
    GOOGLE_DCHECK_EQ(end - target, size);
  } else {
    value.SerializeWithCachedSizes(output);
  }
  WriteTag(field_number, WIRETYPE_END_GROUP, output);
}
void WireFormatLite::WriteString(int field_number, const string& value,
                                 io::CodedOutputStream* output) {
  // String is for UTF-8 text only
  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
  output->WriteVarint32(value.size());
  output->WriteString(value);
}
//***************************************************************************************
BOOL CBCGPXMLSettings::Write (LPCTSTR pszKey, LPBYTE pData, UINT nBytes)
{
	if (m_bReadOnly)
	{
		ASSERT (FALSE);
		return FALSE;
	}

	ASSERT (pszKey != NULL);
	ASSERT (pData != NULL);
	ASSERT (AfxIsValidAddress (pData, nBytes, FALSE));

	LPTSTR lpszBuffer = new TCHAR [nBytes * 2 + 1];
	ASSERT (lpszBuffer != NULL);

	lpszBuffer [0] = 0;

	char lpszByte [3];
	int j = 0;

	for (UINT i = 0; i < nBytes; i++)
	{
		sprintf (lpszByte, "%02x", pData [i]);

		lpszBuffer [j++] = lpszByte [0];
		lpszBuffer [j++] = lpszByte [1];
	}

	lpszBuffer [j] = 0;

	BOOL bRes = WriteTag (pszKey, lpszBuffer);

	delete [] lpszBuffer;
	return bRes;
}
Exemplo n.º 9
0
// Polygon list
bool CLwoWriter::WritePolygons()
{
	MSG_DEBUG("POLS | FACE");

	// "POLS" + size
	WriteChunk(CLwoFile::CHUNK_POLS);

	// type : "FACE"
	WriteTag(CLwoFile::CHUNK_FACE);

	CLwoFile::CLayer::FaceVector& faces = m_curLayer.GetFaceVector();
	CLwoFile::CLayer::FaceVector::iterator faceIt, faceBegin, faceEnd;
	faceBegin = faces.begin();
	faceEnd = faces.end();

	for(faceIt = faceBegin; faceIt != faceEnd; ++faceIt) // For each LWO face
	{
		ushort vertexCount = faceIt->VertexCount();
		WriteShort(vertexCount);

		for(ushort v=0; v<vertexCount; ++v) // For each vertex in LWO face
		{
			ushort vertexIndex = faceIt->GetVertexIndexVector()[v]; // Retreive vertex index
			WriteShort(vertexIndex);
		}
	}

	return true;
}
Exemplo n.º 10
0
void AddTag(CIccIO *pIO, CIccProfile *pIcc)
{
  std::string textIn;

  printf("Enter tag signature to be added [ex- cprt] : ");
  textIn = GetUserInput();

	icTagSignature tagSig = (icTagSignature)icGetSigVal(textIn.c_str());

	switch (tagSig) {
		case icSigProfileDescriptionTag:
		case icSigCopyrightTag:
			printf("Enter the text to be saved in the tag : ");
			textIn = GetUserInput();
			if(!AddTextTag(textIn.c_str(), pIcc, tagSig))
				printf("Write operation failed.\n");
			else
				printf("Tag added successfully.\n");  
			break;
		default:
			if(!WriteTag(pIcc, tagSig))
				printf("Write operation failed.\n");
			else
				printf("Tag added successfully.\n");  
	}

}
Exemplo n.º 11
0
void WireFormatLite::WriteMessage(int field_number,
                                  const MessageLite& value,
                                  io::CodedOutputStream* output) {
  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
  const int size = value.GetCachedSize();
  output->WriteVarint32(size);
  value.SerializeWithCachedSizes(output);
}
Exemplo n.º 12
0
int Connect(PLC *Plc,char *TagName, char *responseValue)
{
	int result=SUCCESS;
	int path_size=0;
	char ip[16];
	BYTE path[40];
	Eip_Session *Session=NULL;
	Eip_Connection *Connection=NULL;
	int dataType;
	
	Log(LOG_DEBUG,"[Connect] Building Session for %s\n",Plc->PlcName);
	path_size=ParsePath(Plc->PlcPath,ip,path);
	if (path_size>0)
	{
		Session=OpenSession(ip);
		if (Session!=NULL)
		{
			if (RegisterSession(Session)<0)
			{
				CloseSession(Session);
				Log(LOG_CRIT,"[Connect] Unable to register session for Plc: %s (%s) \n",Plc->PlcName,cip_err_msg);
				return ERROR;
			}
		} else
		{
			Log(LOG_CRIT,"[Connect] Unable to open session for Plc: %s (%s)\n",Plc->PlcName,cip_err_msg);
			return ERROR;
		}
		if (Plc->NetWork)
			Connection=ConnectPLCOverDHP(Session,Plc->PlcType,(int)Session,GetSerial(),MAX_SAMPLE,Plc->NetWork,path,path_size);
		else
			Connection=ConnectPLCOverCNET(Session,Plc->PlcType,(int)Session,GetSerial(),MAX_SAMPLE,path,path_size);
		if (Connection!=NULL)
		{
			Log(LOG_DEBUG,"[Connect] Connection (%p) created for PLC : %s (%s) )\n",Connection,Plc->PlcName,cip_err_msg);
		} else 
		{
			Log(LOG_CRIT,"[Connect] Unable to create connection for Plc: %s (%s)\n",Plc->PlcName,cip_err_msg);
			return ERROR;
		}
	} else Log(LOG_ERR,"[Connect] Invalid path : %s\n",Plc->PlcPath);

	Log(LOG_DEBUG,"[Connect] Connect : %s [%s](%p / %p)\n",TagName,writeValue,Session,Connection);
	if (ReadTag(Plc, Session, Connection, TagName, &dataType, responseValue)!=SUCCESS)
		return ERROR;
	else
	{
		if (isWrite)
		{
			if (WriteTag(Plc, Session, Connection, TagName,dataType)!=SUCCESS)
				return ERROR; 
			Log(LOG_DEBUG,"[Connect] %s [%s] %x (%p / %p)\n",TagName,writeValue,dataType,Session,Connection);
			if (ReadTag(Plc, Session, Connection, TagName, &dataType, responseValue)!=SUCCESS)
				return ERROR;
		}
	}
	return result;
}
Exemplo n.º 13
0
bool SQFunctionProto::Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
{
	SQInteger i,nsize=_literals.size();
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(WriteObject(v,up,write,_sourcename));
	_CHECK_IO(WriteObject(v,up,write,_name));
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		_CHECK_IO(WriteObject(v,up,write,_literals[i]));
	}
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_parameters.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		_CHECK_IO(WriteObject(v,up,write,_parameters[i]));
	}
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_outervalues.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		_CHECK_IO(SafeWrite(v,write,up,&_outervalues[i]._type,sizeof(SQUnsignedInteger)));
		_CHECK_IO(WriteObject(v,up,write,_outervalues[i]._src));
		_CHECK_IO(WriteObject(v,up,write,_outervalues[i]._name));
	}
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_localvarinfos.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		SQLocalVarInfo &lvi=_localvarinfos[i];
		_CHECK_IO(WriteObject(v,up,write,lvi._name));
		_CHECK_IO(SafeWrite(v,write,up,&lvi._pos,sizeof(SQUnsignedInteger)));
		_CHECK_IO(SafeWrite(v,write,up,&lvi._start_op,sizeof(SQUnsignedInteger)));
		_CHECK_IO(SafeWrite(v,write,up,&lvi._end_op,sizeof(SQUnsignedInteger)));
	}
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_lineinfos.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	_CHECK_IO(SafeWrite(v,write,up,&_lineinfos[0],sizeof(SQLineInfo)*nsize));
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_instructions.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	_CHECK_IO(SafeWrite(v,write,up,&_instructions[0],sizeof(SQInstruction)*nsize));
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_functions.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		_CHECK_IO(_funcproto(_functions[i])->Save(v,up,write));
	}
	_CHECK_IO(SafeWrite(v,write,up,&_stacksize,sizeof(_stacksize)));
	_CHECK_IO(SafeWrite(v,write,up,&_bgenerator,sizeof(_bgenerator)));
	_CHECK_IO(SafeWrite(v,write,up,&_varparams,sizeof(_varparams)));
	return true;
}
Exemplo n.º 14
0
 void FileLogger::LogMessage(SeverityType theSeverity,
     const char* theSourceFile, int theSourceLine,
     const char* theMessage)
 {
   if(mFileStream.is_open() && IsActive())
   {
     WriteTag(mFileStream, theSeverity, theSourceFile, theSourceLine);
     mFileStream << theMessage << std::endl;
   }
 }
//***************************************************************************************
BOOL CBCGPXMLSettings::Write (LPCTSTR pszKey, LPCTSTR pszData)
{
	if (m_bReadOnly)
	{
		ASSERT (FALSE);
		return FALSE;
	}

	return WriteTag (pszKey, pszData);
}
Exemplo n.º 16
0
 std::ostream& FileLogger::GetStream(SeverityType theSeverity,
     const char* theSourceFile, int theSourceLine, int theExitCode)
 {
   std::ostream* anResult = &gNullStream;
   if(mFileStream.is_open() && IsActive())
   {
     anResult = &mFileStream;
     WriteTag(mFileStream, theSeverity, theSourceFile, theSourceLine);
   }
   return *anResult;
 }
Exemplo n.º 17
0
void CFileDataIO::WriteTagPtrList(const TagPtrList& tagList)
{
	uint32 count = tagList.size();
	wxASSERT( count <= 0xFF );
	
	WriteUInt8(count);
	TagPtrList::const_iterator it;
	for (it = tagList.begin(); it != tagList.end(); it++) {
		WriteTag(**it);
	}
}
Exemplo n.º 18
0
bool CLwoWriter::WriteHeader()
{
	MSG_DEBUG("FORM | LWO2");

	// "FORM" + size
	WriteChunk(CLwoFile::CHUNK_FORM);

	// "LWO2"
	WriteTag(CLwoFile::CHUNK_LWO2);

	return true;
}
Exemplo n.º 19
0
/*!
 * \brief Send device description.
 *
 * This uHTTP CGI function will be registered when UpnpRegisterDeviceTree()
 * is called for the first time.
 */
static int UpnpCgiDeviceDescription(HTTPD_SESSION *hs)
{
    HTTP_STREAM *stream = hs->s_stream;
    SSDP_DEVICE *sdev = NULL;
    SSDP_SERVICE *ssvc;
    char *type;

    type = HttpArgParseFirst(&hs->s_req);
    if (type) {
        for (sdev = device_registration; sdev; sdev = sdev->sdev_next) {
            if (strcmp(sdev->sdev_type, type) == 0) {
                break;
            }
        }
    }
    if (sdev) {
        UPNP_DEVICE_INFO *udev = sdev->sdev_info;

        XmlHead(hs->s_stream);
        s_puts("<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\r\n", hs->s_stream);
        SpecVersion(stream);

        s_puts("<device>\r\n", stream);
        s_printf(stream, "<deviceType>urn:%s:device:%s:1</deviceType>\r\n", sdev->sdev_domain, sdev->sdev_type);
        WriteTag(stream, "friendlyName", udev->udev_name);
        WriteTag(stream, "manufacturer", udev->udev_mnf->umnf_name);
        WritePrepTag(stream, "manufacturerURL", udev->udev_mnf->umnf_url, "http://");
        WriteTag(stream, "modelDescription", udev->udev_mdl->umdl_desc);
        WriteTag(stream, "modelName", udev->udev_mdl->umdl_name);
        WriteTag(stream, "modelNumber", udev->udev_mdl->umdl_num);
        WritePrepTag(stream, "modelURL", udev->udev_mdl->umdl_url, "http://");
        WriteTag(stream, "UDN", sdev->sdev_uuid);
        if (sdev->sdev_svc) {
            s_puts("<serviceList>\r\n", stream);
            for (ssvc = sdev->sdev_svc; ssvc; ssvc = ssvc->ssvc_next) {
                UPNP_SERVICE_INFO *usvc = sdev->sdev_svc->ssvc_info;

                s_puts("<service>\r\n", stream);
                s_printf(stream, "<serviceType>urn:schemas-upnp-org:service:%s:1</serviceType>\r\n", sdev->sdev_svc->ssvc_type);
                s_printf(stream, "<serviceId>urn:upnp-org:serviceId:%s:1</serviceId>\r\n", sdev->sdev_svc->ssvc_type);
                s_printf(stream, "<SCPDURL>%s?%s=%s</SCPDURL>", usvc->usvc_url_scpd, sdev->sdev_type, ssvc->ssvc_type);
                s_printf(stream, "<controlURL>%s?%s=%s</controlURL>", usvc->usvc_url_ctrl, sdev->sdev_type, ssvc->ssvc_type);
                s_printf(stream, "<eventSubURL>%s?%s=%s</eventSubURL>", usvc->usvc_url_event, sdev->sdev_type, ssvc->ssvc_type);
                s_puts("</service>\r\n", stream);
            }
            s_puts("</serviceList>\r\n", stream);
        }
        WriteTag(stream, "presentationURL", udev->udev_presentation);
        s_puts("</device>\r\n", stream);
        s_puts("</root>\r\n", stream);
    }
    s_flush(stream);

    return 0;
}
Exemplo n.º 20
0
/**
 *  This method gets called when a tag needs to write it's attributes
 *
 *  @update  gess 3/25/98
 *  @param
 *  @return  result status
 */
nsresult CViewSourceHTML::WriteAttributes(const nsAString& tagName, 
                                          nsTokenAllocator* allocator, 
                                          PRInt32 attrCount, PRBool aOwnerInError) {
  nsresult result=NS_OK;

  if(attrCount){ //go collect the attributes...
    int attr = 0;
    for(attr = 0; attr < attrCount; ++attr){
      CToken* theToken = mTokenizer->PeekToken();
      if(theToken)  {
        eHTMLTokenTypes theType = eHTMLTokenTypes(theToken->GetTokenType());
        if(eToken_attribute == theType){
          mTokenizer->PopToken(); //pop it for real...
          mTokenNode.AddAttribute(theToken);  //and add it to the node.

          CAttributeToken* theAttrToken = (CAttributeToken*)theToken;
          const nsSubstring& theKey = theAttrToken->GetKey();

          // The attribute is only in error if its owner is NOT in error.
          const PRBool attributeInError =
            !aOwnerInError && theAttrToken->IsInError();

          result = WriteTag(kAttributeName,theKey,0,attributeInError);
          const nsSubstring& theValue = theAttrToken->GetValue();

          if(!theValue.IsEmpty() || theAttrToken->mHasEqualWithoutValue){
            if (IsUrlAttribute(tagName, theKey, theValue)) {
              WriteHrefAttribute(allocator, theValue);
            } else {
              WriteTag(kAttributeValue,theValue,0,attributeInError);
            }
          }
        }
      }
      else return kEOF;
    }
  }

  return result;
}
Exemplo n.º 21
0
// Discontinuous Vertex Mapping
bool CLwoWriter::WriteDiscVertexMapping()
{
	CLwoFile::CLayer::TexCoordMap& texCoords = m_curLayer.GetTexCoordMap();
	if(texCoords.size() == 0)
		return true;

	MSG_DEBUG("VMAD | TXUV");

	// "VMAD" + size
	WriteChunk(CLwoFile::CHUNK_VMAD);

	// type : "TXUV"
	WriteTag(CLwoFile::CHUNK_TXUV);

	ushort dimension = 2; // UVs are 2D
	WriteShort(dimension);

	std::string name("txuv00");
	WriteString(name);

	CLwoFile::CLayer::TexCoordMap::iterator texCoordIt, texCoordEnd;
	texCoordEnd = texCoords.end();

	std::vector< CLwoFile::CLayer::CTexCoord > uvVector;
	ushort pointIndex = 0;
	ushort polyIndex = 0;
	Vector3D uv(3);

	for(texCoordIt = texCoords.begin(); texCoordIt != texCoordEnd; ++texCoordIt) // For each LWO texCoord
	{
		uvVector = texCoordIt->second;
		std::vector< CLwoFile::CLayer::CTexCoord >::iterator uvVectorIt, uvVectorEnd;
		uvVectorEnd = uvVector.end();

		for(uvVectorIt = uvVector.begin(); uvVectorIt != uvVectorEnd; ++uvVectorIt) // For each LWO face
		{
			if(uvVectorIt == uvVector.begin()) // skip the first one since it was written in the VMAP
				continue;

			pointIndex = texCoordIt->first;
			WriteShort(pointIndex); // vertex position index

			ushort polyIndex = uvVectorIt->m_faceIndex;
			WriteShort(polyIndex); // face index

			uv = uvVectorIt->m_texCoord;
			WriteVector2D(uv); // Write UV
		}
	}

	return true;
}
//***************************************************************************************
BOOL CBCGPXMLSettings::Write (LPCTSTR pszKey, DWORD dwVal)
{
	if (m_bReadOnly)
	{
		ASSERT (FALSE);
		return FALSE;
	}

	CString str;
	str.Format (_T("%d"), dwVal);

	return WriteTag (pszKey, str);
}
Exemplo n.º 23
0
CString CBCGPTagManager::WriteTextFormat (const CString& strTag, const CBCGPTextFormat& value)
{
	CString str;

	if (!value.IsEmpty())
	{
		CString strValue;

		WriteTag (strValue, WriteString (s_TextFormatFamily, value.GetFontFamily()));
		WriteTag (strValue, WriteDouble (s_TextFormatSize, (double)value.GetFontSize(), 0.0));
		WriteTag (strValue, WriteInt (s_TextFormatWeight, value.GetFontWeight(), 0));
		WriteTag (strValue, WriteInt (s_TextFormatStyle, value.GetFontStyle(), CBCGPTextFormat::BCGP_FONT_STYLE_NORMAL));
		WriteTag (strValue, WriteString (s_TextFormatLocale, value.GetFontLocale()));
		WriteTag (strValue, WriteInt (s_TextFormatAlignHorz, value.GetTextAlignment(), CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_LEADING));
		WriteTag (strValue, WriteInt (s_TextFormatAlignVert, value.GetTextVerticalAlignment(), CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_LEADING));
		WriteTag (strValue, WriteBool (s_TextFormatWordWrap, value.IsWordWrap(), FALSE));
		WriteTag (strValue, WriteBool (s_TextFormatClipping, value.IsClipText(), FALSE));
		WriteTag (strValue, WriteDouble (s_TextFormatAngle, value.GetDrawingAngle(), 0.0));

		WriteItem (str, strTag, strValue);
	}

	return str;
}
Exemplo n.º 24
0
void CXmlParser::WriteTag(CXmlNode& Node, _tstring& sResult, const int nNesting)
{
	sResult += GetNesting(nNesting);
	sResult += _T("<");
	sResult += Node.Data[TAG_NAME];
	{
		// Записываем все атрибуты
		CXmlNode::TData::const_iterator it = Node.Data.begin();
		const CXmlNode::TData::const_iterator itEnd = Node.Data.end();
		for (; it != itEnd; ++it)
		{
			if (it->first != TAG_NAME && it->first != TAG_VALUE)
			{
				sResult += _T(" ");
				sResult += it->first;
				sResult += _T("=\"");
				sResult += it->second;
				sResult += _T("\"");
			}
		}
	}
	sResult += _T(">");

	_tstring sRowValue = Node.Data[TAG_VALUE];
	if (!sRowValue.empty() && sRowValue != _T("\n"))
		sResult += sRowValue;

	{
		// Записываем все дочерние узлы
		CXmlNode::TChilds::iterator it = Node.Childs.begin();
		const CXmlNode::TChilds::const_iterator itEnd = Node.Childs.end();
		for (; it != itEnd; ++it)
		{
			sResult += _T("\n");
			WriteTag(*it, sResult, nNesting + 1);
		}
	}

	// Закрывающий тэг
	if (Node.Childs.size() > 1)
	{
		sResult += _T("\n");
		sResult += GetNesting(nNesting);
	}
	sResult += _T("</");
	sResult += Node.Data[TAG_NAME];
	sResult += _T(">");
}
Exemplo n.º 25
0
static int GetTag(unsigned long index, struct SectorTag* buffer)
{
   int retVal = TRUE;

   if (!GetCachedTag(index, buffer))
   {
      retVal = XMStoDOSmove((char*)buffer, XMSHandle,
			    index*sizeof(struct SectorTag),
			    sizeof(struct SectorTag)) ==
					       sizeof(struct SectorTag);

      if (retVal)
      {
         retVal = WriteTag(index, buffer);
      }
   }
                                         
   return retVal;
}
Exemplo n.º 26
0
// Vertex Mapping, We use it in association with VMADs, see WriteDiscVertexMapping below
bool CLwoWriter::WriteVertexMapping()
{
	CLwoFile::CLayer::TexCoordMap& texCoords = m_curLayer.GetTexCoordMap();
	if(texCoords.size() == 0)
		return true;

	MSG_DEBUG("VMAP | TXUV");

	// "VMAP" + size
	WriteChunk(CLwoFile::CHUNK_VMAP);

	// type : "TXUV"
	WriteTag(CLwoFile::CHUNK_TXUV);

	ushort dimension = 2; // UVs are 2D
	WriteShort(dimension);

	std::string name("txuv00");
	WriteString(name);

	CLwoFile::CLayer::TexCoordMap::iterator texCoordIt, texCoordEnd;
	texCoordEnd = texCoords.end();

	ushort pointIndex;
	Vector3D uv(3);

	for(texCoordIt = texCoords.begin(); texCoordIt != texCoordEnd; ++texCoordIt) // For each LWO texCoord
	{
		pointIndex = texCoordIt->first;
		WriteShort(pointIndex); // vertex position index

		uv = (texCoordIt->second)[0].m_texCoord; // Retreive the first UV coordinate for this control point (the one assigned to the first face)
		WriteVector2D(uv); // Write UV
	}

	return true;
}
Exemplo n.º 27
0
void debug_stream_test_cb (puObject* obj)
{
  SStream* s = new SStream;
  strncpy (s->filename, "teststream.txt",(PATH_MAX-1));
  strncpy (s->mode, "w",3);
  OpenStream (s);

  WriteComment ("Comment...testing testing testing", s);
  WriteComment ("", s);
  WriteTag ('bgno', "---- object ----", s);
  WriteTag ('bgno', "---- nested Object ----", s);
  WriteTag ('int_', "---- int ----", s);
  int i = 500;
  WriteInt (&i, s);
  WriteTag ('uint', "---- unsigned int ----", s);
  unsigned int ui = 12345678;
  WriteUInt (&ui, s);
  float f = 12345.67f;
  WriteTag ('flot', "---- float ----", s);
  WriteFloat (&f, s);
  double d = 987654.3210;
  WriteTag ('dubl', "---- double ----", s);
  WriteDouble (&d, s);
  WriteTag ('stng', "---- string ----", s);
  WriteString ("This a string", s);
  SVector v;
  v.x = 1.0;
  v.y = 2.0;
  v.z = 3.0;
  WriteTag ('vect', "--- vector ----", s);
  WriteVector (&v, s);
  SPosition pos;
  pos.lat = 1000.0;
  pos.lon = 2000.0;
  pos.alt = 3000.0;
  WriteTag ('posn', "---- position ----", s);
  WritePosition (&pos, s);
  SMessage mesg;
  WriteTag ('mesg', "---- message ----", s);
  WriteMessage (&mesg, s);
  WriteTag ('endo', s);
  WriteTag ('endo', s);

  CloseStream (s);
  delete s;
}
Exemplo n.º 28
0
void CXmlParser::Save(_tstring& sResult)
{
	WriteTag(m_Data, sResult, 0);
}
Exemplo n.º 29
0
/*!
 * \brief Send service description.
 *
 * This uHTTP CGI function will be registered when UpnpRegisterDeviceTree()
 * is called for the first time.
 */
static int UpnpCgiServiceDescription(HTTPD_SESSION *hs)
{
    SSDP_SERVICE *ssvc = NULL;
    SSDP_DEVICE *sdev = NULL;
    HTTP_STREAM *stream = hs->s_stream;
    const char *dev_type;

    dev_type = HttpArgParseFirst(&hs->s_req);
    if (dev_type) {
        const char *svc_type = HttpArgValue(&hs->s_req);

        if (dev_type) {
            for (sdev = device_registration; sdev; sdev = sdev->sdev_next) {
                if (strcmp(sdev->sdev_type, dev_type) == 0) {
                    for (ssvc = sdev->sdev_svc; ssvc; ssvc = ssvc->ssvc_next) {
                        if (strcmp(ssvc->ssvc_type, svc_type) == 0) {
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
    if (ssvc) {
        SOAP_PROCEDURE *act;
        UPNP_VARIABLE *stv;
        UPNP_SERVICE_INFO *usvc = ssvc->ssvc_info;

        XmlHead(hs->s_stream);
        s_puts("<scpd xmlns=\"urn:schemas-upnp-org:service-1-0\">\r\n", stream);
        SpecVersion(stream);

        act = usvc->usvc_proc;
        if (act) {
            s_puts("<actionList>\r\n", stream);
            do {
                s_puts("<action>\r\n", stream);
                WriteTag(stream, "name", act->proc_name);
                if (act->proc_argi || act->proc_argo) {
                    SOAP_ARG *arg;

                    s_puts("<argumentList>\r\n", stream);
                    for (arg = act->proc_argi; arg; arg = arg->arg_next) {
                        s_puts("<argument>\r\n", stream);
                        WriteTag(stream, "name", arg->arg_name);
                        WriteTag(stream, "relatedStateVariable", ((UPNP_VARIABLE *) arg->arg_info)->ustv_name);
                        WriteTag(stream, "direction", "in");
                        s_puts("</argument>\r\n", stream);
                    }
                    for (arg = act->proc_argo; arg; arg = (SOAP_ARG *) arg->arg_next) {
                        s_puts("<argument>\r\n", stream);
                        WriteTag(stream, "name", arg->arg_name);
                        WriteTag(stream, "relatedStateVariable", ((UPNP_VARIABLE *) arg->arg_info)->ustv_name);
                        WriteTag(stream, "direction", "out");
                        s_puts("</argument>\r\n", stream);
                    }
                    s_puts("</argumentList>\r\n", stream);
                }
                s_puts("</action>\r\n", stream);
            } while ((act = act->proc_next) != NULL);
            s_puts("</actionList>\r\n", stream);
        }

        stv = usvc->usvc_stv;
        if (stv) {
            s_puts("<serviceStateTable>\r\n", stream);
            do {
                s_printf(stream, "<stateVariable sendEvents=\"%s\">\r\n", stv->ustv_events ? "yes" : "no");
                WriteTag(stream, "name", stv->ustv_name);
                WriteTag(stream, "dataType", UpnpVarTypeString(stv->ustv_type));
                WriteTag(stream, "defaultValue", stv->ustv_default);
                s_puts("</stateVariable>\r\n", stream);
            } while((stv = stv->ustv_next) != NULL);
            s_puts("</serviceStateTable>\r\n", stream);
        }
        s_puts("</scpd>\r\n", stream);
    }
    s_flush(stream);

    return 0;
}
Exemplo n.º 30
0
/**
 *
 *  @update  gess 3/25/98
 *  @param   aToken -- token object to be put into content model
 *  @return  0 if all is well; non-zero is an error
 */
nsresult
CViewSourceHTML::HandleToken(CToken* aToken)
{
  nsresult        result=NS_OK;
  CHTMLToken*     theToken= (CHTMLToken*)(aToken);
  eHTMLTokenTypes theType= (eHTMLTokenTypes)theToken->GetTokenType();

  NS_ASSERTION(mSink, "No sink in CViewSourceHTML::HandleToken? Was WillBuildModel called?");

  mTokenNode.Init(theToken, mTokenizer->GetTokenAllocator());

  switch(theType) {

    case eToken_start:
      {
        const nsSubstring& startValue = aToken->GetStringValue();
        result = WriteTag(kStartTag,startValue,aToken->GetAttributeCount(),aToken->IsInError());

        if((ePlainText!=mDocType) && (NS_OK==result)) {
          result = mSink->NotifyTagObservers(&mTokenNode);
        }
      }
      break;

    case eToken_end:
      {
        const nsSubstring& endValue = aToken->GetStringValue();
        result = WriteTag(kEndTag,endValue,aToken->GetAttributeCount(),aToken->IsInError());
      }
      break;

    case eToken_cdatasection:
      {
        nsAutoString theStr;
        theStr.AssignLiteral("<!");
        theStr.Append(aToken->GetStringValue());
        if (!aToken->IsInError()) {
          theStr.AppendLiteral(">");
        }
        result=WriteTag(kCData,theStr,0,aToken->IsInError());
      }
      break;

    case eToken_markupDecl:
      {
        nsAutoString theStr;
        theStr.AssignLiteral("<!");
        theStr.Append(aToken->GetStringValue());
        if (!aToken->IsInError()) {
          theStr.AppendLiteral(">");
        }
        result=WriteTag(kMarkupDecl,theStr,0,aToken->IsInError());
      }
      break;

    case eToken_comment:
      {
        nsAutoString theStr;
        aToken->AppendSourceTo(theStr);
        result=WriteTag(kComment,theStr,0,aToken->IsInError());
      }
      break;

    case eToken_doctypeDecl:
      {
        const nsSubstring& doctypeValue = aToken->GetStringValue();
        result=WriteTag(kDoctype,doctypeValue,0,aToken->IsInError());
      }
      break;

    case eToken_newline:
      {
        const nsSubstring& newlineValue = aToken->GetStringValue();
        result=WriteTag(kText,newlineValue,0,PR_FALSE);
        ++mTokenCount;
        if (NS_VIEWSOURCE_TOKENS_PER_BLOCK > 0 &&
            mTokenCount > NS_VIEWSOURCE_TOKENS_PER_BLOCK) {
          StartNewPreBlock();
        }
      }
      break;

    case eToken_whitespace:
      {
        const nsSubstring& wsValue = aToken->GetStringValue();
        result=WriteTag(kText,wsValue,0,PR_FALSE);
        ++mTokenCount;
        if (NS_VIEWSOURCE_TOKENS_PER_BLOCK > 0 &&
            mTokenCount > NS_VIEWSOURCE_TOKENS_PER_BLOCK &&
            !wsValue.IsEmpty()) {
          PRUnichar ch = wsValue.Last();
          if (ch == kLF || ch == kCR)
            StartNewPreBlock();
        }
      }
      break;

    case eToken_text:
      {
        const nsSubstring& str = aToken->GetStringValue();
        result=WriteTag(kText,str,aToken->GetAttributeCount(),aToken->IsInError());
        ++mTokenCount;
        if (NS_VIEWSOURCE_TOKENS_PER_BLOCK > 0 &&
            mTokenCount > NS_VIEWSOURCE_TOKENS_PER_BLOCK && !str.IsEmpty()) {
          PRUnichar ch = str.Last();
          if (ch == kLF || ch == kCR)
            StartNewPreBlock();
        }
      }

      break;

    case eToken_entity:
      result=WriteTag(kEntity,aToken->GetStringValue(),0,aToken->IsInError());
      break;

    case eToken_instruction:
      result=WriteTag(kPI,aToken->GetStringValue(),0,aToken->IsInError());
      break;

    default:
      result=NS_OK;
  }//switch

  mTokenNode.ReleaseAll();

  return result;
}