mirror of https://github.com/leahneukirchen/mblaze
Compare commits
No commits in common. 'master' and 'v0.5' have entirely different histories.
@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
# mcount - count mails from sequence on stdin
|
||||
|
||||
[ -t 1 ] && stdout=1
|
||||
|
||||
awk -v stdout=$stdout '
|
||||
!/^ *</ { n++ }
|
||||
!stdout { print }
|
||||
END { fflush(); print n " mails processed" > "/dev/stderr" }
|
||||
'
|
@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
# mmailto mailto:... - mailto: handler spawning mcom in a terminal emulator
|
||||
|
||||
tryterm() {
|
||||
if [ -z "$TERMINAL" ] && command -v "$1" >/dev/null; then
|
||||
TERMINAL="$*"
|
||||
fi
|
||||
}
|
||||
|
||||
tryterm x-terminal-emulator
|
||||
tryterm urxvt
|
||||
tryterm xterm
|
||||
|
||||
if [ -z "$TERMINAL" ]; then
|
||||
echo 'No terminal emulator found, set $TERMINAL.' 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IFS='
|
||||
'
|
||||
|
||||
exec $TERMINAL -e mcom $(
|
||||
awk -v url="$1" '
|
||||
|
||||
function decode(s) {
|
||||
hexdigits = "0123456789abcdef"
|
||||
for (i = 1; i < length(s); i++) {
|
||||
if (substr(s, i, 3) ~ /%[0-9a-fA-F][0-9a-fA-F]/) {
|
||||
c = sprintf("%c", (index(hexdigits, tolower(substr(s, i+1, 1)))-1) * 16 + \
|
||||
index(hexdigits, tolower(substr(s, i+2, 1)))-1)
|
||||
if (c == "\n") c = " "
|
||||
s = substr(s, 1, i-1) c substr(s, i+3)
|
||||
i += 2
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
url = decode(url)
|
||||
sub(/^mailto:/, "", url)
|
||||
split(url, parts, "?")
|
||||
to = parts[1]
|
||||
split(parts[2], fields, "&")
|
||||
args[1] = to
|
||||
for (i in fields) {
|
||||
split(fields[i], kv, "=")
|
||||
if (kv[1] != "r") {
|
||||
args[length(args)+1] = "-" kv[1]
|
||||
args[length(args)+1] = kv[2]
|
||||
}
|
||||
}
|
||||
for (i in args) {
|
||||
print decode(args[i])
|
||||
}
|
||||
}
|
||||
'
|
||||
)
|
@ -1,18 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
# mopenall [MSG] - open every attachements in xdg-open
|
||||
|
||||
[ "$#" -eq 0 ] && set -- .
|
||||
|
||||
f="$(mseq "$1" | sed 1q)"
|
||||
[ -z "$f" ] && printf 'No message %s.\n' "$1" 1>&2 && exit 1
|
||||
|
||||
dir=$(mktemp -d -t menter.XXXXXX)
|
||||
cd "$dir"
|
||||
mshow -t "$1"
|
||||
mshow -B -x "$1" 2>/dev/null
|
||||
for f in * ; do
|
||||
xdg-open "$f" &
|
||||
done
|
||||
wait
|
||||
echo rm -r "$dir"
|
||||
rm -r "$dir"
|
@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
# mrecode - recode stdin respecting PIPE_CHARSET into UTF-8
|
||||
|
||||
case "$PIPE_CHARSET" in
|
||||
''|*[Uu][Nn][Kk][Nn][Oo][Ww][Nn]*) exec cat;;
|
||||
*) exec iconv -f "$PIPE_CHARSET" -t UTF-8;;
|
||||
esac
|
||||
|
||||
if [ -n "$PIPE_CHARSET" ]; then
|
||||
exec iconv -f "$PIPE_CHARSET" -t UTF-8
|
||||
else
|
||||
exec cat
|
||||
fi
|
||||
|
@ -1,28 +1,86 @@
|
||||
#include <time.h>
|
||||
|
||||
time_t
|
||||
mytimegm(struct tm *tm)
|
||||
// from musl@1cc81f5cb, slightly tweaked
|
||||
|
||||
static long long
|
||||
__year_to_secs(long long year, int *is_leap)
|
||||
{
|
||||
int mon = tm->tm_mon + 1 - 2; /* put March first, Feb last */
|
||||
long long year = tm->tm_year + 1900;
|
||||
if (year-2ULL <= 136) {
|
||||
int y = year;
|
||||
int leaps = (y-68)>>2;
|
||||
if (!((y-68)&3)) {
|
||||
leaps--;
|
||||
if (is_leap) *is_leap = 1;
|
||||
} else if (is_leap) *is_leap = 0;
|
||||
return 31536000*(y-70) + 86400*leaps;
|
||||
}
|
||||
|
||||
int cycles, centuries, leaps, rem;
|
||||
|
||||
cycles = (year-100) / 400;
|
||||
rem = (year-100) % 400;
|
||||
if (rem < 0) {
|
||||
cycles--;
|
||||
rem += 400;
|
||||
}
|
||||
if (!rem) {
|
||||
*is_leap = 1;
|
||||
centuries = 0;
|
||||
leaps = 0;
|
||||
} else {
|
||||
if (rem >= 200) {
|
||||
if (rem >= 300) centuries = 3, rem -= 300;
|
||||
else centuries = 2, rem -= 200;
|
||||
} else {
|
||||
if (rem >= 100) centuries = 1, rem -= 100;
|
||||
else centuries = 0;
|
||||
}
|
||||
if (!rem) {
|
||||
*is_leap = 0;
|
||||
leaps = 0;
|
||||
} else {
|
||||
leaps = rem / 4U;
|
||||
rem %= 4U;
|
||||
*is_leap = !rem;
|
||||
}
|
||||
}
|
||||
|
||||
leaps += 97*cycles + 24*centuries - *is_leap;
|
||||
|
||||
if (mon <= 0 || mon >= 12) {
|
||||
int adj = mon / 12;
|
||||
mon %= 12;
|
||||
if (mon <= 0) {
|
||||
return (year-100) * 31536000LL + leaps * 86400LL + 946684800 + 86400;
|
||||
}
|
||||
|
||||
static int
|
||||
__month_to_secs(int month, int is_leap)
|
||||
{
|
||||
static const int secs_through_month[] = {
|
||||
0, 31*86400, 59*86400, 90*86400,
|
||||
120*86400, 151*86400, 181*86400, 212*86400,
|
||||
243*86400, 273*86400, 304*86400, 334*86400 };
|
||||
int t = secs_through_month[month];
|
||||
if (is_leap && month >= 2) t+=86400;
|
||||
return t;
|
||||
}
|
||||
|
||||
time_t tm_to_secs(const struct tm *tm)
|
||||
{
|
||||
int is_leap;
|
||||
long long year = tm->tm_year;
|
||||
int month = tm->tm_mon;
|
||||
if (month >= 12 || month < 0) {
|
||||
int adj = month / 12;
|
||||
month %= 12;
|
||||
if (month < 0) {
|
||||
adj--;
|
||||
mon += 12;
|
||||
month += 12;
|
||||
}
|
||||
year += adj;
|
||||
}
|
||||
|
||||
time_t t = 0;
|
||||
t += tm->tm_sec;
|
||||
t += 60 * tm->tm_min;
|
||||
t += 60*60 * tm->tm_hour;
|
||||
t += 24*60*60 * (tm->tm_mday - 1);
|
||||
t += 24*60*60 * (367*mon/12);
|
||||
t += 24*60*60 * (year/4 - year/100 + year/400);
|
||||
t += 24*60*60 * (365*year - 719498L);
|
||||
long long t = __year_to_secs(year, &is_leap);
|
||||
t += __month_to_secs(month, is_leap);
|
||||
t += 86400LL * (tm->tm_mday-1);
|
||||
t += 3600LL * tm->tm_hour;
|
||||
t += 60LL * tm->tm_min;
|
||||
t += tm->tm_sec;
|
||||
return t;
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
cd ${0%/*}
|
||||
. ./lib.sh
|
||||
|
||||
plan 9
|
||||
|
||||
cat <<EOF >tmp
|
||||
Header: foo
|
||||
Header2: bar
|
||||
Header-Three: quux
|
||||
Header_Four: ding
|
||||
|
||||
Body
|
||||
EOF
|
||||
|
||||
check_same 'Header' 'mhdr -h Header ./tmp' 'echo foo'
|
||||
check_same 'Header2' 'mhdr -h Header2 ./tmp' 'echo bar'
|
||||
check_same 'Header-Three' 'mhdr -h Header-Three ./tmp' 'echo quux'
|
||||
check_same 'Header_Four' 'mhdr -h Header_Four ./tmp' 'echo ding'
|
||||
|
||||
check_same 'header' 'mhdr -h header ./tmp' 'echo foo'
|
||||
check_same 'header2' 'mhdr -h header2 ./tmp' 'echo bar'
|
||||
check_same 'header-Three' 'mhdr -h header-Three ./tmp' 'echo quux'
|
||||
check_same 'header_Four' 'mhdr -h header_Four ./tmp' 'echo ding'
|
||||
|
||||
check 'issue 235' 'mhdr ./tmp |grep -i header_four'
|
@ -1,41 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
cd ${0%/*}
|
||||
. ./lib.sh
|
||||
plan 2
|
||||
|
||||
# Nested MIME where the outer boundary is a prefix of the inner boundary
|
||||
cat <<EOF >tmp
|
||||
MIME-Version: 1.0
|
||||
Content-type: multipart/mixed; charset=iso-8859-1;
|
||||
boundary="_xec5AqfRYxfhARmklHx"
|
||||
|
||||
|
||||
--_xec5AqfRYxfhARmklHx
|
||||
Content-type: Multipart/alternative; charset=iso-8859-1;
|
||||
boundary="_xec5AqfRYxfhARmklHx8"
|
||||
|
||||
|
||||
--_xec5AqfRYxfhARmklHx8
|
||||
Content-type: text/plain; charset=iso-8859-1
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Disposition: inline
|
||||
|
||||
foo
|
||||
--_xec5AqfRYxfhARmklHx8
|
||||
Content-type: text/html; charset=iso-8859-1
|
||||
Content-Transfer-Encoding: Quoted-printable
|
||||
Content-Disposition: inline
|
||||
|
||||
bar
|
||||
--_xec5AqfRYxfhARmklHx8--
|
||||
|
||||
--_xec5AqfRYxfhARmklHx
|
||||
Content-Type: application/zip
|
||||
Content-Transfer-Encoding: Base64
|
||||
|
||||
quux
|
||||
--_xec5AqfRYxfhARmklHx--
|
||||
EOF
|
||||
|
||||
check 'nested mail has 5 attachments' 'mshow -t ./tmp | wc -l | grep 6'
|
||||
check 'nested mail has text/html attachment' 'mshow -t ./tmp | grep text/html'
|
@ -1,53 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
cd ${0%/*}
|
||||
. ./lib.sh
|
||||
plan 3
|
||||
|
||||
# Mail with \n\n and \r\n\r\n
|
||||
cr=$(printf '\r')
|
||||
cat <<EOF >tmp
|
||||
Content-Type: multipart/form-data; boundary=------------------------55a586f81559face$cr
|
||||
$cr
|
||||
--------------------------55a586f81559face$cr
|
||||
Content-Disposition: form-data; name="a"; filename="foo"$cr
|
||||
Content-Type: application/octet-stream$cr
|
||||
$cr
|
||||
foo$cr
|
||||
|
||||
previously there are two NL$cr
|
||||
$cr
|
||||
--------------------------55a586f81559face$cr
|
||||
Content-Disposition: form-data; name="a"; filename="bar"$cr
|
||||
Content-Type: application/octet-stream$cr
|
||||
$cr
|
||||
bar$cr
|
||||
$cr
|
||||
--------------------------55a586f81559face--$cr
|
||||
EOF
|
||||
|
||||
check 'mail has 3 attachments' 'mshow -t ./tmp | wc -l | grep 4'
|
||||
check 'mail attachment foo has size 35' 'mshow -t ./tmp | grep size=35.*name=\"foo\"'
|
||||
|
||||
# Mail with linebreaks in base64 quartets
|
||||
cat <<EOF >tmp
|
||||
Subject: base64
|
||||
MIME-Version: 1.0
|
||||
Content-Type: multipart/mixed; boundary="----_=_2f8f1e2243b55f8618eaf0d9_=_"
|
||||
|
||||
This is a multipart message in MIME format.
|
||||
|
||||
------_=_2f8f1e2243b55f8618eaf0d9_=_
|
||||
Content-Disposition: attachment; filename=base64
|
||||
Content-Type: application/binary
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
dGhp
|
||||
cyBpc
|
||||
yBzb21
|
||||
lIGJhc2
|
||||
U2NAo=
|
||||
|
||||
------_=_2f8f1e2243b55f8618eaf0d9_=_--
|
||||
EOF
|
||||
|
||||
check 'mail decodes correctly' 'mshow -O ./tmp 2 | grep -q "this is some base64"'
|
@ -1,26 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
cd ${0%/*}
|
||||
. ./lib.sh
|
||||
plan 2
|
||||
|
||||
cat <<EOF >tmp.1
|
||||
Subject: message 1
|
||||
|
||||
This is message 1.
|
||||
EOF
|
||||
|
||||
cat <<EOF >tmp.2
|
||||
Subject: message 2
|
||||
|
||||
This is message 2. It has a trailing empty line.
|
||||
|
||||
EOF
|
||||
|
||||
printf >tmp.3 'Subject: message 3
|
||||
|
||||
This is message 3. It has a no trailing newline, oops.'
|
||||
|
||||
mexport ./tmp.1 ./tmp.2 ./tmp.3 >./tmp.mbox
|
||||
|
||||
check 'generated mbox has 16 lines' 'cat ./tmp.mbox | wc -l | grep 16'
|
||||
check 'generated mbox has 7 empty lines' 'grep -c "^$" ./tmp.mbox | grep 7'
|
@ -1,85 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
cd ${0%/*}
|
||||
. ./lib.sh
|
||||
plan 9
|
||||
|
||||
rm -rf test.dir
|
||||
mkdir test.dir
|
||||
cd test.dir
|
||||
|
||||
mmkdir inbox
|
||||
|
||||
cat <<EOF >tmp.1
|
||||
Subject: message 1
|
||||
|
||||
This is message 1.
|
||||
EOF
|
||||
|
||||
cat <<EOF >tmp.2
|
||||
Subject: message 2
|
||||
|
||||
This is message 2. It has a trailing empty line.
|
||||
|
||||
EOF
|
||||
|
||||
printf >tmp.3 'Subject: message 3
|
||||
|
||||
This is message 3. It has a no trailing newline, oops.'
|
||||
|
||||
cat <<EOF >tmp.4
|
||||
Subject: message 4
|
||||
|
||||
|
||||
|
||||
This is message 4. It has multiple trailing empty lines.
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
mexport ./tmp.1 | mdeliver -M inbox/
|
||||
check 'message 1 is delivered verbatim via mbox' 'cmp ./tmp.1 ./inbox/new/*:2,'
|
||||
rm -f ./inbox/new/*
|
||||
|
||||
mexport ./tmp.2 | mdeliver -M inbox/
|
||||
check 'message 2 is delivered verbatim via mbox' 'cmp ./tmp.2 ./inbox/new/*:2,'
|
||||
rm -f ./inbox/new/*
|
||||
|
||||
mexport ./tmp.3 | mdeliver -M inbox/
|
||||
check 'message 3 gets a newline via mbox' 'awk 1 ./tmp.3 | cmp - ./inbox/new/*:2,'
|
||||
rm -f ./inbox/new/*
|
||||
|
||||
mexport ./tmp.4 | mdeliver -M inbox/
|
||||
check 'message 4 gets delivered verbatim via mbox' 'cmp ./tmp.4 ./inbox/new/*:2,'
|
||||
rm -f ./inbox/new/*
|
||||
|
||||
mdeliver inbox/ <./tmp.1
|
||||
check 'message 1 is delivered verbatim via stdin' 'cmp ./tmp.1 ./inbox/new/*:2,'
|
||||
rm -f ./inbox/new/*
|
||||
|
||||
mdeliver inbox/ <./tmp.2
|
||||
check 'message 2 is delivered verbatim via stdin' 'cmp ./tmp.2 ./inbox/new/*:2,'
|
||||
rm -f ./inbox/new/*
|
||||
|
||||
mdeliver inbox/ <./tmp.3
|
||||
check 'message 3 gets a newline via stdin' 'cmp ./tmp.3 ./inbox/new/*:2,'
|
||||
rm -f ./inbox/new/*
|
||||
|
||||
mdeliver inbox/ <./tmp.4
|
||||
check 'message 4 is delivered verbatim via stdin' 'cmp ./tmp.4 ./inbox/new/*:2,'
|
||||
rm -f ./inbox/new/*
|
||||
|
||||
|
||||
cat <<EOF >tmp.mbox
|
||||
From nobody Thu Jan 1 00:59:59 1970
|
||||
Subject: message 1
|
||||
|
||||
This is message 1.
|
||||
From nobody Thu Jan 1 00:59:59 1970
|
||||
Subject: message 2
|
||||
|
||||
This is message 2.
|
||||
|
||||
EOF
|
||||
|
||||
mdeliver -M inbox/ <./tmp.mbox
|
||||
check 'mdeliver -M is tolerant with missing empty lines' 'ls inbox/new | wc -l | grep 2'
|
@ -1,166 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
cd ${0%/*}
|
||||
. ./lib.sh
|
||||
plan 12
|
||||
|
||||
rm -rf test.dir
|
||||
mkdir test.dir
|
||||
(
|
||||
cd test.dir
|
||||
|
||||
export PIPE_CONTENTTYPE='text/plain; format=flowed'
|
||||
export COLUMNS=80
|
||||
|
||||
cat <<! >a
|
||||
this
|
||||
is
|
||||
flowed.
|
||||
!
|
||||
cat <<! >b
|
||||
this is flowed.
|
||||
!
|
||||
check 'simple reflow' 'mflow <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
this
|
||||
is
|
||||
two spaces.
|
||||
!
|
||||
cat <<! >b
|
||||
this is two spaces.
|
||||
!
|
||||
check 'simple space stuffing' 'mflow <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
this
|
||||
is
|
||||
flowed.
|
||||
this is fixed.
|
||||
!
|
||||
cat <<! >b
|
||||
this is flowed.
|
||||
this is fixed.
|
||||
!
|
||||
check 'simple fixed' 'mflow <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
> this
|
||||
> is
|
||||
> quoted.
|
||||
this
|
||||
is
|
||||
unquoted.
|
||||
!
|
||||
cat <<! >b
|
||||
> this is quoted.
|
||||
this is unquoted.
|
||||
!
|
||||
check 'simple quoted' 'mflow <a | cmp - b'
|
||||
|
||||
(
|
||||
export PIPE_CONTENTTYPE='text/plain; format=flowed; delsp=yes'
|
||||
|
||||
cat <<! >a
|
||||
> this
|
||||
> is
|
||||
> delsp.
|
||||
|
||||
> double
|
||||
> spaced
|
||||
!
|
||||
cat <<! >b
|
||||
> thisisdelsp.
|
||||
|
||||
> double spaced
|
||||
!
|
||||
check 'simple delsp' 'mflow <a | cmp - b'
|
||||
)
|
||||
|
||||
cat <<! >a
|
||||
this
|
||||
is
|
||||
way more than eighty chars which is the terminal width to flow.
|
||||
this
|
||||
is
|
||||
way more than eighty chars which is the terminal width to flow.
|
||||
!
|
||||
cat <<! >b
|
||||
this is way more than eighty chars which is the terminal width to flow. this is
|
||||
way more than eighty chars which is the terminal width to flow.
|
||||
!
|
||||
check 'simple wrap' 'mflow <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
this
|
||||
is
|
||||
way more than eighty chars which is the terminal width to flow.
|
||||
averylongwordcomeshere.
|
||||
this
|
||||
is
|
||||
way more than eighty chars which is the terminal width to flow.
|
||||
!
|
||||
cat <<! >b
|
||||
this is way more than eighty chars which is the terminal width to flow.
|
||||
averylongwordcomeshere. this is way more than eighty chars which is the
|
||||
terminal width to flow.
|
||||
!
|
||||
check 'more complex wrap' 'mflow <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
foo
|
||||
bar.
|
||||
|
||||
quux.
|
||||
!
|
||||
cat <<! >b
|
||||
foo bar.
|
||||
|
||||
quux.
|
||||
!
|
||||
check 'space before empty line' 'mflow <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
Aaaaa bbbbb ccccc ddddd eeeee aaaaa bbbbb ccccc ddddd eeeee
|
||||
aaaaa bbbbb ccccc ddddd eeeee aaaaa bbbbb ccccc ddddd eeeee
|
||||
aaaaa bbbbb ccccc
|
||||
ffffff gggggg hhhhhh iiiiii.
|
||||
!
|
||||
cat <<! >b
|
||||
Aaaaa bbbbb ccccc ddddd eeeee aaaaa bbbbb ccccc ddddd eeeee aaaaa bbbbb ccccc
|
||||
ddddd eeeee aaaaa bbbbb ccccc ddddd eeeee aaaaa bbbbb ccccc ffffff gggggg
|
||||
hhhhhh iiiiii.
|
||||
!
|
||||
check 'fixed lines are wrapped too' 'mflow <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
some
|
||||
wrapped.
|
||||
--
|
||||
signature
|
||||
!
|
||||
cat <<! >b
|
||||
some wrapped.
|
||||
--
|
||||
signature
|
||||
!
|
||||
check 'passes usenet signature marker as is' 'mflow <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
some regular text being force wrapped because the line is way too long oh no who writes so long lines.
|
||||
!
|
||||
cat <<! >b
|
||||
some regular text being force wrapped because the line is way too long oh no
|
||||
who writes so long lines.
|
||||
!
|
||||
check 'force wrapping' 'mflow -f <a | cmp - b'
|
||||
|
||||
cat <<! >a
|
||||
> some regular text being force wrapped because the line is way too long oh no who writes so long lines.
|
||||
!
|
||||
cat <<! >b
|
||||
> some regular text being force wrapped because the line is way too long oh no
|
||||
> who writes so long lines.
|
||||
!
|
||||
check 'force wrapping of quoted text' 'mflow -f <a | cmp - b'
|
||||
|
||||
)
|
@ -1,26 +0,0 @@
|
||||
#ifndef PLEDGE_H
|
||||
#define PLEDGE_H
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
|
||||
#ifndef _BSD_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
#endif
|
||||
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
xpledge(const char *promises, const char *execpromises)
|
||||
{
|
||||
if (pledge(promises, execpromises) == -1)
|
||||
err(1, "pledge");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define xpledge(promises, execpromises) do { } while(0)
|
||||
|
||||
#endif /* __OpenBSD__ */
|
||||
|
||||
#endif /* PLEDGE_H */
|
Loading…
Reference in New Issue