예제 #1
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Parse status window type. */
StatusWindowType ParseStatusWindowType(const TokenNode *tp)
{
   static const StringMappingType mapping[] = {
      { "corner",    SW_CORNER   },
      { "off",       SW_OFF      },
      { "screen",    SW_SCREEN   },
      { "window",    SW_WINDOW   }
   };
   return ParseAttribute(mapping, ARRAY_LENGTH(mapping), tp,
                         "coordinates", SW_SCREEN);
}
	void CImageAttribute::SetAttributeString(LPCTSTR pStrImageAttri)
	{
		if (m_sImageAttribute == pStrImageAttri)
			return;

		Clear();

		m_sImageAttribute = pStrImageAttri;
		m_sImage = m_sImageAttribute;
		ParseAttribute(pStrImageAttri);
	}
void AttributesScheme::loadXMLSettings(xml::XMLElement* elem)
{
	xml::xmlSubElementsMapIT it= elem->getElementsBegin();
	xml::xmlSubElementsMapIT end= elem->getElementsEnd();
	for(;it!=end;++it)
	{
		if((*it)->GetType()!=xml::ENT_Element)continue;
		xml::XMLElement* e=dynamic_cast<xml::XMLElement*>(*it);
		if(e->getName().equals_ignore_case(mT("Attribute")))
		{
			ParseAttribute(e);
		}
	}
}
bool GenericXMLParser::ParseTag(String &tag, Anything &tagAttributes)
{
	StartTrace(GenericXMLParser.ParseTag);
	tag = ParseName();
	Trace("tag = " << tag);
	while (!IsEof()) {
		SkipWhitespace();
		int c = Peek();
		switch (c) {
			case '>': // done with tag
				c = Get();
				return true;//lint !e438
			case '/': // an empty tag? i.e. <br />
				c = Get();
				if ('>' == Peek()) {
					c = Get();
					return false;//lint !e438
				}
				// an error occured, ignore '/' silently
				PutBack(c);
			default: {//lint !e616
				String name;
				String value;
				if (ParseAttribute(name, value)) {
					tagAttributes[name] = value;
				} else {
					// non-well formed XML...no value given
					if (name.Length() > 0) {
						tagAttributes.Append(name);
					} else {
						String msg("Unexpected character <");
						c = Get();
						msg.AppendAsHex((unsigned char)c).Append("> near ").Append(tag);
						Error(msg);
						tagAttributes.Append(String(char(c)));
					}
				}
			}
		}
	}
	Error("unexpected EOF in Tag");
	return false; // no body to expect
}
예제 #5
0
	bool XMLReader::ParseElement()
	{
		// element ::= EmptyElemTag
		//				| STag content ETag
		// EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
		// STag	   ::=   	'<' Name (S Attribute)* S? '>'
		if (ParseString("<") && ParseName(mCurrentName)) {
			mNodeType = kElement;
			mAttributes.clear();
			while (ParseRequiredWhitespace()) {
				Attribute attribute;
				if (ParseString("/>")) {
					mIsEmptyElement = true;
					PopNamespaces(PushNamespaces());
					return true;
				}
				else if (ParseString(">")) {
					mIsEmptyElement = false;
					PushTag();
					return true;
				}
				else if (ParseAttribute(attribute)) {
					mAttributes.push_back(attribute);
				}
				else return false;
			}
			if (ParseString("/>")) {
				mIsEmptyElement = true;
				PopNamespaces(PushNamespaces());
				return true;
			}
			else if (ParseString(">")) {
				mIsEmptyElement = false;
				PushTag();
				return true;
			}
		}

		return false;
	}
