re.c File Reference

Regexp and regexp substitutions implementations. More...

#include "dprint.h"
#include "mem/mem.h"
#include "re.h"
#include <string.h>

Include dependency graph for re.c:

Go to the source code of this file.

Defines

#define MAX_REPLACE_WITH   100
#define REPLACE_BUFFER_SIZE   1024

Functions

int parse_repl (struct replace_with *rw, char **begin, char *end, int *max_token_nb, int with_sep)
static int replace_build (const char *match, int nmatch, regmatch_t *pmatch, struct subst_expr *se, struct sip_msg *msg, str *rpl)
 Replies will be allocated with the proper size & rpl.len set.
void replace_lst_free (struct replace_lst *l)
 frees the entire list, head (l) too
void subst_expr_free (struct subst_expr *se)
struct subst_exprsubst_parser (str *subst)
 Parse a /regular expression/replacement/flags into a subst_expr structure.
struct replace_lstsubst_run (struct subst_expr *se, const char *input, struct sip_msg *msg, int *count)
 run substitutions
strsubst_str (const char *input, struct sip_msg *msg, struct subst_expr *se, int *count)


Detailed Description

Regexp and regexp substitutions implementations.

Definition in file re.c.


Define Documentation

#define MAX_REPLACE_WITH   100

Definition at line 69 of file re.c.

Referenced by build_rule(), parse_repl(), and rule_translate().

#define REPLACE_BUFFER_SIZE   1024

Referenced by replace_build().


Function Documentation

int parse_repl ( struct replace_with rw,
char **  begin,
char *  end,
int *  max_token_nb,
int  with_sep 
)

static int replace_build ( const char *  match,
int  nmatch,
regmatch_t *  pmatch,
struct subst_expr se,
struct sip_msg msg,
str rpl 
) [static]

void replace_lst_free ( struct replace_lst l  ) 

frees the entire list, head (l) too

Definition at line 57 of file re.c.

References replace_lst::next, pkg_free, replace_lst::rpl, and _str::s.

Referenced by subst_body_f(), subst_f(), subst_run(), and subst_str().

void subst_expr_free ( struct subst_expr se  ) 

Definition at line 47 of file re.c.

References pkg_free, subst_expr::re, subst_expr::replacement, and _str::s.

Referenced by subst_parser(), and tr_txt_parse_re().

struct subst_expr* subst_parser ( str subst  )  [read]

Parse a /regular expression/replacement/flags into a subst_expr structure.

Definition at line 207 of file re.c.

References _str::len, LM_DBG, LM_ERR, subst_expr::max_pmatch, parse_repl(), pkg_free, pkg_malloc, subst_expr::re, _str::s, subst_expr_free(), and WITH_SEP.

Referenced by fixup_subst(), fixup_substre(), ldap_result_check_fixup(), ldap_result_fixup(), and tr_txt_parse_re().

struct replace_lst* subst_run ( struct subst_expr se,
const char *  input,
struct sip_msg msg,
int *  count 
) [read]

run substitutions

Returns:
0 if no match or error, or subst result; if count!=0 it will be set to 0 (no match), the number of matches or -1 (error).
Note:
WARNING: input must be 0 terminated!

Definition at line 500 of file re.c.

References LM_DBG, LM_ERR, subst_expr::max_pmatch, pkg_free, pkg_malloc, subst_expr::re, subst_expr::replace_all, replace_build(), and replace_lst_free().

Referenced by subst_body_f(), subst_f(), and subst_str().

str* subst_str ( const char *  input,
struct sip_msg msg,
struct subst_expr se,
int *  count 
)

Returns:
the substitution result in a str, input must be 0 term 0 on no match or malloc error if count is non zero it will be set to the number of matches, or -1 if error

Definition at line 583 of file re.c.

References _str::len, LM_DBG, LM_ERR, replace_lst::next, replace_lst::offset, pkg_free, pkg_malloc, replace_lst_free(), replace_lst::rpl, _str::s, replace_lst::size, and subst_run().

Referenced by ldap_result_check(), ldap_write_result(), ops_subst(), subst_uri_f(), subst_user_f(), and tr_txt_eval_re().


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