Hi list,

attached are the missing regex-features (e.g. the issues Alex mentioned).
What is new:
* replaced regex_t with new gw_regex_t
* all regex.h functions are mapped to a panic on systems w/o regex libraries
* at compile-time a warning is issued if the libraries are missing.
(gwlib/regex.c:358:2: warning: #warning "Using regular expressions although regex-libraries are missing! May result in a PANIC at runtime!")


This means: if the regex-libraries are missing and regex-parameters are used then Kannel will die at runtime!
I have tested the patch, but please review it nevertheless.


Best regards,
David

Alexander Malysh wrote:

patch commited to cvs.
Known issue: kannel doesn't build on systems with missing 'regexp.h'.
(imo) all modern systems has 'regexp.h' support.

David is working on this issue...

Thanks a lot to David!

On Tuesday 20 January 2004 16:07, David Schmitz wrote:


Hi,

attached is a patch implementing some new configuration parameters based
on POSIX regular expressions. All new parameters can be used in parallel
with the non-regex-parameters. More elaborate documentation is included
in the userdoc-part of the patch.

Awaiting votes and comments, please.

Regards,
David

PS:
Modified files:
gwlib/cfg.def
gwlib/regex.[ch]
gw/wap_push_ppg_pushuser.c
gw/urltrans.[ch]
gw/smscconn.c
gw/smsbox.c
gw/bb_smscconn.c
gw/smscconn_p.h
doc/userguide/userguide.xml

The following params are new:
Group: core
white-list-regex
black-list-regex
----
Group: wap-push-user
allowed-prefix-regex
denied-prefix-regex
white-list-regex
black-list-regex
----
Group: smsbox
white-list-regex
black-list-regex
----
Group: smsc
allowed-smsc-id-regex
denied-smsc-id-regex
preferred-smsc-id-regex
allowed-prefix-regex
denied-prefix-regex
preferred-prefix-regex
----
Group: sms-service
accepted-smsc-regex
allowed-prefix-regex
denied-prefix-regex
allowed-receiver-prefix-regex
denied-receiver-prefix-regex
white-list-regex
black-list-regex
keyword-regex
----
Group: sendsms-user
allowed-prefix-regex
denied-prefix-regex
white-list-regex
black-list-regex







--

Mit freundlichen Gruessen/Best regards

David Schmitz
Softwareentwicklung

-----------------------------------------------------------------
Wapme Systems AG
Vogelsanger Weg 80
40470 D�sseldorf

Tel.:  + 49 -211-7 48 45 - 2708
Fax:  + 49 -211-80-6-06-2801

E-Mail:   [EMAIL PROTECTED]
Internet: http://www.wapme-systems.de

Index: gw/bb_smscconn.c
===================================================================
RCS file: /home/cvs/gateway/gw/bb_smscconn.c,v
retrieving revision 1.72
diff -u -b -B -r1.72 bb_smscconn.c
--- gw/bb_smscconn.c    23 Jan 2004 14:56:06 -0000      1.72
+++ gw/bb_smscconn.c    28 Jan 2004 10:55:39 -0000
@@ -113,8 +113,8 @@
 static Numhash *black_list;
 static Numhash *white_list;
 
-static regex_t *white_list_regex = NULL;
-static regex_t *black_list_regex = NULL;
+static gw_regex_t *white_list_regex = NULL;
+static gw_regex_t *black_list_regex = NULL;
 
 static long router_thread = -1;
 
@@ -271,7 +271,7 @@
         bb_alog_sms(conn, sms, "REJECTED - not white-regex-listed SMS");
         msg_destroy(sms);
         return SMSCCONN_FAILED_REJECTED;
-    }
+    };
     
     if (black_list &&
        numhash_find_number(black_list, sms->sms.sender) == 1) {
@@ -288,7 +288,7 @@
         bb_alog_sms(conn, sms, "REJECTED - black-regex-listed SMS");
         msg_destroy(sms);
         return SMSCCONN_FAILED_REJECTED;
-    }
+    };
 
     if (sms->sms.sms_type != report_mo)
        sms->sms.sms_type = mo;
