summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-11-30 18:06:43 -0500
committerJune McEnroe <june@causal.agency>2018-11-30 18:06:43 -0500
commit9d769111aef9a3e6148bf8205c3556cc0c5a46a9 (patch)
tree608ba62c47d2a139159ae384bf34f870fdcd41fb /chat.c
parentMeasure length of log timestamp more consistently (diff)
downloadcatgirl-9d769111aef9a3e6148bf8205c3556cc0c5a46a9.tar.gz
catgirl-9d769111aef9a3e6148bf8205c3556cc0c5a46a9.zip
Separate ircConnect and ircDisconnect
Diffstat (limited to '')
-rw-r--r--chat.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/chat.c b/chat.c
index 014076b..152bf84 100644
--- a/chat.c
+++ b/chat.c
@@ -60,39 +60,35 @@ static char *prompt(const char *prompt) {
 
 int main(int argc, char *argv[]) {
 	char *host = NULL;
-	const char *port = "6697";
-	const char *pass = NULL;
-	const char *webirc = NULL;
+	char *port = "6697";
+	char *pass = NULL;
+	char *webirc = NULL;
 
 	int opt;
 	while (0 < (opt = getopt(argc, argv, "NW:h:j:l:n:p:u:vw:"))) {
 		switch (opt) {
 			break; case 'N': self.notify = true;
-			break; case 'W': webirc = optarg;
+			break; case 'W': webirc = strdup(optarg);
 			break; case 'h': host = strdup(optarg);
 			break; case 'j': selfJoin(optarg);
 			break; case 'l': logOpen(optarg);
 			break; case 'n': selfNick(optarg);
-			break; case 'p': port = optarg;
+			break; case 'p': port = strdup(optarg);
 			break; case 'u': selfUser(optarg);
 			break; case 'v': self.verbose = true;
-			break; case 'w': pass = optarg;
+			break; case 'w': pass = strdup(optarg);
 			break; default:  return EX_USAGE;
 		}
 	}
+	if (!port) err(EX_OSERR, "strdup");
 
 	if (!host) host = prompt("Host: ");
 	if (!self.nick) self.nick = prompt("Name: ");
 	if (!self.user) selfUser(self.nick);
 
 	inputTab();
-
 	uiInit();
-	uiLog(TagStatus, UIWarm, L"Traveling...");
 	uiDraw();
-
-	int irc = ircConnect(host, port, pass, webirc);
-	free(host);
-
-	eventLoop(STDIN_FILENO, irc);
+	ircInit(host, port, pass, webirc);
+	eventLoop();
 }