Skip to content

Commit

Permalink
use do_match wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhangui committed Oct 29, 2023
1 parent 68ad1d4 commit 43a0682
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 104 deletions.
46 changes: 25 additions & 21 deletions indimail-mta-x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,10 @@ qlx.h

qmail-inject: load qmail-inject.o headerbody.o hfield.o \
newfield.o quote.o control.o qmail.o envrules.o wildmat.o \
srs.o rcpthosts.o auto_control.o parse_env.o \
srs.o rcpthosts.o auto_control.o parse_env.o do_match.o \
variables.o set_environment.o auto_qmail.o auto_prefix.o srs.lib
./load qmail-inject headerbody.o hfield.o newfield.o \
quote.o control.o qmail.o envrules.o \
quote.o control.o qmail.o envrules.o do_match.o \
wildmat.o srs.o rcpthosts.o auto_control.o variables.o \
auto_qmail.o auto_prefix.o parse_env.o \
set_environment.o $(static_option) $(QMAILLIB) \
Expand All @@ -1089,9 +1089,13 @@ hassrs.h set_environment.h conf-srs

envrules.o: \
compile envrules.c envrules.h control.h \
qregex.h wildmat.h parse_env.h
wildmat.h parse_env.h
./compile envrules.c

do_match.o: \
compile do_match.c do_match.h wildmat.h
./compile do_match.c

parse_env.o: \
compile parse_env.c parse_env.h
./compile parse_env.c
Expand Down Expand Up @@ -1362,11 +1366,11 @@ compile mailfilter.c mailfilter.h qmulti.h qmail.h
spawn-filter: \
load spawn-filter.o variables.o report.o auto_qmail.o \
auto_prefix.o control.o wildmat.o qregex.o parse_env.o \
auto_control.o envrules.o getDomainToken.o \
auto_control.o envrules.o getDomainToken.o do_match.o \
socket.lib dns.lib
./load spawn-filter variables.o report.o auto_qmail.o \
auto_prefix.o control.o wildmat.o qregex.o auto_control.o \
getDomainToken.o envrules.o parse_env.o \
getDomainToken.o envrules.o parse_env.o do_match.o \
$(static_option) $(QMAILLIB) $(dynamic_option) \
`cat dns.lib socket.lib` -lm

Expand Down Expand Up @@ -1425,13 +1429,13 @@ qmail-direct.9 conf-sysconfdir

qmail-queue: \
load qmail-queue.o triggerpull.o fmtqfn.o get_uid.o auto_split.o \
auto_uids.o variables.o auto_prefix.o auto_qmail.o \
auto_uids.o variables.o auto_prefix.o auto_qmail.o do_match.o \
control.o auto_control.o strsalloc.o custom_error.o getqueue.o \
syncdir.o socket.lib rt.lib
syncdir.o wildmat.o socket.lib rt.lib
./load qmail-queue triggerpull.o fmtqfn.o get_uid.o auto_split.o \
auto_uids.o auto_prefix.o variables.o auto_qmail.o \
auto_uids.o auto_prefix.o variables.o auto_qmail.o do_match.o \
control.o auto_control.o strsalloc.o custom_error.o getqueue.o \
syncdir.o $(static_option) $(QMAILLIB) $(dynamic_option) \
syncdir.o wildmat.o $(static_option) $(QMAILLIB) $(dynamic_option) \
`cat socket.lib rt.lib`

qmail-queue.8: \
Expand All @@ -1446,7 +1450,7 @@ qmail-queue-clients.9 conf-prefix
> qmail-queue-clients.7

qmail-queue.o: \
compile qmail-queue.c triggerpull.h \
compile qmail-queue.c triggerpull.h do_match.h \
control.h auto_uids.h fmtqfn.h variables.h qmail.h \
qscheduler.h syncdir.h haslibrt.h auto_prefix.h \
auto_split.h conf-sync conf-qhpsi conf-ip conf-mailarch
Expand Down Expand Up @@ -1598,14 +1602,14 @@ varargs.h dossl.h hastlsa.h auto_control.h conf-tls

qmail-send: \
load qmail-send.o qsutil.o control.o newfield.o prioq.o parse_env.o \
trigger.o fmtqfn.o quote.o readsubdir.o qmail.o \
trigger.o fmtqfn.o quote.o readsubdir.o qmail.o do_match.o \
auto_qmail.o srs.o rcpthosts.o auto_control.o auto_split.o \
variables.o getDomainToken.o do_rate.o envrules.o qregex.o wildmat.o \
auto_prefix.o delivery_rate.o syncdir.o srs.lib rt.lib
./load qmail-send qsutil.o control.o newfield.o \
prioq.o trigger.o fmtqfn.o quote.o readsubdir.o \
getDomainToken.o do_rate.o wildmat.o qmail.o auto_qmail.o \
auto_split.o variables.o envrules.o srs.o \
auto_split.o variables.o envrules.o srs.o do_match.o \
delivery_rate.o rcpthosts.o auto_control.o auto_prefix.o \
syncdir.o parse_env.o $(static_option) \
-L../libsrs2-x/libsrs2/.libs `cat srs.lib` $(QMAILLIB) \
Expand Down Expand Up @@ -1659,15 +1663,15 @@ compile set_queuedir.c set_queuedir.h auto_qmail.h control.h

