示例#1
0
std::string AnswerGenerator::GetElement( DataElement element, const MatchedTemplate & matchedTemplate, const DBResultList & dbResultList )
{
	switch( element )
	{
	case FOCUS_TAG:
		return GetTagName( "focus", matchedTemplate );
	case FOCUS_TEXT:
		return GetWord( "focus", matchedTemplate );
	case TARGET_TAG:
		return GetTagName( "target", matchedTemplate );
	case TARGET_TEXT:
		return GetWord( "target", matchedTemplate );
	case COMPONENT1_TAG:
		return GetTagName( "component1", matchedTemplate );
	case COMPONENT1_TEXT:
		return GetWord( "component1", matchedTemplate );
	case COMPONENT2_TAG:
		return GetTagName( "component2", matchedTemplate );
	case COMPONENT2_TEXT:
		return GetWord( "component2", matchedTemplate );
	case RESULT_VALUE:
		return GetResultData( matchedTemplate._questionNo, dbResultList );
	case RESULT_LIST:
		return GetResultDataList( matchedTemplate._questionNo, dbResultList );
	}
	return "%?%";
}
示例#2
0
文件: TuxMXS.c 项目: VanErt1/tuxeip
int InsBobine(LISTE *tags,TMxMsg *msg5,TMxMsg *msg6)
{	int i,nbre_vars=0;
	char tagn[500];
	char values[500];
	char *str,*name;
	char tagname[30];
	//char *name;
	if (TEST) return(0);

	Log(LOG_DEBUG,"Entering InsBobine\n");
	if ((msg5==NULL)&&(msg6==NULL)) return(-1);

	memset(tagn,0,sizeof(tagn));
	memset(values,0,sizeof(values));

	sprintf(tagn,"TEMPS,MACHINE,");
	sprintf(values,"now(),'%s',",MXNAME);

	for (i=0;i<10;i++)
	{
		if ((msg5!=NULL)&&(GetTagName(tags,msg5->Variables[i].Repere,tagname)))
		{ name=strchr(tagname,'_');
			if (name!=NULL)
			{
				name++;
				if (nbre_vars++) {sprintf(tagn+strlen(tagn),",");sprintf(values+strlen(values),",");}
				sprintf(tagn+strlen(tagn),"%s",name);
				str=msg5->Variables[i].Value;
				sprintf(values+strlen(values),"'%s'",str);
			}
		}
		if ((msg6!=NULL)&&(GetTagName(tags,msg6->Variables[i].Repere,tagname)))
		{ name=strchr(tagname,'_');
			if (name!=NULL)
			{
				name++;
				if (nbre_vars++) {sprintf(tagn+strlen(tagn),",");sprintf(values+strlen(values),",");}
				sprintf(tagn+strlen(tagn),"%s",name);
				str=msg6->Variables[i].Value;
				sprintf(values+strlen(values),"'%s'",str);
			}
		}
	}
	readwritedata(plc,&variables);
	for (i=0;i<AB_VARCOUNT;i++)
	{
		TAG *atag=variables.Data[i];
		sprintf(tagn+strlen(tagn),",");sprintf(values+strlen(values),",");
		sprintf(tagn+strlen(tagn),"%s",atag->TagName);
		sprintf(values+strlen(values),"'%f'",atag->Value);
	}
	Log(LOG_DEBUG,"InsBobine : %s \n %s \n length : (%d , %d)\n",tagn,values,strlen(tagn),strlen(values));
	i=_Execute(&Default_Db,"insert into BOBINE (%s) values (%s)",tagn,values);

	Log(LOG_NOTICE,"insert into BOBINE (%s) values (%s)\n",tagn,values);
	Log(LOG_NOTICE,"InsBobine : %s (%d)\n",MysqlErrorMsg,i);
	return(i);
}
示例#3
0
static void
PrintTagList(struct TagItem *tags)
{
  struct TagItem *tstate;
  struct TagItem *tag;

  if( tags == NULL )
  {
    KPrintF( "No taglist!\n" );
  }
  else
  {
    tstate = tags;

    while( ( tag = NextTagItem( &tstate ) ) )
    {
      switch( GetDatatype( tag->ti_Tag ) )
      {
        case dt_Hex:
          KPrintF( "\n  %30s, 0x%08lx,", 
                   (ULONG) GetTagName( tag->ti_Tag ), tag->ti_Data );
          break;

        case dt_Dec:
          KPrintF( "\n  %30s, %ld,", 
                   (ULONG) GetTagName( tag->ti_Tag ), tag->ti_Data );
          break;

        case dt_Boolean:
          KPrintF( "\n  %30s, %s,", 
                   (ULONG) GetTagName( tag->ti_Tag ), 
                   tag->ti_Data ? (ULONG) "TRUE" : (ULONG) "FALSE" );
          break;

        case dt_String:
          KPrintF( "\n  %30s, %s,", 
                   (ULONG) GetTagName( tag->ti_Tag ),
		   tag->ti_Data != 0 ? tag->ti_Data : (ULONG) "(null)" );
          break;

        case dt_Fixed:
        {
          KPrintF( "\n  %30s, %ld.%ld,", 
                   (ULONG) GetTagName( tag->ti_Tag ), 
                   tag->ti_Data >> 16,
                   ( ( tag->ti_Data & 0xffff ) * 1000 ) >> 16 );
          break;
        }
      }
    }

    KPrintF("\n  TAG_DONE)");
  }
}
// return -1 if do not need to read next tag
static int DumpTag(struct uffs_DeviceSt *dev, int block, int page, uffs_Tags *tag, dump_msg_cb *dump)
{
	struct uffs_TagStoreSt *s = &tag->s;
	struct uffs_MiniHeaderSt header;
	URET ret;

	if (!TAG_IS_DIRTY(tag)) {
		// is a clean page ?
		ret = uffs_LoadMiniHeader(dev, block, page, &header);
		if (ret == U_FAIL) {
			dump(dev, "Fail to load mini header from page 0\n");
		}
		else {
			if (header.status == 0xFF)
				dump(dev, "page %d CLEAN\n", page);
			else {
				dump(dev, "page %d NOT clean ! header: ", page);
				DumpBufHex(dev, (u8 *)&header, sizeof(header), dump);
				dump(dev, ", tag: ");
				DumpBufHex(dev, (u8 *)s, sizeof(struct uffs_TagStoreSt), dump);
				dump(dev, "\n");
			}
		}
		return -1;
	}
	
	dump(dev, " - page %2d/%2d %s %d/%d len%4d\n", page, s->page_id, GetTagName(s), s->serial, s->parent, s->data_len);
	
	return 0;
}
示例#5
0
文件: xmlutil.cpp 项目: cw2018/xtpui
std::wstring CXmlUtil::GetRootName(const XMLDOMDocumentPtr& doc)
{
    LocalHResult hr;
    if (doc)
    {
        XMLDOMElementPtr ele;
        hr = doc->get_documentElement(&ele);
        return GetTagName(ele);
    }
    return std::wstring();
}
示例#6
0
文件: TuxMXS.c 项目: VanErt1/tuxeip
void Update(LISTE *tags,TMxMsg *msg)
{	int i;
	if (TEST) return;
	char tagname[30];
	for(i=0;i<10;i++)
	{
		if (GetTagName(tags,msg->Variables[i].Repere,tagname))
		{
			UpdateTag(tagname,msg->Variables[i].Value);
			Log(LOG_DEBUG,"Update [%s] %d = %s\n",tagname,msg->Variables[i].Repere,msg->Variables[i].Value);
		}
	};
}
示例#7
0
/* used in saved game to save space */
const char *GetTagShortName(val_type val)
{
	switch (val.v.tag)
	{
		case TAG_NIL : return "$";
		case TAG_INT : return "I";
		case TAG_OBJECT : return "O";
		case TAG_LIST : return "L";
		case TAG_RESOURCE : return "R";
	}

	return GetTagName(val);
}
示例#8
0
std::string ReportManager::report()
{
	std::stringstream ss;
	size_t total = 0;
	ss << "[MM] **** MmSystem Memory Report ****" << std::endl;

	for (size_t i = 0; i < TAG_COUNT; ++i)
	{
		total += tags_[i];
		ss << "[MM] " << GetTagName((mm::RECORD_TAG)i) << ": "
		   << tags_[i] << " bytes(" << float(tags_[i]) / 1024.f / 1024.f << " Mb), "
		   << "(" << cnts_[i] << "/" << peekcnts_[i] << ") cnts"
		   << std::endl;
	}
	ss << "[MM] ---------------" << std::endl;
	ss << "[MM] total: " << total << " bytes(" << float(total) / 1024.f / 1024.f << " Mb)" << std::endl;

	return ss.str();
}
示例#9
0
void TraceInfo(int session_id,char *class_name,int message_id,int num_parms,
			   parm_node parms[])
{
	int i;
	val_type val;
	
	SendSessionAdminText(session_id,"%-15s%-20s ",class_name,GetNameByID(message_id));
	
	for (i=0;i<num_parms;i++)
	{
		SendSessionAdminText(session_id,"%s = ",GetNameByID(parms[i].name_id));
		val.int_val = parms[i].value;
		SendSessionAdminText(session_id,"%s ",GetTagName(val));
		SendSessionAdminText(session_id,"%s",GetDataName(val));
		
		if (i != num_parms-1)
			SendSessionAdminText(session_id,", ");
	}
	SendSessionAdminText(session_id,"\n");
}
示例#10
0
static void
PrintTagList(struct TagItem *tags)
{
  struct TagItem *tstate;
  struct TagItem *tag;

  if(tags == NULL)
  {
    KPrintF("No taglist\n");
  }
  else
  {
    tstate = tags;
    while((tag = NextTagItem(&tstate)))
    {
      KPrintF("\n  %30s, 0x%08lx,", GetTagName( tag->ti_Tag ), tag->ti_Data);
    }
    KPrintF("\n  TAG_DONE)");
  }
}
void IGameplayCueInterface::HandleGameplayCue(AActor *Self, FGameplayTag GameplayCueTag, EGameplayCueEvent::Type EventType, FGameplayCueParameters Parameters)
{
	SCOPE_CYCLE_COUNTER(STAT_GameplayCueInterface_HandleGameplayCue);

	// Look up a custom function for this gameplay tag. 
	UClass* Class = Self->GetClass();
	IGameplayTagsModule& GameplayTagsModule = IGameplayTagsModule::Get();
	FGameplayTagContainer TagAndParentsContainer = GameplayTagsModule.GetGameplayTagsManager().RequestGameplayTagParents(GameplayCueTag);

	Parameters.OriginalTag = GameplayCueTag;

	//Find entry for the class
	FGameplayCueTagFunctionList& GameplayTagFunctionList = PerClassGameplayTagToFunctionMap.FindOrAdd(Class);
	TArray<FCueNameAndUFunction>* FunctionList = GameplayTagFunctionList.Find(GameplayCueTag);
	if (FunctionList == NULL)
	{
		//generate new function list
		FunctionList = &GameplayTagFunctionList.Add(GameplayCueTag);

		for (auto InnerTagIt = TagAndParentsContainer.CreateConstIterator(); InnerTagIt; ++InnerTagIt)
		{
			UFunction* Func = NULL;
			FName CueName = InnerTagIt->GetTagName();

			Func = Class->FindFunctionByName(CueName, EIncludeSuperFlag::IncludeSuper);
			// If the handler calls ForwardGameplayCueToParent, keep calling functions until one consumes the cue and doesn't forward it
			while (Func)
			{
				FCueNameAndUFunction NewCueFunctionPair;
				NewCueFunctionPair.Tag = *InnerTagIt;
				NewCueFunctionPair.Func = Func;
				FunctionList->Add(NewCueFunctionPair);

				Func = Func->GetSuperFunction();
			}

			// Native functions cant be named with ".", so look for them with _. 
			FName NativeCueFuncName = *CueName.ToString().Replace(TEXT("."), TEXT("_"));
			Func = Class->FindFunctionByName(NativeCueFuncName, EIncludeSuperFlag::IncludeSuper);

			while (Func)
			{
				FCueNameAndUFunction NewCueFunctionPair;
				NewCueFunctionPair.Tag = *InnerTagIt;
				NewCueFunctionPair.Func = Func;
				FunctionList->Add(NewCueFunctionPair);

				Func = Func->GetSuperFunction();
			}
		}
	}

	//Iterate through all functions in the list until we should no longer continue
	check(FunctionList);
		
	bool bShouldContinue = true;
	for (int32 FunctionIndex = 0; bShouldContinue && (FunctionIndex < FunctionList->Num()); ++FunctionIndex)
	{
		FCueNameAndUFunction& CueFunctionPair = FunctionList->GetData()[FunctionIndex];
		UFunction* Func = CueFunctionPair.Func;
		Parameters.MatchedTagName = CueFunctionPair.Tag;

		// Reset the forward parameter now, so we can check it after function
		bForwardToParent = false;
		IGameplayCueInterface::DispatchBlueprintCustomHandler(Self, Func, EventType, Parameters);

		bShouldContinue = bForwardToParent;
	}

	if (bShouldContinue)
	{
		TArray<UGameplayCueSet*> Sets;
		GetGameplayCueSets(Sets);
		for (UGameplayCueSet* Set : Sets)
		{
			bShouldContinue = Set->HandleGameplayCue(Self, GameplayCueTag, EventType, Parameters);
			if (!bShouldContinue)
			{
				break;
			}
		}
	}

	if (bShouldContinue)
	{
		Parameters.MatchedTagName = GameplayCueTag;
		GameplayCueDefaultHandler(EventType, Parameters);
	}
}
// Builds the option list from the data source.
void ElementFormControlDataSelect::BuildOptions()
{
	widget->ClearOptions();

	if (data_source == NULL)
		return;

	// Store the old selection value and index. These will be used to restore the selection to the
	// most appropriate option after the options have been rebuilt.
	Rocket::Core::String old_value = GetValue();
	int old_selection = GetSelection();

	Rocket::Core::String fields_attribute = GetAttribute<Rocket::Core::String>("fields", "");
	Rocket::Core::String valuefield_attribute = GetAttribute<Rocket::Core::String>("valuefield", "");
	Rocket::Core::String data_formatter_attribute = GetAttribute<Rocket::Core::String>("formatter", "");
	DataFormatter* data_formatter = NULL;

	// Process the attributes.
	if (fields_attribute.Empty())
	{
		Core::Log::Message(Rocket::Core::Log::LT_ERROR, "DataQuery failed, no fields specified for %s.", GetTagName().CString());
		return;
	}

	if (valuefield_attribute.Empty())
	{
		valuefield_attribute = fields_attribute.Substring(0, fields_attribute.Find(","));
	}

	if (!data_formatter_attribute.Empty())
	{
		data_formatter = DataFormatter::GetDataFormatter(data_formatter_attribute);
		if (!data_formatter)
			Core::Log::Message(Rocket::Core::Log::LT_WARNING, "Unable to find data formatter named '%s', formatting skipped.", data_formatter_attribute.CString());
	}

	// Build a list of attributes
	Rocket::Core::String fields(valuefield_attribute);
	fields += ",";
	fields += fields_attribute;

	DataQuery query(data_source, data_table, fields);
	while (query.NextRow())
	{
		Rocket::Core::StringList fields;
		Rocket::Core::String value = query.Get<Rocket::Core::String>(0, "");

		for (size_t i = 1; i < query.GetNumFields(); ++i)
			fields.push_back(query.Get< Rocket::Core::String>(i, ""));

		Rocket::Core::String formatted("");
		if (fields.size() > 0)
			formatted = fields[0];

		if (data_formatter)
			data_formatter->FormatData(formatted, fields);

		// Add the data as an option.
		widget->AddOption(formatted, value, -1, false);
	}

	// If an option was selected before, attempt to restore the selection to it.
	if (old_selection > -1)
	{
		// Try to find a selection with the same value as the previous one.
		for (int i = 0; i < GetNumOptions(); ++i)
		{
			SelectOption* option = GetOption(i);
			if (option->GetValue() == old_value)
			{
				widget->SetSelection(i, true);
				return;
			}
		}

		// Failed to find an option with the same value. Attempt to at least set the same index.
		int new_selection = Rocket::Core::Math::Clamp(old_selection, 0, GetNumOptions() - 1);
		if (GetNumOptions() == 0)
			new_selection = -1;

		widget->SetSelection(new_selection, true);
	}
}
//--------------------------------------------------------------------------
/// Returns the CommandTree as XML based on the contents of this Processor
/// \return XML describing the added commands and Processors
//--------------------------------------------------------------------------
string CommandProcessor::GetCommandTree()
{
    stringstream strOut;

    // Add the link to the settings. Only add this link if there are editable items.
    if (GetEditableCount() > 0)
    {
        strOut << "<" << GetTagName() << "Settings name='Settings' url='" << GetFullPathString().asCharArray() << "/settings.xml' display='true'>";
        strOut << "</" << GetTagName() << "Settings>";
    }

    // Add the child nodes
    CommandList::const_iterator objIter;

    for (objIter = m_Commands.begin(); objIter < m_Commands.end(); ++objIter)
    {
        CommandResponse* pObj = *objIter;
        PsAssert(pObj != NULL);

        if (pObj->GetTreeInclude())
        {
            strOut << "<" << pObj->GetTagName() << " name='" << pObj->GetDisplayName() << "' url='";

            if (pObj->GetURL() != NULL)
            {
                strOut << GetFullPathString().asCharArray() << "/" << pObj->GetURL();
            }

            strOut << "' ";

            if (pObj->GetEditableContent() != NOT_EDITABLE)
            {
                strOut << "editable='TRUE' ";
            }

            strOut << "display='" << GetUIDisplayModeString(pObj->GetUIDisplayMode()) << "' prefix='";
            strOut << GetTitlePrefix() << "' ></" << pObj->GetTagName() << ">";
        }
    }

    // Add the sub-tree
    vector<CommandProcessor*>::const_iterator it;

    for (it = m_Processors.begin() ; it < m_Processors.end(); ++it)
    {
        CommandProcessor* pProc = *it;
        PsAssert(pProc != NULL);

        strOut << "<" << pProc->GetTagName() << " name='" << pProc->GetDisplayName() << "' id='";
        strOut << pProc->GetID() << "' display='" << GetUIDisplayModeString(pProc->GetUIDisplayMode());
        strOut << "' url='" << pProc->GetFullPathString().asCharArray() << "' prefix='" << GetTitlePrefix() << "'";

        string derivedAttrs = pProc->GetDerivedAttributes();

        if (!derivedAttrs.empty())
        {
            strOut << " " << derivedAttrs;
        }

        strOut << ">";

        strOut << pProc->GetCommandTree();

        strOut << "</" << pProc->GetTagName() << ">";
    }

    return strOut.str();
}
void UK2Node_GameplayCueEvent::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
{
	// actions get registered under specific object-keys; the idea is that 
	// actions might have to be updated (or deleted) if their object-key is  
	// mutated (or removed)... here we use the node's class (so if the node 
	// type disappears, then the action should go with it)
	UClass* ActionKey = GetClass();
	// to keep from needlessly instantiating a UBlueprintNodeSpawner, first   
	// check to make sure that the registrar is looking for actions of this type
	// (could be regenerating actions for a specific asset, and therefore the 
	// registrar would only accept actions corresponding to that asset)
	if (!ActionRegistrar.IsOpenForRegistration(ActionKey))
	{
		return;
	}

	auto CustomizeCueNodeLambda = [](UEdGraphNode* NewNode, bool bIsTemplateNode, FName TagName)
	{
		UK2Node_GameplayCueEvent* EventNode = CastChecked<UK2Node_GameplayCueEvent>(NewNode);
		EventNode->CustomFunctionName = TagName;
	};
	
	IGameplayTagsModule& GameplayTagsModule = IGameplayTagsModule::Get();
	FGameplayTag RootTag = GameplayTagsModule.GetGameplayTagsManager().RequestGameplayTag(FName(TEXT("GameplayCue")));
	
	
	FGameplayTagContainer CueTags = GameplayTagsModule.GetGameplayTagsManager().RequestGameplayTagChildren(RootTag);
	// Add a root GameplayCue function as a default
	CueTags.AddTag(RootTag);
	for (auto TagIt = CueTags.CreateConstIterator(); TagIt; ++TagIt)
	{
		UBlueprintNodeSpawner::FCustomizeNodeDelegate PostSpawnDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(CustomizeCueNodeLambda, TagIt->GetTagName());
		
		UBlueprintNodeSpawner* NodeSpawner = UBlueprintEventNodeSpawner::Create(GetClass(), TagIt->GetTagName());
		check(NodeSpawner != nullptr);
		NodeSpawner->CustomizeNodeDelegate = PostSpawnDelegate;
		
		ActionRegistrar.AddBlueprintAction(ActionKey, NodeSpawner);
	}
}
示例#15
0
CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, bool bStartTag) {
  m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
  if (IsEOF()) {
    return nullptr;
  }
  CFX_ByteString tag_name, tag_space;
  bool bEndTag;
  GetTagName(tag_space, tag_name, bEndTag, bStartTag);
  if (tag_name.IsEmpty() || bEndTag) {
    return nullptr;
  }
  CXML_Element* pElement = new CXML_Element;
  pElement->m_pParent = pParent;
  pElement->SetTag(tag_space.AsStringC(), tag_name.AsStringC());
  do {
    CFX_ByteString attr_space, attr_name;
    while (m_dwIndex < m_dwBufferSize) {
      SkipWhiteSpaces();
      if (IsEOF()) {
        break;
      }
      if (!g_FXCRT_XML_IsNameIntro(m_pBuffer[m_dwIndex])) {
        break;
      }
      GetName(attr_space, attr_name);
      SkipWhiteSpaces();
      if (IsEOF()) {
        break;
      }
      if (m_pBuffer[m_dwIndex] != '=') {
        break;
      }
      m_dwIndex++;
      SkipWhiteSpaces();
      if (IsEOF()) {
        break;
      }
      CFX_WideString attr_value;
      GetAttrValue(attr_value);
      pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value);
    }
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (m_dwIndex < m_dwBufferSize || IsEOF()) {
      break;
    }
  } while (ReadNextBlock());
  SkipWhiteSpaces();
  if (IsEOF()) {
    return pElement;
  }
  uint8_t ch = m_pBuffer[m_dwIndex++];
  if (ch == '/') {
    m_dwIndex++;
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    return pElement;
  }
  if (ch != '>') {
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    delete pElement;
    return nullptr;
  }
  SkipWhiteSpaces();
  if (IsEOF()) {
    return pElement;
  }
  CFX_UTF8Decoder decoder;
  CFX_WideTextBuf content;
  bool bCDATA = false;
  int32_t iState = 0;
  do {
    while (m_dwIndex < m_dwBufferSize) {
      ch = m_pBuffer[m_dwIndex++];
      switch (iState) {
        case 0:
          if (ch == '<') {
            iState = 1;
          } else if (ch == '&') {
            decoder.ClearStatus();
            decoder.AppendChar(GetCharRef());
          } else {
            decoder.Input(ch);
          }
          break;
        case 1:
          if (ch == '!') {
            iState = 2;
          } else if (ch == '?') {
            SkipLiterals("?>");
            SkipWhiteSpaces();
            iState = 0;
          } else if (ch == '/') {
            CFX_ByteString space, name;
            GetName(space, name);
            SkipWhiteSpaces();
            m_dwIndex++;
            iState = 10;
          } else {
            content << decoder.GetResult();
            CFX_WideString dataStr = content.MakeString();
            if (!bCDATA && !m_bSaveSpaceChars) {
              dataStr.TrimRight(L" \t\r\n");
            }
            InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement);
            content.Clear();
            decoder.Clear();
            bCDATA = false;
            iState = 0;
            m_dwIndex--;
            CXML_Element* pSubElement = ParseElement(pElement, true);
            if (!pSubElement) {
              break;
            }
            pSubElement->m_pParent = pElement;
            pElement->m_Children.push_back(
                {CXML_Element::Element, pSubElement});
            SkipWhiteSpaces();
          }
          break;
        case 2:
          if (ch == '[') {
            SkipLiterals("]]>");
          } else if (ch == '-') {
            m_dwIndex++;
            SkipLiterals("-->");
          } else {
            SkipLiterals(">");
          }
          decoder.Clear();
          SkipWhiteSpaces();
          iState = 0;
          break;
      }
      if (iState == 10) {
        break;
      }
    }
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) {
      break;
    }
  } while (ReadNextBlock());
  content << decoder.GetResult();
  CFX_WideString dataStr = content.MakeString();
  if (!m_bSaveSpaceChars) {
    dataStr.TrimRight(L" \t\r\n");
  }
  InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement);
  content.Clear();
  decoder.Clear();
  bCDATA = false;
  return pElement;
}
示例#16
0
char *BlakodStackInfo()
{
	static char buf[5000];
	class_node *c;
	int i;

	buf[0] = '\0';
	for (i=message_depth-1;i>=0;i--)
	{
		char s[1000];
		if (stack[i].class_id == INVALID_CLASS)
		{
			sprintf(s,"Server");
		}
		else
		{
			c = GetClassByID(stack[i].class_id);
			if (c == NULL)
				sprintf(s,"Invalid class %i",stack[i].class_id);
			else
			{
				char *bp;
				char *class_name;
				char buf2[200];
				char parms[800];
				int j;

				/* for current frame, stack[] has pointer at beginning of function;
					use current pointer instead */
				bp = stack[i].bkod_ptr;
				if (i == message_depth-1)
					bp = bkod;

				class_name = "(unknown)";
				if (c->class_name)
					class_name = c->class_name;
				/* use %.*s with a fixed string of pluses to get exactly one plus per
					propagate depth */
				sprintf(s,"%.*s%s::%s",stack[i].propagate_depth,"++++++++++++++++++++++",class_name,GetNameByID(stack[i].message_id));
				strcat(s,"(");
				parms[0] = '\0';
				for (j=0;j<stack[i].num_parms;j++)
				{
					val_type val;
					val.int_val = stack[i].parms[j].value;
					sprintf(buf2,"#%s=%s %s",GetNameByID(stack[i].parms[j].name_id),
							  GetTagName(val),GetDataName(val));
					if (j > 0)
						strcat(parms,",");
					strcat(parms,buf2);
				}
				strcat(s,parms);
				strcat(s,")");
				sprintf(buf2," %s (%i)",c->fname,GetSourceLine(c,bp));
				strcat(s,buf2);
			}
		}
		if (i < message_depth-1)
			strcat(buf,"\n");
		strcat(buf,s);
		if (strlen(buf) > sizeof(buf) - 1000)
		{
			strcat(buf,"\n...and more");
			break;
		}
	}
	return buf;
}
示例#17
0
void psXMLTag::GetTagParm(const char* parm, csString& value )
{
    psString param(" ");
    param.Append(parm);
    param.Append('=');
 
    int start = FindSubString(param, 0, XML_CASE_INSENSITIVE);

    //Checks to see if the parm is getting mixed up with the tag name.
    if ( start==1 )
    {
        psString tagName;
        GetTagName(tagName);
        start = FindSubString(param,(int)tagName.Length(),XML_CASE_INSENSITIVE); 
    }
        
    psString tempStr;

    value="";

    const char *myData = GetData();

    while ( start != -1 )
    {
        start += (int)param.Length();
        
        if (start >= (int)Length())
            return;
        
        // skip whitespace after parm name
        while (myData[start]==' ')
        {
            start++;
            if (start >= (int)Length())
                return;
        }
        
        size_t end = start+1;  // parm is at least one char
        
        // Determine delimiter, if any
        char chr;
        
        if ( myData[start] == '\"')
            chr = '\"';
        else if ( myData[start] == '[')
            chr = ']';
        else if ( myData[start] == '\'')
            chr = '\'';
        else
            chr = ' ';
        
        while ( end < Length() && myData[end]!=chr && myData[end] != '>')
            end++;
        
        GetSubString(tempStr, start+(chr!=' '), end);
        
        // Replace any xml code with the correct '&'
        const char* what = "&amp;";
        const char* with = "&";
        
        while (tempStr.FindSubString(what) != -1)
            tempStr.ReplaceSubString(what,with); 

       
        what = "&apos;";
        with = "'";
        while (tempStr.FindSubString(what) != -1)
            tempStr.ReplaceSubString(what,with);
     
        value = tempStr;
        return;
    }
}
示例#18
0
/* returns either RETURN_PROPAGATE or RETURN_NO_PROPAGATE.  If no propagate,
* then the return value in ret_val is good.
*/
int InterpretAtMessage(int object_id,class_node* c,message_node* m,
					   int num_sent_parms,
					   parm_node sent_parms[],val_type *ret_val)
{
	opcode_type opcode;
	char opcode_char;
	char num_locals,num_parms;
	local_var_type local_vars;
	int parm_id;
	val_type parm_init_value;
	
	int i,j;
	char *inst_start;
	Bool found_parm;
	
	num_locals = get_byte();
	num_parms = get_byte();
	
	local_vars.num_locals = num_locals+num_parms;
	if (local_vars.num_locals > MAX_LOCALS)
	{
		dprintf("InterpretAtMessage found too many locals and parms for OBJECT %i CLASS %s MESSAGE %s (%s) aborting and returning NIL\n",
			object_id,
			c? c->class_name : "(unknown)",
			m? GetNameByID(m->message_id) : "(unknown)",
			BlakodDebugInfo());
		(*ret_val).int_val = NIL;
		return RETURN_NO_PROPAGATE;
	}
	
	if (ConfigBool(DEBUG_INITLOCALS))
	{
		parm_init_value.v.tag = TAG_INVALID;
		parm_init_value.v.data = 1;
		
		for (i = 0; i < local_vars.num_locals; i++)
		{
			local_vars.locals[i] = parm_init_value;
		}
	}
	
	/* both table and call parms are sorted */
	
	j = 0;
	for (i=0;i<num_parms;i++)
	{
		parm_id = get_int(); /* match this with parameters */
		parm_init_value.int_val = get_int();
		
		/* look if we have a value for this parm */
		found_parm = False;
		j = 0;			/* don't assume sorted for now */
		while (j < num_sent_parms)
		{
			if (sent_parms[j].name_id == parm_id)
			{
			/* assuming no RetrieveValue needed here, since InterpretCall
				does that for us */
				local_vars.locals[i].int_val = sent_parms[j].value;
				found_parm = True;
				j++;
				break;
			}
			j++;
		}
		
		if (!found_parm)
			local_vars.locals[i].int_val = parm_init_value.int_val;
	}
	
	for(;;)			/* returns when gets a blakod return */
	{
		num_interpreted++;
		
		/* infinite loop check */
		if (num_interpreted > ConfigInt(BLAKOD_MAX_STATEMENTS))
		{
			bprintf("InterpretAtMessage interpreted too many instructions--infinite loop?\n");
			
			dprintf("Infinite loop at depth %i\n", message_depth);
			dprintf("  OBJECT %i CLASS %s MESSAGE %s (%s) aborting and returning NIL\n",
				object_id,
				c? c->class_name : "(unknown)",
				m? GetNameByID(m->message_id) : "(unknown)",
				BlakodDebugInfo());
			
			dprintf("  Local variables:\n");
			for (i=0;i<local_vars.num_locals;i++)
			{
				dprintf("  %3i : %s %5i\n",
					i,
					GetTagName(local_vars.locals[i]),
					local_vars.locals[i].v.data);
			}
			
			(*ret_val).int_val = NIL;
			return RETURN_NO_PROPAGATE;
		}
		
		opcode_char = get_byte();
		
		//memcpy(&opcode,&opcode_char,1);
		{
			char *ch=(char*)&opcode;
			*ch = opcode_char ;
		}
		
		/* use continues instead of breaks here since there is nothing
		after the switch, for efficiency */
		
		switch (opcode.command)
		{
			case UNARY_ASSIGN : 
				InterpretUnaryAssign(object_id,&local_vars,opcode);
				continue;
			case BINARY_ASSIGN : 
				InterpretBinaryAssign(object_id,&local_vars,opcode);
				continue;
			case GOTO : 
				inst_start = bkod - 1; /* we've read one byte of instruction so far */
				InterpretGoto(object_id,&local_vars,opcode,inst_start);
				continue;
			case CALL : 
				InterpretCall(object_id,&local_vars,opcode);
				continue;
			case RETURN : 
				if (opcode.dest == PROPAGATE)
					return RETURN_PROPAGATE;
				else
				{
					int data;
					data = get_int();	    
					*ret_val = RetrieveValue(object_id,&local_vars,opcode.source1,data);
					return RETURN_NO_PROPAGATE;
				}
				/* can't get here */
					continue;
			default : 
				bprintf("InterpretAtMessage found INVALID OPCODE command %i.  die.\n", opcode.command);
				FlushDefaultChannels();
				continue;
		}
	}
}
示例#19
0
CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, FX_BOOL bStartTag)
{
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (IsEOF()) {
        return NULL;
    }
    CFX_ByteString tag_name, tag_space;
    FX_BOOL bEndTag;
    GetTagName(tag_space, tag_name, bEndTag, bStartTag);
    if (tag_name.IsEmpty() || bEndTag) {
        return NULL;
    }
    CXML_Element* pElement;
    pElement = FX_NEW CXML_Element;
    if (pElement) {
        pElement->m_pParent = pParent;
        pElement->SetTag(tag_space, tag_name);
    }
    if (!pElement) {
        return NULL;
    }
    do {
        CFX_ByteString attr_space, attr_name;
        while (m_dwIndex < m_dwBufferSize) {
            SkipWhiteSpaces();
            if (IsEOF()) {
                break;
            }
            if (!g_FXCRT_XML_IsNameIntro(m_pBuffer[m_dwIndex])) {
                break;
            }
            GetName(attr_space, attr_name);
            SkipWhiteSpaces();
            if (IsEOF()) {
                break;
            }
            if (m_pBuffer[m_dwIndex] != '=') {
                break;
            }
            m_dwIndex ++;
            SkipWhiteSpaces();
            if (IsEOF()) {
                break;
            }
            CFX_WideString attr_value;
            GetAttrValue(attr_value);
            pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value);
        }
        m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
        if (m_dwIndex < m_dwBufferSize || IsEOF()) {
            break;
        }
    } while (ReadNextBlock());
    SkipWhiteSpaces();
    if (IsEOF()) {
        return pElement;
    }
    FX_BYTE ch = m_pBuffer[m_dwIndex ++];
    if (ch == '/') {
        m_dwIndex ++;
        m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
        return pElement;
    }
    if (ch != '>') {
        m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
        delete pElement;
        return NULL;
    }
    SkipWhiteSpaces();
    if (IsEOF()) {
        return pElement;
    }
    CFX_UTF8Decoder decoder;
    CFX_WideTextBuf content;
    FX_BOOL bCDATA = FALSE;
    FX_INT32 iState = 0;
    do {
        while (m_dwIndex < m_dwBufferSize) {
            ch = m_pBuffer[m_dwIndex ++];
            switch (iState) {
                case 0:
                    if (ch == '<') {
                        iState = 1;
                    } else if (ch == '&') {
                        decoder.ClearStatus();
                        decoder.AppendChar(GetCharRef());
                    } else {
                        decoder.Input(ch);
                    }
                    break;
                case 1:
                    if (ch == '!') {
                        iState = 2;
                    } else if (ch == '?') {
                        SkipLiterals(FX_BSTRC("?>"));
                        SkipWhiteSpaces();
                        iState = 0;
                    } else if (ch == '/') {
                        CFX_ByteString space, name;
                        GetName(space, name);
                        SkipWhiteSpaces();
                        m_dwIndex ++;
                        iState = 10;
                    } else {
                        content << decoder.GetResult();
                        CFX_WideString dataStr = content.GetWideString();
                        if (!bCDATA && !m_bSaveSpaceChars) {
                            dataStr.TrimRight((FX_LPCWSTR)L" \t\r\n");
                        }
                        InsertContentSegment(bCDATA, dataStr, pElement);
                        content.Clear();
                        decoder.Clear();
                        bCDATA = FALSE;
                        iState = 0;
                        m_dwIndex --;
                        CXML_Element* pSubElement = ParseElement(pElement, TRUE);
                        if (pSubElement == NULL) {
                            break;
                        }
                        pSubElement->m_pParent = pElement;
                        pElement->m_Children.Add((FX_LPVOID)CXML_Element::Element);
                        pElement->m_Children.Add(pSubElement);
                        SkipWhiteSpaces();
                    }
                    break;
                case 2:
                    if (ch == '[') {
                        SkipLiterals(FX_BSTRC("]]>"));
                    } else if (ch == '-') {
                        m_dwIndex ++;
                        SkipLiterals(FX_BSTRC("-->"));
                    } else {
                        SkipLiterals(FX_BSTRC(">"));
                    }
                    decoder.Clear();
                    SkipWhiteSpaces();
                    iState = 0;
                    break;
            }
            if (iState == 10) {
                break;
            }
        }
        m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
        if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) {
            break;
        }
    } while (ReadNextBlock());
    content << decoder.GetResult();
    CFX_WideString dataStr = content.GetWideString();
    if (!m_bSaveSpaceChars) {
        dataStr.TrimRight((FX_LPCWSTR)L" \t\r\n");
    }
    InsertContentSegment(bCDATA, dataStr, pElement);
    content.Clear();
    decoder.Clear();
    bCDATA = FALSE;
    return pElement;
}