00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _re_h
00034 #define _re_h
00035
00036 #include "str.h"
00037 #include "pvar.h"
00038 #include "parser/msg_parser.h"
00039 #include <sys/types.h>
00040 #include <regex.h>
00041
00042 #define WITH_SEP 1
00043 #define WITHOUT_SEP 0
00044
00045 enum replace_special { REPLACE_NMATCH, REPLACE_CHAR, REPLACE_URI,
00046 REPLACE_SPEC };
00047
00048 struct replace_with{
00049 int offset;
00050 int size;
00051 enum replace_special type;
00052 union{
00053 int nmatch;
00054 char c;
00055 pv_spec_t spec;
00056 }u;
00057 };
00058
00059 struct subst_expr{
00060 regex_t* re;
00061 str replacement;
00062 int replace_all;
00063 int n_escapes;
00064 int max_pmatch ;
00065 struct replace_with replace[1];
00066 };
00067
00068 struct replace_lst{
00069 int offset;
00070 int size;
00071 str rpl;
00072 struct replace_lst *next;
00073 };
00074
00075
00076
00077 void subst_expr_free(struct subst_expr* se);
00078 void replace_lst_free(struct replace_lst* l);
00079 int parse_repl(struct replace_with * rw, char ** begin,
00080 char * end, int *max_token_nb, int flag);
00081 struct subst_expr* subst_parser(str* subst);
00082 struct replace_lst* subst_run( struct subst_expr* se, const char* input,
00083 struct sip_msg* msg, int *count);
00084 str* subst_str(const char* input, struct sip_msg* msg,
00085 struct subst_expr* se, int* count);
00086
00087
00088
00089 #endif
00090