diff options
Diffstat (limited to '')
-rw-r--r-- | imbox.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/imbox.c b/imbox.c index 1852815..b385366 100644 --- a/imbox.c +++ b/imbox.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2019, 2020 C. McEnroe <june@causal.agency> +/* Copyright (C) 2019-2021 C. McEnroe <june@causal.agency> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,14 +75,16 @@ int main(int argc, char *argv[]) { const char *from = NULL; const char *to = NULL; const char *cc = NULL; + const char *move = NULL; bool idle = false; int rppFlags = 0; int opt; - while (0 < (opt = getopt(argc, argv, "C:F:S:T:h:im:p:vw"))) { + while (0 < (opt = getopt(argc, argv, "C:F:M:S:T:h:im:p:vw"))) { switch (opt) { break; case 'C': cc = optarg; break; case 'F': from = optarg; + break; case 'M': move = optarg; break; case 'S': subject = optarg; break; case 'T': to = optarg; break; case 'h': host = optarg; @@ -121,7 +123,10 @@ int main(int argc, char *argv[]) { respFree(resp); enum Atom examine = atom("examine"); - fprintf(imap.w, "%s EXAMINE \"%s\"\r\n", Atoms[examine], mailbox); + fprintf( + imap.w, "%s %s \"%s\"\r\n", + Atoms[examine], (move ? "SELECT" : "EXAMINE"), mailbox + ); for (; resp = respOk(imapResp(&imap)), resp.tag != examine; respFree(resp)); respFree(resp); @@ -180,6 +185,18 @@ search:; } respFree(resp); + if (move) { + enum Atom mov = atom("move"); + fprintf(imap.w, "%s MOVE ", Atoms[mov]); + for (size_t i = 0; i < nums.len; ++i) { + uint32_t num = dataCheck(nums.ptr[i], Number).number; + fprintf(imap.w, "%s%" PRIu32, (i ? "," : ""), num); + } + fprintf(imap.w, " \"%s\"\r\n", move); + for (; resp = respOk(imapResp(&imap)), resp.tag != mov; respFree(resp)); + respFree(resp); + } + fprintf(imap.w, "ayy LOGOUT\r\n"); fclose(imap.r); fclose(imap.w); |