@@ -451,6 +451,11 @@
             panic(0, "Could not compile pattern '%s'", octstr_get_cstr(os));
         octstr_destroy(os);
     }
+    if ((os = cfg_get(grp, octstr_imm("black-list-regex"))) != NULL) {
+        if ((black_list_regex = gw_regex_comp(os, REG_EXTENDED)) == NULL)
+            panic(0, "Could not compile pattern '%s'", octstr_get_cstr(os));
+        octstr_destroy(os);
+    }
 
     smsc_groups = cfg_get_multi_group(cfg, octstr_imm("smsc"));
     /*
Index: gw/smsbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsbox.c,v
retrieving revision 1.244
diff -u -b -B -r1.244 smsbox.c
--- gw/smsbox.c 23 Jan 2004 14:56:06 -0000      1.244
+++ gw/smsbox.c 28 Jan 2004 10:55:40 -0000
@@ -125,8 +125,8 @@
 static int mo_recode = 0;
 static Numhash *white_list;
 static Numhash *black_list;
-static regex_t *white_list_regex = NULL;
-static regex_t *black_list_regex = NULL;
+static gw_regex_t *white_list_regex = NULL;
+static gw_regex_t *black_list_regex = NULL;
 static unsigned long max_http_retries = HTTP_MAX_RETRIES;
 static unsigned long http_queue_delay = HTTP_RETRY_DELAY;
 static Octstr *ppg_service_name = NULL;
Index: gw/smscconn.c
===================================================================
RCS file: /home/cvs/gateway/gw/smscconn.c,v
retrieving revision 1.44
diff -u -b -B -r1.44 smscconn.c
--- gw/smscconn.c       23 Jan 2004 14:56:06 -0000      1.44
+++ gw/smscconn.c       28 Jan 2004 10:55:40 -0000
@@ -221,6 +221,27 @@
         if ((conn->preferred_prefix_regex = gw_regex_comp(preferred_prefix_regex, 
REG_EXTENDED)) == NULL)
             panic(0, "Could not compile pattern '%s'", 
octstr_get_cstr(preferred_prefix_regex));
              
+    GET_OPTIONAL_VAL(allowed_smsc_id_regex, "allowed-smsc-id-regex");
+    if (allowed_smsc_id_regex != NULL) 
+        if ((conn->allowed_smsc_id_regex = gw_regex_comp(allowed_smsc_id_regex, 
REG_EXTENDED)) == NULL)
+            panic(0, "Could not compile pattern '%s'", 
octstr_get_cstr(allowed_smsc_id_regex));
+    GET_OPTIONAL_VAL(denied_smsc_id_regex, "denied-smsc-id-regex");
+    if (denied_smsc_id_regex != NULL) 
+        if ((conn->denied_smsc_id_regex = gw_regex_comp(denied_smsc_id_regex, 
REG_EXTENDED)) == NULL)
+            panic(0, "Could not compile pattern '%s'", 
octstr_get_cstr(denied_smsc_id_regex));
+    GET_OPTIONAL_VAL(allowed_prefix_regex, "allowed-prefix-regex");
+    if (allowed_prefix_regex != NULL) 
+        if ((conn->allowed_prefix_regex = gw_regex_comp(allowed_prefix_regex, 
REG_EXTENDED)) == NULL)
+            panic(0, "Could not compile pattern '%s'", 
octstr_get_cstr(allowed_prefix_regex));
+    GET_OPTIONAL_VAL(denied_prefix_regex, "denied-prefix-regex");
+    if (denied_prefix_regex != NULL) 
+        if ((conn->denied_prefix_regex = gw_regex_comp(denied_prefix_regex, 
REG_EXTENDED)) == NULL)
+            panic(0, "Could not compile pattern '%s'", 
octstr_get_cstr(denied_prefix_regex));
+    GET_OPTIONAL_VAL(preferred_prefix_regex, "preferred-prefix-regex");
+    if (preferred_prefix_regex != NULL) 
+        if ((conn->preferred_prefix_regex = gw_regex_comp(preferred_prefix_regex, 
REG_EXTENDED)) == NULL)
+            panic(0, "Could not compile pattern '%s'", 
octstr_get_cstr(preferred_prefix_regex));
+             
     if (cfg_get_integer(&throughput, grp, octstr_imm("throughput")) == -1)
         conn->throughput = 0;   /* defaults to no throughtput limitation */
     else 
