summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-10 19:40:13 -0500
committerJune McEnroe <june@causal.agency>2020-02-10 19:40:13 -0500
commitb59431bb15ec74f05119a7c710a1f6a21e702bad (patch)
treeaa80af87cf2af090dc8d243a80577d8bd5b2106c /chat.c
parentShow heat and other unread in title (diff)
downloadcatgirl-b59431bb15ec74f05119a7c710a1f6a21e702bad.tar.gz
catgirl-b59431bb15ec74f05119a7c710a1f6a21e702bad.zip
Add -s to save and load buffers
Diffstat (limited to '')
-rw-r--r--chat.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/chat.c b/chat.c
index c58fdc5..e8713bb 100644
--- a/chat.c
+++ b/chat.c
@@ -47,6 +47,15 @@ size_t idNext = Network + 1;
 
 struct Self self = { .color = Default };
 
+static const char *save;
+static void exitSave(void) {
+	int error = uiSave(save);
+	if (error) {
+		warn("%s", save);
+		_exit(EX_IOERR);
+	}
+}
+
 uint32_t hashInit;
 
 int procPipe[2] = { -1, -1 };
@@ -84,7 +93,7 @@ int main(int argc, char *argv[]) {
 	const char *user = NULL;
 	const char *real = NULL;
 
-	const char *Opts = "!C:H:O:a:c:eh:j:k:n:p:r:u:vw:";
+	const char *Opts = "!C:H:O:a:c:eh:j:k:n:p:r:s:u:vw:";
 	const struct option LongOpts[] = {
 		{ "insecure", no_argument, NULL, '!' },
 		{ "copy", required_argument, NULL, 'C' },
@@ -99,6 +108,7 @@ int main(int argc, char *argv[]) {
 		{ "nick", required_argument, NULL, 'n' },
 		{ "port", required_argument, NULL, 'p' },
 		{ "real", required_argument, NULL, 'r' },
+		{ "save", required_argument, NULL, 's' },
 		{ "user", required_argument, NULL, 'u' },
 		{ "debug", no_argument, NULL, 'v' },
 		{ "pass", required_argument, NULL, 'w' },
@@ -121,6 +131,7 @@ int main(int argc, char *argv[]) {
 			break; case 'n': nick = optarg;
 			break; case 'p': port = optarg;
 			break; case 'r': real = optarg;
+			break; case 's': save = optarg;
 			break; case 'u': user = optarg;
 			break; case 'v': self.debug = true;
 			break; case 'w': pass = optarg;
@@ -154,6 +165,10 @@ int main(int argc, char *argv[]) {
 	if (privFile) fclose(privFile);
 
 	uiInit();
+	if (save) {
+		uiLoad(save);
+		atexit(exitSave);
+	}
 	uiShowID(Network);
 	uiFormat(Network, Cold, NULL, "Traveling...");
 	uiDraw();
84bcc0feb371194f&follow=1'>ui-snapshot: set unused cgit_filter fields to zeroJohn Keeping 2014-01-12html: remove redundant htmlfd variableJohn Keeping 2014-01-12tests: add Valgrind supportJohn Keeping 2014-01-12cache: don't leave cache_slot fields uninitializedJohn Keeping 2014-01-10filter: split filter functions into their own fileJason A. Donenfeld 2014-01-10filter: make exit status localJason A. Donenfeld 2014-01-10parsing: fix header typoJason A. Donenfeld 2014-01-10cgit.c: Fix comment on bit mask hackLukas Fleischer 2014-01-10cgit.c: Use "else" for mutually exclusive branchesLukas Fleischer 2014-01-10ui-snapshot.c: Do not reinvent suffixcmp()Lukas Fleischer 2014-01-10Refactor cgit_parse_snapshots_mask()Lukas Fleischer 2014-01-10Disallow use of undocumented snapshot delimitersLukas Fleischer 2014-01-10Replace most uses of strncmp() with prefixcmp()Lukas Fleischer 2014-01-09README: Fix dependenciesLukas Fleischer 2014-01-08README: Spelling and formatting fixesLukas Fleischer 2014-01-08Fix UTF-8 with syntax-highlighting.pyPřemysl Janouch 2014-01-08Add a suggestion to the manpagePřemysl Janouch 2014-01-08Fix the example configurationPřemysl Janouch 2014-01-08Fix about-formatting.shPřemysl Janouch 2014-01-08Fix some spelling errorsPřemysl Janouch 2014-01-08filters: highlight.sh: add css comments for highlight 2.6 and 3.8Ferry Huberts