summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2008-03-09 16:20:50 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2008-03-09 16:20:50 (GMT)
commit67f891b804218ca7b42318fadeedfeec9243a0d6 (patch) (side-by-side diff)
tree8b6b14e31236a91108865b85241b02f069a30b0e
parent14cc2f2806c7b66992ca4a41d6f8da6020931194 (diff)
downloadmailfromd-67f891b804218ca7b42318fadeedfeec9243a0d6.tar.gz
mailfromd-67f891b804218ca7b42318fadeedfeec9243a0d6.tar.bz2
Prefix all exception codes with `e_'.
* src/mfstat.awk: Look for mf_exception_code/mf_exception_count. * src/lex.l (variable_or_const): Add type cast. * src/mailfromd.h (enum mf_status_code): Retain only first four proper status codes. (enum mf_exception_code): New type. (mf_status_to_exception): New macro (mf_exception_str,string_to_exception): New functions (mf_status_str): Rewrite as macro. (string_to_stat): Remove. * src/mf-status.mfi: Prefix codes with e_ * src/status.mfi: Prefix exception codes with e_. Retain succes, not_found, failure, and temp_failure for backward compatibility. Retain old exception names if m4 symbol COMPAT_4_3 is defined. * src/gram.y, src/snarf.m4, src/bi_poll.m4, src/bi_string.m4, src/drivers.c, src/bi_dns.m4, src/bi_system.m4, src/bi_spf.m4, src/prog.c, src/bi_ipaddr.m4, src/bi_sa.m4, src/bi_io.m4, src/bi_sieve.m4, src/bi_vars.m4, src/bi_other.m4, src/bi_mail.m4, src/bi_gettext.m4, src/bi_db.m4, : Use new exception names. * configure.ac (MF_VERSION_PATCH): Set to 90 * doc/mailfromd.texi: Document changes. git-svn-id: file:///svnroot/mailfromd/branches/release_4_3_patches@1628 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ChangeLog24
-rw-r--r--configure.ac2
-rw-r--r--doc/mailfromd.texi128
-rw-r--r--src/bi_db.m422
-rw-r--r--src/bi_dns.m422
-rw-r--r--src/bi_gettext.m44
-rw-r--r--src/bi_io.m416
-rw-r--r--src/bi_ipaddr.m46
-rw-r--r--src/bi_mail.m414
-rw-r--r--src/bi_other.m414
-rw-r--r--src/bi_poll.m418
-rw-r--r--src/bi_sa.m452
-rw-r--r--src/bi_sieve.m413
-rw-r--r--src/bi_spf.m42
-rw-r--r--src/bi_string.m48
-rw-r--r--src/bi_system.m42
-rw-r--r--src/bi_vars.m42
-rw-r--r--src/drivers.c6
-rw-r--r--src/gram.y12
-rw-r--r--src/lex.l2
-rw-r--r--src/mailfromd.h54
-rw-r--r--src/mf-status.mfi12
-rw-r--r--src/mfstat.awk8
-rw-r--r--src/prog.c28
-rw-r--r--src/snarf.m42
-rw-r--r--src/status.mfi8
26 files changed, 267 insertions, 214 deletions
diff --git a/ChangeLog b/ChangeLog
index 9abbf87..66cdf70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
2008-03-09 Sergey Poznyakoff <gray@gnu.org.ua>
+ Prefix all exception codes with `e_'.
+
+ * src/mfstat.awk: Look for mf_exception_code/mf_exception_count.
+ * src/lex.l (variable_or_const): Add type cast.
+ * src/mailfromd.h (enum mf_status_code): Retain only first four proper
+ status codes.
+ (enum mf_exception_code): New type.
+ (mf_status_to_exception): New macro
+ (mf_exception_str,string_to_exception): New functions
+ (mf_status_str): Rewrite as macro.
+ (string_to_stat): Remove.
+ * src/mf-status.mfi: Prefix codes with e_
+ * src/status.mfi: Prefix exception codes with e_. Retain
+ succes, not_found, failure, and temp_failure for backward
+ compatibility.
+ Retain old exception names if m4 symbol COMPAT_4_3 is defined.
+ * src/gram.y, src/snarf.m4, src/bi_poll.m4, src/bi_string.m4,
+ src/drivers.c, src/bi_dns.m4, src/bi_system.m4, src/bi_spf.m4,
+ src/prog.c, src/bi_ipaddr.m4, src/bi_sa.m4, src/bi_io.m4,
+ src/bi_sieve.m4, src/bi_vars.m4, src/bi_other.m4, src/bi_mail.m4,
+ src/bi_gettext.m4, src/bi_db.m4, : Use new exception names.
+ * configure.ac (MF_VERSION_PATCH): Set to 90
+ * doc/mailfromd.texi: Document changes.
+
Name clashes between constants and variables went unnoticed by the
compiler. Bug reported by Thomas Lynch.
Fix this and rename exception codes to minimize chances of such
diff --git a/configure.ac b/configure.ac
index 6b55d68..c76eae4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@
AC_PREREQ(2.59)
m4_define([MF_VERSION_MAJOR], 4)
m4_define([MF_VERSION_MINOR], 3)
-m4_define([MF_VERSION_PATCH], 1)
+m4_define([MF_VERSION_PATCH], 90)
AC_INIT([mailfromd],
MF_VERSION_MAJOR.MF_VERSION_MINOR[]m4_ifdef([MF_VERSION_PATCH],.MF_VERSION_PATCH),
[bug-mailfromd@gnu.org.ua])
diff --git a/doc/mailfromd.texi b/doc/mailfromd.texi
index e4b456d..27ff4c4 100644
--- a/doc/mailfromd.texi
+++ b/doc/mailfromd.texi
@@ -133,6 +133,7 @@ Sender Address Verification.
Building the Package
+* 43x-440:: Upgrading from 4.3.x to 4.4
* 420-43x:: Upgrading from 4.2 to 4.3.x
* 410-420:: Upgrading from 4.1 to 4.2
* 400-410:: Upgrading from 4.0 to 4.1
@@ -987,6 +988,7 @@ the corresponding section below.
@end enumerate
@menu
+* 43x-440:: Upgrading from 4.3.x to 4.4
* 420-43x:: Upgrading from 4.2 to 4.3.x
* 410-420:: Upgrading from 4.1 to 4.2
* 400-410:: Upgrading from 4.0 to 4.1
@@ -996,6 +998,11 @@ the corresponding section below.
* 1x-2x:: Upgrading from 1.x to 2.x
@end menu
+@node 43x-440
+@section Upgrading from 4.3.x to 4.4
+@cindex Upgrading from 4.3.x to 4.4
+@UNREVISED{}
+
@node 420-43x
@section Upgrading from 4.2 to 4.3.x
@cindex Upgrading from 4.2 to 4.3.x
@@ -3167,7 +3174,7 @@ done
@end smallexample
Another common case are undefined Sendmail macros. In this case the
-@code{macroundef} exception is generated:
+@code{e_macroundef} exception is generated:
@smallexample
RUNTIME ERROR near foo.c:34: Macro not defined: @{client_adr@}
@@ -5386,7 +5393,7 @@ starting at @var{start}. If @var{length} is omitted, the rest of
@var{str} is used.
If @var{length} is greater than the actual length of the string, the
-@code{range} exception is signalled.
+@code{e_range} exception is signalled.
@smallexample
substr("mailfrom", 4) @result{} "from"
@@ -5520,7 +5527,7 @@ supplied arguments match their corresponding conversion specifiers.
By default, the arguments are used in the order given, where each
@samp{*} and each conversion specifier asks for the next argument. If
insufficiently many arguments are given, @code{sprintf} raises
-@samp{range} exception. One can also specify explicitly which
+@samp{e_range} exception. One can also specify explicitly which
argument is taken, at each place where an argument is required, by
writing @samp{%@var{m}$}, instead of @samp{%} and @samp{*@var{m}$}
instead of @samp{*}, where the decimal integer @var{m} denotes the
@@ -5657,7 +5664,7 @@ arguments:
@end table
If the function is unable to encode the string, it raises the
-exception @code{failure}.
+exception @code{e_failure}.
For example:
@@ -5674,7 +5681,7 @@ message_header_encode(%string, "ISO-8859-1")
(string @var{text}, [string @var{charset}])
@var{text} must be a header value encoded in accordance with @acronym{RFC}
2047. The function returns the decoded string. If the decoding fails,
-it raises @code{failure} exception. The optional argument
+it raises @code{e_failure} exception. The optional argument
@var{charset} specifies the character set to use (default --
@samp{UTF-8}).
@@ -5734,7 +5741,7 @@ using @var{domain} as @code{EHLO} domain and @var{mailfrom} as
In contrast to @code{strictpoll} function, this function does not use
cache database and does not fall back to polling @acronym{MX} servers if the
main poll tempfails. The function can throw one of the following
-exceptions: @code{failure}, @code{temp_failure}.
+exceptions: @code{e_failure}, @code{e_temp_failure}.
@end deftypefn
@deftypefn {Built-in Function} number _pollmx @
@@ -5746,7 +5753,7 @@ FROM} address. Returns 0 or 1 depending on the result of the test.
In contrast to @code{stdpoll} function, @code{_pollmx} does
not use cache database and does not fall back to polling the @var{ip}
if the poll fails. The function can throw one of the following
-exceptions: @code{failure}, @code{temp_failure}.
+exceptions: @code{e_failure}, @code{e_temp_failure}.
@end deftypefn
@deftypefn {Built-in Function} number stdpoll @
@@ -5755,7 +5762,7 @@ exceptions: @code{failure}, @code{temp_failure}.
Performs standard poll for @var{email}, using @var{domain} as
@code{EHLO} domain and @var{mailfrom} as @code{MAIL FROM} address.
Returns 0 or 1 depending on the result of the test. Can raise one of
-the following exceptions: @code{failure}, @code{temp_failure}.
+the following exceptions: @code{e_failure}, @code{e_temp_failure}.
In @code{on} statement context, it is synonymous to @code{poll}
without explicit @var{host}. @FIXME{more details and references}
@@ -5873,7 +5880,7 @@ inet_ntoa(len_to_netmask(24)) @result{} 255.255.255.0
inet_ntoa(len_to_netmask(7)) @result{} 254.0.0.0
@end smallexample
-If @var{n} is greater than 32 the function raises @code{range}
+If @var{n} is greater than 32 the function raises @code{e_range}
exception.
@end deftypefn
@@ -6031,7 +6038,7 @@ returns the fully qualified domain name of the host represented by
Sendmail variable @samp{client_addr}.
If there is no @samp{PTR} record for @var{ip}, @code{primitive_hostname}
-raises the exception @code{not_found}.
+raises the exception @code{e_not_found}.
If @acronym{DNS} query fails, the function raises @code{failure} or
@code{temp_failure}, depending on the character of the failure.
@@ -6066,7 +6073,7 @@ is a host name or @acronym{IP} address.
records for the @var{domain}.
If @var{domain} has no @samp{MX} records, @code{primitive_ismx} raises
-exception @code{not_found}.
+exception @code{e_not_found}.
If @acronym{DNS} query fails, the function raises @code{failure} or
@code{temp_failure}, depending on the character of the failure.
@@ -6090,7 +6097,7 @@ function returns @code{false}.
Reverse of @code{primitive_hostname}. The @code{primitive_resolve} function
returns the @acronym{IP} address for the host name specified by @var{host}
argument. If @var{host} has no A records, the function raises the
-exception @code{not_found}.
+exception @code{e_not_found}.
If @acronym{DNS} lookup fails, the function raises @code{failure} or
@code{temp_failure}, depending on the character of the failure.
@@ -6312,14 +6319,14 @@ rest of database functions (see above).
(@pxref{Database Formats}). If it is valid, the function returns the
expiration interval for that format. @FIXME{How to obtain negative
expiration??} Otherwise, @code{db_expire_interval} raises the
-@code{not_found} exception.
+@code{e_not_found} exception.
@end deftypefn
@deftypefn {Built-in Function} string db_name (string @var{fmtid})
The @var{fmt} argument is a database format identifier
(@pxref{Database Formats}). The function returns the file name
for that format. If @var{fmtid} does not match any known format,
-@code{db_name} raises the @code{not_found} exception.
+@code{db_name} raises the @code{e_not_found} exception.
@end deftypefn
@cindex getting cache status
@@ -6327,7 +6334,7 @@ for that format. If @var{fmtid} does not match any known format,
@deftypefn {Built-in Function} number db_get_active (string @var{fmtid})
Returns the flag indicating whether the cache database @var{fmtid}
is currently enabled. If @var{fmtid} does not match any known format,
-@code{db_name} raises the @code{not_found} exception.
+@code{db_name} raises the @code{e_not_found} exception.
@end deftypefn
@cindex disabling cache
@@ -6401,7 +6408,7 @@ the program's standard output.
of an existing file and @code{open} will attempt to open this file for
reading.
- The @code{open} function will signal exception @code{failure} if it
+ The @code{open} function will signal exception @code{e_failure} if it
is unable to open the resource or get the required access to it.
@end deftypefn
@@ -6410,7 +6417,7 @@ is unable to open the resource or get the required access to it.
previous call to @code{open}. The function @code{close} closes the
resource and deallocates any memory associated with it.
- @code{close} will signal @code{range} exception if @var{rd} lies
+ @code{close} will signal @code{e_range} exception if @var{rd} lies
outside of allowed range of resource descriptors. @FIXME{More info on it}
@end deftypefn
@@ -6425,8 +6432,8 @@ termination of the filtering program.
Writes the string @var{str} to the resource descriptor @var{rd}. If
the @var{size} argument is given, writes this number of bytes.
- The function will signal @code{range} exception if @var{rd} lies
-outside of allowed range of resource descriptors, and @code{ioerr}
+ The function will signal @code{e_range} exception if @var{rd} lies
+outside of allowed range of resource descriptors, and @code{e_io}
exception if an @acronym{I/O} error occurs.
@end deftypefn
@@ -6436,7 +6443,7 @@ descriptor @var{rd}. The terminating newline character will be
removed from the return value.
The function will signal @code{range} exception if @var{rd} lies
-outside of allowed range of resource descriptors, and @code{ioerr}
+outside of allowed range of resource descriptors, and @code{e_io}
exception if an @acronym{I/O} error occurs.
@end deftypefn
@@ -6691,8 +6698,8 @@ message.
@end table
The @code{sa} function can signal the following exceptions:
-@code{failure} if the connection fails, @code{url} if the supplied
-@acronym{URL} is invalid and @code{range} if the supplied port number
+@code{e_failure} if the connection fails, @code{e_url} if the supplied
+@acronym{URL} is invalid and @code{e_range} if the supplied port number
is out of the range 1--65535.
The simplest way to use the function is:
@@ -6749,8 +6756,8 @@ done
@code{clamav_virus_name} global variable.
The @code{clamav} function can signal the following exceptions:
-@code{failure} if connection failed, @code{url} if the supplied
-@acronym{URL} is invalid and @code{range} if the supplied port number
+@code{e_failure} if connection failed, @code{e_url} if the supplied
+@acronym{URL} is invalid and @code{e_range} if the supplied port number
is out of the range 1--65535.
An example usage:
@@ -6781,7 +6788,7 @@ of greylisting period in the internal variable
@code{greylist_seconds_left}. @xref{Greylisting}, for a detailed
explanation.
- The function @code{greylist} can signal @code{dbfailure} exception.
+ The function @code{greylist} can signal @code{e_dbfailure} exception.
@end deftypefn
@deftypefn {Built-in Function} boolean listens (string @var{host}, [number @var{port}])
@@ -8298,7 +8305,7 @@ returns true only if any of the @samp{MX}s for (domain or email) @var{x}
match the globbing pattern @var{y}.
Both @code{mx matches} and @code{mx fnmatches} can signal the
-following exceptions: @code{temp_failure}, @code{failure}.
+following exceptions: @code{e_temp_failure}, @code{e_failure}.
The value of any parenthesized subexpression occurring within the
right-hand side argument to @code{matches} or @code{mx matches} can be
@@ -9047,69 +9054,71 @@ following table summarizes all the exception types implemented by
@command{mailfromd} version @value{VERSION}:
@table @code
-@cindex dbfailure, exception type
-@item dbfailure
+@cindex e_dbfailure, exception type
+@item e_dbfailure
General database failure. For example, the database cannot be
opened. This exception can be signaled by any function that queries
any @acronym{DBM} database.
-@cindex divzero, exception type
-@item divzero
+@cindex e_divzero, exception type
+@item e_divzero
Division by zero.
+@cindex e_failure, exception type
@cindex failure, exception type
-@item failure
+@item e_failure
+@itemx failure
A general failure has occurred. In particular, this exception is
signaled by @acronym{DNS} lookup functions when any permanent failure occurs.
This exception can be signaled by any @acronym{DNS}-related function
(@code{hasmx}, @code{poll}, etc.) or operation (@code{mx matches}).
-@cindex invcidr, exception type
-@item invcidr
+@cindex e_invcidr, exception type
+@item e_invcidr
Invalid @acronym{CIDR} notation. This is signaled by @code{match_cidr} function
when its second argument is not a valid @acronym{CIDR}.
-@cindex invip, exception type
-@item invip
+@cindex e_invip, exception type
+@item e_invip
Invalid @acronym{IP} address. This is signaled by @code{match_cidr} function
when its first argument is not a valid @acronym{IP} address.
-@cindex invtime, exception type
-@item invtime
+@cindex e_invtime, exception type
+@item e_invtime
Invalid time interval specification. It is signaled by
@code{interval} function if its argument is not a valid time interval
(@pxref{time interval specification}).
-@cindex ioerr, exception type
-@item ioerr
+@cindex e_io, exception type
+@item e_io
An error occurred during the input-output operation. @xref{I/O
functions}, for a description of functions that can signal this
exception.
-@cindex macroundef, exception type
-@item macroundef
+@cindex e_macroundef, exception type
+@item e_macroundef
A Sendmail macro is undefined.
-@cindex noresolve, exception type
-@item noresolve
+@cindex e_noresolve, exception type
+@item e_noresolve
The argument of a @acronym{DNS}-related function cannot be resolved to host
name or @acronym{IP} address. Currently only @code{ismx} (@pxref{ismx}) raises
this exception.
-@cindex range, exception type
-@item range
+@cindex e_range, exception type
+@item e_range
The supplied argument is outside the allowed range. This is
signalled, for example, by @code{substring} function (@pxref{substring}).
-@cindex regcomp, exception type
-@item regcomp
+@cindex e_regcomp, exception type
+@item e_regcomp
Regular expression cannot be compiled. This can happen when a
regular expression (a right-hand argument of a @code{matches}
operator) is built at the runtime and the produced string is an
invalid regex.
-@cindex ston_conv, exception type
-@item ston_conv
+@cindex e_ston_conv, exception type
+@item e_ston_conv
String-to-number conversion failed. This can be signaled when a
string is used in numeric context which cannot be converted to the numeric
data type. For example:
@@ -9126,13 +9135,15 @@ data type. For example:
The @code{if} condition will signal @code{ston_conv}, since @samp{10a}
cannot be converted to a number.
+@cindex e_temp_failure, exception type
@cindex temp_failure, exception type
-@item temp_failure
+@item e_temp_failure
+@itemx temp_failure
A temporary failure has occurred. This can be signaled by
@acronym{DNS}-related functions or operations.
-@cindex url, exception type
-@item url
+@cindex e_url, exception type
+@item e_url
The supplied @acronym{URL} is invalid. @xref{Interfaces to
Third-Party Programs}.
@@ -9140,14 +9151,17 @@ Third-Party Programs}.
@end table
@cindex success, exception type
+@cindex e_success, exception type
@cindex not_found, exception type
+@cindex e_not_found, exception type
In addition to these, two symbols are defined that are not exception
types in the strict sense of the world, but are provided to make
writing filter scripts more convenient. These are @code{success},
meaning successful return from a function, and @code{not_found},
meaning that the required entity (e.g. domain name or email address)
was not found. @xref{figure-poll-wrapper}, for an illustration on
-how these can be used.
+how these can be used. For consistency with other exception codes,
+these can be spelled as @code{e_success} and @code{e_not_found}.
@cindex exceptions, default handling
@cindex default exception handling
@@ -9179,8 +9193,8 @@ where @var{exception-list} is the list of exception types, separated
by the word @code{or}. A special form @samp{*}, which stands for
all exceptions, is allowed as well. The @var{handler-body} is the list of
statements comprising the handler body. For example, the code below
-installs a handler for exceptions 2 (@samp{failure}) and 3
-(@samp{temp_failure}):
+installs a handler for exceptions 2 (@samp{e_failure}) and 3
+(@samp{e_temp_failure}):
@smallexample
@group
@@ -9204,7 +9218,7 @@ above code snippet will look like:
@group
#include <status.mfh>
-catch failure or temp_failure
+catch e_failure or e_temp_failure
do
@dots{}
done
@@ -9255,7 +9269,7 @@ In the latter case, a log message is also issued:
prog envfrom
do
- catch failure or temp_failure
+ catch e_failure or e_temp_failure
do
echo "Caught exception $1: $2"
continue
diff --git a/src/bi_db.m4 b/src/bi_db.m4
index f366008..024337e 100644
--- a/src/bi_db.m4
+++ b/src/bi_db.m4
@@ -29,7 +29,7 @@ dbmap_lookup(eval_environ_t env, char *dbname, const char *keystr,
if (!defval)
defval = "";
if (mu_dbm_open(dbname, &db, MU_STREAM_READ, 0, NULL))
- MF_THROW(mf_dbfailure,
+ MF_THROW(mfe_dbfailure,
_("mu_dbm_open(%s) failed: %s"),
dbname,
mu_dbm_strerror());
@@ -91,7 +91,7 @@ MF_DEFUN(dbput, VOID, STRING dbname, STRING keystr, STRING value,
DBM_DATUM contents;
if (mu_dbm_open(dbname, &db, MU_STREAM_RDWR, 0640, NULL))
- MF_THROW(mf_dbfailure,
+ MF_THROW(mfe_dbfailure,
_("mu_dbm_open(%s) failed: %s"),
dbname,
mu_dbm_strerror());
@@ -108,7 +108,7 @@ MF_DEFUN(dbput, VOID, STRING dbname, STRING keystr, STRING value,
rc = mu_dbm_insert(&db, key, contents, 1);
mu_dbm_close(&db);
MF_ASSERT(rc == 0,
- mf_dbfailure,
+ mfe_dbfailure,
_("Failed to insert data to %s: %s %s: %s"),
dbname,
keystr,
@@ -123,7 +123,7 @@ MF_DEFUN(dbdel, VOID, STRING dbname, STRING keystr, OPTIONAL, NUMBER null)
DBM_DATUM key;
int rc;
if (mu_dbm_open(dbname, &db, MU_STREAM_RDWR, 0640, NULL))
- MF_THROW(mf_dbfailure,
+ MF_THROW(mfe_dbfailure,
_("mu_dbm_open(%s) failed: %s"),
dbname,
mu_dbm_strerror());
@@ -135,7 +135,7 @@ MF_DEFUN(dbdel, VOID, STRING dbname, STRING keystr, OPTIONAL, NUMBER null)
rc = mu_dbm_delete(&db, key);
mu_dbm_close(&db);
MF_ASSERT(rc == 0,
- mf_dbfailure,
+ mfe_dbfailure,
_("Failed to delete data `%s' from `%s': %s"),
keystr,
dbname,
@@ -192,7 +192,7 @@ MF_DEFUN(greylist, NUMBER, STRING email, NUMBER interval)
rc = mu_dbm_open(greylist_format->dbname, &db, MU_STREAM_RDWR, 0600,
&readonly);
- MF_ASSERT(rc == 0, mf_dbfailure, _("mu_dbm_open(%s) failed: %s"),
+ MF_ASSERT(rc == 0, mfe_dbfailure, _("mu_dbm_open(%s) failed: %s"),
greylist_format->dbname, mu_dbm_strerror());
memset(&key, 0, sizeof key);
@@ -205,7 +205,7 @@ MF_DEFUN(greylist, NUMBER, STRING email, NUMBER interval)
time_t timestamp, diff;
MF_ASSERT(MU_DATUM_SIZE(contents) == sizeof timestamp,
- mf_dbfailure,
+ mfe_dbfailure,
_("Greylist database %s has wrong data size"),
greylist_format->dbname);
@@ -279,7 +279,7 @@ MF_DEFUN(db_name, STRING, STRING fmtid)
{
struct db_format *fmt = db_format_lookup(fmtid);
MF_ASSERT(fmt != NULL,
- mf_not_found,
+ mfe_not_found,
_("No such db format: %s"), fmtid);
MF_RETURN_STRING(fmt->dbname);
}
@@ -289,7 +289,7 @@ MF_DEFUN(db_get_active, NUMBER, STRING fmtid)
{
struct db_format *fmt = db_format_lookup(fmtid);
MF_ASSERT(fmt != NULL,
- mf_not_found,
+ mfe_not_found,
_("No such db format: %s"), fmtid);
MF_RETURN(fmt->enabled);
}
@@ -299,7 +299,7 @@ MF_DEFUN(db_set_active, VOID, STRING fmtid, NUMBER active)
{
struct db_format *fmt = db_format_lookup(fmtid);
MF_ASSERT(fmt != NULL,
- mf_not_found,
+ mfe_not_found,
_("No such db format: %s"), fmtid);
fmt->enabled = active;
}
@@ -309,7 +309,7 @@ MF_DEFUN(db_expire_interval, NUMBER, STRING fmtid)
{
struct db_format *fmt = db_format_lookup(fmtid);
MF_ASSERT(fmt != NULL,
- mf_not_found,
+ mfe_not_found,
_("No such db format: %s"), fmtid);
MF_RETURN(fmt->expire_interval);
}
diff --git a/src/bi_dns.m4 b/src/bi_dns.m4
index 7e92c96..ad09ee1 100644
--- a/src/bi_dns.m4
+++ b/src/bi_dns.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@ MF_DEFUN(primitive_hostname, STRING, STRING string)
stat = resolve_ipstr(string, &hbuf);
MF_ASSERT(stat == mf_success,
- stat,
+ mf_status_to_exception(stat),
_("Cannot resolve IP %s"),
string);
@@ -43,12 +43,12 @@ MF_DEFUN(primitive_resolve, STRING, STRING string, OPTIONAL, STRING domain)
if (MF_OPTVAL(domain,"")[0]) {
stat = resolve_ipstr_domain(string, domain, &ipstr);
MF_ASSERT(stat == mf_success,
- stat,
+ mf_status_to_exception(stat),
_("Cannot resolve %s.%s"), string, domain);
} else {
stat = resolve_hostname(string, &ipstr);
MF_ASSERT(stat == mf_success,
- stat,
+ mf_status_to_exception(stat),
_("Cannot resolve %s"), string);
}
pushs(env, ipstr);
@@ -117,7 +117,7 @@ MF_DEFUN(dns_getname, STRING, STRING ipstr)
char *names[64];
MF_ASSERT(inet_aton(ipstr, &addr),
- mf_invip,
+ mfe_invip,
_("Invalid IP: %s"), ipstr);
dnstat = ptr_lookup(addr, names, NELEMS(names), &ttl, NULL, 0);
@@ -160,7 +160,7 @@ MF_DEFUN(primitive_hasmx, NUMBER, STRING string)
mxstat = getmx(string, mxbuf);
MF_ASSERT(mxstat == mf_success || mxstat == mf_not_found,
- mxstat,
+ mf_status_to_exception(mxstat),
_("Cannot get MX records for %s"),
string);
@@ -182,7 +182,7 @@ MF_DEFUN(getmx, STRING, STRING domain, OPTIONAL, NUMBER resolve)
else
mxstat = getmx(domain, mxbuf);
MF_ASSERT(mxstat == mf_success || mxstat == mf_not_found,
- mxstat,
+ mf_status_to_exception(mxstat),
_("Cannot get MX records for %s"), domain);
if (mxstat == mf_not_found)
MF_RETURN_STRING("");
@@ -220,9 +220,9 @@ resolve_host(const char *string, unsigned long *ip)
rc = inet_aton(ipstr, &addr);
free(ipstr);
if (rc == 0) {
- mu_error(_("INTERNAL ERROR at %s:%lu: resolve_hostname returned "
+ mu_error(_("INTERNAL ERROR at %s:%d: resolve_hostname returned "
"invalid IP address: %s"),
- __FILE__, __FILE__, ipstr);
+ __FILE__, __LINE__, ipstr);
return 1;
}
*ip = addr.s_addr;
@@ -237,13 +237,13 @@ MF_DEFUN(primitive_ismx, NUMBER, STRING domain, STRING ipstr)
int rc = 0;
int i;
- MF_ASSERT(resolve_host(ipstr, &ip) == 0, mf_noresolve,
+ MF_ASSERT(resolve_host(ipstr, &ip) == 0, mfe_noresolve,
_("Cannot resolve host name %s"), ipstr);
mxstat = getmx(domain, mxbuf);
MF_ASSERT(mxstat == mf_success,
- mxstat,
+ mf_status_to_exception(mxstat),
_("Cannot get MXs for %s"), domain);
for (i = 0; i < MAXMXCOUNT && mxbuf[i]; i++) {
diff --git a/src/bi_gettext.m4 b/src/bi_gettext.m4
index aeb008c..f97b238 100644
--- a/src/bi_gettext.m4
+++ b/src/bi_gettext.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2007 Sergey Poznyakoff
+ Copyright (C) 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@ MF_DEFUN(bindtextdomain, STRING, STRING domain, STRING dirname)
{
char *s = bindtextdomain(domain[0] ? domain : NULL, dirname);
MF_ASSERT(s != NULL,
- mf_failure,
+ mfe_failure,
"bindtextdomain failed: %s", mu_strerror(errno));
MF_RETURN_STRING(s);
}
diff --git a/src/bi_io.m4 b/src/bi_io.m4
index 17303a9..40810a0 100644
--- a/src/bi_io.m4
+++ b/src/bi_io.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -226,7 +226,7 @@ MF_DEFUN(open, NUMBER, STRING name)
break;
}
MF_ASSERT(i < NSTREAMS,
- mf_failure,
+ mfe_failure,
_("No more files available"));
debug1(10, "opening stream %s", name);
@@ -256,7 +256,7 @@ MF_DEFUN(open, NUMBER, STRING name)
rc = opf(&iotab[i], name, flags);
MF_ASSERT(rc == 0,
- mf_failure,
+ mfe_failure,
_("Cannot open stream %s: %s"), name,
mu_strerror(rc));
debug2(10, "open(%s) = %d", name, i);
@@ -269,7 +269,7 @@ MF_DEFUN(close, VOID, NUMBER fd)
struct io_stream *iotab = MF_GET_DATA;
MF_ASSERT(fd >= 0 && fd < NSTREAMS,
- mf_range,
+ mfe_range,
_("Invalid file descriptor"));
close_stream(&iotab[fd]);
}
@@ -282,11 +282,11 @@ MF_DEFUN(write, VOID, NUMBER fd, STRING str, OPTIONAL, NUMBER n)
debug2(10, "writing %s to %d", str, fd);
MF_ASSERT(fd >= 0 && fd < NSTREAMS && OFD(iotab[fd]),
- mf_range,
+ mfe_range,
_("Invalid file descriptor"));
rc = write(OFD(iotab[fd]), str, MF_OPTVAL(n, strlen (str)));
MF_ASSERT(n == rc,
- mf_ioerr,
+ mfe_io,
_("Write error on %s: %s"),
iotab[fd].name, mu_strerror(errno));
}
@@ -298,11 +298,11 @@ MF_DEFUN(getline, STRING, NUMBER fd)
int rc;
MF_ASSERT(fd >= 0 && fd < NSTREAMS && IFD(iotab[fd]),
- mf_range,
+ mfe_range,
_("Invalid file descriptor"));
rc = read_stream_line(&iotab[fd]);
MF_ASSERT(rc == 0,
- mf_ioerr,
+ mfe_io,
_("Read error on %s: %s"),
iotab[fd].name, mu_strerror(errno));
MF_RETURN_STRING(iotab[fd].buf);
diff --git a/src/bi_ipaddr.m4 b/src/bi_ipaddr.m4
index 44b5b10..8a34a25 100644
--- a/src/bi_ipaddr.m4
+++ b/src/bi_ipaddr.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2007 Sergey Poznyakoff
+ Copyright (C) 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -51,7 +51,7 @@ MF_DEFUN(inet_aton, NUMBER, STRING s)
struct in_addr addr;
MF_ASSERT(inet_aton(s, &addr),
- mf_invip,
+ mfe_invip,
_("Invalid IP address (%s)"),
s);
MF_RETURN(ntohl(addr.s_addr));
@@ -72,7 +72,7 @@ MF_DEFUN(len_to_netmask, NUMBER, NUMBER x)
unsigned long n = (unsigned long) x;
unsigned long netmask;
- MF_ASSERT(n <= 32, mf_range,
+ MF_ASSERT(n <= 32, mfe_range,
_("Invalid netmask: %lu"), n);
n = 32 - n;
if (n == 32)
diff --git a/src/bi_mail.m4 b/src/bi_mail.m4
index 8b106d8..01fc37b 100644
--- a/src/bi_mail.m4
+++ b/src/bi_mail.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@ _send(eval_environ_t env,
status = mu_mailer_create(&mailer, mailer_url);
if (status) {
destroy(ptr);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Cannot create mailer `%s': %s"),
mailer_url, mu_strerror(status));
}
@@ -37,7 +37,7 @@ _send(eval_environ_t env,
if (status) {
destroy(ptr);
mu_mailer_destroy(&mailer);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Bad recipient address `%s': %s"),
to, mu_strerror(status));
}
@@ -49,7 +49,7 @@ _send(eval_environ_t env,
mu_address_destroy(&to_addr);
mu_mailer_destroy(&mailer);
destroy(ptr);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Bad sender address `%s': %s"),
from, mu_strerror(status));
}
@@ -61,7 +61,7 @@ _send(eval_environ_t env,
mu_address_destroy(&from_addr);
mu_mailer_destroy(&mailer);
destroy(ptr);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Opening mailer `%s' failed: %s"),
mailer_url, mu_strerror (status));
}
@@ -71,7 +71,7 @@ _send(eval_environ_t env,
mu_address_destroy(&from_addr);
mu_mailer_destroy(&mailer);
destroy(ptr);
- MF_ASSERT(status == 0, mf_failure,
+ MF_ASSERT(status == 0, mfe_failure,
_("Cannot send message: %s"),
mu_strerror(status));
return 0;
@@ -299,7 +299,7 @@ MF_DEFUN(send_dsn, VOID, STRING to,
status = build_mime(&mime, env_get_stream(env),
sender, recpt, text);
MF_ASSERT(status == 0,
- mf_failure,
+ mfe_failure,
_("Cannot create DSN: %s"),
mu_strerror(status));
diff --git a/src/bi_other.m4 b/src/bi_other.m4
index d9a51db..68facb0 100644
--- a/src/bi_other.m4
+++ b/src/bi_other.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -33,13 +33,13 @@ valid_user_p(eval_environ_t env, const char *name)
break;
case EAGAIN:
- MF_THROW(mf_temp_failure,
+ MF_THROW(mfe_temp_failure,
_("Temporary failure querying for username %s"),
name);
break;
default:
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Failure querying for username %s"),
name);
break;
@@ -66,7 +66,7 @@ MF_DEFUN(interval, NUMBER, STRING str)
const char *endp;
MF_ASSERT(parse_time_interval(str, &t, &endp) == 0,
- mf_invtime,
+ mfe_invtime,
_("Unrecognized time format (near `%s')"), endp);
MF_RETURN(t);
}
@@ -78,7 +78,7 @@ MF_DEFUN(rate, NUMBER, STRING key, NUMBER interval, OPTIONAL, NUMBER mincnt)
long lrate;
MF_ASSERT(get_rate(key, &rate, MF_OPTVAL(mincnt)) == mf_success,
- mf_dbfailure,
+ mfe_dbfailure,
_("Cannot get rate for %s"), key);
lrate = rate * interval;
@@ -90,7 +90,7 @@ MF_DEFUN(debug_level, NUMBER, OPTIONAL, STRING modname)
{
int level;
MF_ASSERT(debug_module_level(MF_OPTVAL(modname, NULL), &level) == 0,
- mf_range,
+ mfe_range,
_("Invalid module name: %s"), modname);
MF_RETURN(level);
}
@@ -104,7 +104,7 @@ MF_DEFUN(debug_spec, STRING, OPTIONAL, STRING modnames)
int rc = debug_spec_string(MF_OPTVAL(modnames, NULL), &buf);
MF_ASSERT(rc == 0,
- mf_failure,
+ mfe_failure,
"%s", mu_strerror(rc));
s = MF_ALLOC_HEAP(off, strlen(buf) + 1);
strcpy(s, buf);
diff --git a/src/bi_poll.m4 b/src/bi_poll.m4
index 979ffd8..8f0f4e3 100644
--- a/src/bi_poll.m4
+++ b/src/bi_poll.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -46,8 +46,8 @@ MF_DEFUN(stdpoll, NUMBER, STRING email, STRING ehlo, STRING mailfrom)
locus->file, locus->line,
email, ehlo, mailfrom);
rc = method_standard(env, email, ehlo, mailfrom);
- MF_ASSERT(mf_resolved(rc), rc,
- _("Unhandled exception %s"), mf_status_str(rc));
+ MF_ASSERT(mf_resolved(rc), mf_status_to_exception(rc),
+ _("Unhandled exception %s"), mf_exception_str(rc));
MF_RETURN(rc);
}
@@ -66,8 +66,8 @@ MF_DEFUN(strictpoll, NUMBER, STRING host, STRING email, STRING ehlo,
ehlo, mailfrom);
rc = method_strict(env, email, host, ehlo, mailfrom);
- MF_ASSERT(mf_resolved(rc), rc,
- _("Unhandled exception %s"), mf_status_str(rc));
+ MF_ASSERT(mf_resolved(rc), mf_status_to_exception(rc),
+ _("Unhandled exception %s"), mf_exception_str(rc));
MF_RETURN(rc);
}
@@ -87,8 +87,8 @@ MF_DEFUN(_pollhost, NUMBER, STRING host, STRING email, STRING ehlo,
rc = check_on_host(env, email, host, ehlo, mailfrom);
- MF_ASSERT(mf_resolved(rc), rc,
- _("Unhandled exception %s"), mf_status_str(rc));
+ MF_ASSERT(mf_resolved(rc), mf_status_to_exception(rc),
+ _("Unhandled exception %s"), mf_exception_str(rc));
MF_RETURN(rc);
}
@@ -107,8 +107,8 @@ MF_DEFUN(_pollmx, NUMBER, STRING domain, STRING email, STRING ehlo,
rc = check_mx_records(env, email, domain, ehlo, mailfrom, NULL);
- MF_ASSERT(mf_resolved(rc), rc,
- _("Unhandled exception %s"), mf_status_str(rc));
+ MF_ASSERT(mf_resolved(rc), mf_status_to_exception(rc),
+ _("Unhandled exception %s"), mf_exception_str(rc));
MF_RETURN(rc);
}
diff --git a/src/bi_sa.m4 b/src/bi_sa.m4
index 3bd5cad..af76982 100644
--- a/src/bi_sa.m4
+++ b/src/bi_sa.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -35,11 +35,11 @@ spamd_connect_tcp(eval_environ_t env, mu_stream_t *stream,
char *host, int port)
{
int rc = mu_tcp_stream_create(stream, host, port, 0);
- MF_ASSERT(rc == 0, mf_failure,
+ MF_ASSERT(rc == 0, mfe_failure,
"mu_tcp_stream_create: %s",
mu_strerror(rc));
rc = mu_stream_open(*stream);
- MF_ASSERT(rc == 0, mf_failure,
+ MF_ASSERT(rc == 0, mfe_failure,
"mu_stream_open: %s",
mu_strerror(rc));
return rc;
@@ -53,7 +53,7 @@ spamd_connect_socket(eval_environ_t env, mu_stream_t *stream, char *path)
struct sockaddr_un addr;
fd = socket(PF_UNIX, SOCK_STREAM, 0);
- MF_ASSERT(fd >= 0, mf_failure,
+ MF_ASSERT(fd >= 0, mfe_failure,
"socket: %s", mu_strerror(errno));
memset(&addr, 0, sizeof addr);
@@ -62,14 +62,14 @@ spamd_connect_socket(eval_environ_t env, mu_stream_t *stream, char *path)
addr.sun_path[sizeof addr.sun_path - 1] = 0;
if (connect(fd, (struct sockaddr *) &addr, sizeof(addr))) {
close(fd);
- MF_THROW(mf_failure, "connect: %s", mu_strerror(errno));
+ MF_THROW(mfe_failure, "connect: %s", mu_strerror(errno));
}
fp = fdopen(fd, "w+");
rc = mu_stdio_stream_create(stream, fp, MU_STREAM_RDWR);
if (rc) {
fclose(fp);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
"mu_stdio_stream_create: %s",
mu_strerror(rc));
}
@@ -78,7 +78,7 @@ spamd_connect_socket(eval_environ_t env, mu_stream_t *stream, char *path)
if (rc) {
mu_stream_destroy (stream, mu_stream_get_owner (*stream));
fclose(fp);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
"mu_stream_open: %s",
mu_strerror(rc));
}
@@ -243,20 +243,20 @@ open_connection(eval_environ_t env, char *urlstr, int *isfile, char **phost)
rc = mu_url_create(&url, urlstr);
if (rc)
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Cannot create URL from `%s': %s"),
urlstr, mu_strerror(rc));
if (rc = mu_url_parse(url)) {
mu_url_destroy(&url);
- MF_THROW(mf_url,
+ MF_THROW(mfe_url,
_("%s: error parsing URL: %s"),
urlstr, mu_strerror(rc));
}
if (rc = mu_url_get_scheme(url, buffer, sizeof buffer, NULL)) {
mu_url_destroy(&url);
- MF_THROW(mf_url,
+ MF_THROW(mfe_url,
_("%s: cannot get scheme: %s"),
urlstr, mu_strerror(rc));
}
@@ -265,7 +265,7 @@ open_connection(eval_environ_t env, char *urlstr, int *isfile, char **phost)
|| strcmp(buffer, "socket") == 0) {
size_t size;
if (rc = mu_url_get_path(url, NULL, 0, &size)) {
- MF_THROW(mf_url,
+ MF_THROW(mfe_url,
_("%s: cannot get path: %s"),
urlstr, mu_strerror(rc));
}
@@ -281,21 +281,21 @@ open_connection(eval_environ_t env, char *urlstr, int *isfile, char **phost)
if (rc = mu_url_get_port(url, &n)) {
mu_url_destroy(&url);
- MF_THROW(mf_url,
+ MF_THROW(mfe_url,
_("%s: cannot get port: %s"),
urlstr, mu_strerror(rc));
}
if (n == 0 || (port = n) != n) {
mu_url_destroy(&url);
- MF_THROW(mf_range,
+ MF_THROW(mfe_range,
_("Port out of range: %ld"),
n);
}
if (rc = mu_url_get_host(url, NULL, 0, &size)) {
mu_url_destroy(&url);
- MF_THROW(mf_url,
+ MF_THROW(mfe_url,
_("%s: cannot get host: %s"),
urlstr, mu_strerror(rc));
}
@@ -306,7 +306,7 @@ open_connection(eval_environ_t env, char *urlstr, int *isfile, char **phost)
}
mu_url_get_host(url, path, size + 1, NULL);
} else
- MF_THROW(mf_url,
+ MF_THROW(mfe_url,
_("Invalid URL: %s"), buffer);
mu_url_destroy(&url);
@@ -366,12 +366,12 @@ MF_DEFUN(sa, NUMBER, STRING urlstr, NUMBER prec)
spamd_read_line(ostr, buffer, sizeof buffer, NULL);
if (got_sigpipe) {
spamd_destroy(&ostr);
- MF_THROW(mf_failure, _("Remote side has closed connection"));
+ MF_THROW(mfe_failure, _("Remote side has closed connection"));
}
if (sscanf(buffer, "SPAMD/%18s %d %*s", version_str, &result) != 2) {
spamd_destroy(&ostr);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("spamd responded with bad string '%s'"),
buffer);
}
@@ -379,7 +379,7 @@ MF_DEFUN(sa, NUMBER, STRING urlstr, NUMBER prec)
decode_float(&version, version_str, 1);
if (version < 10) {
spamd_destroy(&ostr);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Unsupported SPAMD version: %s"),
version_str);
}
@@ -388,7 +388,7 @@ MF_DEFUN(sa, NUMBER, STRING urlstr, NUMBER prec)
if (sscanf (buffer, "Spam: %5s ; %20s / %20s",
spam_str, score_str, threshold_str) != 3) {
spamd_destroy(&ostr);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("spamd responded with bad Spam header '%s'"),
buffer);
}
@@ -435,7 +435,7 @@ MF_DEFUN(clamav, NUMBER, STRING urlstr)
spamd_read_line(cstr, buffer, sizeof buffer, NULL);
if (sscanf(buffer, "PORT %hu\n", &port) != 1) {
spamd_destroy(&cstr);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Bad response from clamav: expected `PORT' but found `%s'"),
buffer);
}
@@ -447,7 +447,7 @@ MF_DEFUN(clamav, NUMBER, STRING urlstr)
free(host);
if (rc) {
spamd_destroy(&cstr);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
"mu_tcp_stream_create: %s",
mu_strerror(rc));
}
@@ -456,7 +456,7 @@ MF_DEFUN(clamav, NUMBER, STRING urlstr)
if (rc) {
spamd_destroy(&cstr);
mu_stream_destroy(&dstr, mu_stream_get_owner(dstr));
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
"mu_stream_open: %s",
mu_strerror(rc));
}
@@ -468,11 +468,11 @@ MF_DEFUN(clamav, NUMBER, STRING urlstr)
rc = spamd_read_line(cstr, buffer, sizeof buffer, NULL);
spamd_destroy(&cstr);
- MF_ASSERT(rc == 0, mf_failure, _("Error reading clamav response: %s"),
+ MF_ASSERT(rc == 0, mfe_failure, _("Error reading clamav response: %s"),
mu_strerror(rc));
p = strrchr(buffer, ' ');
- MF_ASSERT(p, mf_failure,
+ MF_ASSERT(p, mfe_failure,
_("Unknown clamav response: %s"), buffer);
++p;
if (strncmp(p, "OK", 2) == 0)
@@ -495,11 +495,11 @@ MF_DEFUN(clamav, NUMBER, STRING urlstr)
rc = 1;
} else if (strncmp(p, "ERROR", 5) == 0) {
/* FIXME: mf code */
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Clamav error: %s"),
buffer);
} else {
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Unknown clamav response: %s"),
buffer);
}
diff --git a/src/bi_sieve.m4 b/src/bi_sieve.m4
index f8551cb..04ae8f9 100644
--- a/src/bi_sieve.m4
+++ b/src/bi_sieve.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2007 Sergey Poznyakoff
+ Copyright (C) 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -79,7 +79,6 @@ mf_stream_to_message(mu_stream_t stream, mu_message_t *msg)
{
int rc;
mu_mailbox_t mbox;
- char *buf = NULL;
size_t n;
mu_stream_flush (stream);
@@ -113,7 +112,7 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER dbg)
int retval = 0;
int f = MF_OPTVAL(dbg);
- MF_ASSERT(rc == 0, mf_failure,
+ MF_ASSERT(rc == 0, mfe_failure,
_("Failed to initialize sieve machine: %s"),
mu_strerror(rc));
@@ -134,7 +133,7 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER dbg)
if (debug_flags) {
rc = mu_debug_create(&mudebug, NULL);
- MF_ASSERT(rc == 0, mf_failure,
+ MF_ASSERT(rc == 0, mfe_failure,
_("Cannot create debug object: %s"),
mu_strerror(rc));
mu_debug_set_level(mudebug, debug_flags);
@@ -160,7 +159,7 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER dbg)
rc = mf_stream_to_message(mstr, &msg);
if (rc) {
mu_sieve_machine_destroy(&mach);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Cannot translate stream to message: %s"),
mu_strerror (rc));
}
@@ -173,13 +172,13 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER dbg)
/*mu_message_destroy(&msg, mu_message_get_owner(msg));*/
if (rc) {
mu_sieve_machine_destroy(&mach);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Sieving failed: %s"),
mu_strerror(rc));
}
} else {
mu_sieve_machine_destroy(&mach);
- MF_THROW(mf_failure,
+ MF_THROW(mfe_failure,
_("Compilation of Sieve script %s failed"),
script);
}
diff --git a/src/bi_spf.m4 b/src/bi_spf.m4
index 0680521..0cb09d5 100644
--- a/src/bi_spf.m4
+++ b/src/bi_spf.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2007 Sergey Poznyakoff
+ Copyright (C) 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/bi_string.m4 b/src/bi_string.m4
index 82aa30d..dadad8a 100644
--- a/src/bi_string.m4
+++ b/src/bi_string.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -56,7 +56,7 @@ MF_DEFUN(substring, STRING, STRING string, NUMBER start, NUMBER end)
start = t;
}
- MF_ASSERT(start < len && end < len, mf_range,
+ MF_ASSERT(start < len && end < len, mfe_range,
_("Argument out of range"));
len = end - start + 1;
@@ -74,11 +74,11 @@ MF_DEFUN(substr, STRING, STRING string, NUMBER start, OPTIONAL, NUMBER nbytes)
long len = strlen(string);
char *s;
- MF_ASSERT(start >= 0, mf_range,
+ MF_ASSERT(start >= 0, mfe_range,
_("Argument out of range: start=%ld"), start);
if (!MF_DEFINED(nbytes))
nbytes = len - start;
- MF_ASSERT(nbytes >= 0, mf_range,
+ MF_ASSERT(nbytes >= 0, mfe_range,
_("Argument out of range: start=%ld, len=%ld"), start, len);
s = MF_ALLOC_HEAP(off, nbytes + 1);
diff --git a/src/bi_system.m4 b/src/bi_system.m4
index ebf00da..7981c4e 100644
--- a/src/bi_system.m4
+++ b/src/bi_system.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/bi_vars.m4 b/src/bi_vars.m4
index 2c1a07c..7adcb94 100644
--- a/src/bi_vars.m4
+++ b/src/bi_vars.m4
@@ -1,5 +1,5 @@
/* This file is part of mailfromd. -*- c -*-
- Copyright (C) 2006, 2007 Sergey Poznyakoff
+ Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/drivers.c b/src/drivers.c
index 56290b8..1d1ae89 100644
--- a/src/drivers.c
+++ b/src/drivers.c
@@ -1327,9 +1327,9 @@ print_type_catch(NODE *node, int level)
print_level(level);
printf("CATCH ");
- for (i = 0; i < mf_status_count; i++)
+ for (i = 0; i < mf_exception_count; i++)
if (node->v.catch.exmask & EXMASK(i))
- printf("%s ", mf_status_str(i));
+ printf("%s ", mf_exception_str(i));
printf("\n");
print_node_list(node->v.catch.node, level+1);
printf("END CATCH\n");
@@ -1394,7 +1394,7 @@ void
print_type_throw(NODE *node, int level)
{
print_level(level);
- printf("THROW %s\n", mf_status_str(node->v.throw.code));
+ printf("THROW %s\n", mf_exception_str(node->v.throw.code));
print_node(node->v.throw.expr, level+1);
}
diff --git a/src/gram.y b/src/gram.y
index bb68ded..22d02cf 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -1715,7 +1715,7 @@ catchlist : '*'
int i;
$$.head = $$.tail = NULL;
- for (i = 0; i < mf_status_count; i++) {
+ for (i = 0; i < mf_exception_count; i++) {
struct valist *p = xmalloc(sizeof *p);
p->next = NULL;
p->value.type = dtype_number;
@@ -1736,7 +1736,7 @@ throw : THROW value expr
$$ = alloc_node(node_type_throw, &$1);
if ($2.type != dtype_number)
parse_error(_("Exception code not a number"));
- if ($2.v.number > mf_status_count)
+ if ($2.v.number > mf_exception_count)
parse_error(_("Invalid exception number: %lu"),
$2.v.number);
@@ -1923,9 +1923,9 @@ branch : WHEN { allow_unquoted_strings = 1; } valist ':'
static int warned_once = 0;
for (p = $3.head; p; p = p->next) {
if (p->value.type == dtype_string) {
- mf_status status;
- if (string_to_stat(p->value.v.literal->text,
- &status)) {
+ mf_exception exception;
+ if (string_to_exception(p->value.v.literal->text,
+ &exception)) {
parse_error(_("Unknown exception code: %s"),
p->value.v.literal->text);
YYERROR;
@@ -1936,7 +1936,7 @@ branch : WHEN { allow_unquoted_strings = 1; } valist ':'
warned_once = 1;
}
p->value.type = dtype_number;
- p->value.v.number = status;
+ p->value.v.number = exception;
}
}
diff --git a/src/lex.l b/src/lex.l
index c33f2a6..3a069af 100644
--- a/src/lex.l
+++ b/src/lex.l
@@ -93,7 +93,7 @@ variable_or_const()
} v;
const struct value *value_ptr;
- switch (variable_or_constant_lookup(yylval.literal->text, &v)) {
+ switch (variable_or_constant_lookup(yylval.literal->text, (void**)&v)) {
case SYM_UNDEF:
parse_error(_("Variable %s is not defined"),
yylval.literal->text);
diff --git a/src/mailfromd.h b/src/mailfromd.h
index 54449c4..d3531f5 100644
--- a/src/mailfromd.h
+++ b/src/mailfromd.h
@@ -79,26 +79,36 @@ typedef enum mf_status_code {
mf_success,
mf_not_found,
mf_failure,
- mf_temp_failure,
-
- mf_ston_conv,
- mf_divzero,
- mf_regcomp,
- mf_invip,
- mf_invcidr,
- mf_invtime,
- mf_dbfailure,
- mf_range,
- mf_url,
- mf_noresolve,
- mf_ioerr,
- mf_macroundef,
-
- mf_status_count
+ mf_temp_failure
} mf_status;
#define mf_resolved(c) ((c) == mf_success || (c) == mf_not_found)
+/* Exception codes. */
+typedef enum mf_exception_code {
+ mfe_success,
+ mfe_not_found,
+ mfe_failure,
+ mfe_temp_failure,
+
+ mfe_ston_conv,
+ mfe_divzero,
+ mfe_regcomp,
+ mfe_invip,
+ mfe_invcidr,
+ mfe_invtime,
+ mfe_dbfailure,
+ mfe_range,
+ mfe_url,
+ mfe_noresolve,
+ mfe_io,
+ mfe_macroundef,
+
+ mf_exception_count
+} mf_exception;
+
+#define mf_status_to_exception(s) ((mf_exception)(s))
+
#define EXMASK(n) ((unsigned)1<<(n))
/* SMTP (libmilter) states */
@@ -690,9 +700,10 @@ void parse_pragma(char *text);
const struct locus *get_locus(void);
const char *header_command_str(enum header_opcode opcode);
const char *sfsistat_str(sfsistat stat);
-const char *mf_status_str(mf_status stat);
+const char *mf_exception_str(mf_exception ex);
+#define mf_status_str(s) mf_exception_str(mf_status_to_exception(s))
+int string_to_exception(const char *str, mf_exception *status);
const char *storage_class_str(storage_class_t sc);
-int string_to_stat(const char *str, mf_status *status);
enum smtp_state string_to_state(const char *name);
const char *state_to_string(enum smtp_state state);
void parse_error(char *fmt, ...);
@@ -762,11 +773,12 @@ void env_save_catches(eval_environ_t env);
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# endif
-void env_throw(eval_environ_t env, mf_status status,
+void env_throw(eval_environ_t env, mf_exception exception,
const char *fmt, ...) ATTRIBUTE_NORETURN;
-void env_throw_bi(eval_environ_t env, mf_status status, const char *biname,
+void env_throw_bi(eval_environ_t env, mf_exception exception,
+ const char *biname,
const char *fmt, ...) ATTRIBUTE_NORETURN;
-void env_throw_0(eval_environ_t env, mf_status status,
+void env_throw_0(eval_environ_t env, mf_exception exception,
size_t text_off) ATTRIBUTE_NORETURN;
void env_push_string(eval_environ_t env, char *arg);
diff --git a/src/mf-status.mfi b/src/mf-status.mfi
index 7687e1a..97112a4 100644
--- a/src/mf-status.mfi
+++ b/src/mf-status.mfi
@@ -22,31 +22,31 @@ TEMPLATE /* */ -*- c -*-
#include "mailfromd.h"
static struct status_tab {
- mf_status status;
+ mf_exception ex;
char *name;
} status_tab[] = {
- %{ { mf_%NAME, "%NAME" },%}
+ %{ { mfe_%NAME, "e_%NAME" },%}
{ 0, NULL }
};
int
-string_to_stat(const char *str, mf_status *status)
+string_to_exception(const char *str, mf_exception *status)
{
struct status_tab *sp;
for (sp = status_tab; sp->name; sp++)
if (strcmp(str, sp->name) == 0) {
- *status = sp->status;
+ *status = sp->ex;
return 0;
}
return 1;
}
const char *
-mf_status_str(mf_status stat)
+mf_exception_str(mf_exception ex)
{
struct status_tab *sp;
for (sp = status_tab; sp->name; sp++)
- if (sp->status == stat)
+ if (sp->ex == ex)
return sp->name;
return _("UNKNOWN");
}
diff --git a/src/mfstat.awk b/src/mfstat.awk
index 1e396ed..77d31dc 100644
--- a/src/mfstat.awk
+++ b/src/mfstat.awk
@@ -1,5 +1,5 @@
# This file is part of mailfromd.
-# Copyright (C) 2007 Sergey Poznyakoff
+# Copyright (C) 2007, 2008 Sergey Poznyakoff
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@ BEGIN {
header[nh++] = "THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT."
}
-state == 0 && /typedef enum mf_status_code/ { state = 1; next }
+state == 0 && /typedef enum mf_exception_code/ { state = 1; next }
state == 0 && /TEMPLATE/ {
state = 2;
if (NF > 1) {
@@ -35,9 +35,9 @@ state == 0 && /TEMPLATE/ {
}
state == 0 { next }
-state == 1 && $1 == "mf_status_count" { state = 0 }
+state == 1 && $1 == "mf_exception_count" { state = 0 }
state == 1 {
- if (match($1, "mf_(.+),", a))
+ if (match($1, "mfe_(.+),", a))
status_code[code++] = a[1];
}
diff --git a/src/prog.c b/src/prog.c
index 50185f9..f39fb1b 100644
--- a/src/prog.c
+++ b/src/prog.c
@@ -271,8 +271,8 @@ struct eval_environ {
mu_stream_t stream; /* Capture stream */
/* Non-local exits */
- prog_counter_t defcatch[mf_status_count];
- prog_counter_t catch[mf_status_count];
+ prog_counter_t defcatch[mf_exception_count];
+ prog_counter_t catch[mf_exception_count];
/* Built-in private data */
void **bi_priv_array;
@@ -751,7 +751,7 @@ instr_ston(eval_environ_t env)
if (PROG_TRACE_ENGINE)
prog_trace(env, "STON %s", s);
if (*p)
- env_throw(env, mf_ston_conv,
+ env_throw(env, mfe_ston_conv,
"Cannot convert stack value to number (stopped at %8.8s)",
p);
@@ -793,7 +793,7 @@ instr_symbol(eval_environ_t env)
if (PROG_TRACE_ENGINE)
prog_trace(env, "SYMBOL %s", symbol);
if (!s)
- env_throw(env, mf_macroundef, _("Macro not defined: %s"),
+ env_throw(env, mfe_macroundef, _("Macro not defined: %s"),
symbol);
if (PROG_TRACE_ENGINE)
@@ -1086,7 +1086,7 @@ instr_div(eval_environ_t env)
if (PROG_TRACE_ENGINE)
prog_trace(env, "DIV %ld %ld", a, b);
if (b == 0)
- env_throw(env, mf_divzero,
+ env_throw(env, mfe_divzero,
"Division by zero at %08lx", (unsigned long)env->pc);
push(env, (STKVAL) (a / b));
}
@@ -1187,7 +1187,7 @@ instr_regcomp(eval_environ_t env)
if (v) {
char errbuf[512];
regerror(v, &rtx->re, errbuf, sizeof(errbuf));
- env_throw(env, mf_regcomp,
+ env_throw(env, mfe_regcomp,
"compiling regex `%s': %s",
expr,
errbuf);
@@ -1443,11 +1443,11 @@ instr_catch(eval_environ_t env)
if (PROG_TRACE_ENGINE)
prog_trace(env, "CATCH %ld, %ld", entry, off);
- for (i = 0; i < mf_status_count; i++)
+ for (i = 0; i < mf_exception_count; i++)
if (mask & EXMASK(i)) {
if (PROG_TRACE_ENGINE)
prog_trace(env, "CATCH TARGET: %s",
- mf_status_str((mf_status)i));
+ mf_exception_str((mf_exception)i));
env->catch[i] = entry;
}
@@ -1461,9 +1461,9 @@ dump_catch(prog_counter_t i)
printf("%ld (%ld)", (long) prog[i], i + (long) prog[i]);
printf("; Targets: ");
- for (i = 0; i < mf_status_count; i++)
+ for (i = 0; i < mf_exception_count; i++)
if (mask & EXMASK(i))
- printf("%s ", mf_status_str((mf_status)i));
+ printf("%s ", mf_exception_str((mf_exception)i));
}
void
@@ -1473,7 +1473,7 @@ instr_throw(eval_environ_t env)
size_t off = (size_t) get_arg(env, 0);
advance_pc(env, 1);
adjust_stack(env, 1);
- if (n > mf_status_count)
+ if (n > mf_exception_count)
runtime_error(env, _("Invalid exception number: %lu"), n);
env_throw_0(env, (mf_status) n, off);
}
@@ -1481,7 +1481,7 @@ instr_throw(eval_environ_t env)
void
dump_throw(prog_counter_t i)
{
- printf("%s", mf_status_str((mf_status) prog[i]));
+ printf("%s", mf_exception_str((mf_exception) prog[i]));
}
@@ -1520,7 +1520,7 @@ instr_saveex(eval_environ_t env)
if (PROG_TRACE_ENGINE)
prog_trace(env, "SAVEEX %x", exmask);
push(env, (STKVAL) exmask);
- for (i = 0; i < mf_status_count; i++) {
+ for (i = 0; i < mf_exception_count; i++) {
if (EXMASK(i) & exmask)
push(env, (STKVAL) env->catch[i]);
}
@@ -1540,7 +1540,7 @@ instr_restex(eval_environ_t env)
if (PROG_TRACE_ENGINE)
prog_trace(env, "RESTEX %x", exmask);
- for (i = 0; i < mf_status_count; i++) {
+ for (i = 0; i < mf_exception_count; i++) {
if (EXMASK(i) & exmask)
env->catch[i] = (prog_counter_t)
env->dataseg[env->base-i-1];
diff --git a/src/snarf.m4 b/src/snarf.m4
index f8aae79..6d41932 100644
--- a/src/snarf.m4
+++ b/src/snarf.m4
@@ -436,7 +436,7 @@ m4_ifdef([<__MF_VA_START_USED__>],m4_dnl
[<m4_pushdef([<__ARGN__>],[<$1+mf_argcount(__MF_ARGLIST__)>])
((__bi_argcnt > __ARGN__) ?m4_dnl
__mf_c_getarg($2)(env, __ARGN__ + 1) :m4_dnl
- (MF_THROW(mf_range, "Argument %d is not supplied", __ARGN__),m4_dnl
+ (MF_THROW(mfe_range, "Argument %d is not supplied", __ARGN__),m4_dnl
(__mf_c_type($2)) 0))m4_dnl
m4_popdef([<__ARGN__>])>],
[<m4_errprint(m4___file__:m4___line__: [<MF_VA_ARG>] without previous [<MF_VA_START>]
diff --git a/src/status.mfi b/src/status.mfi
index 40ac06f..9d69096 100644
--- a/src/status.mfi
+++ b/src/status.mfi
@@ -10,11 +10,14 @@ const FAMILY_INET 2
%{const e_%NAME %CODE%}
-# Backward-compatible definitions
+# `Status' definitions definitions
const success e_success
const not_found e_not_found
const failure e_failure
const temp_failure e_temp_failure
+
+# Backward-compatible definitions
+m4_ifdef(`COMPAT_4_3',`
const ston_conv e_ston_conv
const divzero e_divzero
const regcomp e_regcomp
@@ -25,5 +28,6 @@ const dbfailure e_dbfailure
const range e_range
const url e_url
const noresolve e_noresolve
-const ioerr e_ioerr
+const ioerr e_io
const macroundef e_macroundef
+') \ No newline at end of file

Return to:

Send suggestions and report system problems to the System administrator.