@@ -447,6 +468,18 @@
     else if (conn->denied_smsc_id_regex && msg->sms.smsc_id != NULL) {
         if (gw_regex_matches(conn->denied_smsc_id_regex, msg->sms.smsc_id) == MATCH) 
             return -1;
+    };
+
+    if (conn->allowed_smsc_id_regex) {
+        if (msg->sms.smsc_id == NULL)
+            return -1;
+        
+        if (gw_regex_matches(conn->allowed_smsc_id_regex, msg->sms.smsc_id) == 
NO_MATCH) 
+            return -1;
+    }
+    else if (conn->denied_smsc_id_regex && msg->sms.smsc_id != NULL) {
+        if (gw_regex_matches(conn->denied_smsc_id_regex, msg->sms.smsc_id) == MATCH) 
+            return -1;
     }
 
     /* Have allowed */
@@ -459,6 +492,11 @@
             return -1;
     }
 
+    if (conn->allowed_prefix_regex && ! conn->denied_prefix_regex) {
+        if (gw_regex_matches(conn->allowed_prefix_regex, msg->sms.receiver) == 
NO_MATCH)
+            return -1;
+    }
+
     /* Have denied */
     if (conn->denied_prefix && ! conn->allowed_prefix &&
        (does_prefix_match(conn->denied_prefix, msg->sms.receiver) == 1))
@@ -469,6 +507,11 @@
             return -1;
     }
 
+    if (conn->denied_prefix_regex && ! conn->allowed_prefix_regex) {
+        if (gw_regex_matches(conn->denied_prefix_regex, msg->sms.receiver) == MATCH)
+            return -1;
+    }
+
     /* Have allowed and denied */
     if (conn->denied_prefix && conn->allowed_prefix &&
        (does_prefix_match(conn->allowed_prefix, msg->sms.receiver) != 1) &&
@@ -498,7 +541,7 @@
     if (conn->preferred_prefix_regex) {
         if (gw_regex_matches(conn->preferred_prefix_regex, msg->sms.receiver) == 
MATCH)
             return 1;
-    }
+    };
         
     return 0;
 }
Index: gw/urltrans.c
===================================================================
RCS file: /home/cvs/gateway/gw/urltrans.c,v
retrieving revision 1.92
diff -u -b -B -r1.92 urltrans.c
--- gw/urltrans.c       23 Jan 2004 14:56:06 -0000      1.92
+++ gw/urltrans.c       28 Jan 2004 10:55:40 -0000
@@ -128,14 +128,14 @@
     int catch_all;
     Octstr *dlr_url;   /* Url to call for delivery reports */
 
-    regex_t *keyword_regex;       /* the compiled regular expression for the keyword*/
-    regex_t *accepted_smsc_regex;
-    regex_t *allowed_prefix_regex;
-    regex_t *denied_prefix_regex;
-    regex_t *allowed_receiver_prefix_regex;
-    regex_t *denied_receiver_prefix_regex;
-    regex_t *white_list_regex;
-    regex_t *black_list_regex;
+    gw_regex_t *keyword_regex;       /* the compiled regular expression for the 
keyword*/
+    gw_regex_t *accepted_smsc_regex;
+    gw_regex_t *allowed_prefix_regex;
+    gw_regex_t *denied_prefix_regex;
+    gw_regex_t *allowed_receiver_prefix_regex;
+    gw_regex_t *denied_receiver_prefix_regex;
+    gw_regex_t *white_list_regex;
+    gw_regex_t *black_list_regex;
 };
 
 
@@ -791,7 +791,7 @@
     return t->white_list;
 }
 
-regex_t *urltrans_white_list_regex(URLTranslation *t)
+gw_regex_t *urltrans_white_list_regex(URLTranslation *t)
 {
     return t->white_list_regex;
 }
