#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <pcre.h>
#include "../../sr_module.h"
#include "../../dprint.h"
#include "../../pt.h"
#include "../../mem/shm_mem.h"
#include "../../str.h"
#include "../../locking.h"
#include "../../mod_fix.h"
#include "../../mi/mi.h"

Go to the source code of this file.
Defines | |
| #define | FILE_MAX_LINE 500 |
| #define | GROUP_MAX_SIZE 8192 |
| #define | MAX_GROUPS 20 |
| #define | RELOAD 1 |
| #define | START 0 |
Functions | |
| static void | destroy (void) |
| static void | free_shared_memory (void) |
| static int | load_pcres (int action) |
| Convert the file content into regular expresions and store them in pcres. | |
| static struct mi_root * | mi_pcres_reload (struct mi_root *cmd, void *param) |
| Reload pcres by reading the file again. | |
| static int | mod_init (void) |
| Init module function. | |
| static int | w_pcre_match (struct sip_msg *_msg, char *_s1, char *_s2) |
| Return true if the argument matches the regular expression parameter. | |
| static int | w_pcre_match_group (struct sip_msg *_msg, char *_s1, char *_s2) |
| Return true if the string argument matches the pattern group parameter. | |
Variables | |
| static cmd_export_t | cmds [] |
| struct module_exports | exports |
| static char * | file |
| static int | group_max_size = GROUP_MAX_SIZE |
| static int | max_groups = MAX_GROUPS |
| static mi_export_t | mi_cmds [] |
| static int * | num_pcres |
| static param_export_t | params [] |
| static int | pcre_caseless = 0 |
| static int | pcre_dotall = 0 |
| static int | pcre_extended = 0 |
| static int | pcre_multiline = 0 |
| static int | pcre_options = 0x00000000 |
| static pcre ** | pcres |
| static pcre *** | pcres_addr |
| gen_lock_t * | reload_lock |
Definition in file regex_mod.c.
| #define FILE_MAX_LINE 500 |
| #define GROUP_MAX_SIZE 8192 |
Max size of a group
Definition at line 58 of file regex_mod.c.
| #define MAX_GROUPS 20 |
Max number of groups
Definition at line 57 of file regex_mod.c.
| #define RELOAD 1 |
| #define START 0 |
| static void destroy | ( | void | ) | [static] |
| static void free_shared_memory | ( | void | ) | [static] |
Definition at line 484 of file regex_mod.c.
References num_pcres, pcres, pcres_addr, reload_lock, and shm_free.
| static int load_pcres | ( | int | action | ) | [static] |
Convert the file content into regular expresions and store them in pcres.
Definition at line 252 of file regex_mod.c.
References file, FILE_MAX_LINE, free_shared_memory(), group_max_size, LM_ERR, LM_NOTICE, max_groups, NULL, num_pcres, pcre_options, pcres, pcres_addr, pkg_free, pkg_malloc, RELOAD, reload_lock, shm_free, shm_malloc(), and START.
Referenced by mi_pcres_reload(), and mod_init().
Reload pcres by reading the file again.
Definition at line 655 of file regex_mod.c.
References file, init_mi_tree(), LM_ERR, LM_NOTICE, load_pcres(), MI_INTERNAL_ERR_LEN, MI_INTERNAL_ERR_S, MI_OK_LEN, MI_OK_S, MI_SSTR, NULL, and RELOAD.
| static int mod_init | ( | void | ) | [static] |
Init module function.
Definition at line 177 of file regex_mod.c.
References file, free_shared_memory(), LM_CRIT, LM_DBG, LM_ERR, LM_INFO, LM_NOTICE, load_pcres(), NULL, num_pcres, pcre_caseless, pcre_dotall, pcre_extended, pcre_multiline, pcre_options, pcres_addr, reload_lock, shm_malloc(), and START.
| static int w_pcre_match | ( | struct sip_msg * | _msg, | |
| char * | _s1, | |||
| char * | _s2 | |||
| ) | [static] |
Return true if the argument matches the regular expression parameter.
Definition at line 517 of file regex_mod.c.
References fixup_get_svalue(), len, LM_DBG, LM_ERR, NULL, pcre_options, s, and _str::s.
| static int w_pcre_match_group | ( | struct sip_msg * | _msg, | |
| char * | _s1, | |||
| char * | _s2 | |||
| ) | [static] |
Return true if the string argument matches the pattern group parameter.
Definition at line 582 of file regex_mod.c.
References file, fixup_get_svalue(), len, LM_DBG, LM_ERR, NULL, num_pcres, pcres_addr, reload_lock, and s.
cmd_export_t cmds[] [static] |
Definition at line 118 of file regex_mod.c.
| struct module_exports exports |
Definition at line 157 of file regex_mod.c.
char* file [static] |
Definition at line 70 of file regex_mod.c.
int group_max_size = GROUP_MAX_SIZE [static] |
int max_groups = MAX_GROUPS [static] |
mi_export_t mi_cmds[] [static] |
Initial value:
{
{ "regex_reload", mi_pcres_reload, MI_NO_INPUT_FLAG, 0, 0 },
{ 0, 0, 0, 0 ,0 }
}
Definition at line 148 of file regex_mod.c.
int* num_pcres [static] |
Definition at line 84 of file regex_mod.c.
Referenced by free_shared_memory(), load_pcres(), mod_init(), and w_pcre_match_group().
param_export_t params[] [static] |
Definition at line 133 of file regex_mod.c.
int pcre_caseless = 0 [static] |
int pcre_dotall = 0 [static] |
int pcre_extended = 0 [static] |
int pcre_multiline = 0 [static] |
int pcre_options = 0x00000000 [static] |
Definition at line 85 of file regex_mod.c.
Referenced by load_pcres(), mod_init(), and w_pcre_match().
pcre** pcres [static] |
pcre*** pcres_addr [static] |
Definition at line 83 of file regex_mod.c.
Referenced by free_shared_memory(), load_pcres(), mod_init(), and w_pcre_match_group().
| gen_lock_t* reload_lock |
Definition at line 64 of file regex_mod.c.
1.5.6