summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/client.c b/client.c
index 4bb1f54..cdf0009 100644
--- a/client.c
+++ b/client.c
@@ -119,6 +119,7 @@ static void handleUser(struct Client *client, struct Message msg) {
 }
 
 static void handlePass(struct Client *client, struct Message msg) {
+	if (!clientPass) return;
 	if (!msg.params[0] || strcmp(clientPass, msg.params[0])) {
 		passRequired(client);
 	} else {
@@ -227,3 +228,23 @@ void clientRecv(struct Client *client) {
 	client->len -= line - client->buf;
 	memmove(client->buf, line, client->len);
 }
+
+size_t clientDiff(const struct Client *client) {
+	if (client->need) return 0;
+	return ringDiff(client->reader);
+}
+
+// TODO: Read several lines based on LOWAT for POLLOUT?
+void clientRead(struct Client *client) {
+	time_t time;
+	const char *line = ringRead(&time, client->reader);
+	if (!line) return;
+	if (client->serverTime) {
+		char ts[sizeof("YYYY-MM-DDThh:mm:ss.sssZ")];
+		struct tm *tm = gmtime(&time);
+		strftime(ts, sizeof(ts), "%FT%T.000Z", tm);
+		clientFormat(client, "@time=%s %s\r\n", ts, line);
+	} else {
+		clientFormat(client, "%s\r\n", line);
+	}
+}