@@ -801,7 +801,7 @@
     return t->black_list;
 }
 
-regex_t *urltrans_black_list_regex(URLTranslation *t)
+gw_regex_t *urltrans_black_list_regex(URLTranslation *t)
 {
     return t->black_list_regex;
 }
Index: gw/wap_push_ppg_pushuser.c
===================================================================
RCS file: /home/cvs/gateway/gw/wap_push_ppg_pushuser.c,v
retrieving revision 1.18
diff -u -b -B -r1.18 wap_push_ppg_pushuser.c
--- gw/wap_push_ppg_pushuser.c  23 Jan 2004 15:10:09 -0000      1.18
+++ gw/wap_push_ppg_pushuser.c  28 Jan 2004 10:55:40 -0000
@@ -78,16 +78,16 @@
     Octstr *country_prefix;
     Octstr *allowed_prefix;            /* phone number prefixes allowed by 
                                           this user when pushing*/
-    regex_t *allowed_prefix_regex;
+    gw_regex_t *allowed_prefix_regex;
     
     Octstr *denied_prefix;             /* and denied ones */
-    regex_t *denied_prefix_regex;
+    gw_regex_t *denied_prefix_regex;
 
     Numhash *white_list;               /* phone numbers of this user, used for 
                                           push*/
-    regex_t *white_list_regex;
+    gw_regex_t *white_list_regex;
     Numhash *black_list;               /* numbers should not be used for push*/
-    regex_t *black_list_regex;
+    gw_regex_t *black_list_regex;
 
     Octstr *user_deny_ip;              /* this user allows pushes from these 
                                           IPs*/
Index: gw/smscconn_p.h
===================================================================
RCS file: /home/cvs/gateway/gw/smscconn_p.h,v
retrieving revision 1.43
diff -u -b -B -r1.43 smscconn_p.h
--- gw/smscconn_p.h     23 Jan 2004 14:56:06 -0000      1.43
+++ gw/smscconn_p.h     28 Jan 2004 10:55:40 -0000
@@ -169,18 +169,18 @@
     Octstr *id;                        /* Abstract name specified in configuration and
                                   used for logging and routing */
     Octstr *allowed_smsc_id;
-    regex_t *allowed_smsc_id_regex;
+    gw_regex_t *allowed_smsc_id_regex;
     Octstr *denied_smsc_id;
-    regex_t *denied_smsc_id_regex;
+    gw_regex_t *denied_smsc_id_regex;
     Octstr *preferred_smsc_id;
-    regex_t *preferred_smsc_id_regex;
+    gw_regex_t *preferred_smsc_id_regex;
 
     Octstr *allowed_prefix;
-    regex_t *allowed_prefix_regex;
+    gw_regex_t *allowed_prefix_regex;
     Octstr *denied_prefix;
-    regex_t *denied_prefix_regex;
+    gw_regex_t *denied_prefix_regex;
     Octstr *preferred_prefix;
-    regex_t *preferred_prefix_regex;
+    gw_regex_t *preferred_prefix_regex;
     Octstr *unified_prefix;
     
     Octstr *our_host;   /* local device IP to bind for TCP communication */
Index: gwlib/regex.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/regex.c,v
retrieving revision 1.7
diff -u -b -B -r1.7 regex.c
--- gwlib/regex.c       23 Jan 2004 14:56:06 -0000      1.7
+++ gwlib/regex.c       28 Jan 2004 10:55:40 -0000
@@ -83,7 +83,7 @@
  * Generic regular expression functions.
  */
 
-void gw_regex_destroy(regex_t *preg)
+void gw_regex_destroy(gw_regex_t *preg)
 {
     gw_assert(preg != NULL);
 
@@ -91,13 +91,13 @@
 }
 
 
