about summary refs log tree commit diff
path: root/imbox.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--imbox.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/imbox.c b/imbox.c
index 1f65517..a4d34d7 100644
--- a/imbox.c
+++ b/imbox.c
@@ -54,6 +54,7 @@ static void mboxrd(char *header, char *body) {
 		*crlf = '\0';
 		printf("%s\n", header);
 	}
+	if (!body) return;
 	for (char *crlf; (crlf = strstr(body, "\r\n")); body = &crlf[2]) {
 		*crlf = '\0';
 		char *from = body;
@@ -86,15 +87,17 @@ int main(int argc, char *argv[]) {
 	const char *cc = NULL;
 	bool unseen = false;
 	bool idle = false;
+	bool body = true;
 
 	const char *move = NULL;
 	bool seen = false;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "C:F:M:S:T:Uh:im:p:svw"))) {
+	while (0 < (opt = getopt(argc, argv, "C:F:HM:S:T:Uh:im:p:svw"))) {
 		switch (opt) {
 			break; case 'C': cc = optarg;
 			break; case 'F': from = optarg;
+			break; case 'H': body = false;
 			break; case 'M': move = optarg;
 			break; case 'S': subject = optarg;
 			break; case 'T': to = optarg;
@@ -169,7 +172,8 @@ search:;
 	fprintf(imap.w, "%s FETCH ", Atoms[fetch]);
 	printNums(imap.w, nums);
 	fprintf(
-		imap.w, " (BODY[HEADER.FIELDS (" FETCH_HEADERS ")] BODY[TEXT])\r\n"
+		imap.w, " (BODY[HEADER.FIELDS (" FETCH_HEADERS ")]%s)\r\n",
+		(body ? " BODY[TEXT]" : "")
 	);
 	for (; resp = respOk(imapResp(&imap)), resp.tag != fetch; respFree(resp)) {
 		if (resp.resp != AtomFetch) continue;
@@ -191,7 +195,7 @@ search:;
 		}
 		mboxrd(
 			dataCheck(header, String).string,
-			dataCheck(body, String).string
+			(body.type == String ? body.string : NULL)
 		);
 	}
 	respFree(resp);