axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mili...@apache.org
Subject svn commit: r547645 [2/3] - in /webservices/axis2/scratch/c/guththila_ng: ./ guththila/include/ guththila/src/
Date Fri, 15 Jun 2007 12:13:26 GMT
Modified: webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_stack.c
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_stack.c?view=diff&rev=547645&r1=547644&r2=547645
==============================================================================
--- webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_stack.c (original)
+++ webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_stack.c Fri Jun 15 05:13:24 2007
@@ -1,93 +1,94 @@
-#include <guththila_stack.h>
-
-guththila_stack_t* GUTHTHILA_CALL guththila_stack_create()
-{
-	guththila_stack_t *stack = NULL;
-	stack = (guththila_stack_t *)malloc(sizeof(guththila_stack_t));	
-
-	if (!stack) return NULL;
-
-	stack->data = NULL;
-	stack->data = (void **)malloc(sizeof(void **) * GUTHTHILA_STACK_DEFAULT);
-
-	if (!stack->data){
-		free(stack);
-		return NULL;
-	} else {		
-		stack->max = GUTHTHILA_STACK_DEFAULT;
-		stack->top = 0;
-		return stack; 
-	}	
-}
-
-int GUTHTHILA_CALL guththila_stack_init(guththila_stack_t *stack)
-{
-	stack->top = 0;
-	stack->data = (void **)malloc(sizeof(void **) * GUTHTHILA_STACK_DEFAULT);
-
-	if (!stack->data){		
-		return GUTHTHILA_FAILURE;
-	} else {		
-		stack->max = GUTHTHILA_STACK_DEFAULT;		
-		return GUTHTHILA_SUCCESS; 
-	}	
-}
-
-void GUTHTHILA_CALL guththila_stack_free(guththila_stack_t *stack)
-{	
-	if (stack->data) free (stack->data);
-	free(stack);
-}
-
-void GUTHTHILA_CALL guththila_stack_free_data(guththila_stack_t *stack)
-{
-	if (stack->data) free (stack->data);
-}
-
-void * GUTHTHILA_CALL guththila_stack_pop(guththila_stack_t *stack)
-{
-	if (stack->top > 0){		 
-		return stack->data[stack->top-- - 1];;
-	} 
-	return NULL;
-}
-
-int GUTHTHILA_CALL guththila_stack_push(guththila_stack_t *stack, void *data)
-{
-	if (stack->top >= stack->max) {
-		stack->data = (void **) realloc(stack->data, sizeof(void **) * (stack->max += GUTHTHILA_STACK_DEFAULT));
-		
-		if (!stack->data) return GUTHTHILA_FAILURE;			
-	}
-	stack->data[stack->top] = data;
-	return stack->top++;
-}
-
-void * GUTHTHILA_CALL guththila_stack_peek(guththila_stack_t *stack)
-{
-	if (stack->top > 0){		 
-		return stack->data[stack->top - 1];
-	} else {
-		return NULL;
-	}
-}
-
-int GUTHTHILA_CALL guththila_stack_del_top(guththila_stack_t *stack)
-{
-	if (stack->top > 0){
-		free(stack->data[stack->top]);
-		return GUTHTHILA_SUCCESS;
-	} 
-	return GUTHTHILA_FAILURE;
-}
-
-int GUTHTHILA_CALL guththila_stack_is_empty(guththila_stack_t *stack)
-{
-	return stack->top == 0 ? 1 : 0;
-}
-
-void * GUTHTHILA_CALL guththila_stack_get_by_index(guththila_stack_t *stack, int index)
-{	
-	return index < stack->top ? stack->data[index] : NULL;
-}
-
+#include <guththila_stack.h>
+
+guththila_stack_t* GUTHTHILA_CALL guththila_stack_create()
+{
+	guththila_stack_t *stack = NULL;
+	stack = (guththila_stack_t *)malloc(sizeof(guththila_stack_t));	
+
+	if (!stack) return NULL;
+
+	stack->data = NULL;
+	stack->data = (void **)malloc(sizeof(void **) * GUTHTHILA_STACK_DEFAULT);
+
+	if (!stack->data){
+		free(stack);
+		return NULL;
+	} else {		
+		stack->max = GUTHTHILA_STACK_DEFAULT;
+		stack->top = 0;
+		return stack; 
+	}	
+}
+
+int GUTHTHILA_CALL guththila_stack_init(guththila_stack_t *stack)
+{
+	stack->top = 0;
+	stack->data = (void **)malloc(sizeof(void **) * GUTHTHILA_STACK_DEFAULT);
+
+	if (!stack->data){		
+		return GUTHTHILA_FAILURE;
+	} else {		
+		stack->max = GUTHTHILA_STACK_DEFAULT;		
+		return GUTHTHILA_SUCCESS; 
+	}	
+}
+
+void GUTHTHILA_CALL guththila_stack_free(guththila_stack_t *stack)
+{	
+	if (stack->data) free (stack->data);
+	free(stack);
+}
+
+void GUTHTHILA_CALL guththila_stack_free_data(guththila_stack_t *stack)
+{
+	if (stack->data) free (stack->data);
+}
+
+void * GUTHTHILA_CALL guththila_stack_pop(guththila_stack_t *stack)
+{
+	if (stack->top > 0){		 
+		return stack->data[stack->top-- - 1];;
+	} 
+	return NULL;
+}
+
+int GUTHTHILA_CALL guththila_stack_push(guththila_stack_t *stack, void *data)
+{
+	if (stack->top >= stack->max) {
+		stack->data = (void **) realloc(stack->data, sizeof(void **) * (stack->max += GUTHTHILA_STACK_DEFAULT));
+		
+		if (!stack->data) return GUTHTHILA_FAILURE;			
+	}
+	stack->data[stack->top] = data;
+	return stack->top++;
+}
+
+void * GUTHTHILA_CALL guththila_stack_peek(guththila_stack_t *stack)
+{
+	if (stack->top > 0){		 
+		return stack->data[stack->top - 1];
+	} else {
+		return NULL;
+	}
+}
+
+int GUTHTHILA_CALL guththila_stack_del_top(guththila_stack_t *stack)
+{
+	if (stack->top > 0){
+		free(stack->data[stack->top]);
+		return GUTHTHILA_SUCCESS;
+	} 
+	return GUTHTHILA_FAILURE;
+}
+
+int GUTHTHILA_CALL guththila_stack_is_empty(guththila_stack_t *stack)
+{
+	return stack->top == 0 ? 1 : 0;
+}
+
+void * GUTHTHILA_CALL guththila_stack_get_by_index(guththila_stack_t *stack, int index)
+{	
+	return index < stack->top ? stack->data[index] : NULL;
+}
+
+

