imgtools/imgcheck/libxml/xmlregexp.h
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2  * Summary: regular expressions handling
       
     3  * Description: basic API for libxml regular expressions handling used
       
     4  *              for XML Schemas and validation.
       
     5  *
       
     6  * Copy: See Copyright for the status of this software.
       
     7  *
       
     8  * Author: Daniel Veillard
       
     9  */
       
    10 
       
    11 #ifndef __XML_REGEXP_H__
       
    12 #define __XML_REGEXP_H__
       
    13 
       
    14 #include <libxml/xmlversion.h>
       
    15 
       
    16 #ifdef LIBXML_REGEXP_ENABLED
       
    17 
       
    18 #ifdef __cplusplus
       
    19 extern "C" {
       
    20 #endif
       
    21 
       
    22 /**
       
    23  * xmlRegexpPtr:
       
    24  *
       
    25  * A libxml regular expression, they can actually be far more complex
       
    26  * thank the POSIX regex expressions.
       
    27  */
       
    28 typedef struct _xmlRegexp xmlRegexp;
       
    29 typedef xmlRegexp *xmlRegexpPtr;
       
    30 
       
    31 /**
       
    32  * xmlRegExecCtxtPtr:
       
    33  *
       
    34  * A libxml progressive regular expression evaluation context
       
    35  */
       
    36 typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
       
    37 typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
       
    38 
       
    39 #ifdef __cplusplus
       
    40 }
       
    41 #endif 
       
    42 #include <libxml/tree.h>
       
    43 #include <libxml/dict.h>
       
    44 #ifdef __cplusplus
       
    45 extern "C" {
       
    46 #endif
       
    47 
       
    48 /*
       
    49  * The POSIX like API
       
    50  */
       
    51 XMLPUBFUN xmlRegexpPtr XMLCALL
       
    52 		    xmlRegexpCompile	(const xmlChar *regexp);
       
    53 XMLPUBFUN void XMLCALL			 xmlRegFreeRegexp(xmlRegexpPtr regexp);
       
    54 XMLPUBFUN int XMLCALL			
       
    55 		    xmlRegexpExec	(xmlRegexpPtr comp,
       
    56 					 const xmlChar *value);
       
    57 XMLPUBFUN void XMLCALL			
       
    58     		    xmlRegexpPrint	(FILE *output,
       
    59 					 xmlRegexpPtr regexp);
       
    60 XMLPUBFUN int XMLCALL			
       
    61 		    xmlRegexpIsDeterminist(xmlRegexpPtr comp);
       
    62 
       
    63 /*
       
    64  * Callback function when doing a transition in the automata
       
    65  */
       
    66 typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,
       
    67 	                             const xmlChar *token,
       
    68 				     void *transdata,
       
    69 				     void *inputdata);
       
    70 
       
    71 /*
       
    72  * The progressive API
       
    73  */
       
    74 XMLPUBFUN xmlRegExecCtxtPtr XMLCALL	
       
    75     		    xmlRegNewExecCtxt	(xmlRegexpPtr comp,
       
    76 					 xmlRegExecCallbacks callback,
       
    77 					 void *data);
       
    78 XMLPUBFUN void XMLCALL			
       
    79 		    xmlRegFreeExecCtxt	(xmlRegExecCtxtPtr exec);
       
    80 XMLPUBFUN int XMLCALL			
       
    81     		    xmlRegExecPushString(xmlRegExecCtxtPtr exec,
       
    82 					 const xmlChar *value,
       
    83 					 void *data);
       
    84 XMLPUBFUN int XMLCALL			
       
    85 		    xmlRegExecPushString2(xmlRegExecCtxtPtr exec,
       
    86 					 const xmlChar *value,
       
    87 					 const xmlChar *value2,
       
    88 					 void *data);
       
    89 
       
    90 XMLPUBFUN int XMLCALL
       
    91 		    xmlRegExecNextValues(xmlRegExecCtxtPtr exec,
       
    92 		    			 int *nbval,
       
    93 		    			 int *nbneg,
       
    94 					 xmlChar **values,
       
    95 					 int *terminal);
       
    96 XMLPUBFUN int XMLCALL
       
    97 		    xmlRegExecErrInfo	(xmlRegExecCtxtPtr exec,
       
    98 		    			 const xmlChar **string,
       
    99 					 int *nbval,
       
   100 		    			 int *nbneg,
       
   101 					 xmlChar **values,
       
   102 					 int *terminal);
       
   103 #ifdef LIBXML_EXPR_ENABLED
       
   104 /*
       
   105  * Formal regular expression handling
       
   106  * Its goal is to do some formal work on content models
       
   107  */
       
   108 
       
   109 /* expressions are used within a context */
       
   110 typedef struct _xmlExpCtxt xmlExpCtxt;
       
   111 typedef xmlExpCtxt *xmlExpCtxtPtr;
       
   112 
       
   113 XMLPUBFUN void XMLCALL
       
   114 			xmlExpFreeCtxt	(xmlExpCtxtPtr ctxt);
       
   115 XMLPUBFUN xmlExpCtxtPtr XMLCALL
       
   116 			xmlExpNewCtxt	(int maxNodes,
       
   117 					 xmlDictPtr dict);
       
   118 
       
   119 XMLPUBFUN int XMLCALL
       
   120 			xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);
       
   121 XMLPUBFUN int XMLCALL
       
   122 			xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);
       
   123 
       
   124 /* Expressions are trees but the tree is opaque */
       
   125 typedef struct _xmlExpNode xmlExpNode;
       
   126 typedef xmlExpNode *xmlExpNodePtr;
       
   127 
       
   128 typedef enum {
       
   129     XML_EXP_EMPTY = 0,
       
   130     XML_EXP_FORBID = 1,
       
   131     XML_EXP_ATOM = 2,
       
   132     XML_EXP_SEQ = 3,
       
   133     XML_EXP_OR = 4,
       
   134     XML_EXP_COUNT = 5
       
   135 } xmlExpNodeType;
       
   136 
       
   137 /*
       
   138  * 2 core expressions shared by all for the empty language set 
       
   139  * and for the set with just the empty token
       
   140  */
       
   141 XMLPUBVAR xmlExpNodePtr forbiddenExp;
       
   142 XMLPUBVAR xmlExpNodePtr emptyExp;
       
   143 
       
   144 /*
       
   145  * Expressions are reference counted internally
       
   146  */
       
   147 XMLPUBFUN void XMLCALL
       
   148 			xmlExpFree	(xmlExpCtxtPtr ctxt,
       
   149 					 xmlExpNodePtr expr);
       
   150 XMLPUBFUN void XMLCALL
       
   151 			xmlExpRef	(xmlExpNodePtr expr);
       
   152 
       
   153 /*
       
   154  * constructors can be either manual or from a string
       
   155  */
       
   156 XMLPUBFUN xmlExpNodePtr XMLCALL
       
   157 			xmlExpParse	(xmlExpCtxtPtr ctxt,
       
   158 					 const char *expr);
       
   159 XMLPUBFUN xmlExpNodePtr XMLCALL
       
   160 			xmlExpNewAtom	(xmlExpCtxtPtr ctxt,
       
   161 					 const xmlChar *name,
       
   162 					 int len);
       
   163 XMLPUBFUN xmlExpNodePtr XMLCALL
       
   164 			xmlExpNewOr	(xmlExpCtxtPtr ctxt,
       
   165 					 xmlExpNodePtr left,
       
   166 					 xmlExpNodePtr right);
       
   167 XMLPUBFUN xmlExpNodePtr XMLCALL
       
   168 			xmlExpNewSeq	(xmlExpCtxtPtr ctxt,
       
   169 					 xmlExpNodePtr left,
       
   170 					 xmlExpNodePtr right);
       
   171 XMLPUBFUN xmlExpNodePtr XMLCALL
       
   172 			xmlExpNewRange	(xmlExpCtxtPtr ctxt,
       
   173 					 xmlExpNodePtr subset,
       
   174 					 int min,
       
   175 					 int max);
       
   176 /*
       
   177  * The really interesting APIs
       
   178  */
       
   179 XMLPUBFUN int XMLCALL
       
   180 			xmlExpIsNillable(xmlExpNodePtr expr);
       
   181 XMLPUBFUN int XMLCALL
       
   182 			xmlExpMaxToken	(xmlExpNodePtr expr);
       
   183 XMLPUBFUN int XMLCALL
       
   184 			xmlExpGetLanguage(xmlExpCtxtPtr ctxt,
       
   185 					 xmlExpNodePtr expr,
       
   186 					 const xmlChar**langList,
       
   187 					 int len);
       
   188 XMLPUBFUN int XMLCALL
       
   189 			xmlExpGetStart	(xmlExpCtxtPtr ctxt,
       
   190 					 xmlExpNodePtr expr,
       
   191 					 const xmlChar**tokList,
       
   192 					 int len);
       
   193 XMLPUBFUN xmlExpNodePtr XMLCALL
       
   194 			xmlExpStringDerive(xmlExpCtxtPtr ctxt,
       
   195 					 xmlExpNodePtr expr,
       
   196 					 const xmlChar *str,
       
   197 					 int len);
       
   198 XMLPUBFUN xmlExpNodePtr XMLCALL
       
   199 			xmlExpExpDerive	(xmlExpCtxtPtr ctxt,
       
   200 					 xmlExpNodePtr expr,
       
   201 					 xmlExpNodePtr sub);
       
   202 XMLPUBFUN int XMLCALL
       
   203 			xmlExpSubsume	(xmlExpCtxtPtr ctxt,
       
   204 					 xmlExpNodePtr expr,
       
   205 					 xmlExpNodePtr sub);
       
   206 XMLPUBFUN void XMLCALL
       
   207 			xmlExpDump	(xmlBufferPtr buf,
       
   208 					 xmlExpNodePtr expr);
       
   209 #endif /* LIBXML_EXPR_ENABLED */
       
   210 #ifdef __cplusplus
       
   211 }
       
   212 #endif 
       
   213 
       
   214 #endif /* LIBXML_REGEXP_ENABLED */
       
   215 
       
   216 #endif /*__XML_REGEXP_H__ */