diff options
-rw-r--r-- | COPYING | 3 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | blaze822.c | 32 | ||||
-rwxr-xr-x | contrib/mvi | 343 | ||||
-rw-r--r-- | filter.c | 8 | ||||
-rw-r--r-- | maddr.c | 13 | ||||
-rw-r--r-- | man/maddr.1 | 2 | ||||
-rw-r--r-- | man/magrep.1 | 2 | ||||
-rw-r--r-- | man/mblaze.7 | 2 | ||||
-rw-r--r-- | man/mcom.1 | 2 | ||||
-rw-r--r-- | man/mdeliver.1 | 2 | ||||
-rw-r--r-- | man/mdirs.1 | 2 | ||||
-rw-r--r-- | man/mexport.1 | 2 | ||||
-rw-r--r-- | man/mflag.1 | 2 | ||||
-rw-r--r-- | man/mgenmid.1 | 2 | ||||
-rw-r--r-- | man/mhdr.1 | 2 | ||||
-rw-r--r-- | man/minc.1 | 2 | ||||
-rw-r--r-- | man/mless.1 | 2 | ||||
-rw-r--r-- | man/mlist.1 | 2 | ||||
-rw-r--r-- | man/mmime.1 | 2 | ||||
-rw-r--r-- | man/mmsg.7 | 2 | ||||
-rw-r--r-- | man/mpick.1 | 5 | ||||
-rw-r--r-- | man/mscan.1 | 2 | ||||
-rw-r--r-- | man/msed.1 | 2 | ||||
-rw-r--r-- | man/mseq.1 | 2 | ||||
-rw-r--r-- | man/mshow.1 | 2 | ||||
-rw-r--r-- | man/msort.1 | 2 | ||||
-rw-r--r-- | man/mthread.1 | 2 | ||||
-rw-r--r-- | mdirs.c | 4 | ||||
-rw-r--r-- | mexport.c | 8 | ||||
-rw-r--r-- | mflag.c | 32 | ||||
-rw-r--r-- | mgenmid.c | 12 | ||||
-rw-r--r-- | mhdr.c | 25 | ||||
-rw-r--r-- | minc.c | 2 | ||||
-rw-r--r-- | mlist.c | 34 | ||||
-rw-r--r-- | mmime.c | 4 | ||||
-rw-r--r-- | mscan.c | 28 | ||||
-rw-r--r-- | msed.c | 24 | ||||
-rw-r--r-- | mseq.c | 6 | ||||
-rw-r--r-- | mshow.c | 20 | ||||
-rw-r--r-- | msort.c | 8 | ||||
-rw-r--r-- | mytimegm.c | 130 | ||||
-rw-r--r-- | rfc2045.c | 4 | ||||
-rw-r--r-- | seq.c | 14 |
44 files changed, 577 insertions, 226 deletions
diff --git a/COPYING b/COPYING index caee955..4d00555 100644 --- a/COPYING +++ b/COPYING @@ -1,7 +1,6 @@ mblaze is in the public domain. -To the extent possible under law, -Christian Neukirchen <chneukirchen@gmail.com> +To the extent possible under law, Leah Neukirchen <leah@vuxu.org> has waived all copyright and related or neighboring rights to this work. http://creativecommons.org/publicdomain/zero/1.0/ diff --git a/README b/README index 3ae4918..cbdb745 100644 --- a/README +++ b/README @@ -103,7 +103,7 @@ SEE ALSO mailx(1), nmh(7) AUTHORS - Christian Neukirchen <chneukirchen@gmail.com> + Leah Neukirchen <leah@vuxu.org> LICENSE mblaze is in the public domain. diff --git a/blaze822.c b/blaze822.c index d15f4c9..1154e3d 100644 --- a/blaze822.c +++ b/blaze822.c @@ -19,19 +19,19 @@ static long parse_posint(char **s, size_t minn, size_t maxn) { - long n; - char *end; + long n; + char *end; - errno = 0; - n = strtol(*s, &end, 10); - if (errno) + errno = 0; + n = strtol(*s, &end, 10); + if (errno) return -1; - if (n < (long)minn || n > (long)maxn) { + if (n < (long)minn || n > (long)maxn) { errno = ERANGE; return -1; - } - *s = end; - return n; + } + *s = end; + return n; } time_t @@ -60,7 +60,7 @@ blaze822_date(char *s) { while (iswsp(*s)) s++; - if (i3("jan")) tm.tm_mon = 0; + if (i3("jan")) tm.tm_mon = 0; else if (i3("feb")) tm.tm_mon = 1; else if (i3("mar")) tm.tm_mon = 2; else if (i3("apr")) tm.tm_mon = 3; @@ -111,12 +111,12 @@ blaze822_date(char *s) { s++; if ((c = parse_posint(&s, 0, 10000)) < 0) goto fail; if (neg) { - tm.tm_hour += c / 100; - tm.tm_min += c % 100; + tm.tm_hour += c / 100; + tm.tm_min += c % 100; } else { - tm.tm_hour -= c / 100; - tm.tm_min -= c % 100; - } + tm.tm_hour -= c / 100; + tm.tm_min -= c % 100; + } } tm.tm_isdst = -1; @@ -183,7 +183,7 @@ blaze822_addr(char *s, char **dispo, char **addro) } else if (*s == '(') { s++; - if (!*addr) { // assume: user@host (name) + if (!*addr) { // assume: user@host (name) *c-- = 0; while (c > disp && iswsp(*c)) *c-- = 0; diff --git a/contrib/mvi b/contrib/mvi new file mode 100755 index 0000000..412e25c --- /dev/null +++ b/contrib/mvi @@ -0,0 +1,343 @@ +#!/bin/sh + +clear_buf() { + while + tput cup "${i:-0}" 0 && tput el \ + && [ "$(( i+=1 ))" -le "$1" ] + do :; done +} + +term_init() { + cols=$(tput cols) + rows=$(tput lines) + start_headers=$(( rows / 4 )) + start_body=$(( start_headers + 1 )) + end_body=$(( rows - start_body - 2 )) + term_clear_headers=$(clear_buf "$start_headers"; tput cup 0 0) + term_clear_body=$(tput cup "$(( start_body ))" 0; tput ed) + term_move_status=$(tput cup "$(( rows ))" $(( cols - 5 )); tput el) + term_move_cmd=$(tput cup "$(( rows ))" 0) + term_init_cmd=$(tput cnorm; tput el) + term_done_cmd=$(tput civis) +} + +statusline() { + printf "%s%s" "$term_move_status" "$@" +} + +cmdline() { + printf "%s%s:" "$term_move_cmd" "$term_init_cmd" + stty "$stty_default" + tput cnorm + read -r cmd + case "$cmd" in + "|"*) ;; + "!"*) ;; + esac + printf "%s" "$term_done_cmd" + stty -echo -icanon + headers + body +} + +update() { + buf_row=1 + [ "$buf_col" -le 0 ] && buf_col=1 + mshow 2>/dev/null | mcolor \ + | cut -c "$(( buf_col ))-$(( cols + buf_col - 1 ))" \ + | trunc_lines >"$buf_path" + buf_len=$(wc -l <"$buf_path") + : $(( buf_len = buf_len + 1 )) + : $(( buf_end = buf_len - end_body )) + update_body=1 +} + +trunc_lines() { + t=$(tput el) + while read -r l; do + printf "%s%s\n" "$l" "$t" + done +} + +headers() { + printf "%s" "$term_clear_headers" + + : $(( x = hdr_row - (start_headers / 2) )) + : $(( y = hdr_row + (start_headers / 2) )) + + [ "$x" -gt 0 ] && x="+$x" + [ "$y" -gt 0 ] && y="+$y" + + COLUMNS=$cols mscan ".$x:.$y" 2>/dev/null \ + | awk ' +function fg(c, s) { return sprintf("\033[38;5;%03dm%s\033[0m", c, s) } +function so(s) { return sprintf("\033[1m%s\033[0m", s) } +/^>/ { print so(fg(119, $0)); next } +/^ *\\_/ { print fg(242, $0); next } +{ print } +' +} + +body() { + [ "$buf_row" -gt "$buf_end" ] && buf_row=$buf_end + [ "$buf_row" -lt 1 ] && buf_row=1 + + : $(( x = buf_row )) + : $(( y = end_body + buf_row )) + + [ "${update_body}" = "${x},${y}p" ] && return + + printf "%s" "$term_clear_body" + + update_body="${x},${y}p" + sed -n "$update_body" "$buf_path" + + [ "$buf_len" -gt "$end_body" ] \ + && statusline "$(( 100 * y / buf_len ))%" +} + +draw() { + headers + body +} + +init() { + tput smcup # save position + tput civis # cursor invisible + term_init + + stty_default=$(stty -g) + stty -echo -icanon + + update + draw +} + +close() { + tput sgr0 # reset char attributes + tput cnorm # normal cursor + tput rmcup # restore position + stty "$stty_default" # restore stty settings + [ -e "$buf_path" ] && rm "$buf_path" + exit "${1-0}" +} + +motion() { + [ -z "$mv" ] || [ -z "$in_new" ] && return + mseq -C "$in_new"; + mv= + in_new= +} + +readchar() { + c=$(dd bs=1 count=1 2>/dev/null) + printf '%d' "'$c" +} + +in_read() { + set -- $in_buf + [ "$#" -eq 0 ] && in_key=$(readchar) && return + in_key=$1; shift; in_buf=$@ +} + +in_back() { + set -- "$in_key" $in_buf + in_buf=$@ +} + +in_prefix() { + n= + while [ "$in_key" -le 59 ] && [ "$in_key" -ge 47 ]; do + : $(( n = n * 10 + $(printf \\$(printf "%03o" "$in_key")) )) + in_read + done + [ "$1" -eq "1" ] && in_cnt1=${n:-0} || in_cnt2=${n:-0} +} + +in_motion() { + cnt=$(( (in_cnt1 < 1 ? 1 : in_cnt1) * (in_cnt2 < 1 ? 1 : in_cnt2) )) + mv= + case "$in_key" in + # $ + 36) mseq -C "$" ;; + # ^ + 94) mseq -C 1 ;; + # j + 106) mseq -C ".+$cnt" ;; + # k + 107) mseq -C ".-$cnt" ;; + # P + 80) mseq -C "$(mseq ".-1=" | head -n1 | mscan -n)" ;; + # N + 78) mseq -C "$(( $(mseq ".=" | tail -n1 | mscan -n) + 1 ))" ;; + # p + 112) mseq -C "$(mseq "._" | head -n1 | mscan -n)" ;; + # n + 110) mseq -C "$(mseq "._" | tail -n1 | mscan -n)" ;; + # [ + 91) mseq -C "$(mseq ".=" | head -n1 | mscan -n)" ;; + # ] + 93) mseq -C "$(mseq ".=" | tail -n1 | mscan -n)" ;; + esac +} + +in_motionln() { + cnt=$(( (in_cnt1 < 1 ? 1 : in_cnt1) * (in_cnt2 < 1 ? 1 : in_cnt2) )) + mv= + case "$in_key" in + # return + j + 0|43|106) mv=".:.+$cnt"; in_new=".+$cnt" ;; + # - k + 45|107) mv=".-$cnt:."; in_new=".-$cnt" ;; + # G + 71) + [ "$in_cnt1" -eq 0 ] && [ "$in_cnt2" -eq 0 ] \ + && in_new="\$" \ + && mv="$in_cur:$in_new" \ + && return + in_new="$cnt" + [ "$cnt" -gt "$in_cur" ] \ + && mv="$in_cur:$in_new" \ + || mv="$in_new:$in_cur" + ;; + # P [ + 80|91) + in_new=$in_cur + while [ $(( cnt-=1 )) -ge 0 ]; do + j=$(mscan -n "$in_new=" | head -n1) + mv="$j:$in_new $mv" + in_new=$(( j - 1 )) + done + : $(( in_new+=1 )) + # XXX: should [ ] move one more??? + #[ "$in_cur" -eq "$in_new" ] && : $(( in_new-=1 )) + #true + ;; + # N ] + 78|93) + # mv=".:$(mseq ".=" | tail -n1 | mscan -n)" + in_new=$in_cur + while [ $(( cnt-=1 )) -ge 0 ]; do + j=$(mscan -n "$in_new=" | tail -n1) + mv="$mv $in_new:$j" + in_new=$(( j + 1 )) + done + : $(( in_new-=1 )) + #[ "$in_cur" -eq "$in_new" ] && : $(( in_new+=1 )) + #true + ;; + # { + 123) in_new=$(mscan -n ".^" | head -n1); mv="$in_new:." ;; + # } + 125) in_new=$(mscan -n "._" | tail -n1); mv=".:$in_new" ;; + *) false ;; + esac +} + +in_action() { + c=$in_key + + in_read + in_prefix 2 + in_motionln || { [ "$in_key" -eq "$c" ] && mv="."; } + [ -z "$mv" ] && return 1 + + case "$c" in + # d + 100) + mflag -S "$mv" >/dev/null + mseq -f : | mseq -S + motion + headers + ;; + # u + 117) + mflag -s "$mv" >/dev/null + mseq -f : | mseq -S + motion + headers + ;; + esac +} + +in_esc() { + stty min 0 time 1 + c=$(readchar) + rv=0 + case "$c" in + 91) + c=$(readchar) + # page up/down + [ "$c" -eq 53 ] && : $(( buf_row-=end_body )) + [ "$c" -eq 54 ] && : $(( buf_row+=end_body )) + c=$(readchar) + body + ;; + *) c=$(readchar); c=$(readchar); rv=1 ;; + esac + stty min 1 time 0 + return $rv +} + +trap 'close 130;' INT TERM + +buf_path=$(mktemp /tmp/.mcurse_body.XXXXX) + +buf_col=1 +buf_row=1 +buf_len= +buf_end= + +hdr_row=0 + +init + +while :; do + in_buf= + in_key= + in_cnt1=0 + in_cnt2=0 + in_cur=$(mscan -n .) + in_new= + + printf "%s" "$term_move_cmd" + + in_read + + [ "$in_key" -eq 27 ] \ + && in_esc \ + && continue + + in_prefix 1 + + in_motionln \ + && motion \ + && update \ + && draw \ + && continue + + case "$in_key" in + # d u + 100|117) in_action ;; + # D + 68) in_key="100"; in_back; in_action ;; # input buffer to dd + # U + 85) in_key="117"; in_back; in_action ;; # input buffer to uu + # e + 101) ${EDITOR=ed} $(mseq .) && update && draw ;; + # v + 118) ${VISUAL=vi} $(mseq .) && update && draw ;; + # L | C-l + 76|12) tput clear && term_init && update && draw ;; + # : + 58) cmdline ;; + # q + 113) close ;; + # c + 99) hdr_row=0 && headers ;; + # J + 74) : $(( buf_row+=(in_cnt1 < 1 ? 1 : in_cnt1) )) && body ;; + # K + 75) : $(( buf_row-=(in_cnt1 < 1 ? 1 : in_cnt1) )) && body ;; + esac +done diff --git a/filter.c b/filter.c index 87e48ca..7c64bcb 100644 --- a/filter.c +++ b/filter.c @@ -1,4 +1,4 @@ -#include <poll.h> +#include <poll.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -86,11 +86,11 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno) } // ok to fail when closed already - close(pipe0[1]); - close(pipe1[0]); + close(pipe0[1]); + close(pipe1[0]); int status; - waitpid(pid, &status, 0); + waitpid(pid, &status, 0); *outputo = output; *outleno = outlen; diff --git a/maddr.c b/maddr.c index cf6298f..b2dcc44 100644 --- a/maddr.c +++ b/maddr.c @@ -32,20 +32,19 @@ addr(char *file) v = blaze822_chdr(msg, h); if (v) { char *disp, *addr; + char vdec[1024]; + blaze822_decode_rfc2047(vdec, v, sizeof vdec - 1, "UTF-8"); + vdec[sizeof vdec - 1] = 0; + v = vdec; + while ((v = blaze822_addr(v, &disp, &addr))) { if (disp && addr && strcmp(disp, addr) == 0) disp = 0; if (disp && addr) { - char dispdec[1024]; - blaze822_decode_rfc2047(dispdec, disp, - sizeof dispdec - 1, "UTF-8"); - dispdec[sizeof dispdec - 1] = 0; - if (aflag) printf("%s\n", addr); else - printf("%s <%s>\n", - dispdec, addr); + printf("%s <%s>\n", disp, addr); } else if (addr) { printf("%s\n", addr); } diff --git a/man/maddr.1 b/man/maddr.1 index 56d30f4..743ad85 100644 --- a/man/maddr.1 +++ b/man/maddr.1 @@ -50,7 +50,7 @@ and the same with .Sh SEE ALSO .Xr mmsg 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/magrep.1 b/man/magrep.1 index df16470..4c83127 100644 --- a/man/magrep.1 +++ b/man/magrep.1 @@ -86,7 +86,7 @@ and with exit status higher than 1 if an error occurred. .Xr mmsg 7 , .Xr regex 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh TRIVIA .Nm is not called mgrep because many tools with this name already exist. diff --git a/man/mblaze.7 b/man/mblaze.7 index 88485d0..7a860b1 100644 --- a/man/mblaze.7 +++ b/man/mblaze.7 @@ -159,7 +159,7 @@ For scripting, you must make these arguments explicit. .Xr mailx 1 , .Xr nmh 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mcom.1 b/man/mcom.1 index 18a4dda..17fc240 100644 --- a/man/mcom.1 +++ b/man/mcom.1 @@ -70,7 +70,7 @@ Default signature. .Xr mmime 1 , .Xr mmsg 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mdeliver.1 b/man/mdeliver.1 index 0f48536..40f5a0d 100644 --- a/man/mdeliver.1 +++ b/man/mdeliver.1 @@ -78,7 +78,7 @@ the flags of the new message file to be .Pp .Lk https://cr.yp.to/proto/maildir.html "Using maildir format" .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mdirs.1 b/man/mdirs.1 index 457eeaa..ddd3171 100644 --- a/man/mdirs.1 +++ b/man/mdirs.1 @@ -29,7 +29,7 @@ need to start with .Sh SEE ALSO .Xr find 1 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mexport.1 b/man/mexport.1 index 9b0f5ee..edc13fe 100644 --- a/man/mexport.1 +++ b/man/mexport.1 @@ -53,7 +53,7 @@ headers according to the Maildir flags. .Pp .Lk https://cr.yp.to/proto/maildir.html "Using maildir format" .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mflag.1 b/man/mflag.1 index a8f3c1b..35d5b10 100644 --- a/man/mflag.1 +++ b/man/mflag.1 @@ -101,7 +101,7 @@ link is updated in all cases, when affected. .Pp .Lk https://cr.yp.to/proto/maildir.html "Using maildir format" .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mgenmid.1 b/man/mgenmid.1 index 9d8f646..c0eff76 100644 --- a/man/mgenmid.1 +++ b/man/mgenmid.1 @@ -45,7 +45,7 @@ fails. .%T Recommendations for generating Message IDs .Re .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mhdr.1 b/man/mhdr.1 index efd4fbf..ddfb1ba 100644 --- a/man/mhdr.1 +++ b/man/mhdr.1 @@ -66,7 +66,7 @@ and >1 if an error occurs. .%D October 2008 .Re .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/minc.1 b/man/minc.1 index ff1d3be..4ea7100 100644 --- a/man/minc.1 +++ b/man/minc.1 @@ -30,7 +30,7 @@ Don't print the new Maildir files. .Sh SEE ALSO .Lk https://cr.yp.to/proto/maildir.html "Using maildir format" .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mless.1 b/man/mless.1 index 87132d4..fea1992 100644 --- a/man/mless.1 +++ b/man/mless.1 @@ -50,7 +50,7 @@ to read the next (resp. previous) message. .Xr mshow 1 , .Xr mmsg 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mlist.1 b/man/mlist.1 index 1c5a472..1ec0679 100644 --- a/man/mlist.1 +++ b/man/mlist.1 @@ -84,7 +84,7 @@ Multiple options are regarded as a conjunction. .Pp .Lk https://cr.yp.to/proto/maildir.html "Using maildir format" .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mmime.1 b/man/mmime.1 index f0660b6..4385e28 100644 --- a/man/mmime.1 +++ b/man/mmime.1 @@ -68,7 +68,7 @@ message. .%D October 2008 .Re .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mmsg.7 b/man/mmsg.7 index f792bac..3809f19 100644 --- a/man/mmsg.7 +++ b/man/mmsg.7 @@ -92,4 +92,4 @@ refers to the last message (like .Sq Li -1 ) . .El .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org diff --git a/man/mpick.1 b/man/mpick.1 index cbf2ad1..5e1b9d2 100644 --- a/man/mpick.1 +++ b/man/mpick.1 @@ -139,11 +139,14 @@ tests are given by the following EBNF: .Ed .Sh EXIT STATUS .Ex -std +.Sh EXAMPLES +You can use mpick to filter mail by moving them across Maildir inboxes. +.Dl mv $(mlist ./INBOX | mpick -t 'from ~~~ \&"github\&"') ./github/cur .Sh SEE ALSO .Xr lr 1 , .Xr mailx 1 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .An Duncan Overbruck Aq Mt mail@duncano.de .Sh LICENSE .Nm diff --git a/man/mscan.1 b/man/mscan.1 index f7d12ae..47f26b6 100644 --- a/man/mscan.1 +++ b/man/mscan.1 @@ -170,7 +170,7 @@ You are in .Sh SEE ALSO .Xr mmsg 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/msed.1 b/man/msed.1 index a74e50e..cdffcd1 100644 --- a/man/msed.1 +++ b/man/msed.1 @@ -116,7 +116,7 @@ contains the letter .Xr mmsg 7 , .Xr regex 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mseq.1 b/man/mseq.1 index 07f33aa..78bf02f 100644 --- a/man/mseq.1 +++ b/man/mseq.1 @@ -91,7 +91,7 @@ File were the sequence is stored. .Sh SEE ALSO .Xr mmsg 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mshow.1 b/man/mshow.1 index 90cba25..bcce6b4 100644 --- a/man/mshow.1 +++ b/man/mshow.1 @@ -118,7 +118,7 @@ if known. .Sh SEE ALSO .Xr mmsg 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/msort.1 b/man/msort.1 index 8b9fb38..91ae80c 100644 --- a/man/msort.1 +++ b/man/msort.1 @@ -54,7 +54,7 @@ Sort flagged messages before unflagged messages. .Sh SEE ALSO .Xr mmsg 7 .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/man/mthread.1 b/man/mthread.1 index fd1484a..d4fd69f 100644 --- a/man/mthread.1 +++ b/man/mthread.1 @@ -38,7 +38,7 @@ Do not prune unresolved Message-IDs at the top-level. .Pp .Lk https://www.jwz.org/doc/threading.html "Message threading" .Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE .Nm is in the public domain. diff --git a/mdirs.c b/mdirs.c index 4213924..e133ed7 100644 --- a/mdirs.c +++ b/mdirs.c @@ -19,7 +19,7 @@ void mdirs(char *fpath) { DIR *dir; - struct dirent *d; + struct dirent *d; struct stat st; dir = opendir(fpath); @@ -63,7 +63,7 @@ mdirs(char *fpath) if (chdir("..") < 0) exit(-1); - closedir(dir); + closedir(dir); } int diff --git a/mexport.c b/mexport.c index 7c31609..60a986d 100644 --- a/mexport.c +++ b/mexport.c @@ -29,8 +29,8 @@ export(char *file) char from[1024] = "nobody"; - char *v; - if ((v = blaze822_hdr(msg, "return-path")) || + char *v; + if ((v = blaze822_hdr(msg, "return-path")) || (v = blaze822_hdr(msg, "x-envelope-from"))) { char *s = strchr(v, '<'); char *e = strchr(s, '>'); @@ -39,10 +39,10 @@ export(char *file) memcpy(from, s, e-s); from[e-s] = 0; } - } + } time_t date = -1; - if ((v = blaze822_hdr(msg, "date"))) { + if ((v = blaze822_hdr(msg, "date"))) { date = blaze822_date(v); } diff --git a/mflag.c b/mflag.c index 87ce67e..852caa9 100644 --- a/mflag.c +++ b/mflag.c @@ -26,16 +26,18 @@ char *curfile; void add(char *file) { - if (idx >= argsalloc) { - argsalloc *= 2; - if (argsalloc < 0) - exit(-1); - args = realloc(args, sizeof (char *) * argsalloc); - } - if (!args) - exit(-1); - args[idx] = strdup(file); - idx++; + if (idx >= argsalloc) { + argsalloc *= 2; + if (argsalloc < 0) + exit(-1); + args = realloc(args, sizeof (char *) * argsalloc); + } + if (!args) + exit(-1); + while (*file == ' ' || *file == '\t') + file++; + args[idx] = strdup(file); + idx++; } void @@ -85,7 +87,7 @@ doit: *t = 0; if (rename(file+indent, dst+indent) < 0) { - fprintf(stderr, "minc: can't rename '%s' to '%s': %s\n", + fprintf(stderr, "mflag: can't rename '%s' to '%s': %s\n", file+indent, dst+indent, strerror(errno)); goto skip; } @@ -115,11 +117,11 @@ main(int argc, char *argv[]) case 'p': case 'r': case 's': case 't': case 'd': case 'f': flags[(unsigned int)uc(c)] = -1; break; - case 'X': + case 'X': while (*optarg) flags[(unsigned int)*optarg++] = 1; break; - case 'x': + case 'x': while (*optarg) flags[(unsigned int)*optarg++] = -1; break; @@ -127,8 +129,8 @@ main(int argc, char *argv[]) default: fprintf(stderr, "Usage: mflag [-DFPRST] [-X str]\n" - " [-dfprst] [-x str]\n" - " [-v] [msgs...]\n" + " [-dfprst] [-x str]\n" + " [-v] [msgs...]\n" ); exit(1); } diff --git a/mgenmid.c b/mgenmid.c index a9b878b..7464daa 100644 --- a/mgenmid.c +++ b/mgenmid.c @@ -103,14 +103,14 @@ fallback: rnd |= (1LL << 63); // set highest bit to force full width - putchar('<'); + putchar('<'); printb36(((uint64_t)tp.tv_sec << 16) + (tp.tv_nsec >> 16)); - putchar('.'); + putchar('.'); printb36(rnd); - putchar('@'); + putchar('@'); fputs(host, stdout); - putchar('>'); - putchar('\n'); + putchar('>'); + putchar('\n'); - return 0; + return 0; } diff --git a/mhdr.c b/mhdr.c index 25f5a89..839625f 100644 --- a/mhdr.c +++ b/mhdr.c @@ -61,21 +61,22 @@ void print_addresses(char *s) { char *disp, *addr; + char sdec[4096]; + + if (dflag) { + blaze822_decode_rfc2047(sdec, s, sizeof sdec, "UTF-8"); + sdec[sizeof sdec - 1] = 0; + s = sdec; + } + while ((s = blaze822_addr(s, &disp, &addr))) { - if (Hflag && (disp || addr)) + if (Hflag && addr) printf("%s\t", curfile); - if (disp && addr) { - if (dflag) { - char d[4096]; - blaze822_decode_rfc2047(d, disp, sizeof d, - "UTF-8"); - printf("%s <%s>\n", d, addr); - } else { - printf("%s <%s>\n", disp, addr); - } - } else if (addr) { + + if (disp && addr) + printf("%s <%s>\n", disp, addr); + else if (addr) printf("%s\n", addr); - } } } diff --git a/minc.c b/minc.c index a8e6cb9..7246763 100644 --- a/minc.c +++ b/minc.c @@ -19,7 +19,7 @@ void inc(char *dir) { DIR *fd; - struct dirent *d; + struct dirent *d; char src[PATH_MAX]; char dst[PATH_MAX]; diff --git a/mlist.c b/mlist.c index 0f7bd88..82eea73 100644 --- a/mlist.c +++ b/mlist.c @@ -93,11 +93,11 @@ list(char *prefix, char *file) #include <sys/syscall.h> struct linux_dirent64 { - ino64_t d_ino; /* 64-bit inode number */ - off64_t d_off; /* 64-bit offset to next structure */ + ino64_t d_ino; /* 64-bit inode number */ + off64_t d_off; /* 64-bit offset to next structure */ unsigned short d_reclen; /* Size of this dirent */ - unsigned char d_type; /* File type */ - char d_name[]; /* Filename (null-terminated) */ + unsigned char d_type; /* File type */ + char d_name[]; /* Filename (null-terminated) */ }; #define BUF_SIZE 1024000 @@ -144,7 +144,7 @@ void listdir(char *dir) { DIR *fd; - struct dirent *d; + struct dirent *d; fd = opendir(dir); if (!fd) @@ -222,11 +222,11 @@ main(int argc, char *argv[]) case 'p': case 'r': case 's': case 't': case 'd': case 'f': flags[(unsigned int)uc(c)] = -1; break; - case 'X': + case 'X': while (*optarg) flags[(unsigned int)*optarg++] = 1; break; - case 'x': + case 'x': while (*optarg) flags[(unsigned int)*optarg++] = -1; break; @@ -239,14 +239,14 @@ main(int argc, char *argv[]) usage: fprintf(stderr, "Usage: mlist [-DFPRST] [-X str]\n" - " [-dfprst] [-x str]\n" - " [-N | -n | -C | -c]\n" - " [-i] [dirs...]\n" + " [-dfprst] [-x str]\n" + " [-N | -n | -C | -c]\n" + " [-i] [dirs...]\n" ); exit(1); } - int i; + int i; for (i = 0, flagsum = 0, flagset = 0; (size_t)i < sizeof flags; i++) { if (flags[i] != 0) @@ -255,10 +255,14 @@ main(int argc, char *argv[]) flagsum++; } - if (optind == argc && isatty(0)) - goto usage; - else - blaze822_loop(argc-optind, argv+optind, listarg); + if (optind == argc) { + if (isatty(0)) + goto usage; + blaze822_loop(0, 0, listarg); + } else { + for (i = optind; i < argc; i++) + listarg(argv[i]); + } if (iflag && imatched) printf("%6ld unseen %3ld flagged %6ld msg\n", diff --git a/mmime.c b/mmime.c index 4f2dd4f..78bd757 100644 --- a/mmime.c +++ b/mmime.c @@ -104,8 +104,8 @@ int gen_qp(uint8_t *s, off_t size, int maxlinelen, int header) static const char * basenam(const char *s) { - char *r = strrchr(s, '/'); - return r ? r + 1 : s; + char *r = strrchr(s, '/'); + return r ? r + 1 : s; } int gen_file(char *file, char *ct) diff --git a/mscan.c b/mscan.c index 39115c5..992148d 100644 --- a/mscan.c +++ b/mscan.c @@ -143,7 +143,7 @@ fmt_date(struct message *msg, int w, int iso) else if (tm->tm_yday != curyday) strftime(date, sizeof date, "%a %b %e", tm); else - strftime(date, sizeof date, "%a %H:%M", tm); + strftime(date, sizeof date, "%a %H:%M", tm); } return date; @@ -173,7 +173,7 @@ fmt_subject(struct message *msg, char *file, int strip) i++; continue; } else if (strncasecmp("re:", subjdec+i, 3) == 0 || - strncasecmp("aw:", subjdec+i, 3) == 0) { + strncasecmp("aw:", subjdec+i, 3) == 0) { i += 3; continue; } else if (strncasecmp("fwd:", subjdec+i, 4) == 0) { @@ -191,21 +191,24 @@ fmt_subject(struct message *msg, char *file, int strip) static char * fmt_from(struct message *msg) { - static char fromdec[64]; + static char fromdec[256]; char *from = "(unknown)"; - char to[256]; char *v, *w; if (!msg) return ""; - if ((v = blaze822_hdr(msg, "from"))) { - if (itsme(v) && ((w = blaze822_hdr(msg, "to")))) { - snprintf(to, sizeof to, "TO:%s", w); - from = to; + if ((v = blaze822_hdr(msg, "from"))) { + blaze822_decode_rfc2047(fromdec, v, sizeof fromdec - 1, "UTF-8"); + fromdec[sizeof fromdec - 1] = 0; + from = fromdec; + + if (itsme(fromdec) && ((w = blaze822_hdr(msg, "to")))) { + snprintf(fromdec, sizeof fromdec, "TO:%s", w); + from = fromdec; } else { char *disp, *addr; - blaze822_addr(v, &disp, &addr); + blaze822_addr(fromdec, &disp, &addr); if (disp) from = disp; else if (addr) @@ -213,10 +216,7 @@ fmt_from(struct message *msg) } } - blaze822_decode_rfc2047(fromdec, from, sizeof fromdec - 1, "UTF-8"); - fromdec[sizeof fromdec - 1] = 0; - - return fromdec; + return from; } static char * @@ -505,7 +505,7 @@ main(int argc, char *argv[]) curyear = tm->tm_year; curyday = tm->tm_yday; - setlocale(LC_ALL, ""); // for wcwidth later + setlocale(LC_ALL, ""); // for wcwidth later if (wcwidth(0xfffd) > 0) replacement = 0xfffd; diff --git a/msed.c b/msed.c index 20a720b..5c82745 100644 --- a/msed.c +++ b/msed.c @@ -80,17 +80,17 @@ subst(char *str, char *srch, char *repl, char *flags) void printhdr(char *hdr, int rest) { - int uc = 1; + int uc = 1; - while (*hdr && *hdr != ':') { - putc(uc ? toupper(*hdr) : *hdr, stdout); - uc = (*hdr == '-'); - hdr++; - } + while (*hdr && *hdr != ':') { + putc(uc ? toupper(*hdr) : *hdr, stdout); + uc = (*hdr == '-'); + hdr++; + } - if (rest) { - printf("%s\n", hdr); - } + if (rest) { + printf("%s\n", hdr); + } } void @@ -101,7 +101,7 @@ sed(char *file) return; char *h = 0; - while ((h = blaze822_next_header(msg, h))) { + while ((h = blaze822_next_header(msg, h))) { regex_t headerrx; char headersel[1024]; @@ -215,7 +215,7 @@ sed(char *file) printf(": %s\n", v); free(v); } - } + } // loop, do all a// @@ -283,7 +283,7 @@ sed(char *file) } while (*e && *e != ';' && *e != '\n') e++; - } + } printf("\n"); fwrite(blaze822_body(msg), 1, blaze822_bodylen(msg), stdout); diff --git a/mseq.c b/mseq.c index 00ec844..4ceacf2 100644 --- a/mseq.c +++ b/mseq.c @@ -273,9 +273,9 @@ main(int argc, char *argv[]) usage: fprintf(stderr, "Usage: mseq [-fr] [-c msg] [msgs...]\n" - " mseq -S [-fr] < sequence\n" - " mseq -A [-fr] < sequence\n" - " mseq -C msg\n" + " mseq -S [-fr] < sequence\n" + " mseq -A [-fr] < sequence\n" + " mseq -C msg\n" ); exit(1); } diff --git a/mshow.c b/mshow.c index 4342ed2..38242f9 100644 --- a/mshow.c +++ b/mshow.c @@ -93,7 +93,7 @@ print_u8recode(char *body, size_t bodylen, char *srcenc) final_char = bufptr[-1]; } - if (r != (size_t)-1) { // done, flush iconv + if (r != (size_t)-1) { // done, flush iconv bufptr = buf; buflen = sizeof buf; r = iconv(ic, 0, 0, &bufptr, &buflen); @@ -389,8 +389,8 @@ static int extract_stdout; static const char * basenam(const char *s) { - char *r = strrchr(s, '/'); - return r ? r + 1 : s; + char *r = strrchr(s, '/'); + return r ? r + 1 : s; } static int @@ -702,16 +702,16 @@ main(int argc, char *argv[]) case 'O': Oflag = optarg; break; case 'R': Rflag = 1; break; case 'n': nflag = 1; break; - default: + default: fprintf(stderr, "Usage: mshow [-h headers] [-A mimetypes] [-qrHL] [msgs...]\n" - " mshow -x msg parts...\n" - " mshow -O msg parts...\n" - " mshow -t msgs...\n" - " mshow -R msg\n" + " mshow -x msg parts...\n" + " mshow -O msg parts...\n" + " mshow -t msgs...\n" + " mshow -R msg\n" ); - exit(1); - } + exit(1); + } if (xflag) { // extract extract(xflag, argc-optind, argv+optind, 0); diff --git a/msort.c b/msort.c index 323717a..e364a83 100644 --- a/msort.c +++ b/msort.c @@ -78,10 +78,10 @@ fetch_from(char *file) char *v = blaze822_hdr(msg, "from"); if (v) { char *disp, *addr; - blaze822_addr(v, &disp, &addr); - if (disp) - from = strdup(disp); - else if (addr) + blaze822_addr(v, &disp, &addr); + if (disp) + from = strdup(disp); + else if (addr) from = strdup(addr); } diff --git a/mytimegm.c b/mytimegm.c index 3d3fccd..7b63b2f 100644 --- a/mytimegm.c +++ b/mytimegm.c @@ -5,82 +5,82 @@ static long long __year_to_secs(long long year, int *is_leap) { - 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; - } + 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; + 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; - } - } + 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; + leaps += 97*cycles + 24*centuries - *is_leap; - return (year-100) * 31536000LL + leaps * 86400LL + 946684800 + 86400; + 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; + 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--; - month += 12; - } - year += adj; - } - 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; + 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--; + month += 12; + } + year += adj; + } + 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; } diff --git a/rfc2045.c b/rfc2045.c index fec445d..a13608c 100644 --- a/rfc2045.c +++ b/rfc2045.c @@ -13,7 +13,7 @@ char textplain[] = "text/plain; charset=US-ASCII"; int blaze822_check_mime(struct message *msg) { - char *v = blaze822_hdr(msg, "mime-version"); + char *v = blaze822_hdr(msg, "mime-version"); if (v && v[0] && v[0] == '1' && v[1] && v[1] == '.' && @@ -35,7 +35,7 @@ blaze822_mime_body(struct message *msg, *bodyleno = 0; *bodychunko = 0; return 0; - } + } char *ct = blaze822_hdr(msg, "content-type"); char *cte = blaze822_hdr(msg, "content-transfer-encoding"); diff --git a/seq.c b/seq.c index 4fd6c28..f1fb6b1 100644 --- a/seq.c +++ b/seq.c @@ -72,19 +72,19 @@ struct msgnum { int msgnumorder(const void *a, const void *b) { - struct msgnum *ia = (struct msgnum *)a; - struct msgnum *ib = (struct msgnum *)b; + struct msgnum *ia = (struct msgnum *)a; + struct msgnum *ib = (struct msgnum *)b; - return strcmp(ia->file, ib->file); + return strcmp(ia->file, ib->file); } long blaze822_seq_find(char *file) { struct msgnum key, **result; - key.file = file; + key.file = file; - if (!(result = tfind(&key, &msgnums, msgnumorder))) + if (!(result = tfind(&key, &msgnums, msgnumorder))) return 0; return (*result)->pos; @@ -128,7 +128,7 @@ blaze822_seq_load(char *map) char * blaze822_seq_cur(void) { - static char b[PATH_MAX]; + static char b[PATH_MAX]; char *override = getenv("MAILDOT"); if (override) @@ -455,7 +455,7 @@ static long iterdir(char *dir, void (*cb)(char *)) { DIR *fd, *fd2; - struct dirent *d; + struct dirent *d; long i = 0; |