about summary refs log tree commit diff
path: root/imap.h
diff options
context:
space:
mode:
Diffstat (limited to 'imap.h')
-rw-r--r--imap.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/imap.h b/imap.h
index 8b6b717..3b3bfc7 100644
--- a/imap.h
+++ b/imap.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2020  June 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
@@ -12,6 +12,17 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ * Additional permission under GNU GPL version 3 section 7:
+ *
+ * If you modify this Program, or any covered work, by linking or
+ * combining it with OpenSSL (or a modified version of that library),
+ * containing parts covered by the terms of the OpenSSL License and the
+ * original SSLeay license, the licensors of this Program grant you
+ * additional permission to convey the resulting work. Corresponding
+ * Source for a non-source form of such a combination shall include the
+ * source code for the parts of OpenSSL used as well as that of the
+ * covered work.
  */
 
 #ifndef IMAP_H
@@ -143,13 +154,30 @@ struct Resp {
 	const char *text;
 };
 
+static inline struct Resp respOk(struct Resp resp) {
+	if (resp.resp == AtomNo || resp.resp == AtomBad || resp.resp == AtomBye) {
+		errx(EX_CONFIG, "%s: %s", Atoms[resp.tag], resp.text);
+	}
+	return resp;
+}
+
 static inline void respFree(struct Resp resp) {
 	listFree(resp.code);
 	listFree(resp.data);
 }
 
 extern bool imapVerbose;
-void imapOpen(FILE **read, FILE **write, const char *host, const char *port);
-struct Resp imapResp(FILE *imapRead);
+
+struct IMAP {
+	int sock;
+	FILE *r;
+	FILE *w;
+	size_t cap;
+	char *buf;
+	char *ptr;
+};
+
+struct IMAP imapOpen(const char *host, const char *port);
+struct Resp imapResp(struct IMAP *imap);
 
 #endif /* IMAP_H */