slowq-send: \
load slowq-send.o qsutil.o control.o newfield.o prioq.o \
trigger.o fmtqfn.o quote.o readsubdir.o qmail.o \
trigger.o fmtqfn.o quote.o readsubdir.o qmail.o do_match.o \
auto_qmail.o srs.o rcpthosts.o auto_control.o auto_split.o \
variables.o envrules.o parse_env.o qregex.o wildmat.o \
getDomainToken.o do_rate.o delivery_rate.o auto_prefix.o \
syncdir.o srs.lib
./load slowq-send qsutil.o control.o newfield.o \
prioq.o trigger.o fmtqfn.o quote.o readsubdir.o \
do_rate.o wildmat.o qmail.o auto_qmail.o auto_split.o \
variables.o envrules.o parse_env.o srs.o \
variables.o envrules.o parse_env.o srs.o do_match.o \
rcpthosts.o delivery_rate.o auto_control.o getDomainToken.o \
auto_prefix.o syncdir.o \
$(static_option) -L../libsrs2-x/libsrs2/.libs \
Expand Down Expand Up @@ -1844,7 +1848,7 @@ qmail_smtpd.so: \
smtpd.o rcpthosts.o recipients.o indimail_stub.o ip.o ipme.o \
ipalloc.o strsalloc.o control.o etrn.o atrn.o received.o \
wildmat.o qmail.o variables.o envrules.o auto_qmail.o \
bodycheck.o sqlmatch.o qcount_dir.o mail_acl.o \
bodycheck.o sqlmatch.o qcount_dir.o mail_acl.o do_match.o \
socket_ip4loopback.o socket_v6loopback.o socket_v4mappedprefix.o \
socket_v6any.o spf.o dns.o auto_uids.o qregex_sql.o srs.o \
tablematch.o greylist.o query_skt.o fn_handler.o load_mysql.o \
Expand All @@ -1857,7 +1861,7 @@ gsasl.lib mysql_config
qcount_dir.o ip.o ipme.o ipalloc.o strsalloc.o control.o \
etrn.o atrn.o received.o wildmat.o qmail.o auto_qmail.o \
variables.o envrules.o bodycheck.o spf.o dns.o srs.o \
sqlmatch.o socket_v4mappedprefix.o parse_env.o \
sqlmatch.o socket_v4mappedprefix.o parse_env.o do_match.o \
socket_ip4loopback.o socket_v6loopback.o socket_v6any.o \
mail_acl.o auto_uids.o qregex_sql.o tablematch.o greylist.o \
auto_break.o auto_control.o auto_assign.o query_skt.o fn_handler.o \
Expand All @@ -1870,7 +1874,7 @@ gsasl.lib mysql_config
smtpd.o rcpthosts.o recipients.o auto_control.o auto_assign.o \
qcount_dir.o ip.o ipme.o ipalloc.o strsalloc.o control.o etrn.o atrn.o \
received.o wildmat.o qmail.o variables.o envrules.o parse_env.o srs.o \
bodycheck.o spf.o dns.o sqlmatch.o auto_qmail.o \
bodycheck.o spf.o dns.o sqlmatch.o auto_qmail.o do_match.o \
socket_v4mappedprefix.o socket_ip4loopback.o socket_v6loopback.o \
socket_v6any.o mail_acl.o auto_uids.o qregex_sql.o tablematch.o \
greylist.o auto_break.o indimail_stub.o load_mysql.o query_skt.o \
Expand All @@ -1884,7 +1888,7 @@ qmail-smtpd: \
load qmail-smtpd.o smtpd.o rcpthosts.o recipients.o parse_env.o \
ip.o ipme.o ipalloc.o strsalloc.o control.o etrn.o atrn.o \
received.o wildmat.o qmail.o variables.o auto_control.o \
envrules.o bodycheck.o sqlmatch.o indimail_stub.o \
envrules.o bodycheck.o sqlmatch.o indimail_stub.o do_match.o \
socket_ip4loopback.o socket_v6loopback.o socket_v4mappedprefix.o \
socket_v6any.o mail_acl.o spf.o dns.o auto_uids.o auto_qmail.o \
qregex_sql.o tablematch.o greylist.o auto_assign.o qcount_dir.o \
Expand All @@ -1895,7 +1899,7 @@ tls.lib gsasl.lib srs.lib mysql_config conf-sql
ip.o ipme.o ipalloc.o strsalloc.o control.o etrn.o atrn.o \
qcount_dir.o received.o wildmat.o qmail.o variables.o \
envrules.o bodycheck.o spf.o dns.o sqlmatch.o auto_qmail.o \
socket_v4mappedprefix.o socket_ip4loopback.o \
socket_v4mappedprefix.o socket_ip4loopback.o do_match.o \
socket_v6loopback.o socket_v6any.o mail_acl.o auto_uids.o \
indimail_stub.o qregex_sql.o tablematch.o greylist.o auto_break.o \
auto_control.o auto_assign.o query_skt.o fn_handler.o \
Expand Down Expand Up @@ -3473,9 +3477,9 @@ batv.o: compile batv.c conf-batv batv.h

