summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--bounce.c8
-rw-r--r--pounce.16
2 files changed, 12 insertions, 2 deletions
diff --git a/bounce.c b/bounce.c
index 712b9c3..648a17b 100644
--- a/bounce.c
+++ b/bounce.c
@@ -91,10 +91,12 @@ int main(int argc, char *argv[]) {
 	const char *user = NULL;
 	const char *real = NULL;
 	const char *join = NULL;
+	const char *away = "pounced :3";
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "C:H:K:NTP:W:a:h:j:n:p:r:u:vw:"))) {
+	while (0 < (opt = getopt(argc, argv, "A:C:H:K:NTP:W:a:h:j:n:p:r:u:vw:"))) {
 		switch (opt) {
+			break; case 'A': away = optarg;
 			break; case 'C': strlcpy(certPath, optarg, sizeof(certPath));
 			break; case 'H': localHost = optarg;
 			break; case 'K': strlcpy(privPath, optarg, sizeof(privPath));
@@ -147,6 +149,7 @@ int main(int argc, char *argv[]) {
 	}
 	eventAdd(server, NULL);
 
+	size_t clients = 0;
 	while (0 < poll(event.fds, event.len, -1)) {
 		for (size_t i = 0; i < event.len; ++i) {
 			short revents = event.fds[i].revents;
@@ -156,6 +159,7 @@ int main(int argc, char *argv[]) {
 				int fd;
 				struct tls *tls = listenAccept(&fd, event.fds[i].fd);
 				eventAdd(fd, clientAlloc(tls));
+				if (!clients++) serverFormat("AWAY\r\n");
 				continue;
 			}
 
@@ -172,10 +176,10 @@ int main(int argc, char *argv[]) {
 			if (revents & POLLIN) clientRecv(client);
 			if (revents & POLLOUT) clientConsume(client);
 			if (clientError(client) || revents & (POLLHUP | POLLERR)) {
-				// TODO: Set AWAY if no more clients remain.
 				clientFree(client);
 				close(event.fds[i].fd);
 				eventRemove(i);
+				if (!--clients) serverFormat("AWAY :%s\r\n", away);
 				break;
 			}
 		}
diff --git a/pounce.1 b/pounce.1
index 8c76f02..95e554b 100644
--- a/pounce.1
+++ b/pounce.1
@@ -9,6 +9,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl NTv
+.Op Fl A Ar away
 .Op Fl C Ar cert
 .Op Fl H Ar host
 .Op Fl K Ar priv
@@ -39,6 +40,11 @@ and uniquely identify themselves by username.
 The arguments are as follows:
 .
 .Bl -tag -width "-W @file"
+.It Fl A Ar away
+Set away status to
+.Ar away
+when no clients are connected.
+.
 .It Fl C Ar cert
 Load TLS certificate from
 .Ar cert .
olspan='3' class='logmsg'> 2019-02-18Don't match nested parentheses in Tag for CJune McEnroe Fixes mistaken highlight of: pngWrite(file, (uint8_t []) { 0, 0, 0 }, 3); 2019-02-18Match whitespace between * [] {}June McEnroe 2019-02-18Fix function-like #define regexJune McEnroe A define like #define FOO (1) is not function-like. 2019-02-18Match Tag in RustJune McEnroe 2019-02-18Match sh functions as TagJune McEnroe 2019-02-18Match Sh and Ss as Tag in mdocJune McEnroe 2019-02-18Match statics and typedefs as TagJune McEnroe 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