guththila_token.h

00001 
00002 /*
00003  * Licensed to the Apache Software Foundation (ASF) under one or more
00004  * contributor license agreements.  See the NOTICE file distributed with
00005  * this work for additional information regarding copyright ownership.
00006  * The ASF licenses this file to You under the Apache License, Version 2.0
00007  * (the "License"); you may not use this file except in compliance with
00008  * the License.  You may obtain a copy of the License at
00009  *
00010  *      http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 #ifndef GUTHTHILA_TOKEN_H
00019 #define GUTHTHILA_TOKEN_H
00020 
00021 #include <guththila_defines.h>
00022 #include <guththila_stack.h>
00023 
00024 EXTERN_C_START()  
00025 
00026 typedef struct guththila_token_s
00027 {
00028     short type;
00029     guththila_char_t *start;
00030     int _start;
00031     size_t size;
00032     int last;
00033     int ref;
00034 } guththila_token_t;
00035 
00036 enum guththila_token_type
00037 {
00038     _Unknown = 1, 
00039         _name, 
00040         _attribute_name, 
00041         _attribute_value, 
00042         _prefix,
00043     _char_data, 
00044         _text_data
00045 };
00046 
00047 typedef struct guththila_tok_list_s
00048 {
00049     guththila_stack_t fr_stack;
00050     guththila_token_t **list;
00051     int no_list;
00052     int cur_list;
00053     int *capacity;    
00054 } guththila_tok_list_t;
00055 
00056 #ifndef GUTHTHILA_TOK_DEF_SIZE
00057 #define GUTHTHILA_TOK_DEF_SIZE 16
00058 #endif  
00059 
00060 #ifndef GUTHTHILA_TOK_DEF_LIST_SIZE
00061 #define GUTHTHILA_TOK_DEF_LIST_SIZE 16
00062 #endif 
00063 
00064 #ifndef GUTHTHILA_TOKEN_LEN
00065 #define GUTHTHILA_TOKEN_LEN(tok) (tok->size)
00066 #endif  
00067 
00068 #ifndef GUTHTHILA_TOKEN_TO_STRING
00069 #define GUTHTHILA_TOKEN_TO_STRING(tok, string, _env) \
00070     { \
00071         string  = (guththila_char_t *) AXIS2_MALLOC(_env->allocator, (GUTHTHILA_TOKEN_LEN(tok) + 1) * sizeof(guththila_char_t)); \
00072         memcpy(string, (tok)->start, GUTHTHILA_TOKEN_LEN(tok));         \
00073         string[GUTHTHILA_TOKEN_LEN(tok)] = 0; \
00074     }
00075 #endif  
00076 
00077 /*
00078  * Initialize token list.
00079  */
00080 int GUTHTHILA_CALL
00081 guththila_tok_list_init(
00082     guththila_tok_list_t * tok_list,
00083     const axutil_env_t * env);
00084 
00085 /* 
00086  * Free the token list. Allocated tokens are not free. 
00087  */
00088 void GUTHTHILA_CALL
00089 guththila_tok_list_free(
00090     guththila_tok_list_t * tok_list,
00091     const axutil_env_t * env);
00092 
00093 /*
00094  * Get a token from the list.
00095  */
00096 guththila_token_t *
00097 GUTHTHILA_CALL guththila_tok_list_get_token(
00098         guththila_tok_list_t * tok_list,
00099     const axutil_env_t * env);
00100 
00101 /*
00102  * Release a token to the token list.
00103  */
00104 int GUTHTHILA_CALL
00105 guththila_tok_list_release_token(
00106     guththila_tok_list_t * tok_list,
00107     guththila_token_t * token,
00108     const axutil_env_t * env);
00109 
00110 /*
00111  * Free the tokens in the token list.
00112  */
00113 void GUTHTHILA_CALL
00114 guththila_tok_list_free_data(
00115     guththila_tok_list_t * tok_list,
00116     const axutil_env_t * env);
00117 
00118 /*
00119  * Grow the token list.
00120  */
00121 int GUTHTHILA_CALL
00122 guththila_tok_list_grow(
00123     guththila_tok_list_t * tok_list,
00124     const axutil_env_t * env);
00125 
00126 /*
00127  * Compare a token with a string.
00128  * Return 0 if match. 
00129  */
00130 int GUTHTHILA_CALL
00131 guththila_tok_str_cmp(
00132     guththila_token_t * tok,
00133     guththila_char_t *str,
00134     size_t str_len,
00135     const axutil_env_t * env);
00136 
00137 /* 
00138  * Compare two tokens for string equalance 
00139  * Return 0 if match. 
00140  */
00141 int GUTHTHILA_CALL
00142 guththila_tok_tok_cmp(
00143     guththila_token_t * tok1,
00144     guththila_token_t * tok2,
00145     const axutil_env_t * env);
00146 
00147 void GUTHTHILA_CALL
00148 guththila_set_token(
00149     guththila_token_t* tok,
00150     guththila_char_t* start,
00151     short type,
00152     int size,
00153     int _start,
00154     int last,
00155     int ref,
00156     const axutil_env_t* env);
00157 
00158 EXTERN_C_END() 
00159 #endif  
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 

Generated on Fri Apr 17 11:49:43 2009 for Axis2/C by  doxygen 1.5.3