summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-11-14 11:24:55 -0500
committerJune McEnroe <june@causal.agency>2020-11-14 11:24:55 -0500
commit7229eee4b507ab14f7553a14cba4f009a716bcde (patch)
tree8e0aaf0833a58e0e50e19e8260d08cb4676b7a15
parentWait for POLLIN to do client tls_handshake (diff)
downloadpounce-7229eee4b507ab14f7553a14cba4f009a716bcde.tar.gz
pounce-7229eee4b507ab14f7553a14cba4f009a716bcde.zip
Make struct Client public
Diffstat (limited to '')
-rw-r--r--bounce.c2
-rw-r--r--bounce.h18
-rw-r--r--client.c23
3 files changed, 18 insertions, 25 deletions
diff --git a/bounce.c b/bounce.c
index 5b5e524..0354bf5 100644
--- a/bounce.c
+++ b/bounce.c
@@ -493,7 +493,7 @@ int main(int argc, char *argv[]) {
 			struct Client *client = event.clients[i];
 			if (revents & POLLOUT) clientConsume(client);
 			if (revents & POLLIN) clientRecv(client);
-			if (clientError(client) || revents & (POLLHUP | POLLERR)) {
+			if (client->error || revents & (POLLHUP | POLLERR)) {
 				clientFree(client);
 				eventRemove(i);
 			}
diff --git a/bounce.h b/bounce.h
index 6b376ae..a6ad31f 100644
--- a/bounce.h
+++ b/bounce.h
@@ -184,12 +184,28 @@ void serverEnqueue(const char *format, ...)
 	__attribute__((format(printf, 1, 2)));
 void serverDequeue(void);
 
+enum Need {
+	BIT(NeedHandshake),
+	BIT(NeedNick),
+	BIT(NeedUser),
+	BIT(NeedPass),
+	BIT(NeedCapEnd),
+};
+struct Client {
+	bool error;
+	struct tls *tls;
+	enum Need need;
+	enum Cap caps;
+	size_t consumer;
+	size_t setPos;
+	char buf[MessageCap];
+	size_t len;
+};
 extern enum Cap clientCaps;
 extern char *clientPass;
 extern char *clientAway;
 struct Client *clientAlloc(struct tls *tls);
 void clientFree(struct Client *client);
-bool clientError(const struct Client *client);
 void clientRecv(struct Client *client);
 void clientSend(struct Client *client, const char *ptr, size_t len);
 void clientFormat(struct Client *client, const char *format, ...)
diff --git a/client.c b/client.c
index 6f36539..4327a89 100644
--- a/client.c
+++ b/client.c
@@ -47,25 +47,6 @@ char *clientAway;
 
 static size_t active;
 
-enum Need {
-	BIT(NeedHandshake),
-	BIT(NeedNick),
-	BIT(NeedUser),
-	BIT(NeedPass),
-	BIT(NeedCapEnd),
-};
-
-struct Client {
-	struct tls *tls;
-	enum Need need;
-	size_t consumer;
-	size_t setPos;
-	enum Cap caps;
-	char buf[MessageCap];
-	size_t len;
-	bool error;
-};
-
 struct Client *clientAlloc(struct tls *tls) {
 	struct Client *client = calloc(1, sizeof(*client));
 	if (!client) err(EX_OSERR, "calloc");
@@ -100,10 +81,6 @@ void clientFree(struct Client *client) {
 	free(client);
 }
 
-bool clientError(const struct Client *client) {
-	return client->error;
-}
-
 void clientSend(struct Client *client, const char *ptr, size_t len) {
 	if (verbose) fprintf(stderr, "\x1B[34m%.*s\x1B[m", (int)len, ptr);
 	while (len) {
6ed949d2e8f085ac23d908bd29&follow=1'>Match 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