ze-filter  (ze-filter-0.8.0-develop-180218)
mlfi_cleanup.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * ze-filter - Mail Server Filter for sendmail
5  *
6  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
7  *
8  * Auteur : Jose Marcio Martins da Cruz
9  * jose.marcio.mc@gmail.org
10  *
11  * Historique :
12  * Creation : janvier 2002
13  *
14  * This program is free software, but with restricted license :
15  *
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * More details about ze-filter license can be found at ze-filter
22  * web site : http://foss.jose-marcio.org
23  */
24 
25 
26 /* ****************************************************************************
27  * *
28  * *
29  ******************************************************************************/
30 sfsistat
32  SMFICTX *ctx;
33  bool ok;
34 
35 {
36  sfsistat rstat = SMFIS_CONTINUE;
37  CTXPRIV_T *priv = MLFIPRIV(ctx);
38 
39  if (priv == NULL)
40  return rstat;
41  (void) free_private_data(priv, ok);
42  if (ok)
43  smfi_setpriv(ctx, NULL);
44  /*
45  * return status
46  */
47  return rstat;
48 }
49 
50 
51 /* ****************************************************************************
52  * *
53  * *
54  ******************************************************************************/
55 void
57  MSG_T *msg;
58 
59 {
60  if (msg == NULL)
61  return;
62  FREE(msg->virus);
63 }
64 
65 bool
67  CTXPRIV_T *priv;
68  bool ok;
69 
70 {
71  if (priv == NULL)
72  return TRUE;
73 
74  /*
75  * release private memory
76  */
77  free_message(&(priv->msg));
78  FREE(priv->sm_msgid);
79  FREE(priv->reply_code);
80  FREE(priv->env_from);
81  FREE(priv->env_to);
82  FREE(priv->hdr_mailer);
83  FREE(priv->hdr_from);
84  FREE(priv->hdr_to);
85 
86 #if _FFR_DELAYED_REJECT
88 #endif
89 
90  priv->env_rcpt = rcpt_list_free(priv->env_rcpt);
91  priv->env_rcpt = NULL;
92  priv->env_nb_rcpt = 0;
93  priv->rej_greyrcpt = 0;
94  priv->pass_ok = FALSE;
96  *priv->body_chunk = '\0';
97  memset(priv->body_chunk, 0, sizeof (priv->body_chunk));
98  priv->body_res_scan = 0;
99  priv->body_nb = 0;
100  priv->body_scan_state = 0;
102  priv->lcontent = NULL;
104  memset(&priv->tcontent, 0, sizeof (priv->tcontent));
105  priv->msg_size = 0;
106  priv->msg_short = FALSE;
107  FREE(priv->score_str);
108  FREE(priv->status_str);
109  priv->dbrcpt_msg_unknown = 0;
110  priv->dbrcpt_msg_spamtrap = 0;
111  if (!spool_file_forget(priv))
112  ZE_LogMsgError(0, "spool_file_forget error");
113  priv->save_msg = FALSE;
114  priv->save_why = 0;
115  FREE(priv->hdr_subject);
116  priv->headers = clear_msgheader_list(priv->headers);
117  memset(&priv->spamchk, 0, sizeof (priv->spamchk));
118  memset(&priv->rawScores, 0, sizeof (priv->rawScores));
119  memset(&priv->netScores, 0, sizeof (priv->netScores));
120  memset(&priv->dspScores, 0, sizeof (priv->dspScores));
121  if (ok) {
122  FREE(priv->mailserver);
123  FREE(priv->peer_addr);
124  FREE(priv->peer_name);
125  FREE(priv->ident);
126  FREE(priv->helohost);
127  FREE(priv->daemon);
128  FREE(priv);
129  }
130 
131  /*
132  * return status
133  */
134  return TRUE;
135 }
rcpt_addr_T * env_rcpt
char * virus
msg_scores_T rawScores
void free_content_field_rec(content_field_T *)
Definition: ze-mimelist.c:176
sfsistat mlfi_cleanup(SMFICTX *ctx, bool ok)
Definition: mlfi_cleanup.c:31
#define FREE(x)
Definition: macros.h:37
char * peer_addr
char * reply_code
bool ok
Definition: ze-connopen.c:59
int hdr_content_encoding
void free_message(MSG_T *msg)
Definition: mlfi_cleanup.c:56
char * hdr_mailer
#define FALSE
Definition: macros.h:160
#define SMFIS_CONTINUE
#define ZE_LogMsgError(level,...)
Definition: zeSyslog.h:113
char * env_to
#define MLFIPRIV(ctx)
#define FREE_DELAYED_RESULT(dres)
Definition: ze-filter.c:171
int dbrcpt_msg_spamtrap
bool spool_file_forget(CTXPRIV_T *)
Definition: ze-spool.c:245
unsigned long msg_size
content_field_T tcontent
char * mailserver
char * hdr_to
char * daemon
#define TRUE
Definition: macros.h:157
int dbrcpt_msg_unknown
dresult_T delayed_result
bool free_private_data(CTXPRIV_T *priv, bool ok)
Definition: mlfi_cleanup.c:66
content_field_T * lcontent
char body_chunk[SZ_CHUNK]
header_T * headers
char * peer_name
msg_scores_T netScores
char * env_from
char * helohost
header_T * clear_msgheader_list(header_T *)
Definition: ze-headers.c:93
char * score_str
void free_content_field_list(content_field_T *)
Definition: ze-mimelist.c:201
char * ident
int body_scan_state
char * status_str
char * hdr_subject
rcpt_addr_T * rcpt_list_free(rcpt_addr_T *)
Definition: ze-rcpt-list.c:36
char * hdr_from
#define MIME_ENCODE_NONE
Definition: ze-demime.h:44
msg_scores_T dspScores
int msg[MAX_SCORE+2]
Definition: ze-stats.c:41
char * sm_msgid
spamchk_T spamchk