Exemplo n.º 1
0
void acl_token_name(const ACL_TOKEN *token, ACL_VSTRING *buf)
{
	int   i, n;
	char *ptr, *pend, ch;
	const ACL_TOKEN *token_iter;

	ACL_VSTRING_RESET(buf);
	token_iter = token;
	while (token_iter && token_iter->parent != NULL) {
		ACL_VSTRING_ADDCH(buf, token_iter->ch);
		token_iter = token_iter->parent;
	}

	ACL_VSTRING_TERMINATE(buf);

	pend = acl_vstring_end(buf) - 1;
	ptr = STR(buf);
	i = 0;
	n = (int) (pend - ptr + 1) / 2;
	while (i < n) {
		ch = *ptr;
		*ptr = *pend;
		*pend = ch;
		i++;
		ptr++;
		pend--;
	}
}
Exemplo n.º 2
0
static const char *xml_parse_meta_text(ACL_XML *xml, const char *data)
{
	int   ch;

	if (LEN(xml->curr_node->text) == 0) {
		SKIP_SPACE(data);
	}

	while ((ch = *data) != 0) {
		if (xml->curr_node->quote) {
			if (ch == xml->curr_node->quote) {
				xml->curr_node->quote = 0;
			}
			ACL_VSTRING_ADDCH(xml->curr_node->text, ch);
		} else if (IS_QUOTE(ch)) {
			if (xml->curr_node->quote == 0) {
				xml->curr_node->quote = ch;
			}
			ACL_VSTRING_ADDCH(xml->curr_node->text, ch);
		} else if (ch == '<') {
			xml->curr_node->nlt++;
			ACL_VSTRING_ADDCH(xml->curr_node->text, ch);
		} else if (ch == '>') {
			if (xml->curr_node->nlt == 0) {
				char *last;
				size_t off;

				data++;
				xml->curr_node->status = ACL_XML_S_MEND;
				if ((xml->curr_node->flag & ACL_XML_F_META_QM) == 0)
					break;

				last = acl_vstring_end(xml->curr_node->text) - 1;
				if (last < STR(xml->curr_node->text) || *last != '?')
					break;
				off = ACL_VSTRING_LEN(xml->curr_node->text) - 1;
				if (off == 0)
					break;
				ACL_VSTRING_AT_OFFSET(xml->curr_node->text, off);
				ACL_VSTRING_TERMINATE(xml->curr_node->text);
				xml_meta_attr(xml->curr_node);
				break;
			}
			xml->curr_node->nlt--;
			ACL_VSTRING_ADDCH(xml->curr_node->text, ch);
		} else {
			ACL_VSTRING_ADDCH(xml->curr_node->text, ch);
		}
		data++;
	}

	ACL_VSTRING_TERMINATE(xml->curr_node->text);
	return (data);
}
Exemplo n.º 3
0
char* string::buf_end()
{
	if (scan_ptr_ == NULL)
		scan_ptr_ = STR(vbf_);
	char *pEnd = acl_vstring_end(vbf_);
	if (scan_ptr_ >= pEnd)
	{
		if (!empty())
			clear();
		return NULL;
	}
	return pEnd;
}
Exemplo n.º 4
0
size_t string::scan_move()
{
	if (scan_ptr_ == NULL)
		return 0;

	char *pEnd = acl_vstring_end(vbf_);
	if (scan_ptr_ >= pEnd)
	{
		clear();
		return 0;
	}

	size_t len = pEnd - scan_ptr_;
	acl_vstring_memmove(vbf_, scan_ptr_, len);
	TERM(vbf_);
	scan_ptr_  = STR(vbf_);

	return len;
}
Exemplo n.º 5
0
static void test_string(ACL_FILE_HANDLE fd, ssize_t max, int debug)
{
	ACL_VSTRING *vp = acl_vstring_mmap_alloc(fd, 1, max);
	const char *s = "hello world!";

	printf("-------------------------------------------------------\r\n");
	incr_string(vp, max - 1, NULL, debug);

	printf("-------------------------------------------------------\r\n");
	incr_string(vp, max - 1 - strlen(s), s, debug);

	printf("-------------------------------------------------------\r\n");
	incr_string(vp, max, NULL, debug);

	printf("-------------------------------------------------------\r\n");
	incr_string(vp, max + 2, NULL, debug);

	printf("-------------------------------------------------------\r\n");
	acl_vstring_strcat(vp, s);
	incr_string(vp, max - strlen(s) - 1, NULL, debug);

	printf("-------------------------------------------------------\r\n");
	acl_vstring_strcat(vp, s);
	incr_string(vp, max, NULL, debug);

	printf("-------------------------------------------------------\r\n");
	acl_vstring_strcat(vp, s);
	incr_string(vp, max + 10, NULL, debug);

	printf(">>>[%s]\r\n", acl_vstring_str(vp));
	printf(">>>len: %ld, %ld, %p, %p\r\n",
		(long) strlen(acl_vstring_str(vp)),
		(long) ACL_VSTRING_LEN(vp),
		acl_vstring_str(vp), acl_vstring_end(vp));
	acl_vstring_free(vp);
}