예제 #6
0
	bool XMLReader::ParseXmlDeclaration()
	{
		// XMLDecl	::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
		// VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
		// EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )
		// SDDecl ::=  S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
		if (ParseString("<?xml")) {
			mNodeType = kXmlDeclaration;
			mCurrentName.SetName("xml");
			mAttributes.clear();
			while (ParseRequiredWhitespace()) {
				Attribute attribute;
				if (ParseString("?>")) return true;
				else if (ParseAttribute(attribute)) {
					mAttributes.push_back(attribute);
				}
				else return false;
			}
			if (ParseString("?>")) return true;
		}
		return false;
	}
 // This reads xmlStream until the end of the start or empty-element tag is
 // reached, parsing attributes along the way into attributeDestination,
 // throwing an exception if it does not reach the end of the tag without
 // the stream ending or finding malformed XML. All the characters of the
 // tag get put into tagRecord if it is not NULL.
 inline void
 RestrictedXmlParser::CloseStartTag( AttributeMap* attributeDestination,
                                     std::ostream* tagRecord )
 {
   if( !(SkipWhitespace( tagRecord )) )
   {
     throw std::runtime_error( "Could not find end of start tag!" );
   }
   // Now currentChar is the end of the start tag ('>'), or the first
   // character of the end of an empty element tag ('/' in "/>") (or the
   // tag is malformed with a '/' out of place), or is the first character
   // of an attribute name.
   if( TagIsStillOpen( tagRecord ) )
   {
     ParseAttribute( attributeDestination,
                     tagRecord );
     if( !(ReadCharacter( tagRecord )) )
     {
       throw std::runtime_error( "Could not find end of start tag!" );
     }
     CloseStartTag( attributeDestination,
                    tagRecord );
   }
 }
