about summary refs log tree commit diff
path: root/imbox.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-16 20:38:04 -0500
committerJune McEnroe <june@causal.agency>2021-02-16 20:38:04 -0500
commit4ea8f158a7965f866e91e5f11c1ba189079bd935 (patch)
tree25cea835df81a25a6fac7780e7a2108d61bc6f88 /imbox.c
parentDon't use Fl Fl for long options (diff)
downloadimbox-4ea8f158a7965f866e91e5f11c1ba189079bd935.tar.gz
imbox-4ea8f158a7965f866e91e5f11c1ba189079bd935.zip
Add -M to move messages after export
Diffstat (limited to 'imbox.c')
-rw-r--r--imbox.c23
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);
/commit/ui.c?h=2.0&id=a6ede6f91f41ca20d02454de3bd33329d35fbbd1&follow=1'>Factor out allocating conversion between wcs and mbsJune McEnroe 2018-08-07Match commands case-insensitivelyJune McEnroe Also include the slash in their names so that they can be added to tab-complete later. 2018-08-07Convert input to multibyte before handlingJune McEnroe 2018-08-07Populate tab-complete listJune McEnroe 2018-08-07Fix /me formatting side-effectsJune McEnroe NEVER pass side-effects to a macro. 2018-08-07Define ui.c BUF_LEN with enumJune McEnroe 2018-08-07Hack clang into checking uiFmt format stringsJune McEnroe 2018-08-07Handle PART and QUIT without messagesJune McEnroe 2018-08-07Make safe filling the who bufferJune McEnroe 2018-08-07Add reverse and reset IRC formatting codesJune McEnroe 2018-08-06Rewrite line editing again, add formattingJune McEnroe 2018-08-06Fix allocation size in vaswprintfJune McEnroe This is so embarrassing. It only started crashing once it had strings that were long enough, and then it took me so long to notice this mistake. I was worried I was still doing va_list wrong somehow. 2018-08-06Implement word wrappingJune McEnroe 2018-08-06Use wchar_t strings for all of UIJune McEnroe vaswprintf is a nightmare. 2018-08-06Rename line editing functionsJune McEnroe 2018-08-05Initialize all possible color pairsJune McEnroe This is actually possible with use_default_colors! 2018-08-05Refactor color initializationJune McEnroe 2018-08-05Add ^L redrawJune McEnroe 2018-08-05Use 16 colors if availableJune McEnroe Fall back to using bold if there are only 8 colors. This also allowed bright background colors in 16-color terminals. I must port this system to torus. I'll be able to remove the awful termcap patch hack. 2018-08-05Limit parsed colors to number of mIRC colorsJune McEnroe Oh boy that's embarrassing. 2018-08-04Show source link on exitJune McEnroe 2018-08-04Implement line editing, scrollingJune McEnroe Don't really have a way to implement the M-* keys, and currently missing C-w. 2018-08-04Handle /topicJune McEnroe