RTS API Documentation  1.10.11
switch_regex.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Michael Jerris <mike@jerris.com>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Michael Jerris <mike@jerris.com>
27  *
28  * switch_regex.h -- pcre wrapper and extensions Header
29  *
30  */
31 /*! \file switch_regex.h
32  \brief Regex Header
33 */
34 #ifndef SWITCH_REGEX_H
35 #define SWITCH_REGEX_H
36 
38 /**
39  * @defgroup switch_regex Regular Expressions
40  * @ingroup FREESWITCH
41  * @{
42  */
43  typedef struct real_pcre switch_regex_t;
44 
45 SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern, int options, const char **errorptr, int *erroroffset,
46  const unsigned char *tables);
47 
48 SWITCH_DECLARE(int) switch_regex_copy_substring(const char *subject, int *ovector, int stringcount, int stringnumber, char *buffer, int size);
49 
50 SWITCH_DECLARE(void) switch_regex_free(void *data);
51 
52 SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen);
53 SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, const char *data, const char *field_data,
54  char *substituted, switch_size_t len, int *ovector);
55 
56 /*!
57  \brief Function to evaluate an expression against a string
58  \param target The string to find a match in
59  \param expression The regular expression to run against the string
60  \return Boolean if a match was found or not
61 */
62 SWITCH_DECLARE(switch_status_t) switch_regex_match(const char *target, const char *expression);
63 
64 /*!
65  \brief Function to evaluate an expression against a string
66  \param target The string to find a match in
67  \param expression The regular expression to run against the string
68  \param partial_match If non-zero returns SUCCESS if the target is a partial match, on successful return, this is set to non-zero if the match was partial and zero if it was a full match
69  \return Boolean if a match was found or not
70 */
71 SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, const char *expression, int *partial_match);
72 
73 SWITCH_DECLARE(void) switch_capture_regex(switch_regex_t *re, int match_count, const char *field_data,
74  int *ovector, const char *var, switch_cap_callback_t callback, void *user_data);
75 
76 SWITCH_DECLARE_NONSTD(void) switch_regex_set_var_callback(const char *var, const char *val, void *user_data);
77 SWITCH_DECLARE_NONSTD(void) switch_regex_set_event_header_callback(const char *var, const char *val, void *user_data);
78 
79 #define switch_regex_safe_free(re) if (re) {\
80  switch_regex_free(re);\
81  re = NULL;\
82  }
83 
84 
85 /** @} */
86 
88 #endif
89 /* For Emacs:
90  * Local Variables:
91  * mode:c
92  * indent-tabs-mode:t
93  * tab-width:4
94  * c-basic-offset:4
95  * End:
96  * For VIM:
97  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
98  */
int switch_regex_copy_substring(const char *subject, int *ovector, int stringcount, int stringnumber, char *buffer, int size)
Definition: switch_regex.c:44
void switch_perform_substitution(switch_regex_t *re, int match_count, const char *data, const char *field_data, char *substituted, switch_size_t len, int *ovector)
Definition: switch_regex.c:131
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
struct real_pcre switch_regex_t
Definition: switch_regex.h:43
switch_status_t switch_regex_match_partial(const char *target, const char *expression, int *partial_match)
Function to evaluate an expression against a string.
Definition: switch_regex.c:215
uintptr_t switch_size_t
int switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen)
Definition: switch_regex.c:55
#define SWITCH_DECLARE_NONSTD(type)
void switch_capture_regex(switch_regex_t *re, int match_count, const char *field_data, int *ovector, const char *var, switch_cap_callback_t callback, void *user_data)
Definition: switch_regex.c:196
switch_status_t
Common return values.
void switch_regex_set_var_callback(const char *var, const char *val, void *user_data)
Definition: switch_regex.c:306
const cJSON *const target
void(* switch_cap_callback_t)(const char *var, const char *val, void *user_data)
#define SWITCH_DECLARE(type)
char * buffer
Definition: switch_cJSON.h:153
switch_regex_t * switch_regex_compile(const char *pattern, int options, const char **errorptr, int *erroroffset, const unsigned char *tables)
Definition: switch_regex.c:36
void switch_regex_set_event_header_callback(const char *var, const char *val, void *user_data)
Definition: switch_regex.c:313
switch_status_t switch_regex_match(const char *target, const char *expression)
Function to evaluate an expression against a string.
Definition: switch_regex.c:300
void switch_regex_free(void *data)
Definition: switch_regex.c:49
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42