예제 #8
0
파일: Scale.cpp 프로젝트: jpoirier/x-gauges
Scale::Scale(const QDomElement& el)
{
	m_bBoundScale = true;
	
	Q_ASSERT(el.tagName() == TAG_SCALE);
	QString qsA = ParseAttribute(el, TAG_PARAM);
	m_pPar = ParameterContainer::GetInstance()->GetParameter(qsA);
	if(m_pPar == NULL) {
		qCritical() << "Scale parameter" << qsA << "does not exist in ParameterContainer.";
	} 
		
	m_bYellow		= el.attribute(TAG_YELLOW)!=QLatin1String(TAG_NO);
	m_bGreen			= el.attribute(TAG_GREEN)!=QLatin1String(TAG_NO);
	m_bLowLimit		= el.attribute(TAG_LO_LIMIT)!=QLatin1String(TAG_NO);
	qsA = el.attribute(TAG_HI_LIMIT);
	m_eHighLimit	= qsA==QLatin1String(TAG_NO) ? ltNone : 
						  qsA==QLatin1String(TAG_ARC) ? ltArc : ltTick;
						  
	m_fDumping     = el.attribute(TAG_DUMPING, "0").toFloat();
	m_vDump.resize(m_pPar->GetCount());
	
	// Scale type
	Q_ASSERT(m_pPar->GetUnitKeyUser() >= 0);
	bool bFound = false;
	QDomElement et = el.firstChildElement(TAG_TYPE);
	for(; !et.isNull(); et = et.nextSiblingElement(TAG_TYPE)) {
		// We are only interested in user selected units
		bFound = (ParseUnitKey(et, TAG_UNIT) == m_pPar->GetUnitKeyUser());
		if(bFound) {
			m_fS = ParseAttribute(et, TAG_LOW).toFloat();
			m_fE = ParseAttribute(et, TAG_HIGH).toFloat();
	
			m_fMajorTickStep      = ParseAttribute(et, TAG_MAJOR).toFloat();
			m_iMinorIntervalCount = ParseAttribute(et, TAG_MINOR).toInt();
			m_fLabelStep          = ParseAttribute(et, TAG_LABEL).toFloat();
			m_fMultiplier         = et.attribute(TAG_MULT,"1").toFloat();
			m_iDecimals           = el.attribute(TAG_DECIMALS).toInt();
			
			break;
		}
	}
}		
void
nsMathMLmpaddedFrame::ProcessAttributes()
{
  /*
  parse the attributes

  width  = [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | h-unit | namedspace)
  height = [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | v-unit | namedspace)
  depth  = [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | v-unit | namedspace)
  lspace = [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | h-unit | namedspace)
  voffset= [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | v-unit | namedspace)
  */

  nsAutoString value;

  /* The REC says:
  There is one exceptional element, <mpadded>, whose attributes cannot be 
  set with <mstyle>. When the attributes width, height and depth are specified
  on an <mstyle> element, they apply only to the <mspace/> element. Similarly, 
  when lspace is set with <mstyle>, it applies only to the <mo> element. To be
  consistent, the voffset attribute of the mpadded element can not be set on
  mstyle. 
  */

  // See if attributes are local, don't access mstyle !

  // width
  mWidthSign = NS_MATHML_SIGN_INVALID;
  GetAttribute(mContent, nullptr, nsGkAtoms::width, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mWidthSign, mWidth, mWidthPseudoUnit)) {      
      ReportParseError(nsGkAtoms::width->GetUTF16String(), value.get());
    }
  }

  // height
  mHeightSign = NS_MATHML_SIGN_INVALID;
  GetAttribute(mContent, nullptr, nsGkAtoms::height, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mHeightSign, mHeight, mHeightPseudoUnit)) {
      ReportParseError(nsGkAtoms::height->GetUTF16String(), value.get());
    }
  }

  // depth
  mDepthSign = NS_MATHML_SIGN_INVALID;
  GetAttribute(mContent, nullptr, nsGkAtoms::depth_, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mDepthSign, mDepth, mDepthPseudoUnit)) {
      ReportParseError(nsGkAtoms::depth_->GetUTF16String(), value.get());
    }
  }

  // lspace
  mLeadingSpaceSign = NS_MATHML_SIGN_INVALID;
  GetAttribute(mContent, nullptr, nsGkAtoms::lspace_, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mLeadingSpaceSign, mLeadingSpace, 
                        mLeadingSpacePseudoUnit)) {
      ReportParseError(nsGkAtoms::lspace_->GetUTF16String(), value.get());
    }
  }

  // voffset
  mVerticalOffsetSign = NS_MATHML_SIGN_INVALID;
  GetAttribute(mContent, nullptr, nsGkAtoms::voffset_, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mVerticalOffsetSign, mVerticalOffset,
                        mVerticalOffsetPseudoUnit)) {
      ReportParseError(nsGkAtoms::voffset_->GetUTF16String(), value.get());
    }
  }
  
}
예제 #10
0
bool XSDParser::ParseContent(DTDElement& node, bool extended /*=false*/)
{
    DTDElement::EType curr_type;
    int emb=0;
    bool eatEOT= false;
    bool hasContents= false;
    TToken tok;
    for ( tok=GetNextToken(); ; tok=GetNextToken()) {
        emb= node.GetContent().size();
        if (tok != T_EOF &&
            tok != K_ENDOFTAG &&
            tok != K_ANNOTATION) {
            hasContents= true;
        }
        switch (tok) {
        case T_EOF:
            return hasContents;
        case K_ENDOFTAG:
            if (eatEOT) {
                eatEOT= false;
                break;
            }
            FixEmbeddedNames(node);
            return hasContents;
        case K_COMPLEXTYPE:
            ParseComplexType(node);
            break;
        case K_SIMPLECONTENT:
            ParseSimpleContent(node);
            break;
        case K_EXTENSION:
            ParseExtension(node);
            break;
        case K_RESTRICTION:
            ParseRestriction(node);
            break;
        case K_ATTRIBUTE:
            ParseAttribute(node);
            break;
        case K_ATTRIBUTEGROUP:
            ParseAttributeGroup(node);
            break;
        case K_ANY:
            node.SetTypeIfUnknown(DTDElement::eSequence);
            {
                string name = CreateTmpEmbeddedName(node.GetName(), emb);
                DTDElement& elem = m_MapElement[name];
                elem.SetName(name);
                elem.SetSourceLine(Lexer().CurrentLine());
                elem.SetEmbedded();
                elem.SetType(DTDElement::eAny);
                elem.SetQualified(node.IsQualified());
                ParseAny(elem);
                AddElementContent(node,name);
            }
            break;
        case K_SEQUENCE:
            emb= node.GetContent().size();
            if (emb != 0 && extended) {
                node.SetTypeIfUnknown(DTDElement::eSequence);
                if (node.GetType() != DTDElement::eSequence) {
                    ParseError("sequence");
                }
                tok = GetRawAttributeSet();
                eatEOT = true;
                break;
            }
            curr_type = node.GetType();
            if (curr_type == DTDElement::eUnknown ||
                curr_type == DTDElement::eUnknownGroup ||
                (m_ResolveTypes && curr_type == DTDElement::eEmpty)) {
                node.SetType(DTDElement::eSequence);
                ParseContainer(node);
                if (node.GetContent().empty()) {
                    node.ResetType(curr_type);
                }
            } else {
                string name = CreateTmpEmbeddedName(node.GetName(), emb);
                DTDElement& elem = m_MapElement[name];
                elem.SetName(name);
                elem.SetSourceLine(Lexer().CurrentLine());
                elem.SetEmbedded();
                elem.SetType(DTDElement::eSequence);
                elem.SetQualified(node.IsQualified());
                ParseContainer(elem);
                AddElementContent(node,name);
            }
            break;
        case K_CHOICE:
            curr_type = node.GetType();
            if (curr_type == DTDElement::eUnknown ||
                curr_type == DTDElement::eUnknownGroup ||
                (m_ResolveTypes && curr_type == DTDElement::eEmpty)) {
                node.SetType(DTDElement::eChoice);
                ParseContainer(node);
                if (node.GetContent().empty()) {
                    node.ResetType(curr_type);
                }
            } else {
                string name = CreateTmpEmbeddedName(node.GetName(), emb);
                DTDElement& elem = m_MapElement[name];
                elem.SetName(name);
                elem.SetSourceLine(Lexer().CurrentLine());
                elem.SetEmbedded();
                elem.SetType(DTDElement::eChoice);
                elem.SetQualified(node.IsQualified());
                ParseContainer(elem);
                AddElementContent(node,name);
            }
            break;
        case K_SET:
            curr_type = node.GetType();
            if (curr_type == DTDElement::eUnknown ||
                curr_type == DTDElement::eUnknownGroup ||
                (m_ResolveTypes && curr_type == DTDElement::eEmpty)) {
                node.SetType(DTDElement::eSet);
                ParseContainer(node);
                if (node.GetContent().empty()) {
                    node.ResetType(curr_type);
                }
            } else {
                string name = CreateTmpEmbeddedName(node.GetName(), emb);
                DTDElement& elem = m_MapElement[name];
                elem.SetName(name);
                elem.SetSourceLine(Lexer().CurrentLine());
                elem.SetEmbedded();
                elem.SetType(DTDElement::eSet);
                elem.SetQualified(node.IsQualified());
                ParseContainer(elem);
                AddElementContent(node,name);
            }
            break;
        case K_ELEMENT:
            {
	            string name = ParseElementContent(&node,emb);
	            AddElementContent(node,name);
            }
            break;
        case K_GROUP:
            {
	            string name = ParseGroup(&node,emb);
	            AddElementContent(node,name);
            }
            break;
        case K_ANNOTATION:
            SetCommentsIfEmpty(&(node.Comments()));
            ParseAnnotation();
            break;
        case K_UNION:
            ParseUnion(node);
            break;
        case K_LIST:
            ParseList(node);
            break;
        default:
            for ( tok = GetNextToken(); tok == K_ATTPAIR || tok == K_XMLNS; tok = GetNextToken())
                ;
            if (tok == K_CLOSING) {
                ParseContent(node);
            }
            break;
        }
    }
    FixEmbeddedNames(node);
    return hasContents;
}
예제 #11
0
ClassAd *ClassAdXMLParser::
ParseClassAd(ClassAd *classad_in)
{
	bool             in_classad;
	ClassAd          *classad = NULL;
	ClassAd          *local_ad = NULL;
	XMLLexer::Token  token;

	classad = NULL;
	in_classad = false;

	while (lexer.PeekToken(&token)) {
		if (!in_classad) {
			lexer.ConsumeToken(NULL);
			if (   token.token_type == XMLLexer::tokenType_Tag 
				&& token.tag_id     == XMLLexer::tagID_ClassAd) {
				
				// We have a ClassAd tag
				if (token.tag_type   == XMLLexer::tagType_Start) {
					in_classad = true;
					if ( classad_in ) {
						classad_in->Clear();
						classad = classad_in;
					} else {
						local_ad = new ClassAd();
						classad = local_ad;
					}
					classad->DisableDirtyTracking();
				} else {
					// We're done, return the ClassAd we got, if any.
                    in_classad = false;
					break;
				}
			}
		} else {
			if (token.token_type == XMLLexer::tokenType_Tag) {
			  if (token.tag_id   == XMLLexer::tagID_Attribute) {
			    if (token.tag_type == XMLLexer::tagType_Invalid) {
				  delete local_ad;
			      return NULL;
			    } else if( token.tag_type == XMLLexer::tagType_Start) {
					string attribute_name;
					ExprTree *tree;
					
					tree = ParseAttribute(attribute_name);
					if (tree != NULL) {
						classad->Insert(attribute_name, tree);
					}
					else {
					  delete local_ad;
					  return NULL;
					}
			    } else {
					lexer.ConsumeToken(NULL);
				}
              } else if (token.tag_id   == XMLLexer::tagID_ClassAd) {
                  lexer.ConsumeToken(NULL);
                  if (token.tag_type == XMLLexer::tagType_End) {
                      in_classad = false;
                      break;
                  } else {
                      // This is invalid, but we'll just ignore it.
                  }
			  } else if (   token.tag_id != XMLLexer::tagID_XML
							  && token.tag_id != XMLLexer::tagID_XMLStylesheet
							  && token.tag_id != XMLLexer::tagID_Doctype
							  && token.tag_id != XMLLexer::tagID_ClassAds) {
					// We got a non-attribute, non-xml thingy within a 
					// ClassAd. That must be an error, but we'll just skip
					// it in the hopes of recovering.
					lexer.ConsumeToken(NULL);
					break;
				}
			} else {
				lexer.ConsumeToken(NULL);
			}
		}
	}
	if (classad != NULL) {
		classad->EnableDirtyTracking();
	}
	return classad;
}
예제 #12
0
	void CImageAttribute::ModifyAttribute(LPCTSTR pStrModify)
	{
		ParseAttribute(pStrModify);
	}
