You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by so...@apache.org on 2005/08/23 19:00:31 UTC
svn commit: r239435 - in /httpd/mod_smtpd/trunk: smtp.h smtp_core.c
Author: soc-rian
Date: Tue Aug 23 10:00:29 2005
New Revision: 239435
URL: http://svn.apache.org/viewcvs?rev=239435&view=rev
Log:
Made changes to everyone hook is a "run all" hook. Had to modify run_hook
implementor macro to return OK if one returns OK and DECLINED if all hooks
return DECLINED.
Modified:
httpd/mod_smtpd/trunk/smtp.h
httpd/mod_smtpd/trunk/smtp_core.c
Modified: httpd/mod_smtpd/trunk/smtp.h
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/smtp.h?rev=239435&r1=239434&r2=239435&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/smtp.h (original)
+++ httpd/mod_smtpd/trunk/smtp.h Tue Aug 23 10:00:29 2005
@@ -22,6 +22,45 @@
extern "C" {
#endif
+/**
+ * Implement an optional hook that runs until one of the functions
+ * returns something other than OK or DECLINE.
+ *
+ * @param ns The namespace prefix of the hook functions
+ * @param link The linkage declaration prefix of the hook
+ * @param ret The type of the return value of the hook
+ * @param ret The type of the return value of the hook
+ * @param name The name of the hook
+ * @param args_decl The declaration of the arguments for the hook
+ * @param args_use The names for the arguments for the hook
+ * @param ok Success value
+ * @param decline Decline value
+ */
+#define APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(ns,link,ret,name,args_decl,args_use,ok,decline) \
+link##_DECLARE(ret) ns##_run_##name args_decl \
+ { \
+ ns##_LINK_##name##_t *pHook; \
+ int n; \
+ ret rv; ret endrv = decline;\
+ apr_array_header_t *pHookArray=apr_optional_hook_get(#name); \
+\
+ if(!pHookArray) \
+ return ok; \
+\
+ pHook=(ns##_LINK_##name##_t *)pHookArray->elts; \
+ for(n=0 ; n < pHookArray->nelts ; ++n) \
+ { \
+ rv=(pHook[n].pFunc)args_use; \
+\
+ if(rv != ok && rv != decline) \
+ return rv; \
+\
+ if(rv == ok) \
+ endrv = ok; \
+ } \
+ return endrv; \
+ }
+
/* SMTP handlers registration */
#define HANDLER_PROTOTYPE smtpd_conn_rec *scr, char *buffer, smtpd_return_data *in_data, void *data
Modified: httpd/mod_smtpd/trunk/smtp_core.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/smtp_core.c?rev=239435&r1=239434&r2=239435&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/smtp_core.c (original)
+++ httpd/mod_smtpd/trunk/smtp_core.c Tue Aug 23 10:00:29 2005
@@ -45,81 +45,81 @@
static apr_hash_t *smtpd_handlers;
/* Implement 'smtpd_run_unrecognized_command'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode,
- unrecognized_command,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in,
- char *command, char *data),
- (scr, in, command, data),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode,
+ unrecognized_command,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in,
+ char *command, char *data),
+ (scr, in, command, data),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_connect'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, connect,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in),
- (scr, in),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, connect,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in),
+ (scr, in),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_reset_transaction'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode,
- reset_transaction,
- (smtpd_conn_rec *scr),
- (scr),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode,
+ reset_transaction,
+ (smtpd_conn_rec *scr),
+ (scr),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_helo'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, helo,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in, char *str),
- (scr, in, str),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, helo,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in, char *str),
+ (scr, in, str),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_ehlo'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, ehlo,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in, char *str),
- (scr, in, str),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, ehlo,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in, char *str),
+ (scr, in, str),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_mail'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, mail,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in, char *str),
- (scr, in, str),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, mail,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in, char *str),
+ (scr, in, str),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_rcpt'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, rcpt,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in, char *str),
- (scr, in, str),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, rcpt,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in, char *str),
+ (scr, in, str),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_vrfy'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, vrfy,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in, char *str),
- (scr, in, str),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, vrfy,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in, char *str),
+ (scr, in, str),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_quit'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, quit,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in),
- (scr, in),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, quit,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in),
+ (scr, in),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_data'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, data,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in),
- (scr, in),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, data,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in),
+ (scr, in),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_data_post'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode,
- data_post,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in),
- (scr, in),
- SMTPD_DECLINED, SMTPD_DECLINED);
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode,
+ data_post,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in),
+ (scr, in),
+ SMTPD_OK, SMTPD_DECLINED);
/* Implement 'smtpd_run_queue'. */
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(smtpd, SMTPD, smtpd_retcode, queue,
- (smtpd_conn_rec *scr,
- smtpd_return_data *in),
- (scr, in),
- SMTPD_DECLINED, SMTPD_OK);
-
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL_MOD(smtpd, SMTPD, smtpd_retcode, queue,
+ (smtpd_conn_rec *scr,
+ smtpd_return_data *in),
+ (scr, in),
+ SMTPD_OK, SMTPD_DECLINED);
+
/* public methods */
/* functions other modules can use */