summary refs log tree commit diff
path: root/bounce.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-11-08 17:25:48 -0500
committerJune McEnroe <june@causal.agency>2019-11-08 17:25:48 -0500
commitda2643bc8039de811b4b0e5e1ce367e9236153cd (patch)
tree816909e0adcfcb9542c18d341b3b0275a26371a3 /bounce.c
parentJust write the example normally (diff)
downloadpounce-da2643bc8039de811b4b0e5e1ce367e9236153cd.tar.gz
pounce-da2643bc8039de811b4b0e5e1ce367e9236153cd.zip
Only change AWAY status for registered clients
Turns out I did eventually fix this, because I may want to implement
"passive clients" for logging or notification stuff, which wouldn't
affect AWAY status either.
Diffstat (limited to 'bounce.c')
-rw-r--r--bounce.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/bounce.c b/bounce.c
index 407dd44..c174249 100644
--- a/bounce.c
+++ b/bounce.c
@@ -228,7 +228,6 @@ int main(int argc, char *argv[]) {
 	const char *real = NULL;
 
 	const char *join = NULL;
-	const char *away = "pounced :3";
 	const char *quit = "connection reset by purr";
 
 	const char *Opts = "!A:C:H:K:NP:Q:U:W:a:c:ef:g:h:j:k:n:p:r:s:u:vw:x";
@@ -264,7 +263,7 @@ int main(int argc, char *argv[]) {
 	while (0 < (opt = getopt_config(argc, argv, Opts, LongOpts, NULL))) {
 		switch (opt) {
 			break; case '!': insecure = true;
-			break; case 'A': away = optarg;
+			break; case 'A': clientAway = optarg;
 			break; case 'C': strlcpy(certPath, optarg, sizeof(certPath));
 			break; case 'H': bindHost = optarg;
 			break; case 'K': strlcpy(privPath, optarg, sizeof(privPath));
@@ -322,6 +321,7 @@ int main(int argc, char *argv[]) {
 	}
 	if (!user) user = nick;
 	if (!real) real = nick;
+	if (!clientAway) clientAway = "pounced :3";
 
 	ringAlloc(ringSize);
 	if (savePath) saveLoad(savePath);
@@ -367,7 +367,7 @@ int main(int argc, char *argv[]) {
 	if (plain) explicit_bzero(plain, strlen(plain));
 
 	while (!stateReady()) serverRecv();
-	serverFormat("AWAY :%s\r\n", away);
+	serverFormat("AWAY :%s\r\n", clientAway);
 	if (join) serverFormat("JOIN :%s\r\n", join);
 
 	signal(SIGINT, signalHandler);
@@ -383,7 +383,6 @@ int main(int argc, char *argv[]) {
 	}
 	eventAdd(server, NULL);
 
-	size_t clients = 0;
 	for (;;) {
 		int nfds = poll(event.fds, event.len, -1);
 		if (nfds < 0 && errno != EINTR) err(EX_IOERR, "poll");
@@ -423,7 +422,6 @@ int main(int argc, char *argv[]) {
 					close(fd);
 				} else {
 					eventAdd(fd, clientAlloc(tls));
-					if (!clients++) serverFormat("AWAY\r\n");
 				}
 				continue;
 			}
@@ -434,7 +432,6 @@ int main(int argc, char *argv[]) {
 			if (clientError(client) || revents & (POLLHUP | POLLERR)) {
 				clientFree(client);
 				eventRemove(i);
-				if (!--clients) serverFormat("AWAY :%s\r\n", away);
 			}
 		}