From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 32305 invoked from network); 28 May 2021 15:35:20 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 28 May 2021 15:35:20 -0000 Received: from mout.gmx.net ([212.227.15.19]) by 1ess; Fri May 28 11:25:46 -0400 2021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622215544; bh=fcCZH35TWLiOyNv1SfJrQJbytour09PinCBuAxV9+G0=; h=X-UI-Sender-Class:Date:From:To:Subject; b=YSs43KREpA6lRkIMPb7LJYkEuqpQ3378p+2bxT1K2s/Im5TKBi1X76/nBkpcpBpCI eqCBLMsUVq/JwdMvfuoGp9a1Xb14jgneYuGTCjPjFuRTNS9ebC08KGABZ9hMqXaspC HHxv42dPlC1RhjrzCXbZbOFHiip2XRZHPSGPaGu8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from purple.my.domain ([84.248.10.74]) by mail.gmx.net (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1Ml6qM-1l87Xg0SPk-00lRXN; Fri, 28 May 2021 17:25:44 +0200 Message-ID: <971EAFFF76D75B465FE8AE28F208FAB9@gmx.com> Date: Fri, 28 May 2021 18:25:41 +0300 From: risto.salminen@gmx.com To: 9front@9front.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:HbGIiiDG1zdRzgbhDh6pSM9pL7xdXXhXvtD3ryoJa0hAcsIbHkc raSqeR8KOdxVBM8bICYrVG/+4gokpYOv88Um5OLmgt1J5kCQ0/nWifIm5wA1gaMZgIM50+s Sxce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Pq/smQhNTs BmgWbBl/Tp7028lH75XnGRBiZ1WG4imv67QnHD6+tFRRu7+GtV2QSCcf+EIygCB5o4pPF4vPQ PhopwezzvzvSwZvB6hGVCH5LuYTErE6+uYSL4VYP2KuGgAmZS/KH5HNWAXxVwVf+JJpxLrBan /9wGY9ehjuEoHV4zTLP8XyGR7RTAI3hbpTFKRvFoOlJVJ8wB+RAGhYuq90BmEbRvLCbcEXpxE yxEOIDn8lG9bhEbR9DCXhJ6YM0kTQlNggjAnngFMNKLmx3d7JRJrhbBQOWcNapf8BuoZn3CKV lXZU8yKHdIZDOmT0l List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: extensible transactional app browser-oriented dependency database Subject: [9front] upas/nedmail: copy messages between IMAP folders Reply-To: 9front@9front.org Precedence: bulk Dear 9front community, the following patch makes nedmail to take advantage of the message copy support introduced in my previous mail. This is useful when one wants to archive messages from inbox to another IMAP folder. I have been using this for half a year now, as the upas/fs part of the changes too. Would this be useful for the broader audience? Thanks, rsal diff -r 7c895ae504fa sys/man/1/nedmail =2D-- a/sys/man/1/nedmail Fri May 28 13:02:58 2021 +0200 +++ b/sys/man/1/nedmail Fri May 28 16:57:27 2021 +0300 @@ -153,6 +153,10 @@ .B b Print the headers for the next ten messages. .TP +.BI c " mbox +Copy message to the named mailbox. +At the moment only supported with IMAP mailboxes. +.TP .B d Mark message to be deleted upon exiting .IR nedmail . @@ -184,6 +188,16 @@ but allow the user to type in text to be included with the forwarded message. .TP +.BI move " mbox +Copy message to the named mailbox +and mark it as deleted. +This is just +.B c +followed by +.B d +for convenience. +At the moment only supported with IMAP mailboxes. +.TP .B p Print message. An interrupt stops the printing. diff -r 7c895ae504fa sys/src/cmd/upas/ned/nedmail.c =2D-- a/sys/src/cmd/upas/ned/nedmail.c Fri May 28 13:02:58 2021 +0200 +++ b/sys/src/cmd/upas/ned/nedmail.c Fri May 28 16:57:27 2021 +0300 @@ -93,6 +93,7 @@ Mfn acmd; Mfn bangcmd; Mfn bcmd; +Mfn ccmd; Mfn dcmd; Mfn eqcmd; Mfn Fcmd; @@ -106,6 +107,7 @@ Mfn kcmd; Mfn mbcmd; Mfn mcmd; +Mfn movecmd; Mfn Pcmd; Mfn pcmd; Mfn pipecmd; @@ -130,6 +132,7 @@ { "a", 1, 1, acmd, "a\t" "reply to sender and recipients" }, { "A", 1, 0, acmd, "A\t" "reply to sender and recipients with copy" }, { "b", 0, 0, bcmd, "b\t" "print the next 10 headers" }, + { "c", 1, 1, ccmd, "c mbox\t" "copy message to mailbox" }, { "d", 0, 1, dcmd, "d\t" "mark for deletion" }, { "F", 1, 1, Fcmd, "f\t" "set message flags [+-][aDdfrSs]" }, { "f", 0, 1, fcmd, "f\t" "file message by from address" }, @@ -143,6 +146,7 @@ { "m", 1, 1, mcmd, "m addr\t" "forward mail" }, { "M", 1, 0, mcmd, "M addr\t" "forward mail with message" }, { "mb", 1, 0, mbcmd, "mb mbox\t" "switch mailboxes" }, + { "move", 1, 1, movecmd, "move mbox\t" "move message to mailbox" }, { "p", 1, 0, pcmd, "p\t" "print the processed message" }, { "P", 0, 0, Pcmd, "P\t" "print the raw message" }, { "\"", 0, 0, quotecmd, "\"\t" "print a quoted version of msg" }, @@ -2406,6 +2410,57 @@ return m; } +Message* +ccmd(Cmd *c, Message *m) +{ + char buf[1024], *dest, *e, *p, *msg; + int fd; + + if(c->an !=3D 2){ + eprint("!usage: c mailbox\n"); + return nil; + } + dest =3D c->av[1]; + fd =3D open("/mail/fs/ctl", OWRITE); + if(fd < 0){ + eprint("can't open /mail/fs/ctl: %r\n"); + return nil; + } + while(m->parent !=3D &top) + m =3D m->parent; + msg =3D strrchr(m->path, '/'); + if(msg =3D=3D nil) + msg =3D m->path; + else + msg++; + p =3D buf; + e =3D buf + sizeof buf; + p =3D seprint(p, e, "copy %s %s %s", mbname, msg, dest); + if(write(fd, buf, p - buf) < 0){ + eprint("!error %r\n"); + close(fd); + return nil; + } + eprint("!copied to %s\n", dest); + setflags(m, "S"); + close(fd); + return m; +} + +Message* +movecmd(Cmd *c, Message *m) +{ + Message *r; + + r =3D ccmd(c, m); + if(r =3D=3D nil) + return nil; + r =3D dcmd(c, m); + if(r =3D=3D nil) + return nil; + return r; +} + int appendtofile(Message *m, char *part, char *base, int mbox, int f) {