about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-09 18:26:53 -0400
committerJune McEnroe <june@causal.agency>2018-08-09 18:26:53 -0400
commitd1fea96e8632b92f561420eaff9468fcd846d297 (patch)
tree81a11b733fac9f67f63acab22e68425fa61e8c6c
parentIgnore trailing space on slash commands (diff)
downloadcatgirl-d1fea96e8632b92f561420eaff9468fcd846d297.tar.gz
catgirl-d1fea96e8632b92f561420eaff9468fcd846d297.zip
Add PASS option
WEBIRC is now -W.
-rw-r--r--chat.c10
-rw-r--r--chat.h4
-rw-r--r--irc.c12
3 files changed, 18 insertions, 8 deletions
diff --git a/chat.c b/chat.c
index b966fd1..9325bb6 100644
--- a/chat.c
+++ b/chat.c
@@ -55,17 +55,19 @@ static char *prompt(const char *prompt) {
 int main(int argc, char *argv[]) {
 	char *host = NULL;
 	const char *port = "6697";
-	const char *webPass = NULL;
+	const char *pass = NULL;
+	const char *webirc = NULL;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "h:j:n:p:vw:"))) {
+	while (0 < (opt = getopt(argc, argv, "W:h:j:n:p:vw:"))) {
 		switch (opt) {
+			break; case 'W': webirc = optarg;
 			break; case 'h': host = strdup(optarg);
 			break; case 'j': chat.chan = strdup(optarg);
 			break; case 'n': chat.nick = strdup(optarg);
 			break; case 'p': port = optarg;
 			break; case 'v': chat.verbose = true;
-			break; case 'w': webPass = optarg;
+			break; case 'w': pass = optarg;
 			break; default:  return EX_USAGE;
 		}
 	}
@@ -82,7 +84,7 @@ int main(int argc, char *argv[]) {
 	uiLog(L"Traveling...");
 	uiDraw();
 
-	int sock = ircConnect(host, port, webPass);
+	int sock = ircConnect(host, port, pass, webirc);
 	free(host);
 
 	struct pollfd fds[2] = {
diff --git a/chat.h b/chat.h
index 3a84b6c..af13410 100644
--- a/chat.h
+++ b/chat.h
@@ -41,7 +41,9 @@ enum {
 	IRC_UNDERLINE = 037,
 };
 
-int ircConnect(const char *host, const char *port, const char *webPass);
+int ircConnect(
+	const char *host, const char *port, const char *pass, const char *webPass
+);
 void ircRead(void);
 void ircWrite(const char *ptr, size_t len);
 
diff --git a/irc.c b/irc.c
index b718b13..b9bef73 100644
--- a/irc.c
+++ b/irc.c
@@ -43,7 +43,9 @@ static void webirc(const char *pass) {
 	);
 }
 
-int ircConnect(const char *host, const char *port, const char *webPass) {
+int ircConnect(
+	const char *host, const char *port, const char *pass, const char *webPass
+) {
 	int error;
 
 	struct tls_config *config = tls_config_new();
@@ -80,8 +82,12 @@ int ircConnect(const char *host, const char *port, const char *webPass) {
 	if (error) err(EX_PROTOCOL, "tls_connect");
 
 	if (webPass) webirc(webPass);
-	ircFmt("NICK %s\r\n", chat.nick);
-	ircFmt("USER %s 0 * :%s\r\n", chat.user, chat.nick);
+	if (pass) ircFmt("PASS :%s\r\n", pass);
+	ircFmt(
+		"NICK %s\r\n"
+		"USER %s 0 * :%s\r\n",
+		chat.nick, chat.user, chat.nick
+	);
 
 	return sock;
 }
2019-02-18Clean up htmlHeaderJune McEnroe 2019-02-18Remove hi line numberingJune McEnroe Tags are much better for referring to specific parts of a file and line numbering is better done by a post-processing tool such as cat -n or producing a two-column HTML <table>. 2019-02-18Add Tag class to hiJune McEnroe 2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe Running hi twice to insert stuff between the head and the content is a bit of a hack but oh well. 2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe Renames previous -n option to -m to stay consistent with cat -n. Prefixing lines with line numbers affects where the first tab indent ends up relative to the text above it. Not sure if it's worth fixing somehow. 2019-02-17Always split spans after newlinesJune McEnroe Simplifies ANSI and IRC output code, and prepares for line numbered output. 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe