diff --git a/0615c6f b/db55009 index 0615c6f..db55009 100644 --- a/0615c6f +++ b/db55009 @@ -26,6 +26,17 @@ int i, fd_max; FILE *io[max_client_fd]; enum { CLOSED, HEADER, CHATTING } state[max_client_fd]; char *nick[max_client_fd]; +char *auth[max_client_fd]; +enum { ECHO = 1 } opts[max_client_fd]; +typedef enum { RAW=0, LINE=1, FROM=2, FULL=3 } proto_t; +proto_t proto_in[max_client_fd]; +proto_t proto_out[max_client_fd]; + +// protocols: +// 0: raw +// 1: line (default for client->server) +// 2: from: line (default for server->client) +// 3: time from: to, line (default for server->server) void error(const char *format, ...) { @@ -145,6 +156,8 @@ int accept_new_client(void) if (client >= fd_max) fd_max = client + 1; state[client] = HEADER; + proto_in[client] = LINE; + proto_out[client] = FROM; return 0; } @@ -190,6 +203,18 @@ void header(int client, char *line) value); if (!strcmp(key, "nick")) { nick[client] = strdup(value); + } else if (!strcmp(key, "auth")) { + auth[client] = strdup(value); + } else if (!strcmp(key, "echo")) { + opts[client] |= atoi(value) ? ECHO : 0; + } else if (!strcmp(key, "proto")) { + char *proto_out = strchr(value, ' '); + if (!proto_out) { + fprintf(stderr, "bad proto header from client %d: %s\n", client, value); + return; + } + proto_in[client] = atoi(value); + proto_out[client] = atoi(proto_out + 1); } }