Exemplo n.º 1
0
// add a byte to the 'lowercase value' of the current field
void CDOMElement::addValueLC(char c, unsigned char lastFlags, unsigned char flags)
{
	if(this->valueLC_length+1 >= this->valueLC_buffer_size)
		this->valueLC = (char *)_REALLOC(this->valueLC, (this->valueLC_buffer_size+=128)) ;

	if(c == '\0')
	{
		// special case : sent by the end of the tag
		if(lastFlags & CFLAG_ENDCHAR && this->valueLC_length > 0)
		{
			// last char was a endchar : delete it
			this->valueLC[this->valueLC_length-1] = '\0';
		}
		else
		{
			// last char was ok (or value is empty) : add nul at end
			this->valueLC[this->valueLC_length++] = '\0';
		}
		return;
	}

	if(flags & CFLAG_ENDCHAR)
	{
		if(lastFlags & CFLAG_ENDCHAR)
		{
			// it's a nth endchar : ignore it
		}
		else
		{
			// it's the first endchar : replace it by space
			if(this->valueLC)
				this->valueLC[this->valueLC_length++] = ' ';
		}
	}
	else
	{
		// normal char
		if(this->valueLC)
			this->valueLC[this->valueLC_length++] = c;
	}
};
Exemplo n.º 2
0
// add a byte to the 'value' of the current field
void CDOMElement::addValueC(char c, unsigned char lastFlags, unsigned char flags)
{
	// increase size anyway
	if(this->value_length+1 >= this->value_buffer_size)
		this->value = (char *)_REALLOC(this->value, (this->value_buffer_size+=128)) ;

	if(c == '\0')
	{
		// special case : sent by the end of the tag
		this->value[this->value_length = this->value_end] = '\0';	// rtrim
		return;
	}

	// left trim
	if(this->value_length == 0 && flags & CFLAG_SPACECHAR)
		return;

	if(this->value)
	{
		this->value[this->value_length++] = c;
		if(!(flags & CFLAG_SPACECHAR))
			this->value_end = this->value_length;
	}
}
Exemplo n.º 3
0
void * DIGCLIENT DIGCliRealloc( void * p, size_t amount )
/*******************************************************/
{
    return( _REALLOC( p, amount ) );
}
Exemplo n.º 4
0
void XMLCALL CDOMDocument::start(void *userData, const char *el, const char **attr)
{
  CDOMDocument *_this = (CDOMDocument *)(userData);

	if(CDOMElement *node = _this->createElement(el))
	{
		if(!_this->documentElement)
		{
			_this->documentElement = node;
		}
		else
		{
			node->parentNode = _this->currentNode;
			if(!_this->currentNode->lastChild)
			{
				_this->currentNode->firstChild = _this->currentNode->lastChild = node;
			}
			else
			{
				for(CDOMNode *n=_this->currentNode->lastChild; n; n=n->previousSibling)
				{
					if(n->nodeType==CDOMNode::XML_ELEMENT_NODE && strcmp(((CDOMElement*)n)->tagName, el)==0)
					{
						node->index = ((CDOMElement*)n)->index+1;
						break;
					}
				}
				_this->currentNode->lastChild->nextSibling = node;
				node->previousSibling = _this->currentNode->lastChild;
				_this->currentNode->lastChild = node;
			}
		}
		_this->currentNode = node;

		int len_el = strlen(el)+1;
		int m;

		node->pathoffset = _this->freepathoffset;
		m = _this->path_msize;
		if(_this->freepathoffset + 1 + len_el > m)
		{
			m = _this->freepathoffset + 1 + len_el;
			_this->path = (char *)_REALLOC(_this->path, m);
		}
		if(_this->path)
		{
			_this->path_msize = m;

			_this->path[_this->freepathoffset] = '/';
			memcpy(_this->path+_this->freepathoffset+1, el, len_el);
			_this->freepathoffset += len_el;
		}

		node->upathoffset = _this->freeupathoffset;
		m = _this->upath_msize;
		if(_this->freeupathoffset + 1 + len_el + 1+33+1 > m)
		{
			m = _this->freeupathoffset + 1 + len_el + 1+33+1;
			_this->upath = (char *)_REALLOC(_this->upath, m);
		}
		if(_this->upath)
		{
			_this->upath_msize = m;

			_this->upath[_this->freeupathoffset] = '/';
			memcpy(_this->upath+_this->freeupathoffset+1, el, len_el);
			_strupr((char *)(_this->upath) + _this->freeupathoffset+1);
			_this->freeupathoffset += len_el;
			_this->freeupathoffset += sprintf((char *)(_this->upath) + _this->freeupathoffset, "[%i]", node->index);
		}

		if(_this->onStart)
			(_this->onStart)(_this, (const char *)el, _this->path, _this->upath);
	}
	_this->depth++;
}
Exemplo n.º 5
0
void * DIGCLIENT DIGCliRealloc( void * p, unsigned amount )
/*********************************************************/
{
    return( _REALLOC( p, amount ) );
}