void
nsMathMLmpaddedFrame::ProcessAttributes()
{
  /*
  parse the attributes

  width  = [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | h-unit | namedspace)
  height = [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | v-unit | namedspace)
  depth  = [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | v-unit | namedspace)
  lspace = [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | h-unit | namedspace)
  voffset= [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | v-unit | namedspace)
  */

  nsAutoString value;

  // width
  mWidthSign = NS_MATHML_SIGN_INVALID;
  mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::width, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mWidthSign, mWidth, mWidthPseudoUnit)) {      
      ReportParseError(nsGkAtoms::width->GetUTF16String(), value.get());
    }
  }

  // height
  mHeightSign = NS_MATHML_SIGN_INVALID;
  mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::height, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mHeightSign, mHeight, mHeightPseudoUnit)) {
      ReportParseError(nsGkAtoms::height->GetUTF16String(), value.get());
    }
  }

  // depth
  mDepthSign = NS_MATHML_SIGN_INVALID;
  mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::depth_, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mDepthSign, mDepth, mDepthPseudoUnit)) {
      ReportParseError(nsGkAtoms::depth_->GetUTF16String(), value.get());
    }
  }

  // lspace
  mLeadingSpaceSign = NS_MATHML_SIGN_INVALID;
  mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::lspace_, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mLeadingSpaceSign, mLeadingSpace, 
                        mLeadingSpacePseudoUnit)) {
      ReportParseError(nsGkAtoms::lspace_->GetUTF16String(), value.get());
    }
  }

  // voffset
  mVerticalOffsetSign = NS_MATHML_SIGN_INVALID;
  mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::voffset_, value);
  if (!value.IsEmpty()) {
    if (!ParseAttribute(value, mVerticalOffsetSign, mVerticalOffset,
                        mVerticalOffsetPseudoUnit)) {
      ReportParseError(nsGkAtoms::voffset_->GetUTF16String(), value.get());
    }
  }
  
}
예제 #14
0
status_t
PackageFile::WriteToPath(const char *path, ItemState *state)
{
	if (state == NULL)
		return B_ERROR;

	BPath &destination = state->destination;
	status_t ret = B_OK;
	parser_debug("File: %s WriteToPath() called!\n", fPath.String());

	BFile file;
	if (state->status == B_NO_INIT || destination.InitCheck() != B_OK) {
		ret = InitPath(path, &destination);
		if (ret != B_OK)
			return ret;

		ret = file.SetTo(destination.Path(),
			B_WRITE_ONLY | B_CREATE_FILE | B_FAIL_IF_EXISTS);
		if (ret == B_ENTRY_NOT_FOUND) {
			BPath directory;
			destination.GetParent(&directory);
			if (create_directory(directory.Path(), kDefaultMode) != B_OK)
				return B_ERROR;

			ret = file.SetTo(destination.Path(), B_WRITE_ONLY | B_CREATE_FILE);
		} else if (ret == B_FILE_EXISTS)
			state->status = B_FILE_EXISTS;

		if (ret != B_OK)
			return ret;
	}

	if (state->status == B_FILE_EXISTS) {
		switch (state->policy) {
			case P_EXISTS_OVERWRITE:
				ret = file.SetTo(destination.Path(),
					B_WRITE_ONLY | B_ERASE_FILE);
				break;

			case P_EXISTS_NONE:
			case P_EXISTS_ASK:
				ret = B_FILE_EXISTS;
				break;

			case P_EXISTS_SKIP:
				return B_OK;
		}
	}

	if (ret != B_OK)
		return ret;

	parser_debug(" File created!\n");

	// Set the file permissions, creation and modification times
	ret = file.SetPermissions(static_cast<mode_t>(fMode));
	if (fCreationTime && ret == B_OK)
		ret = file.SetCreationTime(static_cast<time_t>(fCreationTime));
	if (fModificationTime && ret == B_OK)
		ret = file.SetModificationTime(static_cast<time_t>(fModificationTime));

	if (ret != B_OK)
		return ret;

	// Set the mimetype and application signature if present
	BNodeInfo info(&file);
	if (fMimeType.Length() > 0) {
		ret = info.SetType(fMimeType.String());
		if (ret != B_OK)
			return ret;
	}
	if (fSignature.Length() > 0) {
		ret = info.SetPreferredApp(fSignature.String());
		if (ret != B_OK)
			return ret;
	}

	if (fOffset) {
		parser_debug("We have an offset\n");
		if (!fPackage)
			return B_ERROR;

		ret = fPackage->InitCheck();
		if (ret != B_OK)
			return ret;

		// We need to parse the data section now
		fPackage->Seek(fOffset, SEEK_SET);
		uint8 buffer[7];

		char *attrName = 0;
		uint32 nameSize = 0;
		uint8 *attrData = new uint8[P_CHUNK_SIZE];
		uint64 dataSize = P_CHUNK_SIZE;
		uint8 *temp = new uint8[P_CHUNK_SIZE];
		uint64 tempSize = P_CHUNK_SIZE;

		uint64 attrCSize = 0, attrOSize = 0;
		uint32 attrType = 0; // type_code type
		bool attrStarted = false, done = false;

		uint8 section = P_ATTRIBUTE;

		while (fPackage->Read(buffer, 7) == 7) {
			if (!memcmp(buffer, "FBeA", 5)) {
				parser_debug("-> Attribute\n");
				section = P_ATTRIBUTE;
				continue;
			} else if (!memcmp(buffer, "FiDa", 5)) {
				parser_debug("-> File data\n");
				section = P_DATA;
				continue;
			}

			switch (section) {
				case P_ATTRIBUTE:
					ret = ParseAttribute(buffer, &file, &attrName, &nameSize,
						&attrType, &attrData, &dataSize, &temp, &tempSize,
						&attrCSize, &attrOSize, &attrStarted, &done);
					break;

				case P_DATA:
					ret = ParseData(buffer, &file, fOriginalSize, &done);
					break;

				default:
					return B_ERROR;
			}

			if (ret != B_OK || done)
				break;
		}

		delete[] attrData;
		delete[] temp;
	}

	return ret;
}
예제 #15
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Parse tray. */
void ParseTray(const TokenNode *tp)
{
   static const StringMappingType mapping[] = {
      { "bottom",    THIDE_BOTTOM   },
      { "left",      THIDE_LEFT     },
      { "off",       THIDE_OFF      },
      { "right",     THIDE_RIGHT    },
      { "top",       THIDE_TOP      }
   };
   const TokenNode *np;
   const char *attr;
   TrayType *tray;
   TrayAutoHideType autohide;

   Assert(tp);

   tray = CreateTray();

   autohide = ParseAttribute(mapping, ARRAY_LENGTH(mapping), tp,
                             "autohide", THIDE_OFF);
   SetAutoHideTray(tray, autohide);

   attr = FindAttribute(tp->attributes, X_ATTRIBUTE);
   if(attr) {
      SetTrayX(tray, attr);
   }

   attr = FindAttribute(tp->attributes, Y_ATTRIBUTE);
   if(attr) {
      SetTrayY(tray, attr);
   }

   attr = FindAttribute(tp->attributes, WIDTH_ATTRIBUTE);
   if(attr) {
      SetTrayWidth(tray, attr);
   }

   attr = FindAttribute(tp->attributes, HEIGHT_ATTRIBUTE);
   if(attr) {
      SetTrayHeight(tray, attr);
   }

   attr = FindAttribute(tp->attributes, "valign");
   SetTrayVerticalAlignment(tray, attr);

   attr = FindAttribute(tp->attributes, "halign");
   SetTrayHorizontalAlignment(tray, attr);

   attr = FindAttribute(tp->attributes, "layout");
   SetTrayLayout(tray, attr);

   attr = FindAttribute(tp->attributes, "layer");
   if(attr) {
      SetTrayLayer(tray, ParseLayer(tp, attr));
   }

   for(np = tp->subnodeHead; np; np = np->next) {
      switch(np->type) {
      case TOK_PAGER:
         ParsePager(np, tray);
         break;
      case TOK_TASKLIST:
         ParseTaskList(np, tray);
         break;
      case TOK_SWALLOW:
         ParseSwallow(np, tray);
         break;
      case TOK_TRAYBUTTON:
         ParseTrayButton(np, tray);
         break;
      case TOK_CLOCK:
         ParseClock(np, tray);
         break;
      case TOK_DOCK:
         ParseDock(np, tray);
         break;
      case TOK_SPACER:
         ParseSpacer(np, tray);
         break;
      default:
         InvalidTag(np, TOK_TRAY);
         break;
      }
   }

}
예제 #16
0
FarXMLNode *FarXMLScanner::ParseChildNode()
{
    SkipWhitespace();

  int tagStartLine = fCurLine;
  int tagStartCol = GetCurColumn();
  if (!NextExpectedChar ('<'))
    return NULL;

  FarString tagName = NextName();
    if (tagName.IsEmpty())
    return NULL;

    FarXMLNode *theNode = new FarXMLNode();
  theNode->SetTag (tagName);
  theNode->SetStartPosition (tagStartLine, tagStartCol);

  while (1)
  {
    SkipWhitespace();
    char c = PeekNextChar();
    if (c == '/')
    {
      NextChar();
      if (!NextExpectedChar ('>'))
      {
        delete theNode;
        return NULL;
      }
      break;
    }
    else if (c == '>')
    {
      NextChar();
      SkipWhitespace();
      while (1)
      {
        if (PeekNextChar() == '<' && PeekNextChar (1) == '/')
          break;
        FarXMLNode *nextChild = ParseChildNode();
        if (!nextChild)
        {
          delete theNode;
          return NULL;
        }
        theNode->AddChild (nextChild);
        SkipWhitespace();
      }
      NextChar(); // <
      NextChar(); // /
      FarString closeTagName = NextName();
      if (closeTagName != tagName)
      {
        ReportError (tagName);
        delete theNode;
        return NULL;
      }
      SkipWhitespace();
      if (!NextExpectedChar ('>'))
      {
        delete theNode;
        return NULL;
      }
      break;
    }
    else
    {
      if (!ParseAttribute (theNode))
      {
        delete theNode;
        return NULL;
      }
    }
  }
  theNode->SetEndPosition (fCurLine, GetCurColumn());
  SkipWhitespace();

  return theNode;
}