diff options
Diffstat (limited to 'notemap.c')
-rw-r--r-- | notemap.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/notemap.c b/notemap.c index 8cdde70..8612493 100644 --- a/notemap.c +++ b/notemap.c @@ -295,11 +295,10 @@ int main(int argc, char *argv[]) { enum Atom create = atom("create"); enum Atom replace = atom("replace"); - FILE *imapRead, *imap; - imapOpen(&imapRead, &imap, host, port); + struct IMAP imap = imapOpen(host, port); for ( struct Resp resp; - resp = imapResp(imapRead), resp.resp != AtomBye; + resp = imapResp(&imap), resp.resp != AtomBye; respFree(resp) ) { if (resp.resp == AtomNo || resp.resp == AtomBad) { @@ -309,13 +308,13 @@ int main(int argc, char *argv[]) { if (!login) { login = atom("login"); fprintf( - imap, "%s LOGIN \"%s\" \"%s\"\r\n", + imap.w, "%s LOGIN \"%s\" \"%s\"\r\n", Atoms[login], user, pass ); } if (resp.tag == login) { - fprintf(imap, "%s SELECT \"%s\"\r\n", Atoms[next], mailbox); + fprintf(imap.w, "%s SELECT \"%s\"\r\n", Atoms[next], mailbox); } ssize_t len; @@ -324,7 +323,7 @@ next: len = getline(&entry, &cap, map); if (ferror(map)) err(EX_IOERR, "%s", path); if (len < 1) { - fprintf(imap, "ayy LOGOUT\r\n"); + fprintf(imap.w, "ayy LOGOUT\r\n"); continue; } if (entry[len - 1] == '\n') entry[len - 1] = '\0'; @@ -347,7 +346,7 @@ next: } fprintf( - imap, + imap.w, "%s SEARCH HEADER X-Universally-Unique-Identifier \"%s\"\r\n", Atoms[AtomSearch], uuid ); @@ -361,13 +360,13 @@ next: if (resp.data.len) { seq = dataCheck(resp.data.ptr[0], Number).number; fprintf( - imap, "%s FETCH %" PRIu32 " ENVELOPE\r\n", + imap.w, "%s FETCH %" PRIu32 " ENVELOPE\r\n", Atoms[AtomFetch], seq ); } else { message = format(user, uuid, note); fprintf( - imap, "%s APPEND %s (\\Seen) {%zu}\r\n", + imap.w, "%s APPEND %s (\\Seen) {%zu}\r\n", Atoms[create], mailbox, strlen(message) ); } @@ -405,13 +404,13 @@ next: message = format(user, uuid, note); fprintf( - imap, "%s APPEND %s (\\Seen) {%zu}\r\n", + imap.w, "%s APPEND %s (\\Seen) {%zu}\r\n", Atoms[replace], mailbox, strlen(message) ); } if (resp.tag == AtomContinue) { - fprintf(imap, "%s\r\n", message); + fprintf(imap.w, "%s\r\n", message); free(message); } @@ -423,13 +422,13 @@ next: if (resp.tag == replace) { printf("~ %s\n", note); fprintf( - imap, "%s STORE %" PRIu32 " +FLAGS (\\Deleted)\r\n", + imap.w, "%s STORE %" PRIu32 " +FLAGS (\\Deleted)\r\n", Atoms[next], seq ); } } - fclose(imapRead); - fclose(imap); + fclose(imap.r); + fclose(imap.w); int ret = EX_OK; for (int i = 0; i < argc; ++i) { |