Style and include cleanups.

This commit is contained in:
Ian Gulliver
2016-02-17 16:40:09 -08:00
parent 8e2e7b2562
commit ae5b4c1ce4
19 changed files with 213 additions and 245 deletions

View File

@@ -12,7 +12,6 @@
#include "stats.h"
#include "client.h"
struct client {
struct peer peer;
char id[UUID_LEN];
@@ -38,11 +37,6 @@ struct serializer {
};
#define NUM_SERIALIZERS (sizeof(serializers) / sizeof(*serializers))
void client_init() {
signal(SIGPIPE, SIG_IGN);
}
static void client_hangup(struct client *client) {
fprintf(stderr, "C %s (%s): Client disconnected\n", client->id, client->serializer->name);
if (client->prev) {
@@ -61,15 +55,6 @@ static void client_hangup_wrapper(struct peer *peer) {
client_hangup((struct client *) peer);
}
struct serializer *client_get_serializer(char *name) {
for (int i = 0; i < NUM_SERIALIZERS; i++) {
if (strcasecmp(serializers[i].name, name) == 0) {
return &serializers[i];
}
}
return NULL;
}
static bool client_hello(int fd, struct serializer *serializer) {
struct buf buf = BUF_INIT;
serializer->serialize(NULL, &buf);
@@ -82,6 +67,19 @@ static bool client_hello(int fd, struct serializer *serializer) {
return true;
}
void client_init() {
signal(SIGPIPE, SIG_IGN);
}
struct serializer *client_get_serializer(char *name) {
for (int i = 0; i < NUM_SERIALIZERS; i++) {
if (strcasecmp(serializers[i].name, name) == 0) {
return &serializers[i];
}
}
return NULL;
}
void client_add(int fd, struct serializer *serializer) {
int flags = fcntl(fd, F_GETFL, 0);
assert(flags >= 0);