From dc77a612c1655fd59cba11a6a8e9472f488f20c4 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 26 Jan 2020 19:04:14 -0500 Subject: Log out after reading all notes --- notemap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/notemap.c b/notemap.c index 963cd0a..2b0fe3b 100644 --- a/notemap.c +++ b/notemap.c @@ -394,9 +394,13 @@ int main(int argc, char *argv[]) { break; case Next: { ssize_t len; next: - // FIXME: Handle EOF. len = getline(&entry, &entryCap, map); - if (len < 0) err(EX_IOERR, "%s", path); + if (ferror(map)) err(EX_IOERR, "%s", path); + if (len < 1) { + fprintf(imap, "ayy LOGOUT\r\n"); + fclose(imap); + return EX_OK; + } if (entry[len - 1] == '\n') entry[len - 1] = '\0'; note = entry; -- cgit 1.4.1