From 377cdc9fa24d0e297a55c6b582f9f18d8340a0a6 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sun, 30 Sep 2012 03:34:46 +0200 Subject: [PATCH] Rename eof to at_end. This is more fitting as end of file is not really true for a socket. --- src/file.c | 18 +++++++++--------- src/stream.c | 6 +++--- src/stream.h | 4 ++-- src/tcpsocket.c | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/file.c b/src/file.c index d8b5395..6cf9da3 100644 --- a/src/file.c +++ b/src/file.c @@ -57,7 +57,7 @@ struct CFWFile { CFWStream stream; int fd; - bool eof; + bool at_end; }; static int @@ -98,7 +98,7 @@ file_read(void *ptr, void *buf, size_t len) ssize_t ret; if ((ret = read(file->fd, buf, len)) == 0) - file->eof = true; + file->at_end = true; return ret; } @@ -116,11 +116,11 @@ file_write(void *ptr, const void *buf, size_t len) } static bool -file_eof(void *ptr) +file_at_end(void *ptr) { CFWFile *file = ptr; - return file->eof; + return file->at_end; } static void @@ -134,7 +134,7 @@ file_close(void *ptr) static struct cfw_stream_ops stream_ops = { .read = file_read, .write = file_write, - .eof = file_eof, + .at_end = file_at_end, .close = file_close }; @@ -148,7 +148,7 @@ ctor(void *ptr, va_list args) /* Make sure we have a valid file in case we error out */ cfw_stream->ctor(ptr, args); - file->eof = false; + file->at_end = false; if ((flags = parse_mode(mode)) == -1) return false; @@ -184,7 +184,7 @@ static CFWFile cfw_stdin_ = { .ops = &stream_ops }, .fd = 0, - .eof = false + .at_end = false }; static CFWFile cfw_stdout_ = { .stream = { @@ -195,7 +195,7 @@ static CFWFile cfw_stdout_ = { .ops = &stream_ops }, .fd = 1, - .eof = false + .at_end = false }; static CFWFile cfw_stderr_ = { .stream = { @@ -206,7 +206,7 @@ static CFWFile cfw_stderr_ = { .ops = &stream_ops }, .fd = 2, - .eof = false + .at_end = false }; CFWFile *cfw_stdin = &cfw_stdin_; CFWFile *cfw_stdout = &cfw_stdout_; diff --git a/src/stream.c b/src/stream.c index 613d80e..ad7b359 100644 --- a/src/stream.c +++ b/src/stream.c @@ -141,7 +141,7 @@ cfw_stream_read_line(void *ptr) return NULL; for (;;) { - if (stream->ops->eof(stream)) { + if (stream->ops->at_end(stream)) { free(buf); if (stream->cache == NULL) @@ -274,7 +274,7 @@ cfw_stream_write_line(void *ptr, const char *str) } bool -cfw_stream_eof(void *ptr) +cfw_stream_at_end(void *ptr) { CFWStream *stream = ptr; @@ -284,7 +284,7 @@ cfw_stream_eof(void *ptr) if (stream->cache != NULL) return false; - return stream->ops->eof(stream); + return stream->ops->at_end(stream); } void diff --git a/src/stream.h b/src/stream.h index 03b545b..7202d64 100644 --- a/src/stream.h +++ b/src/stream.h @@ -36,7 +36,7 @@ struct cfw_stream_ops { ssize_t (*read)(void*, void*, size_t); bool (*write)(void*, const void*, size_t); - bool (*eof)(void*); + bool (*at_end)(void*); void (*close)(void*); }; @@ -53,6 +53,6 @@ extern CFWString* cfw_stream_read_line(void*); extern bool cfw_stream_write(void*, const void*, size_t); extern bool cfw_stream_write_string(void*, const char*); extern bool cfw_stream_write_line(void*, const char*); -extern bool cfw_stream_eof(void*); +extern bool cfw_stream_at_end(void*); extern void cfw_stream_close(void*); #endif diff --git a/src/tcpsocket.c b/src/tcpsocket.c index a624185..104c6ae 100644 --- a/src/tcpsocket.c +++ b/src/tcpsocket.c @@ -42,7 +42,7 @@ struct CFWTCPSocket { CFWStream stream; int fd; - bool eof; + bool at_end; }; static ssize_t @@ -52,7 +52,7 @@ sock_read(void *ptr, void *buf, size_t len) ssize_t ret; if ((ret = recv(sock->fd, buf, len, 0)) == 0) - sock->eof = true; + sock->at_end = true; return ret; } @@ -70,11 +70,11 @@ sock_write(void *ptr, const void *buf, size_t len) } static bool -sock_eof(void *ptr) +sock_at_end(void *ptr) { CFWTCPSocket *sock = ptr; - return sock->eof; + return sock->at_end; } static void @@ -89,7 +89,7 @@ sock_close(void *ptr) static struct cfw_stream_ops stream_ops = { .read = sock_read, .write = sock_write, - .eof = sock_eof, + .at_end = sock_at_end, .close = sock_close }; @@ -102,7 +102,7 @@ ctor(void *ptr, va_list args) sock->fd = -1; sock->stream.ops = &stream_ops; - sock->eof = false; + sock->at_end = false; return true; }