Modified: webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_token.c
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_token.c?view=diff&rev=547645&r1=547644&r2=547645
==============================================================================
--- webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_token.c (original)
+++ webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_token.c Fri Jun 15 05:13:24 2007
@@ -1,146 +1,147 @@
-#include <guththila_token.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#define TOK_LIST_FREE(tok_list) \
-	(if (tok_list) {free(tok_list)})
-
-#define TOK_LIST_SIZE(tok_list) (tok_list->size)
-
-guththila_tok_list_t * GUTHTHILA_CALL guththila_tok_list_create()
-{
-	int i = 0;
-	guththila_tok_list_t *tok_list = (guththila_tok_list_t *)malloc(sizeof(guththila_tok_list_t));
-	if (!tok_list) return NULL;
-	
-	tok_list->list = (guththila_token_t **)malloc(sizeof(guththila_token_t *) * GUTHTHILA_TOK_DEF_LIST_SIZE);
-	
-	if (tok_list->list && guththila_stack_init(&tok_list->fr_stack)){
-		tok_list->capacity = (int *)malloc(sizeof(int) * GUTHTHILA_TOK_DEF_LIST_SIZE);
-		if (tok_list->capacity) {
-			tok_list->no_list = GUTHTHILA_TOK_DEF_LIST_SIZE;			
-			tok_list->list[0] = (guththila_token_t *)malloc(sizeof(guththila_token_t ) * GUTHTHILA_TOK_DEF_SIZE);
-			for (i = 0;i < GUTHTHILA_TOK_DEF_SIZE; i++){
-				guththila_stack_push(&tok_list->fr_stack, &tok_list->list[0][i]);
-			}
-			tok_list->capacity[0] = GUTHTHILA_TOK_DEF_SIZE;
-			tok_list->cur_list = 0;
-			tok_list->no_list = GUTHTHILA_TOK_DEF_LIST_SIZE;
-			return tok_list;	
-		}
-	}		
-	free(tok_list);
-	return NULL;	
-}
-
-int GUTHTHILA_CALL guththila_tok_list_grow(guththila_tok_list_t *tok_list)
-{	
-	int i = 0;
-	int cur = 0;
-	int cur_cap = 0;
-	guththila_token_t **list = NULL;
-	if (tok_list->cur_list < tok_list->no_list -1) {
-		cur = ++tok_list->cur_list;
-		cur_cap = tok_list->capacity[cur -1] * 2;
-		tok_list->list[cur] = (guththila_token_t *)malloc(sizeof(guththila_token_t ) * cur_cap);
-		for (i = 0;i < cur_cap; i++){
-			guththila_stack_push(&tok_list->fr_stack, &tok_list->list[cur][i]);
-		}
-		tok_list->capacity[cur] = cur_cap;		
-		return GUTHTHILA_SUCCESS;
-	} else {
-		list = (guththila_token_t **)malloc(sizeof(guththila_token_t *) * tok_list->no_list * 2);															
-		if (list) {
-			for (i = 0; i <= tok_list->cur_list; i++) {
-				list[i] = tok_list->list[i];
-			}
-			tok_list->no_list = tok_list->no_list * 2;
-			free(tok_list->list);
-			tok_list->list = list;
-			guththila_tok_list_grow(tok_list);
-		}
-	}
-	return GUTHTHILA_FAILURE;
-}
-
-int GUTHTHILA_CALL guththila_tok_list_init(guththila_tok_list_t *tok_list)
-{		
-	int i = 0;
-	tok_list->list = (guththila_token_t **)malloc(sizeof(guththila_token_t *) * GUTHTHILA_TOK_DEF_LIST_SIZE);
-	
-	if (tok_list->list && guththila_stack_init(&tok_list->fr_stack)){
-		tok_list->capacity = (int *)malloc(sizeof(int) * GUTHTHILA_TOK_DEF_LIST_SIZE);
-		if (tok_list->capacity) {
-			tok_list->no_list = GUTHTHILA_TOK_DEF_LIST_SIZE;			
-			tok_list->list[0] = (guththila_token_t *)malloc(sizeof(guththila_token_t ) * GUTHTHILA_TOK_DEF_SIZE);
-			for (i = 0;i < GUTHTHILA_TOK_DEF_SIZE; i++){
-				guththila_stack_push(&tok_list->fr_stack, &tok_list->list[0][i]);
-			}
-			tok_list->capacity[0] = GUTHTHILA_TOK_DEF_SIZE;
-			tok_list->cur_list = 0;
-			tok_list->no_list = GUTHTHILA_TOK_DEF_LIST_SIZE;
-			return GUTHTHILA_SUCCESS;	
-		}
-	}		
-	return GUTHTHILA_FAILURE;	
-}
-
-void GUTHTHILA_CALL guththila_tok_list_free(guththila_tok_list_t *tok_list)
-{	
-	int i = 0;
-	guththila_stack_free_data(&tok_list->fr_stack);
-	for (; i <= tok_list->cur_list; i++) {
-		free(tok_list->list[i]);
-	}
-	free(tok_list->list);	
-	free(tok_list);
-}
-
-void GUTHTHILA_CALL guththila_tok_list_free_data(guththila_tok_list_t *tok_list)
-{
-	int i = 0;
-	guththila_stack_free_data(&tok_list->fr_stack);
-	
-	for (; i <= tok_list->cur_list; i++) {
-		free(tok_list->list[i]);
-	}
-	free(tok_list->list);	
-}
-
-guththila_token_t * GUTHTHILA_CALL guththila_tok_list_get_token(guththila_tok_list_t *tok_list)
-{
-	if (tok_list->fr_stack.top > 0 || guththila_tok_list_grow(tok_list)){
-		return guththila_stack_pop(&tok_list->fr_stack);			
-	} 	
-	return NULL;
-}
-
-int GUTHTHILA_CALL guththila_tok_list_release_token(guththila_tok_list_t *tok_list, guththila_token_t *token)
-{
-	return guththila_stack_push(&tok_list->fr_stack, token); 										
-}
-
-int GUTHTHILA_CALL guththila_tok_str_cmp(guththila_token_t *tok, char *str, size_t str_len)
-{
-	unsigned int i = 0;
-	if (tok->size != str_len) return -1;
-	for (; i < tok->size; i++) {
-		if (tok->start[i] != str[i]) {
-			return -1;
-		}
-	}
-	return 0;
-}
-
-int GUTHTHILA_CALL guththila_tok_tok_cmp(guththila_token_t *tok1, guththila_token_t *tok2)
-{
-	unsigned int i = 0;
-	if (tok1->size != tok2->size) return -1;
-	for (; i < tok1->size; i++) {
-		if (tok1->start[i] != tok2->start[i]) {
-			return -1;
-		}
-	}
-	return 0;
-}
\ No newline at end of file
+#include <guththila_token.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define TOK_LIST_FREE(tok_list) \
+	(if (tok_list) {free(tok_list)})
+
+#define TOK_LIST_SIZE(tok_list) (tok_list->size)
+
+guththila_tok_list_t * GUTHTHILA_CALL guththila_tok_list_create()
+{
+	int i = 0;
+	guththila_tok_list_t *tok_list = (guththila_tok_list_t *)malloc(sizeof(guththila_tok_list_t));
+	if (!tok_list) return NULL;
+	
+	tok_list->list = (guththila_token_t **)malloc(sizeof(guththila_token_t *) * GUTHTHILA_TOK_DEF_LIST_SIZE);
+	
+	if (tok_list->list && guththila_stack_init(&tok_list->fr_stack)){
+		tok_list->capacity = (int *)malloc(sizeof(int) * GUTHTHILA_TOK_DEF_LIST_SIZE);
+		if (tok_list->capacity) {
+			tok_list->no_list = GUTHTHILA_TOK_DEF_LIST_SIZE;			
+			tok_list->list[0] = (guththila_token_t *)malloc(sizeof(guththila_token_t ) * GUTHTHILA_TOK_DEF_SIZE);
+			for (i = 0;i < GUTHTHILA_TOK_DEF_SIZE; i++){
+				guththila_stack_push(&tok_list->fr_stack, &tok_list->list[0][i]);
+			}
+			tok_list->capacity[0] = GUTHTHILA_TOK_DEF_SIZE;
+			tok_list->cur_list = 0;
+			tok_list->no_list = GUTHTHILA_TOK_DEF_LIST_SIZE;
+			return tok_list;	
+		}
+	}		
+	free(tok_list);
+	return NULL;	
+}
+
+int GUTHTHILA_CALL guththila_tok_list_grow(guththila_tok_list_t *tok_list)
+{	
+	int i = 0;
+	int cur = 0;
+	int cur_cap = 0;
+	guththila_token_t **list = NULL;
+	if (tok_list->cur_list < tok_list->no_list -1) {
+		cur = ++tok_list->cur_list;
+		cur_cap = tok_list->capacity[cur -1] * 2;
+		tok_list->list[cur] = (guththila_token_t *)malloc(sizeof(guththila_token_t ) * cur_cap);
+		for (i = 0;i < cur_cap; i++){
+			guththila_stack_push(&tok_list->fr_stack, &tok_list->list[cur][i]);
+		}
+		tok_list->capacity[cur] = cur_cap;		
+		return GUTHTHILA_SUCCESS;
+	} else {
+		list = (guththila_token_t **)malloc(sizeof(guththila_token_t *) * tok_list->no_list * 2);															
+		if (list) {
+			for (i = 0; i <= tok_list->cur_list; i++) {
+				list[i] = tok_list->list[i];
+			}
+			tok_list->no_list = tok_list->no_list * 2;
+			free(tok_list->list);
+			tok_list->list = list;
+			guththila_tok_list_grow(tok_list);
+		}
+	}
+	return GUTHTHILA_FAILURE;
+}
+
+int GUTHTHILA_CALL guththila_tok_list_init(guththila_tok_list_t *tok_list)
+{		
+	int i = 0;
+	tok_list->list = (guththila_token_t **)malloc(sizeof(guththila_token_t *) * GUTHTHILA_TOK_DEF_LIST_SIZE);
+	
+	if (tok_list->list && guththila_stack_init(&tok_list->fr_stack)){
+		tok_list->capacity = (int *)malloc(sizeof(int) * GUTHTHILA_TOK_DEF_LIST_SIZE);
+		if (tok_list->capacity) {
+			tok_list->no_list = GUTHTHILA_TOK_DEF_LIST_SIZE;			
+			tok_list->list[0] = (guththila_token_t *)malloc(sizeof(guththila_token_t ) * GUTHTHILA_TOK_DEF_SIZE);
+			for (i = 0;i < GUTHTHILA_TOK_DEF_SIZE; i++){
+				guththila_stack_push(&tok_list->fr_stack, &tok_list->list[0][i]);
+			}
+			tok_list->capacity[0] = GUTHTHILA_TOK_DEF_SIZE;
+			tok_list->cur_list = 0;
+			tok_list->no_list = GUTHTHILA_TOK_DEF_LIST_SIZE;
+			return GUTHTHILA_SUCCESS;	
+		}
+	}		
+	return GUTHTHILA_FAILURE;	
+}
+
+void GUTHTHILA_CALL guththila_tok_list_free(guththila_tok_list_t *tok_list)
+{	
+	int i = 0;
+	guththila_stack_free_data(&tok_list->fr_stack);
+	for (; i <= tok_list->cur_list; i++) {
+		free(tok_list->list[i]);
+	}
+	free(tok_list->list);	
+	free(tok_list);
+}
+
+void GUTHTHILA_CALL guththila_tok_list_free_data(guththila_tok_list_t *tok_list)
+{
+	int i = 0;
+	guththila_stack_free_data(&tok_list->fr_stack);
+	
+	for (; i <= tok_list->cur_list; i++) {
+		free(tok_list->list[i]);
+	}
+	free(tok_list->list);	
+}
+
+guththila_token_t * GUTHTHILA_CALL guththila_tok_list_get_token(guththila_tok_list_t *tok_list)
+{
+	if (tok_list->fr_stack.top > 0 || guththila_tok_list_grow(tok_list)){
+		return guththila_stack_pop(&tok_list->fr_stack);			
+	} 	
+	return NULL;
+}
+
+int GUTHTHILA_CALL guththila_tok_list_release_token(guththila_tok_list_t *tok_list, guththila_token_t *token)
+{
+	return guththila_stack_push(&tok_list->fr_stack, token); 										
+}
+
+int GUTHTHILA_CALL guththila_tok_str_cmp(guththila_token_t *tok, char *str, size_t str_len)
+{
+	unsigned int i = 0;
+	if (tok->size != str_len) return -1;
+	for (; i < tok->size; i++) {
+		if (tok->start[i] != str[i]) {
+			return -1;
+		}
+	}
+	return 0;
+}
+
+int GUTHTHILA_CALL guththila_tok_tok_cmp(guththila_token_t *tok1, guththila_token_t *tok2)
+{
+	unsigned int i = 0;
+	if (tok1->size != tok2->size) return -1;
+	for (; i < tok1->size; i++) {
+		if (tok1->start[i] != tok2->start[i]) {
+			return -1;
+		}
+	}
+	return 0;
+}
+

