1# @configure_input@                                     -*- shell-script -*-
2# Configurable variable values for Mailutils test suite.
3# Copyright (C) 2004-2021 Free Software Foundation, Inc.
4
5PATH=@abs_builddir@:@abs_top_builddir@/testsuite:@abs_top_builddir@/mh:$top_srcdir:$srcdir:$PATH
6spooldir=$abs_top_srcdir/testsuite/spool/
7MHETCDIR=@abs_top_srcdir@/mh/etc
8
9# mimeflt [FILE]
10# Filter out all variable information from a MIME message in FILE.
11# If FILE is not given, filter stdin.
12# "Variable information" means part boundary and Content-ID header values.
13# These elements are likely to change between invocations of mhn -build.
14#
15# Stderr is redirected to /dev/null because "one true awk" (used, in
16# particular, on FreeBSD) complains when closing stdin fails, even if
17# it did not use it at all (it fails because stdin is closed earlier by
18# MH_SETUP).
19mimeflt() {
20awk '
21/^Content-Type:/ {
22  if (match($0, /boundary=".*"/)) {
23    s=substr($0,RSTART+10,RLENGTH-11)
24    boundary[++boundary_num] = s
25    sub(/boundary=".*"/,"boundary=\"BOUNDARY-" boundary_num "\"")
26  }
27}
28/^X-IMAPbase:/ { next }
29/^Content-ID:/ {
30	content_id[$2]++
31	print "Content-ID:", ++content_id_num
32	next
33}
34{
35  if ($0 == ("--" boundary[boundary_num])) {
36    print "--BOUNDARY-" boundary_num
37  } else if ($0 == ("--" boundary[boundary_num] "--")) {
38    print "--BOUNDARY-" boundary_num "--"
39    boundary_num--
40  } else
41    print
42}
43' $* 2>/dev/null
44}
45