💾 Archived View for gem.sdf.org › jquah › extracurriculars › myblaze.patch captured on 2022-04-28 at 17:58:49.
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
--- mblaze-1.1/GNUmakefile 2021-01-14 10:45:22.000000000 -0500 +++ mblaze-1.1f/GNUmakefile 2021-05-31 19:11:33.146804008 -0400 @@ -15,7 +15,7 @@ endif DESTDIR= -PREFIX=/usr/local +PREFIX=/usr BINDIR=$(PREFIX)/bin MANDIR=$(PREFIX)/share/man @@ -62,6 +62,7 @@ ln -sf mcom $(DESTDIR)$(BINDIR)/mfwd ln -sf mcom $(DESTDIR)$(BINDIR)/mrep ln -sf mdeliver $(DESTDIR)$(BINDIR)/mrefile + ln -sf mdeliver $(DESTDIR)$(BINDIR)/mdelete install -m0644 man/*.1 $(DESTDIR)$(MANDIR)/man1 install -m0644 man/*.5 $(DESTDIR)$(MANDIR)/man5 install -m0644 man/*.7 $(DESTDIR)$(MANDIR)/man7 --- mblaze-1.1/mdeliver.c 2021-01-14 10:45:22.000000000 -0500 +++ mblaze-1.1f/mdeliver.c 2021-05-31 19:01:02.500148004 -0400 @@ -287,6 +287,22 @@ unlink(file); } +void +mdelete(char *file) + { + while (*file == ' ' || *file == '\t') + file++; + + if (!kflag) { + unlink(file); + if (vflag) + fprintf(stderr, "Messages deleted.\n"); + } + + if (kflag) + fprintf(stderr, "Deletion command overridden.\n"); + } + int main(int argc, char *argv[]) { @@ -323,6 +339,32 @@ return 0; } + if (strchr(argv[0], 't')) { + // mdelete(1) + + int c; + while ((c = getopt(argc, argv, "kv")) != -1) + switch (c) { + case 'k': kflag = 1; break; + case 'v': vflag = 1; break; + default: +usage3: + fprintf(stderr, + "Usage: mdelete [-kv] [msgs]... \n"); + exit(1); + } + + if (argc == optind - 1) + goto usage3; + + if (argc == optind && isatty(0)) + goto usage3; + else + blaze822_loop(argc - optind, argv + optind, mdelete); + + return 0; + } + int c; while ((c = getopt(argc, argv, "cMvX:")) != -1) switch (c) { --- mblaze-1.1/mmime.c 2021-01-14 10:45:22.000000000 -0500 +++ mblaze-1.1f/mmime.c 2021-06-12 20:35:09.994308179 -0400 @@ -134,6 +134,68 @@ return linelen; } +size_t +gen_flowd(uint8_t *s, off_t size, size_t maxlinelen, size_t linelen) +{ + off_t i; + int header = linelen > 0; + + for (i = 0; i < size; i++) { + // inspect utf8 sequence to not wrap in between multibyte + int mb; + if ((s[i] & 0x80) == 0) mb = 3; + else if ((s[i] & 0xc0) == 0x80) mb = 3; + else if ((s[i] & 0xe0) == 0xc0) mb = 6; + else if ((s[i] & 0xf0) == 0xe0) mb = 9; + else if ((s[i] & 0xf8) == 0xf0) mb = 12; + else mb = 3; + + if (linelen >= maxlinelen-mb-!!header) { + linelen = 0; + if (header) { + printf("\n"); + } else { + puts(" "); + } + } + + if ((s[i] > 126) || + (linelen == 0 && + (strncmp((char *)s, "From ", 5) == 0 || + (s[i] == '.' && i+1 < size && + (s[i+1] == '\n' || s[i+1] == '\r'))))) { + putc_unlocked(s[i], stdout); + linelen ++; + } else if (header && + (s[i] == '\n' || s[i] == '\t' || s[i] == '_')) { + putc_unlocked(s[i], stdout); + linelen ++; + } else if (header && s[i] == ' ') { + putc_unlocked('_', stdout); + linelen++; + } else if (s[i] < 33 && s[i] != '\n') { + if ((s[i] == ' ' || s[i] == '\t') && + i+1 < size && + (s[i+1] != '\n' && s[i+1] != '\r')) { + putc_unlocked(s[i], stdout); + linelen++; + } else { + putc_unlocked(s[i], stdout); + linelen++; + } + } else if (s[i] == '\n') { + putc_unlocked('\n', stdout); + linelen = 0; + } else { + putc_unlocked(s[i], stdout); + linelen++; + } + } + if (linelen > 0 && !header) + puts("\n"); + return linelen; +} + static const char * basenam(const char *s) { @@ -401,8 +463,8 @@ inheader = 0; printf("MIME-Version: 1.0\n"); if (rflag) { - printf("Content-Type: text/plain; charset=UTF-8\n"); - printf("Content-Transfer-Encoding: quoted-printable\n\n"); + printf("Content-Type: text/plain; charset=US-ASCII\n"); + printf("Content-Transfer-Encoding: 7bit\n\n"); } else { printf("Content-Type: %s; boundary=\"%s\"\n", tflag, sep); @@ -435,14 +497,14 @@ if (!rflag && !intext) { printf("\n--%s\n", sep); - printf("Content-Type: text/plain; charset=UTF-8\n"); + printf("Content-Type: text/plain; charset=US-ASCII; format=flowed\n"); printf("Content-Disposition: inline\n"); - printf("Content-Transfer-Encoding: quoted-printable\n\n"); + printf("Content-Transfer-Encoding: 7bit\n\n"); intext = 1; } - gen_qp((uint8_t *)line, strlen(line), 78, 0); + gen_flowd((uint8_t *)line, strlen(line), 78, 0); } if (!rflag && !inheader) printf("\n--%s--\n", sep);