uacl: \
load uacl.o mail_acl.o wildmat.o control.o \
variables.o qregex.o auto_control.o
variables.o qregex.o do_match.o auto_control.o
./load uacl mail_acl.o wildmat.o control.o \
variables.o qregex.o auto_control.o $(QMAILLIB)
variables.o qregex.o do_match.o auto_control.o $(QMAILLIB)

uacl.o: \
compile uacl.c qregex.h mail_acl.h control.h \
Expand Down
1 change: 1 addition & 0 deletions indimail-mta-x/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -695,3 +695,4 @@ filterit
filterit.o
filterit_sub.o
backup.conf
do_match.o
46 changes: 46 additions & 0 deletions indimail-mta-x/do_match.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* $Id: $
*/

#include <matchregex.h>
#include <env.h>
#include "do_match.h"
#include "wildmat.h"
#include <fnmatch.h>

int
do_match(int use_regex, char *text, char *regex, char **errStr)
{
int i;

if (errStr)
*errStr = 0;
if (use_regex)
return (matchregex(text, regex, errStr));
else
if (env_get("USE_FNMATCH")) {
#ifdef FNM_CASEFOLD
i = FNM_PATHNAME|FNM_CASEFOLD;
#else
i = FNM_PATHNAME;
#endif
switch(fnmatch(regex, text, i))
{
case 0:
return (1);
case FNM_NOMATCH:
return (0);
default:
return (AM_REGEX_ERR);
}
} else
return (wildmat_internal(text, regex));
}

void
getversion_do_match_c()
{
static char *x = "$Id: $";
x = sccsidwildmath;
x++;
}
8 changes: 8 additions & 0 deletions indimail-mta-x/do_match.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* $Id: $
*/
#ifndef _DO_MATCH_H
#define _DO_MATCH_H

int do_match(int, char *, char *, char **);
#endif
1 change: 1 addition & 0 deletions indimail-mta-x/doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Release 3.0.6-1.1 Start 25/10/2023 End XX/XX/XXXX
17. filterit_sub.c, qmail-queue.c, smtpd.c, qregex.c, bug - error in regexp
treated as match
18. test-indimail-mta: added test case to test invalid regex expression
19. envrules.c, mail_acl.c, do_match.c: moved do_match to do_match.c

* Tue Oct 17 2023 18:34:04 +0000 Manvendra Bhangui <indimail-mta@indimail.org> 3.0.5-1.1%{?dist}
Release 3.0.5-1.1 Start 11/09/2023 End 17/10/2023
Expand Down
36 changes: 1 addition & 35 deletions indimail-mta-x/envrules.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,47 +65,14 @@
* Initial revision
*
*/
#include <ctype.h>
#include <fnmatch.h>
#include <error.h>
#include <stralloc.h>
#include <env.h>
#include <str.h>
#include "parse_env.h"
#include "control.h"
#include "envrules.h"
#include "qregex.h"
#include "matchregex.h"
#include "wildmat.h"

int
do_match(int use_regex, char *text, char *regex, char **errStr)
{
int i;

if (errStr)
*errStr = 0;
if (use_regex)
return (matchregex(text, regex, errStr));
else
if (env_get("USE_FNMATCH")) {
#ifdef FNM_CASEFOLD
i = FNM_PATHNAME|FNM_CASEFOLD;
#else
i = FNM_PATHNAME;
#endif
switch(fnmatch(regex, text, i))
{
case 0:
return (1);
case FNM_NOMATCH:
return (0);
default:
return (AM_REGEX_ERR);
}
} else
return (wildmat_internal(text, regex));
}
#include "do_match.h"

int
envrules(char *email, char *envrules_f, char *rulesfile, char **errStr)
Expand Down Expand Up @@ -195,6 +162,5 @@ getversion_envrules_c()
{
static char *x = "$Id: envrules.c,v 1.21 2023-01-13 12:09:25+05:30 Cprogrammer Exp mbhangui $";

x = sccsidwildmath;
x++;
}
Loading

0 comments on commit 43a0682

Please sign in to comment.