]> git.mikk.net Git - smtpsink/commitdiff
Clean up module return code handling; renamed SSM_MSG to more descriptive
authorchris mikkelson <chris@mikk.net>
Fri, 3 Apr 2009 02:06:05 +0000 (21:06 -0500)
committerchris mikkelson <chris@mikk.net>
Fri, 3 Apr 2009 02:06:05 +0000 (21:06 -0500)
SSM_RESPONSE, and cleaned up macros, adding SSM_PASSED to avoid the explicit
(ret & 0x0F) comparisons.

module.c
smtpsink.h

index 94eea33e2be1db407b168a652a263b75ba3e5180..f3ed34fb09f0d3d89b5f9a76991332ce8559f6a4 100644 (file)
--- a/module.c
+++ b/module.c
@@ -78,7 +78,7 @@ module_connect(struct conn *c) {
        for (i = 0; i < nmod; i++) {
                if (modlist[i]->ssm_connect) {
                        ret = modlist[i]->ssm_connect(c);
-                       if ((ret & 0x0F) != SSM_PASS) return ret;
+                       if (!SSM_PASSED(ret)) return ret;
                }
        }
        return SSM_ACCEPT;
@@ -92,7 +92,7 @@ module_helo(struct conn *c, char *cmd, int len, int argoff)
        for (i = 0; i < nmod; i++) {
                if (modlist[i]->ssm_helo) {
                        ret = modlist[i]->ssm_helo(c,cmd,len,argoff);
-                       if ((ret & 0x0F) != SSM_PASS) return ret;
+                       if (!SSM_PASSED(ret)) return ret;
                }
        }
        return SSM_ACCEPT;
@@ -106,7 +106,7 @@ module_mail(struct conn *c, char *cmd, int len, int argoff)
        for (i = 0; i < nmod; i++) {
                if (modlist[i]->ssm_mail) {
                        ret = modlist[i]->ssm_mail(c,cmd,len,argoff);
-                       if ((ret & 0x0F) != SSM_PASS) return ret;
+                       if (!SSM_PASSED(ret)) return ret;
                }
        }
        return SSM_ACCEPT;
@@ -119,7 +119,7 @@ module_rcpt(struct conn *c, char *cmd, int len, int argoff)
        for (i = 0; i < nmod; i++) {
                if (modlist[i]->ssm_rcpt) {
                        ret = modlist[i]->ssm_rcpt(c,cmd,len,argoff);
-                       if ((ret & 0x0F) != SSM_PASS) return ret;
+                       if (!SSM_PASSED(ret)) return ret;
                }
        }
        return SSM_ACCEPT;
@@ -132,7 +132,7 @@ module_data(struct conn *c, char *cmd, int len, int argoff)
        for (i = 0; i < nmod; i++) {
                if (modlist[i]->ssm_enddata) {
                        ret = modlist[i]->ssm_data(c, cmd, len, argoff);
-                       if ((ret & 0x0F) != SSM_PASS) return ret;
+                       if (!SSM_PASSED(ret)) return ret;
                }
        }
        return SSM_ACCEPT;
@@ -157,7 +157,7 @@ module_enddata(struct conn *c)
        for (i = 0; i < nmod; i++) {
                if (modlist[i]->ssm_enddata) {
                        ret = modlist[i]->ssm_enddata(c);
-                       if ((ret & 0x0F) != SSM_PASS) return ret;
+                       if (!SSM_PASSED(ret)) return ret;
                }
        }
        return SSM_ACCEPT;
index 75076ae412ec30a05943b46f688675ffbc347895..56d6f84ca093ac3638493550fc6548ac4979b23f 100644 (file)
@@ -39,15 +39,18 @@ int respond(struct conn *, const char *, ...);
 /* SSM_PASS: move on to next module */
 /* SSM_ACCEPT: stop processing, accept command */
 /* SSM_REJECT: stop processing, reject command */
-/* SSM_MSG | SSM_ACCEPT: stop processing, accept command, module responded */
-/* SSM_MSG | SSM_REJECT: stop processing, reject command, module responded */
+/* SSM_RESPONSE | SSM_ACCEPT: stop processing, accept command, module responded */
+/* SSM_RESPONSE | SSM_REJECT: stop processing, reject command, module responded */
 #define SSM_PASS       0
 #define SSM_ACCEPT     1       
 #define SSM_REJECT     2
-#define SSM_MSG                (1 << 8)
+#define SSM_RESPONSE   (1 << 8)
 
-#define SSM_ACCEPTED(x)                ((x & 0x0F) == SSM_ACCEPT)
-#define SSM_RESPONDED(x)       (x & 0x100)
+#define SSM_ACTION(x)          ((x) & 0x0F)
+#define SSM_PASSED(x)          (SSM_ACTION(x) == SSM_PASS)
+#define SSM_ACCEPTED(x)                (SSM_ACTION(x) == SSM_ACCEPT)
+#define SSM_REJECTED(x)                (SSM_ACTION(x) == SSM_REJECT)
+#define SSM_RESPONDED(x)       ((x) & SSM_RESPONSE)
 
 struct smtpsink_module {
        unsigned ssm_module_index;