Module: sip-router
Branch: master
Commit: feef2d2e0bdbc5232138e0308e8e1cd9daf0a4ab
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=feef2d2…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 16 16:54:44 2009 +0100
Include dlfcn.h for RTLD_NOW and friends.
There is a test in sr_module.h which tests whether the macro RTLD_NOW is
defined and defines it to DL_LAZY if not. The header file did not include
dlfcn.h which defines the macro RTLD_NOW, so as a result it was always
re-defined to DL_LAZY.
---
sr_module.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/sr_module.h b/sr_module.h
index 0078f25..bdf64de 100644
--- a/sr_module.h
+++ b/sr_module.h
@@ -58,6 +58,8 @@
#ifndef sr_module_h
#define sr_module_h
+#include <dlfcn.h>
+
#include "parser/msg_parser.h" /* for sip_msg */
#include "version.h"
#include "rpc.h"
Module: sip-router
Branch: janakj/kcore
Commit: 301e4abff0ac546969eaa6b26b97574883fcba08
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=301e4ab…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 16 15:23:26 2009 +0100
Adding files regexp.[ch] from kamailio core
---
lib/kcore/regexp.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/kcore/regexp.h | 41 +++++++++++++++++
2 files changed, 163 insertions(+), 0 deletions(-)
diff --git a/lib/kcore/regexp.c b/lib/kcore/regexp.c
new file mode 100644
index 0000000..da724ca
--- /dev/null
+++ b/lib/kcore/regexp.c
@@ -0,0 +1,122 @@
+/*
+ * $Id$
+ *
+ * Regular expression functions
+ *
+ * Copyright (C) 2003 Juha Heinanen
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/*!
+ * \file
+ * \brief Regular Expression functions
+ */
+
+#include <sys/types.h>
+#include <string.h>
+#include <regex.h>
+#include <ctype.h>
+#include "regexp.h"
+#include "dprint.h"
+
+/*! \brief Replace in replacement tokens \\d with substrings of string pointed by
+ * pmatch.
+ */
+int replace(regmatch_t* pmatch, char* string, char* replacement, str* result)
+{
+ int len, i, j, digit, size;
+
+ len = strlen(replacement);
+ j = 0;
+
+ for (i = 0; i < len; i++) {
+ if (replacement[i] == '\\') {
+ if (i < len - 1) {
+ if (isdigit((unsigned char)replacement[i+1])) {
+ digit = replacement[i+1] - '0';
+ if (pmatch[digit].rm_so != -1) {
+ size = pmatch[digit].rm_eo - pmatch[digit].rm_so;
+ if (j + size < result->len) {
+ memcpy(&(result->s[j]), string+pmatch[digit].rm_so, size);
+ j = j + size;
+ } else {
+ return -1;
+ }
+ } else {
+ return -2;
+ }
+ i = i + 1;
+ continue;
+ } else {
+ i = i + 1;
+ }
+ } else {
+ return -3;
+ }
+ }
+ if (j + 1 < result->len) {
+ result->s[j] = replacement[i];
+ j = j + 1;
+ } else {
+ return -4;
+ }
+ }
+ result->len = j;
+ return 1;
+}
+
+
+/*! \brief Match pattern against string and store result in pmatch */
+int reg_match(char *pattern, char *string, regmatch_t *pmatch)
+{
+ regex_t preg;
+
+ if (regcomp(&preg, pattern, REG_EXTENDED | REG_NEWLINE)) {
+ return -1;
+ }
+ if (preg.re_nsub > MAX_MATCH) {
+ regfree(&preg);
+ return -2;
+ }
+ if (regexec(&preg, string, MAX_MATCH, pmatch, 0)) {
+ regfree(&preg);
+ return -3;
+ }
+ regfree(&preg);
+ return 0;
+}
+
+
+/*! \brief Match pattern against string and, if match succeeds, and replace string
+ * with replacement substituting tokens \\d with matched substrings.
+ */
+int reg_replace(char *pattern, char *replacement, char *string, str *result)
+{
+ regmatch_t pmatch[MAX_MATCH];
+
+ LM_DBG("pattern: '%s', replacement: '%s', string: '%s'\n",
+ pattern, replacement, string);
+
+ if (reg_match(pattern, string, &(pmatch[0]))) {
+ return -1;
+ }
+
+ return replace(&pmatch[0], string, replacement, result);
+
+}
diff --git a/lib/kcore/regexp.h b/lib/kcore/regexp.h
new file mode 100644
index 0000000..e63ed60
--- /dev/null
+++ b/lib/kcore/regexp.h
@@ -0,0 +1,41 @@
+/*
+ * $Id$
+ *
+ * Regular expression definitions
+ *
+ * Copyright (C) 2003 Juha Heinanen
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/*!
+ * \file
+ * \brief Regular expression definitions
+ */
+
+
+#ifndef REGEXP_H
+#define REGEXP_H
+
+#include "str.h"
+
+#define MAX_MATCH 6
+
+extern int reg_replace(char *pattern, char *replacement, char *string, str *result);
+
+#endif
Module: sip-router
Branch: master
Commit: 5a68f95d1068617c2cbd324b56a0f5632db1a70c
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5a68f95…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 16 14:46:51 2009 +0100
Kamailio compatiblity: function to set/get all branch flags
---
dset.c | 19 +++++++++++++++++++
dset.h | 22 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/dset.c b/dset.c
index 8c0a555..cbc636b 100644
--- a/dset.c
+++ b/dset.c
@@ -126,6 +126,25 @@ int resetbflag(unsigned int branch, flag_t flag)
}
+int getbflags(flag_t* res, unsigned int branch)
+{
+ flag_t* flags;
+ if (res == NULL) return -1;
+ if ((flags = get_bflags_ptr(branch)) == NULL) return -1;
+ *res = *flags;
+ return 1;
+}
+
+
+int setbflagsval(unsigned int branch, flag_t val)
+{
+ flag_t* flags;
+ if ((flags = get_bflags_ptr(branch)) == NULL) return -1;
+ *flags = val;
+ return 1;
+}
+
+
/*
* Initialize the branch iterator, the next
* call to next_branch will return the first
diff --git a/dset.h b/dset.h
index 36ffaff..e350238 100644
--- a/dset.h
+++ b/dset.h
@@ -121,4 +121,26 @@ int resetbflag(unsigned int branch, flag_t flag);
*/
int isbflagset(unsigned int branch, flag_t flag);
+/**
+ * Get the value of all branch flags for a branch
+ *
+ * This function returns the value of all branch flags
+ * combined in a single variable.
+ * @param res A pointer to a variable to store the result
+ * @param branch Number of the branch (0 for the main Request-URI branch)
+ * @return 1 on success, -1 on failure
+ */
+int getbflags(flag_t* res, unsigned int branch);
+
+/**
+ * Set the value of all branch flags at once for a given branch.
+ *
+ * This function sets the value of all branch flags for a given
+ * branch at once.
+ * @param branch Number of the branch (0 for the main Request-URI branch)
+ * @param val All branch flags combined into a single variable
+ * @return 1 on success, -1 on failure
+ */
+int setbflagsval(unsigned int branch, flag_t val);
+
#endif /* _DSET_H */
Module: sip-router
Branch: janakj/kcore
Commit: 1e7d236d330626eb6d564cd8dab5a5c40cea8458
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1e7d236…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Sun Mar 15 17:51:58 2009 +0100
Merge branch 'sr' into kcore
* sr: (33 commits)
Kamailio compatiblity: Function get_diversion_param
Kamailio compatibility: function reset_dst_uri
Support for P-Preferred-Identity and P-Asserted-Identity in the core.
Export parse_phostport function to modules.
Functions to set/reset/test per-branch flags.
Added missing hash_func.h header
MDString Array was renamed to MD5StringArray
Kamailio compatibility: Rename MDStringArray to MD5StringArray
timers: helpers for forking separate timer procs
Export get_sock_info_list function to modules
K. compatibility members of the branch structure in dset.c
Few kamailio compatiblity macros
destroy_avps kamailio compatiblity function.
Remove function replace_len which is no longer needed.
Kamailio compatibility changes: replace_build
Importing kamailio fixes into the sip-router version of re.c
Use parse_repl from within subst_parser function.
Kamailio compatiblity changes: REPLACE_BUFFER_SIZE
Kamailio compatibility: parse_repl
Kamailio compatibility declarations
...
---