diff options
| author | mikeos <mike.osipov@gmail.com> | 2012-12-06 22:37:47 +0400 |
|---|---|---|
| committer | mikeos <mike.osipov@gmail.com> | 2012-12-06 22:37:47 +0400 |
| commit | 656e5b71064f5ee521e3d28a6c1c0e7f5f85a622 (patch) | |
| tree | b749278e4fe2cccee11e1c268eb166dcc3d82c8d | |
| parent | dc34d7710cac12ccf7b6d1b0fc852cbbac76bf31 (diff) | |
remove open_memstream usage
| -rw-r--r-- | main.c | 41 |
1 files changed, 8 insertions, 33 deletions
@@ -642,49 +642,24 @@ static int test_servs(fd_set *readfds) return count; } -static int store_info(char **ptr) +void send_info(int sock) { struct channel *chan; - FILE *stream; - size_t size = 0; int total = 0; + FILE *fp; - stream = open_memstream(ptr, &size); - if (stream == NULL) - sys_err("open_memstream"); + fp = fdopen(sock, "w"); LIST_FOREACH(chan, &channels, entries) { - fprintf(stream, "%s => %s", chan->addr, chan->server->remote_addr); + fprintf(fp, "%s => %s", chan->addr, chan->server->remote_addr); if (chan->connected == 0) - fprintf(stream, ": not connected"); - fprintf(stream, "\n"); + fprintf(fp, ": not connected"); + fprintf(fp, "\n"); total++; } - fprintf(stream, "total: %d\n", total); - fclose(stream); - - return size; -} - -void send_info(int sock) -{ - char *buf = NULL; - char *p; - size_t size; - int n; - - size = store_info(&buf); - p = buf; - while (size > 0) { - n = write(sock, p, size); - if (n < 0) - sys_err("write"); - size -= n; - p += n; - } - - free(buf); + fprintf(fp, "total: %d\n", total); + fclose(fp); } static void accept_unix(int unix_sock) |
