Commit 31c81ae3 authored by Timo Sirainen's avatar Timo Sirainen Committed by Johannes Berg

use T_BEGIN/T_END

Johannes: Timo's patch, adjusted to fix compilation and carry
          a backport for dovecot 1.0 in case somebody still
          uses that

For the original (although modified by somebody else to compile):
Acked-by: 's avatarPhil Carmody <phil@dovecot.fi>
parent eba2805c
......@@ -90,7 +90,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
return FALSE;
#endif
t_push();
T_BEGIN {
boxname = mailbox_get_name(box);
if (lowercase) {
......@@ -110,7 +110,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
rc = memcmp(name, boxname, len) == 0;
t_pop();
} T_END;
return rc;
}
......@@ -257,7 +257,7 @@ static int parse_folder_setting(const struct antispam_config *cfg,
int cnt = 0;
enum match_type i;
t_push();
T_BEGIN {
for (i = 0; i < NUM_MT; ++i) {
tmp = getenv(t_strconcat(setting, match_info[i].suffix, NULL),
......@@ -286,7 +286,7 @@ static int parse_folder_setting(const struct antispam_config *cfg,
}
}
t_pop();
} T_END;
if (!cnt)
debug(&cfg->dbgcfg, "no %s folders\n", display_name);
......
......@@ -217,6 +217,11 @@ static inline int _mail_get_stream(struct mail *mail,
return 0;
}
#define mail_get_stream _mail_get_stream
#define T_BEGIN \
STMT_START { t_push();
#define T_END \
t_pop(); } STMT_END
#elif DOVECOT_IS_EQ(1, 1)
#define mempool_unref pool_unref
#define module_arg void
......@@ -260,10 +265,6 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
#define module_arg struct module *
#define ME(err) MAIL_ERROR_ ##err,
#if DOVECOT_P_IS_GE(2,2,14)
#define t_push() t_push(__func__)
#endif
static inline const char *const *
get_mail_headers(struct mail *mail, const char *hdr)
{
......
......@@ -508,10 +508,10 @@ void antispam_mail_storage_created(struct mail_storage *storage)
static const char *_getenv(const char *env, void *data ATTR_UNUSED)
{
t_push();
T_BEGIN {
env = t_str_ucase(t_strconcat("antispam_", env, NULL));
env = getenv(env);
t_pop();
} T_END;
return env;
}
......
......@@ -498,10 +498,10 @@ void antispam_mail_storage_created(struct mail_storage *storage)
static const char *_getenv(const char *env, void *data ATTR_UNUSED)
{
t_push();
T_BEGIN {
env = t_str_ucase(t_strconcat("antispam_", env, NULL));
env = getenv(env);
t_pop();
} T_END;
return env;
}
......
......@@ -494,11 +494,11 @@ static const char *_getenv(const char *name, void *data)
struct mail_user *user = data;
const char *env;
t_push();
T_BEGIN {
env = t_strconcat("antispam_", t_str_lcase(name), NULL);
env = mail_user_plugin_getenv(user, env);
t_pop();
} T_END;
return env;
}
......
......@@ -113,7 +113,7 @@ static int call_reaver(const struct antispam_config *cfg,
debugv(&cfg->dbgcfg, argv);
t_push();
T_BEGIN {
for (i = 0; i < cfg->crm.extra_env_num; i++) {
char *name, *value;
name = t_strdup_noconst(cfg->crm.extra_env[i]);
......@@ -124,7 +124,7 @@ static int call_reaver(const struct antispam_config *cfg,
}
setenv(name, value, 1);
}
t_pop();
} T_END;
execv(cfg->crm.reaver_binary, argv);
/* fall through if reaver can't be found */
......
......@@ -14,7 +14,7 @@ static void _debug(const struct antispam_debug_config *cfg,
if (cfg->target == ADT_NONE)
return;
t_push();
T_BEGIN {
fmt = t_strconcat("antispam: ", format, NULL);
......@@ -30,7 +30,7 @@ static void _debug(const struct antispam_debug_config *cfg,
break;
}
t_pop();
} T_END;
}
void debug(const struct antispam_debug_config *cfg, const char *fmt, ...)
......@@ -48,7 +48,7 @@ void debugv(const struct antispam_debug_config *cfg, char **args)
char *buf;
const char *str;
t_push();
T_BEGIN {
buf = t_buffer_get(buflen);
while (1) {
......@@ -72,7 +72,7 @@ void debugv(const struct antispam_debug_config *cfg, char **args)
t_buffer_alloc(pos);
debug(cfg, "%s", buf);
t_pop();
} T_END;
}
void debugv_not_stderr(const struct antispam_debug_config *cfg, char **args)
......
......@@ -141,7 +141,7 @@ static int call_dspam(const struct antispam_config *cfg,
*/
debugv_not_stderr(&cfg->dbgcfg, argv);
t_push();
T_BEGIN {
for (i = 0; i < cfg->dspam.extra_env_num; i++) {
char *name, *value;
name = t_strdup_noconst(cfg->dspam.extra_env[i]);
......@@ -152,7 +152,7 @@ static int call_dspam(const struct antispam_config *cfg,
}
setenv(name, value, 1);
}
t_pop();
} T_END;
execv(cfg->dspam.binary, argv);
debug(&cfg->dbgcfg, "executing %s failed: %d (uid=%d, gid=%d)",
......
......@@ -136,7 +136,7 @@ static int process_tmpdir(const struct antispam_config *cfg,
enum classification wanted;
int rc = 0;
t_push();
T_BEGIN {
buf = t_malloc(20 + ast->tmplen);
......@@ -159,7 +159,7 @@ static int process_tmpdir(const struct antispam_config *cfg,
close(fd);
}
t_pop();
} T_END;
return rc;
}
......@@ -168,7 +168,7 @@ static void clear_tmpdir(struct antispam_transaction_context *ast)
{
char *buf;
t_push();
T_BEGIN {
buf = t_malloc(20 + ast->tmplen);
......@@ -180,7 +180,7 @@ static void clear_tmpdir(struct antispam_transaction_context *ast)
}
rmdir(ast->tmpdir);
t_pop();
} T_END;
}
static void backend_rollback(const struct antispam_config *cfg ATTR_UNUSED,
......@@ -250,7 +250,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
return -1;
}
t_push();
T_BEGIN {
buf = t_malloc(20 + ast->tmplen);
i_snprintf(buf, 20 + ast->tmplen - 1, "%s/%d", ast->tmpdir, ast->count);
......@@ -311,8 +311,8 @@ static int backend_handle_mail(const struct antispam_config *cfg,
o_stream_destroy(&outstream);
out_close:
close(fd);
out:
t_pop();
out: ;
} T_END;
return ret;
}
......
......@@ -165,7 +165,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
return -1;
}
t_push();
T_BEGIN {
/* atomically create a _new_ file */
while (ast->count <= 9999) {
......@@ -174,9 +174,6 @@ static int backend_handle_mail(const struct antispam_config *cfg,
if (fd >= 0 || errno != EEXIST)
break;
/* current filename in buf already exists, zap it */
t_pop();
t_push();
/* buf is invalid now! */
}
if (fd < 0) {
......@@ -225,8 +222,8 @@ static int backend_handle_mail(const struct antispam_config *cfg,
close(fd);
if (ret)
unlink(buf);
out:
t_pop();
out: ;
} T_END;
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment