From e97c4e27d34c15324bf71d5dc8443f61a1e26a46 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 Aug 2008 20:02:58 +0200 Subject: client: renamed Interface to struct client Second patch: rename the internal struct name. We will eventually export this type as an opaque forward-declared struct later, so we can pass a struct pointer instead of a file descriptor, which would save us an expensive linear lookup. --- src/client.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/client.c b/src/client.c index a6ca85497..37d150775 100644 --- a/src/client.c +++ b/src/client.c @@ -59,7 +59,7 @@ static struct strnode *list_cache; static struct strnode *list_cache_head; static struct strnode *list_cache_tail; -typedef struct _Interface { +struct client { char buffer[INTERFACE_MAX_BUFFER_LENGTH]; size_t bufferLength; size_t bufferPos; @@ -81,16 +81,16 @@ typedef struct _Interface { size_t send_buf_used; /* bytes used this instance */ size_t send_buf_size; /* bytes usable this instance */ size_t send_buf_alloc; /* bytes actually allocated */ -} Interface; +}; -static Interface *interfaces; +static struct client *interfaces; -static void flushInterfaceBuffer(Interface * interface); +static void flushInterfaceBuffer(struct client *interface); -static void printInterfaceOutBuffer(Interface * interface); +static void printInterfaceOutBuffer(struct client *interface); #ifdef SO_SNDBUF -static size_t get_default_snd_buf_size(Interface * interface) +static size_t get_default_snd_buf_size(struct client *interface) { int new_size; socklen_t sockOptLen = sizeof(int); @@ -106,13 +106,13 @@ static size_t get_default_snd_buf_size(Interface * interface) return INTERFACE_DEFAULT_OUT_BUFFER_SIZE; } #else /* !SO_SNDBUF */ -static size_t get_default_snd_buf_size(Interface * interface) +static size_t get_default_snd_buf_size(struct client *interface) { return INTERFACE_DEFAULT_OUT_BUFFER_SIZE; } #endif /* !SO_SNDBUF */ -static void set_send_buf_size(Interface * interface) +static void set_send_buf_size(struct client *interface) { size_t new_size = get_default_snd_buf_size(interface); if (interface->send_buf_size != new_size) { @@ -127,7 +127,7 @@ static void set_send_buf_size(Interface * interface) } } -static void openInterface(Interface * interface, int fd) +static void openInterface(struct client *interface, int fd) { assert(interface->fd < 0); @@ -168,7 +168,7 @@ static void free_cmd_list(struct strnode *list) } } -static void cmd_list_clone(Interface * interface) +static void cmd_list_clone(struct client *interface) { struct strnode *new = dup_strlist(interface->cmd_list); free_cmd_list(interface->cmd_list); @@ -181,7 +181,7 @@ static void cmd_list_clone(Interface * interface) interface->cmd_list_tail = new; } -static void new_cmd_list_ptr(Interface * interface, char *s, const int size) +static void new_cmd_list_ptr(struct client *interface, char *s, const int size) { int i; struct strnode *new; @@ -209,7 +209,7 @@ out: interface->cmd_list = interface->cmd_list_tail = new; } -static void closeInterface(Interface * interface) +static void closeInterface(struct client *interface) { struct sllnode *buf; if (interface->fd < 0) @@ -284,7 +284,7 @@ void openAInterface(int fd, const struct sockaddr *addr) } } -static int processLineOfInput(Interface * interface) +static int processLineOfInput(struct client *interface) { int ret = 1; char *line = interface->buffer + interface->bufferPos; @@ -355,7 +355,7 @@ static int processLineOfInput(Interface * interface) return ret; } -static int processBytesRead(Interface * interface, int bytesRead) +static int processBytesRead(struct client *interface, int bytesRead) { int ret = 0; char *buf_tail = &(interface->buffer[interface->bufferLength - 1]); @@ -403,7 +403,7 @@ static int processBytesRead(Interface * interface, int bytesRead) return ret; } -static int interfaceReadInput(Interface * interface) +static int interfaceReadInput(struct client *interface) { int bytesRead; @@ -583,7 +583,7 @@ void initInterfaces(void) interface_max_output_buffer_size = tmp * 1024; } - interfaces = xmalloc(sizeof(Interface) * interface_max_connections); + interfaces = xmalloc(sizeof(interfaces[0]) * interface_max_connections); list_cache = xcalloc(interface_list_cache_size, sizeof(struct strnode)); list_cache_head = &(list_cache[0]); @@ -638,7 +638,7 @@ void closeOldInterfaces(void) } } -static void flushInterfaceBuffer(Interface * interface) +static void flushInterfaceBuffer(struct client *interface) { struct sllnode *buf; ssize_t ret = 0; @@ -690,7 +690,7 @@ int interfacePrintWithFD(int fd, const char *buffer, size_t buflen) { static unsigned int i; size_t copylen; - Interface *interface; + struct client *interface; assert(fd >= 0); @@ -729,7 +729,7 @@ int interfacePrintWithFD(int fd, const char *buffer, size_t buflen) return 0; } -static void printInterfaceOutBuffer(Interface * interface) +static void printInterfaceOutBuffer(struct client *interface) { ssize_t ret; struct sllnode *buf; -- cgit v1.2.3