regex_mod.c File Reference

REGEX :: Perl-compatible regular expressions using PCRE library Copyright (C) 2008 Iñaki Baz Castillo. More...

#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"

Include dependency graph for regex_mod.c:

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_rootmi_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


Detailed Description

REGEX :: Perl-compatible regular expressions using PCRE library Copyright (C) 2008 Iñaki Baz Castillo.

Definition in file regex_mod.c.


Define Documentation

#define FILE_MAX_LINE   500

Max line size in the file

Definition at line 56 of file regex_mod.c.

Referenced by load_pcres().

#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

Definition at line 54 of file regex_mod.c.

Referenced by load_pcres(), and mi_pcres_reload().

#define START   0

Definition at line 53 of file regex_mod.c.

Referenced by load_pcres(), and mod_init().


Function Documentation

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().

static struct mi_root * mi_pcres_reload ( struct mi_root cmd,
void *  param 
) [static, read]

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]

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.


Variable Documentation

cmd_export_t cmds[] [static]

Definition at line 118 of file regex_mod.c.

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]

Definition at line 72 of file regex_mod.c.

Referenced by load_pcres().

int max_groups = MAX_GROUPS [static]

Definition at line 71 of file regex_mod.c.

Referenced by load_pcres().

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]

Definition at line 73 of file regex_mod.c.

Referenced by mod_init().

int pcre_dotall = 0 [static]

Definition at line 75 of file regex_mod.c.

Referenced by mod_init().

int pcre_extended = 0 [static]

Definition at line 76 of file regex_mod.c.

Referenced by mod_init().

int pcre_multiline = 0 [static]

Definition at line 74 of file regex_mod.c.

Referenced by mod_init().

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]

Definition at line 82 of file regex_mod.c.

Referenced by free_shared_memory(), and load_pcres().

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.


Generated on Thu May 24 10:00:42 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6