Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:19:32

0001 /*
0002  * Summary: regular expressions handling
0003  * Description: basic API for libxml regular expressions handling used
0004  *              for XML Schemas and validation.
0005  *
0006  * Copy: See Copyright for the status of this software.
0007  *
0008  * Author: Daniel Veillard
0009  */
0010 
0011 #ifndef __XML_REGEXP_H__
0012 #define __XML_REGEXP_H__
0013 
0014 #include <stdio.h>
0015 #include <libxml/xmlversion.h>
0016 #include <libxml/xmlstring.h>
0017 
0018 #ifdef LIBXML_REGEXP_ENABLED
0019 
0020 #ifdef __cplusplus
0021 extern "C" {
0022 #endif
0023 
0024 /**
0025  * xmlRegexpPtr:
0026  *
0027  * A libxml regular expression, they can actually be far more complex
0028  * thank the POSIX regex expressions.
0029  */
0030 typedef struct _xmlRegexp xmlRegexp;
0031 typedef xmlRegexp *xmlRegexpPtr;
0032 
0033 /**
0034  * xmlRegExecCtxtPtr:
0035  *
0036  * A libxml progressive regular expression evaluation context
0037  */
0038 typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
0039 typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
0040 
0041 /*
0042  * The POSIX like API
0043  */
0044 XMLPUBFUN xmlRegexpPtr
0045             xmlRegexpCompile    (const xmlChar *regexp);
0046 XMLPUBFUN void           xmlRegFreeRegexp(xmlRegexpPtr regexp);
0047 XMLPUBFUN int
0048             xmlRegexpExec   (xmlRegexpPtr comp,
0049                      const xmlChar *value);
0050 XMLPUBFUN void
0051             xmlRegexpPrint  (FILE *output,
0052                      xmlRegexpPtr regexp);
0053 XMLPUBFUN int
0054             xmlRegexpIsDeterminist(xmlRegexpPtr comp);
0055 
0056 /**
0057  * xmlRegExecCallbacks:
0058  * @exec: the regular expression context
0059  * @token: the current token string
0060  * @transdata: transition data
0061  * @inputdata: input data
0062  *
0063  * Callback function when doing a transition in the automata
0064  */
0065 typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,
0066                                  const xmlChar *token,
0067                      void *transdata,
0068                      void *inputdata);
0069 
0070 /*
0071  * The progressive API
0072  */
0073 XMLPUBFUN xmlRegExecCtxtPtr
0074             xmlRegNewExecCtxt   (xmlRegexpPtr comp,
0075                      xmlRegExecCallbacks callback,
0076                      void *data);
0077 XMLPUBFUN void
0078             xmlRegFreeExecCtxt  (xmlRegExecCtxtPtr exec);
0079 XMLPUBFUN int
0080             xmlRegExecPushString(xmlRegExecCtxtPtr exec,
0081                      const xmlChar *value,
0082                      void *data);
0083 XMLPUBFUN int
0084             xmlRegExecPushString2(xmlRegExecCtxtPtr exec,
0085                      const xmlChar *value,
0086                      const xmlChar *value2,
0087                      void *data);
0088 
0089 XMLPUBFUN int
0090             xmlRegExecNextValues(xmlRegExecCtxtPtr exec,
0091                      int *nbval,
0092                      int *nbneg,
0093                      xmlChar **values,
0094                      int *terminal);
0095 XMLPUBFUN int
0096             xmlRegExecErrInfo   (xmlRegExecCtxtPtr exec,
0097                      const xmlChar **string,
0098                      int *nbval,
0099                      int *nbneg,
0100                      xmlChar **values,
0101                      int *terminal);
0102 #ifdef LIBXML_EXPR_ENABLED
0103 /*
0104  * Formal regular expression handling
0105  * Its goal is to do some formal work on content models
0106  */
0107 
0108 /* expressions are used within a context */
0109 typedef struct _xmlExpCtxt xmlExpCtxt;
0110 typedef xmlExpCtxt *xmlExpCtxtPtr;
0111 
0112 XMLPUBFUN void
0113             xmlExpFreeCtxt  (xmlExpCtxtPtr ctxt);
0114 XMLPUBFUN xmlExpCtxtPtr
0115             xmlExpNewCtxt   (int maxNodes,
0116                      xmlDictPtr dict);
0117 
0118 XMLPUBFUN int
0119             xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);
0120 XMLPUBFUN int
0121             xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);
0122 
0123 /* Expressions are trees but the tree is opaque */
0124 typedef struct _xmlExpNode xmlExpNode;
0125 typedef xmlExpNode *xmlExpNodePtr;
0126 
0127 typedef enum {
0128     XML_EXP_EMPTY = 0,
0129     XML_EXP_FORBID = 1,
0130     XML_EXP_ATOM = 2,
0131     XML_EXP_SEQ = 3,
0132     XML_EXP_OR = 4,
0133     XML_EXP_COUNT = 5
0134 } xmlExpNodeType;
0135 
0136 /*
0137  * 2 core expressions shared by all for the empty language set
0138  * and for the set with just the empty token
0139  */
0140 XMLPUBVAR xmlExpNodePtr forbiddenExp;
0141 XMLPUBVAR xmlExpNodePtr emptyExp;
0142 
0143 /*
0144  * Expressions are reference counted internally
0145  */
0146 XMLPUBFUN void
0147             xmlExpFree  (xmlExpCtxtPtr ctxt,
0148                      xmlExpNodePtr expr);
0149 XMLPUBFUN void
0150             xmlExpRef   (xmlExpNodePtr expr);
0151 
0152 /*
0153  * constructors can be either manual or from a string
0154  */
0155 XMLPUBFUN xmlExpNodePtr
0156             xmlExpParse (xmlExpCtxtPtr ctxt,
0157                      const char *expr);
0158 XMLPUBFUN xmlExpNodePtr
0159             xmlExpNewAtom   (xmlExpCtxtPtr ctxt,
0160                      const xmlChar *name,
0161                      int len);
0162 XMLPUBFUN xmlExpNodePtr
0163             xmlExpNewOr (xmlExpCtxtPtr ctxt,
0164                      xmlExpNodePtr left,
0165                      xmlExpNodePtr right);
0166 XMLPUBFUN xmlExpNodePtr
0167             xmlExpNewSeq    (xmlExpCtxtPtr ctxt,
0168                      xmlExpNodePtr left,
0169                      xmlExpNodePtr right);
0170 XMLPUBFUN xmlExpNodePtr
0171             xmlExpNewRange  (xmlExpCtxtPtr ctxt,
0172                      xmlExpNodePtr subset,
0173                      int min,
0174                      int max);
0175 /*
0176  * The really interesting APIs
0177  */
0178 XMLPUBFUN int
0179             xmlExpIsNillable(xmlExpNodePtr expr);
0180 XMLPUBFUN int
0181             xmlExpMaxToken  (xmlExpNodePtr expr);
0182 XMLPUBFUN int
0183             xmlExpGetLanguage(xmlExpCtxtPtr ctxt,
0184                      xmlExpNodePtr expr,
0185                      const xmlChar**langList,
0186                      int len);
0187 XMLPUBFUN int
0188             xmlExpGetStart  (xmlExpCtxtPtr ctxt,
0189                      xmlExpNodePtr expr,
0190                      const xmlChar**tokList,
0191                      int len);
0192 XMLPUBFUN xmlExpNodePtr
0193             xmlExpStringDerive(xmlExpCtxtPtr ctxt,
0194                      xmlExpNodePtr expr,
0195                      const xmlChar *str,
0196                      int len);
0197 XMLPUBFUN xmlExpNodePtr
0198             xmlExpExpDerive (xmlExpCtxtPtr ctxt,
0199                      xmlExpNodePtr expr,
0200                      xmlExpNodePtr sub);
0201 XMLPUBFUN int
0202             xmlExpSubsume   (xmlExpCtxtPtr ctxt,
0203                      xmlExpNodePtr expr,
0204                      xmlExpNodePtr sub);
0205 XMLPUBFUN void
0206             xmlExpDump  (xmlBufferPtr buf,
0207                      xmlExpNodePtr expr);
0208 #endif /* LIBXML_EXPR_ENABLED */
0209 #ifdef __cplusplus
0210 }
0211 #endif
0212 
0213 #endif /* LIBXML_REGEXP_ENABLED */
0214 
0215 #endif /*__XML_REGEXP_H__ */