Modified: webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_xml_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_xml_parser.c?view=diff&rev=547645&r1=547644&r2=547645
==============================================================================
--- webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_xml_parser.c (original)
+++ webservices/axis2/scratch/c/guththila_ng/guththila/src/guththila_xml_parser.c Fri Jun 15 05:13:24 2007
@@ -1,922 +1,917 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <guththila.h>
-#include <guththila_reader.h>
-
-#define GUTHTHILA_VALIDATION_PARSER
-
-int is_inited = 0;
-static void GUTHTHILA_CALL guththila_token_close(guththila_t *m, guththila_token_t *tok, int tok_type, int referer);
-static int GUTHTHILA_CALL guththila_process_xml_dec(guththila_t *m);
-
-#ifndef GUTHTHILA_SKIP_SPACES
-#define GUTHTHILA_SKIP_SPACES(m, c) while (0x20 == c || 0x9 == c || 0xD == c || 0xA == c){c = guththila_reader_next_char(m->reader, 0);}
-#endif
-
-#ifndef GUTHTHILA_SKIP_SPACES_WITH_NEW_LINE
-#define GUTHTHILA_SKIP_SPACES_WITH_NEW_LINE(m, c) while (0x20 == c || 0x9 == c || 0xD == c || 0xA == c || '\n' == c){c = guththila_reader_next_char(m->reader, 0);}
-#endif
-
-#ifndef GUTHTHILA_LAST_CHAR
-#define GUTHTHILA_LAST_CHAR(m) (m->buffer.buff + m->buffer.next - 1)
-#endif
-
-#ifndef GUTHTHILA_TOKEN_OPEN
-#define GUTHTHILA_TOKEN_OPEN(m, tok)					\
-	m->temp_tok = guththila_tok_list_get_token(&m->tokens);	\
-	m->temp_tok->type = _Unknown;							\
-	m->temp_tok->_start = m->reader->next;		\
-	m->reader->last_start = m->reader->next;	
-#endif
-
-#ifndef GUTHTHILA_PROCESS_EQU
-#define GUTHTHILA_PROCESS_EQU(m, c, ic)							\
-	GUTHTHILA_SKIP_SPACES(m, c);									\
-    if (0x3D == c){												\
-        ic = guththila_reader_next_char(m->reader, 0);		\
-		GUTHTHILA_SKIP_SPACES(m, ic);	\
-	}															
-#endif    
-
-#ifndef GUTHTHILA_ATTRIBUTE_INITIALIZE
-#define GUTHTHILA_ATTRIBUTE_INITIALIZE(_attr, _pref, _name, _val)	\
-	(_attr->pref = (_pref));							\
-	(_attr->name = (_name));							\
-	(_attr->val  = (_val));							
-#endif
-
-#ifndef GUTHTHILA_NAMESPACE_INITIALIZE
-#define GUTHTHILA_NAMESPACE_INITIALIZE(_namesp, _name, _uri)	\
-	(_namesp->name = _name);								\
-	(_namesp->uri = _uri);
-#endif
-
-static void GUTHTHILA_CALL guththila_token_close(guththila_t *m, guththila_token_t *tok, int tok_type, int referer)
-{
-	guththila_attr_t *attr = NULL;
-	guththila_namespace_t *namesp = NULL;
-	guththila_element_t *elem = NULL;
-	guththila_elem_namesp_t *e_namesp = NULL;
-	int counter = 0, nmsp_no = 0, i = 0;
-	m->temp_tok->type = tok_type;									
-	m->temp_tok->size = m->reader->next - m->temp_tok->_start;							
-	m->temp_tok->start = GUTHTHILA_BUF_POS(m->reader->buffer, m->reader->next - 1) - m->temp_tok->size;
-	m->temp_tok->ref = referer;	
-	m->reader->last_start = -1;
-	switch(tok_type){										
-	case _attribute_name:									
-		m->temp_name = m->temp_tok;							
-		m->temp_tok = NULL;
-		break;												
-	case _char_data:										
-		m->value = m->temp_tok;	
-		m->temp_tok = NULL;
-		break;												
-	case _attribute_value:	
-		if (m->temp_prefix && GUTHTHILA_TOKEN_LEN(m->temp_prefix) == 5 && (m->temp_prefix->start)[0] == 'x' && 
-						(m->temp_prefix->start)[1] == 'm' && (m->temp_prefix->start)[2] == 'l' &&
-						(m->temp_prefix->start)[3] == 'n' && (m->temp_prefix->start)[4] == 's' ){
-#ifndef GUTHTHILA_VALIDATION_PARSER
-			namesp = (guththila_namespace_t *) malloc(sizeof(guththila_namespace_t));
-			GUTHTHILA_NAMESPACE_INITIALIZE(namesp, m->temp_name, m->temp_tok); 
-			guththila_stack_push(&m->namesp, namesp);
-#else
-			elem = (guththila_element_t *)guththila_stack_peek(&m->elem);
-			if (elem && !elem->is_namesp) {
-				e_namesp = (guththila_elem_namesp_t *)malloc(sizeof(guththila_elem_namesp_t));
-				if (e_namesp) {
-					e_namesp->namesp = (guththila_namespace_t *)malloc(sizeof(guththila_namespace_t) * GUTHTHILA_NAMESPACE_DEF_SIZE);
-					if (e_namesp->namesp) {
-						e_namesp->no = 1;
-						e_namesp->size = GUTHTHILA_NAMESPACE_DEF_SIZE;
-						e_namesp->namesp[0].name = m->temp_name;
-						e_namesp->namesp[0].uri = m->temp_tok;
-						guththila_stack_push(&m->namesp, e_namesp);
-						elem->is_namesp = 1;
-					}
-				}
-			} else {
-				e_namesp = (guththila_elem_namesp_t *)guththila_stack_peek(&m->namesp);
-				if (e_namesp->no < e_namesp->size) {					
-					e_namesp->namesp[e_namesp->no].name = m->temp_name;
-					e_namesp->namesp[e_namesp->no].uri = m->temp_tok;
-					e_namesp->no++;
-				} else {
-					e_namesp->namesp = (guththila_namespace_t *)realloc(e_namesp->namesp , sizeof(guththila_namespace_t) * e_namesp->size * 2);
-					if (e_namesp->namesp) {						
-						e_namesp->size *= 2;
-						e_namesp->namesp[e_namesp->no].name = m->temp_name;
-						e_namesp->namesp[e_namesp->no].uri = m->temp_tok;						
-						e_namesp->no++;
-					}
-				}
-			}
-#endif
-		} else {
-			attr = (guththila_attr_t *) malloc(sizeof(guththila_attr_t));			
-#ifdef GUTHTHILA_VALIDATION_PARSER
-			if (m->temp_prefix) {
-				nmsp_no = GUTHTHILA_STACK_SIZE(m->namesp);				
-				for (counter = 0; counter < nmsp_no; counter++) {
-					e_namesp = (guththila_elem_namesp_t *)guththila_stack_get_by_index(&m->namesp, counter);
-					for (i = 0; i < e_namesp->no; i++) {
-						if (!guththila_tok_tok_cmp(e_namesp->namesp[i].name, m->temp_prefix)) {
-							GUTHTHILA_ATTRIBUTE_INITIALIZE(attr, m->temp_prefix, m->temp_name, m->temp_tok);			
-							guththila_stack_push(&m->attrib, attr);
-							counter += nmsp_no;
-							break;
-						}
-					}
-				}
-			} else {
-				GUTHTHILA_ATTRIBUTE_INITIALIZE(attr, m->temp_prefix, m->temp_name, m->temp_tok);			
-				guththila_stack_push(&m->attrib, attr);
-			}
-#else
-			GUTHTHILA_ATTRIBUTE_INITIALIZE(attr, m->temp_prefix, m->temp_name, m->temp_tok);
-			guththila_stack_push(&m->attrib, attr);
-#endif
-		}
-		m->temp_prefix = NULL;
-		m->temp_name = NULL;
-		m->temp_tok = NULL;
-		break;												
-	case _prefix:											
-		m->temp_prefix = m->temp_tok;							
-		m->temp_tok = NULL;
-		break;												
-	default:												
-		m->prefix = m->temp_prefix;										
-		m->name = m->temp_tok;		
-		m->temp_tok = NULL;		
-		break;	
-	}											
-}
-
-#ifndef GUTHTHILA_VARIABLE_INITIALZE
-#define GUTHTHILA_VARIABLE_INITIALZE(m) \
-	m->temp_prefix = NULL;	\
-	m->temp_name = NULL;	\
-	m->temp_tok = NULL;	\
-	if (m->value) guththila_tok_list_release_token(&m->tokens, m->value);	\
-	m->name = NULL; \
-	m->prefix = NULL; \
-	m->value = NULL; \
-	m->is_whitespace = 0; \
-	m->is_char = 0;	
-#endif
-
-
-#ifndef GUTHTHILA_TOKEN_CLOSE
-#define GUTHTHILA_TOKEN_CLOSE(m, tok, tok_type, referer) guththila_token_close(m, tok, tok_type, referer)
-#endif 
-
-GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_init(guththila_t *m, void *reader)
-{
-	if (!reader) return NULL;
-	m->reader = (guththila_reader_t *)reader;
-	if (!guththila_tok_list_init(&m->tokens)){
-		return GUTHTHILA_FAILURE;
-	}
-
-	guththila_stack_init(&m->elem);
-    guththila_stack_init(&m->attrib);
-    guththila_stack_init(&m->namesp);
-
-    m->name = NULL;
-    m->prefix = NULL;
-    m->value = NULL;
-
-    m->status = S_1;
-
-    m->is_whitespace = 0;
-    m->is_char = 0;
-	m->guththila_event = -1;
-	
-	m->temp_name = NULL;
-	m->temp_prefix = NULL;
-	m->temp_tok = NULL;
-    return GUTHTHILA_SUCCESS;
-}
-
-GUTHTHILA_EXPORT guththila_t* GUTHTHILA_CALL guththila_create(void *reader)
-{
-	guththila_t *m = (guththila_t *) malloc(sizeof(guththila_t *));
-	if (!m) return NULL;
-
-	m->reader = (guththila_reader_t *)reader;
-	if (!guththila_tok_list_init(&m->tokens)){
-		free(m);		
-		return NULL;
-	}
-
-	guththila_stack_init(&m->elem);
-    guththila_stack_init(&m->attrib);
-    guththila_stack_init(&m->namesp);
-
-    m->name = NULL;
-    m->prefix = NULL;
-    m->value = NULL;
-
-    m->status = S_1;
-
-    m->is_whitespace = 0;
-    m->is_char = 0;
-	m->guththila_event = -1;
-	
-	m->temp_name = NULL;
-	m->temp_prefix = NULL;
-	m->temp_tok = NULL;
-	return m;
-}
-
-GUTHTHILA_EXPORT void GUTHTHILA_CALL guththila_free(guththila_t *m)
-{
-	int size = 0, i = 0;
-	guththila_namespace_t *namesp = NULL;
-	guththila_attr_t *attr = NULL;
-	if (m->prefix){
-		guththila_tok_list_release_token(&m->tokens, m->prefix);
-	}
-
-	if (m->name){
-		guththila_tok_list_release_token(&m->tokens, m->name);
-	}
-
-	if (m->value){
-		guththila_tok_list_release_token(&m->tokens, m->value);
-	}	
-
-	if (m->temp_tok){
-		guththila_tok_list_release_token(&m->tokens, m->temp_tok);
-	}
-
-	if (m->temp_name){
-		guththila_tok_list_release_token(&m->tokens, m->temp_name);
-	}
-
-	if (m->temp_prefix){
-		guththila_tok_list_release_token(&m->tokens, m->temp_prefix);
-	}
-
-	size = GUTHTHILA_STACK_SIZE(m->attrib);
-	for ( i = 0; i < size; i++) {
-		attr = (guththila_attr_t *)guththila_stack_pop(&m->attrib);
-		if (attr) {
-			if (attr->name) guththila_tok_list_release_token(&m->tokens, attr->name);
-			if (attr->pref) guththila_tok_list_release_token(&m->tokens, attr->pref);
-			free(attr);
-		}
-	}
-	guththila_stack_free_data(&m->attrib);
-
-	size = GUTHTHILA_STACK_SIZE(m->namesp);
-	for ( i = 0; i < size; i++) {
-		namesp = (guththila_namespace_t *)guththila_stack_pop(&m->namesp);
-		if (namesp) {
-			if (namesp->name) guththila_tok_list_release_token(&m->tokens, namesp->name);
-			if (namesp->uri) guththila_tok_list_release_token(&m->tokens, namesp->uri);
-			free(namesp);
-		}
-	}
-	guththila_stack_free_data(&m->namesp);
-
-	guththila_tok_list_free_data(&m->tokens);
-	free(m);
-	return;
-}
-
-GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_un_init(guththila_t *m)
-{
-	int size = 0, i = 0;
-	guththila_namespace_t *namesp = NULL;
-	guththila_attr_t *attr = NULL;
-	if (m->prefix){
-		guththila_tok_list_release_token(&m->tokens, m->prefix);
-	}
-
-	if (m->name){
-		guththila_tok_list_release_token(&m->tokens, m->name);
-	}
-
-	if (m->value){
-		guththila_tok_list_release_token(&m->tokens, m->value);
-	}	
-
-	if (m->temp_tok){
-		guththila_tok_list_release_token(&m->tokens, m->temp_tok);
-	}
-
-	if (m->temp_name){
-		guththila_tok_list_release_token(&m->tokens, m->temp_name);
-	}
-
-	if (m->temp_prefix){
-		guththila_tok_list_release_token(&m->tokens, m->temp_prefix);
-	}
-
-	size = GUTHTHILA_STACK_SIZE(m->attrib);
-	for ( i = 0; i < size; i++) {
-		attr = (guththila_attr_t *)guththila_stack_pop(&m->attrib);
-		if (attr) {
-			if (attr->name) guththila_tok_list_release_token(&m->tokens, attr->name);
-			if (attr->pref) guththila_tok_list_release_token(&m->tokens, attr->pref);
-			free(attr);
-		}
-	}
-	guththila_stack_free_data(&m->attrib);
-
-	size = GUTHTHILA_STACK_SIZE(m->namesp);
-	for ( i = 0; i < size; i++) {
-		namesp = (guththila_namespace_t *)guththila_stack_pop(&m->namesp);
-		if (namesp) {
-			if (namesp->name) guththila_tok_list_release_token(&m->tokens, namesp->name);
-			if (namesp->uri) guththila_tok_list_release_token(&m->tokens, namesp->uri);
-			free(namesp);
-		}
-	}
-	guththila_stack_free_data(&m->namesp);
-
-	guththila_tok_list_free_data(&m->tokens);
-	return GUTHTHILA_SUCCESS;
-}
-
-
-GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_next(guththila_t *m)
-{
-	guththila_element_t *elem = NULL;
-	guththila_elem_namesp_t *nmsp = NULL;
-	guththila_token_t *tok = NULL;
-	int temp = 0, quote = 0, ref = 0;
-	guththila_char *last_c = NULL;
-	char c_arra[16] = {0};	
-	int c = -1;
-	guththila_attr_t *attr = NULL;
-	int size = 0, i = 0, nmsp_counter;
-
-	size = GUTHTHILA_STACK_SIZE(m->attrib);
-	for ( i = 0; i < size; i++) {
-		attr = (guththila_attr_t *)guththila_stack_pop(&m->attrib);
-		if (attr) {
-			if (attr->name) guththila_tok_list_release_token(&m->tokens, attr->name);
-			if (attr->pref) guththila_tok_list_release_token(&m->tokens, attr->pref);
-			free(attr);
-		}		
-	}
-
-	GUTHTHILA_VARIABLE_INITIALZE(m);
-#ifdef GUTHTHILA_VALIDATION_PARSER
-	if (m->guththila_event == GUTHTHILA_EMPTY_ELEMENT) {
-		elem = (guththila_element_t *)guththila_stack_pop(&m->elem);
-		if (elem->is_namesp) {
-			nmsp = (guththila_elem_namesp_t *)guththila_stack_pop(&m->namesp);
-			for (nmsp_counter = 0; nmsp_counter < nmsp->no; nmsp_counter++) {
-				guththila_tok_list_release_token(&m->tokens, nmsp->namesp[i].name);
-				guththila_tok_list_release_token(&m->tokens, nmsp->namesp[i].uri);
-			}
-			free(nmsp);
-		}
-		if (elem->name) guththila_tok_list_release_token(&m->tokens, elem->name);
-		if (elem->prefix) guththila_tok_list_release_token(&m->tokens, elem->prefix);
-		free(elem);
-	}
-#endif 
-	c = guththila_reader_next_char(m->reader, 0);
-	if (m->status == S_1){
-        while (isspace(c)){
-			c = guththila_reader_next_char(m->reader, 0);
-            if (c == -1)
-                return -1;
-        }
-		if ('<' == c) {
-			m->status = S_2;
-		} else {
-			return -1;
-		}
-	} 
-	if ('<' == c && m->status == S_2) {	
-		c = guththila_reader_next_char(m->reader, 0);
-		if (c != '?' && c != '!' && c != '/'){
-			if (GUTHTHILA_IS_VALID_STARTING_CHAR(c)){
-				GUTHTHILA_TOKEN_OPEN(m, tok);
-				c = guththila_reader_next_char(m->reader, 0);
-				while(!GUTHTHILA_IS_SPACE(c) && c != '>' && c != '/'){
-					if (c != ':'){
-						c = guththila_reader_next_char(m->reader, 0);
-					} else {
-						GUTHTHILA_TOKEN_CLOSE(m, tok, _prefix, 0);							
-						c = guththila_reader_next_char(m->reader, 0);
-						GUTHTHILA_TOKEN_OPEN(m, tok);
-					}
-				}
-				GUTHTHILA_TOKEN_CLOSE(m, tok, _name, 0);
-#ifdef GUTHTHILA_VALIDATION_PARSER		
-				elem = (guththila_element_t *)malloc(sizeof(guththila_element_t));
-				elem->name = m->name;
-				elem->prefix = m->prefix;
-				elem->is_namesp = 0;
-				guththila_stack_push(&m->elem, elem);		
-#endif 
-			}
-			GUTHTHILA_SKIP_SPACES(m, c);
-			for(;;){
-				if (c == '/') {					
-					if ('>' == guththila_reader_next_char(m->reader, 0)){
-						return m->guththila_event = GUTHTHILA_EMPTY_ELEMENT;
-					} else {
-						return -1;
-					}
-				} else if (c == '>') {
-					m->guththila_event = GUTHTHILA_START_ELEMENT;
-					return GUTHTHILA_START_ELEMENT;
-				} else if (c != -1){
-					if (GUTHTHILA_IS_VALID_STARTING_CHAR(c)){
-						GUTHTHILA_TOKEN_OPEN(m, tok);
-						c = guththila_reader_next_char(m->reader, 0);
-						while(!GUTHTHILA_IS_SPACE(c) && c != '='){
-							if (c != ':'){
-								c = guththila_reader_next_char(m->reader, 0);
-							} else if (c == ':'){
-								GUTHTHILA_TOKEN_CLOSE(m, tok, _prefix, 0);							
-								c = guththila_reader_next_char(m->reader, 0);
-								GUTHTHILA_TOKEN_OPEN(m, tok);
-							} 
-						}
-						GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_name, 0);
-					} else {
-						return -1;
-					}
-					GUTHTHILA_PROCESS_EQU(m, c, quote);
-					
-					if ('\'' == quote || '\"' == quote) {
-						c = guththila_reader_next_char(m->reader, 0);
-						GUTHTHILA_TOKEN_OPEN(m, tok);
-						while (c != quote) {
-							c = guththila_reader_next_char(m->reader, 0);							
-						}
-						GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_value, 0);					
-						c = guththila_reader_next_char(m->reader, 0);
-						GUTHTHILA_SKIP_SPACES(m, c);						
-					} else {
-						return -1;
-					}
-				}  else {
-					return -1;
-				}
-			}
-		} else if (c == '/'){
-			m->guththila_event = GUTHTHILA_END_ELEMENT;
-			c = guththila_reader_next_char(m->reader, -1);
-			if (GUTHTHILA_IS_VALID_STARTING_CHAR(c)){
-				GUTHTHILA_TOKEN_OPEN(m, tok);
-				c = guththila_reader_next_char(m->reader, 0);
-				while(!GUTHTHILA_IS_SPACE(c) && c != '>'){
-					if (c != ':'){
-						c = guththila_reader_next_char(m->reader, 0);
-					}else {
-						GUTHTHILA_TOKEN_CLOSE(m, tok, _prefix, 0);							
-						c = guththila_reader_next_char(m->reader, 0);
-						GUTHTHILA_TOKEN_OPEN(m, tok);
-					} 					
-				}
-				GUTHTHILA_TOKEN_CLOSE(m, tok, _name, 0);
-
-#ifdef GUTHTHILA_VALIDATION_PARSER	
-				elem = (guththila_element_t *)guththila_stack_pop(&m->elem);
-				if (!elem || (!elem->prefix && m->prefix) || (elem->prefix && !m->prefix)) return -1;
-				if (guththila_tok_tok_cmp(m->name, elem->name)) {
-					return -1;
-				}
-				if (elem->prefix && m->prefix && guththila_tok_tok_cmp(m->prefix, elem->prefix)) {
-					return -1;
-				}
-				if (elem->is_namesp) {
-					nmsp = (guththila_elem_namesp_t *)guththila_stack_pop(&m->namesp);
-					for (nmsp_counter = 0; nmsp_counter < nmsp->no; nmsp_counter++) {
-						guththila_tok_list_release_token(&m->tokens, nmsp->namesp[i].name);
-						guththila_tok_list_release_token(&m->tokens, nmsp->namesp[i].uri);
-					}
-					free(nmsp);
-				}
-				if (elem->name) guththila_tok_list_release_token(&m->tokens, elem->name);
-				if (elem->prefix) guththila_tok_list_release_token(&m->tokens, elem->prefix);
-				free(elem);
-#endif 
-				GUTHTHILA_SKIP_SPACES(m, c);
-				if (c != '>')
-					return -1;
-				return GUTHTHILA_END_ELEMENT;
-			}
-			return -1;
-		} else if(c == '!') { 
-			if (2 == guththila_reader_next_no_char(m->reader, 0, c_arra, 2) && '-' == c_arra[0] && '-' == c_arra[1]){
-				c = guththila_reader_next_char(m->reader, 0);
-				GUTHTHILA_TOKEN_OPEN(m, tok);
-				while (1) {
-					c = guththila_reader_next_char(m->reader, 0);
-					if ('-' == c) {						
-						c = guththila_reader_next_char(m->reader,	0);
-						if ('-' == c) {
-							if ('>' == guththila_reader_next_char(m->reader, 0)){
-								m->guththila_event = GUTHTHILA_COMMENT;								
-								while (c != '<') {
-									c = guththila_reader_next_char(m->reader, 0);
-									if (c == -1)
-										return -1;
-								}
-								GUTHTHILA_TOKEN_CLOSE(m, tok, _char_data, 0);
-								GUTHTHILA_READER_STEP_BACK(m->reader);
-								return GUTHTHILA_COMMENT;
-							}
-							else {
-								return -1;
-							}
-						}
-					}
-				}
-			} else {
-				c = guththila_reader_next_char(m->reader, 0);
-				while ('<' != c)
-					c = guththila_reader_next_char(m->reader, -1);
-			}
-		} else if (c == '?'){
-			c = guththila_process_xml_dec(m);	
-			if (c != -1)
-				return GUTHTHILA_START_DOCUMENT;
-			else 
-				return -1;
-		} 
-	} else if (c != '<' && m->status == S_2 && c != -1){
-		m->is_whitespace = 0;
-		m->is_char = 0;
-
-		m->guththila_event = GUTHTHILA_CHARACTER;
-		GUTHTHILA_TOKEN_OPEN(m, tok);
-		
-		if (isspace(c)){
-			m->is_whitespace = 1;
-		}
-		do {
-			c = guththila_reader_next_char(m->reader, -1);
-			if (isspace(c)) {
-				if (!m->is_char)
-					m->is_whitespace = 1;
-				else
-					m->is_whitespace = 0;
-			}
-			else if (c == '&')
-				ref = 1;
-			else if (c == -1){			
-				return -1;
-			}
-			else if (c != '<'){
-				m->is_whitespace = 0;
-				m->is_char = 1;
-			}
-		} while (c != '<');
-		GUTHTHILA_TOKEN_CLOSE(m, tok, _char_data, ref);
-		GUTHTHILA_READER_STEP_BACK(m->reader);
-		return GUTHTHILA_CHARACTER;
-	} else {
-        return -1;															
-	}
-	return c;
-}
-
-
-static int GUTHTHILA_CALL guththila_process_xml_dec(guththila_t *m)
-{
-	guththila_token_t *tok = NULL;
-	char c_arra[16] = {0};	
-	int c = -1;
-	int quote = -1;
-	int nc = -1;
-
-	if (3 == guththila_reader_next_no_char(m->reader, GUTHTHILA_EOF, c_arra, 3) && 'x' == c_arra[0] && 'm' == c_arra[1] && 'l' == c_arra[2]) {
-		c = guththila_reader_next_char(m->reader, GUTHTHILA_EOF);
-		GUTHTHILA_SKIP_SPACES(m, c);
-		
-		if (c == 'v') {
-			GUTHTHILA_TOKEN_OPEN(m, tok); 
-			if(6 == guththila_reader_next_no_char(m->reader, 0, c_arra, 6) && 
-					'e' == c_arra[0] && 'r' == c_arra[1] &&
-					's' == c_arra[2] && 'i' == c_arra[3] &&
-					'o' == c_arra[4] && 'n' == c_arra[5]) {	
-			
-				c = guththila_reader_next_char(m->reader, 0);
-				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_name, 0);
-				GUTHTHILA_PROCESS_EQU(m, c, quote);
-
-				nc = guththila_reader_next_char(m->reader, 0);
-
-				GUTHTHILA_TOKEN_OPEN(m, tok);
-				while(nc != quote)
-					nc = guththila_reader_next_char(m->reader, 0);
-
-				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_value, 0);
-
-				c = guththila_reader_next_char(m->reader, 0);
-				GUTHTHILA_SKIP_SPACES(m, c);
-			} else{
-				return -1;
-			}
-		}
-
-		if (c == 'e') {
-			GUTHTHILA_TOKEN_OPEN(m, tok);
-			if(7 == guththila_reader_next_no_char(m->reader, 0, c_arra, 7) &&
-				'n' == c_arra[0] && 'c' == c_arra[1] &&
-				'o' == c_arra[2] && 'd' == c_arra[3] &&		
-				'i' == c_arra[4] && 'n' == c_arra[5] &&		
-				'g' == c_arra[6]) {
-				
-				c = guththila_reader_next_char(m->reader, 0);
-				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_name, 0);
-				GUTHTHILA_PROCESS_EQU(m, c, quote);
-
-				nc = guththila_reader_next_char(m->reader, 0);
-
-				GUTHTHILA_TOKEN_OPEN(m, tok);
-				while(nc != quote)
-					nc = guththila_reader_next_char(m->reader, 0);
-
-				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_value, 0);
-
-				c = guththila_reader_next_char(m->reader, 0);
-				GUTHTHILA_SKIP_SPACES(m, c);				
-			}
-		}
-
-		if (c == 's') {
-			GUTHTHILA_TOKEN_OPEN(m, tok);			
-			if(9 == guththila_reader_next_no_char(m->reader, 0, c_arra, 9) &&
-				't' == c_arra[0] && 'a' == c_arra[1] &&
-				'n' == c_arra[2] && 'd' == c_arra[3] &&		
-				'a' == c_arra[4] && 'l' == c_arra[5] &&		
-				'o' == c_arra[6] && 'n' == c_arra[7] &&
-				'e' == c_arra[8]) {
-
-				c = guththila_reader_next_char(m->reader, 0);
-				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_name, 0);
-				GUTHTHILA_PROCESS_EQU(m, c, quote);
-
-				nc = guththila_reader_next_char(m->reader, 0);
-				GUTHTHILA_TOKEN_OPEN(m, tok);								
-
-				while(nc != quote)
-					nc = guththila_reader_next_char(m->reader, 0);
-
-				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_value, 0);
-
-				c = guththila_reader_next_char(m->reader, 0);
-				GUTHTHILA_SKIP_SPACES(m, c);																				
-			}
-		}
-
-		if (c == '?') {
-			if ('>' == guththila_reader_next_char(m->reader, 0)){
-                m->guththila_event = GUTHTHILA_START_DOCUMENT;
-			} else {
-				return -1;
-			}
-		}
-	}
-	return c;
-}
-
-
-GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_get_attribute_count(guththila_t *m)
-{
-	return GUTHTHILA_STACK_SIZE(m->attrib);
-}
-                                                
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_name(guththila_t * m, guththila_attr_t * att)
-{
-	char *str = NULL;
-	if (att) {
-		GUTHTHILA_TOKEN_TO_STRING(att->name, str);  
-		return str;
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_value (guththila_t *m, guththila_attr_t * att)
-{
-	char *str = NULL;
-	if (att) {
-		GUTHTHILA_TOKEN_TO_STRING(att->val, str);  
-		return str;
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_prefix (guththila_t *m, guththila_attr_t * att)
-{
-	char *str = NULL;
-	if (att) {
-		GUTHTHILA_TOKEN_TO_STRING(att->pref, str);  
-		return str;
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_attr_t * GUTHTHILA_CALL guththila_get_attribute (guththila_t * m)
-{
-	return (guththila_attr_t *)guththila_stack_pop(&m->attrib);
-}
-
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_name_by_number (guththila_t * m, int i)
-{
-	char *str = NULL;
-	guththila_attr_t *attr = (guththila_attr_t *)guththila_stack_get_by_index(&m->attrib, i - 1);
-	if (attr){
-		GUTHTHILA_TOKEN_TO_STRING(attr->name, str);  
-		return str;		
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_value_by_number (guththila_t * m, int i)
-{
-	char *str = NULL;
-	guththila_attr_t *attr = (guththila_attr_t *)guththila_stack_get_by_index(&m->attrib, i - 1);
-	if (attr){
-		GUTHTHILA_TOKEN_TO_STRING(attr->val, str);  
-		return str;		
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_prefix_by_number (guththila_t * m, int i)
-{
-	char *str = NULL;
-	guththila_attr_t *attr = (guththila_attr_t *)guththila_stack_get_by_index(&m->attrib, i - 1);
-	if (attr && attr->pref){
-		GUTHTHILA_TOKEN_TO_STRING(attr->pref, str);  
-		return str;		
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_name (guththila_t * m)
-{
-	char *str = NULL;
-	if (m->name){
-		GUTHTHILA_TOKEN_TO_STRING(m->name, str);  
-		return str;		
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_prefix (guththila_t * m)
-{
-	char *str = NULL;
-	if (m->prefix){
-		GUTHTHILA_TOKEN_TO_STRING(m->prefix, str);  
-		return str;		
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_value (guththila_t * m)
-{
-	char *str = NULL;
-	if (m->value){
-		GUTHTHILA_TOKEN_TO_STRING(m->value, str);  
-		return str;		
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_namespace_t * GUTHTHILA_CALL guththila_get_namespace (guththila_t * m)
-{
-#ifndef GUTHTHILA_VALIDATION_PARSER
-	return (guththila_namespace_t *)guththila_stack_pop(&m->namesp);
-#else
-	return NULL;
-#endif
-}
-
-GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_get_namespace_count (guththila_t *m)
-{
-#ifndef GUTHTHILA_VALIDATION_PARSER
-	return GUTHTHILA_STACK_SIZE(m->namesp);
-#else
-	guththila_elem_namesp_t *nmsp = NULL;
-	if (((guththila_element_t *)guththila_stack_peek(&m->elem))->is_namesp) {
-		nmsp = (guththila_elem_namesp_t *)guththila_stack_peek(&m->namesp);
-		return nmsp->no; 
-	}
-	return 0;
-#endif
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_namespace_uri (guththila_t * m, guththila_namespace_t * ns)
-{
-	char *str = NULL;
-	if (ns->uri){
-		GUTHTHILA_TOKEN_TO_STRING(ns->uri, str);  
-		return str;		
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_namespace_prefix (guththila_t *m, guththila_namespace_t * ns)
-{
-	char *str = NULL;
-	if (ns->name){
-		GUTHTHILA_TOKEN_TO_STRING(ns->name, str);  
-		return str;		
-	}
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_namespace_prefix_by_number (guththila_t * m, int i)
-{
-	guththila_token_t *token = NULL;
-	char *str = NULL;
-	guththila_namespace_t *namesp = NULL;
-#ifndef GUTHTHILA_VALIDATION_PARSER
-	if (GUTHTHILA_STACK_SIZE(m->namesp) >= i){
-		namesp = guththila_stack_get_by_index(&m->namesp, i);
-		if (namesp && namesp->name) {
-			GUTHTHILA_TOKEN_TO_STRING(namesp->name, str);
-			return str;
-		}
-	}
-#else
-	guththila_elem_namesp_t *nmsp = NULL;
-	if (((guththila_element_t *)guththila_stack_peek(&m->elem))->is_namesp) {
-		nmsp = (guththila_elem_namesp_t *)guththila_stack_peek(&m->namesp);
-		if (nmsp && nmsp->no >= i) {
-			GUTHTHILA_TOKEN_TO_STRING(nmsp->namesp[i - 1].name, str);
-			return str;
-		}
-	}
-#endif
-	return NULL;
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_namespace_uri_by_number (guththila_t * m, int i) 
-{
-	guththila_token_t *token = NULL;
-	char *str = NULL;
-	guththila_namespace_t *namesp = NULL;
-	/*TODO check the given index, this can begn from 1, here I assume begin from 0*/
-#ifndef GUTHTHILA_VALIDATION_PARSER
-	if (GUTHTHILA_STACK_SIZE(m->namesp) > i){
-		namesp = guththila_stack_get_by_index(&m->namesp, i);
-		if (namesp && namesp->uri) {
-			GUTHTHILA_TOKEN_TO_STRING(namesp->uri, str);
-			return str;
-		}
-	}
-#else
-	guththila_elem_namesp_t *nmsp = NULL;
-	if (((guththila_element_t *)guththila_stack_peek(&m->elem))->is_namesp) {
-		nmsp = (guththila_elem_namesp_t *)guththila_stack_peek(&m->namesp);
-		if (nmsp && nmsp->no >= i) {
-			GUTHTHILA_TOKEN_TO_STRING(nmsp->namesp[i - 1].uri, str);
-			return str;
-		}
-	}
-#endif
-	return NULL;
-
-}
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_namespace_by_number (guththila_t * m, int i)
-{
-#ifndef GUTHTHILA_VALIDATION_PARSER
-	return NULL;
-#else
-	guththila_attr_t *attr  = NULL;
-	char *str = NULL;
-	int j = 0, k = 0, count = 0;
-	guththila_elem_namesp_t *nmsp = NULL;
-	if ( i <= GUTHTHILA_STACK_SIZE(m->attrib)) {	
-		attr = (guththila_attr_t *)guththila_stack_get_by_index(&m->attrib, i - 1);  
-		if (attr && attr->pref) {
-			count = GUTHTHILA_STACK_SIZE(m->namesp);
-			for ( j = 0; j < count; j++) { 
-				nmsp = (guththila_elem_namesp_t *)guththila_stack_get_by_index(&m->namesp, j);
-				for (k = 0; k < nmsp->no; k++) {
-					if (!guththila_tok_tok_cmp(nmsp->namesp[k].name, attr->pref)) {
-						GUTHTHILA_TOKEN_TO_STRING(nmsp->namesp[k].uri, str);
-						return str;
-					}
-				}
-			}
-		}
-	}
-	return NULL;
-#endif
-}
-
-GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_encoding (guththila_t *m)
-{
-	return "UTF-8";
-}
\ No newline at end of file
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <guththila.h>
+#include <guththila_reader.h>
+
+#define GUTHTHILA_VALIDATION_PARSER
+
+int is_inited = 0;
+static void GUTHTHILA_CALL guththila_token_close(guththila_t *m, guththila_token_t *tok, int tok_type, int referer);
+static int GUTHTHILA_CALL guththila_process_xml_dec(guththila_t *m);
+
+#ifndef GUTHTHILA_SKIP_SPACES
+#define GUTHTHILA_SKIP_SPACES(m, c) while (0x20 == c || 0x9 == c || 0xD == c || 0xA == c){c = guththila_reader_next_char(m->reader, 0);}
+#endif
+
+#ifndef GUTHTHILA_SKIP_SPACES_WITH_NEW_LINE
+#define GUTHTHILA_SKIP_SPACES_WITH_NEW_LINE(m, c) while (0x20 == c || 0x9 == c || 0xD == c || 0xA == c || '\n' == c){c = guththila_reader_next_char(m->reader, 0);}
+#endif
+
+#ifndef GUTHTHILA_LAST_CHAR
+#define GUTHTHILA_LAST_CHAR(m) (m->buffer.buff + m->buffer.next - 1)
+#endif
+
+#ifndef GUTHTHILA_TOKEN_OPEN
+#define GUTHTHILA_TOKEN_OPEN(m, tok)					\
+	m->temp_tok = guththila_tok_list_get_token(&m->tokens);	\
+	m->temp_tok->type = _Unknown;							\
+	m->temp_tok->_start = m->reader->next;		\
+	m->reader->last_start = m->reader->next;	
+#endif
+
+#ifndef GUTHTHILA_PROCESS_EQU
+#define GUTHTHILA_PROCESS_EQU(m, c, ic)							\
+	GUTHTHILA_SKIP_SPACES(m, c);									\
+    if (0x3D == c){												\
+        ic = guththila_reader_next_char(m->reader, 0);		\
+		GUTHTHILA_SKIP_SPACES(m, ic);	\
+	}															
+#endif    
+
+#ifndef GUTHTHILA_ATTRIBUTE_INITIALIZE
+#define GUTHTHILA_ATTRIBUTE_INITIALIZE(_attr, _pref, _name, _val)	\
+	(_attr->pref = (_pref));							\
+	(_attr->name = (_name));							\
+	(_attr->val  = (_val));							
+#endif
+
+#ifndef GUTHTHILA_NAMESPACE_INITIALIZE
+#define GUTHTHILA_NAMESPACE_INITIALIZE(_namesp, _name, _uri)	\
+	(_namesp->name = _name);								\
+	(_namesp->uri = _uri);
+#endif
+
+static void GUTHTHILA_CALL guththila_token_close(guththila_t *m, guththila_token_t *tok, int tok_type, int referer)
+{
+	guththila_attr_t *attr = NULL;
+	guththila_element_t *elem = NULL;
+	guththila_elem_namesp_t *e_namesp = NULL;
+	int counter = 0, nmsp_no = 0, i = 0;
+	m->temp_tok->type = tok_type;									
+	m->temp_tok->size = m->reader->next - m->temp_tok->_start;							
+	m->temp_tok->start = GUTHTHILA_BUF_POS(m->reader->buffer, m->reader->next - 1) - m->temp_tok->size;
+	m->temp_tok->ref = referer;	
+	m->reader->last_start = -1;
+	switch(tok_type){										
+	case _attribute_name:									
+		m->temp_name = m->temp_tok;							
+		m->temp_tok = NULL;
+		break;												
+	case _char_data:										
+		m->value = m->temp_tok;	
+		m->temp_tok = NULL;
+		break;												
+	case _attribute_value:	
+		if (m->temp_prefix && GUTHTHILA_TOKEN_LEN(m->temp_prefix) == 5 && (m->temp_prefix->start)[0] == 'x' && 
+						(m->temp_prefix->start)[1] == 'm' && (m->temp_prefix->start)[2] == 'l' &&
+						(m->temp_prefix->start)[3] == 'n' && (m->temp_prefix->start)[4] == 's' ){
+#ifndef GUTHTHILA_VALIDATION_PARSER
+			namesp = (guththila_namespace_t *) malloc(sizeof(guththila_namespace_t));
+			GUTHTHILA_NAMESPACE_INITIALIZE(namesp, m->temp_name, m->temp_tok); 
+			guththila_stack_push(&m->namesp, namesp);
+#else
+			elem = (guththila_element_t *)guththila_stack_peek(&m->elem);
+			if (elem && !elem->is_namesp) {
+				e_namesp = (guththila_elem_namesp_t *)malloc(sizeof(guththila_elem_namesp_t));
+				if (e_namesp) {
+					e_namesp->namesp = (guththila_namespace_t *)malloc(sizeof(guththila_namespace_t) * GUTHTHILA_NAMESPACE_DEF_SIZE);
+					if (e_namesp->namesp) {
+						e_namesp->no = 1;
+						e_namesp->size = GUTHTHILA_NAMESPACE_DEF_SIZE;
+						e_namesp->namesp[0].name = m->temp_name;
+						e_namesp->namesp[0].uri = m->temp_tok;
+						guththila_stack_push(&m->namesp, e_namesp);
+						elem->is_namesp = 1;
+					}
+				}
+			} else {
+				e_namesp = (guththila_elem_namesp_t *)guththila_stack_peek(&m->namesp);
+				if (e_namesp->no < e_namesp->size) {					
+					e_namesp->namesp[e_namesp->no].name = m->temp_name;
+					e_namesp->namesp[e_namesp->no].uri = m->temp_tok;
+					e_namesp->no++;
+				} else {
+					e_namesp->namesp = (guththila_namespace_t *)realloc(e_namesp->namesp , sizeof(guththila_namespace_t) * e_namesp->size * 2);
+					if (e_namesp->namesp) {						
+						e_namesp->size *= 2;
+						e_namesp->namesp[e_namesp->no].name = m->temp_name;
+						e_namesp->namesp[e_namesp->no].uri = m->temp_tok;						
+						e_namesp->no++;
+					}
+				}
+			}
+#endif
+		} else {
+			attr = (guththila_attr_t *) malloc(sizeof(guththila_attr_t));			
+#ifdef GUTHTHILA_VALIDATION_PARSER
+			if (m->temp_prefix) {
+				nmsp_no = GUTHTHILA_STACK_SIZE(m->namesp);				
+				for (counter = 0; counter < nmsp_no; counter++) {
+					e_namesp = (guththila_elem_namesp_t *)guththila_stack_get_by_index(&m->namesp, counter);
+					for (i = 0; i < e_namesp->no; i++) {
+						if (!guththila_tok_tok_cmp(e_namesp->namesp[i].name, m->temp_prefix)) {
+							GUTHTHILA_ATTRIBUTE_INITIALIZE(attr, m->temp_prefix, m->temp_name, m->temp_tok);			
+							guththila_stack_push(&m->attrib, attr);
+							counter += nmsp_no;
+							break;
+						}
+					}
+				}
+			} else {
+				GUTHTHILA_ATTRIBUTE_INITIALIZE(attr, m->temp_prefix, m->temp_name, m->temp_tok);			
+				guththila_stack_push(&m->attrib, attr);
+			}
+#else
+			GUTHTHILA_ATTRIBUTE_INITIALIZE(attr, m->temp_prefix, m->temp_name, m->temp_tok);
+			guththila_stack_push(&m->attrib, attr);
+#endif
+		}
+		m->temp_prefix = NULL;
+		m->temp_name = NULL;
+		m->temp_tok = NULL;
+		break;												
+	case _prefix:											
+		m->temp_prefix = m->temp_tok;							
+		m->temp_tok = NULL;
+		break;												
+	default:												
+		m->prefix = m->temp_prefix;										
+		m->name = m->temp_tok;		
+		m->temp_tok = NULL;		
+		break;	
+	}											
+}
+
+#ifndef GUTHTHILA_VARIABLE_INITIALZE
+#define GUTHTHILA_VARIABLE_INITIALZE(m) \
+	m->temp_prefix = NULL;	\
+	m->temp_name = NULL;	\
+	m->temp_tok = NULL;	\
+	if (m->value) guththila_tok_list_release_token(&m->tokens, m->value);	\
+	m->name = NULL; \
+	m->prefix = NULL; \
+	m->value = NULL; \
+	m->is_whitespace = 0; \
+	m->is_char = 0;	
+#endif
+
+
+#ifndef GUTHTHILA_TOKEN_CLOSE
+#define GUTHTHILA_TOKEN_CLOSE(m, tok, tok_type, referer) guththila_token_close(m, tok, tok_type, referer)
+#endif 
+
+GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_init(guththila_t *m, void *reader)
+{
+	if (!reader) return GUTHTHILA_FAILURE;
+	m->reader = (guththila_reader_t *)reader;
+	if (!guththila_tok_list_init(&m->tokens)){
+		return GUTHTHILA_FAILURE;
+	}
+
+	guththila_stack_init(&m->elem);
+    guththila_stack_init(&m->attrib);
+    guththila_stack_init(&m->namesp);
+
+    m->name = NULL;
+    m->prefix = NULL;
+    m->value = NULL;
+
+    m->status = S_1;
+
+    m->is_whitespace = 0;
+    m->is_char = 0;
+	m->guththila_event = -1;
+	
+	m->temp_name = NULL;
+	m->temp_prefix = NULL;
+	m->temp_tok = NULL;
+    return GUTHTHILA_SUCCESS;
+}
+
+GUTHTHILA_EXPORT guththila_t* GUTHTHILA_CALL guththila_create(void *reader)
+{
+	guththila_t *m = (guththila_t *) malloc(sizeof(guththila_t *));
+	if (!m) return NULL;
+
+	m->reader = (guththila_reader_t *)reader;
+	if (!guththila_tok_list_init(&m->tokens)){
+		free(m);		
+		return NULL;
+	}
+
+	guththila_stack_init(&m->elem);
+    guththila_stack_init(&m->attrib);
+    guththila_stack_init(&m->namesp);
+
+    m->name = NULL;
+    m->prefix = NULL;
+    m->value = NULL;
+
+    m->status = S_1;
+
+    m->is_whitespace = 0;
+    m->is_char = 0;
+	m->guththila_event = -1;
+	
+	m->temp_name = NULL;
+	m->temp_prefix = NULL;
+	m->temp_tok = NULL;
+	return m;
+}
+
+GUTHTHILA_EXPORT void GUTHTHILA_CALL guththila_free(guththila_t *m)
+{
+	int size = 0, i = 0;
+	guththila_namespace_t *namesp = NULL;
+	guththila_attr_t *attr = NULL;
+	if (m->prefix){
+		guththila_tok_list_release_token(&m->tokens, m->prefix);
+	}
+
+	if (m->name){
+		guththila_tok_list_release_token(&m->tokens, m->name);
+	}
+
+	if (m->value){
+		guththila_tok_list_release_token(&m->tokens, m->value);
+	}	
+
+	if (m->temp_tok){
+		guththila_tok_list_release_token(&m->tokens, m->temp_tok);
+	}
+
+	if (m->temp_name){
+		guththila_tok_list_release_token(&m->tokens, m->temp_name);
+	}
+
+	if (m->temp_prefix){
+		guththila_tok_list_release_token(&m->tokens, m->temp_prefix);
+	}
+
+	size = GUTHTHILA_STACK_SIZE(m->attrib);
+	for ( i = 0; i < size; i++) {
+		attr = (guththila_attr_t *)guththila_stack_pop(&m->attrib);
+		if (attr) {
+			if (attr->name) guththila_tok_list_release_token(&m->tokens, attr->name);
+			if (attr->pref) guththila_tok_list_release_token(&m->tokens, attr->pref);
+			free(attr);
+		}
+	}
+	guththila_stack_free_data(&m->attrib);
+
+	size = GUTHTHILA_STACK_SIZE(m->namesp);
+	for ( i = 0; i < size; i++) {
+		namesp = (guththila_namespace_t *)guththila_stack_pop(&m->namesp);
+		if (namesp) {
+			if (namesp->name) guththila_tok_list_release_token(&m->tokens, namesp->name);
+			if (namesp->uri) guththila_tok_list_release_token(&m->tokens, namesp->uri);
+			free(namesp);
+		}
+	}
+	guththila_stack_free_data(&m->namesp);
+
+	guththila_tok_list_free_data(&m->tokens);
+	free(m);
+	return;
+}
+
+GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_un_init(guththila_t *m)
+{
+	int size = 0, i = 0;
+	guththila_namespace_t *namesp = NULL;
+	guththila_attr_t *attr = NULL;
+	if (m->prefix){
+		guththila_tok_list_release_token(&m->tokens, m->prefix);
+	}
+
+	if (m->name){
+		guththila_tok_list_release_token(&m->tokens, m->name);
+	}
+
+	if (m->value){
+		guththila_tok_list_release_token(&m->tokens, m->value);
+	}	
+
+	if (m->temp_tok){
+		guththila_tok_list_release_token(&m->tokens, m->temp_tok);
+	}
+
+	if (m->temp_name){
+		guththila_tok_list_release_token(&m->tokens, m->temp_name);
+	}
+
+	if (m->temp_prefix){
+		guththila_tok_list_release_token(&m->tokens, m->temp_prefix);
+	}
+
+	size = GUTHTHILA_STACK_SIZE(m->attrib);
+	for ( i = 0; i < size; i++) {
+		attr = (guththila_attr_t *)guththila_stack_pop(&m->attrib);
+		if (attr) {
+			if (attr->name) guththila_tok_list_release_token(&m->tokens, attr->name);
+			if (attr->pref) guththila_tok_list_release_token(&m->tokens, attr->pref);
+			free(attr);
+		}
+	}
+	guththila_stack_free_data(&m->attrib);
+
+	size = GUTHTHILA_STACK_SIZE(m->namesp);
+	for ( i = 0; i < size; i++) {
+		namesp = (guththila_namespace_t *)guththila_stack_pop(&m->namesp);
+		if (namesp) {
+			if (namesp->name) guththila_tok_list_release_token(&m->tokens, namesp->name);
+			if (namesp->uri) guththila_tok_list_release_token(&m->tokens, namesp->uri);
+			free(namesp);
+		}
+	}
+	guththila_stack_free_data(&m->namesp);
+
+	guththila_tok_list_free_data(&m->tokens);
+	return GUTHTHILA_SUCCESS;
+}
+
+
+GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_next(guththila_t *m)
+{
+	guththila_element_t *elem = NULL;
+	guththila_elem_namesp_t *nmsp = NULL;
+	guththila_token_t *tok = NULL;
+	int quote = 0, ref = 0;
+	char c_arra[16] = {0};	
+	int c = -1;
+	guththila_attr_t *attr = NULL;
+	int size = 0, i = 0, nmsp_counter;
+
+	size = GUTHTHILA_STACK_SIZE(m->attrib);
+	for ( i = 0; i < size; i++) {
+		attr = (guththila_attr_t *)guththila_stack_pop(&m->attrib);
+		if (attr) {
+			if (attr->name) guththila_tok_list_release_token(&m->tokens, attr->name);
+			if (attr->pref) guththila_tok_list_release_token(&m->tokens, attr->pref);
+			free(attr);
+		}		
+	}
+
+	GUTHTHILA_VARIABLE_INITIALZE(m);
+#ifdef GUTHTHILA_VALIDATION_PARSER
+	if (m->guththila_event == GUTHTHILA_EMPTY_ELEMENT) {
+		elem = (guththila_element_t *)guththila_stack_pop(&m->elem);
+		if (elem->is_namesp) {
+			nmsp = (guththila_elem_namesp_t *)guththila_stack_pop(&m->namesp);
+			for (nmsp_counter = 0; nmsp_counter < nmsp->no; nmsp_counter++) {
+				guththila_tok_list_release_token(&m->tokens, nmsp->namesp[i].name);
+				guththila_tok_list_release_token(&m->tokens, nmsp->namesp[i].uri);
+			}
+			free(nmsp);
+		}
+		if (elem->name) guththila_tok_list_release_token(&m->tokens, elem->name);
+		if (elem->prefix) guththila_tok_list_release_token(&m->tokens, elem->prefix);
+		free(elem);
+	}
+#endif 
+	c = guththila_reader_next_char(m->reader, 0);
+	if (m->status == S_1){
+        while (isspace(c)){
+			c = guththila_reader_next_char(m->reader, 0);
+            if (c == -1)
+                return -1;
+        }
+		if ('<' == c) {
+			m->status = S_2;
+		} else {
+			return -1;
+		}
+	} 
+	if ('<' == c && m->status == S_2) {	
+		c = guththila_reader_next_char(m->reader, 0);
+		if (c != '?' && c != '!' && c != '/'){
+			if (GUTHTHILA_IS_VALID_STARTING_CHAR(c)){
+				GUTHTHILA_TOKEN_OPEN(m, tok);
+				c = guththila_reader_next_char(m->reader, 0);
+				while(!GUTHTHILA_IS_SPACE(c) && c != '>' && c != '/'){
+					if (c != ':'){
+						c = guththila_reader_next_char(m->reader, 0);
+					} else {
+						GUTHTHILA_TOKEN_CLOSE(m, tok, _prefix, 0);							
+						c = guththila_reader_next_char(m->reader, 0);
+						GUTHTHILA_TOKEN_OPEN(m, tok);
+					}
+				}
+				GUTHTHILA_TOKEN_CLOSE(m, tok, _name, 0);
+#ifdef GUTHTHILA_VALIDATION_PARSER		
+				elem = (guththila_element_t *)malloc(sizeof(guththila_element_t));
+				elem->name = m->name;
+				elem->prefix = m->prefix;
+				elem->is_namesp = 0;
+				guththila_stack_push(&m->elem, elem);		
+#endif 
+			}
+			GUTHTHILA_SKIP_SPACES(m, c);
+			for(;;){
+				if (c == '/') {					
+					if ('>' == guththila_reader_next_char(m->reader, 0)){
+						return m->guththila_event = GUTHTHILA_EMPTY_ELEMENT;
+					} else {
+						return -1;
+					}
+				} else if (c == '>') {
+					m->guththila_event = GUTHTHILA_START_ELEMENT;
+					return GUTHTHILA_START_ELEMENT;
+				} else if (c != -1){
+					if (GUTHTHILA_IS_VALID_STARTING_CHAR(c)){
+						GUTHTHILA_TOKEN_OPEN(m, tok);
+						c = guththila_reader_next_char(m->reader, 0);
+						while(!GUTHTHILA_IS_SPACE(c) && c != '='){
+							if (c != ':'){
+								c = guththila_reader_next_char(m->reader, 0);
+							} else if (c == ':'){
+								GUTHTHILA_TOKEN_CLOSE(m, tok, _prefix, 0);							
+								c = guththila_reader_next_char(m->reader, 0);
+								GUTHTHILA_TOKEN_OPEN(m, tok);
+							} 
+						}
+						GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_name, 0);
+					} else {
+						return -1;
+					}
+					GUTHTHILA_PROCESS_EQU(m, c, quote);
+					
+					if ('\'' == quote || '\"' == quote) {
+						c = guththila_reader_next_char(m->reader, 0);
+						GUTHTHILA_TOKEN_OPEN(m, tok);
+						while (c != quote) {
+							c = guththila_reader_next_char(m->reader, 0);							
+						}
+						GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_value, 0);					
+						c = guththila_reader_next_char(m->reader, 0);
+						GUTHTHILA_SKIP_SPACES(m, c);						
+					} else {
+						return -1;
+					}
+				}  else {
+					return -1;
+				}
+			}
+		} else if (c == '/'){
+			m->guththila_event = GUTHTHILA_END_ELEMENT;
+			c = guththila_reader_next_char(m->reader, -1);
+			if (GUTHTHILA_IS_VALID_STARTING_CHAR(c)){
+				GUTHTHILA_TOKEN_OPEN(m, tok);
+				c = guththila_reader_next_char(m->reader, 0);
+				while(!GUTHTHILA_IS_SPACE(c) && c != '>'){
+					if (c != ':'){
+						c = guththila_reader_next_char(m->reader, 0);
+					}else {
+						GUTHTHILA_TOKEN_CLOSE(m, tok, _prefix, 0);							
+						c = guththila_reader_next_char(m->reader, 0);
+						GUTHTHILA_TOKEN_OPEN(m, tok);
+					} 					
+				}
+				GUTHTHILA_TOKEN_CLOSE(m, tok, _name, 0);
+
+#ifdef GUTHTHILA_VALIDATION_PARSER	
+				elem = (guththila_element_t *)guththila_stack_pop(&m->elem);
+				if (!elem || (!elem->prefix && m->prefix) || (elem->prefix && !m->prefix)) return -1;
+				if (guththila_tok_tok_cmp(m->name, elem->name)) {
+					return -1;
+				}
+				if (elem->prefix && m->prefix && guththila_tok_tok_cmp(m->prefix, elem->prefix)) {
+					return -1;
+				}
+				if (elem->is_namesp) {
+					nmsp = (guththila_elem_namesp_t *)guththila_stack_pop(&m->namesp);
+					for (nmsp_counter = 0; nmsp_counter < nmsp->no; nmsp_counter++) {
+						guththila_tok_list_release_token(&m->tokens, nmsp->namesp[i].name);
+						guththila_tok_list_release_token(&m->tokens, nmsp->namesp[i].uri);
+					}
+					free(nmsp);
+				}
+				if (elem->name) guththila_tok_list_release_token(&m->tokens, elem->name);
+				if (elem->prefix) guththila_tok_list_release_token(&m->tokens, elem->prefix);
+				free(elem);
+#endif 
+				GUTHTHILA_SKIP_SPACES(m, c);
+				if (c != '>')
+					return -1;
+				return GUTHTHILA_END_ELEMENT;
+			}
+			return -1;
+		} else if(c == '!') { 
+			if (2 == guththila_reader_next_no_char(m->reader, 0, c_arra, 2) && '-' == c_arra[0] && '-' == c_arra[1]){
+				c = guththila_reader_next_char(m->reader, 0);
+				GUTHTHILA_TOKEN_OPEN(m, tok);
+				while (1) {
+					c = guththila_reader_next_char(m->reader, 0);
+					if ('-' == c) {						
+						c = guththila_reader_next_char(m->reader,	0);
+						if ('-' == c) {
+							if ('>' == guththila_reader_next_char(m->reader, 0)){
+								m->guththila_event = GUTHTHILA_COMMENT;								
+								while (c != '<') {
+									c = guththila_reader_next_char(m->reader, 0);
+									if (c == -1)
+										return -1;
+								}
+								GUTHTHILA_TOKEN_CLOSE(m, tok, _char_data, 0);
+								GUTHTHILA_READER_STEP_BACK(m->reader);
+								return GUTHTHILA_COMMENT;
+							}
+							else {
+								return -1;
+							}
+						}
+					}
+				}
+			} else {
+				c = guththila_reader_next_char(m->reader, 0);
+				while ('<' != c)
+					c = guththila_reader_next_char(m->reader, -1);
+			}
+		} else if (c == '?'){
+			c = guththila_process_xml_dec(m);	
+			if (c != -1)
+				return GUTHTHILA_START_DOCUMENT;
+			else 
+				return -1;
+		} 
+	} else if (c != '<' && m->status == S_2 && c != -1){
+		m->is_whitespace = 0;
+		m->is_char = 0;
+
+		m->guththila_event = GUTHTHILA_CHARACTER;
+		GUTHTHILA_TOKEN_OPEN(m, tok);
+		
+		if (isspace(c)){
+			m->is_whitespace = 1;
+		}
+		do {
+			c = guththila_reader_next_char(m->reader, -1);
+			if (isspace(c)) {
+				if (!m->is_char)
+					m->is_whitespace = 1;
+				else
+					m->is_whitespace = 0;
+			}
+			else if (c == '&')
+				ref = 1;
+			else if (c == -1){			
+				return -1;
+			}
+			else if (c != '<'){
+				m->is_whitespace = 0;
+				m->is_char = 1;
+			}
+		} while (c != '<');
+		GUTHTHILA_TOKEN_CLOSE(m, tok, _char_data, ref);
+		GUTHTHILA_READER_STEP_BACK(m->reader);
+		return GUTHTHILA_CHARACTER;
+	} else {
+        return -1;															
+	}
+	return c;
+}
+
+
+static int GUTHTHILA_CALL guththila_process_xml_dec(guththila_t *m)
+{
+	guththila_token_t *tok = NULL;
+	char c_arra[16] = {0};	
+	int c = -1;
+	int quote = -1;
+	int nc = -1;
+
+	if (3 == guththila_reader_next_no_char(m->reader, GUTHTHILA_EOF, c_arra, 3) && 'x' == c_arra[0] && 'm' == c_arra[1] && 'l' == c_arra[2]) {
+		c = guththila_reader_next_char(m->reader, GUTHTHILA_EOF);
+		GUTHTHILA_SKIP_SPACES(m, c);
+		
+		if (c == 'v') {
+			GUTHTHILA_TOKEN_OPEN(m, tok); 
+			if(6 == guththila_reader_next_no_char(m->reader, 0, c_arra, 6) && 
+					'e' == c_arra[0] && 'r' == c_arra[1] &&
+					's' == c_arra[2] && 'i' == c_arra[3] &&
+					'o' == c_arra[4] && 'n' == c_arra[5]) {	
+			
+				c = guththila_reader_next_char(m->reader, 0);
+				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_name, 0);
+				GUTHTHILA_PROCESS_EQU(m, c, quote);
+
+				nc = guththila_reader_next_char(m->reader, 0);
+
+				GUTHTHILA_TOKEN_OPEN(m, tok);
+				while(nc != quote)
+					nc = guththila_reader_next_char(m->reader, 0);
+
+				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_value, 0);
+
+				c = guththila_reader_next_char(m->reader, 0);
+				GUTHTHILA_SKIP_SPACES(m, c);
+			} else{
+				return -1;
+			}
+		}
+
+		if (c == 'e') {
+			GUTHTHILA_TOKEN_OPEN(m, tok);
+			if(7 == guththila_reader_next_no_char(m->reader, 0, c_arra, 7) &&
+				'n' == c_arra[0] && 'c' == c_arra[1] &&
+				'o' == c_arra[2] && 'd' == c_arra[3] &&		
+				'i' == c_arra[4] && 'n' == c_arra[5] &&		
+				'g' == c_arra[6]) {
+				
+				c = guththila_reader_next_char(m->reader, 0);
+				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_name, 0);
+				GUTHTHILA_PROCESS_EQU(m, c, quote);
+
+				nc = guththila_reader_next_char(m->reader, 0);
+
+				GUTHTHILA_TOKEN_OPEN(m, tok);
+				while(nc != quote)
+					nc = guththila_reader_next_char(m->reader, 0);
+
+				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_value, 0);
+
+				c = guththila_reader_next_char(m->reader, 0);
+				GUTHTHILA_SKIP_SPACES(m, c);				
+			}
+		}
+
+		if (c == 's') {
+			GUTHTHILA_TOKEN_OPEN(m, tok);			
+			if(9 == guththila_reader_next_no_char(m->reader, 0, c_arra, 9) &&
+				't' == c_arra[0] && 'a' == c_arra[1] &&
+				'n' == c_arra[2] && 'd' == c_arra[3] &&		
+				'a' == c_arra[4] && 'l' == c_arra[5] &&		
+				'o' == c_arra[6] && 'n' == c_arra[7] &&
+				'e' == c_arra[8]) {
+
+				c = guththila_reader_next_char(m->reader, 0);
+				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_name, 0);
+				GUTHTHILA_PROCESS_EQU(m, c, quote);
+
+				nc = guththila_reader_next_char(m->reader, 0);
+				GUTHTHILA_TOKEN_OPEN(m, tok);								
+
+				while(nc != quote)
+					nc = guththila_reader_next_char(m->reader, 0);
+
+				GUTHTHILA_TOKEN_CLOSE(m, tok, _attribute_value, 0);
+
+				c = guththila_reader_next_char(m->reader, 0);
+				GUTHTHILA_SKIP_SPACES(m, c);																				
+			}
+		}
+
+		if (c == '?') {
+			if ('>' == guththila_reader_next_char(m->reader, 0)){
+                m->guththila_event = GUTHTHILA_START_DOCUMENT;
+			} else {
+				return -1;
+			}
+		}
+	}
+	return c;
+}
+
+
+GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_get_attribute_count(guththila_t *m)
+{
+	return GUTHTHILA_STACK_SIZE(m->attrib);
+}
+                                                
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_name(guththila_t * m, guththila_attr_t * att)
+{
+	char *str = NULL;
+	if (att) {
+		GUTHTHILA_TOKEN_TO_STRING(att->name, str);  
+		return str;
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_value (guththila_t *m, guththila_attr_t * att)
+{
+	char *str = NULL;
+	if (att) {
+		GUTHTHILA_TOKEN_TO_STRING(att->val, str);  
+		return str;
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_prefix (guththila_t *m, guththila_attr_t * att)
+{
+	char *str = NULL;
+	if (att) {
+		GUTHTHILA_TOKEN_TO_STRING(att->pref, str);  
+		return str;
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_attr_t * GUTHTHILA_CALL guththila_get_attribute (guththila_t * m)
+{
+	return (guththila_attr_t *)guththila_stack_pop(&m->attrib);
+}
+
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_name_by_number (guththila_t * m, int i)
+{
+	char *str = NULL;
+	guththila_attr_t *attr = (guththila_attr_t *)guththila_stack_get_by_index(&m->attrib, i - 1);
+	if (attr){
+		GUTHTHILA_TOKEN_TO_STRING(attr->name, str);  
+		return str;		
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_value_by_number (guththila_t * m, int i)
+{
+	char *str = NULL;
+	guththila_attr_t *attr = (guththila_attr_t *)guththila_stack_get_by_index(&m->attrib, i - 1);
+	if (attr){
+		GUTHTHILA_TOKEN_TO_STRING(attr->val, str);  
+		return str;		
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_prefix_by_number (guththila_t * m, int i)
+{
+	char *str = NULL;
+	guththila_attr_t *attr = (guththila_attr_t *)guththila_stack_get_by_index(&m->attrib, i - 1);
+	if (attr && attr->pref){
+		GUTHTHILA_TOKEN_TO_STRING(attr->pref, str);  
+		return str;		
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_name (guththila_t * m)
+{
+	char *str = NULL;
+	if (m->name){
+		GUTHTHILA_TOKEN_TO_STRING(m->name, str);  
+		return str;		
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_prefix (guththila_t * m)
+{
+	char *str = NULL;
+	if (m->prefix){
+		GUTHTHILA_TOKEN_TO_STRING(m->prefix, str);  
+		return str;		
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_value (guththila_t * m)
+{
+	char *str = NULL;
+	if (m->value){
+		GUTHTHILA_TOKEN_TO_STRING(m->value, str);  
+		return str;		
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_namespace_t * GUTHTHILA_CALL guththila_get_namespace (guththila_t * m)
+{
+#ifndef GUTHTHILA_VALIDATION_PARSER
+	return (guththila_namespace_t *)guththila_stack_pop(&m->namesp);
+#else
+	return NULL;
+#endif
+}
+
+GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_get_namespace_count (guththila_t *m)
+{
+#ifndef GUTHTHILA_VALIDATION_PARSER
+	return GUTHTHILA_STACK_SIZE(m->namesp);
+#else
+	guththila_elem_namesp_t *nmsp = NULL;
+	if (((guththila_element_t *)guththila_stack_peek(&m->elem))->is_namesp) {
+		nmsp = (guththila_elem_namesp_t *)guththila_stack_peek(&m->namesp);
+		return nmsp->no; 
+	}
+	return 0;
+#endif
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_namespace_uri (guththila_t * m, guththila_namespace_t * ns)
+{
+	char *str = NULL;
+	if (ns->uri){
+		GUTHTHILA_TOKEN_TO_STRING(ns->uri, str);  
+		return str;		
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_namespace_prefix (guththila_t *m, guththila_namespace_t * ns)
+{
+	char *str = NULL;
+	if (ns->name){
+		GUTHTHILA_TOKEN_TO_STRING(ns->name, str);  
+		return str;		
+	}
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_namespace_prefix_by_number (guththila_t * m, int i)
+{
+	char *str = NULL;
+#ifndef GUTHTHILA_VALIDATION_PARSER
+	if (GUTHTHILA_STACK_SIZE(m->namesp) >= i){
+		namesp = guththila_stack_get_by_index(&m->namesp, i);
+		if (namesp && namesp->name) {
+			GUTHTHILA_TOKEN_TO_STRING(namesp->name, str);
+			return str;
+		}
+	}
+#else
+	guththila_elem_namesp_t *nmsp = NULL;
+	if (((guththila_element_t *)guththila_stack_peek(&m->elem))->is_namesp) {
+		nmsp = (guththila_elem_namesp_t *)guththila_stack_peek(&m->namesp);
+		if (nmsp && nmsp->no >= i) {
+			GUTHTHILA_TOKEN_TO_STRING(nmsp->namesp[i - 1].name, str);
+			return str;
+		}
+	}
+#endif
+	return NULL;
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_namespace_uri_by_number (guththila_t * m, int i) 
+{
+	char *str = NULL;
+	/*TODO check the given index, this can begn from 1, here I assume begin from 0*/
+#ifndef GUTHTHILA_VALIDATION_PARSER
+	if (GUTHTHILA_STACK_SIZE(m->namesp) > i){
+		namesp = guththila_stack_get_by_index(&m->namesp, i);
+		if (namesp && namesp->uri) {
+			GUTHTHILA_TOKEN_TO_STRING(namesp->uri, str);
+			return str;
+		}
+	}
+#else
+	guththila_elem_namesp_t *nmsp = NULL;
+	if (((guththila_element_t *)guththila_stack_peek(&m->elem))->is_namesp) {
+		nmsp = (guththila_elem_namesp_t *)guththila_stack_peek(&m->namesp);
+		if (nmsp && nmsp->no >= i) {
+			GUTHTHILA_TOKEN_TO_STRING(nmsp->namesp[i - 1].uri, str);
+			return str;
+		}
+	}
+#endif
+	return NULL;
+
+}
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_attribute_namespace_by_number (guththila_t * m, int i)
+{
+#ifndef GUTHTHILA_VALIDATION_PARSER
+	return NULL;
+#else
+	guththila_attr_t *attr  = NULL;
+	char *str = NULL;
+	int j = 0, k = 0, count = 0;
+	guththila_elem_namesp_t *nmsp = NULL;
+	if ( i <= GUTHTHILA_STACK_SIZE(m->attrib)) {	
+		attr = (guththila_attr_t *)guththila_stack_get_by_index(&m->attrib, i - 1);  
+		if (attr && attr->pref) {
+			count = GUTHTHILA_STACK_SIZE(m->namesp);
+			for ( j = 0; j < count; j++) { 
+				nmsp = (guththila_elem_namesp_t *)guththila_stack_get_by_index(&m->namesp, j);
+				for (k = 0; k < nmsp->no; k++) {
+					if (!guththila_tok_tok_cmp(nmsp->namesp[k].name, attr->pref)) {
+						GUTHTHILA_TOKEN_TO_STRING(nmsp->namesp[k].uri, str);
+						return str;
+					}
+				}
+			}
+		}
+	}
+	return NULL;
+#endif
+}
+
+GUTHTHILA_EXPORT guththila_char * GUTHTHILA_CALL guththila_get_encoding (guththila_t *m)
+{
+	return "UTF-8";
+}
+



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message