summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-01-26 19:04:14 -0500
committerJune McEnroe <june@causal.agency>2020-01-26 19:04:14 -0500
commitdc77a612c1655fd59cba11a6a8e9472f488f20c4 (patch)
tree8f428cdb6a6422d966adb939c625e158797ec7b7
parentReference MIME part 1 standard (diff)
downloadnotemap-dc77a612c1655fd59cba11a6a8e9472f488f20c4.tar.gz
notemap-dc77a612c1655fd59cba11a6a8e9472f488f20c4.zip
Log out after reading all notes
-rw-r--r--notemap.c8
1 files 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;