-regex_t *gw_regex_comp_real(const Octstr *pattern, int cflags, const char *file, 
+gw_regex_t *gw_regex_comp_real(const Octstr *pattern, int cflags, const char *file, 
                             long line, const char *func)
 {
     int rc;
-    regex_t *preg;
+    gw_regex_t *preg;
     
-    preg = gw_malloc(sizeof(regex_t));
+    preg = gw_malloc(sizeof(gw_regex_t));
 
     if ((rc = regcomp(preg, pattern ? octstr_get_cstr(pattern) : NULL, cflags)) != 0) 
{
         char buffer[512];
@@ -112,7 +112,7 @@
 }
 
 
-int gw_regex_exec_real(const regex_t *preg, const Octstr *string, size_t nmatch, 
+int gw_regex_exec_real(const gw_regex_t *preg, const Octstr *string, size_t nmatch, 
                        regmatch_t pmatch[], int eflags, const char *file, long line, 
                        const char *func)
 {
@@ -133,7 +131,7 @@
 }
 
 
-Octstr *gw_regex_error(int errcode, const regex_t *preg)
+Octstr *gw_regex_error(int errcode, const gw_regex_t *preg)
 {
     char errbuf[512];
     Octstr *os;
@@ -163,7 +161,7 @@
 /* This function substitutes for $0-$9, filling in regular expression
  * submatches. Pass it the same nmatch and pmatch arguments that you
  * passed gw_regexec(). pmatch should not be greater than the maximum number
- * of subexpressions - i.e. one more than the re_nsub member of regex_t.
+ * of subexpressions - i.e. one more than the re_nsub member of gw_regex_t.
  *
  * input should be the string with the $-expressions, source should be the
  * string that was matched against.
@@ -248,7 +246,7 @@
 int gw_regex_match_real(const Octstr *re, const Octstr *os, const char *file, 
                         long line, const char *func)
 {
-    regex_t *regexp;
+    gw_regex_t *regexp;
     int rc;
 
     /* compile */
@@ -265,7 +263,7 @@
 }
 
 
-int gw_regex_match_pre_real(const regex_t *preg, const Octstr *os, const char *file, 
+int gw_regex_match_pre_real(const gw_regex_t *preg, const Octstr *os, const char 
*file, 
                             long line, const char *func)
 {
     int rc;
@@ -283,7 +281,7 @@
                             const char *file, long line, const char *func)
 {
     Octstr *result;
-    regex_t *regexp;
+    gw_regex_t *regexp;
     regmatch_t pmatch[REGEX_MAX_SUB_MATCH];
     int rc;
     char *rsub;
@@ -314,7 +312,7 @@
 }
 
 
-Octstr *gw_regex_subst_pre_real(const regex_t *preg, const Octstr *os, const Octstr 
*rule, 
+Octstr *gw_regex_subst_pre_real(const gw_regex_t *preg, const Octstr *os, const 
Octstr *rule, 
                                 const char *file, long line, const char *func)
 {
     Octstr *result;
@@ -343,16 +341,26 @@
     return result;
 }
 
-int gw_regex_matches(const regex_t *preg, const Octstr *os) {
+int gw_regex_matches(const gw_regex_t *preg, const Octstr *os) {
     size_t n = 1;
     regmatch_t p[10];
 
     gw_assert(os != NULL && preg != NULL);
     
-    debug("", 0, "exec regex on string: %s", octstr_get_cstr(os));
     return
         (gw_regex_exec(preg, os, n, p, 0) == 0) ? MATCH : NO_MATCH;
-}
+};
 
+#else
+void* gw_regex_panic() {
+#warning "Using regular expressions although regex-libraries are missing! May result 
in a PANIC at runtime!"
+    panic(0, "Regex error! Cannot use regular expressions since regex-libraries are 
missing.");
+    return NULL;
+}
+int gw_regex_int_panic() {
+#warning "Using regular expressions although regex-libraries are missing! May result 
in a PANIC at runtime!"
+    panic(0, "Regex error! Cannot use regular expressions since regex-libraries are 
missing.");
+    return 0;
+}
 #endif  /* HAVE_REGEX || HAVE_PCRE */
 
Index: ./gw/urltrans.h
===================================================================
RCS file: /home/cvs/gateway/gw/urltrans.h,v
retrieving revision 1.31
diff -u -b -B -r1.31 urltrans.h
--- ./gw/urltrans.h     23 Jan 2004 14:56:06 -0000      1.31
+++ ./gw/urltrans.h     28 Jan 2004 10:55:40 -0000
@@ -304,8 +304,8 @@
 /* Return white and black to number list */
 Numhash *urltrans_white_list(URLTranslation *t);
 Numhash *urltrans_black_list(URLTranslation *t);
-regex_t *urltrans_white_list_regex(URLTranslation *t);
-regex_t *urltrans_black_list_regex(URLTranslation *t);
+gw_regex_t *urltrans_white_list_regex(URLTranslation *t);
+gw_regex_t *urltrans_black_list_regex(URLTranslation *t);
 
 /* Return value of true (!0) or false (0) variables */
 int urltrans_assume_plain_text(URLTranslation *t);
Index: ./gwlib/regex.h
===================================================================
RCS file: /home/cvs/gateway/gwlib/regex.h,v
retrieving revision 1.6
diff -u -b -B -r1.6 regex.h
--- ./gwlib/regex.h     23 Jan 2004 14:56:06 -0000      1.6
+++ ./gwlib/regex.h     28 Jan 2004 10:55:41 -0000
@@ -76,8 +76,23 @@
 # include <pcreposix.h>
 #endif
 
+#define gw_regex_subst(re, os, rule) \
+    gw_regex_subst_real(re, os, rule, __FILE__, __LINE__, __func__)
+#define gw_regex_comp(pattern, cflags) \
+    gw_regex_comp_real(pattern, cflags, __FILE__, __LINE__, __func__)
+#define gw_regex_exec(preg, string, nmatch, pmatch, eflags) \
+    gw_regex_exec_real(preg, string, nmatch, pmatch, eflags, \
+                       __FILE__, __LINE__, __func__)
+#define gw_regex_match(re, os) \
+    gw_regex_match_real(re, os, __FILE__, __LINE__, __func__)
+#define gw_regex_match_pre(preg, os) \
+    gw_regex_match_pre_real(preg, os, __FILE__, __LINE__, __func__)
+#define gw_regex_subst_pre(preg, os, rule) \
+    gw_regex_subst_pre_real(preg, os, rule, __FILE__, __LINE__, __func__)
+
 #if defined(HAVE_REGEX) || defined(HAVE_PCRE)
 
+#define gw_regex_t regex_t
 
 /*
  * We handle a maximum of 10 subexpression matches and 
@@ -94,7 +109,7 @@
 /*
  * Destroy a previously compiled regular expression.
  */
-void gw_regex_destroy(regex_t *preg);
+void gw_regex_destroy(gw_regex_t *preg);
 
 
 /*
@@ -102,35 +117,30 @@
  * the regular expression type as function result.
  * If the compilation fails, return NULL.
  */
-regex_t *gw_regex_comp_real(const Octstr *pattern, int cflags, const char *file, 
+gw_regex_t *gw_regex_comp_real(const Octstr *pattern, int cflags, const char *file, 
                             long line, const char *func);
-#define gw_regex_comp(pattern, cflags) \
-    gw_regex_comp_real(pattern, cflags, __FILE__, __LINE__, __func__)
 
 
 /*
  * Execute a previously compile regular expression on a given
  * string and provide the matches via nmatch and pmatch[].
  */
-int gw_regex_exec_real(const regex_t *preg, const Octstr *string, size_t nmatch, 
+int gw_regex_exec_real(const gw_regex_t *preg, const Octstr *string, size_t nmatch, 
                        regmatch_t pmatch[], int eflags, const char *file, long line, 
                        const char *func);
-#define gw_regex_exec(preg, string, nmatch, pmatch, eflags) \
-    gw_regex_exec_real(preg, string, nmatch, pmatch, eflags, \
-                       __FILE__, __LINE__, __func__)
 
 
 /*
  * Provide the error description string of an regex operation as
  * Octstr instead of a char[].
  */
-Octstr *gw_regex_error(int errcode, const regex_t *preg);
+Octstr *gw_regex_error(int errcode, const gw_regex_t *preg);
 
 
 /* This function substitutes for $0-$9, filling in regular expression
  * submatches. Pass it the same nmatch and pmatch arguments that you
  * passed gw_regexec(). pmatch should not be greater than the maximum number
- * of subexpressions - i.e. one more than the re_nsub member of regex_t.
+ * of subexpressions - i.e. one more than the re_nsub member of gw_regex_t.
  *
  * input should be the string with the $-expressions, source should be the
  * string that was matched against.
@@ -152,8 +162,6 @@
  */
 int gw_regex_match_real(const Octstr *re, const Octstr *os, const char *file, 
                         long line, const char *func);
-#define gw_regex_match(re, os) \
-    gw_regex_match_real(re, os, __FILE__, __LINE__, __func__)
 
 
 /*
@@ -161,10 +169,8 @@
  * regular expression.
  * Return 1 if the regular expression is successfully matching, 0 otherwise.
  */
-int gw_regex_match_pre_real(const regex_t *preg, const Octstr *os, const char *file, 
+int gw_regex_match_pre_real(const gw_regex_t *preg, const Octstr *os, const char 
*file, 
                             long line, const char *func);
-#define gw_regex_match_pre(preg, os) \
-    gw_regex_match_pre_real(preg, os, __FILE__, __LINE__, __func__)
 
 
 /*
@@ -178,8 +184,6 @@
  */
 Octstr *gw_regex_subst_real(const Octstr *re, const Octstr *os, const Octstr *rule, 
                             const char *file, long line, const char *func);
-#define gw_regex_subst(re, os, rule) \
-    gw_regex_subst_real(re, os, rule, __FILE__, __LINE__, __func__)
 
 /*
  * Math directly a given source string against a previously pre-compiled
@@ -187,17 +191,42 @@
  * return the substitued Octstr as result. Same as gw_regex_subst() but a 
  * pre-compiled RE is passed as first argument.
  */
-Octstr *gw_regex_subst_pre_real(const regex_t *preg, const Octstr *os, const Octstr 
*rule, 
+Octstr *gw_regex_subst_pre_real(const gw_regex_t *preg, const Octstr *os, const 
Octstr *rule, 
                                 const char *file, long line, const char *func);
-#define gw_regex_subst_pre(preg, os, rule) \
-    gw_regex_subst_pre_real(preg, os, rule, __FILE__, __LINE__, __func__)
 
 
 /*
  * checks whether or not a given Oct-string matches the regular expression.
  * returns MATCH on match otherwise NO_MATCH
  */
-int gw_regex_matches(const regex_t *preg, const Octstr *os);
+int gw_regex_matches(const gw_regex_t *preg, const Octstr *os);
+
+#else
+
+#define gw_regex_t void
+/*
+ * Empty definitions for all functions in case no regex-library was found at compile 
time.
+ * Thus if these functions are called in spite of missing libraries Kannel will panic.
+ */
+enum {
+    MATCH = 1,
+    NO_MATCH = -1
+};
+#define REG_EXTENDED 0
+#define regmatch_t void*
+
+void* gw_regex_panic();
+int gw_regex_int_panic();
+#define gw_regex_matches(preg, os) gw_regex_int_panic()
+#define gw_regex_subst_pre_real(preg, os, rule, file, line, func) gw_regex_panic()
+#define gw_regex_subst_real(re, os, rule, file, line, func) gw_regex_panic()
+#define gw_regex_match_pre_real(preg, os, file, line, func) gw_regex_int_panic()
+#define gw_regex_match_real(re, os, file, line, func) gw_regex_int_panic()
+#define gw_regex_sub(input, source, nmatch, pmatch) gw_regex_panic()
+#define gw_regex_error(errcode, preg) gw_regex_panic()
+#define gw_regex_exec_real(preg, string, nmatch, pmatch, eflags, file, line, func) 
gw_regex_int_panic()
+#define gw_regex_comp_real(pattern, cflagsm, file, line, func) gw_regex_panic()
+#define gw_regex_destroy(preg) gw_regex_panic()
 
 #endif
 #endif  /* REGEX_H */

Reply via email to