From 796d804f33979e075d749d4cf4a8f7f6b48ab3ef Mon Sep 17 00:00:00 2001 From: angt Date: Tue, 20 Oct 2015 17:47:18 +0200 Subject: [PATCH] Code cleanup --- glorytun.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/glorytun.c b/glorytun.c index f312d75..cfe3c8e 100644 --- a/glorytun.c +++ b/glorytun.c @@ -11,7 +11,8 @@ #include #include -#define GT_NAME "glorytun" +#define GT_NAME "glorytun" +#define GT_BUFFER_SIZE (256*1024) volatile sig_atomic_t running; @@ -66,7 +67,7 @@ static int gt_set_signal (void) sigaction(SIGPIPE, &sa, NULL); } -static inline int buffer_read_fd (buffer_t *buffer, int fd) +static inline int read_to_buffer (int fd, buffer_t *buffer) { buffer_shift(buffer); @@ -90,7 +91,7 @@ static inline int buffer_read_fd (buffer_t *buffer, int fd) return 1; } -static inline int buffer_write_fd (buffer_t *buffer, int fd) +static inline int write_from_buffer (int fd, buffer_t *buffer) { size_t size = buffer_read_size(buffer); @@ -128,7 +129,7 @@ int main (int argc, char **argv) }; buffer_t input; - buffer_setup(&input, NULL, 256*1024); + buffer_setup(&input, NULL, GT_BUFFER_SIZE); while (running) { int ret = poll(fds, COUNT(fds), -1); @@ -144,7 +145,7 @@ int main (int argc, char **argv) continue; if (fds[0].revents & POLLIN) { - int read_ret = buffer_read_fd(&input, fds[0].fd); + int read_ret = read_to_buffer(fds[0].fd, &input); printf("read %zu\n", buffer_read_size(&input)); buffer_format(&input); }