OSDN Git Service

Add MS7619SE
[uclinux-h8/uClinux-dist.git] / user / ser / re.h
1 /*
2  * $Id: re.h,v 1.6 2004/11/12 16:58:58 andrei Exp $
3  *
4  * regexp and regexp substitutions implementations
5  * 
6  * Copyright (C) 2001-2003 FhG Fokus
7  *
8  * This file is part of ser, a free SIP server.
9  *
10  * ser is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version
14  *
15  * For a license to use the ser software under conditions
16  * other than those described here, or to purchase support for this
17  * software, please contact iptel.org by e-mail at the following addresses:
18  *    info@iptel.org
19  *
20  * ser is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License 
26  * along with this program; if not, write to the Free Software 
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28  *
29  *
30  * History:
31  * --------
32  *   2003-08-04  created by andrei
33  *   2004-11-12  minor api extension, added *count (andrei)
34  */
35
36 #ifndef _re_h
37 #define _re_h
38
39 #include "str.h"
40 #include "parser/msg_parser.h"
41 #include <sys/types.h> /* for regex */
42 #include <regex.h>
43
44 enum replace_special { REPLACE_NMATCH, REPLACE_CHAR, REPLACE_URI };
45
46 struct replace_with{
47         int offset; /* offset in string */
48         int size;   /* size of replace "anchor" in string */
49         enum replace_special type;
50         union{
51                 int nmatch;
52                 char c;
53         }u;
54 };
55
56 struct subst_expr{
57         regex_t* re;
58         str replacement;
59         int replace_all; 
60         int n_escapes; /* escapes number (replace[] size) */
61         int max_pmatch ; /* highest () referenced */
62         struct replace_with replace[1]; /* 0 does not work on all compilers */
63 };
64
65 struct replace_lst{
66         int offset;
67         int size;   /* at offset, delete size bytes and replace them with rpl */
68         str rpl;
69         struct replace_lst *next;
70 };
71
72
73
74 void subst_expr_free(struct subst_expr* se);
75 void replace_lst_free(struct replace_lst* l);
76 struct subst_expr*  subst_parser(str* subst);
77 struct replace_lst* subst_run( struct subst_expr* se, const char* input, 
78                                        struct sip_msg* msg, int *count);
79 str* subst_str(const char* input, struct sip_msg* msg,
80                                 struct subst_expr* se, int* count);
81
82
83
84 #endif
85