109 #ifdef STRCASECMP_IN_STRINGS_H
177 #define STRING_AND_LEN(x) (x), (sizeof(x) - 1)
222 #define STR(x) vstring_str(x)
265 bounce_template_reset(tp);
271 if (buffer && origin) {
294 msg_panic(
"bounce_template_parse_buffer: nothing to do here");
300 #define CLEANUP_AND_RETURN() do { \
301 bounce_template_reset(tp); \
312 #define GETLINE(line, buf) \
313 (((line) = (buf)) != 0 ? ((buf) = split_at((buf), '\n'), (line)) : 0)
316 for (hval = cp + hlen; *hval && (*hval ==
':' ||
ISSPACE(*hval)); hval++)
319 msg_warn(
"%s: empty \"%s\" header value in %s template "
320 "-- ignoring this template",
325 msg_warn(
"%s: non-ASCII \"%s\" header value in %s template "
326 "-- ignoring this template",
336 }
else if (
strcasecmp(
"postmaster-subject", cp) == 0) {
338 msg_warn(
"%s: inapplicable \"%s\" header label in %s template "
339 "-- ignoring this template",
345 msg_warn(
"%s: unknown \"%s\" header label in %s template "
346 "-- ignoring this template",
355 while (cp && (*cp == 0 ||
allspace(cp)))
358 msg_warn(
"%s: missing message text in %s template "
359 "-- ignoring this template",
368 #define NON_ASCII(p) ((p) && *(p) && !allascii((p)))
372 msg_warn(
"%s: 8-bit message text in %s template",
374 msg_warn(
"please specify a charset value other than us-ascii");
375 msg_warn(
"-- ignoring this template for now");
386 cpp = (
char **)
mymalloc(
sizeof(*cpp) * cpp_len);
388 cpp[cpp_used++] = cp;
389 if (cpp_used >= cpp_len) {
391 sizeof(*cpp) * 2 * cpp_len);
402 static const char *bounce_template_lookup(
const char *key,
int unused_mode,
412 const char *utf8_val;
418 for (bp = time_parameter; bp->
param_name; bp++) {
421 for (bd = time_divisors; bd->
suffix; bd++) {
424 if (result > 999 && bd->
divisor < 86400) {
425 msg_warn(
"%s: excessive result \"%d\" in %s "
426 "template conversion of parameter \"%s\"",
428 msg_warn(
"please increase time unit \"%s\" of \"%s\" "
430 msg_warn(
"for instructions see the bounce(5) manual");
431 }
else if (result == 0 && bp->
value[0] && bd->
divisor > 1) {
432 msg_warn(
"%s: zero result in %s template "
433 "conversion of parameter \"%s\"",
435 msg_warn(
"please reduce time unit \"%s\" of \"%s\" "
437 msg_warn(
"for instructions see the bounce(5) manual");
445 msg_fatal(
"%s: unrecognized suffix \"%s\" in parameter \"%s\"",
457 for (sp = str_parameter; sp->
param_name; sp++) {
459 asc_val = sp->
value[0];
461 msg_warn(
"%s: conversion \"%s\" failed: "
462 "non-ASCII input value: \"%s\"",
463 tp->
origin, key, asc_val);
466 msg_warn(
"%s: conversion \"%s\" failed: "
467 "input value: \"%s\"",
468 tp->
origin, key, asc_val);
488 bounce_template_parse_buffer(tp);
490 out_fn(fp,
"From: %s", tp->
from);
493 out_fn(fp,
"To: %s", rcpt);
506 bounce_template_parse_buffer(tp);
510 bounce_template_lookup, (
void *) tp);
512 msg_fatal(
"%s: bad $name syntax in %s template: %s",
515 msg_fatal(
"%s: undefined $name in %s template: %s",
517 out_fn(fp,
STR(buf));
529 bounce_template_parse_buffer(tp);
const char * mime_charset
#define BOUNCE_TMPL_FLAG_NEW_BUFFER
#define MAC_EXP_FLAG_PRINTABLE
char * mystrdup(const char *str)
#define STRING_AND_LEN(x)
int mac_expand(VSTRING *result, const char *pattern, int flags, const char *filter, MAC_EXP_LOOKUP_FN lookup, void *context)
NORETURN msg_panic(const char *fmt,...)
void * myrealloc(void *ptr, ssize_t len)
const struct BOUNCE_TEMPLATE * prototype
void bounce_template_free(BOUNCE_TEMPLATE *tp)
int allspace(const char *string)
VSTREAM * vstream_fprintf(VSTREAM *stream, const char *fmt,...)
const char * midna_domain_to_utf8(const char *name)
const char ** message_text
void msg_warn(const char *fmt,...)
VSTRING * vstring_alloc(ssize_t len)
#define VAR_DELAY_WARN_TIME
VSTRING * vstring_sprintf(VSTRING *vp, const char *format,...)
void bounce_template_expand(BOUNCE_XP_PUT_FN out_fn, VSTREAM *fp, BOUNCE_TEMPLATE *tp)
BOUNCE_TEMPLATE * bounce_template_create(const BOUNCE_TEMPLATE *prototype)
NORETURN msg_fatal(const char *fmt,...)
const char * mail_conf_lookup_eval(const char *name)
const char * mime_encoding
int strcasecmp(const char *s1, const char *s2)
VSTRING * vstring_free(VSTRING *vp)
int const char typedef int(* BOUNCE_XP_PUT_FN)(VSTREAM *, const char *)
#define MAIL_ATTR_ENC_8BIT
void bounce_template_headers(BOUNCE_XP_PRN_FN out_fn, VSTREAM *fp, BOUNCE_TEMPLATE *tp, const char *rcpt, int postmaster_copy)
void bounce_template_dump(VSTREAM *fp, BOUNCE_TEMPLATE *tp)
void bounce_template_load(BOUNCE_TEMPLATE *tp, const char *origin, const char *buffer)
#define CLEANUP_AND_RETURN()
#define GETLINE(line, buf)
#define VAR_MAX_QUEUE_TIME
void * mymalloc(ssize_t len)
const char * postmaster_subject